@box/metadata-editor 0.53.1 → 0.54.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 +52 -50
- package/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-footer/metadata-instance-form-footer.js +21 -20
- package/package.json +3 -3
- package/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/types.d.ts +1 -1
- package/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-footer/metadata-instance-form-footer.d.ts +1 -1
- package/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form-footer/types.d.ts +1 -0
@@ -1,93 +1,95 @@
|
|
1
1
|
import "../../../../../../styles/metadata-instance-form.css";
|
2
|
-
import { Card as
|
3
|
-
import { Formik 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
|
2
|
+
import { Card as N } from "@box/blueprint-web";
|
3
|
+
import { Formik as T, Form as v } from "formik";
|
4
|
+
import { useState as d, useRef as P, useEffect as U, useMemo as _ } from "react";
|
5
|
+
import { TEMPLATE_CUSTOM_PROPERTIES as x } from "../../../../constants.js";
|
6
|
+
import { useAutofill as L } from "../../../../utils/autofill-context.js";
|
7
|
+
import { TemplateInstance as R } from "../../../metadata-editor-fields/metadata-editor-fields.js";
|
8
|
+
import { MetadataEmptyState as j } from "../../../metadata-empty-state/metadata-empty-state.js";
|
9
|
+
import { UnsavedChangesModal as B } 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 w } from "../delete-confirmation-modal/delete-confirmation-modal.js";
|
12
|
-
import { MetadataInstanceFormFooter as
|
13
|
-
import { MetadataInstanceFormHeader as
|
14
|
-
import { createJSONPatch as
|
12
|
+
import { MetadataInstanceFormFooter as H } from "../metadata-instance-form-footer/metadata-instance-form-footer.js";
|
13
|
+
import { MetadataInstanceFormHeader as J } from "../metadata-instance-form-header/metadata-instance-form-header.js";
|
14
|
+
import { createJSONPatch as K } from "./utils.js";
|
15
15
|
import { jsx as n, jsxs as f } from "react/jsx-runtime";
|
16
|
-
const
|
17
|
-
metadataInstanceForm:
|
18
|
-
},
|
16
|
+
const V = "_metadataInstanceForm_1hu4u_1", q = {
|
17
|
+
metadataInstanceForm: V
|
18
|
+
}, me = (u) => {
|
19
19
|
const {
|
20
20
|
isAiSuggestionsFeatureEnabled: o,
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
21
|
+
isDeleteButtonDisabled: p,
|
22
|
+
isUnsavedChangesModalOpen: g = !1,
|
23
|
+
onCancel: C,
|
24
|
+
onDelete: h,
|
25
|
+
onSubmit: F,
|
25
26
|
selectedTemplateInstance: e,
|
26
27
|
setIsUnsavedChangesModalOpen: s,
|
27
|
-
onUnsavedChangesModalCancel:
|
28
|
-
} =
|
28
|
+
onUnsavedChangesModalCancel: M
|
29
|
+
} = u, [S, m] = d(!1), {
|
29
30
|
isFetchingSuggestions: a,
|
30
|
-
getAiSuggestions:
|
31
|
-
} =
|
32
|
-
await
|
33
|
-
},
|
34
|
-
t ? s(!0) :
|
35
|
-
},
|
31
|
+
getAiSuggestions: I
|
32
|
+
} = L(), i = e.templateKey === x, r = async (t) => {
|
33
|
+
await F(t, K(t, e)), s(!1);
|
34
|
+
}, E = (t) => {
|
35
|
+
t ? s(!0) : C();
|
36
|
+
}, D = () => {
|
36
37
|
m(!0);
|
37
|
-
},
|
38
|
+
}, b = {
|
38
39
|
metadata: {
|
39
40
|
...e
|
40
41
|
}
|
41
|
-
}, l =
|
42
|
-
|
43
|
-
|
42
|
+
}, l = P(null), [c, A] = d(null);
|
43
|
+
U(() => {
|
44
|
+
A(l.current);
|
44
45
|
}, []);
|
45
|
-
const
|
46
|
+
const y = _(() => {
|
46
47
|
const t = e.fields.length === 0;
|
47
48
|
return i ? /* @__PURE__ */ n(k, {
|
48
49
|
isLoading: a
|
49
|
-
}) : t ? /* @__PURE__ */ n(
|
50
|
+
}) : t ? /* @__PURE__ */ n(j, {
|
50
51
|
isBoxAiSuggestionsFeatureEnabled: o,
|
51
52
|
level: "instance"
|
52
|
-
}) : /* @__PURE__ */ n(
|
53
|
+
}) : /* @__PURE__ */ n(R, {
|
53
54
|
disableForm: a,
|
54
55
|
portalElement: c
|
55
56
|
});
|
56
57
|
}, [i, e.fields.length, a, o, c]);
|
57
|
-
return /* @__PURE__ */ n(
|
58
|
-
initialValues:
|
58
|
+
return /* @__PURE__ */ n(T, {
|
59
|
+
initialValues: b,
|
59
60
|
onSubmit: r,
|
60
61
|
children: ({
|
61
62
|
values: t,
|
62
|
-
dirty:
|
63
|
-
}) => /* @__PURE__ */ f(
|
64
|
-
children: [/* @__PURE__ */ f(
|
63
|
+
dirty: O
|
64
|
+
}) => /* @__PURE__ */ f(v, {
|
65
|
+
children: [/* @__PURE__ */ f(N, {
|
65
66
|
ref: l,
|
66
|
-
className:
|
67
|
-
children: [/* @__PURE__ */ n(
|
67
|
+
className: q.metadataInstanceForm,
|
68
|
+
children: [/* @__PURE__ */ n(J, {
|
68
69
|
isAiSuggestionsFeatureEnabled: o && !i,
|
69
70
|
isLoading: a,
|
70
|
-
onAutofill:
|
71
|
+
onAutofill: I,
|
71
72
|
templateName: e.displayName
|
72
|
-
}),
|
73
|
+
}), y, /* @__PURE__ */ n(H, {
|
74
|
+
isDeleteButtonDisabled: p,
|
73
75
|
isLoading: a,
|
74
|
-
onCancel: () =>
|
75
|
-
onDelete:
|
76
|
+
onCancel: () => E(O),
|
77
|
+
onDelete: D
|
76
78
|
})]
|
77
|
-
}), /* @__PURE__ */ n(
|
78
|
-
onCancel:
|
79
|
+
}), /* @__PURE__ */ n(B, {
|
80
|
+
onCancel: M,
|
79
81
|
onDismiss: () => s(!1),
|
80
82
|
onSaveAndContinue: () => r(t),
|
81
|
-
open:
|
83
|
+
open: g
|
82
84
|
}), /* @__PURE__ */ n(w, {
|
83
|
-
onConfirm: () =>
|
85
|
+
onConfirm: () => h(e),
|
84
86
|
onDismiss: () => m(!1),
|
85
|
-
open:
|
87
|
+
open: S,
|
86
88
|
templateName: e.displayName
|
87
89
|
})]
|
88
90
|
})
|
89
91
|
});
|
90
92
|
};
|
91
93
|
export {
|
92
|
-
|
94
|
+
me as MetadataInstanceForm
|
93
95
|
};
|
@@ -1,35 +1,36 @@
|
|
1
1
|
import "../../../../../../styles/metadata-instance-form-footer.css";
|
2
|
-
import { TextButton as
|
3
|
-
import { useFormikContext as
|
4
|
-
import { useIntl as
|
2
|
+
import { TextButton as b, Button as r } from "@box/blueprint-web";
|
3
|
+
import { useFormikContext as F } from "formik";
|
4
|
+
import { useIntl as g } from "react-intl";
|
5
5
|
import o from "./messages.js";
|
6
6
|
import { jsx as e, jsxs as i } from "react/jsx-runtime";
|
7
|
-
const
|
8
|
-
metadataInstanceFormFooter:
|
9
|
-
buttonsContainer:
|
10
|
-
buttons:
|
11
|
-
},
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
const f = "_metadataInstanceFormFooter_17478_1", _ = "_buttonsContainer_17478_8", C = "_buttons_17478_8", a = {
|
8
|
+
metadataInstanceFormFooter: f,
|
9
|
+
buttonsContainer: _,
|
10
|
+
buttons: C
|
11
|
+
}, M = ({
|
12
|
+
isDeleteButtonDisabled: m,
|
13
|
+
isLoading: c,
|
14
|
+
onCancel: l,
|
15
|
+
onDelete: d
|
15
16
|
}) => {
|
16
|
-
const t =
|
17
|
+
const t = g(), {
|
17
18
|
isSubmitting: s,
|
18
|
-
submitForm:
|
19
|
-
} =
|
19
|
+
submitForm: u
|
20
|
+
} = F(), n = c || s;
|
20
21
|
return /* @__PURE__ */ e("div", {
|
21
22
|
className: a.metadataInstanceFormFooter,
|
22
23
|
children: /* @__PURE__ */ i("div", {
|
23
24
|
className: a.buttonsContainer,
|
24
|
-
children: [/* @__PURE__ */ e(
|
25
|
-
disabled: n,
|
26
|
-
onClick:
|
25
|
+
children: [/* @__PURE__ */ e(b, {
|
26
|
+
disabled: n || m,
|
27
|
+
onClick: d,
|
27
28
|
children: t.formatMessage(o.deleteButton)
|
28
29
|
}), /* @__PURE__ */ i("div", {
|
29
30
|
className: a.buttons,
|
30
31
|
children: [/* @__PURE__ */ e(r, {
|
31
32
|
disabled: n,
|
32
|
-
onClick:
|
33
|
+
onClick: l,
|
33
34
|
size: "large",
|
34
35
|
variant: "secondary",
|
35
36
|
children: t.formatMessage(o.cancelButton)
|
@@ -37,7 +38,7 @@ const g = "_metadataInstanceFormFooter_17478_1", f = "_buttonsContainer_17478_8"
|
|
37
38
|
disabled: n,
|
38
39
|
loading: s,
|
39
40
|
loadingAriaLabel: t.formatMessage(o.loadingAriaLabel),
|
40
|
-
onClick:
|
41
|
+
onClick: u,
|
41
42
|
size: "large",
|
42
43
|
children: t.formatMessage(o.saveButton)
|
43
44
|
})]
|
@@ -46,5 +47,5 @@ const g = "_metadataInstanceFormFooter_17478_1", f = "_buttonsContainer_17478_8"
|
|
46
47
|
});
|
47
48
|
};
|
48
49
|
export {
|
49
|
-
|
50
|
+
M as MetadataInstanceFormFooter
|
50
51
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@box/metadata-editor",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.54.0",
|
4
4
|
"peerDependencies": {
|
5
5
|
"@ariakit/react": "0.4.5",
|
6
6
|
"@box/blueprint-web": "^7.20.0",
|
@@ -13,7 +13,7 @@
|
|
13
13
|
},
|
14
14
|
"devDependencies": {
|
15
15
|
"@ariakit/react": "0.4.5",
|
16
|
-
"@box/blueprint-web": "^7.30.
|
16
|
+
"@box/blueprint-web": "^7.30.1",
|
17
17
|
"@box/blueprint-web-assets": "^4.25.0",
|
18
18
|
"@box/storybook-utils": "^0.6.1",
|
19
19
|
"@testing-library/react": "^15.0.6",
|
@@ -52,5 +52,5 @@
|
|
52
52
|
"**/*.css"
|
53
53
|
],
|
54
54
|
"license": "SEE LICENSE IN LICENSE",
|
55
|
-
"gitHead": "
|
55
|
+
"gitHead": "c4e8483378415e000dd6bb2a9ca046d5176f98f0"
|
56
56
|
}
|
@@ -2,8 +2,8 @@ import { type MetadataFormFieldValue, type MetadataTemplateInstance } from '../.
|
|
2
2
|
import { type FormValues } from '../../types';
|
3
3
|
export type MetadataInstanceFormProps = {
|
4
4
|
isAiSuggestionsFeatureEnabled: boolean;
|
5
|
+
isDeleteButtonDisabled: boolean;
|
5
6
|
isUnsavedChangesModalOpen: boolean;
|
6
|
-
/** The MetadataTemplate is used when creating a new instance, while MetadataTemplateInstance is applied when editing an existing one. */
|
7
7
|
selectedTemplateInstance: MetadataTemplateInstance;
|
8
8
|
onCancel: () => void;
|
9
9
|
onDelete: (templateInstance: MetadataTemplateInstance) => void;
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { type MetadataInstanceFormFooterProps } from './types';
|
2
|
-
export declare const MetadataInstanceFormFooter: ({ isLoading, onCancel, onDelete }: MetadataInstanceFormFooterProps) => import("react/jsx-runtime").JSX.Element;
|
2
|
+
export declare const MetadataInstanceFormFooter: ({ isDeleteButtonDisabled, isLoading, onCancel, onDelete, }: MetadataInstanceFormFooterProps) => import("react/jsx-runtime").JSX.Element;
|