index.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. exports.__esModule = true;
  4. exports.default = void 0;
  5. var _babelHelperVueJsxMergeProps = _interopRequireDefault(require("@vue/babel-helper-vue-jsx-merge-props"));
  6. var _utils = require("../utils");
  7. var _functional = require("../utils/functional");
  8. var _button = _interopRequireDefault(require("../button"));
  9. var _radioGroup = _interopRequireDefault(require("../radio-group"));
  10. var _Item = _interopRequireDefault(require("./Item"));
  11. // Utils
  12. // Components
  13. var _createNamespace = (0, _utils.createNamespace)('address-list'),
  14. createComponent = _createNamespace[0],
  15. bem = _createNamespace[1],
  16. t = _createNamespace[2];
  17. function AddressList(h, props, slots, ctx) {
  18. function genList(list, disabled) {
  19. if (!list) {
  20. return;
  21. }
  22. return list.map(function (item, index) {
  23. return h(_Item.default, {
  24. "attrs": {
  25. "data": item,
  26. "disabled": disabled,
  27. "switchable": props.switchable,
  28. "defaultTagText": props.defaultTagText
  29. },
  30. "key": item.id,
  31. "scopedSlots": {
  32. bottom: slots['item-bottom'],
  33. tag: slots.tag
  34. },
  35. "on": {
  36. "select": function select() {
  37. (0, _functional.emit)(ctx, disabled ? 'select-disabled' : 'select', item, index);
  38. if (!disabled) {
  39. (0, _functional.emit)(ctx, 'input', item.id);
  40. }
  41. },
  42. "edit": function edit() {
  43. (0, _functional.emit)(ctx, disabled ? 'edit-disabled' : 'edit', item, index);
  44. },
  45. "click": function click() {
  46. (0, _functional.emit)(ctx, 'click-item', item, index);
  47. }
  48. }
  49. });
  50. });
  51. }
  52. var List = genList(props.list);
  53. var DisabledList = genList(props.disabledList, true);
  54. return h("div", (0, _babelHelperVueJsxMergeProps.default)([{
  55. "class": bem()
  56. }, (0, _functional.inherit)(ctx)]), [slots.top == null ? void 0 : slots.top(), h(_radioGroup.default, {
  57. "attrs": {
  58. "value": props.value
  59. }
  60. }, [List]), props.disabledText && h("div", {
  61. "class": bem('disabled-text')
  62. }, [props.disabledText]), DisabledList, slots.default == null ? void 0 : slots.default(), h("div", {
  63. "class": bem('bottom')
  64. }, [h(_button.default, {
  65. "attrs": {
  66. "round": true,
  67. "block": true,
  68. "type": "danger",
  69. "text": props.addButtonText || t('add')
  70. },
  71. "class": bem('add'),
  72. "on": {
  73. "click": function click() {
  74. (0, _functional.emit)(ctx, 'add');
  75. }
  76. }
  77. })])]);
  78. }
  79. AddressList.props = {
  80. list: Array,
  81. value: [Number, String],
  82. disabledList: Array,
  83. disabledText: String,
  84. addButtonText: String,
  85. defaultTagText: String,
  86. switchable: {
  87. type: Boolean,
  88. default: true
  89. }
  90. };
  91. var _default = createComponent(AddressList);
  92. exports.default = _default;