@box/metadata-editor 0.60.4 → 0.61.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/esm/index.js +18 -16
- package/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form.js +20 -20
- package/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-header/metadata-instance-form-header.js +39 -33
- package/esm/lib/components/metadata-instance-list/subcomponents/metadata-instance/metadata-instance.js +16 -16
- package/esm/lib/components/metadata-instance-list/subcomponents/metadata-instance-header/messages.js +2 -2
- package/esm/lib/components/metadata-instance-list/subcomponents/metadata-instance-header/metadata-instance-header.js +19 -15
- package/esm/lib/utils/api-wrapper.js +19 -0
- package/esm/lib/utils/autofill-context.js +33 -32
- package/i18n/en-US.js +2 -2
- package/i18n/en-US.properties +2 -2
- package/i18n/json/src/lib/components/metadata-instance-list/subcomponents/metadata-instance-header/messages.json +1 -1
- package/package.json +2 -2
- package/types/index.d.ts +1 -0
- package/types/lib/components/metadata-instance-list/subcomponents/metadata-instance/types.d.ts +1 -1
- package/types/lib/components/metadata-instance-list/types.d.ts +1 -1
- package/types/lib/utils/api-wrapper.d.ts +2 -0
- package/types/lib/utils/autofill-context.d.ts +5 -3
package/esm/index.js
CHANGED
@@ -1,35 +1,37 @@
|
|
1
1
|
import { AddMetadataTemplateDropdown as o } from "./lib/components/add-metadata-template-dropdown/add-metadata-template-dropdown.js";
|
2
2
|
import { FilterDropdownMenu as r } from "./lib/components/filter-dropdown-menu/index.js";
|
3
|
-
import { SingleLevelTaxonomyField as
|
3
|
+
import { SingleLevelTaxonomyField as p } from "./lib/components/metadata-editor-fields/components/metadata-taxonomy-field/single-level-taxonomy-field.js";
|
4
4
|
import { MetadataEmptyState as f } from "./lib/components/metadata-empty-state/metadata-empty-state.js";
|
5
5
|
import { DeleteConfirmationModal as l } from "./lib/components/metadata-instance-editor/subcomponents/delete-confirmation-modal/delete-confirmation-modal.js";
|
6
6
|
import { MetadataInstanceFormHeader as i } from "./lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-header/metadata-instance-form-header.js";
|
7
7
|
import { CustomInstanceNewField as s } from "./lib/components/metadata-instance-editor/subcomponents/custom-instance-new-field/custom-instance-new-field.js";
|
8
8
|
import { MetadataInstanceForm as I } from "./lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form.js";
|
9
|
-
import { MetadataInstanceList as
|
10
|
-
import { MetadataInstanceHeader as
|
11
|
-
import { UnsavedChangesModal as
|
9
|
+
import { MetadataInstanceList as A } from "./lib/components/metadata-instance-list/metadata-instance-list.js";
|
10
|
+
import { MetadataInstanceHeader as F } from "./lib/components/metadata-instance-list/subcomponents/metadata-instance-header/metadata-instance-header.js";
|
11
|
+
import { UnsavedChangesModal as v } from "./lib/components/unsaved-changes-modal/unsaved-changes-modal.js";
|
12
12
|
import { defaultInitialValues as U, defaultMetadataValueMap as g } from "./lib/defaults.js";
|
13
|
-
import { MetadataEditor as
|
14
|
-
import { U as
|
15
|
-
import { AutofillContext as
|
13
|
+
import { MetadataEditor as y } from "./lib/metadata-editor.js";
|
14
|
+
import { U as H } from "../chunks/types.js";
|
15
|
+
import { AutofillContext as S, AutofillContextProvider as T, useAutofill as V } from "./lib/utils/autofill-context.js";
|
16
|
+
import { withApiWrapper as P } from "./lib/utils/api-wrapper.js";
|
16
17
|
export {
|
17
18
|
o as AddMetadataTemplateDropdown,
|
18
|
-
|
19
|
-
|
19
|
+
S as AutofillContext,
|
20
|
+
T as AutofillContextProvider,
|
20
21
|
s as CustomInstanceNewField,
|
21
22
|
l as DeleteConfirmationModal,
|
22
23
|
r as FilterDropdownMenu,
|
23
|
-
|
24
|
+
y as MetadataEditor,
|
24
25
|
f as MetadataEmptyState,
|
25
26
|
I as MetadataInstanceForm,
|
26
27
|
i as MetadataInstanceFormHeader,
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
F as MetadataInstanceHeader,
|
29
|
+
A as MetadataInstanceList,
|
30
|
+
p as SingleLevelTaxonomyField,
|
31
|
+
v as UnsavedChangesModal,
|
32
|
+
H as UpdateMode,
|
32
33
|
U as defaultInitialValues,
|
33
34
|
g as defaultMetadataValueMap,
|
34
|
-
|
35
|
+
V as useAutofill,
|
36
|
+
P as withApiWrapper
|
35
37
|
};
|
@@ -2,10 +2,10 @@ import "../../../../../../styles/metadata-instance-form.css";
|
|
2
2
|
import { Card as v } from "@box/blueprint-web";
|
3
3
|
import { Formik as N, Form as P } from "formik";
|
4
4
|
import { useState as c, useRef as U, useEffect as _, useMemo as x } from "react";
|
5
|
-
import { TEMPLATE_CUSTOM_PROPERTIES as
|
6
|
-
import { useAutofill as
|
7
|
-
import { TemplateInstance as
|
8
|
-
import { MetadataEmptyState as
|
5
|
+
import { TEMPLATE_CUSTOM_PROPERTIES as L } from "../../../../constants.js";
|
6
|
+
import { useAutofill as R } from "../../../../utils/autofill-context.js";
|
7
|
+
import { TemplateInstance as B } from "../../../metadata-editor-fields/metadata-editor-fields.js";
|
8
|
+
import { MetadataEmptyState as K } from "../../../metadata-empty-state/metadata-empty-state.js";
|
9
9
|
import { UnsavedChangesModal as j } from "../../../unsaved-changes-modal/unsaved-changes-modal.js";
|
10
10
|
import { CustomInstance as k } from "../custom-instance/custom-instance.js";
|
11
11
|
import { DeleteConfirmationModal as $ } from "../delete-confirmation-modal/delete-confirmation-modal.js";
|
@@ -15,7 +15,7 @@ import { createJSONPatch as J } from "./utils.js";
|
|
15
15
|
import { jsx as t, jsxs as d } from "react/jsx-runtime";
|
16
16
|
const V = "_metadataInstanceForm_1hu4u_1", q = {
|
17
17
|
metadataInstanceForm: V
|
18
|
-
},
|
18
|
+
}, me = (p) => {
|
19
19
|
const {
|
20
20
|
areAiSuggestionsAvailable: f,
|
21
21
|
isAiSuggestionsFeatureEnabled: o,
|
@@ -27,44 +27,44 @@ const V = "_metadataInstanceForm_1hu4u_1", q = {
|
|
27
27
|
selectedTemplateInstance: e,
|
28
28
|
setIsUnsavedChangesModalOpen: i,
|
29
29
|
onDiscardUnsavedChanges: M
|
30
|
-
} = p, [S,
|
30
|
+
} = p, [S, r] = c(!1), {
|
31
31
|
isFetchingSuggestions: n,
|
32
32
|
getAiSuggestions: E
|
33
|
-
} =
|
33
|
+
} = R(), s = e.templateKey === L, I = async (a) => {
|
34
34
|
await F(a, J(a, e));
|
35
35
|
}, D = (a) => {
|
36
36
|
a ? i(!0) : h();
|
37
|
-
},
|
38
|
-
|
39
|
-
},
|
37
|
+
}, b = () => {
|
38
|
+
r(!0);
|
39
|
+
}, y = {
|
40
40
|
metadata: {
|
41
41
|
...e
|
42
42
|
}
|
43
|
-
},
|
43
|
+
}, m = U(null), [l, A] = c(null);
|
44
44
|
_(() => {
|
45
|
-
A(
|
45
|
+
A(m.current);
|
46
46
|
}, [e.templateKey, e.scope]);
|
47
47
|
const O = x(() => {
|
48
48
|
const a = e.fields.length === 0;
|
49
49
|
return s ? /* @__PURE__ */ t(k, {
|
50
50
|
isLoading: n
|
51
|
-
}) : a ? /* @__PURE__ */ t(
|
51
|
+
}) : a ? /* @__PURE__ */ t(K, {
|
52
52
|
isBoxAiSuggestionsFeatureEnabled: o,
|
53
53
|
level: "instance"
|
54
|
-
}) : /* @__PURE__ */ t(
|
54
|
+
}) : /* @__PURE__ */ t(B, {
|
55
55
|
disableForm: n,
|
56
56
|
portalElement: l
|
57
57
|
});
|
58
|
-
}, [s, e.fields.length,
|
58
|
+
}, [s, e.fields.length, n, o, l]);
|
59
59
|
return /* @__PURE__ */ t(N, {
|
60
|
-
initialValues:
|
60
|
+
initialValues: y,
|
61
61
|
onSubmit: I,
|
62
62
|
children: ({
|
63
63
|
values: a,
|
64
64
|
dirty: T
|
65
65
|
}) => /* @__PURE__ */ d(P, {
|
66
66
|
children: [/* @__PURE__ */ d(v, {
|
67
|
-
ref:
|
67
|
+
ref: m,
|
68
68
|
className: q.metadataInstanceForm,
|
69
69
|
children: [/* @__PURE__ */ t(H, {
|
70
70
|
areAiSuggestionsAvailable: f,
|
@@ -76,7 +76,7 @@ const V = "_metadataInstanceForm_1hu4u_1", q = {
|
|
76
76
|
isDeleteButtonDisabled: u,
|
77
77
|
isLoading: n,
|
78
78
|
onCancel: () => D(T),
|
79
|
-
onDelete:
|
79
|
+
onDelete: b
|
80
80
|
})]
|
81
81
|
}), /* @__PURE__ */ t(j, {
|
82
82
|
onBackToEdit: () => i(!1),
|
@@ -84,7 +84,7 @@ const V = "_metadataInstanceForm_1hu4u_1", q = {
|
|
84
84
|
open: g
|
85
85
|
}), /* @__PURE__ */ t($, {
|
86
86
|
onConfirm: () => C(e),
|
87
|
-
onDismiss: () =>
|
87
|
+
onDismiss: () => r(!1),
|
88
88
|
open: S,
|
89
89
|
templateName: e.displayName
|
90
90
|
})]
|
@@ -92,5 +92,5 @@ const V = "_metadataInstanceForm_1hu4u_1", q = {
|
|
92
92
|
}, `${e.scope}.${e.templateKey}`);
|
93
93
|
};
|
94
94
|
export {
|
95
|
-
|
95
|
+
me as MetadataInstanceForm
|
96
96
|
};
|
@@ -1,43 +1,49 @@
|
|
1
1
|
import "../../../../../../styles/metadata-instance-form-header.css";
|
2
|
-
import { Text as
|
3
|
-
import { BoxAiLogo as
|
4
|
-
import { useFormikContext as
|
5
|
-
import { useIntl as
|
2
|
+
import { Text as x, Tooltip as M, Button as _ } from "@box/blueprint-web";
|
3
|
+
import { BoxAiLogo as H } from "@box/blueprint-web-assets/icons/Logo";
|
4
|
+
import { useFormikContext as k, getIn as m } from "formik";
|
5
|
+
import { useIntl as v } from "react-intl";
|
6
6
|
import e from "./messages.js";
|
7
|
-
import { jsxs as
|
8
|
-
const
|
9
|
-
metadataInstanceFormHeader:
|
10
|
-
title:
|
11
|
-
},
|
12
|
-
areAiSuggestionsAvailable:
|
13
|
-
isAiSuggestionsFeatureEnabled:
|
14
|
-
isLoading:
|
15
|
-
templateName:
|
16
|
-
onAutofill:
|
7
|
+
import { jsxs as A, jsx as n } from "react/jsx-runtime";
|
8
|
+
const T = "_metadataInstanceFormHeader_1b2cc_1", S = "_title_1b2cc_8", c = {
|
9
|
+
metadataInstanceFormHeader: T,
|
10
|
+
title: S
|
11
|
+
}, V = ({
|
12
|
+
areAiSuggestionsAvailable: d,
|
13
|
+
isAiSuggestionsFeatureEnabled: u,
|
14
|
+
isLoading: s,
|
15
|
+
templateName: f,
|
16
|
+
onAutofill: g
|
17
17
|
}) => {
|
18
18
|
const {
|
19
|
-
isSubmitting:
|
20
|
-
values:
|
21
|
-
setFieldValue:
|
22
|
-
} =
|
23
|
-
const
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
19
|
+
isSubmitting: p,
|
20
|
+
values: i,
|
21
|
+
setFieldValue: B
|
22
|
+
} = k(), t = v(), I = async () => {
|
23
|
+
const r = m(i, "metadata.fields"), F = m(i, "metadata.templateKey"), a = await g(F, r);
|
24
|
+
B("metadata.fields", r.map((o) => {
|
25
|
+
const l = a == null ? void 0 : a.find((h) => h.key === o.key);
|
26
|
+
return l ? {
|
27
|
+
...o,
|
28
|
+
aiSuggestion: l.aiSuggestion
|
29
|
+
} : o;
|
30
|
+
}));
|
31
|
+
}, b = f ?? t.formatMessage(e.customInstanceTitle), y = !d || p || s;
|
32
|
+
return /* @__PURE__ */ A("div", {
|
33
|
+
className: c.metadataInstanceFormHeader,
|
34
|
+
children: [/* @__PURE__ */ n(x, {
|
29
35
|
as: "h1",
|
30
|
-
className:
|
36
|
+
className: c.title,
|
31
37
|
variant: "titleMedium",
|
32
|
-
children:
|
33
|
-
}),
|
38
|
+
children: b
|
39
|
+
}), u && /* @__PURE__ */ n(M, {
|
34
40
|
content: t.formatMessage(e.autofillButtonTooltip),
|
35
|
-
children: /* @__PURE__ */
|
36
|
-
disabled:
|
37
|
-
icon:
|
38
|
-
loading:
|
41
|
+
children: /* @__PURE__ */ n(_, {
|
42
|
+
disabled: y,
|
43
|
+
icon: H,
|
44
|
+
loading: s,
|
39
45
|
loadingAriaLabel: t.formatMessage(e.loadingButtonAriaLabel),
|
40
|
-
onClick:
|
46
|
+
onClick: I,
|
41
47
|
variant: "secondary",
|
42
48
|
"data-target-id": "Button-autofillButton",
|
43
49
|
children: t.formatMessage(e.autofillButton)
|
@@ -46,5 +52,5 @@ const v = "_metadataInstanceFormHeader_1b2cc_1", A = "_title_1b2cc_8", i = {
|
|
46
52
|
});
|
47
53
|
};
|
48
54
|
export {
|
49
|
-
|
55
|
+
V as MetadataInstanceFormHeader
|
50
56
|
};
|
@@ -5,39 +5,39 @@ import { MetadataInstanceHeader as h } from "../metadata-instance-header/metadat
|
|
5
5
|
import { MetadataInstanceContent as D } from "../metadata-instance-content/metadata-instance-content.js";
|
6
6
|
import { MetadataInstanceFooter as V } from "../metadata-instance-footer/metadata-instance-footer.js";
|
7
7
|
import { MetadataEmptyState as b } from "../../../metadata-empty-state/metadata-empty-state.js";
|
8
|
-
import { jsxs as
|
8
|
+
import { jsxs as d, jsx as o, Fragment as l } from "react/jsx-runtime";
|
9
9
|
const H = "_topDivider_tzhlb_1", S = "_bottomDivider_tzhlb_5", n = {
|
10
10
|
topDivider: H,
|
11
11
|
bottomDivider: S
|
12
12
|
}, w = ({
|
13
|
-
isAiSuggestionsFeatureEnabled:
|
13
|
+
isAiSuggestionsFeatureEnabled: s,
|
14
14
|
onEdit: u,
|
15
15
|
onEditWithAutofill: p,
|
16
16
|
templateInstance: t
|
17
17
|
}) => {
|
18
|
-
const
|
19
|
-
return /* @__PURE__ */
|
20
|
-
children: [/* @__PURE__ */
|
18
|
+
const e = t.fields, y = e.every((a) => !a.value), v = e.some((a) => !a.value), c = e.length > 0, [i, r] = E(!0);
|
19
|
+
return /* @__PURE__ */ d(f, {
|
20
|
+
children: [/* @__PURE__ */ o(h, {
|
21
21
|
canEdit: !0,
|
22
|
-
isAiSuggestionsFeatureEnabled:
|
23
|
-
onAutofill: p,
|
22
|
+
isAiSuggestionsFeatureEnabled: s,
|
23
|
+
onAutofill: () => p(t),
|
24
24
|
onEdit: () => u(t),
|
25
25
|
templateName: t == null ? void 0 : t.displayName
|
26
|
-
}), /* @__PURE__ */
|
26
|
+
}), /* @__PURE__ */ o(m, {
|
27
27
|
className: n.topDivider
|
28
|
-
}), i && y ? /* @__PURE__ */
|
29
|
-
isAnyEmptyValueHidden:
|
30
|
-
isBoxAiSuggestionsFeatureEnabled:
|
28
|
+
}), i && y ? /* @__PURE__ */ o(b, {
|
29
|
+
isAnyEmptyValueHidden: c,
|
30
|
+
isBoxAiSuggestionsFeatureEnabled: s,
|
31
31
|
level: "instance",
|
32
32
|
onShowEmptyValues: () => r(!1)
|
33
|
-
}) : /* @__PURE__ */
|
34
|
-
children: [/* @__PURE__ */
|
33
|
+
}) : /* @__PURE__ */ d(l, {
|
34
|
+
children: [/* @__PURE__ */ o(D, {
|
35
35
|
shouldHideEmptyValues: i,
|
36
36
|
templateInstance: t
|
37
|
-
}),
|
38
|
-
children: [/* @__PURE__ */
|
37
|
+
}), v && /* @__PURE__ */ d(l, {
|
38
|
+
children: [/* @__PURE__ */ o(m, {
|
39
39
|
className: n.bottomDivider
|
40
|
-
}), /* @__PURE__ */
|
40
|
+
}), /* @__PURE__ */ o(V, {
|
41
41
|
isAnyEmptyValueHidden: i,
|
42
42
|
onHideEmptyValues: () => r(!0),
|
43
43
|
onShowEmptyValues: () => r(!1)
|
package/esm/lib/components/metadata-instance-list/subcomponents/metadata-instance-header/messages.js
CHANGED
@@ -6,11 +6,11 @@ const e = t({
|
|
6
6
|
},
|
7
7
|
autofillButtonTooltip: {
|
8
8
|
id: "metadataEditor.viewInstance.metadataInstanceHeader.autofillButtonTooltip",
|
9
|
-
defaultMessage: "Autofill with Box AI"
|
9
|
+
defaultMessage: "Autofill {templateName} with Box AI"
|
10
10
|
},
|
11
11
|
autofillButtonAriaLabel: {
|
12
12
|
id: "metadataEditor.viewInstance.metadataInstanceHeader.autofillButtonAriaLabel",
|
13
|
-
defaultMessage: "Autofill with Box AI"
|
13
|
+
defaultMessage: "Autofill {templateName} with Box AI"
|
14
14
|
},
|
15
15
|
editButtonTooltip: {
|
16
16
|
id: "metadataEditor.viewInstance.metadataInstanceHeader.editButtonTooltip",
|
@@ -3,43 +3,47 @@ import { Text as f, Tooltip as i, IconButton as s } from "@box/blueprint-web";
|
|
3
3
|
import { Pencil as g } from "@box/blueprint-web-assets/icons/Line";
|
4
4
|
import { BoxAiLogo as b } from "@box/blueprint-web-assets/icons/Logo";
|
5
5
|
import { useIntl as I } from "react-intl";
|
6
|
-
import
|
6
|
+
import n from "./messages.js";
|
7
7
|
import { jsxs as r, jsx as a } from "react/jsx-runtime";
|
8
|
-
const
|
9
|
-
metadataInstanceHeader:
|
10
|
-
iconButtonsContainer:
|
11
|
-
title:
|
8
|
+
const _ = "_metadataInstanceHeader_1vbbg_1", h = "_iconButtonsContainer_1vbbg_7", p = "_title_1vbbg_15", e = {
|
9
|
+
metadataInstanceHeader: _,
|
10
|
+
iconButtonsContainer: h,
|
11
|
+
title: p
|
12
12
|
}, T = ({
|
13
13
|
canEdit: c,
|
14
14
|
isAiSuggestionsFeatureEnabled: l,
|
15
15
|
onEdit: d,
|
16
|
-
onAutofill:
|
17
|
-
templateName:
|
16
|
+
onAutofill: u,
|
17
|
+
templateName: t
|
18
18
|
}) => {
|
19
|
-
const
|
19
|
+
const o = I(), m = t || o.formatMessage(n.customInstanceTitle), B = l && t;
|
20
20
|
return /* @__PURE__ */ r("div", {
|
21
21
|
className: e.metadataInstanceHeader,
|
22
22
|
children: [/* @__PURE__ */ a(f, {
|
23
23
|
as: "h1",
|
24
24
|
className: e.title,
|
25
25
|
variant: "titleMedium",
|
26
|
-
children:
|
26
|
+
children: m
|
27
27
|
}), c && /* @__PURE__ */ r("div", {
|
28
28
|
className: e.iconButtonsContainer,
|
29
29
|
children: [B && /* @__PURE__ */ a(i, {
|
30
|
-
content:
|
30
|
+
content: o.formatMessage(n.autofillButtonTooltip, {
|
31
|
+
templateName: t
|
32
|
+
}),
|
31
33
|
children: /* @__PURE__ */ a(s, {
|
32
|
-
"aria-label":
|
34
|
+
"aria-label": o.formatMessage(n.autofillButtonAriaLabel, {
|
35
|
+
templateName: t
|
36
|
+
}),
|
33
37
|
icon: b,
|
34
|
-
onClick:
|
38
|
+
onClick: u,
|
35
39
|
variant: "icon-logo",
|
36
40
|
"data-target-id": "IconButton-autofillButtonAriaLabel"
|
37
41
|
})
|
38
42
|
}), /* @__PURE__ */ a(i, {
|
39
|
-
content:
|
43
|
+
content: o.formatMessage(n.editButtonTooltip),
|
40
44
|
children: /* @__PURE__ */ a(s, {
|
41
|
-
"aria-label":
|
42
|
-
templateName:
|
45
|
+
"aria-label": o.formatMessage(n.editButtonAriaLabel, {
|
46
|
+
templateName: t
|
43
47
|
}),
|
44
48
|
icon: g,
|
45
49
|
onClick: d,
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { AutofillContextProvider as f } from "./autofill-context.js";
|
2
|
+
import { jsx as o } from "react/jsx-runtime";
|
3
|
+
function e(t) {
|
4
|
+
return ({
|
5
|
+
isAiSuggestionsFeatureEnabled: r,
|
6
|
+
fetchSuggestions: p,
|
7
|
+
...i
|
8
|
+
}) => /* @__PURE__ */ o(f, {
|
9
|
+
fetchSuggestions: p,
|
10
|
+
isAiSuggestionsFeatureEnabled: r,
|
11
|
+
children: /* @__PURE__ */ o(t, {
|
12
|
+
isAiSuggestionsFeatureEnabled: r,
|
13
|
+
...i
|
14
|
+
})
|
15
|
+
});
|
16
|
+
}
|
17
|
+
export {
|
18
|
+
e as withApiWrapper
|
19
|
+
};
|
@@ -1,60 +1,61 @@
|
|
1
|
-
import { createContext as
|
2
|
-
import { TEMPLATE_CUSTOM_PROPERTIES as
|
1
|
+
import { createContext as p, useState as m, useCallback as v, useMemo as x, useContext as A } from "react";
|
2
|
+
import { TEMPLATE_CUSTOM_PROPERTIES as P } from "../constants.js";
|
3
3
|
import { fetchSuggestions as E } from "./utils.js";
|
4
|
-
import { jsx as
|
5
|
-
const
|
4
|
+
import { jsx as M } from "react/jsx-runtime";
|
5
|
+
const h = /* @__PURE__ */ p(null), O = ({
|
6
6
|
children: e,
|
7
|
-
isAiSuggestionsFeatureEnabled:
|
7
|
+
isAiSuggestionsFeatureEnabled: r,
|
8
|
+
fetchSuggestions: i = E
|
8
9
|
}) => {
|
9
|
-
const [t,
|
10
|
-
let
|
11
|
-
if (!
|
10
|
+
const [t, S] = m({}), [u, l] = m(!1), a = v(async (s, c, C = !1) => {
|
11
|
+
let n = [];
|
12
|
+
if (!r)
|
12
13
|
throw new Error("AI Suggestions feature not available.");
|
13
|
-
if (
|
14
|
+
if (s === P)
|
14
15
|
throw new Error("Can't fetch suggestions for Custom Metadata instance");
|
15
|
-
if (!t[
|
16
|
-
|
16
|
+
if (!t[s] || C) {
|
17
|
+
l(!0);
|
17
18
|
try {
|
18
|
-
|
19
|
+
n = await i(s, c), S({
|
19
20
|
...t,
|
20
|
-
[
|
21
|
-
...Object.fromEntries(
|
21
|
+
[s]: {
|
22
|
+
...Object.fromEntries(n.map((o) => [o.key, o.aiSuggestion]))
|
22
23
|
}
|
23
24
|
});
|
24
25
|
} catch {
|
25
26
|
} finally {
|
26
|
-
|
27
|
+
l(!1);
|
27
28
|
}
|
28
29
|
} else
|
29
|
-
|
30
|
-
var
|
31
|
-
const
|
30
|
+
n = c.map((o) => {
|
31
|
+
var g;
|
32
|
+
const f = (g = t == null ? void 0 : t.templateKey) == null ? void 0 : g[o.key];
|
32
33
|
return {
|
33
34
|
...o,
|
34
|
-
...
|
35
|
-
aiSuggestion:
|
35
|
+
...f ? {
|
36
|
+
aiSuggestion: f
|
36
37
|
} : null
|
37
38
|
};
|
38
39
|
});
|
39
|
-
return
|
40
|
-
}, [t]),
|
40
|
+
return n;
|
41
|
+
}, [r, t, i]), w = x(() => ({
|
41
42
|
getAiSuggestions: a,
|
42
|
-
isAiSuggestionsFeatureEnabled:
|
43
|
-
isFetchingSuggestions:
|
43
|
+
isAiSuggestionsFeatureEnabled: r,
|
44
|
+
isFetchingSuggestions: u,
|
44
45
|
suggestions: t
|
45
|
-
}), [a,
|
46
|
-
return /* @__PURE__ */
|
47
|
-
value:
|
46
|
+
}), [a, r, u, t]);
|
47
|
+
return /* @__PURE__ */ M(h.Provider, {
|
48
|
+
value: w,
|
48
49
|
children: e
|
49
50
|
});
|
50
|
-
},
|
51
|
-
const e =
|
51
|
+
}, d = () => {
|
52
|
+
const e = A(h);
|
52
53
|
if (!e)
|
53
54
|
throw new Error("useAutofill should be wrapped inside AutofillProvider");
|
54
55
|
return e;
|
55
56
|
};
|
56
57
|
export {
|
57
|
-
|
58
|
-
|
59
|
-
|
58
|
+
h as AutofillContext,
|
59
|
+
O as AutofillContextProvider,
|
60
|
+
d as useAutofill
|
60
61
|
};
|
package/i18n/en-US.js
CHANGED
@@ -91,8 +91,8 @@ export default {
|
|
91
91
|
"metadataEditor.unsavedChangesModal.header": "Unsaved Changes",
|
92
92
|
"metadataEditor.viewInstance.metadataInstanceFooter.hideEmptyValuesCTA": "Hide empty values",
|
93
93
|
"metadataEditor.viewInstance.metadataInstanceFooter.showEmptyValuesCTA": "Show empty values",
|
94
|
-
"metadataEditor.viewInstance.metadataInstanceHeader.autofillButtonAriaLabel": "Autofill with Box AI",
|
95
|
-
"metadataEditor.viewInstance.metadataInstanceHeader.autofillButtonTooltip": "Autofill with Box AI",
|
94
|
+
"metadataEditor.viewInstance.metadataInstanceHeader.autofillButtonAriaLabel": "Autofill {templateName} with Box AI",
|
95
|
+
"metadataEditor.viewInstance.metadataInstanceHeader.autofillButtonTooltip": "Autofill {templateName} with Box AI",
|
96
96
|
"metadataEditor.viewInstance.metadataInstanceHeader.customMetadataTitle": "Custom Metadata",
|
97
97
|
"metadataEditor.viewInstance.metadataInstanceHeader.editButtonAriaLabel": "Edit {templateName}",
|
98
98
|
"metadataEditor.viewInstance.metadataInstanceHeader.editButtonTooltip": "Edit"
|
package/i18n/en-US.properties
CHANGED
@@ -183,9 +183,9 @@ metadataEditor.viewInstance.metadataInstanceFooter.hideEmptyValuesCTA = Hide emp
|
|
183
183
|
# Call to action to show hidden empty values
|
184
184
|
metadataEditor.viewInstance.metadataInstanceFooter.showEmptyValuesCTA = Show empty values
|
185
185
|
# Aria label for the autofill button
|
186
|
-
metadataEditor.viewInstance.metadataInstanceHeader.autofillButtonAriaLabel = Autofill with Box AI
|
186
|
+
metadataEditor.viewInstance.metadataInstanceHeader.autofillButtonAriaLabel = Autofill {templateName} with Box AI
|
187
187
|
# Tooltip text explaining that by clicking button user can autofill template using Box AI
|
188
|
-
metadataEditor.viewInstance.metadataInstanceHeader.autofillButtonTooltip = Autofill with Box AI
|
188
|
+
metadataEditor.viewInstance.metadataInstanceHeader.autofillButtonTooltip = Autofill {templateName} with Box AI
|
189
189
|
# Header with Custom Metadata template name
|
190
190
|
metadataEditor.viewInstance.metadataInstanceHeader.customMetadataTitle = Custom Metadata
|
191
191
|
# Aria label for the edit button
|
@@ -1 +1 @@
|
|
1
|
-
[{"id":"metadataEditor.viewInstance.metadataInstanceHeader.customMetadataTitle","description":"Header with Custom Metadata template name","defaultMessage":"Custom Metadata"},{"id":"metadataEditor.viewInstance.metadataInstanceHeader.autofillButtonTooltip","description":"Tooltip text explaining that by clicking button user can autofill template using Box AI","defaultMessage":"Autofill with Box AI"},{"id":"metadataEditor.viewInstance.metadataInstanceHeader.autofillButtonAriaLabel","description":"Aria label for the autofill button","defaultMessage":"Autofill with Box AI"},{"id":"metadataEditor.viewInstance.metadataInstanceHeader.editButtonTooltip","description":"Tooltip text explaining that by clicking button user can edit template","defaultMessage":"Edit"},{"id":"metadataEditor.viewInstance.metadataInstanceHeader.editButtonAriaLabel","description":"Aria label for the edit button","defaultMessage":"Edit {templateName}"}]
|
1
|
+
[{"id":"metadataEditor.viewInstance.metadataInstanceHeader.customMetadataTitle","description":"Header with Custom Metadata template name","defaultMessage":"Custom Metadata"},{"id":"metadataEditor.viewInstance.metadataInstanceHeader.autofillButtonTooltip","description":"Tooltip text explaining that by clicking button user can autofill template using Box AI","defaultMessage":"Autofill {templateName} with Box AI"},{"id":"metadataEditor.viewInstance.metadataInstanceHeader.autofillButtonAriaLabel","description":"Aria label for the autofill button","defaultMessage":"Autofill {templateName} with Box AI"},{"id":"metadataEditor.viewInstance.metadataInstanceHeader.editButtonTooltip","description":"Tooltip text explaining that by clicking button user can edit template","defaultMessage":"Edit"},{"id":"metadataEditor.viewInstance.metadataInstanceHeader.editButtonAriaLabel","description":"Aria label for the edit button","defaultMessage":"Edit {templateName}"}]
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@box/metadata-editor",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.61.0",
|
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": "93e3d2d7d217f2c872083186f18113abeabcf30e"
|
57
57
|
}
|
package/types/index.d.ts
CHANGED
package/types/lib/components/metadata-instance-list/subcomponents/metadata-instance/types.d.ts
CHANGED
@@ -2,6 +2,6 @@ import { type MetadataTemplateInstance } from '../../../../types';
|
|
2
2
|
export type MetadataInstanceProps = {
|
3
3
|
isAiSuggestionsFeatureEnabled: boolean;
|
4
4
|
onEdit: (templateInstance: MetadataTemplateInstance) => void;
|
5
|
-
onEditWithAutofill: () => void;
|
5
|
+
onEditWithAutofill: (templateInstance: MetadataTemplateInstance) => void;
|
6
6
|
templateInstance: MetadataTemplateInstance;
|
7
7
|
};
|
@@ -2,6 +2,6 @@ import { type MetadataTemplateInstance } from '../../types';
|
|
2
2
|
export type MetadataInstanceListProps = {
|
3
3
|
isAiSuggestionsFeatureEnabled: boolean;
|
4
4
|
onEdit: (templateInstacne: MetadataTemplateInstance) => void;
|
5
|
-
onEditWithAutofill: () => void;
|
5
|
+
onEditWithAutofill: (templateInstance: MetadataTemplateInstance) => void;
|
6
6
|
templateInstances: MetadataTemplateInstance[];
|
7
7
|
};
|
@@ -0,0 +1,2 @@
|
|
1
|
+
import { type AutofillContextProviderProps } from './autofill-context';
|
2
|
+
export declare function withApiWrapper<P extends object>(WrappedComponent: React.ComponentType<P>): ({ isAiSuggestionsFeatureEnabled, fetchSuggestions, ...props }: P & Omit<AutofillContextProviderProps, 'children'>) => import("react/jsx-runtime").JSX.Element;
|
@@ -6,9 +6,11 @@ export interface AutofillContextType {
|
|
6
6
|
isAiSuggestionsFeatureEnabled: boolean;
|
7
7
|
suggestions: AutofillSuggestions;
|
8
8
|
}
|
9
|
-
export
|
10
|
-
export declare const AutofillContextProvider: ({ children, isAiSuggestionsFeatureEnabled, }: {
|
9
|
+
export interface AutofillContextProviderProps {
|
11
10
|
children: React.ReactNode;
|
12
11
|
isAiSuggestionsFeatureEnabled: boolean;
|
13
|
-
|
12
|
+
fetchSuggestions: (templateKey: string, fields: MetadataTemplateField[]) => Promise<MetadataTemplateField[]>;
|
13
|
+
}
|
14
|
+
export declare const AutofillContext: React.Context<AutofillContextType>;
|
15
|
+
export declare const AutofillContextProvider: ({ children, isAiSuggestionsFeatureEnabled, fetchSuggestions, }: AutofillContextProviderProps) => React.ReactElement;
|
14
16
|
export declare const useAutofill: () => AutofillContextType;
|