@box/metadata-template-editor 1.19.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.
- package/LICENSE +379 -0
- package/README.md +57 -0
- package/dist/chunks/metadata-field-configurator.module.js +17 -0
- package/dist/chunks/types.js +34 -0
- package/dist/esm/index.js +34 -0
- package/dist/esm/lib/components/field-selector/field-selector.js +39 -0
- package/dist/esm/lib/components/field-selector/index.js +4 -0
- package/dist/esm/lib/components/field-selector/messages.js +14 -0
- package/dist/esm/lib/components/field-type-dropdown/field-type-dropdown.js +47 -0
- package/dist/esm/lib/components/field-type-dropdown/index.js +4 -0
- package/dist/esm/lib/components/field-type-dropdown/messages.js +14 -0
- package/dist/esm/lib/components/field-type-tiles/field-type-tiles.js +40 -0
- package/dist/esm/lib/components/field-type-tiles/index.js +4 -0
- package/dist/esm/lib/components/field-type-tiles/messages.js +14 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/confirmation-modal/confirmation-modal.js +46 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/confirmation-modal/messages.js +18 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/field-action-slot/field-action-slot.js +80 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/field-context-menu/field-context-menu.js +115 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/field-edit-content/field-edit-content.js +101 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/chip.js +33 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/index.js +4 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/levels-chain.js +118 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/utils.js +34 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/__mocks__/getInitialValues.js +33 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/dropdown-default-values.js +15 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/dropdown-field-configuration.js +66 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/sortable-option-list.js +294 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/index.js +6 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-default-values.js +15 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-field-configuration.js +149 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-field-configurator-initial-state.js +54 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector-messages.js +38 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector.js +103 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/useTaxonomySelect.js +19 -0
- package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/utils.js +4 -0
- package/dist/esm/lib/components/metadata-field-configurator/context/field-configurator-context.js +68 -0
- package/dist/esm/lib/components/metadata-field-configurator/context/field-extensions-context.js +9 -0
- package/dist/esm/lib/components/metadata-field-configurator/context/taxonomy-options-context.js +23 -0
- package/dist/esm/lib/components/metadata-field-configurator/hooks/useFieldConfiguratorBehavior.js +119 -0
- package/dist/esm/lib/components/metadata-field-configurator/hooks/useFieldValidation.js +68 -0
- package/dist/esm/lib/components/metadata-field-configurator/hooks/useTaxonomyFetch.js +27 -0
- package/dist/esm/lib/components/metadata-field-configurator/hooks/useTemplateFieldSchema.js +44 -0
- package/dist/esm/lib/components/metadata-field-configurator/index.js +11 -0
- package/dist/esm/lib/components/metadata-field-configurator/messages/configurator-messages.js +136 -0
- package/dist/esm/lib/components/metadata-field-configurator/messages/dropdown-messages.js +38 -0
- package/dist/esm/lib/components/metadata-field-configurator/messages/levels-chain-messages.js +18 -0
- package/dist/esm/lib/components/metadata-field-configurator/messages/taxonomy-messages.js +38 -0
- package/dist/esm/lib/components/metadata-field-configurator/metadata-field-configurator.js +154 -0
- package/dist/esm/lib/components/metadata-field-configurator/utils.js +53 -0
- package/dist/esm/lib/components/metadata-field-list/index.js +5 -0
- package/dist/esm/lib/components/metadata-field-list/metadata-field-list.js +279 -0
- package/dist/esm/lib/components/metadata-template-editor-form/metadata-template-editor-form.js +137 -0
- package/dist/esm/lib/components/metadata-template-editor-modal/index.js +4 -0
- package/dist/esm/lib/components/metadata-template-editor-modal/metadata-template-editor-modal.js +103 -0
- package/dist/esm/lib/hooks/useMetadataTemplateFormSchema.js +16 -0
- package/dist/esm/lib/hooks/useTemplateNameSchema.js +12 -0
- package/dist/esm/lib/index.js +14 -0
- package/dist/esm/lib/messages.js +118 -0
- package/dist/esm/lib/metadata-template-editor.js +179 -0
- package/dist/esm/lib/utils/constants.js +8 -0
- package/dist/esm/lib/utils/field-options/field-type-icon.js +34 -0
- package/dist/esm/lib/utils/field-options/index.js +9 -0
- package/dist/esm/lib/utils/field-options/messages.js +48 -0
- package/dist/esm/lib/utils/field-options/useFieldOptions.js +19 -0
- package/dist/esm/lib/utils/key-generation.js +29 -0
- package/dist/esm/lib/utils/template-type-conversion/convertLocalConfiguratorToTemplateField.js +78 -0
- package/dist/esm/lib/utils/template-type-conversion/convertTemplateFieldToLocalConfigurator.js +90 -0
- package/dist/esm/lib/utils/template-type-conversion/generateJSONPatchTemplateOperations.js +179 -0
- package/dist/esm/lib/utils/template-type-conversion/mapFieldsWithUniqueKeys.js +14 -0
- package/dist/i18n/bn-IN.js +108 -0
- package/dist/i18n/bn-IN.properties +196 -0
- package/dist/i18n/da-DK.js +108 -0
- package/dist/i18n/da-DK.properties +196 -0
- package/dist/i18n/de-DE.js +108 -0
- package/dist/i18n/de-DE.properties +196 -0
- package/dist/i18n/en-AU.js +108 -0
- package/dist/i18n/en-AU.properties +196 -0
- package/dist/i18n/en-CA.js +108 -0
- package/dist/i18n/en-CA.properties +196 -0
- package/dist/i18n/en-GB.js +108 -0
- package/dist/i18n/en-GB.properties +196 -0
- package/dist/i18n/en-US.js +108 -0
- package/dist/i18n/en-US.properties +212 -0
- package/dist/i18n/en-x-pseudo.js +108 -0
- package/dist/i18n/en-x-pseudo.properties +196 -0
- package/dist/i18n/es-419.js +108 -0
- package/dist/i18n/es-419.properties +196 -0
- package/dist/i18n/es-ES.js +108 -0
- package/dist/i18n/es-ES.properties +196 -0
- package/dist/i18n/fi-FI.js +108 -0
- package/dist/i18n/fi-FI.properties +196 -0
- package/dist/i18n/fr-CA.js +108 -0
- package/dist/i18n/fr-CA.properties +196 -0
- package/dist/i18n/fr-FR.js +108 -0
- package/dist/i18n/fr-FR.properties +196 -0
- package/dist/i18n/hi-IN.js +108 -0
- package/dist/i18n/hi-IN.properties +196 -0
- package/dist/i18n/it-IT.js +108 -0
- package/dist/i18n/it-IT.properties +196 -0
- package/dist/i18n/ja-JP.js +108 -0
- package/dist/i18n/ja-JP.properties +196 -0
- package/dist/i18n/json/src/lib/components/field-selector/messages.json +1 -0
- package/dist/i18n/json/src/lib/components/field-type-dropdown/messages.json +1 -0
- package/dist/i18n/json/src/lib/components/field-type-tiles/messages.json +1 -0
- package/dist/i18n/json/src/lib/components/metadata-field-configurator/components/confirmation-modal/messages.json +1 -0
- package/dist/i18n/json/src/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector-messages.json +1 -0
- package/dist/i18n/json/src/lib/components/metadata-field-configurator/messages/configurator-messages.json +1 -0
- package/dist/i18n/json/src/lib/components/metadata-field-configurator/messages/dropdown-messages.json +1 -0
- package/dist/i18n/json/src/lib/components/metadata-field-configurator/messages/levels-chain-messages.json +1 -0
- package/dist/i18n/json/src/lib/components/metadata-field-configurator/messages/taxonomy-messages.json +1 -0
- package/dist/i18n/json/src/lib/messages.json +1 -0
- package/dist/i18n/json/src/lib/utils/field-options/messages.json +1 -0
- package/dist/i18n/ko-KR.js +108 -0
- package/dist/i18n/ko-KR.properties +196 -0
- package/dist/i18n/nb-NO.js +108 -0
- package/dist/i18n/nb-NO.properties +196 -0
- package/dist/i18n/nl-NL.js +108 -0
- package/dist/i18n/nl-NL.properties +196 -0
- package/dist/i18n/pl-PL.js +108 -0
- package/dist/i18n/pl-PL.properties +196 -0
- package/dist/i18n/pt-BR.js +108 -0
- package/dist/i18n/pt-BR.properties +196 -0
- package/dist/i18n/ru-RU.js +108 -0
- package/dist/i18n/ru-RU.properties +196 -0
- package/dist/i18n/sv-SE.js +108 -0
- package/dist/i18n/sv-SE.properties +196 -0
- package/dist/i18n/tr-TR.js +108 -0
- package/dist/i18n/tr-TR.properties +196 -0
- package/dist/i18n/zh-CN.js +108 -0
- package/dist/i18n/zh-CN.properties +196 -0
- package/dist/i18n/zh-TW.js +108 -0
- package/dist/i18n/zh-TW.properties +196 -0
- package/dist/styles/chip.css +1 -0
- package/dist/styles/dropdown-field-configuration.css +1 -0
- package/dist/styles/field-context-menu.css +1 -0
- package/dist/styles/field-selector.css +1 -0
- package/dist/styles/field-type-dropdown.css +1 -0
- package/dist/styles/levels-chain.css +1 -0
- package/dist/styles/metadata-field-configurator.css +1 -0
- package/dist/styles/metadata-field-list.css +1 -0
- package/dist/styles/metadata-template-editor-form.css +1 -0
- package/dist/styles/metadata-template-editor-modal.css +1 -0
- package/dist/styles/metadata-template-editor.css +1 -0
- package/dist/styles/sortable-option-list.css +1 -0
- package/dist/styles/taxonomy-field-configuration.css +1 -0
- package/dist/styles/taxonomy-field-configurator-initial-state.css +1 -0
- package/dist/styles/taxonomy-selector.css +1 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/lib/components/field-selector/field-selector.d.ts +16 -0
- package/dist/types/lib/components/field-selector/index.d.ts +1 -0
- package/dist/types/lib/components/field-selector/messages.d.ts +13 -0
- package/dist/types/lib/components/field-type-dropdown/field-type-dropdown.d.ts +15 -0
- package/dist/types/lib/components/field-type-dropdown/index.d.ts +2 -0
- package/dist/types/lib/components/field-type-dropdown/messages.d.ts +12 -0
- package/dist/types/lib/components/field-type-tiles/field-type-tiles.d.ts +12 -0
- package/dist/types/lib/components/field-type-tiles/index.d.ts +2 -0
- package/dist/types/lib/components/field-type-tiles/messages.d.ts +12 -0
- package/dist/types/lib/components/metadata-field-configurator/components/confirmation-modal/confirmation-modal.d.ts +31 -0
- package/dist/types/lib/components/metadata-field-configurator/components/confirmation-modal/messages.d.ts +18 -0
- package/dist/types/lib/components/metadata-field-configurator/components/field-action-slot/field-action-slot.d.ts +30 -0
- package/dist/types/lib/components/metadata-field-configurator/components/field-context-menu/field-context-menu.d.ts +23 -0
- package/dist/types/lib/components/metadata-field-configurator/components/field-edit-content/field-edit-content.d.ts +20 -0
- package/dist/types/lib/components/metadata-field-configurator/components/levels-chain/chip.d.ts +17 -0
- package/dist/types/lib/components/metadata-field-configurator/components/levels-chain/index.d.ts +1 -0
- package/dist/types/lib/components/metadata-field-configurator/components/levels-chain/levels-chain.d.ts +31 -0
- package/dist/types/lib/components/metadata-field-configurator/components/levels-chain/utils.d.ts +10 -0
- package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/__mocks__/getInitialValues.d.ts +2 -0
- package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/dropdown-default-values.d.ts +2 -0
- package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/dropdown-field-configuration.d.ts +1 -0
- package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/sortable-option-list.d.ts +6 -0
- package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/index.d.ts +2 -0
- package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-default-values.d.ts +2 -0
- package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-field-configuration.d.ts +1 -0
- package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-field-configurator-initial-state.d.ts +1 -0
- package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector-messages.d.ts +43 -0
- package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector.d.ts +12 -0
- package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/useTaxonomySelect.d.ts +5 -0
- package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/utils.d.ts +2 -0
- package/dist/types/lib/components/metadata-field-configurator/context/field-configurator-context.d.ts +57 -0
- package/dist/types/lib/components/metadata-field-configurator/context/field-extensions-context.d.ts +52 -0
- package/dist/types/lib/components/metadata-field-configurator/context/taxonomy-options-context.d.ts +21 -0
- package/dist/types/lib/components/metadata-field-configurator/hooks/useFieldConfiguratorBehavior.d.ts +57 -0
- package/dist/types/lib/components/metadata-field-configurator/hooks/useFieldValidation.d.ts +27 -0
- package/dist/types/lib/components/metadata-field-configurator/hooks/useTaxonomyFetch.d.ts +19 -0
- package/dist/types/lib/components/metadata-field-configurator/hooks/useTemplateFieldSchema.d.ts +15 -0
- package/dist/types/lib/components/metadata-field-configurator/index.d.ts +6 -0
- package/dist/types/lib/components/metadata-field-configurator/messages/configurator-messages.d.ts +164 -0
- package/dist/types/lib/components/metadata-field-configurator/messages/dropdown-messages.d.ts +43 -0
- package/dist/types/lib/components/metadata-field-configurator/messages/levels-chain-messages.d.ts +18 -0
- package/dist/types/lib/components/metadata-field-configurator/messages/taxonomy-messages.d.ts +43 -0
- package/dist/types/lib/components/metadata-field-configurator/metadata-field-configurator.d.ts +191 -0
- package/dist/types/lib/components/metadata-field-configurator/stories/story-fixtures.d.ts +5 -0
- package/dist/types/lib/components/metadata-field-configurator/utils.d.ts +24 -0
- package/dist/types/lib/components/metadata-field-list/index.d.ts +2 -0
- package/dist/types/lib/components/metadata-field-list/metadata-field-list.d.ts +109 -0
- package/dist/types/lib/components/metadata-template-editor-form/metadata-template-editor-form.d.ts +20 -0
- package/dist/types/lib/components/metadata-template-editor-modal/index.d.ts +1 -0
- package/dist/types/lib/components/metadata-template-editor-modal/metadata-template-editor-modal.d.ts +56 -0
- package/dist/types/lib/hooks/useMetadataTemplateFormSchema.d.ts +17 -0
- package/dist/types/lib/hooks/useTemplateNameSchema.d.ts +2 -0
- package/dist/types/lib/index.d.ts +7 -0
- package/dist/types/lib/messages.d.ts +143 -0
- package/dist/types/lib/metadata-template-editor.d.ts +290 -0
- package/dist/types/lib/types.d.ts +311 -0
- package/dist/types/lib/utils/constants.d.ts +9 -0
- package/dist/types/lib/utils/field-options/field-type-icon.d.ts +6 -0
- package/dist/types/lib/utils/field-options/index.d.ts +4 -0
- package/dist/types/lib/utils/field-options/messages.d.ts +60 -0
- package/dist/types/lib/utils/field-options/useFieldOptions.d.ts +34 -0
- package/dist/types/lib/utils/key-generation.d.ts +24 -0
- package/dist/types/lib/utils/template-type-conversion/convertLocalConfiguratorToTemplateField.d.ts +25 -0
- package/dist/types/lib/utils/template-type-conversion/convertTemplateFieldToLocalConfigurator.d.ts +8 -0
- package/dist/types/lib/utils/template-type-conversion/generateJSONPatchTemplateOperations.d.ts +16 -0
- package/dist/types/lib/utils/template-type-conversion/mapFieldsWithUniqueKeys.d.ts +8 -0
- package/package.json +61 -0
package/dist/esm/lib/components/metadata-template-editor-modal/metadata-template-editor-modal.js
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { MetadataTemplateEditor as D } from "../../metadata-template-editor.js";
|
|
2
|
+
import { M as A } from "../../../../chunks/types.js";
|
|
3
|
+
import "../field-type-tiles/field-type-tiles.js";
|
|
4
|
+
import "../metadata-field-list/metadata-field-list.js";
|
|
5
|
+
import "../field-selector/field-selector.js";
|
|
6
|
+
import "../field-type-dropdown/field-type-dropdown.js";
|
|
7
|
+
import "../metadata-field-configurator/hooks/useTemplateFieldSchema.js";
|
|
8
|
+
import "../metadata-field-configurator/metadata-field-configurator.js";
|
|
9
|
+
import "../metadata-field-configurator/utils.js";
|
|
10
|
+
import "../metadata-field-configurator/context/field-extensions-context.js";
|
|
11
|
+
import { useId as F, useRef as j, useState as c, useCallback as k, useEffect as w } from "react";
|
|
12
|
+
import z from "clsx";
|
|
13
|
+
import { Modal as e } from "@box/blueprint-web";
|
|
14
|
+
import { useIntl as R } from "react-intl";
|
|
15
|
+
import r from "../../messages.js";
|
|
16
|
+
import { jsx as t, jsxs as T } from "react/jsx-runtime";
|
|
17
|
+
import '../../../../styles/metadata-template-editor-modal.css';const H = "_modal_q1b7q_1", G = "_centeredBody_q1b7q_7", h = {
|
|
18
|
+
modal: H,
|
|
19
|
+
centeredBody: G
|
|
20
|
+
};
|
|
21
|
+
function re({
|
|
22
|
+
open: m,
|
|
23
|
+
onOpenChange: i,
|
|
24
|
+
onTemplateLoad: C,
|
|
25
|
+
onValidationChange: E,
|
|
26
|
+
onCancel: f,
|
|
27
|
+
title: B,
|
|
28
|
+
...s
|
|
29
|
+
}) {
|
|
30
|
+
const o = R(), p = F(), d = j(null), [u, y] = c(!1), [S, b] = c(!1), [n, g] = c(void 0), l = s.mode === A.Edit, q = k(() => {
|
|
31
|
+
f?.(), i(!1);
|
|
32
|
+
}, [f, i]);
|
|
33
|
+
w(() => {
|
|
34
|
+
m || (b(!1), g(void 0));
|
|
35
|
+
}, [m]);
|
|
36
|
+
const N = (a) => {
|
|
37
|
+
a ? i(a) : d.current?.requestClose();
|
|
38
|
+
}, _ = (a) => {
|
|
39
|
+
g(a.displayName), C?.(a);
|
|
40
|
+
}, M = (a) => async (x) => {
|
|
41
|
+
y(!0);
|
|
42
|
+
try {
|
|
43
|
+
await a(x), i(!1);
|
|
44
|
+
} finally {
|
|
45
|
+
y(!1);
|
|
46
|
+
}
|
|
47
|
+
}, v = l ? {
|
|
48
|
+
...s,
|
|
49
|
+
onEditTemplate: M(s.onEditTemplate)
|
|
50
|
+
} : {
|
|
51
|
+
...s,
|
|
52
|
+
onCreateTemplate: M(s.onCreateTemplate)
|
|
53
|
+
}, I = u || l && !S, L = l && !n;
|
|
54
|
+
return /* @__PURE__ */ t(e, {
|
|
55
|
+
open: m,
|
|
56
|
+
onOpenChange: N,
|
|
57
|
+
children: /* @__PURE__ */ T(e.Content, {
|
|
58
|
+
size: "large",
|
|
59
|
+
className: h.modal,
|
|
60
|
+
children: [/* @__PURE__ */ t(e.Header, {
|
|
61
|
+
children: B ?? (l && n ? o.formatMessage(r.editTitle, {
|
|
62
|
+
templateName: n
|
|
63
|
+
}) : o.formatMessage(r.createTitle))
|
|
64
|
+
}), /* @__PURE__ */ t(e.ScrollableContainer, {
|
|
65
|
+
className: z({
|
|
66
|
+
[h.centeredBody]: L
|
|
67
|
+
}),
|
|
68
|
+
children: /* @__PURE__ */ t(e.Body, {
|
|
69
|
+
children: /* @__PURE__ */ t(D, {
|
|
70
|
+
...v,
|
|
71
|
+
ref: d,
|
|
72
|
+
formId: p,
|
|
73
|
+
hideActions: !0,
|
|
74
|
+
onCancel: q,
|
|
75
|
+
onDirtyStateChange: b,
|
|
76
|
+
onValidationChange: E,
|
|
77
|
+
onTemplateLoad: _
|
|
78
|
+
})
|
|
79
|
+
})
|
|
80
|
+
}), /* @__PURE__ */ T(e.Footer, {
|
|
81
|
+
children: [/* @__PURE__ */ t(e.Footer.SecondaryButton, {
|
|
82
|
+
onClick: () => d.current?.requestClose(),
|
|
83
|
+
size: "large",
|
|
84
|
+
children: o.formatMessage(r.cancel)
|
|
85
|
+
}), /* @__PURE__ */ t(e.Footer.PrimaryButton, {
|
|
86
|
+
variant: "primary",
|
|
87
|
+
type: "submit",
|
|
88
|
+
form: p,
|
|
89
|
+
loading: u,
|
|
90
|
+
loadingAriaLabel: o.formatMessage(r.submitting),
|
|
91
|
+
disabled: I,
|
|
92
|
+
children: o.formatMessage(r.save)
|
|
93
|
+
})]
|
|
94
|
+
}), /* @__PURE__ */ t(e.Close, {
|
|
95
|
+
"aria-label": o.formatMessage(r.closeAriaLabel)
|
|
96
|
+
})]
|
|
97
|
+
})
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
export {
|
|
101
|
+
re as MetadataTemplateEditorModal,
|
|
102
|
+
re as default
|
|
103
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useMemo as a } from "react";
|
|
2
|
+
import * as e from "yup";
|
|
3
|
+
import { useTemplateNameSchema as o } from "./useTemplateNameSchema.js";
|
|
4
|
+
import { useTemplateFieldSchema as r } from "../components/metadata-field-configurator/hooks/useTemplateFieldSchema.js";
|
|
5
|
+
const l = () => {
|
|
6
|
+
const m = r(), t = o();
|
|
7
|
+
return a(() => e.object().shape({
|
|
8
|
+
displayName: t,
|
|
9
|
+
templateKey: e.string().notRequired(),
|
|
10
|
+
fields: e.array().of(m).notRequired(),
|
|
11
|
+
hidden: e.boolean()
|
|
12
|
+
}), [m, t]);
|
|
13
|
+
};
|
|
14
|
+
export {
|
|
15
|
+
l as useMetadataTemplateFormSchema
|
|
16
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useMemo as s } from "react";
|
|
2
|
+
import { useIntl as r } from "react-intl";
|
|
3
|
+
import * as a from "yup";
|
|
4
|
+
import { METADATA_TEMPLATE_NAME_MAX_LENGTH as i } from "../utils/constants.js";
|
|
5
|
+
import t from "../messages.js";
|
|
6
|
+
const n = ["new_template"], M = () => {
|
|
7
|
+
const e = r();
|
|
8
|
+
return s(() => a.string().min(1).max(i, e.formatMessage(t.fieldNameTooLong)).required(e.formatMessage(t.fieldRequired)).test("no-whitespace-only", e.formatMessage(t.fieldRequired), (o) => !o || o.trim().length > 0).test("forbidden-display-name", e.formatMessage(t.forbiddenDisplayName), (o) => !n.some((m) => o.toLowerCase().includes(m))), [e]);
|
|
9
|
+
};
|
|
10
|
+
export {
|
|
11
|
+
M as useTemplateNameSchema
|
|
12
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MetadataTemplateEditor as a } from "./metadata-template-editor.js";
|
|
2
|
+
import { useMetadataTemplateFormSchema as r } from "./hooks/useMetadataTemplateFormSchema.js";
|
|
3
|
+
import { useTemplateNameSchema as p } from "./hooks/useTemplateNameSchema.js";
|
|
4
|
+
import { convertApiMetadataTemplateFieldToLocalConfiguratorField as l } from "./utils/template-type-conversion/convertTemplateFieldToLocalConfigurator.js";
|
|
5
|
+
import { mapFieldsWithUniqueKeys as f } from "./utils/template-type-conversion/mapFieldsWithUniqueKeys.js";
|
|
6
|
+
import { generateJSONPatchTemplateOperations as T } from "./utils/template-type-conversion/generateJSONPatchTemplateOperations.js";
|
|
7
|
+
export {
|
|
8
|
+
a as MetadataTemplateEditor,
|
|
9
|
+
l as convertApiMetadataTemplateFieldToLocalConfiguratorField,
|
|
10
|
+
T as generateJSONPatchTemplateOperations,
|
|
11
|
+
f as mapFieldsWithUniqueKeys,
|
|
12
|
+
r as useMetadataTemplateFormSchema,
|
|
13
|
+
p as useTemplateNameSchema
|
|
14
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { defineMessages as e } from "react-intl";
|
|
2
|
+
const t = e({
|
|
3
|
+
createTitle: {
|
|
4
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.createTitle",
|
|
5
|
+
defaultMessage: "New Metadata Template"
|
|
6
|
+
},
|
|
7
|
+
editTitle: {
|
|
8
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.editTitle",
|
|
9
|
+
defaultMessage: 'Edit "{templateName}" Metadata Template'
|
|
10
|
+
},
|
|
11
|
+
templateName: {
|
|
12
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.templateName.label",
|
|
13
|
+
defaultMessage: "Template Name"
|
|
14
|
+
},
|
|
15
|
+
templateNameDescription: {
|
|
16
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.templateName.description",
|
|
17
|
+
defaultMessage: "Display name of the template shown to users"
|
|
18
|
+
},
|
|
19
|
+
cancel: {
|
|
20
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.cancel",
|
|
21
|
+
defaultMessage: "Cancel"
|
|
22
|
+
},
|
|
23
|
+
save: {
|
|
24
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.save",
|
|
25
|
+
defaultMessage: "Save"
|
|
26
|
+
},
|
|
27
|
+
fields: {
|
|
28
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.fields.label",
|
|
29
|
+
defaultMessage: "Fields"
|
|
30
|
+
},
|
|
31
|
+
fieldsAddFirst: {
|
|
32
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.fields.description",
|
|
33
|
+
defaultMessage: "Add your first field to the Template:"
|
|
34
|
+
},
|
|
35
|
+
fieldsLearnMore: {
|
|
36
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.fields.learnMore",
|
|
37
|
+
defaultMessage: "Learn more about Metadata Field Types"
|
|
38
|
+
},
|
|
39
|
+
fieldRequired: {
|
|
40
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.fieldRequired",
|
|
41
|
+
defaultMessage: "This field is required"
|
|
42
|
+
},
|
|
43
|
+
forbiddenDisplayName: {
|
|
44
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.forbiddenDisplayName",
|
|
45
|
+
defaultMessage: "This display name is forbidden. Please choose another one."
|
|
46
|
+
},
|
|
47
|
+
invalidCharacters: {
|
|
48
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.invalidCharacters",
|
|
49
|
+
defaultMessage: "The field contains illegal characters."
|
|
50
|
+
},
|
|
51
|
+
fieldNameTooLong: {
|
|
52
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.fieldNameTooLong",
|
|
53
|
+
defaultMessage: "The field name is too long."
|
|
54
|
+
},
|
|
55
|
+
displayNameUsedBefore: {
|
|
56
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.displayNameUsedBefore",
|
|
57
|
+
defaultMessage: "This display name has already been used before. Please choose another one."
|
|
58
|
+
},
|
|
59
|
+
submitting: {
|
|
60
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.submitting",
|
|
61
|
+
defaultMessage: "Submitting..."
|
|
62
|
+
},
|
|
63
|
+
closeAriaLabel: {
|
|
64
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.closeAriaLabel",
|
|
65
|
+
defaultMessage: "Close metadata template editor"
|
|
66
|
+
},
|
|
67
|
+
saveSuccessNotification: {
|
|
68
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.saveSuccessNotification",
|
|
69
|
+
defaultMessage: "Template saved successfully."
|
|
70
|
+
},
|
|
71
|
+
saveErrorNotification: {
|
|
72
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.saveErrorNotification",
|
|
73
|
+
defaultMessage: "Failed to save template. Please try again."
|
|
74
|
+
},
|
|
75
|
+
notificationSuccessIconAriaLabel: {
|
|
76
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.notificationSuccessIconAriaLabel",
|
|
77
|
+
defaultMessage: "Success"
|
|
78
|
+
},
|
|
79
|
+
notificationErrorIconAriaLabel: {
|
|
80
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.notificationErrorIconAriaLabel",
|
|
81
|
+
defaultMessage: "Error"
|
|
82
|
+
},
|
|
83
|
+
notificationCloseButtonAriaLabel: {
|
|
84
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.notificationCloseButtonAriaLabel",
|
|
85
|
+
defaultMessage: "Close notification"
|
|
86
|
+
},
|
|
87
|
+
loading: {
|
|
88
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.loading",
|
|
89
|
+
defaultMessage: "Loading template…"
|
|
90
|
+
},
|
|
91
|
+
fetchError: {
|
|
92
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.fetchError",
|
|
93
|
+
defaultMessage: "Something went wrong. Please reload to try again."
|
|
94
|
+
},
|
|
95
|
+
reload: {
|
|
96
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.reload",
|
|
97
|
+
defaultMessage: "Reload"
|
|
98
|
+
},
|
|
99
|
+
unsavedChangesTitle: {
|
|
100
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.unsavedChangesTitle",
|
|
101
|
+
defaultMessage: "Unsaved Changes"
|
|
102
|
+
},
|
|
103
|
+
unsavedChangesBody: {
|
|
104
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.unsavedChangesBody",
|
|
105
|
+
defaultMessage: "You have unsaved changes. If you leave now, your changes will be lost."
|
|
106
|
+
},
|
|
107
|
+
unsavedChangesDiscard: {
|
|
108
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.unsavedChangesDiscard",
|
|
109
|
+
defaultMessage: "Leave Without Saving"
|
|
110
|
+
},
|
|
111
|
+
unsavedChangesKeepEditing: {
|
|
112
|
+
id: "groupSharedFeatures.metadataTemplateEditor.templateForm.unsavedChangesKeepEditing",
|
|
113
|
+
defaultMessage: "Keep Editing"
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
export {
|
|
117
|
+
t as default
|
|
118
|
+
};
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { forwardRef as W, useState as n, useCallback as L, useImperativeHandle as G, useEffect as N, useMemo as Q } from "react";
|
|
2
|
+
import { Formik as X } from "formik";
|
|
3
|
+
import { useIntl as Y } from "react-intl";
|
|
4
|
+
import { useNotification as Z, LoadingIndicator as $, EmptyState as M, Text as P } from "@box/blueprint-web";
|
|
5
|
+
import { ErrorState404 as ee } from "@box/blueprint-web-assets/illustrations/Medium";
|
|
6
|
+
import { ArrowsRotating as te } from "@box/blueprint-web-assets/icons/Line";
|
|
7
|
+
import { M as ae } from "../../chunks/types.js";
|
|
8
|
+
import { useMetadataTemplateFormSchema as oe } from "./hooks/useMetadataTemplateFormSchema.js";
|
|
9
|
+
import { convertApiMetadataTemplateFieldToLocalConfiguratorField as ie } from "./utils/template-type-conversion/convertTemplateFieldToLocalConfigurator.js";
|
|
10
|
+
import { mapFieldsWithUniqueKeys as re } from "./utils/template-type-conversion/mapFieldsWithUniqueKeys.js";
|
|
11
|
+
import { generateJSONPatchTemplateOperations as se } from "./utils/template-type-conversion/generateJSONPatchTemplateOperations.js";
|
|
12
|
+
import ne from "./components/metadata-template-editor-form/metadata-template-editor-form.js";
|
|
13
|
+
import le from "./components/metadata-field-configurator/components/confirmation-modal/confirmation-modal.js";
|
|
14
|
+
import a from "./messages.js";
|
|
15
|
+
import { CONFLICT_HTTP_STATUS as ce } from "./utils/constants.js";
|
|
16
|
+
import { jsx as r, jsxs as de, Fragment as me } from "react/jsx-runtime";
|
|
17
|
+
import "./hooks/useTemplateNameSchema.js";
|
|
18
|
+
import '../../styles/metadata-template-editor.css';const fe = "_loading_1o2vk_8", pe = "_error_1o2vk_15", A = {
|
|
19
|
+
loading: fe,
|
|
20
|
+
error: pe
|
|
21
|
+
}, ue = {
|
|
22
|
+
displayName: "",
|
|
23
|
+
templateKey: "",
|
|
24
|
+
fields: [],
|
|
25
|
+
hidden: !1
|
|
26
|
+
}, Ue = /* @__PURE__ */ W(function({
|
|
27
|
+
onCancel: d,
|
|
28
|
+
onDirtyStateChange: u,
|
|
29
|
+
onValidationChange: I,
|
|
30
|
+
onSubmitError: S,
|
|
31
|
+
onTemplateLoad: h,
|
|
32
|
+
taxonomyOptions: F,
|
|
33
|
+
fetchTaxonomies: _,
|
|
34
|
+
formId: B,
|
|
35
|
+
hideActions: K = !1,
|
|
36
|
+
fieldExtensions: U,
|
|
37
|
+
...l
|
|
38
|
+
}, w) {
|
|
39
|
+
const x = oe(), {
|
|
40
|
+
formatMessage: t
|
|
41
|
+
} = Y(), {
|
|
42
|
+
addNotification: y
|
|
43
|
+
} = Z(), c = l.mode === ae.Edit, [g, k] = n(!1), [D, m] = n(!1), f = L(() => {
|
|
44
|
+
g ? m(!0) : d?.();
|
|
45
|
+
}, [g, d]);
|
|
46
|
+
G(w, () => ({
|
|
47
|
+
requestClose: f
|
|
48
|
+
}), [f]);
|
|
49
|
+
const O = L((e) => {
|
|
50
|
+
k(e), u?.(e);
|
|
51
|
+
}, [u]), [V, v] = n(c), [H, C] = n(!1), [R, j] = n(0), [o, T] = n(void 0), p = c ? l.fetchTemplate : void 0, q = () => {
|
|
52
|
+
j((e) => e + 1);
|
|
53
|
+
};
|
|
54
|
+
N(() => {
|
|
55
|
+
if (!p)
|
|
56
|
+
return;
|
|
57
|
+
let e = !1;
|
|
58
|
+
return v(!0), C(!1), T(void 0), (async () => {
|
|
59
|
+
try {
|
|
60
|
+
const s = await p();
|
|
61
|
+
e || T(s);
|
|
62
|
+
} catch {
|
|
63
|
+
e || C(!0);
|
|
64
|
+
} finally {
|
|
65
|
+
e || v(!1);
|
|
66
|
+
}
|
|
67
|
+
})(), () => {
|
|
68
|
+
e = !0;
|
|
69
|
+
};
|
|
70
|
+
}, [p, R]), N(() => {
|
|
71
|
+
o !== void 0 && h?.(o);
|
|
72
|
+
}, [o, h]);
|
|
73
|
+
const E = c ? void 0 : l.namespace, b = Q(() => o ? {
|
|
74
|
+
displayName: o.displayName,
|
|
75
|
+
templateKey: o.templateKey,
|
|
76
|
+
namespace: o.namespace,
|
|
77
|
+
hidden: o.isHidden,
|
|
78
|
+
fields: o.fields.map((e) => ie(e))
|
|
79
|
+
} : {
|
|
80
|
+
...ue,
|
|
81
|
+
namespace: E ?? ""
|
|
82
|
+
}, [o, E]), z = async (e) => {
|
|
83
|
+
try {
|
|
84
|
+
if (c) {
|
|
85
|
+
const i = se(b, e);
|
|
86
|
+
await l.onEditTemplate(i);
|
|
87
|
+
} else {
|
|
88
|
+
const i = re(e.fields), s = {
|
|
89
|
+
namespace: e.namespace,
|
|
90
|
+
templateKey: e.templateKey,
|
|
91
|
+
displayName: e.displayName,
|
|
92
|
+
hidden: e.hidden,
|
|
93
|
+
fields: i
|
|
94
|
+
};
|
|
95
|
+
await l.onCreateTemplate(s);
|
|
96
|
+
}
|
|
97
|
+
y({
|
|
98
|
+
sensitivity: "foreground",
|
|
99
|
+
variant: "success",
|
|
100
|
+
styledText: t(a.saveSuccessNotification),
|
|
101
|
+
typeIconAriaLabel: t(a.notificationSuccessIconAriaLabel),
|
|
102
|
+
closeButtonAriaLabel: t(a.notificationCloseButtonAriaLabel)
|
|
103
|
+
});
|
|
104
|
+
} catch (i) {
|
|
105
|
+
let s;
|
|
106
|
+
if (i instanceof Error && "status" in i) {
|
|
107
|
+
const {
|
|
108
|
+
status: J
|
|
109
|
+
} = i;
|
|
110
|
+
s = t(J === ce ? a.displayNameUsedBefore : a.saveErrorNotification);
|
|
111
|
+
} else
|
|
112
|
+
s = t(a.saveErrorNotification);
|
|
113
|
+
y({
|
|
114
|
+
sensitivity: "foreground",
|
|
115
|
+
variant: "error",
|
|
116
|
+
styledText: s,
|
|
117
|
+
typeIconAriaLabel: t(a.notificationErrorIconAriaLabel),
|
|
118
|
+
closeButtonAriaLabel: t(a.notificationCloseButtonAriaLabel)
|
|
119
|
+
});
|
|
120
|
+
try {
|
|
121
|
+
S?.(i);
|
|
122
|
+
} catch {
|
|
123
|
+
}
|
|
124
|
+
throw i;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
127
|
+
return V ? /* @__PURE__ */ r("div", {
|
|
128
|
+
className: A.loading,
|
|
129
|
+
children: /* @__PURE__ */ r($, {
|
|
130
|
+
size: "large",
|
|
131
|
+
"aria-label": t(a.loading)
|
|
132
|
+
})
|
|
133
|
+
}) : H ? /* @__PURE__ */ r("div", {
|
|
134
|
+
className: A.error,
|
|
135
|
+
children: /* @__PURE__ */ r(M, {
|
|
136
|
+
body: /* @__PURE__ */ r(P, {
|
|
137
|
+
as: "p",
|
|
138
|
+
children: t(a.fetchError)
|
|
139
|
+
}),
|
|
140
|
+
illustration: ee,
|
|
141
|
+
size: "large",
|
|
142
|
+
children: /* @__PURE__ */ r(M.PrimaryAction, {
|
|
143
|
+
startIcon: te,
|
|
144
|
+
onClick: q,
|
|
145
|
+
children: t(a.reload)
|
|
146
|
+
})
|
|
147
|
+
})
|
|
148
|
+
}) : /* @__PURE__ */ de(me, {
|
|
149
|
+
children: [/* @__PURE__ */ r(X, {
|
|
150
|
+
initialValues: b,
|
|
151
|
+
validationSchema: x,
|
|
152
|
+
onSubmit: z,
|
|
153
|
+
children: /* @__PURE__ */ r(ne, {
|
|
154
|
+
formId: B,
|
|
155
|
+
onCancel: f,
|
|
156
|
+
taxonomyOptions: F,
|
|
157
|
+
fetchTaxonomies: _,
|
|
158
|
+
hideActions: K,
|
|
159
|
+
isEditMode: c,
|
|
160
|
+
onDirtyStateChange: O,
|
|
161
|
+
onValidationChange: I,
|
|
162
|
+
fieldExtensions: U
|
|
163
|
+
})
|
|
164
|
+
}), D && /* @__PURE__ */ r(le, {
|
|
165
|
+
onClose: () => m(!1),
|
|
166
|
+
onConfirm: () => {
|
|
167
|
+
m(!1), d?.();
|
|
168
|
+
},
|
|
169
|
+
title: t(a.unsavedChangesTitle),
|
|
170
|
+
body: t(a.unsavedChangesBody),
|
|
171
|
+
confirmLabel: t(a.unsavedChangesDiscard),
|
|
172
|
+
cancelLabel: t(a.unsavedChangesKeepEditing)
|
|
173
|
+
})]
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
export {
|
|
177
|
+
Ue as MetadataTemplateEditor,
|
|
178
|
+
Ue as default
|
|
179
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
const T = 4096, A = 256, E = 64, _ = 4096, M = 409;
|
|
2
|
+
export {
|
|
3
|
+
M as CONFLICT_HTTP_STATUS,
|
|
4
|
+
A as METADATA_TEMPLATE_FIELD_KEY_MAX_LENGTH,
|
|
5
|
+
T as METADATA_TEMPLATE_FIELD_NAME_MAX_LENGTH,
|
|
6
|
+
E as METADATA_TEMPLATE_KEY_MAX_LENGTH,
|
|
7
|
+
_ as METADATA_TEMPLATE_NAME_MAX_LENGTH
|
|
8
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { TextInput as n, Taxonomy as o, Section as m, Calendar as u, Numbers as c } from "@box/blueprint-web-assets/icons/Medium";
|
|
2
|
+
import { F as t } from "../../../../chunks/types.js";
|
|
3
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
4
|
+
const d = (a) => (e) => {
|
|
5
|
+
switch (a) {
|
|
6
|
+
case t.Text:
|
|
7
|
+
return /* @__PURE__ */ r(n, {
|
|
8
|
+
...e
|
|
9
|
+
});
|
|
10
|
+
case t.Number:
|
|
11
|
+
return /* @__PURE__ */ r(c, {
|
|
12
|
+
...e
|
|
13
|
+
});
|
|
14
|
+
case t.Date:
|
|
15
|
+
return /* @__PURE__ */ r(u, {
|
|
16
|
+
...e
|
|
17
|
+
});
|
|
18
|
+
case t.Dropdown:
|
|
19
|
+
return /* @__PURE__ */ r(m, {
|
|
20
|
+
...e
|
|
21
|
+
});
|
|
22
|
+
case t.Taxonomy:
|
|
23
|
+
return /* @__PURE__ */ r(o, {
|
|
24
|
+
...e
|
|
25
|
+
});
|
|
26
|
+
default:
|
|
27
|
+
return /* @__PURE__ */ r(n, {
|
|
28
|
+
...e
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
export {
|
|
33
|
+
d as FieldTypeIcon
|
|
34
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FieldTypeIcon as o } from "./field-type-icon.js";
|
|
2
|
+
import { fieldTypeDescriptionMessages as p, fieldTypesTitleMessages as r } from "./messages.js";
|
|
3
|
+
import { useFieldOptions as f } from "./useFieldOptions.js";
|
|
4
|
+
export {
|
|
5
|
+
o as FieldTypeIcon,
|
|
6
|
+
p as fieldTypeDescriptionMessages,
|
|
7
|
+
r as fieldTypesTitleMessages,
|
|
8
|
+
f as useFieldOptions
|
|
9
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { defineMessages as e } from "react-intl";
|
|
2
|
+
const t = e({
|
|
3
|
+
text: {
|
|
4
|
+
id: "groupSharedFeatures.metadataTemplateEditor.fieldTypes.text",
|
|
5
|
+
defaultMessage: "Text"
|
|
6
|
+
},
|
|
7
|
+
number: {
|
|
8
|
+
id: "groupSharedFeatures.metadataTemplateEditor.fieldTypes.number",
|
|
9
|
+
defaultMessage: "Number"
|
|
10
|
+
},
|
|
11
|
+
date: {
|
|
12
|
+
id: "groupSharedFeatures.metadataTemplateEditor.fieldTypes.date",
|
|
13
|
+
defaultMessage: "Date"
|
|
14
|
+
},
|
|
15
|
+
dropdown: {
|
|
16
|
+
id: "groupSharedFeatures.metadataTemplateEditor.fieldTypes.dropdown",
|
|
17
|
+
defaultMessage: "Dropdown"
|
|
18
|
+
},
|
|
19
|
+
taxonomy: {
|
|
20
|
+
id: "groupSharedFeatures.metadataTemplateEditor.fieldTypes.taxonomy",
|
|
21
|
+
defaultMessage: "Taxonomy"
|
|
22
|
+
}
|
|
23
|
+
}), d = e({
|
|
24
|
+
text: {
|
|
25
|
+
id: "groupSharedFeatures.metadataTemplateEditor.fieldTypeDescriptions.text",
|
|
26
|
+
defaultMessage: "Free text input up to 10,000 characters"
|
|
27
|
+
},
|
|
28
|
+
number: {
|
|
29
|
+
id: "groupSharedFeatures.metadataTemplateEditor.fieldTypeDescriptions.number",
|
|
30
|
+
defaultMessage: "Supports all numeric values"
|
|
31
|
+
},
|
|
32
|
+
date: {
|
|
33
|
+
id: "groupSharedFeatures.metadataTemplateEditor.fieldTypeDescriptions.date",
|
|
34
|
+
defaultMessage: "Date field with calendar picker"
|
|
35
|
+
},
|
|
36
|
+
dropdown: {
|
|
37
|
+
id: "groupSharedFeatures.metadataTemplateEditor.fieldTypeDescriptions.dropdown",
|
|
38
|
+
defaultMessage: "Supports single and multiple selections"
|
|
39
|
+
},
|
|
40
|
+
taxonomy: {
|
|
41
|
+
id: "groupSharedFeatures.metadataTemplateEditor.fieldTypeDescriptions.taxonomy",
|
|
42
|
+
defaultMessage: "Hierarchical list of selectable options"
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
export {
|
|
46
|
+
d as fieldTypeDescriptionMessages,
|
|
47
|
+
t as fieldTypesTitleMessages
|
|
48
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { FieldTypeIcon as i } from "./field-type-icon.js";
|
|
2
|
+
import { fieldTypeDescriptionMessages as o, fieldTypesTitleMessages as l } from "./messages.js";
|
|
3
|
+
import { useMemo as r } from "react";
|
|
4
|
+
import { useIntl as a } from "react-intl";
|
|
5
|
+
import { F as t } from "../../../../chunks/types.js";
|
|
6
|
+
function T() {
|
|
7
|
+
const s = a();
|
|
8
|
+
return {
|
|
9
|
+
availableFieldTypes: r(() => Object.values(t).map((e) => ({
|
|
10
|
+
type: e,
|
|
11
|
+
label: s.formatMessage(l[e]),
|
|
12
|
+
description: s.formatMessage(o[e]),
|
|
13
|
+
Icon: i(e)
|
|
14
|
+
})), [s])
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
T as useFieldOptions
|
|
19
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
function u(r, t) {
|
|
2
|
+
const s = r.replace(/[^a-zA-Z0-9\s]/g, "").replace(/\w*/g, (n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).replace(/\s/g, ""), e = s.charAt(0).toLowerCase() + s.slice(1);
|
|
3
|
+
return e.length !== 0 ? /^\d/.test(e) ? t + e : e : t;
|
|
4
|
+
}
|
|
5
|
+
const l = (r, t) => !t.includes(r), p = ({
|
|
6
|
+
displayName: r,
|
|
7
|
+
existingKeys: t,
|
|
8
|
+
defaultKey: a,
|
|
9
|
+
maxKeyLength: o
|
|
10
|
+
}) => {
|
|
11
|
+
if (o <= 3)
|
|
12
|
+
throw new Error("max key length is too short");
|
|
13
|
+
const s = o - 3, e = u(r, a).substring(0, s);
|
|
14
|
+
if (l(e, t))
|
|
15
|
+
return e;
|
|
16
|
+
let n = 1, c = 0, i;
|
|
17
|
+
do {
|
|
18
|
+
if (c >= 1e3)
|
|
19
|
+
throw new Error("Exceeded maximum iterations while generating unique key");
|
|
20
|
+
i = `${e}${n}`, n += 1, c += 1;
|
|
21
|
+
} while (!l(i, t));
|
|
22
|
+
if (i.length > o)
|
|
23
|
+
throw new Error("could not generate unique key less than max key length");
|
|
24
|
+
return i;
|
|
25
|
+
};
|
|
26
|
+
export {
|
|
27
|
+
u as displayNameToKey,
|
|
28
|
+
p as generateKey
|
|
29
|
+
};
|
package/dist/esm/lib/utils/template-type-conversion/convertLocalConfiguratorToTemplateField.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { T as i, F as s, A as l } from "../../../../chunks/types.js";
|
|
2
|
+
import { generateKey as d } from "../key-generation.js";
|
|
3
|
+
import { METADATA_TEMPLATE_FIELD_KEY_MAX_LENGTH as T } from "../constants.js";
|
|
4
|
+
const u = (e) => {
|
|
5
|
+
const {
|
|
6
|
+
taxonomy: o
|
|
7
|
+
} = e, p = o.availableTaxonomies.find((t) => t.taxonomyKey === o.taxonomyKey)?.levels.map((t) => t.level) || [];
|
|
8
|
+
return o.selection === i.AllowAny ? p : o.selectedLevels || [];
|
|
9
|
+
}, L = (e, o = []) => {
|
|
10
|
+
const {
|
|
11
|
+
name: y,
|
|
12
|
+
description: p,
|
|
13
|
+
hidden: r,
|
|
14
|
+
type: t
|
|
15
|
+
} = e, m = d({
|
|
16
|
+
displayName: y,
|
|
17
|
+
existingKeys: o,
|
|
18
|
+
defaultKey: "field",
|
|
19
|
+
maxKeyLength: T
|
|
20
|
+
}), n = {
|
|
21
|
+
key: m,
|
|
22
|
+
displayName: y,
|
|
23
|
+
description: p,
|
|
24
|
+
hidden: r
|
|
25
|
+
};
|
|
26
|
+
let a;
|
|
27
|
+
switch (t) {
|
|
28
|
+
case s.Text:
|
|
29
|
+
a = {
|
|
30
|
+
...n,
|
|
31
|
+
type: l.String
|
|
32
|
+
};
|
|
33
|
+
break;
|
|
34
|
+
case s.Number:
|
|
35
|
+
a = {
|
|
36
|
+
...n,
|
|
37
|
+
type: l.Float
|
|
38
|
+
};
|
|
39
|
+
break;
|
|
40
|
+
case s.Date:
|
|
41
|
+
a = {
|
|
42
|
+
...n,
|
|
43
|
+
type: l.Date
|
|
44
|
+
};
|
|
45
|
+
break;
|
|
46
|
+
case s.Dropdown:
|
|
47
|
+
a = {
|
|
48
|
+
...n,
|
|
49
|
+
type: e.dropdown.allowMultipleSelections ? l.MultiSelect : l.Enum,
|
|
50
|
+
options: e.dropdown.options.map((c) => ({
|
|
51
|
+
key: c.key
|
|
52
|
+
}))
|
|
53
|
+
};
|
|
54
|
+
break;
|
|
55
|
+
case s.Taxonomy:
|
|
56
|
+
a = {
|
|
57
|
+
...n,
|
|
58
|
+
type: l.Taxonomy,
|
|
59
|
+
taxonomyKey: e.taxonomy.taxonomyKey,
|
|
60
|
+
optionsRules: {
|
|
61
|
+
selectableLevels: u(e),
|
|
62
|
+
multiSelect: e.taxonomy.allowMultipleSelections
|
|
63
|
+
},
|
|
64
|
+
namespace: e.taxonomy.namespace
|
|
65
|
+
};
|
|
66
|
+
break;
|
|
67
|
+
default:
|
|
68
|
+
throw new Error(`Unsupported field type: ${t}`);
|
|
69
|
+
}
|
|
70
|
+
return {
|
|
71
|
+
field: a,
|
|
72
|
+
updatedKeys: [...o, m]
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
export {
|
|
76
|
+
L as convertLocalConfiguratorToTemplateField,
|
|
77
|
+
u as resolveSelectableLevels
|
|
78
|
+
};
|