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