@box/metadata-editor 0.120.21 → 0.121.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,120 +1,121 @@
1
- import { Tooltip as L, Button as x, LoadingIndicator as R, IconButton as k, SplitButton as v, DropdownMenu as N, Text as D } from "@box/blueprint-web";
2
- import { BoxAiLogo as E } from "@box/blueprint-web-assets/icons/Logo";
3
- import { BoxAiColor as K } from "@box/blueprint-web-assets/icons/Medium";
4
- import { useLocalStorageAIAgents as O } from "@box/box-ai-agent-selector";
5
- import { useFormikContext as j, getIn as p } from "formik";
6
- import { useEffect as w, useMemo as F, forwardRef as P, useState as Y } from "react";
7
- import { useIntl as G } from "react-intl";
8
- import { EXTRACT_AI_AGENT_LOCAL_STORAGE_KEY as V, EXTRACT_AGENTS_MAP as y } from "../../../../constants.js";
9
- import { autofillMessages as X } from "../../../../messages.js";
10
- import { useAutofill as q } from "../../../../utils/autofill-context.js";
11
- import { getTooltipContent as z } from "../../../../utils/utils.js";
1
+ import { Tooltip as N, Button as R, LoadingIndicator as k, IconButton as v, SplitButton as x, DropdownMenu as G, Text as D } from "@box/blueprint-web";
2
+ import { BoxAiAdvancedLogo24 as K, BoxAiLogo24 as O } from "@box/blueprint-web-assets/icons/Logo";
3
+ import { useLocalStorageAIAgents as j } from "@box/box-ai-agent-selector";
4
+ import { useFormikContext as w, getIn as p } from "formik";
5
+ import { useEffect as F, useMemo as P, forwardRef as Y, useState as V } from "react";
6
+ import { useIntl as E } from "react-intl";
7
+ import { EXTRACT_AI_AGENT_LOCAL_STORAGE_KEY as X, EXTRACT_AGENTS_MAP as S } from "../../../../constants.js";
8
+ import { autofillMessages as q } from "../../../../messages.js";
9
+ import { useAutofill as z } from "../../../../utils/autofill-context.js";
10
+ import { getTooltipContent as H } from "../../../../utils/utils.js";
12
11
  import g from "./messages.js";
13
- import { jsx as o, jsxs as H } from "react/jsx-runtime";
14
- import '../../../../../../styles/metadata-instance-form-autofill-button.css';const J = "_loadingIndicator_i1hyy_1", Q = "_actionMenuItem_i1hyy_11", U = "_splitButtonIcon_i1hyy_17", S = {
15
- loadingIndicator: J,
16
- actionMenuItem: Q,
17
- splitButtonIcon: U
18
- }, W = /* @__PURE__ */ P(({
12
+ import { jsx as t, jsxs as J } from "react/jsx-runtime";
13
+ import '../../../../../../styles/metadata-instance-form-autofill-button.css';const Q = "_loadingIndicator_i1hyy_1", U = "_actionMenuItem_i1hyy_11", W = "_splitButtonIcon_i1hyy_17", T = {
14
+ loadingIndicator: Q,
15
+ actionMenuItem: U,
16
+ splitButtonIcon: W
17
+ }, Z = /* @__PURE__ */ Y(({
19
18
  isButtonDisabled: I,
20
19
  onAutofill: A,
21
- onAgentChange: u,
20
+ onAgentChange: m,
22
21
  storedAgent: B,
23
- ...a
24
- }, _) => {
25
- const m = G(), [i, d] = Y(B || "standard"), e = (t) => {
26
- d(t), u(t), setTimeout(() => {
27
- A(t);
22
+ icon: n,
23
+ ..._
24
+ }, h) => {
25
+ const a = E(), [d, i] = V(B || "standard"), r = (o) => {
26
+ i(o), m(o), setTimeout(() => {
27
+ A(o);
28
28
  }, 0);
29
29
  };
30
- return /* @__PURE__ */ o(v, {
31
- ...a,
32
- ref: _,
30
+ return /* @__PURE__ */ t(x, {
31
+ ..._,
32
+ ref: h,
33
33
  disabled: I,
34
34
  dropdownTriggerAriaLabel: "See agent options.",
35
- icon: E,
36
- label: m.formatMessage(g.autofillButton),
35
+ icon: n,
36
+ label: a.formatMessage(g.autofillButton),
37
37
  onClick: () => A(),
38
38
  variant: "secondary",
39
- children: /* @__PURE__ */ o(N.RadioGroup, {
40
- onValueChange: (t) => e(t),
41
- value: i,
42
- children: Object.entries(y).map(([t, s]) => {
43
- const n = s.ICON;
44
- return /* @__PURE__ */ o(N.RadioSelectItem, {
45
- value: s.AGENT_TYPE,
46
- children: /* @__PURE__ */ H("div", {
47
- className: S.actionMenuItem,
48
- children: [/* @__PURE__ */ o(n, {
39
+ children: /* @__PURE__ */ t(G.RadioGroup, {
40
+ onValueChange: (o) => r(o),
41
+ value: d,
42
+ children: Object.entries(S).map(([o, e]) => {
43
+ const l = e.ICON;
44
+ return /* @__PURE__ */ t(G.RadioSelectItem, {
45
+ value: e.AGENT_TYPE,
46
+ children: /* @__PURE__ */ J("div", {
47
+ className: T.actionMenuItem,
48
+ children: [/* @__PURE__ */ t(l, {
49
49
  "aria-hidden": !0,
50
- className: S.splitButtonIcon
51
- }), /* @__PURE__ */ o(D, {
50
+ className: T.splitButtonIcon
51
+ }), /* @__PURE__ */ t(D, {
52
52
  as: "span",
53
- children: m.formatMessage(g[s.DISPLAY_MSG])
53
+ children: a.formatMessage(g[e.DISPLAY_MSG])
54
54
  })]
55
55
  })
56
- }, t);
56
+ }, o);
57
57
  })
58
58
  })
59
59
  });
60
60
  }), mt = ({
61
61
  areAiSuggestionsAvailable: I,
62
62
  isBetaLanguageEnabled: A,
63
- isLoading: u,
63
+ isLoading: m,
64
64
  variant: B = "secondary-button",
65
- isAdvancedExtractAgentEnabled: a = !1,
65
+ isAdvancedExtractAgentEnabled: n = !1,
66
66
  onAutofill: _
67
67
  }) => {
68
68
  const {
69
- isSubmitting: m,
70
- values: i,
69
+ isSubmitting: h,
70
+ values: a,
71
71
  setFieldValue: d
72
- } = j(), e = G(), [t, s] = O(V), {
73
- suggestions: n
74
- } = q();
75
- w(() => {
76
- if (n) {
77
- const r = p(i, "metadata.fields"), M = p(i, "metadata.templateKey");
78
- d("metadata.fields", r == null ? void 0 : r.map((l) => {
79
- var c;
80
- const f = (c = n == null ? void 0 : n[M]) == null ? void 0 : c[l.key];
72
+ } = w(), i = E(), [r, o] = j(X), {
73
+ suggestions: e
74
+ } = z();
75
+ F(() => {
76
+ if (e) {
77
+ const s = p(a, "metadata.fields"), C = p(a, "metadata.templateKey");
78
+ d("metadata.fields", s == null ? void 0 : s.map((c) => {
79
+ var u;
80
+ const f = (u = e == null ? void 0 : e[C]) == null ? void 0 : u[c.key];
81
81
  return f ? {
82
- ...l,
82
+ ...c,
83
83
  aiSuggestion: f
84
- } : l;
84
+ } : c;
85
85
  }));
86
86
  }
87
- }, [n, d]);
88
- const h = (r) => {
89
- var c, b;
90
- const M = p(i, "metadata.templateKey"), l = p(i, "metadata.scope"), f = r ? (c = y[r]) == null ? void 0 : c.AGENT_ID : (b = y[t]) == null ? void 0 : b.AGENT_ID;
91
- _(M, l, a ? f : void 0);
92
- }, C = !I || m || u, T = F(() => z(a, t, e), [a, t, e]);
93
- return B === "secondary-button" ? /* @__PURE__ */ o(L, {
94
- content: T,
95
- children: a ? /* @__PURE__ */ o(W, {
96
- isButtonDisabled: C,
97
- onAgentChange: s,
98
- onAutofill: h,
99
- storedAgent: t
100
- }) : /* @__PURE__ */ o(x, {
101
- disabled: C,
102
- icon: E,
103
- onClick: () => h(),
87
+ }, [e, d]);
88
+ const l = (s) => {
89
+ var u, L;
90
+ const C = p(a, "metadata.templateKey"), c = p(a, "metadata.scope"), f = s ? (u = S[s]) == null ? void 0 : u.AGENT_ID : (L = S[r]) == null ? void 0 : L.AGENT_ID;
91
+ _(C, c, n ? f : void 0);
92
+ }, M = !I || h || m, y = r === "enhanced" && n ? K : O, b = P(() => H(n, r, i), [n, r, i]);
93
+ return B === "secondary-button" ? /* @__PURE__ */ t(N, {
94
+ content: b,
95
+ children: n ? /* @__PURE__ */ t(Z, {
96
+ icon: y,
97
+ isButtonDisabled: M,
98
+ onAgentChange: o,
99
+ onAutofill: l,
100
+ storedAgent: r
101
+ }) : /* @__PURE__ */ t(R, {
102
+ disabled: M,
103
+ icon: y,
104
+ onClick: () => l(),
104
105
  variant: "secondary",
105
106
  "data-target-id": "Button-autofillButton",
106
- children: e.formatMessage(g.autofillButton)
107
+ children: i.formatMessage(g.autofillButton)
107
108
  })
108
- }) : /* @__PURE__ */ o(L, {
109
- content: T,
110
- children: u ? /* @__PURE__ */ o(R, {
111
- "aria-label": e.formatMessage(g.loadingButtonAriaLabel),
112
- className: S.loadingIndicator
113
- }) : /* @__PURE__ */ o(k, {
114
- "aria-label": e.formatMessage(X.autofillButtonAriaLabel),
115
- disabled: C,
116
- icon: K,
117
- onClick: () => h(),
109
+ }) : /* @__PURE__ */ t(N, {
110
+ content: b,
111
+ children: m ? /* @__PURE__ */ t(k, {
112
+ "aria-label": i.formatMessage(g.loadingButtonAriaLabel),
113
+ className: T.loadingIndicator
114
+ }) : /* @__PURE__ */ t(v, {
115
+ "aria-label": i.formatMessage(q.autofillButtonAriaLabel),
116
+ disabled: M,
117
+ icon: y,
118
+ onClick: () => l(),
118
119
  variant: "icon-logo",
119
120
  "data-target-id": "IconButton-autofillButtonAriaLabel"
120
121
  })
@@ -1,53 +1,53 @@
1
- import { Tooltip as l, IconButton as c } from "@box/blueprint-web";
1
+ import { Tooltip as c, IconButton as l } from "@box/blueprint-web";
2
2
  import { Pencil as A } from "@box/blueprint-web-assets/icons/Line";
3
- import { BoxAiColor as C } from "@box/blueprint-web-assets/icons/Medium";
3
+ import { BoxAiAdvancedLogo24 as C, BoxAiLogo24 as L } from "@box/blueprint-web-assets/icons/Logo";
4
4
  import { useLocalStorageAIAgents as b } from "@box/box-ai-agent-selector";
5
- import { useMemo as L } from "react";
5
+ import { useMemo as h } from "react";
6
6
  import { useIntl as M } from "react-intl";
7
- import { EXTRACT_AI_AGENT_LOCAL_STORAGE_KEY as h, EXTRACT_AGENTS_MAP as H } from "../../../../constants.js";
8
- import { autofillMessages as N } from "../../../../messages.js";
9
- import { getTooltipContent as E } from "../../../../utils/utils.js";
10
- import G from "../../../interactive-header-text/interactive-header-text.js";
7
+ import { EXTRACT_AI_AGENT_LOCAL_STORAGE_KEY as H, EXTRACT_AGENTS_MAP as N } from "../../../../constants.js";
8
+ import { autofillMessages as G } from "../../../../messages.js";
9
+ import { getTooltipContent as v } from "../../../../utils/utils.js";
10
+ import x from "../../../interactive-header-text/interactive-header-text.js";
11
11
  import i from "./messages.js";
12
12
  import { jsxs as m, jsx as o } from "react/jsx-runtime";
13
- import '../../../../../../styles/metadata-instance-header.css';const v = "_metadataInstanceHeader_17bsu_1", x = "_iconButtonsContainer_17bsu_6", R = "_title_17bsu_14", s = {
14
- metadataInstanceHeader: v,
15
- iconButtonsContainer: x,
16
- title: R
17
- }, z = ({
13
+ import '../../../../../../styles/metadata-instance-header.css';const R = "_metadataInstanceHeader_17bsu_1", S = "_iconButtonsContainer_17bsu_6", j = "_title_17bsu_14", s = {
14
+ metadataInstanceHeader: R,
15
+ iconButtonsContainer: S,
16
+ title: j
17
+ }, F = ({
18
18
  areAiSuggestionsAvailable: u,
19
19
  canEdit: d,
20
20
  isAiSuggestionsFeatureEnabled: f,
21
- isBetaLanguageEnabled: S,
21
+ isBetaLanguageEnabled: k,
22
22
  onEdit: _,
23
23
  onAutofill: p,
24
24
  templateName: e,
25
25
  isAdvancedExtractAgentEnabled: a = !1
26
26
  }) => {
27
27
  var r;
28
- const t = M(), B = e || t.formatMessage(i.customInstanceTitle), I = f && e, [n] = b(h), T = a && ((r = H[n]) == null ? void 0 : r.AGENT_ID), g = L(() => E(a, n, t), [a, n, t]);
28
+ const t = M(), B = e || t.formatMessage(i.customInstanceTitle), g = f && e, [n] = b(H), I = a && ((r = N[n]) == null ? void 0 : r.AGENT_ID), T = h(() => v(a, n, t), [a, n, t]);
29
29
  return /* @__PURE__ */ m("div", {
30
30
  className: s.metadataInstanceHeader,
31
- children: [/* @__PURE__ */ o(G, {
31
+ children: [/* @__PURE__ */ o(x, {
32
32
  className: s.title,
33
33
  title: B
34
34
  }), d && /* @__PURE__ */ m("div", {
35
35
  className: s.iconButtonsContainer,
36
- children: [I && /* @__PURE__ */ o(l, {
37
- content: g,
38
- children: /* @__PURE__ */ o(c, {
39
- "aria-label": t.formatMessage(N.autofillButtonAriaLabelWithTemplateName, {
36
+ children: [g && /* @__PURE__ */ o(c, {
37
+ content: T,
38
+ children: /* @__PURE__ */ o(l, {
39
+ "aria-label": t.formatMessage(G.autofillButtonAriaLabelWithTemplateName, {
40
40
  templateName: e
41
41
  }),
42
42
  disabled: !u,
43
- icon: C,
44
- onClick: () => p(T || void 0),
43
+ icon: n === "enhanced" && a ? C : L,
44
+ onClick: () => p(I || void 0),
45
45
  variant: "icon-logo",
46
46
  "data-target-id": "IconButton-autofillButtonAriaLabelWithTemplateName"
47
47
  })
48
- }), /* @__PURE__ */ o(l, {
48
+ }), /* @__PURE__ */ o(c, {
49
49
  content: t.formatMessage(i.editButtonTooltip),
50
- children: /* @__PURE__ */ o(c, {
50
+ children: /* @__PURE__ */ o(l, {
51
51
  "aria-label": t.formatMessage(i.editButtonAriaLabel, {
52
52
  templateName: e
53
53
  }),
@@ -60,5 +60,5 @@ import '../../../../../../styles/metadata-instance-header.css';const v = "_metad
60
60
  });
61
61
  };
62
62
  export {
63
- z as MetadataInstanceHeader
63
+ F as MetadataInstanceHeader
64
64
  };
@@ -12,4 +12,5 @@ export type AutofillSplitButtonProps = {
12
12
  isButtonDisabled: boolean;
13
13
  onAutofill: (agentType?: string) => void;
14
14
  storedAgent: StoredAgentType;
15
+ icon: React.FunctionComponent<React.SVGProps<SVGSVGElement>>;
15
16
  };
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@box/metadata-editor",
3
- "version": "0.120.21",
3
+ "version": "0.121.0",
4
4
  "peerDependencies": {
5
5
  "@ariakit/react": "0.4.15",
6
6
  "@box/box-ai-agent-selector": "^0.41.7",
7
7
  "@box/blueprint-web": "^7.30.3",
8
- "@box/blueprint-web-assets": "^4.53.0",
8
+ "@box/blueprint-web-assets": "^4.59.1",
9
9
  "@box/combobox-with-api": "^0.26.0",
10
10
  "formik": "^2.0.3",
11
11
  "lodash": "^4.17.15",
@@ -15,9 +15,9 @@
15
15
  },
16
16
  "devDependencies": {
17
17
  "@ariakit/react": "0.4.15",
18
- "@box/box-ai-agent-selector": "^0.48.4",
18
+ "@box/box-ai-agent-selector": "^0.48.6",
19
19
  "@box/babel-plugin-target-attributes": "1.3.0",
20
- "@box/blueprint-web": "^12.37.0",
20
+ "@box/blueprint-web": "^12.38.0",
21
21
  "@box/blueprint-web-assets": "^4.60.0",
22
22
  "@box/storybook-utils": "^0.13.14",
23
23
  "@testing-library/react": "^15.0.6",