@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.
@@ -1,21 +1,21 @@
1
1
  import "../../../../../../styles/metadata-instance-form.css";
2
- import { Card as E } from "@box/blueprint-web";
3
- import { Formik as b } from "formik";
4
- import { useState as O, useMemo as y } from "react";
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 v } from "../../../metadata-empty-state/metadata-empty-state.js";
9
- import { UnsavedChangesModal as L } from "../../../unsaved-changes-modal/unsaved-changes-modal.js";
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 U } from "../metadata-instance-form-header/metadata-instance-form-header.js";
14
- import { createJSONPatch as j } from "./utils.js";
15
- import { jsx as t, jsxs as l, Fragment as R } from "react/jsx-runtime";
16
- const k = "_metadataInstanceForm_1hu4u_1", B = {
17
- metadataInstanceForm: k
18
- }, te = (d) => {
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
- } = d, [C, m] = O(!1), {
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, j(a, e)), s(!1);
32
- }, h = (a) => {
32
+ g(e.id, R(a, e)), s(!1);
33
+ }, M = (a) => {
33
34
  a ? s(!0) : f();
34
- }, M = () => {
35
+ }, I = () => {
35
36
  m(!0);
36
- }, I = {
37
+ }, S = {
37
38
  metadata: {
38
39
  ...e
39
40
  }
40
- }, S = y(() => {
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(v, {
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(b, {
52
- initialValues: I,
52
+ return /* @__PURE__ */ t(O, {
53
+ initialValues: S,
53
54
  onSubmit: r,
54
55
  children: ({
55
56
  values: a,
56
- dirty: D
57
- }) => /* @__PURE__ */ l(R, {
58
- children: [/* @__PURE__ */ l(E, {
59
- className: B.metadataInstanceForm,
60
- children: [/* @__PURE__ */ t(U, {
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
- }), S, /* @__PURE__ */ t(P, {
65
+ }), D, /* @__PURE__ */ t(P, {
65
66
  isLoading: n,
66
- onCancel: () => h(D),
67
- onDelete: M
67
+ onCancel: () => M(E),
68
+ onDelete: I
68
69
  })]
69
- }), /* @__PURE__ */ t(L, {
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: C,
78
+ open: h,
77
79
  templateName: e.displayName
78
80
  })]
79
81
  })
80
82
  });
81
83
  };
82
84
  export {
83
- te as MetadataInstanceForm
85
+ ae as MetadataInstanceForm
84
86
  };
@@ -1,55 +1,56 @@
1
1
  import { Modal as e } from "@box/blueprint-web";
2
- import { useState as y, useEffect as b, useCallback as c } from "react";
3
- import { useIntl as p, FormattedMessage as g } from "react-intl";
4
- import r from "./messages.js";
5
- import { jsx as a, jsxs as s } from "react/jsx-runtime";
6
- function x({
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: l,
9
- defaultOpen: f = !0,
10
- open: d = f
8
+ onDismiss: r,
9
+ onCancel: d,
10
+ defaultOpen: u = !0,
11
+ open: h = u
11
12
  }) {
12
- const n = p(), [C, o] = y(d);
13
- b(() => o(d), [d]);
14
- const u = c((h) => {
15
- o(h), h || l == null || l();
16
- }, [l]), M = c(async () => {
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]), m = c(() => {
19
- l == null || l(), o(!1);
20
- }, [l]);
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: u,
24
- open: C,
25
- children: /* @__PURE__ */ s(e.Content, {
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(g, {
29
- ...r.unsavedChangesModalHeader
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(g, {
34
- ...r.unsavedChangesModalBody
34
+ children: /* @__PURE__ */ a(f, {
35
+ ...l.unsavedChangesModalBody
35
36
  })
36
37
  })
37
- }), /* @__PURE__ */ s(e.Footer, {
38
+ }), /* @__PURE__ */ n(e.Footer, {
38
39
  children: [/* @__PURE__ */ a(e.Footer.SecondaryButton, {
39
- onClick: m,
40
+ onClick: y,
40
41
  size: "large",
41
- children: n.formatMessage(r.unsavedChangesModalDismissCTA)
42
+ children: c.formatMessage(l.unsavedChangesModalDismissCTA)
42
43
  }), /* @__PURE__ */ a(e.Footer.PrimaryButton, {
43
- onClick: M,
44
+ onClick: C,
44
45
  size: "large",
45
- children: n.formatMessage(r.unsavedChangesModalSaveAndContinueCTA)
46
+ children: c.formatMessage(l.unsavedChangesModalSaveAndContinueCTA)
46
47
  })]
47
48
  }), /* @__PURE__ */ a(e.Close, {
48
- "aria-label": n.formatMessage(r.unsavedChangesModalCloseLabel)
49
+ "aria-label": c.formatMessage(l.unsavedChangesModalCloseLabel)
49
50
  })]
50
51
  })
51
52
  });
52
53
  }
53
54
  export {
54
- x as UnsavedChangesModal
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.49.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": "0382194d1e9c1a1c900b1e95d631fad1461993fc"
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;