@box/metadata-template-editor 1.20.9 → 1.20.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/chip.js +21 -0
- package/dist/chunks/dropdown-field-configuration.js +62 -0
- package/dist/chunks/field-context-menu.js +90 -0
- package/dist/chunks/field-selector.js +23 -0
- package/dist/chunks/field-type-dropdown.js +31 -0
- package/dist/chunks/levels-chain.js +125 -0
- package/dist/chunks/metadata-field-configurator.module.js +17 -16
- package/dist/chunks/metadata-field-list.js +229 -0
- package/dist/chunks/metadata-template-editor-form.js +107 -0
- package/dist/chunks/metadata-template-editor-modal.js +77 -0
- package/dist/chunks/metadata-template-editor.js +157 -0
- package/dist/chunks/sortable-option-list.js +231 -0
- package/dist/chunks/taxonomy-field-configuration.js +126 -0
- package/dist/chunks/taxonomy-field-configurator-initial-state.js +48 -0
- package/dist/chunks/taxonomy-selector.js +90 -0
- package/dist/chunks/types.js +22 -33
- package/dist/esm/index.js +13 -34
- package/dist/esm/lib/components/field-selector/field-selector.js +2 -39
- package/dist/esm/lib/components/field-selector/index.js +2 -4
- package/dist/esm/lib/components/field-selector/messages.js +10 -12
- package/dist/esm/lib/components/field-type-dropdown/field-type-dropdown.js +2 -47
- package/dist/esm/lib/components/field-type-dropdown/index.js +2 -4
- package/dist/esm/lib/components/field-type-dropdown/messages.js +10 -12
- package/dist/esm/lib/components/field-type-tiles/field-type-tiles.js +32 -39
- package/dist/esm/lib/components/field-type-tiles/index.js +2 -4
- package/dist/esm/lib/components/field-type-tiles/messages.js +10 -12
- package/dist/esm/lib/components/metadata-field-configurator/components/confirmation-modal/confirmation-modal.js +32 -45
- package/dist/esm/lib/components/metadata-field-configurator/components/confirmation-modal/messages.js +14 -16
- package/dist/esm/lib/components/metadata-field-configurator/components/field-action-slot/field-action-slot.js +62 -79
- package/dist/esm/lib/components/metadata-field-configurator/components/field-context-menu/field-context-menu.js +2 -115
- package/dist/esm/lib/components/metadata-field-configurator/components/field-edit-content/field-edit-content.js +83 -100
- package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/chip.js +2 -33
- package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/index.js +2 -4
- package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/levels-chain.js +2 -118
- package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/utils.js +16 -33
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/__mocks__/getInitialValues.js +34 -32
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/dropdown-default-values.js +10 -14
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/dropdown-field-configuration.js +2 -66
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/sortable-option-list.js +2 -294
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/index.js +3 -6
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-default-values.js +11 -15
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-field-configuration.js +2 -149
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-field-configurator-initial-state.js +2 -54
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector-messages.js +34 -36
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector.js +2 -103
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/useTaxonomySelect.js +15 -19
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/utils.js +2 -4
- package/dist/esm/lib/components/metadata-field-configurator/context/field-configurator-context.js +60 -66
- package/dist/esm/lib/components/metadata-field-configurator/context/field-extensions-context.js +5 -8
- package/dist/esm/lib/components/metadata-field-configurator/context/taxonomy-options-context.js +14 -20
- package/dist/esm/lib/components/metadata-field-configurator/hooks/useFieldConfiguratorBehavior.js +99 -118
- package/dist/esm/lib/components/metadata-field-configurator/hooks/useFieldValidation.js +52 -66
- package/dist/esm/lib/components/metadata-field-configurator/hooks/useTaxonomyFetch.js +23 -26
- package/dist/esm/lib/components/metadata-field-configurator/hooks/useTemplateFieldSchema.js +34 -43
- package/dist/esm/lib/components/metadata-field-configurator/index.js +5 -11
- package/dist/esm/lib/components/metadata-field-configurator/messages/configurator-messages.js +131 -134
- package/dist/esm/lib/components/metadata-field-configurator/messages/dropdown-messages.js +34 -36
- package/dist/esm/lib/components/metadata-field-configurator/messages/levels-chain-messages.js +14 -16
- package/dist/esm/lib/components/metadata-field-configurator/messages/taxonomy-messages.js +34 -36
- package/dist/esm/lib/components/metadata-field-configurator/metadata-field-configurator.js +94 -153
- package/dist/esm/lib/components/metadata-field-configurator/utils.js +42 -49
- package/dist/esm/lib/components/metadata-field-list/index.js +2 -5
- package/dist/esm/lib/components/metadata-field-list/metadata-field-list.js +2 -279
- package/dist/esm/lib/components/metadata-template-editor-form/metadata-template-editor-form.js +2 -137
- package/dist/esm/lib/components/metadata-template-editor-modal/index.js +2 -4
- package/dist/esm/lib/components/metadata-template-editor-modal/metadata-template-editor-modal.js +2 -103
- package/dist/esm/lib/hooks/useMetadataTemplateFormSchema.js +13 -15
- package/dist/esm/lib/hooks/useTemplateNameSchema.js +8 -10
- package/dist/esm/lib/index.js +7 -14
- package/dist/esm/lib/messages.js +114 -116
- package/dist/esm/lib/metadata-template-editor.js +2 -182
- package/dist/esm/lib/utils/constants.js +2 -8
- package/dist/esm/lib/utils/field-options/field-type-icon.js +14 -33
- package/dist/esm/lib/utils/field-options/index.js +4 -9
- package/dist/esm/lib/utils/field-options/messages.js +43 -46
- package/dist/esm/lib/utils/field-options/useFieldOptions.js +14 -18
- package/dist/esm/lib/utils/key-generation.js +16 -27
- package/dist/esm/lib/utils/template-type-conversion/convertLocalConfiguratorToTemplateField.js +63 -77
- package/dist/esm/lib/utils/template-type-conversion/convertTemplateFieldToLocalConfigurator.js +69 -89
- package/dist/esm/lib/utils/template-type-conversion/generateJSONPatchTemplateOperations.js +150 -169
- package/dist/esm/lib/utils/template-type-conversion/mapFieldsWithUniqueKeys.js +8 -13
- package/dist/styles/chip.css +1 -1
- package/dist/styles/dropdown-field-configuration.css +1 -1
- package/dist/styles/field-context-menu.css +1 -1
- package/dist/styles/levels-chain.css +1 -1
- package/dist/styles/metadata-field-configurator.css +1 -1
- package/dist/styles/metadata-field-list.css +1 -1
- package/dist/styles/metadata-template-editor-form.css +1 -1
- package/dist/styles/metadata-template-editor-modal.css +1 -1
- package/dist/styles/metadata-template-editor.css +1 -1
- package/dist/styles/sortable-option-list.css +1 -1
- package/dist/styles/taxonomy-field-configuration.css +1 -1
- package/dist/styles/taxonomy-field-configurator-initial-state.css +1 -1
- package/dist/styles/taxonomy-selector.css +1 -1
- package/package.json +6 -6
package/dist/esm/lib/components/metadata-field-configurator/hooks/useFieldConfiguratorBehavior.js
CHANGED
|
@@ -1,119 +1,100 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
function
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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 {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
function
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
|
2
|
-
import {
|
|
3
|
-
import { createDefaultFieldValues as
|
|
4
|
-
import {
|
|
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 };
|