hys-ui 0.1.0 → 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 +137 -1
- package/README.md +18 -6
- package/dist/components/HysAccordion/HysAccordion.vue.js +1 -1
- package/dist/components/HysAccordion/HysAccordion2.vue.js +181 -47
- package/dist/components/HysAlert/HysAlert.vue.js +14 -14
- package/dist/components/HysAnimatedNumber/HysAnimatedNumber.vue.js +23 -20
- 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 -26
- 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 -84
- package/dist/components/HysCalendar/HysCalendar2.vue.js +803 -2
- package/dist/components/HysCard/HysCard.vue.js +1 -1
- package/dist/components/HysCard/HysCard2.vue.js +177 -44
- package/dist/components/HysCascader/HysCascader.vue.js +5 -182
- 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 +5 -39
- package/dist/components/HysCheckbox/HysCheckbox2.vue.js +200 -2
- 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/HysCommandPalette/HysCommandPalette.vue.js +52 -51
- package/dist/components/HysCommentEditor/HysCommentEditor.vue.js +17 -17
- package/dist/components/HysDataGrid/HysDataGrid.vue.js +1 -1
- package/dist/components/HysDataGrid/HysDataGrid2.vue.js +397 -390
- 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/HysDrawer/HysDrawer.vue.js +1 -1
- package/dist/components/HysDrawer/HysDrawer2.vue.js +55 -54
- package/dist/components/HysFileManager/HysFileManager.vue.js +5 -63
- package/dist/components/HysFileManager/HysFileManager2.vue.js +86 -2
- package/dist/components/HysForm/HysForm.vue.js +3 -3
- package/dist/components/HysForm/HysForm2.vue.js +580 -92
- package/dist/components/HysFormItem/HysFormItem.vue.js +5 -69
- package/dist/components/HysFormItem/HysFormItem2.vue.js +521 -2
- package/dist/components/HysGantt/HysGantt.vue.js +5 -264
- package/dist/components/HysGantt/HysGantt2.vue.js +1399 -2
- package/dist/components/HysInput/HysInput.vue.js +2 -2
- package/dist/components/HysInput/HysInput2.vue.js +468 -120
- package/dist/components/HysMention/HysMention.vue.js +2 -2
- package/dist/components/HysMention/HysMention2.vue.js +89 -88
- package/dist/components/HysModal/HysModal.vue.js +2 -2
- package/dist/components/HysModal/HysModal2.vue.js +35 -35
- package/dist/components/HysNotificationCenter/HysNotificationCenter.vue.js +37 -36
- package/dist/components/HysNumberInput/HysNumberInput.vue.js +2 -2
- package/dist/components/HysNumberInput/HysNumberInput2.vue.js +561 -70
- package/dist/components/HysOrgTree/HysOrgTree.vue.js +41 -36
- package/dist/components/HysPagination/HysPagination.vue.js +2 -2
- package/dist/components/HysPagination/HysPagination2.vue.js +93 -91
- package/dist/components/HysPermissionMatrix/HysPermissionMatrix.vue.js +5 -41
- package/dist/components/HysPermissionMatrix/HysPermissionMatrix2.vue.js +101 -2
- 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 +5 -40
- package/dist/components/HysRadioGroup/HysRadioGroup2.vue.js +205 -2
- package/dist/components/HysRating/HysRating.vue.js +1 -1
- package/dist/components/HysRating/HysRating2.vue.js +288 -68
- package/dist/components/HysResizablePanel/HysResizablePanel.vue.js +46 -28
- package/dist/components/HysRichTextEditor/HysRichTextEditor.vue.js +2 -2
- package/dist/components/HysRichTextEditor/HysRichTextEditor2.vue.js +87 -67
- package/dist/components/HysSearch/HysSearch.vue.js +50 -38
- package/dist/components/HysSegmented/HysSegmented.vue.js +5 -58
- 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 -164
- 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/HysSplitPane/HysSplitPane.vue.js +48 -42
- package/dist/components/HysSteps/HysSteps.vue.js +2 -2
- package/dist/components/HysSteps/HysSteps2.vue.js +111 -36
- package/dist/components/HysSwitch/HysSwitch.vue.js +2 -2
- package/dist/components/HysSwitch/HysSwitch2.vue.js +235 -42
- package/dist/components/HysTable/HysTable.vue.js +1 -1
- package/dist/components/HysTable/HysTable2.vue.js +1471 -82
- 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 -66
- package/dist/components/HysTagInput/HysTagInput.vue.js +43 -42
- package/dist/components/HysTextarea/HysTextarea.vue.js +137 -66
- package/dist/components/HysToast/HysToast.vue.js +2 -2
- package/dist/components/HysToast/HysToast2.vue.js +121 -38
- package/dist/components/HysTour/HysTour.vue.js +47 -42
- package/dist/components/HysTransfer/HysTransfer.vue.js +5 -207
- 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 -301
- package/dist/components/HysTreeSelect/HysTreeSelect.vue.js +5 -129
- 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 +97 -78
- 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 +94 -3
- 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/toastEscape.js +16 -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/useDialog.js +16 -16
- package/dist/composables/useFloating.js +98 -52
- package/dist/composables/useGanttDependencies.js +306 -0
- package/dist/composables/useGanttHistory.js +157 -0
- package/dist/composables/useGanttLabelResize.js +100 -0
- package/dist/composables/useHysToast.js +148 -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/config.js +18 -15
- package/dist/index.js +149 -136
- 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 -29
- package/dist/types/components/HysCard/HysCard.vue.d.ts +57 -5
- 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 +55 -27
- 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/HysDrawer/HysDrawer.vue.d.ts +1 -0
- package/dist/types/components/HysFileManager/HysFileManager.vue.d.ts +8 -4
- 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 +88 -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 -33
- package/dist/types/components/HysOrgTree/HysOrgTree.vue.d.ts +4 -1
- package/dist/types/components/HysPagination/HysPagination.vue.d.ts +1 -1
- package/dist/types/components/HysPermissionMatrix/HysPermissionMatrix.vue.d.ts +8 -1
- 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 +62 -17
- package/dist/types/components/HysRating/HysRating.vue.d.ts +85 -5
- package/dist/types/components/HysResizablePanel/HysResizablePanel.vue.d.ts +6 -0
- 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 -14
- 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 +6 -0
- package/dist/types/components/HysSteps/HysSteps.vue.d.ts +65 -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 +55 -7
- package/dist/types/components/HysTour/HysTour.vue.d.ts +5 -3
- package/dist/types/components/HysTransfer/HysTransfer.vue.d.ts +55 -30
- 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 +138 -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/toastEscape.d.ts +1 -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/useHysToast.d.ts +50 -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 +38 -7
- package/package.json +47 -11
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { defineComponent as k, createApp as F, h as m, getCurrentInstance as Q, shallowReactive as A, Fragment as R, onDeactivated as B, onActivated as N, onScopeDispose as P, nextTick as W, render as b } from "vue";
|
|
2
|
+
import X from "../components/HysToast/HysToast.vue.js";
|
|
3
|
+
import { provideHysConfig as z, useHysRootAttrs as G } from "../config.js";
|
|
4
|
+
let J = 0;
|
|
5
|
+
const g = (n = "top-center") => n === "top" ? "top-center" : n === "bottom" ? "bottom-center" : n;
|
|
6
|
+
function K(n = {}) {
|
|
7
|
+
const l = Q();
|
|
8
|
+
if (!l) throw new Error("useHysToast must be called during component setup");
|
|
9
|
+
const p = G(), a = A([]), d = /* @__PURE__ */ new Map();
|
|
10
|
+
let r, x = !0, v = !1;
|
|
11
|
+
const M = Number.isFinite(n.maxCount) ? Math.max(1, Math.floor(n.maxCount)) : 5, w = (e) => typeof e == "string" ? { message: e } : e;
|
|
12
|
+
function C(e) {
|
|
13
|
+
try {
|
|
14
|
+
e == null || e();
|
|
15
|
+
} catch (o) {
|
|
16
|
+
try {
|
|
17
|
+
l.appContext.config.errorHandler ? l.appContext.config.errorHandler(o, l.proxy, "HysToast callback") : console.error(o);
|
|
18
|
+
} catch (s) {
|
|
19
|
+
console.error(s);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function H(e) {
|
|
24
|
+
if (e.finished) return;
|
|
25
|
+
e.finished = !0;
|
|
26
|
+
const o = a.indexOf(e);
|
|
27
|
+
o >= 0 && a.splice(o, 1), d.delete(e.token), e.resolve(), C(e.onAfterClose);
|
|
28
|
+
const s = r;
|
|
29
|
+
W(() => {
|
|
30
|
+
s && s === r && !a.length && (b(null, s), s.remove(), r = void 0);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
function h(e) {
|
|
34
|
+
if (!(e.closing || e.finished)) {
|
|
35
|
+
e.closing = !0;
|
|
36
|
+
try {
|
|
37
|
+
C(e.onClose);
|
|
38
|
+
} finally {
|
|
39
|
+
const o = d.get(e.token);
|
|
40
|
+
o ? o.close() : H(e);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function I(e, o) {
|
|
45
|
+
if (e.closing || e.finished || v) return;
|
|
46
|
+
const s = w(o), t = e.type;
|
|
47
|
+
Object.assign(e, s, { id: e.id }), s.type && s.type !== t && s.duration === void 0 && (e.duration = s.type === "loading" ? 0 : n.duration), W(() => {
|
|
48
|
+
var f;
|
|
49
|
+
e.closing || (f = d.get(e.token)) == null || f.restart();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function j(e) {
|
|
53
|
+
const o = g(e.position), s = Math.max(0, e.offset ?? 24) + "px", t = { position: "fixed", width: "max-content", display: "flex", flexDirection: o.startsWith("bottom") ? "column-reverse" : "column", gap: "10px", alignItems: o.endsWith("left") ? "flex-start" : o.endsWith("right") ? "flex-end" : "center", maxWidth: `calc(100vw - ${Math.max(16, e.offset ?? 24) * 2}px)`, pointerEvents: "none", zIndex: e.zIndex ?? 2e3 };
|
|
54
|
+
return o === "center" ? Object.assign(t, { left: "50%", top: "50%", transform: "translate(-50%,-50%)" }) : (o.startsWith("bottom") ? t.bottom = `max(${s},env(safe-area-inset-bottom))` : t.top = `max(${s},env(safe-area-inset-top))`, o.endsWith("left") ? t.left = `max(${s},env(safe-area-inset-left))` : o.endsWith("right") ? t.right = `max(${s},env(safe-area-inset-right))` : Object.assign(t, { left: "50%", transform: "translateX(-50%)" })), t;
|
|
55
|
+
}
|
|
56
|
+
const q = k({
|
|
57
|
+
name: "HysToastQueue",
|
|
58
|
+
setup() {
|
|
59
|
+
return z({ theme: () => p.value["data-hys-theme"], motion: () => p.value["data-hys-motion"] }), () => {
|
|
60
|
+
const e = /* @__PURE__ */ new Map();
|
|
61
|
+
for (const o of a) {
|
|
62
|
+
const s = `${g(o.position)}:${o.offset ?? 24}:${o.zIndex ?? 2e3}`, t = e.get(s) || [];
|
|
63
|
+
t.push(o), e.set(s, t);
|
|
64
|
+
}
|
|
65
|
+
return m(R, [...e].map(([o, s]) => m("div", { key: o, ...p.value, class: "hys-ui-toast-stack", style: j(s[0]) }, s.map((t) => m(X, {
|
|
66
|
+
key: t.token,
|
|
67
|
+
ref: (f) => {
|
|
68
|
+
f ? d.set(t.token, f) : d.delete(t.token);
|
|
69
|
+
},
|
|
70
|
+
"data-toast-id": t.id,
|
|
71
|
+
message: t.message,
|
|
72
|
+
type: t.type,
|
|
73
|
+
duration: t.duration,
|
|
74
|
+
closable: t.closable ?? !0,
|
|
75
|
+
showIcon: t.showIcon ?? !0,
|
|
76
|
+
pauseOnHover: t.pauseOnHover ?? !0,
|
|
77
|
+
closeOnEscape: t.closeOnEscape,
|
|
78
|
+
position: t.position,
|
|
79
|
+
offset: t.offset,
|
|
80
|
+
zIndex: t.zIndex,
|
|
81
|
+
plain: t.plain,
|
|
82
|
+
repeat: t.repeat,
|
|
83
|
+
teleport: !1,
|
|
84
|
+
onClose: () => h(t),
|
|
85
|
+
onAfterClose: () => H(t)
|
|
86
|
+
}, {
|
|
87
|
+
...t.content !== void 0 ? { default: () => typeof t.content == "function" ? t.content() : t.content } : {},
|
|
88
|
+
...t.icon !== void 0 ? { icon: () => typeof t.icon == "function" ? t.icon() : t.icon } : {}
|
|
89
|
+
})))));
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
function D() {
|
|
94
|
+
if (r) return;
|
|
95
|
+
const e = typeof n.appendTo == "string" ? document.querySelector(n.appendTo) : n.appendTo ?? document.body;
|
|
96
|
+
if (!e) throw new Error("Toast appendTo target was not found");
|
|
97
|
+
r = document.createElement("div"), r.dataset.hysToastHost = "", e.appendChild(r);
|
|
98
|
+
const o = m(q);
|
|
99
|
+
o.appContext = l.appContext, b(o, r);
|
|
100
|
+
}
|
|
101
|
+
function O(e) {
|
|
102
|
+
const o = w(e), s = { type: "info", ...n, ...o };
|
|
103
|
+
s.type === "loading" && o.duration === void 0 && (s.duration = 0);
|
|
104
|
+
const t = a.find((i) => !i.closing && (o.id && i.id === o.id || s.grouping && o.message && o.content === void 0 && i.message === o.message && i.type === s.type && g(i.position) === g(s.position)));
|
|
105
|
+
if (t)
|
|
106
|
+
return o.id || t.repeat++, I(t, o), t.handle;
|
|
107
|
+
const f = "hys-toast-" + ++J, $ = o.id ?? f;
|
|
108
|
+
let T;
|
|
109
|
+
const S = new Promise((i) => {
|
|
110
|
+
T = i;
|
|
111
|
+
}), c = A({ ...s, token: f, id: $, repeat: 1, closing: !1, finished: !1, resolve: T });
|
|
112
|
+
if (c.handle = { id: $, closed: S, close: () => h(c), update: (i) => I(c, i) }, v || !x || !c.message && (c.content == null || c.content === !1 || c.content === ""))
|
|
113
|
+
return c.finished = !0, T(), c.handle;
|
|
114
|
+
for (; a.filter((i) => !i.closing).length >= M; ) h(a.find((i) => !i.closing));
|
|
115
|
+
return D(), a.push(c), c.handle;
|
|
116
|
+
}
|
|
117
|
+
function E() {
|
|
118
|
+
for (const e of [...a])
|
|
119
|
+
e.closing || (e.closing = !0, C(e.onClose)), H(e);
|
|
120
|
+
r && (b(null, r), r.remove(), r = void 0);
|
|
121
|
+
}
|
|
122
|
+
B(() => {
|
|
123
|
+
x = !1, E();
|
|
124
|
+
}), N(() => {
|
|
125
|
+
x = !0;
|
|
126
|
+
}), P(() => {
|
|
127
|
+
v = !0, E();
|
|
128
|
+
});
|
|
129
|
+
const u = (e) => (o) => O({ ...w(o), type: e });
|
|
130
|
+
return { show: O, success: u("success"), info: u("info"), warning: u("warning"), error: u("error"), loading: u("loading"), closeAll: () => {
|
|
131
|
+
for (const e of [...a]) h(e);
|
|
132
|
+
} };
|
|
133
|
+
}
|
|
134
|
+
function Y(n = {}) {
|
|
135
|
+
let l, p = !1;
|
|
136
|
+
const a = k({ setup() {
|
|
137
|
+
return l = K(n), () => null;
|
|
138
|
+
} }), d = F(k({ setup() {
|
|
139
|
+
return z(n), () => m(a);
|
|
140
|
+
} }));
|
|
141
|
+
return d.mount(document.createElement("div")), { ...l, dispose() {
|
|
142
|
+
p || (p = !0, d.unmount());
|
|
143
|
+
} };
|
|
144
|
+
}
|
|
145
|
+
export {
|
|
146
|
+
Y as createHysToast,
|
|
147
|
+
K as useHysToast
|
|
148
|
+
};
|
|
@@ -0,0 +1,474 @@
|
|
|
1
|
+
import { ref as A, computed as v, shallowRef as re, watch as _, nextTick as $, onActivated as Ne, onDeactivated as We, onBeforeUnmount as Ve } from "vue";
|
|
2
|
+
import { tableValue as ue, tableToken as y, tableFilterPredicate as De, tableCompare as Be } from "./table.js";
|
|
3
|
+
function Ge(n, b, ie, s) {
|
|
4
|
+
const d = A(!0), g = v(() => !!n.loading || !!n.disabled), K = A(
|
|
5
|
+
Array.isArray(n.defaultSort) ? [...n.defaultSort] : n.defaultSort ? [n.defaultSort] : n.defaultSort === void 0 ? b().filter((e) => e.defaultSortOrder).map((e) => ({ key: e.key, direction: e.defaultSortOrder })) : []
|
|
6
|
+
), se = A({
|
|
7
|
+
...Object.fromEntries(
|
|
8
|
+
b().filter((e) => e.defaultFilterValue).map((e) => [e.key, [...e.defaultFilterValue]])
|
|
9
|
+
),
|
|
10
|
+
...n.defaultFilters
|
|
11
|
+
}), I = A(1), N = A(10), ce = A([
|
|
12
|
+
...n.defaultSelectedRowKeys ?? []
|
|
13
|
+
]), ve = A([...n.defaultExpandedRowKeys ?? []]), p = A(
|
|
14
|
+
n.defaultCurrentRowKey ?? null
|
|
15
|
+
), x = re(
|
|
16
|
+
/* @__PURE__ */ new Map()
|
|
17
|
+
), h = re(
|
|
18
|
+
/* @__PURE__ */ new Map()
|
|
19
|
+
), C = re(/* @__PURE__ */ new Map());
|
|
20
|
+
let W = /* @__PURE__ */ new WeakSet();
|
|
21
|
+
const ee = /* @__PURE__ */ new WeakMap();
|
|
22
|
+
let Re = 0;
|
|
23
|
+
function te(e) {
|
|
24
|
+
const a = typeof n.rowKey == "function" ? n.rowKey(e) : ue(e, n.rowKey ?? "id");
|
|
25
|
+
return typeof a == "string" || typeof a == "number" && Number.isFinite(a) ? a : (ee.has(e) || ee.set(e, "@hys-table-row:" + ++Re), ee.get(e));
|
|
26
|
+
}
|
|
27
|
+
const f = v(() => {
|
|
28
|
+
const e = [], a = [], t = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new WeakSet(), o = [...n.rows].reverse().map((r) => ({
|
|
29
|
+
row: r,
|
|
30
|
+
parent: void 0,
|
|
31
|
+
depth: 0
|
|
32
|
+
}));
|
|
33
|
+
for (; o.length; ) {
|
|
34
|
+
const { row: r, parent: u, depth: c } = o.pop();
|
|
35
|
+
if (!r || typeof r != "object" || l.has(r)) continue;
|
|
36
|
+
l.add(r);
|
|
37
|
+
const w = te(r), k = y(w);
|
|
38
|
+
if (t.has(k)) continue;
|
|
39
|
+
const q = n.treeMode ? ue(r, n.childrenKey ?? "children") : void 0, S = x.value.get(k), U = (S == null ? void 0 : S.row) === r && S.override ? S.rows : Array.isArray(q) ? q : (S == null ? void 0 : S.row) === r ? S.rows : [], i = {
|
|
40
|
+
row: r,
|
|
41
|
+
key: w,
|
|
42
|
+
token: k,
|
|
43
|
+
index: a.length,
|
|
44
|
+
depth: c,
|
|
45
|
+
rootToken: (u == null ? void 0 : u.rootToken) ?? k,
|
|
46
|
+
parent: u,
|
|
47
|
+
children: [],
|
|
48
|
+
lazy: !!n.treeMode && !!n.loadChildren && !Array.isArray(q) && (S == null ? void 0 : S.row) !== r && !!ue(r, n.hasChildrenKey ?? "hasChildren")
|
|
49
|
+
};
|
|
50
|
+
if (t.set(k, i), a.push(i), ((u == null ? void 0 : u.children) ?? e).push(i), n.treeMode)
|
|
51
|
+
for (let oe = U.length - 1; oe >= 0; oe--)
|
|
52
|
+
o.push({ row: U[oe], parent: i, depth: c + 1 });
|
|
53
|
+
}
|
|
54
|
+
return { roots: e, all: a, map: t };
|
|
55
|
+
}), M = v(() => [
|
|
56
|
+
...new Set(n.selectedRowKeys ?? ce.value)
|
|
57
|
+
]), m = v(
|
|
58
|
+
() => new Set(M.value.map(y))
|
|
59
|
+
), V = v(() => [
|
|
60
|
+
...new Set(
|
|
61
|
+
n.expandedRowKeys ?? (n.defaultExpandAll && !fe.value ? f.value.all.filter((e) => e.children.length || e.lazy || ie()).map((e) => e.key) : ve.value)
|
|
62
|
+
)
|
|
63
|
+
]), fe = A(!1), D = v(() => new Set(V.value.map(y))), G = /* @__PURE__ */ new Map();
|
|
64
|
+
_(
|
|
65
|
+
[M, () => f.value.all, () => n.reserveSelection],
|
|
66
|
+
() => {
|
|
67
|
+
var a, t;
|
|
68
|
+
for (const l of G.keys())
|
|
69
|
+
m.value.has(l) || G.delete(l);
|
|
70
|
+
for (const l of M.value) {
|
|
71
|
+
const o = f.value.map.get(y(l));
|
|
72
|
+
o && G.set(o.token, o.row);
|
|
73
|
+
}
|
|
74
|
+
if (!n.reserveSelection) {
|
|
75
|
+
const l = M.value.filter(
|
|
76
|
+
(o) => f.value.map.has(y(o))
|
|
77
|
+
);
|
|
78
|
+
l.length !== M.value.length && j(l);
|
|
79
|
+
}
|
|
80
|
+
let e;
|
|
81
|
+
for (const [l, o] of x.value)
|
|
82
|
+
((a = f.value.map.get(l)) == null ? void 0 : a.row) !== o.row && (e ?? (e = new Map(x.value)), e.delete(l));
|
|
83
|
+
e && (x.value = e);
|
|
84
|
+
for (const [l, o] of h.value)
|
|
85
|
+
((t = f.value.map.get(l)) == null ? void 0 : t.row) !== o.row && P(l);
|
|
86
|
+
},
|
|
87
|
+
{ immediate: !0 }
|
|
88
|
+
);
|
|
89
|
+
const E = v(() => {
|
|
90
|
+
const e = n.sorts ?? (n.sort !== void 0 ? n.sort ? [n.sort] : [] : K.value), a = /* @__PURE__ */ new Set();
|
|
91
|
+
return e.filter(
|
|
92
|
+
(t) => ["asc", "desc"].includes(t.direction) && b().some((l) => l.key === t.key && l.sortable) && !a.has(t.key) && (a.add(t.key), !0)
|
|
93
|
+
).slice(0, n.multiSort ? void 0 : 1).sort(
|
|
94
|
+
(t, l) => {
|
|
95
|
+
var o, r;
|
|
96
|
+
return (((o = b().find((u) => u.key === l.key)) == null ? void 0 : o.sortPriority) ?? 0) - (((r = b().find((u) => u.key === t.key)) == null ? void 0 : r.sortPriority) ?? 0);
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
}), F = v(
|
|
100
|
+
() => n.filters ?? se.value
|
|
101
|
+
), z = v(() => {
|
|
102
|
+
const e = f.value, a = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Map(), l = De(F.value, b());
|
|
103
|
+
if (!n.serverMode)
|
|
104
|
+
for (let u = e.all.length - 1; u >= 0; u--) {
|
|
105
|
+
const c = e.all[u];
|
|
106
|
+
(l(c.row) || c.children.some((w) => a.has(w.token))) && a.add(c.token);
|
|
107
|
+
}
|
|
108
|
+
const o = Be(E.value, b());
|
|
109
|
+
function r(u) {
|
|
110
|
+
const c = n.serverMode ? [...u] : u.filter((w) => a.has(w.token));
|
|
111
|
+
return n.serverMode || !E.value.length ? c : c.sort((w, k) => o(w.row, k.row) || w.index - k.index);
|
|
112
|
+
}
|
|
113
|
+
for (const u of e.all)
|
|
114
|
+
u.children.length && t.set(u.token, r(u.children));
|
|
115
|
+
return { roots: r(e.roots), children: t };
|
|
116
|
+
}), J = v(
|
|
117
|
+
() => typeof n.pagination == "object" ? n.pagination : {}
|
|
118
|
+
), B = v(() => {
|
|
119
|
+
const e = n.pageSize ?? J.value.pageSize ?? N.value;
|
|
120
|
+
return Number.isFinite(e) && e > 0 ? Math.floor(e) : 10;
|
|
121
|
+
}), de = v(
|
|
122
|
+
() => n.serverMode ? Math.max(0, n.total ?? J.value.total ?? n.rows.length) : z.value.roots.length
|
|
123
|
+
), he = v(
|
|
124
|
+
() => Math.max(1, Math.ceil(de.value / B.value))
|
|
125
|
+
), L = v(() => {
|
|
126
|
+
const e = n.page ?? J.value.page ?? I.value;
|
|
127
|
+
return Math.min(
|
|
128
|
+
he.value,
|
|
129
|
+
Math.max(1, Number.isFinite(e) ? Math.floor(e) : 1)
|
|
130
|
+
);
|
|
131
|
+
}), we = v(
|
|
132
|
+
() => !n.pagination || n.serverMode ? z.value.roots : z.value.roots.slice(
|
|
133
|
+
(L.value - 1) * B.value,
|
|
134
|
+
L.value * B.value
|
|
135
|
+
)
|
|
136
|
+
), Q = v(() => {
|
|
137
|
+
const e = [], a = [...we.value].reverse();
|
|
138
|
+
for (; a.length; ) {
|
|
139
|
+
const t = a.pop();
|
|
140
|
+
if (e.push(t), D.value.has(t.token) || !n.serverMode && Object.values(F.value).some((l) => l.length)) {
|
|
141
|
+
const l = z.value.children.get(t.token) ?? [];
|
|
142
|
+
for (let o = l.length - 1; o >= 0; o--) a.push(l[o]);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return e;
|
|
146
|
+
}), ke = v(() => {
|
|
147
|
+
const e = [], a = [...z.value.roots].reverse();
|
|
148
|
+
for (; a.length; ) {
|
|
149
|
+
const t = a.pop();
|
|
150
|
+
e.push(t.row);
|
|
151
|
+
const l = z.value.children.get(t.token) ?? [];
|
|
152
|
+
for (let o = l.length - 1; o >= 0; o--) a.push(l[o]);
|
|
153
|
+
}
|
|
154
|
+
return e;
|
|
155
|
+
}), X = v(
|
|
156
|
+
() => n.currentRowKey !== void 0 ? n.currentRowKey : p.value
|
|
157
|
+
), Y = v(
|
|
158
|
+
() => {
|
|
159
|
+
var e;
|
|
160
|
+
return X.value == null || (e = f.value.map.get(y(X.value))) == null ? void 0 : e.row;
|
|
161
|
+
}
|
|
162
|
+
), ae = v(() => {
|
|
163
|
+
const e = /* @__PURE__ */ new Set();
|
|
164
|
+
if (n.checkStrictly !== !1) return e;
|
|
165
|
+
for (let a = f.value.all.length - 1; a >= 0; a--) {
|
|
166
|
+
const t = f.value.all[a];
|
|
167
|
+
t.children.some(
|
|
168
|
+
(l) => e.has(l.token) || m.value.has(l.token)
|
|
169
|
+
) && !t.children.filter(R).every((l) => m.value.has(l.token)) && e.add(t.token);
|
|
170
|
+
}
|
|
171
|
+
return e;
|
|
172
|
+
});
|
|
173
|
+
function R(e) {
|
|
174
|
+
var a;
|
|
175
|
+
return n.selectable !== !1 && ((a = n.getSelectionProps) == null ? void 0 : a.call(n, e.row, e.index).disabled) !== !0 && (typeof n.selectable != "function" || n.selectable(e.row, e.index));
|
|
176
|
+
}
|
|
177
|
+
const H = v(() => {
|
|
178
|
+
const e = [], a = [...we.value].reverse();
|
|
179
|
+
for (; a.length; ) {
|
|
180
|
+
const t = a.pop();
|
|
181
|
+
R(t) && e.push(t);
|
|
182
|
+
const l = z.value.children.get(t.token) ?? [];
|
|
183
|
+
for (let o = l.length - 1; o >= 0; o--) a.push(l[o]);
|
|
184
|
+
}
|
|
185
|
+
return e;
|
|
186
|
+
}), le = v(
|
|
187
|
+
() => !!H.value.length && H.value.every((e) => m.value.has(e.token))
|
|
188
|
+
), ye = v(
|
|
189
|
+
() => !le.value && H.value.some(
|
|
190
|
+
(e) => m.value.has(e.token) || ae.value.has(e.token)
|
|
191
|
+
)
|
|
192
|
+
), ge = v(() => ({
|
|
193
|
+
action: "page",
|
|
194
|
+
page: L.value,
|
|
195
|
+
pageSize: B.value,
|
|
196
|
+
sorts: E.value.map((e) => ({ ...e })),
|
|
197
|
+
filters: Object.fromEntries(
|
|
198
|
+
Object.entries(F.value).map(([e, a]) => [e, [...a]])
|
|
199
|
+
),
|
|
200
|
+
currentData: ke.value
|
|
201
|
+
}));
|
|
202
|
+
function Z(e, a = {}) {
|
|
203
|
+
const t = { ...ge.value, ...a, action: e };
|
|
204
|
+
s("queryChange", t), s("change", t);
|
|
205
|
+
}
|
|
206
|
+
function Ae(e, a = "page") {
|
|
207
|
+
if (g.value || !d.value) return;
|
|
208
|
+
const t = Math.max(1, Math.min(he.value, Math.floor(e) || 1));
|
|
209
|
+
I.value = t, s("update:page", t), s("pageChange", t), Z(a, { page: t });
|
|
210
|
+
}
|
|
211
|
+
function Ke(e) {
|
|
212
|
+
g.value || !d.value || !Number.isFinite(e) || e < 1 || (N.value = Math.floor(e), I.value = 1, s("update:pageSize", N.value), s("pageSizeChange", N.value), s("update:page", 1), s("pageChange", 1), Z("pageSize", { page: 1, pageSize: N.value }));
|
|
213
|
+
}
|
|
214
|
+
function Se(e) {
|
|
215
|
+
if (g.value || !d.value) return;
|
|
216
|
+
const a = (Array.isArray(e) ? [...e] : e ? [e] : []).filter(
|
|
217
|
+
(t) => b().some((l) => l.key === t.key && l.sortable) && ["asc", "desc"].includes(t.direction)
|
|
218
|
+
);
|
|
219
|
+
K.value = n.multiSort ? a : a.slice(0, 1), n.multiSort && K.value.sort(
|
|
220
|
+
(t, l) => {
|
|
221
|
+
var o, r;
|
|
222
|
+
return (((o = b().find((u) => u.key === l.key)) == null ? void 0 : o.sortPriority) ?? 0) - (((r = b().find((u) => u.key === t.key)) == null ? void 0 : r.sortPriority) ?? 0);
|
|
223
|
+
}
|
|
224
|
+
), I.value = 1, s("update:sort", K.value[0] ?? null), s("update:sorts", K.value), s("sortChange", K.value[0] ?? null, K.value), s("update:page", 1), Z("sort", { sorts: K.value, page: 1 });
|
|
225
|
+
}
|
|
226
|
+
function ze(e, a) {
|
|
227
|
+
var u, c, w;
|
|
228
|
+
if (!e.sortable) return;
|
|
229
|
+
const t = (u = E.value.find((k) => k.key === e.key)) == null ? void 0 : u.direction, l = (c = e.sortOrders) != null && c.length ? e.sortOrders : (w = n.sortOrders) != null && w.length ? n.sortOrders : ["asc", "desc", null], o = a ? t === a ? null : a : l[(l.indexOf(t ?? null) + 1) % l.length], r = n.multiSort ? E.value.filter((k) => k.key !== e.key) : [];
|
|
230
|
+
o && r.push({ key: e.key, direction: o }), Se(r);
|
|
231
|
+
}
|
|
232
|
+
function Me(e) {
|
|
233
|
+
g.value || !d.value || (se.value = e, I.value = 1, s("update:filters", e), s("filterChange", e), s("update:page", 1), Z("filter", { filters: e, page: 1 }));
|
|
234
|
+
}
|
|
235
|
+
function Oe(e, a) {
|
|
236
|
+
b().some((t) => t.key === e) && Me({ ...F.value, [e]: [...a] });
|
|
237
|
+
}
|
|
238
|
+
function Ee(e) {
|
|
239
|
+
Me(
|
|
240
|
+
e ? Object.fromEntries(
|
|
241
|
+
Object.entries(F.value).filter(
|
|
242
|
+
([a]) => !e.includes(a)
|
|
243
|
+
)
|
|
244
|
+
) : {}
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
function T(e) {
|
|
248
|
+
return f.value.map.get(
|
|
249
|
+
y(typeof e == "object" ? te(e) : e)
|
|
250
|
+
);
|
|
251
|
+
}
|
|
252
|
+
function O() {
|
|
253
|
+
return M.value.flatMap((e) => {
|
|
254
|
+
var l;
|
|
255
|
+
const a = y(e), t = ((l = f.value.map.get(a)) == null ? void 0 : l.row) ?? (n.reserveSelection ? G.get(a) : void 0);
|
|
256
|
+
return t ? [t] : [];
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
async function j(e) {
|
|
260
|
+
if (g.value || !d.value) return !1;
|
|
261
|
+
const a = [...new Set(e)];
|
|
262
|
+
ce.value = a, s("update:selectedRowKeys", a), await $();
|
|
263
|
+
const t = d.value && a.length === M.value.length && a.every((l) => m.value.has(y(l)));
|
|
264
|
+
return t && s("selectionChange", O(), M.value), t;
|
|
265
|
+
}
|
|
266
|
+
function ne(e) {
|
|
267
|
+
if (!(n.checkStrictly !== !1 || n.selectionType === "radio"))
|
|
268
|
+
for (let a = f.value.all.length - 1; a >= 0; a--) {
|
|
269
|
+
const t = f.value.all[a], l = t.children.filter(R);
|
|
270
|
+
!l.length || !R(t) || (l.every((o) => e.has(o.token)) ? e.add(t.token) : e.delete(t.token));
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
let be;
|
|
274
|
+
async function Fe(e, a, t = !1) {
|
|
275
|
+
const l = T(e);
|
|
276
|
+
if (!l || !R(l) || g.value) return !1;
|
|
277
|
+
const o = a ?? !m.value.has(l.token);
|
|
278
|
+
if (n.selectionType === "radio") {
|
|
279
|
+
const i = await j(o ? [l.key] : []);
|
|
280
|
+
return i && s("select", O(), l.row, o), i;
|
|
281
|
+
}
|
|
282
|
+
const r = t && n.rangeSelection ? Q.value.findIndex((i) => i.token === be) : -1, u = Q.value.findIndex((i) => i.token === l.token), c = r >= 0 && u >= 0 ? Q.value.slice(Math.min(r, u), Math.max(r, u) + 1) : [l], w = new Set(m.value), k = [...c], q = /* @__PURE__ */ new Set();
|
|
283
|
+
for (; k.length; ) {
|
|
284
|
+
const i = k.pop();
|
|
285
|
+
q.has(i.token) || (q.add(i.token), R(i) && (o ? w.add(i.token) : w.delete(i.token)), n.checkStrictly === !1 && k.push(...i.children));
|
|
286
|
+
}
|
|
287
|
+
ne(w);
|
|
288
|
+
const S = [
|
|
289
|
+
...new Map([
|
|
290
|
+
...M.value.filter((i) => w.has(y(i))).map((i) => [y(i), i]),
|
|
291
|
+
...f.value.all.filter((i) => w.has(i.token)).map((i) => [i.token, i.key])
|
|
292
|
+
]).values()
|
|
293
|
+
], U = await j(S);
|
|
294
|
+
return U && (be = l.token, s("select", O(), l.row, o), c.length > 1 && s(
|
|
295
|
+
"selectRange",
|
|
296
|
+
O(),
|
|
297
|
+
c.filter(R).map((i) => i.row),
|
|
298
|
+
o
|
|
299
|
+
)), U;
|
|
300
|
+
}
|
|
301
|
+
async function Te(e) {
|
|
302
|
+
if (n.selectionType === "radio") return !1;
|
|
303
|
+
const a = e ?? (ye.value && n.selectOnIndeterminate === !1 ? !1 : !le.value), t = new Set(m.value);
|
|
304
|
+
for (const r of H.value)
|
|
305
|
+
a ? t.add(r.token) : t.delete(r.token);
|
|
306
|
+
ne(t);
|
|
307
|
+
const l = [
|
|
308
|
+
...new Map([
|
|
309
|
+
...M.value.filter((r) => t.has(y(r))).map((r) => [y(r), r]),
|
|
310
|
+
...f.value.all.filter((r) => t.has(r.token)).map((r) => [r.token, r.key])
|
|
311
|
+
]).values()
|
|
312
|
+
], o = await j(l);
|
|
313
|
+
return o && s("selectAll", O(), a), o;
|
|
314
|
+
}
|
|
315
|
+
async function je() {
|
|
316
|
+
if (n.selectionType === "radio" || g.value || !d.value)
|
|
317
|
+
return !1;
|
|
318
|
+
const e = new Set(m.value);
|
|
319
|
+
for (const l of H.value)
|
|
320
|
+
(n.checkStrictly !== !1 || !l.children.some(R)) && (e.has(l.token) ? e.delete(l.token) : e.add(l.token));
|
|
321
|
+
ne(e);
|
|
322
|
+
const a = [
|
|
323
|
+
...new Map([
|
|
324
|
+
...M.value.filter((l) => e.has(y(l))).map((l) => [y(l), l]),
|
|
325
|
+
...f.value.all.filter((l) => e.has(l.token)).map((l) => [l.token, l.key])
|
|
326
|
+
]).values()
|
|
327
|
+
], t = await j(a);
|
|
328
|
+
return t && s("selectInvert", O(), M.value), t;
|
|
329
|
+
}
|
|
330
|
+
async function Pe(e) {
|
|
331
|
+
if (g.value || !d.value) return !1;
|
|
332
|
+
const a = e == null ? void 0 : T(e);
|
|
333
|
+
if (e != null && !a) return !1;
|
|
334
|
+
const t = Y.value;
|
|
335
|
+
p.value = (a == null ? void 0 : a.key) ?? null, s("update:currentRowKey", p.value), await $();
|
|
336
|
+
const l = d.value && X.value === ((a == null ? void 0 : a.key) ?? null);
|
|
337
|
+
return l && Y.value !== t && s("currentChange", Y.value, t), l;
|
|
338
|
+
}
|
|
339
|
+
function P(e) {
|
|
340
|
+
const a = h.value.get(e);
|
|
341
|
+
if (!a) return;
|
|
342
|
+
a.controller.abort(), W.delete(a.row);
|
|
343
|
+
const t = new Map(h.value);
|
|
344
|
+
t.delete(e), h.value = t;
|
|
345
|
+
}
|
|
346
|
+
async function xe(e, a = !1) {
|
|
347
|
+
var u;
|
|
348
|
+
const t = T(e), l = n.loadChildren;
|
|
349
|
+
if (!t || !l || !n.treeMode || g.value || !d.value || h.value.has(t.token))
|
|
350
|
+
return !1;
|
|
351
|
+
if (!a && !t.lazy && x.value.has(t.token)) return !0;
|
|
352
|
+
W.add(t.row);
|
|
353
|
+
const o = { row: t.row, controller: new AbortController() };
|
|
354
|
+
h.value = new Map(h.value).set(t.token, o);
|
|
355
|
+
const r = new Map(C.value);
|
|
356
|
+
r.delete(t.token), C.value = r;
|
|
357
|
+
try {
|
|
358
|
+
const c = await l(t.row, {
|
|
359
|
+
signal: o.controller.signal,
|
|
360
|
+
key: t.key,
|
|
361
|
+
depth: t.depth
|
|
362
|
+
});
|
|
363
|
+
if (!d.value || o.controller.signal.aborted || h.value.get(t.token) !== o || ((u = f.value.map.get(t.token)) == null ? void 0 : u.row) !== t.row || n.loadChildren !== l)
|
|
364
|
+
return !1;
|
|
365
|
+
if (!Array.isArray(c))
|
|
366
|
+
throw new TypeError("loadChildren must return an array");
|
|
367
|
+
return x.value = new Map(x.value).set(t.token, {
|
|
368
|
+
row: t.row,
|
|
369
|
+
rows: c
|
|
370
|
+
}), s("load", t.row, c), !0;
|
|
371
|
+
} catch (c) {
|
|
372
|
+
return d.value && !o.controller.signal.aborted && h.value.get(t.token) === o && (C.value = new Map(C.value).set(t.token, c), s("loadError", t.row, c)), !1;
|
|
373
|
+
} finally {
|
|
374
|
+
if (h.value.get(t.token) === o) {
|
|
375
|
+
const c = new Map(h.value);
|
|
376
|
+
c.delete(t.token), h.value = c;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
function me(e) {
|
|
381
|
+
var a;
|
|
382
|
+
return ((a = n.rowExpandable) == null ? void 0 : a.call(n, e.row)) !== !1 && (e.children.length > 0 || e.lazy || !!n.expandable || ie());
|
|
383
|
+
}
|
|
384
|
+
async function qe(e, a) {
|
|
385
|
+
var r;
|
|
386
|
+
const t = T(e);
|
|
387
|
+
if (!t || !n.treeMode || g.value || !d.value || !Array.isArray(a))
|
|
388
|
+
return !1;
|
|
389
|
+
P(t.token), W.add(t.row);
|
|
390
|
+
const l = { row: t.row, rows: [...a], override: !0 };
|
|
391
|
+
x.value = new Map(x.value).set(t.token, l);
|
|
392
|
+
const o = new Map(C.value);
|
|
393
|
+
return o.delete(t.token), C.value = o, await $(), !d.value || x.value.get(t.token) !== l || ((r = f.value.map.get(t.token)) == null ? void 0 : r.row) !== t.row ? !1 : (s("childrenChange", t.row, l.rows), !0);
|
|
394
|
+
}
|
|
395
|
+
async function Ie(e, a) {
|
|
396
|
+
const t = T(e);
|
|
397
|
+
if (!t || !me(t) || g.value || !d.value) return !1;
|
|
398
|
+
const l = a ?? !D.value.has(t.token), o = V.value.filter((u) => y(u) !== t.token);
|
|
399
|
+
return l && o.push(t.key), fe.value = !0, ve.value = o, s("update:expandedRowKeys", o), await $(), d.value && D.value.has(t.token) === l ? (s("expandChange", t.row, l, V.value), l || P(t.token), !0) : !1;
|
|
400
|
+
}
|
|
401
|
+
function Ce() {
|
|
402
|
+
d.value = !1;
|
|
403
|
+
for (const e of [...h.value.keys()]) P(e);
|
|
404
|
+
}
|
|
405
|
+
return _(
|
|
406
|
+
() => n.loadChildren,
|
|
407
|
+
() => {
|
|
408
|
+
for (const e of [...h.value.keys()]) P(e);
|
|
409
|
+
x.value = /* @__PURE__ */ new Map(), C.value = /* @__PURE__ */ new Map(), W = /* @__PURE__ */ new WeakSet();
|
|
410
|
+
}
|
|
411
|
+
), _(g, (e) => {
|
|
412
|
+
if (e) for (const a of [...h.value.keys()]) P(a);
|
|
413
|
+
}), _(
|
|
414
|
+
[V, () => f.value.all, () => h.value.size, d, g],
|
|
415
|
+
() => {
|
|
416
|
+
var a;
|
|
417
|
+
if (!d.value || g.value) return;
|
|
418
|
+
let e = Math.max(0, 4 - h.value.size);
|
|
419
|
+
for (const t of f.value.all) {
|
|
420
|
+
if (!e) break;
|
|
421
|
+
t.lazy && D.value.has(t.token) && !W.has(t.row) && !C.value.has(t.token) && ((a = n.rowExpandable) == null ? void 0 : a.call(n, t.row)) !== !1 && (e--, xe(t.key));
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
{ immediate: !0, flush: "post" }
|
|
425
|
+
), Ne(() => d.value = !0), We(Ce), Ve(Ce), {
|
|
426
|
+
live: d,
|
|
427
|
+
busy: g,
|
|
428
|
+
graph: f,
|
|
429
|
+
rowId: te,
|
|
430
|
+
selectedKeys: M,
|
|
431
|
+
selectedSet: m,
|
|
432
|
+
expandedKeys: V,
|
|
433
|
+
expandedSet: D,
|
|
434
|
+
halfSet: ae,
|
|
435
|
+
eligible: R,
|
|
436
|
+
allSelected: le,
|
|
437
|
+
someSelected: ye,
|
|
438
|
+
sorts: E,
|
|
439
|
+
filters: F,
|
|
440
|
+
processed: z,
|
|
441
|
+
filteredRows: ke,
|
|
442
|
+
display: Q,
|
|
443
|
+
page: L,
|
|
444
|
+
pageSize: B,
|
|
445
|
+
total: de,
|
|
446
|
+
pagination: J,
|
|
447
|
+
currentKey: X,
|
|
448
|
+
currentRow: Y,
|
|
449
|
+
query: ge,
|
|
450
|
+
pending: h,
|
|
451
|
+
loadErrors: C,
|
|
452
|
+
canExpand: me,
|
|
453
|
+
toggleSort: ze,
|
|
454
|
+
setSort: Se,
|
|
455
|
+
setFilter: Oe,
|
|
456
|
+
clearFilter: Ee,
|
|
457
|
+
requestPage: Ae,
|
|
458
|
+
changeSize: Ke,
|
|
459
|
+
toggleRowSelection: Fe,
|
|
460
|
+
toggleAllSelection: Te,
|
|
461
|
+
invertSelection: je,
|
|
462
|
+
clearSelection: () => j([]),
|
|
463
|
+
getSelectionRows: O,
|
|
464
|
+
getHalfSelectionRows: () => f.value.all.filter((e) => ae.value.has(e.token)).map((e) => e.row),
|
|
465
|
+
setCurrentRow: Pe,
|
|
466
|
+
toggleRowExpansion: Ie,
|
|
467
|
+
loadRow: xe,
|
|
468
|
+
updateKeyChildren: qe,
|
|
469
|
+
find: T
|
|
470
|
+
};
|
|
471
|
+
}
|
|
472
|
+
export {
|
|
473
|
+
Ge as useTable
|
|
474
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { watch as x, nextTick as u, onMounted as T, onActivated as E, onDeactivated as Y, onBeforeUnmount as B } from "vue";
|
|
2
|
+
function L(v, n, F, M) {
|
|
3
|
+
let s = !0, a, i, f = -1, r;
|
|
4
|
+
const h = () => {
|
|
5
|
+
var e;
|
|
6
|
+
return ((e = v.value) == null ? void 0 : e.tagName) === "TEXTAREA" ? v.value : void 0;
|
|
7
|
+
};
|
|
8
|
+
function p() {
|
|
9
|
+
a = void 0;
|
|
10
|
+
const e = h();
|
|
11
|
+
if (!s || !e) return;
|
|
12
|
+
if (!n.autosize) {
|
|
13
|
+
r && (e.style.height = r.height, e.style.overflowY = r.overflowY, r = void 0);
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!e.getBoundingClientRect().width) return;
|
|
17
|
+
r ?? (r = { height: e.style.height, overflowY: e.style.overflowY });
|
|
18
|
+
const d = typeof n.autosize == "object" ? n.autosize : {}, t = getComputedStyle(e), c = parseFloat(t.lineHeight) || parseFloat(t.fontSize) * 1.5 || 21, w = (parseFloat(t.paddingTop) || 0) + (parseFloat(t.paddingBottom) || 0), l = (parseFloat(t.borderTopWidth) || 0) + (parseFloat(t.borderBottomWidth) || 0), R = Math.max(
|
|
19
|
+
1,
|
|
20
|
+
Math.min(1e4, Math.floor(d.minRows || 1))
|
|
21
|
+
), A = d.maxRows && Number.isFinite(d.maxRows) ? Math.max(R, d.maxRows) : 1 / 0;
|
|
22
|
+
e.style.height = "0px";
|
|
23
|
+
const b = e.scrollHeight + l, g = Math.min(
|
|
24
|
+
A * c + w + l,
|
|
25
|
+
Math.max(R * c + w + l, b)
|
|
26
|
+
);
|
|
27
|
+
e.style.height = (t.boxSizing === "border-box" ? g : Math.max(c, g - w - l)) + "px", e.style.overflowY = b > g + 1 ? "auto" : "hidden";
|
|
28
|
+
}
|
|
29
|
+
async function o() {
|
|
30
|
+
await u(), !(!s || !h() || !n.autosize && !r) && (a !== void 0 && cancelAnimationFrame(a), a = requestAnimationFrame(p));
|
|
31
|
+
}
|
|
32
|
+
function m() {
|
|
33
|
+
i == null || i.disconnect(), i = void 0, f = -1, window.removeEventListener("resize", o);
|
|
34
|
+
const e = h();
|
|
35
|
+
if (!(!s || !e)) {
|
|
36
|
+
if (!n.autosize) {
|
|
37
|
+
o();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
window.addEventListener("resize", o), typeof ResizeObserver < "u" && (i = new ResizeObserver((d) => {
|
|
41
|
+
var c;
|
|
42
|
+
const t = (c = d[0]) == null ? void 0 : c.contentRect.width;
|
|
43
|
+
t !== void 0 && Math.abs(t - f) > 0.5 && (f = t, o());
|
|
44
|
+
}), i.observe(e)), o();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function z() {
|
|
48
|
+
s = !0, u(m);
|
|
49
|
+
}
|
|
50
|
+
function y() {
|
|
51
|
+
s = !1, i == null || i.disconnect(), i = void 0, a !== void 0 && cancelAnimationFrame(a), a = void 0, window.removeEventListener("resize", o);
|
|
52
|
+
}
|
|
53
|
+
return x([M, F, () => n.rows, () => n.autosize], o, {
|
|
54
|
+
deep: !0
|
|
55
|
+
}), x(v, () => {
|
|
56
|
+
r = void 0, u(m);
|
|
57
|
+
}), x(
|
|
58
|
+
() => n.autosize,
|
|
59
|
+
() => {
|
|
60
|
+
u(m);
|
|
61
|
+
},
|
|
62
|
+
{ deep: !0 }
|
|
63
|
+
), T(() => {
|
|
64
|
+
var e;
|
|
65
|
+
z(), (e = document.fonts) == null || e.ready.then(() => {
|
|
66
|
+
s && o();
|
|
67
|
+
});
|
|
68
|
+
}), E(z), Y(y), B(y), o;
|
|
69
|
+
}
|
|
70
|
+
export {
|
|
71
|
+
L as useTextareaSize
|
|
72
|
+
};
|