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

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 (88) hide show
  1. package/.vlaude/last-session-id +1 -1
  2. package/components/base/autoComplete/api.ts +1 -1
  3. package/components/base/cascader/api.ts +1 -1
  4. package/components/base/datePicker/__tests__/useDatePicker.test.ts +8 -17
  5. package/components/base/datePicker/api.ts +1 -1
  6. package/components/base/datePicker/index.ts +1 -1
  7. package/components/base/datePicker/useDatePicker.ts +1 -18
  8. package/components/base/empty/api.ts +1 -1
  9. package/components/base/select/api.ts +1 -1
  10. package/components/base/timePicker/__tests__/useTimePicker.test.ts +5 -4
  11. package/components/base/timePicker/api.ts +1 -1
  12. package/components/base/timePicker/useTimePicker.ts +1 -1
  13. package/components/base/tooltip/api.ts +2 -3
  14. package/components/base/tooltip/index.ts +2 -3
  15. package/components/base/tooltip/props.d.ts +6 -12
  16. package/components/base/tooltip/useTooltip.ts +56 -175
  17. package/components/base/transfer/api.ts +2 -2
  18. package/components/message/confirm/api.ts +2 -2
  19. package/compositions/common/useLocale.ts +53 -0
  20. package/dist/components/base/datePicker/index.d.ts +1 -1
  21. package/dist/components/base/datePicker/useDatePicker.d.ts +0 -7
  22. package/dist/components/base/tooltip/index.d.ts +0 -1
  23. package/dist/components/base/tooltip/useTooltip.d.ts +17 -20
  24. package/dist/compositions/common/useLocale.d.ts +14 -0
  25. package/dist/core.js +498 -851
  26. package/dist/index.d.ts +2 -1
  27. package/dist/locale/en.d.ts +3 -0
  28. package/dist/locale/index.d.ts +9 -0
  29. package/dist/locale/types.d.ts +222 -0
  30. package/dist/locale/zh.d.ts +3 -0
  31. package/index.ts +9 -1
  32. package/locale/.vlaude/last-session-id +1 -0
  33. package/locale/en.ts +187 -0
  34. package/locale/index.ts +29 -0
  35. package/locale/types.ts +214 -0
  36. package/locale/zh.ts +190 -0
  37. package/package.json +19 -32
  38. package/.vlaude/session-switch.signal +0 -1
  39. package/compositions/commandPalette/index.ts +0 -11
  40. package/compositions/commandPalette/types.ts +0 -29
  41. package/compositions/commandPalette/useCommandPalette.ts +0 -135
  42. package/compositions/contextMenu/index.ts +0 -10
  43. package/compositions/contextMenu/types.ts +0 -21
  44. package/compositions/contextMenu/useContextMenu.ts +0 -101
  45. package/compositions/editor/index.ts +0 -18
  46. package/compositions/editor/types.ts +0 -147
  47. package/compositions/editor/useEditor.ts +0 -224
  48. package/compositions/index.ts +0 -15
  49. package/compositions/overlay/index.ts +0 -14
  50. package/compositions/overlay/useOverlayStack.ts +0 -146
  51. package/compositions/peekView/index.ts +0 -10
  52. package/compositions/peekView/usePeekView.ts +0 -99
  53. package/compositions/theme/index.ts +0 -17
  54. package/compositions/theme/presets/compact.ts +0 -117
  55. package/compositions/theme/presets/dark.ts +0 -113
  56. package/compositions/theme/presets/index.ts +0 -11
  57. package/compositions/theme/presets/light.ts +0 -113
  58. package/compositions/theme/types.ts +0 -46
  59. package/compositions/theme/useTheme.ts +0 -269
  60. package/compositions/toast/index.ts +0 -10
  61. package/compositions/toast/useToast.ts +0 -176
  62. package/compositions/tooltip/index.ts +0 -9
  63. package/compositions/tooltip/useTooltip.ts +0 -10
  64. package/dist/compositions/commandPalette/index.d.ts +0 -11
  65. package/dist/compositions/commandPalette/types.d.ts +0 -20
  66. package/dist/compositions/commandPalette/useCommandPalette.d.ts +0 -32
  67. package/dist/compositions/contextMenu/index.d.ts +0 -10
  68. package/dist/compositions/contextMenu/types.d.ts +0 -12
  69. package/dist/compositions/contextMenu/useContextMenu.d.ts +0 -52
  70. package/dist/compositions/editor/index.d.ts +0 -10
  71. package/dist/compositions/editor/types.d.ts +0 -132
  72. package/dist/compositions/editor/useEditor.d.ts +0 -13
  73. package/dist/compositions/index.d.ts +0 -15
  74. package/dist/compositions/overlay/index.d.ts +0 -10
  75. package/dist/compositions/overlay/useOverlayStack.d.ts +0 -188
  76. package/dist/compositions/peekView/index.d.ts +0 -10
  77. package/dist/compositions/peekView/usePeekView.d.ts +0 -16
  78. package/dist/compositions/theme/index.d.ts +0 -11
  79. package/dist/compositions/theme/presets/compact.d.ts +0 -6
  80. package/dist/compositions/theme/presets/dark.d.ts +0 -2
  81. package/dist/compositions/theme/presets/index.d.ts +0 -11
  82. package/dist/compositions/theme/presets/light.d.ts +0 -2
  83. package/dist/compositions/theme/types.d.ts +0 -41
  84. package/dist/compositions/theme/useTheme.d.ts +0 -167
  85. package/dist/compositions/toast/index.d.ts +0 -10
  86. package/dist/compositions/toast/useToast.d.ts +0 -71
  87. package/dist/compositions/tooltip/index.d.ts +0 -9
  88. package/dist/compositions/tooltip/useTooltip.d.ts +0 -10
package/dist/core.js CHANGED
@@ -1,6 +1,6 @@
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";
1
+ import { computed, createVNode, inject, nextTick, onBeforeUnmount, onMounted, onUnmounted, provide, ref, shallowRef, toRef, triggerRef, watch } from "vue";
2
2
  import * as _interactjsModule from "interactjs";
3
- import { arrow, autoUpdate, computePosition, flip, offset, shift } from "@floating-ui/dom";
3
+ import { arrow, autoUpdate, computePosition } from "@floating-ui/dom";
4
4
  import dayjs from "dayjs";
5
5
  //#endregion
6
6
  //#region components/base/avatar/index.ts
@@ -245,7 +245,7 @@ var props$47 = {
245
245
  },
246
246
  placeholder: {
247
247
  type: String,
248
- default: "请选择..."
248
+ default: void 0
249
249
  },
250
250
  toMatch: {
251
251
  type: Function,
@@ -1895,10 +1895,6 @@ var props$36 = {
1895
1895
  type: String,
1896
1896
  default: "top"
1897
1897
  },
1898
- delay: {
1899
- type: Number,
1900
- default: 300
1901
- },
1902
1898
  disabled: {
1903
1899
  type: Boolean,
1904
1900
  default: false
@@ -1911,158 +1907,78 @@ var props$36 = {
1911
1907
  //#endregion
1912
1908
  //#region components/base/tooltip/useTooltip.ts
1913
1909
  /**
1914
- * @description tooltip composable manages show/hide with delay, positioning via usePopper, singleton, scroll/interaction dismissal
1910
+ * @description tooltip composable,管理 hover 显示/隐藏及定位
1915
1911
  * @author 阿怪
1916
1912
  * @date 2026/2/25
1917
- * @version v2.0.0
1913
+ * @version v1.0.0
1918
1914
  *
1919
1915
  * 江湖的业务千篇一律,复杂的代码好几百行。
1920
1916
  */
1921
- var HIDE_DELAY = 100;
1922
- /** Singleton: only one tooltip visible at a time */
1923
- var activeHide = null;
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
+ }
1924
1950
  function useTooltip(props) {
1925
1951
  const visible = ref(false);
1926
- const positionData = ref(null);
1952
+ const tooltipStyle = ref({});
1927
1953
  const triggerRef = ref(null);
1928
1954
  const tooltipRef = ref(null);
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 = () => {
1955
+ const show = async () => {
1953
1956
  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 = () => {
1969
1957
  visible.value = true;
1970
- activeHide = hideImmediate;
1971
- addInteractionListeners();
1972
- addScrollListeners();
1973
- };
1974
- /** Initialize popper positioning — called after tooltip DOM is mounted */
1975
- const initPopper = () => {
1958
+ await nextTick();
1976
1959
  if (!triggerRef.value || !tooltipRef.value) return;
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;
1960
+ tooltipStyle.value = calcPosition(triggerRef.value.getBoundingClientRect(), tooltipRef.value, props.placement);
1993
1961
  };
1994
- /** Hide tooltip with a short delay (allows cursor to move between trigger and tooltip) */
1995
1962
  const hide = () => {
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
- }
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);
1963
+ visible.value = false;
1964
+ tooltipStyle.value = {};
2042
1965
  };
2043
- onBeforeUnmount(() => {
2044
- hideImmediate();
2045
- });
2046
1966
  return {
2047
1967
  visible,
2048
- positionData,
1968
+ tooltipStyle,
2049
1969
  triggerRef,
2050
1970
  tooltipRef,
2051
- arrowRef,
2052
- tooltipId,
2053
1971
  show,
2054
- hide,
2055
- hideImmediate,
2056
- initPopper
1972
+ hide
2057
1973
  };
2058
1974
  }
2059
1975
  //#endregion
2060
1976
  //#region components/base/tooltip/index.ts
2061
1977
  /**
2062
- * @description tooltip core barrel export
1978
+ * @description tooltip core 导出
2063
1979
  * @author 阿怪
2064
1980
  * @date 2026/2/25
2065
- * @version v2.0.0
1981
+ * @version v1.0.0
2066
1982
  *
2067
1983
  * 江湖的业务千篇一律,复杂的代码好几百行。
2068
1984
  */
@@ -2244,11 +2160,11 @@ var ConfirmCore = { props: {
2244
2160
  },
2245
2161
  confirmText: {
2246
2162
  type: String,
2247
- default: "确定"
2163
+ default: void 0
2248
2164
  },
2249
2165
  cancelText: {
2250
2166
  type: String,
2251
- default: "取消"
2167
+ default: void 0
2252
2168
  },
2253
2169
  title: {
2254
2170
  type: String,
@@ -2787,7 +2703,7 @@ var props$25 = {
2787
2703
  },
2788
2704
  placeholder: {
2789
2705
  type: String,
2790
- default: "请选择日期..."
2706
+ default: void 0
2791
2707
  },
2792
2708
  format: {
2793
2709
  type: String,
@@ -2831,52 +2747,6 @@ var props$25 = {
2831
2747
  * 从 lib/useDatePicker 移植,去掉 usePopover / useBorder 依赖。
2832
2748
  * 纯日历数据管理,不含任何 popover 逻辑。
2833
2749
  */
2834
- /** 基础星期头(汉字显示) */
2835
- var BASE_WEEK_NAME = [
2836
- {
2837
- day: "日",
2838
- isCurrentMonth: true
2839
- },
2840
- {
2841
- day: "壹",
2842
- isCurrentMonth: true
2843
- },
2844
- {
2845
- day: "贰",
2846
- isCurrentMonth: true
2847
- },
2848
- {
2849
- day: "叁",
2850
- isCurrentMonth: true
2851
- },
2852
- {
2853
- day: "肆",
2854
- isCurrentMonth: true
2855
- },
2856
- {
2857
- day: "伍",
2858
- isCurrentMonth: true
2859
- },
2860
- {
2861
- day: "陆",
2862
- isCurrentMonth: true
2863
- }
2864
- ];
2865
- /** 月份名称 */
2866
- var BASE_MONTH_NAME = [
2867
- "1月",
2868
- "2月",
2869
- "3月",
2870
- "4月",
2871
- "5月",
2872
- "6月",
2873
- "7月",
2874
- "8月",
2875
- "9月",
2876
- "10月",
2877
- "11月",
2878
- "12月"
2879
- ];
2880
2750
  /**
2881
2751
  * 将 string | Date 转换为 dayjs 对象。
2882
2752
  * headless 组件需要用此函数更新 currentRef。
@@ -2939,7 +2809,7 @@ function useDatePicker(props) {
2939
2809
  */
2940
2810
  const updateDateRef = (value) => {
2941
2811
  if (isEmpty(value)) {
2942
- displayValue.value = props.placeholder ?? "请选择日期...";
2812
+ displayValue.value = "";
2943
2813
  needPlaceholder = true;
2944
2814
  } else {
2945
2815
  needPlaceholder = false;
@@ -5002,7 +4872,7 @@ var BadgeCore = { props: {
5002
4872
  var EmptyCore = { props: {
5003
4873
  description: {
5004
4874
  type: String,
5005
- default: "暂无数据"
4875
+ default: void 0
5006
4876
  },
5007
4877
  image: {
5008
4878
  type: String,
@@ -5046,7 +4916,7 @@ var props$10 = {
5046
4916
  },
5047
4917
  placeholder: {
5048
4918
  type: String,
5049
- default: "请输入..."
4919
+ default: void 0
5050
4920
  },
5051
4921
  disabled: {
5052
4922
  type: Boolean,
@@ -5574,7 +5444,7 @@ var props$6 = {
5574
5444
  },
5575
5445
  placeholder: {
5576
5446
  type: String,
5577
- default: "请选择"
5447
+ default: void 0
5578
5448
  },
5579
5449
  disabled: {
5580
5450
  type: Boolean,
@@ -5864,7 +5734,7 @@ var props$5 = {
5864
5734
  },
5865
5735
  titles: {
5866
5736
  type: Array,
5867
- default: () => ["源列表", "目标列表"]
5737
+ default: void 0
5868
5738
  },
5869
5739
  filterable: {
5870
5740
  type: Boolean,
@@ -5872,7 +5742,7 @@ var props$5 = {
5872
5742
  },
5873
5743
  filterPlaceholder: {
5874
5744
  type: String,
5875
- default: "请输入搜索内容"
5745
+ default: void 0
5876
5746
  }
5877
5747
  };
5878
5748
  //#endregion
@@ -6450,683 +6320,460 @@ var AnchorCore = {
6450
6320
  useAnchor
6451
6321
  };
6452
6322
  //#endregion
6453
- //#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
6454
- /*!
6455
- * pinia v3.0.4
6456
- * (c) 2025 Eduardo San Martin Morote
6457
- * @license MIT
6458
- */
6459
- var IS_CLIENT = typeof window !== "undefined";
6460
- /**
6461
- * setActivePinia must be called to handle SSR at the top of functions like
6462
- * `fetch`, `setup`, `serverPrefetch` and others
6463
- */
6464
- var activePinia;
6465
- /**
6466
- * Sets or unsets the active pinia. Used in SSR and internally when calling
6467
- * actions and getters
6468
- *
6469
- * @param pinia - Pinia instance
6470
- */
6471
- var setActivePinia = (pinia) => activePinia = pinia;
6472
- process.env.NODE_ENV;
6473
- var piniaSymbol = process.env.NODE_ENV !== "production" ? Symbol("pinia") : Symbol();
6474
- function isPlainObject(o) {
6475
- return o && typeof o === "object" && Object.prototype.toString.call(o) === "[object Object]" && typeof o.toJSON !== "function";
6476
- }
6477
- /**
6478
- * Possible types for SubscriptionCallback
6479
- */
6480
- var MutationType;
6481
- (function(MutationType) {
6482
- /**
6483
- * Direct mutation of the state:
6484
- *
6485
- * - `store.name = 'new name'`
6486
- * - `store.$state.name = 'new name'`
6487
- * - `store.list.push('new item')`
6488
- */
6489
- MutationType["direct"] = "direct";
6490
- /**
6491
- * Mutated the state with `$patch` and an object
6492
- *
6493
- * - `store.$patch({ name: 'newName' })`
6494
- */
6495
- MutationType["patchObject"] = "patch object";
6496
- /**
6497
- * Mutated the state with `$patch` and a function
6498
- *
6499
- * - `store.$patch(state => state.name = 'newName')`
6500
- */
6501
- MutationType["patchFunction"] = "patch function";
6502
- })(MutationType || (MutationType = {}));
6503
- 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 };
6504
- function bom(blob, { autoBom = false } = {}) {
6505
- 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 });
6506
- return blob;
6507
- }
6508
- function download(url, name, opts) {
6509
- const xhr = new XMLHttpRequest();
6510
- xhr.open("GET", url);
6511
- xhr.responseType = "blob";
6512
- xhr.onload = function() {
6513
- saveAs(xhr.response, name, opts);
6514
- };
6515
- xhr.onerror = function() {
6516
- console.error("could not download file");
6517
- };
6518
- xhr.send();
6519
- }
6520
- function corsEnabled(url) {
6521
- const xhr = new XMLHttpRequest();
6522
- xhr.open("HEAD", url, false);
6523
- try {
6524
- xhr.send();
6525
- } catch (e) {}
6526
- return xhr.status >= 200 && xhr.status <= 299;
6527
- }
6528
- function click(node) {
6529
- try {
6530
- node.dispatchEvent(new MouseEvent("click"));
6531
- } catch (e) {
6532
- const evt = new MouseEvent("click", {
6533
- bubbles: true,
6534
- cancelable: true,
6535
- view: window,
6536
- detail: 0,
6537
- screenX: 80,
6538
- screenY: 20,
6539
- clientX: 80,
6540
- clientY: 20,
6541
- ctrlKey: false,
6542
- altKey: false,
6543
- shiftKey: false,
6544
- metaKey: false,
6545
- button: 0,
6546
- relatedTarget: null
6547
- });
6548
- node.dispatchEvent(evt);
6549
- }
6550
- }
6551
- var _navigator = typeof navigator === "object" ? navigator : { userAgent: "" };
6552
- var isMacOSWebView = /Macintosh/.test(_navigator.userAgent) && /AppleWebKit/.test(_navigator.userAgent) && !/Safari/.test(_navigator.userAgent);
6553
- var saveAs = !IS_CLIENT ? () => {} : typeof HTMLAnchorElement !== "undefined" && "download" in HTMLAnchorElement.prototype && !isMacOSWebView ? downloadSaveAs : "msSaveOrOpenBlob" in _navigator ? msSaveAs : fileSaverSaveAs;
6554
- function downloadSaveAs(blob, name = "download", opts) {
6555
- const a = document.createElement("a");
6556
- a.download = name;
6557
- a.rel = "noopener";
6558
- if (typeof blob === "string") {
6559
- a.href = blob;
6560
- if (a.origin !== location.origin) if (corsEnabled(a.href)) download(blob, name, opts);
6561
- else {
6562
- a.target = "_blank";
6563
- click(a);
6564
- }
6565
- else click(a);
6566
- } else {
6567
- a.href = URL.createObjectURL(blob);
6568
- setTimeout(function() {
6569
- URL.revokeObjectURL(a.href);
6570
- }, 4e4);
6571
- setTimeout(function() {
6572
- click(a);
6573
- }, 0);
6574
- }
6575
- }
6576
- function msSaveAs(blob, name = "download", opts) {
6577
- if (typeof blob === "string") if (corsEnabled(blob)) download(blob, name, opts);
6578
- else {
6579
- const a = document.createElement("a");
6580
- a.href = blob;
6581
- a.target = "_blank";
6582
- setTimeout(function() {
6583
- click(a);
6584
- });
6323
+ //#region locale/zh.ts
6324
+ var zh = {
6325
+ common: {
6326
+ confirm: "确定",
6327
+ cancel: "取消",
6328
+ close: "关闭",
6329
+ search: "搜索",
6330
+ reset: "重置",
6331
+ all: "全部",
6332
+ noData: "暂无数据",
6333
+ loading: "加载中...",
6334
+ save: "保存"
6335
+ },
6336
+ pagination: {
6337
+ totalPrefix: "共 ",
6338
+ totalSuffix: " 条"
6339
+ },
6340
+ datePicker: {
6341
+ placeholder: "请选择日期...",
6342
+ year: (year) => `${year}年`,
6343
+ month: (month) => `${month}月`,
6344
+ hour: "时",
6345
+ minute: "",
6346
+ second: "秒",
6347
+ confirm: "确定",
6348
+ weekNames: [
6349
+ "日",
6350
+ "一",
6351
+ "二",
6352
+ "三",
6353
+ "四",
6354
+ "五",
6355
+ "六"
6356
+ ],
6357
+ monthNames: [
6358
+ "1月",
6359
+ "2月",
6360
+ "3月",
6361
+ "4月",
6362
+ "5月",
6363
+ "6月",
6364
+ "7月",
6365
+ "8月",
6366
+ "9月",
6367
+ "10月",
6368
+ "11月",
6369
+ "12月"
6370
+ ]
6371
+ },
6372
+ timePicker: {
6373
+ placeholder: "请选择时间...",
6374
+ hour: "时",
6375
+ minute: "分",
6376
+ second: "秒"
6377
+ },
6378
+ select: {
6379
+ placeholder: "请选择...",
6380
+ clear: "清空",
6381
+ noData: "暂无数据",
6382
+ loading: "加载中..."
6383
+ },
6384
+ autoComplete: {
6385
+ placeholder: "请输入...",
6386
+ loading: "加载中",
6387
+ clear: "清空",
6388
+ noData: "暂无建议"
6389
+ },
6390
+ cascader: {
6391
+ placeholder: "请选择",
6392
+ noMatch: "暂无匹配数据"
6393
+ },
6394
+ image: {
6395
+ loadError: "加载失败",
6396
+ zoomOut: "缩小",
6397
+ zoomIn: "放大",
6398
+ rotate: "旋转",
6399
+ close: "关闭"
6400
+ },
6401
+ transfer: {
6402
+ sourceTitle: "源列表",
6403
+ targetTitle: "目标列表",
6404
+ noData: "暂无数据",
6405
+ filterPlaceholder: "请输入搜索内容"
6406
+ },
6407
+ empty: { description: "暂无数据" },
6408
+ a11y: {
6409
+ rate: "评分",
6410
+ tagClose: "关闭",
6411
+ anchorNav: "锚点导航",
6412
+ backTop: "回到顶部",
6413
+ carouselPrev: "上一张",
6414
+ carouselNext: "下一张",
6415
+ toLightMode: "切换到亮色模式",
6416
+ toDarkMode: "切换到暗色模式",
6417
+ expandSider: "展开侧边栏",
6418
+ collapseSider: "折叠侧边栏"
6419
+ },
6420
+ upload: {
6421
+ trigger: "点击或拖拽文件到此处上传",
6422
+ triggerSimple: "点击上传文件",
6423
+ oversize: (name, max) => max ? `文件 "${name}" 超过大小限制(最大 ${max})` : `文件 "${name}" 超过大小限制`,
6424
+ uploadFailed: "上传失败",
6425
+ statusWaiting: "等待中",
6426
+ statusUploading: "上传中",
6427
+ statusDone: "已完成",
6428
+ statusFailed: "上传失败"
6429
+ },
6430
+ searchTable: {
6431
+ search: "搜索",
6432
+ reset: "重置"
6433
+ },
6434
+ editableTable: {
6435
+ summary: "合计",
6436
+ addRow: "+ 添加行",
6437
+ addFirstRow: "添加第一行",
6438
+ confirmDelete: "确定删除这一行?",
6439
+ delete: "删除",
6440
+ cancel: "取消",
6441
+ noData: "暂无数据"
6442
+ },
6443
+ formPage: {
6444
+ loading: "加载中...",
6445
+ cancel: "取消",
6446
+ saveDraft: "保存草稿",
6447
+ save: "保存",
6448
+ saving: "保存中...",
6449
+ submit: "提交",
6450
+ submitting: "提交中...",
6451
+ basicInfo: "基本信息",
6452
+ editTitle: (title) => `编辑${title}`,
6453
+ createTitle: (title) => `新建${title}`
6454
+ },
6455
+ approvalDialog: {
6456
+ submitTitle: "提交审批",
6457
+ submitConfirm: "确认提交",
6458
+ approveTitle: "审批通过",
6459
+ approveConfirm: "确认通过",
6460
+ rejectTitle: "驳回申请",
6461
+ rejectConfirm: "确认驳回",
6462
+ rejectPlaceholder: "请输入驳回原因...",
6463
+ remarkPlaceholder: "添加备注(可选)...",
6464
+ required: "* 必填",
6465
+ cancel: "取消",
6466
+ processing: "处理中..."
6467
+ },
6468
+ crudPage: {
6469
+ all: "全部",
6470
+ fieldPlaceholder: (label) => `请输入${label}`
6471
+ },
6472
+ login: {
6473
+ username: "用户名",
6474
+ usernamePlaceholder: "请输入用户名",
6475
+ password: "密码",
6476
+ passwordPlaceholder: "请输入密码",
6477
+ remember: "记住我",
6478
+ login: "登 录",
6479
+ loggingIn: "登录中..."
6480
+ },
6481
+ form: {
6482
+ inputPlaceholder: (label) => `请输入${label}`,
6483
+ selectPlaceholder: (label) => `请选择${label}`
6484
+ },
6485
+ routes: {
6486
+ createSuffix: " - 新建",
6487
+ editSuffix: " - 编辑",
6488
+ detailSuffix: " - 详情"
6489
+ },
6490
+ request: {
6491
+ success: "操作成功",
6492
+ opFailed: "操作失败",
6493
+ failed: "请求失败",
6494
+ failedWithStatus: (status) => `请求失败(${status})`,
6495
+ failedWithMsg: (msg) => `请求失败: ${msg}`,
6496
+ timeout: "请求超时",
6497
+ timeoutRetry: "请求超时,请稍后重试",
6498
+ canceled: "请求已取消",
6499
+ permissionDenied: "权限不足,无法执行此操作",
6500
+ invalidUrl: (url) => `无效的请求地址: ${url}`,
6501
+ decodeFailed: (reason) => `解码失败: ${reason}`,
6502
+ parseFailed: "数据解析失败",
6503
+ networkError: "网络错误",
6504
+ networkException: "网络异常,请检查网络连接",
6505
+ unknownError: (error) => `未知错误: ${error}`,
6506
+ unknown: "发生了未知错误",
6507
+ uploadFailed: "上传失败",
6508
+ uploadCanceled: "上传已取消"
6509
+ },
6510
+ aiChat: {
6511
+ inputPlaceholder: "输入消息…",
6512
+ send: "发送",
6513
+ defaultTitle: (n) => `对话 ${n}`,
6514
+ phaseTyping: "正在输入…",
6515
+ phaseThinking: "思考中…",
6516
+ phaseReplying: "回复中…",
6517
+ phaseSending: "发送中…"
6585
6518
  }
6586
- else navigator.msSaveOrOpenBlob(bom(blob, opts), name);
6587
- }
6588
- function fileSaverSaveAs(blob, name, opts, popup) {
6589
- popup = popup || open("", "_blank");
6590
- if (popup) popup.document.title = popup.document.body.innerText = "downloading...";
6591
- if (typeof blob === "string") return download(blob, name, opts);
6592
- const force = blob.type === "application/octet-stream";
6593
- const isSafari = /constructor/i.test(String(_global.HTMLElement)) || "safari" in _global;
6594
- const isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent);
6595
- if ((isChromeIOS || force && isSafari || isMacOSWebView) && typeof FileReader !== "undefined") {
6596
- const reader = new FileReader();
6597
- reader.onloadend = function() {
6598
- let url = reader.result;
6599
- if (typeof url !== "string") {
6600
- popup = null;
6601
- throw new Error("Wrong reader.result type");
6602
- }
6603
- url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, "data:attachment/file;");
6604
- if (popup) popup.location.href = url;
6605
- else location.assign(url);
6606
- popup = null;
6607
- };
6608
- reader.readAsDataURL(blob);
6609
- } else {
6610
- const url = URL.createObjectURL(blob);
6611
- if (popup) popup.location.assign(url);
6612
- else location.href = url;
6613
- popup = null;
6614
- setTimeout(function() {
6615
- URL.revokeObjectURL(url);
6616
- }, 4e4);
6519
+ };
6520
+ //#endregion
6521
+ //#region locale/en.ts
6522
+ var en = {
6523
+ common: {
6524
+ confirm: "OK",
6525
+ cancel: "Cancel",
6526
+ close: "Close",
6527
+ search: "Search",
6528
+ reset: "Reset",
6529
+ all: "All",
6530
+ noData: "No data",
6531
+ loading: "Loading...",
6532
+ save: "Save"
6533
+ },
6534
+ pagination: {
6535
+ totalPrefix: "",
6536
+ totalSuffix: " items"
6537
+ },
6538
+ datePicker: {
6539
+ placeholder: "Select date...",
6540
+ year: (year) => `${year}`,
6541
+ month: (month) => `${month}`,
6542
+ hour: "Hour",
6543
+ minute: "Min",
6544
+ second: "Sec",
6545
+ confirm: "OK",
6546
+ weekNames: [
6547
+ "Sun",
6548
+ "Mon",
6549
+ "Tue",
6550
+ "Wed",
6551
+ "Thu",
6552
+ "Fri",
6553
+ "Sat"
6554
+ ],
6555
+ monthNames: [
6556
+ "Jan",
6557
+ "Feb",
6558
+ "Mar",
6559
+ "Apr",
6560
+ "May",
6561
+ "Jun",
6562
+ "Jul",
6563
+ "Aug",
6564
+ "Sep",
6565
+ "Oct",
6566
+ "Nov",
6567
+ "Dec"
6568
+ ]
6569
+ },
6570
+ timePicker: {
6571
+ placeholder: "Select time...",
6572
+ hour: "Hour",
6573
+ minute: "Min",
6574
+ second: "Sec"
6575
+ },
6576
+ select: {
6577
+ placeholder: "Select...",
6578
+ clear: "Clear",
6579
+ noData: "No data",
6580
+ loading: "Loading..."
6581
+ },
6582
+ autoComplete: {
6583
+ placeholder: "Enter...",
6584
+ loading: "Loading",
6585
+ clear: "Clear",
6586
+ noData: "No suggestions"
6587
+ },
6588
+ cascader: {
6589
+ placeholder: "Select",
6590
+ noMatch: "No matching data"
6591
+ },
6592
+ image: {
6593
+ loadError: "Load failed",
6594
+ zoomOut: "Zoom out",
6595
+ zoomIn: "Zoom in",
6596
+ rotate: "Rotate",
6597
+ close: "Close"
6598
+ },
6599
+ transfer: {
6600
+ sourceTitle: "Source",
6601
+ targetTitle: "Target",
6602
+ noData: "No data",
6603
+ filterPlaceholder: "Search..."
6604
+ },
6605
+ empty: { description: "No data" },
6606
+ a11y: {
6607
+ rate: "Rating",
6608
+ tagClose: "Close",
6609
+ anchorNav: "Anchor navigation",
6610
+ backTop: "Back to top",
6611
+ carouselPrev: "Previous",
6612
+ carouselNext: "Next",
6613
+ toLightMode: "Switch to light mode",
6614
+ toDarkMode: "Switch to dark mode",
6615
+ expandSider: "Expand sidebar",
6616
+ collapseSider: "Collapse sidebar"
6617
+ },
6618
+ upload: {
6619
+ trigger: "Click or drag file here to upload",
6620
+ triggerSimple: "Click to upload",
6621
+ oversize: (name, max) => max ? `File "${name}" exceeds size limit (max ${max})` : `File "${name}" exceeds size limit`,
6622
+ uploadFailed: "Upload failed",
6623
+ statusWaiting: "Waiting",
6624
+ statusUploading: "Uploading",
6625
+ statusDone: "Done",
6626
+ statusFailed: "Failed"
6627
+ },
6628
+ searchTable: {
6629
+ search: "Search",
6630
+ reset: "Reset"
6631
+ },
6632
+ editableTable: {
6633
+ summary: "Total",
6634
+ addRow: "+ Add row",
6635
+ addFirstRow: "Add first row",
6636
+ confirmDelete: "Delete this row?",
6637
+ delete: "Delete",
6638
+ cancel: "Cancel",
6639
+ noData: "No data"
6640
+ },
6641
+ formPage: {
6642
+ loading: "Loading...",
6643
+ cancel: "Cancel",
6644
+ saveDraft: "Save draft",
6645
+ save: "Save",
6646
+ saving: "Saving...",
6647
+ submit: "Submit",
6648
+ submitting: "Submitting...",
6649
+ basicInfo: "Basic info",
6650
+ editTitle: (title) => `Edit ${title}`,
6651
+ createTitle: (title) => `New ${title}`
6652
+ },
6653
+ approvalDialog: {
6654
+ submitTitle: "Submit for approval",
6655
+ submitConfirm: "Confirm submission",
6656
+ approveTitle: "Approve",
6657
+ approveConfirm: "Confirm approval",
6658
+ rejectTitle: "Reject",
6659
+ rejectConfirm: "Confirm rejection",
6660
+ rejectPlaceholder: "Enter rejection reason...",
6661
+ remarkPlaceholder: "Add remark (optional)...",
6662
+ required: "* Required",
6663
+ cancel: "Cancel",
6664
+ processing: "Processing..."
6665
+ },
6666
+ crudPage: {
6667
+ all: "All",
6668
+ fieldPlaceholder: (label) => `Enter ${label}`
6669
+ },
6670
+ login: {
6671
+ username: "Username",
6672
+ usernamePlaceholder: "Enter username",
6673
+ password: "Password",
6674
+ passwordPlaceholder: "Enter password",
6675
+ remember: "Remember me",
6676
+ login: "Log in",
6677
+ loggingIn: "Logging in..."
6678
+ },
6679
+ form: {
6680
+ inputPlaceholder: (label) => `Enter ${label}`,
6681
+ selectPlaceholder: (label) => `Select ${label}`
6682
+ },
6683
+ routes: {
6684
+ createSuffix: " - New",
6685
+ editSuffix: " - Edit",
6686
+ detailSuffix: " - Details"
6687
+ },
6688
+ request: {
6689
+ success: "Success",
6690
+ opFailed: "Operation failed",
6691
+ failed: "Request failed",
6692
+ failedWithStatus: (status) => `Request failed (${status})`,
6693
+ failedWithMsg: (msg) => `Request failed: ${msg}`,
6694
+ timeout: "Request timed out",
6695
+ timeoutRetry: "Request timed out, please try again",
6696
+ canceled: "Request canceled",
6697
+ permissionDenied: "Permission denied",
6698
+ invalidUrl: (url) => `Invalid request URL: ${url}`,
6699
+ decodeFailed: (reason) => `Decode failed: ${reason}`,
6700
+ parseFailed: "Failed to parse data",
6701
+ networkError: "Network error",
6702
+ networkException: "Network error, please check your connection",
6703
+ unknownError: (error) => `Unknown error: ${error}`,
6704
+ unknown: "An unknown error occurred",
6705
+ uploadFailed: "Upload failed",
6706
+ uploadCanceled: "Upload canceled"
6707
+ },
6708
+ aiChat: {
6709
+ inputPlaceholder: "Type a message…",
6710
+ send: "Send",
6711
+ defaultTitle: (n) => `Chat ${n}`,
6712
+ phaseTyping: "Typing…",
6713
+ phaseThinking: "Thinking…",
6714
+ phaseReplying: "Replying…",
6715
+ phaseSending: "Sending…"
6617
6716
  }
6618
- }
6619
- var { assign: assign$1 } = Object;
6717
+ };
6718
+ //#endregion
6719
+ //#region locale/index.ts
6620
6720
  /**
6621
- * Mutates in place `newState` with `oldState` to _hot update_ it. It will
6622
- * remove any key not existing in `newState` and recursively merge plain
6623
- * objects.
6721
+ * @description kine-design locale entry built-in language packs + types.
6624
6722
  *
6625
- * @param newState - new state object to be patched
6626
- * @param oldState - old state that should be used to patch newState
6627
- * @returns - newState
6628
- */
6629
- function patchObject(newState, oldState) {
6630
- for (const key in oldState) {
6631
- const subPatch = oldState[key];
6632
- if (!(key in newState)) continue;
6633
- const targetValue = newState[key];
6634
- if (isPlainObject(targetValue) && isPlainObject(subPatch) && !isRef(subPatch) && !isReactive(subPatch)) newState[key] = patchObject(targetValue, subPatch);
6635
- else newState[key] = subPatch;
6636
- }
6637
- return newState;
6638
- }
6639
- var noop = () => {};
6640
- function addSubscription(subscriptions, callback, detached, onCleanup = noop) {
6641
- subscriptions.add(callback);
6642
- const removeSubscription = () => {
6643
- subscriptions.delete(callback) && onCleanup();
6644
- };
6645
- if (!detached && getCurrentScope()) onScopeDispose(removeSubscription);
6646
- return removeSubscription;
6647
- }
6648
- function triggerSubscriptions(subscriptions, ...args) {
6649
- subscriptions.forEach((callback) => {
6650
- callback(...args);
6651
- });
6652
- }
6653
- var fallbackRunWithContext = (fn) => fn();
6654
- /**
6655
- * Marks a function as an action for `$onAction`
6656
- * @internal
6657
- */
6658
- var ACTION_MARKER = Symbol();
6659
- /**
6660
- * Action name symbol. Allows to add a name to an action after defining it
6661
- * @internal
6662
- */
6663
- var ACTION_NAME = Symbol();
6664
- function mergeReactiveObjects(target, patchToApply) {
6665
- if (target instanceof Map && patchToApply instanceof Map) patchToApply.forEach((value, key) => target.set(key, value));
6666
- else if (target instanceof Set && patchToApply instanceof Set) patchToApply.forEach(target.add, target);
6667
- for (const key in patchToApply) {
6668
- if (!patchToApply.hasOwnProperty(key)) continue;
6669
- const subPatch = patchToApply[key];
6670
- const targetValue = target[key];
6671
- if (isPlainObject(targetValue) && isPlainObject(subPatch) && target.hasOwnProperty(key) && !isRef(subPatch) && !isReactive(subPatch)) target[key] = mergeReactiveObjects(targetValue, subPatch);
6672
- else target[key] = subPatch;
6673
- }
6674
- return target;
6675
- }
6676
- var skipHydrateSymbol = process.env.NODE_ENV !== "production" ? Symbol("pinia:skipHydration") : Symbol();
6677
- /**
6678
- * Returns whether a value should be hydrated
6723
+ * The library ships only the two general languages (zh / en). To use another
6724
+ * language, build a full dictionary that satisfies `KineLocaleMessages` in the
6725
+ * consuming app and pass it straight to the provider:
6679
6726
  *
6680
- * @param obj - target variable
6681
- * @returns true if `obj` should be hydrated
6727
+ * import type { KineLocaleMessages } from '@kine-design/core';
6728
+ * const bn: KineLocaleMessages = { ...full Bengali dictionary... };
6729
+ * // <KConfigProvider :locale="bn"> ... </KConfigProvider>
6730
+ *
6731
+ * TypeScript enforces full key coverage, so a partial/forgotten key is a
6732
+ * compile error in the app — the same guarantee the built-in packs enjoy.
6733
+ * @author kine-design
6734
+ * @version v1.0.0
6682
6735
  */
6683
- function shouldHydrate(obj) {
6684
- return !isPlainObject(obj) || !Object.prototype.hasOwnProperty.call(obj, skipHydrateSymbol);
6685
- }
6686
- var { assign } = Object;
6687
- function isComputed(o) {
6688
- return !!(isRef(o) && o.effect);
6689
- }
6690
- function createOptionsStore(id, options, pinia, hot) {
6691
- const { state, actions, getters } = options;
6692
- const initialState = pinia.state.value[id];
6693
- let store;
6694
- function setup() {
6695
- if (!initialState && (!(process.env.NODE_ENV !== "production") || !hot))
6696
- /* istanbul ignore if */
6697
- pinia.state.value[id] = state ? state() : {};
6698
- const localState = process.env.NODE_ENV !== "production" && hot ? toRefs(ref(state ? state() : {}).value) : toRefs(pinia.state.value[id]);
6699
- return assign(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name) => {
6700
- 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}".`);
6701
- computedGetters[name] = markRaw(computed(() => {
6702
- setActivePinia(pinia);
6703
- const store = pinia._s.get(id);
6704
- return getters[name].call(store, store);
6705
- }));
6706
- return computedGetters;
6707
- }, {}));
6708
- }
6709
- store = createSetupStore(id, setup, options, pinia, hot, true);
6710
- return store;
6711
- }
6712
- function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
6713
- let scope;
6714
- const optionsForPlugin = assign({ actions: {} }, options);
6715
- /* istanbul ignore if */
6716
- if (process.env.NODE_ENV !== "production" && !pinia._e.active) throw new Error("Pinia destroyed");
6717
- const $subscribeOptions = { deep: true };
6718
- /* istanbul ignore else */
6719
- if (process.env.NODE_ENV !== "production") $subscribeOptions.onTrigger = (event) => {
6720
- /* istanbul ignore else */
6721
- if (isListening) debuggerEvents = event;
6722
- else if (isListening == false && !store._hotUpdating)
6723
- /* istanbul ignore else */
6724
- if (Array.isArray(debuggerEvents)) debuggerEvents.push(event);
6725
- else console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug.");
6726
- };
6727
- let isListening;
6728
- let isSyncListening;
6729
- let subscriptions = /* @__PURE__ */ new Set();
6730
- let actionSubscriptions = /* @__PURE__ */ new Set();
6731
- let debuggerEvents;
6732
- const initialState = pinia.state.value[$id];
6733
- if (!isOptionsStore && !initialState && (!(process.env.NODE_ENV !== "production") || !hot))
6734
- /* istanbul ignore if */
6735
- pinia.state.value[$id] = {};
6736
- const hotState = ref({});
6737
- let activeListener;
6738
- function $patch(partialStateOrMutator) {
6739
- let subscriptionMutation;
6740
- isListening = isSyncListening = false;
6741
- /* istanbul ignore else */
6742
- if (process.env.NODE_ENV !== "production") debuggerEvents = [];
6743
- if (typeof partialStateOrMutator === "function") {
6744
- partialStateOrMutator(pinia.state.value[$id]);
6745
- subscriptionMutation = {
6746
- type: MutationType.patchFunction,
6747
- storeId: $id,
6748
- events: debuggerEvents
6749
- };
6750
- } else {
6751
- mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator);
6752
- subscriptionMutation = {
6753
- type: MutationType.patchObject,
6754
- payload: partialStateOrMutator,
6755
- storeId: $id,
6756
- events: debuggerEvents
6757
- };
6758
- }
6759
- const myListenerId = activeListener = Symbol();
6760
- nextTick().then(() => {
6761
- if (activeListener === myListenerId) isListening = true;
6762
- });
6763
- isSyncListening = true;
6764
- triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]);
6765
- }
6766
- const $reset = isOptionsStore ? function $reset() {
6767
- const { state } = options;
6768
- const newState = state ? state() : {};
6769
- this.$patch(($state) => {
6770
- assign($state, newState);
6771
- });
6772
- } : process.env.NODE_ENV !== "production" ? () => {
6773
- throw new Error(`🍍: Store "${$id}" is built using the setup syntax and does not implement $reset().`);
6774
- } : noop;
6775
- function $dispose() {
6776
- scope.stop();
6777
- subscriptions.clear();
6778
- actionSubscriptions.clear();
6779
- pinia._s.delete($id);
6780
- }
6781
- /**
6782
- * Helper that wraps function so it can be tracked with $onAction
6783
- * @param fn - action to wrap
6784
- * @param name - name of the action
6785
- */
6786
- const action = (fn, name = "") => {
6787
- if (ACTION_MARKER in fn) {
6788
- fn[ACTION_NAME] = name;
6789
- return fn;
6790
- }
6791
- const wrappedAction = function() {
6792
- setActivePinia(pinia);
6793
- const args = Array.from(arguments);
6794
- const afterCallbackSet = /* @__PURE__ */ new Set();
6795
- const onErrorCallbackSet = /* @__PURE__ */ new Set();
6796
- function after(callback) {
6797
- afterCallbackSet.add(callback);
6798
- }
6799
- function onError(callback) {
6800
- onErrorCallbackSet.add(callback);
6801
- }
6802
- triggerSubscriptions(actionSubscriptions, {
6803
- args,
6804
- name: wrappedAction[ACTION_NAME],
6805
- store,
6806
- after,
6807
- onError
6808
- });
6809
- let ret;
6810
- try {
6811
- ret = fn.apply(this && this.$id === $id ? this : store, args);
6812
- } catch (error) {
6813
- triggerSubscriptions(onErrorCallbackSet, error);
6814
- throw error;
6815
- }
6816
- if (ret instanceof Promise) return ret.then((value) => {
6817
- triggerSubscriptions(afterCallbackSet, value);
6818
- return value;
6819
- }).catch((error) => {
6820
- triggerSubscriptions(onErrorCallbackSet, error);
6821
- return Promise.reject(error);
6822
- });
6823
- triggerSubscriptions(afterCallbackSet, ret);
6824
- return ret;
6825
- };
6826
- wrappedAction[ACTION_MARKER] = true;
6827
- wrappedAction[ACTION_NAME] = name;
6828
- return wrappedAction;
6829
- };
6830
- const _hmrPayload = /* @__PURE__ */ markRaw({
6831
- actions: {},
6832
- getters: {},
6833
- state: [],
6834
- hotState
6835
- });
6836
- const partialStore = {
6837
- _p: pinia,
6838
- $id,
6839
- $onAction: addSubscription.bind(null, actionSubscriptions),
6840
- $patch,
6841
- $reset,
6842
- $subscribe(callback, options = {}) {
6843
- const removeSubscription = addSubscription(subscriptions, callback, options.detached, () => stopWatcher());
6844
- const stopWatcher = scope.run(() => watch(() => pinia.state.value[$id], (state) => {
6845
- if (options.flush === "sync" ? isSyncListening : isListening) callback({
6846
- storeId: $id,
6847
- type: MutationType.direct,
6848
- events: debuggerEvents
6849
- }, state);
6850
- }, assign({}, $subscribeOptions, options)));
6851
- return removeSubscription;
6852
- },
6853
- $dispose
6854
- };
6855
- const store = reactive(process.env.NODE_ENV !== "production" || (process.env.NODE_ENV !== "production" || false) && !(process.env.NODE_ENV === "test") && IS_CLIENT ? assign({
6856
- _hmrPayload,
6857
- _customProperties: markRaw(/* @__PURE__ */ new Set())
6858
- }, partialStore) : partialStore);
6859
- pinia._s.set($id, store);
6860
- const setupStore = (pinia._a && pinia._a.runWithContext || fallbackRunWithContext)(() => pinia._e.run(() => (scope = effectScope()).run(() => setup({ action }))));
6861
- for (const key in setupStore) {
6862
- const prop = setupStore[key];
6863
- if (isRef(prop) && !isComputed(prop) || isReactive(prop)) {
6864
- if (process.env.NODE_ENV !== "production" && hot) hotState.value[key] = toRef(setupStore, key);
6865
- else if (!isOptionsStore) {
6866
- if (initialState && shouldHydrate(prop)) if (isRef(prop)) prop.value = initialState[key];
6867
- else mergeReactiveObjects(prop, initialState[key]);
6868
- pinia.state.value[$id][key] = prop;
6869
- }
6870
- /* istanbul ignore else */
6871
- if (process.env.NODE_ENV !== "production") _hmrPayload.state.push(key);
6872
- } else if (typeof prop === "function") {
6873
- setupStore[key] = process.env.NODE_ENV !== "production" && hot ? prop : action(prop, key);
6874
- /* istanbul ignore else */
6875
- if (process.env.NODE_ENV !== "production") _hmrPayload.actions[key] = prop;
6876
- optionsForPlugin.actions[key] = prop;
6877
- } else if (process.env.NODE_ENV !== "production") {
6878
- if (isComputed(prop)) {
6879
- _hmrPayload.getters[key] = isOptionsStore ? options.getters[key] : prop;
6880
- if (IS_CLIENT) (setupStore._getters || (setupStore._getters = markRaw([]))).push(key);
6881
- }
6882
- }
6883
- }
6884
- /* istanbul ignore if */
6885
- assign(store, setupStore);
6886
- assign(toRaw(store), setupStore);
6887
- Object.defineProperty(store, "$state", {
6888
- get: () => process.env.NODE_ENV !== "production" && hot ? hotState.value : pinia.state.value[$id],
6889
- set: (state) => {
6890
- /* istanbul ignore if */
6891
- if (process.env.NODE_ENV !== "production" && hot) throw new Error("cannot set hotState");
6892
- $patch(($state) => {
6893
- assign($state, state);
6894
- });
6895
- }
6896
- });
6897
- /* istanbul ignore else */
6898
- if (process.env.NODE_ENV !== "production") store._hotUpdate = markRaw((newStore) => {
6899
- store._hotUpdating = true;
6900
- newStore._hmrPayload.state.forEach((stateKey) => {
6901
- if (stateKey in store.$state) {
6902
- const newStateTarget = newStore.$state[stateKey];
6903
- const oldStateSource = store.$state[stateKey];
6904
- if (typeof newStateTarget === "object" && isPlainObject(newStateTarget) && isPlainObject(oldStateSource)) patchObject(newStateTarget, oldStateSource);
6905
- else newStore.$state[stateKey] = oldStateSource;
6906
- }
6907
- store[stateKey] = toRef(newStore.$state, stateKey);
6908
- });
6909
- Object.keys(store.$state).forEach((stateKey) => {
6910
- if (!(stateKey in newStore.$state)) delete store[stateKey];
6911
- });
6912
- isListening = false;
6913
- isSyncListening = false;
6914
- pinia.state.value[$id] = toRef(newStore._hmrPayload, "hotState");
6915
- isSyncListening = true;
6916
- nextTick().then(() => {
6917
- isListening = true;
6918
- });
6919
- for (const actionName in newStore._hmrPayload.actions) {
6920
- const actionFn = newStore[actionName];
6921
- store[actionName] = action(actionFn, actionName);
6922
- }
6923
- for (const getterName in newStore._hmrPayload.getters) {
6924
- const getter = newStore._hmrPayload.getters[getterName];
6925
- store[getterName] = isOptionsStore ? computed(() => {
6926
- setActivePinia(pinia);
6927
- return getter.call(store, store);
6928
- }) : getter;
6929
- }
6930
- Object.keys(store._hmrPayload.getters).forEach((key) => {
6931
- if (!(key in newStore._hmrPayload.getters)) delete store[key];
6932
- });
6933
- Object.keys(store._hmrPayload.actions).forEach((key) => {
6934
- if (!(key in newStore._hmrPayload.actions)) delete store[key];
6935
- });
6936
- store._hmrPayload = newStore._hmrPayload;
6937
- store._getters = newStore._getters;
6938
- store._hotUpdating = false;
6939
- });
6940
- if ((process.env.NODE_ENV !== "production" || false) && !(process.env.NODE_ENV === "test") && IS_CLIENT) {
6941
- const nonEnumerable = {
6942
- writable: true,
6943
- configurable: true,
6944
- enumerable: false
6945
- };
6946
- [
6947
- "_p",
6948
- "_hmrPayload",
6949
- "_getters",
6950
- "_customProperties"
6951
- ].forEach((p) => {
6952
- Object.defineProperty(store, p, assign({ value: store[p] }, nonEnumerable));
6953
- });
6954
- }
6955
- pinia._p.forEach((extender) => {
6956
- /* istanbul ignore else */
6957
- if ((process.env.NODE_ENV !== "production" || false) && !(process.env.NODE_ENV === "test") && IS_CLIENT) {
6958
- const extensions = scope.run(() => extender({
6959
- store,
6960
- app: pinia._a,
6961
- pinia,
6962
- options: optionsForPlugin
6963
- }));
6964
- Object.keys(extensions || {}).forEach((key) => store._customProperties.add(key));
6965
- assign(store, extensions);
6966
- } else assign(store, scope.run(() => extender({
6967
- store,
6968
- app: pinia._a,
6969
- pinia,
6970
- options: optionsForPlugin
6971
- })));
6972
- });
6973
- 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
6974
- state: () => new MyClass()
6975
- Found in store "${store.$id}".`);
6976
- if (initialState && isOptionsStore && options.hydrate) options.hydrate(store.$state, initialState);
6977
- isListening = true;
6978
- isSyncListening = true;
6979
- return store;
6980
- }
6981
- /*! #__NO_SIDE_EFFECTS__ */
6982
- function defineStore(id, setup, setupOptions) {
6983
- let options;
6984
- const isSetupStore = typeof setup === "function";
6985
- options = isSetupStore ? setupOptions : setup;
6986
- function useStore(pinia, hot) {
6987
- const hasContext = hasInjectionContext();
6988
- pinia = (process.env.NODE_ENV === "test" && activePinia && activePinia._testing ? null : pinia) || (hasContext ? inject(piniaSymbol, null) : null);
6989
- if (pinia) setActivePinia(pinia);
6990
- 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.");
6991
- pinia = activePinia;
6992
- if (!pinia._s.has(id)) {
6993
- if (isSetupStore) createSetupStore(id, setup, options, pinia);
6994
- else createOptionsStore(id, options, pinia);
6995
- /* istanbul ignore else */
6996
- if (process.env.NODE_ENV !== "production") useStore._pinia = pinia;
6997
- }
6998
- const store = pinia._s.get(id);
6999
- if (process.env.NODE_ENV !== "production" && hot) {
7000
- const hotId = "__hot:" + id;
7001
- const newStore = isSetupStore ? createSetupStore(hotId, setup, options, pinia, true) : createOptionsStore(hotId, assign({}, options), pinia, true);
7002
- hot._hotUpdate(newStore);
7003
- delete pinia.state.value[hotId];
7004
- pinia._s.delete(hotId);
7005
- }
7006
- if (process.env.NODE_ENV !== "production" && IS_CLIENT) {
7007
- const currentInstance = getCurrentInstance();
7008
- if (currentInstance && currentInstance.proxy && !hot) {
7009
- const vm = currentInstance.proxy;
7010
- const cache = "_pStores" in vm ? vm._pStores : vm._pStores = {};
7011
- cache[id] = store;
7012
- }
7013
- }
7014
- return store;
7015
- }
7016
- useStore.$id = id;
7017
- return useStore;
7018
- }
6736
+ /** Built-in language packs, keyed by locale name. */
6737
+ var locales = {
6738
+ zh,
6739
+ en
6740
+ };
6741
+ /** Fallback locale used when none is provided / an unknown name is passed. */
6742
+ var DEFAULT_LOCALE = "zh";
7019
6743
  //#endregion
7020
- //#region compositions/overlay/useOverlayStack.ts
6744
+ //#region compositions/common/useLocale.ts
7021
6745
  /**
7022
- * @description overlay stack manager — unified z-index and ESC handling for all popups
6746
+ * @description composable for unified component locale with global injection
6747
+ * support — the i18n counterpart of `useComponentSize`. Components call
6748
+ * `useLocale()` to get the active message dictionary (a computed ref) and read
6749
+ * their user-facing strings from it instead of hardcoding text.
7023
6750
  * @author kine-design
7024
- * @date 2026/5/22 00:00
7025
6751
  * @version v1.0.0
7026
6752
  *
7027
6753
  * 江湖的业务千篇一律,复杂的代码好几百行。
7028
6754
  */
7029
- var Z_INDEX_BASE = 100;
7030
- var idCounter = 0;
7031
- var generateId = (type) => `overlay-${type}-${++idCounter}`;
7032
- var useOverlayStackStore = defineStore("overlayStack", () => {
7033
- const overlayStack = ref([]);
7034
- const isEmpty = computed(() => overlayStack.value.length === 0);
7035
- const topItem = computed(() => overlayStack.value.length > 0 ? overlayStack.value[overlayStack.value.length - 1] : void 0);
7036
- const push = (item) => {
7037
- const zIndex = overlayStack.value.length + Z_INDEX_BASE;
7038
- const entry = {
7039
- ...item,
7040
- zIndex
7041
- };
7042
- overlayStack.value.push(entry);
7043
- return entry;
7044
- };
7045
- const pop = () => {
7046
- const item = overlayStack.value.pop();
7047
- if (item) item.close();
7048
- return item;
7049
- };
7050
- const remove = (id) => {
7051
- const index = overlayStack.value.findIndex((item) => item.id === id);
7052
- if (index !== -1) {
7053
- overlayStack.value.splice(index, 1);
7054
- recalculateZIndices();
7055
- }
7056
- };
7057
- const recalculateZIndices = () => {
7058
- overlayStack.value.forEach((item, index) => {
7059
- item.zIndex = index + Z_INDEX_BASE;
7060
- });
7061
- };
7062
- const handleEsc = (e) => {
7063
- if (e.key === "Escape" && !isEmpty.value) pop();
7064
- };
7065
- let listenerAttached = false;
7066
- const attachEscListener = () => {
7067
- if (!listenerAttached) {
7068
- document.addEventListener("keydown", handleEsc);
7069
- listenerAttached = true;
7070
- }
7071
- };
7072
- const detachEscListener = () => {
7073
- if (listenerAttached) {
7074
- document.removeEventListener("keydown", handleEsc);
7075
- listenerAttached = false;
7076
- }
7077
- };
7078
- return {
7079
- overlayStack,
7080
- isEmpty,
7081
- topItem,
7082
- push,
7083
- pop,
7084
- remove,
7085
- attachEscListener,
7086
- detachEscListener
7087
- };
7088
- });
7089
- function useOverlayStack() {
7090
- const store = useOverlayStackStore();
7091
- onMounted(() => {
7092
- store.attachEscListener();
7093
- });
7094
- onBeforeUnmount(() => {
7095
- store.detachEscListener();
7096
- });
7097
- return store;
6755
+ var KINE_LOCALE_KEY = Symbol("kine-locale");
6756
+ function resolveMessages(config) {
6757
+ if (!config) return locales["zh"];
6758
+ if (typeof config === "string") return locales[config] ?? locales["zh"];
6759
+ return config;
7098
6760
  }
7099
- function useOverlayItem(type) {
7100
- const store = useOverlayStackStore();
7101
- let itemId;
7102
- const register = (closeFn) => {
7103
- const id = generateId(type);
7104
- const entry = store.push({
7105
- id,
7106
- type,
7107
- close: closeFn
7108
- });
7109
- itemId = entry.id;
7110
- return entry;
7111
- };
7112
- const unregister = () => {
7113
- if (itemId) {
7114
- store.remove(itemId);
7115
- itemId = void 0;
7116
- }
7117
- };
7118
- const currentZIndex = computed(() => {
7119
- if (!itemId) return void 0;
7120
- return store.overlayStack.find((i) => i.id === itemId)?.zIndex;
7121
- });
7122
- onBeforeUnmount(() => {
7123
- unregister();
7124
- });
7125
- return {
7126
- register,
7127
- unregister,
7128
- currentZIndex
7129
- };
6761
+ /**
6762
+ * Resolve the active message dictionary from the nearest `KConfigProvider`.
6763
+ * Falls back to the default (zh) pack when no provider is present.
6764
+ */
6765
+ function useLocale() {
6766
+ const injected = inject(KINE_LOCALE_KEY, void 0);
6767
+ return computed(() => resolveMessages(injected?.value));
6768
+ }
6769
+ var activeLocaleMessages = locales["zh"];
6770
+ /** Set the global active dictionary. Called by KConfigProvider on locale change. */
6771
+ function setActiveLocaleMessages(config) {
6772
+ activeLocaleMessages = resolveMessages(config);
6773
+ }
6774
+ /** Read the global active dictionary from non-component (pure-function) code. */
6775
+ function getActiveLocaleMessages() {
6776
+ return activeLocaleMessages;
7130
6777
  }
7131
6778
  //#endregion
7132
- export { AffixCore, AlertCore, AnchorCore, AutoCompleteCore, AvatarCore, BASE_MONTH_NAME, BASE_WEEK_NAME, BackTopCore, BadgeCore, BorderCore, BreadcrumbCore, ButtonCore, CardCore, CarouselCore, CascaderCore, CheckboxCore, CollapseCore, ConfirmCore, DEFAULT_MENU_CONFIG, DEFAULT_TREE_CONFIG, DarkModeCore, DatePickerCore, DescriptionsCore, DialogCore, DividerCore, DrawerCore, DropdownCore, EmptyCore, FormCore, GridCore, ImageCore, InputCore, InputNumberCore, 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, fixKey, generateTimeColumn, getNewModelValue, initChecked, toDayjs, treeNodeProps, props as treeProps, useDatePicker, useMessageQueue, useNotificationQueue, useOverlayItem, useOverlayStack, useOverlayStackStore, usePagination, useTable, useTree };
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 };