@box/metadata-template-browser 1.16.3

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.
Files changed (177) hide show
  1. package/LICENSE +379 -0
  2. package/README.md +57 -0
  3. package/dist/chunks/types.js +6 -0
  4. package/dist/esm/index.js +4 -0
  5. package/dist/esm/lib/components/breadcrumb-navigation/breadcrumb-navigation.js +51 -0
  6. package/dist/esm/lib/components/breadcrumb-navigation/index.js +4 -0
  7. package/dist/esm/lib/components/breadcrumb-navigation/messages.js +18 -0
  8. package/dist/esm/lib/components/browse-list/browse-list.js +83 -0
  9. package/dist/esm/lib/components/browse-list/index.js +4 -0
  10. package/dist/esm/lib/components/browse-list/messages.js +18 -0
  11. package/dist/esm/lib/components/browser-row/browser-row.js +63 -0
  12. package/dist/esm/lib/components/browser-row/index.js +4 -0
  13. package/dist/esm/lib/components/error-state/error-state.js +32 -0
  14. package/dist/esm/lib/components/error-state/index.js +4 -0
  15. package/dist/esm/lib/components/error-state/messages.js +10 -0
  16. package/dist/esm/lib/components/index.js +24 -0
  17. package/dist/esm/lib/components/load-more-feedback/index.js +6 -0
  18. package/dist/esm/lib/components/load-more-feedback/load-more-error-row.js +44 -0
  19. package/dist/esm/lib/components/load-more-feedback/load-more-loading-row.js +34 -0
  20. package/dist/esm/lib/components/load-more-feedback/messages.js +22 -0
  21. package/dist/esm/lib/components/loader-skeleton/index.js +4 -0
  22. package/dist/esm/lib/components/loader-skeleton/loader-skeleton.js +26 -0
  23. package/dist/esm/lib/components/messages.js +30 -0
  24. package/dist/esm/lib/components/metadata-template-browser-container.js +35 -0
  25. package/dist/esm/lib/components/metadata-template-browser-controller.js +58 -0
  26. package/dist/esm/lib/components/metadata-template-browser-list-box/index.js +4 -0
  27. package/dist/esm/lib/components/metadata-template-browser-list-box/metadata-template-browser-list-box.js +65 -0
  28. package/dist/esm/lib/components/namespace-row/index.js +4 -0
  29. package/dist/esm/lib/components/namespace-row/messages.js +10 -0
  30. package/dist/esm/lib/components/namespace-row/namespace-row.js +32 -0
  31. package/dist/esm/lib/components/search-list/index.js +4 -0
  32. package/dist/esm/lib/components/search-list/messages.js +22 -0
  33. package/dist/esm/lib/components/search-list/search-list.js +76 -0
  34. package/dist/esm/lib/components/template-row/index.js +4 -0
  35. package/dist/esm/lib/components/template-row/messages.js +10 -0
  36. package/dist/esm/lib/components/template-row/template-row.js +70 -0
  37. package/dist/esm/lib/components/virtualized-grid-list/grid-list-load-more-sentinel.js +49 -0
  38. package/dist/esm/lib/components/virtualized-grid-list/index.js +4 -0
  39. package/dist/esm/lib/components/virtualized-grid-list/messages.js +10 -0
  40. package/dist/esm/lib/components/virtualized-grid-list/virtualized-grid-list.js +66 -0
  41. package/dist/esm/lib/constants.js +14 -0
  42. package/dist/esm/lib/contexts/contexts.js +129 -0
  43. package/dist/esm/lib/contexts/hooks.js +46 -0
  44. package/dist/esm/lib/contexts/index.js +17 -0
  45. package/dist/esm/lib/contexts/provider.js +59 -0
  46. package/dist/esm/lib/contexts/reducer.js +180 -0
  47. package/dist/esm/lib/contexts/use-template-browser-actions.js +263 -0
  48. package/dist/esm/lib/hooks/use-is-initial-browse-loading.js +16 -0
  49. package/dist/esm/lib/metadata-template-browser.js +27 -0
  50. package/dist/i18n/bn-IN.js +26 -0
  51. package/dist/i18n/bn-IN.properties +48 -0
  52. package/dist/i18n/da-DK.js +26 -0
  53. package/dist/i18n/da-DK.properties +48 -0
  54. package/dist/i18n/de-DE.js +26 -0
  55. package/dist/i18n/de-DE.properties +48 -0
  56. package/dist/i18n/en-AU.js +26 -0
  57. package/dist/i18n/en-AU.properties +48 -0
  58. package/dist/i18n/en-CA.js +26 -0
  59. package/dist/i18n/en-CA.properties +48 -0
  60. package/dist/i18n/en-GB.js +26 -0
  61. package/dist/i18n/en-GB.properties +48 -0
  62. package/dist/i18n/en-US.js +26 -0
  63. package/dist/i18n/en-US.properties +48 -0
  64. package/dist/i18n/en-x-pseudo.js +26 -0
  65. package/dist/i18n/en-x-pseudo.properties +48 -0
  66. package/dist/i18n/es-419.js +26 -0
  67. package/dist/i18n/es-419.properties +48 -0
  68. package/dist/i18n/es-ES.js +26 -0
  69. package/dist/i18n/es-ES.properties +48 -0
  70. package/dist/i18n/fi-FI.js +26 -0
  71. package/dist/i18n/fi-FI.properties +48 -0
  72. package/dist/i18n/fr-CA.js +26 -0
  73. package/dist/i18n/fr-CA.properties +48 -0
  74. package/dist/i18n/fr-FR.js +26 -0
  75. package/dist/i18n/fr-FR.properties +48 -0
  76. package/dist/i18n/hi-IN.js +26 -0
  77. package/dist/i18n/hi-IN.properties +48 -0
  78. package/dist/i18n/it-IT.js +26 -0
  79. package/dist/i18n/it-IT.properties +48 -0
  80. package/dist/i18n/ja-JP.js +26 -0
  81. package/dist/i18n/ja-JP.properties +48 -0
  82. package/dist/i18n/json/src/lib/components/breadcrumb-navigation/messages.json +1 -0
  83. package/dist/i18n/json/src/lib/components/browse-list/messages.json +1 -0
  84. package/dist/i18n/json/src/lib/components/error-state/messages.json +1 -0
  85. package/dist/i18n/json/src/lib/components/load-more-feedback/messages.json +1 -0
  86. package/dist/i18n/json/src/lib/components/messages.json +1 -0
  87. package/dist/i18n/json/src/lib/components/namespace-row/messages.json +1 -0
  88. package/dist/i18n/json/src/lib/components/search-list/messages.json +1 -0
  89. package/dist/i18n/json/src/lib/components/template-row/messages.json +1 -0
  90. package/dist/i18n/json/src/lib/components/virtualized-grid-list/messages.json +1 -0
  91. package/dist/i18n/ko-KR.js +26 -0
  92. package/dist/i18n/ko-KR.properties +48 -0
  93. package/dist/i18n/nb-NO.js +26 -0
  94. package/dist/i18n/nb-NO.properties +48 -0
  95. package/dist/i18n/nl-NL.js +26 -0
  96. package/dist/i18n/nl-NL.properties +48 -0
  97. package/dist/i18n/pl-PL.js +26 -0
  98. package/dist/i18n/pl-PL.properties +48 -0
  99. package/dist/i18n/pt-BR.js +26 -0
  100. package/dist/i18n/pt-BR.properties +48 -0
  101. package/dist/i18n/ru-RU.js +26 -0
  102. package/dist/i18n/ru-RU.properties +48 -0
  103. package/dist/i18n/sv-SE.js +26 -0
  104. package/dist/i18n/sv-SE.properties +48 -0
  105. package/dist/i18n/tr-TR.js +26 -0
  106. package/dist/i18n/tr-TR.properties +48 -0
  107. package/dist/i18n/zh-CN.js +26 -0
  108. package/dist/i18n/zh-CN.properties +48 -0
  109. package/dist/i18n/zh-TW.js +26 -0
  110. package/dist/i18n/zh-TW.properties +48 -0
  111. package/dist/styles/breadcrumb-navigation.css +1 -0
  112. package/dist/styles/browser-row.css +1 -0
  113. package/dist/styles/grid-list-load-more-sentinel.css +1 -0
  114. package/dist/styles/load-more-error-row.css +1 -0
  115. package/dist/styles/load-more-loading-row.css +1 -0
  116. package/dist/styles/loader-skeleton.css +1 -0
  117. package/dist/styles/metadata-template-browser-container.css +1 -0
  118. package/dist/styles/metadata-template-browser-controller.css +1 -0
  119. package/dist/styles/metadata-template-browser-list-box.css +1 -0
  120. package/dist/styles/virtualized-grid-list.css +1 -0
  121. package/dist/types/index.d.ts +3 -0
  122. package/dist/types/lib/components/breadcrumb-navigation/breadcrumb-navigation.d.ts +12 -0
  123. package/dist/types/lib/components/breadcrumb-navigation/index.d.ts +1 -0
  124. package/dist/types/lib/components/breadcrumb-navigation/messages.d.ts +17 -0
  125. package/dist/types/lib/components/browse-list/browse-list.d.ts +23 -0
  126. package/dist/types/lib/components/browse-list/index.d.ts +2 -0
  127. package/dist/types/lib/components/browse-list/messages.d.ts +17 -0
  128. package/dist/types/lib/components/browser-row/browser-row.d.ts +25 -0
  129. package/dist/types/lib/components/browser-row/index.d.ts +1 -0
  130. package/dist/types/lib/components/error-state/error-state.d.ts +11 -0
  131. package/dist/types/lib/components/error-state/index.d.ts +2 -0
  132. package/dist/types/lib/components/error-state/messages.d.ts +7 -0
  133. package/dist/types/lib/components/index.d.ts +15 -0
  134. package/dist/types/lib/components/load-more-feedback/index.d.ts +2 -0
  135. package/dist/types/lib/components/load-more-feedback/load-more-error-row.d.ts +10 -0
  136. package/dist/types/lib/components/load-more-feedback/load-more-loading-row.d.ts +6 -0
  137. package/dist/types/lib/components/load-more-feedback/messages.d.ts +22 -0
  138. package/dist/types/lib/components/loader-skeleton/index.d.ts +1 -0
  139. package/dist/types/lib/components/loader-skeleton/loader-skeleton.d.ts +5 -0
  140. package/dist/types/lib/components/messages.d.ts +32 -0
  141. package/dist/types/lib/components/metadata-template-browser-container.d.ts +8 -0
  142. package/dist/types/lib/components/metadata-template-browser-controller.d.ts +11 -0
  143. package/dist/types/lib/components/metadata-template-browser-list-box/index.d.ts +1 -0
  144. package/dist/types/lib/components/metadata-template-browser-list-box/metadata-template-browser-list-box.d.ts +6 -0
  145. package/dist/types/lib/components/namespace-row/index.d.ts +2 -0
  146. package/dist/types/lib/components/namespace-row/messages.d.ts +7 -0
  147. package/dist/types/lib/components/namespace-row/namespace-row.d.ts +10 -0
  148. package/dist/types/lib/components/search-list/index.d.ts +2 -0
  149. package/dist/types/lib/components/search-list/messages.d.ts +22 -0
  150. package/dist/types/lib/components/search-list/search-list.d.ts +12 -0
  151. package/dist/types/lib/components/template-row/index.d.ts +2 -0
  152. package/dist/types/lib/components/template-row/messages.d.ts +7 -0
  153. package/dist/types/lib/components/template-row/template-row.d.ts +19 -0
  154. package/dist/types/lib/components/virtualized-grid-list/grid-list-load-more-sentinel.d.ts +15 -0
  155. package/dist/types/lib/components/virtualized-grid-list/index.d.ts +2 -0
  156. package/dist/types/lib/components/virtualized-grid-list/messages.d.ts +7 -0
  157. package/dist/types/lib/components/virtualized-grid-list/virtualized-grid-list.d.ts +37 -0
  158. package/dist/types/lib/constants.d.ts +8 -0
  159. package/dist/types/lib/contexts/contexts.d.ts +47 -0
  160. package/dist/types/lib/contexts/hooks.d.ts +13 -0
  161. package/dist/types/lib/contexts/index.d.ts +7 -0
  162. package/dist/types/lib/contexts/provider.d.ts +14 -0
  163. package/dist/types/lib/contexts/reducer.d.ts +106 -0
  164. package/dist/types/lib/contexts/use-template-browser-actions.d.ts +9 -0
  165. package/dist/types/lib/hooks/use-is-initial-browse-loading.d.ts +7 -0
  166. package/dist/types/lib/metadata-template-browser.d.ts +23 -0
  167. package/dist/types/lib/stories/shared/constants.d.ts +16 -0
  168. package/dist/types/lib/stories/shared/create-mock-event-service.d.ts +2 -0
  169. package/dist/types/lib/stories/shared/create-mock-items-service.d.ts +53 -0
  170. package/dist/types/lib/stories/shared/generate-namespaces.d.ts +6 -0
  171. package/dist/types/lib/stories/shared/generate-templates.d.ts +8 -0
  172. package/dist/types/lib/stories/shared/index.d.ts +8 -0
  173. package/dist/types/lib/stories/shared/paginate-items.d.ts +2 -0
  174. package/dist/types/lib/stories/shared/story-container.d.ts +5 -0
  175. package/dist/types/lib/stories/shared/story-interaction-helpers.d.ts +30 -0
  176. package/dist/types/lib/types.d.ts +116 -0
  177. package/package.json +49 -0
@@ -0,0 +1,70 @@
1
+ import { IconButton as m, Text as c } from "@box/blueprint-web";
2
+ import { Pencil as p } from "@box/blueprint-web-assets/icons/Fill";
3
+ import { Metadata as f } from "@box/blueprint-web-assets/icons/Medium";
4
+ import { useCallback as h, Fragment as u } from "react";
5
+ import { useIntl as g } from "react-intl";
6
+ import { T as v } from "../../../../chunks/types.js";
7
+ import { messages as b } from "./messages.js";
8
+ import { jsx as i, jsxs as x } from "react/jsx-runtime";
9
+ import { useConsumerState as y } from "../../contexts/hooks.js";
10
+ import { BrowserRow as S } from "../browser-row/browser-row.js";
11
+ const w = (o) => {
12
+ if (!o.ancestors || o.ancestors.length === 0)
13
+ return;
14
+ const n = o.ancestors.length - 1;
15
+ return o.ancestors.map((r, a) => /* @__PURE__ */ x(u, {
16
+ children: [a > 0 && /* @__PURE__ */ i(c, {
17
+ "aria-hidden": "true",
18
+ as: "span",
19
+ color: "textOnLightSecondary",
20
+ variant: "caption",
21
+ children: " / "
22
+ }), /* @__PURE__ */ i(c, {
23
+ as: "span",
24
+ color: "textOnLightSecondary",
25
+ variant: a === n ? "captionBold" : "caption",
26
+ children: r.displayName
27
+ })]
28
+ }, r.fqn));
29
+ };
30
+ function j({
31
+ template: o,
32
+ variant: n,
33
+ onEdit: r
34
+ }) {
35
+ const {
36
+ formatMessage: a
37
+ } = g(), {
38
+ isDisabled: d
39
+ } = y(), l = h((t) => {
40
+ t.stopPropagation(), r(o.id);
41
+ }, [r, o.id]), s = n === v.Search, e = !!o.canEdit;
42
+ return /* @__PURE__ */ i(S, {
43
+ id: o.id,
44
+ isTrailingSlotHoverOnly: e,
45
+ leadingIcon: s ? void 0 : /* @__PURE__ */ i(f, {}),
46
+ subtitle: s ? w(o) : void 0,
47
+ title: o.displayName,
48
+ trailingSlot: e ? (
49
+ // onPointerDown stops React Aria from registering a press on the
50
+ // GridListItem — without it, the onSelectionChange bridge in
51
+ // VirtualizedGridList routes the click through onAction even though
52
+ // onClick.stopPropagation() is called (pointer events fire first).
53
+ /* @__PURE__ */ i("div", {
54
+ onPointerDown: (t) => t.stopPropagation(),
55
+ children: /* @__PURE__ */ i(m, {
56
+ "aria-label": a(b.editAriaLabel, {
57
+ displayName: o.displayName
58
+ }),
59
+ disabled: d,
60
+ icon: p,
61
+ onClick: l,
62
+ size: "x-small"
63
+ })
64
+ })
65
+ ) : void 0
66
+ });
67
+ }
68
+ export {
69
+ j as TemplateRow
70
+ };
@@ -0,0 +1,49 @@
1
+ import { useRef as f, useEffect as p } from "react";
2
+ import { GridListItem as L } from "react-aria-components";
3
+ import { useIntl as A } from "react-intl";
4
+ import { LOAD_MORE_SENTINEL_ID as h } from "../../constants.js";
5
+ import { messages as E } from "./messages.js";
6
+ import { jsx as _ } from "react/jsx-runtime";
7
+ import '../../../../styles/grid-list-load-more-sentinel.css';const I = "_sentinel_im31a_1", b = {
8
+ sentinel: I
9
+ };
10
+ function D({
11
+ onLoadMore: r,
12
+ scrollContainerRef: n
13
+ }) {
14
+ const s = f(r);
15
+ s.current = r;
16
+ const {
17
+ formatMessage: c
18
+ } = A(), m = c(E.loadMoreSentinelAriaLabel);
19
+ return p(() => {
20
+ const e = n.current;
21
+ let t, i = !1;
22
+ const o = () => {
23
+ if (!e || i)
24
+ return;
25
+ const {
26
+ scrollTop: u,
27
+ scrollHeight: d,
28
+ clientHeight: a
29
+ } = e;
30
+ d - u - a <= a && (i = !0, s.current());
31
+ }, l = () => {
32
+ cancelAnimationFrame(t), t = requestAnimationFrame(o);
33
+ };
34
+ return e?.addEventListener("scroll", l, {
35
+ passive: !0
36
+ }), t = requestAnimationFrame(o), () => {
37
+ e?.removeEventListener("scroll", l), cancelAnimationFrame(t);
38
+ };
39
+ }, [n]), /* @__PURE__ */ _(L, {
40
+ "aria-hidden": "true",
41
+ className: b.sentinel,
42
+ id: h,
43
+ isDisabled: !0,
44
+ textValue: m
45
+ });
46
+ }
47
+ export {
48
+ D as GridListLoadMoreSentinel
49
+ };
@@ -0,0 +1,4 @@
1
+ import { VirtualizedGridList as t } from "./virtualized-grid-list.js";
2
+ export {
3
+ t as VirtualizedGridList
4
+ };
@@ -0,0 +1,10 @@
1
+ import { defineMessages as e } from "react-intl";
2
+ const r = e({
3
+ loadMoreSentinelAriaLabel: {
4
+ id: "groupSharedFeatures.metadataTemplateBrowser.virtualizedGridList.loadMoreSentinelAriaLabel",
5
+ defaultMessage: "Load more items"
6
+ }
7
+ });
8
+ export {
9
+ r as messages
10
+ };
@@ -0,0 +1,66 @@
1
+ import { useMemo as h, useRef as O, useCallback as f } from "react";
2
+ import { ListLayout as T, Virtualizer as w, GridList as C, Collection as M } from "react-aria-components";
3
+ import { LOAD_MORE_ERROR_ROW_ID as G } from "../../constants.js";
4
+ import { T as H } from "../../../../chunks/types.js";
5
+ import { GridListLoadMoreSentinel as A } from "./grid-list-load-more-sentinel.js";
6
+ import { jsx as t, jsxs as D } from "react/jsx-runtime";
7
+ import { useConsumerState as I } from "../../contexts/hooks.js";
8
+ import { LoadMoreLoadingRow as W } from "../load-more-feedback/load-more-loading-row.js";
9
+ import { LoadMoreErrorRow as b } from "../load-more-feedback/load-more-error-row.js";
10
+ import '../../../../styles/virtualized-grid-list.css';const x = "_list_dukvn_1", V = {
11
+ list: x
12
+ }, j = 40, k = 58, v = 2;
13
+ function Y({
14
+ ariaLabel: d,
15
+ items: R,
16
+ onAction: e,
17
+ children: _,
18
+ onLoadMore: L,
19
+ hasMoreItems: p,
20
+ isFetchingMore: l,
21
+ loadMoreError: a,
22
+ onRetry: i,
23
+ selectedKeys: r,
24
+ listType: m
25
+ }) {
26
+ const {
27
+ isDisabled: n
28
+ } = I(), E = h(() => new T({
29
+ estimatedRowHeight: m === H.Browse ? j : k,
30
+ gap: v
31
+ }), [m]), c = O(null), u = f((o) => {
32
+ if (o === G) {
33
+ n || i();
34
+ return;
35
+ }
36
+ e(o);
37
+ }, [n, e, i]), S = f((o) => {
38
+ if (o === "all")
39
+ return;
40
+ const [s] = o;
41
+ s !== void 0 && !r.has(String(s)) && u(s);
42
+ }, [u, r]), g = p && !l && a === null && !n;
43
+ return /* @__PURE__ */ t(w, {
44
+ layout: E,
45
+ children: /* @__PURE__ */ D(C, {
46
+ ref: c,
47
+ "aria-label": d,
48
+ className: V.list,
49
+ onSelectionChange: S,
50
+ selectedKeys: r,
51
+ selectionMode: "single",
52
+ children: [/* @__PURE__ */ t(M, {
53
+ items: R,
54
+ children: _
55
+ }), l && /* @__PURE__ */ t(W, {}), a !== null && /* @__PURE__ */ t(b, {
56
+ onRetry: i
57
+ }), g && /* @__PURE__ */ t(A, {
58
+ onLoadMore: L,
59
+ scrollContainerRef: c
60
+ })]
61
+ })
62
+ });
63
+ }
64
+ export {
65
+ Y as VirtualizedGridList
66
+ };
@@ -0,0 +1,14 @@
1
+ const _ = "LOAD_MORE_ERROR_ROW_ID", O = "LOAD_MORE_LOADING_ROW_ID", R = "LOAD_MORE_SENTINEL_ID", E = 200, s = 500, e = {
2
+ entries: []
3
+ }, D = {
4
+ entries: []
5
+ };
6
+ export {
7
+ _ as LOAD_MORE_ERROR_ROW_ID,
8
+ O as LOAD_MORE_LOADING_ROW_ID,
9
+ R as LOAD_MORE_SENTINEL_ID,
10
+ E as PAGE_SIZE,
11
+ s as SEARCH_DEBOUNCE_MS,
12
+ e as emptyNamespacesResponse,
13
+ D as emptyTemplatesResponse
14
+ };
@@ -0,0 +1,129 @@
1
+ import { createContext as i, useMemo as l } from "react";
2
+ import { useTemplateBrowserActions as d } from "./use-template-browser-actions.js";
3
+ import { jsx as C } from "react/jsx-runtime";
4
+ const B = /* @__PURE__ */ i(null);
5
+ function H({
6
+ children: n,
7
+ namespaceFQN: t,
8
+ path: o
9
+ }) {
10
+ const e = l(() => ({
11
+ namespaceFQN: t,
12
+ path: o
13
+ }), [t, o]);
14
+ return /* @__PURE__ */ C(B.Provider, {
15
+ value: e,
16
+ children: n
17
+ });
18
+ }
19
+ const s = /* @__PURE__ */ i(null);
20
+ function J({
21
+ children: n,
22
+ namespaces: t,
23
+ templates: o,
24
+ isNamespacesExhausted: e,
25
+ namespaceNextMarker: r,
26
+ templateNextMarker: u,
27
+ isFetching: v,
28
+ isFetchingMore: c,
29
+ initialLoadError: S,
30
+ browseError: P,
31
+ loadMoreError: f
32
+ }) {
33
+ const x = l(() => ({
34
+ namespaces: t,
35
+ templates: o,
36
+ isNamespacesExhausted: e,
37
+ namespaceNextMarker: r,
38
+ templateNextMarker: u,
39
+ isFetching: v,
40
+ isFetchingMore: c,
41
+ initialLoadError: S,
42
+ browseError: P,
43
+ loadMoreError: f
44
+ }), [t, o, e, r, u, v, c, S, P, f]);
45
+ return /* @__PURE__ */ C(s.Provider, {
46
+ value: x,
47
+ children: n
48
+ });
49
+ }
50
+ const w = /* @__PURE__ */ i(null);
51
+ function K({
52
+ children: n,
53
+ searchValue: t,
54
+ searchQuery: o,
55
+ searchResults: e,
56
+ searchNextMarker: r,
57
+ isFetchingSearch: u,
58
+ searchError: v
59
+ }) {
60
+ const c = l(() => ({
61
+ searchValue: t,
62
+ searchQuery: o,
63
+ searchResults: e,
64
+ searchNextMarker: r,
65
+ isFetchingSearch: u,
66
+ searchError: v
67
+ }), [t, o, e, r, u, v]);
68
+ return /* @__PURE__ */ C(w.Provider, {
69
+ value: c,
70
+ children: n
71
+ });
72
+ }
73
+ const m = /* @__PURE__ */ i(null);
74
+ function O({
75
+ children: n,
76
+ selectedTemplateId: t
77
+ }) {
78
+ const o = l(() => ({
79
+ selectedTemplateId: t
80
+ }), [t]);
81
+ return /* @__PURE__ */ C(m.Provider, {
82
+ value: o,
83
+ children: n
84
+ });
85
+ }
86
+ const A = /* @__PURE__ */ i(null);
87
+ function T({
88
+ children: n,
89
+ isLoading: t = !1,
90
+ isDisabled: o = !1
91
+ }) {
92
+ const e = l(() => ({
93
+ isLoading: t,
94
+ isDisabled: o
95
+ }), [t, o]);
96
+ return /* @__PURE__ */ C(A.Provider, {
97
+ value: e,
98
+ children: n
99
+ });
100
+ }
101
+ const j = /* @__PURE__ */ i(null);
102
+ function U({
103
+ children: n,
104
+ itemsServiceRef: t,
105
+ eventServiceRef: o,
106
+ stateRef: e,
107
+ dispatch: r,
108
+ levelCache: u
109
+ }) {
110
+ const v = d(t, o, e, r, u);
111
+ return /* @__PURE__ */ C(j.Provider, {
112
+ value: v,
113
+ children: n
114
+ });
115
+ }
116
+ export {
117
+ s as BrowseStateContext,
118
+ J as BrowseStateContextProvider,
119
+ j as BrowserActionsContext,
120
+ U as BrowserActionsContextProvider,
121
+ A as ConsumerStateContext,
122
+ T as ConsumerStateContextProvider,
123
+ B as NavigationStateContext,
124
+ H as NavigationStateContextProvider,
125
+ w as SearchStateContext,
126
+ K as SearchStateContextProvider,
127
+ m as SelectionStateContext,
128
+ O as SelectionStateContextProvider
129
+ };
@@ -0,0 +1,46 @@
1
+ import { useContext as e } from "react";
2
+ import { NavigationStateContext as r, BrowseStateContext as o, SearchStateContext as n, SelectionStateContext as a, ConsumerStateContext as s, BrowserActionsContext as u } from "./contexts.js";
3
+ function c() {
4
+ const t = e(r);
5
+ if (t === null)
6
+ throw new Error("useNavigationState must be used within a MetadataTemplateBrowserProvider");
7
+ return t;
8
+ }
9
+ function S() {
10
+ const t = e(o);
11
+ if (t === null)
12
+ throw new Error("useBrowseState must be used within a MetadataTemplateBrowserProvider");
13
+ return t;
14
+ }
15
+ function l() {
16
+ const t = e(n);
17
+ if (t === null)
18
+ throw new Error("useSearchState must be used within a MetadataTemplateBrowserProvider");
19
+ return t;
20
+ }
21
+ function m() {
22
+ const t = e(a);
23
+ if (t === null)
24
+ throw new Error("useSelectionState must be used within a MetadataTemplateBrowserProvider");
25
+ return t;
26
+ }
27
+ function d() {
28
+ const t = e(s);
29
+ if (t === null)
30
+ throw new Error("useConsumerState must be used within a ConsumerStateContextProvider");
31
+ return t;
32
+ }
33
+ function h() {
34
+ const t = e(u);
35
+ if (t === null)
36
+ throw new Error("useBrowserActions must be used within a MetadataTemplateBrowserProvider");
37
+ return t;
38
+ }
39
+ export {
40
+ S as useBrowseState,
41
+ h as useBrowserActions,
42
+ d as useConsumerState,
43
+ c as useNavigationState,
44
+ l as useSearchState,
45
+ m as useSelectionState
46
+ };
@@ -0,0 +1,17 @@
1
+ import { browserReducer as r, initialState as o } from "./reducer.js";
2
+ import { ConsumerStateContext as s, ConsumerStateContextProvider as u } from "./contexts.js";
3
+ import { MetadataTemplateBrowserProvider as i } from "./provider.js";
4
+ import { useBrowseState as m, useBrowserActions as x, useConsumerState as p, useNavigationState as C, useSearchState as c, useSelectionState as d } from "./hooks.js";
5
+ export {
6
+ s as ConsumerStateContext,
7
+ u as ConsumerStateContextProvider,
8
+ i as MetadataTemplateBrowserProvider,
9
+ r as browserReducer,
10
+ o as initialState,
11
+ m as useBrowseState,
12
+ x as useBrowserActions,
13
+ p as useConsumerState,
14
+ C as useNavigationState,
15
+ c as useSearchState,
16
+ d as useSelectionState
17
+ };
@@ -0,0 +1,59 @@
1
+ import { useReducer as m, useRef as t } from "react";
2
+ import { NavigationStateContextProvider as u, BrowseStateContextProvider as x, SearchStateContextProvider as M, SelectionStateContextProvider as N, BrowserActionsContextProvider as E } from "./contexts.js";
3
+ import { browserReducer as f, initialState as S } from "./reducer.js";
4
+ import { jsx as r } from "react/jsx-runtime";
5
+ function w({
6
+ children: n,
7
+ namespaceFQN: h,
8
+ itemsService: a,
9
+ eventService: s,
10
+ initialSelectedTemplateId: l
11
+ }) {
12
+ const [e, d] = m(f, {
13
+ ...S,
14
+ namespaceFQN: h,
15
+ selectedTemplateId: l ?? null
16
+ }), o = t(e);
17
+ o.current = e;
18
+ const p = t(/* @__PURE__ */ new Map()), c = t(a);
19
+ c.current = a;
20
+ const i = t(s);
21
+ return i.current = s, /* @__PURE__ */ r(u, {
22
+ namespaceFQN: e.namespaceFQN,
23
+ path: e.path,
24
+ children: /* @__PURE__ */ r(x, {
25
+ namespaces: e.namespaces,
26
+ templates: e.templates,
27
+ isNamespacesExhausted: e.isNamespacesExhausted,
28
+ namespaceNextMarker: e.namespaceNextMarker,
29
+ templateNextMarker: e.templateNextMarker,
30
+ isFetching: e.isFetching,
31
+ isFetchingMore: e.isFetchingMore,
32
+ initialLoadError: e.initialLoadError,
33
+ browseError: e.browseError,
34
+ loadMoreError: e.loadMoreError,
35
+ children: /* @__PURE__ */ r(M, {
36
+ searchValue: e.searchValue,
37
+ searchQuery: e.searchQuery,
38
+ searchResults: e.searchResults,
39
+ searchNextMarker: e.searchNextMarker,
40
+ isFetchingSearch: e.isFetchingSearch,
41
+ searchError: e.searchError,
42
+ children: /* @__PURE__ */ r(N, {
43
+ selectedTemplateId: e.selectedTemplateId,
44
+ children: /* @__PURE__ */ r(E, {
45
+ itemsServiceRef: c,
46
+ eventServiceRef: i,
47
+ stateRef: o,
48
+ dispatch: d,
49
+ levelCache: p,
50
+ children: n
51
+ })
52
+ })
53
+ })
54
+ })
55
+ });
56
+ }
57
+ export {
58
+ w as MetadataTemplateBrowserProvider
59
+ };
@@ -0,0 +1,180 @@
1
+ let a = /* @__PURE__ */ (function(e) {
2
+ return e.NavigateTo = "NAVIGATE_TO", e.NavigateBack = "NAVIGATE_BACK", e.BrowseFetchStart = "BROWSE_FETCH_START", e.BrowseLoaded = "BROWSE_LOADED", e.InitialLoadError = "INITIAL_LOAD_ERROR", e.BrowseError = "BROWSE_ERROR", e.LoadMoreStart = "LOAD_MORE_START", e.LoadMoreNamespacesLoaded = "LOAD_MORE_NAMESPACES_LOADED", e.LoadMoreTemplatesLoaded = "LOAD_MORE_TEMPLATES_LOADED", e.LoadMoreError = "LOAD_MORE_ERROR", e.SearchValueChange = "SEARCH_VALUE_CHANGE", e.SearchFetchStart = "SEARCH_FETCH_START", e.SearchLoaded = "SEARCH_LOADED", e.SearchError = "SEARCH_ERROR", e.SearchClear = "SEARCH_CLEAR", e.LoadMoreSearchLoaded = "LOAD_MORE_SEARCH_LOADED", e.TemplateSelect = "TEMPLATE_SELECT", e;
3
+ })({});
4
+ const l = {
5
+ namespaceFQN: "",
6
+ path: [],
7
+ namespaces: [],
8
+ templates: [],
9
+ isNamespacesExhausted: !1,
10
+ namespaceNextMarker: void 0,
11
+ templateNextMarker: void 0,
12
+ isFetching: !1,
13
+ isFetchingMore: !1,
14
+ initialLoadError: null,
15
+ browseError: null,
16
+ loadMoreError: null,
17
+ searchValue: "",
18
+ searchQuery: "",
19
+ searchResults: [],
20
+ searchNextMarker: void 0,
21
+ isFetchingSearch: !1,
22
+ searchError: null,
23
+ selectedTemplateId: null
24
+ };
25
+ function t(e, r) {
26
+ switch (r.type) {
27
+ case a.NavigateTo:
28
+ return {
29
+ ...e,
30
+ namespaceFQN: r.namespace.id,
31
+ path: [...e.path, {
32
+ fqn: r.namespace.id,
33
+ displayName: r.namespace.displayName
34
+ }],
35
+ namespaces: [],
36
+ templates: [],
37
+ namespaceNextMarker: void 0,
38
+ templateNextMarker: void 0,
39
+ isNamespacesExhausted: !1,
40
+ initialLoadError: null,
41
+ browseError: null,
42
+ loadMoreError: null
43
+ };
44
+ case a.NavigateBack:
45
+ return {
46
+ ...e,
47
+ namespaceFQN: r.fqn,
48
+ path: e.path.filter((s) => r.fqn === s.fqn || r.fqn.startsWith(`${s.fqn}.`)),
49
+ namespaces: r.cached.namespaces,
50
+ templates: r.cached.templates,
51
+ namespaceNextMarker: r.cached.namespaceNextMarker,
52
+ templateNextMarker: r.cached.templateNextMarker,
53
+ isNamespacesExhausted: r.cached.isNamespacesExhausted,
54
+ isFetching: !1,
55
+ initialLoadError: null,
56
+ browseError: null,
57
+ loadMoreError: null
58
+ };
59
+ case a.BrowseFetchStart:
60
+ return {
61
+ ...e,
62
+ isFetching: !0,
63
+ initialLoadError: null,
64
+ browseError: null
65
+ };
66
+ case a.BrowseLoaded:
67
+ return {
68
+ ...e,
69
+ isFetching: !1,
70
+ namespaces: r.namespaces,
71
+ namespaceNextMarker: r.namespaceNextMarker,
72
+ // Namespaces are exhausted when the response carries no next_marker,
73
+ // which includes the case where the response is empty (no namespaces at all).
74
+ isNamespacesExhausted: !r.namespaceNextMarker,
75
+ templates: r.templates,
76
+ templateNextMarker: r.templateNextMarker
77
+ };
78
+ case a.InitialLoadError:
79
+ return {
80
+ ...e,
81
+ isFetching: !1,
82
+ initialLoadError: r.error
83
+ };
84
+ case a.BrowseError:
85
+ return {
86
+ ...e,
87
+ isFetching: !1,
88
+ browseError: r.error
89
+ };
90
+ case a.LoadMoreStart:
91
+ return {
92
+ ...e,
93
+ isFetchingMore: !0,
94
+ loadMoreError: null
95
+ };
96
+ case a.LoadMoreNamespacesLoaded:
97
+ return {
98
+ ...e,
99
+ isFetchingMore: !1,
100
+ namespaces: [...e.namespaces, ...r.entries],
101
+ namespaceNextMarker: r.nextMarker,
102
+ isNamespacesExhausted: !r.nextMarker,
103
+ // When namespaces become exhausted on this page, the first template page
104
+ // is fetched in the same request and stored here.
105
+ ...r.templates !== void 0 && {
106
+ templates: r.templates,
107
+ templateNextMarker: r.templateNextMarker
108
+ }
109
+ };
110
+ case a.LoadMoreTemplatesLoaded:
111
+ return {
112
+ ...e,
113
+ isFetchingMore: !1,
114
+ templates: [...e.templates, ...r.entries],
115
+ templateNextMarker: r.nextMarker
116
+ };
117
+ case a.LoadMoreError:
118
+ return {
119
+ ...e,
120
+ isFetchingMore: !1,
121
+ loadMoreError: r.error
122
+ };
123
+ case a.SearchValueChange:
124
+ return {
125
+ ...e,
126
+ searchValue: r.value
127
+ };
128
+ case a.SearchFetchStart:
129
+ return {
130
+ ...e,
131
+ isFetchingSearch: !0,
132
+ searchQuery: r.query,
133
+ searchResults: [],
134
+ searchNextMarker: void 0,
135
+ searchError: null
136
+ };
137
+ case a.SearchLoaded:
138
+ return {
139
+ ...e,
140
+ isFetchingSearch: !1,
141
+ searchResults: r.results,
142
+ searchNextMarker: r.nextMarker
143
+ };
144
+ case a.SearchError:
145
+ return {
146
+ ...e,
147
+ isFetchingSearch: !1,
148
+ searchError: r.error
149
+ };
150
+ case a.SearchClear:
151
+ return {
152
+ ...e,
153
+ searchValue: "",
154
+ searchQuery: "",
155
+ searchResults: [],
156
+ searchNextMarker: void 0,
157
+ isFetchingSearch: !1,
158
+ searchError: null
159
+ };
160
+ case a.LoadMoreSearchLoaded:
161
+ return {
162
+ ...e,
163
+ isFetchingMore: !1,
164
+ searchResults: [...e.searchResults, ...r.entries],
165
+ searchNextMarker: r.nextMarker
166
+ };
167
+ case a.TemplateSelect:
168
+ return {
169
+ ...e,
170
+ selectedTemplateId: r.template.id
171
+ };
172
+ default:
173
+ return e;
174
+ }
175
+ }
176
+ export {
177
+ a as BrowserActionType,
178
+ t as browserReducer,
179
+ l as initialState
180
+ };