hys-ui 0.2.0 → 0.4.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 +59 -0
- package/README.md +68 -59
- package/dist/components/HysAlert/HysAlert.vue.js +5 -54
- package/dist/components/HysAlert/HysAlert2.vue.js +159 -2
- package/dist/components/HysAnimatedNumber/HysAnimatedNumber.vue.js +5 -41
- package/dist/components/HysAnimatedNumber/HysAnimatedNumber2.vue.js +146 -2
- package/dist/components/HysAutocomplete/HysAutocomplete.vue.js +2 -2
- package/dist/components/HysAutocomplete/HysAutocomplete2.vue.js +285 -273
- package/dist/components/HysAvatarGroup/HysAvatarGroup.vue.js +1 -1
- package/dist/components/HysAvatarGroup/HysAvatarGroup2.vue.js +102 -98
- package/dist/components/HysBreadcrumb/HysBreadcrumb.vue.js +1 -1
- package/dist/components/HysBreadcrumb/HysBreadcrumb2.vue.js +273 -59
- package/dist/components/HysButton/HysButton.vue.js +2 -2
- package/dist/components/HysButton/HysButton2.vue.js +227 -60
- package/dist/components/HysButtonGroup/HysButtonGroup.vue.js +7 -0
- package/dist/components/HysButtonGroup/HysButtonGroup2.vue.js +51 -0
- package/dist/components/HysCalendar/HysCalendar.vue.js +3 -3
- package/dist/components/HysCalendar/HysCalendar2.vue.js +237 -225
- package/dist/components/HysCascader/HysCascader.vue.js +2 -2
- package/dist/components/HysCascader/HysCascader2.vue.js +337 -324
- package/dist/components/HysColorPicker/HysColorPanel.vue.js +7 -0
- package/dist/components/HysColorPicker/HysColorPanel2.vue.js +238 -0
- package/dist/components/HysColorPicker/HysColorPicker.vue.js +2 -2
- package/dist/components/HysColorPicker/HysColorPicker2.vue.js +239 -217
- package/dist/components/HysCommandPalette/HysCommandPalette.vue.js +90 -76
- package/dist/components/HysContextMenu/HysContextMenu.vue.js +5 -89
- package/dist/components/HysContextMenu/HysContextMenu2.vue.js +247 -2
- package/dist/components/HysContextMenu/HysMenuPanel.vue.js +7 -0
- package/dist/components/HysContextMenu/HysMenuPanel2.vue.js +208 -0
- package/dist/components/HysContextMenu/HysMenuSlot.js +10 -0
- package/dist/components/HysDataGrid/HysDataGrid.vue.js +1 -1
- package/dist/components/HysDataGrid/HysDataGrid2.vue.js +1008 -559
- package/dist/components/HysDatePicker/HysDatePicker.vue.js +2 -0
- package/dist/components/HysDatePicker/HysDatePickerControl.vue.js +2 -2
- package/dist/components/HysDatePicker/HysDatePickerControl2.vue.js +539 -526
- package/dist/components/HysDateRangePicker/HysDateRangePicker.vue.js +5 -3
- package/dist/components/HysDrawer/HysDrawer.vue.js +1 -1
- package/dist/components/HysDrawer/HysDrawer2.vue.js +434 -84
- package/dist/components/HysEmpty/HysEmpty.vue.js +5 -41
- package/dist/components/HysEmpty/HysEmpty2.vue.js +181 -2
- package/dist/components/HysFormItem/HysFormItem.vue.js +2 -2
- package/dist/components/HysFormItem/HysFormItem2.vue.js +171 -164
- package/dist/components/HysGantt/HysGantt.vue.js +1 -1
- package/dist/components/HysGantt/HysGantt2.vue.js +810 -795
- package/dist/components/HysMention/HysMention.vue.js +1 -1
- package/dist/components/HysMention/HysMention2.vue.js +1092 -142
- package/dist/components/HysModal/HysModal.vue.js +2 -2
- package/dist/components/HysModal/HysModal2.vue.js +491 -85
- package/dist/components/HysPagination/HysPagination.vue.js +2 -2
- package/dist/components/HysPagination/HysPagination2.vue.js +243 -180
- package/dist/components/HysPopover/HysPopover.vue.js +5 -91
- package/dist/components/HysPopover/HysPopover2.vue.js +120 -2
- package/dist/components/HysProgress/HysProgress.vue.js +2 -2
- package/dist/components/HysProgress/HysProgress2.vue.js +319 -52
- package/dist/components/HysSearch/HysSearch.vue.js +5 -82
- package/dist/components/HysSearch/HysSearch2.vue.js +176 -2
- package/dist/components/HysSelect/HysSelect.vue.js +2 -2
- package/dist/components/HysSelect/HysSelect2.vue.js +755 -590
- package/dist/components/HysSlider/HysSlider.vue.js +2 -2
- package/dist/components/HysSlider/HysSlider2.vue.js +192 -188
- package/dist/components/HysSlider/SliderTooltip.vue.js +2 -2
- package/dist/components/HysSlider/SliderTooltip2.vue.js +103 -89
- package/dist/components/HysSplitPane/HysSplitPane.vue.js +315 -58
- package/dist/components/HysSplitPane/HysSplitPane3.vue.js +5 -0
- package/dist/components/HysTable/HysTable.vue.js +2 -2
- package/dist/components/HysTable/HysTable2.vue.js +1416 -1127
- package/dist/components/HysTagInput/HysTagInput.vue.js +5 -82
- package/dist/components/HysTagInput/HysTagInput2.vue.js +396 -2
- package/dist/components/HysTimeline/HysTimeline.vue.js +2 -2
- package/dist/components/HysTimeline/HysTimeline2.vue.js +243 -24
- package/dist/components/HysTooltip/HysTooltip.vue.js +5 -64
- package/dist/components/HysTooltip/HysTooltip2.vue.js +110 -2
- package/dist/components/HysTour/HysTour.vue.js +291 -63
- package/dist/components/HysTour/HysTour3.vue.js +5 -0
- package/dist/components/HysTransfer/HysTransfer.vue.js +2 -2
- package/dist/components/HysTransfer/HysTransfer2.vue.js +237 -207
- package/dist/components/HysTransfer/HysTransferPanel.vue.js +1 -1
- package/dist/components/HysTransfer/HysTransferPanel2.vue.js +320 -271
- package/dist/components/HysTree/HysTree.vue.js +2 -2
- package/dist/components/HysTree/HysTree2.vue.js +195 -184
- package/dist/components/HysTreeSelect/HysTreeSelect.vue.js +4 -4
- package/dist/components/HysTreeSelect/HysTreeSelect2.vue.js +389 -377
- package/dist/components/HysUpload/HysUpload.vue.js +2 -2
- package/dist/components/HysUpload/HysUpload2.vue.js +459 -125
- package/dist/components/HysVirtualTable/HysVirtualTable.vue.js +5 -94
- package/dist/components/HysVirtualTable/HysVirtualTable2.vue.js +656 -2
- package/dist/composables/buttonGroup.js +12 -0
- package/dist/composables/color.js +97 -0
- package/dist/composables/dataGrid.js +68 -0
- package/dist/composables/drawer.js +17 -0
- package/dist/composables/feedback.js +14 -0
- package/dist/composables/floatingPosition.js +18 -0
- package/dist/composables/mentionDocument.js +79 -0
- package/dist/composables/mentionEditor.js +58 -0
- package/dist/composables/menu.js +96 -0
- package/dist/composables/modal.js +14 -0
- package/dist/composables/overlayManager.js +48 -18
- package/dist/composables/progress.js +94 -0
- package/dist/composables/selectOptions.js +44 -38
- package/dist/composables/splitPaneSizes.js +58 -0
- package/dist/composables/table.js +128 -105
- package/dist/composables/tagInput.js +16 -0
- package/dist/composables/timeline.js +19 -0
- package/dist/composables/transfer.js +19 -17
- package/dist/composables/upload.js +55 -0
- package/dist/composables/uploadRequest.js +58 -0
- package/dist/composables/useAlert.js +124 -0
- package/dist/composables/useColorPicker.js +402 -0
- package/dist/composables/useContextMenu.js +514 -0
- package/dist/composables/useDataGridRemote.js +67 -0
- package/dist/composables/useDialog.js +86 -43
- package/dist/composables/useDrawerPush.js +33 -0
- package/dist/composables/useDrawerResize.js +221 -0
- package/dist/composables/useFloating.js +118 -80
- package/dist/composables/useHysModal.js +185 -0
- package/dist/composables/useMentionCaret.js +81 -0
- package/dist/composables/useMentionList.js +81 -0
- package/dist/composables/useMentionModel.js +90 -0
- package/dist/composables/useMentionOptions.js +421 -0
- package/dist/composables/useModal.js +295 -0
- package/dist/composables/useModalInteraction.js +394 -0
- package/dist/composables/usePopupSurface.js +458 -0
- package/dist/composables/useSplitPaneDrag.js +52 -0
- package/dist/composables/useSplitPaneStorage.js +38 -0
- package/dist/composables/useTable.js +344 -312
- package/dist/composables/useTableSticky.js +79 -0
- package/dist/composables/useTagInput.js +313 -0
- package/dist/composables/useTourLayout.js +129 -0
- package/dist/composables/useTransferMotion.js +185 -0
- package/dist/composables/useUpload.js +472 -0
- package/dist/composables/useUploadModel.js +65 -0
- package/dist/composables/useUploadRequests.js +266 -0
- package/dist/composables/useVirtualTableLayout.js +277 -0
- package/dist/composables/virtualTable.js +43 -0
- package/dist/config.js +11 -11
- package/dist/index.js +175 -153
- package/dist/internal/MultiSplitPane.vue.js +305 -0
- package/dist/internal/MultiSplitPane2.vue.js +4 -0
- package/dist/internal/PopupReference.js +39 -0
- package/dist/internal/PopupSurfacePanel.vue.js +7 -0
- package/dist/internal/PopupSurfacePanel2.vue.js +92 -0
- package/dist/motion/PopupMotion.js +105 -0
- package/dist/motion/popup.js +10 -0
- package/dist/style.css +1 -1
- package/dist/types/components/HysAlert/HysAlert.vue.d.ts +32 -22
- package/dist/types/components/HysAnimatedNumber/HysAnimatedNumber.vue.d.ts +61 -7
- package/dist/types/components/HysAutocomplete/HysAutocomplete.vue.d.ts +7 -7
- package/dist/types/components/HysAvatarGroup/HysAvatarGroup.vue.d.ts +6 -1
- package/dist/types/components/HysBadge/HysBadge.vue.d.ts +3 -3
- package/dist/types/components/HysBreadcrumb/HysBreadcrumb.vue.d.ts +54 -31
- package/dist/types/components/HysButton/HysButton.vue.d.ts +82 -22
- package/dist/types/components/HysButtonGroup/HysButtonGroup.vue.d.ts +30 -0
- package/dist/types/components/HysCalendar/HysCalendar.vue.d.ts +3 -2
- package/dist/types/components/HysCascader/HysCascader.vue.d.ts +7 -7
- package/dist/types/components/HysCascader/HysCascaderColumn.vue.d.ts +2 -2
- package/dist/types/components/HysColorPicker/HysColorPanel.vue.d.ts +58 -0
- package/dist/types/components/HysColorPicker/HysColorPicker.vue.d.ts +63 -10
- package/dist/types/components/HysCommandPalette/HysCommandPalette.vue.d.ts +2 -1
- package/dist/types/components/HysContextMenu/HysContextMenu.vue.d.ts +50 -34
- package/dist/types/components/HysContextMenu/HysMenuPanel.vue.d.ts +79 -0
- package/dist/types/components/HysContextMenu/HysMenuSlot.d.ts +8 -0
- package/dist/types/components/HysDataGrid/HysDataGrid.vue.d.ts +65 -118
- package/dist/types/components/HysDatePicker/HysDatePickerControl.vue.d.ts +3 -3
- package/dist/types/components/HysDrawer/HysDrawer.vue.d.ts +92 -35
- package/dist/types/components/HysEmpty/HysEmpty.vue.d.ts +24 -20
- package/dist/types/components/HysFileManager/HysFileManager.vue.d.ts +2 -2
- package/dist/types/components/HysGantt/HysGantt.vue.d.ts +2 -1
- package/dist/types/components/HysMention/HysMention.vue.d.ts +91 -39
- package/dist/types/components/HysModal/HysModal.vue.d.ts +111 -34
- package/dist/types/components/HysNumberInput/HysNumberInput.vue.d.ts +2 -2
- package/dist/types/components/HysPagination/HysPagination.vue.d.ts +55 -4
- package/dist/types/components/HysPopover/HysPopover.vue.d.ts +41 -29
- package/dist/types/components/HysProgress/HysProgress.vue.d.ts +18 -24
- package/dist/types/components/HysRating/HysRating.vue.d.ts +1 -1
- package/dist/types/components/HysResizablePanel/HysResizablePanel.vue.d.ts +2 -2
- package/dist/types/components/HysSearch/HysSearch.vue.d.ts +45 -7
- package/dist/types/components/HysSelect/HysSelect.vue.d.ts +19 -5
- package/dist/types/components/HysSlider/HysSlider.vue.d.ts +5 -4
- package/dist/types/components/HysSlider/SliderTooltip.vue.d.ts +3 -1
- package/dist/types/components/HysSplitPane/HysSplitPane.vue.d.ts +125 -14
- package/dist/types/components/HysSteps/HysSteps.vue.d.ts +1 -1
- package/dist/types/components/HysTable/HysTable.vue.d.ts +1742 -5
- package/dist/types/components/HysTabs/HysTabs.vue.d.ts +2 -2
- package/dist/types/components/HysTagInput/HysTagInput.vue.d.ts +47 -25
- package/dist/types/components/HysTimeline/HysTimeline.vue.d.ts +19 -32
- package/dist/types/components/HysTooltip/HysTooltip.vue.d.ts +39 -19
- package/dist/types/components/HysTour/HysTour.vue.d.ts +46 -8
- package/dist/types/components/HysTransfer/HysTransfer.vue.d.ts +2 -2
- package/dist/types/components/HysTransfer/HysTransferPanel.vue.d.ts +5 -3
- package/dist/types/components/HysTree/HysTree.vue.d.ts +2 -2
- package/dist/types/components/HysUpload/HysUpload.vue.d.ts +55 -67
- package/dist/types/components/HysVirtualTable/HysVirtualTable.vue.d.ts +71 -40
- package/dist/types/composables/autocomplete.d.ts +3 -0
- package/dist/types/composables/avatar.d.ts +3 -0
- package/dist/types/composables/buttonGroup.d.ts +9 -0
- package/dist/types/composables/cascader.d.ts +3 -0
- package/dist/types/composables/color.d.ts +97 -0
- package/dist/types/composables/dataGrid.d.ts +100 -0
- package/dist/types/composables/datePicker.d.ts +3 -0
- package/dist/types/composables/drawer.d.ts +102 -0
- package/dist/types/composables/feedback.d.ts +98 -0
- package/dist/types/composables/floatingPosition.d.ts +14 -0
- package/dist/types/composables/formContext.d.ts +2 -0
- package/dist/types/composables/mention.d.ts +284 -0
- package/dist/types/composables/mentionDocument.d.ts +15 -0
- package/dist/types/composables/mentionEditor.d.ts +7 -0
- package/dist/types/composables/menu.d.ts +183 -0
- package/dist/types/composables/modal.d.ts +185 -0
- package/dist/types/composables/overlayManager.d.ts +7 -3
- package/dist/types/composables/popupSurface.d.ts +83 -0
- package/dist/types/composables/progress.d.ts +92 -0
- package/dist/types/composables/selectOptions.d.ts +7 -0
- package/dist/types/composables/splitPaneSizes.d.ts +11 -0
- package/dist/types/composables/table.d.ts +119 -6
- package/dist/types/composables/tagInput.d.ts +96 -0
- package/dist/types/composables/timeline.d.ts +82 -0
- package/dist/types/composables/tour.d.ts +68 -0
- package/dist/types/composables/transfer.d.ts +7 -0
- package/dist/types/composables/tree.d.ts +3 -0
- package/dist/types/composables/treeSelect.d.ts +3 -0
- package/dist/types/composables/upload.d.ts +202 -0
- package/dist/types/composables/uploadRequest.d.ts +3 -0
- package/dist/types/composables/useAlert.d.ts +21 -0
- package/dist/types/composables/useCascader.d.ts +1 -1
- package/dist/types/composables/useColorPicker.d.ts +101 -0
- package/dist/types/composables/useContextMenu.d.ts +81 -0
- package/dist/types/composables/useDataGridRemote.d.ts +15 -0
- package/dist/types/composables/useDialog.d.ts +16 -3
- package/dist/types/composables/useDrawerPush.d.ts +6 -0
- package/dist/types/composables/useDrawerResize.d.ts +27 -0
- package/dist/types/composables/useFloating.d.ts +22 -3
- package/dist/types/composables/useHysModal.d.ts +44 -0
- package/dist/types/composables/useMentionCaret.d.ts +6 -0
- package/dist/types/composables/useMentionList.d.ts +23 -0
- package/dist/types/composables/useMentionModel.d.ts +14 -0
- package/dist/types/composables/useMentionOptions.d.ts +26 -0
- package/dist/types/composables/useModal.d.ts +62 -0
- package/dist/types/composables/useModalInteraction.d.ts +27 -0
- package/dist/types/composables/usePopupSurface.d.ts +3341 -0
- package/dist/types/composables/useSplitPaneDrag.d.ts +14 -0
- package/dist/types/composables/useSplitPaneStorage.d.ts +4 -0
- package/dist/types/composables/useTable.d.ts +7 -3
- package/dist/types/composables/useTableSticky.d.ts +22 -0
- package/dist/types/composables/useTagInput.d.ts +66 -0
- package/dist/types/composables/useTourLayout.d.ts +33 -0
- package/dist/types/composables/useTransferMotion.d.ts +36 -0
- package/dist/types/composables/useUpload.d.ts +94 -0
- package/dist/types/composables/useUploadModel.d.ts +14 -0
- package/dist/types/composables/useUploadRequests.d.ts +38 -0
- package/dist/types/composables/useVirtualTableLayout.d.ts +51 -0
- package/dist/types/composables/virtualTable.d.ts +126 -0
- package/dist/types/config.d.ts +1 -0
- package/dist/types/index.d.ts +53 -3
- package/dist/types/internal/MultiSplitPane.vue.d.ts +54 -0
- package/dist/types/internal/PopupReference.d.ts +18 -0
- package/dist/types/internal/PopupSurfacePanel.vue.d.ts +37 -0
- package/dist/types/motion/PopupMotion.d.ts +59 -0
- package/dist/types/motion/popup.d.ts +12 -0
- package/package.json +3 -2
- package/dist/components/HysSplitPane/HysSplitPane2.vue.js +0 -4
- package/dist/components/HysTour/HysTour2.vue.js +0 -4
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
import { computed as w, shallowRef as W, ref as ce, watch as Z, onBeforeUnmount as we, onDeactivated as Me, onMounted as Se } from "vue";
|
|
2
|
+
function k(e, c) {
|
|
3
|
+
const d = e.id ?? (c == null ? void 0 : c.id) ?? e.value;
|
|
4
|
+
return {
|
|
5
|
+
option: e,
|
|
6
|
+
key: (e.type ?? e.prefix ?? "") + ":" + typeof d + ":" + d,
|
|
7
|
+
user: c ?? {
|
|
8
|
+
id: String(d),
|
|
9
|
+
name: typeof e.label == "string" ? e.label : String(e.value),
|
|
10
|
+
disabled: e.disabled
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
function ke(e, c, d) {
|
|
15
|
+
const g = e, O = g[(c == null ? void 0 : c.value) ?? "value"];
|
|
16
|
+
if (typeof O != "string" && typeof O != "number") return;
|
|
17
|
+
const b = { ...e, value: O };
|
|
18
|
+
if (c) {
|
|
19
|
+
const A = g[c.label ?? "label"], z = g[c.id ?? "id"];
|
|
20
|
+
b.label = typeof A == "string" || typeof A == "function" ? A : void 0, b.id = typeof z == "string" || typeof z == "number" ? z : void 0, b.disabled = !!g[c.disabled ?? "disabled"];
|
|
21
|
+
for (const N of ["group", "avatar", "description", "type"]) {
|
|
22
|
+
const F = g[c[N] ?? N];
|
|
23
|
+
b[N] = typeof F == "string" ? F : void 0;
|
|
24
|
+
}
|
|
25
|
+
b.payload = g.payload ?? e;
|
|
26
|
+
}
|
|
27
|
+
return b.group ?? (b.group = d), b;
|
|
28
|
+
}
|
|
29
|
+
const R = (e) => e.normalize("NFKC").toLocaleLowerCase(), $ = (e) => R(e).replace(/ü/g, "v").replace(/[\s'’-]/g, "");
|
|
30
|
+
function Oe(e, c) {
|
|
31
|
+
let d = 0;
|
|
32
|
+
for (const g of e) {
|
|
33
|
+
const O = c.indexOf(g, d);
|
|
34
|
+
if (O < 0) return !1;
|
|
35
|
+
d = O + g.length;
|
|
36
|
+
}
|
|
37
|
+
return !0;
|
|
38
|
+
}
|
|
39
|
+
function ze(e, c) {
|
|
40
|
+
return c.split(".").reduce(
|
|
41
|
+
(d, g) => d && typeof d == "object" ? d[g] : void 0,
|
|
42
|
+
e
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
function ue(e) {
|
|
46
|
+
return Array.isArray(e) ? e.map(ue).filter(Boolean).join(" ") : typeof e == "string" || typeof e == "number" ? String(e) : "";
|
|
47
|
+
}
|
|
48
|
+
function j(e, c) {
|
|
49
|
+
return typeof e == "number" && Number.isFinite(e) ? Math.max(0, Math.floor(e)) : c;
|
|
50
|
+
}
|
|
51
|
+
function Ne(e) {
|
|
52
|
+
return Array.isArray(e) ? { items: e, hasMore: !1 } : e;
|
|
53
|
+
}
|
|
54
|
+
function Pe(e, c, d, g, O, b) {
|
|
55
|
+
const A = w(() => {
|
|
56
|
+
const t = d.value, n = (t == null ? void 0 : t.options) ?? e.options, o = (t == null ? void 0 : t.loadOptions) ?? e.loadOptions;
|
|
57
|
+
return [
|
|
58
|
+
{
|
|
59
|
+
key: "$default",
|
|
60
|
+
options: n,
|
|
61
|
+
loader: o,
|
|
62
|
+
fields: e.fieldNames
|
|
63
|
+
},
|
|
64
|
+
...(e.sources ?? []).filter(
|
|
65
|
+
(l) => {
|
|
66
|
+
var i;
|
|
67
|
+
return !l.prefixes || l.prefixes.includes(((i = c.value) == null ? void 0 : i.prefix) ?? "");
|
|
68
|
+
}
|
|
69
|
+
).map((l) => ({
|
|
70
|
+
key: "source:" + l.key,
|
|
71
|
+
loader: l.loadOptions,
|
|
72
|
+
options: l.options,
|
|
73
|
+
fields: l.fieldNames ?? e.fieldNames,
|
|
74
|
+
group: l.group
|
|
75
|
+
}))
|
|
76
|
+
];
|
|
77
|
+
}), z = w(
|
|
78
|
+
() => A.value.filter((t) => t.loader)
|
|
79
|
+
), N = /* @__PURE__ */ new WeakMap();
|
|
80
|
+
let F = 0;
|
|
81
|
+
const fe = w(
|
|
82
|
+
() => JSON.stringify(
|
|
83
|
+
z.value.map(({ key: t, loader: n }) => (N.has(n) || N.set(n, ++F), [t, N.get(n)]))
|
|
84
|
+
)
|
|
85
|
+
), K = w(() => {
|
|
86
|
+
const t = c.value;
|
|
87
|
+
return t && !g.value ? JSON.stringify([
|
|
88
|
+
t.prefix,
|
|
89
|
+
t.query,
|
|
90
|
+
t.start,
|
|
91
|
+
t.manual,
|
|
92
|
+
fe.value,
|
|
93
|
+
e.pageSize
|
|
94
|
+
]) : void 0;
|
|
95
|
+
}), M = W(/* @__PURE__ */ new Map()), L = ce(!1), D = ce(!1), T = W(), Q = w(
|
|
96
|
+
() => e.loading || L.value && !D.value
|
|
97
|
+
), X = w(
|
|
98
|
+
() => z.value.some(({ key: t }) => {
|
|
99
|
+
var n;
|
|
100
|
+
return (n = M.value.get(t)) == null ? void 0 : n.hasMore;
|
|
101
|
+
})
|
|
102
|
+
), p = /* @__PURE__ */ new Map();
|
|
103
|
+
let S, Y, _ = -1 / 0;
|
|
104
|
+
function B() {
|
|
105
|
+
clearTimeout(Y), S == null || S.abort(), S = void 0, L.value = !1, D.value = !1;
|
|
106
|
+
}
|
|
107
|
+
function de() {
|
|
108
|
+
if (!e.cache) return;
|
|
109
|
+
const t = typeof e.cache == "object" ? e.cache : void 0;
|
|
110
|
+
return {
|
|
111
|
+
ttl: j(t == null ? void 0 : t.ttl, 3e4),
|
|
112
|
+
limit: j(t == null ? void 0 : t.maxEntries, 40)
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
async function ve(t, n, o, l, i, u) {
|
|
116
|
+
const r = t.loader, s = Math.max(1, j(e.pageSize, 20)), a = JSON.stringify([
|
|
117
|
+
t.key,
|
|
118
|
+
N.get(r),
|
|
119
|
+
n.prefix,
|
|
120
|
+
n.query,
|
|
121
|
+
s,
|
|
122
|
+
o,
|
|
123
|
+
l
|
|
124
|
+
]), v = de(), y = v && !u ? p.get(a) : void 0;
|
|
125
|
+
if (y && y.expires > Date.now())
|
|
126
|
+
return p.delete(a), p.set(a, y), y.page;
|
|
127
|
+
p.delete(a);
|
|
128
|
+
const x = Ne(
|
|
129
|
+
await r({
|
|
130
|
+
...n,
|
|
131
|
+
text: O.value,
|
|
132
|
+
page: o,
|
|
133
|
+
pageSize: s,
|
|
134
|
+
cursor: l,
|
|
135
|
+
signal: i
|
|
136
|
+
})
|
|
137
|
+
);
|
|
138
|
+
if (!i.aborted && (v != null && v.limit) && v.ttl)
|
|
139
|
+
for (p.set(a, { expires: Date.now() + v.ttl, page: x }); p.size > v.limit; )
|
|
140
|
+
p.delete(p.keys().next().value);
|
|
141
|
+
return x;
|
|
142
|
+
}
|
|
143
|
+
async function q(t, n, o, l) {
|
|
144
|
+
if (n.aborted || K.value !== o) return !1;
|
|
145
|
+
_ = Date.now();
|
|
146
|
+
const i = M.value, u = z.value.filter((s) => {
|
|
147
|
+
const a = i.get(s.key);
|
|
148
|
+
return t === "initial" || (t === "more" ? (a == null ? void 0 : a.hasMore) && !a.failed : a == null ? void 0 : a.failed);
|
|
149
|
+
});
|
|
150
|
+
let r = !1;
|
|
151
|
+
return await Promise.all(
|
|
152
|
+
u.map(async (s) => {
|
|
153
|
+
const a = i.get(s.key), v = ((a == null ? void 0 : a.page) ?? 0) + 1;
|
|
154
|
+
try {
|
|
155
|
+
const y = await ve(
|
|
156
|
+
s,
|
|
157
|
+
l,
|
|
158
|
+
v,
|
|
159
|
+
a == null ? void 0 : a.cursor,
|
|
160
|
+
n,
|
|
161
|
+
t === "retry"
|
|
162
|
+
);
|
|
163
|
+
if (n.aborted || K.value !== o) return;
|
|
164
|
+
const x = [...(a == null ? void 0 : a.items) ?? [], ...y.items], G = y.hasMore ?? (y.nextCursor !== void 0 ? y.nextCursor !== null : y.total !== void 0 && x.length < y.total), J = new Map(M.value);
|
|
165
|
+
J.set(s.key, {
|
|
166
|
+
page: v,
|
|
167
|
+
cursor: y.nextCursor ?? void 0,
|
|
168
|
+
hasMore: G,
|
|
169
|
+
items: x
|
|
170
|
+
}), M.value = J, r = !0;
|
|
171
|
+
} catch (y) {
|
|
172
|
+
if (n.aborted || K.value !== o) return;
|
|
173
|
+
const x = new Map(M.value);
|
|
174
|
+
x.set(s.key, {
|
|
175
|
+
page: (a == null ? void 0 : a.page) ?? 0,
|
|
176
|
+
cursor: a == null ? void 0 : a.cursor,
|
|
177
|
+
hasMore: (a == null ? void 0 : a.hasMore) ?? !1,
|
|
178
|
+
items: (a == null ? void 0 : a.items) ?? [],
|
|
179
|
+
failed: !0
|
|
180
|
+
}), M.value = x, T.value = { reason: y }, b(y, l);
|
|
181
|
+
}
|
|
182
|
+
})
|
|
183
|
+
), !n.aborted && (S == null ? void 0 : S.signal) === n && (S = void 0, L.value = !1, D.value = !1), r;
|
|
184
|
+
}
|
|
185
|
+
function U(t) {
|
|
186
|
+
if (t !== "initial" && L.value)
|
|
187
|
+
return Promise.resolve(!1);
|
|
188
|
+
B(), t === "initial" && (M.value = /* @__PURE__ */ new Map()), t !== "more" && (T.value = void 0);
|
|
189
|
+
const n = c.value, o = K.value;
|
|
190
|
+
if (!n || !o || !z.value.length)
|
|
191
|
+
return Promise.resolve(!1);
|
|
192
|
+
const l = new AbortController();
|
|
193
|
+
S = l, L.value = !0, D.value = t !== "initial" && [...M.value.values()].some(({ items: u }) => u.length);
|
|
194
|
+
const i = t === "initial" ? Math.max(
|
|
195
|
+
j(e.debounce, 180),
|
|
196
|
+
j(e.throttle, 0) - (Date.now() - _)
|
|
197
|
+
) : 0;
|
|
198
|
+
return i ? (Y = setTimeout(
|
|
199
|
+
() => void q(t, l.signal, o, n),
|
|
200
|
+
i
|
|
201
|
+
), Promise.resolve(!1)) : q(t, l.signal, o, n);
|
|
202
|
+
}
|
|
203
|
+
Z(
|
|
204
|
+
[K, () => e.debounce, () => e.throttle],
|
|
205
|
+
() => void U("initial"),
|
|
206
|
+
{ flush: "post" }
|
|
207
|
+
), we(B), Me(B);
|
|
208
|
+
const ye = () => {
|
|
209
|
+
U("retry");
|
|
210
|
+
}, me = () => X.value ? U("more") : Promise.resolve(!1), P = W([]);
|
|
211
|
+
function ee() {
|
|
212
|
+
if (P.value = [], !(!e.historyKey || typeof window > "u"))
|
|
213
|
+
try {
|
|
214
|
+
const t = JSON.parse(
|
|
215
|
+
window.localStorage.getItem(e.historyKey) ?? "[]"
|
|
216
|
+
);
|
|
217
|
+
Array.isArray(t) && (P.value = t.filter(
|
|
218
|
+
(n) => n && typeof n.prefix == "string" && Number.isFinite(n.count) && n.option && ["number", "string"].includes(typeof n.option.value)
|
|
219
|
+
));
|
|
220
|
+
} catch {
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
Se(ee), Z(() => e.historyKey, ee);
|
|
224
|
+
function he(t, n) {
|
|
225
|
+
const o = k(t).key, l = P.value.filter(
|
|
226
|
+
(u) => u.prefix !== n || k(u.option).key !== o
|
|
227
|
+
), i = P.value.find(
|
|
228
|
+
(u) => u.prefix === n && k(u.option).key === o
|
|
229
|
+
);
|
|
230
|
+
if (P.value = [
|
|
231
|
+
{ option: t, prefix: n, count: ((i == null ? void 0 : i.count) ?? 0) + 1 },
|
|
232
|
+
...l
|
|
233
|
+
].slice(0, j(e.recentLimit, 8)), !!e.historyKey)
|
|
234
|
+
try {
|
|
235
|
+
window.localStorage.setItem(
|
|
236
|
+
e.historyKey,
|
|
237
|
+
JSON.stringify(
|
|
238
|
+
P.value.map(({ prefix: u, count: r, option: s }) => ({
|
|
239
|
+
prefix: u,
|
|
240
|
+
count: r,
|
|
241
|
+
option: {
|
|
242
|
+
id: s.id,
|
|
243
|
+
value: s.value,
|
|
244
|
+
label: k(s).user.name,
|
|
245
|
+
type: s.type,
|
|
246
|
+
avatar: s.avatar
|
|
247
|
+
}
|
|
248
|
+
}))
|
|
249
|
+
)
|
|
250
|
+
);
|
|
251
|
+
} catch {
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
const te = w(() => {
|
|
255
|
+
var n, o, l;
|
|
256
|
+
const t = [];
|
|
257
|
+
if (!((n = d.value) != null && n.options) && !e.options && !e.loadOptions && !((o = d.value) != null && o.loadOptions))
|
|
258
|
+
for (const i of e.users ?? [])
|
|
259
|
+
t.push(
|
|
260
|
+
k(
|
|
261
|
+
{
|
|
262
|
+
id: i.id,
|
|
263
|
+
value: i.name,
|
|
264
|
+
label: i.name,
|
|
265
|
+
disabled: i.disabled
|
|
266
|
+
},
|
|
267
|
+
i
|
|
268
|
+
)
|
|
269
|
+
);
|
|
270
|
+
for (const i of A.value) {
|
|
271
|
+
const u = i.options ?? [], r = ((l = M.value.get(i.key)) == null ? void 0 : l.items) ?? [];
|
|
272
|
+
for (const [s, a] of [...u, ...r].entries()) {
|
|
273
|
+
const v = ke(a, i.fields, i.group);
|
|
274
|
+
v && t.push({
|
|
275
|
+
...k(v),
|
|
276
|
+
remote: s >= u.length
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return t;
|
|
281
|
+
}), I = w(() => {
|
|
282
|
+
var n;
|
|
283
|
+
const t = ((n = d.value) == null ? void 0 : n.searchMode) ?? e.searchMode ?? "includes";
|
|
284
|
+
return typeof t == "string" ? [t] : t;
|
|
285
|
+
}), E = W();
|
|
286
|
+
let V = !1;
|
|
287
|
+
Z(
|
|
288
|
+
() => I.value.some((t) => t === "pinyin" || t === "initials"),
|
|
289
|
+
(t) => {
|
|
290
|
+
!t || E.value || V || (V = !0, import("pinyin-pro").then((n) => {
|
|
291
|
+
E.value = n.pinyin;
|
|
292
|
+
}).catch(() => {
|
|
293
|
+
}).finally(() => {
|
|
294
|
+
V = !1;
|
|
295
|
+
}));
|
|
296
|
+
},
|
|
297
|
+
{ immediate: !0 }
|
|
298
|
+
);
|
|
299
|
+
const ne = /* @__PURE__ */ new Map();
|
|
300
|
+
function ge(t, n, o) {
|
|
301
|
+
if (!o) return 0;
|
|
302
|
+
const l = [
|
|
303
|
+
n,
|
|
304
|
+
String(t.value),
|
|
305
|
+
...t.keywords ?? [],
|
|
306
|
+
...(e.searchFields ?? []).map(
|
|
307
|
+
(r) => ue(
|
|
308
|
+
typeof r == "function" ? r(t) : ze(t, r)
|
|
309
|
+
)
|
|
310
|
+
)
|
|
311
|
+
], i = l.map(R);
|
|
312
|
+
if (i.some((r) => r === o)) return 5;
|
|
313
|
+
if (i.some((r) => r.startsWith(o))) return 4;
|
|
314
|
+
if (i.join(" ").includes(o) || o.includes(" ") && o.split(/\s+/).every((r) => i.some((s) => s.includes(r))))
|
|
315
|
+
return 3;
|
|
316
|
+
if (I.value.includes("fuzzy") && i.some((r) => Oe(o, r)))
|
|
317
|
+
return 1;
|
|
318
|
+
if (!E.value || !I.value.some((r) => r === "pinyin" || r === "initials"))
|
|
319
|
+
return -1;
|
|
320
|
+
const u = $(o);
|
|
321
|
+
for (const r of l) {
|
|
322
|
+
if (!new RegExp("\\p{Script=Han}", "u").test(r)) continue;
|
|
323
|
+
let s = ne.get(r);
|
|
324
|
+
if (!s) {
|
|
325
|
+
const a = E.value(r, {
|
|
326
|
+
toneType: "none",
|
|
327
|
+
type: "array",
|
|
328
|
+
nonZh: "consecutive"
|
|
329
|
+
});
|
|
330
|
+
s = {
|
|
331
|
+
full: $(a.join("")),
|
|
332
|
+
initials: $(a.map((v) => v[0]).join(""))
|
|
333
|
+
}, ne.set(r, s);
|
|
334
|
+
}
|
|
335
|
+
if (I.value.includes("pinyin") && s.full.includes(u) || I.value.includes("initials") && s.initials.includes(u))
|
|
336
|
+
return 2;
|
|
337
|
+
}
|
|
338
|
+
return -1;
|
|
339
|
+
}
|
|
340
|
+
const ae = w(() => {
|
|
341
|
+
var y, x, G, J, ie;
|
|
342
|
+
const t = c.value;
|
|
343
|
+
if (!t || g.value || Q.value) return [];
|
|
344
|
+
const n = R(t.query.trim()), o = d.value, l = (o == null ? void 0 : o.filterOption) ?? e.filterOption, i = /* @__PURE__ */ new Set(), u = te.value.slice();
|
|
345
|
+
if (!n) {
|
|
346
|
+
const f = P.value.filter(
|
|
347
|
+
(m) => m.prefix === t.prefix
|
|
348
|
+
), h = ((y = e.locale) == null ? void 0 : y.recent) ?? "最近使用", C = ((x = e.locale) == null ? void 0 : x.recommended) ?? "常用推荐", H = [
|
|
349
|
+
...e.recommendations ?? [],
|
|
350
|
+
...u.filter(({ option: m }) => m.recommended).map(({ option: m }) => m),
|
|
351
|
+
...f.filter(({ count: m }) => m > 1).sort((m, oe) => oe.count - m.count).map(({ option: m }) => m)
|
|
352
|
+
];
|
|
353
|
+
u.unshift(
|
|
354
|
+
...H.map(
|
|
355
|
+
(m) => k({ ...m, group: C })
|
|
356
|
+
),
|
|
357
|
+
...f.map(
|
|
358
|
+
({ option: m }) => k({ ...m, group: h })
|
|
359
|
+
)
|
|
360
|
+
);
|
|
361
|
+
}
|
|
362
|
+
const r = u.flatMap((f) => {
|
|
363
|
+
var le, se;
|
|
364
|
+
const { option: h, user: C, key: H } = f;
|
|
365
|
+
if (i.has(H) || h.prefix !== void 0 && h.prefix !== t.prefix)
|
|
366
|
+
return [];
|
|
367
|
+
const m = ge(h, C.name, n);
|
|
368
|
+
if (!(typeof l == "function" ? l(t.query, h, t.prefix) : l === !1 || l !== !0 && f.remote || m >= 0)) return [];
|
|
369
|
+
i.add(H);
|
|
370
|
+
const xe = ((le = e.groupBy) == null ? void 0 : le.call(e, h, t)) ?? h.group, re = C.disabled || ((se = e.canSelect) == null ? void 0 : se.call(e, h, t)) === !1;
|
|
371
|
+
return [
|
|
372
|
+
{
|
|
373
|
+
entry: {
|
|
374
|
+
...f,
|
|
375
|
+
option: { ...h, group: xe },
|
|
376
|
+
user: re === C.disabled ? C : { ...C, disabled: re }
|
|
377
|
+
},
|
|
378
|
+
relevance: m
|
|
379
|
+
}
|
|
380
|
+
];
|
|
381
|
+
}), s = e.sortOptions;
|
|
382
|
+
s && r.sort(
|
|
383
|
+
(f, h) => typeof s == "function" ? s(f.entry.option, h.entry.option, t) : h.relevance - f.relevance
|
|
384
|
+
);
|
|
385
|
+
const a = j(e.maxOptions, 8), v = r.slice(0, a || void 0).map(({ entry: f }) => f);
|
|
386
|
+
if (!T.value && ((o == null ? void 0 : o.allowCreate) ?? e.allowCreate) && n && !u.some(
|
|
387
|
+
({ option: f }) => (!f.prefix || f.prefix === t.prefix) && R(String(f.value)) === n
|
|
388
|
+
)) {
|
|
389
|
+
const f = ((G = e.createOption) == null ? void 0 : G.call(e, t)) ?? {
|
|
390
|
+
value: t.query,
|
|
391
|
+
label: (((J = e.locale) == null ? void 0 : J.create) ?? "创建 {value}").replace(
|
|
392
|
+
"{value}",
|
|
393
|
+
t.query
|
|
394
|
+
)
|
|
395
|
+
};
|
|
396
|
+
if (f && ((ie = e.canSelect) == null ? void 0 : ie.call(e, f, t)) !== !1) {
|
|
397
|
+
const h = k(f);
|
|
398
|
+
i.has(h.key) || v.push({ ...h, created: !0 });
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return v;
|
|
402
|
+
}), be = w(
|
|
403
|
+
() => ae.value.filter(({ user: t }) => !t.disabled)
|
|
404
|
+
);
|
|
405
|
+
return {
|
|
406
|
+
entries: te,
|
|
407
|
+
choices: ae,
|
|
408
|
+
enabled: be,
|
|
409
|
+
busy: Q,
|
|
410
|
+
loadingMore: D,
|
|
411
|
+
hasMore: X,
|
|
412
|
+
loadError: T,
|
|
413
|
+
retry: ye,
|
|
414
|
+
loadMore: me,
|
|
415
|
+
cancelLoad: B,
|
|
416
|
+
remember: he
|
|
417
|
+
};
|
|
418
|
+
}
|
|
419
|
+
export {
|
|
420
|
+
Pe as useMentionOptions
|
|
421
|
+
};
|