@box/metadata-template-editor 2.1.12 → 2.2.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/dist/chunks/dropdown-field-configuration.js +1 -1
- package/dist/chunks/metadata-field-list.js +158 -132
- package/dist/chunks/metadata-template-editor-form.js +98 -74
- package/dist/chunks/metadata-template-editor-modal.js +71 -58
- package/dist/chunks/metadata-template-editor.js +41 -40
- package/dist/chunks/types.js +1 -1
- package/dist/esm/lib/components/metadata-field-configurator/components/field-action-slot/field-action-slot.js +9 -9
- package/dist/esm/lib/components/metadata-field-configurator/components/field-edit-content/field-edit-content.js +33 -35
- package/dist/esm/lib/components/metadata-field-configurator/metadata-field-configurator.js +61 -53
- package/dist/esm/lib/messages.js +12 -0
- package/dist/styles/metadata-template-editor-form.css +1 -1
- package/dist/styles/metadata-template-editor-modal.css +1 -1
- package/dist/types/lib/components/metadata-field-configurator/components/field-action-slot/field-action-slot.d.ts +6 -1
- package/dist/types/lib/components/metadata-field-configurator/components/field-edit-content/field-edit-content.d.ts +7 -1
- package/dist/types/lib/components/metadata-field-configurator/metadata-field-configurator.d.ts +7 -1
- package/dist/types/lib/components/metadata-field-list/metadata-field-list.d.ts +6 -0
- package/dist/types/lib/components/metadata-template-editor-form/metadata-template-editor-form.d.ts +11 -2
- package/dist/types/lib/messages.d.ts +15 -0
- package/dist/types/lib/metadata-template-editor.d.ts +18 -1
- package/dist/types/lib/types.d.ts +3 -2
- package/package.json +1 -1
|
@@ -3,75 +3,88 @@ import t from "../esm/lib/messages.js";
|
|
|
3
3
|
import { t as n } from "./metadata-template-editor.js";
|
|
4
4
|
import { Modal as r } from "@box/blueprint-web";
|
|
5
5
|
import { useIntl as i } from "react-intl";
|
|
6
|
-
import {
|
|
7
|
-
import { useCallback as
|
|
8
|
-
import
|
|
9
|
-
import '../styles/metadata-template-editor-modal.css';var
|
|
10
|
-
modal: "
|
|
11
|
-
centeredBody: "
|
|
6
|
+
import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
7
|
+
import { useCallback as c, useEffect as l, useId as u, useRef as d, useState as f } from "react";
|
|
8
|
+
import p from "clsx";
|
|
9
|
+
import '../styles/metadata-template-editor-modal.css';var m = {
|
|
10
|
+
modal: "_modal_1s9i6_1",
|
|
11
|
+
centeredBody: "_centeredBody_1s9i6_7",
|
|
12
|
+
modalScrollableContainer: "_modalScrollableContainer_1s9i6_15",
|
|
13
|
+
modalBody: "_modalBody_1s9i6_21"
|
|
12
14
|
};
|
|
13
|
-
function
|
|
14
|
-
let
|
|
15
|
-
|
|
16
|
-
}, [
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}, [
|
|
20
|
-
let
|
|
21
|
-
e ?
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
|
|
15
|
+
function h({ open: h, onOpenChange: g, onTemplateLoad: _, onValidationChange: v, onCancel: y, title: b, ...x }) {
|
|
16
|
+
let S = i(), C = u(), w = d(null), [T, E] = f(!1), [D, O] = f(!1), [k, A] = f(void 0), j = x.mode === e.Edit, M = x.mode === e.ReadOnly, N = c(() => {
|
|
17
|
+
y?.(), g(!1);
|
|
18
|
+
}, [y, g]);
|
|
19
|
+
l(() => {
|
|
20
|
+
h || (O(!1), A(void 0));
|
|
21
|
+
}, [h]);
|
|
22
|
+
let P = (e) => {
|
|
23
|
+
e ? g(e) : w.current?.requestClose();
|
|
24
|
+
}, F = (e) => {
|
|
25
|
+
A(e.displayName), _?.(e);
|
|
26
|
+
}, I = (e) => async (...t) => {
|
|
27
|
+
E(!0);
|
|
26
28
|
try {
|
|
27
|
-
await e(...t),
|
|
29
|
+
await e(...t), g(!1);
|
|
28
30
|
} finally {
|
|
29
|
-
|
|
31
|
+
E(!1);
|
|
30
32
|
}
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
}, L;
|
|
34
|
+
L = j ? {
|
|
35
|
+
...x,
|
|
36
|
+
onEditTemplate: I(x.onEditTemplate)
|
|
37
|
+
} : M ? x : {
|
|
38
|
+
...x,
|
|
39
|
+
onCreateTemplate: I(x.onCreateTemplate)
|
|
40
|
+
};
|
|
41
|
+
let R = T || j && !D, z = (j || M) && !k, B;
|
|
42
|
+
B = M ? k ? S.formatMessage(t.viewTitle, { templateName: k }) : "" : j && k ? S.formatMessage(t.editTitle, { templateName: k }) : S.formatMessage(t.createTitle);
|
|
43
|
+
let V = b ?? B;
|
|
44
|
+
return /* @__PURE__ */ o(r, {
|
|
45
|
+
open: h,
|
|
46
|
+
onOpenChange: P,
|
|
47
|
+
children: /* @__PURE__ */ s(r.Content, {
|
|
42
48
|
size: "large",
|
|
43
|
-
className:
|
|
49
|
+
className: m.modal,
|
|
44
50
|
children: [
|
|
45
|
-
/* @__PURE__ */
|
|
46
|
-
/* @__PURE__ */
|
|
47
|
-
className:
|
|
48
|
-
children: /* @__PURE__ */
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
51
|
+
/* @__PURE__ */ o(r.Header, { children: V }),
|
|
52
|
+
/* @__PURE__ */ o(r.ScrollableContainer, {
|
|
53
|
+
className: p(m.modalScrollableContainer, { [m.centeredBody]: z }),
|
|
54
|
+
children: /* @__PURE__ */ o(r.Body, {
|
|
55
|
+
className: m.modalBody,
|
|
56
|
+
children: /* @__PURE__ */ o(n, {
|
|
57
|
+
...L,
|
|
58
|
+
ref: w,
|
|
59
|
+
formId: C,
|
|
60
|
+
hideActions: !0,
|
|
61
|
+
onCancel: N,
|
|
62
|
+
onDirtyStateChange: O,
|
|
63
|
+
onValidationChange: v,
|
|
64
|
+
onTemplateLoad: F
|
|
65
|
+
})
|
|
66
|
+
})
|
|
58
67
|
}),
|
|
59
|
-
/* @__PURE__ */ o(r.Footer, { children:
|
|
60
|
-
onClick:
|
|
68
|
+
/* @__PURE__ */ o(r.Footer, { children: M ? /* @__PURE__ */ o(r.Footer.PrimaryButton, {
|
|
69
|
+
onClick: N,
|
|
61
70
|
size: "large",
|
|
62
|
-
children:
|
|
63
|
-
}), /* @__PURE__ */
|
|
71
|
+
children: S.formatMessage(t.close)
|
|
72
|
+
}) : /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(r.Footer.SecondaryButton, {
|
|
73
|
+
onClick: () => w.current?.requestClose(),
|
|
74
|
+
size: "large",
|
|
75
|
+
children: S.formatMessage(t.cancel)
|
|
76
|
+
}), /* @__PURE__ */ o(r.Footer.PrimaryButton, {
|
|
64
77
|
variant: "primary",
|
|
65
78
|
type: "submit",
|
|
66
|
-
form:
|
|
67
|
-
loading:
|
|
68
|
-
loadingAriaLabel:
|
|
69
|
-
disabled:
|
|
70
|
-
children:
|
|
71
|
-
})] }),
|
|
72
|
-
/* @__PURE__ */
|
|
79
|
+
form: C,
|
|
80
|
+
loading: T,
|
|
81
|
+
loadingAriaLabel: S.formatMessage(t.submitting),
|
|
82
|
+
disabled: R,
|
|
83
|
+
children: S.formatMessage(t.save)
|
|
84
|
+
})] }) }),
|
|
85
|
+
/* @__PURE__ */ o(r.Close, { "aria-label": S.formatMessage(t.closeAriaLabel) })
|
|
73
86
|
]
|
|
74
87
|
})
|
|
75
88
|
});
|
|
76
89
|
}
|
|
77
|
-
export {
|
|
90
|
+
export { h as t };
|
|
@@ -27,15 +27,15 @@ import '../styles/metadata-template-editor.css';var C = {
|
|
|
27
27
|
templateKey: "",
|
|
28
28
|
fields: [],
|
|
29
29
|
hidden: !1
|
|
30
|
-
}, w = /*#__PURE__*/ m(function({ onCancel: m, onDirtyStateChange: w, onValidationChange: re, onSubmitError: ie, onTemplateLoad: T, taxonomyOptions:
|
|
31
|
-
let
|
|
30
|
+
}, w = /*#__PURE__*/ m(function({ onCancel: m, onDirtyStateChange: w, onValidationChange: re, onSubmitError: ie, onTemplateLoad: T, taxonomyOptions: ae, fetchTaxonomies: E, disabledFieldTypes: D, taxonomyInitialStateLabels: O, formId: k, hideActions: A = !1, fieldExtensions: j, ...M }, N) {
|
|
31
|
+
let P = i(), { formatMessage: F } = te(), { addNotification: I } = ee(), L = M.mode === e.Edit, R = M.mode === e.ReadOnly, [z, B] = y(!1), [V, H] = y(!1), U = h(() => {
|
|
32
32
|
z ? H(!0) : m?.();
|
|
33
33
|
}, [z, m]);
|
|
34
|
-
_(
|
|
34
|
+
_(N, () => ({ requestClose: U }), [U]);
|
|
35
35
|
let W = h((e) => {
|
|
36
36
|
B(e), w?.(e);
|
|
37
|
-
}, [w]), [G, K] = y(R), [q, J] = y(!1), [
|
|
38
|
-
|
|
37
|
+
}, [w]), [G, K] = y(L || R), [q, J] = y(!1), [oe, se] = y(0), [Y, X] = y(void 0), Z = L || R ? M.fetchTemplate : void 0, ce = () => {
|
|
38
|
+
se((e) => e + 1);
|
|
39
39
|
};
|
|
40
40
|
g(() => {
|
|
41
41
|
if (!Z) return;
|
|
@@ -52,10 +52,10 @@ import '../styles/metadata-template-editor.css';var C = {
|
|
|
52
52
|
})(), () => {
|
|
53
53
|
e = !0;
|
|
54
54
|
};
|
|
55
|
-
}, [Z,
|
|
55
|
+
}, [Z, oe]), g(() => {
|
|
56
56
|
Y !== void 0 && T?.(Y);
|
|
57
57
|
}, [Y, T]);
|
|
58
|
-
let Q = R ? void 0 :
|
|
58
|
+
let Q = L || R ? void 0 : M.namespace, $ = v(() => Y ? {
|
|
59
59
|
displayName: Y.displayName,
|
|
60
60
|
templateKey: Y.templateKey,
|
|
61
61
|
namespace: Y.namespace,
|
|
@@ -64,41 +64,41 @@ import '../styles/metadata-template-editor.css';var C = {
|
|
|
64
64
|
} : {
|
|
65
65
|
...ne,
|
|
66
66
|
namespace: Q ?? ""
|
|
67
|
-
}, [Y, Q]),
|
|
68
|
-
disabledFieldTypes:
|
|
69
|
-
taxonomyInitialStateLabels:
|
|
70
|
-
}), [
|
|
67
|
+
}, [Y, Q]), le = v(() => ({
|
|
68
|
+
disabledFieldTypes: D,
|
|
69
|
+
taxonomyInitialStateLabels: O
|
|
70
|
+
}), [D, O]);
|
|
71
71
|
return G ? /* @__PURE__ */ f("div", {
|
|
72
72
|
className: C.loading,
|
|
73
73
|
children: /* @__PURE__ */ f(u, {
|
|
74
74
|
size: "large",
|
|
75
|
-
"aria-label":
|
|
75
|
+
"aria-label": F(r.loading)
|
|
76
76
|
})
|
|
77
77
|
}) : q ? /* @__PURE__ */ f("div", {
|
|
78
78
|
className: C.error,
|
|
79
79
|
children: /* @__PURE__ */ f(l, {
|
|
80
80
|
body: /* @__PURE__ */ f(d, {
|
|
81
81
|
as: "p",
|
|
82
|
-
children:
|
|
82
|
+
children: F(r.fetchError)
|
|
83
83
|
}),
|
|
84
84
|
illustration: S,
|
|
85
85
|
size: "large",
|
|
86
86
|
children: /* @__PURE__ */ f(l.PrimaryAction, {
|
|
87
87
|
startIcon: b,
|
|
88
|
-
onClick:
|
|
89
|
-
children:
|
|
88
|
+
onClick: ce,
|
|
89
|
+
children: F(r.reload)
|
|
90
90
|
})
|
|
91
91
|
})
|
|
92
92
|
}) : /* @__PURE__ */ p(t.Provider, {
|
|
93
|
-
value:
|
|
93
|
+
value: le,
|
|
94
94
|
children: [/* @__PURE__ */ f(x, {
|
|
95
95
|
initialValues: $,
|
|
96
|
-
validationSchema:
|
|
96
|
+
validationSchema: R ? void 0 : P,
|
|
97
97
|
onSubmit: async (e) => {
|
|
98
|
-
try {
|
|
99
|
-
if (
|
|
98
|
+
if (!R) try {
|
|
99
|
+
if (L) {
|
|
100
100
|
let t = s($, e);
|
|
101
|
-
await
|
|
101
|
+
await M.onEditTemplate(t, {
|
|
102
102
|
namespaceFQN: $.namespace,
|
|
103
103
|
templateKey: $.templateKey
|
|
104
104
|
});
|
|
@@ -110,27 +110,27 @@ import '../styles/metadata-template-editor.css';var C = {
|
|
|
110
110
|
hidden: e.hidden,
|
|
111
111
|
fields: t
|
|
112
112
|
};
|
|
113
|
-
await
|
|
113
|
+
await M.onCreateTemplate(n);
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
I({
|
|
116
116
|
sensitivity: "foreground",
|
|
117
117
|
variant: "success",
|
|
118
|
-
styledText:
|
|
119
|
-
typeIconAriaLabel:
|
|
120
|
-
closeButtonAriaLabel:
|
|
118
|
+
styledText: F(r.saveSuccessNotification),
|
|
119
|
+
typeIconAriaLabel: F(r.notificationSuccessIconAriaLabel),
|
|
120
|
+
closeButtonAriaLabel: F(r.notificationCloseButtonAriaLabel)
|
|
121
121
|
});
|
|
122
122
|
} catch (e) {
|
|
123
123
|
let t;
|
|
124
124
|
if (e instanceof Error && "status" in e) {
|
|
125
125
|
let { status: n } = e;
|
|
126
|
-
t =
|
|
127
|
-
} else t =
|
|
128
|
-
|
|
126
|
+
t = F(n === 409 ? r.displayNameUsedBefore : r.saveErrorNotification);
|
|
127
|
+
} else t = F(r.saveErrorNotification);
|
|
128
|
+
I({
|
|
129
129
|
sensitivity: "foreground",
|
|
130
130
|
variant: "error",
|
|
131
131
|
styledText: t,
|
|
132
|
-
typeIconAriaLabel:
|
|
133
|
-
closeButtonAriaLabel:
|
|
132
|
+
typeIconAriaLabel: F(r.notificationErrorIconAriaLabel),
|
|
133
|
+
closeButtonAriaLabel: F(r.notificationCloseButtonAriaLabel)
|
|
134
134
|
});
|
|
135
135
|
try {
|
|
136
136
|
ie?.(e);
|
|
@@ -139,25 +139,26 @@ import '../styles/metadata-template-editor.css';var C = {
|
|
|
139
139
|
}
|
|
140
140
|
},
|
|
141
141
|
children: /* @__PURE__ */ f(c, {
|
|
142
|
-
formId:
|
|
142
|
+
formId: k,
|
|
143
143
|
onCancel: U,
|
|
144
|
-
taxonomyOptions:
|
|
145
|
-
fetchTaxonomies:
|
|
146
|
-
hideActions:
|
|
147
|
-
isEditMode:
|
|
144
|
+
taxonomyOptions: ae,
|
|
145
|
+
fetchTaxonomies: E,
|
|
146
|
+
hideActions: A,
|
|
147
|
+
isEditMode: L,
|
|
148
|
+
readOnly: R,
|
|
148
149
|
onDirtyStateChange: W,
|
|
149
150
|
onValidationChange: re,
|
|
150
|
-
fieldExtensions:
|
|
151
|
+
fieldExtensions: j
|
|
151
152
|
})
|
|
152
153
|
}), V && /* @__PURE__ */ f(n, {
|
|
153
154
|
onClose: () => H(!1),
|
|
154
155
|
onConfirm: () => {
|
|
155
156
|
H(!1), m?.();
|
|
156
157
|
},
|
|
157
|
-
title:
|
|
158
|
-
body:
|
|
159
|
-
confirmLabel:
|
|
160
|
-
cancelLabel:
|
|
158
|
+
title: F(r.unsavedChangesTitle),
|
|
159
|
+
body: F(r.unsavedChangesBody),
|
|
160
|
+
confirmLabel: F(r.unsavedChangesDiscard),
|
|
161
|
+
cancelLabel: F(r.unsavedChangesKeepEditing)
|
|
161
162
|
})]
|
|
162
163
|
});
|
|
163
164
|
});
|
package/dist/chunks/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var e = /* @__PURE__ */ function(e) {
|
|
2
|
-
return e.Create = "create", e.Edit = "edit", e;
|
|
2
|
+
return e.Create = "create", e.Edit = "edit", e.ReadOnly = "readOnly", e;
|
|
3
3
|
}({}), t = /* @__PURE__ */ function(e) {
|
|
4
4
|
return e.Text = "text", e.Number = "number", e.Date = "date", e.Dropdown = "dropdown", e.Taxonomy = "taxonomy", e;
|
|
5
5
|
}({}), n = /* @__PURE__ */ function(e) {
|
|
@@ -8,13 +8,13 @@ import { useState as l } from "react";
|
|
|
8
8
|
import { SurfaceStatusSurfaceGray as u } from "@box/blueprint-web-assets/tokens/tokens";
|
|
9
9
|
import { Hidden as d, Pencil as f } from "@box/blueprint-web-assets/icons/Line";
|
|
10
10
|
import p from "clsx";
|
|
11
|
-
var m = ({ isHidden: m, isExpanded: h = !1, index: g, maxIndex: _, onReorderFields: v, onToggleVisibility: y, onRequestDelete: b, onRequestDuplicate: x, extensions: S, fieldCollapsedText: C, collapsedMenuSlot: w }) => {
|
|
12
|
-
let
|
|
11
|
+
var m = ({ isHidden: m, isExpanded: h = !1, index: g, maxIndex: _, onReorderFields: v, onToggleVisibility: y, onRequestDelete: b, onRequestDuplicate: x, extensions: S, fieldCollapsedText: C, collapsedMenuSlot: w, readOnly: T = !1 }) => {
|
|
12
|
+
let E = o(), [D, O] = l(!1), k = !h && w ? /* @__PURE__ */ s("div", {
|
|
13
13
|
className: t.contextMenuWithCollapsedText,
|
|
14
14
|
children: w
|
|
15
15
|
}) : /* @__PURE__ */ s(n, {
|
|
16
16
|
className: p(t.fieldContextMenu, {
|
|
17
|
-
[t.menuOpen]:
|
|
17
|
+
[t.menuOpen]: D,
|
|
18
18
|
[t.contextMenuWithCollapsedText]: C && !h
|
|
19
19
|
}),
|
|
20
20
|
index: g,
|
|
@@ -24,7 +24,7 @@ var m = ({ isHidden: m, isExpanded: h = !1, index: g, maxIndex: _, onReorderFiel
|
|
|
24
24
|
onToggleVisibility: y,
|
|
25
25
|
onRequestDelete: b,
|
|
26
26
|
onRequestDuplicate: x,
|
|
27
|
-
onOpenChange:
|
|
27
|
+
onOpenChange: O
|
|
28
28
|
});
|
|
29
29
|
return /* @__PURE__ */ c("div", {
|
|
30
30
|
className: p(t.fieldActionSlot, { [t.expanded]: h }),
|
|
@@ -33,25 +33,25 @@ var m = ({ isHidden: m, isExpanded: h = !1, index: g, maxIndex: _, onReorderFiel
|
|
|
33
33
|
icon: d,
|
|
34
34
|
iconPosition: "left",
|
|
35
35
|
color: u,
|
|
36
|
-
text:
|
|
36
|
+
text: E.formatMessage(e.hiddenStatus).toUpperCase(),
|
|
37
37
|
className: t.hiddenBadge
|
|
38
38
|
}),
|
|
39
39
|
C && !h && /* @__PURE__ */ s(a, {
|
|
40
40
|
as: "span",
|
|
41
41
|
variant: "bodySmall",
|
|
42
42
|
color: "textOnLightSecondary",
|
|
43
|
-
className: p(t.fieldCollapsedText, { [t.menuOpen]:
|
|
43
|
+
className: p(t.fieldCollapsedText, { [t.menuOpen]: D }),
|
|
44
44
|
children: C
|
|
45
45
|
}),
|
|
46
46
|
/* @__PURE__ */ c("div", {
|
|
47
|
-
className: p(t.expandedToolbarActions, { [t.menuOpen]:
|
|
47
|
+
className: p(t.expandedToolbarActions, { [t.menuOpen]: D }),
|
|
48
48
|
children: [S.length > 0 && /* @__PURE__ */ c(i.TabList, {
|
|
49
49
|
variant: "contentSwitcher",
|
|
50
50
|
containerClassname: t.extensionTabsContainer,
|
|
51
51
|
children: [/* @__PURE__ */ s(i.Tab, {
|
|
52
52
|
id: "edit",
|
|
53
53
|
variant: "contentSwitcher",
|
|
54
|
-
"aria-label":
|
|
54
|
+
"aria-label": E.formatMessage(e.editTabAriaLabel),
|
|
55
55
|
children: /* @__PURE__ */ s(f, { "aria-hidden": "true" })
|
|
56
56
|
}), S.map((e, t) => /* @__PURE__ */ s(i.Tab, {
|
|
57
57
|
id: `ext-${t}`,
|
|
@@ -59,7 +59,7 @@ var m = ({ isHidden: m, isExpanded: h = !1, index: g, maxIndex: _, onReorderFiel
|
|
|
59
59
|
"aria-label": e.label,
|
|
60
60
|
children: /* @__PURE__ */ s(e.icon, { "aria-hidden": "true" })
|
|
61
61
|
}, e.label))]
|
|
62
|
-
}),
|
|
62
|
+
}), !T && k]
|
|
63
63
|
})
|
|
64
64
|
]
|
|
65
65
|
});
|
|
@@ -8,22 +8,21 @@ import { Select as o, TextInput as s, TextWithInfoBadge as c, TooltipProvider as
|
|
|
8
8
|
import { useIntl as u } from "react-intl";
|
|
9
9
|
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
10
10
|
import { useMemo as p } from "react";
|
|
11
|
-
var m = ({ nameInputId: m, descriptionInputId: h, isTypeEditable: g, externalErrors: _, externalTouched: v, handleTypeChange: y, hideDescription: b = !1 }) => {
|
|
12
|
-
let
|
|
11
|
+
var m = ({ nameInputId: m, descriptionInputId: h, isTypeEditable: g, externalErrors: _, externalTouched: v, handleTypeChange: y, hideDescription: b = !1, readOnly: x = !1 }) => {
|
|
12
|
+
let S = u(), C = t(), { values: w, errors: T, touched: E, handleChange: D, handleBlur: O } = i(), k = (e) => {
|
|
13
13
|
if (_ && v?.[e]) return _[e];
|
|
14
|
-
let t =
|
|
15
|
-
if (
|
|
16
|
-
},
|
|
17
|
-
infoBadgeAriaLabel:
|
|
18
|
-
infoText:
|
|
14
|
+
let t = T[e];
|
|
15
|
+
if (E[e] && t != null && typeof t == "string") return t;
|
|
16
|
+
}, A = p(() => /* @__PURE__ */ d(l, { children: /* @__PURE__ */ d(c, {
|
|
17
|
+
infoBadgeAriaLabel: S.formatMessage(n.descriptionLearnMoreBadgeAriaLabel),
|
|
18
|
+
infoText: S.formatMessage(n.descriptionInfoTooltip),
|
|
19
19
|
children: /* @__PURE__ */ d("label", {
|
|
20
20
|
className: r.labelWithTooltip,
|
|
21
21
|
htmlFor: h,
|
|
22
|
-
children:
|
|
22
|
+
children: S.formatMessage(n.fieldDescriptionLabel)
|
|
23
23
|
})
|
|
24
|
-
}) }), [
|
|
24
|
+
}) }), [S, h]), j = x || w.isFieldReadOnly;
|
|
25
25
|
return /* @__PURE__ */ d("fieldset", {
|
|
26
|
-
disabled: C.isFieldReadOnly,
|
|
27
26
|
className: r.fieldset,
|
|
28
27
|
children: /* @__PURE__ */ f("div", {
|
|
29
28
|
className: r.expandedContent,
|
|
@@ -33,48 +32,47 @@ var m = ({ nameInputId: m, descriptionInputId: h, isTypeEditable: g, externalErr
|
|
|
33
32
|
children: [/* @__PURE__ */ d(s, {
|
|
34
33
|
name: "name",
|
|
35
34
|
id: m,
|
|
36
|
-
label:
|
|
37
|
-
placeholder:
|
|
38
|
-
value:
|
|
39
|
-
error:
|
|
40
|
-
onChange:
|
|
41
|
-
onBlur:
|
|
42
|
-
|
|
43
|
-
required: !
|
|
35
|
+
label: S.formatMessage(n.fieldNameLabel),
|
|
36
|
+
placeholder: S.formatMessage(n.fieldNameInputPlaceholder),
|
|
37
|
+
value: w.name,
|
|
38
|
+
error: j ? void 0 : k("name"),
|
|
39
|
+
onChange: D,
|
|
40
|
+
onBlur: O,
|
|
41
|
+
readOnly: j,
|
|
42
|
+
required: !j
|
|
44
43
|
}), /* @__PURE__ */ d(o, {
|
|
45
44
|
name: "type",
|
|
46
|
-
label:
|
|
47
|
-
placeholder:
|
|
48
|
-
value:
|
|
49
|
-
"aria-readonly": !g,
|
|
50
|
-
readonly: !g,
|
|
51
|
-
disabled: C.isFieldReadOnly,
|
|
45
|
+
label: S.formatMessage(n.fieldTypeLabel),
|
|
46
|
+
placeholder: S.formatMessage(n.fieldTypePlaceholder),
|
|
47
|
+
value: w.type,
|
|
48
|
+
"aria-readonly": j || !g,
|
|
49
|
+
readonly: j || !g,
|
|
52
50
|
onValueChange: y,
|
|
53
51
|
className: r.fieldTypeSelect,
|
|
54
|
-
required: !
|
|
55
|
-
children: /* @__PURE__ */ d(o.Content, { children:
|
|
52
|
+
required: !j,
|
|
53
|
+
children: /* @__PURE__ */ d(o.Content, { children: C.availableFieldTypes.map((e) => /* @__PURE__ */ d(o.Option, {
|
|
56
54
|
text: typeof e.label == "string" ? e.label : String(e.label),
|
|
57
55
|
value: e.type
|
|
58
56
|
}, e.type)) })
|
|
59
57
|
})]
|
|
60
58
|
}),
|
|
61
|
-
[e.Dropdown, e.Taxonomy].includes(
|
|
59
|
+
[e.Dropdown, e.Taxonomy].includes(w.type) && /* @__PURE__ */ d("div", {
|
|
62
60
|
className: r.typeSpecific,
|
|
63
|
-
children: a(
|
|
61
|
+
children: a(w.type)
|
|
64
62
|
}),
|
|
65
63
|
!b && /* @__PURE__ */ d("div", {
|
|
66
64
|
className: r.description,
|
|
67
65
|
children: /* @__PURE__ */ d(s, {
|
|
68
66
|
name: "description",
|
|
69
67
|
id: h,
|
|
70
|
-
label:
|
|
71
|
-
placeholder:
|
|
72
|
-
value:
|
|
73
|
-
error:
|
|
68
|
+
label: A,
|
|
69
|
+
placeholder: S.formatMessage(n.fieldDescriptionInputPlaceholder),
|
|
70
|
+
value: w.description ?? "",
|
|
71
|
+
error: j ? void 0 : k("description"),
|
|
74
72
|
hideLabel: !0,
|
|
75
|
-
|
|
76
|
-
onChange:
|
|
77
|
-
onBlur:
|
|
73
|
+
readOnly: j,
|
|
74
|
+
onChange: D,
|
|
75
|
+
onBlur: O
|
|
78
76
|
})
|
|
79
77
|
})
|
|
80
78
|
]
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { general as e } from "./messages/configurator-messages.js";
|
|
2
2
|
import t from "./components/confirmation-modal/confirmation-modal.js";
|
|
3
3
|
import { t as n } from "../../../../chunks/metadata-field-configurator.module.js";
|
|
4
|
-
import { FieldActionSlot as
|
|
5
|
-
import { FieldConfiguratorContext as
|
|
6
|
-
import { TaxonomyOptionsContext as
|
|
7
|
-
import { FieldEditContent as
|
|
4
|
+
import { FieldActionSlot as r } from "./components/field-action-slot/field-action-slot.js";
|
|
5
|
+
import { FieldConfiguratorContext as i } from "./context/field-configurator-context.js";
|
|
6
|
+
import { TaxonomyOptionsContext as ee } from "./context/taxonomy-options-context.js";
|
|
7
|
+
import { FieldEditContent as te } from "./components/field-edit-content/field-edit-content.js";
|
|
8
8
|
import { FieldExtensionsContext as a } from "./context/field-extensions-context.js";
|
|
9
|
-
import { EDIT_TAB_ID as o, useFieldConfiguratorBehavior as
|
|
10
|
-
import { Accordion as
|
|
11
|
-
import { useIntl as
|
|
12
|
-
import { Fragment as
|
|
9
|
+
import { EDIT_TAB_ID as o, useFieldConfiguratorBehavior as s } from "./hooks/useFieldConfiguratorBehavior.js";
|
|
10
|
+
import { Accordion as c, Tabs as l } from "@box/blueprint-web";
|
|
11
|
+
import { useIntl as u } from "react-intl";
|
|
12
|
+
import { Fragment as ne, jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
13
13
|
import "react";
|
|
14
|
-
var p = ({ index: p, maxIndex: m, values: h, onValuesChange: g, onDelete: _, onDuplicate: v, onReorderFields:
|
|
15
|
-
let
|
|
14
|
+
var p = ({ index: p, maxIndex: m, values: h, onValuesChange: g, onDelete: _, onDuplicate: v, onReorderFields: y, onTouchStart: b, onDragStart: x, onDragEnd: S, externalErrors: re, externalTouched: ie, dndDragHandleProps: C, fieldCollapsedText: ae, isExpanded: w, onExpandedChange: T, taxonomyOptions: E, fetchTaxonomies: D, submitAttemptCount: O, fieldExtensions: k, onValidationChange: A, readOnly: j = !1 }) => {
|
|
15
|
+
let M = u(), { contextValue: N, taxonomyContextValue: P, extensions: F, isActive: I, handleAccordionValueChange: L, isDeleteConfirmationModalOpen: R, openConfirmationModal: z, closeConfirmationModal: oe, handleDeleteField: B, activeTabId: V, setActiveTabId: H, isTypeEditable: U, uniqueKey: W, nameInputId: G, descriptionInputId: K, accordionTitle: q, TitleIcon: se, hasErrors: ce, handleTypeChange: le, handleChangeVisibility: ue } = s({
|
|
16
16
|
values: h,
|
|
17
17
|
onValuesChange: g,
|
|
18
18
|
onDelete: _,
|
|
@@ -23,71 +23,79 @@ var p = ({ index: p, maxIndex: m, values: h, onValuesChange: g, onDelete: _, onD
|
|
|
23
23
|
fetchTaxonomies: D,
|
|
24
24
|
fieldExtensionsProp: k,
|
|
25
25
|
onValidationChange: A
|
|
26
|
-
}),
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
}), de = j ? {
|
|
27
|
+
...N,
|
|
28
|
+
values: {
|
|
29
|
+
...N.values,
|
|
30
|
+
isFieldReadOnly: !0
|
|
31
|
+
}
|
|
32
|
+
} : N, J = /* @__PURE__ */ d(te, {
|
|
33
|
+
nameInputId: G,
|
|
34
|
+
descriptionInputId: K,
|
|
35
|
+
isTypeEditable: U,
|
|
36
|
+
externalErrors: re,
|
|
37
|
+
externalTouched: ie,
|
|
38
|
+
handleTypeChange: le,
|
|
39
|
+
readOnly: j
|
|
40
|
+
}), fe = F.length > 0 ? /* @__PURE__ */ f(ne, { children: [/* @__PURE__ */ d(l.TabPanel, {
|
|
34
41
|
tabId: o,
|
|
35
42
|
children: J
|
|
36
|
-
}),
|
|
43
|
+
}), F.map((e, t) => /* @__PURE__ */ d(l.TabPanel, {
|
|
37
44
|
tabId: `ext-${t}`,
|
|
38
45
|
className: n.extensionContent,
|
|
39
46
|
children: e.renderContent(h)
|
|
40
|
-
}, e.label))] }) : J, Y = w === !1, X = /* @__PURE__ */ d(
|
|
47
|
+
}, e.label))] }) : J, Y = w === !1, X = /* @__PURE__ */ d(c.Item, {
|
|
41
48
|
highlighted: !0,
|
|
42
|
-
startElement: /* @__PURE__ */ d(
|
|
49
|
+
startElement: /* @__PURE__ */ d(se, {
|
|
43
50
|
fontSize: "20px",
|
|
44
51
|
role: "presentation"
|
|
45
52
|
}),
|
|
46
|
-
value:
|
|
47
|
-
title:
|
|
48
|
-
action: /* @__PURE__ */ d(
|
|
49
|
-
fieldCollapsedText:
|
|
53
|
+
value: W,
|
|
54
|
+
title: q,
|
|
55
|
+
action: /* @__PURE__ */ d(r, {
|
|
56
|
+
fieldCollapsedText: ae,
|
|
50
57
|
isHidden: h.hidden,
|
|
51
|
-
isExpanded:
|
|
58
|
+
isExpanded: I,
|
|
52
59
|
index: p,
|
|
53
60
|
maxIndex: m,
|
|
54
|
-
onReorderFields:
|
|
55
|
-
onToggleVisibility:
|
|
56
|
-
onRequestDelete:
|
|
61
|
+
onReorderFields: y,
|
|
62
|
+
onToggleVisibility: ue,
|
|
63
|
+
onRequestDelete: z,
|
|
57
64
|
onRequestDuplicate: v,
|
|
58
|
-
extensions:
|
|
65
|
+
extensions: F,
|
|
66
|
+
readOnly: j
|
|
59
67
|
}),
|
|
60
68
|
className: n.fieldAccordionItem,
|
|
61
|
-
iconVariant:
|
|
62
|
-
children:
|
|
63
|
-
}), Z =
|
|
64
|
-
selectedId:
|
|
65
|
-
setSelectedId: (e) =>
|
|
69
|
+
iconVariant: ce ? "alert-error" : void 0,
|
|
70
|
+
children: fe
|
|
71
|
+
}), Z = F.length > 0 ? /* @__PURE__ */ d(l, {
|
|
72
|
+
selectedId: V,
|
|
73
|
+
setSelectedId: (e) => H(e ?? "edit"),
|
|
66
74
|
children: X
|
|
67
|
-
}) : X, Q = /* @__PURE__ */ f(
|
|
68
|
-
value:
|
|
75
|
+
}) : X, Q = /* @__PURE__ */ f(i.Provider, {
|
|
76
|
+
value: de,
|
|
69
77
|
children: [/* @__PURE__ */ d("div", {
|
|
70
|
-
draggable: Y && !
|
|
71
|
-
onDragStart: Y && !
|
|
72
|
-
onDragEnd: Y && !
|
|
73
|
-
onTouchStart: Y && !
|
|
74
|
-
...Y ?
|
|
75
|
-
...Y ?
|
|
76
|
-
children: w === void 0 ? /* @__PURE__ */ d(
|
|
78
|
+
draggable: Y && !C,
|
|
79
|
+
onDragStart: Y && !C && x ? (e) => x(e, p) : void 0,
|
|
80
|
+
onDragEnd: Y && !C && S ? (e) => S(e, p) : void 0,
|
|
81
|
+
onTouchStart: Y && !C && b ? (e) => b(e, p) : void 0,
|
|
82
|
+
...Y ? C?.listeners ?? {} : {},
|
|
83
|
+
...Y ? C?.attributes ?? {} : {},
|
|
84
|
+
children: w === void 0 ? /* @__PURE__ */ d(c, {
|
|
77
85
|
type: "single",
|
|
78
86
|
collapsible: !0,
|
|
79
|
-
value:
|
|
80
|
-
onValueChange:
|
|
87
|
+
value: I ? W : "",
|
|
88
|
+
onValueChange: L,
|
|
81
89
|
children: Z
|
|
82
90
|
}) : Z
|
|
83
|
-
}),
|
|
84
|
-
onClose:
|
|
85
|
-
onConfirm:
|
|
86
|
-
title:
|
|
87
|
-
body:
|
|
91
|
+
}), R && /* @__PURE__ */ d(t, {
|
|
92
|
+
onClose: oe,
|
|
93
|
+
onConfirm: B,
|
|
94
|
+
title: M.formatMessage(e.deleteFieldTitle, { fieldName: h.name }),
|
|
95
|
+
body: M.formatMessage(e.deleteFieldDescription)
|
|
88
96
|
})]
|
|
89
|
-
}), $ = E !== void 0 || D !== void 0 ? /* @__PURE__ */ d(
|
|
90
|
-
value:
|
|
97
|
+
}), $ = E !== void 0 || D !== void 0 ? /* @__PURE__ */ d(ee.Provider, {
|
|
98
|
+
value: P,
|
|
91
99
|
children: Q
|
|
92
100
|
}) : Q;
|
|
93
101
|
return k === void 0 ? $ : /* @__PURE__ */ d(a.Provider, {
|