@box/tree 0.46.0 → 0.47.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.
@@ -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 { 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
- import { s as e } from "../../../../chunks/nodes.module.js";
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,
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: c,
29
- metadata: l
13
+ name: i,
14
+ metadata: e
30
15
  },
31
- level: u,
32
- getNodeProps: x,
33
- handleSelect: _,
34
- handleExpand: R,
35
- isBranch: y,
36
- isExpanded: f,
37
- isDisabled: a,
38
- isSelected: N,
39
- size: o,
40
- withIcon: v,
41
- containsSelection: V
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 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, {
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: D,
50
- subtitle: i,
51
- withDivider: O
52
- } = r === "labeled" ? {
53
- labelName: l.labelName,
54
- labelValue: l.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: 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,
74
- [e["node--nonselectable"]]: !I,
75
- "node--with-divider": O
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": 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,
83
- size: o === "small" ? "small" : "medium"
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,
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__ */ p("div", {
92
- className: d(n.content),
93
- children: [v && r === "content" && /* @__PURE__ */ t(Q, {
94
- iconType: l.iconType,
95
- size: o
96
- }), v && r === "user" && /* @__PURE__ */ t(U, {
97
- avatarSrc: l.avatarSrc,
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
- children: [r === "labeled" && /* @__PURE__ */ t(L, {
104
- ref: b,
82
+ ...!O && {
83
+ onClick: h
84
+ },
85
+ children: [c === "labeled" && /* @__PURE__ */ o(R, {
86
+ ref: N,
105
87
  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
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: c
113
- }), i && /* @__PURE__ */ t("span", {
94
+ children: i
95
+ }), s && /* @__PURE__ */ o("span", {
114
96
  ref: $,
115
97
  className: n.subtitle,
116
- children: i
98
+ children: s
117
99
  })]
118
100
  })]
119
101
  })]
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,
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": l == null ? void 0 : l.dataTargetId,
131
- children: c
107
+ "data-target-id": e == null ? void 0 : e.dataTargetId,
108
+ children: i
132
109
  });
133
- return /* @__PURE__ */ t("div", {
134
- ref: h,
135
- ...A,
136
- children: j ? S : /* @__PURE__ */ t(W, {
137
- labelElementRef: b,
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: T,
140
- tooltipContent: /* @__PURE__ */ p("div", {
116
+ textElementRef: D,
117
+ tooltipContent: /* @__PURE__ */ u("div", {
141
118
  className: n.tooltip,
142
- children: [r === "labeled" && /* @__PURE__ */ t(L, {
143
- ref: b,
119
+ children: [c === "labeled" && /* @__PURE__ */ o(R, {
120
+ ref: N,
144
121
  color: "textOnDarkDefault",
145
122
  isInTooltip: !0,
146
123
  labelName: w,
147
- labelValue: D
148
- }), /* @__PURE__ */ t("span", {
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: M
131
+ children: G
155
132
  })
156
133
  });
157
134
  }
158
135
  export {
159
- be as ContentNode
136
+ oe as ContentNode
160
137
  };
@@ -0,0 +1,9 @@
1
+ import "react-intl";
2
+ import "@box/blueprint-web";
3
+ import "./messages.js";
4
+ import { E as d } from "../../../../chunks/expander-with-loading.js";
5
+ import "react/jsx-runtime";
6
+ import "../expander/expander.js";
7
+ export {
8
+ d as ExpanderWithLoading
9
+ };
@@ -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, LoadMoreNode, LoadingNode, ReloadNode, TreeProps } from '../types';
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/tree",
3
- "version": "0.46.0",
3
+ "version": "0.47.1",
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": "^11.10.1",
15
- "@box/blueprint-web-assets": "^4.41.1",
16
- "@box/item-icon": "^0.9.133",
17
- "@box/storybook-utils": "^0.12.0",
14
+ "@box/blueprint-web": "^11.10.2",
15
+ "@box/blueprint-web-assets": "^4.42.0",
16
+ "@box/item-icon": "^0.9.134",
17
+ "@box/storybook-utils": "^0.12.1",
18
18
  "@faker-js/faker": "^8.4.1",
19
19
  "react": "^18.3.0",
20
20
  "react-dom": "^18.3.0",