@box/metadata-view 2.0.1 → 2.2.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.
@@ -1,12 +1,12 @@
1
1
  import { t as e } from "./types.js";
2
- import { t } from "./item-action-menu.js";
3
- import { THUMBNAIL_LIST_VIEW_HEIGHTS as n } from "../esm/lib/components/constants.js";
4
- import { ActionCell as r, Cell as i, Row as a, Text as o } from "@box/blueprint-web";
5
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
6
- import { ItemTypeIcon as l } from "@box/item-icon";
7
- import u from "clsx";
8
- import d from "lodash/get";
9
- import '../styles/table-row.css';var f = {
2
+ import { THUMBNAIL_LIST_VIEW_HEIGHTS as t } from "../esm/lib/components/constants.js";
3
+ import { ActionCellContent as n } from "../esm/lib/components/metadata-table/table-body/action-cell-content.js";
4
+ import { Cell as r, Row as i, Text as a } from "@box/blueprint-web";
5
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
6
+ import { ItemTypeIcon as c } from "@box/item-icon";
7
+ import l from "clsx";
8
+ import u from "lodash/get";
9
+ import '../styles/table-row.css';var d = {
10
10
  tableHeaderActionsWrapper: "_tableHeaderActionsWrapper_1sntd_1",
11
11
  tableHeaderActions: "_tableHeaderActions_1sntd_1",
12
12
  tableRow: "_tableRow_1sntd_33",
@@ -18,56 +18,54 @@ import '../styles/table-row.css';var f = {
18
18
  tableNameCellText: "_tableNameCellText_1sntd_65",
19
19
  tableNameCellIconInline: "_tableNameCellIconInline_1sntd_70",
20
20
  iconCell: "_iconCell_1sntd_74"
21
- }, p = ({ areSelectionCheckboxesDisabled: p, columns: m, dataTargetPrefix: h, iconColumnVariant: g, item: _, itemActionMenuProps: v, onTableRowClick: y, shouldRenderActionColumn: b, zoomLevel: x = 0 }) => /* @__PURE__ */ c(a, {
22
- className: u(f.tableRow, { [f.isClickable]: y }),
23
- "data-target-id": h ? `${h}-itemRow-${_.id}` : void 0,
24
- id: _.id,
25
- onAction: () => y?.(_),
21
+ }, f = ({ areSelectionCheckboxesDisabled: f, columns: p, dataTargetPrefix: m, iconColumnVariant: h, item: g, itemActionMenuProps: _, onTableRowClick: v, renderActionCell: y, shouldRenderActionColumn: b, zoomLevel: x = 0 }) => /* @__PURE__ */ s(i, {
22
+ className: l(d.tableRow, { [d.isClickable]: v }),
23
+ "data-target-id": m ? `${m}-itemRow-${g.id}` : void 0,
24
+ id: g.id,
25
+ onAction: () => v?.(g),
26
26
  children: [
27
- g === e.COLUMN ? /* @__PURE__ */ s(i, {
28
- style: { height: n[x] },
29
- children: /* @__PURE__ */ s(l, {
30
- className: f.iconCell,
31
- item: _
27
+ h === e.COLUMN ? /* @__PURE__ */ o(r, {
28
+ style: { height: t[x] },
29
+ children: /* @__PURE__ */ o(c, {
30
+ className: d.iconCell,
31
+ item: g
32
32
  })
33
- }, `item-type-icon-${_.id}`) : null,
34
- m.map((t) => {
35
- let { cellRenderer: n, id: r, isItemMetadata: a, subtitle: p, textValue: m, type: h } = t, v = `${m}-${_.id}`;
36
- if (n) return /* @__PURE__ */ s(i, { children: n(_, t) }, v);
37
- let y = d(_, a ? r.split(".")[1] : r);
38
- if (r === "name" && (g === e.INLINE || g === e.INLINE_SUBTITLE)) return /* @__PURE__ */ s(i, { children: /* @__PURE__ */ c("div", {
39
- className: f.tableNameCell,
40
- children: [/* @__PURE__ */ s(l, { item: _ }), /* @__PURE__ */ c("div", {
41
- className: u(f.tableNameCellTitle, { [f.hasSubtitle]: g === e.INLINE_SUBTITLE }),
42
- children: [/* @__PURE__ */ s(o, {
33
+ }, `item-type-icon-${g.id}`) : null,
34
+ p.map((t) => {
35
+ let { cellRenderer: n, id: i, isItemMetadata: f, subtitle: p, textValue: m, type: _ } = t, v = `${m}-${g.id}`;
36
+ if (n) return /* @__PURE__ */ o(r, { children: n(g, t) }, v);
37
+ let y = u(g, f ? i.split(".")[1] : i);
38
+ if (i === "name" && (h === e.INLINE || h === e.INLINE_SUBTITLE)) return /* @__PURE__ */ o(r, { children: /* @__PURE__ */ s("div", {
39
+ className: d.tableNameCell,
40
+ children: [/* @__PURE__ */ o(c, { item: g }), /* @__PURE__ */ s("div", {
41
+ className: l(d.tableNameCellTitle, { [d.hasSubtitle]: h === e.INLINE_SUBTITLE }),
42
+ children: [/* @__PURE__ */ o(a, {
43
43
  as: "span",
44
- className: f.tableNameCellText,
44
+ className: d.tableNameCellText,
45
45
  children: y
46
- }), g === e.INLINE_SUBTITLE ? /* @__PURE__ */ s(o, {
46
+ }), h === e.INLINE_SUBTITLE ? /* @__PURE__ */ o(a, {
47
47
  as: "span",
48
- className: f.tableNameCellText,
48
+ className: d.tableNameCellText,
49
49
  color: "textOnLightSecondary",
50
50
  children: p
51
51
  }) : null]
52
52
  })]
53
53
  }) }, v);
54
- if (h === "multiSelect") {
55
- let e = d(_, r);
56
- return /* @__PURE__ */ s(i, { children: e ? e.join(" ") : "" }, v);
54
+ if (_ === "multiSelect") {
55
+ let e = u(g, i);
56
+ return /* @__PURE__ */ o(r, { children: e ? e.join(" ") : "" }, v);
57
57
  }
58
- return /* @__PURE__ */ s(i, { children: /* @__PURE__ */ s(o, {
58
+ return /* @__PURE__ */ o(r, { children: /* @__PURE__ */ o(a, {
59
59
  as: "span",
60
60
  children: y
61
61
  }) }, v);
62
62
  }),
63
- b && /* @__PURE__ */ s(r, {
64
- isCheckboxDisabled: p,
65
- children: (e) => v ? /* @__PURE__ */ s(t, {
66
- ...v,
67
- item: _,
68
- onOpenChange: e
69
- }) : null
63
+ b && /* @__PURE__ */ o(n, {
64
+ isCheckboxDisabled: f,
65
+ item: g,
66
+ itemActionMenuProps: _,
67
+ renderActionCell: y
70
68
  })
71
69
  ]
72
- }, _.id);
73
- export { f as n, p as t };
70
+ }, g.id);
71
+ export { d as n, f as t };
@@ -1,3 +1,3 @@
1
1
  import { createContext as e, useContext as t } from "react";
2
- var n = /* @__PURE__ */ e(null), r = () => t(n);
2
+ var n = /*#__PURE__*/ e(null), r = () => t(n);
3
3
  export { n as AdvancedFilterContext, r as useAdvancedFilterContext };
@@ -1,3 +1,3 @@
1
1
  import { createContext as e, useContext as t } from "react";
2
- var n = /* @__PURE__ */ e(null), r = n.Provider, i = () => t(n);
2
+ var n = /*#__PURE__*/ e(null), r = n.Provider, i = () => t(n);
3
3
  export { r as FilterChipPopoverPortalProvider, i as useFilterChipPopoverPortalElement };
@@ -1,4 +1,4 @@
1
- function e(e) {
2
- return !!e.HeaderActions || e?.selectionMode && e.selectionMode !== "none";
1
+ function e(e, t) {
2
+ return !!(t || e.HeaderActions || e?.selectionMode && e.selectionMode !== "none");
3
3
  }
4
4
  export { e as getShouldRenderActionColumn };
@@ -1,8 +1,8 @@
1
1
  import { useEffect as e, useMemo as t, useRef as n } from "react";
2
2
  import { useVirtualizer as r } from "@tanstack/react-virtual";
3
3
  import { Size14 as i } from "@box/blueprint-web-assets/tokens/px-tokens";
4
- var a = parseInt(i, 10), o = ({ items: i, hasNextPage: o = !1, isLoading: s = !1, parentRef: c, approximateRowHeight: l = a, onGetNextPage: u, placeholderRowsCount: d = 20 }) => {
5
- let f = n(0), p = r({
4
+ var a = parseInt(i, 10), o = ({ items: i, hasNextPage: o = !1, isLoading: s = !1, parentRef: c, approximateRowHeight: l = a, onGetNextPage: u, placeholderRowsCount: d = 20, getItemKey: f, onVisibleRangeChange: p }) => {
5
+ let m = n(0), h = n(!1), g = r({
6
6
  count: t(() => i.length + (s || o ? d : 0), [
7
7
  i,
8
8
  o,
@@ -10,16 +10,43 @@ var a = parseInt(i, 10), o = ({ items: i, hasNextPage: o = !1, isLoading: s = !1
10
10
  d
11
11
  ]),
12
12
  getScrollElement: () => c.current,
13
- getItemKey: (e) => i[e]?.id || `table-item-${e}`,
13
+ getItemKey: (e) => {
14
+ let t = i[e];
15
+ return t && f ? f(t, e) : t?.id || `table-item-${e}`;
16
+ },
14
17
  estimateSize: () => l
15
- }), m = p.getVirtualItems();
18
+ }), _ = g.getVirtualItems(), v = i[0]?.id;
16
19
  e(() => {
17
- f.current = i.length;
18
- }, [i.length]), (i.length === 0 || i.length > 0 && f.current === 0) && c.current && (c.current.scrollTop = 0);
19
- let h = m[m.length - 1], g = !!h && h.index >= i.length - 1;
20
- return !s && g && o && u && u(), {
21
- totalVirtualSize: p.getTotalSize(),
22
- virtualItemsToDisplay: m
20
+ h.current = !1, m.current = i.length;
21
+ }, [i.length, v]), (i.length === 0 || i.length > 0 && m.current === 0) && c.current && (c.current.scrollTop = 0);
22
+ let y = _[_.length - 1], b = !!y && y.index >= i.length - 1;
23
+ e(() => {
24
+ if (!b) {
25
+ s || (h.current = !1);
26
+ return;
27
+ }
28
+ !s && o && u && !h.current && (h.current = !0, u());
29
+ }, [
30
+ s,
31
+ b,
32
+ o,
33
+ u,
34
+ i.length,
35
+ v
36
+ ]);
37
+ let x = _[0]?.index ?? -1, S = _[_.length - 1]?.index ?? -1, C = x < i.length ? x : -1, w = Math.min(S, i.length - 1);
38
+ return e(() => {
39
+ !p || C < 0 || p({
40
+ startIndex: C,
41
+ endIndex: w
42
+ });
43
+ }, [
44
+ C,
45
+ w,
46
+ p
47
+ ]), {
48
+ totalVirtualSize: g.getTotalSize(),
49
+ virtualItemsToDisplay: _
23
50
  };
24
51
  };
25
52
  export { o as useInfiniteScrollTableItems };
@@ -9,19 +9,21 @@ import { Column as s, DataTableWrapper as c, ListCheckbox as l, TableHeader as u
9
9
  import { useRef as f } from "react";
10
10
  import { useIntl as p } from "react-intl";
11
11
  import { jsx as m, jsxs as h } from "react/jsx-runtime";
12
- var g = ({ areSelectionCheckboxesDisabled: g = !1, columns: _, dataTargetPrefix: v, hasNextPage: y = !1, iconColumnVariant: b, isInfiniteScrollEnabled: x = !1, isLoading: S = !1, isSelectAllEnabled: C, itemActionMenuProps: w, items: T, maxActionColumnWidth: E, minActionColumnWidth: D, onGetNextPage: O, onInlineEditChange: k, onTableRowClick: A, placeholderRowsCount: j, zoomLevel: M, ...N }) => {
13
- let { formatMessage: P } = p(), F = f(null), { virtualItemsToDisplay: I, totalVirtualSize: L } = n({
12
+ var g = ({ areSelectionCheckboxesDisabled: g = !1, columns: _, dataTargetPrefix: v, hasNextPage: y = !1, iconColumnVariant: b, isInfiniteScrollEnabled: x = !1, isLoading: S = !1, isSelectAllEnabled: C, itemActionMenuProps: w, items: T, maxActionColumnWidth: E, minActionColumnWidth: D, onGetNextPage: O, onInlineEditChange: k, onTableRowClick: A, placeholderRowsCount: j, zoomLevel: M, getItemKey: N, onVisibleRangeChange: P, renderActionCell: F, ...I }) => {
13
+ let { formatMessage: L } = p(), R = f(null), { virtualItemsToDisplay: z, totalVirtualSize: B } = n({
14
14
  items: T,
15
15
  hasNextPage: y,
16
16
  isLoading: S,
17
- parentRef: F,
17
+ parentRef: R,
18
18
  onGetNextPage: O,
19
- placeholderRowsCount: j
20
- }), R = [];
19
+ placeholderRowsCount: j,
20
+ getItemKey: N,
21
+ onVisibleRangeChange: P
22
+ }), V = [];
21
23
  if (b === e.COLUMN) {
22
24
  M ||= 0;
23
25
  let e = parseInt(t[M], 10) + 24;
24
- R.push({
26
+ V.push({
25
27
  id: "item-type-icon",
26
28
  isRowHeader: !1,
27
29
  hideHeader: !1,
@@ -29,7 +31,7 @@ var g = ({ areSelectionCheckboxesDisabled: g = !1, columns: _, dataTargetPrefix:
29
31
  maxWidth: e
30
32
  });
31
33
  }
32
- let z = _.map((e) => {
34
+ let H = _.map((e) => {
33
35
  let { id: t, isRowHeader: n, headerRenderer: r, textValue: i, type: a, allowsSorting: o, ...s } = e, c = a !== "multiSelect" && a !== "enum" && o === !0;
34
36
  return {
35
37
  ...s,
@@ -43,13 +45,13 @@ var g = ({ areSelectionCheckboxesDisabled: g = !1, columns: _, dataTargetPrefix:
43
45
  allowsSorting: c
44
46
  };
45
47
  });
46
- R.push(...z), a(N) && R.push({
48
+ V.push(...H), a(I, !!F) && V.push({
47
49
  id: "actions",
48
50
  className: i.tableHeaderActions,
49
51
  children: /* @__PURE__ */ h("div", {
50
52
  className: i.tableHeaderActionsWrapper,
51
- children: [N.HeaderActions, C ? /* @__PURE__ */ m(l, {
52
- "aria-label": P(r.selectAll),
53
+ children: [I.HeaderActions, C ? /* @__PURE__ */ m(l, {
54
+ "aria-label": L(r.selectAll),
53
55
  className: i.selectAllCheckbox,
54
56
  isDisabled: S || g
55
57
  }) : null]
@@ -60,14 +62,14 @@ var g = ({ areSelectionCheckboxesDisabled: g = !1, columns: _, dataTargetPrefix:
60
62
  maxWidth: E,
61
63
  minWidth: D
62
64
  });
63
- let B = /* @__PURE__ */ m(u, {
64
- columns: R,
65
+ let U = /* @__PURE__ */ m(u, {
66
+ columns: V,
65
67
  children: (e) => /* @__PURE__ */ m(s, { ...e })
66
- }), V = {
67
- columnCount: R.length,
68
+ }), W = {
69
+ columnCount: V.length,
68
70
  columns: _,
69
71
  dataTargetPrefix: v,
70
- formatMessage: P,
72
+ formatMessage: L,
71
73
  iconColumnVariant: b,
72
74
  isLoading: S,
73
75
  areSelectionCheckboxesDisabled: g,
@@ -75,17 +77,18 @@ var g = ({ areSelectionCheckboxesDisabled: g = !1, columns: _, dataTargetPrefix:
75
77
  items: T,
76
78
  onInlineEditChange: k,
77
79
  onTableRowClick: A,
78
- tableHeader: B,
79
- tableProps: N,
80
- zoomLevel: M
80
+ tableHeader: U,
81
+ tableProps: I,
82
+ zoomLevel: M,
83
+ renderActionCell: F
81
84
  };
82
85
  return x ? /* @__PURE__ */ m(c, {
83
- ref: F,
86
+ ref: R,
84
87
  children: /* @__PURE__ */ m(o, {
85
- ...V,
86
- totalVirtualSize: L,
87
- virtualItems: I
88
+ ...W,
89
+ totalVirtualSize: B,
90
+ virtualItems: z
88
91
  })
89
- }) : /* @__PURE__ */ m(o, { ...V });
92
+ }) : /* @__PURE__ */ m(o, { ...W });
90
93
  };
91
94
  export { g as MetadataTable };
@@ -0,0 +1,13 @@
1
+ import { t as e } from "../../../../../chunks/item-action-menu.js";
2
+ import { ActionCell as t } from "@box/blueprint-web";
3
+ import n from "react";
4
+ import { jsx as r } from "react/jsx-runtime";
5
+ var i = /*#__PURE__*/ n.memo(({ item: n, itemActionMenuProps: i, isCheckboxDisabled: a, renderActionCell: o }) => /* @__PURE__ */ r(t, {
6
+ isCheckboxDisabled: a,
7
+ children: (t) => o ? o(n, t) : i ? /* @__PURE__ */ r(e, {
8
+ ...i,
9
+ item: n,
10
+ onOpenChange: t
11
+ }) : null
12
+ }));
13
+ export { i as ActionCellContent };
@@ -1,138 +1,133 @@
1
1
  import { t as e } from "../../../../../chunks/types.js";
2
- import { t } from "../../../../../chunks/item-action-menu.js";
3
- import { THUMBNAIL_LIST_VIEW_HEIGHTS as n } from "../../constants.js";
4
- import { GhostTableRow as r } from "./ghost-table-row/ghost-table-row.js";
2
+ import { THUMBNAIL_LIST_VIEW_HEIGHTS as t } from "../../constants.js";
3
+ import { GhostTableRow as n } from "./ghost-table-row/ghost-table-row.js";
4
+ import { ActionCellContent as r } from "./action-cell-content.js";
5
5
  import { t as i } from "../../../../../chunks/inline-editing-cell.js";
6
6
  import { n as a, t as o } from "../../../../../chunks/table-row.js";
7
- import { ActionCell as s, Cell as c, Row as l, TableBody as u, Text as d } from "@box/blueprint-web";
8
- import f from "react";
9
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
10
- import { ItemTypeIcon as h } from "@box/item-icon";
11
- import g from "clsx";
12
- import _ from "lodash/get";
13
- var v = (e, t, n) => _(e, n ? t.split(".")[1] : t), y = /* @__PURE__ */ f.memo(({ column: t, iconColumnVariant: n, item: r }) => {
14
- let { id: i, isItemMetadata: o, subtitle: s, textValue: l } = t, u = `${l}-${r.id}`;
15
- return /* @__PURE__ */ p(c, { children: /* @__PURE__ */ m("div", {
7
+ import { Cell as s, Row as c, TableBody as l, Text as u } from "@box/blueprint-web";
8
+ import d from "react";
9
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
10
+ import { ItemTypeIcon as m } from "@box/item-icon";
11
+ import h from "clsx";
12
+ import g from "lodash/get";
13
+ var _ = (e, t, n) => g(e, n ? t.split(".")[1] : t), v = /*#__PURE__*/ d.memo(({ column: t, iconColumnVariant: n, item: r }) => {
14
+ let { id: i, isItemMetadata: o, subtitle: c, textValue: l } = t, d = `${l}-${r.id}`;
15
+ return /* @__PURE__ */ f(s, { children: /* @__PURE__ */ p("div", {
16
16
  className: a.tableNameCell,
17
- children: [/* @__PURE__ */ p(h, {
17
+ children: [/* @__PURE__ */ f(m, {
18
18
  className: a.tableNameCellIconInline,
19
19
  item: r
20
- }), /* @__PURE__ */ m("div", {
21
- className: g(a.tableNameCellTitle, { [a.hasSubtitle]: n === e.INLINE_SUBTITLE }),
22
- children: [/* @__PURE__ */ p(d, {
20
+ }), /* @__PURE__ */ p("div", {
21
+ className: h(a.tableNameCellTitle, { [a.hasSubtitle]: n === e.INLINE_SUBTITLE }),
22
+ children: [/* @__PURE__ */ f(u, {
23
23
  as: "span",
24
24
  className: a.tableNameCellText,
25
- children: v(r, i, o)
26
- }), n === e.INLINE_SUBTITLE && /* @__PURE__ */ p(d, {
25
+ children: _(r, i, o)
26
+ }), n === e.INLINE_SUBTITLE && /* @__PURE__ */ f(u, {
27
27
  as: "span",
28
28
  className: a.tableNameCellText,
29
29
  color: "textOnLightSecondary",
30
- children: s
30
+ children: c
31
31
  })]
32
32
  })]
33
- }) }, u);
34
- }), b = /* @__PURE__ */ f.memo(({ column: e, item: t }) => {
33
+ }) }, d);
34
+ }), y = /*#__PURE__*/ d.memo(({ column: e, item: t }) => {
35
35
  let n = `${e.textValue}-${t.id}`;
36
- return /* @__PURE__ */ p(c, { children: e.cellRenderer?.(t, e) }, n);
37
- }), x = /* @__PURE__ */ f.memo(({ column: e, item: t }) => {
38
- let n = `${e.textValue}-${t.id}`, r = _(t, e.id);
39
- return r ? /* @__PURE__ */ p(c, { children: r.join(" ") }, n) : /* @__PURE__ */ p(c, {}, n);
40
- }), S = /* @__PURE__ */ f.memo(({ column: e, item: t }) => {
36
+ return /* @__PURE__ */ f(s, { children: e.cellRenderer?.(t, e) }, n);
37
+ }), b = /*#__PURE__*/ d.memo(({ column: e, item: t }) => {
38
+ let n = `${e.textValue}-${t.id}`, r = g(t, e.id);
39
+ return r ? /* @__PURE__ */ f(s, { children: r.join(" ") }, n) : /* @__PURE__ */ f(s, {}, n);
40
+ }), x = /*#__PURE__*/ d.memo(({ column: e, item: t }) => {
41
41
  let { id: n, isItemMetadata: r, textValue: i } = e, a = `${i}-${t.id}`;
42
- return /* @__PURE__ */ p(c, { children: /* @__PURE__ */ p(d, {
42
+ return /* @__PURE__ */ f(s, { children: /* @__PURE__ */ f(u, {
43
43
  as: "span",
44
- children: v(t, n, r)
44
+ children: _(t, n, r)
45
45
  }) }, a);
46
- }), C = /* @__PURE__ */ f.memo(({ column: t, iconColumnVariant: n, item: r, onInlineEditChange: a }) => {
46
+ }), S = /*#__PURE__*/ d.memo(({ column: t, iconColumnVariant: n, item: r, onInlineEditChange: a }) => {
47
47
  let { cellRenderer: o, id: s, isInlineEditingEnabled: c, type: l } = t, u = s === "item.name" && (n === e.INLINE || n === e.INLINE_SUBTITLE);
48
- return o ? /* @__PURE__ */ p(b, {
48
+ return o ? /* @__PURE__ */ f(y, {
49
49
  column: t,
50
50
  item: r
51
- }) : u ? /* @__PURE__ */ p(y, {
51
+ }) : u ? /* @__PURE__ */ f(v, {
52
52
  column: t,
53
53
  iconColumnVariant: n,
54
54
  item: r
55
- }) : c && (l === "multiSelect" || l === "enum") ? /* @__PURE__ */ p(i, {
55
+ }) : c && (l === "multiSelect" || l === "enum") ? /* @__PURE__ */ f(i, {
56
56
  column: t,
57
57
  item: r,
58
58
  onInlineEditChange: a
59
- }, `${t.id}-${r.id}`) : p(l === "multiSelect" ? x : S, {
59
+ }, `${t.id}-${r.id}`) : f(l === "multiSelect" ? b : x, {
60
60
  column: t,
61
61
  item: r
62
62
  });
63
- }), w = /* @__PURE__ */ f.memo(({ item: e, zoomLevel: t }) => /* @__PURE__ */ p(c, {
64
- style: { height: n[t] },
65
- children: /* @__PURE__ */ p(h, {
63
+ }), C = /*#__PURE__*/ d.memo(({ item: e, zoomLevel: n }) => /* @__PURE__ */ f(s, {
64
+ style: { height: t[n] },
65
+ children: /* @__PURE__ */ f(m, {
66
66
  className: a.iconCell,
67
67
  item: e
68
68
  })
69
- }, `item-type-icon-${e.id}`)), T = /* @__PURE__ */ f.memo(({ item: e, itemActionMenuProps: n, isCheckboxDisabled: r }) => /* @__PURE__ */ p(s, {
70
- isCheckboxDisabled: r,
71
- children: (r) => n ? /* @__PURE__ */ p(t, {
72
- ...n,
73
- item: e,
74
- onOpenChange: r
75
- }) : null
76
- })), E = ({ areSelectionCheckboxesDisabled: t, columnCount: n, columns: i, dataTargetPrefix: s, iconColumnVariant: c, items: d, itemActionMenuProps: f, onInlineEditChange: h, onTableRowClick: _, shouldRenderActionColumn: v, virtualItems: y, totalVirtualSize: b, zoomLevel: x }) => {
77
- let S = c === e.COLUMN;
78
- if (y) {
79
- let e = (e) => /* @__PURE__ */ p(r, {
80
- columnLength: n || 0,
69
+ }, `item-type-icon-${e.id}`)), w = ({ areSelectionCheckboxesDisabled: t, columnCount: i, columns: s, dataTargetPrefix: u, iconColumnVariant: d, items: m, itemActionMenuProps: g, onInlineEditChange: _, onTableRowClick: v, renderActionCell: y, shouldRenderActionColumn: b, virtualItems: x, totalVirtualSize: w, zoomLevel: T }) => {
70
+ let E = d === e.COLUMN;
71
+ if (x) {
72
+ let e = (e) => /* @__PURE__ */ f(n, {
73
+ columnLength: i || 0,
81
74
  rowKey: `ghost-${e}`
82
- }), a = (e) => /* @__PURE__ */ p(o, {
75
+ }), r = (e) => /* @__PURE__ */ f(o, {
83
76
  areSelectionCheckboxesDisabled: t,
84
- columns: i,
85
- dataTargetPrefix: s,
86
- iconColumnVariant: c,
77
+ columns: s,
78
+ dataTargetPrefix: u,
79
+ iconColumnVariant: d,
87
80
  item: e,
88
- itemActionMenuProps: f,
89
- onTableRowClick: _,
90
- shouldRenderActionColumn: v,
91
- zoomLevel: x
92
- }), h = () => y[0]?.start || 0, g = () => {
93
- let e = y[y.length - 1]?.end || 0;
94
- return Math.max((b || 0) - e, 0);
95
- }, S = h(), C = g();
96
- return /* @__PURE__ */ m(u, { children: [
97
- !!S && /* @__PURE__ */ p(l, {
81
+ itemActionMenuProps: g,
82
+ onTableRowClick: v,
83
+ renderActionCell: y,
84
+ shouldRenderActionColumn: b,
85
+ zoomLevel: T
86
+ }), a = () => x[0]?.start || 0, h = () => {
87
+ let e = x[x.length - 1]?.end || 0;
88
+ return Math.max((w || 0) - e, 0);
89
+ }, _ = a(), S = h();
90
+ return /* @__PURE__ */ p(l, { children: [
91
+ !!_ && /* @__PURE__ */ f(c, {
98
92
  isDisabled: !0,
99
- style: { height: `${S}px` }
93
+ style: { height: `${_}px` }
100
94
  }),
101
- y.map(({ index: t }) => t >= d.length ? e(t) : a(d[t])),
102
- !!C && /* @__PURE__ */ p(l, {
95
+ x.map(({ index: t }) => t >= m.length ? e(t) : r(m[t])),
96
+ !!S && /* @__PURE__ */ f(c, {
103
97
  isDisabled: !0,
104
- style: { height: `${C}px` }
98
+ style: { height: `${S}px` }
105
99
  })
106
100
  ] });
107
101
  }
108
- return /* @__PURE__ */ p(u, {
109
- items: d.map((e) => ({
102
+ return /* @__PURE__ */ f(l, {
103
+ items: m.map((e) => ({
110
104
  key: e.id,
111
105
  ...e
112
106
  })),
113
- children: (e) => /* @__PURE__ */ m(l, {
114
- className: g(a.tableRow, { [a.isClickable]: _ }),
115
- "data-target-id": s ? `${s}-itemRow-${e.id}` : void 0,
107
+ children: (e) => /* @__PURE__ */ p(c, {
108
+ className: h(a.tableRow, { [a.isClickable]: v }),
109
+ "data-target-id": u ? `${u}-itemRow-${e.id}` : void 0,
116
110
  id: e.id,
117
- onAction: () => _?.(e),
111
+ onAction: () => v?.(e),
118
112
  children: [
119
- S && /* @__PURE__ */ p(w, {
113
+ E && /* @__PURE__ */ f(C, {
120
114
  item: e,
121
- zoomLevel: x
115
+ zoomLevel: T
122
116
  }),
123
- i.map((t) => /* @__PURE__ */ p(C, {
117
+ s.map((t) => /* @__PURE__ */ f(S, {
124
118
  column: t,
125
- iconColumnVariant: c,
119
+ iconColumnVariant: d,
126
120
  item: e,
127
- onInlineEditChange: h
121
+ onInlineEditChange: _
128
122
  }, `${t.textValue}-${e.id}`)),
129
- v && /* @__PURE__ */ p(T, {
123
+ b && /* @__PURE__ */ f(r, {
130
124
  isCheckboxDisabled: t,
131
125
  item: e,
132
- itemActionMenuProps: f
126
+ itemActionMenuProps: g,
127
+ renderActionCell: y
133
128
  })
134
129
  ]
135
130
  }, e.id)
136
131
  });
137
132
  };
138
- export { E as default };
133
+ export { w as default };
@@ -5,19 +5,19 @@ import r from "./table-body/table-body-with-data.js";
5
5
  import { getShouldRenderActionColumn as i } from "./actionColumn.js";
6
6
  import { Table as a } from "@box/blueprint-web";
7
7
  import { jsx as o, jsxs as s } from "react/jsx-runtime";
8
- var c = ({ columnCount: c, columns: l, dataTargetPrefix: u, formatMessage: d, iconColumnVariant: f, isLoading: p, areSelectionCheckboxesDisabled: m, itemActionMenuProps: h, items: g, onInlineEditChange: _, onTableRowClick: v, style: y, tableHeader: b, tableProps: x, virtualItems: S, totalVirtualSize: C, zoomLevel: w }) => {
9
- let T = i(x), E = c || (() => {
8
+ var c = ({ columnCount: c, columns: l, dataTargetPrefix: u, formatMessage: d, iconColumnVariant: f, isLoading: p, areSelectionCheckboxesDisabled: m, itemActionMenuProps: h, items: g, onInlineEditChange: _, onTableRowClick: v, renderActionCell: y, style: b, tableHeader: x, tableProps: S, virtualItems: C, totalVirtualSize: w, zoomLevel: T }) => {
9
+ let E = i(S, !!y), D = c || (() => {
10
10
  let t = l.length;
11
- return f === e.COLUMN && (t += 1), T && (t += 1), t;
12
- })(), D = p && !S?.length;
11
+ return f === e.COLUMN && (t += 1), E && (t += 1), t;
12
+ })(), O = p && !C?.length;
13
13
  return /* @__PURE__ */ s(a, {
14
14
  "aria-label": d(n.listView),
15
15
  selectionBehavior: "toggle",
16
- style: y,
17
- ...x,
18
- children: [b, D ? /* @__PURE__ */ o(t, { columnLength: E }) : /* @__PURE__ */ o(r, {
16
+ style: b,
17
+ ...S,
18
+ children: [x, O ? /* @__PURE__ */ o(t, { columnLength: D }) : /* @__PURE__ */ o(r, {
19
19
  areSelectionCheckboxesDisabled: m,
20
- columnCount: E,
20
+ columnCount: D,
21
21
  columns: l,
22
22
  dataTargetPrefix: u,
23
23
  iconColumnVariant: f,
@@ -26,10 +26,11 @@ var c = ({ columnCount: c, columns: l, dataTargetPrefix: u, formatMessage: d, ic
26
26
  items: g,
27
27
  onInlineEditChange: _,
28
28
  onTableRowClick: v,
29
- shouldRenderActionColumn: T,
30
- totalVirtualSize: C,
31
- virtualItems: S,
32
- zoomLevel: w
29
+ renderActionCell: y,
30
+ shouldRenderActionColumn: E,
31
+ totalVirtualSize: w,
32
+ virtualItems: C,
33
+ zoomLevel: T
33
34
  })]
34
35
  });
35
36
  };
@@ -2,5 +2,5 @@ interface TableProps {
2
2
  HeaderActions?: React.ReactElement;
3
3
  selectionMode?: string;
4
4
  }
5
- export declare function getShouldRenderActionColumn(tableProps: TableProps): boolean;
5
+ export declare function getShouldRenderActionColumn(tableProps: TableProps, hasRenderActionCell?: boolean): boolean;
6
6
  export {};
@@ -1,4 +1,9 @@
1
1
  import { Item } from '@box/types';
2
+ /** The indices of the first and last currently-virtualized (visible) rows. */
3
+ export type VisibleRange = {
4
+ startIndex: number;
5
+ endIndex: number;
6
+ };
2
7
  type UseInfiniteScrollTableItemsProps = {
3
8
  items: Item[];
4
9
  hasNextPage?: boolean;
@@ -7,8 +12,12 @@ type UseInfiniteScrollTableItemsProps = {
7
12
  approximateRowHeight?: number;
8
13
  onGetNextPage?: () => void;
9
14
  placeholderRowsCount?: number;
15
+ /** Custom key function for the virtualizer. Defaults to item.id. */
16
+ getItemKey?: (item: Item, index: number) => string;
17
+ /** Called when the first or last visible row index changes. */
18
+ onVisibleRangeChange?: (range: VisibleRange) => void;
10
19
  };
11
- export declare const useInfiniteScrollTableItems: ({ items, hasNextPage, isLoading, parentRef, approximateRowHeight, onGetNextPage, placeholderRowsCount, }: UseInfiniteScrollTableItemsProps) => {
20
+ export declare const useInfiniteScrollTableItems: ({ items, hasNextPage, isLoading, parentRef, approximateRowHeight, onGetNextPage, placeholderRowsCount, getItemKey, onVisibleRangeChange, }: UseInfiniteScrollTableItemsProps) => {
12
21
  totalVirtualSize: number;
13
22
  virtualItemsToDisplay: import('@tanstack/virtual-core').VirtualItem[];
14
23
  };
@@ -1,5 +1,5 @@
1
1
  export { MetadataTable } from './metadata-table';
2
- export type { MetadataTableProps } from './metadata-table';
2
+ export type { MetadataTableProps, RenderActionCell, VisibleRange } from './metadata-table';
3
3
  export { InlineEditingCell } from './table-body/inline-editing-cell';
4
4
  export type { InlineEditingCellProps } from './table-body/inline-editing-cell';
5
5
  export * from './table-renderer';
@@ -1,7 +1,11 @@
1
1
  import { TableProps } from '@box/blueprint-web';
2
2
  import { Item } from '@box/types';
3
+ import { VisibleRange } from './hooks/useInfiniteScrollTableItems';
3
4
  import { IconColumnVariant, Column, MetadataProps } from '../../types';
4
5
  import { InlineEditingCellProps } from './table-body/inline-editing-cell';
6
+ export type { VisibleRange };
7
+ /** Custom action cell renderer. When provided, replaces ItemActionMenu inside ActionCell. */
8
+ export type RenderActionCell = (item: Item, onOpenChange: (open: boolean) => void) => React.ReactNode;
5
9
  export interface MetadataTableProps extends TableProps, MetadataProps, Pick<InlineEditingCellProps, 'onInlineEditChange'> {
6
10
  areSelectionCheckboxesDisabled?: boolean;
7
11
  columns: Column[];
@@ -17,5 +21,8 @@ export interface MetadataTableProps extends TableProps, MetadataProps, Pick<Inli
17
21
  onTableRowClick?: (item: Item) => void;
18
22
  placeholderRowsCount?: number;
19
23
  zoomLevel?: number;
24
+ getItemKey?: (item: Item, index: number) => string;
25
+ onVisibleRangeChange?: (range: VisibleRange) => void;
26
+ renderActionCell?: RenderActionCell;
20
27
  }
21
- export declare const MetadataTable: ({ areSelectionCheckboxesDisabled, columns, dataTargetPrefix, hasNextPage, iconColumnVariant, isInfiniteScrollEnabled, isLoading, isSelectAllEnabled, itemActionMenuProps, items, maxActionColumnWidth, minActionColumnWidth, onGetNextPage, onInlineEditChange, onTableRowClick, placeholderRowsCount, zoomLevel, ...tableProps }: MetadataTableProps) => import("react/jsx-runtime").JSX.Element;
28
+ export declare const MetadataTable: ({ areSelectionCheckboxesDisabled, columns, dataTargetPrefix, hasNextPage, iconColumnVariant, isInfiniteScrollEnabled, isLoading, isSelectAllEnabled, itemActionMenuProps, items, maxActionColumnWidth, minActionColumnWidth, onGetNextPage, onInlineEditChange, onTableRowClick, placeholderRowsCount, zoomLevel, getItemKey, onVisibleRangeChange, renderActionCell, ...tableProps }: MetadataTableProps) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,17 @@
1
+ import { Item } from '@box/types';
2
+ import { default as React } from 'react';
3
+ import { ItemActionMenuProps } from '../../item-action-menu';
4
+ import { RenderActionCell } from '../metadata-table';
5
+ export interface ActionCellContentProps {
6
+ item: Item;
7
+ itemActionMenuProps?: Omit<ItemActionMenuProps, 'item' | 'onOpenChange' | 'viewMode'>;
8
+ isCheckboxDisabled?: boolean;
9
+ renderActionCell?: RenderActionCell;
10
+ }
11
+ /**
12
+ * Renders the trailing action cell for a table row. A consumer-provided
13
+ * `renderActionCell` takes precedence; otherwise it falls back to the default
14
+ * `ItemActionMenu`. Shared by both the virtualized (TableRow) and
15
+ * non-virtualized (TableBodyWithData) render paths.
16
+ */
17
+ export declare const ActionCellContent: React.MemoExoticComponent<({ item, itemActionMenuProps, isCheckboxDisabled, renderActionCell }: ActionCellContentProps) => import("react/jsx-runtime").JSX.Element>;
@@ -2,10 +2,11 @@ import { TableProps } from '@box/blueprint-web';
2
2
  import { Item } from '@box/types';
3
3
  import { VirtualItem } from '@tanstack/react-virtual';
4
4
  import { IconColumnVariant, Column } from '../../../types';
5
- import { MetadataTableProps } from '../metadata-table';
5
+ import { MetadataTableProps, RenderActionCell } from '../metadata-table';
6
6
  import { InlineEditingCellProps } from './inline-editing-cell';
7
7
  interface TableBodyWithDataProps extends Omit<MetadataTableProps, keyof TableProps>, Pick<InlineEditingCellProps, 'onInlineEditChange'> {
8
8
  columnCount?: number;
9
+ renderActionCell?: RenderActionCell;
9
10
  shouldRenderActionColumn?: boolean;
10
11
  totalVirtualSize?: number;
11
12
  virtualItems?: VirtualItem[];
@@ -16,5 +17,5 @@ type CellProps = {
16
17
  iconColumnVariant: IconColumnVariant;
17
18
  };
18
19
  export type DataCellProps = CellProps & Pick<InlineEditingCellProps, 'onInlineEditChange'>;
19
- declare const TableBodyWithData: ({ areSelectionCheckboxesDisabled, columnCount, columns, dataTargetPrefix, iconColumnVariant, items, itemActionMenuProps, onInlineEditChange, onTableRowClick, shouldRenderActionColumn, virtualItems, totalVirtualSize, zoomLevel, }: TableBodyWithDataProps) => import("react/jsx-runtime").JSX.Element;
20
+ declare const TableBodyWithData: ({ areSelectionCheckboxesDisabled, columnCount, columns, dataTargetPrefix, iconColumnVariant, items, itemActionMenuProps, onInlineEditChange, onTableRowClick, renderActionCell, shouldRenderActionColumn, virtualItems, totalVirtualSize, zoomLevel, }: TableBodyWithDataProps) => import("react/jsx-runtime").JSX.Element;
20
21
  export default TableBodyWithData;
@@ -8,7 +8,9 @@ export interface TableRowProps {
8
8
  item: Item;
9
9
  itemActionMenuProps: MetadataTableProps['itemActionMenuProps'];
10
10
  onTableRowClick: MetadataTableProps['onTableRowClick'];
11
+ /** Custom action cell renderer. When provided, replaces ItemActionMenu inside ActionCell. */
12
+ renderActionCell?: MetadataTableProps['renderActionCell'];
11
13
  shouldRenderActionColumn?: boolean;
12
14
  zoomLevel?: number;
13
15
  }
14
- export declare const TableRow: ({ areSelectionCheckboxesDisabled, columns, dataTargetPrefix, iconColumnVariant, item, itemActionMenuProps, onTableRowClick, shouldRenderActionColumn, zoomLevel, }: TableRowProps) => import("react/jsx-runtime").JSX.Element;
16
+ export declare const TableRow: ({ areSelectionCheckboxesDisabled, columns, dataTargetPrefix, iconColumnVariant, item, itemActionMenuProps, onTableRowClick, renderActionCell, shouldRenderActionColumn, zoomLevel, }: TableRowProps) => import("react/jsx-runtime").JSX.Element;
@@ -3,6 +3,7 @@ import { useIntl } from 'react-intl';
3
3
  import { TableProps } from '@box/blueprint-web';
4
4
  import { Item } from '@box/types';
5
5
  import { IconColumnVariant, Column, MetadataProps } from '../../types';
6
+ import { RenderActionCell } from './metadata-table';
6
7
  import { InlineEditingCellProps } from './table-body/inline-editing-cell';
7
8
  export interface TableRendererProps extends Pick<InlineEditingCellProps, 'onInlineEditChange'> {
8
9
  columns: Column[];
@@ -15,6 +16,8 @@ export interface TableRendererProps extends Pick<InlineEditingCellProps, 'onInli
15
16
  itemActionMenuProps?: MetadataProps['itemActionMenuProps'];
16
17
  items: MetadataProps['items'];
17
18
  onTableRowClick?: (item: Item) => void;
19
+ /** Custom action cell renderer. When provided, replaces ItemActionMenu inside ActionCell. */
20
+ renderActionCell?: RenderActionCell;
18
21
  style?: React.CSSProperties;
19
22
  tableHeader: React.ReactNode;
20
23
  tableProps: TableProps;
@@ -22,4 +25,4 @@ export interface TableRendererProps extends Pick<InlineEditingCellProps, 'onInli
22
25
  totalVirtualSize?: number;
23
26
  zoomLevel?: number;
24
27
  }
25
- export declare const TableRenderer: ({ columnCount: passedColumnCount, columns, dataTargetPrefix, formatMessage, iconColumnVariant, isLoading, areSelectionCheckboxesDisabled, itemActionMenuProps, items, onInlineEditChange, onTableRowClick, style, tableHeader, tableProps, virtualItems, totalVirtualSize, zoomLevel, }: TableRendererProps) => import("react/jsx-runtime").JSX.Element;
28
+ export declare const TableRenderer: ({ columnCount: passedColumnCount, columns, dataTargetPrefix, formatMessage, iconColumnVariant, isLoading, areSelectionCheckboxesDisabled, itemActionMenuProps, items, onInlineEditChange, onTableRowClick, renderActionCell, style, tableHeader, tableProps, virtualItems, totalVirtualSize, zoomLevel, }: TableRendererProps) => import("react/jsx-runtime").JSX.Element;
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@box/metadata-view",
3
- "version": "2.0.1",
3
+ "version": "2.2.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
- "@box/blueprint-web": "^16.0.0",
7
- "@box/blueprint-web-assets": "^5.0.0",
8
- "@box/box-item-type-selector": "^2.0.0",
9
- "@box/content-field": "^2.0.0",
10
- "@box/item-icon": "^3.0.0",
11
- "@box/metadata-filter": "^2.0.0",
12
- "@box/types": "3.0.0",
6
+ "@box/blueprint-web": "^16.1.1",
7
+ "@box/blueprint-web-assets": "^5.1.1",
8
+ "@box/box-item-type-selector": "^2.1.1",
9
+ "@box/content-field": "^2.1.1",
10
+ "@box/item-icon": "^3.2.0",
11
+ "@box/metadata-filter": "^2.1.2",
12
+ "@box/types": "3.1.1",
13
13
  "@tanstack/react-virtual": "^3.10.8",
14
14
  "formik": "^2.4.5",
15
15
  "lodash": "^4.17.15",
@@ -19,15 +19,15 @@
19
19
  "react-intl": "^6.4.2"
20
20
  },
21
21
  "devDependencies": {
22
- "@box/blueprint-web": "^16.0.0",
23
- "@box/blueprint-web-assets": "^5.0.0",
24
- "@box/box-item-type-selector": "^2.0.0",
25
- "@box/content-field": "^2.0.0",
26
- "@box/eslint-plugin-blueprint": "2.0.0",
27
- "@box/item-icon": "^3.0.0",
28
- "@box/metadata-filter": "^2.0.0",
29
- "@box/storybook-utils": "1.0.0",
30
- "@box/types": "3.0.0",
22
+ "@box/blueprint-web": "^16.1.1",
23
+ "@box/blueprint-web-assets": "^5.1.1",
24
+ "@box/box-item-type-selector": "^2.1.1",
25
+ "@box/content-field": "^2.1.1",
26
+ "@box/eslint-plugin-blueprint": "2.1.1",
27
+ "@box/item-icon": "^3.2.0",
28
+ "@box/metadata-filter": "^2.1.2",
29
+ "@box/storybook-utils": "1.1.1",
30
+ "@box/types": "3.1.1",
31
31
  "@tanstack/react-virtual": "^3.10.8",
32
32
  "react-intl": "^6.4.2"
33
33
  },