@vtable-guild/vtable-guild 2.2.2 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/src/components/Button.mjs +108 -0
- package/dist/core/src/components/Checkbox.mjs +84 -0
- package/dist/core/src/components/Input.mjs +82 -0
- package/dist/core/src/components/Radio.mjs +69 -0
- package/dist/core/src/components/Scrollbar.mjs +179 -0
- package/dist/core/src/components/ScrollbarBar.mjs +103 -0
- package/dist/core/src/components/Tooltip.mjs +321 -0
- package/dist/core/src/components/VTableGuildConfigProvider.mjs +77 -0
- package/dist/core/src/components/VirtualList/Filler.mjs +55 -0
- package/dist/core/src/components/VirtualList/Item.mjs +29 -0
- package/dist/core/src/components/VirtualList/VirtualList.mjs +373 -0
- package/dist/core/src/components/VirtualList/VirtualScrollBar.mjs +216 -0
- package/dist/core/src/components/VirtualList/hooks/useChildren.mjs +21 -0
- package/dist/core/src/components/VirtualList/hooks/useDiffItem.mjs +16 -0
- package/dist/core/src/components/VirtualList/hooks/useFrameWheel.mjs +48 -0
- package/dist/core/src/components/VirtualList/hooks/useGetSize.mjs +25 -0
- package/dist/core/src/components/VirtualList/hooks/useHeights.mjs +56 -0
- package/dist/core/src/components/VirtualList/hooks/useMobileTouchMove.mjs +40 -0
- package/dist/core/src/components/VirtualList/hooks/useOriginScroll.mjs +17 -0
- package/dist/core/src/components/VirtualList/hooks/useScrollDrag.mjs +41 -0
- package/dist/core/src/components/VirtualList/hooks/useScrollTo.mjs +88 -0
- package/dist/core/src/components/VirtualList/utils/CacheMap.mjs +24 -0
- package/dist/core/src/components/VirtualList/utils/algorithmUtil.mjs +22 -0
- package/dist/core/src/components/VirtualList/utils/isFirefox.mjs +4 -0
- package/dist/core/src/components/VirtualList/utils/scrollbarUtil.mjs +7 -0
- package/dist/core/src/composables/useScrollbar.mjs +55 -0
- package/dist/core/src/composables/useTheme.mjs +92 -0
- package/dist/core/src/index.d.ts +1 -0
- package/dist/core/src/index.d.ts.map +1 -1
- package/dist/core/src/plugin/index.mjs +27 -0
- package/dist/core/src/utils/classPrefix.mjs +100 -0
- package/dist/core/src/utils/devWarn.d.ts +4 -0
- package/dist/core/src/utils/devWarn.d.ts.map +1 -0
- package/dist/core/src/utils/devWarn.mjs +5 -0
- package/dist/core/src/utils/mergeDeep.mjs +20 -0
- package/dist/core/src/utils/props.mjs +33 -0
- package/dist/core/src/utils/tv.mjs +19 -0
- package/dist/icons/src/AntdvEmptyIcon.mjs +37 -0
- package/dist/icons/src/AntdvSpinIndicator.mjs +23 -0
- package/dist/icons/src/CaretDownIcon.d.ts.map +1 -1
- package/dist/icons/src/CaretDownIcon.mjs +9 -0
- package/dist/icons/src/CaretRightIcon.d.ts.map +1 -1
- package/dist/icons/src/CaretUpIcon.d.ts.map +1 -1
- package/dist/icons/src/CaretUpIcon.mjs +9 -0
- package/dist/icons/src/DownOutlinedIcon.d.ts.map +1 -1
- package/dist/icons/src/DownOutlinedIcon.mjs +9 -0
- package/dist/icons/src/ElArrowDownIcon.d.ts.map +1 -1
- package/dist/icons/src/ElArrowDownIcon.mjs +9 -0
- package/dist/icons/src/ElCaretBottomIcon.d.ts.map +1 -1
- package/dist/icons/src/ElCaretBottomIcon.mjs +9 -0
- package/dist/icons/src/ElCaretTopIcon.d.ts.map +1 -1
- package/dist/icons/src/ElCaretTopIcon.mjs +9 -0
- package/dist/icons/src/ElFilterIcon.d.ts.map +1 -1
- package/dist/icons/src/ElLoadingIcon.mjs +28 -0
- package/dist/icons/src/FilterFilledIcon.d.ts.map +1 -1
- package/dist/icons/src/FilterFilledIcon.mjs +9 -0
- package/dist/icons/src/SearchIcon.d.ts.map +1 -1
- package/dist/icons/src/SearchIcon.mjs +9 -0
- package/dist/icons/src/createSvgIcon.d.ts +13 -0
- package/dist/icons/src/createSvgIcon.d.ts.map +1 -0
- package/dist/icons/src/createSvgIcon.mjs +23 -0
- package/dist/index.mjs +82 -10196
- package/dist/table/src/components/ColGroup.mjs +25 -0
- package/dist/table/src/components/ExpandIcon.mjs +60 -0
- package/dist/table/src/components/FilterDropdown.d.ts.map +1 -1
- package/dist/table/src/components/FilterDropdown.mjs +324 -0
- package/dist/table/src/components/FilterIcon.mjs +30 -0
- package/dist/table/src/components/ResizeHandle.mjs +28 -0
- package/dist/table/src/components/SelectionCheckbox.mjs +33 -0
- package/dist/table/src/components/SelectionDropdown.d.ts.map +1 -1
- package/dist/table/src/components/SelectionDropdown.mjs +73 -0
- package/dist/table/src/components/SelectionRadio.mjs +28 -0
- package/dist/table/src/components/SortButton.mjs +30 -0
- package/dist/table/src/components/Table.d.ts.map +1 -1
- package/dist/table/src/components/Table.mjs +781 -0
- package/dist/table/src/components/TableBody.mjs +124 -0
- package/dist/table/src/components/TableCell.d.ts.map +1 -1
- package/dist/table/src/components/TableCell.mjs +222 -0
- package/dist/table/src/components/TableEmpty.mjs +38 -0
- package/dist/table/src/components/TableHeader.mjs +51 -0
- package/dist/table/src/components/TableHeaderCell.d.ts.map +1 -1
- package/dist/table/src/components/TableHeaderCell.mjs +391 -0
- package/dist/table/src/components/TableLoading.mjs +46 -0
- package/dist/table/src/components/TableRow.mjs +34 -0
- package/dist/table/src/components/VTable.vue.d.ts.map +1 -1
- package/dist/table/src/components/VTable.vue.mjs +155 -0
- package/dist/table/src/components/VTable.vue2.mjs +4 -0
- package/dist/table/src/components/VTableSummary.mjs +29 -0
- package/dist/table/src/components/VTableSummaryCell.d.ts.map +1 -1
- package/dist/table/src/components/VTableSummaryCell.mjs +68 -0
- package/dist/table/src/components/VTableSummaryRow.mjs +19 -0
- package/dist/table/src/components/VirtualTableBody.d.ts.map +1 -1
- package/dist/table/src/components/VirtualTableBody.mjs +172 -0
- package/dist/table/src/composables/index.d.ts +2 -1
- package/dist/table/src/composables/index.d.ts.map +1 -1
- package/dist/table/src/composables/useColumns.d.ts +6 -1
- package/dist/table/src/composables/useColumns.d.ts.map +1 -1
- package/dist/table/src/composables/useColumns.mjs +81 -0
- package/dist/table/src/composables/useControlledColumnState.d.ts +24 -0
- package/dist/table/src/composables/useControlledColumnState.d.ts.map +1 -0
- package/dist/table/src/composables/useControlledColumnState.mjs +23 -0
- package/dist/table/src/composables/useExpand.mjs +37 -0
- package/dist/table/src/composables/useFilter.d.ts.map +1 -1
- package/dist/table/src/composables/useFilter.mjs +68 -0
- package/dist/table/src/composables/useFixedColumnStyle.d.ts +18 -0
- package/dist/table/src/composables/useFixedColumnStyle.d.ts.map +1 -0
- package/dist/table/src/composables/useFixedColumnStyle.mjs +21 -0
- package/dist/table/src/composables/useHoverState.mjs +26 -0
- package/dist/table/src/composables/useResize.mjs +42 -0
- package/dist/table/src/composables/useScroll.d.ts +5 -4
- package/dist/table/src/composables/useScroll.d.ts.map +1 -1
- package/dist/table/src/composables/useScroll.mjs +68 -0
- package/dist/table/src/composables/useSelection.d.ts.map +1 -1
- package/dist/table/src/composables/useSelection.mjs +246 -0
- package/dist/table/src/composables/useSorter.d.ts +1 -5
- package/dist/table/src/composables/useSorter.d.ts.map +1 -1
- package/dist/table/src/composables/useSorter.mjs +161 -0
- package/dist/table/src/composables/useTreeData.d.ts +2 -0
- package/dist/table/src/composables/useTreeData.d.ts.map +1 -1
- package/dist/table/src/composables/useTreeData.mjs +92 -0
- package/dist/table/src/composables/useVirtual.mjs +19 -0
- package/dist/table/src/constants.mjs +8 -0
- package/dist/table/src/context.d.ts +90 -85
- package/dist/table/src/context.d.ts.map +1 -1
- package/dist/table/src/context.mjs +4 -0
- package/dist/table/src/index.d.ts.map +1 -1
- package/dist/table/src/index.mjs +23 -0
- package/dist/table/src/preset-config.mjs +35 -0
- package/dist/table/src/utils/cell.mjs +79 -0
- package/dist/table/src/utils/popupPosition.d.ts +20 -0
- package/dist/table/src/utils/popupPosition.d.ts.map +1 -0
- package/dist/table/src/utils/popupPosition.mjs +24 -0
- package/dist/table/src/utils/popupPosition.test.d.ts +2 -0
- package/dist/table/src/utils/popupPosition.test.d.ts.map +1 -0
- package/dist/table/src/utils/vnode.mjs +10 -0
- package/dist/theme/src/presets/antdv/button.mjs +70 -0
- package/dist/theme/src/presets/antdv/checkbox.mjs +51 -0
- package/dist/theme/src/presets/antdv/input.mjs +40 -0
- package/dist/theme/src/presets/antdv/radio.mjs +34 -0
- package/dist/theme/src/presets/antdv/scrollbar.mjs +22 -0
- package/dist/theme/src/presets/antdv/table-locale.mjs +55 -0
- package/dist/theme/src/presets/antdv/table.mjs +285 -0
- package/dist/theme/src/presets/antdv/tooltip.mjs +20 -0
- package/dist/theme/src/presets/element-plus/button.mjs +70 -0
- package/dist/theme/src/presets/element-plus/checkbox.mjs +65 -0
- package/dist/theme/src/presets/element-plus/input.mjs +39 -0
- package/dist/theme/src/presets/element-plus/radio.mjs +34 -0
- package/dist/theme/src/presets/element-plus/scrollbar.mjs +22 -0
- package/dist/theme/src/presets/element-plus/table-locale.mjs +56 -0
- package/dist/theme/src/presets/element-plus/table.mjs +235 -0
- package/dist/theme/src/presets/element-plus/tooltip.mjs +21 -0
- package/dist/theme/src/presets/index.mjs +92 -0
- package/package.json +5 -2
- package/dist/index.cjs +0 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { reactive as h, ref as g, onBeforeUnmount as W } from "vue";
|
|
2
|
+
import { getColumnKey as b } from "./useColumns.mjs";
|
|
3
|
+
function S(v) {
|
|
4
|
+
const r = h({}), c = g(!1);
|
|
5
|
+
let t = null, s = "", m = 0, u = 0;
|
|
6
|
+
function a(n) {
|
|
7
|
+
if (!t) return;
|
|
8
|
+
const o = n.clientX - m;
|
|
9
|
+
let e = u + o;
|
|
10
|
+
const l = t.minWidth ?? 50, i = t.maxWidth;
|
|
11
|
+
e = Math.max(l, e), i !== void 0 && (e = Math.min(i, e)), r[s] = e;
|
|
12
|
+
}
|
|
13
|
+
function f(n) {
|
|
14
|
+
if (!t) return;
|
|
15
|
+
const o = t, e = r[s];
|
|
16
|
+
p(), v.onResizeColumn?.(o, e);
|
|
17
|
+
}
|
|
18
|
+
function p() {
|
|
19
|
+
document.removeEventListener("pointermove", a), document.removeEventListener("pointerup", f), document.body.style.cursor = "", document.body.style.userSelect = "", c.value = !1, t = null;
|
|
20
|
+
}
|
|
21
|
+
function y(n, o, e) {
|
|
22
|
+
e.preventDefault(), e.stopPropagation(), t = n;
|
|
23
|
+
const l = b(n) ?? String(o);
|
|
24
|
+
s = String(l), m = e.clientX;
|
|
25
|
+
const i = r[s];
|
|
26
|
+
if (i)
|
|
27
|
+
u = i;
|
|
28
|
+
else {
|
|
29
|
+
const d = n.width;
|
|
30
|
+
u = typeof d == "number" ? d : parseInt(String(d) || "100", 10);
|
|
31
|
+
}
|
|
32
|
+
c.value = !0, document.body.style.cursor = "col-resize", document.body.style.userSelect = "none", document.addEventListener("pointermove", a), document.addEventListener("pointerup", f);
|
|
33
|
+
}
|
|
34
|
+
return W(p), {
|
|
35
|
+
columnWidths: r,
|
|
36
|
+
startResize: y,
|
|
37
|
+
isResizing: c
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
S as useResize
|
|
42
|
+
};
|
|
@@ -10,13 +10,14 @@ export interface FixedOffset {
|
|
|
10
10
|
isLastLeft?: boolean;
|
|
11
11
|
isFirstRight?: boolean;
|
|
12
12
|
}
|
|
13
|
+
export interface ScrollEdgeState {
|
|
14
|
+
atStart: ComputedRef<boolean>;
|
|
15
|
+
atEnd: ComputedRef<boolean>;
|
|
16
|
+
}
|
|
13
17
|
export interface UseScrollReturn {
|
|
14
18
|
headerWrapRef: Ref<HTMLElement | null>;
|
|
15
19
|
bodyWrapRef: Ref<HTMLElement | null>;
|
|
16
|
-
scrollState:
|
|
17
|
-
atStart: boolean;
|
|
18
|
-
atEnd: boolean;
|
|
19
|
-
}>;
|
|
20
|
+
scrollState: ScrollEdgeState;
|
|
20
21
|
handleBodyScroll: (e: {
|
|
21
22
|
scrollTop: number;
|
|
22
23
|
scrollLeft: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useScroll.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/useScroll.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,WAAW,EAAE,KAAK,GAAG,EAAE,MAAM,KAAK,CAAA;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAO/C,MAAM,WAAW,YAAY;IAC3B,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,
|
|
1
|
+
{"version":3,"file":"useScroll.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/useScroll.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkC,KAAK,WAAW,EAAE,KAAK,GAAG,EAAE,MAAM,KAAK,CAAA;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAO/C,MAAM,WAAW,YAAY;IAC3B,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACnB,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;IAC7B,KAAK,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;CAC5B;AAED,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IACtC,WAAW,EAAE,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,CAAA;IACpC,WAAW,EAAE,eAAe,CAAA;IAC5B,gBAAgB,EAAE,CAAC,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAA;IACxE,YAAY,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAA;IAChD,iBAAiB,EAAE,MAAM,IAAI,CAAA;IAC7B,oBAAoB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,aAAa,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAC3E;AAED,wBAAgB,SAAS,CAAC,OAAO,EAAE;IACjC,cAAc,EAAE,MAAM,UAAU,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAAE,CAAA;CAC5D,GAAG,eAAe,CAoGlB"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { ref as r, computed as h, watch as W, nextTick as b } from "vue";
|
|
2
|
+
import { getColumnKey as k } from "./useColumns.mjs";
|
|
3
|
+
function w(f, o) {
|
|
4
|
+
return k(f) ?? o;
|
|
5
|
+
}
|
|
6
|
+
function C(f) {
|
|
7
|
+
const o = r(null), i = r(null), c = r(0), s = r(0), x = {
|
|
8
|
+
atStart: h(() => c.value <= 0),
|
|
9
|
+
atEnd: h(() => c.value >= s.value - 1)
|
|
10
|
+
};
|
|
11
|
+
function a(e, n) {
|
|
12
|
+
c.value = e, typeof n == "number" && (s.value = Math.max(0, n)), o.value && (o.value.scrollLeft = e);
|
|
13
|
+
}
|
|
14
|
+
function S(e) {
|
|
15
|
+
const n = i.value;
|
|
16
|
+
a(e.scrollLeft, n ? n.scrollWidth - n.clientWidth : s.value);
|
|
17
|
+
}
|
|
18
|
+
function g() {
|
|
19
|
+
const e = i.value;
|
|
20
|
+
e && a(e.scrollLeft, e.scrollWidth - e.clientWidth);
|
|
21
|
+
}
|
|
22
|
+
W(i, () => {
|
|
23
|
+
b(g);
|
|
24
|
+
});
|
|
25
|
+
const L = h(() => {
|
|
26
|
+
const e = f.displayColumns(), n = /* @__PURE__ */ new Map();
|
|
27
|
+
let p = 0, m = -1;
|
|
28
|
+
for (let t = 0; t < e.length; t++)
|
|
29
|
+
e[t].fixed === "left" && (m = t);
|
|
30
|
+
for (let t = 0; t < e.length; t++) {
|
|
31
|
+
const l = e[t];
|
|
32
|
+
if (l.fixed !== "left") continue;
|
|
33
|
+
const u = w(l, t), d = typeof l.width == "number" ? l.width : parseInt(String(l.width) || "0", 10);
|
|
34
|
+
n.set(u, {
|
|
35
|
+
left: p,
|
|
36
|
+
isLastLeft: t === m
|
|
37
|
+
}), p += d;
|
|
38
|
+
}
|
|
39
|
+
let y = 0, v = e.length;
|
|
40
|
+
for (let t = 0; t < e.length; t++)
|
|
41
|
+
if (e[t].fixed === "right") {
|
|
42
|
+
v = t;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
for (let t = e.length - 1; t >= 0; t--) {
|
|
46
|
+
const l = e[t];
|
|
47
|
+
if (l.fixed !== "right") continue;
|
|
48
|
+
const u = w(l, t), d = typeof l.width == "number" ? l.width : parseInt(String(l.width) || "0", 10);
|
|
49
|
+
n.set(u, {
|
|
50
|
+
right: y,
|
|
51
|
+
isFirstRight: t === v
|
|
52
|
+
}), y += d;
|
|
53
|
+
}
|
|
54
|
+
return n;
|
|
55
|
+
});
|
|
56
|
+
return {
|
|
57
|
+
headerWrapRef: o,
|
|
58
|
+
bodyWrapRef: i,
|
|
59
|
+
scrollState: x,
|
|
60
|
+
handleBodyScroll: S,
|
|
61
|
+
fixedOffsets: L,
|
|
62
|
+
updateScrollState: g,
|
|
63
|
+
syncHorizontalScroll: a
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
C as useScroll
|
|
68
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSelection.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/useSelection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAWjD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,OAAO,CAAA;IACtB,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,mBAAmB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC1E,YAAY,EAAE,MAAM,YAAY,CAAC,OAAO,CAAC,GAAG,SAAS,CAAA;IACrD,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,CAAA;IAClD,IAAI,EAAE,MAAM,OAAO,EAAE,CAAA;IACrB,WAAW,EAAE,MAAM,OAAO,EAAE,CAAA;IAC5B,kBAAkB,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IAC7C,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAA;CAC/B;
|
|
1
|
+
{"version":3,"file":"useSelection.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/useSelection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAWjD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAA;IAChB,aAAa,EAAE,OAAO,CAAA;IACtB,QAAQ,EAAE,OAAO,CAAA;CAClB;AAED,MAAM,WAAW,mBAAmB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC1E,YAAY,EAAE,MAAM,YAAY,CAAC,OAAO,CAAC,GAAG,SAAS,CAAA;IACrD,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,KAAK,GAAG,CAAA;IAClD,IAAI,EAAE,MAAM,OAAO,EAAE,CAAA;IACrB,WAAW,EAAE,MAAM,OAAO,EAAE,CAAA;IAC5B,kBAAkB,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IAC7C,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAA;CAC/B;AAuDD,wBAAgB,YAAY,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAClE,OAAO,EAAE,mBAAmB,CAAC,OAAO,CAAC;;sBA2IZ,GAAG,KAAG,OAAO;yBA3FV,OAAO,KAAG,OAAO;gCAiHV,OAAO,SAAS,MAAM,KAAG,cAAc;wBAoJ/C,OAAO,SAAS,MAAM,gBAAgB,UAAU,KAAG,IAAI;0BAarD,OAAO,KAAG,IAAI;;2BAqCf,IAAI;0BAmBL,IAAI;gCAQE,GAAG,EAAE;EAgBvC"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { ref as P, watch as F, computed as w } from "vue";
|
|
2
|
+
function te(K) {
|
|
3
|
+
const { data: o, childrenColumnName: u, getRowKey: N } = K, C = [];
|
|
4
|
+
let x = 0;
|
|
5
|
+
function A(g, k, h) {
|
|
6
|
+
g.forEach((m) => {
|
|
7
|
+
const E = x, f = N(m, E), d = m[u], I = {
|
|
8
|
+
key: f,
|
|
9
|
+
record: m,
|
|
10
|
+
index: E,
|
|
11
|
+
level: k,
|
|
12
|
+
parentKey: h?.key,
|
|
13
|
+
childrenKeys: []
|
|
14
|
+
};
|
|
15
|
+
C.push(I), h?.childrenKeys.push(f), x += 1, Array.isArray(d) && d.length > 0 && A(d, k + 1, I);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return A(o, 0), C;
|
|
19
|
+
}
|
|
20
|
+
function ne(K) {
|
|
21
|
+
return K.data.map((o, u) => ({
|
|
22
|
+
key: K.getRowKey(o, u),
|
|
23
|
+
record: o,
|
|
24
|
+
index: u,
|
|
25
|
+
level: 0,
|
|
26
|
+
childrenKeys: []
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
function ce(K) {
|
|
30
|
+
const { rowSelection: o, getRowKey: u, data: N, visibleData: C, childrenColumnName: x, onSelectionChange: A } = K, g = P(/* @__PURE__ */ new Set()), k = P(!1), h = P(null);
|
|
31
|
+
F(
|
|
32
|
+
() => o()?.defaultSelectedRowKeys,
|
|
33
|
+
(e) => {
|
|
34
|
+
k.value || !e?.length || (g.value = new Set(e), k.value = !0);
|
|
35
|
+
},
|
|
36
|
+
{ immediate: !0 }
|
|
37
|
+
);
|
|
38
|
+
function m() {
|
|
39
|
+
return o()?.selectedRowKeys !== void 0;
|
|
40
|
+
}
|
|
41
|
+
const E = w(() => o()?.checkStrictly === !1), f = w(
|
|
42
|
+
() => E.value ? te({
|
|
43
|
+
data: N(),
|
|
44
|
+
childrenColumnName: x?.() ?? "children",
|
|
45
|
+
getRowKey: u
|
|
46
|
+
}) : ne({
|
|
47
|
+
data: N(),
|
|
48
|
+
getRowKey: u
|
|
49
|
+
})
|
|
50
|
+
), d = w(() => {
|
|
51
|
+
const e = /* @__PURE__ */ new Map();
|
|
52
|
+
return f.value.forEach((t) => e.set(t.key, t)), e;
|
|
53
|
+
}), I = w(
|
|
54
|
+
() => f.value.filter((e) => e.parentKey === void 0).map((e) => e.key)
|
|
55
|
+
);
|
|
56
|
+
function y(e) {
|
|
57
|
+
return o()?.getCheckboxProps?.(e)?.disabled ?? !1;
|
|
58
|
+
}
|
|
59
|
+
function j(e) {
|
|
60
|
+
return d.value.get(e)?.childrenKeys ?? [];
|
|
61
|
+
}
|
|
62
|
+
const G = w(() => {
|
|
63
|
+
const e = d.value, t = /* @__PURE__ */ new Map(), l = f.value;
|
|
64
|
+
for (let n = l.length - 1; n >= 0; n -= 1) {
|
|
65
|
+
const c = l[n], s = [];
|
|
66
|
+
for (const r of c.childrenKeys) {
|
|
67
|
+
const i = e.get(r);
|
|
68
|
+
if (!i || y(i.record)) continue;
|
|
69
|
+
s.push(r);
|
|
70
|
+
const a = t.get(r);
|
|
71
|
+
a && s.push(...a);
|
|
72
|
+
}
|
|
73
|
+
t.set(c.key, s);
|
|
74
|
+
}
|
|
75
|
+
return t;
|
|
76
|
+
});
|
|
77
|
+
function V(e) {
|
|
78
|
+
if (o()?.checkStrictly !== !1)
|
|
79
|
+
return new Set(e);
|
|
80
|
+
const t = new Set(e), l = (n) => {
|
|
81
|
+
const c = j(n);
|
|
82
|
+
c.forEach(l);
|
|
83
|
+
const s = d.value.get(n);
|
|
84
|
+
if (!s || y(s.record)) return;
|
|
85
|
+
const r = c.map((a) => d.value.get(a)).filter((a) => !!a && !y(a.record));
|
|
86
|
+
if (r.length === 0) return;
|
|
87
|
+
r.every((a) => t.has(a.key)) ? t.add(n) : t.delete(n);
|
|
88
|
+
};
|
|
89
|
+
return I.value.forEach(l), t;
|
|
90
|
+
}
|
|
91
|
+
const S = w(() => {
|
|
92
|
+
const e = o(), t = e?.selectedRowKeys !== void 0 ? new Set(e.selectedRowKeys) : g.value;
|
|
93
|
+
return V(t);
|
|
94
|
+
});
|
|
95
|
+
F(
|
|
96
|
+
[f, () => o()?.preserveSelectedRowKeys],
|
|
97
|
+
() => {
|
|
98
|
+
if (m() || o()?.preserveSelectedRowKeys) return;
|
|
99
|
+
const e = new Set(f.value.map((l) => l.key)), t = new Set(
|
|
100
|
+
Array.from(g.value).filter((l) => e.has(l))
|
|
101
|
+
);
|
|
102
|
+
t.size !== g.value.size && (g.value = t);
|
|
103
|
+
},
|
|
104
|
+
{ immediate: !0 }
|
|
105
|
+
);
|
|
106
|
+
function z(e) {
|
|
107
|
+
return S.value.has(e);
|
|
108
|
+
}
|
|
109
|
+
function p(e) {
|
|
110
|
+
return f.value.filter((t) => e.has(t.key)).map((t) => t.record);
|
|
111
|
+
}
|
|
112
|
+
function H() {
|
|
113
|
+
return C().map((e, t) => d.value.get(u(e, t)) ?? null).filter((e) => e !== null);
|
|
114
|
+
}
|
|
115
|
+
function D() {
|
|
116
|
+
return H().filter((e) => !y(e.record));
|
|
117
|
+
}
|
|
118
|
+
function J() {
|
|
119
|
+
return f.value.filter((e) => !y(e.record));
|
|
120
|
+
}
|
|
121
|
+
function L(e, t) {
|
|
122
|
+
const l = u(e, t), n = z(l), c = y(e);
|
|
123
|
+
if (o()?.checkStrictly !== !1)
|
|
124
|
+
return {
|
|
125
|
+
checked: n,
|
|
126
|
+
indeterminate: !1,
|
|
127
|
+
disabled: c
|
|
128
|
+
};
|
|
129
|
+
const s = G.value.get(l) ?? [];
|
|
130
|
+
if (s.length === 0)
|
|
131
|
+
return {
|
|
132
|
+
checked: n,
|
|
133
|
+
indeterminate: !1,
|
|
134
|
+
disabled: c
|
|
135
|
+
};
|
|
136
|
+
const r = s.filter((i) => S.value.has(i)).length;
|
|
137
|
+
return {
|
|
138
|
+
checked: n,
|
|
139
|
+
indeterminate: r > 0 && r < s.length,
|
|
140
|
+
disabled: c
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
function v(e, t) {
|
|
144
|
+
const l = V(e);
|
|
145
|
+
m() || (g.value = l);
|
|
146
|
+
{
|
|
147
|
+
const n = Array.from(l), c = p(l);
|
|
148
|
+
o()?.onChange?.(n, c), A?.();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
function q(e, t, l, n) {
|
|
152
|
+
const c = d.value.get(e);
|
|
153
|
+
if (!c || y(c.record)) return;
|
|
154
|
+
const s = t.has(e);
|
|
155
|
+
l ? t.add(e) : t.delete(e), s !== l && n.push(c.record), j(e).forEach(
|
|
156
|
+
(r) => q(r, t, l, n)
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
function O(e, t, l) {
|
|
160
|
+
const n = o();
|
|
161
|
+
if (!n) return;
|
|
162
|
+
const c = u(e, t), s = !z(c);
|
|
163
|
+
if (n.type !== "radio" && l?.shiftKey && h.value !== null && o()?.checkStrictly !== !1) {
|
|
164
|
+
const i = D(), a = i.findIndex((b) => b.key === c), M = i.findIndex(
|
|
165
|
+
(b) => b.key === h.value
|
|
166
|
+
);
|
|
167
|
+
if (a !== -1 && M !== -1) {
|
|
168
|
+
const [b, $] = a > M ? [M, a] : [a, M], R = new Set(S.value), B = [];
|
|
169
|
+
i.slice(b, $ + 1).forEach((T) => {
|
|
170
|
+
const ee = R.has(T.key);
|
|
171
|
+
s ? R.add(T.key) : R.delete(T.key), ee !== s && B.push(T.record);
|
|
172
|
+
}), v(R), n.onSelectMultiple?.(s, p(R), B), h.value = c;
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (n.type === "radio") {
|
|
177
|
+
const i = s ? /* @__PURE__ */ new Set([c]) : /* @__PURE__ */ new Set();
|
|
178
|
+
v(i), n.onSelect?.(e, s, p(i)), h.value = c;
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
const r = new Set(S.value);
|
|
182
|
+
s ? r.add(c) : r.delete(c), v(r), n.onSelect?.(e, s, p(r)), h.value = c;
|
|
183
|
+
}
|
|
184
|
+
function Q(e, t) {
|
|
185
|
+
const l = o();
|
|
186
|
+
if (!l) return;
|
|
187
|
+
const n = u(e, t), c = !z(n), s = new Set(S.value);
|
|
188
|
+
q(n, s, c, []), v(s), l.onSelect?.(e, c, p(s)), h.value = n;
|
|
189
|
+
}
|
|
190
|
+
function U(e, t, l) {
|
|
191
|
+
if (y(e)) return;
|
|
192
|
+
const n = o();
|
|
193
|
+
if (n) {
|
|
194
|
+
if (n.checkStrictly === !1 && n.type !== "radio") {
|
|
195
|
+
Q(e, t);
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
O(e, t, l);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
function W(e) {
|
|
202
|
+
const t = o();
|
|
203
|
+
if (!t) return;
|
|
204
|
+
const l = J(), n = new Set(S.value), c = [];
|
|
205
|
+
l.forEach((s) => {
|
|
206
|
+
const r = n.has(s.key);
|
|
207
|
+
e ? n.add(s.key) : n.delete(s.key), r !== e && c.push(s.record);
|
|
208
|
+
}), v(n), t.onSelectAll?.(e, p(n), c);
|
|
209
|
+
}
|
|
210
|
+
const X = w(() => {
|
|
211
|
+
const e = D();
|
|
212
|
+
if (e.length === 0) return "none";
|
|
213
|
+
const t = e.filter((l) => S.value.has(l.key)).length;
|
|
214
|
+
return t === 0 ? "none" : t === e.length ? "all" : "partial";
|
|
215
|
+
});
|
|
216
|
+
function Y() {
|
|
217
|
+
const e = o();
|
|
218
|
+
if (!e) return;
|
|
219
|
+
const t = D(), l = new Set(S.value);
|
|
220
|
+
t.forEach((n) => {
|
|
221
|
+
l.has(n.key) ? l.delete(n.key) : l.add(n.key);
|
|
222
|
+
}), v(l), e.onSelectInvert?.(Array.from(V(l)));
|
|
223
|
+
}
|
|
224
|
+
function Z() {
|
|
225
|
+
const e = o();
|
|
226
|
+
e && (v(/* @__PURE__ */ new Set()), e.onSelectNone?.());
|
|
227
|
+
}
|
|
228
|
+
function _() {
|
|
229
|
+
return D().map((e) => e.key);
|
|
230
|
+
}
|
|
231
|
+
return {
|
|
232
|
+
selectedKeySet: S,
|
|
233
|
+
isSelected: z,
|
|
234
|
+
isDisabled: y,
|
|
235
|
+
getSelectionState: L,
|
|
236
|
+
toggleRow: U,
|
|
237
|
+
toggleAll: W,
|
|
238
|
+
allCheckedState: X,
|
|
239
|
+
invertSelection: Y,
|
|
240
|
+
clearSelection: Z,
|
|
241
|
+
getChangeableRowKeys: _
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
export {
|
|
245
|
+
ce as useSelection
|
|
246
|
+
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ComputedRef } from 'vue';
|
|
2
2
|
import { ColumnType, Key, SortOrder, SorterResultLike } from '../types';
|
|
3
|
+
import { getColumnKey } from './useColumns';
|
|
3
4
|
export interface SorterState<TRecord extends Record<string, unknown> = Record<string, unknown>> {
|
|
4
5
|
columnKey: Key | undefined;
|
|
5
6
|
order: SortOrder;
|
|
@@ -7,11 +8,6 @@ export interface SorterState<TRecord extends Record<string, unknown> = Record<st
|
|
|
7
8
|
multiplePriority: number | false;
|
|
8
9
|
}
|
|
9
10
|
export type SorterResult<TRecord extends Record<string, unknown> = Record<string, unknown>> = SorterResultLike<TRecord> | Array<SorterResultLike<TRecord>>;
|
|
10
|
-
/**
|
|
11
|
-
* 获取列的唯一标识。
|
|
12
|
-
* 优先使用 key,其次 dataIndex 转字符串。
|
|
13
|
-
*/
|
|
14
|
-
declare function getColumnKey<TRecord extends Record<string, unknown>>(column: ColumnType<TRecord>): Key | undefined;
|
|
15
11
|
export interface UseSorterOptions<TRecord extends Record<string, unknown>> {
|
|
16
12
|
columns: () => ColumnType<TRecord>[];
|
|
17
13
|
tableSortDirections?: () => SortOrder[] | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSorter.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/useSorter.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useSorter.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/useSorter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,KAAK,CAAA;AACvD,OAAO,KAAK,EAEV,UAAU,EACV,GAAG,EACH,SAAS,EAET,gBAAgB,EACjB,MAAM,UAAU,CAAA;AACjB,OAAO,EAAkB,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3D,MAAM,WAAW,WAAW,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5F,SAAS,EAAE,GAAG,GAAG,SAAS,CAAA;IAC1B,KAAK,EAAE,SAAS,CAAA;IAChB,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,SAAS,CAAA;IACvC,gBAAgB,EAAE,MAAM,GAAG,KAAK,CAAA;CACjC;AAED,MAAM,MAAM,YAAY,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACtF,gBAAgB,CAAC,OAAO,CAAC,GACzB,KAAK,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAA;AA+DpC,MAAM,WAAW,gBAAgB,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACvE,OAAO,EAAE,MAAM,UAAU,CAAC,OAAO,CAAC,EAAE,CAAA;IACpC,mBAAmB,CAAC,EAAE,MAAM,SAAS,EAAE,GAAG,SAAS,CAAA;IACnD,cAAc,CAAC,EAAE,CAAC,YAAY,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,IAAI,CAAA;CAC/D;AAED,wBAAgB,SAAS,CAAC,OAAO,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/D,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC;;kBA2OF,WAAW,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,CAAC;;;;;;2BA7HrC,UAAU,CAAC,OAAO,CAAC,KAAG,SAAS;8BAiB5B,UAAU,CAAC,OAAO,CAAC,KAAG,IAAI;qBAoEnC,OAAO,EAAE,KAAG,OAAO,EAAE;EA+C9C;AAED,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { watch as z, computed as a } from "vue";
|
|
2
|
+
import { getColumnKey as c, getByDataIndex as b } from "./useColumns.mjs";
|
|
3
|
+
import { useControlledColumnState as M } from "./useControlledColumnState.mjs";
|
|
4
|
+
function C(t) {
|
|
5
|
+
if (!(!t || typeof t != "object" || typeof t == "function"))
|
|
6
|
+
return t;
|
|
7
|
+
}
|
|
8
|
+
function S(t) {
|
|
9
|
+
const o = C(t.sorter)?.multiple;
|
|
10
|
+
return typeof o == "number" && Number.isFinite(o) ? o : !1;
|
|
11
|
+
}
|
|
12
|
+
function x(t) {
|
|
13
|
+
return {
|
|
14
|
+
column: t.column,
|
|
15
|
+
columnKey: t.columnKey,
|
|
16
|
+
order: t.order,
|
|
17
|
+
field: t.column?.dataIndex
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function B(t, o) {
|
|
21
|
+
return typeof t == "number" && typeof o == "number" ? t - o : String(t ?? "").localeCompare(String(o ?? ""));
|
|
22
|
+
}
|
|
23
|
+
function U(t, o) {
|
|
24
|
+
const u = t.sortDirections ?? o;
|
|
25
|
+
return u && u.length > 0 ? u : ["ascend", "descend"];
|
|
26
|
+
}
|
|
27
|
+
function q(t, o) {
|
|
28
|
+
const u = o.indexOf(t);
|
|
29
|
+
return u === -1 ? o[0] ?? null : u >= o.length - 1 ? null : o[u + 1];
|
|
30
|
+
}
|
|
31
|
+
function A(t, o) {
|
|
32
|
+
return Number(o.multiplePriority) - Number(t.multiplePriority);
|
|
33
|
+
}
|
|
34
|
+
function L(t) {
|
|
35
|
+
const { columns: o, tableSortDirections: u, onSorterChange: K } = t, {
|
|
36
|
+
innerState: d,
|
|
37
|
+
isControlled: p,
|
|
38
|
+
readValue: P,
|
|
39
|
+
writeValue: D
|
|
40
|
+
} = M({
|
|
41
|
+
controlledValue: (r) => r.sortOrder
|
|
42
|
+
}), m = /* @__PURE__ */ new Set();
|
|
43
|
+
function k() {
|
|
44
|
+
const r = /* @__PURE__ */ new Set();
|
|
45
|
+
o().forEach((e) => {
|
|
46
|
+
if (!e.sorter) return;
|
|
47
|
+
const n = c(e);
|
|
48
|
+
if (n === void 0) return;
|
|
49
|
+
const i = String(n);
|
|
50
|
+
r.add(i), e.sortOrder === void 0 && (m.has(i) || (m.add(i), e.defaultSortOrder && (d[i] = e.defaultSortOrder)));
|
|
51
|
+
}), Object.keys(d).forEach((e) => {
|
|
52
|
+
r.has(e) || delete d[e];
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
z([() => o(), () => u?.()], () => k(), {
|
|
56
|
+
immediate: !0,
|
|
57
|
+
deep: !0
|
|
58
|
+
});
|
|
59
|
+
function y(r) {
|
|
60
|
+
return c(r) === void 0 ? null : P(r, null);
|
|
61
|
+
}
|
|
62
|
+
function g(r) {
|
|
63
|
+
const e = [];
|
|
64
|
+
o().forEach((i) => {
|
|
65
|
+
if (!i.sorter) return;
|
|
66
|
+
const l = c(i);
|
|
67
|
+
if (l === void 0) return;
|
|
68
|
+
const f = r && String(l) === String(r.columnKey) ? r.order : y(i);
|
|
69
|
+
f && e.push({
|
|
70
|
+
columnKey: l,
|
|
71
|
+
order: f,
|
|
72
|
+
column: i,
|
|
73
|
+
multiplePriority: S(i)
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
const n = e.filter((i) => i.multiplePriority === !1);
|
|
77
|
+
return n.length > 0 ? [n[n.length - 1]] : e.sort(A);
|
|
78
|
+
}
|
|
79
|
+
function v(r) {
|
|
80
|
+
return r.length === 0 ? {
|
|
81
|
+
column: void 0,
|
|
82
|
+
columnKey: void 0,
|
|
83
|
+
order: null,
|
|
84
|
+
field: void 0
|
|
85
|
+
} : r.length === 1 ? x(r[0]) : r.map(x);
|
|
86
|
+
}
|
|
87
|
+
function h(r) {
|
|
88
|
+
return y(r);
|
|
89
|
+
}
|
|
90
|
+
function O(r) {
|
|
91
|
+
o().forEach((e) => {
|
|
92
|
+
if (!e.sorter || p(e)) return;
|
|
93
|
+
const n = c(e);
|
|
94
|
+
n !== void 0 && (r && !r(e) || delete d[String(n)]);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function j(r) {
|
|
98
|
+
if (!r.sorter) return;
|
|
99
|
+
const e = c(r);
|
|
100
|
+
if (e === void 0) return;
|
|
101
|
+
const n = h(r), i = U(r, u?.()), l = q(n, i), f = S(r);
|
|
102
|
+
p(r) || (f === !1 ? O() : O((V) => S(V) === !1), D(r, l ?? void 0));
|
|
103
|
+
const R = g({
|
|
104
|
+
columnKey: e,
|
|
105
|
+
order: l
|
|
106
|
+
});
|
|
107
|
+
K?.(v(R));
|
|
108
|
+
}
|
|
109
|
+
function w(r) {
|
|
110
|
+
if (!r.sorter) return null;
|
|
111
|
+
if (typeof r.sorter == "function")
|
|
112
|
+
return r.sorter;
|
|
113
|
+
const e = C(r.sorter);
|
|
114
|
+
return e?.compare ? e.compare : (n, i) => B(b(n, r.dataIndex), b(i, r.dataIndex));
|
|
115
|
+
}
|
|
116
|
+
const s = a(() => g()), E = a(() => s.value[0] ?? {
|
|
117
|
+
columnKey: void 0,
|
|
118
|
+
order: null,
|
|
119
|
+
column: void 0,
|
|
120
|
+
multiplePriority: !1
|
|
121
|
+
}), F = a(() => v(s.value)), I = a(
|
|
122
|
+
() => s.value.map((r) => ({
|
|
123
|
+
column: r.column,
|
|
124
|
+
order: r.order
|
|
125
|
+
}))
|
|
126
|
+
);
|
|
127
|
+
function N(r) {
|
|
128
|
+
if (s.value.length === 0) return r;
|
|
129
|
+
const e = s.value.map((n) => {
|
|
130
|
+
if (!n.column || !n.order) return null;
|
|
131
|
+
const i = w(n.column);
|
|
132
|
+
return i ? {
|
|
133
|
+
compareFn: i,
|
|
134
|
+
multiplier: n.order === "descend" ? -1 : 1
|
|
135
|
+
} : null;
|
|
136
|
+
}).filter(
|
|
137
|
+
(n) => n !== null
|
|
138
|
+
);
|
|
139
|
+
return e.length === 0 ? r : [...r].sort((n, i) => {
|
|
140
|
+
for (const l of e) {
|
|
141
|
+
const f = l.compareFn(n, i) * l.multiplier;
|
|
142
|
+
if (f !== 0)
|
|
143
|
+
return f;
|
|
144
|
+
}
|
|
145
|
+
return 0;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
sorterState: E,
|
|
150
|
+
sorterStates: s,
|
|
151
|
+
sorterResult: F,
|
|
152
|
+
sortColumns: I,
|
|
153
|
+
getSortOrder: h,
|
|
154
|
+
toggleSortOrder: j,
|
|
155
|
+
sortData: N
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
export {
|
|
159
|
+
c as getColumnKey,
|
|
160
|
+
L as useSorter
|
|
161
|
+
};
|
|
@@ -35,6 +35,8 @@ export interface UseTreeDataOptions<TRecord = Record<string, unknown>> {
|
|
|
35
35
|
export interface UseTreeDataReturn<TRecord = Record<string, unknown>> {
|
|
36
36
|
/** Flattened visible rows */
|
|
37
37
|
flattenData: ComputedRef<FlattenRow<TRecord>[]>;
|
|
38
|
+
/** record → 其可见行元信息的映射,供按 record 身份 O(1) 查行(替代逐行 .find()) */
|
|
39
|
+
rowMetaMap: ComputedRef<Map<TRecord, FlattenRow<TRecord>>>;
|
|
38
40
|
/** Whether tree mode is active (data has children) */
|
|
39
41
|
isTreeData: ComputedRef<boolean>;
|
|
40
42
|
/** Toggle a row's expanded state */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTreeData.d.ts","sourceRoot":"","sources":["../../../../../table/src/composables/useTreeData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAEnC,MAAM,WAAW,UAAU,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,2BAA2B;IAC3B,MAAM,EAAE,OAAO,CAAA;IACf,+BAA+B;IAC/B,KAAK,EAAE,MAAM,CAAA;IACb,6CAA6C;IAC7C,QAAQ,EAAE,OAAO,CAAA;IACjB,sCAAsC;IACtC,WAAW,EAAE,OAAO,CAAA;IACpB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,GAAG,CAAA;CAChB;AAED,MAAM,WAAW,kBAAkB,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACnE,2BAA2B;IAC3B,IAAI,EAAE,MAAM,OAAO,EAAE,CAAA;IACrB,sDAAsD;IACtD,kBAAkB,CAAC,EAAE,MAAM,MAAM,GAAG,SAAS,CAAA;IAC7C,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,MAAM,GAAG,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