hys-ui 0.1.1 → 0.2.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/CHANGELOG.md +111 -0
- package/README.md +3 -1
- package/dist/components/HysAccordion/HysAccordion.vue.js +1 -1
- package/dist/components/HysAccordion/HysAccordion2.vue.js +181 -47
- package/dist/components/HysAutocomplete/HysAutocomplete.vue.js +7 -0
- package/dist/components/HysAutocomplete/HysAutocomplete2.vue.js +627 -0
- package/dist/components/HysAvatar/HysAvatar.vue.js +5 -35
- package/dist/components/HysAvatar/HysAvatar2.vue.js +221 -2
- package/dist/components/HysAvatarGroup/HysAvatarGroup.vue.js +7 -0
- package/dist/components/HysAvatarGroup/HysAvatarGroup2.vue.js +252 -0
- package/dist/components/HysBadge/HysBadge.vue.js +2 -2
- package/dist/components/HysBadge/HysBadge2.vue.js +154 -27
- package/dist/components/HysBreadcrumb/HysBreadcrumb.vue.js +5 -38
- package/dist/components/HysBreadcrumb/HysBreadcrumb2.vue.js +74 -2
- package/dist/components/HysButton/HysButton.vue.js +2 -2
- package/dist/components/HysButton/HysButton2.vue.js +29 -28
- package/dist/components/HysCalendar/HysCalendar.vue.js +5 -92
- package/dist/components/HysCalendar/HysCalendar2.vue.js +803 -2
- package/dist/components/HysCard/HysCard.vue.js +2 -2
- package/dist/components/HysCard/HysCard2.vue.js +175 -42
- package/dist/components/HysCascader/HysCascader.vue.js +5 -194
- package/dist/components/HysCascader/HysCascader2.vue.js +760 -2
- package/dist/components/HysCascader/HysCascaderColumn.vue.js +7 -0
- package/dist/components/HysCascader/HysCascaderColumn2.vue.js +232 -0
- package/dist/components/HysCheckbox/HysCheckbox.vue.js +3 -3
- package/dist/components/HysCheckbox/HysCheckbox2.vue.js +180 -65
- package/dist/components/HysCheckboxGroup/HysCheckboxGroup.vue.js +7 -0
- package/dist/components/HysCheckboxGroup/HysCheckboxGroup2.vue.js +237 -0
- package/dist/components/HysColorPicker/HysColorPicker.vue.js +2 -2
- package/dist/components/HysColorPicker/HysColorPicker2.vue.js +107 -106
- package/dist/components/HysDataGrid/HysDataGrid.vue.js +1 -1
- package/dist/components/HysDataGrid/HysDataGrid2.vue.js +399 -392
- package/dist/components/HysDatePicker/HysDatePicker.vue.js +268 -139
- package/dist/components/HysDatePicker/HysDatePickerControl.vue.js +7 -0
- package/dist/components/HysDatePicker/HysDatePickerControl2.vue.js +807 -0
- package/dist/components/HysDatePicker/HysDatePickerPanel.vue.js +7 -0
- package/dist/components/HysDatePicker/HysDatePickerPanel2.vue.js +357 -0
- package/dist/components/HysDateRangePicker/HysDateRangePicker.vue.js +268 -158
- package/dist/components/HysDivider/HysDivider.vue.js +2 -2
- package/dist/components/HysDivider/HysDivider2.vue.js +33 -13
- package/dist/components/HysFileManager/HysFileManager.vue.js +3 -3
- package/dist/components/HysFileManager/HysFileManager2.vue.js +43 -42
- package/dist/components/HysForm/HysForm.vue.js +3 -3
- package/dist/components/HysForm/HysForm2.vue.js +578 -92
- package/dist/components/HysFormItem/HysFormItem.vue.js +5 -85
- package/dist/components/HysFormItem/HysFormItem2.vue.js +521 -2
- package/dist/components/HysGantt/HysGantt.vue.js +1 -1
- package/dist/components/HysGantt/HysGantt2.vue.js +1369 -272
- package/dist/components/HysInput/HysInput.vue.js +2 -2
- package/dist/components/HysInput/HysInput2.vue.js +467 -120
- package/dist/components/HysMention/HysMention.vue.js +2 -2
- package/dist/components/HysMention/HysMention2.vue.js +89 -88
- package/dist/components/HysNumberInput/HysNumberInput.vue.js +2 -2
- package/dist/components/HysNumberInput/HysNumberInput2.vue.js +561 -79
- package/dist/components/HysOrgTree/HysOrgTree.vue.js +29 -26
- package/dist/components/HysPagination/HysPagination.vue.js +1 -1
- package/dist/components/HysPagination/HysPagination2.vue.js +2 -0
- package/dist/components/HysPermissionMatrix/HysPermissionMatrix.vue.js +2 -2
- package/dist/components/HysPermissionMatrix/HysPermissionMatrix2.vue.js +52 -51
- package/dist/components/HysRadio/HysRadio.vue.js +7 -0
- package/dist/components/HysRadio/HysRadio2.vue.js +180 -0
- package/dist/components/HysRadioGroup/HysRadioGroup.vue.js +2 -2
- package/dist/components/HysRadioGroup/HysRadioGroup2.vue.js +190 -65
- package/dist/components/HysRating/HysRating.vue.js +1 -1
- package/dist/components/HysRating/HysRating2.vue.js +288 -68
- package/dist/components/HysRichTextEditor/HysRichTextEditor.vue.js +1 -1
- package/dist/components/HysRichTextEditor/HysRichTextEditor2.vue.js +70 -69
- package/dist/components/HysSearch/HysSearch.vue.js +37 -36
- package/dist/components/HysSegmented/HysSegmented.vue.js +5 -63
- package/dist/components/HysSegmented/HysSegmented2.vue.js +273 -2
- package/dist/components/HysSelect/HysSelect.vue.js +3 -2
- package/dist/components/HysSelect/HysSelect2.vue.js +859 -185
- package/dist/components/HysSkeleton/HysSkeleton.vue.js +2 -2
- package/dist/components/HysSkeleton/HysSkeleton2.vue.js +126 -29
- package/dist/components/HysSlider/HysSlider.vue.js +2 -2
- package/dist/components/HysSlider/HysSlider2.vue.js +532 -59
- package/dist/components/HysSlider/SliderTooltip.vue.js +7 -0
- package/dist/components/HysSlider/SliderTooltip2.vue.js +156 -0
- package/dist/components/HysSteps/HysSteps.vue.js +1 -1
- package/dist/components/HysSteps/HysSteps2.vue.js +110 -36
- package/dist/components/HysSwitch/HysSwitch.vue.js +2 -2
- package/dist/components/HysSwitch/HysSwitch2.vue.js +232 -50
- package/dist/components/HysTable/HysTable.vue.js +2 -2
- package/dist/components/HysTable/HysTable2.vue.js +1473 -88
- package/dist/components/HysTable/HysTableFilterOptions.vue.js +7 -0
- package/dist/components/HysTable/HysTableFilterOptions2.vue.js +133 -0
- package/dist/components/HysTabs/HysTabs.vue.js +2 -2
- package/dist/components/HysTabs/HysTabs2.vue.js +262 -68
- package/dist/components/HysTagInput/HysTagInput.vue.js +43 -42
- package/dist/components/HysTextarea/HysTextarea.vue.js +138 -77
- package/dist/components/HysTransfer/HysTransfer.vue.js +5 -223
- package/dist/components/HysTransfer/HysTransfer2.vue.js +416 -2
- package/dist/components/HysTransfer/HysTransferPanel.vue.js +7 -0
- package/dist/components/HysTransfer/HysTransferPanel2.vue.js +454 -0
- package/dist/components/HysTree/HysTree.vue.js +2 -3
- package/dist/components/HysTree/HysTree2.vue.js +641 -302
- package/dist/components/HysTreeSelect/HysTreeSelect.vue.js +5 -136
- package/dist/components/HysTreeSelect/HysTreeSelect2.vue.js +558 -2
- package/dist/components/HysTreeSelect/HysTreeSelectPanel.vue.js +7 -0
- package/dist/components/HysTreeSelect/HysTreeSelectPanel2.vue.js +323 -0
- package/dist/components/HysUpload/HysUpload.vue.js +2 -2
- package/dist/components/HysUpload/HysUpload2.vue.js +77 -76
- package/dist/composables/autocomplete.js +50 -0
- package/dist/composables/avatar.js +57 -0
- package/dist/composables/calendar.js +96 -0
- package/dist/composables/cascader.js +79 -0
- package/dist/composables/choice.js +38 -0
- package/dist/composables/choiceModel.js +67 -0
- package/dist/composables/datePicker.js +227 -0
- package/dist/composables/formContext.js +92 -7
- package/dist/composables/formLayout.js +57 -0
- package/dist/composables/formValidation.js +240 -0
- package/dist/composables/ganttConflicts.js +143 -0
- package/dist/composables/numberInput.js +91 -0
- package/dist/composables/rating.js +16 -0
- package/dist/composables/selectOptions.js +54 -0
- package/dist/composables/table.js +150 -0
- package/dist/composables/textInput.js +34 -0
- package/dist/composables/transfer.js +63 -0
- package/dist/composables/tree.js +118 -0
- package/dist/composables/treeSelect.js +71 -0
- package/dist/composables/useCascader.js +438 -0
- package/dist/composables/useDatePicker.js +425 -0
- package/dist/composables/useFloating.js +97 -51
- package/dist/composables/useGanttDependencies.js +306 -0
- package/dist/composables/useGanttHistory.js +157 -0
- package/dist/composables/useGanttLabelResize.js +100 -0
- package/dist/composables/useTable.js +474 -0
- package/dist/composables/useTextareaSize.js +72 -0
- package/dist/composables/useTransfer.js +257 -0
- package/dist/composables/useTree.js +439 -0
- package/dist/composables/useTreeSelect.js +361 -0
- package/dist/index.js +149 -139
- package/dist/style.css +1 -1
- package/dist/types/components/HysAccordion/HysAccordion.vue.d.ts +61 -22
- package/dist/types/components/HysAutocomplete/HysAutocomplete.vue.d.ts +201 -0
- package/dist/types/components/HysAvatar/HysAvatar.vue.d.ts +28 -15
- package/dist/types/components/HysAvatarGroup/HysAvatarGroup.vue.d.ts +99 -0
- package/dist/types/components/HysBadge/HysBadge.vue.d.ts +41 -4
- package/dist/types/components/HysBreadcrumb/HysBreadcrumb.vue.d.ts +38 -10
- package/dist/types/components/HysButton/HysButton.vue.d.ts +0 -1
- package/dist/types/components/HysCalendar/HysCalendar.vue.d.ts +119 -31
- package/dist/types/components/HysCard/HysCard.vue.d.ts +55 -7
- package/dist/types/components/HysCascader/HysCascader.vue.d.ts +129 -41
- package/dist/types/components/HysCascader/HysCascaderColumn.vue.d.ts +55 -0
- package/dist/types/components/HysCheckbox/HysCheckbox.vue.d.ts +50 -39
- package/dist/types/components/HysCheckboxGroup/HysCheckboxGroup.vue.d.ts +73 -0
- package/dist/types/components/HysDataGrid/HysDataGrid.vue.d.ts +1 -1
- package/dist/types/components/HysDatePicker/HysDatePicker.vue.d.ts +66 -14
- package/dist/types/components/HysDatePicker/HysDatePickerControl.vue.d.ts +90 -0
- package/dist/types/components/HysDatePicker/HysDatePickerPanel.vue.d.ts +93 -0
- package/dist/types/components/HysDateRangePicker/HysDateRangePicker.vue.d.ts +66 -14
- package/dist/types/components/HysDivider/HysDivider.vue.d.ts +8 -3
- package/dist/types/components/HysFileManager/HysFileManager.vue.d.ts +2 -2
- package/dist/types/components/HysForm/HysForm.vue.d.ts +110 -18
- package/dist/types/components/HysFormItem/HysFormItem.vue.d.ts +108 -2
- package/dist/types/components/HysGantt/HysGantt.vue.d.ts +82 -4
- package/dist/types/components/HysInput/HysInput.vue.d.ts +52 -29
- package/dist/types/components/HysMention/HysMention.vue.d.ts +2 -2
- package/dist/types/components/HysNumberInput/HysNumberInput.vue.d.ts +93 -35
- package/dist/types/components/HysOrgTree/HysOrgTree.vue.d.ts +1 -0
- package/dist/types/components/HysPagination/HysPagination.vue.d.ts +1 -1
- package/dist/types/components/HysPermissionMatrix/HysPermissionMatrix.vue.d.ts +2 -2
- package/dist/types/components/HysPopover/HysPopover.vue.d.ts +3 -3
- package/dist/types/components/HysProgress/HysProgress.vue.d.ts +1 -1
- package/dist/types/components/HysRadio/HysRadio.vue.d.ts +56 -0
- package/dist/types/components/HysRadioGroup/HysRadioGroup.vue.d.ts +34 -12
- package/dist/types/components/HysRating/HysRating.vue.d.ts +85 -5
- package/dist/types/components/HysRichTextEditor/HysRichTextEditor.vue.d.ts +4 -4
- package/dist/types/components/HysSearch/HysSearch.vue.d.ts +2 -2
- package/dist/types/components/HysSegmented/HysSegmented.vue.d.ts +64 -32
- package/dist/types/components/HysSelect/HysSelect.vue.d.ts +120 -20
- package/dist/types/components/HysSkeleton/HysSkeleton.vue.d.ts +30 -2
- package/dist/types/components/HysSlider/HysSlider.vue.d.ts +66 -9
- package/dist/types/components/HysSlider/SliderTooltip.vue.d.ts +22 -0
- package/dist/types/components/HysSplitPane/HysSplitPane.vue.d.ts +1 -1
- package/dist/types/components/HysSteps/HysSteps.vue.d.ts +64 -9
- package/dist/types/components/HysSwitch/HysSwitch.vue.d.ts +76 -17
- package/dist/types/components/HysTable/HysTable.vue.d.ts +206 -32
- package/dist/types/components/HysTable/HysTableFilterOptions.vue.d.ts +18 -0
- package/dist/types/components/HysTabs/HysTabs.vue.d.ts +76 -23
- package/dist/types/components/HysTagInput/HysTagInput.vue.d.ts +5 -5
- package/dist/types/components/HysTextarea/HysTextarea.vue.d.ts +44 -27
- package/dist/types/components/HysToast/HysToast.vue.d.ts +3 -3
- package/dist/types/components/HysTour/HysTour.vue.d.ts +2 -2
- package/dist/types/components/HysTransfer/HysTransfer.vue.d.ts +55 -40
- package/dist/types/components/HysTransfer/HysTransferPanel.vue.d.ts +105 -0
- package/dist/types/components/HysTree/HysTree.vue.d.ts +140 -73
- package/dist/types/components/HysTreeSelect/HysTreeSelect.vue.d.ts +102 -23
- package/dist/types/components/HysTreeSelect/HysTreeSelectPanel.vue.d.ts +56 -0
- package/dist/types/composables/autocomplete.d.ts +106 -0
- package/dist/types/composables/avatar.d.ts +70 -0
- package/dist/types/composables/calendar.d.ts +66 -0
- package/dist/types/composables/cascader.d.ts +192 -0
- package/dist/types/composables/choice.d.ts +110 -0
- package/dist/types/composables/choiceModel.d.ts +11 -0
- package/dist/types/composables/datePicker.d.ts +247 -0
- package/dist/types/composables/formContext.d.ts +133 -8
- package/dist/types/composables/formLayout.d.ts +11 -0
- package/dist/types/composables/formValidation.d.ts +13 -0
- package/dist/types/composables/gantt.d.ts +68 -0
- package/dist/types/composables/ganttConflicts.d.ts +30 -0
- package/dist/types/composables/numberInput.d.ts +45 -0
- package/dist/types/composables/rating.d.ts +18 -0
- package/dist/types/composables/segmented.d.ts +15 -0
- package/dist/types/composables/selectOptions.d.ts +44 -0
- package/dist/types/composables/slider.d.ts +21 -0
- package/dist/types/composables/table.d.ts +309 -0
- package/dist/types/composables/textInput.d.ts +76 -0
- package/dist/types/composables/transfer.d.ts +180 -0
- package/dist/types/composables/tree.d.ts +237 -0
- package/dist/types/composables/treeSelect.d.ts +167 -0
- package/dist/types/composables/useCascader.d.ts +162 -0
- package/dist/types/composables/useDatePicker.d.ts +79 -0
- package/dist/types/composables/useFloating.d.ts +8 -5
- package/dist/types/composables/useGanttDependencies.d.ts +83 -0
- package/dist/types/composables/useGanttHistory.d.ts +42 -0
- package/dist/types/composables/useGanttLabelResize.d.ts +23 -0
- package/dist/types/composables/useTable.d.ts +60 -0
- package/dist/types/composables/useTextareaSize.d.ts +3 -0
- package/dist/types/composables/useTransfer.d.ts +58 -0
- package/dist/types/composables/useTree.d.ts +77 -0
- package/dist/types/composables/useTreeSelect.d.ts +117 -0
- package/dist/types/index.d.ts +33 -7
- package/package.json +2 -1
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { ref as k, computed as r, watch as te, onDeactivated as he, onBeforeUnmount as ge, onActivated as se, nextTick as E } from "vue";
|
|
2
|
+
import { transferRows as de, transferWords as Se, transferLabel as we } from "./transfer.js";
|
|
3
|
+
const H = ["left", "right"], K = (a, i) => a.length === i.length && a.every((f, B) => f === i[B]), D = (a) => [
|
|
4
|
+
...new Set(
|
|
5
|
+
a.filter(
|
|
6
|
+
(i) => typeof i == "string" || typeof i == "number" && Number.isFinite(i)
|
|
7
|
+
)
|
|
8
|
+
)
|
|
9
|
+
], y = (a, i) => Number.isFinite(a) && a > 0 ? Math.max(1, Math.floor(a)) : i;
|
|
10
|
+
function ye(a, i, f, B) {
|
|
11
|
+
const I = new Set(a.modelValue ?? a.defaultValue ?? []), g = k(!0), J = k([...a.defaultValue ?? []]), R = k([
|
|
12
|
+
...a.defaultCheckedKeys ?? [],
|
|
13
|
+
...(a.leftDefaultChecked ?? []).filter(
|
|
14
|
+
(e) => !I.has(e)
|
|
15
|
+
),
|
|
16
|
+
...(a.rightDefaultChecked ?? []).filter(
|
|
17
|
+
(e) => I.has(e)
|
|
18
|
+
)
|
|
19
|
+
]), Q = y(
|
|
20
|
+
typeof a.pagination == "object" ? a.pagination.pageSize : void 0,
|
|
21
|
+
10
|
|
22
|
+
), U = k({ left: "", right: "" }), V = k({ left: 1, right: 1 }), L = k({ left: Q, right: Q }), b = k(!1), X = k("");
|
|
23
|
+
let N = 0, T = 0;
|
|
24
|
+
const s = r(() => de(a)), q = r(() => D(a.modelValue ?? J.value)), c = r(() => new Set(q.value)), W = r(() => Se(a.locale)), x = r(
|
|
25
|
+
() => !g.value || i.value || !!a.loading || b.value
|
|
26
|
+
), o = r(
|
|
27
|
+
() => D(a.checkedKeys ?? R.value).filter((e) => {
|
|
28
|
+
const t = s.value.map.get(e);
|
|
29
|
+
return t && !t.disabled && !(a.oneWay && c.value.has(e));
|
|
30
|
+
})
|
|
31
|
+
), ae = r(() => new Set(o.value)), F = r(() => {
|
|
32
|
+
const e = s.value.rows.filter((l) => !c.value.has(l.key)), t = a.targetOrder && a.targetOrder !== "original" ? q.value.flatMap((l) => {
|
|
33
|
+
const n = s.value.map.get(l);
|
|
34
|
+
return n ? [n] : [];
|
|
35
|
+
}) : s.value.rows.filter((l) => c.value.has(l.key));
|
|
36
|
+
return { left: e, right: t };
|
|
37
|
+
}), O = r(() => {
|
|
38
|
+
var e, t;
|
|
39
|
+
return {
|
|
40
|
+
left: ((e = a.searchValues) == null ? void 0 : e.left) ?? U.value.left,
|
|
41
|
+
right: ((t = a.searchValues) == null ? void 0 : t.right) ?? U.value.right
|
|
42
|
+
};
|
|
43
|
+
}), d = r(
|
|
44
|
+
() => Object.fromEntries(
|
|
45
|
+
H.map((e) => {
|
|
46
|
+
const t = O.value[e].trim(), l = t.toLocaleLowerCase();
|
|
47
|
+
return [
|
|
48
|
+
e,
|
|
49
|
+
t ? F.value[e].filter(
|
|
50
|
+
(n) => a.filterMethod ? a.filterMethod(t, n.option, e) : n.label.toLocaleLowerCase().includes(l)
|
|
51
|
+
) : F.value[e]
|
|
52
|
+
];
|
|
53
|
+
})
|
|
54
|
+
)
|
|
55
|
+
), Y = r(
|
|
56
|
+
() => typeof a.pagination == "object" ? a.pagination : {}
|
|
57
|
+
), v = r(() => {
|
|
58
|
+
var e, t;
|
|
59
|
+
return {
|
|
60
|
+
left: y((e = a.pageSizes) == null ? void 0 : e.left, L.value.left),
|
|
61
|
+
right: y((t = a.pageSizes) == null ? void 0 : t.right, L.value.right)
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
te(
|
|
65
|
+
() => Y.value.pageSize,
|
|
66
|
+
(e) => {
|
|
67
|
+
L.value = {
|
|
68
|
+
left: y(e, 10),
|
|
69
|
+
right: y(e, 10)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
const P = r(() => ({
|
|
74
|
+
left: Math.max(
|
|
75
|
+
1,
|
|
76
|
+
Math.ceil(d.value.left.length / v.value.left)
|
|
77
|
+
),
|
|
78
|
+
right: Math.max(
|
|
79
|
+
1,
|
|
80
|
+
Math.ceil(d.value.right.length / v.value.right)
|
|
81
|
+
)
|
|
82
|
+
})), S = r(() => {
|
|
83
|
+
var e, t;
|
|
84
|
+
return {
|
|
85
|
+
left: Math.min(
|
|
86
|
+
P.value.left,
|
|
87
|
+
y((e = a.pages) == null ? void 0 : e.left, V.value.left)
|
|
88
|
+
),
|
|
89
|
+
right: Math.min(
|
|
90
|
+
P.value.right,
|
|
91
|
+
y((t = a.pages) == null ? void 0 : t.right, V.value.right)
|
|
92
|
+
)
|
|
93
|
+
};
|
|
94
|
+
}), Z = r(() => ({
|
|
95
|
+
left: a.pagination ? d.value.left.slice(
|
|
96
|
+
(S.value.left - 1) * v.value.left,
|
|
97
|
+
S.value.left * v.value.left
|
|
98
|
+
) : d.value.left,
|
|
99
|
+
right: a.pagination ? d.value.right.slice(
|
|
100
|
+
(S.value.right - 1) * v.value.right,
|
|
101
|
+
S.value.right * v.value.right
|
|
102
|
+
) : d.value.right
|
|
103
|
+
}));
|
|
104
|
+
function _(e) {
|
|
105
|
+
return e ? o.value.filter(
|
|
106
|
+
(t) => c.value.has(t) === (e === "right")
|
|
107
|
+
) : [...o.value];
|
|
108
|
+
}
|
|
109
|
+
async function C(e) {
|
|
110
|
+
if (x.value) return !1;
|
|
111
|
+
const t = D(e).filter((u) => {
|
|
112
|
+
const h = s.value.map.get(u);
|
|
113
|
+
return h && !h.disabled && !(a.oneWay && c.value.has(u));
|
|
114
|
+
}), l = [...o.value];
|
|
115
|
+
if (K(t, l) && K(t, D(a.checkedKeys ?? R.value)))
|
|
116
|
+
return !1;
|
|
117
|
+
const n = ++T, m = H.map((u) => ({
|
|
118
|
+
side: u,
|
|
119
|
+
before: l.filter(
|
|
120
|
+
(h) => c.value.has(h) === (u === "right")
|
|
121
|
+
),
|
|
122
|
+
next: t.filter(
|
|
123
|
+
(h) => c.value.has(h) === (u === "right")
|
|
124
|
+
)
|
|
125
|
+
}));
|
|
126
|
+
if (R.value = t, f("update:checkedKeys", [...t]), g.value) {
|
|
127
|
+
for (const u of m)
|
|
128
|
+
K(u.before, u.next) || f("checkChange", u.side, [...u.next]);
|
|
129
|
+
f("selectChange", [...m[0].next], [...m[1].next]);
|
|
130
|
+
}
|
|
131
|
+
return await E(), !(!g.value || i.value || a.loading || n !== T || !K(t, o.value));
|
|
132
|
+
}
|
|
133
|
+
function le(e, t) {
|
|
134
|
+
const l = s.value.map.get(e);
|
|
135
|
+
if (!l || l.disabled || a.oneWay && c.value.has(e))
|
|
136
|
+
return Promise.resolve(!1);
|
|
137
|
+
const n = new Set(o.value);
|
|
138
|
+
return t ?? !n.has(e) ? n.add(e) : n.delete(e), C([...n]);
|
|
139
|
+
}
|
|
140
|
+
function G(e, t = "page") {
|
|
141
|
+
return (t === "all" ? F.value[e] : t === "filtered" ? d.value[e] : Z.value[e]).filter((l) => !l.disabled && !(a.oneWay && e === "right"));
|
|
142
|
+
}
|
|
143
|
+
function ne(e, t = !0, l = "page") {
|
|
144
|
+
const n = new Set(o.value);
|
|
145
|
+
for (const m of G(e, l))
|
|
146
|
+
t ? n.add(m.key) : n.delete(m.key);
|
|
147
|
+
return C([...n]);
|
|
148
|
+
}
|
|
149
|
+
function ue(e, t = "page") {
|
|
150
|
+
const l = new Set(o.value);
|
|
151
|
+
for (const n of G(e, t))
|
|
152
|
+
l.has(n.key) ? l.delete(n.key) : l.add(n.key);
|
|
153
|
+
return C([...l]);
|
|
154
|
+
}
|
|
155
|
+
function re(e) {
|
|
156
|
+
return C(
|
|
157
|
+
e ? o.value.filter(
|
|
158
|
+
(t) => c.value.has(t) !== (e === "right")
|
|
159
|
+
) : []
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
async function ie(e, t = _(
|
|
163
|
+
e === "right" ? "left" : "right"
|
|
164
|
+
)) {
|
|
165
|
+
if (x.value) return !1;
|
|
166
|
+
const l = e === "right", n = [...q.value], m = new Set(n), u = D(t).filter((z) => {
|
|
167
|
+
const ee = s.value.map.get(z);
|
|
168
|
+
return ee && !ee.disabled && m.has(z) !== l;
|
|
169
|
+
});
|
|
170
|
+
if (!u.length) return !1;
|
|
171
|
+
const h = new Set(u), A = l ? a.targetOrder === "unshift" ? [...u, ...n] : [...n, ...u] : n.filter((z) => !h.has(z)), ve = ++N;
|
|
172
|
+
return b.value = !0, J.value = A, f("update:modelValue", [...A]), g.value && f("change", [...A], e, [...u]), await E(), ve !== N || (b.value = !1, !g.value || i.value || a.loading || !K(A, q.value)) ? !1 : (C(o.value.filter((z) => !h.has(z))), X.value = we(W.value.moved, {
|
|
173
|
+
direction: l ? W.value.added : W.value.removed,
|
|
174
|
+
count: u.length
|
|
175
|
+
}), a.validateEvent !== !1 && B(), !0);
|
|
176
|
+
}
|
|
177
|
+
function fe(e, t) {
|
|
178
|
+
if (x.value || !Number.isFinite(t)) return;
|
|
179
|
+
const l = Math.max(
|
|
180
|
+
1,
|
|
181
|
+
Math.min(P.value[e], Math.floor(t))
|
|
182
|
+
);
|
|
183
|
+
l !== (w.pages ?? S.value)[e] && (V.value[e] = l, j("pages", e, l), f("pageChange", e, l, v.value[e]));
|
|
184
|
+
}
|
|
185
|
+
function oe(e, t) {
|
|
186
|
+
if (x.value || !Number.isFinite(t) || t < 1) return;
|
|
187
|
+
const l = Math.floor(t);
|
|
188
|
+
l !== (w.pageSizes ?? v.value)[e] && (L.value[e] = l, V.value[e] = 1, j("pageSizes", e, l), j("pages", e, 1), f("pageSizeChange", e, l), f("pageChange", e, 1, l));
|
|
189
|
+
}
|
|
190
|
+
function $(e, t) {
|
|
191
|
+
if (x.value || (M ?? O.value)[e] === t)
|
|
192
|
+
return;
|
|
193
|
+
const l = S.value[e];
|
|
194
|
+
U.value[e] = t, V.value[e] = 1;
|
|
195
|
+
const n = { ...M ?? O.value, [e]: t };
|
|
196
|
+
M = n, f("update:searchValues", n), E(() => {
|
|
197
|
+
M === n && (M = void 0);
|
|
198
|
+
}), l !== 1 && j("pages", e, 1), f("search", e, t);
|
|
199
|
+
}
|
|
200
|
+
function ce(e) {
|
|
201
|
+
for (const t of e ? [e] : H) $(t, "");
|
|
202
|
+
}
|
|
203
|
+
let M;
|
|
204
|
+
const w = {};
|
|
205
|
+
function j(e, t, l) {
|
|
206
|
+
const n = {
|
|
207
|
+
...w[e] ?? (e === "pages" ? S.value : v.value),
|
|
208
|
+
[t]: l
|
|
209
|
+
};
|
|
210
|
+
w[e] = n, f("update:" + e, n), E(() => {
|
|
211
|
+
w[e] === n && delete w[e];
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
function p() {
|
|
215
|
+
g.value = !1, N++, T++, b.value = !1, M = void 0, delete w.pages, delete w.pageSizes;
|
|
216
|
+
}
|
|
217
|
+
return he(p), ge(p), se(() => g.value = !0), te(
|
|
218
|
+
() => [i.value, a.loading],
|
|
219
|
+
() => {
|
|
220
|
+
(i.value || a.loading) && (N++, T++, b.value = !1);
|
|
221
|
+
}
|
|
222
|
+
), {
|
|
223
|
+
live: g,
|
|
224
|
+
busy: x,
|
|
225
|
+
pending: b,
|
|
226
|
+
data: s,
|
|
227
|
+
keys: q,
|
|
228
|
+
targetSet: c,
|
|
229
|
+
checked: o,
|
|
230
|
+
checkedSet: ae,
|
|
231
|
+
words: W,
|
|
232
|
+
all: F,
|
|
233
|
+
filtered: d,
|
|
234
|
+
visible: Z,
|
|
235
|
+
searchValues: O,
|
|
236
|
+
pageSizes: v,
|
|
237
|
+
pages: S,
|
|
238
|
+
pageCounts: P,
|
|
239
|
+
pagination: Y,
|
|
240
|
+
announcement: X,
|
|
241
|
+
getCheckedKeys: _,
|
|
242
|
+
setCheckedKeys: C,
|
|
243
|
+
check: le,
|
|
244
|
+
checkAll: ne,
|
|
245
|
+
invertSelection: ue,
|
|
246
|
+
clearChecked: re,
|
|
247
|
+
move: ie,
|
|
248
|
+
setPage: fe,
|
|
249
|
+
setPageSize: oe,
|
|
250
|
+
setSearch: $,
|
|
251
|
+
clearSearch: ce,
|
|
252
|
+
selectionScope: G
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
export {
|
|
256
|
+
ye as useTransfer
|
|
257
|
+
};
|
|
@@ -0,0 +1,439 @@
|
|
|
1
|
+
import { ref as xe, shallowRef as A, computed as f, watch as q, onDeactivated as ze, onBeforeUnmount as Re, onActivated as He, nextTick as F, toRaw as be } from "vue";
|
|
2
|
+
import { treeIndex as pe, treeLocale as Oe, treeKeys as x, treeKey as X, treeAssign as Se, treeField as Ue } from "./tree.js";
|
|
3
|
+
const I = (u, b) => u.length === b.length && u.every((i, z) => i === b[z]), Ae = (u, b) => u.size === b.length && b.every((i) => u.has(i));
|
|
4
|
+
function Je(u, b, i, z, T = {}) {
|
|
5
|
+
const h = xe(!0), ne = A(u.defaultValue ?? null), ue = A(
|
|
6
|
+
u.defaultCheckedKeys ?? []
|
|
7
|
+
), Y = A(
|
|
8
|
+
u.defaultExpandedKeys ?? []
|
|
9
|
+
), R = A([]), re = xe(u.defaultSearchValue ?? ""), N = A(/* @__PURE__ */ new Map()), M = A(/* @__PURE__ */ new Set()), m = A(/* @__PURE__ */ new Map()), r = f(
|
|
10
|
+
() => pe(u.nodes, u, N.value)
|
|
11
|
+
), Ne = f(() => ({ ...Oe, ...u.locale })), v = f(() => !h.value || b.value || !!u.loading), B = f(
|
|
12
|
+
() => u.modelValue === void 0 ? ne.value : u.modelValue
|
|
13
|
+
), y = f(
|
|
14
|
+
() => x(
|
|
15
|
+
Array.isArray(B.value) ? B.value : X(B.value) ? [B.value] : []
|
|
16
|
+
)
|
|
17
|
+
), se = f(() => new Set(y.value)), D = f(() => !!u.multiple || Array.isArray(B.value)), Z = f(() => u.searchValue ?? re.value), P = f(
|
|
18
|
+
() => x(u.expandedKeys ?? Y.value)
|
|
19
|
+
), _ = f(() => new Set(u.loadedKeys ?? R.value)), H = (e) => {
|
|
20
|
+
const l = [];
|
|
21
|
+
let a = r.value.map.get(e);
|
|
22
|
+
for (; (a == null ? void 0 : a.parent) !== void 0; )
|
|
23
|
+
l.push(a.parent), a = r.value.map.get(a.parent);
|
|
24
|
+
return l;
|
|
25
|
+
}, V = f(() => {
|
|
26
|
+
const e = new Set(P.value);
|
|
27
|
+
if (u.autoExpandParent)
|
|
28
|
+
for (let l = r.value.rows.length - 1; l >= 0; l--) {
|
|
29
|
+
const a = r.value.rows[l];
|
|
30
|
+
e.has(a.key) && a.parent !== void 0 && e.add(a.parent);
|
|
31
|
+
}
|
|
32
|
+
return e;
|
|
33
|
+
}), $ = f(() => {
|
|
34
|
+
const e = /* @__PURE__ */ new Set(), l = Z.value.trim();
|
|
35
|
+
if (!l) return e;
|
|
36
|
+
for (const a of r.value.rows)
|
|
37
|
+
(u.filterNode ? u.filterNode(l, a.node) : a.label.toLocaleLowerCase().includes(l.toLocaleLowerCase())) && e.add(a.key);
|
|
38
|
+
return e;
|
|
39
|
+
}), Me = f(() => {
|
|
40
|
+
const e = Z.value.trim(), l = new Set($.value);
|
|
41
|
+
if (e && u.filterMode !== "highlight") {
|
|
42
|
+
for (let t = r.value.rows.length - 1; t >= 0; t--) {
|
|
43
|
+
const n = r.value.rows[t];
|
|
44
|
+
l.has(n.key) && n.parent !== void 0 && l.add(n.parent);
|
|
45
|
+
}
|
|
46
|
+
if (u.showMatchedChildren) {
|
|
47
|
+
const t = new Set($.value);
|
|
48
|
+
for (const n of r.value.rows)
|
|
49
|
+
n.parent !== void 0 && t.has(n.parent) && (t.add(n.key), l.add(n.key));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const a = /* @__PURE__ */ new Set();
|
|
53
|
+
return r.value.rows.filter((t) => {
|
|
54
|
+
const n = e && u.filterMode !== "highlight" ? l.has(t.key) : t.parent === void 0 || a.has(t.parent);
|
|
55
|
+
return n && (e && u.filterMode !== "highlight" || V.value.has(t.key)) && a.add(t.key), n;
|
|
56
|
+
});
|
|
57
|
+
}), p = (e) => !!e && !e.checkboxDisabled && e.checkable;
|
|
58
|
+
function Pe(e, l = !0) {
|
|
59
|
+
const a = [], t = [e];
|
|
60
|
+
for (; t.length; ) {
|
|
61
|
+
const n = r.value.map.get(t.pop());
|
|
62
|
+
if (!(!n || l && !p(n))) {
|
|
63
|
+
a.push(n.key);
|
|
64
|
+
for (let s = n.children.length - 1; s >= 0; s--)
|
|
65
|
+
t.push(n.children[s]);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return a;
|
|
69
|
+
}
|
|
70
|
+
function de(e, l = !u.checkStrictly) {
|
|
71
|
+
const a = new Set(x(e)), t = /* @__PURE__ */ new Set();
|
|
72
|
+
if (l) {
|
|
73
|
+
const n = /* @__PURE__ */ new Set(), s = [...e];
|
|
74
|
+
for (; s.length; ) {
|
|
75
|
+
const o = s.pop(), d = r.value.map.get(o);
|
|
76
|
+
if (!(!d || n.has(o) || !p(d))) {
|
|
77
|
+
n.add(o), a.add(o);
|
|
78
|
+
for (const c of d.children) s.push(c);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
for (let o = r.value.rows.length - 1; o >= 0; o--) {
|
|
82
|
+
const d = r.value.rows[o];
|
|
83
|
+
if (!p(d)) continue;
|
|
84
|
+
const c = d.children.filter(
|
|
85
|
+
(C) => p(r.value.map.get(C))
|
|
86
|
+
);
|
|
87
|
+
c.length && (c.every((C) => a.has(C)) ? a.add(d.key) : (a.delete(d.key), c.some((C) => a.has(C) || t.has(C)) && t.add(d.key)));
|
|
88
|
+
}
|
|
89
|
+
} else
|
|
90
|
+
for (const n of u.halfCheckedKeys ?? [])
|
|
91
|
+
r.value.map.has(n) && !a.has(n) && t.add(n);
|
|
92
|
+
return { full: a, half: t };
|
|
93
|
+
}
|
|
94
|
+
const oe = f(
|
|
95
|
+
() => de(u.checkedKeys ?? ue.value)
|
|
96
|
+
), S = f(() => oe.value.full), O = f(() => oe.value.half), U = (e, l = !1) => r.value.rows.filter((a) => e.has(a.key) && (!l || !a.hasChildren)).map((a) => a.key), ie = (e = !1) => U(S.value, e), ce = () => U(O.value), fe = (e = !1, l = !1) => r.value.rows.filter(
|
|
97
|
+
(a) => (S.value.has(a.key) || l && O.value.has(a.key)) && (!e || !a.hasChildren)
|
|
98
|
+
).map((a) => a.node), E = (e) => X(e) ? e : typeof u.nodeKey == "function" ? u.nodeKey(e) : Ue(
|
|
99
|
+
e,
|
|
100
|
+
typeof u.nodeKey == "string" ? u.nodeKey : r.value.fields.id
|
|
101
|
+
), L = (e) => r.value.map.get(E(e)), k = (e) => {
|
|
102
|
+
var l;
|
|
103
|
+
return (l = L(e)) == null ? void 0 : l.node;
|
|
104
|
+
};
|
|
105
|
+
let w = 0, ve = 0, he = 0;
|
|
106
|
+
function ee(e, l, a) {
|
|
107
|
+
return {
|
|
108
|
+
node: e,
|
|
109
|
+
checked: l,
|
|
110
|
+
checkedKeys: ie(),
|
|
111
|
+
checkedNodes: fe(),
|
|
112
|
+
halfCheckedKeys: ce(),
|
|
113
|
+
halfCheckedNodes: r.value.rows.filter((t) => O.value.has(t.key)).map((t) => t.node),
|
|
114
|
+
event: a
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
async function we(e, l, a, t) {
|
|
118
|
+
if (v.value) return !1;
|
|
119
|
+
const n = de(e), s = [...n.full], o = ++ve, d = w;
|
|
120
|
+
return Ae(S.value, s) || (u.checkedKeys === void 0 && (ue.value = s), i("update:checkedKeys", s), i("check", s, {
|
|
121
|
+
...ee(l, a, t),
|
|
122
|
+
checkedKeys: U(n.full),
|
|
123
|
+
checkedNodes: r.value.rows.filter((c) => n.full.has(c.key)).map((c) => c.node),
|
|
124
|
+
halfCheckedKeys: U(n.half),
|
|
125
|
+
halfCheckedNodes: r.value.rows.filter((c) => n.half.has(c.key)).map((c) => c.node)
|
|
126
|
+
}), await F(), !h.value || w !== d || o !== ve || !Ae(S.value, s)) ? !1 : (i("check-change", ee(l, a, t)), z(), !0);
|
|
127
|
+
}
|
|
128
|
+
function Ve(e, l = !1) {
|
|
129
|
+
const a = x(e).filter((t) => {
|
|
130
|
+
const n = r.value.map.get(t);
|
|
131
|
+
return !n || p(n) && (!l || !n.hasChildren);
|
|
132
|
+
});
|
|
133
|
+
for (const t of S.value)
|
|
134
|
+
r.value.map.has(t) && !p(r.value.map.get(t)) && a.push(t);
|
|
135
|
+
return we(a);
|
|
136
|
+
}
|
|
137
|
+
function Ee(e, l, a = !u.checkStrictly, t) {
|
|
138
|
+
const n = L(e);
|
|
139
|
+
if (!p(n) || !n) return Promise.resolve(!1);
|
|
140
|
+
const s = new Set(S.value), o = a ? Pe(n.key) : [n.key];
|
|
141
|
+
for (const d of o) l ? s.add(d) : s.delete(d);
|
|
142
|
+
if (!l && !u.checkStrictly)
|
|
143
|
+
for (const d of H(n.key)) s.delete(d);
|
|
144
|
+
return we([...s], n.node, l, t);
|
|
145
|
+
}
|
|
146
|
+
async function ae(e, l = null, a) {
|
|
147
|
+
if (v.value || u.selectable === !1) return !1;
|
|
148
|
+
const t = x(e).filter((d) => {
|
|
149
|
+
const c = r.value.map.get(d);
|
|
150
|
+
return !c || !c.disabled && c.selectable;
|
|
151
|
+
});
|
|
152
|
+
if (D.value || t.splice(1), I(t, y.value)) return !1;
|
|
153
|
+
const n = D.value ? t : t[0] ?? null, s = w, o = ++he;
|
|
154
|
+
return u.modelValue === void 0 && (ne.value = n), i("update:modelValue", n), l && i("select", l, {
|
|
155
|
+
node: l,
|
|
156
|
+
selected: t.includes(E(l)),
|
|
157
|
+
selectedKeys: t,
|
|
158
|
+
selectedNodes: t.flatMap((d) => k(d) ?? []),
|
|
159
|
+
event: a
|
|
160
|
+
}), await F(), !h.value || w !== s || o !== he || !I(t, y.value) ? !1 : (i("selection-change", {
|
|
161
|
+
node: l,
|
|
162
|
+
selected: l ? t.includes(E(l)) : !1,
|
|
163
|
+
selectedKeys: t,
|
|
164
|
+
selectedNodes: t.flatMap((d) => k(d) ?? []),
|
|
165
|
+
event: a
|
|
166
|
+
}), z(), !0);
|
|
167
|
+
}
|
|
168
|
+
function Le(e, l) {
|
|
169
|
+
if (v.value || e.disabled || !e.selectable || u.selectable === !1)
|
|
170
|
+
return Promise.resolve(!1);
|
|
171
|
+
const a = se.value.has(e.key) ? D.value || u.allowDeselect ? y.value.filter((t) => t !== e.key) : y.value : D.value ? [...y.value, e.key] : [e.key];
|
|
172
|
+
return ae(a, e.node, l);
|
|
173
|
+
}
|
|
174
|
+
async function le(e) {
|
|
175
|
+
if (v.value) return !1;
|
|
176
|
+
const l = x(e), a = w;
|
|
177
|
+
return I(l, P.value) ? !1 : (u.expandedKeys === void 0 && (Y.value = l), i("update:expandedKeys", l), await F(), h.value && w === a && I(l, P.value));
|
|
178
|
+
}
|
|
179
|
+
const K = /* @__PURE__ */ new Map();
|
|
180
|
+
function j() {
|
|
181
|
+
for (const e of K.values()) e.controller.abort();
|
|
182
|
+
K.clear(), M.value = /* @__PURE__ */ new Set();
|
|
183
|
+
}
|
|
184
|
+
function G(e, l = !1) {
|
|
185
|
+
var ke;
|
|
186
|
+
const a = r.value.map.get(e);
|
|
187
|
+
if (!a || v.value || ((ke = T.loadActive) == null ? void 0 : ke.value) === !1 || !u.loadChildren || a.leaf)
|
|
188
|
+
return Promise.resolve(!1);
|
|
189
|
+
if (!l && (_.value.has(e) || a.children.length))
|
|
190
|
+
return Promise.resolve(!0);
|
|
191
|
+
if (K.has(e)) return K.get(e).promise;
|
|
192
|
+
const t = new AbortController(), n = w, s = u.nodes, o = u.loadChildren;
|
|
193
|
+
let d;
|
|
194
|
+
const c = new Promise((W) => d = W);
|
|
195
|
+
K.set(e, { controller: t, promise: c }), t.signal.addEventListener("abort", () => d(!1), {
|
|
196
|
+
once: !0
|
|
197
|
+
}), M.value = /* @__PURE__ */ new Set([...M.value, e]);
|
|
198
|
+
const C = new Map(m.value);
|
|
199
|
+
return C.delete(e), m.value = C, (async () => {
|
|
200
|
+
var W, Ke;
|
|
201
|
+
try {
|
|
202
|
+
const g = await o(a.node, {
|
|
203
|
+
signal: t.signal,
|
|
204
|
+
key: e
|
|
205
|
+
});
|
|
206
|
+
if (t.signal.aborted || !h.value || n !== w || s !== u.nodes || ((W = r.value.map.get(e)) == null ? void 0 : W.node) !== a.node || o !== u.loadChildren)
|
|
207
|
+
return !1;
|
|
208
|
+
if (!Array.isArray(g))
|
|
209
|
+
throw new TypeError("loadChildren must resolve to an array");
|
|
210
|
+
const te = x([...u.loadedKeys ?? R.value, e]);
|
|
211
|
+
if (u.loadedKeys === void 0 && (R.value = te), i("update:loadedKeys", te), await F(), t.signal.aborted || !h.value || n !== w || !_.value.has(e))
|
|
212
|
+
return !1;
|
|
213
|
+
const Ce = new Map(N.value);
|
|
214
|
+
return Ce.set(e, g), N.value = Ce, i("children-loaded", { node: a.node, children: g }), i("load", { node: a.node, children: g, loadedKeys: te }), !0;
|
|
215
|
+
} catch (g) {
|
|
216
|
+
return t.signal.aborted || !h.value || n !== w || (m.value = new Map([...m.value, [e, g]]), i("load-error", { node: a.node, error: g })), !1;
|
|
217
|
+
} finally {
|
|
218
|
+
if (((Ke = K.get(e)) == null ? void 0 : Ke.controller) === t) {
|
|
219
|
+
K.delete(e);
|
|
220
|
+
const g = new Set(M.value);
|
|
221
|
+
g.delete(e), M.value = g;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
})().then(d, () => d(!1)), c;
|
|
225
|
+
}
|
|
226
|
+
async function qe(e, l = !0) {
|
|
227
|
+
const a = r.value.map.get(e);
|
|
228
|
+
if (!a || a.disabled || !a.hasChildren || v.value) return !1;
|
|
229
|
+
const t = m.value.has(e);
|
|
230
|
+
let n = P.value.filter((o) => o !== e);
|
|
231
|
+
!l && u.autoExpandParent && (n = n.filter((o) => !H(o).includes(e))), l && (u.accordion && (n = n.filter((o) => {
|
|
232
|
+
let d = r.value.map.get(o);
|
|
233
|
+
for (; d && d.depth > a.depth; )
|
|
234
|
+
d = d.parent === void 0 ? void 0 : r.value.map.get(d.parent);
|
|
235
|
+
return !d || d.parent !== a.parent || d.key === e;
|
|
236
|
+
})), n.push(e));
|
|
237
|
+
const s = await le(n);
|
|
238
|
+
return s && i(l ? "node-expand" : "node-collapse", a.node, {
|
|
239
|
+
key: e,
|
|
240
|
+
expanded: l,
|
|
241
|
+
expandedKeys: [...V.value]
|
|
242
|
+
}), l && V.value.has(e) && (!m.value.has(e) || t) && await G(e), s;
|
|
243
|
+
}
|
|
244
|
+
function Te(e) {
|
|
245
|
+
v.value || (u.searchValue === void 0 && (re.value = e), i("update:searchValue", e), i("search", e));
|
|
246
|
+
}
|
|
247
|
+
async function Be(e, l = !0) {
|
|
248
|
+
if (e !== null) {
|
|
249
|
+
const a = r.value.map.get(e);
|
|
250
|
+
if (!a || a.disabled || !a.selectable) return !1;
|
|
251
|
+
}
|
|
252
|
+
return e !== null && l && await le(
|
|
253
|
+
x([...P.value, ...H(e)])
|
|
254
|
+
), ae(
|
|
255
|
+
e === null ? [] : [e],
|
|
256
|
+
e === null ? null : k(e) ?? null
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
function J(e, l) {
|
|
260
|
+
const a = r.value.map.get(e);
|
|
261
|
+
if (!a) return;
|
|
262
|
+
let t = Se(a.node, r.value.fields.children, [
|
|
263
|
+
...l
|
|
264
|
+
]), n = a;
|
|
265
|
+
for (; n.parent !== void 0; ) {
|
|
266
|
+
const s = r.value.map.get(n.parent);
|
|
267
|
+
t = Se(
|
|
268
|
+
s.node,
|
|
269
|
+
r.value.fields.children,
|
|
270
|
+
s.children.map((o) => o === n.key ? t : k(o))
|
|
271
|
+
), n = s;
|
|
272
|
+
}
|
|
273
|
+
return r.value.roots.map((s) => s === n.key ? t : k(s));
|
|
274
|
+
}
|
|
275
|
+
async function Q(e, l, a) {
|
|
276
|
+
if (!e || v.value) return !1;
|
|
277
|
+
const t = pe(e, u);
|
|
278
|
+
return t.invalid || (i("update:nodes", e), i("data-change", { nodes: e, action: l, key: a }), await F(), !h.value) ? !1 : I(
|
|
279
|
+
r.value.rows.map((n) => n.key),
|
|
280
|
+
t.rows.map((n) => n.key)
|
|
281
|
+
) && r.value.rows.every(
|
|
282
|
+
(n, s) => n.parent === t.rows[s].parent && be(n.node) === be(t.rows[s].node)
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
function ye(e) {
|
|
286
|
+
return (e.parent === void 0 ? r.value.roots : r.value.map.get(e.parent).children).map((l) => k(l));
|
|
287
|
+
}
|
|
288
|
+
function ge(e, l, a) {
|
|
289
|
+
const t = L(l), n = E(e);
|
|
290
|
+
if (!t || t.disabled || !X(n) || r.value.map.has(n))
|
|
291
|
+
return Promise.resolve(!1);
|
|
292
|
+
const s = ye(t), o = s.indexOf(t.node);
|
|
293
|
+
return s.splice(o + (a ? 1 : 0), 0, e), Q(
|
|
294
|
+
t.parent === void 0 ? s : J(t.parent, s),
|
|
295
|
+
a ? "insertAfter" : "insertBefore",
|
|
296
|
+
n
|
|
297
|
+
);
|
|
298
|
+
}
|
|
299
|
+
const De = (e, l) => {
|
|
300
|
+
const a = E(e), t = l === void 0 ? void 0 : L(l);
|
|
301
|
+
return !X(a) || r.value.map.has(a) || l !== void 0 && (!t || t.disabled || t.leaf) ? Promise.resolve(!1) : Q(
|
|
302
|
+
t ? J(t.key, [
|
|
303
|
+
...t.children.map((n) => k(n)),
|
|
304
|
+
e
|
|
305
|
+
]) : [...u.nodes, e],
|
|
306
|
+
"append",
|
|
307
|
+
a
|
|
308
|
+
);
|
|
309
|
+
};
|
|
310
|
+
function Fe(e) {
|
|
311
|
+
const l = L(e);
|
|
312
|
+
if (!l || l.disabled) return Promise.resolve(!1);
|
|
313
|
+
const a = ye(l).filter((t) => E(t) !== l.key);
|
|
314
|
+
return Q(
|
|
315
|
+
l.parent === void 0 ? a : J(l.parent, a),
|
|
316
|
+
"remove",
|
|
317
|
+
l.key
|
|
318
|
+
);
|
|
319
|
+
}
|
|
320
|
+
async function Ie(e) {
|
|
321
|
+
var a;
|
|
322
|
+
return !r.value.map.get(e) || v.value ? !1 : ((a = K.get(e)) == null || a.controller.abort(), K.delete(e), G(e, !0));
|
|
323
|
+
}
|
|
324
|
+
q(
|
|
325
|
+
() => [
|
|
326
|
+
u.nodes,
|
|
327
|
+
u.loadChildren,
|
|
328
|
+
u.nodeKey,
|
|
329
|
+
u.fieldNames
|
|
330
|
+
],
|
|
331
|
+
() => {
|
|
332
|
+
w++, j(), N.value = /* @__PURE__ */ new Map(), R.value = [], m.value = /* @__PURE__ */ new Map();
|
|
333
|
+
},
|
|
334
|
+
{ flush: "sync" }
|
|
335
|
+
), q(
|
|
336
|
+
() => [u.nodes, u.defaultExpandAll],
|
|
337
|
+
() => {
|
|
338
|
+
u.defaultExpandAll && u.expandedKeys === void 0 && (Y.value = r.value.rows.filter((e) => e.hasChildren).map((e) => e.key));
|
|
339
|
+
},
|
|
340
|
+
{ immediate: !0 }
|
|
341
|
+
), q(
|
|
342
|
+
() => {
|
|
343
|
+
var e;
|
|
344
|
+
return [
|
|
345
|
+
...V.value,
|
|
346
|
+
h.value,
|
|
347
|
+
v.value,
|
|
348
|
+
r.value,
|
|
349
|
+
(e = T.loadActive) == null ? void 0 : e.value
|
|
350
|
+
];
|
|
351
|
+
},
|
|
352
|
+
() => {
|
|
353
|
+
var e;
|
|
354
|
+
if (!v.value && ((e = T.loadActive) == null ? void 0 : e.value) !== !1)
|
|
355
|
+
for (const l of V.value) {
|
|
356
|
+
const a = r.value.map.get(l);
|
|
357
|
+
a != null && a.hasChildren && !a.children.length && !_.value.has(l) && !m.value.has(l) && G(l);
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
{ immediate: !0 }
|
|
361
|
+
), q(
|
|
362
|
+
() => u.loadedKeys,
|
|
363
|
+
(e, l) => {
|
|
364
|
+
if (e && l) {
|
|
365
|
+
const a = new Map(N.value);
|
|
366
|
+
for (const t of l) e.includes(t) || a.delete(t);
|
|
367
|
+
N.value = a;
|
|
368
|
+
}
|
|
369
|
+
},
|
|
370
|
+
{ flush: "sync" }
|
|
371
|
+
);
|
|
372
|
+
function me() {
|
|
373
|
+
h.value = !1, w++, j();
|
|
374
|
+
}
|
|
375
|
+
return T.loadActive && q(
|
|
376
|
+
T.loadActive,
|
|
377
|
+
(e) => {
|
|
378
|
+
e || j();
|
|
379
|
+
},
|
|
380
|
+
{ flush: "sync" }
|
|
381
|
+
), q(
|
|
382
|
+
v,
|
|
383
|
+
(e) => {
|
|
384
|
+
e && j();
|
|
385
|
+
},
|
|
386
|
+
{ flush: "sync" }
|
|
387
|
+
), ze(me), Re(me), He(() => h.value = !0), {
|
|
388
|
+
live: h,
|
|
389
|
+
busy: v,
|
|
390
|
+
index: r,
|
|
391
|
+
words: Ne,
|
|
392
|
+
query: Z,
|
|
393
|
+
expanded: V,
|
|
394
|
+
rawExpanded: P,
|
|
395
|
+
selected: y,
|
|
396
|
+
selection: se,
|
|
397
|
+
multiple: D,
|
|
398
|
+
visible: Me,
|
|
399
|
+
matches: $,
|
|
400
|
+
checked: S,
|
|
401
|
+
halfChecked: O,
|
|
402
|
+
loadingKeys: M,
|
|
403
|
+
failures: m,
|
|
404
|
+
ancestors: H,
|
|
405
|
+
getNode: k,
|
|
406
|
+
getNodeInfo: L,
|
|
407
|
+
getCheckedKeys: ie,
|
|
408
|
+
getCheckedNodes: fe,
|
|
409
|
+
getHalfCheckedKeys: ce,
|
|
410
|
+
checkInfo: ee,
|
|
411
|
+
setCheckedKeys: Ve,
|
|
412
|
+
setChecked: Ee,
|
|
413
|
+
selectNode: Le,
|
|
414
|
+
setSelectedKeys: ae,
|
|
415
|
+
setCurrentKey: Be,
|
|
416
|
+
getCurrentKey: () => y.value[0] ?? null,
|
|
417
|
+
getCurrentNode: () => y.value.length ? k(y.value[0]) ?? null : null,
|
|
418
|
+
setExpandedKeys: le,
|
|
419
|
+
expandNode: qe,
|
|
420
|
+
filter: Te,
|
|
421
|
+
reloadNode: Ie,
|
|
422
|
+
load: G,
|
|
423
|
+
append: De,
|
|
424
|
+
remove: Fe,
|
|
425
|
+
insertBefore: (e, l) => ge(e, l, !1),
|
|
426
|
+
insertAfter: (e, l) => ge(e, l, !0),
|
|
427
|
+
updateKeyChildren: (e, l) => {
|
|
428
|
+
var a, t;
|
|
429
|
+
return (a = r.value.map.get(e)) != null && a.disabled || (t = r.value.map.get(e)) != null && t.leaf && l.length ? Promise.resolve(!1) : Q(
|
|
430
|
+
J(e, l),
|
|
431
|
+
"updateKeyChildren",
|
|
432
|
+
e
|
|
433
|
+
);
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
export {
|
|
438
|
+
Je as useTree
|
|
439
|
+
};
|