@box/metadata-editor 0.49.0 → 0.50.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/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form.js +34 -32
- package/esm/lib/components/unsaved-changes-modal/unsaved-changes-modal.js +31 -30
- package/package.json +2 -2
- package/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/types.d.ts +2 -0
- package/types/lib/components/metadata-instance-list/types.d.ts +1 -1
- package/types/lib/components/unsaved-changes-modal/types.d.ts +7 -0
- package/types/lib/components/unsaved-changes-modal/unsaved-changes-modal.d.ts +1 -1
@@ -1,21 +1,21 @@
|
|
1
1
|
import "../../../../../../styles/metadata-instance-form.css";
|
2
|
-
import { Card as
|
3
|
-
import { Formik as
|
4
|
-
import { useState as
|
2
|
+
import { Card as b } from "@box/blueprint-web";
|
3
|
+
import { Formik as O } from "formik";
|
4
|
+
import { useState as v, useMemo as y } from "react";
|
5
5
|
import { TEMPLATE_CUSTOM_PROPERTIES as A } from "../../../../constants.js";
|
6
6
|
import { useAutofill as N } from "../../../../utils/autofill-context.js";
|
7
7
|
import { TemplateInstance as T } from "../../../metadata-editor-fields/metadata-editor-fields.js";
|
8
|
-
import { MetadataEmptyState as
|
9
|
-
import { UnsavedChangesModal as
|
8
|
+
import { MetadataEmptyState as L } from "../../../metadata-empty-state/metadata-empty-state.js";
|
9
|
+
import { UnsavedChangesModal as U } from "../../../unsaved-changes-modal/unsaved-changes-modal.js";
|
10
10
|
import { CustomInstance as _ } from "../custom-instance/custom-instance.js";
|
11
11
|
import { DeleteConfirmationModal as x } from "../delete-confirmation-modal/delete-confirmation-modal.js";
|
12
12
|
import { MetadataInstanceFormFooter as P } from "../metadata-instance-form-footer/metadata-instance-form-footer.js";
|
13
|
-
import { MetadataInstanceFormHeader as
|
14
|
-
import { createJSONPatch as
|
15
|
-
import { jsx as t, jsxs as l, Fragment as
|
16
|
-
const
|
17
|
-
metadataInstanceForm:
|
18
|
-
},
|
13
|
+
import { MetadataInstanceFormHeader as j } from "../metadata-instance-form-header/metadata-instance-form-header.js";
|
14
|
+
import { createJSONPatch as R } from "./utils.js";
|
15
|
+
import { jsx as t, jsxs as l, Fragment as k } from "react/jsx-runtime";
|
16
|
+
const B = "_metadataInstanceForm_1hu4u_1", H = {
|
17
|
+
metadataInstanceForm: B
|
18
|
+
}, ae = (d) => {
|
19
19
|
const {
|
20
20
|
isAiSuggestionsFeatureEnabled: o,
|
21
21
|
isLoading: c,
|
@@ -24,61 +24,63 @@ const k = "_metadataInstanceForm_1hu4u_1", B = {
|
|
24
24
|
onDelete: u,
|
25
25
|
onSubmit: g,
|
26
26
|
selectedTemplateInstance: e,
|
27
|
-
setIsUnsavedChangesModalOpen: s
|
28
|
-
|
27
|
+
setIsUnsavedChangesModalOpen: s,
|
28
|
+
onUnsavedChangesModalCancel: C
|
29
|
+
} = d, [h, m] = v(!1), {
|
29
30
|
isFetchingSuggestions: F
|
30
31
|
} = N(), n = c || F, i = e.templateKey === A, r = (a) => {
|
31
|
-
g(e.id,
|
32
|
-
},
|
32
|
+
g(e.id, R(a, e)), s(!1);
|
33
|
+
}, M = (a) => {
|
33
34
|
a ? s(!0) : f();
|
34
|
-
},
|
35
|
+
}, I = () => {
|
35
36
|
m(!0);
|
36
|
-
},
|
37
|
+
}, S = {
|
37
38
|
metadata: {
|
38
39
|
...e
|
39
40
|
}
|
40
|
-
},
|
41
|
+
}, D = y(() => {
|
41
42
|
const a = e.fields.length === 0;
|
42
43
|
return i ? /* @__PURE__ */ t(_, {
|
43
44
|
isLoading: n
|
44
|
-
}) : a ? /* @__PURE__ */ t(
|
45
|
+
}) : a ? /* @__PURE__ */ t(L, {
|
45
46
|
isBoxAiSuggestionsFeatureEnabled: o,
|
46
47
|
level: "instance"
|
47
48
|
}) : /* @__PURE__ */ t(T, {
|
48
49
|
disableForm: n
|
49
50
|
});
|
50
51
|
}, [i, e.fields.length, n, o]);
|
51
|
-
return /* @__PURE__ */ t(
|
52
|
-
initialValues:
|
52
|
+
return /* @__PURE__ */ t(O, {
|
53
|
+
initialValues: S,
|
53
54
|
onSubmit: r,
|
54
55
|
children: ({
|
55
56
|
values: a,
|
56
|
-
dirty:
|
57
|
-
}) => /* @__PURE__ */ l(
|
58
|
-
children: [/* @__PURE__ */ l(
|
59
|
-
className:
|
60
|
-
children: [/* @__PURE__ */ t(
|
57
|
+
dirty: E
|
58
|
+
}) => /* @__PURE__ */ l(k, {
|
59
|
+
children: [/* @__PURE__ */ l(b, {
|
60
|
+
className: H.metadataInstanceForm,
|
61
|
+
children: [/* @__PURE__ */ t(j, {
|
61
62
|
isAiSuggestionsFeatureEnabled: o && !i,
|
62
63
|
isLoading: n,
|
63
64
|
templateName: e.displayName
|
64
|
-
}),
|
65
|
+
}), D, /* @__PURE__ */ t(P, {
|
65
66
|
isLoading: n,
|
66
|
-
onCancel: () =>
|
67
|
-
onDelete:
|
67
|
+
onCancel: () => M(E),
|
68
|
+
onDelete: I
|
68
69
|
})]
|
69
|
-
}), /* @__PURE__ */ t(
|
70
|
+
}), /* @__PURE__ */ t(U, {
|
71
|
+
onCancel: C,
|
70
72
|
onDismiss: () => s(!1),
|
71
73
|
onSaveAndContinue: () => r(a),
|
72
74
|
open: p
|
73
75
|
}), /* @__PURE__ */ t(x, {
|
74
76
|
onConfirm: () => u(e.id),
|
75
77
|
onDismiss: () => m(!1),
|
76
|
-
open:
|
78
|
+
open: h,
|
77
79
|
templateName: e.displayName
|
78
80
|
})]
|
79
81
|
})
|
80
82
|
});
|
81
83
|
};
|
82
84
|
export {
|
83
|
-
|
85
|
+
ae as MetadataInstanceForm
|
84
86
|
};
|
@@ -1,55 +1,56 @@
|
|
1
1
|
import { Modal as e } from "@box/blueprint-web";
|
2
|
-
import { useState as
|
3
|
-
import { useIntl as
|
4
|
-
import
|
5
|
-
import { jsx as a, jsxs as
|
6
|
-
function
|
2
|
+
import { useState as b, useEffect as p, useCallback as g } from "react";
|
3
|
+
import { useIntl as B, FormattedMessage as f } from "react-intl";
|
4
|
+
import l from "./messages.js";
|
5
|
+
import { jsx as a, jsxs as n } from "react/jsx-runtime";
|
6
|
+
function z({
|
7
7
|
onSaveAndContinue: t,
|
8
|
-
onDismiss:
|
9
|
-
|
10
|
-
|
8
|
+
onDismiss: r,
|
9
|
+
onCancel: d,
|
10
|
+
defaultOpen: u = !0,
|
11
|
+
open: h = u
|
11
12
|
}) {
|
12
|
-
const
|
13
|
-
|
14
|
-
const
|
15
|
-
o(
|
16
|
-
}, [
|
13
|
+
const c = B(), [M, o] = b(h);
|
14
|
+
p(() => o(h), [h]);
|
15
|
+
const m = g((s) => {
|
16
|
+
o(s), s || r == null || r();
|
17
|
+
}, [r]), C = g(async () => {
|
17
18
|
await (t == null ? void 0 : t()), o(!1);
|
18
|
-
}, [t]),
|
19
|
-
|
20
|
-
}, [
|
19
|
+
}, [t]), y = g(() => {
|
20
|
+
r == null || r(), d == null || d(), o(!1);
|
21
|
+
}, [r, d]);
|
21
22
|
return /* @__PURE__ */ a(e, {
|
22
23
|
modal: !0,
|
23
|
-
onOpenChange:
|
24
|
-
open:
|
25
|
-
children: /* @__PURE__ */
|
24
|
+
onOpenChange: m,
|
25
|
+
open: M,
|
26
|
+
children: /* @__PURE__ */ n(e.Content, {
|
26
27
|
size: "small",
|
27
28
|
children: [/* @__PURE__ */ a(e.Header, {
|
28
|
-
children: /* @__PURE__ */ a(
|
29
|
-
...
|
29
|
+
children: /* @__PURE__ */ a(f, {
|
30
|
+
...l.unsavedChangesModalHeader
|
30
31
|
})
|
31
32
|
}), /* @__PURE__ */ a(e.ScrollableContainer, {
|
32
33
|
children: /* @__PURE__ */ a(e.Body, {
|
33
|
-
children: /* @__PURE__ */ a(
|
34
|
-
...
|
34
|
+
children: /* @__PURE__ */ a(f, {
|
35
|
+
...l.unsavedChangesModalBody
|
35
36
|
})
|
36
37
|
})
|
37
|
-
}), /* @__PURE__ */
|
38
|
+
}), /* @__PURE__ */ n(e.Footer, {
|
38
39
|
children: [/* @__PURE__ */ a(e.Footer.SecondaryButton, {
|
39
|
-
onClick:
|
40
|
+
onClick: y,
|
40
41
|
size: "large",
|
41
|
-
children:
|
42
|
+
children: c.formatMessage(l.unsavedChangesModalDismissCTA)
|
42
43
|
}), /* @__PURE__ */ a(e.Footer.PrimaryButton, {
|
43
|
-
onClick:
|
44
|
+
onClick: C,
|
44
45
|
size: "large",
|
45
|
-
children:
|
46
|
+
children: c.formatMessage(l.unsavedChangesModalSaveAndContinueCTA)
|
46
47
|
})]
|
47
48
|
}), /* @__PURE__ */ a(e.Close, {
|
48
|
-
"aria-label":
|
49
|
+
"aria-label": c.formatMessage(l.unsavedChangesModalCloseLabel)
|
49
50
|
})]
|
50
51
|
})
|
51
52
|
});
|
52
53
|
}
|
53
54
|
export {
|
54
|
-
|
55
|
+
z as UnsavedChangesModal
|
55
56
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@box/metadata-editor",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.50.1",
|
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": "8463bedb52cb3c061d48d6608e22d9aa0a7d2bfb"
|
56
56
|
}
|
@@ -9,6 +9,8 @@ export type MetadataInstanceFormProps = {
|
|
9
9
|
onDelete: (id: string) => void;
|
10
10
|
onSubmit: (id: string, operations: JSONPatchOperations) => void;
|
11
11
|
setIsUnsavedChangesModalOpen: (isUnsavedChangesModalOpen: boolean) => void;
|
12
|
+
/** Callback invoked when clicking Cancel button on the UnsavedChangesModal - can be used to reset form values */
|
13
|
+
onUnsavedChangesModalCancel?: () => void;
|
12
14
|
};
|
13
15
|
export declare const JSONPatchOp: {
|
14
16
|
readonly ADD: "add";
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { type MetadataTemplateInstance } from '../../types';
|
2
2
|
export type MetadataInstanceListProps = {
|
3
3
|
isAiSuggestionsFeatureEnabled: boolean;
|
4
|
-
onEdit: () => void;
|
4
|
+
onEdit: (templateInstacne: MetadataTemplateInstance) => void;
|
5
5
|
onEditWithAutofill: () => void;
|
6
6
|
templateInstances: MetadataTemplateInstance[];
|
7
7
|
};
|
@@ -16,4 +16,11 @@ export interface UnsavedChangesModalProps extends Pick<ModalProps, 'open' | 'def
|
|
16
16
|
* closing the modal, as the modal will handle it.
|
17
17
|
*/
|
18
18
|
onDismiss?: () => void;
|
19
|
+
/**
|
20
|
+
* Callback to be invoked when the user clicks the "Dismiss" button.
|
21
|
+
*
|
22
|
+
* This callback is expected to perform the dismissal action and does not need to handle
|
23
|
+
* closing the modal, as the modal will handle it.
|
24
|
+
*/
|
25
|
+
onCancel?: () => void;
|
19
26
|
}
|
@@ -1,2 +1,2 @@
|
|
1
1
|
import { type UnsavedChangesModalProps } from './types';
|
2
|
-
export declare function UnsavedChangesModal({ onSaveAndContinue, onDismiss, defaultOpen, open: propsOpen, }: UnsavedChangesModalProps): import("react/jsx-runtime").JSX.Element;
|
2
|
+
export declare function UnsavedChangesModal({ onSaveAndContinue, onDismiss, onCancel, defaultOpen, open: propsOpen, }: UnsavedChangesModalProps): import("react/jsx-runtime").JSX.Element;
|