@kine-design/core 0.0.1-beta.11 → 0.0.1-beta.12

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 (60) hide show
  1. package/components/base/tooltip/api.ts +3 -2
  2. package/components/base/tooltip/index.ts +3 -2
  3. package/components/base/tooltip/props.d.ts +12 -6
  4. package/components/base/tooltip/useTooltip.ts +175 -56
  5. package/compositions/commandPalette/index.ts +11 -0
  6. package/compositions/commandPalette/types.ts +29 -0
  7. package/compositions/commandPalette/useCommandPalette.ts +135 -0
  8. package/compositions/contextMenu/index.ts +10 -0
  9. package/compositions/contextMenu/types.ts +21 -0
  10. package/compositions/contextMenu/useContextMenu.ts +101 -0
  11. package/compositions/editor/index.ts +18 -0
  12. package/compositions/editor/types.ts +147 -0
  13. package/compositions/editor/useEditor.ts +224 -0
  14. package/compositions/index.ts +15 -0
  15. package/compositions/overlay/index.ts +14 -0
  16. package/compositions/overlay/useOverlayStack.ts +146 -0
  17. package/compositions/peekView/index.ts +10 -0
  18. package/compositions/peekView/usePeekView.ts +99 -0
  19. package/compositions/theme/index.ts +17 -0
  20. package/compositions/theme/presets/compact.ts +117 -0
  21. package/compositions/theme/presets/dark.ts +113 -0
  22. package/compositions/theme/presets/index.ts +11 -0
  23. package/compositions/theme/presets/light.ts +113 -0
  24. package/compositions/theme/types.ts +46 -0
  25. package/compositions/theme/useTheme.ts +269 -0
  26. package/compositions/toast/index.ts +10 -0
  27. package/compositions/toast/useToast.ts +176 -0
  28. package/compositions/tooltip/index.ts +9 -0
  29. package/compositions/tooltip/useTooltip.ts +10 -0
  30. package/dist/components/base/tooltip/index.d.ts +1 -0
  31. package/dist/components/base/tooltip/useTooltip.d.ts +20 -17
  32. package/dist/compositions/commandPalette/index.d.ts +11 -0
  33. package/dist/compositions/commandPalette/types.d.ts +20 -0
  34. package/dist/compositions/commandPalette/useCommandPalette.d.ts +32 -0
  35. package/dist/compositions/contextMenu/index.d.ts +10 -0
  36. package/dist/compositions/contextMenu/types.d.ts +12 -0
  37. package/dist/compositions/contextMenu/useContextMenu.d.ts +52 -0
  38. package/dist/compositions/editor/index.d.ts +10 -0
  39. package/dist/compositions/editor/types.d.ts +132 -0
  40. package/dist/compositions/editor/useEditor.d.ts +13 -0
  41. package/dist/compositions/index.d.ts +15 -0
  42. package/dist/compositions/overlay/index.d.ts +10 -0
  43. package/dist/compositions/overlay/useOverlayStack.d.ts +188 -0
  44. package/dist/compositions/peekView/index.d.ts +10 -0
  45. package/dist/compositions/peekView/usePeekView.d.ts +16 -0
  46. package/dist/compositions/theme/index.d.ts +11 -0
  47. package/dist/compositions/theme/presets/compact.d.ts +6 -0
  48. package/dist/compositions/theme/presets/dark.d.ts +2 -0
  49. package/dist/compositions/theme/presets/index.d.ts +11 -0
  50. package/dist/compositions/theme/presets/light.d.ts +2 -0
  51. package/dist/compositions/theme/types.d.ts +41 -0
  52. package/dist/compositions/theme/useTheme.d.ts +167 -0
  53. package/dist/compositions/toast/index.d.ts +10 -0
  54. package/dist/compositions/toast/useToast.d.ts +71 -0
  55. package/dist/compositions/tooltip/index.d.ts +9 -0
  56. package/dist/compositions/tooltip/useTooltip.d.ts +10 -0
  57. package/dist/core.js +811 -48
  58. package/dist/index.d.ts +1 -0
  59. package/index.ts +2 -0
  60. package/package.json +13 -2
package/dist/core.js CHANGED
@@ -1,6 +1,6 @@
1
- import { computed, createVNode, inject, nextTick, onBeforeUnmount, onMounted, onUnmounted, provide, ref, shallowRef, toRef, triggerRef, watch } from "vue";
1
+ import { computed, createVNode, effectScope, getCurrentInstance, getCurrentScope, hasInjectionContext, inject, isReactive, isRef, markRaw, nextTick, onBeforeUnmount, onMounted, onScopeDispose, onUnmounted, provide, reactive, ref, shallowRef, toRaw, toRef, toRefs, triggerRef, watch } from "vue";
2
2
  import * as _interactjsModule from "interactjs";
3
- import { arrow, autoUpdate, computePosition } from "@floating-ui/dom";
3
+ import { arrow, autoUpdate, computePosition, flip, offset, shift } from "@floating-ui/dom";
4
4
  import dayjs from "dayjs";
5
5
  //#endregion
6
6
  //#region components/base/avatar/index.ts
@@ -1895,6 +1895,10 @@ var props$36 = {
1895
1895
  type: String,
1896
1896
  default: "top"
1897
1897
  },
1898
+ delay: {
1899
+ type: Number,
1900
+ default: 300
1901
+ },
1898
1902
  disabled: {
1899
1903
  type: Boolean,
1900
1904
  default: false
@@ -1907,78 +1911,158 @@ var props$36 = {
1907
1911
  //#endregion
1908
1912
  //#region components/base/tooltip/useTooltip.ts
1909
1913
  /**
1910
- * @description tooltip composable,管理 hover 显示/隐藏及定位
1914
+ * @description tooltip composable manages show/hide with delay, positioning via usePopper, singleton, scroll/interaction dismissal
1911
1915
  * @author 阿怪
1912
1916
  * @date 2026/2/25
1913
- * @version v1.0.0
1917
+ * @version v2.0.0
1914
1918
  *
1915
1919
  * 江湖的业务千篇一律,复杂的代码好几百行。
1916
1920
  */
1917
- /**
1918
- * 根据 trigger 元素的 getBoundingClientRect placement 计算 tooltip 的 fixed 定位样式
1919
- */
1920
- function calcPosition(rect, tooltipEl, placement) {
1921
- const gap = 8;
1922
- const tooltipRect = tooltipEl.getBoundingClientRect();
1923
- let left = 0;
1924
- let top = 0;
1925
- switch (placement) {
1926
- case "top":
1927
- left = rect.left + rect.width / 2 - tooltipRect.width / 2;
1928
- top = rect.top - tooltipRect.height - gap;
1929
- break;
1930
- case "bottom":
1931
- left = rect.left + rect.width / 2 - tooltipRect.width / 2;
1932
- top = rect.bottom + gap;
1933
- break;
1934
- case "left":
1935
- left = rect.left - tooltipRect.width - gap;
1936
- top = rect.top + rect.height / 2 - tooltipRect.height / 2;
1937
- break;
1938
- case "right":
1939
- left = rect.right + gap;
1940
- top = rect.top + rect.height / 2 - tooltipRect.height / 2;
1941
- break;
1942
- }
1943
- return {
1944
- position: "fixed",
1945
- left: `${left}px`,
1946
- top: `${top}px`,
1947
- zIndex: "9999"
1948
- };
1949
- }
1921
+ var HIDE_DELAY = 100;
1922
+ /** Singleton: only one tooltip visible at a time */
1923
+ var activeHide = null;
1950
1924
  function useTooltip(props) {
1951
1925
  const visible = ref(false);
1952
- const tooltipStyle = ref({});
1926
+ const positionData = ref(null);
1953
1927
  const triggerRef = ref(null);
1954
1928
  const tooltipRef = ref(null);
1955
- const show = async () => {
1929
+ const arrowRef = ref(null);
1930
+ let showTimer = null;
1931
+ let hideTimer = null;
1932
+ let popperCleanup = null;
1933
+ const tooltipId = `k-tooltip-${Math.random().toString(36).slice(2, 10)}`;
1934
+ /** Clean up popper auto-update subscription */
1935
+ const destroyPopper = () => {
1936
+ if (popperCleanup) {
1937
+ popperCleanup();
1938
+ popperCleanup = null;
1939
+ }
1940
+ };
1941
+ /** Immediately hide — no delay */
1942
+ const hideImmediate = () => {
1943
+ clearTimers();
1944
+ visible.value = false;
1945
+ positionData.value = null;
1946
+ destroyPopper();
1947
+ if (activeHide === hideImmediate) activeHide = null;
1948
+ removeInteractionListeners();
1949
+ removeScrollListeners();
1950
+ };
1951
+ /** Show tooltip after delay */
1952
+ const show = () => {
1956
1953
  if (props.disabled) return;
1954
+ if (activeHide && activeHide !== hideImmediate) activeHide();
1955
+ if (hideTimer) {
1956
+ clearTimeout(hideTimer);
1957
+ hideTimer = null;
1958
+ }
1959
+ if (visible.value) return;
1960
+ const delay = props.delay ?? 300;
1961
+ showTimer = setTimeout(() => {
1962
+ showTimer = null;
1963
+ if (props.disabled) return;
1964
+ doShow();
1965
+ }, delay);
1966
+ };
1967
+ /** Actually display the tooltip and set up popper */
1968
+ const doShow = () => {
1957
1969
  visible.value = true;
1958
- await nextTick();
1970
+ activeHide = hideImmediate;
1971
+ addInteractionListeners();
1972
+ addScrollListeners();
1973
+ };
1974
+ /** Initialize popper positioning — called after tooltip DOM is mounted */
1975
+ const initPopper = () => {
1959
1976
  if (!triggerRef.value || !tooltipRef.value) return;
1960
- tooltipStyle.value = calcPosition(triggerRef.value.getBoundingClientRect(), tooltipRef.value, props.placement);
1977
+ destroyPopper();
1978
+ const { clear } = usePopper(triggerRef.value, tooltipRef.value, (data) => {
1979
+ positionData.value = {
1980
+ style: { ...data.style },
1981
+ arrowStyle: { ...data.arrowStyle },
1982
+ placement: data.placement
1983
+ };
1984
+ }, arrowRef.value ?? void 0, {
1985
+ placement: props.placement,
1986
+ middleware: [
1987
+ offset(8),
1988
+ flip(),
1989
+ shift({ padding: 8 })
1990
+ ]
1991
+ });
1992
+ popperCleanup = clear;
1961
1993
  };
1994
+ /** Hide tooltip with a short delay (allows cursor to move between trigger and tooltip) */
1962
1995
  const hide = () => {
1963
- visible.value = false;
1964
- tooltipStyle.value = {};
1996
+ if (showTimer) {
1997
+ clearTimeout(showTimer);
1998
+ showTimer = null;
1999
+ }
2000
+ if (!visible.value) return;
2001
+ hideTimer = setTimeout(() => {
2002
+ hideTimer = null;
2003
+ hideImmediate();
2004
+ }, HIDE_DELAY);
2005
+ };
2006
+ const clearTimers = () => {
2007
+ if (showTimer) {
2008
+ clearTimeout(showTimer);
2009
+ showTimer = null;
2010
+ }
2011
+ if (hideTimer) {
2012
+ clearTimeout(hideTimer);
2013
+ hideTimer = null;
2014
+ }
1965
2015
  };
2016
+ const onInteraction = () => {
2017
+ hideImmediate();
2018
+ };
2019
+ const addInteractionListeners = () => {
2020
+ document.addEventListener("mousedown", onInteraction, true);
2021
+ document.addEventListener("keydown", onInteraction, true);
2022
+ };
2023
+ const removeInteractionListeners = () => {
2024
+ document.removeEventListener("mousedown", onInteraction, true);
2025
+ document.removeEventListener("keydown", onInteraction, true);
2026
+ };
2027
+ const onScroll = () => {
2028
+ if (!triggerRef.value) {
2029
+ hideImmediate();
2030
+ return;
2031
+ }
2032
+ const rect = triggerRef.value.getBoundingClientRect();
2033
+ if (!(rect.bottom > 0 && rect.top < window.innerHeight && rect.right > 0 && rect.left < window.innerWidth)) hideImmediate();
2034
+ };
2035
+ const addScrollListeners = () => {
2036
+ window.addEventListener("scroll", onScroll, true);
2037
+ window.addEventListener("resize", onScroll, true);
2038
+ };
2039
+ const removeScrollListeners = () => {
2040
+ window.removeEventListener("scroll", onScroll, true);
2041
+ window.removeEventListener("resize", onScroll, true);
2042
+ };
2043
+ onBeforeUnmount(() => {
2044
+ hideImmediate();
2045
+ });
1966
2046
  return {
1967
2047
  visible,
1968
- tooltipStyle,
2048
+ positionData,
1969
2049
  triggerRef,
1970
2050
  tooltipRef,
2051
+ arrowRef,
2052
+ tooltipId,
1971
2053
  show,
1972
- hide
2054
+ hide,
2055
+ hideImmediate,
2056
+ initPopper
1973
2057
  };
1974
2058
  }
1975
2059
  //#endregion
1976
2060
  //#region components/base/tooltip/index.ts
1977
2061
  /**
1978
- * @description tooltip core 导出
2062
+ * @description tooltip core barrel export
1979
2063
  * @author 阿怪
1980
2064
  * @date 2026/2/25
1981
- * @version v1.0.0
2065
+ * @version v2.0.0
1982
2066
  *
1983
2067
  * 江湖的业务千篇一律,复杂的代码好几百行。
1984
2068
  */
@@ -6320,6 +6404,685 @@ var AnchorCore = {
6320
6404
  useAnchor
6321
6405
  };
6322
6406
  //#endregion
6407
+ //#region ../../node_modules/.pnpm/pinia@3.0.4_typescript@5.9.3_vue@3.5.30_typescript@5.9.3_/node_modules/pinia/dist/pinia.mjs
6408
+ /*!
6409
+ * pinia v3.0.4
6410
+ * (c) 2025 Eduardo San Martin Morote
6411
+ * @license MIT
6412
+ */
6413
+ var IS_CLIENT = typeof window !== "undefined";
6414
+ /**
6415
+ * setActivePinia must be called to handle SSR at the top of functions like
6416
+ * `fetch`, `setup`, `serverPrefetch` and others
6417
+ */
6418
+ var activePinia;
6419
+ /**
6420
+ * Sets or unsets the active pinia. Used in SSR and internally when calling
6421
+ * actions and getters
6422
+ *
6423
+ * @param pinia - Pinia instance
6424
+ */
6425
+ var setActivePinia = (pinia) => activePinia = pinia;
6426
+ process.env.NODE_ENV;
6427
+ var piniaSymbol = process.env.NODE_ENV !== "production" ? Symbol("pinia") : Symbol();
6428
+ function isPlainObject(o) {
6429
+ return o && typeof o === "object" && Object.prototype.toString.call(o) === "[object Object]" && typeof o.toJSON !== "function";
6430
+ }
6431
+ /**
6432
+ * Possible types for SubscriptionCallback
6433
+ */
6434
+ var MutationType;
6435
+ (function(MutationType) {
6436
+ /**
6437
+ * Direct mutation of the state:
6438
+ *
6439
+ * - `store.name = 'new name'`
6440
+ * - `store.$state.name = 'new name'`
6441
+ * - `store.list.push('new item')`
6442
+ */
6443
+ MutationType["direct"] = "direct";
6444
+ /**
6445
+ * Mutated the state with `$patch` and an object
6446
+ *
6447
+ * - `store.$patch({ name: 'newName' })`
6448
+ */
6449
+ MutationType["patchObject"] = "patch object";
6450
+ /**
6451
+ * Mutated the state with `$patch` and a function
6452
+ *
6453
+ * - `store.$patch(state => state.name = 'newName')`
6454
+ */
6455
+ MutationType["patchFunction"] = "patch function";
6456
+ })(MutationType || (MutationType = {}));
6457
+ var _global = typeof window === "object" && window.window === window ? window : typeof self === "object" && self.self === self ? self : typeof global === "object" && global.global === global ? global : typeof globalThis === "object" ? globalThis : { HTMLElement: null };
6458
+ function bom(blob, { autoBom = false } = {}) {
6459
+ if (autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) return new Blob([String.fromCharCode(65279), blob], { type: blob.type });
6460
+ return blob;
6461
+ }
6462
+ function download(url, name, opts) {
6463
+ const xhr = new XMLHttpRequest();
6464
+ xhr.open("GET", url);
6465
+ xhr.responseType = "blob";
6466
+ xhr.onload = function() {
6467
+ saveAs(xhr.response, name, opts);
6468
+ };
6469
+ xhr.onerror = function() {
6470
+ console.error("could not download file");
6471
+ };
6472
+ xhr.send();
6473
+ }
6474
+ function corsEnabled(url) {
6475
+ const xhr = new XMLHttpRequest();
6476
+ xhr.open("HEAD", url, false);
6477
+ try {
6478
+ xhr.send();
6479
+ } catch (e) {}
6480
+ return xhr.status >= 200 && xhr.status <= 299;
6481
+ }
6482
+ function click(node) {
6483
+ try {
6484
+ node.dispatchEvent(new MouseEvent("click"));
6485
+ } catch (e) {
6486
+ const evt = new MouseEvent("click", {
6487
+ bubbles: true,
6488
+ cancelable: true,
6489
+ view: window,
6490
+ detail: 0,
6491
+ screenX: 80,
6492
+ screenY: 20,
6493
+ clientX: 80,
6494
+ clientY: 20,
6495
+ ctrlKey: false,
6496
+ altKey: false,
6497
+ shiftKey: false,
6498
+ metaKey: false,
6499
+ button: 0,
6500
+ relatedTarget: null
6501
+ });
6502
+ node.dispatchEvent(evt);
6503
+ }
6504
+ }
6505
+ var _navigator = typeof navigator === "object" ? navigator : { userAgent: "" };
6506
+ var isMacOSWebView = /Macintosh/.test(_navigator.userAgent) && /AppleWebKit/.test(_navigator.userAgent) && !/Safari/.test(_navigator.userAgent);
6507
+ var saveAs = !IS_CLIENT ? () => {} : typeof HTMLAnchorElement !== "undefined" && "download" in HTMLAnchorElement.prototype && !isMacOSWebView ? downloadSaveAs : "msSaveOrOpenBlob" in _navigator ? msSaveAs : fileSaverSaveAs;
6508
+ function downloadSaveAs(blob, name = "download", opts) {
6509
+ const a = document.createElement("a");
6510
+ a.download = name;
6511
+ a.rel = "noopener";
6512
+ if (typeof blob === "string") {
6513
+ a.href = blob;
6514
+ if (a.origin !== location.origin) if (corsEnabled(a.href)) download(blob, name, opts);
6515
+ else {
6516
+ a.target = "_blank";
6517
+ click(a);
6518
+ }
6519
+ else click(a);
6520
+ } else {
6521
+ a.href = URL.createObjectURL(blob);
6522
+ setTimeout(function() {
6523
+ URL.revokeObjectURL(a.href);
6524
+ }, 4e4);
6525
+ setTimeout(function() {
6526
+ click(a);
6527
+ }, 0);
6528
+ }
6529
+ }
6530
+ function msSaveAs(blob, name = "download", opts) {
6531
+ if (typeof blob === "string") if (corsEnabled(blob)) download(blob, name, opts);
6532
+ else {
6533
+ const a = document.createElement("a");
6534
+ a.href = blob;
6535
+ a.target = "_blank";
6536
+ setTimeout(function() {
6537
+ click(a);
6538
+ });
6539
+ }
6540
+ else navigator.msSaveOrOpenBlob(bom(blob, opts), name);
6541
+ }
6542
+ function fileSaverSaveAs(blob, name, opts, popup) {
6543
+ popup = popup || open("", "_blank");
6544
+ if (popup) popup.document.title = popup.document.body.innerText = "downloading...";
6545
+ if (typeof blob === "string") return download(blob, name, opts);
6546
+ const force = blob.type === "application/octet-stream";
6547
+ const isSafari = /constructor/i.test(String(_global.HTMLElement)) || "safari" in _global;
6548
+ const isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent);
6549
+ if ((isChromeIOS || force && isSafari || isMacOSWebView) && typeof FileReader !== "undefined") {
6550
+ const reader = new FileReader();
6551
+ reader.onloadend = function() {
6552
+ let url = reader.result;
6553
+ if (typeof url !== "string") {
6554
+ popup = null;
6555
+ throw new Error("Wrong reader.result type");
6556
+ }
6557
+ url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, "data:attachment/file;");
6558
+ if (popup) popup.location.href = url;
6559
+ else location.assign(url);
6560
+ popup = null;
6561
+ };
6562
+ reader.readAsDataURL(blob);
6563
+ } else {
6564
+ const url = URL.createObjectURL(blob);
6565
+ if (popup) popup.location.assign(url);
6566
+ else location.href = url;
6567
+ popup = null;
6568
+ setTimeout(function() {
6569
+ URL.revokeObjectURL(url);
6570
+ }, 4e4);
6571
+ }
6572
+ }
6573
+ var { assign: assign$1 } = Object;
6574
+ /**
6575
+ * Mutates in place `newState` with `oldState` to _hot update_ it. It will
6576
+ * remove any key not existing in `newState` and recursively merge plain
6577
+ * objects.
6578
+ *
6579
+ * @param newState - new state object to be patched
6580
+ * @param oldState - old state that should be used to patch newState
6581
+ * @returns - newState
6582
+ */
6583
+ function patchObject(newState, oldState) {
6584
+ for (const key in oldState) {
6585
+ const subPatch = oldState[key];
6586
+ if (!(key in newState)) continue;
6587
+ const targetValue = newState[key];
6588
+ if (isPlainObject(targetValue) && isPlainObject(subPatch) && !isRef(subPatch) && !isReactive(subPatch)) newState[key] = patchObject(targetValue, subPatch);
6589
+ else newState[key] = subPatch;
6590
+ }
6591
+ return newState;
6592
+ }
6593
+ var noop = () => {};
6594
+ function addSubscription(subscriptions, callback, detached, onCleanup = noop) {
6595
+ subscriptions.add(callback);
6596
+ const removeSubscription = () => {
6597
+ subscriptions.delete(callback) && onCleanup();
6598
+ };
6599
+ if (!detached && getCurrentScope()) onScopeDispose(removeSubscription);
6600
+ return removeSubscription;
6601
+ }
6602
+ function triggerSubscriptions(subscriptions, ...args) {
6603
+ subscriptions.forEach((callback) => {
6604
+ callback(...args);
6605
+ });
6606
+ }
6607
+ var fallbackRunWithContext = (fn) => fn();
6608
+ /**
6609
+ * Marks a function as an action for `$onAction`
6610
+ * @internal
6611
+ */
6612
+ var ACTION_MARKER = Symbol();
6613
+ /**
6614
+ * Action name symbol. Allows to add a name to an action after defining it
6615
+ * @internal
6616
+ */
6617
+ var ACTION_NAME = Symbol();
6618
+ function mergeReactiveObjects(target, patchToApply) {
6619
+ if (target instanceof Map && patchToApply instanceof Map) patchToApply.forEach((value, key) => target.set(key, value));
6620
+ else if (target instanceof Set && patchToApply instanceof Set) patchToApply.forEach(target.add, target);
6621
+ for (const key in patchToApply) {
6622
+ if (!patchToApply.hasOwnProperty(key)) continue;
6623
+ const subPatch = patchToApply[key];
6624
+ const targetValue = target[key];
6625
+ if (isPlainObject(targetValue) && isPlainObject(subPatch) && target.hasOwnProperty(key) && !isRef(subPatch) && !isReactive(subPatch)) target[key] = mergeReactiveObjects(targetValue, subPatch);
6626
+ else target[key] = subPatch;
6627
+ }
6628
+ return target;
6629
+ }
6630
+ var skipHydrateSymbol = process.env.NODE_ENV !== "production" ? Symbol("pinia:skipHydration") : Symbol();
6631
+ /**
6632
+ * Returns whether a value should be hydrated
6633
+ *
6634
+ * @param obj - target variable
6635
+ * @returns true if `obj` should be hydrated
6636
+ */
6637
+ function shouldHydrate(obj) {
6638
+ return !isPlainObject(obj) || !Object.prototype.hasOwnProperty.call(obj, skipHydrateSymbol);
6639
+ }
6640
+ var { assign } = Object;
6641
+ function isComputed(o) {
6642
+ return !!(isRef(o) && o.effect);
6643
+ }
6644
+ function createOptionsStore(id, options, pinia, hot) {
6645
+ const { state, actions, getters } = options;
6646
+ const initialState = pinia.state.value[id];
6647
+ let store;
6648
+ function setup() {
6649
+ if (!initialState && (!(process.env.NODE_ENV !== "production") || !hot))
6650
+ /* istanbul ignore if */
6651
+ pinia.state.value[id] = state ? state() : {};
6652
+ const localState = process.env.NODE_ENV !== "production" && hot ? toRefs(ref(state ? state() : {}).value) : toRefs(pinia.state.value[id]);
6653
+ return assign(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name) => {
6654
+ if (process.env.NODE_ENV !== "production" && name in localState) console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${name}" in store "${id}".`);
6655
+ computedGetters[name] = markRaw(computed(() => {
6656
+ setActivePinia(pinia);
6657
+ const store = pinia._s.get(id);
6658
+ return getters[name].call(store, store);
6659
+ }));
6660
+ return computedGetters;
6661
+ }, {}));
6662
+ }
6663
+ store = createSetupStore(id, setup, options, pinia, hot, true);
6664
+ return store;
6665
+ }
6666
+ function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
6667
+ let scope;
6668
+ const optionsForPlugin = assign({ actions: {} }, options);
6669
+ /* istanbul ignore if */
6670
+ if (process.env.NODE_ENV !== "production" && !pinia._e.active) throw new Error("Pinia destroyed");
6671
+ const $subscribeOptions = { deep: true };
6672
+ /* istanbul ignore else */
6673
+ if (process.env.NODE_ENV !== "production") $subscribeOptions.onTrigger = (event) => {
6674
+ /* istanbul ignore else */
6675
+ if (isListening) debuggerEvents = event;
6676
+ else if (isListening == false && !store._hotUpdating)
6677
+ /* istanbul ignore else */
6678
+ if (Array.isArray(debuggerEvents)) debuggerEvents.push(event);
6679
+ else console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug.");
6680
+ };
6681
+ let isListening;
6682
+ let isSyncListening;
6683
+ let subscriptions = /* @__PURE__ */ new Set();
6684
+ let actionSubscriptions = /* @__PURE__ */ new Set();
6685
+ let debuggerEvents;
6686
+ const initialState = pinia.state.value[$id];
6687
+ if (!isOptionsStore && !initialState && (!(process.env.NODE_ENV !== "production") || !hot))
6688
+ /* istanbul ignore if */
6689
+ pinia.state.value[$id] = {};
6690
+ const hotState = ref({});
6691
+ let activeListener;
6692
+ function $patch(partialStateOrMutator) {
6693
+ let subscriptionMutation;
6694
+ isListening = isSyncListening = false;
6695
+ /* istanbul ignore else */
6696
+ if (process.env.NODE_ENV !== "production") debuggerEvents = [];
6697
+ if (typeof partialStateOrMutator === "function") {
6698
+ partialStateOrMutator(pinia.state.value[$id]);
6699
+ subscriptionMutation = {
6700
+ type: MutationType.patchFunction,
6701
+ storeId: $id,
6702
+ events: debuggerEvents
6703
+ };
6704
+ } else {
6705
+ mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator);
6706
+ subscriptionMutation = {
6707
+ type: MutationType.patchObject,
6708
+ payload: partialStateOrMutator,
6709
+ storeId: $id,
6710
+ events: debuggerEvents
6711
+ };
6712
+ }
6713
+ const myListenerId = activeListener = Symbol();
6714
+ nextTick().then(() => {
6715
+ if (activeListener === myListenerId) isListening = true;
6716
+ });
6717
+ isSyncListening = true;
6718
+ triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]);
6719
+ }
6720
+ const $reset = isOptionsStore ? function $reset() {
6721
+ const { state } = options;
6722
+ const newState = state ? state() : {};
6723
+ this.$patch(($state) => {
6724
+ assign($state, newState);
6725
+ });
6726
+ } : process.env.NODE_ENV !== "production" ? () => {
6727
+ throw new Error(`🍍: Store "${$id}" is built using the setup syntax and does not implement $reset().`);
6728
+ } : noop;
6729
+ function $dispose() {
6730
+ scope.stop();
6731
+ subscriptions.clear();
6732
+ actionSubscriptions.clear();
6733
+ pinia._s.delete($id);
6734
+ }
6735
+ /**
6736
+ * Helper that wraps function so it can be tracked with $onAction
6737
+ * @param fn - action to wrap
6738
+ * @param name - name of the action
6739
+ */
6740
+ const action = (fn, name = "") => {
6741
+ if (ACTION_MARKER in fn) {
6742
+ fn[ACTION_NAME] = name;
6743
+ return fn;
6744
+ }
6745
+ const wrappedAction = function() {
6746
+ setActivePinia(pinia);
6747
+ const args = Array.from(arguments);
6748
+ const afterCallbackSet = /* @__PURE__ */ new Set();
6749
+ const onErrorCallbackSet = /* @__PURE__ */ new Set();
6750
+ function after(callback) {
6751
+ afterCallbackSet.add(callback);
6752
+ }
6753
+ function onError(callback) {
6754
+ onErrorCallbackSet.add(callback);
6755
+ }
6756
+ triggerSubscriptions(actionSubscriptions, {
6757
+ args,
6758
+ name: wrappedAction[ACTION_NAME],
6759
+ store,
6760
+ after,
6761
+ onError
6762
+ });
6763
+ let ret;
6764
+ try {
6765
+ ret = fn.apply(this && this.$id === $id ? this : store, args);
6766
+ } catch (error) {
6767
+ triggerSubscriptions(onErrorCallbackSet, error);
6768
+ throw error;
6769
+ }
6770
+ if (ret instanceof Promise) return ret.then((value) => {
6771
+ triggerSubscriptions(afterCallbackSet, value);
6772
+ return value;
6773
+ }).catch((error) => {
6774
+ triggerSubscriptions(onErrorCallbackSet, error);
6775
+ return Promise.reject(error);
6776
+ });
6777
+ triggerSubscriptions(afterCallbackSet, ret);
6778
+ return ret;
6779
+ };
6780
+ wrappedAction[ACTION_MARKER] = true;
6781
+ wrappedAction[ACTION_NAME] = name;
6782
+ return wrappedAction;
6783
+ };
6784
+ const _hmrPayload = /* @__PURE__ */ markRaw({
6785
+ actions: {},
6786
+ getters: {},
6787
+ state: [],
6788
+ hotState
6789
+ });
6790
+ const partialStore = {
6791
+ _p: pinia,
6792
+ $id,
6793
+ $onAction: addSubscription.bind(null, actionSubscriptions),
6794
+ $patch,
6795
+ $reset,
6796
+ $subscribe(callback, options = {}) {
6797
+ const removeSubscription = addSubscription(subscriptions, callback, options.detached, () => stopWatcher());
6798
+ const stopWatcher = scope.run(() => watch(() => pinia.state.value[$id], (state) => {
6799
+ if (options.flush === "sync" ? isSyncListening : isListening) callback({
6800
+ storeId: $id,
6801
+ type: MutationType.direct,
6802
+ events: debuggerEvents
6803
+ }, state);
6804
+ }, assign({}, $subscribeOptions, options)));
6805
+ return removeSubscription;
6806
+ },
6807
+ $dispose
6808
+ };
6809
+ const store = reactive(process.env.NODE_ENV !== "production" || (process.env.NODE_ENV !== "production" || false) && !(process.env.NODE_ENV === "test") && IS_CLIENT ? assign({
6810
+ _hmrPayload,
6811
+ _customProperties: markRaw(/* @__PURE__ */ new Set())
6812
+ }, partialStore) : partialStore);
6813
+ pinia._s.set($id, store);
6814
+ const setupStore = (pinia._a && pinia._a.runWithContext || fallbackRunWithContext)(() => pinia._e.run(() => (scope = effectScope()).run(() => setup({ action }))));
6815
+ for (const key in setupStore) {
6816
+ const prop = setupStore[key];
6817
+ if (isRef(prop) && !isComputed(prop) || isReactive(prop)) {
6818
+ if (process.env.NODE_ENV !== "production" && hot) hotState.value[key] = toRef(setupStore, key);
6819
+ else if (!isOptionsStore) {
6820
+ if (initialState && shouldHydrate(prop)) if (isRef(prop)) prop.value = initialState[key];
6821
+ else mergeReactiveObjects(prop, initialState[key]);
6822
+ pinia.state.value[$id][key] = prop;
6823
+ }
6824
+ /* istanbul ignore else */
6825
+ if (process.env.NODE_ENV !== "production") _hmrPayload.state.push(key);
6826
+ } else if (typeof prop === "function") {
6827
+ setupStore[key] = process.env.NODE_ENV !== "production" && hot ? prop : action(prop, key);
6828
+ /* istanbul ignore else */
6829
+ if (process.env.NODE_ENV !== "production") _hmrPayload.actions[key] = prop;
6830
+ optionsForPlugin.actions[key] = prop;
6831
+ } else if (process.env.NODE_ENV !== "production") {
6832
+ if (isComputed(prop)) {
6833
+ _hmrPayload.getters[key] = isOptionsStore ? options.getters[key] : prop;
6834
+ if (IS_CLIENT) (setupStore._getters || (setupStore._getters = markRaw([]))).push(key);
6835
+ }
6836
+ }
6837
+ }
6838
+ /* istanbul ignore if */
6839
+ assign(store, setupStore);
6840
+ assign(toRaw(store), setupStore);
6841
+ Object.defineProperty(store, "$state", {
6842
+ get: () => process.env.NODE_ENV !== "production" && hot ? hotState.value : pinia.state.value[$id],
6843
+ set: (state) => {
6844
+ /* istanbul ignore if */
6845
+ if (process.env.NODE_ENV !== "production" && hot) throw new Error("cannot set hotState");
6846
+ $patch(($state) => {
6847
+ assign($state, state);
6848
+ });
6849
+ }
6850
+ });
6851
+ /* istanbul ignore else */
6852
+ if (process.env.NODE_ENV !== "production") store._hotUpdate = markRaw((newStore) => {
6853
+ store._hotUpdating = true;
6854
+ newStore._hmrPayload.state.forEach((stateKey) => {
6855
+ if (stateKey in store.$state) {
6856
+ const newStateTarget = newStore.$state[stateKey];
6857
+ const oldStateSource = store.$state[stateKey];
6858
+ if (typeof newStateTarget === "object" && isPlainObject(newStateTarget) && isPlainObject(oldStateSource)) patchObject(newStateTarget, oldStateSource);
6859
+ else newStore.$state[stateKey] = oldStateSource;
6860
+ }
6861
+ store[stateKey] = toRef(newStore.$state, stateKey);
6862
+ });
6863
+ Object.keys(store.$state).forEach((stateKey) => {
6864
+ if (!(stateKey in newStore.$state)) delete store[stateKey];
6865
+ });
6866
+ isListening = false;
6867
+ isSyncListening = false;
6868
+ pinia.state.value[$id] = toRef(newStore._hmrPayload, "hotState");
6869
+ isSyncListening = true;
6870
+ nextTick().then(() => {
6871
+ isListening = true;
6872
+ });
6873
+ for (const actionName in newStore._hmrPayload.actions) {
6874
+ const actionFn = newStore[actionName];
6875
+ store[actionName] = action(actionFn, actionName);
6876
+ }
6877
+ for (const getterName in newStore._hmrPayload.getters) {
6878
+ const getter = newStore._hmrPayload.getters[getterName];
6879
+ store[getterName] = isOptionsStore ? computed(() => {
6880
+ setActivePinia(pinia);
6881
+ return getter.call(store, store);
6882
+ }) : getter;
6883
+ }
6884
+ Object.keys(store._hmrPayload.getters).forEach((key) => {
6885
+ if (!(key in newStore._hmrPayload.getters)) delete store[key];
6886
+ });
6887
+ Object.keys(store._hmrPayload.actions).forEach((key) => {
6888
+ if (!(key in newStore._hmrPayload.actions)) delete store[key];
6889
+ });
6890
+ store._hmrPayload = newStore._hmrPayload;
6891
+ store._getters = newStore._getters;
6892
+ store._hotUpdating = false;
6893
+ });
6894
+ if ((process.env.NODE_ENV !== "production" || false) && !(process.env.NODE_ENV === "test") && IS_CLIENT) {
6895
+ const nonEnumerable = {
6896
+ writable: true,
6897
+ configurable: true,
6898
+ enumerable: false
6899
+ };
6900
+ [
6901
+ "_p",
6902
+ "_hmrPayload",
6903
+ "_getters",
6904
+ "_customProperties"
6905
+ ].forEach((p) => {
6906
+ Object.defineProperty(store, p, assign({ value: store[p] }, nonEnumerable));
6907
+ });
6908
+ }
6909
+ pinia._p.forEach((extender) => {
6910
+ /* istanbul ignore else */
6911
+ if ((process.env.NODE_ENV !== "production" || false) && !(process.env.NODE_ENV === "test") && IS_CLIENT) {
6912
+ const extensions = scope.run(() => extender({
6913
+ store,
6914
+ app: pinia._a,
6915
+ pinia,
6916
+ options: optionsForPlugin
6917
+ }));
6918
+ Object.keys(extensions || {}).forEach((key) => store._customProperties.add(key));
6919
+ assign(store, extensions);
6920
+ } else assign(store, scope.run(() => extender({
6921
+ store,
6922
+ app: pinia._a,
6923
+ pinia,
6924
+ options: optionsForPlugin
6925
+ })));
6926
+ });
6927
+ if (process.env.NODE_ENV !== "production" && store.$state && typeof store.$state === "object" && typeof store.$state.constructor === "function" && !store.$state.constructor.toString().includes("[native code]")) console.warn(`[🍍]: The "state" must be a plain object. It cannot be
6928
+ state: () => new MyClass()
6929
+ Found in store "${store.$id}".`);
6930
+ if (initialState && isOptionsStore && options.hydrate) options.hydrate(store.$state, initialState);
6931
+ isListening = true;
6932
+ isSyncListening = true;
6933
+ return store;
6934
+ }
6935
+ /*! #__NO_SIDE_EFFECTS__ */
6936
+ function defineStore(id, setup, setupOptions) {
6937
+ let options;
6938
+ const isSetupStore = typeof setup === "function";
6939
+ options = isSetupStore ? setupOptions : setup;
6940
+ function useStore(pinia, hot) {
6941
+ const hasContext = hasInjectionContext();
6942
+ pinia = (process.env.NODE_ENV === "test" && activePinia && activePinia._testing ? null : pinia) || (hasContext ? inject(piniaSymbol, null) : null);
6943
+ if (pinia) setActivePinia(pinia);
6944
+ if (process.env.NODE_ENV !== "production" && !activePinia) throw new Error("[🍍]: \"getActivePinia()\" was called but there was no active Pinia. Are you trying to use a store before calling \"app.use(pinia)\"?\nSee https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.\nThis will fail in production.");
6945
+ pinia = activePinia;
6946
+ if (!pinia._s.has(id)) {
6947
+ if (isSetupStore) createSetupStore(id, setup, options, pinia);
6948
+ else createOptionsStore(id, options, pinia);
6949
+ /* istanbul ignore else */
6950
+ if (process.env.NODE_ENV !== "production") useStore._pinia = pinia;
6951
+ }
6952
+ const store = pinia._s.get(id);
6953
+ if (process.env.NODE_ENV !== "production" && hot) {
6954
+ const hotId = "__hot:" + id;
6955
+ const newStore = isSetupStore ? createSetupStore(hotId, setup, options, pinia, true) : createOptionsStore(hotId, assign({}, options), pinia, true);
6956
+ hot._hotUpdate(newStore);
6957
+ delete pinia.state.value[hotId];
6958
+ pinia._s.delete(hotId);
6959
+ }
6960
+ if (process.env.NODE_ENV !== "production" && IS_CLIENT) {
6961
+ const currentInstance = getCurrentInstance();
6962
+ if (currentInstance && currentInstance.proxy && !hot) {
6963
+ const vm = currentInstance.proxy;
6964
+ const cache = "_pStores" in vm ? vm._pStores : vm._pStores = {};
6965
+ cache[id] = store;
6966
+ }
6967
+ }
6968
+ return store;
6969
+ }
6970
+ useStore.$id = id;
6971
+ return useStore;
6972
+ }
6973
+ //#endregion
6974
+ //#region compositions/overlay/useOverlayStack.ts
6975
+ /**
6976
+ * @description overlay stack manager — unified z-index and ESC handling for all popups
6977
+ * @author kine-design
6978
+ * @date 2026/5/22 00:00
6979
+ * @version v1.0.0
6980
+ *
6981
+ * 江湖的业务千篇一律,复杂的代码好几百行。
6982
+ */
6983
+ var Z_INDEX_BASE = 100;
6984
+ var idCounter = 0;
6985
+ var generateId = (type) => `overlay-${type}-${++idCounter}`;
6986
+ var useOverlayStackStore = defineStore("overlayStack", () => {
6987
+ const overlayStack = ref([]);
6988
+ const isEmpty = computed(() => overlayStack.value.length === 0);
6989
+ const topItem = computed(() => overlayStack.value.length > 0 ? overlayStack.value[overlayStack.value.length - 1] : void 0);
6990
+ const push = (item) => {
6991
+ const zIndex = overlayStack.value.length + Z_INDEX_BASE;
6992
+ const entry = {
6993
+ ...item,
6994
+ zIndex
6995
+ };
6996
+ overlayStack.value.push(entry);
6997
+ return entry;
6998
+ };
6999
+ const pop = () => {
7000
+ const item = overlayStack.value.pop();
7001
+ if (item) item.close();
7002
+ return item;
7003
+ };
7004
+ const remove = (id) => {
7005
+ const index = overlayStack.value.findIndex((item) => item.id === id);
7006
+ if (index !== -1) {
7007
+ overlayStack.value.splice(index, 1);
7008
+ recalculateZIndices();
7009
+ }
7010
+ };
7011
+ const recalculateZIndices = () => {
7012
+ overlayStack.value.forEach((item, index) => {
7013
+ item.zIndex = index + Z_INDEX_BASE;
7014
+ });
7015
+ };
7016
+ const handleEsc = (e) => {
7017
+ if (e.key === "Escape" && !isEmpty.value) pop();
7018
+ };
7019
+ let listenerAttached = false;
7020
+ const attachEscListener = () => {
7021
+ if (!listenerAttached) {
7022
+ document.addEventListener("keydown", handleEsc);
7023
+ listenerAttached = true;
7024
+ }
7025
+ };
7026
+ const detachEscListener = () => {
7027
+ if (listenerAttached) {
7028
+ document.removeEventListener("keydown", handleEsc);
7029
+ listenerAttached = false;
7030
+ }
7031
+ };
7032
+ return {
7033
+ overlayStack,
7034
+ isEmpty,
7035
+ topItem,
7036
+ push,
7037
+ pop,
7038
+ remove,
7039
+ attachEscListener,
7040
+ detachEscListener
7041
+ };
7042
+ });
7043
+ function useOverlayStack() {
7044
+ const store = useOverlayStackStore();
7045
+ onMounted(() => {
7046
+ store.attachEscListener();
7047
+ });
7048
+ onBeforeUnmount(() => {
7049
+ store.detachEscListener();
7050
+ });
7051
+ return store;
7052
+ }
7053
+ function useOverlayItem(type) {
7054
+ const store = useOverlayStackStore();
7055
+ let itemId;
7056
+ const register = (closeFn) => {
7057
+ const id = generateId(type);
7058
+ const entry = store.push({
7059
+ id,
7060
+ type,
7061
+ close: closeFn
7062
+ });
7063
+ itemId = entry.id;
7064
+ return entry;
7065
+ };
7066
+ const unregister = () => {
7067
+ if (itemId) {
7068
+ store.remove(itemId);
7069
+ itemId = void 0;
7070
+ }
7071
+ };
7072
+ const currentZIndex = computed(() => {
7073
+ if (!itemId) return void 0;
7074
+ return store.overlayStack.find((i) => i.id === itemId)?.zIndex;
7075
+ });
7076
+ onBeforeUnmount(() => {
7077
+ unregister();
7078
+ });
7079
+ return {
7080
+ register,
7081
+ unregister,
7082
+ currentZIndex
7083
+ };
7084
+ }
7085
+ //#endregion
6323
7086
  //#region locale/zh.ts
6324
7087
  var zh = {
6325
7088
  common: {
@@ -6776,4 +7539,4 @@ function getActiveLocaleMessages() {
6776
7539
  return activeLocaleMessages;
6777
7540
  }
6778
7541
  //#endregion
6779
- export { AffixCore, AlertCore, AnchorCore, AutoCompleteCore, AvatarCore, BackTopCore, BadgeCore, BorderCore, BreadcrumbCore, ButtonCore, CardCore, CarouselCore, CascaderCore, CheckboxCore, CollapseCore, ConfirmCore, DEFAULT_LOCALE, DEFAULT_MENU_CONFIG, DEFAULT_TREE_CONFIG, DarkModeCore, DatePickerCore, DescriptionsCore, DialogCore, DividerCore, DrawerCore, DropdownCore, EmptyCore, FormCore, GridCore, ImageCore, InputCore, InputNumberCore, KINE_LOCALE_KEY, LiCore, ListCore, LoadingCore, MenuCore, MessageCore, MessagePopoverCore, NotificationCore, PaginationCore, PopoverCore, ProgressCore, RadioCore, RateCore, ResultCore, SelectCore, SkeletonCore, SliderCore, SpaceCore, StepsCore, SwitchCore, TableColumnCore, TableCore, TabsCore, TagCore, TimelineCore, TooltipCore, TransferCore, Tree, TreeCore, VirtualListCore, createRadioId, en, fixKey, generateTimeColumn, getActiveLocaleMessages, getNewModelValue, initChecked, locales, setActiveLocaleMessages, toDayjs, treeNodeProps, props as treeProps, useDatePicker, useLocale, useMessageQueue, useNotificationQueue, usePagination, useTable, useTree, zh };
7542
+ export { AffixCore, AlertCore, AnchorCore, AutoCompleteCore, AvatarCore, BackTopCore, BadgeCore, BorderCore, BreadcrumbCore, ButtonCore, CardCore, CarouselCore, CascaderCore, CheckboxCore, CollapseCore, ConfirmCore, DEFAULT_LOCALE, DEFAULT_MENU_CONFIG, DEFAULT_TREE_CONFIG, DarkModeCore, DatePickerCore, DescriptionsCore, DialogCore, DividerCore, DrawerCore, DropdownCore, EmptyCore, FormCore, GridCore, ImageCore, InputCore, InputNumberCore, KINE_LOCALE_KEY, LiCore, ListCore, LoadingCore, MenuCore, MessageCore, MessagePopoverCore, NotificationCore, PaginationCore, PopoverCore, ProgressCore, RadioCore, RateCore, ResultCore, SelectCore, SkeletonCore, SliderCore, SpaceCore, StepsCore, SwitchCore, TableColumnCore, TableCore, TabsCore, TagCore, TimelineCore, TooltipCore, TransferCore, Tree, TreeCore, VirtualListCore, createRadioId, en, fixKey, generateTimeColumn, getActiveLocaleMessages, getNewModelValue, initChecked, locales, setActiveLocaleMessages, toDayjs, treeNodeProps, props as treeProps, useDatePicker, useLocale, useMessageQueue, useNotificationQueue, useOverlayItem, useOverlayStack, useOverlayStackStore, usePagination, useTable, useTree, zh };