@box/metadata-editor 0.51.0 → 0.51.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,27 +1,24 @@
|
|
1
|
-
import { createContext as
|
1
|
+
import { createContext as C, useState as g, useCallback as p, useMemo as A, useContext as v } from "react";
|
2
2
|
import { TEMPLATE_CUSTOM_PROPERTIES as x } from "../constants.js";
|
3
|
-
import {
|
4
|
-
import "
|
5
|
-
const
|
6
|
-
|
7
|
-
|
8
|
-
})), m = /* @__PURE__ */ w(null), I = ({
|
9
|
-
children: o,
|
10
|
-
isAiSuggestionsFeatureEnabled: s
|
3
|
+
import { fetchSuggestions as E } from "./utils.js";
|
4
|
+
import { jsx as P } from "react/jsx-runtime";
|
5
|
+
const m = /* @__PURE__ */ C(null), y = ({
|
6
|
+
children: e,
|
7
|
+
isAiSuggestionsFeatureEnabled: n
|
11
8
|
}) => {
|
12
|
-
const [t,
|
13
|
-
let
|
14
|
-
if (!
|
9
|
+
const [t, h] = g({}), [i, u] = g(!1), a = p(async (r, l, w = !1) => {
|
10
|
+
let s = [];
|
11
|
+
if (!n)
|
15
12
|
throw new Error("AI Suggestions feature not available.");
|
16
|
-
if (
|
13
|
+
if (r === x)
|
17
14
|
throw new Error("Can't fetch suggestions for Custom Metadata instance");
|
18
|
-
if (!t[
|
15
|
+
if (!t[r] || w) {
|
19
16
|
u(!0);
|
20
17
|
try {
|
21
|
-
|
18
|
+
s = await E(r, l), h({
|
22
19
|
...t,
|
23
|
-
[
|
24
|
-
...Object.fromEntries(
|
20
|
+
[r]: {
|
21
|
+
...Object.fromEntries(s.map((o) => [o.key, o.aiSuggestion]))
|
25
22
|
}
|
26
23
|
});
|
27
24
|
} catch {
|
@@ -29,35 +26,35 @@ const E = async (o, s) => s.map((t) => ({
|
|
29
26
|
u(!1);
|
30
27
|
}
|
31
28
|
} else
|
32
|
-
|
33
|
-
var
|
34
|
-
const
|
29
|
+
s = l.map((o) => {
|
30
|
+
var f;
|
31
|
+
const c = (f = t == null ? void 0 : t.templateKey) == null ? void 0 : f[o.key];
|
35
32
|
return {
|
36
|
-
...
|
37
|
-
...
|
38
|
-
aiSuggestion:
|
33
|
+
...o,
|
34
|
+
...c ? {
|
35
|
+
aiSuggestion: c
|
39
36
|
} : null
|
40
37
|
};
|
41
38
|
});
|
42
|
-
return
|
43
|
-
}, [t]),
|
39
|
+
return s;
|
40
|
+
}, [t]), S = A(() => ({
|
44
41
|
getAiSuggestions: a,
|
45
|
-
isAiSuggestionsFeatureEnabled:
|
42
|
+
isAiSuggestionsFeatureEnabled: n,
|
46
43
|
isFetchingSuggestions: i,
|
47
44
|
suggestions: t
|
48
|
-
}), [a,
|
49
|
-
return /* @__PURE__ */
|
50
|
-
value:
|
51
|
-
children:
|
45
|
+
}), [a, n, i, t]);
|
46
|
+
return /* @__PURE__ */ P(m.Provider, {
|
47
|
+
value: S,
|
48
|
+
children: e
|
52
49
|
});
|
53
|
-
},
|
54
|
-
const
|
55
|
-
if (!
|
50
|
+
}, I = () => {
|
51
|
+
const e = v(m);
|
52
|
+
if (!e)
|
56
53
|
throw new Error("useAutofill should be wrapped inside AutofillProvider");
|
57
|
-
return
|
54
|
+
return e;
|
58
55
|
};
|
59
56
|
export {
|
60
57
|
m as AutofillContext,
|
61
|
-
|
62
|
-
|
58
|
+
y as AutofillContextProvider,
|
59
|
+
I as useAutofill
|
63
60
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@box/metadata-editor",
|
3
|
-
"version": "0.51.
|
3
|
+
"version": "0.51.1",
|
4
4
|
"peerDependencies": {
|
5
5
|
"@ariakit/react": "0.4.5",
|
6
6
|
"@box/blueprint-web": "^7.20.0",
|
@@ -52,5 +52,5 @@
|
|
52
52
|
"**/*.css"
|
53
53
|
],
|
54
54
|
"license": "SEE LICENSE IN LICENSE",
|
55
|
-
"gitHead": "
|
55
|
+
"gitHead": "114a9fc84dfc0b21d45b6b647064e736ea022384"
|
56
56
|
}
|
@@ -3,4 +3,3 @@ export declare const updateText: (el: any, text: any) => Promise<void>;
|
|
3
3
|
export declare const blur: () => Promise<void>;
|
4
4
|
export declare const updateTextAndBlur: (el: any, text: any) => Promise<void>;
|
5
5
|
export declare const checkIfFormFieldsAreDisabled: (canvasElement: HTMLElement, fields: MetadataTemplateField[]) => Promise<void>;
|
6
|
-
export declare const fetchSuggestions: (templateKey: string, fields: MetadataTemplateField[]) => Promise<MetadataTemplateField[]>;
|