@deot/vc-components 1.0.56 → 1.0.58

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
@@ -22,7 +22,6 @@ class VcError {
22
22
  if (!message || !target) return;
23
23
  message = `[@deot/vc - ${target}]: ${message}`;
24
24
  this.message = message;
25
- /* istanbul ignore next -- @preserve */
26
25
  process.env.NODE_ENV === "development" && console.error(message);
27
26
  }
28
27
  }
@@ -407,7 +406,6 @@ class Manager {
407
406
  const key = `${prefix}${url}`;
408
407
  const cache = window.localStorage.getItem(key);
409
408
  let icons = JSON.parse(cache || '""');
410
- /* istanbul ignore next -- @preserve */
411
409
  if (!icons) {
412
410
  const data = await new Promise((resolve$) => {
413
411
  const request = new XMLHttpRequest();
@@ -442,7 +440,6 @@ class Manager {
442
440
  });
443
441
  resolve();
444
442
  } catch (e) {
445
- /* istanbul ignore next -- @preserve */
446
443
  reject(new VcError("icon", e));
447
444
  }
448
445
  })();
@@ -454,7 +451,6 @@ class Manager {
454
451
  const icons = {};
455
452
  setTimeout(() => {
456
453
  try {
457
- /* istanbul ignore next -- @preserve */
458
454
  IS_DEV && console.time(url);
459
455
  svgStr.replace(svgReg, "$1")?.match(symbolReg)?.forEach(
460
456
  (i) => i.replace(basicReg, (_, ...args) => {
@@ -469,23 +465,19 @@ class Manager {
469
465
  return "";
470
466
  })
471
467
  );
472
- /* istanbul ignore next -- @preserve */
473
468
  IS_DEV && console.timeEnd(url);
474
469
  resolve(icons);
475
470
  } catch (e) {
476
- /* istanbul ignore next -- @preserve */
477
471
  reject(new VcError("icon", e));
478
472
  }
479
473
  }, 0);
480
474
  });
481
475
  }
482
476
  on(type, fn) {
483
- /* istanbul ignore next -- @preserve */
484
477
  if (typeof type !== "string" || typeof fn !== "function") return this;
485
478
  this.events[type] = this.events[type] || [];
486
479
  if (this.events[type].length >= 100) {
487
480
  delete this.events[type];
488
- /* istanbul ignore else -- @preserve */
489
481
  if (!IS_SERVER) {
490
482
  throw new VcError("icon", `${type} nonexistent`);
491
483
  }
@@ -494,7 +486,6 @@ class Manager {
494
486
  return this;
495
487
  }
496
488
  off(type, fn) {
497
- /* istanbul ignore next -- @preserve */
498
489
  if (typeof type !== "string" || typeof fn !== "function") return this;
499
490
  this.events[type] = this.events[type]?.filter((i) => i != fn);
500
491
  return this;
@@ -758,7 +749,6 @@ const TransitionCollapse = defineComponent({
758
749
  const handleBeforeEnter = (el) => {
759
750
  const duration = props.duration.enter || props.duration;
760
751
  el.style.transition = getTransitionStyle(duration);
761
- /* istanbul ignore next -- @preserve */
762
752
  if (!el.dataset) {
763
753
  el.dataset = {};
764
754
  }
@@ -775,7 +765,6 @@ const TransitionCollapse = defineComponent({
775
765
  const next = createNext(done, duration);
776
766
  try {
777
767
  el.dataset.oldOverflow = el.style.overflow;
778
- /* istanbul ignore next -- @preserve */
779
768
  if (el.scrollHeight !== 0) {
780
769
  el.style.height = el.scrollHeight + "px";
781
770
  el.style.paddingTop = el.dataset.oldPaddingTop + "px";
@@ -798,7 +787,6 @@ const TransitionCollapse = defineComponent({
798
787
  attrs.onAfterEnter?.(el);
799
788
  };
800
789
  const handleBeforeLeave = (el) => {
801
- /* istanbul ignore next -- @preserve */
802
790
  if (!el.dataset) {
803
791
  el.dataset = {};
804
792
  }
@@ -815,7 +803,6 @@ const TransitionCollapse = defineComponent({
815
803
  const next = createNext(done, duration);
816
804
  try {
817
805
  const leaveDuration = props.duration.leave || props.duration;
818
- /* istanbul ignore next -- @preserve */
819
806
  if (el.scrollHeight !== 0) {
820
807
  el.style.transition = getTransitionStyle(leaveDuration);
821
808
  el.style.height = "0px";
@@ -1441,7 +1428,6 @@ const Debounce = defineComponent({
1441
1428
  () => {
1442
1429
  const { wait, exclude, include } = props;
1443
1430
  const ons = Object.entries(attrs).reduce((pre, [key, callback]) => {
1444
- /* istanbul ignore else -- @preserve */
1445
1431
  if ((!exclude || !exclude.test(key)) && (!include || include.test(key)) && typeof callback === "function") {
1446
1432
  pre[key] = debounce(callback, wait, {
1447
1433
  leading: true,
@@ -2901,7 +2887,6 @@ class Portal {
2901
2887
  }
2902
2888
  }
2903
2889
  } catch (e) {
2904
- /* istanbul ignore next -- @preserve */
2905
2890
  throw new VcError("instance", e);
2906
2891
  }
2907
2892
  }
@@ -2912,7 +2897,6 @@ class Portal {
2912
2897
  try {
2913
2898
  Portal.leafs.forEach((leaf) => leaf.destroy());
2914
2899
  } catch (e) {
2915
- /* istanbul ignore next -- @preserve */
2916
2900
  throw new VcError("instance", e);
2917
2901
  }
2918
2902
  }
@@ -2985,7 +2969,6 @@ class Portal {
2985
2969
  return (...args) => {
2986
2970
  const done = () => {
2987
2971
  const leaf = getLeaf();
2988
- /* istanbul ignore next -- @preserve */
2989
2972
  if (!leaf) {
2990
2973
  throw new VcError("portal", "实例不存在或已卸载");
2991
2974
  }
@@ -3036,7 +3019,6 @@ class Portal {
3036
3019
  if (isDestroyed()) return;
3037
3020
  onDestroyed?.(...args);
3038
3021
  leaf.app?.unmount();
3039
- /* istanbul ignore else -- @preserve */
3040
3022
  if (useAllNodes) {
3041
3023
  root?.contains(container) && root.removeChild(container);
3042
3024
  } else if (container && container._children) {
@@ -3064,16 +3046,13 @@ class Portal {
3064
3046
  const handleExtra = (e) => {
3065
3047
  try {
3066
3048
  const path = e.path || $.composedPath(e);
3067
- /* istanbul ignore else -- @preserve */
3068
3049
  if (container && e.target && !container.contains(e.target) && !path?.some((item) => Utils$1.eleInRegExp(item, aliveRegExp))) {
3069
- /* istanbul ignore else -- @preserve */
3070
3050
  if (leaf.wrapper && leaf.wrapper?.[aliveVisibleKey]) {
3071
3051
  typeof leaf.wrapper[aliveVisibleKey] === "function" ? leaf.wrapper[aliveVisibleKey](false) : leaf.wrapper[aliveVisibleKey] = false;
3072
3052
  }
3073
3053
  leaveDelay ? setTimeout($onDestroyed, leaveDelay) : $onDestroyed();
3074
3054
  }
3075
3055
  } catch (error) {
3076
- /* istanbul ignore next -- @preserve */
3077
3056
  throw new VcError("portal", error);
3078
3057
  }
3079
3058
  };
@@ -4175,7 +4154,8 @@ const Chart = /* @__PURE__ */ defineComponent({
4175
4154
  emits: [...EVENTS, 'ready'],
4176
4155
  setup(props, {
4177
4156
  emit,
4178
- slots
4157
+ slots,
4158
+ expose
4179
4159
  }) {
4180
4160
  const instance = getCurrentInstance();
4181
4161
  const chart = shallowRef(null);
@@ -4274,6 +4254,10 @@ const Chart = /* @__PURE__ */ defineComponent({
4274
4254
  }
4275
4255
  });
4276
4256
  });
4257
+ expose({
4258
+ chart,
4259
+ refresh
4260
+ });
4277
4261
  onUnmounted(destroy);
4278
4262
  return () => {
4279
4263
  return createVNode("div", {
@@ -10034,7 +10018,7 @@ const DropdownItem = /* @__PURE__ */ defineComponent({
10034
10018
  }) {
10035
10019
  const owner = getInstance('dropdown', 'dropdownId');
10036
10020
  const currentValue = computed(() => {
10037
- const v = typeof props.value === 'undefined' || props.value === '' ? props.label : props.value;
10021
+ const v = typeof props.value === 'undefined' ? props.label : props.value;
10038
10022
  return v;
10039
10023
  });
10040
10024
  const classes = computed(() => {
@@ -10305,6 +10289,7 @@ const EditorToolbar = /* @__PURE__ */ defineComponent({
10305
10289
  }
10306
10290
  });
10307
10291
  };
10292
+ const handlePrevent = e => e.preventDefault();
10308
10293
  onMounted(() => {
10309
10294
  insertStyle(buttons.value);
10310
10295
  });
@@ -10315,7 +10300,8 @@ const EditorToolbar = /* @__PURE__ */ defineComponent({
10315
10300
  });
10316
10301
  return () => {
10317
10302
  return createVNode("div", {
10318
- "id": props.elementId
10303
+ "id": props.elementId,
10304
+ "onClick": handlePrevent
10319
10305
  }, [renderButtonGroup(buttons.value), slots?.extend?.()]);
10320
10306
  };
10321
10307
  }
@@ -12993,7 +12979,7 @@ const props$A = {
12993
12979
  default: "div"
12994
12980
  },
12995
12981
  fill: {
12996
- type: Boolean,
12982
+ type: [Boolean, Array],
12997
12983
  default: true
12998
12984
  }
12999
12985
  };
@@ -13007,6 +12993,13 @@ const Resizer = defineComponent({
13007
12993
  const width = ref(0);
13008
12994
  const height = ref(0);
13009
12995
  const current = ref();
12996
+ const classes = computed(() => {
12997
+ const v = Array.isArray(props.fill) ? props.fill : [props.fill, props.fill];
12998
+ return {
12999
+ "is-fill-width": v[0],
13000
+ "is-fill-height": v[1]
13001
+ };
13002
+ });
13010
13003
  const currentExposed = computed(() => {
13011
13004
  return {
13012
13005
  height: height.value,
@@ -13057,7 +13050,7 @@ const Resizer = defineComponent({
13057
13050
  props.tag,
13058
13051
  {
13059
13052
  ref: current,
13060
- class: ["vc-resizer", { "is-fill": props.fill }]
13053
+ class: ["vc-resizer", classes.value]
13061
13054
  },
13062
13055
  slots.default?.(currentExposed.value)
13063
13056
  );
@@ -16374,26 +16367,22 @@ const RecycleList = /* @__PURE__ */ defineComponent({
16374
16367
  const index$ = rebuildDataIndexMap.value[index];
16375
16368
  typeof index$ === 'undefined' ? rebuildData.value.unshift(node) : rebuildData.value[index$] = node;
16376
16369
  };
16377
- // 更新item.size
16378
16370
  const refreshItemSize = index => {
16379
16371
  const current = props.inverted ? rebuildData.value[rebuildDataIndexMap.value[index]] : rebuildData.value[index];
16380
- if (!current) return; // 受到`removeUnusedPlaceholders`影响,无效的会被回收
16381
16372
 
16382
- const oldSize = current.size;
16373
+ // 受到`removeUnusedPlaceholders`影响,无效的会被回收
16374
+ if (!current) return;
16375
+ const original = Object.assign({}, current);
16383
16376
  const dom = preloads.value[index] || curloads.value[props.inverted ? index : index - firstItemIndex.value];
16384
16377
  if (dom) {
16385
16378
  current.size = dom[K.offsetSize] || placeholderSize.value;
16386
16379
  } else if (current) {
16387
16380
  current.size = placeholderSize.value;
16388
16381
  }
16389
-
16390
- // 这样的考虑欠佳,待优化
16391
- if (oldSize !== current.size) {
16392
- emit('row-resize', {
16393
- index: current.id,
16394
- size: current.size
16395
- });
16396
- }
16382
+ return {
16383
+ original,
16384
+ changed: current
16385
+ };
16397
16386
  };
16398
16387
  const refreshItemPosition = () => {
16399
16388
  const sizes = Array.from({
@@ -16463,18 +16452,24 @@ const RecycleList = /* @__PURE__ */ defineComponent({
16463
16452
  const refreshLayout = async (start, end) => {
16464
16453
  isRefreshLayout = 1;
16465
16454
  const promiseTasks = [];
16455
+ const resizeChanges = [];
16466
16456
  let item;
16467
16457
  for (let i = start; i < end; i++) {
16468
16458
  item = props.inverted ? rebuildData.value[rebuildDataIndexMap.value[i]] : rebuildData.value[i];
16469
- if (item && item.loaded) {
16470
- continue;
16471
- }
16459
+ if (item && item.loaded) continue;
16472
16460
  setItemData(i, originalData[i]);
16473
- promiseTasks.push(nextTick(() => refreshItemSize(i)));
16461
+ promiseTasks.push(nextTick(() => {
16462
+ const e = refreshItemSize(i);
16463
+ e && resizeChanges.push(e.changed);
16464
+ }));
16474
16465
  }
16475
16466
  await Promise.all(promiseTasks);
16476
16467
  refreshItemPosition();
16477
16468
  setFirstItemIndex();
16469
+ resizeChanges.length > 0 && emit('row-resize', resizeChanges.map(i => ({
16470
+ size: i.size,
16471
+ index: i.id
16472
+ })));
16478
16473
  interrupter.next();
16479
16474
  isRefreshLayout = 0;
16480
16475
  };
@@ -18189,11 +18184,19 @@ const NormalList = /* @__PURE__ */ defineComponent({
18189
18184
  emit,
18190
18185
  slots
18191
18186
  }) {
18187
+ let resizeChanges = [];
18188
+ const emitChanges = () => {
18189
+ if (resizeChanges.length > 0) {
18190
+ emit('row-resize', resizeChanges);
18191
+ resizeChanges = [];
18192
+ }
18193
+ };
18192
18194
  const handleResize = (e, index) => {
18193
- emit('row-resize', {
18195
+ resizeChanges.push({
18194
18196
  index,
18195
18197
  size: e.height
18196
18198
  });
18199
+ nextTick(emitChanges);
18197
18200
  };
18198
18201
  return () => {
18199
18202
  return props.data.map((mergeData, index) => {
@@ -18552,22 +18555,25 @@ const TableBody = /* @__PURE__ */ defineComponent({
18552
18555
  return renderRow(row, row.index);
18553
18556
  })]);
18554
18557
  };
18555
- const handleMergeRowResize = v => {
18558
+ const handleMergeRowResize = changes => {
18556
18559
  if (table.props.rowHeight) return;
18557
- states.list[v.index].rows.forEach(row => {
18558
- const old = row.heightMap[props.fixed || 'main'];
18559
- if (old === v.size) return;
18560
- row.heightMap[props.fixed || 'main'] = v.size;
18561
- const heights = [row.heightMap.main];
18562
- if (states.leftFixedCount) {
18563
- heights.push(row.heightMap.left);
18564
- }
18565
- if (states.rightFixedCount) {
18566
- heights.push(row.heightMap.right);
18567
- }
18568
- if (heights.every(i => !!i)) {
18569
- row.height = Math.max(row.heightMap.left, row.heightMap.main, row.heightMap.right) || '';
18570
- }
18560
+ // 批量处理所有尺寸变化
18561
+ changes.forEach(v => {
18562
+ states.list[v.index].rows.forEach(row => {
18563
+ const old = row.heightMap[props.fixed || 'main'];
18564
+ if (old === v.size) return;
18565
+ row.heightMap[props.fixed || 'main'] = v.size;
18566
+ const heights = [row.heightMap.main];
18567
+ if (states.leftFixedCount) {
18568
+ heights.push(row.heightMap.left);
18569
+ }
18570
+ if (states.rightFixedCount) {
18571
+ heights.push(row.heightMap.right);
18572
+ }
18573
+ if (heights.every(i => !!i)) {
18574
+ row.height = Math.max(row.heightMap.left, row.heightMap.main, row.heightMap.right) || '';
18575
+ }
18576
+ });
18571
18577
  });
18572
18578
  };
18573
18579
  expose({
@@ -21513,7 +21519,6 @@ const Theme = defineComponent({
21513
21519
  setup(props, { slots }) {
21514
21520
  const themeId = Utils.getUid("vc-theme");
21515
21521
  const setVar = (name) => {
21516
- /* istanbul ignore next -- @preserve */
21517
21522
  if (!name) return "";
21518
21523
  const globals = VcInstance.options.Theme?.variables;
21519
21524
  return props.variables?.[name] || globals?.[name] || `var(--${name})`;
@@ -21549,7 +21554,6 @@ const Theme = defineComponent({
21549
21554
  }
21550
21555
  });
21551
21556
  const setCss = (attrs) => {
21552
- /* istanbul ignore next -- @preserve */
21553
21557
  if (!attrs || typeof attrs === "string") return attrs;
21554
21558
  let content = "";
21555
21559
  Object.entries(attrs).forEach(([key, val]) => {
@@ -21558,7 +21562,6 @@ const Theme = defineComponent({
21558
21562
  return content;
21559
21563
  };
21560
21564
  const resetPseudo = () => {
21561
- /* istanbul ignore next -- @preserve */
21562
21565
  if (typeof document === "undefined") return;
21563
21566
  const { pseudo } = props;
21564
21567
  if (!pseudo) return Load.removeStyle(themeId);