kui-vue 6.4.0 → 6.5.0

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.
Files changed (51) hide show
  1. package/ai/kui-components.json +249 -36
  2. package/dist/index.js +2 -2
  3. package/es/index.js +606 -194
  4. package/es/locale/de.js +1 -1
  5. package/es/locale/el.js +1 -1
  6. package/es/locale/en.js +1 -1
  7. package/es/locale/fr.js +1 -1
  8. package/es/locale/it.js +1 -1
  9. package/es/locale/ja.js +1 -1
  10. package/es/locale/ko.js +1 -1
  11. package/es/locale/ru.js +1 -1
  12. package/es/locale/th.js +1 -1
  13. package/es/locale/uk.js +1 -1
  14. package/es/locale/vi.js +1 -1
  15. package/es/locale/zh-CN.js +1 -1
  16. package/es/locale/zh-TW.js +1 -1
  17. package/lib/index.cjs +2 -2
  18. package/lib/locale/de.cjs +1 -1
  19. package/lib/locale/el.cjs +1 -1
  20. package/lib/locale/en.cjs +1 -1
  21. package/lib/locale/fr.cjs +1 -1
  22. package/lib/locale/it.cjs +1 -1
  23. package/lib/locale/ja.cjs +1 -1
  24. package/lib/locale/ko.cjs +1 -1
  25. package/lib/locale/ru.cjs +1 -1
  26. package/lib/locale/th.cjs +1 -1
  27. package/lib/locale/uk.cjs +1 -1
  28. package/lib/locale/vi.cjs +1 -1
  29. package/lib/locale/zh-CN.cjs +1 -1
  30. package/lib/locale/zh-TW.cjs +1 -1
  31. package/package.json +1 -1
  32. package/style/base.css +1 -1
  33. package/style/components.css +2 -2
  34. package/style/index.css +2 -2
  35. package/style/motion.css +1 -1
  36. package/style/theme.css +1 -1
  37. package/types/menu/menu-context.d.cts +1 -0
  38. package/types/menu/menu-context.d.ts +1 -0
  39. package/types/menu/menu.d.cts +13 -0
  40. package/types/menu/menu.d.ts +13 -0
  41. package/types/segmented/index.d.cts +2 -2
  42. package/types/segmented/index.d.ts +2 -2
  43. package/types/splitter/controller.d.cts +49 -0
  44. package/types/splitter/controller.d.ts +49 -0
  45. package/types/splitter/splitter-panel.d.cts +37 -2
  46. package/types/splitter/splitter-panel.d.ts +37 -2
  47. package/types/splitter/splitter.d.cts +24 -5
  48. package/types/splitter/splitter.d.ts +24 -5
  49. package/vetur/attributes.json +132 -12
  50. package/vetur/tags.json +24 -4
  51. package/vetur/web-types.json +157 -13
package/es/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * kui-vue v6.4.0
2
+ * kui-vue v6.5.0
3
3
  * Copyright 2017-present, kui-vue.
4
4
  * All rights reserved.
5
5
  * Homepage: https://k-ui.cn
@@ -1553,7 +1553,7 @@ function parse(x, n) {
1553
1553
  }
1554
1554
  return x;
1555
1555
  }
1556
- function round$2(x, sd, rm, more) {
1556
+ function round$3(x, sd, rm, more) {
1557
1557
  var xc = x.c;
1558
1558
  if (rm === UNDEFINED) rm = x.constructor.RM;
1559
1559
  if (rm !== 0 && rm !== 1 && rm !== 2 && rm !== 3) throw Error(INVALID_RM);
@@ -1649,7 +1649,7 @@ P.div = function(y) {
1649
1649
  q.e--;
1650
1650
  p--;
1651
1651
  }
1652
- if (qi > p) round$2(q, p, Big.RM, r[0] !== UNDEFINED);
1652
+ if (qi > p) round$3(q, p, Big.RM, r[0] !== UNDEFINED);
1653
1653
  return q;
1654
1654
  };
1655
1655
  P.eq = function(y) {
@@ -1805,12 +1805,12 @@ P.pow = function(n) {
1805
1805
  };
1806
1806
  P.prec = function(sd, rm) {
1807
1807
  if (sd !== ~~sd || sd < 1 || sd > MAX_DP) throw Error(INVALID + "precision");
1808
- return round$2(new this.constructor(this), sd, rm);
1808
+ return round$3(new this.constructor(this), sd, rm);
1809
1809
  };
1810
1810
  P.round = function(dp, rm) {
1811
1811
  if (dp === UNDEFINED) dp = 0;
1812
1812
  else if (dp !== ~~dp || dp < -1e6 || dp > MAX_DP) throw Error(INVALID_DP);
1813
- return round$2(new this.constructor(this), dp + this.e + 1, rm);
1813
+ return round$3(new this.constructor(this), dp + this.e + 1, rm);
1814
1814
  };
1815
1815
  P.sqrt = function() {
1816
1816
  var r, c, t, x = this, Big = x.constructor, s = x.s, e = x.e, half = new Big("0.5");
@@ -1829,7 +1829,7 @@ P.sqrt = function() {
1829
1829
  t = r;
1830
1830
  r = half.times(t.plus(x.div(t)));
1831
1831
  } while (t.c.slice(0, e).join("") !== r.c.slice(0, e).join(""));
1832
- return round$2(r, (Big.DP -= 4) + r.e + 1, Big.RM);
1832
+ return round$3(r, (Big.DP -= 4) + r.e + 1, Big.RM);
1833
1833
  };
1834
1834
  P.times = P.mul = function(y) {
1835
1835
  var c, x = this, Big = x.constructor, xc = x.c, yc = (y = new Big(y)).c, a = xc.length, b = yc.length, i = x.e, j = y.e;
@@ -1867,7 +1867,7 @@ P.toExponential = function(dp, rm) {
1867
1867
  var x = this, n = x.c[0];
1868
1868
  if (dp !== UNDEFINED) {
1869
1869
  if (dp !== ~~dp || dp < 0 || dp > MAX_DP) throw Error(INVALID_DP);
1870
- x = round$2(new x.constructor(x), ++dp, rm);
1870
+ x = round$3(new x.constructor(x), ++dp, rm);
1871
1871
  for (; x.c.length < dp;) x.c.push(0);
1872
1872
  }
1873
1873
  return stringify(x, true, !!n);
@@ -1876,7 +1876,7 @@ P.toFixed = function(dp, rm) {
1876
1876
  var x = this, n = x.c[0];
1877
1877
  if (dp !== UNDEFINED) {
1878
1878
  if (dp !== ~~dp || dp < 0 || dp > MAX_DP) throw Error(INVALID_DP);
1879
- x = round$2(new x.constructor(x), dp + x.e + 1, rm);
1879
+ x = round$3(new x.constructor(x), dp + x.e + 1, rm);
1880
1880
  for (dp = dp + x.e + 1; x.c.length < dp;) x.c.push(0);
1881
1881
  }
1882
1882
  return stringify(x, false, !!n);
@@ -1895,7 +1895,7 @@ P.toPrecision = function(sd, rm) {
1895
1895
  var x = this, Big = x.constructor, n = x.c[0];
1896
1896
  if (sd !== UNDEFINED) {
1897
1897
  if (sd !== ~~sd || sd < 1 || sd > MAX_DP) throw Error(INVALID + "precision");
1898
- x = round$2(new Big(x), sd, rm);
1898
+ x = round$3(new Big(x), sd, rm);
1899
1899
  for (; x.c.length < sd;) x.c.push(0);
1900
1900
  }
1901
1901
  return stringify(x, sd <= x.e || x.e <= Big.NE || x.e >= Big.PE, !!n);
@@ -11153,7 +11153,7 @@ var corners_default = /* @__PURE__ */ defineComponent({
11153
11153
  }
11154
11154
  });
11155
11155
  // components/gradient-picker/stops.tsx
11156
- var round$1 = (value) => Math.round(value * 100) / 100;
11156
+ var round$2 = (value) => Math.round(value * 100) / 100;
11157
11157
  var touchStart = (event) => ({
11158
11158
  clientX: event.touches[0].clientX,
11159
11159
  clientY: event.touches[0].clientY,
@@ -11195,7 +11195,7 @@ var stops_default = /* @__PURE__ */ defineComponent({
11195
11195
  const offsetAt = (clientX) => {
11196
11196
  const rect = lane.value?.getBoundingClientRect();
11197
11197
  if (!rect || !rect.width) return 0;
11198
- return round$1(clamp$1((clientX - rect.left) / rect.width * 100, 0, 100));
11198
+ return round$2(clamp$1((clientX - rect.left) / rect.width * 100, 0, 100));
11199
11199
  };
11200
11200
  const stopDrag = () => {
11201
11201
  dragging = false;
@@ -11211,7 +11211,7 @@ var stops_default = /* @__PURE__ */ defineComponent({
11211
11211
  const handleMove = (event) => {
11212
11212
  if (!dragging) return;
11213
11213
  if (Math.abs(event.clientX - startX) > 2 || Math.abs(event.clientY - startY) > 2) moved = true;
11214
- const offset = round$1(clamp$1(offsetAt(event.clientX), minOffset, maxOffset));
11214
+ const offset = round$2(clamp$1(offsetAt(event.clientX), minOffset, maxOffset));
11215
11215
  emit("move", dragIndex, offset);
11216
11216
  removingIndex.value = event.clientY - startY > 24 && props.stops.length > 2 ? dragIndex : -1;
11217
11217
  };
@@ -11288,10 +11288,10 @@ var stops_default = /* @__PURE__ */ defineComponent({
11288
11288
  const step = event.shiftKey ? 10 : 1;
11289
11289
  if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
11290
11290
  event.preventDefault();
11291
- emit("move", index, round$1(clamp$1(stop.offset + (event.key === "ArrowRight" ? step : -step), lower, upper)));
11291
+ emit("move", index, round$2(clamp$1(stop.offset + (event.key === "ArrowRight" ? step : -step), lower, upper)));
11292
11292
  } else if (event.key === "Home" || event.key === "End") {
11293
11293
  event.preventDefault();
11294
- emit("move", index, round$1(event.key === "Home" ? lower : upper));
11294
+ emit("move", index, round$2(event.key === "Home" ? lower : upper));
11295
11295
  } else if ((event.key === "Delete" || event.key === "Backspace") && props.stops.length > 2) {
11296
11296
  event.preventDefault();
11297
11297
  emit("remove", index);
@@ -11339,8 +11339,8 @@ var stops_default = /* @__PURE__ */ defineComponent({
11339
11339
  });
11340
11340
  // components/gradient-picker/types.ts
11341
11341
  var clamp = (value, min, max) => Math.min(max, Math.max(min, Number.isFinite(value) ? value : min));
11342
- var round = (value) => Math.round(value * 100) / 100;
11343
- var clampOffset = (value) => round(clamp(value, 0, 100));
11342
+ var round$1 = (value) => Math.round(value * 100) / 100;
11343
+ var clampOffset = (value) => round$1(clamp(value, 0, 100));
11344
11344
  function createLinearGradient() {
11345
11345
  return [{
11346
11346
  color: "#ff0000",
@@ -11472,7 +11472,7 @@ function formatGradient(value) {
11472
11472
  `linear-gradient(135deg, ${topLeft} 0%, ${bottomRight} 100%)`
11473
11473
  ].join(", ");
11474
11474
  }
11475
- return `linear-gradient(90deg, ${[...value].sort((a, b) => a.offset - b.offset).map((stop) => `${stop.color} ${round(stop.offset)}%`).join(", ")})`;
11475
+ return `linear-gradient(90deg, ${[...value].sort((a, b) => a.offset - b.offset).map((stop) => `${stop.color} ${round$1(stop.offset)}%`).join(", ")})`;
11476
11476
  }
11477
11477
  var gradient_picker_default = markFormFieldComponent(/* @__PURE__ */ defineComponent({
11478
11478
  name: "GradientPicker",
@@ -16392,12 +16392,20 @@ var SubMenu = /* @__PURE__ */ defineComponent({
16392
16392
  const dropdownContext = inject(DropdownContextKey, null);
16393
16393
  const menuContext = inject(MenuContextKey, null);
16394
16394
  const subMenuContext = inject(SubMenuContextKey, null);
16395
- usePopupHost(() => {
16396
- if (menuContext?.openKeys.includes(key)) menuContext.openKeysChange?.(key, false, subMenuContext?.keyPath || []);
16397
- });
16398
16395
  const currentPlacement = ref("bottom-left");
16399
16396
  const transOrigin = ref("bottom left");
16400
16397
  const popTimer = ref();
16398
+ let openTimer;
16399
+ let openRevision = 0;
16400
+ const cancelHoverOpen = () => {
16401
+ clearTimeout(openTimer);
16402
+ openTimer = void 0;
16403
+ openRevision++;
16404
+ };
16405
+ usePopupHost(() => {
16406
+ cancelHoverOpen();
16407
+ if (menuContext?.openKeys.includes(key)) menuContext.openKeysChange?.(key, false, subMenuContext?.keyPath || []);
16408
+ });
16401
16409
  const preCls = menuContext?.dropdown ? "dropdown-menu-submenu" : "menu-submenu";
16402
16410
  const idSeed = String(key ?? instance?.uid ?? "").replace(/[^a-zA-Z0-9_-]/g, "");
16403
16411
  const triggerId = `k-menu-submenu-title-${idSeed}`;
@@ -16410,12 +16418,16 @@ var SubMenu = /* @__PURE__ */ defineComponent({
16410
16418
  });
16411
16419
  });
16412
16420
  onBeforeUnmount(() => {
16421
+ cancelHoverOpen();
16413
16422
  clearTimeout(popTimer.value);
16414
16423
  });
16415
16424
  const clearCurrentPopTimer = () => {
16416
16425
  clearTimeout(popTimer.value);
16417
16426
  };
16418
16427
  const hideCurrentPopTimer = () => {
16428
+ cancelHoverOpen();
16429
+ clearCurrentPopTimer();
16430
+ if (!menuContext?.openKeys.includes(key)) return;
16419
16431
  popTimer.value = setTimeout(() => {
16420
16432
  menuContext?.openKeysChange?.(key, false, subMenuContext?.keyPath || []);
16421
16433
  }, 200);
@@ -16426,8 +16438,12 @@ var SubMenu = /* @__PURE__ */ defineComponent({
16426
16438
  hidePopTimer: hideCurrentPopTimer
16427
16439
  });
16428
16440
  const showPopper = () => {
16441
+ cancelHoverOpen();
16442
+ clearCurrentPopTimer();
16443
+ const revision = openRevision;
16429
16444
  rendered.value = true;
16430
16445
  nextTick(() => {
16446
+ if (revision !== openRevision || props.disabled) return;
16431
16447
  menuContext?.openKeysChange?.(key, true, subMenuContext?.keyPath || []);
16432
16448
  updatePosition();
16433
16449
  });
@@ -16450,6 +16466,13 @@ var SubMenu = /* @__PURE__ */ defineComponent({
16450
16466
  };
16451
16467
  const usePopup = () => menuContext?.mode === "horizontal" || menuContext?.mode === "vertical" || menuContext?.popupInlineCollapsed;
16452
16468
  const openedNow = computed(() => !!menuContext?.openKeys.includes(key));
16469
+ watch(() => [
16470
+ props.disabled,
16471
+ menuContext?.mode,
16472
+ menuContext?.popupInlineCollapsed,
16473
+ menuContext?.subMenuOpenDelay,
16474
+ subMenuContext?.keyPath.every((parent) => menuContext?.openKeys.includes(parent))
16475
+ ], cancelHoverOpen);
16453
16476
  const isMenubarItem = computed(() => menuContext?.mode === "horizontal" && !(subMenuContext?.keyPath.length ?? 0));
16454
16477
  const focusFirstItem = () => {
16455
16478
  const first = firstMenuItemOf(listRef.value);
@@ -16458,6 +16481,8 @@ var SubMenu = /* @__PURE__ */ defineComponent({
16458
16481
  return true;
16459
16482
  };
16460
16483
  const activateTitle = () => {
16484
+ cancelHoverOpen();
16485
+ clearCurrentPopTimer();
16461
16486
  if (props.disabled) return;
16462
16487
  if (menuContext?.mode === "inline" && !menuContext.inlineCollapsed) {
16463
16488
  menuContext.openKeysChange?.(key, !openedNow.value, subMenuContext?.keyPath || []);
@@ -16512,6 +16537,7 @@ var SubMenu = /* @__PURE__ */ defineComponent({
16512
16537
  visibility: popup && !popupPositioned.value ? "hidden" : void 0
16513
16538
  },
16514
16539
  onMouseenter: () => {
16540
+ cancelHoverOpen();
16515
16541
  clearCurrentPopTimer();
16516
16542
  menuContext?.openKeysChange?.(key, true, subMenuContext?.keyPath || []);
16517
16543
  subMenuContext?.clearPopTimer?.();
@@ -16582,13 +16608,17 @@ var SubMenu = /* @__PURE__ */ defineComponent({
16582
16608
  titleProps.onMouseenter = () => {
16583
16609
  if (props.disabled) return;
16584
16610
  clearCurrentPopTimer();
16585
- showPopper();
16611
+ cancelHoverOpen();
16612
+ subMenuContext?.clearPopTimer?.();
16613
+ dropdownContext?.clearPopTimer?.();
16614
+ if (openedNow.value) return;
16615
+ const configured = menuContext?.subMenuOpenDelay ?? 200;
16616
+ const delay = Number.isFinite(configured) ? Math.max(0, configured) : 200;
16617
+ if (delay === 0) showPopper();
16618
+ else openTimer = setTimeout(showPopper, delay);
16586
16619
  };
16587
16620
  titleProps.onMouseleave = () => {
16588
- if (props.disabled) return;
16589
- popTimer.value = setTimeout(() => {
16590
- menuContext?.openKeysChange?.(key, false, subMenuContext?.keyPath || []);
16591
- }, 200);
16621
+ hideCurrentPopTimer();
16592
16622
  };
16593
16623
  }
16594
16624
  if (subMenuContext?.keyPath.length && menuContext?.mode === "inline" && !menuContext?.inlineCollapsed) titleProps.style.paddingLeft = `${(subMenuContext?.keyPath || []).length * 16 + 16}px`;
@@ -16672,6 +16702,10 @@ var menuProps = {
16672
16702
  type: Boolean,
16673
16703
  default: true
16674
16704
  },
16705
+ subMenuOpenDelay: {
16706
+ type: Number,
16707
+ default: 200
16708
+ },
16675
16709
  openKeys: {
16676
16710
  type: Array,
16677
16711
  default: () => []
@@ -16836,6 +16870,7 @@ var Menu = /* @__PURE__ */ defineComponent({
16836
16870
  mode: currentMode,
16837
16871
  inlineCollapsed: computed(() => !!props.inlineCollapsed),
16838
16872
  collapsedTooltip: computed(() => props.collapsedTooltip),
16873
+ subMenuOpenDelay: computed(() => props.subMenuOpenDelay),
16839
16874
  popupInlineCollapsed: computed(() => collapsedInline.value && popupInlineCollapsed.value),
16840
16875
  inlineTransition,
16841
16876
  inlineOpenKeys: tempOpenKeys,
@@ -22497,25 +22532,38 @@ var FormSegmented = markFormFieldComponent(/* @__PURE__ */ defineComponent({
22497
22532
  const itemRefs = /* @__PURE__ */ new Map();
22498
22533
  const indicatorStyle = ref({});
22499
22534
  const ready = ref(false);
22535
+ const animating = ref(false);
22500
22536
  const isVertical = computed(() => props.direction === "vertical");
22501
22537
  let observer;
22502
- let frame = 0;
22538
+ let measured;
22503
22539
  const updateIndicator = () => {
22504
22540
  const item = currentValue.value === void 0 ? void 0 : itemRefs.get(currentValue.value);
22505
- if (!item) {
22541
+ if (!item || item.offsetWidth === 0 || item.offsetHeight === 0) {
22506
22542
  ready.value = false;
22543
+ animating.value = false;
22544
+ measured = void 0;
22507
22545
  indicatorStyle.value = {};
22508
22546
  return;
22509
22547
  }
22548
+ const next = {
22549
+ value: currentValue.value,
22550
+ vertical: isVertical.value,
22551
+ width: item.offsetWidth,
22552
+ height: item.offsetHeight,
22553
+ left: item.offsetLeft,
22554
+ top: item.offsetTop
22555
+ };
22556
+ if (measured && Object.keys(next).every((key) => next[key] === measured[key])) return;
22557
+ animating.value = !!measured && measured.vertical === next.vertical && !Object.is(measured.value, next.value);
22510
22558
  indicatorStyle.value = isVertical.value ? {
22511
- height: `${item.offsetHeight}px`,
22512
- top: `${item.offsetTop}px`
22559
+ height: `${next.height}px`,
22560
+ top: `${next.top}px`
22513
22561
  } : {
22514
- width: `${item.offsetWidth}px`,
22515
- left: `${item.offsetLeft}px`
22562
+ width: `${next.width}px`,
22563
+ left: `${next.left}px`
22516
22564
  };
22517
- cancelAnimationFrame(frame);
22518
- frame = requestAnimationFrame(() => ready.value = true);
22565
+ measured = next;
22566
+ ready.value = true;
22519
22567
  };
22520
22568
  const select = (option) => {
22521
22569
  if (props.disabled || field?.disabled.value || props.readonly || field?.readonly.value || option.disabled || option.value === currentValue.value) return;
@@ -22547,9 +22595,10 @@ var FormSegmented = markFormFieldComponent(/* @__PURE__ */ defineComponent({
22547
22595
  currentValue.value,
22548
22596
  props.direction,
22549
22597
  props.options
22550
- ], () => {
22551
- nextTick(updateIndicator);
22552
- }, { deep: true });
22598
+ ], updateIndicator, {
22599
+ deep: true,
22600
+ flush: "post"
22601
+ });
22553
22602
  onMounted(() => {
22554
22603
  if (typeof ResizeObserver !== "undefined") {
22555
22604
  observer = new ResizeObserver(updateIndicator);
@@ -22559,7 +22608,6 @@ var FormSegmented = markFormFieldComponent(/* @__PURE__ */ defineComponent({
22559
22608
  });
22560
22609
  onUnmounted(() => {
22561
22610
  observer?.disconnect();
22562
- cancelAnimationFrame(frame);
22563
22611
  });
22564
22612
  return () => {
22565
22613
  const size = appearance.size.value;
@@ -22586,6 +22634,11 @@ var FormSegmented = markFormFieldComponent(/* @__PURE__ */ defineComponent({
22586
22634
  "onKeydown": move
22587
22635
  }), [items.value.map((option) => {
22588
22636
  const selected = option.value === currentValue.value;
22637
+ const label = slots.label?.({
22638
+ option,
22639
+ selected
22640
+ }) ?? option.label ?? (option.icon ? void 0 : option.value);
22641
+ const hasLabel = label !== void 0 && label !== null && label !== false && label !== "";
22589
22642
  return createVNode("button", {
22590
22643
  "key": option.value,
22591
22644
  "ref": (el) => el ? itemRefs.set(option.value, el) : itemRefs.delete(option.value),
@@ -22593,15 +22646,17 @@ var FormSegmented = markFormFieldComponent(/* @__PURE__ */ defineComponent({
22593
22646
  "class": ["k-segmented-item", { "k-segmented-item-active": selected }],
22594
22647
  "role": "radio",
22595
22648
  "aria-checked": selected,
22649
+ "aria-label": !hasLabel ? String(option.value) : void 0,
22596
22650
  "disabled": props.disabled || field?.disabled.value || option.disabled,
22597
22651
  "tabindex": option.value === focusValue.value ? 0 : -1,
22598
22652
  "onClick": () => select(option)
22599
- }, [option.icon && createVNode(Icon, { "type": option.icon }, null), createVNode("span", null, [slots.label?.({
22600
- option,
22601
- selected
22602
- }) ?? option.label ?? option.value])]);
22653
+ }, [option.icon && createVNode(Icon, { "type": option.icon }, null), hasLabel && createVNode("span", null, [label])]);
22603
22654
  }), createVNode("span", {
22604
- "class": ["k-segmented-indicator", ready.value && "is-ready"],
22655
+ "class": [
22656
+ "k-segmented-indicator",
22657
+ ready.value && "is-ready",
22658
+ animating.value && "is-animating"
22659
+ ],
22605
22660
  "style": indicatorStyle.value
22606
22661
  }, null)]);
22607
22662
  };
@@ -23909,180 +23964,537 @@ var FormSwitch = markFormFieldComponent(/* @__PURE__ */ defineComponent({
23909
23964
  };
23910
23965
  }
23911
23966
  }));
23967
+ var SplitterPanel = /* @__PURE__ */ defineComponent({
23968
+ name: "SplitterPanel",
23969
+ inheritAttrs: false,
23970
+ props: {
23971
+ size: { type: [Number, String] },
23972
+ min: { type: [Number, String] },
23973
+ max: { type: [Number, String] },
23974
+ resizable: {
23975
+ type: Boolean,
23976
+ default: true
23977
+ },
23978
+ collapsible: Boolean,
23979
+ collapsed: {
23980
+ type: Boolean,
23981
+ default: void 0
23982
+ }
23983
+ },
23984
+ emits: { "update:collapsed": (collapsed) => typeof collapsed === "boolean" },
23985
+ setup(_, { attrs, slots }) {
23986
+ return () => createVNode("div", mergeProps(attrs, { "class": ["k-splitter-panel", attrs.class] }), [slots.default?.()]);
23987
+ }
23988
+ });
23989
+ // components/splitter/controller.ts
23990
+ var emptyState = () => ({
23991
+ sizes: [],
23992
+ min: [],
23993
+ max: [],
23994
+ collapsed: [],
23995
+ dragging: null,
23996
+ preview: null
23997
+ });
23998
+ var finite = (value) => Number.isFinite(value) ? Math.max(0, value) : null;
23999
+ var parseSize = (value, total) => {
24000
+ if (value === void 0 || value === "") return null;
24001
+ if (typeof value === "number") return finite(value);
24002
+ if (typeof value !== "string") return null;
24003
+ const match = /^([+-]?(?:\d+\.?\d*|\.\d+))\s*(%|px)?$/.exec(value.trim());
24004
+ return match ? finite(Number(match[1]) * (match[2] === "%" ? total / 100 : 1)) : null;
24005
+ };
24006
+ var same = (a, b) => a.length === b.length && a.every((size, i) => Object.is(size, b[i]) || Math.abs(size - b[i]) < .001);
24007
+ var round = (sizes) => sizes.map((size) => Number(size.toFixed(3)));
24008
+ function fitSizes(requested, min, max, total) {
24009
+ const result = requested.map((size, i) => Math.max(min[i], Math.min(max[i], size)));
24010
+ for (let pass = 0; pass <= result.length; pass++) {
24011
+ const delta = total - result.reduce((sum, size) => sum + size, 0);
24012
+ if (Math.abs(delta) < .001) break;
24013
+ const available = result.map((size, i) => delta > 0 ? max[i] - size : size - min[i]);
24014
+ const count = available.filter((capacity) => capacity > .001).length;
24015
+ if (!count) break;
24016
+ result.forEach((size, i) => {
24017
+ if (available[i] > .001) result[i] = size + Math.sign(delta) * Math.min(available[i], Math.abs(delta) / count);
24018
+ });
24019
+ }
24020
+ return result;
24021
+ }
24022
+ function createSplitterController() {
24023
+ let options;
24024
+ let container;
24025
+ let observer;
24026
+ let state = emptyState();
24027
+ let signature = "";
24028
+ let previousPanels = [];
24029
+ let previousValue;
24030
+ let total = 0;
24031
+ let initialized = false;
24032
+ const remembered = /* @__PURE__ */ new Map();
24033
+ let drag;
24034
+ let frame = 0;
24035
+ let resizeFrame = 0;
24036
+ let pending;
24037
+ const publish = () => options.onState({
24038
+ ...state,
24039
+ sizes: [...state.sizes],
24040
+ min: [...state.min],
24041
+ max: [...state.max],
24042
+ collapsed: [...state.collapsed]
24043
+ });
24044
+ const emitChange = () => options.onChange(round(state.sizes));
24045
+ const horizontal = () => options.direction === "horizontal";
24046
+ const coordinate = (event) => horizontal() ? event.clientX : event.clientY;
24047
+ const measure = () => {
24048
+ if (!container) return 0;
24049
+ const rect = container.getBoundingClientRect();
24050
+ const style = getComputedStyle(container);
24051
+ const num = (value) => Number.parseFloat(value) || 0;
24052
+ const border = (width, line) => !line || line === "none" || line === "hidden" ? 0 : num(width);
24053
+ const extent = horizontal() ? rect.width - border(style.borderLeftWidth, style.borderLeftStyle) - border(style.borderRightWidth, style.borderRightStyle) - num(style.paddingLeft) - num(style.paddingRight) : rect.height - border(style.borderTopWidth, style.borderTopStyle) - border(style.borderBottomWidth, style.borderBottomStyle) - num(style.paddingTop) - num(style.paddingBottom);
24054
+ return Math.max(0, extent - Math.max(0, options.panels.length - 1) * 4);
24055
+ };
24056
+ const bounds = (available, collapsed) => {
24057
+ const min = options.panels.map((p, i) => collapsed[i] ? 0 : parseSize(p.min, available) ?? 0);
24058
+ const max = options.panels.map((p, i) => collapsed[i] ? 0 : Math.max(min[i], parseSize(p.max, available) ?? available));
24059
+ const minimum = min.reduce((sum, size) => sum + size, 0);
24060
+ if (minimum > available) min.forEach((size, i) => {
24061
+ min[i] = size * available / minimum;
24062
+ });
24063
+ const maximum = max.reduce((sum, size) => sum + size, 0);
24064
+ const last = collapsed.lastIndexOf(false);
24065
+ if (maximum < available && last !== -1) max[last] += available - maximum;
24066
+ return {
24067
+ min,
24068
+ max
24069
+ };
24070
+ };
24071
+ const sync = () => {
24072
+ if (!container || !options) return;
24073
+ const nextTotal = measure();
24074
+ if (nextTotal <= 0 || !options.panels.length) return;
24075
+ const oldByKey = new Map(previousPanels.map((p, i) => [p.key, i]));
24076
+ const collapsed = options.panels.map((p) => {
24077
+ const old = oldByKey.get(p.key);
24078
+ return old === void 0 || p.collapsed !== previousPanels[old]?.collapsed ? !!p.collapsed : !!state.collapsed[old];
24079
+ });
24080
+ if (collapsed.every(Boolean)) collapsed[collapsed.length - 1] = false;
24081
+ const limits = bounds(nextTotal, collapsed);
24082
+ const valueChanged = options.value !== void 0 && (!previousValue || !same(options.value, previousValue));
24083
+ const raw = options.panels.map((p, i) => {
24084
+ const old = oldByKey.get(p.key);
24085
+ if (collapsed[i]) {
24086
+ if (old !== void 0 && state.sizes[old] > 0) remembered.set(p.key, state.sizes[old]);
24087
+ return 0;
24088
+ }
24089
+ if (valueChanged && options.value?.[i] !== void 0) return finite(options.value[i]) ?? null;
24090
+ if (!initialized || old === void 0 || p.size !== previousPanels[old]?.size) return parseSize(p.size, nextTotal);
24091
+ if (state.collapsed[old]) return remembered.get(p.key) ?? parseSize(p.size, nextTotal);
24092
+ return state.sizes[old];
24093
+ });
24094
+ const membershipChanged = previousPanels.length !== options.panels.length || options.panels.some((p) => !oldByKey.has(p.key));
24095
+ if (initialized && membershipChanged && !valueChanged) {
24096
+ const openCount = collapsed.filter((value) => !value).length;
24097
+ raw.forEach((size, i) => {
24098
+ if (size === null) raw[i] = nextTotal / openCount;
24099
+ });
24100
+ const flexible = options.panels.map((p, i) => oldByKey.has(p.key) && p.resizable && !collapsed[i] ? i : -1).filter((i) => i >= 0);
24101
+ const fixed = raw.reduce((sum, size, i) => sum + (flexible.includes(i) ? 0 : size ?? 0), 0);
24102
+ const previous = flexible.reduce((sum, i) => sum + (raw[i] ?? 0), 0);
24103
+ if (previous > 0) flexible.forEach((i) => {
24104
+ raw[i] = (raw[i] ?? 0) * Math.max(0, nextTotal - fixed) / previous;
24105
+ });
24106
+ }
24107
+ const expanding = options.panels.map((p, i) => {
24108
+ const old = oldByKey.get(p.key);
24109
+ return old !== void 0 && state.collapsed[old] && !collapsed[i];
24110
+ });
24111
+ if (initialized && expanding.some(Boolean) && !valueChanged) {
24112
+ const restored = raw.reduce((sum, size, i) => sum + (expanding[i] ? size ?? 0 : 0), 0);
24113
+ const remainder = raw.reduce((sum, size, i) => sum + (expanding[i] ? 0 : size ?? 0), 0);
24114
+ if (remainder > 0) raw.forEach((size, i) => {
24115
+ if (!expanding[i]) raw[i] = (size ?? 0) * Math.max(0, nextTotal - restored) / remainder;
24116
+ });
24117
+ }
24118
+ if (initialized && total !== nextTotal && total > 0 && !valueChanged) {
24119
+ const flexible = options.panels.map((p, i) => p.resizable && !collapsed[i] ? i : -1).filter((i) => i >= 0);
24120
+ const fixed = raw.reduce((sum, size, i) => sum + (flexible.includes(i) ? 0 : size ?? 0), 0);
24121
+ const oldFlexible = flexible.reduce((sum, i) => sum + (raw[i] ?? 0), 0);
24122
+ if (oldFlexible > 0) flexible.forEach((i) => {
24123
+ raw[i] = (raw[i] ?? 0) * Math.max(0, nextTotal - fixed) / oldFlexible;
24124
+ });
24125
+ }
24126
+ const undefinedCount = raw.filter((size) => size === null).length;
24127
+ const defined = raw.reduce((sum, size) => sum + (size ?? 0), 0);
24128
+ const automatic = undefinedCount ? Math.max(0, nextTotal - defined) / undefinedCount : 0;
24129
+ const sizes = fitSizes(raw.map((size) => size ?? automatic), limits.min, limits.max, nextTotal);
24130
+ const changed = !same(state.sizes, sizes);
24131
+ const resized = initialized && total !== nextTotal;
24132
+ total = nextTotal;
24133
+ state = {
24134
+ ...state,
24135
+ sizes,
24136
+ ...limits,
24137
+ collapsed
24138
+ };
24139
+ previousPanels = options.panels.map((p) => ({ ...p }));
24140
+ previousValue = options.value ? [...options.value] : void 0;
24141
+ initialized = true;
24142
+ publish();
24143
+ if (changed && (resized || options.value && !same(options.value, sizes))) emitChange();
24144
+ };
24145
+ const range = (index) => {
24146
+ if (!initialized) return {
24147
+ min: 0,
24148
+ max: 0
24149
+ };
24150
+ const pair = state.sizes[index] + state.sizes[index + 1];
24151
+ return {
24152
+ min: Math.max(state.min[index], pair - state.max[index + 1]),
24153
+ max: Math.min(state.max[index], pair - state.min[index + 1])
24154
+ };
24155
+ };
24156
+ const canResize = (index) => {
24157
+ if (!options || options.disabled || !options.panels[index]?.resizable || !options.panels[index + 1]?.resizable || state.collapsed[index] || state.collapsed[index + 1] || !initialized) return false;
24158
+ const limits = range(index);
24159
+ return limits.max - limits.min > .001;
24160
+ };
24161
+ const pairSizes = (index, requested) => {
24162
+ const limits = range(index);
24163
+ const next = [...state.sizes];
24164
+ next[index] = Math.max(limits.min, Math.min(limits.max, requested));
24165
+ next[index + 1] = state.sizes[index] + state.sizes[index + 1] - next[index];
24166
+ return next;
24167
+ };
24168
+ const commit = (sizes) => {
24169
+ if (same(state.sizes, sizes)) return false;
24170
+ state.sizes = sizes;
24171
+ emitChange();
24172
+ return true;
24173
+ };
24174
+ const flush = () => {
24175
+ cancelAnimationFrame(frame);
24176
+ frame = 0;
24177
+ if (!drag || pending === void 0) return;
24178
+ const next = pairSizes(drag.index, drag.sizes[drag.index] + pending - drag.start);
24179
+ pending = void 0;
24180
+ if (same(drag.proposed, next)) return;
24181
+ drag.proposed = next;
24182
+ if (options.lazy) state.preview = next[drag.index] - drag.sizes[drag.index];
24183
+ else commit(next);
24184
+ publish();
24185
+ options.onResize(round(next));
24186
+ };
24187
+ const move = (event) => {
24188
+ if (!drag || event.pointerId !== drag.id) return;
24189
+ event.preventDefault();
24190
+ pending = coordinate(event);
24191
+ if (!frame) frame = requestAnimationFrame(flush);
24192
+ };
24193
+ const finish = (cancel = false, emit = true) => {
24194
+ if (!drag) return;
24195
+ if (emit) flush();
24196
+ else {
24197
+ cancelAnimationFrame(frame);
24198
+ frame = 0;
24199
+ pending = void 0;
24200
+ }
24201
+ const current = drag;
24202
+ drag = void 0;
24203
+ window.removeEventListener("pointermove", move);
24204
+ window.removeEventListener("pointerup", up);
24205
+ window.removeEventListener("pointercancel", cancelDrag);
24206
+ window.removeEventListener("blur", cancelDrag);
24207
+ window.removeEventListener("keydown", escape);
24208
+ current.target.removeEventListener("lostpointercapture", cancelDrag);
24209
+ try {
24210
+ current.target.releasePointerCapture(current.id);
24211
+ } catch {}
24212
+ document.body.style.cursor = current.cursor;
24213
+ document.body.style.userSelect = current.userSelect;
24214
+ if (!current.hadClass) document.body.classList.remove("k-splitter-dragging");
24215
+ if (emit) commit(cancel ? current.sizes : current.proposed);
24216
+ state.dragging = null;
24217
+ state.preview = null;
24218
+ if (emit) {
24219
+ publish();
24220
+ options.onResizeEnd(round(state.sizes));
24221
+ }
24222
+ };
24223
+ const up = (event) => {
24224
+ if (!drag || event.pointerId !== drag.id) return;
24225
+ pending = coordinate(event);
24226
+ finish();
24227
+ };
24228
+ const cancelDrag = () => finish(true);
24229
+ const escape = (event) => {
24230
+ if (event.key === "Escape") {
24231
+ event.preventDefault();
24232
+ finish(true);
24233
+ }
24234
+ };
24235
+ const start = (index, event) => {
24236
+ if (event.button !== 0 || event.isPrimary === false || drag || !canResize(index)) return;
24237
+ event.preventDefault();
24238
+ const target = event.currentTarget;
24239
+ target.focus({ preventScroll: true });
24240
+ drag = {
24241
+ index,
24242
+ id: event.pointerId,
24243
+ start: coordinate(event),
24244
+ sizes: [...state.sizes],
24245
+ proposed: [...state.sizes],
24246
+ target,
24247
+ cursor: document.body.style.cursor,
24248
+ userSelect: document.body.style.userSelect,
24249
+ hadClass: document.body.classList.contains("k-splitter-dragging")
24250
+ };
24251
+ state.dragging = index;
24252
+ document.body.style.cursor = horizontal() ? "col-resize" : "row-resize";
24253
+ document.body.style.userSelect = "none";
24254
+ document.body.classList.add("k-splitter-dragging");
24255
+ try {
24256
+ target.setPointerCapture(event.pointerId);
24257
+ } catch {}
24258
+ window.addEventListener("pointermove", move, { passive: false });
24259
+ window.addEventListener("pointerup", up);
24260
+ window.addEventListener("pointercancel", cancelDrag);
24261
+ window.addEventListener("blur", cancelDrag);
24262
+ window.addEventListener("keydown", escape);
24263
+ target.addEventListener("lostpointercapture", cancelDrag);
24264
+ publish();
24265
+ options.onResizeStart(round(state.sizes));
24266
+ };
24267
+ const keydown = (index, event) => {
24268
+ if (event.target !== event.currentTarget || !canResize(index)) return;
24269
+ const previous = horizontal() ? "ArrowLeft" : "ArrowUp";
24270
+ if (![
24271
+ previous,
24272
+ horizontal() ? "ArrowRight" : "ArrowDown",
24273
+ "Home",
24274
+ "End"
24275
+ ].includes(event.key)) return;
24276
+ event.preventDefault();
24277
+ const limits = range(index);
24278
+ const requested = event.key === "Home" ? limits.min : event.key === "End" ? limits.max : state.sizes[index] + (event.key === previous ? -1 : 1) * (event.shiftKey ? 1 : 10);
24279
+ const sizes = pairSizes(index, requested);
24280
+ if (same(sizes, state.sizes)) return;
24281
+ options.onResizeStart(round(state.sizes));
24282
+ commit(sizes);
24283
+ publish();
24284
+ options.onResize(round(state.sizes));
24285
+ options.onResizeEnd(round(state.sizes));
24286
+ };
24287
+ const collapseResult = (index, neighbor) => {
24288
+ if (!initialized || options.disabled || !options.panels[index]?.collapsible || !options.panels[index].resizable || !options.panels[neighbor]?.resizable || state.collapsed[neighbor]) return null;
24289
+ const collapsed = [...state.collapsed];
24290
+ collapsed[index] = !collapsed[index];
24291
+ const limits = bounds(total, collapsed);
24292
+ const pair = state.sizes[index] + state.sizes[neighbor];
24293
+ const desired = collapsed[index] ? 0 : remembered.get(options.panels[index].key) ?? parseSize(options.panels[index].size, total) ?? pair / 2;
24294
+ const lower = Math.max(limits.min[index], pair - limits.max[neighbor]);
24295
+ const upper = Math.min(limits.max[index], pair - limits.min[neighbor]);
24296
+ if (lower > upper || collapsed[index] && lower > .001 || !collapsed[index] && upper <= .001) return null;
24297
+ const sizes = [...state.sizes];
24298
+ sizes[index] = Math.max(lower, Math.min(upper, desired));
24299
+ sizes[neighbor] = pair - sizes[index];
24300
+ return {
24301
+ sizes,
24302
+ collapsed,
24303
+ ...limits
24304
+ };
24305
+ };
24306
+ return {
24307
+ configure(next) {
24308
+ const nextSignature = JSON.stringify([
24309
+ next.direction,
24310
+ next.disabled,
24311
+ next.lazy,
24312
+ next.panels
24313
+ ]);
24314
+ const valueChanged = next.value !== void 0 && (!previousValue || !same(next.value, previousValue)) && !same(next.value, state.sizes);
24315
+ options = next;
24316
+ if (next.value === void 0) previousValue = void 0;
24317
+ if (next.value && same(next.value, state.sizes)) previousValue = [...next.value];
24318
+ if (signature === nextSignature && !valueChanged) return;
24319
+ signature = nextSignature;
24320
+ finish(true);
24321
+ sync();
24322
+ },
24323
+ mount(element) {
24324
+ container = element;
24325
+ sync();
24326
+ observer = typeof ResizeObserver === "undefined" ? void 0 : new ResizeObserver(() => {
24327
+ if (resizeFrame) return;
24328
+ resizeFrame = requestAnimationFrame(() => {
24329
+ resizeFrame = 0;
24330
+ if (measure() === total) return;
24331
+ finish(true);
24332
+ sync();
24333
+ });
24334
+ });
24335
+ observer?.observe(element);
24336
+ },
24337
+ dispose() {
24338
+ finish(true, false);
24339
+ observer?.disconnect();
24340
+ cancelAnimationFrame(resizeFrame);
24341
+ resizeFrame = 0;
24342
+ observer = void 0;
24343
+ container = void 0;
24344
+ },
24345
+ start,
24346
+ keydown,
24347
+ canResize,
24348
+ range,
24349
+ canCollapse: (index, neighbor) => !!collapseResult(index, neighbor),
24350
+ toggle(index, neighbor) {
24351
+ const next = collapseResult(index, neighbor);
24352
+ if (!next) return;
24353
+ finish(true);
24354
+ if (!state.collapsed[index]) remembered.set(options.panels[index].key, state.sizes[index]);
24355
+ state = {
24356
+ ...state,
24357
+ ...next
24358
+ };
24359
+ publish();
24360
+ emitChange();
24361
+ options.onCollapse(index, state.collapsed[index]);
24362
+ }
24363
+ };
24364
+ }
23912
24365
  var Splitter = /* @__PURE__ */ defineComponent({
23913
24366
  name: "Splitter",
23914
24367
  inheritAttrs: false,
23915
- props: { direction: {
23916
- type: String,
23917
- default: "horizontal"
23918
- } },
24368
+ props: {
24369
+ direction: {
24370
+ type: String,
24371
+ default: "horizontal"
24372
+ },
24373
+ modelValue: Array,
24374
+ value: Array,
24375
+ disabled: Boolean,
24376
+ lazy: Boolean
24377
+ },
23919
24378
  emits: {
24379
+ "update:modelValue": (sizes) => Array.isArray(sizes),
24380
+ change: (sizes) => Array.isArray(sizes),
23920
24381
  resize: (sizes) => Array.isArray(sizes),
23921
24382
  resizeStart: (sizes) => Array.isArray(sizes),
23922
- resizeEnd: (sizes) => Array.isArray(sizes)
24383
+ resizeEnd: (sizes) => Array.isArray(sizes),
24384
+ collapse: (index, collapsed) => typeof index === "number" && typeof collapsed === "boolean"
23923
24385
  },
23924
24386
  setup(props, { attrs, slots, emit }) {
23925
- const containerRef = ref(null);
23926
- const isDragging = ref(false);
23927
- const activeResizerIndex = ref(null);
23928
- const panelSizes = ref([]);
23929
- const minSizes = ref([]);
23930
- const maxSizes = ref([]);
23931
- let previousBodyCursor = "";
23932
- const parseToPx = (val, total) => {
23933
- if (val === void 0 || val === null || val === "") return null;
23934
- if (typeof val === "number") return val;
23935
- const s = String(val).trim();
23936
- if (s.endsWith("%")) return parseFloat(s) / 100 * total;
23937
- if (s.endsWith("px")) return parseFloat(s);
23938
- if (!isNaN(Number(s))) return parseFloat(s);
23939
- return null;
23940
- };
23941
- const initSizes = () => {
23942
- if (!containerRef.value) return;
23943
- const rect = containerRef.value.getBoundingClientRect();
23944
- const children = slots.default?.() || [];
23945
- const totalSize = (props.direction === "horizontal" ? rect.width : rect.height) - (children.length - 1) * 4;
23946
- minSizes.value = children.map((c) => parseToPx(c.props?.min, totalSize) ?? 0);
23947
- maxSizes.value = children.map((c) => parseToPx(c.props?.max, totalSize) ?? totalSize);
23948
- const rawSizes = children.map((c) => parseToPx(c.props?.size, totalSize));
23949
- const definedSum = rawSizes.reduce((acc, s) => (acc ?? 0) + (s ?? 0), 0) || 0;
23950
- const undefinedCount = rawSizes.filter((s) => s === null).length;
23951
- const spare = Math.max(0, totalSize - definedSum);
23952
- const autoSize = undefinedCount > 0 ? spare / undefinedCount : 0;
23953
- panelSizes.value = rawSizes.map((s) => s ?? autoSize);
23954
- };
23955
- const onMouseDown = (index, event) => {
23956
- if (event.button !== 0) return;
23957
- event.preventDefault();
23958
- isDragging.value = true;
23959
- activeResizerIndex.value = index;
23960
- document.addEventListener("mousemove", onMouseMove);
23961
- document.addEventListener("mouseup", onMouseUp);
23962
- previousBodyCursor = document.body.style.cursor;
23963
- document.body.style.cursor = props.direction === "horizontal" ? "col-resize" : "row-resize";
23964
- document.body.classList.add("k-splitter-dragging");
23965
- emitSize("resizeStart");
23966
- };
23967
- const emitSize = (type) => {
23968
- const sizes = panelSizes.value.map((x) => parseFloat(x.toFixed(3)));
23969
- if (type === "resize") emit("resize", sizes);
23970
- else if (type === "resizeStart") emit("resizeStart", sizes);
23971
- else emit("resizeEnd", sizes);
23972
- };
23973
- const resizePair = (index, requestedSize) => {
23974
- const pairTotal = panelSizes.value[index] + panelSizes.value[index + 1];
23975
- const lower = Math.max(minSizes.value[index], pairTotal - maxSizes.value[index + 1]);
23976
- const upper = Math.min(maxSizes.value[index], pairTotal - minSizes.value[index + 1]);
23977
- const nextSize = Math.max(lower, Math.min(upper, requestedSize));
23978
- panelSizes.value = panelSizes.value.map((size, panelIndex) => {
23979
- if (panelIndex === index) return nextSize;
23980
- if (panelIndex === index + 1) return pairTotal - nextSize;
23981
- return size;
23982
- });
23983
- };
23984
- const onMouseMove = (e) => {
23985
- if (!isDragging.value || activeResizerIndex.value === null || !containerRef.value) return;
23986
- const rect = containerRef.value.getBoundingClientRect();
23987
- const idx = activeResizerIndex.value;
23988
- const children = slots.default?.() || [];
23989
- const resizerWidth = 4;
23990
- const totalResizersWidth = (children.length - 1) * resizerWidth;
23991
- const totalAvailableSize = (props.direction === "horizontal" ? rect.width : rect.height) - totalResizersWidth;
23992
- const resizersBefore = idx * resizerWidth;
23993
- let currentPos = (props.direction === "horizontal" ? e.clientX - rect.left : e.clientY - rect.top) - resizersBefore;
23994
- currentPos = Math.max(0, Math.min(totalAvailableSize, currentPos));
23995
- const offset = panelSizes.value.slice(0, idx).reduce((a, b) => a + b, 0);
23996
- resizePair(idx, currentPos - offset);
23997
- emitSize("resize");
23998
- };
23999
- const finishDragging = (emitEnd = true) => {
24000
- if (!isDragging.value) return;
24001
- isDragging.value = false;
24002
- activeResizerIndex.value = null;
24003
- document.removeEventListener("mousemove", onMouseMove);
24004
- document.removeEventListener("mouseup", onMouseUp);
24005
- document.body.style.cursor = previousBodyCursor;
24006
- document.body.classList.remove("k-splitter-dragging");
24007
- if (emitEnd) emitSize("resizeEnd");
24008
- };
24009
- const onMouseUp = () => finishDragging();
24010
- const onResizerKeydown = (index, event) => {
24011
- const previousKey = props.direction === "horizontal" ? "ArrowLeft" : "ArrowUp";
24012
- if (![
24013
- previousKey,
24014
- props.direction === "horizontal" ? "ArrowRight" : "ArrowDown",
24015
- "Home",
24016
- "End"
24017
- ].includes(event.key)) return;
24018
- event.preventDefault();
24019
- const pairTotal = panelSizes.value[index] + panelSizes.value[index + 1];
24020
- const lower = Math.max(minSizes.value[index], pairTotal - maxSizes.value[index + 1]);
24021
- const upper = Math.min(maxSizes.value[index], pairTotal - minSizes.value[index + 1]);
24022
- const step = event.shiftKey ? 1 : 10;
24023
- const current = panelSizes.value[index];
24024
- const requested = event.key === "Home" ? lower : event.key === "End" ? upper : current + (event.key === previousKey ? -step : step);
24025
- emitSize("resizeStart");
24026
- resizePair(index, requested);
24027
- emitSize("resize");
24028
- emitSize("resizeEnd");
24029
- };
24030
- let ob = null;
24031
- onMounted(() => {
24032
- initSizes();
24033
- ob = new ResizeObserver(() => initSizes());
24034
- if (containerRef.value) ob.observe(containerRef.value);
24387
+ const containerRef = ref();
24388
+ const state = shallowRef(emptyState());
24389
+ const value = useInitialValue(props);
24390
+ const controller = createSplitterController();
24391
+ let nodes = [];
24392
+ const panelOptions = () => nodes.map((node, i) => {
24393
+ const p = node.props ?? {};
24394
+ return {
24395
+ key: String(node.key ?? i),
24396
+ size: p.size,
24397
+ min: p.min,
24398
+ max: p.max,
24399
+ resizable: p.resizable !== false,
24400
+ collapsible: p.collapsible === "" || p.collapsible === true,
24401
+ collapsed: p.collapsed === void 0 ? void 0 : p.collapsed !== false
24402
+ };
24035
24403
  });
24036
- onUnmounted(() => {
24037
- ob?.disconnect();
24038
- finishDragging(false);
24404
+ const configure = () => controller.configure({
24405
+ panels: panelOptions(),
24406
+ direction: props.direction,
24407
+ disabled: props.disabled,
24408
+ lazy: props.lazy,
24409
+ value: value.value,
24410
+ onState: (next) => {
24411
+ state.value = next;
24412
+ },
24413
+ onChange: (sizes) => {
24414
+ value.value = sizes;
24415
+ emit("update:modelValue", sizes);
24416
+ emit("change", sizes);
24417
+ },
24418
+ onResize: (sizes) => emit("resize", sizes),
24419
+ onResizeStart: (sizes) => emit("resizeStart", sizes),
24420
+ onResizeEnd: (sizes) => emit("resizeEnd", sizes),
24421
+ onCollapse: (index, collapsed) => {
24422
+ nodes[index]?.component?.emit("update:collapsed", collapsed);
24423
+ emit("collapse", index, collapsed);
24424
+ }
24039
24425
  });
24426
+ onMounted(() => {
24427
+ configure();
24428
+ if (containerRef.value) controller.mount(containerRef.value);
24429
+ });
24430
+ onUpdated(configure);
24431
+ onBeforeUnmount(() => controller.dispose());
24432
+ const collapseButton = (index, neighbor, before) => {
24433
+ if (!panelOptions()[index]?.collapsible) return null;
24434
+ const collapsed = state.value.collapsed[index];
24435
+ const arrow = props.direction === "horizontal" ? before !== collapsed ? "‹" : "›" : before !== collapsed ? "↑" : "↓";
24436
+ return createVNode("button", {
24437
+ "type": "button",
24438
+ "class": "k-splitter-collapse",
24439
+ "disabled": !controller.canCollapse(index, neighbor),
24440
+ "aria-label": `${collapsed ? "Expand" : "Collapse"} panel ${index + 1}`,
24441
+ "aria-expanded": !collapsed,
24442
+ "onPointerdown": (event) => event.stopPropagation(),
24443
+ "onClick": () => controller.toggle(index, neighbor)
24444
+ }, [arrow]);
24445
+ };
24040
24446
  return () => {
24041
- const children = slots.default?.() || [];
24447
+ nodes = getChildren(slots.default?.()).filter((node) => node.type === SplitterPanel);
24448
+ const current = state.value;
24042
24449
  return createVNode("div", mergeProps(attrs, {
24043
24450
  "ref": containerRef,
24044
24451
  "class": [
24045
24452
  "k-splitter",
24046
24453
  `is-${props.direction}`,
24454
+ { "is-disabled": props.disabled },
24047
24455
  attrs.class
24048
24456
  ]
24049
- }), [children.map((child, index) => {
24050
- const isLast = index === children.length - 1;
24051
- const sizeStyle = {
24052
- flexBasis: `${panelSizes.value[index]}px`,
24053
- flexGrow: 0,
24054
- flexShrink: 0
24055
- };
24056
- return createVNode(Fragment, { "key": child.key ?? index }, [createVNode("div", {
24057
- "class": "k-splitter-item",
24058
- "style": sizeStyle
24059
- }, [child]), !isLast && createVNode("div", {
24060
- "class": "k-splitter-resizer",
24061
- "role": "separator",
24062
- "tabindex": 0,
24063
- "aria-orientation": props.direction === "horizontal" ? "vertical" : "horizontal",
24064
- "aria-valuemin": Math.round(minSizes.value[index] || 0),
24065
- "aria-valuemax": Math.round(maxSizes.value[index] || 0),
24066
- "aria-valuenow": Math.round(panelSizes.value[index] || 0),
24067
- "onMousedown": (event) => onMouseDown(index, event),
24068
- "onKeydown": (event) => onResizerKeydown(index, event)
24069
- }, null)]);
24457
+ }), [nodes.map((node, index) => {
24458
+ const draggable = controller.canResize(index);
24459
+ const limits = controller.range(index);
24460
+ const dragging = current.dragging === index;
24461
+ return createVNode(Fragment, { "key": node.key ?? index }, [createVNode("div", {
24462
+ "class": ["k-splitter-item", { "is-collapsed": current.collapsed[index] }],
24463
+ "aria-hidden": current.collapsed[index] || void 0,
24464
+ "inert": current.collapsed[index] || void 0,
24465
+ "style": {
24466
+ flexBasis: current.sizes[index] === void 0 ? void 0 : `${current.sizes[index]}px`,
24467
+ flexGrow: current.sizes[index] === void 0 ? 1 : 0,
24468
+ flexShrink: 0
24469
+ }
24470
+ }, [node]), index < nodes.length - 1 && createVNode("div", { "class": ["k-splitter-resizer", {
24471
+ "is-active": dragging,
24472
+ "is-after-collapsed": current.collapsed[index + 1],
24473
+ "is-restorable": current.collapsed[index] || current.collapsed[index + 1]
24474
+ }] }, [
24475
+ createVNode("div", {
24476
+ "class": "k-splitter-handle",
24477
+ "role": "separator",
24478
+ "tabindex": draggable ? 0 : -1,
24479
+ "aria-label": `Resize panels ${index + 1} and ${index + 2}`,
24480
+ "aria-orientation": props.direction === "horizontal" ? "vertical" : "horizontal",
24481
+ "aria-disabled": !draggable || void 0,
24482
+ "aria-valuemin": Math.round(limits.min),
24483
+ "aria-valuemax": Math.round(limits.max),
24484
+ "aria-valuenow": Math.round(current.sizes[index] ?? 0),
24485
+ "onPointerdown": (event) => controller.start(index, event),
24486
+ "onKeydown": (event) => controller.keydown(index, event)
24487
+ }, null),
24488
+ createVNode("div", { "class": "k-splitter-actions" }, [collapseButton(index, index + 1, true), collapseButton(index + 1, index, false)]),
24489
+ dragging && props.lazy && current.preview !== null && createVNode("div", {
24490
+ "class": "k-splitter-preview",
24491
+ "style": { transform: props.direction === "horizontal" ? `translateX(${current.preview}px)` : `translateY(${current.preview}px)` }
24492
+ }, null)
24493
+ ])]);
24070
24494
  })]);
24071
24495
  };
24072
24496
  }
24073
24497
  });
24074
- var SplitterPanel = /* @__PURE__ */ defineComponent({
24075
- name: "SplitterPanel",
24076
- inheritAttrs: false,
24077
- props: {
24078
- size: { type: [Number, String] },
24079
- min: { type: [Number, String] },
24080
- max: { type: [Number, String] }
24081
- },
24082
- setup(_, { attrs, slots }) {
24083
- return () => createVNode("div", mergeProps(attrs, { "class": ["k-splitter-panel", attrs.class] }), [slots.default?.()]);
24084
- }
24085
- });
24086
24498
  // components/table/utils.ts
24087
24499
  var flattenColumns = (columns) => columns.flatMap((column) => column.children?.length ? flattenColumns(column.children) : column);
24088
24500
  var countColumnLeaves = (column) => column.children?.length ? column.children.reduce((sum, child) => sum + countColumnLeaves(child), 0) : 1;