@guoyg578/k-ui 0.1.5 → 0.1.6

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 (96) hide show
  1. package/dist/components/KAutoComplete.vue.d.ts +2 -0
  2. package/dist/components/KAutoComplete.vue.js +1 -1
  3. package/dist/components/KAutoComplete.vue_vue_type_script_setup_true_lang.js +89 -29
  4. package/dist/components/KCalendar.vue.js +1 -1
  5. package/dist/components/KCalendar.vue_vue_type_script_setup_true_lang.js +132 -39
  6. package/dist/components/KCascader.vue.d.ts +2 -0
  7. package/dist/components/KCascader.vue.js +1 -1
  8. package/dist/components/KCascader.vue_vue_type_script_setup_true_lang.js +19 -18
  9. package/dist/components/KCheckbox.vue.d.ts +6 -2
  10. package/dist/components/KCheckbox.vue.js +1 -1
  11. package/dist/components/KCheckbox.vue_vue_type_script_setup_true_lang.js +38 -18
  12. package/dist/components/KCheckboxGroup.vue.d.ts +2 -0
  13. package/dist/components/KCheckboxGroup.vue.js +1 -1
  14. package/dist/components/KCheckboxGroup.vue_vue_type_script_setup_true_lang.js +23 -15
  15. package/dist/components/KCollapse.vue.d.ts +3 -1
  16. package/dist/components/KCollapse.vue.js +1 -1
  17. package/dist/components/KCollapse.vue_vue_type_script_setup_true_lang.js +27 -16
  18. package/dist/components/KDataTable.vue.d.ts +48 -1
  19. package/dist/components/KDataTable.vue.js +1 -1
  20. package/dist/components/KDataTable.vue_vue_type_script_setup_true_lang.js +305 -74
  21. package/dist/components/KDatePicker.vue.d.ts +8 -0
  22. package/dist/components/KDatePicker.vue_vue_type_script_setup_true_lang.js +32 -22
  23. package/dist/components/KDialog.vue.d.ts +4 -4
  24. package/dist/components/KDialog.vue.js +1 -1
  25. package/dist/components/KDialog.vue_vue_type_script_setup_true_lang.js +80 -71
  26. package/dist/components/KDropdown.vue.d.ts +4 -3
  27. package/dist/components/KDropdown.vue_vue_type_script_setup_true_lang.js +45 -28
  28. package/dist/components/KDynamicInput.vue.d.ts +2 -0
  29. package/dist/components/KDynamicInput.vue.js +1 -1
  30. package/dist/components/KDynamicInput.vue_vue_type_script_setup_true_lang.js +17 -6
  31. package/dist/components/KDynamicTags.vue.d.ts +2 -0
  32. package/dist/components/KDynamicTags.vue.js +1 -1
  33. package/dist/components/KDynamicTags.vue_vue_type_script_setup_true_lang.js +11 -10
  34. package/dist/components/KForm.vue.d.ts +12 -0
  35. package/dist/components/KForm.vue.js +1 -1
  36. package/dist/components/KForm.vue_vue_type_script_setup_true_lang.js +26 -4
  37. package/dist/components/KFormField.vue.d.ts +3 -1
  38. package/dist/components/KFormField.vue.js +1 -1
  39. package/dist/components/KFormField.vue_vue_type_script_setup_true_lang.js +124 -61
  40. package/dist/components/KInputNumber.vue.js +1 -1
  41. package/dist/components/KInputNumber.vue_vue_type_script_setup_true_lang.js +35 -29
  42. package/dist/components/KMention.vue.d.ts +2 -0
  43. package/dist/components/KMention.vue.js +1 -1
  44. package/dist/components/KMention.vue_vue_type_script_setup_true_lang.js +34 -33
  45. package/dist/components/KMenu.vue.js +1 -1
  46. package/dist/components/KMenu.vue_vue_type_script_setup_true_lang.js +132 -51
  47. package/dist/components/KMenuItem.vue.js +1 -1
  48. package/dist/components/KMenuItem.vue_vue_type_script_setup_true_lang.js +21 -6
  49. package/dist/components/KMessage.d.ts +5 -0
  50. package/dist/components/KMessage.js +36 -23
  51. package/dist/components/KNotification.d.ts +8 -0
  52. package/dist/components/KNotification.js +45 -29
  53. package/dist/components/KNotificationProvider.vue.js +3 -8
  54. package/dist/components/KNotificationProvider.vue_vue_type_script_setup_true_lang.js +11 -0
  55. package/dist/components/KPagination.vue.d.ts +4 -1
  56. package/dist/components/KPagination.vue.js +1 -1
  57. package/dist/components/KPagination.vue_vue_type_script_setup_true_lang.js +36 -33
  58. package/dist/components/KRadio.vue.d.ts +1 -0
  59. package/dist/components/KRadio.vue.js +1 -1
  60. package/dist/components/KRadio.vue_vue_type_script_setup_true_lang.js +22 -14
  61. package/dist/components/KRadioGroup.vue.d.ts +4 -2
  62. package/dist/components/KRadioGroup.vue.js +1 -1
  63. package/dist/components/KRadioGroup.vue_vue_type_script_setup_true_lang.js +16 -4
  64. package/dist/components/KRate.vue.d.ts +5 -0
  65. package/dist/components/KRate.vue.js +1 -1
  66. package/dist/components/KRate.vue_vue_type_script_setup_true_lang.js +72 -24
  67. package/dist/components/KSelect.vue.d.ts +2 -2
  68. package/dist/components/KSelect.vue.js +1 -1
  69. package/dist/components/KSelect.vue_vue_type_script_setup_true_lang.js +1 -1
  70. package/dist/components/KSlider.vue.d.ts +2 -0
  71. package/dist/components/KSlider.vue.js +1 -1
  72. package/dist/components/KSlider.vue_vue_type_script_setup_true_lang.js +17 -16
  73. package/dist/components/KTextarea.vue.d.ts +2 -0
  74. package/dist/components/KTextarea.vue.js +1 -1
  75. package/dist/components/KTextarea.vue_vue_type_script_setup_true_lang.js +10 -9
  76. package/dist/components/KTimePicker.vue.d.ts +2 -0
  77. package/dist/components/KTimePicker.vue.js +1 -1
  78. package/dist/components/KTimePicker.vue_vue_type_script_setup_true_lang.js +61 -48
  79. package/dist/components/KTransfer.vue.d.ts +2 -0
  80. package/dist/components/KTransfer.vue.js +1 -1
  81. package/dist/components/KTransfer.vue_vue_type_script_setup_true_lang.js +35 -34
  82. package/dist/components/KTreeSelect.vue.d.ts +2 -0
  83. package/dist/components/KTreeSelect.vue.js +1 -1
  84. package/dist/components/KTreeSelect.vue_vue_type_script_setup_true_lang.js +15 -14
  85. package/dist/components/KUpload.vue.d.ts +14 -0
  86. package/dist/components/KUpload.vue.js +1 -1
  87. package/dist/components/KUpload.vue_vue_type_script_setup_true_lang.js +159 -117
  88. package/dist/components/checkbox-context.d.ts +10 -0
  89. package/dist/components/checkbox-context.js +4 -0
  90. package/dist/components/form-context.d.ts +19 -2
  91. package/dist/components/form-context.js +31 -1
  92. package/dist/components/menu-context.d.ts +4 -0
  93. package/dist/components/radio-context.d.ts +6 -1
  94. package/dist/k-ui.css +1 -1
  95. package/dist/styles/tokens.css +40 -1
  96. package/package.json +1 -1
@@ -1,7 +1,8 @@
1
- import { computed as e, createBlock as t, defineComponent as n, normalizeClass as r, openBlock as i, renderSlot as a, unref as o, withCtx as s } from "vue";
2
- import { CheckboxGroupRoot as c } from "reka-ui";
1
+ import { CHECKBOX_GROUP_KEY as e } from "./checkbox-context.js";
2
+ import { computed as t, createBlock as n, defineComponent as r, normalizeClass as i, openBlock as a, provide as o, renderSlot as s, toRef as c, unref as l, withCtx as u } from "vue";
3
+ import { CheckboxGroupRoot as d } from "reka-ui";
3
4
  //#region components/KCheckboxGroup.vue?vue&type=script&setup=true&lang.ts
4
- var l = /* @__PURE__ */ n({
5
+ var f = /* @__PURE__ */ r({
5
6
  __name: "KCheckboxGroup",
6
7
  props: {
7
8
  modelValue: { default: () => [] },
@@ -9,21 +10,28 @@ var l = /* @__PURE__ */ n({
9
10
  type: Boolean,
10
11
  default: !1
11
12
  },
12
- direction: { default: "horizontal" }
13
+ direction: { default: "horizontal" },
14
+ size: {}
13
15
  },
14
16
  emits: ["update:modelValue"],
15
- setup(n, { emit: l }) {
16
- let u = n, d = l, f = e(() => u.modelValue.map((e) => String(e)));
17
- function p(e) {
18
- u.modelValue.length > 0 && u.modelValue.every((e) => typeof e == "number") && e.every((e) => /^-?\d+(\.\d+)?$/.test(e)) ? d("update:modelValue", e.map(Number)) : d("update:modelValue", e);
17
+ setup(r, { emit: f }) {
18
+ let p = r, m = f, h = /* @__PURE__ */ new Map();
19
+ o(e, {
20
+ size: c(p, "size"),
21
+ register: (e) => h.set(String(e), e),
22
+ unregister: (e) => h.delete(String(e))
23
+ });
24
+ let g = t(() => p.modelValue.map((e) => String(e)));
25
+ function _(e) {
26
+ m("update:modelValue", e.map((e) => h.has(e) ? h.get(e) : e));
19
27
  }
20
- return (e, l) => (i(), t(o(c), {
21
- "model-value": f.value,
22
- disabled: n.disabled,
23
- class: r(["k-cb-group", `k-cb-group--${n.direction}`]),
24
- "onUpdate:modelValue": l[0] ||= (e) => p(e)
28
+ return (e, t) => (a(), n(l(d), {
29
+ "model-value": g.value,
30
+ disabled: r.disabled,
31
+ class: i(["k-cb-group", `k-cb-group--${r.direction}`]),
32
+ "onUpdate:modelValue": t[0] ||= (e) => _(e)
25
33
  }, {
26
- default: s(() => [a(e.$slots, "default", {}, void 0, !0)]),
34
+ default: u(() => [s(e.$slots, "default", {}, void 0, !0)]),
27
35
  _: 3
28
36
  }, 8, [
29
37
  "model-value",
@@ -33,4 +41,4 @@ var l = /* @__PURE__ */ n({
33
41
  }
34
42
  });
35
43
  //#endregion
36
- export { l as default };
44
+ export { f as default };
@@ -3,9 +3,11 @@ type __VLS_Props = {
3
3
  /** 手风琴模式:同时只展开一项 */
4
4
  accordion?: boolean;
5
5
  };
6
- declare var __VLS_10: {};
6
+ declare var __VLS_10: {}, __VLS_21: {};
7
7
  type __VLS_Slots = {} & {
8
8
  default?: (props: typeof __VLS_10) => any;
9
+ } & {
10
+ default?: (props: typeof __VLS_21) => any;
9
11
  };
10
12
  declare const __VLS_base: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
11
13
  "update:modelValue": (v: string[]) => any;
@@ -2,6 +2,6 @@ import e from "../_virtual/_plugin-vue_export-helper.js";
2
2
  import t from "./KCollapse.vue_vue_type_script_setup_true_lang.js";
3
3
  /* empty css */
4
4
  //#region components/KCollapse.vue
5
- var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-6a540b0c"]]);
5
+ var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-0f4f3bc1"]]);
6
6
  //#endregion
7
7
  export { n as default };
@@ -1,7 +1,7 @@
1
- import { createBlock as e, defineComponent as t, openBlock as n, renderSlot as r, unref as i, withCtx as a } from "vue";
2
- import { AccordionRoot as o } from "reka-ui";
1
+ import { computed as e, createBlock as t, defineComponent as n, openBlock as r, renderSlot as i, unref as a, withCtx as o } from "vue";
2
+ import { AccordionRoot as s } from "reka-ui";
3
3
  //#region components/KCollapse.vue?vue&type=script&setup=true&lang.ts
4
- var s = /* @__PURE__ */ t({
4
+ var c = /* @__PURE__ */ n({
5
5
  __name: "KCollapse",
6
6
  props: {
7
7
  modelValue: { default: () => [] },
@@ -11,25 +11,36 @@ var s = /* @__PURE__ */ t({
11
11
  }
12
12
  },
13
13
  emits: ["update:modelValue"],
14
- setup(t, { emit: s }) {
15
- let c = t, l = s;
16
- function u(e) {
17
- let t = Array.isArray(e) ? e : e ? [e] : [];
18
- if (c.accordion && t.length > 1) {
19
- let e = t.find((e) => !c.modelValue.includes(e));
20
- l("update:modelValue", e ? [e] : []);
21
- } else l("update:modelValue", t);
14
+ setup(n, { emit: c }) {
15
+ let l = n, u = c, d = e(() => l.modelValue[0] ?? "");
16
+ function f(e) {
17
+ let t = Array.isArray(e) ? e[0] : e;
18
+ u("update:modelValue", t ? [t] : []);
22
19
  }
23
- return (s, c) => (n(), e(i(o), {
20
+ function p(e) {
21
+ u("update:modelValue", Array.isArray(e) ? e : e ? [e] : []);
22
+ }
23
+ return (e, c) => n.accordion ? (r(), t(a(s), {
24
+ key: 0,
25
+ type: "single",
26
+ collapsible: "",
27
+ "model-value": d.value,
28
+ class: "k-collapse",
29
+ "onUpdate:modelValue": f
30
+ }, {
31
+ default: o(() => [i(e.$slots, "default", {}, void 0, !0)]),
32
+ _: 3
33
+ }, 8, ["model-value"])) : (r(), t(a(s), {
34
+ key: 1,
24
35
  type: "multiple",
25
- "model-value": t.modelValue,
36
+ "model-value": n.modelValue,
26
37
  class: "k-collapse",
27
- "onUpdate:modelValue": u
38
+ "onUpdate:modelValue": p
28
39
  }, {
29
- default: a(() => [r(s.$slots, "default", {}, void 0, !0)]),
40
+ default: o(() => [i(e.$slots, "default", {}, void 0, !0)]),
30
41
  _: 3
31
42
  }, 8, ["model-value"]));
32
43
  }
33
44
  });
34
45
  //#endregion
35
- export { s as default };
46
+ export { c as default };
@@ -1,11 +1,33 @@
1
1
  import type { VNodeChild } from 'vue';
2
2
  export type RowClassValue = string | string[] | Record<string, boolean> | undefined;
3
+ export type SortOrder = 'ascend' | 'descend';
4
+ export interface SortState {
5
+ columnKey: string;
6
+ order: SortOrder;
7
+ }
3
8
  export interface Column<T = Record<string, any>> {
4
9
  key: string;
5
10
  label?: string;
6
11
  title?: string;
7
12
  width?: string | number;
13
+ /** 列最小宽度 (auto 布局下作为列宽下限) */
14
+ minWidth?: string | number;
15
+ /** 单行截断 + 省略号。需配合 width 或 maxWidth 给出宽度上限才会生效 (auto 布局下没有上限无法截断)。
16
+ * 开启后默认用单元格原始值作 hover title;自定义插槽里可自行覆盖 title。 */
17
+ ellipsis?: boolean;
18
+ /** ellipsis 的最大宽度,接受数字 (px) 或任意 CSS 值,如 'clamp(160px, 22vw, 420px)'。未给则回退到 width。 */
19
+ maxWidth?: string | number;
8
20
  align?: 'left' | 'right' | 'center';
21
+ /** 固定列: 'left' | 'right' (CSS sticky)。固定列建议显式给 width,否则偏移量按 0 计算会错位。 */
22
+ fixed?: 'left' | 'right';
23
+ /** 特殊列类型。'selection' 渲染多选框列 (需配合 row-key 与 v-model:checked-row-keys)。 */
24
+ type?: 'selection';
25
+ /** selection 列: 返回 true 的行禁用选择 */
26
+ disabled?: (row: T) => boolean;
27
+ /** 排序: true / 'default' 用默认比较 row[key];传函数自定义比较 (a, b) => number (升序语义) */
28
+ sorter?: boolean | 'default' | ((a: T, b: T) => number);
29
+ /** 非受控初始排序方向 */
30
+ defaultSortOrder?: SortOrder;
9
31
  cellClass?: string;
10
32
  className?: string;
11
33
  render?: (row: T, index: number) => VNodeChild;
@@ -36,11 +58,22 @@ declare const __VLS_export: <T extends Record<string, any>>(__VLS_props: NonNull
36
58
  striped?: boolean;
37
59
  bordered?: boolean;
38
60
  stickyHeader?: boolean;
61
+ /** body 最大高度;设置后表头自动吸顶 (内部 overflow:auto 限高) */
62
+ maxHeight?: string | number;
39
63
  pagination?: false | DataTablePagination;
40
64
  singleLine?: boolean;
41
65
  scrollX?: string | number;
66
+ /** 远程模式: 不在本地做排序/分页 (数据已由外部处理好) */
67
+ remote?: boolean;
68
+ /** 选中行 key (受控);不传则内部维护 */
69
+ checkedRowKeys?: (string | number)[];
70
+ defaultCheckedRowKeys?: (string | number)[];
71
+ /** 排序状态 (受控,单列);不传则内部维护 */
72
+ sortState?: SortState | null;
42
73
  } & {
43
74
  onRowClick?: ((row: T) => any) | undefined;
75
+ "onUpdate:sortState"?: ((state: SortState | null) => any) | undefined;
76
+ "onUpdate:checkedRowKeys"?: ((keys: (string | number)[], rows: T[]) => any) | undefined;
44
77
  }> & (typeof globalThis extends {
45
78
  __VLS_PROPS_FALLBACK: infer P;
46
79
  } ? P : {});
@@ -50,6 +83,16 @@ declare const __VLS_export: <T extends Record<string, any>>(__VLS_props: NonNull
50
83
  [x: `header-${string}`]: ((props: {
51
84
  col: Column<T>;
52
85
  }) => any) | undefined;
86
+ } & {
87
+ [x: `header-${string}`]: ((props: {
88
+ col: Column<T>;
89
+ }) => any) | undefined;
90
+ } & {
91
+ [x: `cell-${string}`]: ((props: {
92
+ row: T;
93
+ value: any;
94
+ index: number;
95
+ }) => any) | undefined;
53
96
  } & {
54
97
  [x: `cell-${string}`]: ((props: {
55
98
  row: T;
@@ -59,7 +102,11 @@ declare const __VLS_export: <T extends Record<string, any>>(__VLS_props: NonNull
59
102
  } & {
60
103
  empty?: (props: {}) => any;
61
104
  };
62
- emit: (e: "rowClick", row: T) => void;
105
+ emit: {
106
+ (e: "rowClick", row: T): void;
107
+ (e: "update:checkedRowKeys", keys: (string | number)[], rows: T[]): void;
108
+ (e: "update:sortState", state: SortState | null): void;
109
+ };
63
110
  }>) => import("vue").VNode & {
64
111
  __ctx?: Awaited<typeof __VLS_setup>;
65
112
  };
@@ -2,6 +2,6 @@ import e from "../_virtual/_plugin-vue_export-helper.js";
2
2
  import t from "./KDataTable.vue_vue_type_script_setup_true_lang.js";
3
3
  /* empty css */
4
4
  //#region components/KDataTable.vue
5
- var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-cc657cc6"]]);
5
+ var n = /* @__PURE__ */ e(t, [["__scopeId", "data-v-6085ee8c"]]);
6
6
  //#endregion
7
7
  export { n as default };
@@ -1,12 +1,14 @@
1
- import e from "./KLoadingOverlay.vue.js";
2
- import t from "./KEmpty.vue.js";
3
- import n from "./KPagination.vue.js";
4
- import { Fragment as r, computed as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createTextVNode as l, createVNode as u, defineComponent as d, normalizeClass as f, normalizeStyle as p, openBlock as m, ref as h, renderList as g, renderSlot as _, toDisplayString as v, unref as y, watch as b } from "vue";
1
+ import e from "./KCheckbox.vue.js";
2
+ import t from "./KLoadingOverlay.vue.js";
3
+ import n from "./KEmpty.vue.js";
4
+ import r from "./KPagination.vue.js";
5
+ import { Fragment as i, computed as a, createBlock as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, createVNode as d, defineComponent as f, normalizeClass as p, normalizeStyle as m, openBlock as h, ref as g, renderList as _, renderSlot as v, toDisplayString as y, unref as b, watch as x, withModifiers as S } from "vue";
6
+ import { ChevronDown as ee, ChevronUp as te, ChevronsUpDown as ne } from "lucide-vue-next";
5
7
  //#region components/KDataTable.vue?vue&type=script&setup=true&lang.ts
6
- var x = ["onClick"], S = {
8
+ var re = ["aria-sort"], ie = ["onClick"], ae = ["onClick"], oe = ["title"], se = {
7
9
  key: 0,
8
10
  class: "k-table-empty"
9
- }, C = /* @__PURE__ */ d({
11
+ }, C = /* @__PURE__ */ f({
10
12
  __name: "KDataTable",
11
13
  props: {
12
14
  columns: {},
@@ -36,50 +38,203 @@ var x = ["onClick"], S = {
36
38
  type: Boolean,
37
39
  default: !1
38
40
  },
41
+ maxHeight: {},
39
42
  pagination: { type: [Boolean, Object] },
40
43
  singleLine: {
41
44
  type: Boolean,
42
45
  default: !0
43
46
  },
44
- scrollX: {}
47
+ scrollX: {},
48
+ remote: {
49
+ type: Boolean,
50
+ default: !1
51
+ },
52
+ checkedRowKeys: {},
53
+ defaultCheckedRowKeys: {},
54
+ sortState: {}
45
55
  },
46
- emits: ["rowClick"],
47
- setup(C, { emit: w }) {
48
- let T = C, E = w, D = h(1), O = i(() => T.rows ?? T.data ?? []), k = i(() => T.pagination && typeof T.pagination == "object" ? T.pagination : void 0), A = i(() => {
49
- let e = Number(k.value?.pageSize ?? 0);
50
- return Number.isFinite(e) && e > 0 ? e : 0;
51
- }), j = i(() => O.value.length), M = i(() => {
52
- if (!A.value) return O.value;
53
- let e = (D.value - 1) * A.value;
54
- return O.value.slice(e, e + A.value);
55
- }), N = i(() => T.size === "small" || T.size === "sm" ? "sm" : "md"), P = i(() => {
56
- if (T.scrollX !== void 0) return { minWidth: typeof T.scrollX == "number" ? `${T.scrollX}px` : T.scrollX };
56
+ emits: [
57
+ "rowClick",
58
+ "update:checkedRowKeys",
59
+ "update:sortState"
60
+ ],
61
+ setup(C, { emit: ce }) {
62
+ let w = C, T = ce, E = a(() => w.columns.map((e) => e.type === "selection" ? {
63
+ ...e,
64
+ key: e.key || "__selection__"
65
+ } : e)), le = a(() => w.size === "small" || w.size === "sm" ? "sm" : "md"), ue = a(() => w.stickyHeader || w.maxHeight !== void 0), de = a(() => w.maxHeight === void 0 ? void 0 : { maxHeight: D(w.maxHeight) }), fe = a(() => {
66
+ if (w.scrollX !== void 0) return { minWidth: D(w.scrollX) };
57
67
  });
58
- b(() => k.value?.page, (e) => {
59
- typeof e == "number" && e > 0 && (D.value = e);
60
- }, { immediate: !0 }), b([j, A], () => {
61
- let e = A.value ? Math.max(1, Math.ceil(j.value / A.value)) : 1;
62
- D.value > e && (D.value = e), D.value < 1 && (D.value = 1);
68
+ function D(e) {
69
+ if (e !== void 0) return typeof e == "number" ? `${e}px` : e;
70
+ }
71
+ function O(e) {
72
+ if (e === void 0) return 0;
73
+ if (typeof e == "number") return e;
74
+ let t = /^(-?\d+(?:\.\d+)?)px$/.exec(e.trim());
75
+ return t ? Number(t[1]) : 0;
76
+ }
77
+ function k(e) {
78
+ if (e.width !== void 0) return e.width;
79
+ if (e.type === "selection") return 44;
80
+ }
81
+ function pe(e) {
82
+ let t = {}, n = k(e);
83
+ return n !== void 0 && (t.width = D(n)), e.minWidth !== void 0 && (t.minWidth = D(e.minWidth)), Object.keys(t).length ? t : void 0;
84
+ }
85
+ let me = a(() => {
86
+ let e = {}, t = 0;
87
+ for (let n of E.value) n.fixed === "left" && (e[n.key] = t, t += O(k(n)));
88
+ return e;
89
+ }), he = a(() => {
90
+ let e = {}, t = 0, n = E.value;
91
+ for (let r = n.length - 1; r >= 0; r--) {
92
+ let i = n[r];
93
+ i.fixed === "right" && (e[i.key] = t, t += O(k(i)));
94
+ }
95
+ return e;
96
+ }), ge = a(() => {
97
+ let e = E.value.filter((e) => e.fixed === "left");
98
+ return e.length ? e[e.length - 1].key : null;
99
+ }), _e = a(() => {
100
+ let e = E.value.filter((e) => e.fixed === "right");
101
+ return e.length ? e[0].key : null;
63
102
  });
103
+ function A(e, t) {
104
+ if (e.fixed === "left") return {
105
+ position: "sticky",
106
+ left: `${me.value[e.key] ?? 0}px`,
107
+ zIndex: t ? 2 : 1
108
+ };
109
+ if (e.fixed === "right") return {
110
+ position: "sticky",
111
+ right: `${he.value[e.key] ?? 0}px`,
112
+ zIndex: t ? 2 : 1
113
+ };
114
+ }
115
+ function j(e) {
116
+ return e.fixed === "left" ? [
117
+ "k-table__cell--fixed",
118
+ "k-table__cell--fixed-left",
119
+ e.key === ge.value ? "k-table__cell--fixed-left-last" : ""
120
+ ] : e.fixed === "right" ? [
121
+ "k-table__cell--fixed",
122
+ "k-table__cell--fixed-right",
123
+ e.key === _e.value ? "k-table__cell--fixed-right-first" : ""
124
+ ] : [];
125
+ }
126
+ function ve() {
127
+ let e = w.columns.find((e) => e.sorter && e.defaultSortOrder);
128
+ return e ? {
129
+ columnKey: e.key,
130
+ order: e.defaultSortOrder
131
+ } : null;
132
+ }
133
+ let M = g(ve()), N = a(() => w.sortState !== void 0), P = a(() => N.value ? w.sortState ?? null : M.value);
64
134
  function F(e) {
65
- return e.label ?? e.title ?? e.key;
135
+ return !!e.sorter;
66
136
  }
67
137
  function I(e) {
68
- if (e.width !== void 0) return { width: typeof e.width == "number" ? `${e.width}px` : e.width };
138
+ let t = P.value;
139
+ return t && t.columnKey === e.key ? t.order : null;
140
+ }
141
+ function ye(e) {
142
+ if (!F(e)) return;
143
+ let t = I(e);
144
+ return t === "ascend" ? "ascending" : t === "descend" ? "descending" : "none";
145
+ }
146
+ function be(e) {
147
+ if (!F(e)) return;
148
+ let t = I(e), n = t === null ? {
149
+ columnKey: e.key,
150
+ order: "ascend"
151
+ } : t === "ascend" ? {
152
+ columnKey: e.key,
153
+ order: "descend"
154
+ } : null;
155
+ N.value || (M.value = n), T("update:sortState", n);
69
156
  }
70
- function L(e, t) {
157
+ function xe(e, t) {
158
+ return e == null && t == null ? 0 : e == null ? -1 : t == null ? 1 : typeof e == "number" && typeof t == "number" ? e - t : String(e).localeCompare(String(t));
159
+ }
160
+ let L = a(() => w.rows ?? w.data ?? []), R = a(() => {
161
+ let e = P.value;
162
+ if (w.remote || !e) return L.value;
163
+ let t = E.value.find((t) => t.key === e.columnKey && t.sorter);
164
+ if (!t) return L.value;
165
+ let n = typeof t.sorter == "function" ? t.sorter : (e, n) => xe(e[t.key], n[t.key]), r = e.order === "ascend" ? 1 : -1;
166
+ return L.value.slice().sort((e, t) => n(e, t) * r);
167
+ }), z = g(1), B = a(() => w.pagination && typeof w.pagination == "object" ? w.pagination : void 0), V = a(() => {
168
+ let e = Number(B.value?.pageSize ?? 0);
169
+ return Number.isFinite(e) && e > 0 ? e : 0;
170
+ }), H = a(() => R.value.length), U = a(() => {
171
+ if (!V.value) return R.value;
172
+ let e = (z.value - 1) * V.value;
173
+ return R.value.slice(e, e + V.value);
174
+ });
175
+ x(() => B.value?.page, (e) => {
176
+ typeof e == "number" && e > 0 && (z.value = e);
177
+ }, { immediate: !0 }), x([H, V], () => {
178
+ let e = V.value ? Math.max(1, Math.ceil(H.value / V.value)) : 1;
179
+ z.value > e && (z.value = e), z.value < 1 && (z.value = 1);
180
+ });
181
+ let W = g(new Set(w.defaultCheckedRowKeys ?? [])), G = a(() => w.checkedRowKeys !== void 0), K = a(() => G.value ? new Set(w.checkedRowKeys) : W.value), Se = a(() => E.value.find((e) => e.type === "selection")), Ce = a(() => {
182
+ let e = /* @__PURE__ */ new Map();
183
+ return L.value.forEach((t, n) => e.set(Q(t, n), t)), e;
184
+ });
185
+ function q(e) {
186
+ let t = Se.value;
187
+ return t?.disabled ? t.disabled(e) : !1;
188
+ }
189
+ function we(e, t) {
190
+ return K.value.has(Q(e, t));
191
+ }
192
+ let J = a(() => U.value.map((e, t) => ({
193
+ key: Q(e, t),
194
+ disabled: q(e)
195
+ }))), Y = a(() => J.value.filter((e) => !e.disabled)), X = a(() => Y.value.length > 0 && Y.value.every((e) => K.value.has(e.key))), Te = a(() => Y.value.some((e) => K.value.has(e.key)) && !X.value);
196
+ function Ee(e) {
197
+ G.value || (W.value = e);
198
+ let t = [...e], n = Ce.value;
199
+ T("update:checkedRowKeys", t, t.map((e) => n.get(e)).filter((e) => e !== void 0));
200
+ }
201
+ function De(e, t, n) {
202
+ let r = new Set(K.value), i = Q(e, t);
203
+ n ? r.add(i) : r.delete(i), Ee(r);
204
+ }
205
+ function Oe(e) {
206
+ let t = new Set(K.value);
207
+ for (let n of J.value) n.disabled || (e ? t.add(n.key) : t.delete(n.key));
208
+ Ee(t);
209
+ }
210
+ function ke(e) {
211
+ return e.label ?? e.title ?? e.key;
212
+ }
213
+ function Z(e, t) {
71
214
  return e[t.key] ?? "-";
72
215
  }
73
- function R(e, t) {
74
- return typeof T.rowKey == "function" ? T.rowKey(e) : typeof T.rowKey == "string" ? e[T.rowKey] ?? t : t;
216
+ let Ae = 0, je = /* @__PURE__ */ new WeakMap();
217
+ function Q(e, t) {
218
+ if (typeof w.rowKey == "function") return w.rowKey(e);
219
+ if (typeof w.rowKey == "string") return e[w.rowKey] ?? t;
220
+ let n = je.get(e);
221
+ return n === void 0 && (n = ++Ae, je.set(e, n)), n;
75
222
  }
76
- function z(e, t) {
77
- return [{ "k-table__row--hoverable": T.hoverable }, typeof T.rowClassName == "function" ? T.rowClassName(e, t) : T.rowClassName];
223
+ function Me(e, t) {
224
+ return [{ "k-table__row--hoverable": w.hoverable }, typeof w.rowClassName == "function" ? w.rowClassName(e, t) : w.rowClassName];
78
225
  }
79
- function B(e, t, n) {
80
- return e.render ? e.render(t, n) : L(t, e);
226
+ function Ne(e, t, n) {
227
+ return e.render ? e.render(t, n) : Z(t, e);
81
228
  }
82
- let V = d({
229
+ function Pe(e) {
230
+ let t = e.maxWidth ?? e.width;
231
+ if (t !== void 0) return { maxWidth: D(t) };
232
+ }
233
+ function Fe(e, t) {
234
+ let n = Z(e, t);
235
+ return n == null || n === "-" ? void 0 : String(n);
236
+ }
237
+ let $ = f({
83
238
  props: {
84
239
  col: {
85
240
  type: Object,
@@ -95,61 +250,137 @@ var x = ["onClick"], S = {
95
250
  }
96
251
  },
97
252
  setup(e) {
98
- return () => B(e.col, e.row, e.index);
253
+ return () => Ne(e.col, e.row, e.index);
99
254
  }
100
255
  });
101
- return (i, d) => (m(), s("div", { class: f(["k-table-wrap", [`k-table-wrap--${N.value}`, { "k-table-wrap--bordered": C.bordered }]]) }, [
102
- c("div", { class: f(["k-table-scroll", { "k-table-scroll--sticky": C.stickyHeader }]) }, [c("table", {
103
- class: f(["k-table", {
256
+ return (a, f) => (h(), c("div", { class: p(["k-table-wrap", [`k-table-wrap--${le.value}`, { "k-table-wrap--bordered": C.bordered }]]) }, [
257
+ l("div", {
258
+ class: p(["k-table-scroll", { "k-table-scroll--sticky": ue.value }]),
259
+ style: m(de.value)
260
+ }, [l("table", {
261
+ class: p(["k-table", {
104
262
  "k-table--striped": C.striped,
105
263
  "k-table--single-line": C.singleLine
106
264
  }]),
107
- style: p(P.value)
108
- }, [c("thead", null, [c("tr", null, [(m(!0), s(r, null, g(C.columns, (e) => (m(), s("th", {
109
- key: e.key,
110
- style: p(I(e)),
111
- class: f(e.align ? `k-table__th--${e.align}` : "")
112
- }, [_(i.$slots, `header-${e.key}`, { col: e }, () => [l(v(F(e)), 1)], !0)], 6))), 128))])]), c("tbody", null, [(m(!0), s(r, null, g(M.value, (e, t) => (m(), s("tr", {
113
- key: R(e, t),
114
- class: f(z(e, t)),
115
- onClick: (t) => C.hoverable && E("rowClick", e)
116
- }, [(m(!0), s(r, null, g(C.columns, (n) => (m(), s("td", {
117
- key: n.key,
118
- class: f([
119
- n.cellClass,
120
- n.className,
121
- n.align ? `k-table__td--${n.align}` : ""
122
- ])
123
- }, [_(i.$slots, `cell-${n.key}`, {
124
- row: e,
125
- value: L(e, n),
126
- index: t
127
- }, () => [u(y(V), {
128
- col: n,
129
- row: e,
130
- index: t
131
- }, null, 8, [
132
- "col",
133
- "row",
134
- "index"
135
- ])], !0)], 2))), 128))], 10, x))), 128))])], 6), !C.loading && O.value.length === 0 ? (m(), s("div", S, [_(i.$slots, "empty", {}, () => [u(t, {
265
+ style: m(fe.value)
266
+ }, [
267
+ l("colgroup", null, [(h(!0), c(i, null, _(E.value, (e) => (h(), c("col", {
268
+ key: e.key,
269
+ style: m(pe(e))
270
+ }, null, 4))), 128))]),
271
+ l("thead", null, [l("tr", null, [(h(!0), c(i, null, _(E.value, (t) => (h(), c("th", {
272
+ key: t.key,
273
+ scope: "col",
274
+ class: p([
275
+ t.align ? `k-table__th--${t.align}` : "",
276
+ ...j(t),
277
+ { "k-table__th--sortable": F(t) }
278
+ ]),
279
+ style: m(A(t, !0)),
280
+ "aria-sort": ye(t)
281
+ }, [t.type === "selection" ? (h(), o(e, {
282
+ key: 0,
283
+ "model-value": X.value,
284
+ indeterminate: Te.value,
285
+ disabled: Y.value.length === 0,
286
+ "onUpdate:modelValue": Oe,
287
+ onClick: f[0] ||= S(() => {}, ["stop"])
288
+ }, null, 8, [
289
+ "model-value",
290
+ "indeterminate",
291
+ "disabled"
292
+ ])) : F(t) ? (h(), c("button", {
293
+ key: 1,
294
+ type: "button",
295
+ class: "k-table__sorter",
296
+ onClick: (e) => be(t)
297
+ }, [v(a.$slots, `header-${t.key}`, { col: t }, () => [u(y(ke(t)), 1)], !0), l("span", { class: p(["k-table__sort-icon", { "is-active": I(t) }]) }, [I(t) === "ascend" ? (h(), o(b(te), {
298
+ key: 0,
299
+ size: 13
300
+ })) : I(t) === "descend" ? (h(), o(b(ee), {
301
+ key: 1,
302
+ size: 13
303
+ })) : (h(), o(b(ne), {
304
+ key: 2,
305
+ size: 13
306
+ }))], 2)], 8, ie)) : v(a.$slots, `header-${t.key}`, {
307
+ key: 2,
308
+ col: t
309
+ }, () => [u(y(ke(t)), 1)], !0)], 14, re))), 128))])]),
310
+ l("tbody", null, [(h(!0), c(i, null, _(U.value, (t, n) => (h(), c("tr", {
311
+ key: Q(t, n),
312
+ class: p(Me(t, n)),
313
+ onClick: (e) => C.hoverable && T("rowClick", t)
314
+ }, [(h(!0), c(i, null, _(E.value, (r) => (h(), c("td", {
315
+ key: r.key,
316
+ class: p([
317
+ r.cellClass,
318
+ r.className,
319
+ r.align ? `k-table__td--${r.align}` : "",
320
+ ...j(r)
321
+ ]),
322
+ style: m(A(r, !1))
323
+ }, [r.type === "selection" ? (h(), c("span", {
324
+ key: 0,
325
+ class: "k-table__selection",
326
+ onClick: f[1] ||= S(() => {}, ["stop"])
327
+ }, [d(e, {
328
+ "model-value": we(t, n),
329
+ disabled: q(t),
330
+ "onUpdate:modelValue": (e) => De(t, n, e)
331
+ }, null, 8, [
332
+ "model-value",
333
+ "disabled",
334
+ "onUpdate:modelValue"
335
+ ])])) : r.ellipsis ? (h(), c("div", {
336
+ key: 1,
337
+ class: "k-table__ellipsis",
338
+ style: m(Pe(r)),
339
+ title: Fe(t, r)
340
+ }, [v(a.$slots, `cell-${r.key}`, {
341
+ row: t,
342
+ value: Z(t, r),
343
+ index: n
344
+ }, () => [d(b($), {
345
+ col: r,
346
+ row: t,
347
+ index: n
348
+ }, null, 8, [
349
+ "col",
350
+ "row",
351
+ "index"
352
+ ])], !0)], 12, oe)) : v(a.$slots, `cell-${r.key}`, {
353
+ key: 2,
354
+ row: t,
355
+ value: Z(t, r),
356
+ index: n
357
+ }, () => [d(b($), {
358
+ col: r,
359
+ row: t,
360
+ index: n
361
+ }, null, 8, [
362
+ "col",
363
+ "row",
364
+ "index"
365
+ ])], !0)], 6))), 128))], 10, ae))), 128))])
366
+ ], 6), !C.loading && L.value.length === 0 ? (h(), c("div", se, [v(a.$slots, "empty", {}, () => [d(n, {
136
367
  title: C.empty || "暂无数据",
137
368
  compact: ""
138
- }, null, 8, ["title"])], !0)])) : o("", !0)], 2),
139
- A.value > 0 ? (m(), a(n, {
369
+ }, null, 8, ["title"])], !0)])) : s("", !0)], 6),
370
+ V.value > 0 ? (h(), o(r, {
140
371
  key: 0,
141
- page: D.value,
142
- "onUpdate:page": d[0] ||= (e) => D.value = e,
372
+ page: z.value,
373
+ "onUpdate:page": f[2] ||= (e) => z.value = e,
143
374
  class: "k-table-pagination",
144
- "page-size": A.value,
145
- total: j.value,
375
+ "page-size": V.value,
376
+ total: H.value,
146
377
  "show-summary": ""
147
378
  }, null, 8, [
148
379
  "page",
149
380
  "page-size",
150
381
  "total"
151
- ])) : o("", !0),
152
- u(e, {
382
+ ])) : s("", !0),
383
+ d(t, {
153
384
  show: C.loading,
154
385
  text: "加载中..."
155
386
  }, null, 8, ["show"])