index.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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 _constant = require("../utils/constant");
  8. var _functional = require("../utils/functional");
  9. var _tag = _interopRequireDefault(require("../tag"));
  10. var _icon = _interopRequireDefault(require("../icon"));
  11. var _cell = _interopRequireDefault(require("../cell"));
  12. var _radio = _interopRequireDefault(require("../radio"));
  13. var _button = _interopRequireDefault(require("../button"));
  14. var _radioGroup = _interopRequireDefault(require("../radio-group"));
  15. // Utils
  16. // Components
  17. var _createNamespace = (0, _utils.createNamespace)('contact-list'),
  18. createComponent = _createNamespace[0],
  19. bem = _createNamespace[1],
  20. t = _createNamespace[2];
  21. function ContactList(h, props, slots, ctx) {
  22. var List = props.list && props.list.map(function (item, index) {
  23. function onClick() {
  24. (0, _functional.emit)(ctx, 'input', item.id);
  25. (0, _functional.emit)(ctx, 'select', item, index);
  26. }
  27. function RightIcon() {
  28. return h(_radio.default, {
  29. "attrs": {
  30. "name": item.id,
  31. "iconSize": 16,
  32. "checkedColor": _constant.RED
  33. },
  34. "on": {
  35. "click": onClick
  36. }
  37. });
  38. }
  39. function LeftIcon() {
  40. return h(_icon.default, {
  41. "attrs": {
  42. "name": "edit"
  43. },
  44. "class": bem('edit'),
  45. "on": {
  46. "click": function click(event) {
  47. event.stopPropagation();
  48. (0, _functional.emit)(ctx, 'edit', item, index);
  49. }
  50. }
  51. });
  52. }
  53. function Content() {
  54. var nodes = [item.name + "\uFF0C" + item.tel];
  55. if (item.isDefault && props.defaultTagText) {
  56. nodes.push(h(_tag.default, {
  57. "attrs": {
  58. "type": "danger",
  59. "round": true
  60. },
  61. "class": bem('item-tag')
  62. }, [props.defaultTagText]));
  63. }
  64. return nodes;
  65. }
  66. return h(_cell.default, {
  67. "key": item.id,
  68. "attrs": {
  69. "isLink": true,
  70. "center": true,
  71. "valueClass": bem('item-value')
  72. },
  73. "class": bem('item'),
  74. "scopedSlots": {
  75. icon: LeftIcon,
  76. default: Content,
  77. 'right-icon': RightIcon
  78. },
  79. "on": {
  80. "click": onClick
  81. }
  82. });
  83. });
  84. return h("div", (0, _babelHelperVueJsxMergeProps.default)([{
  85. "class": bem()
  86. }, (0, _functional.inherit)(ctx)]), [h(_radioGroup.default, {
  87. "attrs": {
  88. "value": props.value
  89. },
  90. "class": bem('group')
  91. }, [List]), h("div", {
  92. "class": bem('bottom')
  93. }, [h(_button.default, {
  94. "attrs": {
  95. "round": true,
  96. "block": true,
  97. "type": "danger",
  98. "text": props.addText || t('addText')
  99. },
  100. "class": bem('add'),
  101. "on": {
  102. "click": function click() {
  103. (0, _functional.emit)(ctx, 'add');
  104. }
  105. }
  106. })])]);
  107. }
  108. ContactList.props = {
  109. value: null,
  110. list: Array,
  111. addText: String,
  112. defaultTagText: String
  113. };
  114. var _default = createComponent(ContactList);
  115. exports.default = _default;