@box/metadata-view 1.22.0 → 1.23.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,117 +1,126 @@
1
- import { useMemo as $ } from "react";
2
- import { useIntl as x } from "react-intl";
3
- import { IconButton as f, DropdownMenu as r, GridList as g } from "@box/blueprint-web";
4
- import { Ellipsis as T } from "@box/blueprint-web-assets/icons/Fill";
1
+ import T, { useMemo as j } from "react";
2
+ import { useIntl as y } from "react-intl";
3
+ import { IconButton as f, Tooltip as z, DropdownMenu as a, GridList as h } from "@box/blueprint-web";
4
+ import { Ellipsis as R } from "@box/blueprint-web-assets/icons/Fill";
5
5
  import { V as M } from "../../../../chunks/types.js";
6
- import _ from "./messages.js";
7
- import { getDataTargetId as d } from "./identifier.js";
8
- import { jsxs as p, jsx as a } from "react/jsx-runtime";
9
- import '../../../../styles/item-action-menu.css';const A = "_tableActionBar_akgtp_1", N = "_actionItemIcon_akgtp_6", B = {
10
- tableActionBar: A,
11
- actionItemIcon: N
6
+ import { getDataTargetId as m } from "./identifier.js";
7
+ import $ from "./messages.js";
8
+ import { jsxs as p, jsx as o } from "react/jsx-runtime";
9
+ import '../../../../styles/item-action-menu.css';const G = "_tableActionBar_akgtp_1", V = "_actionItemIcon_akgtp_6", k = {
10
+ tableActionBar: G,
11
+ actionItemIcon: V
12
12
  };
13
- function b(c) {
13
+ function A(c) {
14
14
  return (t) => {
15
15
  t.stopPropagation(), c();
16
16
  };
17
17
  }
18
- function L({
18
+ function x({
19
19
  item: c,
20
20
  label: t,
21
21
  onClick: l,
22
- icon: o,
23
- isDisabled: m
22
+ icon: r,
23
+ isDisabled: d
24
24
  }) {
25
- const i = b(() => {
25
+ const i = A(() => {
26
26
  l(c);
27
- }), I = $(() => (m == null ? void 0 : m(c)) ?? !1, [m, c]);
28
- return /* @__PURE__ */ p(r.Item, {
29
- "data-target-id": d(r.Item, t),
27
+ }), I = j(() => (d == null ? void 0 : d(c)) ?? !1, [d, c]);
28
+ return /* @__PURE__ */ p(a.Item, {
29
+ "data-target-id": m(a.Item, t),
30
30
  disabled: I,
31
31
  onClick: i,
32
- children: [/* @__PURE__ */ a(o, {
33
- className: B.actionItemIcon
32
+ children: [/* @__PURE__ */ o(r, {
33
+ className: k.actionItemIcon
34
34
  }), t]
35
35
  }, t);
36
36
  }
37
- function W({
37
+ function K({
38
38
  actions: c,
39
39
  inlineActions: t,
40
40
  isDisabled: l,
41
- item: o,
42
- onOpenChange: m,
41
+ item: r,
42
+ onOpenChange: d,
43
43
  subMenuActions: i,
44
44
  subMenuTrigger: I,
45
- viewMode: h = M.LIST
45
+ viewMode: S = M.LIST
46
46
  }) {
47
47
  const {
48
- formatMessage: k
49
- } = x(), {
50
- label: s,
51
- icon: C
48
+ formatMessage: s
49
+ } = y(), {
50
+ label: N,
51
+ icon: _
52
52
  } = I || {};
53
53
  return /* @__PURE__ */ p("div", {
54
- className: B.tableActionBar,
55
- children: [h === M.LIST && (t == null ? void 0 : t.map(({
54
+ className: k.tableActionBar,
55
+ children: [S === M.LIST && (t == null ? void 0 : t.map(({
56
56
  onClick: n,
57
57
  label: e,
58
- icon: S,
59
- isDisabled: u
60
- }) => /* @__PURE__ */ a(f, {
61
- "aria-label": e,
62
- "data-target-id": d(f, e),
63
- disabled: (u == null ? void 0 : u(o)) ?? !1,
64
- icon: S,
65
- onClick: b(() => n(o)),
66
- size: "large"
67
- }, `${o.id}-${e}`))), c ? /* @__PURE__ */ p(r.Root, {
68
- onOpenChange: m,
69
- children: [/* @__PURE__ */ a(r.Trigger, {
70
- children: h === M.LIST ? /* @__PURE__ */ a(f, {
71
- "aria-label": k(_.actionMenu),
72
- "data-target-id": d(f, "openActionMenu"),
58
+ icon: g,
59
+ isDisabled: u,
60
+ getTooltipContent: B
61
+ }) => {
62
+ const b = B == null ? void 0 : B(r), L = `${r.id}-${e}`, C = /* @__PURE__ */ o(f, {
63
+ "aria-label": e,
64
+ "data-target-id": m(f, e),
65
+ disabled: (u == null ? void 0 : u(r)) ?? !1,
66
+ icon: g,
67
+ onClick: A(() => n(r)),
68
+ size: "large"
69
+ });
70
+ return b ? /* @__PURE__ */ o(z, {
71
+ content: b,
72
+ children: C
73
+ }, L) : /* @__PURE__ */ o(T.Fragment, {
74
+ children: C
75
+ }, L);
76
+ })), c ? /* @__PURE__ */ p(a.Root, {
77
+ onOpenChange: d,
78
+ children: [/* @__PURE__ */ o(a.Trigger, {
79
+ children: S === M.LIST ? /* @__PURE__ */ o(f, {
80
+ "aria-label": s($.actionMenu),
81
+ "data-target-id": m(f, "openActionMenu"),
73
82
  disabled: l,
74
- icon: T,
83
+ icon: R,
75
84
  size: "large"
76
- }) : /* @__PURE__ */ a(g.ActionIconButton, {
77
- "aria-label": k(_.actionMenu),
78
- "data-target-id": d(g.ActionIconButton, "openActionMenu"),
85
+ }) : /* @__PURE__ */ o(h.ActionIconButton, {
86
+ "aria-label": s($.actionMenu),
87
+ "data-target-id": m(h.ActionIconButton, "openActionMenu"),
79
88
  disabled: l,
80
- icon: T
89
+ icon: R
81
90
  })
82
- }), /* @__PURE__ */ p(r.Content, {
91
+ }), /* @__PURE__ */ p(a.Content, {
83
92
  align: "start",
84
- children: [c.map((n) => /* @__PURE__ */ a(L, {
85
- item: o,
93
+ children: [c.map((n) => /* @__PURE__ */ o(x, {
94
+ item: r,
86
95
  ...n
87
- }, n.label)), i && I && /* @__PURE__ */ p(r.SubMenuRoot, {
88
- children: [/* @__PURE__ */ p(r.SubMenuTrigger, {
89
- "data-target-id": d(r.SubMenuTrigger, "openActionSubmenu"),
90
- children: [C && /* @__PURE__ */ a(C, {
91
- className: B.actionItemIcon
92
- }), s]
93
- }), /* @__PURE__ */ a(r.SubMenuContent, {
94
- children: i.map((n) => /* @__PURE__ */ a(L, {
95
- item: o,
96
+ }, n.label)), i && I && /* @__PURE__ */ p(a.SubMenuRoot, {
97
+ children: [/* @__PURE__ */ p(a.SubMenuTrigger, {
98
+ "data-target-id": m(a.SubMenuTrigger, "openActionSubmenu"),
99
+ children: [_ && /* @__PURE__ */ o(_, {
100
+ className: k.actionItemIcon
101
+ }), N]
102
+ }), /* @__PURE__ */ o(a.SubMenuContent, {
103
+ children: i.map((n) => /* @__PURE__ */ o(x, {
104
+ item: r,
96
105
  ...n
97
106
  }, n.label))
98
107
  })]
99
108
  })]
100
109
  })]
101
- }) : null, h === M.GRID && (t == null ? void 0 : t.map(({
110
+ }) : null, S === M.GRID && (t == null ? void 0 : t.map(({
102
111
  onClick: n,
103
112
  label: e,
104
- icon: S,
113
+ icon: g,
105
114
  isDisabled: u
106
- }) => /* @__PURE__ */ a(g.ActionIconButton, {
115
+ }) => /* @__PURE__ */ o(h.ActionIconButton, {
107
116
  "aria-label": e,
108
- "data-target-id": d(g.ActionIconButton, e),
109
- disabled: (u == null ? void 0 : u(o)) ?? !1,
110
- icon: S,
111
- onClick: () => n(o)
112
- }, `${o.id}-${e}`)))]
117
+ "data-target-id": m(h.ActionIconButton, e),
118
+ disabled: (u == null ? void 0 : u(r)) ?? !1,
119
+ icon: g,
120
+ onClick: () => n(r)
121
+ }, `${r.id}-${e}`)))]
113
122
  });
114
123
  }
115
124
  export {
116
- W as ItemActionMenu
125
+ K as ItemActionMenu
117
126
  };
@@ -7,9 +7,12 @@ export interface ItemAction {
7
7
  icon: FunctionComponent<PropsWithChildren<SVGProps<SVGSVGElement>>>;
8
8
  isDisabled?: (item: Item) => boolean;
9
9
  }
10
+ export interface ItemInlineAction extends ItemAction {
11
+ getTooltipContent?: (item: Item) => string;
12
+ }
10
13
  export interface ItemActionMenuProps {
11
14
  actions?: ItemAction[];
12
- inlineActions?: ItemAction[];
15
+ inlineActions?: ItemInlineAction[];
13
16
  isDisabled?: boolean;
14
17
  item: Item;
15
18
  onOpenChange: (open: boolean) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-view",
3
- "version": "1.22.0",
3
+ "version": "1.23.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@box/blueprint-web": "^12.76.2",