@box/metadata-editor 0.116.4 → 0.117.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 +71 -71
- package/dist/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-autofill-button/types.d.ts +1 -1
- package/package.json +1 -1
@@ -1,119 +1,119 @@
|
|
1
|
-
import { Tooltip as
|
2
|
-
import { BoxAiLogo as
|
3
|
-
import { BoxAiColor as
|
4
|
-
import { useLocalStorageAIAgents as
|
5
|
-
import { useFormikContext as
|
6
|
-
import { useEffect as
|
7
|
-
import { useIntl as
|
8
|
-
import { EXTRACT_AI_AGENT_LOCAL_STORAGE_KEY as
|
9
|
-
import { autofillMessages as
|
10
|
-
import { useAutofill as
|
11
|
-
import { getTooltipContent as
|
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
|
14
|
-
import '../../../../../../styles/metadata-instance-form-autofill-button.css';const
|
15
|
-
loadingIndicator:
|
16
|
-
actionMenuItem:
|
17
|
-
splitButtonIcon:
|
18
|
-
},
|
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
|
-
...
|
23
|
+
...a
|
24
24
|
}, _) => {
|
25
|
-
const m =
|
26
|
-
|
27
|
-
|
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(
|
30
|
-
...
|
30
|
+
return /* @__PURE__ */ o(v, {
|
31
|
+
...a,
|
31
32
|
ref: _,
|
32
33
|
disabled: I,
|
33
34
|
dropdownTriggerAriaLabel: "See agent options.",
|
34
|
-
icon:
|
35
|
+
icon: E,
|
35
36
|
label: m.formatMessage(g.autofillButton),
|
36
37
|
onClick: () => A(),
|
37
38
|
variant: "secondary",
|
38
|
-
children: /* @__PURE__ */ o(
|
39
|
-
onValueChange: (t) =>
|
40
|
-
value:
|
41
|
-
children: Object.entries(y).map(([t,
|
42
|
-
const
|
43
|
-
return /* @__PURE__ */ o(
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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:
|
51
|
-
}), /* @__PURE__ */ o(
|
50
|
+
className: S.splitButtonIcon
|
51
|
+
}), /* @__PURE__ */ o(D, {
|
52
52
|
as: "span",
|
53
|
-
children: m.formatMessage(g[
|
53
|
+
children: m.formatMessage(g[s.DISPLAY_MSG])
|
54
54
|
})]
|
55
55
|
})
|
56
56
|
}, t);
|
57
57
|
})
|
58
58
|
})
|
59
59
|
});
|
60
|
-
}),
|
60
|
+
}), mt = ({
|
61
61
|
areAiSuggestionsAvailable: I,
|
62
62
|
isBetaLanguageEnabled: A,
|
63
63
|
isLoading: u,
|
64
64
|
variant: B = "secondary-button",
|
65
|
-
isAdvancedExtractAgentEnabled:
|
65
|
+
isAdvancedExtractAgentEnabled: a = !1,
|
66
66
|
onAutofill: _
|
67
67
|
}) => {
|
68
68
|
const {
|
69
69
|
isSubmitting: m,
|
70
|
-
values:
|
70
|
+
values: i,
|
71
71
|
setFieldValue: d
|
72
|
-
} =
|
73
|
-
suggestions:
|
74
|
-
} =
|
75
|
-
|
76
|
-
if (
|
77
|
-
const
|
78
|
-
d("metadata.fields",
|
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 =
|
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
|
-
}, [
|
88
|
-
const h = (
|
89
|
-
var c;
|
90
|
-
const
|
91
|
-
_(
|
92
|
-
}, C = !I || m || u,
|
93
|
-
return B === "secondary-button" ? /* @__PURE__ */ o(
|
94
|
-
content:
|
95
|
-
children:
|
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:
|
97
|
+
onAgentChange: s,
|
98
98
|
onAutofill: h,
|
99
99
|
storedAgent: t
|
100
|
-
}) : /* @__PURE__ */ o(
|
100
|
+
}) : /* @__PURE__ */ o(x, {
|
101
101
|
disabled: C,
|
102
|
-
icon:
|
102
|
+
icon: E,
|
103
103
|
onClick: () => h(),
|
104
104
|
variant: "secondary",
|
105
105
|
"data-target-id": "Button-autofillButton",
|
106
|
-
children:
|
106
|
+
children: e.formatMessage(g.autofillButton)
|
107
107
|
})
|
108
|
-
}) : /* @__PURE__ */ o(
|
109
|
-
content:
|
110
|
-
children: u ? /* @__PURE__ */ o(
|
111
|
-
"aria-label":
|
112
|
-
className:
|
113
|
-
}) : /* @__PURE__ */ o(
|
114
|
-
"aria-label":
|
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:
|
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
|
-
|
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: (
|
13
|
+
onAutofill: (agentType?: string) => void;
|
14
14
|
storedAgent: StoredAgentType;
|
15
15
|
};
|