index.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. import _mergeJSXProps from "@vue/babel-helper-vue-jsx-merge-props";
  2. import { use } from '../utils';
  3. import { emit, inherit } from '../utils/functional';
  4. import Icon from '../icon';
  5. import Cell from '../cell';
  6. import Button from '../button';
  7. import Radio from '../radio';
  8. import RadioGroup from '../radio-group'; // Types
  9. var _use = use('contact-list'),
  10. sfc = _use[0],
  11. bem = _use[1],
  12. t = _use[2];
  13. function ContactList(h, props, slots, ctx) {
  14. var List = props.list.map(function (item, index) {
  15. var onClick = function onClick() {
  16. emit(ctx, 'input', item.id);
  17. emit(ctx, 'select', item, index);
  18. };
  19. return h(Cell, {
  20. "key": item.id,
  21. "attrs": {
  22. "isLink": true,
  23. "valueClass": bem('item-value')
  24. },
  25. "class": bem('item'),
  26. "scopedSlots": {
  27. "default": function _default() {
  28. return h(Radio, {
  29. "attrs": {
  30. "name": item.id
  31. },
  32. "on": {
  33. "click": onClick
  34. }
  35. }, [h("div", {
  36. "class": bem('name')
  37. }, [item.name + "\uFF0C" + item.tel])]);
  38. },
  39. 'right-icon': function rightIcon() {
  40. return h(Icon, {
  41. "attrs": {
  42. "name": "edit"
  43. },
  44. "class": bem('edit'),
  45. "on": {
  46. "click": function click(event) {
  47. event.stopPropagation();
  48. emit(ctx, 'edit', item, index);
  49. }
  50. }
  51. });
  52. }
  53. },
  54. "on": {
  55. "click": onClick
  56. }
  57. });
  58. });
  59. return h("div", _mergeJSXProps([{
  60. "class": bem()
  61. }, inherit(ctx)]), [h(RadioGroup, {
  62. "attrs": {
  63. "value": props.value
  64. },
  65. "class": bem('group')
  66. }, [List]), h(Button, {
  67. "attrs": {
  68. "square": true,
  69. "size": "large",
  70. "type": "danger",
  71. "text": props.addText || t('addText')
  72. },
  73. "class": bem('add'),
  74. "on": {
  75. "click": function click() {
  76. emit(ctx, 'add');
  77. }
  78. }
  79. })]);
  80. }
  81. ContactList.props = {
  82. value: null,
  83. list: Array,
  84. addText: String
  85. };
  86. export default sfc(ContactList);