@box/metadata-editor 0.92.4 → 0.92.6
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.
@@ -32,14 +32,14 @@ const Co = (E) => {
|
|
32
32
|
taxonomyOptionsFetcher: f
|
33
33
|
} = E, P = v ?? to, [R, u] = C(!1), {
|
34
34
|
isFetchingSuggestions: a,
|
35
|
-
isLongLoading:
|
35
|
+
isLongLoading: d,
|
36
36
|
getAiSuggestions: U,
|
37
|
-
|
37
|
+
clearState: g,
|
38
38
|
suggestions: B
|
39
39
|
} = Q();
|
40
40
|
F(() => () => {
|
41
|
-
|
42
|
-
}, [
|
41
|
+
g();
|
42
|
+
}, [g, o.id]);
|
43
43
|
const p = (o == null ? void 0 : o.templateKey) === G, w = async (t) => {
|
44
44
|
await N(t, oo(t, o));
|
45
45
|
}, K = (t) => {
|
@@ -71,14 +71,14 @@ const Co = (E) => {
|
|
71
71
|
children: [/* @__PURE__ */ r(H, {
|
72
72
|
errorCode: m,
|
73
73
|
isFetchingSuggestions: a,
|
74
|
-
isLongLoading:
|
74
|
+
isLongLoading: d
|
75
75
|
}), /* @__PURE__ */ r(X, {
|
76
76
|
disableForm: a,
|
77
77
|
portalElement: i ?? c,
|
78
78
|
taxonomyOptionsFetcher: f
|
79
79
|
})]
|
80
80
|
});
|
81
|
-
}, [o == null ? void 0 : o.fields.length, p, a,
|
81
|
+
}, [o == null ? void 0 : o.fields.length, p, a, d, i, c, f, s]);
|
82
82
|
return /* @__PURE__ */ r(_, {
|
83
83
|
initialValues: j,
|
84
84
|
onSubmit: w,
|
@@ -1,47 +1,47 @@
|
|
1
|
-
import E, { createContext as d, useState as
|
1
|
+
import E, { createContext as d, useState as l, useCallback as S, useMemo as v, useContext as x } from "react";
|
2
2
|
import { TEMPLATE_CUSTOM_PROPERTIES as A } from "../constants.js";
|
3
3
|
import { jsx as P } from "react/jsx-runtime";
|
4
4
|
const _ = 1e4, T = /* @__PURE__ */ d(null), M = ({
|
5
5
|
children: e,
|
6
6
|
isAiSuggestionsFeatureEnabled: o,
|
7
|
-
fetchSuggestions:
|
7
|
+
fetchSuggestions: c
|
8
8
|
}) => {
|
9
|
-
const [s,
|
9
|
+
const [s, f] = l({}), [r, n] = l(!1), [g, i] = l(!1);
|
10
10
|
E.useEffect(() => {
|
11
11
|
let t;
|
12
12
|
return r ? t = setTimeout(() => {
|
13
|
-
|
14
|
-
}, _) : (
|
13
|
+
i(!0);
|
14
|
+
}, _) : (i(!1), clearTimeout(t)), () => clearTimeout(t);
|
15
15
|
}, [r]);
|
16
16
|
const m = S(async (t, w) => {
|
17
|
-
let
|
17
|
+
let u = [];
|
18
18
|
if (!o)
|
19
19
|
throw new Error("AI Suggestions feature not available.");
|
20
20
|
if (t === A)
|
21
21
|
throw new Error("Can't fetch suggestions for Custom Metadata instance");
|
22
|
-
|
22
|
+
n(!0);
|
23
23
|
try {
|
24
|
-
|
24
|
+
u = await c(t, w), f({
|
25
25
|
...s,
|
26
26
|
[t]: {
|
27
|
-
...Object.fromEntries(
|
27
|
+
...Object.fromEntries(u.map((a) => [a.key, a.aiSuggestion]))
|
28
28
|
}
|
29
29
|
});
|
30
30
|
} catch {
|
31
31
|
} finally {
|
32
|
-
|
32
|
+
n(!1);
|
33
33
|
}
|
34
|
-
return
|
35
|
-
}, [o, s,
|
36
|
-
|
34
|
+
return u;
|
35
|
+
}, [o, s, c]), C = S(() => {
|
36
|
+
f({}), n(!1), i(!1);
|
37
37
|
}, []), h = v(() => ({
|
38
|
-
|
38
|
+
clearState: C,
|
39
39
|
getAiSuggestions: m,
|
40
40
|
isAiSuggestionsFeatureEnabled: o,
|
41
41
|
isFetchingSuggestions: r,
|
42
|
-
isLongLoading:
|
42
|
+
isLongLoading: g,
|
43
43
|
suggestions: s
|
44
|
-
}), [C, m, o, r,
|
44
|
+
}), [C, m, o, r, g, s]);
|
45
45
|
return /* @__PURE__ */ P(T.Provider, {
|
46
46
|
value: h,
|
47
47
|
children: e
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@box/metadata-editor",
|
3
|
-
"version": "0.92.
|
3
|
+
"version": "0.92.6",
|
4
4
|
"peerDependencies": {
|
5
5
|
"@ariakit/react": "0.4.15",
|
6
6
|
"@box/blueprint-web": "^7.30.3",
|
@@ -14,8 +14,8 @@
|
|
14
14
|
"devDependencies": {
|
15
15
|
"@ariakit/react": "0.4.15",
|
16
16
|
"@box/babel-plugin-target-attributes": "1.3.0",
|
17
|
-
"@box/blueprint-web": "^9.18.
|
18
|
-
"@box/blueprint-web-assets": "^4.33.
|
17
|
+
"@box/blueprint-web": "^9.18.3",
|
18
|
+
"@box/blueprint-web-assets": "^4.33.2",
|
19
19
|
"@box/storybook-utils": "^0.8.3",
|
20
20
|
"@testing-library/react": "^15.0.6",
|
21
21
|
"react": "^18.3.0",
|
@@ -53,5 +53,5 @@
|
|
53
53
|
"**/*.css"
|
54
54
|
],
|
55
55
|
"license": "SEE LICENSE IN LICENSE",
|
56
|
-
"gitHead": "
|
56
|
+
"gitHead": "2b482e2a7d776580eb6cf3e25e3fd3c58aa03123"
|
57
57
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { default as React } from 'react';
|
2
2
|
import { AutofillSuggestions, MetadataTemplateField, MetadataTemplateInstance } from '../types';
|
3
3
|
export interface AutofillContextType {
|
4
|
-
|
4
|
+
clearState: () => void;
|
5
5
|
getAiSuggestions: (templateKey: MetadataTemplateInstance['templateKey'], scope: MetadataTemplateInstance['scope']) => Promise<MetadataTemplateField[]>;
|
6
6
|
isAiSuggestionsFeatureEnabled: boolean;
|
7
7
|
isFetchingSuggestions: boolean;
|