@box/metadata-view 0.27.3 → 0.28.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,95 @@
1
+ import { Row as S, Cell as c, Text as s, ActionCell as H } from "@box/blueprint-web";
2
+ import b from "lodash/get";
3
+ import { ItemTypeIcon as m } from "@box/item-icon";
4
+ import L from "clsx";
5
+ import { I as n } from "./types.js";
6
+ import { THUMBNAIL_LIST_VIEW_HEIGHTS as A } from "../esm/lib/components/constants.js";
7
+ import { jsxs as _, jsx as e } from "react/jsx-runtime";
8
+ import { ItemActionMenu as x } from "../esm/lib/components/item-action-menu/item-action-menu.js";
9
+ import '../styles/table-row.css';const E = "_tableHeaderActionsWrapper_uw3hc_1", y = "_tableHeaderActions_uw3hc_1", R = "_tableRow_uw3hc_33", g = "_selectAllCheckbox_uw3hc_42", U = "_tableNameCell_uw3hc_47", k = "_tableNameCellSubTitle_uw3hc_53", B = "_infiniteScrollTableContainerFullHeight_uw3hc_58", W = "_iconCell_uw3hc_64", i = {
10
+ tableHeaderActionsWrapper: E,
11
+ tableHeaderActions: y,
12
+ tableRow: R,
13
+ selectAllCheckbox: g,
14
+ tableNameCell: U,
15
+ tableNameCellSubTitle: k,
16
+ infiniteScrollTableContainerFullHeight: B,
17
+ iconCell: W
18
+ }, q = ({
19
+ item: l,
20
+ columns: N,
21
+ iconColumnVariant: t,
22
+ isSelectAllEnabled: p,
23
+ itemActionMenuProps: d,
24
+ zoomLevel: I = 0
25
+ }) => {
26
+ const T = I;
27
+ return /* @__PURE__ */ _(S, {
28
+ className: i.tableRow,
29
+ id: l.id,
30
+ children: [t === n.COLUMN ? /* @__PURE__ */ e(c, {
31
+ style: {
32
+ height: A[T]
33
+ },
34
+ children: /* @__PURE__ */ e(m, {
35
+ className: i.iconCell,
36
+ item: l
37
+ })
38
+ }, `item-type-icon-${l.id}`) : null, N.map((o) => {
39
+ const {
40
+ cellRenderer: h,
41
+ id: a,
42
+ subTitle: C,
43
+ textValue: f,
44
+ type: w
45
+ } = o, r = `${f}-${l.id}`;
46
+ if (a === "name" && (t === n.INLINE || t === n.INLINE_SUBTITLE))
47
+ return /* @__PURE__ */ e(c, {
48
+ children: /* @__PURE__ */ _("div", {
49
+ className: i.tableNameCell,
50
+ children: [/* @__PURE__ */ e(m, {
51
+ item: l
52
+ }), /* @__PURE__ */ _("div", {
53
+ className: L({
54
+ [i.tableNameCellSubTitle]: t === n.INLINE_SUBTITLE
55
+ }),
56
+ children: [/* @__PURE__ */ e(s, {
57
+ as: "span",
58
+ children: b(l, a)
59
+ }), t === n.INLINE_SUBTITLE ? /* @__PURE__ */ e(s, {
60
+ as: "span",
61
+ color: "textOnLightSecondary",
62
+ children: C
63
+ }) : null]
64
+ })]
65
+ })
66
+ }, r);
67
+ if (h)
68
+ return /* @__PURE__ */ e(c, {
69
+ children: h(l, o)
70
+ }, r);
71
+ if (w === "multiSelect") {
72
+ const u = b(l, a);
73
+ return /* @__PURE__ */ e(c, {
74
+ children: u ? u.join(" ") : ""
75
+ }, r);
76
+ }
77
+ return /* @__PURE__ */ e(c, {
78
+ children: /* @__PURE__ */ e(s, {
79
+ as: "span",
80
+ children: b(l, a)
81
+ })
82
+ }, r);
83
+ }), p && /* @__PURE__ */ e(H, {
84
+ children: (o) => d ? /* @__PURE__ */ e(x, {
85
+ ...d,
86
+ item: l,
87
+ onOpenChange: o
88
+ }) : null
89
+ })]
90
+ }, l.id);
91
+ };
92
+ export {
93
+ q as T,
94
+ i as s
95
+ };
@@ -0,0 +1,33 @@
1
+ import { useRef as h, useMemo as S, useEffect as T } from "react";
2
+ import { useVirtualizer as b } from "@tanstack/react-virtual";
3
+ import { Size14 as p } from "@box/blueprint-web-assets/tokens/px-tokens";
4
+ const z = parseInt(p, 10), V = ({
5
+ items: e,
6
+ hasNextPage: t = !1,
7
+ isLoading: r = !1,
8
+ parentRef: n,
9
+ approximateRowHeight: g = z,
10
+ onGetNextPage: o,
11
+ placeholderRowsCount: c = 20
12
+ }) => {
13
+ const s = h(0), f = S(() => e.length + (r || t ? c : 0), [e, t, r, c]), u = b({
14
+ count: f,
15
+ getScrollElement: () => n.current,
16
+ getItemKey: (I) => {
17
+ var m;
18
+ return ((m = e[I]) == null ? void 0 : m.id) || `table-item-${I}`;
19
+ },
20
+ estimateSize: () => g
21
+ }), l = u.getVirtualItems();
22
+ T(() => {
23
+ s.current = e.length;
24
+ }, [e.length]), (e.length === 0 || e.length > 0 && s.current === 0) && n.current && (n.current.scrollTop = 0);
25
+ const i = l[l.length - 1], a = !!i && i.index >= e.length - 1;
26
+ return !r && a && t && o && o(), {
27
+ getTableHeight: u.getTotalSize,
28
+ virtualItemsToDisplay: l
29
+ };
30
+ };
31
+ export {
32
+ V as useInfiniteScrollTableItems
33
+ };
@@ -1,89 +1,129 @@
1
- import { Text as W, ListCheckbox as g, Table as I, TableHeader as w, Column as C } from "@box/blueprint-web";
2
- import { useIntl as M } from "react-intl";
3
- import N from "./table-body/ghost-table-body.js";
4
- import { s as i, T as y } from "../../../../chunks/table-body-with-data.js";
5
- import { I as A } from "../../../../chunks/types.js";
6
- import { THUMBNAIL_WIDTHS as B } from "../constants.js";
7
- import f from "./messages.js";
8
- import { jsx as a, jsxs as D } from "react/jsx-runtime";
9
- const S = ({
10
- columns: l,
11
- isLoading: o = !1,
1
+ import { Text as D, ListCheckbox as _, TableHeader as v, Column as M } from "@box/blueprint-web";
2
+ import { useRef as E } from "react";
3
+ import { useIntl as S } from "react-intl";
4
+ import { useInfiniteScrollTableItems as k } from "./hooks/useInfiniteScrollTableItems.js";
5
+ import T from "./table-renderer.js";
6
+ import { I as B } from "../../../../chunks/types.js";
7
+ import { THUMBNAIL_WIDTHS as O } from "../constants.js";
8
+ import { s } from "../../../../chunks/table-row.js";
9
+ import P from "./messages.js";
10
+ import { jsx as e } from "react/jsx-runtime";
11
+ const U = 40, K = ({
12
+ columns: o,
13
+ isLoading: l = !1,
12
14
  iconColumnVariant: n,
13
15
  isSelectAllEnabled: d,
14
- items: p,
15
- itemActionMenuProps: u,
16
- zoomLevel: t,
17
- ...H
16
+ items: m,
17
+ itemActionMenuProps: I,
18
+ isInfiniteScrollEnabled: R = !1,
19
+ hasNextPage: x = !1,
20
+ onGetNextPage: C,
21
+ placeholderRowsCount: W,
22
+ zoomLevel: r,
23
+ ...g
18
24
  }) => {
25
+ var u;
19
26
  const {
20
- formatMessage: m
21
- } = M(), s = [], b = 0;
22
- if (n === A.COLUMN) {
23
- t = t || b;
24
- const e = parseInt(B[t], 10) + 24;
25
- s.push({
27
+ formatMessage: c
28
+ } = S(), f = E(null), {
29
+ virtualItemsToDisplay: p,
30
+ getTableHeight: w
31
+ } = k({
32
+ items: m,
33
+ hasNextPage: x,
34
+ isLoading: l,
35
+ parentRef: f,
36
+ onGetNextPage: C,
37
+ placeholderRowsCount: W
38
+ }), a = [], y = 0;
39
+ if (n === B.COLUMN) {
40
+ r = r || y;
41
+ const t = parseInt(O[r], 10) + 24;
42
+ a.push({
26
43
  id: "item-type-icon",
27
44
  isRowHeader: !1,
28
45
  hideHeader: !1,
29
- minWidth: e,
30
- maxWidth: e
46
+ minWidth: t,
47
+ maxWidth: t
31
48
  });
32
49
  }
33
- const T = l.map((e) => {
50
+ const A = o.map((t) => {
34
51
  const {
35
- id: c,
36
- headerRenderer: h,
37
- textValue: r,
38
- ...x
39
- } = e;
52
+ id: H,
53
+ headerRenderer: b,
54
+ textValue: i,
55
+ ...N
56
+ } = t;
40
57
  return {
41
- children: h ? h(r, e) : /* @__PURE__ */ a(W, {
58
+ children: b ? b(i, t) : /* @__PURE__ */ e(D, {
42
59
  as: "span",
43
- children: r
60
+ children: i
44
61
  }),
45
- isRowHeader: c === "name",
46
- id: c,
47
- textValue: r,
48
- ...x
62
+ isRowHeader: H === "name",
63
+ id: H,
64
+ textValue: i,
65
+ ...N
49
66
  };
50
67
  });
51
- return s.push(...T), d && s.push({
68
+ a.push(...A), d && a.push({
52
69
  id: "actions",
53
- className: i.tableHeaderActions,
54
- children: /* @__PURE__ */ a("div", {
55
- className: i.tableHeaderActionsWrapper,
56
- children: /* @__PURE__ */ a(g, {
57
- "aria-label": m(f.selectAll),
58
- className: i.selectAllCheckbox,
59
- isDisabled: o
70
+ className: s.tableHeaderActions,
71
+ children: /* @__PURE__ */ e("div", {
72
+ className: s.tableHeaderActionsWrapper,
73
+ children: /* @__PURE__ */ e(_, {
74
+ "aria-label": c(P.selectAll),
75
+ className: s.selectAllCheckbox,
76
+ isDisabled: l
60
77
  })
61
78
  }),
62
79
  isRowHeader: !1,
63
80
  hideHeader: !1,
64
81
  allowsSorting: !1
65
- }), /* @__PURE__ */ D(I, {
66
- "aria-label": m(f.listView),
67
- selectionBehavior: "toggle",
68
- selectionMode: "multiple",
69
- ...H,
70
- children: [/* @__PURE__ */ a(w, {
71
- columns: s,
72
- children: (e) => /* @__PURE__ */ a(C, {
73
- ...e
82
+ });
83
+ const h = {
84
+ tableHeader: /* @__PURE__ */ e(v, {
85
+ columns: a,
86
+ children: (t) => /* @__PURE__ */ e(M, {
87
+ ...t
88
+ })
89
+ }),
90
+ columns: o,
91
+ iconColumnVariant: n,
92
+ isSelectAllEnabled: d,
93
+ itemActionMenuProps: I,
94
+ items: m,
95
+ isLoading: l,
96
+ formatMessage: c,
97
+ tableProps: g,
98
+ columnCount: a.length,
99
+ zoomLevel: r
100
+ };
101
+ return R ? /* @__PURE__ */ e("div", {
102
+ ref: f,
103
+ className: s.infiniteScrollTableContainerFullHeight,
104
+ children: /* @__PURE__ */ e("div", {
105
+ style: {
106
+ position: "relative",
107
+ width: "100%",
108
+ height: w() + U
109
+ },
110
+ children: /* @__PURE__ */ e(T, {
111
+ ...h,
112
+ style: {
113
+ position: "absolute",
114
+ top: 0,
115
+ left: 0,
116
+ width: "100%",
117
+ transform: `translateY(${((u = p[0]) == null ? void 0 : u.start) || 0}px)`,
118
+ tableLayout: "fixed"
119
+ },
120
+ virtualItems: p
74
121
  })
75
- }), o ? /* @__PURE__ */ a(N, {
76
- columnLength: s.length
77
- }) : /* @__PURE__ */ a(y, {
78
- columns: l,
79
- iconColumnVariant: n,
80
- isSelectAllEnabled: d,
81
- itemActionMenuProps: u,
82
- items: p,
83
- zoomLevel: t
84
- })]
122
+ })
123
+ }) : /* @__PURE__ */ e(T, {
124
+ ...h
85
125
  });
86
126
  };
87
127
  export {
88
- S as default
128
+ K as default
89
129
  };
@@ -0,0 +1,20 @@
1
+ import { Row as h, Cell as i, Ghost as l } from "@box/blueprint-web";
2
+ import { Size5 as a } from "@box/blueprint-web-assets/tokens/tokens";
3
+ import { jsx as r } from "react/jsx-runtime";
4
+ const c = ({
5
+ columnLength: o,
6
+ rowKey: t = "ghost-row"
7
+ }) => /* @__PURE__ */ r(h, {
8
+ children: Array.from({
9
+ length: o
10
+ }, (m, e) => /* @__PURE__ */ r(i, {
11
+ children: /* @__PURE__ */ r(l, {
12
+ height: a,
13
+ variant: "rectangle",
14
+ width: "100%"
15
+ })
16
+ }, e))
17
+ }, t);
18
+ export {
19
+ c as default
20
+ };
@@ -1,27 +1,20 @@
1
- import { TableBody as a, Row as h, Cell as n, Ghost as m } from "@box/blueprint-web";
2
- import { Size5 as d } from "@box/blueprint-web-assets/tokens/tokens";
1
+ import { TableBody as a } from "@box/blueprint-web";
2
+ import l from "./ghost-row/ghost-row.js";
3
3
  import { jsx as r } from "react/jsx-runtime";
4
- const s = 20, g = ({
5
- columnLength: o,
6
- rowLength: l = s
4
+ const s = 20, n = ({
5
+ columnLength: e,
6
+ rowLength: t = s
7
7
  }) => /* @__PURE__ */ r(a, {
8
8
  items: Array.from({
9
- length: l
10
- }, (e, t) => ({
11
- key: t
9
+ length: t
10
+ }, (o, m) => ({
11
+ key: m
12
12
  })),
13
- children: (e) => /* @__PURE__ */ r(h, {
14
- children: Array.from({
15
- length: o
16
- }, (t, i) => /* @__PURE__ */ r(n, {
17
- children: /* @__PURE__ */ r(m, {
18
- height: d,
19
- variant: "rectangle",
20
- width: "100%"
21
- })
22
- }, i))
23
- }, e.key)
13
+ children: (o) => /* @__PURE__ */ r(l, {
14
+ columnLength: e,
15
+ rowKey: o.key
16
+ })
24
17
  });
25
18
  export {
26
- g as default
19
+ n as default
27
20
  };
@@ -1,13 +1,167 @@
1
- import "@box/blueprint-web";
2
- import "lodash/get";
3
- import "react";
4
- import "@box/item-icon";
5
- import "clsx";
6
- import "../../../../../chunks/types.js";
7
- import "../../constants.js";
8
- import { T as s } from "../../../../../chunks/table-body-with-data.js";
9
- import "react/jsx-runtime";
10
- import "../../item-action-menu/item-action-menu.js";
1
+ import { TableBody as y, Row as L, Cell as a, ActionCell as x, Text as p } from "@box/blueprint-web";
2
+ import { ItemTypeIcon as C } from "@box/item-icon";
3
+ import R from "clsx";
4
+ import N from "lodash/get";
5
+ import d from "react";
6
+ import { I as h } from "../../../../../chunks/types.js";
7
+ import { THUMBNAIL_LIST_VIEW_HEIGHTS as S } from "../../constants.js";
8
+ import b from "./ghost-row/ghost-row.js";
9
+ import { s as m, T as w } from "../../../../../chunks/table-row.js";
10
+ import { jsx as r, jsxs as f } from "react/jsx-runtime";
11
+ import { ItemActionMenu as E } from "../../item-action-menu/item-action-menu.js";
12
+ const g = /* @__PURE__ */ d.memo(({
13
+ item: t,
14
+ column: e,
15
+ iconColumnVariant: o
16
+ }) => {
17
+ const {
18
+ id: l,
19
+ subTitle: c
20
+ } = e, i = `${e.textValue}-${t.id}`;
21
+ return /* @__PURE__ */ r(a, {
22
+ children: /* @__PURE__ */ f("div", {
23
+ className: m.tableNameCell,
24
+ children: [/* @__PURE__ */ r(C, {
25
+ item: t
26
+ }), /* @__PURE__ */ f("div", {
27
+ className: R({
28
+ [m.tableNameCellSubTitle]: o === h.INLINE_SUBTITLE
29
+ }),
30
+ children: [/* @__PURE__ */ r(p, {
31
+ as: "span",
32
+ children: N(t, l)
33
+ }), o === h.INLINE_SUBTITLE && /* @__PURE__ */ r(p, {
34
+ as: "span",
35
+ color: "textOnLightSecondary",
36
+ children: c
37
+ })]
38
+ })]
39
+ })
40
+ }, i);
41
+ }), B = /* @__PURE__ */ d.memo(({
42
+ item: t,
43
+ column: e
44
+ }) => {
45
+ var l;
46
+ const o = `${e.textValue}-${t.id}`;
47
+ return /* @__PURE__ */ r(a, {
48
+ children: (l = e.cellRenderer) == null ? void 0 : l.call(e, t, e)
49
+ }, o);
50
+ }), _ = /* @__PURE__ */ d.memo(({
51
+ item: t,
52
+ column: e
53
+ }) => {
54
+ const o = `${e.textValue}-${t.id}`, l = N(t, e.id);
55
+ return l ? /* @__PURE__ */ r(a, {
56
+ children: l.join(" ")
57
+ }, o) : /* @__PURE__ */ r(a, {}, o);
58
+ }), k = /* @__PURE__ */ d.memo(({
59
+ item: t,
60
+ column: e
61
+ }) => {
62
+ const o = `${e.textValue}-${t.id}`;
63
+ return /* @__PURE__ */ r(a, {
64
+ children: /* @__PURE__ */ r(p, {
65
+ as: "span",
66
+ children: N(t, e.id)
67
+ })
68
+ }, o);
69
+ }), U = /* @__PURE__ */ d.memo(({
70
+ item: t,
71
+ column: e,
72
+ iconColumnVariant: o
73
+ }) => {
74
+ const {
75
+ cellRenderer: l,
76
+ id: c,
77
+ type: i
78
+ } = e;
79
+ return c === "name" && (o === h.INLINE || o === h.INLINE_SUBTITLE) ? /* @__PURE__ */ r(g, {
80
+ column: e,
81
+ iconColumnVariant: o,
82
+ item: t
83
+ }) : l ? /* @__PURE__ */ r(B, {
84
+ column: e,
85
+ item: t
86
+ }) : i === "multiSelect" ? /* @__PURE__ */ r(_, {
87
+ column: e,
88
+ item: t
89
+ }) : /* @__PURE__ */ r(k, {
90
+ column: e,
91
+ item: t
92
+ });
93
+ }), W = /* @__PURE__ */ d.memo(({
94
+ item: t,
95
+ zoomLevel: e
96
+ }) => /* @__PURE__ */ r(a, {
97
+ style: {
98
+ height: S[e]
99
+ },
100
+ children: /* @__PURE__ */ r(C, {
101
+ className: m.iconCell,
102
+ item: t
103
+ })
104
+ }, `item-type-icon-${t.id}`)), j = /* @__PURE__ */ d.memo(({
105
+ item: t,
106
+ itemActionMenuProps: e
107
+ }) => /* @__PURE__ */ r(x, {
108
+ children: (o) => e ? /* @__PURE__ */ r(E, {
109
+ ...e,
110
+ item: t,
111
+ onOpenChange: o
112
+ }) : null
113
+ })), J = ({
114
+ columns: t,
115
+ iconColumnVariant: e,
116
+ isSelectAllEnabled: o,
117
+ items: l,
118
+ itemActionMenuProps: c,
119
+ virtualItems: i,
120
+ columnCount: T,
121
+ zoomLevel: u
122
+ }) => {
123
+ const $ = e === h.COLUMN;
124
+ if (i) {
125
+ const n = (s) => /* @__PURE__ */ r(b, {
126
+ columnLength: T || 0,
127
+ rowKey: `ghost-${s}`
128
+ }), I = (s) => /* @__PURE__ */ r(w, {
129
+ columns: t,
130
+ iconColumnVariant: e,
131
+ isSelectAllEnabled: o,
132
+ item: s,
133
+ itemActionMenuProps: c,
134
+ zoomLevel: u
135
+ });
136
+ return /* @__PURE__ */ r(y, {
137
+ items: i,
138
+ children: ({
139
+ index: s
140
+ }) => s >= l.length ? n(s) : I(l[s])
141
+ });
142
+ }
143
+ return /* @__PURE__ */ r(y, {
144
+ items: l.map((n) => ({
145
+ key: n.id,
146
+ ...n
147
+ })),
148
+ children: (n) => /* @__PURE__ */ f(L, {
149
+ className: m.tableRow,
150
+ id: n.id,
151
+ children: [$ && /* @__PURE__ */ r(W, {
152
+ item: n,
153
+ zoomLevel: u
154
+ }), t.map((I) => /* @__PURE__ */ r(U, {
155
+ column: I,
156
+ iconColumnVariant: e,
157
+ item: n
158
+ }, `${I.textValue}-${n.id}`)), o && /* @__PURE__ */ r(j, {
159
+ item: n,
160
+ itemActionMenuProps: c
161
+ })]
162
+ }, n.id)
163
+ });
164
+ };
11
165
  export {
12
- s as default
166
+ J as default
13
167
  };
@@ -0,0 +1,12 @@
1
+ import "@box/blueprint-web";
2
+ import "lodash/get";
3
+ import "@box/item-icon";
4
+ import "clsx";
5
+ import "../../../../../../chunks/types.js";
6
+ import "../../../constants.js";
7
+ import { T as l } from "../../../../../../chunks/table-row.js";
8
+ import "react/jsx-runtime";
9
+ import "../../../item-action-menu/item-action-menu.js";
10
+ export {
11
+ l as default
12
+ };
@@ -0,0 +1,49 @@
1
+ import { Table as b } from "@box/blueprint-web";
2
+ import T from "./table-body/ghost-table-body.js";
3
+ import d from "./table-body/table-body-with-data.js";
4
+ import { I as x } from "../../../../chunks/types.js";
5
+ import B from "./messages.js";
6
+ import { jsxs as j, jsx as i } from "react/jsx-runtime";
7
+ const N = ({
8
+ tableHeader: s,
9
+ columns: t,
10
+ iconColumnVariant: n,
11
+ isSelectAllEnabled: r,
12
+ itemActionMenuProps: c,
13
+ items: f,
14
+ isLoading: l,
15
+ formatMessage: u,
16
+ tableProps: a,
17
+ virtualItems: o,
18
+ style: h,
19
+ columnCount: p,
20
+ zoomLevel: C
21
+ }) => {
22
+ const m = p || (() => {
23
+ let e = t.length;
24
+ return n === x.COLUMN && (e += 1), r && (e += 1), e;
25
+ })(), g = l && !(o != null && o.length);
26
+ return /* @__PURE__ */ j(b, {
27
+ "aria-label": u(B.listView),
28
+ selectionBehavior: "toggle",
29
+ selectionMode: "multiple",
30
+ style: h,
31
+ ...a,
32
+ children: [s, g ? /* @__PURE__ */ i(T, {
33
+ columnLength: m
34
+ }) : /* @__PURE__ */ i(d, {
35
+ columnCount: m,
36
+ columns: t,
37
+ iconColumnVariant: n,
38
+ isLoading: l,
39
+ isSelectAllEnabled: r,
40
+ itemActionMenuProps: c,
41
+ items: f,
42
+ virtualItems: o,
43
+ zoomLevel: C
44
+ })]
45
+ });
46
+ };
47
+ export {
48
+ N as default
49
+ };
@@ -0,0 +1 @@
1
+ ._tableHeaderActionsWrapper_uw3hc_1{position:absolute;top:0;right:var(--size-4);bottom:0;display:flex;gap:var(--space-2);align-items:center;justify-content:center;padding:0 var(--space-2);background:var(--item-background);margin-block:var(--space-2)}._tableHeaderActionsWrapper_uw3hc_1:before{position:absolute;left:0;z-index:0;display:block;width:0;height:50%;box-shadow:-.25rem 0 .625rem .625rem var(--item-background);content:""}._tableHeaderActions_uw3hc_1{position:sticky;right:0;width:var(--size-6);padding:0}._tableRow_uw3hc_33:after{height:100%!important}._tableRow_uw3hc_33[aria-selected=true]:after{height:100%!important}._selectAllCheckbox_uw3hc_42 svg{transform:none!important}._tableNameCell_uw3hc_47{display:flex;gap:var(--space-3);align-items:center}._tableNameCellSubTitle_uw3hc_53{display:flex;flex-direction:column}._infiniteScrollTableContainerFullHeight_uw3hc_58{width:100%;height:100%;overflow:auto}._iconCell_uw3hc_64{width:100%!important;height:100%!important}
@@ -0,0 +1,15 @@
1
+ import { Item } from '@box/types';
2
+ type UseInfiniteScrollTableItemsProps = {
3
+ items: Item[];
4
+ hasNextPage?: boolean;
5
+ isLoading?: boolean;
6
+ parentRef: React.MutableRefObject<HTMLElement | null>;
7
+ approximateRowHeight?: number;
8
+ onGetNextPage?: () => void;
9
+ placeholderRowsCount?: number;
10
+ };
11
+ export declare const useInfiniteScrollTableItems: ({ items, hasNextPage, isLoading, parentRef, approximateRowHeight, onGetNextPage, placeholderRowsCount, }: UseInfiniteScrollTableItemsProps) => {
12
+ getTableHeight: () => number;
13
+ virtualItemsToDisplay: import('@tanstack/virtual-core').VirtualItem[];
14
+ };
15
+ export {};
@@ -4,7 +4,11 @@ export interface MetadataTableProps extends TableProps, MetadataProps {
4
4
  columns: Column[];
5
5
  iconColumnVariant?: IconColumnVariant;
6
6
  isSelectAllEnabled?: boolean;
7
+ isInfiniteScrollEnabled?: boolean;
8
+ hasNextPage?: boolean;
9
+ onGetNextPage?: () => void;
10
+ placeholderRowsCount?: number;
7
11
  zoomLevel?: number;
8
12
  }
9
- declare const MetadataTable: ({ columns, isLoading, iconColumnVariant, isSelectAllEnabled, items, itemActionMenuProps, zoomLevel, ...tableProps }: MetadataTableProps) => import("react/jsx-runtime").JSX.Element;
13
+ declare const MetadataTable: ({ columns, isLoading, iconColumnVariant, isSelectAllEnabled, items, itemActionMenuProps, isInfiniteScrollEnabled, hasNextPage, onGetNextPage, placeholderRowsCount, zoomLevel, ...tableProps }: MetadataTableProps) => import("react/jsx-runtime").JSX.Element;
10
14
  export default MetadataTable;
@@ -0,0 +1,6 @@
1
+ interface GhostTableRowProps {
2
+ columnLength: number;
3
+ rowKey?: string | number;
4
+ }
5
+ declare const GhostTableRow: ({ columnLength, rowKey }: GhostTableRowProps) => import("react/jsx-runtime").JSX.Element;
6
+ export default GhostTableRow;
@@ -1,4 +1,9 @@
1
1
  import { TableProps } from '@box/blueprint-web';
2
+ import { VirtualItem } from '@tanstack/react-virtual';
2
3
  import { MetadataTableProps } from '../metadata-table';
3
- declare const TableBodyWithData: ({ columns, iconColumnVariant, isSelectAllEnabled, items, itemActionMenuProps, zoomLevel, }: Omit<MetadataTableProps, keyof TableProps>) => import("react/jsx-runtime").JSX.Element;
4
+ interface TableBodyWithDataProps extends Omit<MetadataTableProps, keyof TableProps> {
5
+ virtualItems?: VirtualItem[];
6
+ columnCount?: number;
7
+ }
8
+ declare const TableBodyWithData: ({ columns, iconColumnVariant, isSelectAllEnabled, items, itemActionMenuProps, virtualItems, columnCount, zoomLevel, }: TableBodyWithDataProps) => import("react/jsx-runtime").JSX.Element;
4
9
  export default TableBodyWithData;
@@ -0,0 +1,12 @@
1
+ import { Item } from '@box/types';
2
+ import { MetadataTableProps } from '../../metadata-table';
3
+ interface TableRowProps {
4
+ item: Item;
5
+ columns: MetadataTableProps['columns'];
6
+ iconColumnVariant: MetadataTableProps['iconColumnVariant'];
7
+ isSelectAllEnabled: MetadataTableProps['isSelectAllEnabled'];
8
+ itemActionMenuProps: MetadataTableProps['itemActionMenuProps'];
9
+ zoomLevel?: number;
10
+ }
11
+ declare const TableRow: ({ item, columns, iconColumnVariant, isSelectAllEnabled, itemActionMenuProps, zoomLevel, }: TableRowProps) => import("react/jsx-runtime").JSX.Element;
12
+ export default TableRow;
@@ -0,0 +1,21 @@
1
+ import { TableProps } from '@box/blueprint-web';
2
+ import { VirtualItem } from '@tanstack/react-virtual';
3
+ import { useIntl } from 'react-intl';
4
+ import { IconColumnVariant, Column, MetadataProps } from '../../types';
5
+ export interface TableRendererProps {
6
+ tableHeader: React.ReactNode;
7
+ columns: Column[];
8
+ iconColumnVariant?: IconColumnVariant;
9
+ isSelectAllEnabled?: boolean;
10
+ itemActionMenuProps?: MetadataProps['itemActionMenuProps'];
11
+ items: MetadataProps['items'];
12
+ isLoading?: boolean;
13
+ formatMessage: ReturnType<typeof useIntl>['formatMessage'];
14
+ tableProps: TableProps;
15
+ virtualItems?: VirtualItem[];
16
+ style?: React.CSSProperties;
17
+ columnCount?: number;
18
+ zoomLevel?: number;
19
+ }
20
+ declare const TableRenderer: ({ tableHeader, columns, iconColumnVariant, isSelectAllEnabled, itemActionMenuProps, items, isLoading, formatMessage, tableProps, virtualItems, style, columnCount: passedColumnCount, zoomLevel, }: TableRendererProps) => import("react/jsx-runtime").JSX.Element;
21
+ export default TableRenderer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-view",
3
- "version": "0.27.3",
3
+ "version": "0.28.1",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@box/blueprint-web": "^11.12.0",
@@ -8,6 +8,7 @@
8
8
  "@box/item-icon": "^0.9.172",
9
9
  "@box/metadata-filter": "^1.8.4",
10
10
  "@box/types": "0.1.0",
11
+ "@tanstack/react-virtual": "^3.10.8",
11
12
  "formik": "^2.4.5",
12
13
  "lodash": "^4.17.15",
13
14
  "react": "^18.0.0",
@@ -19,10 +20,11 @@
19
20
  "@box/blueprint-web": "^11.12.0",
20
21
  "@box/blueprint-web-assets": "^4.60.0",
21
22
  "@box/eslint-plugin-blueprint": "*",
22
- "@box/item-icon": "^0.16.3",
23
- "@box/metadata-filter": "^1.16.3",
23
+ "@box/item-icon": "^0.16.4",
24
+ "@box/metadata-filter": "^1.16.4",
24
25
  "@box/storybook-utils": "0.13.14",
25
26
  "@box/types": "0.2.1",
27
+ "@tanstack/react-virtual": "^3.10.8",
26
28
  "react-intl": "^6.4.2"
27
29
  },
28
30
  "files": [
@@ -1,153 +0,0 @@
1
- import { TableBody as N, Row as y, Cell as n, ActionCell as T, Text as I } from "@box/blueprint-web";
2
- import C from "lodash/get";
3
- import s from "react";
4
- import { ItemTypeIcon as p } from "@box/item-icon";
5
- import u from "clsx";
6
- import { I as d } from "./types.js";
7
- import { THUMBNAIL_LIST_VIEW_HEIGHTS as f } from "../esm/lib/components/constants.js";
8
- import { jsx as t, jsxs as b } from "react/jsx-runtime";
9
- import { ItemActionMenu as x } from "../esm/lib/components/item-action-menu/item-action-menu.js";
10
- import '../styles/table-body-with-data.css';const S = "_tableHeaderActionsWrapper_rsay7_1", A = "_tableHeaderActions_rsay7_1", L = "_tableRow_rsay7_33", $ = "_selectAllCheckbox_rsay7_42", E = "_tableNameCell_rsay7_47", H = "_tableNameCellSubTitle_rsay7_53", k = "_iconCell_rsay7_58", m = {
11
- tableHeaderActionsWrapper: S,
12
- tableHeaderActions: A,
13
- tableRow: L,
14
- selectAllCheckbox: $,
15
- tableNameCell: E,
16
- tableNameCellSubTitle: H,
17
- iconCell: k
18
- }, R = /* @__PURE__ */ s.memo(({
19
- item: l,
20
- column: e,
21
- iconColumnVariant: r
22
- }) => {
23
- const {
24
- id: o,
25
- subTitle: c
26
- } = e, i = `${e.textValue}-${l.id}`;
27
- return /* @__PURE__ */ t(n, {
28
- children: /* @__PURE__ */ b("div", {
29
- className: m.tableNameCell,
30
- children: [/* @__PURE__ */ t(p, {
31
- item: l
32
- }), /* @__PURE__ */ b("div", {
33
- className: u({
34
- [m.tableNameCellSubTitle]: r === d.INLINE_SUBTITLE
35
- }),
36
- children: [/* @__PURE__ */ t(I, {
37
- as: "span",
38
- children: C(l, o)
39
- }), r === d.INLINE_SUBTITLE && /* @__PURE__ */ t(I, {
40
- as: "span",
41
- color: "textOnLightSecondary",
42
- children: c
43
- })]
44
- })]
45
- })
46
- }, i);
47
- }), W = /* @__PURE__ */ s.memo(({
48
- item: l,
49
- column: e
50
- }) => {
51
- var o;
52
- const r = `${e.textValue}-${l.id}`;
53
- return /* @__PURE__ */ t(n, {
54
- children: (o = e.cellRenderer) == null ? void 0 : o.call(e, l, e)
55
- }, r);
56
- }), w = /* @__PURE__ */ s.memo(({
57
- item: l,
58
- column: e
59
- }) => {
60
- const r = `${e.textValue}-${l.id}`, o = C(l, e.id);
61
- return o ? /* @__PURE__ */ t(n, {
62
- children: o.join(" ")
63
- }, r) : /* @__PURE__ */ t(n, {}, r);
64
- }), B = /* @__PURE__ */ s.memo(({
65
- item: l,
66
- column: e
67
- }) => {
68
- const r = `${e.textValue}-${l.id}`;
69
- return /* @__PURE__ */ t(n, {
70
- children: /* @__PURE__ */ t(I, {
71
- as: "span",
72
- children: C(l, e.id)
73
- })
74
- }, r);
75
- }), U = /* @__PURE__ */ s.memo(({
76
- item: l,
77
- column: e,
78
- iconColumnVariant: r
79
- }) => {
80
- const {
81
- cellRenderer: o,
82
- id: c,
83
- type: i
84
- } = e;
85
- return c === "name" && (r === d.INLINE || r === d.INLINE_SUBTITLE) ? /* @__PURE__ */ t(R, {
86
- column: e,
87
- iconColumnVariant: r,
88
- item: l
89
- }) : o ? /* @__PURE__ */ t(W, {
90
- column: e,
91
- item: l
92
- }) : i === "multiSelect" ? /* @__PURE__ */ t(w, {
93
- column: e,
94
- item: l
95
- }) : /* @__PURE__ */ t(B, {
96
- column: e,
97
- item: l
98
- });
99
- }), g = /* @__PURE__ */ s.memo(({
100
- item: l,
101
- zoomLevel: e
102
- }) => /* @__PURE__ */ t(n, {
103
- style: {
104
- height: f[e]
105
- },
106
- children: /* @__PURE__ */ t(p, {
107
- className: m.iconCell,
108
- item: l
109
- })
110
- }, `item-type-icon-${l.id}`)), j = /* @__PURE__ */ s.memo(({
111
- item: l,
112
- itemActionMenuProps: e
113
- }) => /* @__PURE__ */ t(T, {
114
- children: (r) => e ? /* @__PURE__ */ t(x, {
115
- ...e,
116
- item: l,
117
- onOpenChange: r
118
- }) : null
119
- })), J = ({
120
- columns: l,
121
- iconColumnVariant: e,
122
- isSelectAllEnabled: r,
123
- items: o,
124
- itemActionMenuProps: c,
125
- zoomLevel: i
126
- }) => {
127
- const _ = e === d.COLUMN;
128
- return /* @__PURE__ */ t(N, {
129
- items: o.map((a) => ({
130
- key: a.id,
131
- ...a
132
- })),
133
- children: (a) => /* @__PURE__ */ b(y, {
134
- className: m.tableRow,
135
- id: a.id,
136
- children: [_ && /* @__PURE__ */ t(g, {
137
- item: a,
138
- zoomLevel: i
139
- }), l.map((h) => /* @__PURE__ */ t(U, {
140
- column: h,
141
- iconColumnVariant: e,
142
- item: a
143
- }, `${h.textValue}-${a.id}`)), r && /* @__PURE__ */ t(j, {
144
- item: a,
145
- itemActionMenuProps: c
146
- })]
147
- }, a.id)
148
- });
149
- };
150
- export {
151
- J as T,
152
- m as s
153
- };
@@ -1 +0,0 @@
1
- ._tableHeaderActionsWrapper_rsay7_1{position:absolute;top:0;right:var(--size-4);bottom:0;display:flex;gap:var(--space-2);align-items:center;justify-content:center;padding:0 var(--space-2);background:var(--item-background);margin-block:var(--space-2)}._tableHeaderActionsWrapper_rsay7_1:before{position:absolute;left:0;z-index:0;display:block;width:0;height:50%;box-shadow:-.25rem 0 .625rem .625rem var(--item-background);content:""}._tableHeaderActions_rsay7_1{position:sticky;right:0;width:var(--size-6);padding:0}._tableRow_rsay7_33:after{height:100%!important}._tableRow_rsay7_33[aria-selected=true]:after{height:100%!important}._selectAllCheckbox_rsay7_42 svg{transform:none!important}._tableNameCell_rsay7_47{display:flex;gap:var(--space-3);align-items:center}._tableNameCellSubTitle_rsay7_53{display:flex;flex-direction:column}._iconCell_rsay7_58{width:100%!important;height:100%!important}