index.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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,
  42. value = _a.value,
  43. parentDisabled = _a.disabled,
  44. direction = _a.direction;
  45. this.setData({
  46. value: value,
  47. direction: direction,
  48. parentDisabled: parentDisabled,
  49. });
  50. },
  51. emitChange: function (value) {
  52. var instance = this.parent || this;
  53. instance.$emit('input', value);
  54. instance.$emit('change', value);
  55. if (version_1.canIUseModel()) {
  56. instance.setData({ value: value });
  57. }
  58. },
  59. onChange: function () {
  60. if (!this.data.disabled && !this.data.parentDisabled) {
  61. this.emitChange(this.data.name);
  62. }
  63. },
  64. onClickLabel: function () {
  65. var _a = this.data,
  66. disabled = _a.disabled,
  67. parentDisabled = _a.parentDisabled,
  68. labelDisabled = _a.labelDisabled,
  69. name = _a.name;
  70. if (!(disabled || parentDisabled) && !labelDisabled) {
  71. this.emitChange(name);
  72. }
  73. },
  74. },
  75. });