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