@box/metadata-template-editor 1.20.9 → 1.20.11

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 (95) hide show
  1. package/dist/chunks/chip.js +21 -0
  2. package/dist/chunks/dropdown-field-configuration.js +62 -0
  3. package/dist/chunks/field-context-menu.js +90 -0
  4. package/dist/chunks/field-selector.js +23 -0
  5. package/dist/chunks/field-type-dropdown.js +31 -0
  6. package/dist/chunks/levels-chain.js +125 -0
  7. package/dist/chunks/metadata-field-configurator.module.js +17 -16
  8. package/dist/chunks/metadata-field-list.js +229 -0
  9. package/dist/chunks/metadata-template-editor-form.js +107 -0
  10. package/dist/chunks/metadata-template-editor-modal.js +77 -0
  11. package/dist/chunks/metadata-template-editor.js +157 -0
  12. package/dist/chunks/sortable-option-list.js +231 -0
  13. package/dist/chunks/taxonomy-field-configuration.js +126 -0
  14. package/dist/chunks/taxonomy-field-configurator-initial-state.js +48 -0
  15. package/dist/chunks/taxonomy-selector.js +90 -0
  16. package/dist/chunks/types.js +22 -33
  17. package/dist/esm/index.js +13 -34
  18. package/dist/esm/lib/components/field-selector/field-selector.js +2 -39
  19. package/dist/esm/lib/components/field-selector/index.js +2 -4
  20. package/dist/esm/lib/components/field-selector/messages.js +10 -12
  21. package/dist/esm/lib/components/field-type-dropdown/field-type-dropdown.js +2 -47
  22. package/dist/esm/lib/components/field-type-dropdown/index.js +2 -4
  23. package/dist/esm/lib/components/field-type-dropdown/messages.js +10 -12
  24. package/dist/esm/lib/components/field-type-tiles/field-type-tiles.js +32 -39
  25. package/dist/esm/lib/components/field-type-tiles/index.js +2 -4
  26. package/dist/esm/lib/components/field-type-tiles/messages.js +10 -12
  27. package/dist/esm/lib/components/metadata-field-configurator/components/confirmation-modal/confirmation-modal.js +32 -45
  28. package/dist/esm/lib/components/metadata-field-configurator/components/confirmation-modal/messages.js +14 -16
  29. package/dist/esm/lib/components/metadata-field-configurator/components/field-action-slot/field-action-slot.js +62 -79
  30. package/dist/esm/lib/components/metadata-field-configurator/components/field-context-menu/field-context-menu.js +2 -115
  31. package/dist/esm/lib/components/metadata-field-configurator/components/field-edit-content/field-edit-content.js +83 -100
  32. package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/chip.js +2 -33
  33. package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/index.js +2 -4
  34. package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/levels-chain.js +2 -118
  35. package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/utils.js +16 -33
  36. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/__mocks__/getInitialValues.js +34 -32
  37. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/dropdown-default-values.js +10 -14
  38. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/dropdown-field-configuration.js +2 -66
  39. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/sortable-option-list.js +2 -294
  40. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/index.js +3 -6
  41. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-default-values.js +11 -15
  42. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-field-configuration.js +2 -149
  43. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-field-configurator-initial-state.js +2 -54
  44. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector-messages.js +34 -36
  45. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector.js +2 -103
  46. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/useTaxonomySelect.js +15 -19
  47. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/utils.js +2 -4
  48. package/dist/esm/lib/components/metadata-field-configurator/context/field-configurator-context.js +60 -66
  49. package/dist/esm/lib/components/metadata-field-configurator/context/field-extensions-context.js +5 -8
  50. package/dist/esm/lib/components/metadata-field-configurator/context/taxonomy-options-context.js +14 -20
  51. package/dist/esm/lib/components/metadata-field-configurator/hooks/useFieldConfiguratorBehavior.js +99 -118
  52. package/dist/esm/lib/components/metadata-field-configurator/hooks/useFieldValidation.js +52 -66
  53. package/dist/esm/lib/components/metadata-field-configurator/hooks/useTaxonomyFetch.js +23 -26
  54. package/dist/esm/lib/components/metadata-field-configurator/hooks/useTemplateFieldSchema.js +34 -43
  55. package/dist/esm/lib/components/metadata-field-configurator/index.js +5 -11
  56. package/dist/esm/lib/components/metadata-field-configurator/messages/configurator-messages.js +131 -134
  57. package/dist/esm/lib/components/metadata-field-configurator/messages/dropdown-messages.js +34 -36
  58. package/dist/esm/lib/components/metadata-field-configurator/messages/levels-chain-messages.js +14 -16
  59. package/dist/esm/lib/components/metadata-field-configurator/messages/taxonomy-messages.js +34 -36
  60. package/dist/esm/lib/components/metadata-field-configurator/metadata-field-configurator.js +94 -153
  61. package/dist/esm/lib/components/metadata-field-configurator/utils.js +42 -49
  62. package/dist/esm/lib/components/metadata-field-list/index.js +2 -5
  63. package/dist/esm/lib/components/metadata-field-list/metadata-field-list.js +2 -279
  64. package/dist/esm/lib/components/metadata-template-editor-form/metadata-template-editor-form.js +2 -137
  65. package/dist/esm/lib/components/metadata-template-editor-modal/index.js +2 -4
  66. package/dist/esm/lib/components/metadata-template-editor-modal/metadata-template-editor-modal.js +2 -103
  67. package/dist/esm/lib/hooks/useMetadataTemplateFormSchema.js +13 -15
  68. package/dist/esm/lib/hooks/useTemplateNameSchema.js +8 -10
  69. package/dist/esm/lib/index.js +7 -14
  70. package/dist/esm/lib/messages.js +114 -116
  71. package/dist/esm/lib/metadata-template-editor.js +2 -182
  72. package/dist/esm/lib/utils/constants.js +2 -8
  73. package/dist/esm/lib/utils/field-options/field-type-icon.js +14 -33
  74. package/dist/esm/lib/utils/field-options/index.js +4 -9
  75. package/dist/esm/lib/utils/field-options/messages.js +43 -46
  76. package/dist/esm/lib/utils/field-options/useFieldOptions.js +14 -18
  77. package/dist/esm/lib/utils/key-generation.js +16 -27
  78. package/dist/esm/lib/utils/template-type-conversion/convertLocalConfiguratorToTemplateField.js +63 -77
  79. package/dist/esm/lib/utils/template-type-conversion/convertTemplateFieldToLocalConfigurator.js +69 -89
  80. package/dist/esm/lib/utils/template-type-conversion/generateJSONPatchTemplateOperations.js +150 -169
  81. package/dist/esm/lib/utils/template-type-conversion/mapFieldsWithUniqueKeys.js +8 -13
  82. package/dist/styles/chip.css +1 -1
  83. package/dist/styles/dropdown-field-configuration.css +1 -1
  84. package/dist/styles/field-context-menu.css +1 -1
  85. package/dist/styles/levels-chain.css +1 -1
  86. package/dist/styles/metadata-field-configurator.css +1 -1
  87. package/dist/styles/metadata-field-list.css +1 -1
  88. package/dist/styles/metadata-template-editor-form.css +1 -1
  89. package/dist/styles/metadata-template-editor-modal.css +1 -1
  90. package/dist/styles/metadata-template-editor.css +1 -1
  91. package/dist/styles/sortable-option-list.css +1 -1
  92. package/dist/styles/taxonomy-field-configuration.css +1 -1
  93. package/dist/styles/taxonomy-field-configurator-initial-state.css +1 -1
  94. package/dist/styles/taxonomy-selector.css +1 -1
  95. package/package.json +6 -6
@@ -1,119 +1,100 @@
1
- import { useState as I, useCallback as n, useMemo as w, useRef as x, useEffect as f } from "react";
2
- import { useIntl as oe } from "react-intl";
3
- import re from "lodash/cloneDeep";
4
- import ce from "lodash/set";
5
- import { FieldTypeIcon as de } from "../../../utils/field-options/field-type-icon.js";
6
- import { useFieldExtensions as se } from "../context/field-extensions-context.js";
7
- import { general as le } from "../messages/configurator-messages.js";
8
- import { createDefaultFieldValues as fe, hasVisibleErrors as me } from "../utils.js";
9
- import { useFieldValidation as pe } from "./useFieldValidation.js";
10
- import { useTaxonomyFetch as ae } from "./useTaxonomyFetch.js";
11
- function Re({
12
- values: e,
13
- onValuesChange: i,
14
- onDelete: T,
15
- isExpanded: m,
16
- onExpandedChange: V,
17
- submitAttemptCount: d,
18
- taxonomyOptions: C,
19
- fetchTaxonomies: S,
20
- fieldExtensionsProp: B,
21
- onValidationChange: N
22
- }) {
23
- const u = oe(), {
24
- errors: p,
25
- touched: a,
26
- isValid: s,
27
- validateForm: M,
28
- touchAll: R,
29
- setFieldTouched: P,
30
- setTouched: q,
31
- handleBlur: H
32
- } = pe(e), K = ae(S, C), j = se(), b = B ?? j, [z, A] = I(() => e.isFieldNew === !0), [G, F] = I(!1), [h, O] = I("edit"), o = m !== void 0 ? m : z, J = !e.isFieldReadOnly && e.isFieldNew, r = e.id, L = `field-name-${r}`, Q = `field-description-${r}`, l = n((t, c) => {
33
- i({
34
- ...e,
35
- [t]: c
36
- });
37
- }, [e, i]), k = n((t) => {
38
- const {
39
- name: c,
40
- value: ne
41
- } = t.target, D = re(e);
42
- ce(D, c, ne), i(D);
43
- }, [e, i]), U = w(
44
- () => ({
45
- values: e,
46
- errors: p,
47
- touched: a,
48
- isValid: s,
49
- setFieldValue: l,
50
- setValues: i,
51
- setFieldTouched: P,
52
- setTouched: q,
53
- handleChange: k,
54
- handleBlur: H,
55
- validateForm: M
56
- }),
57
- // setFieldTouched, setTouched, handleBlur are stable (no deps).
58
- // eslint-disable-next-line react-hooks/exhaustive-deps
59
- [e, p, a, s, l, i, k, M]
60
- ), E = x(o);
61
- f(() => {
62
- const t = E.current;
63
- E.current = o, t && !o && (R(), O("edit"));
64
- }, [o]);
65
- const W = x(d);
66
- f(() => {
67
- !d || d === W.current || R();
68
- }, [d]);
69
- const $ = x(N);
70
- $.current = N, f(() => {
71
- $.current?.(s);
72
- }, [s]), f(() => {
73
- e.isFieldNew && (m !== void 0 ? V?.(!0) : A(!0));
74
- }, [e.isFieldNew]);
75
- const X = n((t) => l("hidden", t), [l]), y = n(() => {
76
- T?.(e.key), F(!1);
77
- }, [T, e.key]), Y = n(() => {
78
- e.isFieldNew ? y() : F(!0);
79
- }, [y, e.isFieldNew]), Z = n(() => F(!1), []), _ = n((t) => A(t === r), [r]), v = n((t) => {
80
- i({
81
- ...fe(t),
82
- key: e.key,
83
- hidden: e.hidden,
84
- isFieldNew: e.isFieldNew,
85
- isFieldReadOnly: e.isFieldReadOnly,
86
- name: e.name,
87
- description: e.description
88
- });
89
- }, [i, e]), ee = w(() => {
90
- const t = e.name || u.formatMessage(le.fieldNameInputPlaceholder), c = e.type === "dropdown" ? ` (${e.dropdown?.options?.length ?? 0})` : "";
91
- return `${t}${c}`;
92
- }, [e.name, e.type, e.dropdown?.options?.length, u]), te = w(() => de(e.type), [e.type]), g = h === "edit" ? 0 : Number(h.replace("ext-", "")) + 1, ie = g > 0 ? b[g - 1] ?? null : null;
93
- return {
94
- contextValue: U,
95
- taxonomyContextValue: K,
96
- extensions: b,
97
- isActive: o,
98
- handleAccordionValueChange: _,
99
- isDeleteConfirmationModalOpen: G,
100
- openConfirmationModal: Y,
101
- closeConfirmationModal: Z,
102
- handleDeleteField: y,
103
- activeTabId: h,
104
- setActiveTabId: O,
105
- activeExtension: ie,
106
- isTypeEditable: J,
107
- uniqueKey: r,
108
- nameInputId: L,
109
- descriptionInputId: Q,
110
- accordionTitle: ee,
111
- TitleIcon: te,
112
- hasErrors: me(p, a),
113
- handleTypeChange: v,
114
- handleChangeVisibility: X
115
- };
1
+ import { FieldTypeIcon as e } from "../../../utils/field-options/field-type-icon.js";
2
+ import { general as t } from "../messages/configurator-messages.js";
3
+ import { useFieldExtensions as n } from "../context/field-extensions-context.js";
4
+ import { createDefaultFieldValues as r, hasVisibleErrors as i } from "../utils.js";
5
+ import { useFieldValidation as a } from "./useFieldValidation.js";
6
+ import { useTaxonomyFetch as o } from "./useTaxonomyFetch.js";
7
+ import { useIntl as s } from "react-intl";
8
+ import { useCallback as c, useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
9
+ import p from "lodash/cloneDeep";
10
+ import m from "lodash/set";
11
+ function h({ values: h, onValuesChange: g, onDelete: _, isExpanded: v, onExpandedChange: y, submitAttemptCount: b, taxonomyOptions: x, fetchTaxonomies: S, fieldExtensionsProp: C, onValidationChange: w }) {
12
+ let T = s(), { errors: E, touched: D, isValid: O, validateForm: k, touchAll: A, setFieldTouched: j, setTouched: ee, handleBlur: te } = a(h), ne = o(S, x), M = n(), N = C ?? M, [P, F] = f(() => h.isFieldNew === !0), [I, L] = f(!1), [R, z] = f("edit"), B = v === void 0 ? P : v, V = !h.isFieldReadOnly && h.isFieldNew, H = h.id, U = `field-name-${H}`, W = `field-description-${H}`, G = c((e, t) => {
13
+ g({
14
+ ...h,
15
+ [e]: t
16
+ });
17
+ }, [h, g]), K = c((e) => {
18
+ let { name: t, value: n } = e.target, r = p(h);
19
+ m(r, t, n), g(r);
20
+ }, [h, g]), q = u(() => ({
21
+ values: h,
22
+ errors: E,
23
+ touched: D,
24
+ isValid: O,
25
+ setFieldValue: G,
26
+ setValues: g,
27
+ setFieldTouched: j,
28
+ setTouched: ee,
29
+ handleChange: K,
30
+ handleBlur: te,
31
+ validateForm: k
32
+ }), [
33
+ h,
34
+ E,
35
+ D,
36
+ O,
37
+ G,
38
+ g,
39
+ K,
40
+ k
41
+ ]), J = d(B);
42
+ l(() => {
43
+ let e = J.current;
44
+ J.current = B, e && !B && (A(), z("edit"));
45
+ }, [B]);
46
+ let Y = d(b);
47
+ l(() => {
48
+ !b || b === Y.current || A();
49
+ }, [b]);
50
+ let X = d(w);
51
+ X.current = w, l(() => {
52
+ X.current?.(O);
53
+ }, [O]), l(() => {
54
+ h.isFieldNew && (v === void 0 ? F(!0) : y?.(!0));
55
+ }, [h.isFieldNew]);
56
+ let re = c((e) => G("hidden", e), [G]), Z = c(() => {
57
+ _?.(h.key), L(!1);
58
+ }, [_, h.key]), Q = c(() => {
59
+ h.isFieldNew ? Z() : L(!0);
60
+ }, [Z, h.isFieldNew]), ie = c(() => L(!1), []), ae = c((e) => F(e === H), [H]), oe = c((e) => {
61
+ g({
62
+ ...r(e),
63
+ key: h.key,
64
+ hidden: h.hidden,
65
+ isFieldNew: h.isFieldNew,
66
+ isFieldReadOnly: h.isFieldReadOnly,
67
+ name: h.name,
68
+ description: h.description
69
+ });
70
+ }, [g, h]), se = u(() => `${h.name || T.formatMessage(t.fieldNameInputPlaceholder)}${h.type === "dropdown" ? ` (${h.dropdown?.options?.length ?? 0})` : ""}`, [
71
+ h.name,
72
+ h.type,
73
+ h.dropdown?.options?.length,
74
+ T
75
+ ]), ce = u(() => e(h.type), [h.type]), $ = R === "edit" ? 0 : Number(R.replace("ext-", "")) + 1;
76
+ return {
77
+ contextValue: q,
78
+ taxonomyContextValue: ne,
79
+ extensions: N,
80
+ isActive: B,
81
+ handleAccordionValueChange: ae,
82
+ isDeleteConfirmationModalOpen: I,
83
+ openConfirmationModal: Q,
84
+ closeConfirmationModal: ie,
85
+ handleDeleteField: Z,
86
+ activeTabId: R,
87
+ setActiveTabId: z,
88
+ activeExtension: $ > 0 ? N[$ - 1] ?? null : null,
89
+ isTypeEditable: V,
90
+ uniqueKey: H,
91
+ nameInputId: U,
92
+ descriptionInputId: W,
93
+ accordionTitle: se,
94
+ TitleIcon: ce,
95
+ hasErrors: i(E, D),
96
+ handleTypeChange: oe,
97
+ handleChangeVisibility: re
98
+ };
116
99
  }
117
- export {
118
- Re as useFieldConfiguratorBehavior
119
- };
100
+ export { h as useFieldConfiguratorBehavior };
@@ -1,68 +1,54 @@
1
- import { useState as d, useCallback as n, useEffect as h, useRef as S } from "react";
2
- import * as b from "yup";
3
- import f from "lodash/set";
4
- import y from "lodash/cloneDeep";
5
- import { useTemplateFieldSchema as k } from "./useTemplateFieldSchema.js";
6
- import { markAllTouched as w } from "../utils.js";
7
- function A(t) {
8
- const c = {};
9
- return (t.inner.length > 0 ? t.inner : [t]).forEach((a) => {
10
- a.path && f(c, a.path, a.message);
11
- }), c;
1
+ import { useTemplateFieldSchema as e } from "./useTemplateFieldSchema.js";
2
+ import { markAllTouched as t } from "../utils.js";
3
+ import { useCallback as n, useEffect as r, useRef as i, useState as a } from "react";
4
+ import * as o from "yup";
5
+ import s from "lodash/cloneDeep";
6
+ import c from "lodash/set";
7
+ function l(e) {
8
+ let t = {};
9
+ return (e.inner.length > 0 ? e.inner : [e]).forEach((e) => {
10
+ e.path && c(t, e.path, e.message);
11
+ }), t;
12
12
  }
13
- function Y(t) {
14
- const c = k(), [a, m] = d({}), [T, u] = d(!1), [E, s] = d({}), l = n(async (e, r) => {
15
- try {
16
- if (await c.validate(e, {
17
- abortEarly: !1
18
- }), r?.cancelled)
19
- return;
20
- m({}), u(!0);
21
- } catch (o) {
22
- if (r?.cancelled)
23
- return;
24
- o instanceof b.ValidationError && (m(A(o)), u(!1));
25
- }
26
- }, [c]);
27
- h(() => {
28
- const e = {
29
- cancelled: !1
30
- };
31
- return l(t, e), () => {
32
- e.cancelled = !0;
33
- };
34
- }, [t, l]);
35
- const p = S(t.type);
36
- h(() => {
37
- p.current !== t.type && (p.current = t.type, s(({
38
- dropdown: e,
39
- taxonomy: r,
40
- ...o
41
- }) => o));
42
- }, [t.type]);
43
- const g = n(() => l(t), [l, t]), x = n(() => s(w(t)), [t]), F = n((e, r = !0) => {
44
- s((o) => {
45
- const i = y(o);
46
- return f(i, e, r), i;
47
- });
48
- }, []), V = n((e) => s(e), []), R = n((e) => {
49
- const r = e.target;
50
- r.name && s((o) => {
51
- const i = y(o);
52
- return f(i, r.name, !0), i;
53
- });
54
- }, []);
55
- return {
56
- errors: a,
57
- touched: E,
58
- isValid: T,
59
- validateForm: g,
60
- touchAll: x,
61
- setFieldTouched: F,
62
- setTouched: V,
63
- handleBlur: R
64
- };
13
+ function u(u) {
14
+ let d = e(), [f, p] = a({}), [m, h] = a(!1), [g, _] = a({}), v = n(async (e, t) => {
15
+ try {
16
+ if (await d.validate(e, { abortEarly: !1 }), t?.cancelled) return;
17
+ p({}), h(!0);
18
+ } catch (e) {
19
+ if (t?.cancelled) return;
20
+ e instanceof o.ValidationError && (p(l(e)), h(!1));
21
+ }
22
+ }, [d]);
23
+ r(() => {
24
+ let e = { cancelled: !1 };
25
+ return v(u, e), () => {
26
+ e.cancelled = !0;
27
+ };
28
+ }, [u, v]);
29
+ let y = i(u.type);
30
+ return r(() => {
31
+ y.current !== u.type && (y.current = u.type, _(({ dropdown: e, taxonomy: t, ...n }) => n));
32
+ }, [u.type]), {
33
+ errors: f,
34
+ touched: g,
35
+ isValid: m,
36
+ validateForm: n(() => v(u), [v, u]),
37
+ touchAll: n(() => _(t(u)), [u]),
38
+ setFieldTouched: n((e, t = !0) => {
39
+ _((n) => {
40
+ let r = s(n);
41
+ return c(r, e, t), r;
42
+ });
43
+ }, []),
44
+ setTouched: n((e) => _(e), []),
45
+ handleBlur: n((e) => {
46
+ let t = e.target;
47
+ t.name && _((e) => {
48
+ let n = s(e);
49
+ return c(n, t.name, !0), n;
50
+ });
51
+ }, [])
52
+ };
65
53
  }
66
- export {
67
- Y as useFieldValidation
68
- };
54
+ export { u as useFieldValidation };
@@ -1,27 +1,24 @@
1
- import { useState as c, useRef as p, useCallback as o } from "react";
2
- import { createStaticTaxonomyContext as y } from "../context/taxonomy-options-context.js";
3
- function g(t, u = []) {
4
- const [e, r] = c("idle"), [a, i] = c([]), n = p(!1), s = o(async () => {
5
- if (!(!t || n.current)) {
6
- n.current = !0, r("loading");
7
- try {
8
- const f = await t();
9
- i(f), r("success");
10
- } catch {
11
- r("error");
12
- } finally {
13
- n.current = !1;
14
- }
15
- }
16
- }, [t]), l = o(() => {
17
- e === "success" || e === "loading" || s();
18
- }, [s, e]);
19
- return t ? {
20
- options: a,
21
- status: e,
22
- onSelectorOpen: l
23
- } : y(u);
1
+ import { createStaticTaxonomyContext as e } from "../context/taxonomy-options-context.js";
2
+ import { useCallback as t, useRef as n, useState as r } from "react";
3
+ function i(i, a = []) {
4
+ let [o, s] = r("idle"), [c, l] = r([]), u = n(!1), d = t(async () => {
5
+ if (!(!i || u.current)) {
6
+ u.current = !0, s("loading");
7
+ try {
8
+ l(await i()), s("success");
9
+ } catch {
10
+ s("error");
11
+ } finally {
12
+ u.current = !1;
13
+ }
14
+ }
15
+ }, [i]), f = t(() => {
16
+ o === "success" || o === "loading" || d();
17
+ }, [d, o]);
18
+ return i ? {
19
+ options: c,
20
+ status: o,
21
+ onSelectorOpen: f
22
+ } : e(a);
24
23
  }
25
- export {
26
- g as useTaxonomyFetch
27
- };
24
+ export { i as useTaxonomyFetch };
@@ -1,44 +1,35 @@
1
- import { useMemo as y } from "react";
2
- import { useIntl as h } from "react-intl";
3
- import * as e from "yup";
4
- import { T as b, F as i } from "../../../../../chunks/types.js";
5
- import { METADATA_TEMPLATE_FIELD_NAME_MAX_LENGTH as q } from "../../../utils/constants.js";
6
- import { validationErrors as n } from "../messages/configurator-messages.js";
7
- const j = () => {
8
- const t = h();
9
- return y(() => {
10
- const m = e.string().min(1).max(q, t.formatMessage(n.fieldNameTooLong)).required(t.formatMessage(n.fieldNameCannotBeEmpty)).test("no-whitespace-only", t.formatMessage(n.fieldNameCannotBeEmpty), (o) => !o || o.trim().length > 0), c = e.object().shape({
11
- key: e.string().required(t.formatMessage(n.optionKeyCannotBeEmpty)).test("unique-key", t.formatMessage(n.duplicateOption), (o, r) => {
12
- if (!o)
13
- return !0;
14
- const l = r?.from?.[0]?.value, s = r?.from?.[1].value?.options ?? [], u = s.findIndex((a) => a.id === l?.id);
15
- return !s.some((a, f) => f !== u && a.key === o);
16
- })
17
- }), p = e.object().shape({
18
- dropdown: e.object().shape({
19
- allowMultipleSelections: e.boolean().required(),
20
- options: e.array().of(c).min(1).required()
21
- })
22
- }), d = e.object().shape({
23
- taxonomy: e.object().shape({
24
- namespace: e.string().required(),
25
- taxonomyKey: e.string().required(),
26
- allowMultipleSelections: e.boolean().required(),
27
- selection: e.mixed().oneOf(Object.values(b)).required(),
28
- selectedLevels: e.array().of(e.number().required()).min(1).required()
29
- })
30
- });
31
- return e.lazy((o) => {
32
- const r = e.object().shape({
33
- type: e.mixed().oneOf(Object.values(i)).required(),
34
- name: m,
35
- description: e.string().nullable(),
36
- hidden: e.boolean().required()
37
- });
38
- return o?.type === i.Dropdown ? r.concat(p) : o?.type === i.Taxonomy ? r.concat(d) : r;
39
- });
40
- }, [t]);
41
- };
42
- export {
43
- j as useTemplateFieldSchema
1
+ import { a as e, c as t } from "../../../../../chunks/types.js";
2
+ import { METADATA_TEMPLATE_FIELD_NAME_MAX_LENGTH as n } from "../../../utils/constants.js";
3
+ import { validationErrors as r } from "../messages/configurator-messages.js";
4
+ import { useIntl as i } from "react-intl";
5
+ import { useMemo as a } from "react";
6
+ import * as o from "yup";
7
+ var s = () => {
8
+ let s = i();
9
+ return a(() => {
10
+ let i = o.string().min(1).max(n, s.formatMessage(r.fieldNameTooLong)).required(s.formatMessage(r.fieldNameCannotBeEmpty)).test("no-whitespace-only", s.formatMessage(r.fieldNameCannotBeEmpty), (e) => !e || e.trim().length > 0), a = o.object().shape({ key: o.string().required(s.formatMessage(r.optionKeyCannotBeEmpty)).test("unique-key", s.formatMessage(r.duplicateOption), (e, t) => {
11
+ if (!e) return !0;
12
+ let n = t?.from?.[0]?.value, r = t?.from?.[1].value?.options ?? [], i = r.findIndex((e) => e.id === n?.id);
13
+ return !r.some((t, n) => n !== i && t.key === e);
14
+ }) }), c = o.object().shape({ dropdown: o.object().shape({
15
+ allowMultipleSelections: o.boolean().required(),
16
+ options: o.array().of(a).min(1).required()
17
+ }) }), l = o.object().shape({ taxonomy: o.object().shape({
18
+ namespace: o.string().required(),
19
+ taxonomyKey: o.string().required(),
20
+ allowMultipleSelections: o.boolean().required(),
21
+ selection: o.mixed().oneOf(Object.values(t)).required(),
22
+ selectedLevels: o.array().of(o.number().required()).min(1).required()
23
+ }) });
24
+ return o.lazy((t) => {
25
+ let n = o.object().shape({
26
+ type: o.mixed().oneOf(Object.values(e)).required(),
27
+ name: i,
28
+ description: o.string().nullable(),
29
+ hidden: o.boolean().required()
30
+ });
31
+ return t?.type === e.Dropdown ? n.concat(c) : t?.type === e.Taxonomy ? n.concat(l) : n;
32
+ });
33
+ }, [s]);
44
34
  };
35
+ export { s as useTemplateFieldSchema };
@@ -1,11 +1,5 @@
1
- import { useTemplateFieldSchema as o } from "./hooks/useTemplateFieldSchema.js";
2
- import { MetadataFieldConfigurator as a } from "./metadata-field-configurator.js";
3
- import { createDefaultFieldValues as l } from "./utils.js";
4
- import { FieldExtensionsContext as x, useFieldExtensions as d } from "./context/field-extensions-context.js";
5
- export {
6
- x as FieldExtensionsContext,
7
- a as MetadataFieldConfigurator,
8
- l as createDefaultFieldValues,
9
- d as useFieldExtensions,
10
- o as useTemplateFieldSchema
11
- };
1
+ import { useTemplateFieldSchema as e } from "./hooks/useTemplateFieldSchema.js";
2
+ import { FieldExtensionsContext as t, useFieldExtensions as n } from "./context/field-extensions-context.js";
3
+ import { createDefaultFieldValues as r } from "./utils.js";
4
+ import { MetadataFieldConfigurator as i } from "./metadata-field-configurator.js";
5
+ export { t as FieldExtensionsContext, i as MetadataFieldConfigurator, r as createDefaultFieldValues, n as useFieldExtensions, e as useTemplateFieldSchema };