@box/tree 0.50.1 → 0.50.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.
- package/dist/esm/lib/tree.js +84 -85
- package/dist/types/lib/tree.d.ts +1 -1
- package/package.json +5 -5
package/dist/esm/lib/tree.js
CHANGED
|
@@ -1,129 +1,128 @@
|
|
|
1
|
-
import { TooltipProvider as
|
|
2
|
-
import
|
|
3
|
-
import { useRef as
|
|
4
|
-
import
|
|
5
|
-
import { preventDisabledNodeExpanding as
|
|
1
|
+
import { TooltipProvider as b, useForkRef as h } from "@box/blueprint-web";
|
|
2
|
+
import R from "clsx";
|
|
3
|
+
import { forwardRef as S, useRef as x, useEffect as v, useCallback as C } from "react";
|
|
4
|
+
import M from "react-accessible-treeview";
|
|
5
|
+
import { preventDisabledNodeExpanding as y, preventLoadingContentNodeExpanding as I, serviceNodeKeyboardHandler as T, serviceNodeClickHandler as H } from "./utils.js";
|
|
6
6
|
import { jsx as t } from "react/jsx-runtime";
|
|
7
|
-
import { useSelectionInheritance as
|
|
8
|
-
import { ContentNode as
|
|
9
|
-
import { ServiceNodeWrapper as
|
|
10
|
-
import { LoadMoreNode as
|
|
11
|
-
import { ReloadNode as
|
|
12
|
-
import { LoadingNode as
|
|
13
|
-
import '../../styles/tree.css';const
|
|
14
|
-
tree:
|
|
15
|
-
},
|
|
7
|
+
import { useSelectionInheritance as _ } from "./hooks/useSelectionInheritance.js";
|
|
8
|
+
import { ContentNode as K } from "./components/content-node/content-node.js";
|
|
9
|
+
import { ServiceNodeWrapper as N } from "./components/service-node-wrapper/service-node-wrapper.js";
|
|
10
|
+
import { LoadMoreNode as P } from "./components/load-more-node/load-more-node.js";
|
|
11
|
+
import { ReloadNode as j } from "./components/reload-node/reload-node.js";
|
|
12
|
+
import { LoadingNode as A } from "./components/loading-node/loading-node.js";
|
|
13
|
+
import '../../styles/tree.css';const D = "_tree_17956_1", F = {
|
|
14
|
+
tree: D
|
|
15
|
+
}, V = (i, s, f) => (n) => {
|
|
16
16
|
const {
|
|
17
17
|
element: m,
|
|
18
|
-
isDisabled:
|
|
19
|
-
} =
|
|
20
|
-
id:
|
|
21
|
-
metadata:
|
|
18
|
+
isDisabled: d
|
|
19
|
+
} = n, {
|
|
20
|
+
id: a,
|
|
21
|
+
metadata: c,
|
|
22
22
|
parent: l
|
|
23
23
|
} = m, {
|
|
24
|
-
variant:
|
|
25
|
-
} =
|
|
26
|
-
if (
|
|
24
|
+
variant: o
|
|
25
|
+
} = c;
|
|
26
|
+
if (o === "content" || o === "user" || o === "labeled") {
|
|
27
27
|
const r = {
|
|
28
|
-
...
|
|
29
|
-
size:
|
|
28
|
+
...n,
|
|
29
|
+
size: i,
|
|
30
30
|
withIcon: s
|
|
31
31
|
};
|
|
32
|
-
return /* @__PURE__ */ t(
|
|
32
|
+
return /* @__PURE__ */ t(K, {
|
|
33
33
|
...r,
|
|
34
|
-
containsSelection:
|
|
34
|
+
containsSelection: f.includes(a)
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
if (
|
|
37
|
+
if (o === "loadMore") {
|
|
38
38
|
const r = {
|
|
39
|
-
...
|
|
40
|
-
size:
|
|
39
|
+
...n,
|
|
40
|
+
size: i
|
|
41
41
|
};
|
|
42
|
-
return /* @__PURE__ */ t(
|
|
43
|
-
isDisabled:
|
|
42
|
+
return /* @__PURE__ */ t(N, {
|
|
43
|
+
isDisabled: d,
|
|
44
44
|
parentId: l,
|
|
45
45
|
variant: "loadMore",
|
|
46
|
-
children: /* @__PURE__ */ t(
|
|
46
|
+
children: /* @__PURE__ */ t(P, {
|
|
47
47
|
...r
|
|
48
48
|
})
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
-
if (
|
|
51
|
+
if (o === "reload") {
|
|
52
52
|
const r = {
|
|
53
|
-
...
|
|
54
|
-
size:
|
|
53
|
+
...n,
|
|
54
|
+
size: i
|
|
55
55
|
};
|
|
56
|
-
return /* @__PURE__ */ t(
|
|
57
|
-
isDisabled:
|
|
56
|
+
return /* @__PURE__ */ t(N, {
|
|
57
|
+
isDisabled: d,
|
|
58
58
|
parentId: l,
|
|
59
59
|
variant: "reload",
|
|
60
|
-
children: /* @__PURE__ */ t(
|
|
60
|
+
children: /* @__PURE__ */ t(j, {
|
|
61
61
|
...r
|
|
62
62
|
})
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
|
-
if (
|
|
65
|
+
if (o === "loading") {
|
|
66
66
|
const r = {
|
|
67
|
-
...
|
|
68
|
-
size:
|
|
67
|
+
...n,
|
|
68
|
+
size: i
|
|
69
69
|
};
|
|
70
|
-
return /* @__PURE__ */ t(
|
|
71
|
-
isDisabled:
|
|
70
|
+
return /* @__PURE__ */ t(N, {
|
|
71
|
+
isDisabled: d,
|
|
72
72
|
variant: "loading",
|
|
73
|
-
children: /* @__PURE__ */ t(
|
|
73
|
+
children: /* @__PURE__ */ t(A, {
|
|
74
74
|
...r
|
|
75
75
|
})
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
return null;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
"
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
onSelect: i,
|
|
79
|
+
}, z = /* @__PURE__ */ S(function({
|
|
80
|
+
"aria-label": s,
|
|
81
|
+
size: f = "small",
|
|
82
|
+
data: n,
|
|
83
|
+
withIcons: m = !1,
|
|
84
|
+
onExpand: d,
|
|
85
|
+
onSelect: a,
|
|
87
86
|
onLoadData: c,
|
|
88
|
-
className:
|
|
89
|
-
multiSelect:
|
|
90
|
-
...
|
|
91
|
-
}) {
|
|
92
|
-
const
|
|
93
|
-
selectionInheritors:
|
|
87
|
+
className: l,
|
|
88
|
+
multiSelect: o = !1,
|
|
89
|
+
...r
|
|
90
|
+
}, L) {
|
|
91
|
+
const u = x(null), {
|
|
92
|
+
selectionInheritors: g,
|
|
94
93
|
getSelectionInheritors: p
|
|
95
|
-
} =
|
|
96
|
-
|
|
97
|
-
const e =
|
|
98
|
-
return e && (e.addEventListener("keydown",
|
|
99
|
-
e && (e.removeEventListener("keydown",
|
|
94
|
+
} = _();
|
|
95
|
+
v(() => {
|
|
96
|
+
const e = u.current;
|
|
97
|
+
return e && (e.addEventListener("keydown", y), e.addEventListener("keydown", I)), () => {
|
|
98
|
+
e && (e.removeEventListener("keydown", y), e.removeEventListener("keydown", I));
|
|
100
99
|
};
|
|
101
|
-
}),
|
|
102
|
-
const e =
|
|
103
|
-
return e && (e.addEventListener("keydown",
|
|
104
|
-
e && (e.removeEventListener("keydown",
|
|
100
|
+
}), v(() => {
|
|
101
|
+
const e = u.current, k = T(c), E = H(c);
|
|
102
|
+
return e && (e.addEventListener("keydown", k), e.addEventListener("click", E)), () => {
|
|
103
|
+
e && (e.removeEventListener("keydown", k), e.removeEventListener("click", E));
|
|
105
104
|
};
|
|
106
|
-
}),
|
|
107
|
-
p(
|
|
105
|
+
}), v(() => {
|
|
106
|
+
p(n, r.selectedIds || r.defaultSelectedIds);
|
|
108
107
|
}, []);
|
|
109
|
-
const
|
|
110
|
-
p(
|
|
111
|
-
}, [
|
|
112
|
-
return /* @__PURE__ */ t(
|
|
113
|
-
children: /* @__PURE__ */ t(
|
|
114
|
-
ref:
|
|
115
|
-
"aria-label":
|
|
116
|
-
className:
|
|
117
|
-
data:
|
|
118
|
-
multiSelect:
|
|
119
|
-
nodeRenderer:
|
|
120
|
-
onExpand:
|
|
121
|
-
onSelect:
|
|
122
|
-
...
|
|
108
|
+
const w = C((e) => {
|
|
109
|
+
p(n, Array.from(e.treeState.selectedIds)), a && a(e);
|
|
110
|
+
}, [a, n, p]);
|
|
111
|
+
return /* @__PURE__ */ t(b, {
|
|
112
|
+
children: /* @__PURE__ */ t(M, {
|
|
113
|
+
ref: h(u, L),
|
|
114
|
+
"aria-label": s,
|
|
115
|
+
className: R(F.tree, l),
|
|
116
|
+
data: n,
|
|
117
|
+
multiSelect: o,
|
|
118
|
+
nodeRenderer: V(f, m, g),
|
|
119
|
+
onExpand: d,
|
|
120
|
+
onSelect: w,
|
|
121
|
+
...r
|
|
123
122
|
})
|
|
124
123
|
});
|
|
125
|
-
}
|
|
124
|
+
});
|
|
126
125
|
export {
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
z as Tree,
|
|
127
|
+
z as default
|
|
129
128
|
};
|
package/dist/types/lib/tree.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TreeProps } from './types';
|
|
2
|
-
export declare
|
|
2
|
+
export declare const Tree: import('react').ForwardRefExoticComponent<TreeProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
3
3
|
export default Tree;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/tree",
|
|
3
|
-
"version": "0.50.
|
|
3
|
+
"version": "0.50.3",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@box/blueprint-web": "^7.11.0",
|
|
6
6
|
"@box/blueprint-web-assets": "^4.16.0",
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
"react-intl": "^6.4.2"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@box/blueprint-web": "^12.9.
|
|
15
|
-
"@box/blueprint-web-assets": "^4.
|
|
16
|
-
"@box/item-icon": "^0.9.
|
|
17
|
-
"@box/storybook-utils": "^0.13.
|
|
14
|
+
"@box/blueprint-web": "^12.9.5",
|
|
15
|
+
"@box/blueprint-web-assets": "^4.53.0",
|
|
16
|
+
"@box/item-icon": "^0.9.159",
|
|
17
|
+
"@box/storybook-utils": "^0.13.6",
|
|
18
18
|
"@faker-js/faker": "^8.4.1",
|
|
19
19
|
"react": "^18.3.0",
|
|
20
20
|
"react-dom": "^18.3.0",
|