@box/metadata-editor 0.67.0 → 0.67.2
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,74 +1,85 @@
|
|
1
1
|
import "../../../../../../styles/metadata-instance-form-header.css";
|
2
|
-
import { Focusable as
|
3
|
-
import { Text as
|
2
|
+
import { Focusable as v } from "@ariakit/react";
|
3
|
+
import { Text as K, Tooltip as h, Button as k } from "@box/blueprint-web";
|
4
4
|
import { BoxAiLogo as S } from "@box/blueprint-web-assets/icons/Logo";
|
5
|
-
import { useFormikContext as j, getIn as
|
6
|
-
import { useState as C, useRef as E, useEffect as
|
5
|
+
import { useFormikContext as j, getIn as i } from "formik";
|
6
|
+
import { useState as C, useRef as E, useEffect as I } from "react";
|
7
7
|
import { useIntl as L } from "react-intl";
|
8
|
-
import
|
9
|
-
import
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
8
|
+
import { useAutofill as N } from "../../../../utils/autofill-context.js";
|
9
|
+
import r from "./messages.js";
|
10
|
+
import { jsx as o, jsxs as R } from "react/jsx-runtime";
|
11
|
+
const W = "_metadataInstanceFormHeader_rdx5o_1", D = "_title_rdx5o_9", x = {
|
12
|
+
metadataInstanceFormHeader: W,
|
13
|
+
title: D
|
14
|
+
}, X = ({
|
15
|
+
areAiSuggestionsAvailable: B,
|
16
|
+
isAiSuggestionsFeatureEnabled: F,
|
17
|
+
isLoading: d,
|
18
|
+
templateName: T,
|
19
|
+
onAutofill: y
|
19
20
|
}) => {
|
20
21
|
const {
|
21
|
-
isSubmitting:
|
22
|
-
values:
|
23
|
-
setFieldValue:
|
24
|
-
} = j(),
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
22
|
+
isSubmitting: b,
|
23
|
+
values: n,
|
24
|
+
setFieldValue: u
|
25
|
+
} = j(), s = L(), {
|
26
|
+
suggestions: t
|
27
|
+
} = N(), [M, _] = C(!1), l = E(null);
|
28
|
+
I(() => {
|
29
|
+
if (t) {
|
30
|
+
const e = i(n, "metadata.fields"), a = i(n, "metadata.templateKey");
|
31
|
+
u("metadata.fields", e.map((c) => {
|
32
|
+
var g;
|
33
|
+
const p = (g = t == null ? void 0 : t[a]) == null ? void 0 : g[c.key];
|
34
|
+
return p ? {
|
35
|
+
...c,
|
36
|
+
aiSuggestion: p
|
37
|
+
} : c;
|
38
|
+
}));
|
39
|
+
}
|
40
|
+
}, [t, u]);
|
41
|
+
const A = () => {
|
42
|
+
const e = i(n, "metadata.fields"), a = i(n, "metadata.templateKey");
|
43
|
+
y(a, e);
|
44
|
+
}, m = T ?? s.formatMessage(r.customInstanceTitle);
|
45
|
+
I(() => {
|
46
|
+
if (l.current) {
|
36
47
|
const {
|
37
|
-
scrollWidth:
|
38
|
-
clientWidth:
|
39
|
-
} =
|
40
|
-
|
48
|
+
scrollWidth: e,
|
49
|
+
clientWidth: a
|
50
|
+
} = l.current;
|
51
|
+
_(e > a);
|
41
52
|
}
|
42
|
-
}, [
|
43
|
-
const
|
44
|
-
ref:
|
53
|
+
}, [m]);
|
54
|
+
const f = /* @__PURE__ */ o(K, {
|
55
|
+
ref: l,
|
45
56
|
as: "h1",
|
46
|
-
className:
|
57
|
+
className: x.title,
|
47
58
|
variant: "titleMedium",
|
48
|
-
children:
|
49
|
-
}),
|
50
|
-
return /* @__PURE__ */
|
51
|
-
className:
|
52
|
-
children: [
|
53
|
-
content:
|
54
|
-
children: /* @__PURE__ */
|
55
|
-
render:
|
59
|
+
children: m
|
60
|
+
}), H = !B || b || d;
|
61
|
+
return /* @__PURE__ */ R("div", {
|
62
|
+
className: x.metadataInstanceFormHeader,
|
63
|
+
children: [M ? /* @__PURE__ */ o(h, {
|
64
|
+
content: m,
|
65
|
+
children: /* @__PURE__ */ o(v, {
|
66
|
+
render: f
|
56
67
|
})
|
57
|
-
}) :
|
58
|
-
content:
|
59
|
-
children: /* @__PURE__ */
|
60
|
-
disabled:
|
68
|
+
}) : f, F && /* @__PURE__ */ o(h, {
|
69
|
+
content: s.formatMessage(r.autofillButtonTooltip),
|
70
|
+
children: /* @__PURE__ */ o(k, {
|
71
|
+
disabled: H,
|
61
72
|
icon: S,
|
62
|
-
loading:
|
63
|
-
loadingAriaLabel:
|
64
|
-
onClick:
|
73
|
+
loading: d,
|
74
|
+
loadingAriaLabel: s.formatMessage(r.loadingButtonAriaLabel),
|
75
|
+
onClick: A,
|
65
76
|
variant: "secondary",
|
66
77
|
"data-target-id": "Button-autofillButton",
|
67
|
-
children:
|
78
|
+
children: s.formatMessage(r.autofillButton)
|
68
79
|
})
|
69
80
|
})]
|
70
81
|
});
|
71
82
|
};
|
72
83
|
export {
|
73
|
-
|
84
|
+
X as MetadataInstanceFormHeader
|
74
85
|
};
|
@@ -1,61 +1,49 @@
|
|
1
|
-
import { createContext as
|
2
|
-
import { TEMPLATE_CUSTOM_PROPERTIES as
|
3
|
-
import { fetchSuggestions as
|
4
|
-
import { jsx as
|
5
|
-
const
|
6
|
-
children:
|
7
|
-
isAiSuggestionsFeatureEnabled:
|
8
|
-
fetchSuggestions: i =
|
1
|
+
import { createContext as w, useState as l, useCallback as C, useMemo as S, useContext as p } from "react";
|
2
|
+
import { TEMPLATE_CUSTOM_PROPERTIES as v } from "../constants.js";
|
3
|
+
import { fetchSuggestions as x } from "./utils.js";
|
4
|
+
import { jsx as A } from "react/jsx-runtime";
|
5
|
+
const a = /* @__PURE__ */ w(null), T = ({
|
6
|
+
children: t,
|
7
|
+
isAiSuggestionsFeatureEnabled: o,
|
8
|
+
fetchSuggestions: i = x
|
9
9
|
}) => {
|
10
|
-
const [
|
11
|
-
let
|
12
|
-
if (!
|
10
|
+
const [e, g] = l({}), [u, f] = l(!1), c = C(async (s, m) => {
|
11
|
+
let r = [];
|
12
|
+
if (!o)
|
13
13
|
throw new Error("AI Suggestions feature not available.");
|
14
|
-
if (s ===
|
14
|
+
if (s === v)
|
15
15
|
throw new Error("Can't fetch suggestions for Custom Metadata instance");
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
[
|
22
|
-
|
23
|
-
}
|
24
|
-
});
|
25
|
-
} catch {
|
26
|
-
} finally {
|
27
|
-
l(!1);
|
28
|
-
}
|
29
|
-
} else
|
30
|
-
n = c.map((o) => {
|
31
|
-
var g;
|
32
|
-
const f = (g = t == null ? void 0 : t.templateKey) == null ? void 0 : g[o.key];
|
33
|
-
return {
|
34
|
-
...o,
|
35
|
-
...f ? {
|
36
|
-
aiSuggestion: f
|
37
|
-
} : null
|
38
|
-
};
|
16
|
+
f(!0);
|
17
|
+
try {
|
18
|
+
r = await i(s, m), g({
|
19
|
+
...e,
|
20
|
+
[s]: {
|
21
|
+
...Object.fromEntries(r.map((n) => [n.key, n.aiSuggestion]))
|
22
|
+
}
|
39
23
|
});
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
24
|
+
} catch {
|
25
|
+
} finally {
|
26
|
+
f(!1);
|
27
|
+
}
|
28
|
+
return r;
|
29
|
+
}, [o, e, i]), h = S(() => ({
|
30
|
+
getAiSuggestions: c,
|
31
|
+
isAiSuggestionsFeatureEnabled: o,
|
44
32
|
isFetchingSuggestions: u,
|
45
|
-
suggestions:
|
46
|
-
}), [
|
47
|
-
return /* @__PURE__ */
|
48
|
-
value:
|
49
|
-
children:
|
33
|
+
suggestions: e
|
34
|
+
}), [c, o, u, e]);
|
35
|
+
return /* @__PURE__ */ A(a.Provider, {
|
36
|
+
value: h,
|
37
|
+
children: t
|
50
38
|
});
|
51
|
-
},
|
52
|
-
const
|
53
|
-
if (!
|
39
|
+
}, I = () => {
|
40
|
+
const t = p(a);
|
41
|
+
if (!t)
|
54
42
|
throw new Error("useAutofill should be wrapped inside AutofillProvider");
|
55
|
-
return
|
43
|
+
return t;
|
56
44
|
};
|
57
45
|
export {
|
58
|
-
|
59
|
-
|
60
|
-
|
46
|
+
a as AutofillContext,
|
47
|
+
T as AutofillContextProvider,
|
48
|
+
I as useAutofill
|
61
49
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@box/metadata-editor",
|
3
|
-
"version": "0.67.
|
3
|
+
"version": "0.67.2",
|
4
4
|
"peerDependencies": {
|
5
5
|
"@ariakit/react": "0.4.5",
|
6
6
|
"@box/blueprint-web": "^7.30.3",
|
@@ -53,5 +53,5 @@
|
|
53
53
|
"**/*.css"
|
54
54
|
],
|
55
55
|
"license": "SEE LICENSE IN LICENSE",
|
56
|
-
"gitHead": "
|
56
|
+
"gitHead": "929c67de4e531589b2c79b9617594910874c3062"
|
57
57
|
}
|