@box/metadata-editor 0.56.1 → 0.57.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/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form.js +51 -49
- package/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-header/metadata-instance-form-header.js +28 -27
- package/package.json +2 -2
- package/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/types.d.ts +1 -0
- package/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-header/metadata-instance-form-header.d.ts +1 -1
- package/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-header/types.d.ts +1 -0
@@ -1,56 +1,57 @@
|
|
1
1
|
import "../../../../../../styles/metadata-instance-form.css";
|
2
2
|
import { Card as N } from "@box/blueprint-web";
|
3
|
-
import { Formik as T, Form as
|
4
|
-
import { useState as d, useRef as
|
5
|
-
import { TEMPLATE_CUSTOM_PROPERTIES as
|
6
|
-
import { useAutofill as
|
7
|
-
import { TemplateInstance as
|
8
|
-
import { MetadataEmptyState as
|
9
|
-
import { UnsavedChangesModal as
|
10
|
-
import { CustomInstance as
|
11
|
-
import { DeleteConfirmationModal as
|
12
|
-
import { MetadataInstanceFormFooter as
|
13
|
-
import { MetadataInstanceFormHeader as
|
14
|
-
import { createJSONPatch as
|
3
|
+
import { Formik as T, Form as P } from "formik";
|
4
|
+
import { useState as d, useRef as U, useEffect as _, useMemo as x } from "react";
|
5
|
+
import { TEMPLATE_CUSTOM_PROPERTIES as L } from "../../../../constants.js";
|
6
|
+
import { useAutofill as R } from "../../../../utils/autofill-context.js";
|
7
|
+
import { TemplateInstance as j } from "../../../metadata-editor-fields/metadata-editor-fields.js";
|
8
|
+
import { MetadataEmptyState as B } from "../../../metadata-empty-state/metadata-empty-state.js";
|
9
|
+
import { UnsavedChangesModal as k } from "../../../unsaved-changes-modal/unsaved-changes-modal.js";
|
10
|
+
import { CustomInstance as w } from "../custom-instance/custom-instance.js";
|
11
|
+
import { DeleteConfirmationModal as H } from "../delete-confirmation-modal/delete-confirmation-modal.js";
|
12
|
+
import { MetadataInstanceFormFooter as J } from "../metadata-instance-form-footer/metadata-instance-form-footer.js";
|
13
|
+
import { MetadataInstanceFormHeader as K } from "../metadata-instance-form-header/metadata-instance-form-header.js";
|
14
|
+
import { createJSONPatch as V } from "./utils.js";
|
15
15
|
import { jsx as n, jsxs as f } from "react/jsx-runtime";
|
16
|
-
const
|
17
|
-
metadataInstanceForm:
|
18
|
-
},
|
16
|
+
const q = "_metadataInstanceForm_1hu4u_1", z = {
|
17
|
+
metadataInstanceForm: q
|
18
|
+
}, re = (u) => {
|
19
19
|
const {
|
20
|
+
areAiSuggestionsAvailable: p,
|
20
21
|
isAiSuggestionsFeatureEnabled: o,
|
21
|
-
isDeleteButtonDisabled:
|
22
|
-
isUnsavedChangesModalOpen:
|
23
|
-
onCancel:
|
24
|
-
onDelete:
|
25
|
-
onSubmit:
|
22
|
+
isDeleteButtonDisabled: g,
|
23
|
+
isUnsavedChangesModalOpen: C = !1,
|
24
|
+
onCancel: h,
|
25
|
+
onDelete: F,
|
26
|
+
onSubmit: M,
|
26
27
|
selectedTemplateInstance: e,
|
27
28
|
setIsUnsavedChangesModalOpen: s,
|
28
|
-
onUnsavedChangesModalCancel:
|
29
|
-
} = u, [
|
29
|
+
onUnsavedChangesModalCancel: S
|
30
|
+
} = u, [I, m] = d(!1), {
|
30
31
|
isFetchingSuggestions: a,
|
31
|
-
getAiSuggestions:
|
32
|
-
} =
|
33
|
-
await
|
34
|
-
},
|
35
|
-
t ? s(!0) :
|
32
|
+
getAiSuggestions: E
|
33
|
+
} = R(), i = e.templateKey === L, r = async (t) => {
|
34
|
+
await M(t, V(t, e)), s(!1);
|
35
|
+
}, A = (t) => {
|
36
|
+
t ? s(!0) : h();
|
36
37
|
}, D = () => {
|
37
38
|
m(!0);
|
38
39
|
}, b = {
|
39
40
|
metadata: {
|
40
41
|
...e
|
41
42
|
}
|
42
|
-
}, l =
|
43
|
-
|
44
|
-
|
43
|
+
}, l = U(null), [c, y] = d(null);
|
44
|
+
_(() => {
|
45
|
+
y(l.current);
|
45
46
|
}, []);
|
46
|
-
const
|
47
|
+
const O = x(() => {
|
47
48
|
const t = e.fields.length === 0;
|
48
|
-
return i ? /* @__PURE__ */ n(
|
49
|
+
return i ? /* @__PURE__ */ n(w, {
|
49
50
|
isLoading: a
|
50
|
-
}) : t ? /* @__PURE__ */ n(
|
51
|
+
}) : t ? /* @__PURE__ */ n(B, {
|
51
52
|
isBoxAiSuggestionsFeatureEnabled: o,
|
52
53
|
level: "instance"
|
53
|
-
}) : /* @__PURE__ */ n(
|
54
|
+
}) : /* @__PURE__ */ n(j, {
|
54
55
|
disableForm: a,
|
55
56
|
portalElement: c
|
56
57
|
});
|
@@ -60,36 +61,37 @@ const V = "_metadataInstanceForm_1hu4u_1", q = {
|
|
60
61
|
onSubmit: r,
|
61
62
|
children: ({
|
62
63
|
values: t,
|
63
|
-
dirty:
|
64
|
-
}) => /* @__PURE__ */ f(
|
64
|
+
dirty: v
|
65
|
+
}) => /* @__PURE__ */ f(P, {
|
65
66
|
children: [/* @__PURE__ */ f(N, {
|
66
67
|
ref: l,
|
67
|
-
className:
|
68
|
-
children: [/* @__PURE__ */ n(
|
68
|
+
className: z.metadataInstanceForm,
|
69
|
+
children: [/* @__PURE__ */ n(K, {
|
70
|
+
areAiSuggestionsAvailable: p,
|
69
71
|
isAiSuggestionsFeatureEnabled: o && !i,
|
70
72
|
isLoading: a,
|
71
|
-
onAutofill:
|
73
|
+
onAutofill: E,
|
72
74
|
templateName: e.displayName
|
73
|
-
}),
|
74
|
-
isDeleteButtonDisabled:
|
75
|
+
}), O, /* @__PURE__ */ n(J, {
|
76
|
+
isDeleteButtonDisabled: g,
|
75
77
|
isLoading: a,
|
76
|
-
onCancel: () =>
|
78
|
+
onCancel: () => A(v),
|
77
79
|
onDelete: D
|
78
80
|
})]
|
79
|
-
}), /* @__PURE__ */ n(
|
80
|
-
onCancel:
|
81
|
+
}), /* @__PURE__ */ n(k, {
|
82
|
+
onCancel: S,
|
81
83
|
onDismiss: () => s(!1),
|
82
84
|
onSaveAndContinue: () => r(t),
|
83
|
-
open:
|
84
|
-
}), /* @__PURE__ */ n(
|
85
|
-
onConfirm: () =>
|
85
|
+
open: C
|
86
|
+
}), /* @__PURE__ */ n(H, {
|
87
|
+
onConfirm: () => F(e),
|
86
88
|
onDismiss: () => m(!1),
|
87
|
-
open:
|
89
|
+
open: I,
|
88
90
|
templateName: e.displayName
|
89
91
|
})]
|
90
92
|
})
|
91
93
|
});
|
92
94
|
};
|
93
95
|
export {
|
94
|
-
|
96
|
+
re as MetadataInstanceForm
|
95
97
|
};
|
@@ -1,42 +1,43 @@
|
|
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 F, Tooltip as x, Button as B } from "@box/blueprint-web";
|
3
|
+
import { BoxAiLogo as M } from "@box/blueprint-web-assets/icons/Logo";
|
4
|
+
import { useFormikContext as _, getIn as n } from "formik";
|
5
|
+
import { useIntl as y } from "react-intl";
|
6
6
|
import e from "./messages.js";
|
7
|
-
import { jsxs as
|
8
|
-
const
|
9
|
-
metadataInstanceFormHeader:
|
10
|
-
title:
|
11
|
-
},
|
12
|
-
|
7
|
+
import { jsxs as H, jsx as a } from "react/jsx-runtime";
|
8
|
+
const v = "_metadataInstanceFormHeader_1b2cc_1", A = "_title_1b2cc_8", i = {
|
9
|
+
metadataInstanceFormHeader: v,
|
10
|
+
title: A
|
11
|
+
}, S = ({
|
12
|
+
areAiSuggestionsAvailable: l,
|
13
|
+
isAiSuggestionsFeatureEnabled: r,
|
13
14
|
isLoading: o,
|
14
|
-
templateName:
|
15
|
-
onAutofill:
|
15
|
+
templateName: m,
|
16
|
+
onAutofill: c
|
16
17
|
}) => {
|
17
18
|
const {
|
18
|
-
isSubmitting:
|
19
|
+
isSubmitting: d,
|
19
20
|
values: s,
|
20
|
-
setFieldValue:
|
21
|
-
} =
|
22
|
-
const
|
23
|
-
|
24
|
-
},
|
25
|
-
return /* @__PURE__ */
|
21
|
+
setFieldValue: f
|
22
|
+
} = _(), t = y(), u = async () => {
|
23
|
+
const I = n(s, "metadata.fields"), b = n(s, "metadata.templateKey"), h = await c(b, I);
|
24
|
+
f("metadata.fields", h);
|
25
|
+
}, g = m ?? t.formatMessage(e.customInstanceTitle), p = !l || d || o;
|
26
|
+
return /* @__PURE__ */ H("div", {
|
26
27
|
className: i.metadataInstanceFormHeader,
|
27
|
-
children: [/* @__PURE__ */ a(
|
28
|
+
children: [/* @__PURE__ */ a(F, {
|
28
29
|
as: "h1",
|
29
30
|
className: i.title,
|
30
31
|
variant: "titleMedium",
|
31
|
-
children:
|
32
|
-
}),
|
32
|
+
children: g
|
33
|
+
}), r && /* @__PURE__ */ a(x, {
|
33
34
|
content: t.formatMessage(e.autofillButtonTooltip),
|
34
|
-
children: /* @__PURE__ */ a(
|
35
|
-
disabled:
|
36
|
-
icon:
|
35
|
+
children: /* @__PURE__ */ a(B, {
|
36
|
+
disabled: p,
|
37
|
+
icon: M,
|
37
38
|
loading: o,
|
38
39
|
loadingAriaLabel: t.formatMessage(e.loadingButtonAriaLabel),
|
39
|
-
onClick:
|
40
|
+
onClick: u,
|
40
41
|
variant: "secondary",
|
41
42
|
children: t.formatMessage(e.autofillButton)
|
42
43
|
})
|
@@ -44,5 +45,5 @@ const H = "_metadataInstanceFormHeader_1b2cc_1", v = "_title_1b2cc_8", i = {
|
|
44
45
|
});
|
45
46
|
};
|
46
47
|
export {
|
47
|
-
|
48
|
+
S as MetadataInstanceFormHeader
|
48
49
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@box/metadata-editor",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.57.0",
|
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": "070e08d367f07146160cb5db9832001c9625d59e"
|
56
56
|
}
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import { type MetadataFormFieldValue, type MetadataTemplateInstance } from '../../../../types';
|
2
2
|
import { type FormValues } from '../../types';
|
3
3
|
export type MetadataInstanceFormProps = {
|
4
|
+
areAiSuggestionsAvailable: boolean;
|
4
5
|
isAiSuggestionsFeatureEnabled: boolean;
|
5
6
|
isDeleteButtonDisabled: boolean;
|
6
7
|
isUnsavedChangesModalOpen: boolean;
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { type MetadataInstanceFormHeaderProps } from './types';
|
2
|
-
export declare const MetadataInstanceFormHeader: ({ isAiSuggestionsFeatureEnabled, isLoading, templateName, onAutofill, }: MetadataInstanceFormHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
2
|
+
export declare const MetadataInstanceFormHeader: ({ areAiSuggestionsAvailable, isAiSuggestionsFeatureEnabled, isLoading, templateName, onAutofill, }: MetadataInstanceFormHeaderProps) => import("react/jsx-runtime").JSX.Element;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import { type MetadataTemplateField, type MetadataTemplateInstance } from '../../../../types';
|
2
2
|
export type MetadataInstanceFormHeaderProps = {
|
3
|
+
areAiSuggestionsAvailable: boolean;
|
3
4
|
isAiSuggestionsFeatureEnabled: boolean;
|
4
5
|
isLoading: boolean;
|
5
6
|
onAutofill?: (templateKey: MetadataTemplateInstance['templateKey'], fields: MetadataTemplateField[]) => Promise<MetadataTemplateField[]>;
|