@deot/vc-components 1.0.39 → 1.0.41

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