@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.
- package/dist/components/KAutoComplete.vue.d.ts +2 -0
- package/dist/components/KAutoComplete.vue.js +1 -1
- package/dist/components/KAutoComplete.vue_vue_type_script_setup_true_lang.js +89 -29
- package/dist/components/KCalendar.vue.js +1 -1
- package/dist/components/KCalendar.vue_vue_type_script_setup_true_lang.js +132 -39
- package/dist/components/KCascader.vue.d.ts +2 -0
- package/dist/components/KCascader.vue.js +1 -1
- package/dist/components/KCascader.vue_vue_type_script_setup_true_lang.js +19 -18
- package/dist/components/KCheckbox.vue.d.ts +6 -2
- package/dist/components/KCheckbox.vue.js +1 -1
- package/dist/components/KCheckbox.vue_vue_type_script_setup_true_lang.js +38 -18
- package/dist/components/KCheckboxGroup.vue.d.ts +2 -0
- package/dist/components/KCheckboxGroup.vue.js +1 -1
- package/dist/components/KCheckboxGroup.vue_vue_type_script_setup_true_lang.js +23 -15
- package/dist/components/KCollapse.vue.d.ts +3 -1
- package/dist/components/KCollapse.vue.js +1 -1
- package/dist/components/KCollapse.vue_vue_type_script_setup_true_lang.js +27 -16
- package/dist/components/KDataTable.vue.d.ts +48 -1
- package/dist/components/KDataTable.vue.js +1 -1
- package/dist/components/KDataTable.vue_vue_type_script_setup_true_lang.js +305 -74
- package/dist/components/KDatePicker.vue.d.ts +8 -0
- package/dist/components/KDatePicker.vue_vue_type_script_setup_true_lang.js +32 -22
- package/dist/components/KDialog.vue.d.ts +4 -4
- package/dist/components/KDialog.vue.js +1 -1
- package/dist/components/KDialog.vue_vue_type_script_setup_true_lang.js +80 -71
- package/dist/components/KDropdown.vue.d.ts +4 -3
- package/dist/components/KDropdown.vue_vue_type_script_setup_true_lang.js +45 -28
- package/dist/components/KDynamicInput.vue.d.ts +2 -0
- package/dist/components/KDynamicInput.vue.js +1 -1
- package/dist/components/KDynamicInput.vue_vue_type_script_setup_true_lang.js +17 -6
- package/dist/components/KDynamicTags.vue.d.ts +2 -0
- package/dist/components/KDynamicTags.vue.js +1 -1
- package/dist/components/KDynamicTags.vue_vue_type_script_setup_true_lang.js +11 -10
- package/dist/components/KForm.vue.d.ts +12 -0
- package/dist/components/KForm.vue.js +1 -1
- package/dist/components/KForm.vue_vue_type_script_setup_true_lang.js +26 -4
- package/dist/components/KFormField.vue.d.ts +3 -1
- package/dist/components/KFormField.vue.js +1 -1
- package/dist/components/KFormField.vue_vue_type_script_setup_true_lang.js +124 -61
- package/dist/components/KInputNumber.vue.js +1 -1
- package/dist/components/KInputNumber.vue_vue_type_script_setup_true_lang.js +35 -29
- package/dist/components/KMention.vue.d.ts +2 -0
- package/dist/components/KMention.vue.js +1 -1
- package/dist/components/KMention.vue_vue_type_script_setup_true_lang.js +34 -33
- package/dist/components/KMenu.vue.js +1 -1
- package/dist/components/KMenu.vue_vue_type_script_setup_true_lang.js +132 -51
- package/dist/components/KMenuItem.vue.js +1 -1
- package/dist/components/KMenuItem.vue_vue_type_script_setup_true_lang.js +21 -6
- package/dist/components/KMessage.d.ts +5 -0
- package/dist/components/KMessage.js +36 -23
- package/dist/components/KNotification.d.ts +8 -0
- package/dist/components/KNotification.js +45 -29
- package/dist/components/KNotificationProvider.vue.js +3 -8
- package/dist/components/KNotificationProvider.vue_vue_type_script_setup_true_lang.js +11 -0
- package/dist/components/KPagination.vue.d.ts +4 -1
- package/dist/components/KPagination.vue.js +1 -1
- package/dist/components/KPagination.vue_vue_type_script_setup_true_lang.js +36 -33
- package/dist/components/KRadio.vue.d.ts +1 -0
- package/dist/components/KRadio.vue.js +1 -1
- package/dist/components/KRadio.vue_vue_type_script_setup_true_lang.js +22 -14
- package/dist/components/KRadioGroup.vue.d.ts +4 -2
- package/dist/components/KRadioGroup.vue.js +1 -1
- package/dist/components/KRadioGroup.vue_vue_type_script_setup_true_lang.js +16 -4
- package/dist/components/KRate.vue.d.ts +5 -0
- package/dist/components/KRate.vue.js +1 -1
- package/dist/components/KRate.vue_vue_type_script_setup_true_lang.js +72 -24
- package/dist/components/KSelect.vue.d.ts +2 -2
- package/dist/components/KSelect.vue.js +1 -1
- package/dist/components/KSelect.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/components/KSlider.vue.d.ts +2 -0
- package/dist/components/KSlider.vue.js +1 -1
- package/dist/components/KSlider.vue_vue_type_script_setup_true_lang.js +17 -16
- package/dist/components/KTextarea.vue.d.ts +2 -0
- package/dist/components/KTextarea.vue.js +1 -1
- package/dist/components/KTextarea.vue_vue_type_script_setup_true_lang.js +10 -9
- package/dist/components/KTimePicker.vue.d.ts +2 -0
- package/dist/components/KTimePicker.vue.js +1 -1
- package/dist/components/KTimePicker.vue_vue_type_script_setup_true_lang.js +61 -48
- package/dist/components/KTransfer.vue.d.ts +2 -0
- package/dist/components/KTransfer.vue.js +1 -1
- package/dist/components/KTransfer.vue_vue_type_script_setup_true_lang.js +35 -34
- package/dist/components/KTreeSelect.vue.d.ts +2 -0
- package/dist/components/KTreeSelect.vue.js +1 -1
- package/dist/components/KTreeSelect.vue_vue_type_script_setup_true_lang.js +15 -14
- package/dist/components/KUpload.vue.d.ts +14 -0
- package/dist/components/KUpload.vue.js +1 -1
- package/dist/components/KUpload.vue_vue_type_script_setup_true_lang.js +159 -117
- package/dist/components/checkbox-context.d.ts +10 -0
- package/dist/components/checkbox-context.js +4 -0
- package/dist/components/form-context.d.ts +19 -2
- package/dist/components/form-context.js +31 -1
- package/dist/components/menu-context.d.ts +4 -0
- package/dist/components/radio-context.d.ts +6 -1
- package/dist/k-ui.css +1 -1
- package/dist/styles/tokens.css +40 -1
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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
|
|
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(
|
|
16
|
-
let
|
|
17
|
-
|
|
18
|
-
|
|
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,
|
|
21
|
-
"model-value":
|
|
22
|
-
disabled:
|
|
23
|
-
class:
|
|
24
|
-
"onUpdate:modelValue":
|
|
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:
|
|
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 {
|
|
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-
|
|
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 {
|
|
2
|
-
import { AccordionRoot as
|
|
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
|
|
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(
|
|
15
|
-
let
|
|
16
|
-
function
|
|
17
|
-
let t = Array.isArray(e) ? e
|
|
18
|
-
|
|
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
|
-
|
|
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":
|
|
36
|
+
"model-value": n.modelValue,
|
|
26
37
|
class: "k-collapse",
|
|
27
|
-
"onUpdate:modelValue":
|
|
38
|
+
"onUpdate:modelValue": p
|
|
28
39
|
}, {
|
|
29
|
-
default:
|
|
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 {
|
|
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:
|
|
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-
|
|
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 "./
|
|
2
|
-
import t from "./
|
|
3
|
-
import n from "./
|
|
4
|
-
import
|
|
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
|
|
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__ */
|
|
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: [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}),
|
|
56
|
-
if (
|
|
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
|
-
|
|
59
|
-
typeof e == "number"
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
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.
|
|
135
|
+
return !!e.sorter;
|
|
66
136
|
}
|
|
67
137
|
function I(e) {
|
|
68
|
-
|
|
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
|
|
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
|
-
|
|
74
|
-
|
|
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
|
|
77
|
-
return [{ "k-table__row--hoverable":
|
|
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
|
|
80
|
-
return e.render ? e.render(t, n) :
|
|
226
|
+
function Ne(e, t, n) {
|
|
227
|
+
return e.render ? e.render(t, n) : Z(t, e);
|
|
81
228
|
}
|
|
82
|
-
|
|
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 () =>
|
|
253
|
+
return () => Ne(e.col, e.row, e.index);
|
|
99
254
|
}
|
|
100
255
|
});
|
|
101
|
-
return (
|
|
102
|
-
|
|
103
|
-
class:
|
|
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:
|
|
108
|
-
}, [
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
"
|
|
135
|
-
|
|
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)])) :
|
|
139
|
-
|
|
369
|
+
}, null, 8, ["title"])], !0)])) : s("", !0)], 6),
|
|
370
|
+
V.value > 0 ? (h(), o(r, {
|
|
140
371
|
key: 0,
|
|
141
|
-
page:
|
|
142
|
-
"onUpdate:page":
|
|
372
|
+
page: z.value,
|
|
373
|
+
"onUpdate:page": f[2] ||= (e) => z.value = e,
|
|
143
374
|
class: "k-table-pagination",
|
|
144
|
-
"page-size":
|
|
145
|
-
total:
|
|
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
|
-
])) :
|
|
152
|
-
|
|
382
|
+
])) : s("", !0),
|
|
383
|
+
d(t, {
|
|
153
384
|
show: C.loading,
|
|
154
385
|
text: "加载中..."
|
|
155
386
|
}, null, 8, ["show"])
|