@box/metadata-editor 0.114.0 → 0.115.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.
- package/dist/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-autofill-button/metadata-instance-form-autofill-button.js +83 -80
- package/dist/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-autofill-button/types.d.ts +1 -1
- package/package.json +5 -5
@@ -1,117 +1,120 @@
|
|
1
|
-
import { Tooltip as
|
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
|
4
|
-
import { useLocalStorageAIAgents as
|
5
|
-
import { useFormikContext as O, getIn as
|
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
|
8
|
-
import { EXTRACT_AI_AGENT_LOCAL_STORAGE_KEY as F, EXTRACT_AGENTS_MAP as
|
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
|
13
|
-
import { jsx as
|
14
|
-
import '../../../../../../styles/metadata-instance-form-autofill-button.css';const H = "_loadingIndicator_i1hyy_1", J = "_actionMenuItem_i1hyy_11", Q = "_splitButtonIcon_i1hyy_17",
|
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:
|
20
|
-
onAutofill:
|
21
|
-
onAgentChange:
|
22
|
-
storedAgent:
|
23
|
-
...
|
24
|
-
},
|
25
|
-
const
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
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:
|
33
|
-
onClick:
|
35
|
+
label: m.formatMessage(g.autofillButton),
|
36
|
+
onClick: () => A(),
|
34
37
|
variant: "secondary",
|
35
|
-
children: /* @__PURE__ */
|
36
|
-
onValueChange: (
|
37
|
-
value:
|
38
|
-
children: Object.entries(
|
39
|
-
const
|
40
|
-
return /* @__PURE__ */
|
41
|
-
onClick: () =>
|
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:
|
45
|
-
children: [/* @__PURE__ */
|
47
|
+
className: M.actionMenuItem,
|
48
|
+
children: [/* @__PURE__ */ o(a, {
|
46
49
|
"aria-hidden": !0,
|
47
|
-
className:
|
48
|
-
}), /* @__PURE__ */
|
50
|
+
className: M.splitButtonIcon
|
51
|
+
}), /* @__PURE__ */ o(v, {
|
49
52
|
as: "span",
|
50
|
-
children:
|
53
|
+
children: m.formatMessage(g[e.DISPLAY_MSG])
|
51
54
|
})]
|
52
55
|
})
|
53
|
-
},
|
56
|
+
}, t);
|
54
57
|
})
|
55
58
|
})
|
56
59
|
});
|
57
60
|
}), ut = ({
|
58
|
-
areAiSuggestionsAvailable:
|
59
|
-
isBetaLanguageEnabled:
|
60
|
-
isLoading:
|
61
|
-
variant:
|
62
|
-
isAdvancedExtractAgentEnabled:
|
63
|
-
onAutofill:
|
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:
|
67
|
-
values:
|
68
|
-
setFieldValue:
|
69
|
-
} = O(),
|
70
|
-
suggestions:
|
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 (
|
74
|
-
const
|
75
|
-
|
76
|
-
var
|
77
|
-
const
|
78
|
-
return
|
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:
|
83
|
+
aiSuggestion: f
|
81
84
|
} : l;
|
82
85
|
}));
|
83
86
|
}
|
84
|
-
}, [
|
85
|
-
const
|
86
|
-
var
|
87
|
-
const
|
88
|
-
|
89
|
-
},
|
90
|
-
return
|
91
|
-
content:
|
92
|
-
children:
|
93
|
-
isButtonDisabled:
|
94
|
-
onAgentChange:
|
95
|
-
onAutofill:
|
96
|
-
storedAgent:
|
97
|
-
}) : /* @__PURE__ */
|
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:
|
103
|
+
onClick: () => h(),
|
101
104
|
variant: "secondary",
|
102
105
|
"data-target-id": "Button-autofillButton",
|
103
|
-
children:
|
106
|
+
children: n.formatMessage(g.autofillButton)
|
104
107
|
})
|
105
|
-
}) : /* @__PURE__ */
|
106
|
-
content:
|
107
|
-
children:
|
108
|
-
"aria-label":
|
109
|
-
className:
|
110
|
-
}) : /* @__PURE__ */
|
111
|
-
"aria-label":
|
112
|
-
disabled:
|
113
|
-
icon:
|
114
|
-
onClick:
|
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.
|
3
|
+
"version": "0.115.0",
|
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.
|
18
|
+
"@box/box-ai-agent-selector": "^0.44.2",
|
19
19
|
"@box/babel-plugin-target-attributes": "1.3.0",
|
20
|
-
"@box/blueprint-web": "^12.
|
21
|
-
"@box/blueprint-web-assets": "^4.
|
22
|
-
"@box/storybook-utils": "^0.13.
|
20
|
+
"@box/blueprint-web": "^12.17.1",
|
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",
|