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