index.js 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var version_1 = require("../common/version");
  4. var component_1 = require("../common/component");
  5. var relation_1 = require("../common/relation");
  6. component_1.VantComponent({
  7. field: true,
  8. relation: relation_1.useParent('radio-group', function () {
  9. this.updateFromParent();
  10. }),
  11. classes: ['icon-class', 'label-class'],
  12. props: {
  13. name: null,
  14. value: null,
  15. disabled: Boolean,
  16. useIconSlot: Boolean,
  17. checkedColor: String,
  18. labelPosition: {
  19. type: String,
  20. value: 'right',
  21. },
  22. labelDisabled: Boolean,
  23. shape: {
  24. type: String,
  25. value: 'round',
  26. },
  27. iconSize: {
  28. type: null,
  29. value: 20,
  30. },
  31. },
  32. data: {
  33. direction: '',
  34. parentDisabled: false,
  35. },
  36. methods: {
  37. updateFromParent: function () {
  38. if (!this.parent) {
  39. return;
  40. }
  41. var _a = this.parent.data, value = _a.value, parentDisabled = _a.disabled, direction = _a.direction;
  42. this.setData({
  43. value: value,
  44. direction: direction,
  45. parentDisabled: parentDisabled,
  46. });
  47. },
  48. emitChange: function (value) {
  49. var instance = this.parent || this;
  50. instance.$emit('input', value);
  51. instance.$emit('change', value);
  52. if (version_1.canIUseModel()) {
  53. instance.setData({ value: value });
  54. }
  55. },
  56. onChange: function () {
  57. if (!this.data.disabled && !this.data.parentDisabled) {
  58. this.emitChange(this.data.name);
  59. }
  60. },
  61. onClickLabel: function () {
  62. var _a = this.data, disabled = _a.disabled, parentDisabled = _a.parentDisabled, labelDisabled = _a.labelDisabled, name = _a.name;
  63. if (!(disabled || parentDisabled) && !labelDisabled) {
  64. this.emitChange(name);
  65. }
  66. },
  67. },
  68. });