@box/tree 0.46.0 → 0.47.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/dist/chunks/expander-with-loading.js +42 -0
- package/dist/esm/lib/components/content-node/content-node.js +103 -126
- package/dist/esm/lib/components/content-node/expander-with-loading.js +9 -0
- package/dist/esm/lib/components/content-node/variant-icon.js +24 -0
- package/dist/types/lib/components/content-node/expander-with-loading.d.ts +7 -0
- package/dist/types/lib/components/content-node/variant-icon.d.ts +7 -0
- package/dist/types/lib/stories/shared.d.ts +3 -2
- package/package.json +1 -1
- /package/dist/styles/{content-node.css → expander-with-loading.css} +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useIntl as a } from "react-intl";
|
|
2
|
+
import { LoadingIndicator as _ } from "@box/blueprint-web";
|
|
3
|
+
import m from "../esm/lib/components/content-node/messages.js";
|
|
4
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
5
|
+
import { Expander as x } from "../esm/lib/components/expander/expander.js";
|
|
6
|
+
import '../styles/expander-with-loading.css';const c = "_loader_1xxrm_1", d = "_content_1xxrm_9", p = "_title_1xxrm_15", g = "_subtitle_1xxrm_67", b = "_tooltip_1xxrm_83", f = {
|
|
7
|
+
loader: c,
|
|
8
|
+
content: d,
|
|
9
|
+
"title-wrapper": "_title-wrapper_1xxrm_15",
|
|
10
|
+
title: p,
|
|
11
|
+
"title--small": "_title--small_1xxrm_29",
|
|
12
|
+
"title--selected": "_title--selected_1xxrm_38",
|
|
13
|
+
"title--large": "_title--large_1xxrm_48",
|
|
14
|
+
subtitle: g,
|
|
15
|
+
tooltip: b
|
|
16
|
+
}, w = ({
|
|
17
|
+
metadata: t,
|
|
18
|
+
handleExpand: o,
|
|
19
|
+
isDisabled: i,
|
|
20
|
+
isExpanded: e,
|
|
21
|
+
isLoading: n,
|
|
22
|
+
size: l
|
|
23
|
+
}) => {
|
|
24
|
+
const s = a();
|
|
25
|
+
return n ? /* @__PURE__ */ r(_, {
|
|
26
|
+
"aria-label": s.formatMessage(m.branchContentLoaderLabel),
|
|
27
|
+
className: f.loader,
|
|
28
|
+
size: l === "small" ? "small" : "medium"
|
|
29
|
+
}) : /* @__PURE__ */ r(x, {
|
|
30
|
+
...(t == null ? void 0 : t.dataTargetId) && {
|
|
31
|
+
dataTargetId: `${t.dataTargetId}:${e ? "collapse" : "expand"}`
|
|
32
|
+
},
|
|
33
|
+
disabled: i,
|
|
34
|
+
expanded: e,
|
|
35
|
+
onClick: o,
|
|
36
|
+
size: l
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
w as E,
|
|
41
|
+
f as c
|
|
42
|
+
};
|
|
@@ -1,160 +1,137 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { s as
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
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,
|
|
18
|
-
"title-wrapper": "_title-wrapper_1xxrm_15",
|
|
19
|
-
title: Z,
|
|
20
|
-
"title--small": "_title--small_1xxrm_29",
|
|
21
|
-
"title--selected": "_title--selected_1xxrm_38",
|
|
22
|
-
"title--large": "_title--large_1xxrm_48",
|
|
23
|
-
subtitle: z,
|
|
24
|
-
tooltip: ee
|
|
25
|
-
};
|
|
26
|
-
function be({
|
|
1
|
+
import r from "clsx";
|
|
2
|
+
import { useRef as a, useMemo as P } from "react";
|
|
3
|
+
import { CONTENT_NODE as W, CONTENT_NODE_LOADING as q } from "../../constants.js";
|
|
4
|
+
import { E as B, c as n } from "../../../../chunks/expander-with-loading.js";
|
|
5
|
+
import { VariantIcon as F } from "./variant-icon.js";
|
|
6
|
+
import { s as l } from "../../../../chunks/nodes.module.js";
|
|
7
|
+
import { jsxs as u, jsx as o } from "react/jsx-runtime";
|
|
8
|
+
import { useIntersectionObserver as H } from "../../hooks/useIntersectionObserver.js";
|
|
9
|
+
import { NodeLabel as R } from "../node-label/node-label.js";
|
|
10
|
+
import { TruncatedTooltipText as J } from "../truncated-tooltip-text/truncated-tooltip-text.js";
|
|
11
|
+
function oe({
|
|
27
12
|
element: {
|
|
28
|
-
name:
|
|
29
|
-
metadata:
|
|
13
|
+
name: i,
|
|
14
|
+
metadata: e
|
|
30
15
|
},
|
|
31
|
-
level:
|
|
32
|
-
getNodeProps:
|
|
33
|
-
handleSelect:
|
|
34
|
-
handleExpand:
|
|
35
|
-
isBranch:
|
|
36
|
-
isExpanded:
|
|
37
|
-
isDisabled:
|
|
38
|
-
isSelected:
|
|
39
|
-
size:
|
|
40
|
-
withIcon:
|
|
41
|
-
containsSelection:
|
|
16
|
+
level: p,
|
|
17
|
+
getNodeProps: b,
|
|
18
|
+
handleSelect: m,
|
|
19
|
+
handleExpand: h,
|
|
20
|
+
isBranch: V,
|
|
21
|
+
isExpanded: v,
|
|
22
|
+
isDisabled: f,
|
|
23
|
+
isSelected: x,
|
|
24
|
+
size: t,
|
|
25
|
+
withIcon: L,
|
|
26
|
+
containsSelection: k
|
|
42
27
|
}) {
|
|
43
|
-
const
|
|
44
|
-
isLoading:
|
|
45
|
-
selectable:
|
|
46
|
-
variant:
|
|
47
|
-
} =
|
|
28
|
+
const T = a(null), D = a(null), $ = a(null), N = a(null), {
|
|
29
|
+
isLoading: E = !1,
|
|
30
|
+
selectable: O = !0,
|
|
31
|
+
variant: c
|
|
32
|
+
} = e, {
|
|
48
33
|
labelName: w,
|
|
49
|
-
labelValue:
|
|
50
|
-
subtitle:
|
|
51
|
-
withDivider:
|
|
52
|
-
} =
|
|
53
|
-
labelName:
|
|
54
|
-
labelValue:
|
|
34
|
+
labelValue: I,
|
|
35
|
+
subtitle: s,
|
|
36
|
+
withDivider: _
|
|
37
|
+
} = c === "labeled" ? {
|
|
38
|
+
labelName: e.labelName,
|
|
39
|
+
labelValue: e.labelValue,
|
|
55
40
|
subtitle: void 0,
|
|
56
41
|
withDivider: !1
|
|
57
42
|
} : {
|
|
58
43
|
labelName: void 0,
|
|
59
44
|
labelValue: void 0,
|
|
60
|
-
subtitle:
|
|
61
|
-
withDivider:
|
|
62
|
-
},
|
|
63
|
-
onClick:
|
|
64
|
-
}), [
|
|
65
|
-
[`data-${
|
|
66
|
-
[`data-${
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
45
|
+
subtitle: e.subtitle,
|
|
46
|
+
withDivider: e.withDivider ?? !1
|
|
47
|
+
}, d = P(() => b({
|
|
48
|
+
onClick: m
|
|
49
|
+
}), [b, m]), j = H(T), C = !f && !v && k, y = {
|
|
50
|
+
[`data-${W}`]: !0,
|
|
51
|
+
[`data-${q}`]: E
|
|
52
|
+
}, A = !!s || c === "labeled", g = ["node", l.node, l[`node-${t}-level${p - 1}`], l[`node--${t}`], {
|
|
53
|
+
[l[`node--${t}-extraData`]]: A,
|
|
54
|
+
[l["node--focused"]]: d.className.includes("tree-node--focused"),
|
|
55
|
+
[l["node--disabled"]]: f,
|
|
56
|
+
[l["node--nonselectable"]]: !O,
|
|
57
|
+
"node--with-divider": _
|
|
58
|
+
}], G = /* @__PURE__ */ u("div", {
|
|
59
|
+
...d,
|
|
60
|
+
className: r(g, {
|
|
61
|
+
[l["node--selected"]]: x || C
|
|
76
62
|
}),
|
|
77
|
-
"data-target-id":
|
|
78
|
-
children: [
|
|
79
|
-
className:
|
|
80
|
-
children:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
expanded: f,
|
|
88
|
-
onClick: R,
|
|
89
|
-
size: o
|
|
63
|
+
"data-target-id": e == null ? void 0 : e.dataTargetId,
|
|
64
|
+
children: [V && /* @__PURE__ */ o("div", {
|
|
65
|
+
className: r(l.expander, l[`expander-level${p - 1}`], l[`expander-${t}`]),
|
|
66
|
+
children: /* @__PURE__ */ o(B, {
|
|
67
|
+
handleExpand: h,
|
|
68
|
+
isDisabled: f,
|
|
69
|
+
isExpanded: v,
|
|
70
|
+
isLoading: E,
|
|
71
|
+
metadata: e,
|
|
72
|
+
size: t
|
|
90
73
|
})
|
|
91
|
-
}), /* @__PURE__ */
|
|
92
|
-
className:
|
|
93
|
-
children: [
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
badge: l.badge,
|
|
99
|
-
nodeTitle: c,
|
|
100
|
-
size: o
|
|
101
|
-
}), /* @__PURE__ */ p("div", {
|
|
74
|
+
}), /* @__PURE__ */ u("div", {
|
|
75
|
+
className: r(n.content),
|
|
76
|
+
children: [L && /* @__PURE__ */ o(F, {
|
|
77
|
+
metadata: e,
|
|
78
|
+
name: i,
|
|
79
|
+
size: t
|
|
80
|
+
}), /* @__PURE__ */ u("div", {
|
|
102
81
|
className: n["title-wrapper"],
|
|
103
|
-
|
|
104
|
-
|
|
82
|
+
...!O && {
|
|
83
|
+
onClick: h
|
|
84
|
+
},
|
|
85
|
+
children: [c === "labeled" && /* @__PURE__ */ o(R, {
|
|
86
|
+
ref: N,
|
|
105
87
|
labelName: w,
|
|
106
|
-
labelValue:
|
|
107
|
-
}), /* @__PURE__ */
|
|
108
|
-
ref:
|
|
109
|
-
className:
|
|
110
|
-
[n["title--selected"]]:
|
|
88
|
+
labelValue: I
|
|
89
|
+
}), /* @__PURE__ */ o("span", {
|
|
90
|
+
ref: D,
|
|
91
|
+
className: r(n.title, n[`title--${t}`], {
|
|
92
|
+
[n["title--selected"]]: x || C
|
|
111
93
|
}),
|
|
112
|
-
children:
|
|
113
|
-
}),
|
|
94
|
+
children: i
|
|
95
|
+
}), s && /* @__PURE__ */ o("span", {
|
|
114
96
|
ref: $,
|
|
115
97
|
className: n.subtitle,
|
|
116
|
-
children:
|
|
98
|
+
children: s
|
|
117
99
|
})]
|
|
118
100
|
})]
|
|
119
101
|
})]
|
|
120
|
-
}),
|
|
121
|
-
...
|
|
122
|
-
className:
|
|
123
|
-
[
|
|
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,
|
|
127
|
-
[e["node--nonselectable"]]: !I,
|
|
128
|
-
"node--with-divider": O
|
|
102
|
+
}), M = /* @__PURE__ */ o("div", {
|
|
103
|
+
...d,
|
|
104
|
+
className: r(g, {
|
|
105
|
+
[l["node--selected"]]: d.className.includes("tree-node--selected")
|
|
129
106
|
}),
|
|
130
|
-
"data-target-id":
|
|
131
|
-
children:
|
|
107
|
+
"data-target-id": e == null ? void 0 : e.dataTargetId,
|
|
108
|
+
children: i
|
|
132
109
|
});
|
|
133
|
-
return /* @__PURE__ */
|
|
134
|
-
ref:
|
|
135
|
-
...
|
|
136
|
-
children: j ?
|
|
137
|
-
labelElementRef:
|
|
110
|
+
return /* @__PURE__ */ o("div", {
|
|
111
|
+
ref: T,
|
|
112
|
+
...y,
|
|
113
|
+
children: j ? M : /* @__PURE__ */ o(J, {
|
|
114
|
+
labelElementRef: N,
|
|
138
115
|
subtitleElementRef: $,
|
|
139
|
-
textElementRef:
|
|
140
|
-
tooltipContent: /* @__PURE__ */
|
|
116
|
+
textElementRef: D,
|
|
117
|
+
tooltipContent: /* @__PURE__ */ u("div", {
|
|
141
118
|
className: n.tooltip,
|
|
142
|
-
children: [
|
|
143
|
-
ref:
|
|
119
|
+
children: [c === "labeled" && /* @__PURE__ */ o(R, {
|
|
120
|
+
ref: N,
|
|
144
121
|
color: "textOnDarkDefault",
|
|
145
122
|
isInTooltip: !0,
|
|
146
123
|
labelName: w,
|
|
147
|
-
labelValue:
|
|
148
|
-
}), /* @__PURE__ */
|
|
149
|
-
children: c
|
|
150
|
-
}), i && /* @__PURE__ */ t("span", {
|
|
124
|
+
labelValue: I
|
|
125
|
+
}), /* @__PURE__ */ o("span", {
|
|
151
126
|
children: i
|
|
127
|
+
}), s && /* @__PURE__ */ o("span", {
|
|
128
|
+
children: s
|
|
152
129
|
})]
|
|
153
130
|
}),
|
|
154
|
-
children:
|
|
131
|
+
children: G
|
|
155
132
|
})
|
|
156
133
|
});
|
|
157
134
|
}
|
|
158
135
|
export {
|
|
159
|
-
|
|
136
|
+
oe as ContentNode
|
|
160
137
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { NodeItemIcon as c } from "../node-icon/node-item-icon.js";
|
|
3
|
+
import { NodeAvatar as i } from "../node-icon/node-avatar.js";
|
|
4
|
+
const u = ({
|
|
5
|
+
name: e,
|
|
6
|
+
metadata: r,
|
|
7
|
+
size: o
|
|
8
|
+
}) => {
|
|
9
|
+
const {
|
|
10
|
+
variant: n
|
|
11
|
+
} = r;
|
|
12
|
+
return n === "content" ? /* @__PURE__ */ t(c, {
|
|
13
|
+
iconType: r.iconType,
|
|
14
|
+
size: o
|
|
15
|
+
}) : n === "user" ? /* @__PURE__ */ t(i, {
|
|
16
|
+
avatarSrc: r.avatarSrc,
|
|
17
|
+
badge: r.badge,
|
|
18
|
+
nodeTitle: e,
|
|
19
|
+
size: o
|
|
20
|
+
}) : null;
|
|
21
|
+
};
|
|
22
|
+
export {
|
|
23
|
+
u as VariantIcon
|
|
24
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ContentNodeProps } from '@box/tree';
|
|
2
|
+
type Props = Partial<ContentNodeProps> & {
|
|
3
|
+
isLoading: boolean;
|
|
4
|
+
metadata: ContentNodeProps['element']['metadata'];
|
|
5
|
+
};
|
|
6
|
+
export declare const ExpanderWithLoading: ({ metadata, handleExpand, isDisabled, isExpanded, isLoading, size }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ContentNodeProps } from '@box/tree';
|
|
2
|
+
type Props = Partial<ContentNodeProps> & {
|
|
3
|
+
metadata: ContentNodeProps['element']['metadata'];
|
|
4
|
+
name: string;
|
|
5
|
+
};
|
|
6
|
+
export declare const VariantIcon: ({ name, metadata, size }: Props) => import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ComponentRecord } from '@box/storybook-utils';
|
|
2
|
-
import { ContentNode,
|
|
2
|
+
import { ContentNode, LoadingNode, LoadMoreNode, ReloadNode, TreeProps } from '../types';
|
|
3
3
|
declare const rootNode: ContentNode;
|
|
4
4
|
declare const dataWithContentNodes: ContentNode[];
|
|
5
5
|
declare const dataWithContentNodeWithTitle: ContentNode[];
|
|
6
|
+
declare const dataWithNonSelectableItems: ContentNode[];
|
|
6
7
|
declare const dataWithContentNodeWithTitleAndSubtitle: ContentNode[];
|
|
7
8
|
declare const dataWithContentNodeWithTitleAndExpander: ContentNode[];
|
|
8
9
|
declare const dataWithContentNodeWithTitleSubtitleAndExpander: ContentNode[];
|
|
@@ -13,4 +14,4 @@ declare const dataWithReloadNode: (ContentNode | ReloadNode)[];
|
|
|
13
14
|
declare const dataWithLoadingNode: (ContentNode | LoadingNode)[];
|
|
14
15
|
declare const dataWithNestedNode: (ContentNode | LoadingNode)[];
|
|
15
16
|
declare const nodesVariantsMap: ComponentRecord<Partial<TreeProps>>;
|
|
16
|
-
export { dataWithContentNodeInLoadingState, dataWithContentNodes, dataWithContentNodeWithDivider, dataWithContentNodeWithTitle, dataWithContentNodeWithTitleAndExpander, dataWithContentNodeWithTitleAndSubtitle, dataWithContentNodeWithTitleSubtitleAndExpander, dataWithLoadingNode, dataWithLoadMoreNode, dataWithNestedNode, dataWithReloadNode, nodesVariantsMap, rootNode, };
|
|
17
|
+
export { dataWithContentNodeInLoadingState, dataWithContentNodes, dataWithContentNodeWithDivider, dataWithContentNodeWithTitle, dataWithContentNodeWithTitleAndExpander, dataWithContentNodeWithTitleAndSubtitle, dataWithContentNodeWithTitleSubtitleAndExpander, dataWithLoadingNode, dataWithLoadMoreNode, dataWithNestedNode, dataWithNonSelectableItems, dataWithReloadNode, nodesVariantsMap, rootNode, };
|
package/package.json
CHANGED
|
File without changes
|