@box/metadata-editor 0.60.2 → 0.60.4
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/delete-confirmation-modal/delete-confirmation-modal.js +28 -27
- package/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/utils.js +11 -11
- package/esm/lib/components/unsaved-changes-modal/unsaved-changes-modal.js +20 -19
- package/package.json +2 -2
@@ -1,45 +1,46 @@
|
|
1
1
|
import "../../../../../../styles/delete-confirmation-modal.css";
|
2
2
|
import { Modal as a, Text as c, TextInput as b } from "@box/blueprint-web";
|
3
|
-
import {
|
4
|
-
import {
|
3
|
+
import { useState as f, useEffect as F } from "react";
|
4
|
+
import { useIntl as I, FormattedMessage as s } from "react-intl";
|
5
5
|
import o from "./messages.js";
|
6
|
-
import { jsx as e, jsxs as
|
7
|
-
const
|
8
|
-
modalBody:
|
6
|
+
import { jsx as e, jsxs as d } from "react/jsx-runtime";
|
7
|
+
const P = "_modalBody_yiat3_1", x = {
|
8
|
+
modalBody: P
|
9
9
|
}, T = ({
|
10
10
|
onConfirm: u,
|
11
|
-
templateName:
|
12
|
-
onDismiss:
|
11
|
+
templateName: p,
|
12
|
+
onDismiss: C,
|
13
13
|
open: h
|
14
14
|
}) => {
|
15
|
-
const
|
16
|
-
|
17
|
-
}, l =
|
18
|
-
m(
|
19
|
-
},
|
15
|
+
const n = I(), [r, m] = f(""), [M, g] = f(!0), i = (t) => {
|
16
|
+
t || (C(), m(""));
|
17
|
+
}, l = p || n.formatMessage(o.deleteConfirmationModalCustomMetadata), y = (t) => {
|
18
|
+
m(t);
|
19
|
+
}, B = () => {
|
20
20
|
u(), i(!1);
|
21
21
|
};
|
22
|
-
return
|
22
|
+
return F(() => {
|
23
23
|
g(r !== l);
|
24
24
|
}, [r, l]), /* @__PURE__ */ e(a, {
|
25
25
|
onOpenChange: i,
|
26
26
|
open: h,
|
27
|
-
children: /* @__PURE__ */
|
27
|
+
children: /* @__PURE__ */ d(a.Content, {
|
28
|
+
onEscapeKeyDown: (t) => t.stopPropagation(),
|
28
29
|
size: "small",
|
29
30
|
children: [/* @__PURE__ */ e(a.Header, {
|
30
|
-
"aria-label":
|
31
|
-
children: /* @__PURE__ */ e(
|
31
|
+
"aria-label": n.formatMessage(o.deleteConfirmationModalHeaderAriaLabel),
|
32
|
+
children: /* @__PURE__ */ e(s, {
|
32
33
|
...o.deleteConfirmationModalHeader,
|
33
34
|
values: {
|
34
35
|
templateName: l
|
35
36
|
}
|
36
37
|
})
|
37
38
|
}), /* @__PURE__ */ e(a.ScrollableContainer, {
|
38
|
-
children: /* @__PURE__ */
|
39
|
-
className:
|
39
|
+
children: /* @__PURE__ */ d(a.Body, {
|
40
|
+
className: x.modalBody,
|
40
41
|
children: [/* @__PURE__ */ e(c, {
|
41
42
|
as: "p",
|
42
|
-
children: /* @__PURE__ */ e(
|
43
|
+
children: /* @__PURE__ */ e(s, {
|
43
44
|
...o.deleteConfirmationModalBodyFirstParagraph,
|
44
45
|
values: {
|
45
46
|
templateName: l
|
@@ -47,30 +48,30 @@ const x = "_modalBody_yiat3_1", P = {
|
|
47
48
|
})
|
48
49
|
}), /* @__PURE__ */ e(c, {
|
49
50
|
as: "p",
|
50
|
-
children: /* @__PURE__ */ e(
|
51
|
+
children: /* @__PURE__ */ e(s, {
|
51
52
|
...o.deleteConfirmationModalBodySecondParagraph
|
52
53
|
})
|
53
54
|
}), /* @__PURE__ */ e(b, {
|
54
|
-
label:
|
55
|
-
onChange: (
|
55
|
+
label: n.formatMessage(o.deleteConfirmationModalBodyInputFieldLabel),
|
56
|
+
onChange: (t) => y(t.target.value),
|
56
57
|
placeholder: l,
|
57
58
|
required: !0,
|
58
59
|
value: r
|
59
60
|
})]
|
60
61
|
})
|
61
|
-
}), /* @__PURE__ */
|
62
|
+
}), /* @__PURE__ */ d(a.Footer, {
|
62
63
|
children: [/* @__PURE__ */ e(a.Footer.SecondaryButton, {
|
63
64
|
onClick: () => i(!1),
|
64
65
|
size: "large",
|
65
|
-
children:
|
66
|
+
children: n.formatMessage(o.deleteConfirmationModalCancelButton)
|
66
67
|
}), /* @__PURE__ */ e(a.Footer.PrimaryButton, {
|
67
68
|
disabled: M,
|
68
|
-
onClick:
|
69
|
+
onClick: B,
|
69
70
|
size: "large",
|
70
|
-
children:
|
71
|
+
children: n.formatMessage(o.deleteConfirmationModalConfirmButton)
|
71
72
|
})]
|
72
73
|
}), /* @__PURE__ */ e(a.Close, {
|
73
|
-
"aria-label":
|
74
|
+
"aria-label": n.formatMessage(o.deleteConfirmationModalDismissButton)
|
74
75
|
})]
|
75
76
|
})
|
76
77
|
});
|
package/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/utils.js
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import
|
1
|
+
import h from "lodash/isEmpty";
|
2
2
|
import O from "lodash/isArray";
|
3
3
|
import { TEMPLATE_CUSTOM_PROPERTIES as f } from "../../../../constants.js";
|
4
4
|
const n = {
|
@@ -6,19 +6,19 @@ const n = {
|
|
6
6
|
REMOVE: "remove",
|
7
7
|
REPLACE: "replace",
|
8
8
|
TEST: "test"
|
9
|
-
},
|
10
|
-
const
|
9
|
+
}, p = (e) => e.value === void 0 || e.value === null || e.value === "" || O(e.value) && h(e.value), S = (e, s) => {
|
10
|
+
const o = [], c = e.metadata.fields, r = s.templateKey === f, v = new Map(s.fields.map((t) => [t.key, t])), m = new Map(c.map((t) => [t.key, t]));
|
11
11
|
return c.forEach((t) => {
|
12
|
-
const a =
|
13
|
-
a ? JSON.stringify(t) === JSON.stringify(a) || (!r &&
|
12
|
+
const a = v.get(t.key);
|
13
|
+
a ? JSON.stringify(t) === JSON.stringify(a) || (!r && p(a) && !p(t) ? o.push(y(t.key, u(t))) : (
|
14
14
|
// template instance
|
15
|
-
(!r && t.value !== a.value && a.value !== null && !
|
16
|
-
r && t.value !== a.value) && (
|
17
|
-
)) :
|
15
|
+
(!r && t.value !== a.value && a.value !== null && !p(t) || // custom instance
|
16
|
+
r && t.value !== a.value) && (o.push(E(a.key, u(a))), o.push(M(t.key, u(t))))
|
17
|
+
)) : o.push(y(t.key, t.value));
|
18
18
|
}), s.fields.forEach((t) => {
|
19
|
-
const a =
|
20
|
-
(!a || !r &&
|
21
|
-
}),
|
19
|
+
const a = m.get(t.key);
|
20
|
+
(!a || !r && p(a) && !p(t)) && (o.push(E(t.key, u(t))), o.push(k(t.key)));
|
21
|
+
}), o;
|
22
22
|
}, u = (e) => e.type === "float" ? Number(e.value) : e.value, E = (e, s) => ({
|
23
23
|
op: n.TEST,
|
24
24
|
path: `/${e}`,
|
@@ -1,28 +1,29 @@
|
|
1
1
|
import { Modal as e } from "@box/blueprint-web";
|
2
|
-
import { useState as M, useEffect as
|
3
|
-
import { useIntl as
|
2
|
+
import { useState as M, useEffect as p, useCallback as d } from "react";
|
3
|
+
import { useIntl as v, FormattedMessage as h } from "react-intl";
|
4
4
|
import n from "./messages.js";
|
5
5
|
import { jsx as a, jsxs as C } from "react/jsx-runtime";
|
6
6
|
function x({
|
7
|
-
onBackToEdit:
|
8
|
-
onDiscardChanges:
|
9
|
-
defaultOpen:
|
10
|
-
open:
|
7
|
+
onBackToEdit: i,
|
8
|
+
onDiscardChanges: c,
|
9
|
+
defaultOpen: g = !0,
|
10
|
+
open: r = g
|
11
11
|
}) {
|
12
|
-
const
|
13
|
-
|
14
|
-
const
|
15
|
-
d(), o(!1);
|
16
|
-
}, [d]), u = t(() => {
|
12
|
+
const t = v(), [m, o] = M(r);
|
13
|
+
p(() => o(r), [r]);
|
14
|
+
const l = d(() => {
|
17
15
|
i(), o(!1);
|
18
|
-
}, [i]),
|
19
|
-
|
20
|
-
}, [
|
16
|
+
}, [i]), u = d(() => {
|
17
|
+
c(), o(!1);
|
18
|
+
}, [c]), f = d((s) => {
|
19
|
+
o(s), s || l();
|
20
|
+
}, [l]);
|
21
21
|
return /* @__PURE__ */ a(e, {
|
22
22
|
modal: !0,
|
23
23
|
onOpenChange: f,
|
24
|
-
open:
|
24
|
+
open: m,
|
25
25
|
children: /* @__PURE__ */ C(e.Content, {
|
26
|
+
onEscapeKeyDown: (s) => s.stopPropagation(),
|
26
27
|
size: "small",
|
27
28
|
children: [/* @__PURE__ */ a(e.Header, {
|
28
29
|
children: /* @__PURE__ */ a(h, {
|
@@ -38,14 +39,14 @@ function x({
|
|
38
39
|
children: [/* @__PURE__ */ a(e.Footer.SecondaryButton, {
|
39
40
|
onClick: u,
|
40
41
|
size: "large",
|
41
|
-
children:
|
42
|
+
children: t.formatMessage(n.unsavedChangesModalDiscardChangesCTA)
|
42
43
|
}), /* @__PURE__ */ a(e.Footer.PrimaryButton, {
|
43
|
-
onClick:
|
44
|
+
onClick: l,
|
44
45
|
size: "large",
|
45
|
-
children:
|
46
|
+
children: t.formatMessage(n.unsavedChangesModalContinueEditingCTA)
|
46
47
|
})]
|
47
48
|
}), /* @__PURE__ */ a(e.Close, {
|
48
|
-
"aria-label":
|
49
|
+
"aria-label": t.formatMessage(n.unsavedChangesModalCloseLabel)
|
49
50
|
})]
|
50
51
|
})
|
51
52
|
});
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@box/metadata-editor",
|
3
|
-
"version": "0.60.
|
3
|
+
"version": "0.60.4",
|
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": "cc88fe6001296a03f1dfce7edec7b6cd1b0ed9f0"
|
57
57
|
}
|