@box/metadata-editor 0.60.4 → 0.61.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.
- package/chunks/metadata-editor-field-wrapper.js +34 -32
- package/esm/index.js +18 -16
- package/esm/lib/components/metadata-editor-fields/components/metadata-date-field/metadata-date-field.js +33 -32
- package/esm/lib/components/metadata-editor-fields/components/metadata-enum-field/metadata-enum-field.js +27 -25
- package/esm/lib/components/metadata-editor-fields/components/metadata-float-field/metadata-float-field.js +26 -25
- package/esm/lib/components/metadata-editor-fields/components/metadata-multi-select-field/metadata-multi-select-field.js +33 -31
- package/esm/lib/components/metadata-editor-fields/components/metadata-string-field/metadata-string-field.js +32 -30
- package/esm/lib/components/metadata-editor-fields/editor-field-types.js +28 -22
- package/esm/lib/components/metadata-editor-fields/metadata-editor-fields.js +27 -22
- 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-editor-fields/components/metadata-date-field/metadata-date-field.d.ts +1 -1
- package/types/lib/components/metadata-editor-fields/components/metadata-enum-field/metadata-enum-field.d.ts +1 -1
- package/types/lib/components/metadata-editor-fields/components/metadata-float-field/metadata-float-field.d.ts +1 -1
- package/types/lib/components/metadata-editor-fields/components/metadata-multi-select-field/metadata-multi-select-field.d.ts +1 -1
- package/types/lib/components/metadata-editor-fields/components/metadata-string-field/metadata-string-field.d.ts +1 -4
- package/types/lib/components/metadata-editor-fields/editor-field-types.d.ts +5 -5
- package/types/lib/components/metadata-editor-fields/metadata-editor-field-wrapper.d.ts +4 -2
- 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/test-utils/sample-data.d.ts +2 -1
- package/types/lib/utils/api-wrapper.d.ts +2 -0
- package/types/lib/utils/autofill-context.d.ts +5 -3
@@ -1,26 +1,32 @@
|
|
1
|
-
import {
|
1
|
+
import { forwardRef as r } from "react";
|
2
|
+
import { MetadataDateField as o } from "./components/metadata-date-field/metadata-date-field.js";
|
2
3
|
import { MetadataEnumField as i } from "./components/metadata-enum-field/metadata-enum-field.js";
|
3
|
-
import { MetadataFloatField as
|
4
|
-
import { MetadataMultiSelectField as
|
5
|
-
import { MetadataStringField as
|
6
|
-
import { jsx as
|
7
|
-
const
|
8
|
-
date: (t) => /* @__PURE__ */
|
9
|
-
...t
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
}),
|
20
|
-
|
21
|
-
...t
|
22
|
-
|
4
|
+
import { MetadataFloatField as m } from "./components/metadata-float-field/metadata-float-field.js";
|
5
|
+
import { MetadataMultiSelectField as f } from "./components/metadata-multi-select-field/metadata-multi-select-field.js";
|
6
|
+
import { MetadataStringField as d } from "./components/metadata-string-field/metadata-string-field.js";
|
7
|
+
import { jsx as a } from "react/jsx-runtime";
|
8
|
+
const c = {
|
9
|
+
date: /* @__PURE__ */ r((t, e) => /* @__PURE__ */ a(o, {
|
10
|
+
...t,
|
11
|
+
ref: e
|
12
|
+
})),
|
13
|
+
enum: /* @__PURE__ */ r((t, e) => /* @__PURE__ */ a(i, {
|
14
|
+
...t,
|
15
|
+
ref: e
|
16
|
+
})),
|
17
|
+
float: /* @__PURE__ */ r((t, e) => /* @__PURE__ */ a(m, {
|
18
|
+
...t,
|
19
|
+
ref: e
|
20
|
+
})),
|
21
|
+
multiSelect: /* @__PURE__ */ r((t, e) => /* @__PURE__ */ a(f, {
|
22
|
+
...t,
|
23
|
+
ref: e
|
24
|
+
})),
|
25
|
+
string: /* @__PURE__ */ r((t, e) => /* @__PURE__ */ a(d, {
|
26
|
+
...t,
|
27
|
+
ref: e
|
28
|
+
}))
|
23
29
|
};
|
24
30
|
export {
|
25
|
-
|
31
|
+
c as editorFieldTypes
|
26
32
|
};
|
@@ -1,31 +1,36 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import {
|
7
|
-
|
1
|
+
import { useRef as f, useEffect as l } from "react";
|
2
|
+
import { Text as c } from "@box/blueprint-web";
|
3
|
+
import { useFormikContext as d, getIn as u, FieldArray as p } from "formik";
|
4
|
+
import { FormattedMessage as x } from "react-intl";
|
5
|
+
import g from "../../messages.js";
|
6
|
+
import { M as h, s as F } from "../../../../chunks/metadata-editor-field-wrapper.js";
|
7
|
+
import { jsx as t } from "react/jsx-runtime";
|
8
|
+
const k = (m) => {
|
8
9
|
const {
|
9
|
-
values:
|
10
|
-
} =
|
11
|
-
return
|
12
|
-
|
10
|
+
values: i
|
11
|
+
} = d(), o = "metadata.fields", r = u(i, o), s = f(null), a = r.findIndex((e) => !e.hidden);
|
12
|
+
return l(() => {
|
13
|
+
var e;
|
14
|
+
a > -1 && ((e = s.current) == null || e.focus());
|
15
|
+
}, []), r.length ? /* @__PURE__ */ t(p, {
|
16
|
+
name: o,
|
13
17
|
validateOnChange: !1,
|
14
|
-
children: () =>
|
15
|
-
...
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
children: () => r.map((e, n) => /* @__PURE__ */ t(h, {
|
19
|
+
...m,
|
20
|
+
ref: n === a ? s : null,
|
21
|
+
field: e,
|
22
|
+
index: n
|
23
|
+
}, e.key))
|
24
|
+
}) : /* @__PURE__ */ t(c, {
|
20
25
|
as: "span",
|
21
|
-
className:
|
26
|
+
className: F.noAttributesText,
|
22
27
|
color: "textOnLightSecondary",
|
23
|
-
children: /* @__PURE__ */
|
24
|
-
...
|
28
|
+
children: /* @__PURE__ */ t(x, {
|
29
|
+
...g.noTemplateAtributesError
|
25
30
|
})
|
26
31
|
});
|
27
32
|
};
|
28
33
|
export {
|
29
|
-
|
30
|
-
|
34
|
+
k as TemplateInstance,
|
35
|
+
k as default
|
31
36
|
};
|
@@ -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.1",
|
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": "e2f69a163f18e91fd7f4c4afc4778636657815a0"
|
57
57
|
}
|
package/types/index.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
import { type MetadataFieldProps } from '../../types';
|
2
|
-
export declare const MetadataDateField: (
|
2
|
+
export declare const MetadataDateField: import("react").ForwardRefExoticComponent<MetadataFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
3
3
|
export default MetadataDateField;
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { type MetadataFieldProps } from '../../types';
|
2
|
-
export declare const MetadataEnumField: (
|
2
|
+
export declare const MetadataEnumField: import("react").ForwardRefExoticComponent<MetadataFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
3
3
|
export default MetadataEnumField;
|
@@ -1,3 +1,3 @@
|
|
1
1
|
import { type MetadataFieldProps } from '../../types';
|
2
|
-
export declare const MetadataFloatField: (
|
2
|
+
export declare const MetadataFloatField: import("react").ForwardRefExoticComponent<MetadataFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
3
3
|
export default MetadataFloatField;
|