@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
|
|
2
|
-
import { useIntl as
|
|
3
|
-
import { IconButton as f, DropdownMenu as
|
|
4
|
-
import { Ellipsis as
|
|
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
|
|
7
|
-
import
|
|
8
|
-
import { jsxs as p, jsx as
|
|
9
|
-
import '../../../../styles/item-action-menu.css';const
|
|
10
|
-
tableActionBar:
|
|
11
|
-
actionItemIcon:
|
|
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
|
|
13
|
+
function A(c) {
|
|
14
14
|
return (t) => {
|
|
15
15
|
t.stopPropagation(), c();
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function x({
|
|
19
19
|
item: c,
|
|
20
20
|
label: t,
|
|
21
21
|
onClick: l,
|
|
22
|
-
icon:
|
|
23
|
-
isDisabled:
|
|
22
|
+
icon: r,
|
|
23
|
+
isDisabled: d
|
|
24
24
|
}) {
|
|
25
|
-
const i =
|
|
25
|
+
const i = A(() => {
|
|
26
26
|
l(c);
|
|
27
|
-
}), I =
|
|
28
|
-
return /* @__PURE__ */ p(
|
|
29
|
-
"data-target-id":
|
|
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__ */
|
|
33
|
-
className:
|
|
32
|
+
children: [/* @__PURE__ */ o(r, {
|
|
33
|
+
className: k.actionItemIcon
|
|
34
34
|
}), t]
|
|
35
35
|
}, t);
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function K({
|
|
38
38
|
actions: c,
|
|
39
39
|
inlineActions: t,
|
|
40
40
|
isDisabled: l,
|
|
41
|
-
item:
|
|
42
|
-
onOpenChange:
|
|
41
|
+
item: r,
|
|
42
|
+
onOpenChange: d,
|
|
43
43
|
subMenuActions: i,
|
|
44
44
|
subMenuTrigger: I,
|
|
45
|
-
viewMode:
|
|
45
|
+
viewMode: S = M.LIST
|
|
46
46
|
}) {
|
|
47
47
|
const {
|
|
48
|
-
formatMessage:
|
|
49
|
-
} =
|
|
50
|
-
label:
|
|
51
|
-
icon:
|
|
48
|
+
formatMessage: s
|
|
49
|
+
} = y(), {
|
|
50
|
+
label: N,
|
|
51
|
+
icon: _
|
|
52
52
|
} = I || {};
|
|
53
53
|
return /* @__PURE__ */ p("div", {
|
|
54
|
-
className:
|
|
55
|
-
children: [
|
|
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:
|
|
59
|
-
isDisabled: u
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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:
|
|
83
|
+
icon: R,
|
|
75
84
|
size: "large"
|
|
76
|
-
}) : /* @__PURE__ */
|
|
77
|
-
"aria-label":
|
|
78
|
-
"data-target-id":
|
|
85
|
+
}) : /* @__PURE__ */ o(h.ActionIconButton, {
|
|
86
|
+
"aria-label": s($.actionMenu),
|
|
87
|
+
"data-target-id": m(h.ActionIconButton, "openActionMenu"),
|
|
79
88
|
disabled: l,
|
|
80
|
-
icon:
|
|
89
|
+
icon: R
|
|
81
90
|
})
|
|
82
|
-
}), /* @__PURE__ */ p(
|
|
91
|
+
}), /* @__PURE__ */ p(a.Content, {
|
|
83
92
|
align: "start",
|
|
84
|
-
children: [c.map((n) => /* @__PURE__ */
|
|
85
|
-
item:
|
|
93
|
+
children: [c.map((n) => /* @__PURE__ */ o(x, {
|
|
94
|
+
item: r,
|
|
86
95
|
...n
|
|
87
|
-
}, n.label)), i && I && /* @__PURE__ */ p(
|
|
88
|
-
children: [/* @__PURE__ */ p(
|
|
89
|
-
"data-target-id":
|
|
90
|
-
children: [
|
|
91
|
-
className:
|
|
92
|
-
}),
|
|
93
|
-
}), /* @__PURE__ */ a
|
|
94
|
-
children: i.map((n) => /* @__PURE__ */
|
|
95
|
-
item:
|
|
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,
|
|
110
|
+
}) : null, S === M.GRID && (t == null ? void 0 : t.map(({
|
|
102
111
|
onClick: n,
|
|
103
112
|
label: e,
|
|
104
|
-
icon:
|
|
113
|
+
icon: g,
|
|
105
114
|
isDisabled: u
|
|
106
|
-
}) => /* @__PURE__ */
|
|
115
|
+
}) => /* @__PURE__ */ o(h.ActionIconButton, {
|
|
107
116
|
"aria-label": e,
|
|
108
|
-
"data-target-id":
|
|
109
|
-
disabled: (u == null ? void 0 : u(
|
|
110
|
-
icon:
|
|
111
|
-
onClick: () => n(
|
|
112
|
-
}, `${
|
|
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
|
-
|
|
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?:
|
|
15
|
+
inlineActions?: ItemInlineAction[];
|
|
13
16
|
isDisabled?: boolean;
|
|
14
17
|
item: Item;
|
|
15
18
|
onOpenChange: (open: boolean) => void;
|