@box/tree 0.45.0 → 0.45.2
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/components/content-node/content-node.js +127 -102
- package/dist/esm/lib/components/node-label/index.js +4 -0
- package/dist/esm/lib/components/node-label/node-label.js +34 -0
- package/dist/esm/lib/components/truncated-tooltip-text/truncated-tooltip-text.js +17 -16
- package/dist/esm/lib/tree.js +115 -108
- package/dist/styles/node-label.css +1 -0
- package/dist/types/lib/components/node-label/index.d.ts +1 -0
- package/dist/types/lib/components/node-label/node-label.d.ts +6 -0
- package/dist/types/lib/components/truncated-tooltip-text/truncated-tooltip-text.d.ts +2 -1
- package/dist/types/lib/hooks/useSelectionInheritance.d.ts +2 -2
- package/dist/types/lib/stories/shared.d.ts +1 -1
- package/dist/types/lib/types.d.ts +15 -5
- package/package.json +3 -3
|
@@ -1,135 +1,160 @@
|
|
|
1
|
-
import { LoadingIndicator as
|
|
2
|
-
import
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { useIntl as
|
|
5
|
-
import { CONTENT_NODE as
|
|
1
|
+
import { LoadingIndicator as G } from "@box/blueprint-web";
|
|
2
|
+
import d from "clsx";
|
|
3
|
+
import { useRef as m, useMemo as P } from "react";
|
|
4
|
+
import { useIntl as q } from "react-intl";
|
|
5
|
+
import { CONTENT_NODE as B, CONTENT_NODE_LOADING as F } from "../../constants.js";
|
|
6
6
|
import { s as e } from "../../../../chunks/nodes.module.js";
|
|
7
|
-
import
|
|
8
|
-
import { jsxs as
|
|
9
|
-
import { useIntersectionObserver as
|
|
10
|
-
import { Expander as
|
|
11
|
-
import { NodeItemIcon as
|
|
12
|
-
import { NodeAvatar as
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
import H from "./messages.js";
|
|
8
|
+
import { jsxs as p, jsx as t } from "react/jsx-runtime";
|
|
9
|
+
import { useIntersectionObserver as J } from "../../hooks/useIntersectionObserver.js";
|
|
10
|
+
import { Expander as K } from "../expander/expander.js";
|
|
11
|
+
import { NodeItemIcon as Q } from "../node-icon/node-item-icon.js";
|
|
12
|
+
import { NodeAvatar as U } from "../node-icon/node-avatar.js";
|
|
13
|
+
import { NodeLabel as L } from "../node-label/node-label.js";
|
|
14
|
+
import { TruncatedTooltipText as W } from "../truncated-tooltip-text/truncated-tooltip-text.js";
|
|
15
|
+
import '../../../../styles/content-node.css';const X = "_loader_1xxrm_1", Y = "_content_1xxrm_9", Z = "_title_1xxrm_15", z = "_subtitle_1xxrm_67", ee = "_tooltip_1xxrm_83", n = {
|
|
16
|
+
loader: X,
|
|
17
|
+
content: Y,
|
|
17
18
|
"title-wrapper": "_title-wrapper_1xxrm_15",
|
|
18
|
-
title:
|
|
19
|
+
title: Z,
|
|
19
20
|
"title--small": "_title--small_1xxrm_29",
|
|
20
21
|
"title--selected": "_title--selected_1xxrm_38",
|
|
21
22
|
"title--large": "_title--large_1xxrm_48",
|
|
22
|
-
subtitle:
|
|
23
|
-
tooltip:
|
|
23
|
+
subtitle: z,
|
|
24
|
+
tooltip: ee
|
|
24
25
|
};
|
|
25
|
-
function
|
|
26
|
+
function be({
|
|
26
27
|
element: {
|
|
27
|
-
name:
|
|
28
|
-
metadata:
|
|
28
|
+
name: c,
|
|
29
|
+
metadata: l
|
|
29
30
|
},
|
|
30
|
-
level:
|
|
31
|
-
getNodeProps:
|
|
32
|
-
handleSelect:
|
|
33
|
-
handleExpand:
|
|
34
|
-
isBranch:
|
|
35
|
-
isExpanded:
|
|
36
|
-
isDisabled:
|
|
37
|
-
isSelected:
|
|
31
|
+
level: u,
|
|
32
|
+
getNodeProps: x,
|
|
33
|
+
handleSelect: _,
|
|
34
|
+
handleExpand: R,
|
|
35
|
+
isBranch: y,
|
|
36
|
+
isExpanded: f,
|
|
37
|
+
isDisabled: a,
|
|
38
|
+
isSelected: N,
|
|
38
39
|
size: o,
|
|
39
|
-
withIcon:
|
|
40
|
-
containsSelection:
|
|
40
|
+
withIcon: v,
|
|
41
|
+
containsSelection: V
|
|
41
42
|
}) {
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
43
|
+
const k = q(), h = m(null), T = m(null), $ = m(null), b = m(null), {
|
|
44
|
+
isLoading: g = !1,
|
|
45
|
+
selectable: I = !0,
|
|
46
|
+
variant: r
|
|
47
|
+
} = l, {
|
|
48
|
+
labelName: w,
|
|
49
|
+
labelValue: D,
|
|
50
|
+
subtitle: i,
|
|
51
|
+
withDivider: O
|
|
52
|
+
} = r === "labeled" ? {
|
|
53
|
+
labelName: l.labelName,
|
|
54
|
+
labelValue: l.labelValue,
|
|
55
|
+
subtitle: void 0,
|
|
56
|
+
withDivider: !1
|
|
57
|
+
} : {
|
|
58
|
+
labelName: void 0,
|
|
59
|
+
labelValue: void 0,
|
|
60
|
+
subtitle: l.subtitle,
|
|
61
|
+
withDivider: l.withDivider || !1
|
|
62
|
+
}, s = P(() => x({
|
|
63
|
+
onClick: _
|
|
64
|
+
}), [x, _]), j = J(h), C = !a && !f && V, A = {
|
|
65
|
+
[`data-${B}`]: !0,
|
|
66
|
+
[`data-${F}`]: g
|
|
67
|
+
}, E = !!i || r === "labeled", M = /* @__PURE__ */ p("div", {
|
|
68
|
+
...s,
|
|
69
|
+
className: d("node", e.node, e[`node-${o}-level${u - 1}`], e[`node--${o}`], {
|
|
70
|
+
[e[`node--${o}-extraData`]]: E,
|
|
71
|
+
[e["node--focused"]]: s.className.includes("tree-node--focused"),
|
|
72
|
+
[e["node--selected"]]: N || C,
|
|
73
|
+
[e["node--disabled"]]: a,
|
|
60
74
|
[e["node--nonselectable"]]: !I,
|
|
61
|
-
"node--with-divider":
|
|
75
|
+
"node--with-divider": O
|
|
62
76
|
}),
|
|
63
|
-
"data-target-id":
|
|
64
|
-
children: [
|
|
65
|
-
className:
|
|
66
|
-
children:
|
|
67
|
-
"aria-label":
|
|
68
|
-
className:
|
|
77
|
+
"data-target-id": l == null ? void 0 : l.dataTargetId,
|
|
78
|
+
children: [y && /* @__PURE__ */ t("div", {
|
|
79
|
+
className: d(e.expander, e[`expander-level${u - 1}`], e[`expander-${o}`]),
|
|
80
|
+
children: g ? /* @__PURE__ */ t(G, {
|
|
81
|
+
"aria-label": k.formatMessage(H.branchContentLoaderLabel),
|
|
82
|
+
className: n.loader,
|
|
69
83
|
size: o === "small" ? "small" : "medium"
|
|
70
|
-
}) : /* @__PURE__ */
|
|
71
|
-
dataTargetId:
|
|
72
|
-
disabled:
|
|
73
|
-
expanded:
|
|
74
|
-
onClick:
|
|
84
|
+
}) : /* @__PURE__ */ t(K, {
|
|
85
|
+
dataTargetId: l != null && l.dataTargetId ? `${l.dataTargetId}:${f ? "collapse" : "expand"}` : void 0,
|
|
86
|
+
disabled: a,
|
|
87
|
+
expanded: f,
|
|
88
|
+
onClick: R,
|
|
75
89
|
size: o
|
|
76
90
|
})
|
|
77
|
-
}), /* @__PURE__ */
|
|
78
|
-
className:
|
|
79
|
-
children: [
|
|
80
|
-
iconType:
|
|
91
|
+
}), /* @__PURE__ */ p("div", {
|
|
92
|
+
className: d(n.content),
|
|
93
|
+
children: [v && r === "content" && /* @__PURE__ */ t(Q, {
|
|
94
|
+
iconType: l.iconType,
|
|
81
95
|
size: o
|
|
82
|
-
}),
|
|
83
|
-
avatarSrc:
|
|
84
|
-
badge:
|
|
85
|
-
nodeTitle:
|
|
96
|
+
}), v && r === "user" && /* @__PURE__ */ t(U, {
|
|
97
|
+
avatarSrc: l.avatarSrc,
|
|
98
|
+
badge: l.badge,
|
|
99
|
+
nodeTitle: c,
|
|
86
100
|
size: o
|
|
87
|
-
}), /* @__PURE__ */
|
|
88
|
-
className:
|
|
89
|
-
children: [/* @__PURE__ */
|
|
90
|
-
ref:
|
|
91
|
-
|
|
92
|
-
|
|
101
|
+
}), /* @__PURE__ */ p("div", {
|
|
102
|
+
className: n["title-wrapper"],
|
|
103
|
+
children: [r === "labeled" && /* @__PURE__ */ t(L, {
|
|
104
|
+
ref: b,
|
|
105
|
+
labelName: w,
|
|
106
|
+
labelValue: D
|
|
107
|
+
}), /* @__PURE__ */ t("span", {
|
|
108
|
+
ref: T,
|
|
109
|
+
className: d(n.title, n[`title--${o}`], {
|
|
110
|
+
[n["title--selected"]]: N || C
|
|
93
111
|
}),
|
|
112
|
+
children: c
|
|
113
|
+
}), i && /* @__PURE__ */ t("span", {
|
|
114
|
+
ref: $,
|
|
115
|
+
className: n.subtitle,
|
|
94
116
|
children: i
|
|
95
|
-
}), r && /* @__PURE__ */ n("span", {
|
|
96
|
-
ref: b,
|
|
97
|
-
className: l.subtitle,
|
|
98
|
-
children: r
|
|
99
117
|
})]
|
|
100
118
|
})]
|
|
101
119
|
})]
|
|
102
|
-
}),
|
|
103
|
-
...
|
|
104
|
-
className:
|
|
105
|
-
[e[`node--${o}-extraData`]]:
|
|
106
|
-
[e["node--focused"]]:
|
|
107
|
-
[e["node--selected"]]:
|
|
108
|
-
[e["node--disabled"]]:
|
|
120
|
+
}), S = /* @__PURE__ */ t("div", {
|
|
121
|
+
...s,
|
|
122
|
+
className: d("node", e.node, e[`node-${o}-level${u - 1}`], e[`node--${o}`], {
|
|
123
|
+
[e[`node--${o}-extraData`]]: E,
|
|
124
|
+
[e["node--focused"]]: s.className.includes("tree-node--focused"),
|
|
125
|
+
[e["node--selected"]]: s.className.includes("tree-node--selected"),
|
|
126
|
+
[e["node--disabled"]]: a,
|
|
109
127
|
[e["node--nonselectable"]]: !I,
|
|
110
|
-
"node--with-divider":
|
|
128
|
+
"node--with-divider": O
|
|
111
129
|
}),
|
|
112
|
-
"data-target-id":
|
|
113
|
-
children:
|
|
130
|
+
"data-target-id": l == null ? void 0 : l.dataTargetId,
|
|
131
|
+
children: c
|
|
114
132
|
});
|
|
115
|
-
return /* @__PURE__ */
|
|
116
|
-
ref:
|
|
117
|
-
...
|
|
118
|
-
children:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
133
|
+
return /* @__PURE__ */ t("div", {
|
|
134
|
+
ref: h,
|
|
135
|
+
...A,
|
|
136
|
+
children: j ? S : /* @__PURE__ */ t(W, {
|
|
137
|
+
labelElementRef: b,
|
|
138
|
+
subtitleElementRef: $,
|
|
139
|
+
textElementRef: T,
|
|
140
|
+
tooltipContent: /* @__PURE__ */ p("div", {
|
|
141
|
+
className: n.tooltip,
|
|
142
|
+
children: [r === "labeled" && /* @__PURE__ */ t(L, {
|
|
143
|
+
ref: b,
|
|
144
|
+
color: "textOnDarkDefault",
|
|
145
|
+
isInTooltip: !0,
|
|
146
|
+
labelName: w,
|
|
147
|
+
labelValue: D
|
|
148
|
+
}), /* @__PURE__ */ t("span", {
|
|
149
|
+
children: c
|
|
150
|
+
}), i && /* @__PURE__ */ t("span", {
|
|
124
151
|
children: i
|
|
125
|
-
}), r && /* @__PURE__ */ n("span", {
|
|
126
|
-
children: r
|
|
127
152
|
})]
|
|
128
153
|
}),
|
|
129
|
-
children:
|
|
154
|
+
children: M
|
|
130
155
|
})
|
|
131
156
|
});
|
|
132
157
|
}
|
|
133
158
|
export {
|
|
134
|
-
|
|
159
|
+
be as ContentNode
|
|
135
160
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Text as l } from "@box/blueprint-web";
|
|
2
|
+
import i from "clsx";
|
|
3
|
+
import { forwardRef as p } from "react";
|
|
4
|
+
import { jsxs as c, jsx as a } from "react/jsx-runtime";
|
|
5
|
+
import '../../../../styles/node-label.css';const m = "_label_km4kd_1", b = {
|
|
6
|
+
label: m
|
|
7
|
+
}, v = /* @__PURE__ */ p((o, r) => {
|
|
8
|
+
const {
|
|
9
|
+
color: e = "textOnLightSecondary",
|
|
10
|
+
isInTooltip: s = !1,
|
|
11
|
+
labelName: t,
|
|
12
|
+
labelValue: n
|
|
13
|
+
} = o;
|
|
14
|
+
return /* @__PURE__ */ c("div", {
|
|
15
|
+
ref: r,
|
|
16
|
+
className: i({
|
|
17
|
+
[b.label]: !s
|
|
18
|
+
}),
|
|
19
|
+
children: [/* @__PURE__ */ a(l, {
|
|
20
|
+
as: "span",
|
|
21
|
+
color: e,
|
|
22
|
+
variant: "labelBold",
|
|
23
|
+
children: t.toUpperCase()
|
|
24
|
+
}), /* @__PURE__ */ a(l, {
|
|
25
|
+
as: "span",
|
|
26
|
+
color: e,
|
|
27
|
+
variant: "label",
|
|
28
|
+
children: ` / ${n.toUpperCase()}`
|
|
29
|
+
})]
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
export {
|
|
33
|
+
v as NodeLabel
|
|
34
|
+
};
|
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import { Tooltip as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { jsx as
|
|
4
|
-
function
|
|
1
|
+
import { Tooltip as a } from "@box/blueprint-web";
|
|
2
|
+
import { useState as f, useLayoutEffect as T } from "react";
|
|
3
|
+
import { jsx as p } from "react/jsx-runtime";
|
|
4
|
+
function h({
|
|
5
|
+
labelElementRef: o,
|
|
5
6
|
textElementRef: e,
|
|
6
|
-
subtitleElementRef:
|
|
7
|
-
tooltipContent:
|
|
8
|
-
children:
|
|
7
|
+
subtitleElementRef: n,
|
|
8
|
+
tooltipContent: c,
|
|
9
|
+
children: s
|
|
9
10
|
}) {
|
|
10
|
-
const [
|
|
11
|
-
return
|
|
11
|
+
const [i, u] = f(!1);
|
|
12
|
+
return T(() => {
|
|
12
13
|
const t = () => {
|
|
13
|
-
const
|
|
14
|
-
|
|
14
|
+
const d = [e.current, n.current, o.current].some((r) => r && r.scrollWidth > r.offsetWidth);
|
|
15
|
+
u(d);
|
|
15
16
|
};
|
|
16
17
|
return t(), window.addEventListener("resize", t), () => {
|
|
17
18
|
window.removeEventListener("resize", t);
|
|
18
19
|
};
|
|
19
|
-
}, [e, o]),
|
|
20
|
-
content:
|
|
21
|
-
children:
|
|
22
|
-
}) :
|
|
20
|
+
}, [e, n, o]), i ? /* @__PURE__ */ p(a, {
|
|
21
|
+
content: c,
|
|
22
|
+
children: s
|
|
23
|
+
}) : s;
|
|
23
24
|
}
|
|
24
25
|
export {
|
|
25
|
-
|
|
26
|
+
h as TruncatedTooltipText
|
|
26
27
|
};
|
package/dist/esm/lib/tree.js
CHANGED
|
@@ -1,122 +1,129 @@
|
|
|
1
|
-
import { TooltipProvider as
|
|
2
|
-
import
|
|
3
|
-
import { useRef as h, useEffect as
|
|
1
|
+
import { TooltipProvider as g } from "@box/blueprint-web";
|
|
2
|
+
import b from "clsx";
|
|
3
|
+
import { useRef as h, useEffect as u, useCallback as w } from "react";
|
|
4
4
|
import S from "react-accessible-treeview";
|
|
5
|
-
import { preventDisabledNodeExpanding as
|
|
5
|
+
import { preventDisabledNodeExpanding as E, preventLoadingContentNodeExpanding as y, serviceNodeKeyboardHandler as x, serviceNodeClickHandler as C } from "./utils.js";
|
|
6
6
|
import { jsx as t } from "react/jsx-runtime";
|
|
7
|
-
import { useSelectionInheritance as
|
|
7
|
+
import { useSelectionInheritance as R } from "./hooks/useSelectionInheritance.js";
|
|
8
8
|
import { ContentNode as M } from "./components/content-node/content-node.js";
|
|
9
|
-
import { ServiceNodeWrapper as
|
|
10
|
-
import { LoadMoreNode as
|
|
11
|
-
import { ReloadNode as
|
|
12
|
-
import { LoadingNode as
|
|
13
|
-
import '../../styles/tree.css';const
|
|
14
|
-
tree:
|
|
9
|
+
import { ServiceNodeWrapper as v } from "./components/service-node-wrapper/service-node-wrapper.js";
|
|
10
|
+
import { LoadMoreNode as H } from "./components/load-more-node/load-more-node.js";
|
|
11
|
+
import { ReloadNode as T } from "./components/reload-node/reload-node.js";
|
|
12
|
+
import { LoadingNode as _ } from "./components/loading-node/loading-node.js";
|
|
13
|
+
import '../../styles/tree.css';const K = "_tree_17956_1", P = {
|
|
14
|
+
tree: K
|
|
15
|
+
}, j = (d, s, a) => (o) => {
|
|
16
|
+
const {
|
|
17
|
+
element: m,
|
|
18
|
+
isDisabled: i
|
|
19
|
+
} = o, {
|
|
20
|
+
id: c,
|
|
21
|
+
metadata: f,
|
|
22
|
+
parent: l
|
|
23
|
+
} = m, {
|
|
24
|
+
variant: n
|
|
25
|
+
} = f;
|
|
26
|
+
if (n === "content" || n === "user" || n === "labeled") {
|
|
27
|
+
const r = {
|
|
28
|
+
...o,
|
|
29
|
+
size: d,
|
|
30
|
+
withIcon: s
|
|
31
|
+
};
|
|
32
|
+
return /* @__PURE__ */ t(M, {
|
|
33
|
+
...r,
|
|
34
|
+
containsSelection: a.includes(c)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (n === "loadMore") {
|
|
38
|
+
const r = {
|
|
39
|
+
...o,
|
|
40
|
+
size: d
|
|
41
|
+
};
|
|
42
|
+
return /* @__PURE__ */ t(v, {
|
|
43
|
+
isDisabled: i,
|
|
44
|
+
parentId: l,
|
|
45
|
+
variant: "loadMore",
|
|
46
|
+
children: /* @__PURE__ */ t(H, {
|
|
47
|
+
...r
|
|
48
|
+
})
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (n === "reload") {
|
|
52
|
+
const r = {
|
|
53
|
+
...o,
|
|
54
|
+
size: d
|
|
55
|
+
};
|
|
56
|
+
return /* @__PURE__ */ t(v, {
|
|
57
|
+
isDisabled: i,
|
|
58
|
+
parentId: l,
|
|
59
|
+
variant: "reload",
|
|
60
|
+
children: /* @__PURE__ */ t(T, {
|
|
61
|
+
...r
|
|
62
|
+
})
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (n === "loading") {
|
|
66
|
+
const r = {
|
|
67
|
+
...o,
|
|
68
|
+
size: d
|
|
69
|
+
};
|
|
70
|
+
return /* @__PURE__ */ t(v, {
|
|
71
|
+
isDisabled: i,
|
|
72
|
+
variant: "loading",
|
|
73
|
+
children: /* @__PURE__ */ t(_, {
|
|
74
|
+
...r
|
|
75
|
+
})
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
return null;
|
|
15
79
|
};
|
|
16
|
-
function
|
|
17
|
-
"aria-label":
|
|
18
|
-
size:
|
|
19
|
-
data:
|
|
20
|
-
withIcons:
|
|
21
|
-
onExpand:
|
|
22
|
-
onSelect:
|
|
23
|
-
onLoadData:
|
|
24
|
-
className:
|
|
25
|
-
multiSelect:
|
|
26
|
-
...
|
|
80
|
+
function X({
|
|
81
|
+
"aria-label": d,
|
|
82
|
+
size: s = "small",
|
|
83
|
+
data: a,
|
|
84
|
+
withIcons: o = !1,
|
|
85
|
+
onExpand: m,
|
|
86
|
+
onSelect: i,
|
|
87
|
+
onLoadData: c,
|
|
88
|
+
className: f,
|
|
89
|
+
multiSelect: l = !1,
|
|
90
|
+
...n
|
|
27
91
|
}) {
|
|
28
|
-
const
|
|
29
|
-
selectionInheritors:
|
|
30
|
-
getSelectionInheritors:
|
|
31
|
-
} =
|
|
32
|
-
|
|
33
|
-
const e =
|
|
34
|
-
return e && (e.addEventListener("keydown",
|
|
35
|
-
e && (e.removeEventListener("keydown",
|
|
92
|
+
const r = h(null), {
|
|
93
|
+
selectionInheritors: I,
|
|
94
|
+
getSelectionInheritors: p
|
|
95
|
+
} = R();
|
|
96
|
+
u(() => {
|
|
97
|
+
const e = r.current;
|
|
98
|
+
return e && (e.addEventListener("keydown", E), e.addEventListener("keydown", y)), () => {
|
|
99
|
+
e && (e.removeEventListener("keydown", E), e.removeEventListener("keydown", y));
|
|
36
100
|
};
|
|
37
|
-
}),
|
|
38
|
-
const e =
|
|
39
|
-
return e && (e.addEventListener("keydown",
|
|
40
|
-
e && (e.removeEventListener("keydown",
|
|
101
|
+
}), u(() => {
|
|
102
|
+
const e = r.current, N = x(c), k = C(c);
|
|
103
|
+
return e && (e.addEventListener("keydown", N), e.addEventListener("click", k)), () => {
|
|
104
|
+
e && (e.removeEventListener("keydown", N), e.removeEventListener("click", k));
|
|
41
105
|
};
|
|
42
|
-
}),
|
|
43
|
-
|
|
106
|
+
}), u(() => {
|
|
107
|
+
p(a, n.selectedIds || n.defaultSelectedIds);
|
|
44
108
|
}, []);
|
|
45
|
-
const
|
|
46
|
-
|
|
47
|
-
}, [
|
|
48
|
-
return /* @__PURE__ */ t(
|
|
109
|
+
const L = w((e) => {
|
|
110
|
+
p(a, Array.from(e.treeState.selectedIds)), i && i(e);
|
|
111
|
+
}, [i, a, p]);
|
|
112
|
+
return /* @__PURE__ */ t(g, {
|
|
49
113
|
children: /* @__PURE__ */ t(S, {
|
|
50
|
-
ref:
|
|
51
|
-
"aria-label":
|
|
52
|
-
className:
|
|
53
|
-
data:
|
|
54
|
-
multiSelect:
|
|
55
|
-
nodeRenderer: (
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (n === "content" || n === "user") {
|
|
60
|
-
const r = {
|
|
61
|
-
...e,
|
|
62
|
-
size: o,
|
|
63
|
-
withIcon: b
|
|
64
|
-
};
|
|
65
|
-
return /* @__PURE__ */ t(M, {
|
|
66
|
-
...r,
|
|
67
|
-
containsSelection: y.includes(e.element.id)
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
if (n === "loadMore") {
|
|
71
|
-
const r = {
|
|
72
|
-
...e,
|
|
73
|
-
size: o
|
|
74
|
-
};
|
|
75
|
-
return /* @__PURE__ */ t(m, {
|
|
76
|
-
isDisabled: e.isDisabled,
|
|
77
|
-
parentId: e.element.parent,
|
|
78
|
-
variant: "loadMore",
|
|
79
|
-
children: /* @__PURE__ */ t(R, {
|
|
80
|
-
...r
|
|
81
|
-
})
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
if (n === "reload") {
|
|
85
|
-
const r = {
|
|
86
|
-
...e,
|
|
87
|
-
size: o
|
|
88
|
-
};
|
|
89
|
-
return /* @__PURE__ */ t(m, {
|
|
90
|
-
isDisabled: e.isDisabled,
|
|
91
|
-
parentId: e.element.parent,
|
|
92
|
-
variant: "reload",
|
|
93
|
-
children: /* @__PURE__ */ t(H, {
|
|
94
|
-
...r
|
|
95
|
-
})
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
if (n === "loading") {
|
|
99
|
-
const r = {
|
|
100
|
-
...e,
|
|
101
|
-
size: o
|
|
102
|
-
};
|
|
103
|
-
return /* @__PURE__ */ t(m, {
|
|
104
|
-
isDisabled: e.isDisabled,
|
|
105
|
-
variant: "loading",
|
|
106
|
-
children: /* @__PURE__ */ t(T, {
|
|
107
|
-
...r
|
|
108
|
-
})
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
return null;
|
|
112
|
-
},
|
|
113
|
-
onExpand: N,
|
|
114
|
-
onSelect: I,
|
|
115
|
-
...a
|
|
114
|
+
ref: r,
|
|
115
|
+
"aria-label": d,
|
|
116
|
+
className: b(P.tree, f),
|
|
117
|
+
data: a,
|
|
118
|
+
multiSelect: l,
|
|
119
|
+
nodeRenderer: j(s, o, I),
|
|
120
|
+
onExpand: m,
|
|
121
|
+
onSelect: L,
|
|
122
|
+
...n
|
|
116
123
|
})
|
|
117
124
|
});
|
|
118
125
|
}
|
|
119
126
|
export {
|
|
120
|
-
|
|
121
|
-
|
|
127
|
+
X as Tree,
|
|
128
|
+
X as default
|
|
122
129
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._label_km4kd_1{margin-bottom:.125rem;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-weight:400;font-size:.625rem;font-family:Lato,-apple-system,BlinkMacSystemFont,San Francisco,Segoe UI,Roboto,Helvetica Neue,sans-serif;line-height:1rem;letter-spacing:.0375rem;text-transform:none;text-decoration:none}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { NodeLabel } from './node-label';
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { TextProps } from '@box/blueprint-web';
|
|
2
|
+
export declare const NodeLabel: import('react').ForwardRefExoticComponent<Pick<TextProps, "color"> & {
|
|
3
|
+
isInTooltip?: boolean;
|
|
4
|
+
labelName: string;
|
|
5
|
+
labelValue: string;
|
|
6
|
+
} & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
type TruncatedTooltipTextProps = {
|
|
2
|
+
labelElementRef: React.MutableRefObject<HTMLElement>;
|
|
2
3
|
textElementRef: React.MutableRefObject<HTMLElement>;
|
|
3
4
|
subtitleElementRef: React.MutableRefObject<HTMLElement>;
|
|
4
5
|
tooltipContent: string | React.ReactNode;
|
|
5
6
|
children: React.ReactElement;
|
|
6
7
|
};
|
|
7
|
-
export declare function TruncatedTooltipText({ textElementRef, subtitleElementRef, tooltipContent, children, }: TruncatedTooltipTextProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function TruncatedTooltipText({ labelElementRef, textElementRef, subtitleElementRef, tooltipContent, children, }: TruncatedTooltipTextProps): import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NodeId } from 'react-accessible-treeview';
|
|
2
|
-
import { ContentNode, LoadMoreNode, LoadingNode, Node, ReloadNode } from '../types';
|
|
2
|
+
import { ContentNode, LoadMoreNode, LoadingNode, Node, LabeledNode, ReloadNode } from '../types';
|
|
3
3
|
export declare const useSelectionInheritance: () => {
|
|
4
4
|
selectionInheritors: NodeId[];
|
|
5
|
-
getSelectionInheritors: (data: (Node | ContentNode | LoadMoreNode | LoadingNode | ReloadNode)[], selectedIds?: (string | NodeId)[]) => void;
|
|
5
|
+
getSelectionInheritors: (data: (Node | ContentNode | LabeledNode | LoadMoreNode | LoadingNode | ReloadNode)[], selectedIds?: (string | NodeId)[]) => void;
|
|
6
6
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentRecord } from '@box/storybook-utils';
|
|
2
|
-
import { ContentNode,
|
|
2
|
+
import { ContentNode, LoadMoreNode, LoadingNode, ReloadNode, TreeProps } from '../types';
|
|
3
3
|
declare const rootNode: ContentNode;
|
|
4
4
|
declare const dataWithContentNodes: ContentNode[];
|
|
5
5
|
declare const dataWithContentNodeWithTitle: ContentNode[];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { itemIconTable } from '@box/item-icon';
|
|
2
2
|
import { INode, INodeRendererProps, ITreeViewOnSelectProps, ITreeViewProps, NodeId } from 'react-accessible-treeview';
|
|
3
3
|
type Size = 'small' | 'large';
|
|
4
|
-
type NodeVariant = 'user' | 'content' | 'loadMore' | 'loading' | 'reload';
|
|
4
|
+
type NodeVariant = 'user' | 'content' | 'labeled' | 'loadMore' | 'loading' | 'reload';
|
|
5
5
|
type Badge = 'admin' | 'coadmin';
|
|
6
6
|
type IconType = keyof typeof itemIconTable | 'trash';
|
|
7
7
|
interface Node extends INode {
|
|
@@ -32,6 +32,16 @@ interface ContentNode extends INode {
|
|
|
32
32
|
selectable?: boolean;
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
|
+
interface LabeledNode extends INode {
|
|
36
|
+
metadata: {
|
|
37
|
+
variant: 'labeled';
|
|
38
|
+
dataTargetId?: string;
|
|
39
|
+
isLoading?: boolean;
|
|
40
|
+
labelName: string;
|
|
41
|
+
labelValue: string;
|
|
42
|
+
selectable?: boolean;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
35
45
|
interface LoadMoreNode extends INode {
|
|
36
46
|
metadata: {
|
|
37
47
|
variant: 'loadMore';
|
|
@@ -50,7 +60,7 @@ interface LoadingNode extends INode {
|
|
|
50
60
|
}
|
|
51
61
|
interface TreeProps extends Omit<ITreeViewProps, 'nodeRenderer' | 'propagateSelectUpwards' | 'onLoadData'> {
|
|
52
62
|
'aria-label': string;
|
|
53
|
-
data: (Node | UserNode | ContentNode | LoadMoreNode | LoadingNode | ReloadNode)[];
|
|
63
|
+
data: (Node | UserNode | ContentNode | LabeledNode | LoadMoreNode | LoadingNode | ReloadNode)[];
|
|
54
64
|
size?: Size;
|
|
55
65
|
withIcons?: boolean;
|
|
56
66
|
onLoadData?: (id: NodeId) => void;
|
|
@@ -58,10 +68,10 @@ interface TreeProps extends Omit<ITreeViewProps, 'nodeRenderer' | 'propagateSele
|
|
|
58
68
|
interface NodeProps extends INodeRendererProps {
|
|
59
69
|
size: Size;
|
|
60
70
|
withIcon: boolean;
|
|
61
|
-
element: Node | UserNode | ContentNode | LoadMoreNode | LoadingNode | ReloadNode;
|
|
71
|
+
element: Node | UserNode | ContentNode | LabeledNode | LoadMoreNode | LoadingNode | ReloadNode;
|
|
62
72
|
}
|
|
63
73
|
interface ContentNodeProps extends NodeProps {
|
|
64
|
-
element: ContentNode | UserNode;
|
|
74
|
+
element: ContentNode | LabeledNode | UserNode;
|
|
65
75
|
containsSelection: boolean;
|
|
66
76
|
}
|
|
67
77
|
interface LoadMoreNodeProps extends NodeProps {
|
|
@@ -73,4 +83,4 @@ interface ReloadNodeProps extends NodeProps {
|
|
|
73
83
|
interface LoadingNodeProps extends NodeProps {
|
|
74
84
|
element: LoadingNode;
|
|
75
85
|
}
|
|
76
|
-
export { ContentNode, ContentNodeProps, LoadingNode, LoadingNodeProps, LoadMoreNode, LoadMoreNodeProps, Node, NodeProps, ReloadNode, ReloadNodeProps, UserNode, type Badge, type IconType, type INode, type ITreeViewOnSelectProps, type NodeId, type NodeVariant, type Size, type TreeProps, };
|
|
86
|
+
export { ContentNode, ContentNodeProps, LoadingNode, LoadingNodeProps, LoadMoreNode, LoadMoreNodeProps, Node, NodeProps, LabeledNode, ReloadNode, ReloadNodeProps, UserNode, type Badge, type IconType, type INode, type ITreeViewOnSelectProps, type NodeId, type NodeVariant, type Size, type TreeProps, };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/tree",
|
|
3
|
-
"version": "0.45.
|
|
3
|
+
"version": "0.45.2",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@box/blueprint-web": "^7.11.0",
|
|
6
6
|
"@box/blueprint-web-assets": "^4.16.0",
|
|
@@ -11,9 +11,9 @@
|
|
|
11
11
|
"react-intl": "^6.4.2"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@box/blueprint-web": "^11.
|
|
14
|
+
"@box/blueprint-web": "^11.9.0",
|
|
15
15
|
"@box/blueprint-web-assets": "^4.41.1",
|
|
16
|
-
"@box/item-icon": "^0.9.
|
|
16
|
+
"@box/item-icon": "^0.9.131",
|
|
17
17
|
"@box/storybook-utils": "^0.12.0",
|
|
18
18
|
"@faker-js/faker": "^8.4.1",
|
|
19
19
|
"react": "^18.3.0",
|