@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.
Files changed (21) hide show
  1. package/dist/chunks/dropdown-field-configuration.js +1 -1
  2. package/dist/chunks/metadata-field-list.js +158 -132
  3. package/dist/chunks/metadata-template-editor-form.js +98 -74
  4. package/dist/chunks/metadata-template-editor-modal.js +71 -58
  5. package/dist/chunks/metadata-template-editor.js +41 -40
  6. package/dist/chunks/types.js +1 -1
  7. package/dist/esm/lib/components/metadata-field-configurator/components/field-action-slot/field-action-slot.js +9 -9
  8. package/dist/esm/lib/components/metadata-field-configurator/components/field-edit-content/field-edit-content.js +33 -35
  9. package/dist/esm/lib/components/metadata-field-configurator/metadata-field-configurator.js +61 -53
  10. package/dist/esm/lib/messages.js +12 -0
  11. package/dist/styles/metadata-template-editor-form.css +1 -1
  12. package/dist/styles/metadata-template-editor-modal.css +1 -1
  13. package/dist/types/lib/components/metadata-field-configurator/components/field-action-slot/field-action-slot.d.ts +6 -1
  14. package/dist/types/lib/components/metadata-field-configurator/components/field-edit-content/field-edit-content.d.ts +7 -1
  15. package/dist/types/lib/components/metadata-field-configurator/metadata-field-configurator.d.ts +7 -1
  16. package/dist/types/lib/components/metadata-field-list/metadata-field-list.d.ts +6 -0
  17. package/dist/types/lib/components/metadata-template-editor-form/metadata-template-editor-form.d.ts +11 -2
  18. package/dist/types/lib/messages.d.ts +15 -0
  19. package/dist/types/lib/metadata-template-editor.d.ts +18 -1
  20. package/dist/types/lib/types.d.ts +3 -2
  21. package/package.json +1 -1
@@ -40,7 +40,7 @@ import '../styles/dropdown-field-configuration.css';var p = {
40
40
  shouldFocusLastOption: y,
41
41
  onFocusConsumed: D
42
42
  }),
43
- /* @__PURE__ */ s(a, {
43
+ !h.isFieldReadOnly && /* @__PURE__ */ s(a, {
44
44
  className: p.addOptionButton,
45
45
  onClick: E,
46
46
  children: m(t.addOption)
@@ -16,18 +16,18 @@ import x from "clsx";
16
16
  import te from "lodash/cloneDeep";
17
17
  import S from "lodash/uniqueId";
18
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 = {
19
+ import { SortableContext as ce, arrayMove as T, sortableKeyboardCoordinates as le, useSortable as E, verticalListSortingStrategy as ue } from "@dnd-kit/sortable";
20
+ import { CSS as D } from "@dnd-kit/utilities";
21
+ import '../styles/metadata-field-list.css';var O = {
22
22
  fieldList: "_fieldList_18x5c_1",
23
23
  fieldItem: "_fieldItem_18x5c_11",
24
24
  dragging: "_dragging_18x5c_11",
25
25
  accordionRootContainer: "_accordionRootContainer_18x5c_15"
26
- }, ue = 150;
27
- function A(e) {
26
+ }, de = 150;
27
+ function k(e) {
28
28
  return e.id;
29
29
  }
30
- var j = 150, de = class extends C {
30
+ var A = 150, fe = class extends C {
31
31
  static activators = [{
32
32
  eventName: "onKeyDown",
33
33
  handler: (e, t, n) => {
@@ -42,16 +42,16 @@ var j = 150, de = class extends C {
42
42
  }
43
43
  }];
44
44
  };
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 });
45
+ function pe({ field: e, index: t, maxIndex: n, isExpanded: r, onChangeField: i, onDeleteAtIndex: a, onDuplicateAtIndex: o, onReorderFields: s, onRequestExpand: c, submitAttemptCount: u }) {
46
+ let d = k(e), { attributes: p, listeners: m, setNodeRef: h, transform: g, transition: _, isDragging: v } = E({ id: d });
47
47
  return /* @__PURE__ */ f("li", {
48
48
  ref: h,
49
49
  style: {
50
- transform: O.Translate.toString(g),
50
+ transform: D.Translate.toString(g),
51
51
  transition: _
52
52
  },
53
53
  "data-field-id": d,
54
- className: x(k.fieldItem, { [k.dragging]: v }),
54
+ className: x(O.fieldItem, { [O.dragging]: v }),
55
55
  children: /* @__PURE__ */ f(l, {
56
56
  values: e,
57
57
  onValuesChange: i,
@@ -72,183 +72,209 @@ function fe({ field: e, index: t, maxIndex: n, isExpanded: r, onChangeField: i,
72
72
  })
73
73
  });
74
74
  }
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);
75
+ var j = /*#__PURE__*/ m(function({ fields: m, onChangeFields: x, onDeleteFieldAtIndex: C, onDuplicateField: E, taxonomyOptions: D, fetchTaxonomies: j, disabledFieldTypes: M, taxonomyInitialStateLabels: N, firstInvalidFieldIndex: P, submitAttemptCount: F, fieldExtensions: I, onValidationChange: L, readOnly: R = !1 }, me) {
76
+ let { formatMessage: he } = d(), z = r(), ge = c(j, D), B = y(null), V = y(null), H = y(new Set(m.map((e) => k(e)))), U = a(), W = y(null);
77
77
  g(() => {
78
- G.current = null;
78
+ W.current = null;
79
79
  }, [L]), g(() => {
80
80
  if (!L) return;
81
81
  let e = !1, t = setTimeout(() => {
82
- ee.array().of(W).validate(l, { abortEarly: !0 }).then(() => {
83
- e || G.current === !0 || (G.current = !0, L(!0));
82
+ ee.array().of(U).validate(m, { abortEarly: !0 }).then(() => {
83
+ e || W.current === !0 || (W.current = !0, L(!0));
84
84
  }).catch(() => {
85
- e || G.current === !1 || (G.current = !1, L(!1));
85
+ e || W.current === !1 || (W.current = !1, L(!1));
86
86
  });
87
- }, ue);
87
+ }, de);
88
88
  return () => {
89
89
  e = !0, clearTimeout(t);
90
90
  };
91
91
  }, [
92
- l,
93
- W,
92
+ m,
93
+ U,
94
94
  L
95
95
  ]);
96
- let [K, q] = b(() => {
97
- let e = l.find((e) => e.isFieldNew);
98
- return e ? A(e) : null;
96
+ let [G, K] = b(() => {
97
+ let e = m.find((e) => e.isFieldNew);
98
+ return e ? k(e) : null;
99
99
  });
100
- _(R, () => ({ scrollToAndExpand(e) {
101
- H.current = e, K === e ? (H.current = null, setTimeout(() => {
102
- (V.current?.querySelector(`[data-field-id="${e}"]`))?.scrollIntoView({
100
+ _(me, () => ({ scrollToAndExpand(e) {
101
+ V.current = e, G === e ? (V.current = null, setTimeout(() => {
102
+ (B.current?.querySelector(`[data-field-id="${e}"]`))?.scrollIntoView({
103
103
  behavior: "smooth",
104
104
  block: "nearest"
105
105
  });
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));
106
+ }, 0)) : K(e);
107
+ } }), [G]), g(() => {
108
+ m.forEach((e) => {
109
+ let t = k(e);
110
+ H.current.has(t) || (H.current.add(t), V.current = t, K(t));
111
111
  });
112
- }, [l]), g(() => {
112
+ }, [m]), g(() => {
113
113
  if (P == null || !F) return;
114
- let e = l[P];
114
+ let e = m[P];
115
115
  if (!e) return;
116
- let t = A(e);
117
- q(t), requestAnimationFrame(() => {
118
- (V.current?.querySelector(`[data-field-id="${t}"]`))?.scrollIntoView({
116
+ let t = k(e);
117
+ K(t), requestAnimationFrame(() => {
118
+ (B.current?.querySelector(`[data-field-id="${t}"]`))?.scrollIntoView({
119
119
  behavior: "smooth",
120
120
  block: "nearest"
121
121
  });
122
122
  });
123
123
  }, [F]), g(() => {
124
- let e = H.current;
125
- if (!e || e !== K) return;
126
- H.current = null;
124
+ let e = V.current;
125
+ if (!e || e !== G) return;
126
+ V.current = null;
127
127
  let t = setTimeout(() => {
128
- (V.current?.querySelector(`[data-field-id="${e}"]`))?.scrollIntoView({
128
+ (B.current?.querySelector(`[data-field-id="${e}"]`))?.scrollIntoView({
129
129
  behavior: "smooth",
130
130
  block: "nearest"
131
131
  });
132
- }, j);
132
+ }, A);
133
133
  return () => clearTimeout(t);
134
- }, [K]);
135
- let [J, Y] = b(null), me = se(w(ie, { activationConstraint: { distance: 8 } }), w(ae, { activationConstraint: {
134
+ }, [G]);
135
+ let [q, J] = b(null), _e = se(w(ie, { activationConstraint: { distance: 8 } }), w(ae, { activationConstraint: {
136
136
  delay: 250,
137
137
  tolerance: 5
138
- } }), w(de, { coordinateGetter: le })), he = h((e) => {
139
- Y(String(e.active.id));
140
- }, []), ge = h((e) => {
141
- Y(null);
138
+ } }), w(fe, { coordinateGetter: le })), ve = h((e) => {
139
+ J(String(e.active.id));
140
+ }, []), ye = h((e) => {
141
+ J(null);
142
142
  let { active: t, over: n } = e;
143
143
  if (n && t.id !== n.id) {
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));
144
+ let e = m.findIndex((e) => k(e) === t.id), r = m.findIndex((e) => k(e) === n.id);
145
+ e !== -1 && r !== -1 && x?.(T(m, e, r));
146
146
  }
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);
147
+ }, [m, x]), be = h(() => {
148
+ J(null);
149
+ }, []), xe = h((e, t) => {
150
+ x?.(m.map((n, r) => r === e ? t : n));
151
+ }, [m, x]), Se = h((e) => {
152
+ let t = m[e], n = k(t);
153
+ K((e) => e === n ? null : e), x?.(m.filter((t, n) => n !== e)), C?.(e, t);
154
154
  }, [
155
- l,
156
155
  m,
157
- x
158
- ]), X = h((t) => {
159
- let n = l[t], r = te(n);
156
+ x,
157
+ C
158
+ ]), Ce = h((t) => {
159
+ let n = m[t], r = te(n);
160
160
  r.id = S("field-"), r.key = "", r.isFieldNew = !0, r.type === e.Dropdown && (r.dropdown.options = r.dropdown.options.map((e) => ({
161
161
  ...e,
162
162
  id: S()
163
163
  })));
164
- let i = [...l];
165
- i.splice(t + 1, 0, r), m?.(i), C?.(r);
164
+ let i = [...m];
165
+ i.splice(t + 1, 0, r), x?.(i), E?.(r);
166
166
  }, [
167
- l,
168
167
  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) => {
168
+ x,
169
+ E
170
+ ]), we = h((e, t) => {
171
+ t < 0 || t >= m.length || x?.(T(m, e, t));
172
+ }, [m, x]), Y = h((e) => {
173
173
  let t = e || null;
174
- q(t), t && setTimeout(() => {
175
- (V.current?.querySelector(`[data-field-id="${t}"]`))?.scrollIntoView({
174
+ K(t), t && setTimeout(() => {
175
+ (B.current?.querySelector(`[data-field-id="${t}"]`))?.scrollIntoView({
176
176
  behavior: "smooth",
177
177
  block: "nearest"
178
178
  });
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);
179
+ }, A);
180
+ }, []), Te = m.map((e) => k(e)), X = q ? m.find((e) => k(e) === q) : null, Z = X ? t(X.type) : null, Ee = X ? ((t) => {
181
+ let n = t.name || he(i.fieldNameInputPlaceholder);
182
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
183
+ })(X) : "", De = v(() => ({
184
+ disabledFieldTypes: M ?? z.disabledFieldTypes,
185
+ taxonomyInitialStateLabels: N ?? z.taxonomyInitialStateLabels
186
186
  }), [
187
187
  M,
188
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
- })
228
- })
229
- })
230
- })
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
- })]
189
+ z
190
+ ]), Oe = R ? /* @__PURE__ */ f("ul", {
191
+ ref: B,
192
+ className: O.fieldList,
193
+ children: m.map((e, t) => {
194
+ let n = k(e);
195
+ return /* @__PURE__ */ f("li", {
196
+ "data-field-id": n,
197
+ className: O.fieldItem,
198
+ children: /* @__PURE__ */ f(l, {
199
+ values: e,
200
+ onValuesChange: () => void 0,
201
+ index: t,
202
+ maxIndex: m.length - 1,
203
+ onDuplicate: () => void 0,
204
+ onReorderFields: () => void 0,
205
+ onDragStart: () => void 0,
206
+ onDragEnd: () => void 0,
207
+ onTouchStart: () => void 0,
208
+ isExpanded: G === n,
209
+ onExpandedChange: (e) => {
210
+ e && K(n);
211
+ },
212
+ readOnly: !0
213
+ })
214
+ }, n);
215
+ })
216
+ }) : /* @__PURE__ */ f(ce, {
217
+ items: Te,
218
+ strategy: ue,
219
+ children: /* @__PURE__ */ f("ul", {
220
+ ref: B,
221
+ className: O.fieldList,
222
+ children: m.map((e, t) => {
223
+ let n = k(e);
224
+ return /* @__PURE__ */ f(pe, {
225
+ field: e,
226
+ index: t,
227
+ maxIndex: m.length - 1,
228
+ isExpanded: G === n,
229
+ onChangeField: (e) => xe(t, e),
230
+ onDeleteAtIndex: Se,
231
+ onDuplicateAtIndex: Ce,
232
+ onReorderFields: we,
233
+ onRequestExpand: () => K(n),
234
+ submitAttemptCount: F
235
+ }, n);
246
236
  })
247
237
  })
238
+ }), Q = /* @__PURE__ */ f("div", {
239
+ className: O.accordionRootContainer,
240
+ children: /* @__PURE__ */ f(u, {
241
+ type: "single",
242
+ collapsible: !0,
243
+ value: G ?? "",
244
+ onValueChange: Y,
245
+ children: Oe
246
+ })
247
+ }), ke = R ? Q : /* @__PURE__ */ p(ne, {
248
+ sensors: _e,
249
+ collisionDetection: oe,
250
+ onDragStart: ve,
251
+ onDragEnd: ye,
252
+ onDragCancel: be,
253
+ children: [Q, /* @__PURE__ */ f(re, {
254
+ dropAnimation: null,
255
+ children: X && Z ? /* @__PURE__ */ f(u, {
256
+ type: "single",
257
+ children: /* @__PURE__ */ f(u.Item, {
258
+ value: "ghost",
259
+ title: Ee,
260
+ startElement: /* @__PURE__ */ f(Z, {
261
+ fontSize: "20px",
262
+ role: "presentation"
263
+ }),
264
+ children: null
265
+ })
266
+ }) : null
267
+ })]
268
+ }), $ = /* @__PURE__ */ f(n.Provider, {
269
+ value: De,
270
+ children: /* @__PURE__ */ f(o.Provider, {
271
+ value: ge,
272
+ children: ke
273
+ })
248
274
  });
249
275
  return I === void 0 ? $ : /* @__PURE__ */ f(s.Provider, {
250
276
  value: I,
251
277
  children: $
252
278
  });
253
279
  });
254
- export { M as t };
280
+ export { j as t };
@@ -1,107 +1,131 @@
1
1
  import { t as e } from "./field-selector.js";
2
2
  import { t } from "./field-type-dropdown.js";
3
- import { FieldTypeTiles as n } from "../esm/lib/components/field-type-tiles/field-type-tiles.js";
4
- import { createDefaultFieldValues as r } from "../esm/lib/components/metadata-field-configurator/utils.js";
5
- import { FieldExtensionsContext as i } from "../esm/lib/components/metadata-field-configurator/context/field-extensions-context.js";
6
- import { t as a } from "./metadata-field-list.js";
7
- import o from "../esm/lib/messages.js";
8
- import { Button as s, Link as c, Text as l, TextInput as u } from "@box/blueprint-web";
3
+ import { FieldTypeTiles as ee } from "../esm/lib/components/field-type-tiles/field-type-tiles.js";
4
+ import { createDefaultFieldValues as n } from "../esm/lib/components/metadata-field-configurator/utils.js";
5
+ import { FieldExtensionsContext as r } from "../esm/lib/components/metadata-field-configurator/context/field-extensions-context.js";
6
+ import { t as i } from "./metadata-field-list.js";
7
+ import a from "../esm/lib/messages.js";
8
+ import { Button as o, EmptyState as s, Link as c, Text as l, TextInput as u } from "@box/blueprint-web";
9
9
  import { FormattedMessage as d, useIntl as f } from "react-intl";
10
10
  import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
11
11
  import { useEffect as g, useMemo as _, useRef as v } from "react";
12
+ import te from "clsx";
12
13
  import { Form as y, useFormikContext as b } from "formik";
13
- import '../styles/metadata-template-editor-form.css';var x = {
14
- form: "_form_8cb30_1",
15
- loading: "_loading_8cb30_8",
16
- fields: "_fields_8cb30_15",
17
- actions: "_actions_8cb30_21",
18
- fieldsHeader: "_fieldsHeader_8cb30_28"
19
- }, S = "bodyDefaultBold", C = "h2", w = "https://developer.box.com/guides/metadata/fields/", T = ({ formId: T, onCancel: E, taxonomyOptions: D, fetchTaxonomies: O, hideActions: k, isEditMode: A, onDirtyStateChange: j, onValidationChange: M, fieldExtensions: N }) => {
20
- let P = f(), { errors: F, values: I, setFieldValue: L, isSubmitting: R, isValid: z, touched: B, handleChange: V, handleBlur: H, submitCount: U, dirty: W } = b(), G = v(null), K = _(() => {
21
- if (!Array.isArray(F.fields)) return null;
22
- let e = F.fields.findIndex(Boolean);
14
+ import { NoTemplates as x } from "@box/blueprint-web-assets/illustrations/Medium";
15
+ import '../styles/metadata-template-editor-form.css';var S = {
16
+ form: "_form_1f0e7_1",
17
+ loading: "_loading_1f0e7_10",
18
+ fields: "_fields_1f0e7_17",
19
+ emptyFields: "_emptyFields_1f0e7_23",
20
+ actions: "_actions_1f0e7_28",
21
+ fieldsHeader: "_fieldsHeader_1f0e7_35"
22
+ }, C = "bodyDefaultBold", w = "h2", T = "https://developer.box.com/guides/metadata/fields/", E = ({ formId: E, onCancel: D, taxonomyOptions: O, fetchTaxonomies: k, hideActions: A, isEditMode: j, readOnly: M = !1, onDirtyStateChange: N, onValidationChange: P, fieldExtensions: F }) => {
23
+ let I = f(), { errors: L, values: R, setFieldValue: z, isSubmitting: B, isValid: V, touched: H, handleChange: U, handleBlur: W, submitCount: G, dirty: K } = b(), q = v(null), J = _(() => {
24
+ if (!Array.isArray(L.fields)) return null;
25
+ let e = L.fields.findIndex(Boolean);
23
26
  return e >= 0 ? e : null;
24
- }, [F.fields]), q = (e) => {
25
- let t = r(e.type);
26
- L("fields", [...I.fields, t]);
27
- }, J = (e) => {
28
- L("fields", e);
27
+ }, [L.fields]), Y = (e) => {
28
+ let t = n(e.type);
29
+ z("fields", [...R.fields, t]);
30
+ }, X = (e) => {
31
+ z("fields", e);
29
32
  };
30
33
  g(() => {
31
- j?.(W);
32
- }, [W, j]), g(() => {
33
- M?.(z);
34
- }, [z, M]);
35
- let Y = R || A && !W, X = /* @__PURE__ */ h(y, {
34
+ N?.(K);
35
+ }, [K, N]), g(() => {
36
+ P?.(V);
37
+ }, [V, P]);
38
+ let Z = B || j && !K, Q;
39
+ Q = M && R.fields.length === 0 ? /* @__PURE__ */ m(s, {
40
+ size: "large",
41
+ illustration: x,
42
+ body: /* @__PURE__ */ m(l, {
43
+ as: "p",
44
+ children: I.formatMessage(a.noFields)
45
+ })
46
+ }) : M ? /* @__PURE__ */ m(i, {
47
+ ref: q,
48
+ fields: R.fields,
49
+ taxonomyOptions: O,
50
+ fetchTaxonomies: k,
51
+ readOnly: !0
52
+ }) : R.fields.length === 0 ? /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(ee, { onFieldAdd: Y }), /* @__PURE__ */ m(c, {
53
+ isExternal: !0,
54
+ className: S.fieldsLearnMoreLink,
55
+ href: T,
56
+ target: "_blank",
57
+ children: /* @__PURE__ */ m(d, { ...a.fieldsLearnMore })
58
+ })] }) : /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(i, {
59
+ ref: q,
60
+ fields: R.fields,
61
+ taxonomyOptions: O,
62
+ fetchTaxonomies: k,
63
+ onChangeFields: X,
64
+ firstInvalidFieldIndex: J,
65
+ submitAttemptCount: G
66
+ }), /* @__PURE__ */ m(t, { onFieldAdd: Y })] });
67
+ let $ = /* @__PURE__ */ h(y, {
36
68
  noValidate: !0,
37
- id: T,
38
- className: x.form,
69
+ id: E,
70
+ className: S.form,
39
71
  children: [
40
72
  /* @__PURE__ */ m("div", {
41
- className: x.templateInfo,
73
+ className: S.templateInfo,
42
74
  children: /* @__PURE__ */ m(u, {
43
75
  name: "displayName",
44
- label: P.formatMessage(o.templateName),
45
- placeholder: P.formatMessage(o.templateNameDescription),
46
- value: I.displayName,
47
- error: B.displayName && F.displayName ? F.displayName : void 0,
76
+ label: I.formatMessage(a.templateName),
77
+ placeholder: I.formatMessage(a.templateNameDescription),
78
+ value: R.displayName,
79
+ error: !M && H.displayName && L.displayName ? L.displayName : void 0,
48
80
  onChange: (e) => {
49
- V(e);
81
+ U(e);
50
82
  },
51
- onBlur: H
83
+ onBlur: W,
84
+ readOnly: M
52
85
  })
53
86
  }),
54
87
  /* @__PURE__ */ h("div", {
55
- className: x.fieldsHeader,
88
+ className: S.fieldsHeader,
56
89
  children: [/* @__PURE__ */ m(l, {
57
- as: C,
58
- variant: S,
59
- children: /* @__PURE__ */ m(d, { ...I.fields.length === 0 ? o.fieldsAddFirst : o.fields })
60
- }), I.fields.length > 0 && /* @__PURE__ */ m(e, {
61
- fields: I.fields,
62
- onSelect: (e) => G.current?.scrollToAndExpand(e)
90
+ as: w,
91
+ variant: C,
92
+ children: /* @__PURE__ */ m(d, { ...!M && R.fields.length === 0 ? a.fieldsAddFirst : a.fields })
93
+ }), R.fields.length > 0 && /* @__PURE__ */ m(e, {
94
+ fields: R.fields,
95
+ onSelect: (e) => q.current?.scrollToAndExpand(e)
63
96
  })]
64
97
  }),
65
98
  /* @__PURE__ */ m("div", {
66
- className: x.fields,
67
- children: I.fields.length === 0 ? /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(n, { onFieldAdd: q }), /* @__PURE__ */ m(c, {
68
- isExternal: !0,
69
- className: x.fieldsLearnMoreLink,
70
- href: w,
71
- target: "_blank",
72
- children: /* @__PURE__ */ m(d, { ...o.fieldsLearnMore })
73
- })] }) : /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(a, {
74
- ref: G,
75
- fields: I.fields,
76
- taxonomyOptions: D,
77
- fetchTaxonomies: O,
78
- onChangeFields: J,
79
- firstInvalidFieldIndex: K,
80
- submitAttemptCount: U
81
- }), /* @__PURE__ */ m(t, { onFieldAdd: q })] })
99
+ className: te(S.fields, { [S.emptyFields]: R.fields.length === 0 && M }),
100
+ children: Q
82
101
  }),
83
- !k && /* @__PURE__ */ h("div", {
84
- className: x.actions,
85
- children: [E && /* @__PURE__ */ m(s, {
102
+ !A && /* @__PURE__ */ m("div", {
103
+ className: S.actions,
104
+ children: M ? D && /* @__PURE__ */ m(o, {
105
+ variant: "primary",
106
+ type: "button",
107
+ onClick: D,
108
+ children: I.formatMessage(a.close)
109
+ }) : /* @__PURE__ */ h(p, { children: [D && /* @__PURE__ */ m(o, {
86
110
  variant: "secondary",
87
111
  type: "button",
88
- onClick: E,
89
- loading: R,
90
- disabled: R,
91
- loadingAriaLabel: P.formatMessage(o.submitting),
92
- children: P.formatMessage(o.cancel)
93
- }), /* @__PURE__ */ m(s, {
112
+ onClick: D,
113
+ loading: B,
114
+ disabled: B,
115
+ loadingAriaLabel: I.formatMessage(a.submitting),
116
+ children: I.formatMessage(a.cancel)
117
+ }), /* @__PURE__ */ m(o, {
94
118
  variant: "primary",
95
119
  type: "submit",
96
- disabled: Y,
97
- children: P.formatMessage(o.save)
98
- })]
120
+ disabled: Z,
121
+ children: I.formatMessage(a.save)
122
+ })] })
99
123
  })
100
124
  ]
101
125
  });
102
- return N === void 0 ? X : /* @__PURE__ */ m(i.Provider, {
103
- value: N,
104
- children: X
126
+ return F === void 0 ? $ : /* @__PURE__ */ m(r.Provider, {
127
+ value: F,
128
+ children: $
105
129
  });
106
130
  };
107
- export { T as t };
131
+ export { E as t };