@box/metadata-editor 0.116.4 → 0.117.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,119 +1,119 @@
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
- import { BoxAiLogo as L } from "@box/blueprint-web-assets/icons/Logo";
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
- import { useEffect as P, useMemo as Y, forwardRef as j, useState as w } from "react";
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
- import { autofillMessages as V } from "../../../../messages.js";
10
- import { useAutofill as X } from "../../../../utils/autofill-context.js";
11
- import { getTooltipContent as q } from "../../../../utils/utils.js";
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";
12
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
- loadingIndicator: H,
16
- actionMenuItem: J,
17
- splitButtonIcon: Q
18
- }, U = /* @__PURE__ */ j(({
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(({
19
19
  isButtonDisabled: I,
20
20
  onAutofill: A,
21
21
  onAgentChange: u,
22
22
  storedAgent: B,
23
- ...i
23
+ ...a
24
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);
25
+ const m = G(), [i, d] = Y(B || "standard"), e = (t) => {
26
+ d(t), u(t), setTimeout(() => {
27
+ A(t);
28
+ }, 0);
28
29
  };
29
- return /* @__PURE__ */ o(R, {
30
- ...i,
30
+ return /* @__PURE__ */ o(v, {
31
+ ...a,
31
32
  ref: _,
32
33
  disabled: I,
33
34
  dropdownTriggerAriaLabel: "See agent options.",
34
- icon: L,
35
+ icon: E,
35
36
  label: m.formatMessage(g.autofillButton),
36
37
  onClick: () => A(),
37
38
  variant: "secondary",
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),
45
- value: e.AGENT_TYPE,
46
- children: /* @__PURE__ */ z("div", {
47
- className: M.actionMenuItem,
48
- children: [/* @__PURE__ */ o(a, {
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, {
49
49
  "aria-hidden": !0,
50
- className: M.splitButtonIcon
51
- }), /* @__PURE__ */ o(v, {
50
+ className: S.splitButtonIcon
51
+ }), /* @__PURE__ */ o(D, {
52
52
  as: "span",
53
- children: m.formatMessage(g[e.DISPLAY_MSG])
53
+ children: m.formatMessage(g[s.DISPLAY_MSG])
54
54
  })]
55
55
  })
56
56
  }, t);
57
57
  })
58
58
  })
59
59
  });
60
- }), ut = ({
60
+ }), mt = ({
61
61
  areAiSuggestionsAvailable: I,
62
62
  isBetaLanguageEnabled: A,
63
63
  isLoading: u,
64
64
  variant: B = "secondary-button",
65
- isAdvancedExtractAgentEnabled: i = !1,
65
+ isAdvancedExtractAgentEnabled: a = !1,
66
66
  onAutofill: _
67
67
  }) => {
68
68
  const {
69
69
  isSubmitting: m,
70
- values: r,
70
+ values: i,
71
71
  setFieldValue: d
72
- } = O(), n = N(), [t, e] = K(F), {
73
- suggestions: a
74
- } = X();
75
- P(() => {
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) => {
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
79
  var c;
80
- const f = (c = a == null ? void 0 : a[T]) == null ? void 0 : c[l.key];
80
+ const f = (c = n == null ? void 0 : n[M]) == null ? void 0 : c[l.key];
81
81
  return f ? {
82
82
  ...l,
83
83
  aiSuggestion: f
84
84
  } : l;
85
85
  }));
86
86
  }
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, {
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
96
  isButtonDisabled: C,
97
- onAgentChange: e,
97
+ onAgentChange: s,
98
98
  onAutofill: h,
99
99
  storedAgent: t
100
- }) : /* @__PURE__ */ o(G, {
100
+ }) : /* @__PURE__ */ o(x, {
101
101
  disabled: C,
102
- icon: L,
102
+ icon: E,
103
103
  onClick: () => h(),
104
104
  variant: "secondary",
105
105
  "data-target-id": "Button-autofillButton",
106
- children: n.formatMessage(g.autofillButton)
106
+ children: e.formatMessage(g.autofillButton)
107
107
  })
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),
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
115
  disabled: C,
116
- icon: D,
116
+ icon: K,
117
117
  onClick: () => h(),
118
118
  variant: "icon-logo",
119
119
  "data-target-id": "IconButton-autofillButtonAriaLabel"
@@ -121,5 +121,5 @@ import '../../../../../../styles/metadata-instance-form-autofill-button.css';con
121
121
  });
122
122
  };
123
123
  export {
124
- ut as MetadataInstanceFormAutofillButton
124
+ mt as MetadataInstanceFormAutofillButton
125
125
  };
@@ -10,6 +10,6 @@ export type MetadataInstanceFormAutofillButtonProps = {
10
10
  export type AutofillSplitButtonProps = {
11
11
  onAgentChange: (agentType: StoredAgentType) => void;
12
12
  isButtonDisabled: boolean;
13
- onAutofill: (agentId?: string) => void;
13
+ onAutofill: (agentType?: 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.116.4",
3
+ "version": "0.117.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.45.4",
18
+ "@box/box-ai-agent-selector": "^0.45.5",
19
19
  "@box/babel-plugin-target-attributes": "1.3.0",
20
- "@box/blueprint-web": "^12.23.0",
21
- "@box/blueprint-web-assets": "^4.56.0",
22
- "@box/storybook-utils": "^0.13.9",
20
+ "@box/blueprint-web": "^12.23.1",
21
+ "@box/blueprint-web-assets": "^4.56.6",
22
+ "@box/storybook-utils": "^0.13.10",
23
23
  "@testing-library/react": "^15.0.6",
24
24
  "react": "^18.3.0",
25
25
  "react-dom": "^18.3.0",