@box/metadata-template-browser 1.18.0 → 1.19.1
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.
|
@@ -1,57 +1,65 @@
|
|
|
1
|
-
import { useBrowseState as e, useBrowserActions as t, useConsumerState as n,
|
|
2
|
-
import { t as
|
|
3
|
-
import { BrowseList as
|
|
4
|
-
import { SearchList as
|
|
5
|
-
import { useIsInitialBrowseLoading as
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
1
|
+
import { useBrowseState as e, useBrowserActions as t, useConsumerState as n, useNavigationState as r, useSearchState as i, useSelectionState as a } from "../esm/lib/contexts/hooks.js";
|
|
2
|
+
import { t as o } from "./loader-skeleton.js";
|
|
3
|
+
import { BrowseList as s } from "../esm/lib/components/browse-list/browse-list.js";
|
|
4
|
+
import { SearchList as c } from "../esm/lib/components/search-list/search-list.js";
|
|
5
|
+
import { useIsInitialBrowseLoading as l } from "../esm/lib/hooks/use-is-initial-browse-loading.js";
|
|
6
|
+
import { useFocusFirstRowAfterNavigation as u } from "../esm/lib/hooks/use-focus-first-row-after-navigation.js";
|
|
7
|
+
import d from "clsx";
|
|
8
|
+
import { useCallback as f, useMemo as p, useRef as m } from "react";
|
|
9
|
+
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
10
|
+
import '../styles/metadata-template-browser-list-box.css';var _ = {
|
|
10
11
|
listBox: "_listBox_1qbmg_1",
|
|
11
12
|
browseWrapper: "_browseWrapper_1qbmg_9",
|
|
12
13
|
hidden: "_hidden_1qbmg_16"
|
|
13
14
|
};
|
|
14
|
-
function
|
|
15
|
-
let { isDisabled:
|
|
16
|
-
|
|
15
|
+
function v() {
|
|
16
|
+
let { isDisabled: v } = n(), y = l(), { searchValue: b, searchResults: x } = i(), { namespaces: S, templates: C, isFetching: w } = e(), { selectedTemplateId: T } = a(), { selectTemplate: E, navigateTo: D } = t(), { path: O } = r(), k = b.length > 0, A = m(null);
|
|
17
|
+
u({
|
|
18
|
+
containerRef: A,
|
|
19
|
+
path: O,
|
|
20
|
+
isFetching: w
|
|
21
|
+
});
|
|
22
|
+
let j = f((e) => {
|
|
23
|
+
if (v) return;
|
|
17
24
|
let t = String(e);
|
|
18
|
-
if (
|
|
19
|
-
let e =
|
|
20
|
-
e &&
|
|
25
|
+
if (k) {
|
|
26
|
+
let e = x.find((e) => e.id === t);
|
|
27
|
+
e && E(e);
|
|
21
28
|
return;
|
|
22
29
|
}
|
|
23
|
-
let n =
|
|
30
|
+
let n = C.find((e) => e.id === t);
|
|
24
31
|
if (n) {
|
|
25
|
-
|
|
32
|
+
E(n);
|
|
26
33
|
return;
|
|
27
34
|
}
|
|
28
|
-
let r =
|
|
29
|
-
r &&
|
|
35
|
+
let r = S.find((e) => e.id === t);
|
|
36
|
+
r && D(r);
|
|
30
37
|
}, [
|
|
31
|
-
h,
|
|
32
|
-
w,
|
|
33
38
|
v,
|
|
34
|
-
|
|
35
|
-
|
|
39
|
+
k,
|
|
40
|
+
x,
|
|
41
|
+
C,
|
|
36
42
|
S,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
E,
|
|
44
|
+
D
|
|
45
|
+
]), M = p(() => T ? new Set([T]) : /* @__PURE__ */ new Set(), [T]);
|
|
46
|
+
return y ? /* @__PURE__ */ h("div", {
|
|
47
|
+
className: _.listBox,
|
|
48
|
+
children: /* @__PURE__ */ h(o, {})
|
|
49
|
+
}) : /* @__PURE__ */ g("div", {
|
|
50
|
+
className: _.listBox,
|
|
51
|
+
children: [/* @__PURE__ */ h("div", {
|
|
52
|
+
ref: A,
|
|
53
|
+
"aria-hidden": k,
|
|
54
|
+
className: d(_.browseWrapper, k && _.hidden),
|
|
55
|
+
children: /* @__PURE__ */ h(s, {
|
|
56
|
+
onAction: j,
|
|
57
|
+
selectedKeys: M
|
|
50
58
|
})
|
|
51
|
-
}),
|
|
52
|
-
onAction:
|
|
53
|
-
selectedKeys:
|
|
59
|
+
}), k && /* @__PURE__ */ h(c, {
|
|
60
|
+
onAction: j,
|
|
61
|
+
selectedKeys: M
|
|
54
62
|
})]
|
|
55
63
|
});
|
|
56
64
|
}
|
|
57
|
-
export {
|
|
65
|
+
export { v as t };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useEffect as e, useRef as t } from "react";
|
|
2
|
+
var n = "[role=\"row\"]";
|
|
3
|
+
function r({ containerRef: r, path: i, isFetching: a }) {
|
|
4
|
+
let o = t(i), s = t(!1);
|
|
5
|
+
e(() => {
|
|
6
|
+
i !== o.current && (o.current = i, s.current = !0);
|
|
7
|
+
let e = r.current;
|
|
8
|
+
if (!s.current || a || !e) return;
|
|
9
|
+
s.current = !1;
|
|
10
|
+
let t = () => {
|
|
11
|
+
let { activeElement: t, body: r } = e.ownerDocument;
|
|
12
|
+
if (!(t === null || t === r || e.contains(t))) return !0;
|
|
13
|
+
let i = e.querySelector(n);
|
|
14
|
+
return i ? (i.focus(), !0) : !1;
|
|
15
|
+
};
|
|
16
|
+
if (t()) return;
|
|
17
|
+
let c = new MutationObserver(() => {
|
|
18
|
+
t() && c.disconnect();
|
|
19
|
+
});
|
|
20
|
+
return c.observe(e, {
|
|
21
|
+
childList: !0,
|
|
22
|
+
subtree: !0
|
|
23
|
+
}), () => {
|
|
24
|
+
c.disconnect();
|
|
25
|
+
};
|
|
26
|
+
}, [
|
|
27
|
+
i,
|
|
28
|
+
a,
|
|
29
|
+
r
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
export { r as useFocusFirstRowAfterNavigation };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
import { BreadcrumbEntry } from '../types';
|
|
3
|
+
interface UseFocusFirstRowAfterNavigationParams {
|
|
4
|
+
/** Container holding the browse list. The first descendant `[role="row"]` is focused. */
|
|
5
|
+
readonly containerRef: RefObject<HTMLElement | null>;
|
|
6
|
+
/** Current navigation path. A change in reference is treated as a user navigation. */
|
|
7
|
+
readonly path: readonly BreadcrumbEntry[];
|
|
8
|
+
/** True while the post-navigation fetch is in flight. Focus is deferred until it settles. */
|
|
9
|
+
readonly isFetching: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Restores keyboard focus to the first row of the browse list after a namespace
|
|
13
|
+
* navigation. Without this, the user-activated `NamespaceRow` unmounts during the
|
|
14
|
+
* in-flight fetch (the list is replaced by a loading skeleton), DOM focus drops
|
|
15
|
+
* to `<body>`, and arrow-key navigation appears broken until the user re-tabs in.
|
|
16
|
+
*
|
|
17
|
+
* No-op on initial render — `path` hasn't changed yet, so focus stays wherever
|
|
18
|
+
* the host page placed it. Only user-initiated path transitions trigger the restore.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const containerRef = useRef<HTMLDivElement>(null);
|
|
22
|
+
* const { path } = useNavigationState();
|
|
23
|
+
* const { isFetching } = useBrowseState();
|
|
24
|
+
* useFocusFirstRowAfterNavigation({ containerRef, path, isFetching });
|
|
25
|
+
* return <div ref={containerRef}><BrowseList ... /></div>;
|
|
26
|
+
*/
|
|
27
|
+
export declare function useFocusFirstRowAfterNavigation({ containerRef, path, isFetching, }: UseFocusFirstRowAfterNavigationParams): void;
|
|
28
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/metadata-template-browser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@box/blueprint-web": "^14.16.
|
|
7
|
-
"@box/blueprint-web-assets": "^4.115.
|
|
6
|
+
"@box/blueprint-web": "^14.16.1",
|
|
7
|
+
"@box/blueprint-web-assets": "^4.115.1",
|
|
8
8
|
"lodash": "^4.17.15",
|
|
9
9
|
"react": "^18.0.0",
|
|
10
10
|
"react-aria-components": "1.16.0",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"react-intl": "^6.4.2"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"@box/blueprint-web": "^14.16.
|
|
16
|
-
"@box/blueprint-web-assets": "^4.115.
|
|
15
|
+
"@box/blueprint-web": "^14.16.1",
|
|
16
|
+
"@box/blueprint-web-assets": "^4.115.1",
|
|
17
17
|
"@box/eslint-plugin-blueprint": "1.1.17",
|
|
18
|
-
"@box/storybook-utils": "0.18.
|
|
18
|
+
"@box/storybook-utils": "0.18.1",
|
|
19
19
|
"react-intl": "^6.4.2"
|
|
20
20
|
},
|
|
21
21
|
"publishConfig": {
|