@box/metadata-view 1.17.3 → 1.18.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,8 @@
1
+ import a from "lodash/camelCase";
2
+ function r(n, e) {
3
+ const t = n.displayName || "UnknownComponent", o = a(e);
4
+ return `${t}-${o}`;
5
+ }
6
+ export {
7
+ r as getDataTargetId
8
+ };
@@ -1,110 +1,117 @@
1
1
  import { useMemo as $ } from "react";
2
2
  import { useIntl as x } from "react-intl";
3
- import { IconButton as C, DropdownMenu as e, GridList as i } from "@box/blueprint-web";
4
- import { Ellipsis as _ } from "@box/blueprint-web-assets/icons/Fill";
5
- import { V as d } from "../../../../chunks/types.js";
6
- import b from "./messages.js";
7
- import { jsxs as u, jsx as n } from "react/jsx-runtime";
8
- import '../../../../styles/item-action-menu.css';const N = "_tableActionBar_akgtp_1", R = "_actionItemIcon_akgtp_6", S = {
9
- tableActionBar: N,
10
- actionItemIcon: R
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";
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
11
12
  };
12
- function s(t) {
13
- return (o) => {
14
- o.stopPropagation(), t();
13
+ function b(c) {
14
+ return (t) => {
15
+ t.stopPropagation(), c();
15
16
  };
16
17
  }
17
18
  function L({
18
- item: t,
19
- label: o,
20
- onClick: p,
21
- icon: r,
22
- isDisabled: l
19
+ item: c,
20
+ label: t,
21
+ onClick: l,
22
+ icon: o,
23
+ isDisabled: m
23
24
  }) {
24
- const f = s(() => {
25
- p(t);
26
- }), I = $(() => (l == null ? void 0 : l(t)) ?? !1, [l, t]);
27
- return /* @__PURE__ */ u(e.Item, {
25
+ const i = b(() => {
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),
28
30
  disabled: I,
29
- onClick: f,
30
- children: [/* @__PURE__ */ n(r, {
31
- className: S.actionItemIcon
32
- }), o]
33
- }, o);
31
+ onClick: i,
32
+ children: [/* @__PURE__ */ a(o, {
33
+ className: B.actionItemIcon
34
+ }), t]
35
+ }, t);
34
36
  }
35
- function P({
36
- actions: t,
37
- inlineActions: o,
38
- isDisabled: p,
39
- item: r,
40
- onOpenChange: l,
41
- subMenuActions: f,
37
+ function W({
38
+ actions: c,
39
+ inlineActions: t,
40
+ isDisabled: l,
41
+ item: o,
42
+ onOpenChange: m,
43
+ subMenuActions: i,
42
44
  subMenuTrigger: I,
43
- viewMode: h = d.LIST
45
+ viewMode: h = M.LIST
44
46
  }) {
45
47
  const {
46
48
  formatMessage: k
47
49
  } = x(), {
48
- label: T,
49
- icon: B
50
+ label: s,
51
+ icon: C
50
52
  } = I || {};
51
- return /* @__PURE__ */ u("div", {
52
- className: S.tableActionBar,
53
- children: [h === d.LIST && (o == null ? void 0 : o.map(({
54
- onClick: a,
55
- label: m,
56
- icon: M,
57
- isDisabled: c
58
- }) => /* @__PURE__ */ n(C, {
59
- "aria-label": m,
60
- disabled: (c == null ? void 0 : c(r)) ?? !1,
61
- icon: M,
62
- onClick: s(() => a(r)),
53
+ return /* @__PURE__ */ p("div", {
54
+ className: B.tableActionBar,
55
+ children: [h === M.LIST && (t == null ? void 0 : t.map(({
56
+ onClick: n,
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)),
63
66
  size: "large"
64
- }, `${r.id}-${m}`))), t ? /* @__PURE__ */ u(e.Root, {
65
- onOpenChange: l,
66
- children: [/* @__PURE__ */ n(e.Trigger, {
67
- children: h === d.LIST ? /* @__PURE__ */ n(C, {
68
- "aria-label": k(b.actionMenu),
69
- disabled: p,
70
- icon: _,
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"),
73
+ disabled: l,
74
+ icon: T,
71
75
  size: "large"
72
- }) : /* @__PURE__ */ n(i.ActionIconButton, {
73
- "aria-label": k(b.actionMenu),
74
- disabled: p,
75
- icon: _
76
+ }) : /* @__PURE__ */ a(g.ActionIconButton, {
77
+ "aria-label": k(_.actionMenu),
78
+ "data-target-id": d(g.ActionIconButton, "openActionMenu"),
79
+ disabled: l,
80
+ icon: T
76
81
  })
77
- }), /* @__PURE__ */ u(e.Content, {
82
+ }), /* @__PURE__ */ p(r.Content, {
78
83
  align: "start",
79
- children: [t.map((a) => /* @__PURE__ */ n(L, {
80
- item: r,
81
- ...a
82
- }, a.label)), f && I && /* @__PURE__ */ u(e.SubMenuRoot, {
83
- children: [/* @__PURE__ */ u(e.SubMenuTrigger, {
84
- children: [B && /* @__PURE__ */ n(B, {
85
- className: S.actionItemIcon
86
- }), T]
87
- }), /* @__PURE__ */ n(e.SubMenuContent, {
88
- children: f.map((a) => /* @__PURE__ */ n(L, {
89
- item: r,
90
- ...a
91
- }, a.label))
84
+ children: [c.map((n) => /* @__PURE__ */ a(L, {
85
+ item: o,
86
+ ...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
97
+ }, n.label))
92
98
  })]
93
99
  })]
94
100
  })]
95
- }) : null, h === d.GRID && (o == null ? void 0 : o.map(({
96
- onClick: a,
97
- label: m,
98
- icon: M,
99
- isDisabled: c
100
- }) => /* @__PURE__ */ n(i.ActionIconButton, {
101
- "aria-label": m,
102
- disabled: (c == null ? void 0 : c(r)) ?? !1,
103
- icon: M,
104
- onClick: () => a(r)
105
- }, `${r.id}-${m}`)))]
101
+ }) : null, h === M.GRID && (t == null ? void 0 : t.map(({
102
+ onClick: n,
103
+ label: e,
104
+ icon: S,
105
+ isDisabled: u
106
+ }) => /* @__PURE__ */ a(g.ActionIconButton, {
107
+ "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}`)))]
106
113
  });
107
114
  }
108
115
  export {
109
- P as ItemActionMenu
116
+ W as ItemActionMenu
110
117
  };
@@ -5,12 +5,12 @@ const b = ({
5
5
  id: a,
6
6
  name: i
7
7
  }) => {
8
- var l, s, r;
8
+ var n, s, r;
9
9
  const {
10
- values: n,
10
+ values: d,
11
11
  setFieldValue: u
12
- } = C(), h = ((l = n.metadata.fields[a]) == null ? void 0 : l.options) || [], d = ((r = (s = n.metadata.fields[a]) == null ? void 0 : s.value) == null ? void 0 : r.enum) || [], f = (e, o) => {
13
- const t = new Set(d);
12
+ } = C(), h = ((n = d.metadata.fields[a]) == null ? void 0 : n.options) || [], l = ((r = (s = d.metadata.fields[a]) == null ? void 0 : s.value) == null ? void 0 : r.enum) || [], f = (e, o) => {
13
+ const t = new Set(l);
14
14
  o ? t.add(e) : t.delete(e), u(`metadata.fields.${a}.value.enum`, Array.from(t));
15
15
  };
16
16
  return /* @__PURE__ */ m(c.Legend, {
@@ -18,9 +18,10 @@ const b = ({
18
18
  children: h.map(({
19
19
  key: e
20
20
  }) => {
21
- const o = d.includes(e);
21
+ const o = l.includes(e);
22
22
  return /* @__PURE__ */ m(c.Item, {
23
23
  checked: o,
24
+ "data-target-id": `CheckboxItem-filter_${a}_${e}`,
24
25
  label: e,
25
26
  onCheckedChange: (t) => {
26
27
  f(e, t === !0);
@@ -1,44 +1,45 @@
1
1
  import { ContentField as f } from "@box/blueprint-web";
2
2
  import { useFormikContext as u } from "formik";
3
3
  import p from "lodash/noop";
4
- import { useIntl as h } from "react-intl";
5
- import C from "./messages.js";
4
+ import { useIntl as C } from "react-intl";
5
+ import h from "./messages.js";
6
6
  import { jsx as i } from "react/jsx-runtime";
7
7
  import '../../../../styles/metadata-location-field.css';const v = "_metadataLocationFieldTrigger_1d3ch_1", L = {
8
8
  metadataLocationFieldTrigger: v
9
- }, S = ({
10
- id: t,
9
+ }, N = ({
10
+ id: e,
11
11
  triggerSetValueCallback: n = p,
12
- renderer: s = (a) => a
12
+ renderer: l = (a) => a
13
13
  }) => {
14
14
  var r;
15
15
  const {
16
16
  formatMessage: a
17
- } = h(), {
18
- values: l,
17
+ } = C(), {
18
+ values: s,
19
19
  setFieldValue: o
20
- } = u(), e = (r = l.metadata.fields[t].value.enum) == null ? void 0 : r[0], m = () => {
21
- o(`metadata.fields.${t}.value.enum`, []);
20
+ } = u(), t = (r = s.metadata.fields[e].value.enum) == null ? void 0 : r[0], m = () => {
21
+ o(`metadata.fields.${e}.value.enum`, []);
22
22
  }, d = () => {
23
23
  n((c, F, g = !1) => {
24
- o(`metadata.fields.${t}.value.enum[0]`, {
24
+ o(`metadata.fields.${e}.value.enum[0]`, {
25
25
  folderId: c,
26
26
  folderName: F,
27
27
  isFolderShared: g
28
28
  });
29
29
  });
30
30
  };
31
- return s(/* @__PURE__ */ i("div", {
31
+ return l(/* @__PURE__ */ i("div", {
32
32
  className: L.metadataLocationFieldTrigger,
33
33
  children: /* @__PURE__ */ i(f, {
34
- hintText: a(C.selectFolderHint),
35
- isSharedFolder: e == null ? void 0 : e.isFolderShared,
34
+ "data-target-id": `ContentField-filter_${e}`,
35
+ hintText: a(h.selectFolderHint),
36
+ isSharedFolder: t == null ? void 0 : t.isFolderShared,
36
37
  onClick: d,
37
38
  onClickClearButton: m,
38
- title: e == null ? void 0 : e.folderName
39
+ title: t == null ? void 0 : t.folderName
39
40
  })
40
41
  }));
41
42
  };
42
43
  export {
43
- S as MetadataLocationField
44
+ N as MetadataLocationField
44
45
  };
@@ -1,31 +1,33 @@
1
1
  import { useFormikContext as v } from "formik";
2
2
  import { Radio as a } from "@box/blueprint-web";
3
- import { jsx as l, jsxs as c } from "react/jsx-runtime";
4
- const b = ({
3
+ import { jsx as o, jsxs as c } from "react/jsx-runtime";
4
+ const R = ({
5
5
  id: t,
6
6
  name: i,
7
- placeholder: o
7
+ placeholder: l
8
8
  }) => {
9
- var u, m, n, d;
9
+ var r, m, s, u;
10
10
  const {
11
- values: s,
12
- setFieldValue: r
13
- } = v(), f = ((n = (m = (u = s.metadata.fields[t]) == null ? void 0 : u.value) == null ? void 0 : m.enum) == null ? void 0 : n[0]) || "", p = ((d = s.metadata.fields[t]) == null ? void 0 : d.options) || [];
14
- return /* @__PURE__ */ l(a.Legend, {
11
+ values: d,
12
+ setFieldValue: n
13
+ } = v(), f = ((s = (m = (r = d.metadata.fields[t]) == null ? void 0 : r.value) == null ? void 0 : m.enum) == null ? void 0 : s[0]) || "", p = ((u = d.metadata.fields[t]) == null ? void 0 : u.options) || [];
14
+ return /* @__PURE__ */ o(a.Legend, {
15
15
  header: i,
16
16
  children: /* @__PURE__ */ c(a.Group, {
17
17
  loop: !0,
18
18
  name: i,
19
19
  onValueChange: (e) => {
20
- r(`metadata.fields.${t}.value.enum[0]`, e);
20
+ n(`metadata.fields.${t}.value.enum[0]`, e);
21
21
  },
22
22
  value: f,
23
- children: [o && /* @__PURE__ */ l(a.Item, {
24
- label: o,
23
+ children: [l && /* @__PURE__ */ o(a.Item, {
24
+ "data-target-id": `RadioItem-filter_${t}_placeholder`,
25
+ label: l,
25
26
  value: ""
26
- }, o), p.map(({
27
+ }, l), p.map(({
27
28
  key: e
28
- }) => /* @__PURE__ */ l(a.Item, {
29
+ }) => /* @__PURE__ */ o(a.Item, {
30
+ "data-target-id": `RadioItem-filter_${t}_${e}`,
29
31
  label: e,
30
32
  value: e
31
33
  }, e))]
@@ -33,5 +35,5 @@ const b = ({
33
35
  });
34
36
  };
35
37
  export {
36
- b as MetadataRadioField
38
+ R as MetadataRadioField
37
39
  };
@@ -1,31 +1,32 @@
1
1
  import { SearchInput as i } from "@box/blueprint-web";
2
2
  import { useFormikContext as c } from "formik";
3
3
  import { useIntl as f } from "react-intl";
4
- import l from "./messages.js";
5
- import { jsx as h } from "react/jsx-runtime";
6
- const g = ({
4
+ import n from "./messages.js";
5
+ import { jsx as d } from "react/jsx-runtime";
6
+ const b = ({
7
7
  id: e,
8
- name: n,
8
+ name: s,
9
9
  placeholder: m
10
10
  }) => {
11
- var o, s;
11
+ var o, l;
12
12
  const {
13
13
  formatMessage: t
14
14
  } = f(), {
15
15
  values: u,
16
16
  setFieldValue: r
17
- } = c(), a = (s = (o = u.metadata.fields[e]) == null ? void 0 : o.value) == null ? void 0 : s.enum;
18
- return /* @__PURE__ */ h(i.Controlled, {
17
+ } = c(), a = (l = (o = u.metadata.fields[e]) == null ? void 0 : o.value) == null ? void 0 : l.enum;
18
+ return /* @__PURE__ */ d(i.Controlled, {
19
+ "data-target-id": `SearchInputControlled-filter_${e}`,
19
20
  id: e,
20
- name: n,
21
+ name: s,
21
22
  onChange: (p) => r(`metadata.fields.${e}.value.enum[0]`, p.target.value),
22
23
  onClearInput: () => r(`metadata.fields.${e}.value.enum`, []),
23
24
  placeholder: m,
24
- searchInputAriaLabel: t(l.searchInputAriaLabel),
25
- searchInputClearAriaLabel: t(l.searchInputClearAriaLabel),
25
+ searchInputAriaLabel: t(n.searchInputAriaLabel),
26
+ searchInputClearAriaLabel: t(n.searchInputClearAriaLabel),
26
27
  value: (a == null ? void 0 : a[0]) || ""
27
28
  });
28
29
  };
29
30
  export {
30
- g as MetadataSearchField
31
+ b as MetadataSearchField
31
32
  };
@@ -0,0 +1,5 @@
1
+ interface NamedComponent {
2
+ displayName?: string;
3
+ }
4
+ export declare function getDataTargetId(item: NamedComponent, label: string): string;
5
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-view",
3
- "version": "1.17.3",
3
+ "version": "1.18.1",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
6
  "@box/blueprint-web": "^12.76.2",
@@ -18,12 +18,12 @@
18
18
  "react-intl": "^6.4.2"
19
19
  },
20
20
  "devDependencies": {
21
- "@box/blueprint-web": "^12.98.3",
21
+ "@box/blueprint-web": "^12.99.0",
22
22
  "@box/blueprint-web-assets": "^4.82.0",
23
- "@box/box-item-type-selector": "^1.11.2",
23
+ "@box/box-item-type-selector": "^1.11.3",
24
24
  "@box/eslint-plugin-blueprint": "1.0.5",
25
- "@box/item-icon": "^2.2.2",
26
- "@box/metadata-filter": "^1.48.3",
25
+ "@box/item-icon": "^2.2.3",
26
+ "@box/metadata-filter": "^1.49.1",
27
27
  "@box/storybook-utils": "0.14.19",
28
28
  "@box/types": "2.0.0",
29
29
  "@tanstack/react-virtual": "^3.10.8",