@box/metadata-template-editor 1.25.1 → 1.26.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.
@@ -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 { general as n } from "../esm/lib/components/metadata-field-configurator/messages/configurator-messages.js";
4
- import { useTemplateFieldSchema as r } from "../esm/lib/components/metadata-field-configurator/hooks/useTemplateFieldSchema.js";
5
- import { TaxonomyOptionsContext as i } from "../esm/lib/components/metadata-field-configurator/context/taxonomy-options-context.js";
6
- import { FieldExtensionsContext as a } from "../esm/lib/components/metadata-field-configurator/context/field-extensions-context.js";
7
- import { useTaxonomyFetch as o } from "../esm/lib/components/metadata-field-configurator/hooks/useTaxonomyFetch.js";
8
- import { MetadataFieldConfigurator as s } from "../esm/lib/components/metadata-field-configurator/metadata-field-configurator.js";
9
- import { Accordion as c } from "@box/blueprint-web";
10
- import { useIntl as l } from "react-intl";
11
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
12
- import { forwardRef as f, useCallback as p, useEffect as m, useImperativeHandle as h, useRef as g, useState as _ } from "react";
13
- import * as v from "yup";
14
- import y from "clsx";
15
- import ee from "lodash/cloneDeep";
16
- import b from "lodash/uniqueId";
17
- import { DndContext as te, DragOverlay as x, KeyboardSensor as S, PointerSensor as ne, TouchSensor as C, closestCenter as re, useSensor as w, useSensors as T } from "@dnd-kit/core";
18
- import { SortableContext as E, arrayMove as D, sortableKeyboardCoordinates as ie, useSortable as O, verticalListSortingStrategy as ae } from "@dnd-kit/sortable";
19
- import { CSS as k } from "@dnd-kit/utilities";
20
- import '../styles/metadata-field-list.css';var A = {
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
- }, j = 150;
26
- function M(e) {
26
+ }, ue = 150;
27
+ function A(e) {
27
28
  return e.id;
28
29
  }
29
- var N = 150, P = class extends S {
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 : S.activators[0].handler(e, t, n);
41
+ ].includes(r.tagName) ? !1 : C.activators[0].handler(e, t, n);
41
42
  }
42
43
  }];
43
44
  };
44
- function oe({ field: e, index: t, maxIndex: n, isExpanded: r, onChangeField: i, onDeleteAtIndex: a, onDuplicateAtIndex: o, onReorderFields: c, onRequestExpand: l, submitAttemptCount: d }) {
45
- let f = M(e), { attributes: p, listeners: m, setNodeRef: h, transform: g, transition: _, isDragging: v } = O({ id: f });
46
- return /* @__PURE__ */ u("li", {
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: k.Translate.toString(g),
50
+ transform: O.Translate.toString(g),
50
51
  transition: _
51
52
  },
52
- "data-field-id": f,
53
- className: y(A.fieldItem, { [A.dragging]: v }),
54
- children: /* @__PURE__ */ u(s, {
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: c,
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 && l();
69
+ e && c();
69
70
  },
70
- submitAttemptCount: d
71
+ submitAttemptCount: u
71
72
  })
72
73
  });
73
74
  }
74
- var F = /* @__PURE__ */ f(function({ fields: s, onChangeFields: f, onDeleteFieldAtIndex: y, onDuplicateField: S, taxonomyOptions: O, fetchTaxonomies: k, firstInvalidFieldIndex: F, submitAttemptCount: I, fieldExtensions: L, onValidationChange: R }, z) {
75
- let { formatMessage: B } = l(), V = o(k, O), H = g(null), U = g(null), W = g(new Set(s.map((e) => M(e)))), G = r(), K = g(null);
76
- m(() => {
77
- K.current = null;
78
- }, [R]), m(() => {
79
- if (!R) return;
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
- v.array().of(G).validate(s, { abortEarly: !0 }).then(() => {
82
- e || K.current === !0 || (K.current = !0, R(!0));
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 || K.current === !1 || (K.current = !1, R(!1));
85
+ e || G.current === !1 || (G.current = !1, L(!1));
85
86
  });
86
- }, j);
87
+ }, ue);
87
88
  return () => {
88
89
  e = !0, clearTimeout(t);
89
90
  };
90
91
  }, [
91
- s,
92
- G,
93
- R
92
+ l,
93
+ W,
94
+ L
94
95
  ]);
95
- let [q, J] = _(() => {
96
- let e = s.find((e) => e.isFieldNew);
97
- return e ? M(e) : null;
96
+ let [K, q] = b(() => {
97
+ let e = l.find((e) => e.isFieldNew);
98
+ return e ? A(e) : null;
98
99
  });
99
- h(z, () => ({ scrollToAndExpand(e) {
100
- U.current = e, q === e ? (U.current = null, setTimeout(() => {
101
- (H.current?.querySelector(`[data-field-id="${e}"]`))?.scrollIntoView({
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)) : J(e);
106
- } }), [q]), m(() => {
107
- s.forEach((e) => {
108
- let t = M(e);
109
- W.current.has(t) || (W.current.add(t), U.current = t, J(t));
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
- }, [s]), m(() => {
112
- if (F == null || !I) return;
113
- let e = s[F];
112
+ }, [l]), g(() => {
113
+ if (P == null || !F) return;
114
+ let e = l[P];
114
115
  if (!e) return;
115
- let t = M(e);
116
- J(t), requestAnimationFrame(() => {
117
- (H.current?.querySelector(`[data-field-id="${t}"]`))?.scrollIntoView({
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
- }, [I]), m(() => {
123
- let e = U.current;
124
- if (!e || e !== q) return;
125
- U.current = null;
123
+ }, [F]), g(() => {
124
+ let e = H.current;
125
+ if (!e || e !== K) return;
126
+ H.current = null;
126
127
  let t = setTimeout(() => {
127
- (H.current?.querySelector(`[data-field-id="${e}"]`))?.scrollIntoView({
128
+ (V.current?.querySelector(`[data-field-id="${e}"]`))?.scrollIntoView({
128
129
  behavior: "smooth",
129
130
  block: "nearest"
130
131
  });
131
- }, N);
132
+ }, j);
132
133
  return () => clearTimeout(t);
133
- }, [q]);
134
- let [Y, X] = _(null), se = T(w(ne, { activationConstraint: { distance: 8 } }), w(C, { activationConstraint: {
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(P, { coordinateGetter: ie })), ce = p((e) => {
138
- X(String(e.active.id));
139
- }, []), le = p((e) => {
140
- X(null);
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 = s.findIndex((e) => M(e) === t.id), r = s.findIndex((e) => M(e) === n.id);
144
- e !== -1 && r !== -1 && f?.(D(s, e, r));
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
- }, [s, f]), ue = p(() => {
147
- X(null);
148
- }, []), de = p((e, t) => {
149
- f?.(s.map((n, r) => r === e ? t : n));
150
- }, [s, f]), fe = p((e) => {
151
- let t = s[e], n = M(t);
152
- J((e) => e === n ? null : e), f?.(s.filter((t, n) => n !== e)), y?.(e, t);
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
- s,
155
- f,
156
- y
157
- ]), pe = p((t) => {
158
- let n = s[t], r = ee(n);
159
- r.id = b("field-"), r.key = "", r.isFieldNew = !0, r.type === e.Dropdown && (r.dropdown.options = r.dropdown.options.map((e) => ({
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: b()
162
+ id: S()
162
163
  })));
163
- let i = [...s];
164
- i.splice(t + 1, 0, r), f?.(i), S?.(r);
164
+ let i = [...l];
165
+ i.splice(t + 1, 0, r), m?.(i), C?.(r);
165
166
  }, [
166
- s,
167
- f,
168
- S
169
- ]), me = p((e, t) => {
170
- t < 0 || t >= s.length || f?.(D(s, e, t));
171
- }, [s, f]), he = p((e) => {
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
- J(t), t && setTimeout(() => {
174
- (H.current?.querySelector(`[data-field-id="${t}"]`))?.scrollIntoView({
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
- }, N);
179
- }, []), ge = s.map((e) => M(e)), Z = Y ? s.find((e) => M(e) === Y) : null, Q = Z ? t(Z.type) : null, _e = Z ? ((t) => {
180
- let r = t.name || B(n.fieldNameInputPlaceholder);
181
- return t.type === e.Dropdown ? `${r} (${t.dropdown?.options?.length ?? 0})` : r;
182
- })(Z) : "", $ = /* @__PURE__ */ u(i.Provider, {
183
- value: V,
184
- children: /* @__PURE__ */ d(te, {
185
- sensors: se,
186
- collisionDetection: re,
187
- onDragStart: ce,
188
- onDragEnd: le,
189
- onDragCancel: ue,
190
- children: [/* @__PURE__ */ u("div", {
191
- className: A.accordionRootContainer,
192
- children: /* @__PURE__ */ u(c, {
193
- type: "single",
194
- collapsible: !0,
195
- value: q ?? "",
196
- onValueChange: he,
197
- children: /* @__PURE__ */ u(E, {
198
- items: ge,
199
- strategy: ae,
200
- children: /* @__PURE__ */ u("ul", {
201
- ref: H,
202
- className: A.fieldList,
203
- children: s.map((e, t) => {
204
- let n = M(e);
205
- return /* @__PURE__ */ u(oe, {
206
- field: e,
207
- index: t,
208
- maxIndex: s.length - 1,
209
- isExpanded: q === n,
210
- onChangeField: (e) => de(t, e),
211
- onDeleteAtIndex: fe,
212
- onDuplicateAtIndex: pe,
213
- onReorderFields: me,
214
- onRequestExpand: () => J(n),
215
- submitAttemptCount: I
216
- }, n);
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
- }), /* @__PURE__ */ u(x, {
222
- dropAnimation: null,
223
- children: Z && Q ? /* @__PURE__ */ u(c, {
224
- type: "single",
225
- children: /* @__PURE__ */ u(c.Item, {
226
- value: "ghost",
227
- title: _e,
228
- startElement: /* @__PURE__ */ u(Q, {
229
- fontSize: "20px",
230
- role: "presentation"
231
- }),
232
- children: null
233
- })
234
- }) : null
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 L === void 0 ? $ : /* @__PURE__ */ u(a.Provider, {
239
- value: L,
249
+ return I === void 0 ? $ : /* @__PURE__ */ f(s.Provider, {
250
+ value: I,
240
251
  children: $
241
252
  });
242
253
  });
243
- export { F as t };
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 t from "../esm/lib/components/metadata-field-configurator/components/confirmation-modal/confirmation-modal.js";
4
- import n from "../esm/lib/messages.js";
5
- import { useMetadataTemplateFormSchema as r } from "../esm/lib/hooks/useMetadataTemplateFormSchema.js";
6
- import { convertApiMetadataTemplateFieldToLocalConfiguratorField as i } from "../esm/lib/utils/template-type-conversion/convertTemplateFieldToLocalConfigurator.js";
7
- import { mapFieldsWithUniqueKeys as a } from "../esm/lib/utils/template-type-conversion/mapFieldsWithUniqueKeys.js";
8
- import { generateJSONPatchTemplateOperations as ee } from "../esm/lib/utils/template-type-conversion/generateJSONPatchTemplateOperations.js";
9
- import { t as o } from "./metadata-template-editor-form.js";
10
- import { EmptyState as s, LoadingIndicator as c, Text as l, useNotification as u } from "@box/blueprint-web";
11
- import { useIntl as d } from "react-intl";
12
- import { Fragment as te, jsx as f, jsxs as ne } from "react/jsx-runtime";
13
- import { forwardRef as p, useCallback as m, useEffect as h, useImperativeHandle as re, useMemo as g, useState as _ } from "react";
14
- import { ArrowsRotating as v } from "@box/blueprint-web-assets/icons/Line";
15
- import { Formik as y } from "formik";
16
- import { ErrorState404 as b } from "@box/blueprint-web-assets/illustrations/Medium";
17
- import '../styles/metadata-template-editor.css';var x = {
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
- }, ie = {
25
+ }, ne = {
25
26
  displayName: "",
26
27
  templateKey: "",
27
28
  fields: [],
28
29
  hidden: !1
29
- }, S = /* @__PURE__ */ p(function({ onCancel: p, onDirtyStateChange: S, onValidationChange: C, onSubmitError: w, onTemplateLoad: T, taxonomyOptions: E, fetchTaxonomies: D, formId: O, hideActions: k = !1, fieldExtensions: A, ...j }, M) {
30
- let N = r(), { formatMessage: P } = d(), { addNotification: F } = u(), I = j.mode === e.Edit, [L, R] = _(!1), [z, B] = _(!1), V = m(() => {
31
- L ? B(!0) : p?.();
32
- }, [L, p]);
33
- re(M, () => ({ requestClose: V }), [V]);
34
- let H = m((e) => {
35
- R(e), S?.(e);
36
- }, [S]), [U, W] = _(I), [G, K] = _(!1), [q, J] = _(0), [Y, X] = _(void 0), Z = I ? j.fetchTemplate : void 0, ae = () => {
37
- J((e) => e + 1);
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
- h(() => {
40
+ g(() => {
40
41
  if (!Z) return;
41
42
  let e = !1;
42
- return W(!0), K(!1), X(void 0), (async () => {
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 || K(!0);
48
+ e || J(!0);
48
49
  } finally {
49
- e || W(!1);
50
+ e || K(!1);
50
51
  }
51
52
  })(), () => {
52
53
  e = !0;
53
54
  };
54
- }, [Z, q]), h(() => {
55
+ }, [Z, ae]), g(() => {
55
56
  Y !== void 0 && T?.(Y);
56
57
  }, [Y, T]);
57
- let Q = I ? void 0 : j.namespace, $ = g(() => Y ? {
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) => i(e))
63
+ fields: Y.fields.map((e) => a(e))
63
64
  } : {
64
- ...ie,
65
+ ...ne,
65
66
  namespace: Q ?? ""
66
- }, [Y, Q]);
67
- return U ? /* @__PURE__ */ f("div", {
68
- className: x.loading,
69
- children: /* @__PURE__ */ f(c, {
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": P(n.loading)
75
+ "aria-label": I(r.loading)
72
76
  })
73
- }) : G ? /* @__PURE__ */ f("div", {
74
- className: x.error,
75
- children: /* @__PURE__ */ f(s, {
76
- body: /* @__PURE__ */ f(l, {
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: P(n.fetchError)
82
+ children: I(r.fetchError)
79
83
  }),
80
- illustration: b,
84
+ illustration: S,
81
85
  size: "large",
82
- children: /* @__PURE__ */ f(s.PrimaryAction, {
83
- startIcon: v,
84
- onClick: ae,
85
- children: P(n.reload)
86
+ children: /* @__PURE__ */ f(l.PrimaryAction, {
87
+ startIcon: b,
88
+ onClick: se,
89
+ children: I(r.reload)
86
90
  })
87
91
  })
88
- }) : /* @__PURE__ */ ne(te, { children: [/* @__PURE__ */ f(y, {
89
- initialValues: $,
90
- validationSchema: N,
91
- onSubmit: async (e) => {
92
- try {
93
- if (I) {
94
- let t = ee($, e);
95
- await j.onEditTemplate(t, {
96
- namespaceFQN: $.namespace,
97
- templateKey: $.templateKey
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
- } else {
100
- let t = a(e.fields), n = {
101
- namespace: e.namespace,
102
- templateKey: e.templateKey,
103
- displayName: e.displayName,
104
- hidden: e.hidden,
105
- fields: t
106
- };
107
- await j.onCreateTemplate(n);
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
- F({
110
- sensitivity: "foreground",
111
- variant: "success",
112
- styledText: P(n.saveSuccessNotification),
113
- typeIconAriaLabel: P(n.notificationSuccessIconAriaLabel),
114
- closeButtonAriaLabel: P(n.notificationCloseButtonAriaLabel)
115
- });
116
- } catch (e) {
117
- let t;
118
- if (e instanceof Error && "status" in e) {
119
- let { status: r } = e;
120
- t = P(r === 409 ? n.displayNameUsedBefore : n.saveErrorNotification);
121
- } else t = P(n.saveErrorNotification);
122
- F({
123
- sensitivity: "foreground",
124
- variant: "error",
125
- styledText: t,
126
- typeIconAriaLabel: P(n.notificationErrorIconAriaLabel),
127
- closeButtonAriaLabel: P(n.notificationCloseButtonAriaLabel)
128
- });
129
- try {
130
- w?.(e);
131
- } catch {}
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 { S as t };
164
+ export { w as t };
@@ -1,43 +1,44 @@
1
- import { useFieldConfigurator as e } from "../esm/lib/components/metadata-field-configurator/context/field-configurator-context.js";
2
- import t from "../esm/lib/components/metadata-field-configurator/messages/taxonomy-messages.js";
3
- import { useTaxonomySelect as n } from "../esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/useTaxonomySelect.js";
4
- import { filterTaxonomiesByValue as r } from "../esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/utils.js";
5
- import { t as i } from "./taxonomy-selector.js";
6
- import { Text as a } from "@box/blueprint-web";
7
- import { FormattedMessage as o } from "react-intl";
8
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
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 l = {
11
+ import '../styles/taxonomy-field-configurator-initial-state.css';var u = {
11
12
  taxonomyFieldConfiguratorInitialState: "_taxonomyFieldConfiguratorInitialState_il5v7_1",
12
13
  subheader: "_subheader_il5v7_10"
13
- }, u = () => {
14
- let { values: u, setFieldValue: d } = e(), { onTaxonomySelect: f } = n({
15
- values: u,
16
- setFieldValue: d
17
- });
18
- return /* @__PURE__ */ c("div", {
19
- className: l.taxonomyFieldConfiguratorInitialState,
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__ */ s(a, {
22
+ /* @__PURE__ */ c(o, {
22
23
  as: "h1",
23
24
  color: "textOnLightDefault",
24
25
  variant: "titleMedium",
25
- children: /* @__PURE__ */ s(o, { ...t.callToActionHeader })
26
+ children: m?.header ?? /* @__PURE__ */ c(s, { ...n.callToActionHeader })
26
27
  }),
27
- /* @__PURE__ */ s(a, {
28
+ /* @__PURE__ */ c(o, {
28
29
  as: "p",
29
- className: l.subheader,
30
+ className: u.subheader,
30
31
  color: "textOnLightDefault",
31
32
  variant: "bodyDefault",
32
- children: /* @__PURE__ */ s(o, { ...t.callToActionSubheader })
33
+ children: m?.subheader ?? /* @__PURE__ */ c(s, { ...n.callToActionSubheader })
33
34
  }),
34
- /* @__PURE__ */ s(i, {
35
- data: r(u.taxonomy.availableTaxonomies, u.taxonomy.taxonomySearchValue),
36
- onClick: f,
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
- d("taxonomy", {
40
- ...u.taxonomy,
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 { u as t };
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 { t as u } from "../chunks/field-type-dropdown.js";
4
- import { FieldTypeTiles as d } from "./lib/components/field-type-tiles/field-type-tiles.js";
5
- import { useTemplateFieldSchema as f } from "./lib/components/metadata-field-configurator/hooks/useTemplateFieldSchema.js";
6
- import p from "./lib/components/metadata-field-configurator/components/confirmation-modal/confirmation-modal.js";
7
- import { FieldActionSlot as m } from "./lib/components/metadata-field-configurator/components/field-action-slot/field-action-slot.js";
8
- import { FieldConfiguratorContext as h, useFieldConfigurator as g } from "./lib/components/metadata-field-configurator/context/field-configurator-context.js";
9
- import { TaxonomyOptionsContext as _, createStaticTaxonomyContext as v, useTaxonomyOptions as y } from "./lib/components/metadata-field-configurator/context/taxonomy-options-context.js";
10
- import { createDefaultFieldValues as b } from "./lib/components/metadata-field-configurator/utils.js";
11
- import { FieldEditContent as x } from "./lib/components/metadata-field-configurator/components/field-edit-content/field-edit-content.js";
12
- import { FieldExtensionsContext as S, useFieldExtensions as C } from "./lib/components/metadata-field-configurator/context/field-extensions-context.js";
13
- import { useFieldConfiguratorBehavior as w } from "./lib/components/metadata-field-configurator/hooks/useFieldConfiguratorBehavior.js";
14
- import { MetadataFieldConfigurator as T } from "./lib/components/metadata-field-configurator/metadata-field-configurator.js";
15
- import { t as E } from "../chunks/metadata-field-list.js";
16
- import { t as D } from "../chunks/metadata-template-editor.js";
17
- import { t as O } from "../chunks/metadata-template-editor-modal.js";
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, p as ConfirmationModal, s as EnumOperations, m as FieldActionSlot, h as FieldConfiguratorContext, x as FieldEditContent, S as FieldExtensionsContext, r as FieldOperations, e as FieldSelector, t as FieldType, u as FieldTypeDropdown, d as FieldTypeTiles, T as MetadataFieldConfigurator, E as MetadataFieldList, E as MetadataFieldListDefault, D as MetadataTemplateEditor, O as MetadataTemplateEditorModal, o as MetadataTemplateEditorMode, c as MultiSelectOperations, _ as TaxonomyOptionsContext, n as TaxonomySelection, i as TemplateOperations, b as createDefaultFieldValues, v as createStaticTaxonomyContext, g as useFieldConfigurator, w as useFieldConfiguratorBehavior, C as useFieldExtensions, y as useTaxonomyOptions, f as useTemplateFieldSchema };
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 };
@@ -0,0 +1,3 @@
1
+ import { createContext as e, useContext as t } from "react";
2
+ var n = /* @__PURE__ */ e({ disabledFieldTypes: [] }), r = () => t(n);
3
+ export { n as EditorConfigContext, r as useEditorConfig };
@@ -1,11 +1,14 @@
1
- import { useTemplateFieldSchema as e } from "./hooks/useTemplateFieldSchema.js";
2
- import t from "./components/confirmation-modal/confirmation-modal.js";
3
- import { FieldActionSlot as n } from "./components/field-action-slot/field-action-slot.js";
4
- import { FieldConfiguratorContext as r, useFieldConfigurator as i } from "./context/field-configurator-context.js";
5
- import { TaxonomyOptionsContext as a, createStaticTaxonomyContext as o, useTaxonomyOptions as s } from "./context/taxonomy-options-context.js";
6
- import { createDefaultFieldValues as c } from "./utils.js";
7
- import { FieldEditContent as l } from "./components/field-edit-content/field-edit-content.js";
8
- import { FieldExtensionsContext as u, useFieldExtensions as d } from "./context/field-extensions-context.js";
9
- import { useFieldConfiguratorBehavior as f } from "./hooks/useFieldConfiguratorBehavior.js";
10
- import { MetadataFieldConfigurator as p } from "./metadata-field-configurator.js";
11
- export { t as ConfirmationModal, n as FieldActionSlot, r as FieldConfiguratorContext, l as FieldEditContent, u as FieldExtensionsContext, p as MetadataFieldConfigurator, a as TaxonomyOptionsContext, c as createDefaultFieldValues, o as createStaticTaxonomyContext, i as useFieldConfigurator, f as useFieldConfiguratorBehavior, d as useFieldExtensions, s as useTaxonomyOptions, e as useTemplateFieldSchema };
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 };
@@ -1,7 +1,8 @@
1
- import { useTemplateNameSchema as e } from "./hooks/useTemplateNameSchema.js";
2
- import { useMetadataTemplateFormSchema as t } from "./hooks/useMetadataTemplateFormSchema.js";
3
- import { convertApiMetadataTemplateFieldToLocalConfiguratorField as n } from "./utils/template-type-conversion/convertTemplateFieldToLocalConfigurator.js";
4
- import { mapFieldsWithUniqueKeys as r } from "./utils/template-type-conversion/mapFieldsWithUniqueKeys.js";
5
- import { generateJSONPatchTemplateOperations as i } from "./utils/template-type-conversion/generateJSONPatchTemplateOperations.js";
6
- import { t as a } from "../../chunks/metadata-template-editor.js";
7
- export { a as MetadataTemplateEditor, n as convertApiMetadataTemplateFieldToLocalConfiguratorField, i as generateJSONPatchTemplateOperations, r as mapFieldsWithUniqueKeys, t as useMetadataTemplateFormSchema, e as useTemplateNameSchema };
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 { useIntl as i } from "react-intl";
5
- import { useMemo as a } from "react";
6
- function o() {
7
- let o = i();
8
- return { availableFieldTypes: a(() => Object.values(e).map((e) => ({
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: o.formatMessage(r[e]),
11
- description: o.formatMessage(n[e]),
11
+ label: s.formatMessage(r[e]),
12
+ description: s.formatMessage(n[e]),
12
13
  Icon: t(e)
13
- })), [o]) };
14
+ })), [s, c]) };
14
15
  }
15
- export { o as useFieldOptions };
16
+ export { s as useFieldOptions };
@@ -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.25.1",
3
+ "version": "1.26.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "peerDependencies": {
6
- "@box/blueprint-web": "^14.41.1",
7
- "@box/blueprint-web-assets": "^4.121.1",
6
+ "@box/blueprint-web": "^15.0.0",
7
+ "@box/blueprint-web-assets": "^4.121.2",
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": "^14.41.1",
21
- "@box/blueprint-web-assets": "^4.121.1",
20
+ "@box/blueprint-web": "^15.0.0",
21
+ "@box/blueprint-web-assets": "^4.121.2",
22
22
  "@box/eslint-plugin-blueprint": "1.2.4",
23
- "@box/storybook-utils": "0.20.1",
23
+ "@box/storybook-utils": "0.20.2",
24
24
  "@dnd-kit/core": "^6.1.0",
25
25
  "@dnd-kit/sortable": "^8.0.0",
26
26
  "@dnd-kit/utilities": "^3.2.2",