@box/metadata-template-editor 1.25.1 → 1.26.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/dist/chunks/metadata-field-list.js +169 -158
- package/dist/chunks/metadata-template-editor.js +122 -115
- package/dist/chunks/taxonomy-field-configurator-initial-state.js +28 -27
- package/dist/esm/index.js +19 -16
- package/dist/esm/lib/components/metadata-field-configurator/context/editor-config-context.js +3 -0
- package/dist/esm/lib/components/metadata-field-configurator/index.js +14 -11
- package/dist/esm/lib/index.js +8 -7
- package/dist/esm/lib/utils/field-options/useFieldOptions.js +10 -9
- package/dist/types/lib/components/metadata-field-configurator/context/editor-config-context.d.ts +17 -0
- package/dist/types/lib/components/metadata-field-configurator/index.d.ts +4 -0
- package/dist/types/lib/components/metadata-field-list/metadata-field-list.d.ts +11 -1
- package/dist/types/lib/index.d.ts +2 -0
- package/dist/types/lib/metadata-template-editor.d.ts +11 -1
- package/package.json +6 -6
|
@@ -1,32 +1,33 @@
|
|
|
1
1
|
import { a as e } from "./types.js";
|
|
2
2
|
import { FieldTypeIcon as t } from "../esm/lib/utils/field-options/field-type-icon.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import
|
|
3
|
+
import { EditorConfigContext as n, useEditorConfig as r } from "../esm/lib/components/metadata-field-configurator/context/editor-config-context.js";
|
|
4
|
+
import { general as i } from "../esm/lib/components/metadata-field-configurator/messages/configurator-messages.js";
|
|
5
|
+
import { useTemplateFieldSchema as a } from "../esm/lib/components/metadata-field-configurator/hooks/useTemplateFieldSchema.js";
|
|
6
|
+
import { TaxonomyOptionsContext as o } from "../esm/lib/components/metadata-field-configurator/context/taxonomy-options-context.js";
|
|
7
|
+
import { FieldExtensionsContext as s } from "../esm/lib/components/metadata-field-configurator/context/field-extensions-context.js";
|
|
8
|
+
import { useTaxonomyFetch as c } from "../esm/lib/components/metadata-field-configurator/hooks/useTaxonomyFetch.js";
|
|
9
|
+
import { MetadataFieldConfigurator as l } from "../esm/lib/components/metadata-field-configurator/metadata-field-configurator.js";
|
|
10
|
+
import { Accordion as u } from "@box/blueprint-web";
|
|
11
|
+
import { useIntl as d } from "react-intl";
|
|
12
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
13
|
+
import { forwardRef as m, useCallback as h, useEffect as g, useImperativeHandle as _, useMemo as v, useRef as y, useState as b } from "react";
|
|
14
|
+
import * as ee from "yup";
|
|
15
|
+
import x from "clsx";
|
|
16
|
+
import te from "lodash/cloneDeep";
|
|
17
|
+
import S from "lodash/uniqueId";
|
|
18
|
+
import { DndContext as ne, DragOverlay as re, KeyboardSensor as C, PointerSensor as ie, TouchSensor as ae, closestCenter as oe, useSensor as w, useSensors as se } from "@dnd-kit/core";
|
|
19
|
+
import { SortableContext as ce, arrayMove as T, sortableKeyboardCoordinates as le, useSortable as E, verticalListSortingStrategy as D } from "@dnd-kit/sortable";
|
|
20
|
+
import { CSS as O } from "@dnd-kit/utilities";
|
|
21
|
+
import '../styles/metadata-field-list.css';var k = {
|
|
21
22
|
fieldList: "_fieldList_18x5c_1",
|
|
22
23
|
fieldItem: "_fieldItem_18x5c_11",
|
|
23
24
|
dragging: "_dragging_18x5c_11",
|
|
24
25
|
accordionRootContainer: "_accordionRootContainer_18x5c_15"
|
|
25
|
-
},
|
|
26
|
-
function
|
|
26
|
+
}, ue = 150;
|
|
27
|
+
function A(e) {
|
|
27
28
|
return e.id;
|
|
28
29
|
}
|
|
29
|
-
var
|
|
30
|
+
var j = 150, de = class extends C {
|
|
30
31
|
static activators = [{
|
|
31
32
|
eventName: "onKeyDown",
|
|
32
33
|
handler: (e, t, n) => {
|
|
@@ -37,207 +38,217 @@ var N = 150, P = class extends S {
|
|
|
37
38
|
"SELECT",
|
|
38
39
|
"TEXTAREA",
|
|
39
40
|
"A"
|
|
40
|
-
].includes(r.tagName) ? !1 :
|
|
41
|
+
].includes(r.tagName) ? !1 : C.activators[0].handler(e, t, n);
|
|
41
42
|
}
|
|
42
43
|
}];
|
|
43
44
|
};
|
|
44
|
-
function
|
|
45
|
-
let
|
|
46
|
-
return /* @__PURE__ */
|
|
45
|
+
function fe({ field: e, index: t, maxIndex: n, isExpanded: r, onChangeField: i, onDeleteAtIndex: a, onDuplicateAtIndex: o, onReorderFields: s, onRequestExpand: c, submitAttemptCount: u }) {
|
|
46
|
+
let d = A(e), { attributes: p, listeners: m, setNodeRef: h, transform: g, transition: _, isDragging: v } = E({ id: d });
|
|
47
|
+
return /* @__PURE__ */ f("li", {
|
|
47
48
|
ref: h,
|
|
48
49
|
style: {
|
|
49
|
-
transform:
|
|
50
|
+
transform: O.Translate.toString(g),
|
|
50
51
|
transition: _
|
|
51
52
|
},
|
|
52
|
-
"data-field-id":
|
|
53
|
-
className:
|
|
54
|
-
children: /* @__PURE__ */
|
|
53
|
+
"data-field-id": d,
|
|
54
|
+
className: x(k.fieldItem, { [k.dragging]: v }),
|
|
55
|
+
children: /* @__PURE__ */ f(l, {
|
|
55
56
|
values: e,
|
|
56
57
|
onValuesChange: i,
|
|
57
58
|
index: t,
|
|
58
59
|
maxIndex: n,
|
|
59
60
|
onDelete: () => a(t),
|
|
60
61
|
onDuplicate: () => o(t),
|
|
61
|
-
onReorderFields:
|
|
62
|
+
onReorderFields: s,
|
|
62
63
|
dndDragHandleProps: {
|
|
63
64
|
listeners: m,
|
|
64
65
|
attributes: p
|
|
65
66
|
},
|
|
66
67
|
isExpanded: r,
|
|
67
68
|
onExpandedChange: (e) => {
|
|
68
|
-
e &&
|
|
69
|
+
e && c();
|
|
69
70
|
},
|
|
70
|
-
submitAttemptCount:
|
|
71
|
+
submitAttemptCount: u
|
|
71
72
|
})
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
|
-
var
|
|
75
|
-
let { formatMessage:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}, [
|
|
79
|
-
if (!
|
|
75
|
+
var M = /* @__PURE__ */ m(function({ fields: l, onChangeFields: m, onDeleteFieldAtIndex: x, onDuplicateField: C, taxonomyOptions: E, fetchTaxonomies: O, disabledFieldTypes: M, taxonomyInitialStateLabels: N, firstInvalidFieldIndex: P, submitAttemptCount: F, fieldExtensions: I, onValidationChange: L }, R) {
|
|
76
|
+
let { formatMessage: z } = d(), B = r(), pe = c(O, E), V = y(null), H = y(null), U = y(new Set(l.map((e) => A(e)))), W = a(), G = y(null);
|
|
77
|
+
g(() => {
|
|
78
|
+
G.current = null;
|
|
79
|
+
}, [L]), g(() => {
|
|
80
|
+
if (!L) return;
|
|
80
81
|
let e = !1, t = setTimeout(() => {
|
|
81
|
-
|
|
82
|
-
e ||
|
|
82
|
+
ee.array().of(W).validate(l, { abortEarly: !0 }).then(() => {
|
|
83
|
+
e || G.current === !0 || (G.current = !0, L(!0));
|
|
83
84
|
}).catch(() => {
|
|
84
|
-
e ||
|
|
85
|
+
e || G.current === !1 || (G.current = !1, L(!1));
|
|
85
86
|
});
|
|
86
|
-
},
|
|
87
|
+
}, ue);
|
|
87
88
|
return () => {
|
|
88
89
|
e = !0, clearTimeout(t);
|
|
89
90
|
};
|
|
90
91
|
}, [
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
l,
|
|
93
|
+
W,
|
|
94
|
+
L
|
|
94
95
|
]);
|
|
95
|
-
let [
|
|
96
|
-
let e =
|
|
97
|
-
return e ?
|
|
96
|
+
let [K, q] = b(() => {
|
|
97
|
+
let e = l.find((e) => e.isFieldNew);
|
|
98
|
+
return e ? A(e) : null;
|
|
98
99
|
});
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
(
|
|
100
|
+
_(R, () => ({ scrollToAndExpand(e) {
|
|
101
|
+
H.current = e, K === e ? (H.current = null, setTimeout(() => {
|
|
102
|
+
(V.current?.querySelector(`[data-field-id="${e}"]`))?.scrollIntoView({
|
|
102
103
|
behavior: "smooth",
|
|
103
104
|
block: "nearest"
|
|
104
105
|
});
|
|
105
|
-
}, 0)) :
|
|
106
|
-
} }), [
|
|
107
|
-
|
|
108
|
-
let t =
|
|
109
|
-
|
|
106
|
+
}, 0)) : q(e);
|
|
107
|
+
} }), [K]), g(() => {
|
|
108
|
+
l.forEach((e) => {
|
|
109
|
+
let t = A(e);
|
|
110
|
+
U.current.has(t) || (U.current.add(t), H.current = t, q(t));
|
|
110
111
|
});
|
|
111
|
-
}, [
|
|
112
|
-
if (
|
|
113
|
-
let e =
|
|
112
|
+
}, [l]), g(() => {
|
|
113
|
+
if (P == null || !F) return;
|
|
114
|
+
let e = l[P];
|
|
114
115
|
if (!e) return;
|
|
115
|
-
let t =
|
|
116
|
-
|
|
117
|
-
(
|
|
116
|
+
let t = A(e);
|
|
117
|
+
q(t), requestAnimationFrame(() => {
|
|
118
|
+
(V.current?.querySelector(`[data-field-id="${t}"]`))?.scrollIntoView({
|
|
118
119
|
behavior: "smooth",
|
|
119
120
|
block: "nearest"
|
|
120
121
|
});
|
|
121
122
|
});
|
|
122
|
-
}, [
|
|
123
|
-
let e =
|
|
124
|
-
if (!e || e !==
|
|
125
|
-
|
|
123
|
+
}, [F]), g(() => {
|
|
124
|
+
let e = H.current;
|
|
125
|
+
if (!e || e !== K) return;
|
|
126
|
+
H.current = null;
|
|
126
127
|
let t = setTimeout(() => {
|
|
127
|
-
(
|
|
128
|
+
(V.current?.querySelector(`[data-field-id="${e}"]`))?.scrollIntoView({
|
|
128
129
|
behavior: "smooth",
|
|
129
130
|
block: "nearest"
|
|
130
131
|
});
|
|
131
|
-
},
|
|
132
|
+
}, j);
|
|
132
133
|
return () => clearTimeout(t);
|
|
133
|
-
}, [
|
|
134
|
-
let [
|
|
134
|
+
}, [K]);
|
|
135
|
+
let [J, Y] = b(null), me = se(w(ie, { activationConstraint: { distance: 8 } }), w(ae, { activationConstraint: {
|
|
135
136
|
delay: 250,
|
|
136
137
|
tolerance: 5
|
|
137
|
-
} }), w(
|
|
138
|
-
|
|
139
|
-
}, []),
|
|
140
|
-
|
|
138
|
+
} }), w(de, { coordinateGetter: le })), he = h((e) => {
|
|
139
|
+
Y(String(e.active.id));
|
|
140
|
+
}, []), ge = h((e) => {
|
|
141
|
+
Y(null);
|
|
141
142
|
let { active: t, over: n } = e;
|
|
142
143
|
if (n && t.id !== n.id) {
|
|
143
|
-
let e =
|
|
144
|
-
e !== -1 && r !== -1 &&
|
|
144
|
+
let e = l.findIndex((e) => A(e) === t.id), r = l.findIndex((e) => A(e) === n.id);
|
|
145
|
+
e !== -1 && r !== -1 && m?.(T(l, e, r));
|
|
145
146
|
}
|
|
146
|
-
}, [
|
|
147
|
-
|
|
148
|
-
}, []),
|
|
149
|
-
|
|
150
|
-
}, [
|
|
151
|
-
let t =
|
|
152
|
-
|
|
147
|
+
}, [l, m]), _e = h(() => {
|
|
148
|
+
Y(null);
|
|
149
|
+
}, []), ve = h((e, t) => {
|
|
150
|
+
m?.(l.map((n, r) => r === e ? t : n));
|
|
151
|
+
}, [l, m]), ye = h((e) => {
|
|
152
|
+
let t = l[e], n = A(t);
|
|
153
|
+
q((e) => e === n ? null : e), m?.(l.filter((t, n) => n !== e)), x?.(e, t);
|
|
153
154
|
}, [
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
]),
|
|
158
|
-
let n =
|
|
159
|
-
r.id =
|
|
155
|
+
l,
|
|
156
|
+
m,
|
|
157
|
+
x
|
|
158
|
+
]), X = h((t) => {
|
|
159
|
+
let n = l[t], r = te(n);
|
|
160
|
+
r.id = S("field-"), r.key = "", r.isFieldNew = !0, r.type === e.Dropdown && (r.dropdown.options = r.dropdown.options.map((e) => ({
|
|
160
161
|
...e,
|
|
161
|
-
id:
|
|
162
|
+
id: S()
|
|
162
163
|
})));
|
|
163
|
-
let i = [...
|
|
164
|
-
i.splice(t + 1, 0, r),
|
|
164
|
+
let i = [...l];
|
|
165
|
+
i.splice(t + 1, 0, r), m?.(i), C?.(r);
|
|
165
166
|
}, [
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
]),
|
|
170
|
-
t < 0 || t >=
|
|
171
|
-
}, [
|
|
167
|
+
l,
|
|
168
|
+
m,
|
|
169
|
+
C
|
|
170
|
+
]), be = h((e, t) => {
|
|
171
|
+
t < 0 || t >= l.length || m?.(T(l, e, t));
|
|
172
|
+
}, [l, m]), xe = h((e) => {
|
|
172
173
|
let t = e || null;
|
|
173
|
-
|
|
174
|
-
(
|
|
174
|
+
q(t), t && setTimeout(() => {
|
|
175
|
+
(V.current?.querySelector(`[data-field-id="${t}"]`))?.scrollIntoView({
|
|
175
176
|
behavior: "smooth",
|
|
176
177
|
block: "nearest"
|
|
177
178
|
});
|
|
178
|
-
},
|
|
179
|
-
}, []),
|
|
180
|
-
let
|
|
181
|
-
return t.type === e.Dropdown ? `${
|
|
182
|
-
})(Z) : "",
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
179
|
+
}, j);
|
|
180
|
+
}, []), Se = l.map((e) => A(e)), Z = J ? l.find((e) => A(e) === J) : null, Q = Z ? t(Z.type) : null, Ce = Z ? ((t) => {
|
|
181
|
+
let n = t.name || z(i.fieldNameInputPlaceholder);
|
|
182
|
+
return t.type === e.Dropdown ? `${n} (${t.dropdown?.options?.length ?? 0})` : n;
|
|
183
|
+
})(Z) : "", we = v(() => ({
|
|
184
|
+
disabledFieldTypes: M ?? B.disabledFieldTypes,
|
|
185
|
+
taxonomyInitialStateLabels: N ?? B.taxonomyInitialStateLabels
|
|
186
|
+
}), [
|
|
187
|
+
M,
|
|
188
|
+
N,
|
|
189
|
+
B
|
|
190
|
+
]), $ = /* @__PURE__ */ f(n.Provider, {
|
|
191
|
+
value: we,
|
|
192
|
+
children: /* @__PURE__ */ f(o.Provider, {
|
|
193
|
+
value: pe,
|
|
194
|
+
children: /* @__PURE__ */ p(ne, {
|
|
195
|
+
sensors: me,
|
|
196
|
+
collisionDetection: oe,
|
|
197
|
+
onDragStart: he,
|
|
198
|
+
onDragEnd: ge,
|
|
199
|
+
onDragCancel: _e,
|
|
200
|
+
children: [/* @__PURE__ */ f("div", {
|
|
201
|
+
className: k.accordionRootContainer,
|
|
202
|
+
children: /* @__PURE__ */ f(u, {
|
|
203
|
+
type: "single",
|
|
204
|
+
collapsible: !0,
|
|
205
|
+
value: K ?? "",
|
|
206
|
+
onValueChange: xe,
|
|
207
|
+
children: /* @__PURE__ */ f(ce, {
|
|
208
|
+
items: Se,
|
|
209
|
+
strategy: D,
|
|
210
|
+
children: /* @__PURE__ */ f("ul", {
|
|
211
|
+
ref: V,
|
|
212
|
+
className: k.fieldList,
|
|
213
|
+
children: l.map((e, t) => {
|
|
214
|
+
let n = A(e);
|
|
215
|
+
return /* @__PURE__ */ f(fe, {
|
|
216
|
+
field: e,
|
|
217
|
+
index: t,
|
|
218
|
+
maxIndex: l.length - 1,
|
|
219
|
+
isExpanded: K === n,
|
|
220
|
+
onChangeField: (e) => ve(t, e),
|
|
221
|
+
onDeleteAtIndex: ye,
|
|
222
|
+
onDuplicateAtIndex: X,
|
|
223
|
+
onReorderFields: be,
|
|
224
|
+
onRequestExpand: () => q(n),
|
|
225
|
+
submitAttemptCount: F
|
|
226
|
+
}, n);
|
|
227
|
+
})
|
|
217
228
|
})
|
|
218
229
|
})
|
|
219
230
|
})
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
})
|
|
234
|
-
})
|
|
235
|
-
})
|
|
231
|
+
}), /* @__PURE__ */ f(re, {
|
|
232
|
+
dropAnimation: null,
|
|
233
|
+
children: Z && Q ? /* @__PURE__ */ f(u, {
|
|
234
|
+
type: "single",
|
|
235
|
+
children: /* @__PURE__ */ f(u.Item, {
|
|
236
|
+
value: "ghost",
|
|
237
|
+
title: Ce,
|
|
238
|
+
startElement: /* @__PURE__ */ f(Q, {
|
|
239
|
+
fontSize: "20px",
|
|
240
|
+
role: "presentation"
|
|
241
|
+
}),
|
|
242
|
+
children: null
|
|
243
|
+
})
|
|
244
|
+
}) : null
|
|
245
|
+
})]
|
|
246
|
+
})
|
|
236
247
|
})
|
|
237
248
|
});
|
|
238
|
-
return
|
|
239
|
-
value:
|
|
249
|
+
return I === void 0 ? $ : /* @__PURE__ */ f(s.Provider, {
|
|
250
|
+
value: I,
|
|
240
251
|
children: $
|
|
241
252
|
});
|
|
242
253
|
});
|
|
243
|
-
export {
|
|
254
|
+
export { M as t };
|
|
@@ -1,157 +1,164 @@
|
|
|
1
1
|
import { o as e } from "./types.js";
|
|
2
|
+
import { EditorConfigContext as t } from "../esm/lib/components/metadata-field-configurator/context/editor-config-context.js";
|
|
2
3
|
import "../esm/lib/utils/constants.js";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { useMetadataTemplateFormSchema as
|
|
6
|
-
import { convertApiMetadataTemplateFieldToLocalConfiguratorField as
|
|
7
|
-
import { mapFieldsWithUniqueKeys as
|
|
8
|
-
import { generateJSONPatchTemplateOperations as
|
|
9
|
-
import { t as
|
|
10
|
-
import { EmptyState as
|
|
11
|
-
import { useIntl as
|
|
12
|
-
import {
|
|
13
|
-
import { forwardRef as
|
|
14
|
-
import { ArrowsRotating as
|
|
15
|
-
import { Formik as
|
|
16
|
-
import { ErrorState404 as
|
|
17
|
-
import '../styles/metadata-template-editor.css';var
|
|
4
|
+
import n from "../esm/lib/components/metadata-field-configurator/components/confirmation-modal/confirmation-modal.js";
|
|
5
|
+
import r from "../esm/lib/messages.js";
|
|
6
|
+
import { useMetadataTemplateFormSchema as i } from "../esm/lib/hooks/useMetadataTemplateFormSchema.js";
|
|
7
|
+
import { convertApiMetadataTemplateFieldToLocalConfiguratorField as a } from "../esm/lib/utils/template-type-conversion/convertTemplateFieldToLocalConfigurator.js";
|
|
8
|
+
import { mapFieldsWithUniqueKeys as o } from "../esm/lib/utils/template-type-conversion/mapFieldsWithUniqueKeys.js";
|
|
9
|
+
import { generateJSONPatchTemplateOperations as s } from "../esm/lib/utils/template-type-conversion/generateJSONPatchTemplateOperations.js";
|
|
10
|
+
import { t as c } from "./metadata-template-editor-form.js";
|
|
11
|
+
import { EmptyState as l, LoadingIndicator as u, Text as d, useNotification as ee } from "@box/blueprint-web";
|
|
12
|
+
import { useIntl as te } from "react-intl";
|
|
13
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
14
|
+
import { forwardRef as m, useCallback as h, useEffect as g, useImperativeHandle as _, useMemo as v, useState as y } from "react";
|
|
15
|
+
import { ArrowsRotating as b } from "@box/blueprint-web-assets/icons/Line";
|
|
16
|
+
import { Formik as x } from "formik";
|
|
17
|
+
import { ErrorState404 as S } from "@box/blueprint-web-assets/illustrations/Medium";
|
|
18
|
+
import '../styles/metadata-template-editor.css';var C = {
|
|
18
19
|
form: "_form_1o2vk_1",
|
|
19
20
|
loading: "_loading_1o2vk_8",
|
|
20
21
|
error: "_error_1o2vk_15",
|
|
21
22
|
fields: "_fields_1o2vk_24",
|
|
22
23
|
addField: "_addField_1o2vk_30",
|
|
23
24
|
actions: "_actions_1o2vk_34"
|
|
24
|
-
},
|
|
25
|
+
}, ne = {
|
|
25
26
|
displayName: "",
|
|
26
27
|
templateKey: "",
|
|
27
28
|
fields: [],
|
|
28
29
|
hidden: !1
|
|
29
|
-
},
|
|
30
|
-
let
|
|
31
|
-
|
|
32
|
-
}, [
|
|
33
|
-
|
|
34
|
-
let
|
|
35
|
-
|
|
36
|
-
}, [
|
|
37
|
-
|
|
30
|
+
}, w = /* @__PURE__ */ m(function({ onCancel: m, onDirtyStateChange: w, onValidationChange: re, onSubmitError: ie, onTemplateLoad: T, taxonomyOptions: E, fetchTaxonomies: D, disabledFieldTypes: O, taxonomyInitialStateLabels: k, formId: A, hideActions: j = !1, fieldExtensions: M, ...N }, P) {
|
|
31
|
+
let F = i(), { formatMessage: I } = te(), { addNotification: L } = ee(), R = N.mode === e.Edit, [z, B] = y(!1), [V, H] = y(!1), U = h(() => {
|
|
32
|
+
z ? H(!0) : m?.();
|
|
33
|
+
}, [z, m]);
|
|
34
|
+
_(P, () => ({ requestClose: U }), [U]);
|
|
35
|
+
let W = h((e) => {
|
|
36
|
+
B(e), w?.(e);
|
|
37
|
+
}, [w]), [G, K] = y(R), [q, J] = y(!1), [ae, oe] = y(0), [Y, X] = y(void 0), Z = R ? N.fetchTemplate : void 0, se = () => {
|
|
38
|
+
oe((e) => e + 1);
|
|
38
39
|
};
|
|
39
|
-
|
|
40
|
+
g(() => {
|
|
40
41
|
if (!Z) return;
|
|
41
42
|
let e = !1;
|
|
42
|
-
return
|
|
43
|
+
return K(!0), J(!1), X(void 0), (async () => {
|
|
43
44
|
try {
|
|
44
45
|
let t = await Z();
|
|
45
46
|
e || X(t);
|
|
46
47
|
} catch {
|
|
47
|
-
e ||
|
|
48
|
+
e || J(!0);
|
|
48
49
|
} finally {
|
|
49
|
-
e ||
|
|
50
|
+
e || K(!1);
|
|
50
51
|
}
|
|
51
52
|
})(), () => {
|
|
52
53
|
e = !0;
|
|
53
54
|
};
|
|
54
|
-
}, [Z,
|
|
55
|
+
}, [Z, ae]), g(() => {
|
|
55
56
|
Y !== void 0 && T?.(Y);
|
|
56
57
|
}, [Y, T]);
|
|
57
|
-
let Q =
|
|
58
|
+
let Q = R ? void 0 : N.namespace, $ = v(() => Y ? {
|
|
58
59
|
displayName: Y.displayName,
|
|
59
60
|
templateKey: Y.templateKey,
|
|
60
61
|
namespace: Y.namespace,
|
|
61
62
|
hidden: Y.isHidden,
|
|
62
|
-
fields: Y.fields.map((e) =>
|
|
63
|
+
fields: Y.fields.map((e) => a(e))
|
|
63
64
|
} : {
|
|
64
|
-
...
|
|
65
|
+
...ne,
|
|
65
66
|
namespace: Q ?? ""
|
|
66
|
-
}, [Y, Q])
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
}, [Y, Q]), ce = v(() => ({
|
|
68
|
+
disabledFieldTypes: O,
|
|
69
|
+
taxonomyInitialStateLabels: k
|
|
70
|
+
}), [O, k]);
|
|
71
|
+
return G ? /* @__PURE__ */ f("div", {
|
|
72
|
+
className: C.loading,
|
|
73
|
+
children: /* @__PURE__ */ f(u, {
|
|
70
74
|
size: "large",
|
|
71
|
-
"aria-label":
|
|
75
|
+
"aria-label": I(r.loading)
|
|
72
76
|
})
|
|
73
|
-
}) :
|
|
74
|
-
className:
|
|
75
|
-
children: /* @__PURE__ */ f(
|
|
76
|
-
body: /* @__PURE__ */ f(
|
|
77
|
+
}) : q ? /* @__PURE__ */ f("div", {
|
|
78
|
+
className: C.error,
|
|
79
|
+
children: /* @__PURE__ */ f(l, {
|
|
80
|
+
body: /* @__PURE__ */ f(d, {
|
|
77
81
|
as: "p",
|
|
78
|
-
children:
|
|
82
|
+
children: I(r.fetchError)
|
|
79
83
|
}),
|
|
80
|
-
illustration:
|
|
84
|
+
illustration: S,
|
|
81
85
|
size: "large",
|
|
82
|
-
children: /* @__PURE__ */ f(
|
|
83
|
-
startIcon:
|
|
84
|
-
onClick:
|
|
85
|
-
children:
|
|
86
|
+
children: /* @__PURE__ */ f(l.PrimaryAction, {
|
|
87
|
+
startIcon: b,
|
|
88
|
+
onClick: se,
|
|
89
|
+
children: I(r.reload)
|
|
86
90
|
})
|
|
87
91
|
})
|
|
88
|
-
}) : /* @__PURE__ */
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
92
|
+
}) : /* @__PURE__ */ p(t.Provider, {
|
|
93
|
+
value: ce,
|
|
94
|
+
children: [/* @__PURE__ */ f(x, {
|
|
95
|
+
initialValues: $,
|
|
96
|
+
validationSchema: F,
|
|
97
|
+
onSubmit: async (e) => {
|
|
98
|
+
try {
|
|
99
|
+
if (R) {
|
|
100
|
+
let t = s($, e);
|
|
101
|
+
await N.onEditTemplate(t, {
|
|
102
|
+
namespaceFQN: $.namespace,
|
|
103
|
+
templateKey: $.templateKey
|
|
104
|
+
});
|
|
105
|
+
} else {
|
|
106
|
+
let t = o(e.fields), n = {
|
|
107
|
+
namespace: e.namespace,
|
|
108
|
+
templateKey: e.templateKey,
|
|
109
|
+
displayName: e.displayName,
|
|
110
|
+
hidden: e.hidden,
|
|
111
|
+
fields: t
|
|
112
|
+
};
|
|
113
|
+
await N.onCreateTemplate(n);
|
|
114
|
+
}
|
|
115
|
+
L({
|
|
116
|
+
sensitivity: "foreground",
|
|
117
|
+
variant: "success",
|
|
118
|
+
styledText: I(r.saveSuccessNotification),
|
|
119
|
+
typeIconAriaLabel: I(r.notificationSuccessIconAriaLabel),
|
|
120
|
+
closeButtonAriaLabel: I(r.notificationCloseButtonAriaLabel)
|
|
98
121
|
});
|
|
99
|
-
}
|
|
100
|
-
let t
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
122
|
+
} catch (e) {
|
|
123
|
+
let t;
|
|
124
|
+
if (e instanceof Error && "status" in e) {
|
|
125
|
+
let { status: n } = e;
|
|
126
|
+
t = I(n === 409 ? r.displayNameUsedBefore : r.saveErrorNotification);
|
|
127
|
+
} else t = I(r.saveErrorNotification);
|
|
128
|
+
L({
|
|
129
|
+
sensitivity: "foreground",
|
|
130
|
+
variant: "error",
|
|
131
|
+
styledText: t,
|
|
132
|
+
typeIconAriaLabel: I(r.notificationErrorIconAriaLabel),
|
|
133
|
+
closeButtonAriaLabel: I(r.notificationCloseButtonAriaLabel)
|
|
134
|
+
});
|
|
135
|
+
try {
|
|
136
|
+
ie?.(e);
|
|
137
|
+
} catch {}
|
|
138
|
+
throw e;
|
|
108
139
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
throw e;
|
|
133
|
-
}
|
|
134
|
-
},
|
|
135
|
-
children: /* @__PURE__ */ f(o, {
|
|
136
|
-
formId: O,
|
|
137
|
-
onCancel: V,
|
|
138
|
-
taxonomyOptions: E,
|
|
139
|
-
fetchTaxonomies: D,
|
|
140
|
-
hideActions: k,
|
|
141
|
-
isEditMode: I,
|
|
142
|
-
onDirtyStateChange: H,
|
|
143
|
-
onValidationChange: C,
|
|
144
|
-
fieldExtensions: A
|
|
145
|
-
})
|
|
146
|
-
}), z && /* @__PURE__ */ f(t, {
|
|
147
|
-
onClose: () => B(!1),
|
|
148
|
-
onConfirm: () => {
|
|
149
|
-
B(!1), p?.();
|
|
150
|
-
},
|
|
151
|
-
title: P(n.unsavedChangesTitle),
|
|
152
|
-
body: P(n.unsavedChangesBody),
|
|
153
|
-
confirmLabel: P(n.unsavedChangesDiscard),
|
|
154
|
-
cancelLabel: P(n.unsavedChangesKeepEditing)
|
|
155
|
-
})] });
|
|
140
|
+
},
|
|
141
|
+
children: /* @__PURE__ */ f(c, {
|
|
142
|
+
formId: A,
|
|
143
|
+
onCancel: U,
|
|
144
|
+
taxonomyOptions: E,
|
|
145
|
+
fetchTaxonomies: D,
|
|
146
|
+
hideActions: j,
|
|
147
|
+
isEditMode: R,
|
|
148
|
+
onDirtyStateChange: W,
|
|
149
|
+
onValidationChange: re,
|
|
150
|
+
fieldExtensions: M
|
|
151
|
+
})
|
|
152
|
+
}), V && /* @__PURE__ */ f(n, {
|
|
153
|
+
onClose: () => H(!1),
|
|
154
|
+
onConfirm: () => {
|
|
155
|
+
H(!1), m?.();
|
|
156
|
+
},
|
|
157
|
+
title: I(r.unsavedChangesTitle),
|
|
158
|
+
body: I(r.unsavedChangesBody),
|
|
159
|
+
confirmLabel: I(r.unsavedChangesDiscard),
|
|
160
|
+
cancelLabel: I(r.unsavedChangesKeepEditing)
|
|
161
|
+
})]
|
|
162
|
+
});
|
|
156
163
|
});
|
|
157
|
-
export {
|
|
164
|
+
export { w as t };
|
|
@@ -1,43 +1,44 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import t from "../esm/lib/components/metadata-field-configurator/
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { useEditorConfig as e } from "../esm/lib/components/metadata-field-configurator/context/editor-config-context.js";
|
|
2
|
+
import { useFieldConfigurator as t } from "../esm/lib/components/metadata-field-configurator/context/field-configurator-context.js";
|
|
3
|
+
import n from "../esm/lib/components/metadata-field-configurator/messages/taxonomy-messages.js";
|
|
4
|
+
import { useTaxonomySelect as r } from "../esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/useTaxonomySelect.js";
|
|
5
|
+
import { filterTaxonomiesByValue as i } from "../esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/utils.js";
|
|
6
|
+
import { t as a } from "./taxonomy-selector.js";
|
|
7
|
+
import { Text as o } from "@box/blueprint-web";
|
|
8
|
+
import { FormattedMessage as s } from "react-intl";
|
|
9
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
9
10
|
import "react";
|
|
10
|
-
import '../styles/taxonomy-field-configurator-initial-state.css';var
|
|
11
|
+
import '../styles/taxonomy-field-configurator-initial-state.css';var u = {
|
|
11
12
|
taxonomyFieldConfiguratorInitialState: "_taxonomyFieldConfiguratorInitialState_il5v7_1",
|
|
12
13
|
subheader: "_subheader_il5v7_10"
|
|
13
|
-
},
|
|
14
|
-
let { values:
|
|
15
|
-
values:
|
|
16
|
-
setFieldValue:
|
|
17
|
-
});
|
|
18
|
-
return /* @__PURE__ */
|
|
19
|
-
className:
|
|
14
|
+
}, d = () => {
|
|
15
|
+
let { values: d, setFieldValue: f } = t(), { onTaxonomySelect: p } = r({
|
|
16
|
+
values: d,
|
|
17
|
+
setFieldValue: f
|
|
18
|
+
}), { taxonomyInitialStateLabels: m } = e();
|
|
19
|
+
return /* @__PURE__ */ l("div", {
|
|
20
|
+
className: u.taxonomyFieldConfiguratorInitialState,
|
|
20
21
|
children: [
|
|
21
|
-
/* @__PURE__ */
|
|
22
|
+
/* @__PURE__ */ c(o, {
|
|
22
23
|
as: "h1",
|
|
23
24
|
color: "textOnLightDefault",
|
|
24
25
|
variant: "titleMedium",
|
|
25
|
-
children: /* @__PURE__ */ s
|
|
26
|
+
children: m?.header ?? /* @__PURE__ */ c(s, { ...n.callToActionHeader })
|
|
26
27
|
}),
|
|
27
|
-
/* @__PURE__ */
|
|
28
|
+
/* @__PURE__ */ c(o, {
|
|
28
29
|
as: "p",
|
|
29
|
-
className:
|
|
30
|
+
className: u.subheader,
|
|
30
31
|
color: "textOnLightDefault",
|
|
31
32
|
variant: "bodyDefault",
|
|
32
|
-
children: /* @__PURE__ */ s
|
|
33
|
+
children: m?.subheader ?? /* @__PURE__ */ c(s, { ...n.callToActionSubheader })
|
|
33
34
|
}),
|
|
34
|
-
/* @__PURE__ */
|
|
35
|
-
data:
|
|
36
|
-
onClick:
|
|
35
|
+
/* @__PURE__ */ c(a, {
|
|
36
|
+
data: i(d.taxonomy.availableTaxonomies, d.taxonomy.taxonomySearchValue),
|
|
37
|
+
onClick: p,
|
|
37
38
|
resetValueOnHide: !0,
|
|
38
39
|
onSearchValue: (e) => {
|
|
39
|
-
|
|
40
|
-
...
|
|
40
|
+
f("taxonomy", {
|
|
41
|
+
...d.taxonomy,
|
|
41
42
|
taxonomySearchValue: e
|
|
42
43
|
});
|
|
43
44
|
}
|
|
@@ -45,4 +46,4 @@ import '../styles/taxonomy-field-configurator-initial-state.css';var l = {
|
|
|
45
46
|
]
|
|
46
47
|
});
|
|
47
48
|
};
|
|
48
|
-
export {
|
|
49
|
+
export { d as t };
|
package/dist/esm/index.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
import { t as e } from "../chunks/field-selector.js";
|
|
2
2
|
import { a as t, c as n, i as r, l as i, n as a, o, r as s, s as c, t as l } from "../chunks/types.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
3
|
+
import { EditorConfigContext as u, useEditorConfig as d } from "./lib/components/metadata-field-configurator/context/editor-config-context.js";
|
|
4
|
+
import { t as f } from "../chunks/field-type-dropdown.js";
|
|
5
|
+
import { FieldTypeTiles as p } from "./lib/components/field-type-tiles/field-type-tiles.js";
|
|
6
|
+
import { useTemplateFieldSchema as m } from "./lib/components/metadata-field-configurator/hooks/useTemplateFieldSchema.js";
|
|
7
|
+
import h from "./lib/components/metadata-field-configurator/components/confirmation-modal/confirmation-modal.js";
|
|
8
|
+
import { FieldActionSlot as g } from "./lib/components/metadata-field-configurator/components/field-action-slot/field-action-slot.js";
|
|
9
|
+
import { FieldConfiguratorContext as _, useFieldConfigurator as v } from "./lib/components/metadata-field-configurator/context/field-configurator-context.js";
|
|
10
|
+
import { TaxonomyOptionsContext as y, createStaticTaxonomyContext as b, useTaxonomyOptions as x } from "./lib/components/metadata-field-configurator/context/taxonomy-options-context.js";
|
|
11
|
+
import { t as S } from "../chunks/taxonomy-field-configuration.js";
|
|
12
|
+
import { t as C } from "../chunks/taxonomy-selector.js";
|
|
13
|
+
import { createDefaultFieldValues as w } from "./lib/components/metadata-field-configurator/utils.js";
|
|
14
|
+
import { FieldEditContent as T } from "./lib/components/metadata-field-configurator/components/field-edit-content/field-edit-content.js";
|
|
15
|
+
import { FieldExtensionsContext as E, useFieldExtensions as D } from "./lib/components/metadata-field-configurator/context/field-extensions-context.js";
|
|
16
|
+
import { useFieldConfiguratorBehavior as O } from "./lib/components/metadata-field-configurator/hooks/useFieldConfiguratorBehavior.js";
|
|
17
|
+
import { MetadataFieldConfigurator as k } from "./lib/components/metadata-field-configurator/metadata-field-configurator.js";
|
|
18
|
+
import { t as A } from "../chunks/metadata-field-list.js";
|
|
19
|
+
import { t as j } from "../chunks/metadata-template-editor.js";
|
|
20
|
+
import { t as M } from "../chunks/metadata-template-editor-modal.js";
|
|
18
21
|
import "./lib/components/metadata-template-editor-modal/index.js";
|
|
19
|
-
export { l as AllOps, a as ApiMetadataTemplateFieldType,
|
|
22
|
+
export { l as AllOps, a as ApiMetadataTemplateFieldType, h as ConfirmationModal, u as EditorConfigContext, s as EnumOperations, g as FieldActionSlot, _ as FieldConfiguratorContext, T as FieldEditContent, E as FieldExtensionsContext, r as FieldOperations, e as FieldSelector, t as FieldType, f as FieldTypeDropdown, p as FieldTypeTiles, k as MetadataFieldConfigurator, A as MetadataFieldList, A as MetadataFieldListDefault, j as MetadataTemplateEditor, M as MetadataTemplateEditorModal, o as MetadataTemplateEditorMode, c as MultiSelectOperations, S as TaxonomyFieldConfiguration, y as TaxonomyOptionsContext, n as TaxonomySelection, C as TaxonomySelector, i as TemplateOperations, w as createDefaultFieldValues, b as createStaticTaxonomyContext, d as useEditorConfig, v as useFieldConfigurator, O as useFieldConfiguratorBehavior, D as useFieldExtensions, x as useTaxonomyOptions, m as useTemplateFieldSchema };
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
1
|
+
import { EditorConfigContext as e, useEditorConfig as t } from "./context/editor-config-context.js";
|
|
2
|
+
import { useTemplateFieldSchema as n } from "./hooks/useTemplateFieldSchema.js";
|
|
3
|
+
import r from "./components/confirmation-modal/confirmation-modal.js";
|
|
4
|
+
import { FieldActionSlot as i } from "./components/field-action-slot/field-action-slot.js";
|
|
5
|
+
import { FieldConfiguratorContext as a, useFieldConfigurator as o } from "./context/field-configurator-context.js";
|
|
6
|
+
import { TaxonomyOptionsContext as s, createStaticTaxonomyContext as c, useTaxonomyOptions as l } from "./context/taxonomy-options-context.js";
|
|
7
|
+
import { t as u } from "../../../../chunks/taxonomy-field-configuration.js";
|
|
8
|
+
import { t as d } from "../../../../chunks/taxonomy-selector.js";
|
|
9
|
+
import { createDefaultFieldValues as f } from "./utils.js";
|
|
10
|
+
import { FieldEditContent as p } from "./components/field-edit-content/field-edit-content.js";
|
|
11
|
+
import { FieldExtensionsContext as m, useFieldExtensions as h } from "./context/field-extensions-context.js";
|
|
12
|
+
import { useFieldConfiguratorBehavior as g } from "./hooks/useFieldConfiguratorBehavior.js";
|
|
13
|
+
import { MetadataFieldConfigurator as _ } from "./metadata-field-configurator.js";
|
|
14
|
+
export { r as ConfirmationModal, e as EditorConfigContext, i as FieldActionSlot, a as FieldConfiguratorContext, p as FieldEditContent, m as FieldExtensionsContext, _ as MetadataFieldConfigurator, u as TaxonomyFieldConfiguration, s as TaxonomyOptionsContext, d as TaxonomySelector, f as createDefaultFieldValues, c as createStaticTaxonomyContext, t as useEditorConfig, o as useFieldConfigurator, g as useFieldConfiguratorBehavior, h as useFieldExtensions, l as useTaxonomyOptions, n as useTemplateFieldSchema };
|
package/dist/esm/lib/index.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { EditorConfigContext as e, useEditorConfig as t } from "./components/metadata-field-configurator/context/editor-config-context.js";
|
|
2
|
+
import { useTemplateNameSchema as n } from "./hooks/useTemplateNameSchema.js";
|
|
3
|
+
import { useMetadataTemplateFormSchema as r } from "./hooks/useMetadataTemplateFormSchema.js";
|
|
4
|
+
import { convertApiMetadataTemplateFieldToLocalConfiguratorField as i } from "./utils/template-type-conversion/convertTemplateFieldToLocalConfigurator.js";
|
|
5
|
+
import { mapFieldsWithUniqueKeys as a } from "./utils/template-type-conversion/mapFieldsWithUniqueKeys.js";
|
|
6
|
+
import { generateJSONPatchTemplateOperations as o } from "./utils/template-type-conversion/generateJSONPatchTemplateOperations.js";
|
|
7
|
+
import { t as s } from "../../chunks/metadata-template-editor.js";
|
|
8
|
+
export { e as EditorConfigContext, s as MetadataTemplateEditor, i as convertApiMetadataTemplateFieldToLocalConfiguratorField, o as generateJSONPatchTemplateOperations, a as mapFieldsWithUniqueKeys, t as useEditorConfig, r as useMetadataTemplateFormSchema, n as useTemplateNameSchema };
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { a as e } from "../../../../chunks/types.js";
|
|
2
2
|
import { FieldTypeIcon as t } from "./field-type-icon.js";
|
|
3
3
|
import { fieldTypeDescriptionMessages as n, fieldTypesTitleMessages as r } from "./messages.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { useEditorConfig as i } from "../../components/metadata-field-configurator/context/editor-config-context.js";
|
|
5
|
+
import { useIntl as a } from "react-intl";
|
|
6
|
+
import { useMemo as o } from "react";
|
|
7
|
+
function s() {
|
|
8
|
+
let s = a(), { disabledFieldTypes: c } = i();
|
|
9
|
+
return { availableFieldTypes: o(() => Object.values(e).filter((e) => !c?.includes(e)).map((e) => ({
|
|
9
10
|
type: e,
|
|
10
|
-
label:
|
|
11
|
-
description:
|
|
11
|
+
label: s.formatMessage(r[e]),
|
|
12
|
+
description: s.formatMessage(n[e]),
|
|
12
13
|
Icon: t(e)
|
|
13
|
-
})), [
|
|
14
|
+
})), [s, c]) };
|
|
14
15
|
}
|
|
15
|
-
export {
|
|
16
|
+
export { s as useFieldOptions };
|
package/dist/types/lib/components/metadata-field-configurator/context/editor-config-context.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { FieldType } from '../../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Copy overrides for the taxonomy field's empty (initial) state. Each entry falls back to a
|
|
5
|
+
* built-in localized default when omitted, letting consumers tailor the wording without the
|
|
6
|
+
* library adding a new flag for every text variation.
|
|
7
|
+
*/
|
|
8
|
+
export interface TaxonomyInitialStateLabels {
|
|
9
|
+
header?: ReactNode;
|
|
10
|
+
subheader?: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
export interface EditorConfig {
|
|
13
|
+
disabledFieldTypes?: FieldType[];
|
|
14
|
+
taxonomyInitialStateLabels?: TaxonomyInitialStateLabels;
|
|
15
|
+
}
|
|
16
|
+
export declare const EditorConfigContext: import('react').Context<EditorConfig>;
|
|
17
|
+
export declare const useEditorConfig: () => EditorConfig;
|
|
@@ -6,6 +6,8 @@ export { FieldExtensionsContext, useFieldExtensions } from './context/field-exte
|
|
|
6
6
|
export type { FieldConfiguratorExtension } from './context/field-extensions-context';
|
|
7
7
|
export { FieldConfiguratorContext, useFieldConfigurator } from './context/field-configurator-context';
|
|
8
8
|
export type { FieldConfiguratorContextValue } from './context/field-configurator-context';
|
|
9
|
+
export { EditorConfigContext, useEditorConfig } from './context/editor-config-context';
|
|
10
|
+
export type { EditorConfig, TaxonomyInitialStateLabels } from './context/editor-config-context';
|
|
9
11
|
export { TaxonomyOptionsContext, useTaxonomyOptions, createStaticTaxonomyContext, } from './context/taxonomy-options-context';
|
|
10
12
|
export type { TaxonomyContextValue, TaxonomyFetchStatus } from './context/taxonomy-options-context';
|
|
11
13
|
export { useFieldConfiguratorBehavior } from './hooks/useFieldConfiguratorBehavior';
|
|
@@ -16,3 +18,5 @@ export { FieldActionSlot } from './components/field-action-slot/field-action-slo
|
|
|
16
18
|
export type { FieldActionSlotProps } from './components/field-action-slot/field-action-slot';
|
|
17
19
|
export { default as ConfirmationModal } from './components/confirmation-modal/confirmation-modal';
|
|
18
20
|
export type { ConfirmationModalProps } from './components/confirmation-modal/confirmation-modal';
|
|
21
|
+
export { TaxonomySelector } from './components/type-specific-configuration/taxonomy/taxonomy-selector';
|
|
22
|
+
export { TaxonomyFieldConfiguration } from './components/type-specific-configuration/taxonomy/taxonomy-field-configuration';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MetadataFieldConfiguratorProps } from '../metadata-field-configurator';
|
|
2
|
+
import { TaxonomyInitialStateLabels } from '../metadata-field-configurator/context/editor-config-context';
|
|
2
3
|
import { FieldConfiguratorExtension } from '../metadata-field-configurator/context/field-extensions-context';
|
|
3
|
-
import { FieldData } from '../../types';
|
|
4
|
+
import { FieldData, FieldType } from '../../types';
|
|
4
5
|
/**
|
|
5
6
|
* Imperative handle exposed by `MetadataFieldList` via `forwardRef`.
|
|
6
7
|
* Use it to programmatically scroll to and expand a specific field.
|
|
@@ -34,6 +35,15 @@ export type MetadataFieldListProps = {
|
|
|
34
35
|
* of the list. Mutually exclusive with `taxonomyOptions`.
|
|
35
36
|
*/
|
|
36
37
|
readonly fetchTaxonomies?: MetadataFieldConfiguratorProps['fetchTaxonomies'];
|
|
38
|
+
/**
|
|
39
|
+
* Field types that are disabled/hidden from the field type picker (defaults to none).
|
|
40
|
+
*/
|
|
41
|
+
readonly disabledFieldTypes?: FieldType[];
|
|
42
|
+
/**
|
|
43
|
+
* Copy overrides for the taxonomy field's empty (initial) state. Each entry falls back to a
|
|
44
|
+
* built-in localized default when omitted.
|
|
45
|
+
*/
|
|
46
|
+
readonly taxonomyInitialStateLabels?: TaxonomyInitialStateLabels;
|
|
37
47
|
/**
|
|
38
48
|
* Zero-based index of the first field with validation errors.
|
|
39
49
|
* Combined with `submitAttemptCount` to re-trigger on repeated failed submits.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export { MetadataTemplateEditor } from './metadata-template-editor';
|
|
2
2
|
export type { MetadataTemplateEditorProps } from './metadata-template-editor';
|
|
3
|
+
export { EditorConfigContext, useEditorConfig, } from './components/metadata-field-configurator/context/editor-config-context';
|
|
4
|
+
export type { EditorConfig, TaxonomyInitialStateLabels, } from './components/metadata-field-configurator/context/editor-config-context';
|
|
3
5
|
export { useMetadataTemplateFormSchema } from './hooks/useMetadataTemplateFormSchema';
|
|
4
6
|
export { useTemplateNameSchema } from './hooks/useTemplateNameSchema';
|
|
5
7
|
export { convertApiMetadataTemplateFieldToLocalConfiguratorField } from './utils/template-type-conversion/convertTemplateFieldToLocalConfigurator';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { MetadataTemplateCreateBody, MetadataTemplateEditorMode, MetadataTemplatePatchItem, MetadataTemplateApiResponse } from './types';
|
|
1
|
+
import { FieldType, MetadataTemplateCreateBody, MetadataTemplateEditorMode, MetadataTemplatePatchItem, MetadataTemplateApiResponse } from './types';
|
|
2
2
|
import { MetadataFieldListProps } from './components/metadata-field-list';
|
|
3
3
|
import { FieldConfiguratorExtension } from './components/metadata-field-configurator/context/field-extensions-context';
|
|
4
|
+
import { TaxonomyInitialStateLabels } from './components/metadata-field-configurator/context/editor-config-context';
|
|
4
5
|
type MetadataTemplateEditorCommonProps = {
|
|
5
6
|
/** Called when the user dismisses the form without saving. */
|
|
6
7
|
onCancel?: () => void;
|
|
@@ -109,6 +110,15 @@ type MetadataTemplateEditorCommonProps = {
|
|
|
109
110
|
* ```
|
|
110
111
|
*/
|
|
111
112
|
fetchTaxonomies?: MetadataFieldListProps['fetchTaxonomies'];
|
|
113
|
+
/**
|
|
114
|
+
* Field types that are disabled/hidden from the field type picker (defaults to none).
|
|
115
|
+
*/
|
|
116
|
+
disabledFieldTypes?: FieldType[];
|
|
117
|
+
/**
|
|
118
|
+
* Copy overrides for the taxonomy field's empty (initial) state. Each entry falls back to a
|
|
119
|
+
* built-in localized default when omitted.
|
|
120
|
+
*/
|
|
121
|
+
taxonomyInitialStateLabels?: TaxonomyInitialStateLabels;
|
|
112
122
|
/**
|
|
113
123
|
* HTML `id` applied to the `<form>` element.
|
|
114
124
|
* Useful when submit/cancel buttons are rendered outside the form DOM subtree
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/metadata-template-editor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.26.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"peerDependencies": {
|
|
6
|
-
"@box/blueprint-web": "^
|
|
7
|
-
"@box/blueprint-web-assets": "^4.121.
|
|
6
|
+
"@box/blueprint-web": "^15.1.0",
|
|
7
|
+
"@box/blueprint-web-assets": "^4.121.3",
|
|
8
8
|
"@dnd-kit/core": "^6.1.0",
|
|
9
9
|
"@dnd-kit/sortable": "^8.0.0",
|
|
10
10
|
"@dnd-kit/utilities": "^3.2.2",
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"yup": "^1.6.1"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@box/blueprint-web": "^
|
|
21
|
-
"@box/blueprint-web-assets": "^4.121.
|
|
20
|
+
"@box/blueprint-web": "^15.1.0",
|
|
21
|
+
"@box/blueprint-web-assets": "^4.121.3",
|
|
22
22
|
"@box/eslint-plugin-blueprint": "1.2.4",
|
|
23
|
-
"@box/storybook-utils": "0.20.
|
|
23
|
+
"@box/storybook-utils": "0.20.3",
|
|
24
24
|
"@dnd-kit/core": "^6.1.0",
|
|
25
25
|
"@dnd-kit/sortable": "^8.0.0",
|
|
26
26
|
"@dnd-kit/utilities": "^3.2.2",
|