index.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. (0, component_1.VantComponent)({
  7. field: true,
  8. relation: (0, 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 ((0, 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. });