@box/metadata-taxonomy-picker 2.18.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/LICENSE +379 -0
- package/README.md +57 -0
- package/dist/chunks/empty-state.js +22 -0
- package/dist/chunks/error-state.js +41 -0
- package/dist/chunks/load-more-error-row.js +53 -0
- package/dist/chunks/load-more-loading-row.js +17 -0
- package/dist/chunks/loading-state.js +17 -0
- package/dist/chunks/metadata-taxonomy-picker-shell.js +278 -0
- package/dist/chunks/taxonomy-ancestor-breadcrumb.js +115 -0
- package/dist/chunks/taxonomy-items-list.js +114 -0
- package/dist/chunks/taxonomy-level-filter.js +47 -0
- package/dist/chunks/taxonomy-menu-item.js +99 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/lib/components/metadata-taxonomy-picker-shell/index.js +2 -0
- package/dist/esm/lib/components/metadata-taxonomy-picker-shell/messages.js +24 -0
- package/dist/esm/lib/components/metadata-taxonomy-picker-shell/metadata-taxonomy-picker-shell.js +2 -0
- package/dist/esm/lib/components/taxonomy-ancestor-breadcrumb/index.js +2 -0
- package/dist/esm/lib/components/taxonomy-ancestor-breadcrumb/taxonomy-ancestor-breadcrumb.js +2 -0
- package/dist/esm/lib/components/taxonomy-items-list/empty-state/empty-state.js +2 -0
- package/dist/esm/lib/components/taxonomy-items-list/empty-state/index.js +2 -0
- package/dist/esm/lib/components/taxonomy-items-list/error-state/error-state.js +2 -0
- package/dist/esm/lib/components/taxonomy-items-list/error-state/index.js +2 -0
- package/dist/esm/lib/components/taxonomy-items-list/index.js +6 -0
- package/dist/esm/lib/components/taxonomy-items-list/load-more-feedback/index.js +3 -0
- package/dist/esm/lib/components/taxonomy-items-list/load-more-feedback/load-more-error-row.js +2 -0
- package/dist/esm/lib/components/taxonomy-items-list/load-more-feedback/load-more-loading-row.js +2 -0
- package/dist/esm/lib/components/taxonomy-items-list/load-more-feedback/messages.js +20 -0
- package/dist/esm/lib/components/taxonomy-items-list/loading-state/index.js +2 -0
- package/dist/esm/lib/components/taxonomy-items-list/loading-state/loading-state.js +2 -0
- package/dist/esm/lib/components/taxonomy-items-list/messages.js +36 -0
- package/dist/esm/lib/components/taxonomy-items-list/taxonomy-items-list.js +2 -0
- package/dist/esm/lib/components/taxonomy-level-filter/index.js +2 -0
- package/dist/esm/lib/components/taxonomy-level-filter/messages.js +6 -0
- package/dist/esm/lib/components/taxonomy-level-filter/taxonomy-level-filter.js +2 -0
- package/dist/esm/lib/components/taxonomy-menu-item/index.js +2 -0
- package/dist/esm/lib/components/taxonomy-menu-item/messages.js +6 -0
- package/dist/esm/lib/components/taxonomy-menu-item/taxonomy-menu-item.js +2 -0
- package/dist/esm/lib/components/taxonomy-menu-item/use-taxonomy-menu-item-keyboard.js +100 -0
- package/dist/esm/lib/constants.js +2 -0
- package/dist/esm/lib/hooks/messages.js +16 -0
- package/dist/esm/lib/hooks/use-taxonomy-picker-controller.js +261 -0
- package/dist/esm/lib/metadata-taxonomy-picker.js +10 -0
- package/dist/esm/lib/state/reducer.js +147 -0
- package/dist/esm/lib/state/transitions.js +22 -0
- package/dist/i18n/bn-IN.js +24 -0
- package/dist/i18n/bn-IN.properties +44 -0
- package/dist/i18n/da-DK.js +24 -0
- package/dist/i18n/da-DK.properties +44 -0
- package/dist/i18n/de-DE.js +24 -0
- package/dist/i18n/de-DE.properties +44 -0
- package/dist/i18n/en-AU.js +24 -0
- package/dist/i18n/en-AU.properties +44 -0
- package/dist/i18n/en-CA.js +24 -0
- package/dist/i18n/en-CA.properties +44 -0
- package/dist/i18n/en-GB.js +24 -0
- package/dist/i18n/en-GB.properties +44 -0
- package/dist/i18n/en-US.js +24 -0
- package/dist/i18n/en-US.properties +44 -0
- package/dist/i18n/en-x-pseudo.js +24 -0
- package/dist/i18n/en-x-pseudo.properties +44 -0
- package/dist/i18n/es-419.js +24 -0
- package/dist/i18n/es-419.properties +44 -0
- package/dist/i18n/es-ES.js +24 -0
- package/dist/i18n/es-ES.properties +44 -0
- package/dist/i18n/fi-FI.js +24 -0
- package/dist/i18n/fi-FI.properties +44 -0
- package/dist/i18n/fr-CA.js +24 -0
- package/dist/i18n/fr-CA.properties +44 -0
- package/dist/i18n/fr-FR.js +24 -0
- package/dist/i18n/fr-FR.properties +44 -0
- package/dist/i18n/hi-IN.js +24 -0
- package/dist/i18n/hi-IN.properties +44 -0
- package/dist/i18n/it-IT.js +24 -0
- package/dist/i18n/it-IT.properties +44 -0
- package/dist/i18n/ja-JP.js +24 -0
- package/dist/i18n/ja-JP.properties +44 -0
- package/dist/i18n/json/src/lib/components/metadata-taxonomy-picker-shell/messages.json +1 -0
- package/dist/i18n/json/src/lib/components/taxonomy-items-list/load-more-feedback/messages.json +1 -0
- package/dist/i18n/json/src/lib/components/taxonomy-items-list/messages.json +1 -0
- package/dist/i18n/json/src/lib/components/taxonomy-level-filter/messages.json +1 -0
- package/dist/i18n/json/src/lib/components/taxonomy-menu-item/messages.json +1 -0
- package/dist/i18n/json/src/lib/hooks/messages.json +1 -0
- package/dist/i18n/ko-KR.js +24 -0
- package/dist/i18n/ko-KR.properties +44 -0
- package/dist/i18n/nb-NO.js +24 -0
- package/dist/i18n/nb-NO.properties +44 -0
- package/dist/i18n/nl-NL.js +24 -0
- package/dist/i18n/nl-NL.properties +44 -0
- package/dist/i18n/pl-PL.js +24 -0
- package/dist/i18n/pl-PL.properties +44 -0
- package/dist/i18n/pt-BR.js +24 -0
- package/dist/i18n/pt-BR.properties +44 -0
- package/dist/i18n/ru-RU.js +24 -0
- package/dist/i18n/ru-RU.properties +44 -0
- package/dist/i18n/sv-SE.js +24 -0
- package/dist/i18n/sv-SE.properties +44 -0
- package/dist/i18n/tr-TR.js +24 -0
- package/dist/i18n/tr-TR.properties +44 -0
- package/dist/i18n/zh-CN.js +24 -0
- package/dist/i18n/zh-CN.properties +44 -0
- package/dist/i18n/zh-TW.js +24 -0
- package/dist/i18n/zh-TW.properties +44 -0
- package/dist/styles/empty-state.css +1 -0
- package/dist/styles/error-state.css +1 -0
- package/dist/styles/load-more-error-row.css +1 -0
- package/dist/styles/load-more-loading-row.css +1 -0
- package/dist/styles/loading-state.css +1 -0
- package/dist/styles/metadata-taxonomy-picker-shell.css +1 -0
- package/dist/styles/taxonomy-ancestor-breadcrumb.css +1 -0
- package/dist/styles/taxonomy-items-list.css +1 -0
- package/dist/styles/taxonomy-level-filter.css +1 -0
- package/dist/styles/taxonomy-menu-item.css +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/lib/components/metadata-taxonomy-picker-shell/index.d.ts +1 -0
- package/dist/types/lib/components/metadata-taxonomy-picker-shell/messages.d.ts +27 -0
- package/dist/types/lib/components/metadata-taxonomy-picker-shell/metadata-taxonomy-picker-shell.d.ts +2 -0
- package/dist/types/lib/components/taxonomy-ancestor-breadcrumb/index.d.ts +1 -0
- package/dist/types/lib/components/taxonomy-ancestor-breadcrumb/taxonomy-ancestor-breadcrumb.d.ts +16 -0
- package/dist/types/lib/components/taxonomy-items-list/empty-state/empty-state.d.ts +10 -0
- package/dist/types/lib/components/taxonomy-items-list/empty-state/index.d.ts +1 -0
- package/dist/types/lib/components/taxonomy-items-list/error-state/error-state.d.ts +9 -0
- package/dist/types/lib/components/taxonomy-items-list/error-state/index.d.ts +1 -0
- package/dist/types/lib/components/taxonomy-items-list/index.d.ts +5 -0
- package/dist/types/lib/components/taxonomy-items-list/load-more-feedback/index.d.ts +2 -0
- package/dist/types/lib/components/taxonomy-items-list/load-more-feedback/load-more-error-row.d.ts +10 -0
- package/dist/types/lib/components/taxonomy-items-list/load-more-feedback/load-more-loading-row.d.ts +7 -0
- package/dist/types/lib/components/taxonomy-items-list/load-more-feedback/messages.d.ts +22 -0
- package/dist/types/lib/components/taxonomy-items-list/loading-state/index.d.ts +1 -0
- package/dist/types/lib/components/taxonomy-items-list/loading-state/loading-state.d.ts +6 -0
- package/dist/types/lib/components/taxonomy-items-list/messages.d.ts +42 -0
- package/dist/types/lib/components/taxonomy-items-list/taxonomy-items-list.d.ts +82 -0
- package/dist/types/lib/components/taxonomy-level-filter/index.d.ts +1 -0
- package/dist/types/lib/components/taxonomy-level-filter/messages.d.ts +7 -0
- package/dist/types/lib/components/taxonomy-level-filter/taxonomy-level-filter.d.ts +11 -0
- package/dist/types/lib/components/taxonomy-menu-item/index.d.ts +1 -0
- package/dist/types/lib/components/taxonomy-menu-item/messages.d.ts +7 -0
- package/dist/types/lib/components/taxonomy-menu-item/taxonomy-menu-item.d.ts +20 -0
- package/dist/types/lib/components/taxonomy-menu-item/use-taxonomy-menu-item-keyboard.d.ts +47 -0
- package/dist/types/lib/constants.d.ts +49 -0
- package/dist/types/lib/hooks/messages.d.ts +17 -0
- package/dist/types/lib/hooks/use-taxonomy-picker-controller.d.ts +22 -0
- package/dist/types/lib/metadata-taxonomy-picker.d.ts +8 -0
- package/dist/types/lib/state/reducer.d.ts +180 -0
- package/dist/types/lib/state/transitions.d.ts +4 -0
- package/dist/types/lib/stories/metadata-taxonomy-picker.stories.d.ts +136 -0
- package/dist/types/lib/stories/shared/build-taxonomy-items.d.ts +10 -0
- package/dist/types/lib/stories/shared/create-mock-items-service.d.ts +35 -0
- package/dist/types/lib/stories/shared/generate-deep-nodes.d.ts +39 -0
- package/dist/types/lib/stories/shared/generate-hierarchical-nodes.d.ts +3 -0
- package/dist/types/lib/stories/shared/generate-nodes.d.ts +2 -0
- package/dist/types/lib/stories/shared/generate-search-results.d.ts +10 -0
- package/dist/types/lib/stories/shared/story-container.d.ts +5 -0
- package/dist/types/lib/stories/shared/taxonomy-items-list-fixtures.d.ts +7 -0
- package/dist/types/lib/stories/taxonomy-ancestor-breadcrumb.stories.d.ts +28 -0
- package/dist/types/lib/stories/taxonomy-items-list.stories.d.ts +77 -0
- package/dist/types/lib/stories/taxonomy-menu-item.stories.d.ts +67 -0
- package/dist/types/lib/stories/tests/breadcrumb-navigation.interaction-tests.stories.d.ts +78 -0
- package/dist/types/lib/stories/tests/error-handling.interaction-tests.stories.d.ts +50 -0
- package/dist/types/lib/stories/tests/interaction-tests.stories.d.ts +47 -0
- package/dist/types/lib/stories/tests/level-filter-interaction-tests.stories.d.ts +99 -0
- package/dist/types/lib/stories/tests/level-transitions.interaction-tests.stories.d.ts +60 -0
- package/dist/types/lib/stories/tests/pagination.interaction-tests.stories.d.ts +90 -0
- package/dist/types/lib/stories/tests/portal-and-ref.interaction-tests.stories.d.ts +39 -0
- package/dist/types/lib/stories/tests/search-interaction-tests.stories.d.ts +124 -0
- package/dist/types/lib/stories/tests/shell-selection.interaction-tests.stories.d.ts +56 -0
- package/dist/types/lib/stories/tests/single-level-mode.interaction-tests.stories.d.ts +50 -0
- package/dist/types/lib/stories/tests/taxonomy-menu-item.interaction-tests.stories.d.ts +70 -0
- package/dist/types/lib/stories/tests/visual-regression-tests.stories.d.ts +38 -0
- package/dist/types/lib/types.d.ts +105 -0
- package/package.json +51 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ESTIMATED_BROWSE_ROW_HEIGHT as e, ESTIMATED_SEARCH_ROW_HEIGHT as t } from "../../constants.js";
|
|
2
|
+
import { t as n } from "../../../../chunks/empty-state.js";
|
|
3
|
+
import { t as r } from "../../../../chunks/error-state.js";
|
|
4
|
+
import { t as i } from "../../../../chunks/loading-state.js";
|
|
5
|
+
import { t as a } from "../../../../chunks/taxonomy-items-list.js";
|
|
6
|
+
export { e as ESTIMATED_BROWSE_ROW_HEIGHT, t as ESTIMATED_SEARCH_ROW_HEIGHT, n as EmptyListState, r as ErrorState, i as LoadingState, a as TaxonomyItemsList };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineMessages as e } from "react-intl";
|
|
2
|
+
var t = e({
|
|
3
|
+
loadingRowAriaLabel: {
|
|
4
|
+
id: "groupSharedFeatures.metadataTaxonomyPicker.loadMoreFeedback.loadingRowAriaLabel",
|
|
5
|
+
defaultMessage: "Loading more items"
|
|
6
|
+
},
|
|
7
|
+
errorNoticeText: {
|
|
8
|
+
id: "groupSharedFeatures.metadataTaxonomyPicker.loadMoreFeedback.errorNoticeText",
|
|
9
|
+
defaultMessage: "Loading failed"
|
|
10
|
+
},
|
|
11
|
+
errorNoticeIconAriaLabel: {
|
|
12
|
+
id: "groupSharedFeatures.metadataTaxonomyPicker.loadMoreFeedback.errorNoticeIconAriaLabel",
|
|
13
|
+
defaultMessage: "Error"
|
|
14
|
+
},
|
|
15
|
+
reloadButtonLabel: {
|
|
16
|
+
id: "groupSharedFeatures.metadataTaxonomyPicker.loadMoreFeedback.reloadButtonLabel",
|
|
17
|
+
defaultMessage: "Reload"
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
export { t as messages };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { defineMessages as e } from "react-intl";
|
|
2
|
+
var t = e({
|
|
3
|
+
loadingAriaLabel: {
|
|
4
|
+
id: "groupSharedFeatures.metadataTaxonomyPicker.itemsList.loadingAriaLabel",
|
|
5
|
+
defaultMessage: "Loading taxonomy items"
|
|
6
|
+
},
|
|
7
|
+
emptyStateHeading: {
|
|
8
|
+
id: "groupSharedFeatures.metadataTaxonomyPicker.itemsList.emptyStateHeading",
|
|
9
|
+
defaultMessage: "No subnodes"
|
|
10
|
+
},
|
|
11
|
+
emptyStateBody: {
|
|
12
|
+
id: "groupSharedFeatures.metadataTaxonomyPicker.itemsList.emptyStateBody",
|
|
13
|
+
defaultMessage: "This path does not have subnodes."
|
|
14
|
+
},
|
|
15
|
+
searchEmptyStateHeading: {
|
|
16
|
+
id: "groupSharedFeatures.metadataTaxonomyPicker.itemsList.searchEmptyStateHeading",
|
|
17
|
+
defaultMessage: "No results found"
|
|
18
|
+
},
|
|
19
|
+
searchEmptyStateBody: {
|
|
20
|
+
id: "groupSharedFeatures.metadataTaxonomyPicker.itemsList.searchEmptyStateBody",
|
|
21
|
+
defaultMessage: "Try a different search term."
|
|
22
|
+
},
|
|
23
|
+
errorStateHeading: {
|
|
24
|
+
id: "groupSharedFeatures.metadataTaxonomyPicker.itemsList.errorStateHeading",
|
|
25
|
+
defaultMessage: "Something went wrong."
|
|
26
|
+
},
|
|
27
|
+
errorStateBody: {
|
|
28
|
+
id: "groupSharedFeatures.metadataTaxonomyPicker.itemsList.errorStateBody",
|
|
29
|
+
defaultMessage: "Please reload to try again."
|
|
30
|
+
},
|
|
31
|
+
reloadButton: {
|
|
32
|
+
id: "groupSharedFeatures.metadataTaxonomyPicker.itemsList.reloadButton",
|
|
33
|
+
defaultMessage: "Reload"
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
export { t as messages };
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { useCallback as e, useRef as t } from "react";
|
|
2
|
+
import { useCompositeContext as n } from "@ariakit/react";
|
|
3
|
+
function r({ id: r, multiSelect: i, onSelect: a, onFocusExit: o, rowRef: s, selectionControlRef: c, drillDownRef: l }) {
|
|
4
|
+
let u = n(), d = t(!1), f = e((e) => {
|
|
5
|
+
if (!u) return !1;
|
|
6
|
+
let { activeId: t, items: n } = u.getState(), r = n.findIndex((e) => e.id === t);
|
|
7
|
+
if (r === -1) return !1;
|
|
8
|
+
let i = e === "ArrowDown" ? r + 1 : r - 1;
|
|
9
|
+
if (i < 0 || i >= n.length) return !1;
|
|
10
|
+
let a = n[i].element;
|
|
11
|
+
return a ? (a.focus(), !0) : !1;
|
|
12
|
+
}, [u]), p = e(() => {
|
|
13
|
+
d.current = !0, c.current?.focus();
|
|
14
|
+
}, [c]);
|
|
15
|
+
return {
|
|
16
|
+
handleSelectionControlFocus: e(() => {
|
|
17
|
+
d.current || s.current?.focus(), d.current = !1;
|
|
18
|
+
}, [s]),
|
|
19
|
+
handleRowKeyDown: e((e) => {
|
|
20
|
+
switch (e.key) {
|
|
21
|
+
case "Tab":
|
|
22
|
+
f(e.shiftKey ? "ArrowUp" : "ArrowDown") ? e.preventDefault() : e.shiftKey && o && (e.preventDefault(), o());
|
|
23
|
+
break;
|
|
24
|
+
case "ArrowLeft":
|
|
25
|
+
e.preventDefault(), e.stopPropagation(), p();
|
|
26
|
+
break;
|
|
27
|
+
case "ArrowRight":
|
|
28
|
+
e.preventDefault(), e.stopPropagation(), l.current?.focus();
|
|
29
|
+
break;
|
|
30
|
+
}
|
|
31
|
+
}, [
|
|
32
|
+
p,
|
|
33
|
+
f,
|
|
34
|
+
o,
|
|
35
|
+
l
|
|
36
|
+
]),
|
|
37
|
+
handleRowKeyDownCapture: e((e) => {
|
|
38
|
+
let t = e.target;
|
|
39
|
+
if (!t || t === e.currentTarget) return;
|
|
40
|
+
let n = c.current != null && (c.current === t || c.current.contains(t)), r = l.current != null && (l.current === t || l.current.contains(t));
|
|
41
|
+
if (!(!n && !r)) {
|
|
42
|
+
switch (e.key) {
|
|
43
|
+
case "ArrowUp":
|
|
44
|
+
case "ArrowDown":
|
|
45
|
+
f(e.key) && (e.preventDefault(), e.stopPropagation());
|
|
46
|
+
break;
|
|
47
|
+
case "Tab":
|
|
48
|
+
f(e.shiftKey ? "ArrowUp" : "ArrowDown") ? (e.preventDefault(), e.stopPropagation()) : e.shiftKey && o && (e.preventDefault(), e.stopPropagation(), o());
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
if (n) switch (e.key) {
|
|
52
|
+
case "ArrowRight":
|
|
53
|
+
e.preventDefault(), e.stopPropagation(), l.current?.focus();
|
|
54
|
+
break;
|
|
55
|
+
case "ArrowLeft":
|
|
56
|
+
e.preventDefault(), e.stopPropagation(), s.current?.focus();
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}, [
|
|
61
|
+
f,
|
|
62
|
+
o,
|
|
63
|
+
c,
|
|
64
|
+
l,
|
|
65
|
+
s
|
|
66
|
+
]),
|
|
67
|
+
handleSelectionControlKeyDown: e((e) => {
|
|
68
|
+
switch (e.key) {
|
|
69
|
+
case "Enter":
|
|
70
|
+
i || (e.preventDefault(), a(r));
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
}, [
|
|
74
|
+
i,
|
|
75
|
+
a,
|
|
76
|
+
r
|
|
77
|
+
]),
|
|
78
|
+
handleDrillDownKeyDown: e((e) => {
|
|
79
|
+
switch (e.key) {
|
|
80
|
+
case "Tab":
|
|
81
|
+
f(e.shiftKey ? "ArrowUp" : "ArrowDown") ? e.preventDefault() : e.shiftKey && o && (e.preventDefault(), o());
|
|
82
|
+
break;
|
|
83
|
+
case "Enter":
|
|
84
|
+
case " ":
|
|
85
|
+
e.stopPropagation();
|
|
86
|
+
break;
|
|
87
|
+
case "ArrowLeft":
|
|
88
|
+
e.preventDefault(), c.current ? p() : s.current?.focus();
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}, [
|
|
92
|
+
f,
|
|
93
|
+
o,
|
|
94
|
+
p,
|
|
95
|
+
c,
|
|
96
|
+
s
|
|
97
|
+
])
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
export { r as useTaxonomyMenuItemKeyboard };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e = 36, t = 44, n = 20, r = 9, i = 16, a = 3, o = 16, s = 112, c = 200, l = 400, u = " / ", d = 2, f = 2, p = "…", m = 100, h = 300 * 1e3, g = "__root__", _ = "__breadcrumb_root__", v = 500;
|
|
2
|
+
export { p as BREADCRUMB_ELLIPSIS_CHAR, d as BREADCRUMB_MAX_LINES, f as BREADCRUMB_OVERFLOW_THRESHOLD_PX, _ as BREADCRUMB_ROOT_ID, u as BREADCRUMB_SEPARATOR, h as CACHE_TTL_MS, m as DEFAULT_PAGE_LIMIT, e as ESTIMATED_BROWSE_ROW_HEIGHT, t as ESTIMATED_SEARCH_ROW_HEIGHT, l as LOAD_MORE_ERROR_MIN_VISIBLE_MS, s as LOAD_MORE_GHOST_BLOCK_HEIGHT, a as LOAD_MORE_GHOST_ROW_COUNT, o as LOAD_MORE_GHOST_ROW_HEIGHT, c as LOAD_MORE_ROOT_MARGIN_PX, n as OVERSCAN_COUNT, g as ROOT_CACHE_KEY, v as SEARCH_DEBOUNCE_MS, r as SKELETON_ROW_COUNT, i as SKELETON_ROW_HEIGHT };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineMessages as e } from "react-intl";
|
|
2
|
+
var t = e({
|
|
3
|
+
initialLoadErrorFallback: {
|
|
4
|
+
id: "groupSharedFeatures.metadataTaxonomyPicker.controller.initialLoadErrorFallback",
|
|
5
|
+
defaultMessage: "Failed to load items"
|
|
6
|
+
},
|
|
7
|
+
searchErrorFallback: {
|
|
8
|
+
id: "groupSharedFeatures.metadataTaxonomyPicker.controller.searchErrorFallback",
|
|
9
|
+
defaultMessage: "Failed to search items"
|
|
10
|
+
},
|
|
11
|
+
loadMoreErrorFallback: {
|
|
12
|
+
id: "groupSharedFeatures.metadataTaxonomyPicker.controller.loadMoreErrorFallback",
|
|
13
|
+
defaultMessage: "Failed to load more items"
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
export { t as messages };
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import "../constants.js";
|
|
2
|
+
import { FailedOp as e, PickerActionType as t, initialState as n, pickerReducer as r } from "../state/reducer.js";
|
|
3
|
+
import { messages as i } from "./messages.js";
|
|
4
|
+
import { useCallback as a, useEffect as o, useReducer as s, useRef as c, useState as l } from "react";
|
|
5
|
+
import { useIntl as u } from "react-intl";
|
|
6
|
+
var d = [];
|
|
7
|
+
function f(e) {
|
|
8
|
+
return e ?? "__root__";
|
|
9
|
+
}
|
|
10
|
+
function p(p, m = d, h) {
|
|
11
|
+
let [g, _] = s(r, n), [v, y] = l(!1), b = c(g);
|
|
12
|
+
b.current = g;
|
|
13
|
+
let x = c(p);
|
|
14
|
+
x.current = p;
|
|
15
|
+
let S = c(h);
|
|
16
|
+
S.current = h;
|
|
17
|
+
let C = c(m);
|
|
18
|
+
C.current = m;
|
|
19
|
+
let w = c(void 0), { formatMessage: T } = u(), E = c(T);
|
|
20
|
+
E.current = T;
|
|
21
|
+
let D = c(null), O = c(null), k = c(null), A = c(!1), j = c(/* @__PURE__ */ new Map()), M = a((e, t, n) => {
|
|
22
|
+
j.current.set(f(e), {
|
|
23
|
+
items: t,
|
|
24
|
+
nextMarker: n,
|
|
25
|
+
fetchedAt: Date.now()
|
|
26
|
+
});
|
|
27
|
+
}, []), N = a((e) => {
|
|
28
|
+
let t = f(e), n = j.current.get(t);
|
|
29
|
+
return n ? Date.now() - n.fetchedAt > 3e5 ? (j.current.delete(t), null) : n : null;
|
|
30
|
+
}, []), P = a(async (e) => {
|
|
31
|
+
D.current?.abort();
|
|
32
|
+
let n = new AbortController();
|
|
33
|
+
D.current = n;
|
|
34
|
+
try {
|
|
35
|
+
let r = await x.current.getNodes(e, {
|
|
36
|
+
limit: 100,
|
|
37
|
+
signal: n.signal
|
|
38
|
+
});
|
|
39
|
+
if (n.signal.aborted) return;
|
|
40
|
+
A.current = !0, _({
|
|
41
|
+
type: t.FetchSuccess,
|
|
42
|
+
entries: r.entries,
|
|
43
|
+
nextMarker: r.next_marker,
|
|
44
|
+
forParentId: e
|
|
45
|
+
});
|
|
46
|
+
} catch (r) {
|
|
47
|
+
if (n.signal.aborted || r instanceof DOMException && r.name === "AbortError") return;
|
|
48
|
+
_({
|
|
49
|
+
type: t.FetchError,
|
|
50
|
+
error: r instanceof Error ? r.message : E.current(i.initialLoadErrorFallback),
|
|
51
|
+
forParentId: e
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}, []), F = a((e) => {
|
|
55
|
+
_({ type: t.FetchStart }), P(e);
|
|
56
|
+
}, [P]), I = a(async (e, n) => {
|
|
57
|
+
O.current?.abort();
|
|
58
|
+
let r = new AbortController();
|
|
59
|
+
O.current = r, _({
|
|
60
|
+
type: t.SearchFetchStart,
|
|
61
|
+
query: e
|
|
62
|
+
});
|
|
63
|
+
try {
|
|
64
|
+
let i = n === void 0 ? b.current.levelFilter : n, a = w.current, o = a ? a.parentId : b.current.currentParentId, s = a ? a.levelFilter : i, c = await x.current.searchNodes(e, {
|
|
65
|
+
limit: 100,
|
|
66
|
+
signal: r.signal,
|
|
67
|
+
parentId: o,
|
|
68
|
+
levelFilter: s ?? void 0
|
|
69
|
+
});
|
|
70
|
+
if (r.signal.aborted) return;
|
|
71
|
+
_({
|
|
72
|
+
type: t.SearchFetchSuccess,
|
|
73
|
+
results: c.entries,
|
|
74
|
+
nextMarker: c.next_marker,
|
|
75
|
+
forQuery: e
|
|
76
|
+
}), S.current?.onSearch?.(e);
|
|
77
|
+
} catch (e) {
|
|
78
|
+
if (r.signal.aborted || e instanceof DOMException && e.name === "AbortError") return;
|
|
79
|
+
_({
|
|
80
|
+
type: t.SearchFetchError,
|
|
81
|
+
error: e instanceof Error ? e.message : E.current(i.searchErrorFallback)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
}, []), L = a((e) => {
|
|
85
|
+
if (_({
|
|
86
|
+
type: t.SearchInputChange,
|
|
87
|
+
value: e,
|
|
88
|
+
availableLevels: C.current
|
|
89
|
+
}), k.current !== null && (clearTimeout(k.current), k.current = null), !e) {
|
|
90
|
+
O.current?.abort(), _({ type: t.SearchClear });
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
k.current = setTimeout(() => {
|
|
94
|
+
I(e);
|
|
95
|
+
}, 500);
|
|
96
|
+
}, [I]), R = a((e) => {
|
|
97
|
+
y(e), S.current?.onOpenChange?.(e), e && !A.current && F(null), e || (k.current !== null && (clearTimeout(k.current), k.current = null), D.current?.abort(), O.current?.abort(), j.current.clear(), A.current = !1, _({ type: t.Reset }));
|
|
98
|
+
}, [F]);
|
|
99
|
+
o(() => {
|
|
100
|
+
let e = D, t = O;
|
|
101
|
+
return () => {
|
|
102
|
+
e.current?.abort(), t.current?.abort(), D.current?.abort(), O.current?.abort(), k.current !== null && clearTimeout(k.current);
|
|
103
|
+
};
|
|
104
|
+
}, []);
|
|
105
|
+
let z = a((e) => {
|
|
106
|
+
let t = w.current;
|
|
107
|
+
if (t?.parentId === e?.parentId && t?.levelFilter === e?.levelFilter || (w.current = e, !A.current)) return;
|
|
108
|
+
let { searchInputValue: n } = b.current;
|
|
109
|
+
n !== "" && (k.current !== null && (clearTimeout(k.current), k.current = null), I(n));
|
|
110
|
+
}, [I]), B = a((e) => {
|
|
111
|
+
k.current !== null && (clearTimeout(k.current), k.current = null), O.current?.abort();
|
|
112
|
+
let n = b.current;
|
|
113
|
+
M(n.currentParentId, n.items, n.itemsNextMarker);
|
|
114
|
+
let r = e.ancestors ? [...e.ancestors.map((e) => ({
|
|
115
|
+
id: e.id,
|
|
116
|
+
displayName: e.displayName
|
|
117
|
+
})), {
|
|
118
|
+
id: e.id,
|
|
119
|
+
displayName: e.displayName
|
|
120
|
+
}] : [...n.levelStack, {
|
|
121
|
+
id: e.id,
|
|
122
|
+
displayName: e.displayName
|
|
123
|
+
}];
|
|
124
|
+
_({
|
|
125
|
+
type: t.DrillDown,
|
|
126
|
+
targetParentId: e.id,
|
|
127
|
+
levelStack: r
|
|
128
|
+
}), P(e.id), S.current?.onNavigate?.(e.id, r);
|
|
129
|
+
}, [P, M]), V = a((e) => {
|
|
130
|
+
k.current !== null && (clearTimeout(k.current), k.current = null), D.current?.abort(), O.current?.abort();
|
|
131
|
+
let n = b.current;
|
|
132
|
+
M(n.currentParentId, n.items, n.itemsNextMarker);
|
|
133
|
+
let r = e === null ? -1 : n.levelStack.findIndex((t) => t.id === e), i = r === -1 ? [] : n.levelStack.slice(0, r + 1), a = N(e);
|
|
134
|
+
a ? _({
|
|
135
|
+
type: t.NavigateBack,
|
|
136
|
+
targetParentId: e,
|
|
137
|
+
levelStack: i,
|
|
138
|
+
cached: {
|
|
139
|
+
items: a.items,
|
|
140
|
+
nextMarker: a.nextMarker
|
|
141
|
+
}
|
|
142
|
+
}) : (_({
|
|
143
|
+
type: t.NavigateBackRefetch,
|
|
144
|
+
targetParentId: e,
|
|
145
|
+
levelStack: i
|
|
146
|
+
}), P(e)), S.current?.onNavigate?.(e, i);
|
|
147
|
+
}, [
|
|
148
|
+
P,
|
|
149
|
+
N,
|
|
150
|
+
M
|
|
151
|
+
]), H = a(async () => {
|
|
152
|
+
let { isFetchingMore: e, itemsNextMarker: n, currentParentId: r, items: a } = b.current;
|
|
153
|
+
if (e || n === void 0) return;
|
|
154
|
+
D.current?.abort();
|
|
155
|
+
let o = new AbortController();
|
|
156
|
+
D.current = o;
|
|
157
|
+
let s = Date.now();
|
|
158
|
+
_({ type: t.LoadMoreStart });
|
|
159
|
+
try {
|
|
160
|
+
let e = await x.current.getNodes(r, {
|
|
161
|
+
limit: 100,
|
|
162
|
+
marker: n,
|
|
163
|
+
signal: o.signal
|
|
164
|
+
});
|
|
165
|
+
if (o.signal.aborted || b.current.currentParentId !== r) return;
|
|
166
|
+
_({
|
|
167
|
+
type: t.LoadMoreSuccess,
|
|
168
|
+
entries: e.entries,
|
|
169
|
+
nextMarker: e.next_marker
|
|
170
|
+
}), M(r, [...a, ...e.entries], e.next_marker);
|
|
171
|
+
} catch (e) {
|
|
172
|
+
if (o.signal.aborted || e instanceof DOMException && e.name === "AbortError" || b.current.currentParentId !== r) return;
|
|
173
|
+
let n = 400 - (Date.now() - s);
|
|
174
|
+
if (n > 0 && (await new Promise((e) => setTimeout(e, n)), o.signal.aborted || b.current.currentParentId !== r)) return;
|
|
175
|
+
_({
|
|
176
|
+
type: t.LoadMoreError,
|
|
177
|
+
error: e instanceof Error ? e.message : E.current(i.loadMoreErrorFallback)
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}, [M]), U = a(async () => {
|
|
181
|
+
let { isFetchingSearchMore: e, searchNextMarker: n, searchQuery: r, currentParentId: a, levelFilter: o } = b.current;
|
|
182
|
+
if (e || n === void 0 || r === "") return;
|
|
183
|
+
let s = w.current, c = s ? s.parentId : a, l = (s ? s.levelFilter : o) ?? void 0;
|
|
184
|
+
O.current?.abort();
|
|
185
|
+
let u = new AbortController();
|
|
186
|
+
O.current = u;
|
|
187
|
+
let d = Date.now();
|
|
188
|
+
_({ type: t.SearchLoadMoreStart });
|
|
189
|
+
try {
|
|
190
|
+
let e = await x.current.searchNodes(r, {
|
|
191
|
+
limit: 100,
|
|
192
|
+
marker: n,
|
|
193
|
+
parentId: c,
|
|
194
|
+
levelFilter: l,
|
|
195
|
+
signal: u.signal
|
|
196
|
+
});
|
|
197
|
+
if (u.signal.aborted) return;
|
|
198
|
+
_({
|
|
199
|
+
type: t.SearchLoadMoreSuccess,
|
|
200
|
+
entries: e.entries,
|
|
201
|
+
nextMarker: e.next_marker,
|
|
202
|
+
forQuery: r
|
|
203
|
+
});
|
|
204
|
+
} catch (e) {
|
|
205
|
+
if (u.signal.aborted || e instanceof DOMException && e.name === "AbortError") return;
|
|
206
|
+
let n = 400 - (Date.now() - d);
|
|
207
|
+
if (n > 0 && (await new Promise((e) => setTimeout(e, n)), u.signal.aborted)) return;
|
|
208
|
+
_({
|
|
209
|
+
type: t.SearchLoadMoreError,
|
|
210
|
+
error: e instanceof Error ? e.message : E.current(i.loadMoreErrorFallback),
|
|
211
|
+
forQuery: r
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
}, []), W = a(() => {
|
|
215
|
+
switch (b.current.lastFailedOp) {
|
|
216
|
+
case e.Browse:
|
|
217
|
+
F(b.current.currentParentId);
|
|
218
|
+
break;
|
|
219
|
+
case e.BrowseMore:
|
|
220
|
+
H();
|
|
221
|
+
break;
|
|
222
|
+
case e.Search: {
|
|
223
|
+
let { searchQuery: e } = b.current;
|
|
224
|
+
e !== "" && I(e);
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
case e.SearchMore:
|
|
228
|
+
U();
|
|
229
|
+
break;
|
|
230
|
+
default: break;
|
|
231
|
+
}
|
|
232
|
+
}, [
|
|
233
|
+
F,
|
|
234
|
+
H,
|
|
235
|
+
I,
|
|
236
|
+
U
|
|
237
|
+
]);
|
|
238
|
+
return {
|
|
239
|
+
state: g,
|
|
240
|
+
isOpen: v,
|
|
241
|
+
handleOpenChange: R,
|
|
242
|
+
handleInputValueChange: L,
|
|
243
|
+
actions: {
|
|
244
|
+
drillDown: B,
|
|
245
|
+
navigateBack: V,
|
|
246
|
+
loadMore: H,
|
|
247
|
+
searchLoadMore: U,
|
|
248
|
+
setLevelFilter: a((e) => {
|
|
249
|
+
_({
|
|
250
|
+
type: t.SetLevelFilter,
|
|
251
|
+
level: e
|
|
252
|
+
}), k.current !== null && (clearTimeout(k.current), k.current = null);
|
|
253
|
+
let n = b.current.searchInputValue;
|
|
254
|
+
n && I(n, e);
|
|
255
|
+
}, [I]),
|
|
256
|
+
retry: W,
|
|
257
|
+
setSearchScopeOverride: z
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
export { p as useTaxonomyPickerController };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { t as e } from "../../chunks/metadata-taxonomy-picker-shell.js";
|
|
2
|
+
import { forwardRef as t } from "react";
|
|
3
|
+
import { jsx as n } from "react/jsx-runtime";
|
|
4
|
+
var r = /* @__PURE__ */ t(function(t, r) {
|
|
5
|
+
return /* @__PURE__ */ n(e, {
|
|
6
|
+
...t,
|
|
7
|
+
ref: r
|
|
8
|
+
});
|
|
9
|
+
});
|
|
10
|
+
export { r as MetadataTaxonomyPicker, r as default };
|