@deot/vc-components 1.0.39 → 1.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -2364,7 +2364,7 @@ const defaults = {
2364
2364
  el: "body",
2365
2365
  alive: false,
2366
2366
  multiple: false,
2367
- aliveRegExp: { className: /(vc-hack-alive|vc-hack-cp)/ },
2367
+ aliveRegExp: { className: /(vc-portal-alive)/ },
2368
2368
  aliveVisibleKey: "isVisible",
2369
2369
  aliveUpdateKey: "update",
2370
2370
  leaveDelay: 300,
@@ -2606,7 +2606,7 @@ class Portal {
2606
2606
  if (container && e.target && !container.contains(e.target) && !path?.some((item) => Utils$1.eleInRegExp(item, aliveRegExp))) {
2607
2607
  /* istanbul ignore else -- @preserve */
2608
2608
  if (leaf.wrapper && leaf.wrapper?.[aliveVisibleKey]) {
2609
- leaf.wrapper[aliveVisibleKey] = false;
2609
+ typeof leaf.wrapper[aliveVisibleKey] === "function" ? leaf.wrapper[aliveVisibleKey](false) : leaf.wrapper[aliveVisibleKey] = false;
2610
2610
  }
2611
2611
  leaveDelay ? setTimeout($onDestroyed, leaveDelay) : $onDestroyed();
2612
2612
  }
@@ -3262,6 +3262,8 @@ const popoverKeys$1 = [
3262
3262
  const props$19 = {
3263
3263
  ...pick(props$1c, popoverKeys$1),
3264
3264
  ...pick(props$1g, inputKeys$2),
3265
+ renderOption: [Function],
3266
+ renderOptionGroup: [Function],
3265
3267
  data: {
3266
3268
  type: Array,
3267
3269
  default: () => []
@@ -4689,7 +4691,7 @@ const props$$ = {
4689
4691
 
4690
4692
  /** @jsxImportSource vue */
4691
4693
 
4692
- function _isSlot$3(s) {
4694
+ function _isSlot$2(s) {
4693
4695
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
4694
4696
  }
4695
4697
  const COMPONENT_NAME$1w = 'vc-expand';
@@ -4713,7 +4715,7 @@ const Expand$1 = /* @__PURE__ */ defineComponent({
4713
4715
  enter: 200,
4714
4716
  leave: 200
4715
4717
  }
4716
- }, _isSlot$3(_slot = withDirectives(createVNode(Content, null, {
4718
+ }, _isSlot$2(_slot = withDirectives(createVNode(Content, null, {
4717
4719
  default: () => [(props.alive || !props.alive && isActive.value) && slots.default?.()]
4718
4720
  }), [[vShow, isActive.value]])) ? _slot : {
4719
4721
  default: () => [_slot]
@@ -4863,7 +4865,7 @@ const formatter = (format, arr) => {
4863
4865
 
4864
4866
  /** @jsxImportSource vue */
4865
4867
 
4866
- function _isSlot$2(s) {
4868
+ function _isSlot$1(s) {
4867
4869
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
4868
4870
  }
4869
4871
  const COMPONENT_NAME$1t = 'vc-countdown';
@@ -4998,7 +5000,7 @@ const Countdown = /* @__PURE__ */ defineComponent({
4998
5000
  return (// @ts-ignore
4999
5001
  createVNode(Content, {
5000
5002
  "class": "vc-countdown"
5001
- }, _isSlot$2(_slot = slots.default(binds.value)) ? _slot : {
5003
+ }, _isSlot$1(_slot = slots.default(binds.value)) ? _slot : {
5002
5004
  default: () => [_slot]
5003
5005
  })
5004
5006
  );
@@ -12314,7 +12316,9 @@ const props$u = {
12314
12316
  filterable: {
12315
12317
  type: Boolean,
12316
12318
  default: true
12317
- }
12319
+ },
12320
+ render: [Function],
12321
+ row: Object
12318
12322
  };
12319
12323
 
12320
12324
  /** @jsxImportSource vue */
@@ -12331,7 +12335,7 @@ const Option = /* @__PURE__ */ defineComponent({
12331
12335
  const v = String(props.label || props.value);
12332
12336
  return v.trim();
12333
12337
  });
12334
- const isSelect = computed(() => {
12338
+ const isChecked = computed(() => {
12335
12339
  const {
12336
12340
  current
12337
12341
  } = owner.exposed;
@@ -12348,15 +12352,24 @@ const Option = /* @__PURE__ */ defineComponent({
12348
12352
  const regex = owner.exposed.searchRegex.value;
12349
12353
  return regex.test(formatterLabel.value) || !props.filterable;
12350
12354
  });
12351
- const handleSelect = e => {
12352
- e.stopPropagation();
12355
+ const customOptions = computed(() => {
12356
+ return {
12357
+ store: {
12358
+ last: isLast.value,
12359
+ checked: isChecked.value,
12360
+ click: handleClick
12361
+ },
12362
+ row: props.row
12363
+ };
12364
+ });
12365
+ const handleClick = () => {
12353
12366
  // 禁止操作
12354
12367
  if (props.disabled) return;
12355
12368
  // 已选中,弹层关闭
12356
- if (!owner.exposed.multiple.value && isSelect.value) {
12369
+ if (!owner.exposed.multiple.value && isChecked.value) {
12357
12370
  owner.exposed.close();
12358
12371
  return;
12359
- } else if (isSelect.value) {
12372
+ } else if (isChecked.value) {
12360
12373
  owner.exposed.remove(props.value, formatterLabel.value);
12361
12374
  return;
12362
12375
  }
@@ -12367,15 +12380,17 @@ const Option = /* @__PURE__ */ defineComponent({
12367
12380
  };
12368
12381
  return () => {
12369
12382
  if (!isActive.value) return;
12370
- return createVNode("div", {
12383
+ return typeof props.render === 'function' ? createVNode(Customer, mergeProps({
12384
+ "render": props.render
12385
+ }, customOptions.value), null) : slots.default ? slots.default(customOptions.value) : createVNode("div", {
12371
12386
  "disabled": props.disabled && 'disabled',
12372
12387
  "class": [{
12373
- 'is-select': isSelect.value,
12388
+ 'is-select': isChecked.value,
12374
12389
  'is-last': isLast.value
12375
12390
  }, 'vc-select-option'],
12376
- "onClick": handleSelect,
12391
+ "onClick": withModifiers(handleClick, ['stop']),
12377
12392
  "onMousedown": handlePrevent
12378
- }, [slots.default ? slots.default() : formatterLabel.value, isSelect.value && createVNode(Icon, {
12393
+ }, [formatterLabel.value, isChecked.value && createVNode(Icon, {
12379
12394
  "type": "correct"
12380
12395
  }, null)]);
12381
12396
  };
@@ -12389,7 +12404,9 @@ const props$t = {
12389
12404
  },
12390
12405
  label: {
12391
12406
  type: [String, Number]
12392
- }
12407
+ },
12408
+ row: Object,
12409
+ render: [Function]
12393
12410
  };
12394
12411
 
12395
12412
  /** @jsxImportSource vue */
@@ -12405,10 +12422,19 @@ const OptionGroup = /* @__PURE__ */ defineComponent({
12405
12422
  const v = String(props.label || props.value);
12406
12423
  return v.trim();
12407
12424
  });
12425
+ const customOptions = computed(() => {
12426
+ return {
12427
+ row: props.row
12428
+ };
12429
+ });
12408
12430
  return () => {
12409
12431
  return createVNode("div", {
12410
12432
  "class": "vc-select-option-group"
12411
- }, [createVNode("div", {
12433
+ }, [typeof props.render === 'function' ? createVNode(Customer, mergeProps({
12434
+ "render": props.render
12435
+ }, customOptions.value), null) : slots.title ? slots.title({
12436
+ row: props.row
12437
+ }) : createVNode("div", {
12412
12438
  "class": "vc-select-option-group__title"
12413
12439
  }, [formatterLabel.value]), createVNode("div", null, [slots?.default?.()])]);
12414
12440
  };
@@ -12417,9 +12443,6 @@ const OptionGroup = /* @__PURE__ */ defineComponent({
12417
12443
 
12418
12444
  /** @jsxImportSource vue */
12419
12445
 
12420
- function _isSlot$1(s) {
12421
- return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
12422
- }
12423
12446
  const COMPONENT_NAME$H = 'vc-select';
12424
12447
  const Select = /* @__PURE__ */ defineComponent({
12425
12448
  name: COMPONENT_NAME$H,
@@ -12645,29 +12668,41 @@ const Select = /* @__PURE__ */ defineComponent({
12645
12668
  "max-height": "200px"
12646
12669
  }, {
12647
12670
  default: () => [props.data ? createVNode("div", null, [props.data.map(item => {
12648
- let _slot;
12649
- return Array.isArray(item.children) ? createVNode(OptionGroup, {
12671
+ return Array.isArray(item.children) && item.children.length ? createVNode(OptionGroup, {
12672
+ "row": item,
12650
12673
  "value": item.value,
12651
12674
  "label": item.label,
12652
- "key": item.value
12653
- }, _isSlot$1(_slot = item.children.map($item => {
12654
- return createVNode(Option, {
12655
- "key": $item.value,
12656
- "value": $item.value,
12657
- "label": $item.label,
12658
- "disabled": $item.disabled,
12659
- "filterable": $item.filterable
12660
- }, null);
12661
- })) ? _slot : {
12662
- default: () => [_slot]
12675
+ "key": item.value,
12676
+ "render": props.renderOptionGroup
12677
+ }, {
12678
+ title: slots?.optionGroup,
12679
+ default: () => {
12680
+ return item.children.map($item => {
12681
+ return createVNode(Option, {
12682
+ "key": $item.value,
12683
+ "row": $item,
12684
+ "value": $item.value,
12685
+ "label": $item.label,
12686
+ "disabled": $item.disabled,
12687
+ "filterable": $item.filterable,
12688
+ "render": props.renderOption
12689
+ }, {
12690
+ default: slots?.option
12691
+ });
12692
+ });
12693
+ }
12663
12694
  }) : createVNode(Option, {
12664
12695
  "key": item.value,
12696
+ "row": item,
12665
12697
  "value": item.value,
12666
12698
  "label": item.label,
12667
12699
  "disabled": item.disabled,
12668
- "filterable": item.filterable
12669
- }, null);
12670
- })]) : slots.default?.()]
12700
+ "filterable": item.filterable,
12701
+ "render": props.renderOption
12702
+ }, {
12703
+ default: slots?.option
12704
+ });
12705
+ })]) : slots?.default?.()]
12671
12706
  })]);
12672
12707
  }
12673
12708
  });
@@ -20318,116 +20353,36 @@ const useCollectNode = () => {
20318
20353
  };
20319
20354
  };
20320
20355
 
20321
- const selectKeys = [
20322
- "separator",
20323
- "numerable",
20324
- "nullValue"
20325
- ];
20326
20356
  const props$4 = {
20327
- ...pick(props$19, selectKeys),
20328
- // 暂不支持,仅作为默认值
20329
- max: {
20330
- type: Number,
20331
- default: Infinity,
20332
- validator: (v) => v >= 1
20333
- },
20334
- // 确保所有value是唯一的; 否则会出现问题
20335
- data: {
20336
- type: Array,
20337
- default: () => []
20338
- },
20339
- emptyText: {
20340
- type: String,
20341
- default: "暂无数据"
20342
- },
20343
- renderAfterExpand: {
20344
- type: Boolean,
20345
- default: true
20346
- },
20347
- checkStrictly: {
20348
- type: Boolean,
20349
- default: false
20350
- },
20351
- defaultExpandAll: Boolean,
20352
- expandOnClickNode: {
20353
- type: Boolean,
20354
- default: true
20355
- },
20356
- checkOnClickNode: Boolean,
20357
- checkDescendants: {
20358
- type: Boolean,
20359
- default: false
20357
+ node: {
20358
+ type: Object,
20359
+ default: () => ({})
20360
20360
  },
20361
- autoExpandParent: {
20361
+ renderNodeLabel: Function,
20362
+ renderNodeAfterExpand: {
20362
20363
  type: Boolean,
20363
20364
  default: true
20364
20365
  },
20365
- // checkedValues -> modelValue
20366
- modelValue: [String, Number, Array],
20367
- // Value[]
20368
- expandedValues: {
20369
- type: Array,
20370
- default: () => []
20371
- },
20372
- currentNodeValue: [String, Number],
20373
- render: Function,
20374
20366
  showCheckbox: {
20375
20367
  type: Boolean,
20376
20368
  default: false
20377
20369
  },
20378
- draggable: {
20379
- type: Boolean,
20380
- default: false
20381
- },
20382
- allowDrag: Function,
20383
- allowDrop: Function,
20384
- lazy: {
20385
- type: Boolean,
20386
- default: false
20387
- },
20388
- highlightCurrent: Boolean,
20389
- loadData: Function,
20390
- filterNode: Function,
20391
20370
  accordion: {
20392
20371
  type: Boolean,
20393
20372
  default: false
20394
20373
  },
20395
- indent: {
20396
- type: Number,
20397
- default: 18
20398
- },
20399
- iconClass: String,
20400
- keyValue: {
20401
- type: Object,
20402
- default: () => KEY_VALUE
20403
- },
20404
20374
  allowDispatch: {
20405
20375
  type: Boolean,
20406
20376
  default: true
20407
20377
  }
20408
20378
  };
20409
20379
 
20410
- const treeKeys$1 = [
20411
- "render",
20412
- "renderAfterExpand",
20413
- "showCheckbox",
20414
- "accordion",
20415
- "allowDispatch"
20416
- ];
20417
- const props$3 = {
20418
- ...pick(props$4, treeKeys$1),
20419
- node: {
20420
- type: Object,
20421
- default: () => ({})
20422
- }
20423
- };
20424
-
20425
20380
  /** @jsxImportSource vue */
20426
20381
 
20427
20382
  const COMPONENT_NAME$5 = 'vc-tree-node';
20428
20383
  const TreeNodeContent = /* @__PURE__ */ defineComponent({
20429
20384
  name: COMPONENT_NAME$5,
20430
- props: props$3,
20385
+ props: props$4,
20431
20386
  emits: ['node-expand'],
20432
20387
  setup(props, {
20433
20388
  emit
@@ -20601,20 +20556,20 @@ const TreeNodeContent = /* @__PURE__ */ defineComponent({
20601
20556
  }, null), node.states.loading && createVNode(Spin, {
20602
20557
  "size": 12,
20603
20558
  "class": "vc-tree-node__loading-icon"
20604
- }, null), props.render ? createVNode(Customer, {
20605
- "render": props.render,
20559
+ }, null), props.renderNodeLabel ? createVNode(Customer, {
20560
+ "render": props.renderNodeLabel,
20606
20561
  "store": node,
20607
20562
  "row": node.states.data
20608
20563
  }, null) : createVNode("span", null, [node.getter.label])]), createVNode(TransitionCollapse, null, {
20609
- default: () => [(!props.renderAfterExpand || childNodeRendered.value) && withDirectives(createVNode("div", {
20564
+ default: () => [(!props.renderNodeAfterExpand || childNodeRendered.value) && withDirectives(createVNode("div", {
20610
20565
  "aria-expanded": expanded.value,
20611
20566
  "class": "vc-tree-node__children",
20612
20567
  "role": "group"
20613
20568
  }, [node.childNodes.map(child => {
20614
20569
  return createVNode(TreeNodeContent, {
20615
20570
  "key": getNodeKey(child),
20616
- "render": props.render,
20617
- "renderAfterExpand": props.renderAfterExpand,
20571
+ "renderNodeLabel": props.renderNodeLabel,
20572
+ "renderNodeAfterExpand": props.renderNodeAfterExpand,
20618
20573
  "showCheckbox": props.showCheckbox,
20619
20574
  "allowDispatch": props.allowDispatch,
20620
20575
  "accordion": props.accordion,
@@ -20843,12 +20798,92 @@ const useKeydown = () => {
20843
20798
  };
20844
20799
  };
20845
20800
 
20801
+ const selectKeys = [
20802
+ "separator",
20803
+ "numerable",
20804
+ "nullValue"
20805
+ ];
20806
+ const treeNodeContentKeys = [
20807
+ "renderNodeLabel",
20808
+ "renderNodeAfterExpand",
20809
+ "showCheckbox",
20810
+ "accordion",
20811
+ "allowDispatch"
20812
+ ];
20813
+ const props$3 = {
20814
+ ...pick(props$19, selectKeys),
20815
+ ...pick(props$4, treeNodeContentKeys),
20816
+ // 暂不支持,仅作为默认值
20817
+ max: {
20818
+ type: Number,
20819
+ default: Infinity,
20820
+ validator: (v) => v >= 1
20821
+ },
20822
+ // 确保所有value是唯一的; 否则会出现问题
20823
+ data: {
20824
+ type: Array,
20825
+ default: () => []
20826
+ },
20827
+ emptyText: {
20828
+ type: String,
20829
+ default: "暂无数据"
20830
+ },
20831
+ checkStrictly: {
20832
+ type: Boolean,
20833
+ default: false
20834
+ },
20835
+ defaultExpandAll: Boolean,
20836
+ expandOnClickNode: {
20837
+ type: Boolean,
20838
+ default: true
20839
+ },
20840
+ checkOnClickNode: Boolean,
20841
+ checkDescendants: {
20842
+ type: Boolean,
20843
+ default: false
20844
+ },
20845
+ autoExpandParent: {
20846
+ type: Boolean,
20847
+ default: true
20848
+ },
20849
+ // checkedValues -> modelValue
20850
+ modelValue: [String, Number, Array],
20851
+ // Value[]
20852
+ expandedValues: {
20853
+ type: Array,
20854
+ default: () => []
20855
+ },
20856
+ currentNodeValue: [String, Number],
20857
+ draggable: {
20858
+ type: Boolean,
20859
+ default: false
20860
+ },
20861
+ allowDrag: Function,
20862
+ allowDrop: Function,
20863
+ lazy: {
20864
+ type: Boolean,
20865
+ default: false
20866
+ },
20867
+ highlightCurrent: Boolean,
20868
+ loadData: Function,
20869
+ filterNode: Function,
20870
+ indent: {
20871
+ type: Number,
20872
+ default: 18
20873
+ },
20874
+ iconClass: String,
20875
+ keyValue: {
20876
+ type: Object,
20877
+ default: () => KEY_VALUE
20878
+ }
20879
+ };
20880
+
20846
20881
  /** @jsxImportSource vue */
20847
20882
 
20848
20883
  const COMPONENT_NAME$4 = 'vc-tree';
20849
20884
  const Tree = /* @__PURE__ */ defineComponent({
20850
20885
  name: COMPONENT_NAME$4,
20851
- props: props$4,
20886
+ props: props$3,
20852
20887
  emits: ['update:modelValue', 'change', 'check-change', 'current-change', 'node-click', 'node-contextmenu', 'node-collapse', 'node-expand', 'check', 'node-drag-start', 'node-drag-end', 'node-drop', 'node-drag-leave', 'node-drag-enter', 'node-drag-over'],
20853
20888
  setup(props, {
20854
20889
  expose,
@@ -21022,8 +21057,8 @@ const Tree = /* @__PURE__ */ defineComponent({
21022
21057
  }, [root.childNodes.map(child => {
21023
21058
  return createVNode(TreeNodeContent, {
21024
21059
  "key": getNodeKey(child),
21025
- "render": props.render,
21026
- "renderAfterExpand": props.renderAfterExpand,
21060
+ "renderNodeLabel": props.renderNodeLabel,
21061
+ "renderNodeAfterExpand": props.renderNodeAfterExpand,
21027
21062
  "showCheckbox": props.showCheckbox,
21028
21063
  "allowDispatch": props.allowDispatch,
21029
21064
  "accordion": props.accordion,
@@ -21045,11 +21080,12 @@ const Tree = /* @__PURE__ */ defineComponent({
21045
21080
  const treeKeys = [
21046
21081
  "checkStrictly",
21047
21082
  "data",
21048
- "max"
21083
+ "max",
21084
+ "renderNodeLabel"
21049
21085
  ];
21050
21086
  const props$2 = {
21051
21087
  ...props$19,
21052
- ...pick(props$4, treeKeys)
21088
+ ...pick(props$3, treeKeys)
21053
21089
  };
21054
21090
 
21055
21091
  /** @jsxImportSource vue */
@@ -21273,6 +21309,7 @@ const TreeSelect = /* @__PURE__ */ defineComponent({
21273
21309
  "checkStrictly": props.checkStrictly,
21274
21310
  "allowDispatch": false,
21275
21311
  "showCheckbox": true,
21312
+ "renderNodeLabel": props.renderNodeLabel,
21276
21313
  "onChange": handleChange
21277
21314
  }, null)]
21278
21315
  })]);