@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
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineMessages as e } from "react-intl";
|
|
2
|
+
const t = e({
|
|
3
|
+
noLevels: {
|
|
4
|
+
id: "groupSharedFeatures.metadataTemplateEditor.configurator.levelsChain.noLevels",
|
|
5
|
+
defaultMessage: "There are no levels to display."
|
|
6
|
+
},
|
|
7
|
+
chipSelected: {
|
|
8
|
+
id: "groupSharedFeatures.metadataTemplateEditor.configurator.levelsChain.chipSelected",
|
|
9
|
+
defaultMessage: "selected"
|
|
10
|
+
},
|
|
11
|
+
chipNotSelected: {
|
|
12
|
+
id: "groupSharedFeatures.metadataTemplateEditor.configurator.levelsChain.chipNotSelected",
|
|
13
|
+
defaultMessage: "not selected"
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
export {
|
|
17
|
+
t as default
|
|
18
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { defineMessages as e } from "react-intl";
|
|
2
|
+
const o = e({
|
|
3
|
+
callToActionHeader: {
|
|
4
|
+
id: "groupSharedFeatures.metadataTemplateEditor.configurator.taxonomy.callToActionHeader",
|
|
5
|
+
defaultMessage: "Choose or Create a Taxonomy"
|
|
6
|
+
},
|
|
7
|
+
callToActionSubheader: {
|
|
8
|
+
id: "groupSharedFeatures.metadataTemplateEditor.configurator.taxonomy.callToActionSubheader",
|
|
9
|
+
defaultMessage: "Taxonomies allow you to set dynamic, reusable options for dropdown fields."
|
|
10
|
+
},
|
|
11
|
+
allowMultipleTaxonomySelections: {
|
|
12
|
+
id: "groupSharedFeatures.metadataTemplateEditor.configurator.taxonomy.allowMultipleTaxonomySelections",
|
|
13
|
+
defaultMessage: "Users can pick multiple values"
|
|
14
|
+
},
|
|
15
|
+
selection: {
|
|
16
|
+
id: "groupSharedFeatures.metadataTemplateEditor.configurator.taxonomy.selection",
|
|
17
|
+
defaultMessage: "What level(s) can users select a value from?"
|
|
18
|
+
},
|
|
19
|
+
requiredSelection: {
|
|
20
|
+
id: "groupSharedFeatures.metadataTemplateEditor.configurator.taxonomy.selection.requiredSelection",
|
|
21
|
+
defaultMessage: "Users must pick from the following level:"
|
|
22
|
+
},
|
|
23
|
+
anyLevelSelection: {
|
|
24
|
+
id: "groupSharedFeatures.metadataTemplateEditor.configurator.taxonomy.selection.anyLevelSelection",
|
|
25
|
+
defaultMessage: "Users can pick from any level in the list"
|
|
26
|
+
},
|
|
27
|
+
chooseTaxonomyLevel: {
|
|
28
|
+
id: "groupSharedFeatures.metadataTemplateEditor.configurator.taxonomy.selection.chooseTaxonomyLevel",
|
|
29
|
+
defaultMessage: "Choose the taxonomy level"
|
|
30
|
+
},
|
|
31
|
+
noTaxonomySelectedError: {
|
|
32
|
+
id: "groupSharedFeatures.metadataTemplateEditor.configurator.taxonomy.noTaxonomySelectedError",
|
|
33
|
+
defaultMessage: "Please select a taxonomy"
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
export {
|
|
37
|
+
o as default
|
|
38
|
+
};
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import "./hooks/useTemplateFieldSchema.js";
|
|
2
|
+
import { useIntl as oe } from "react-intl";
|
|
3
|
+
import { Tabs as l, Accordion as g } from "@box/blueprint-web";
|
|
4
|
+
import { FieldConfiguratorContext as te } from "./context/field-configurator-context.js";
|
|
5
|
+
import { TaxonomyOptionsContext as ie } from "./context/taxonomy-options-context.js";
|
|
6
|
+
import { FieldExtensionsContext as ne } from "./context/field-extensions-context.js";
|
|
7
|
+
import { useFieldConfiguratorBehavior as re } from "./hooks/useFieldConfiguratorBehavior.js";
|
|
8
|
+
import { FieldEditContent as le } from "./components/field-edit-content/field-edit-content.js";
|
|
9
|
+
import { FieldActionSlot as ae } from "./components/field-action-slot/field-action-slot.js";
|
|
10
|
+
import de from "./components/confirmation-modal/confirmation-modal.js";
|
|
11
|
+
import { s as a } from "../../../../chunks/metadata-field-configurator.module.js";
|
|
12
|
+
import { general as I } from "./messages/configurator-messages.js";
|
|
13
|
+
import { jsxs as v, Fragment as ce, jsx as e } from "react/jsx-runtime";
|
|
14
|
+
import "./utils.js";
|
|
15
|
+
const Fe = ({
|
|
16
|
+
index: b,
|
|
17
|
+
maxIndex: T,
|
|
18
|
+
values: o,
|
|
19
|
+
onValuesChange: x,
|
|
20
|
+
onDelete: y,
|
|
21
|
+
onDuplicate: F,
|
|
22
|
+
onReorderFields: A,
|
|
23
|
+
onTouchStart: M,
|
|
24
|
+
onDragStart: V,
|
|
25
|
+
onDragEnd: D,
|
|
26
|
+
externalErrors: N,
|
|
27
|
+
externalTouched: q,
|
|
28
|
+
dndDragHandleProps: E,
|
|
29
|
+
isExpanded: n,
|
|
30
|
+
onExpandedChange: P,
|
|
31
|
+
taxonomyOptions: d,
|
|
32
|
+
fetchTaxonomies: c,
|
|
33
|
+
submitAttemptCount: S,
|
|
34
|
+
fieldExtensions: r,
|
|
35
|
+
onValidationChange: j
|
|
36
|
+
}) => {
|
|
37
|
+
const m = oe(), {
|
|
38
|
+
contextValue: B,
|
|
39
|
+
taxonomyContextValue: R,
|
|
40
|
+
extensions: t,
|
|
41
|
+
isActive: w,
|
|
42
|
+
handleAccordionValueChange: z,
|
|
43
|
+
isDeleteConfirmationModalOpen: H,
|
|
44
|
+
openConfirmationModal: K,
|
|
45
|
+
closeConfirmationModal: O,
|
|
46
|
+
handleDeleteField: W,
|
|
47
|
+
activeTabId: $,
|
|
48
|
+
setActiveTabId: k,
|
|
49
|
+
isTypeEditable: G,
|
|
50
|
+
uniqueKey: s,
|
|
51
|
+
nameInputId: J,
|
|
52
|
+
descriptionInputId: L,
|
|
53
|
+
accordionTitle: Q,
|
|
54
|
+
TitleIcon: U,
|
|
55
|
+
hasErrors: X,
|
|
56
|
+
handleTypeChange: Y,
|
|
57
|
+
handleChangeVisibility: Z
|
|
58
|
+
} = re({
|
|
59
|
+
values: o,
|
|
60
|
+
onValuesChange: x,
|
|
61
|
+
onDelete: y,
|
|
62
|
+
isExpanded: n,
|
|
63
|
+
onExpandedChange: P,
|
|
64
|
+
submitAttemptCount: S,
|
|
65
|
+
taxonomyOptions: d,
|
|
66
|
+
fetchTaxonomies: c,
|
|
67
|
+
fieldExtensionsProp: r,
|
|
68
|
+
onValidationChange: j
|
|
69
|
+
}), p = /* @__PURE__ */ e(le, {
|
|
70
|
+
nameInputId: J,
|
|
71
|
+
descriptionInputId: L,
|
|
72
|
+
isTypeEditable: G,
|
|
73
|
+
externalErrors: N,
|
|
74
|
+
externalTouched: q,
|
|
75
|
+
handleTypeChange: Y
|
|
76
|
+
}), _ = t.length > 0 ? /* @__PURE__ */ v(ce, {
|
|
77
|
+
children: [/* @__PURE__ */ e(l.TabPanel, {
|
|
78
|
+
tabId: "edit",
|
|
79
|
+
children: p
|
|
80
|
+
}), t.map((i, ee) => /* @__PURE__ */ e(l.TabPanel, {
|
|
81
|
+
tabId: `ext-${ee}`,
|
|
82
|
+
className: a.extensionContent,
|
|
83
|
+
children: i.renderContent(o)
|
|
84
|
+
}, i.label))]
|
|
85
|
+
}) : p, f = (
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
87
|
+
// @ts-expect-error iconVariant type is too narrow
|
|
88
|
+
/* @__PURE__ */ e(g.Item, {
|
|
89
|
+
startElement: /* @__PURE__ */ e(U, {
|
|
90
|
+
fontSize: "20px",
|
|
91
|
+
role: "presentation"
|
|
92
|
+
}),
|
|
93
|
+
value: s,
|
|
94
|
+
title: Q,
|
|
95
|
+
action: /* @__PURE__ */ e(ae, {
|
|
96
|
+
isExpanded: n,
|
|
97
|
+
isHidden: o.hidden,
|
|
98
|
+
index: b,
|
|
99
|
+
maxIndex: T,
|
|
100
|
+
dndDragHandleProps: E,
|
|
101
|
+
onDragStart: V,
|
|
102
|
+
onDragEnd: D,
|
|
103
|
+
onTouchStart: M,
|
|
104
|
+
onReorderFields: A,
|
|
105
|
+
onToggleVisibility: Z,
|
|
106
|
+
onRequestDelete: K,
|
|
107
|
+
onRequestDuplicate: F,
|
|
108
|
+
extensions: t
|
|
109
|
+
}),
|
|
110
|
+
className: a.fieldAccordionItem,
|
|
111
|
+
iconVariant: X ? "alert-error" : void 0,
|
|
112
|
+
children: _
|
|
113
|
+
})
|
|
114
|
+
), h = t.length > 0 ? /* @__PURE__ */ e(l, {
|
|
115
|
+
selectedId: $,
|
|
116
|
+
setSelectedId: (i) => k(i ?? "edit"),
|
|
117
|
+
children: f
|
|
118
|
+
}) : f, C = /* @__PURE__ */ v(te.Provider, {
|
|
119
|
+
value: B,
|
|
120
|
+
children: [/* @__PURE__ */ e("div", {
|
|
121
|
+
className: a.fieldAccordionWrapper,
|
|
122
|
+
children: n !== void 0 ? (
|
|
123
|
+
// List mode: parent MetadataFieldList provides the shared Accordion root.
|
|
124
|
+
h
|
|
125
|
+
) : (
|
|
126
|
+
// Standalone mode: own Accordion root with self-managed open/close state.
|
|
127
|
+
/* @__PURE__ */ e(g, {
|
|
128
|
+
type: "single",
|
|
129
|
+
collapsible: !0,
|
|
130
|
+
value: w ? s : "",
|
|
131
|
+
onValueChange: z,
|
|
132
|
+
children: h
|
|
133
|
+
})
|
|
134
|
+
)
|
|
135
|
+
}), H && /* @__PURE__ */ e(de, {
|
|
136
|
+
onClose: O,
|
|
137
|
+
onConfirm: W,
|
|
138
|
+
title: m.formatMessage(I.deleteFieldTitle, {
|
|
139
|
+
fieldName: o.name
|
|
140
|
+
}),
|
|
141
|
+
body: m.formatMessage(I.deleteFieldDescription)
|
|
142
|
+
})]
|
|
143
|
+
}), u = d !== void 0 || c !== void 0 ? /* @__PURE__ */ e(ie.Provider, {
|
|
144
|
+
value: R,
|
|
145
|
+
children: C
|
|
146
|
+
}) : C;
|
|
147
|
+
return r !== void 0 ? /* @__PURE__ */ e(ne.Provider, {
|
|
148
|
+
value: r,
|
|
149
|
+
children: u
|
|
150
|
+
}) : u;
|
|
151
|
+
};
|
|
152
|
+
export {
|
|
153
|
+
Fe as MetadataFieldConfigurator
|
|
154
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import l from "lodash/uniqueId";
|
|
2
|
+
import { F as n } from "../../../../chunks/types.js";
|
|
3
|
+
import { taxonomyDefaultValues as s } from "./components/type-specific-configuration/taxonomy/taxonomy-default-values.js";
|
|
4
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
5
|
+
import { TaxonomyFieldConfiguration as a } from "./components/type-specific-configuration/taxonomy/taxonomy-field-configuration.js";
|
|
6
|
+
import { DropdownFieldConfiguration as p } from "./components/type-specific-configuration/dropdown/dropdown-field-configuration.js";
|
|
7
|
+
function j(e) {
|
|
8
|
+
return {
|
|
9
|
+
id: l("field-"),
|
|
10
|
+
key: "",
|
|
11
|
+
hidden: !1,
|
|
12
|
+
name: "",
|
|
13
|
+
type: e ?? void 0,
|
|
14
|
+
description: "",
|
|
15
|
+
isFieldNew: !0,
|
|
16
|
+
isFieldReadOnly: !1,
|
|
17
|
+
...s,
|
|
18
|
+
dropdown: {
|
|
19
|
+
options: e === n.Dropdown ? [{
|
|
20
|
+
id: l(),
|
|
21
|
+
key: "",
|
|
22
|
+
isNew: !0
|
|
23
|
+
}] : [],
|
|
24
|
+
allowMultipleSelections: !1,
|
|
25
|
+
isAllowMultipleSelectionsEnabled: !0
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
const x = (e) => {
|
|
30
|
+
switch (e) {
|
|
31
|
+
case n.Dropdown:
|
|
32
|
+
return /* @__PURE__ */ u(p, {});
|
|
33
|
+
case n.Taxonomy:
|
|
34
|
+
return /* @__PURE__ */ u(a, {});
|
|
35
|
+
default:
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
function d(e, o) {
|
|
40
|
+
return e ? o === !0 ? !0 : typeof e != "object" || typeof o != "object" || !o ? !1 : Object.keys(e).some((t) => d(e[t], o[t])) : !1;
|
|
41
|
+
}
|
|
42
|
+
function f(e) {
|
|
43
|
+
return Object.keys(e).reduce((o, t) => {
|
|
44
|
+
const r = e[t];
|
|
45
|
+
return Array.isArray(r) ? o[t] = r.map((i) => typeof i == "object" && i !== null ? f(i) : !0) : typeof r == "object" && r !== null ? o[t] = f(r) : o[t] = !0, o;
|
|
46
|
+
}, {});
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
j as createDefaultFieldValues,
|
|
50
|
+
x as getConfigurationByType,
|
|
51
|
+
d as hasVisibleErrors,
|
|
52
|
+
f as markAllTouched
|
|
53
|
+
};
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
import { useSensors as re, useSensor as M, PointerSensor as oe, TouchSensor as ne, KeyboardSensor as le, DndContext as ie, closestCenter as ae, DragOverlay as ce } from "@dnd-kit/core";
|
|
2
|
+
import { sortableKeyboardCoordinates as se, arrayMove as K, SortableContext as de, verticalListSortingStrategy as ue, useSortable as me } from "@dnd-kit/sortable";
|
|
3
|
+
import { CSS as pe } from "@dnd-kit/utilities";
|
|
4
|
+
import fe from "lodash/cloneDeep";
|
|
5
|
+
import P from "lodash/uniqueId";
|
|
6
|
+
import ge from "clsx";
|
|
7
|
+
import * as he from "yup";
|
|
8
|
+
import { forwardRef as ye, useRef as w, useEffect as v, useState as G, useImperativeHandle as Ie, useCallback as s } from "react";
|
|
9
|
+
import { useIntl as ve } from "react-intl";
|
|
10
|
+
import { Accordion as q } from "@box/blueprint-web";
|
|
11
|
+
import { general as Se } from "../metadata-field-configurator/messages/configurator-messages.js";
|
|
12
|
+
import { TaxonomyOptionsContext as De } from "../metadata-field-configurator/context/taxonomy-options-context.js";
|
|
13
|
+
import { FieldExtensionsContext as xe } from "../metadata-field-configurator/context/field-extensions-context.js";
|
|
14
|
+
import { useTaxonomyFetch as Te } from "../metadata-field-configurator/hooks/useTaxonomyFetch.js";
|
|
15
|
+
import { F as j } from "../../../../chunks/types.js";
|
|
16
|
+
import { jsx as l, jsxs as _e } from "react/jsx-runtime";
|
|
17
|
+
import { useTemplateFieldSchema as Fe } from "../metadata-field-configurator/hooks/useTemplateFieldSchema.js";
|
|
18
|
+
import { FieldTypeIcon as we } from "../../utils/field-options/field-type-icon.js";
|
|
19
|
+
import { MetadataFieldConfigurator as Ee } from "../metadata-field-configurator/metadata-field-configurator.js";
|
|
20
|
+
import '../../../../styles/metadata-field-list.css';const be = "_fieldList_18x5c_1", Re = "_fieldItem_18x5c_11", Ae = "_dragging_18x5c_11", Ce = "_accordionRootContainer_18x5c_15", E = {
|
|
21
|
+
fieldList: be,
|
|
22
|
+
fieldItem: Re,
|
|
23
|
+
dragging: Ae,
|
|
24
|
+
accordionRootContainer: Ce
|
|
25
|
+
}, Ne = 150;
|
|
26
|
+
function a(h) {
|
|
27
|
+
return h.id;
|
|
28
|
+
}
|
|
29
|
+
const H = 150;
|
|
30
|
+
function Le({
|
|
31
|
+
field: h,
|
|
32
|
+
index: r,
|
|
33
|
+
maxIndex: i,
|
|
34
|
+
isExpanded: S,
|
|
35
|
+
onChangeField: D,
|
|
36
|
+
onDeleteAtIndex: b,
|
|
37
|
+
onDuplicateAtIndex: R,
|
|
38
|
+
onReorderFields: x,
|
|
39
|
+
onRequestExpand: y,
|
|
40
|
+
submitAttemptCount: T
|
|
41
|
+
}) {
|
|
42
|
+
const c = a(h), {
|
|
43
|
+
attributes: A,
|
|
44
|
+
listeners: C,
|
|
45
|
+
setNodeRef: N,
|
|
46
|
+
transform: d,
|
|
47
|
+
transition: u,
|
|
48
|
+
isDragging: _
|
|
49
|
+
} = me({
|
|
50
|
+
id: c
|
|
51
|
+
}), F = {
|
|
52
|
+
transform: pe.Translate.toString(d),
|
|
53
|
+
transition: u
|
|
54
|
+
};
|
|
55
|
+
return /* @__PURE__ */ l("li", {
|
|
56
|
+
ref: N,
|
|
57
|
+
style: F,
|
|
58
|
+
"data-field-id": c,
|
|
59
|
+
className: ge(E.fieldItem, {
|
|
60
|
+
[E.dragging]: _
|
|
61
|
+
}),
|
|
62
|
+
children: /* @__PURE__ */ l(Ee, {
|
|
63
|
+
values: h,
|
|
64
|
+
onValuesChange: D,
|
|
65
|
+
index: r,
|
|
66
|
+
maxIndex: i,
|
|
67
|
+
onDelete: () => b(r),
|
|
68
|
+
onDuplicate: () => R(r),
|
|
69
|
+
onReorderFields: x,
|
|
70
|
+
dndDragHandleProps: {
|
|
71
|
+
listeners: C,
|
|
72
|
+
attributes: A
|
|
73
|
+
},
|
|
74
|
+
isExpanded: S,
|
|
75
|
+
onExpandedChange: (m) => {
|
|
76
|
+
m && y();
|
|
77
|
+
},
|
|
78
|
+
submitAttemptCount: T
|
|
79
|
+
})
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
const Ze = /* @__PURE__ */ ye(function({
|
|
83
|
+
fields: r,
|
|
84
|
+
onChangeFields: i,
|
|
85
|
+
onDeleteFieldAtIndex: S,
|
|
86
|
+
onDuplicateField: D,
|
|
87
|
+
taxonomyOptions: b,
|
|
88
|
+
fetchTaxonomies: R,
|
|
89
|
+
firstInvalidFieldIndex: x,
|
|
90
|
+
submitAttemptCount: y,
|
|
91
|
+
fieldExtensions: T,
|
|
92
|
+
onValidationChange: c
|
|
93
|
+
}, A) {
|
|
94
|
+
const {
|
|
95
|
+
formatMessage: C
|
|
96
|
+
} = ve(), N = Te(R, b), d = w(null), u = w(null), _ = w(new Set(r.map((e) => a(e)))), F = Fe(), m = w(null);
|
|
97
|
+
v(() => {
|
|
98
|
+
m.current = null;
|
|
99
|
+
}, [c]), v(() => {
|
|
100
|
+
if (!c)
|
|
101
|
+
return;
|
|
102
|
+
let e = !1;
|
|
103
|
+
const t = setTimeout(() => {
|
|
104
|
+
he.array().of(F).validate(r, {
|
|
105
|
+
abortEarly: !0
|
|
106
|
+
}).then(() => {
|
|
107
|
+
e || m.current === !0 || (m.current = !0, c(!0));
|
|
108
|
+
}).catch(() => {
|
|
109
|
+
e || m.current === !1 || (m.current = !1, c(!1));
|
|
110
|
+
});
|
|
111
|
+
}, Ne);
|
|
112
|
+
return () => {
|
|
113
|
+
e = !0, clearTimeout(t);
|
|
114
|
+
};
|
|
115
|
+
}, [r, F, c]);
|
|
116
|
+
const [p, f] = G(() => {
|
|
117
|
+
const e = r.find((t) => t.isFieldNew);
|
|
118
|
+
return e ? a(e) : null;
|
|
119
|
+
});
|
|
120
|
+
Ie(A, () => ({
|
|
121
|
+
scrollToAndExpand(e) {
|
|
122
|
+
u.current = e, p === e ? (u.current = null, setTimeout(() => {
|
|
123
|
+
d.current?.querySelector(`[data-field-id="${e}"]`)?.scrollIntoView({
|
|
124
|
+
behavior: "smooth",
|
|
125
|
+
block: "nearest"
|
|
126
|
+
});
|
|
127
|
+
}, 0)) : f(e);
|
|
128
|
+
}
|
|
129
|
+
}), [p]), v(() => {
|
|
130
|
+
r.forEach((e) => {
|
|
131
|
+
const t = a(e);
|
|
132
|
+
_.current.has(t) || (_.current.add(t), u.current = t, f(t));
|
|
133
|
+
});
|
|
134
|
+
}, [r]), v(() => {
|
|
135
|
+
if (x == null || !y)
|
|
136
|
+
return;
|
|
137
|
+
const e = r[x];
|
|
138
|
+
if (!e)
|
|
139
|
+
return;
|
|
140
|
+
const t = a(e);
|
|
141
|
+
f(t), requestAnimationFrame(() => {
|
|
142
|
+
d.current?.querySelector(`[data-field-id="${t}"]`)?.scrollIntoView({
|
|
143
|
+
behavior: "smooth",
|
|
144
|
+
block: "nearest"
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
}, [y]), v(() => {
|
|
148
|
+
const e = u.current;
|
|
149
|
+
if (!e || e !== p)
|
|
150
|
+
return;
|
|
151
|
+
u.current = null;
|
|
152
|
+
const t = setTimeout(() => {
|
|
153
|
+
d.current?.querySelector(`[data-field-id="${e}"]`)?.scrollIntoView({
|
|
154
|
+
behavior: "smooth",
|
|
155
|
+
block: "nearest"
|
|
156
|
+
});
|
|
157
|
+
}, H);
|
|
158
|
+
return () => clearTimeout(t);
|
|
159
|
+
}, [p]);
|
|
160
|
+
const [k, L] = G(null), z = re(M(oe, {
|
|
161
|
+
activationConstraint: {
|
|
162
|
+
distance: 8
|
|
163
|
+
}
|
|
164
|
+
}), M(ne, {
|
|
165
|
+
activationConstraint: {
|
|
166
|
+
delay: 250,
|
|
167
|
+
tolerance: 5
|
|
168
|
+
}
|
|
169
|
+
}), M(le, {
|
|
170
|
+
coordinateGetter: se
|
|
171
|
+
})), B = s((e) => {
|
|
172
|
+
L(String(e.active.id));
|
|
173
|
+
}, []), U = s((e) => {
|
|
174
|
+
L(null);
|
|
175
|
+
const {
|
|
176
|
+
active: t,
|
|
177
|
+
over: o
|
|
178
|
+
} = e;
|
|
179
|
+
if (o && t.id !== o.id) {
|
|
180
|
+
const n = r.findIndex((O) => a(O) === t.id), g = r.findIndex((O) => a(O) === o.id);
|
|
181
|
+
n !== -1 && g !== -1 && i?.(K(r, n, g));
|
|
182
|
+
}
|
|
183
|
+
}, [r, i]), Y = s(() => {
|
|
184
|
+
L(null);
|
|
185
|
+
}, []), J = s((e, t) => {
|
|
186
|
+
i?.(r.map((o, n) => n === e ? t : o));
|
|
187
|
+
}, [r, i]), Q = s((e) => {
|
|
188
|
+
const t = r[e], o = a(t);
|
|
189
|
+
f((n) => n === o ? null : n), i?.(r.filter((n, g) => g !== e)), S?.(e, t);
|
|
190
|
+
}, [r, i, S]), W = s((e) => {
|
|
191
|
+
const t = r[e], o = fe(t);
|
|
192
|
+
o.id = P("field-"), o.key = "", o.isFieldNew = !0, o.type === j.Dropdown && (o.dropdown.options = o.dropdown.options.map((g) => ({
|
|
193
|
+
...g,
|
|
194
|
+
id: P()
|
|
195
|
+
})));
|
|
196
|
+
const n = [...r];
|
|
197
|
+
n.splice(e + 1, 0, o), i?.(n), D?.(o);
|
|
198
|
+
}, [r, i, D]), X = s((e, t) => {
|
|
199
|
+
t < 0 || t >= r.length || i?.(K(r, e, t));
|
|
200
|
+
}, [r, i]), Z = s((e) => {
|
|
201
|
+
const t = e || null;
|
|
202
|
+
f(t), t && setTimeout(() => {
|
|
203
|
+
d.current?.querySelector(`[data-field-id="${t}"]`)?.scrollIntoView({
|
|
204
|
+
behavior: "smooth",
|
|
205
|
+
block: "nearest"
|
|
206
|
+
});
|
|
207
|
+
}, H);
|
|
208
|
+
}, []), ee = r.map((e) => a(e)), I = k ? r.find((e) => a(e) === k) : null, V = I ? we(I.type) : null, te = I ? ((e) => {
|
|
209
|
+
const t = e.name || C(Se.fieldNameInputPlaceholder);
|
|
210
|
+
if (e.type === j.Dropdown) {
|
|
211
|
+
const o = e.dropdown?.options?.length ?? 0;
|
|
212
|
+
return `${t} (${o})`;
|
|
213
|
+
}
|
|
214
|
+
return t;
|
|
215
|
+
})(I) : "", $ = /* @__PURE__ */ l(De.Provider, {
|
|
216
|
+
value: N,
|
|
217
|
+
children: /* @__PURE__ */ _e(ie, {
|
|
218
|
+
sensors: z,
|
|
219
|
+
collisionDetection: ae,
|
|
220
|
+
onDragStart: B,
|
|
221
|
+
onDragEnd: U,
|
|
222
|
+
onDragCancel: Y,
|
|
223
|
+
children: [/* @__PURE__ */ l("div", {
|
|
224
|
+
className: E.accordionRootContainer,
|
|
225
|
+
children: /* @__PURE__ */ l(q, {
|
|
226
|
+
type: "single",
|
|
227
|
+
collapsible: !0,
|
|
228
|
+
value: p ?? "",
|
|
229
|
+
onValueChange: Z,
|
|
230
|
+
children: /* @__PURE__ */ l(de, {
|
|
231
|
+
items: ee,
|
|
232
|
+
strategy: ue,
|
|
233
|
+
children: /* @__PURE__ */ l("ul", {
|
|
234
|
+
ref: d,
|
|
235
|
+
className: E.fieldList,
|
|
236
|
+
children: r.map((e, t) => {
|
|
237
|
+
const o = a(e);
|
|
238
|
+
return /* @__PURE__ */ l(Le, {
|
|
239
|
+
field: e,
|
|
240
|
+
index: t,
|
|
241
|
+
maxIndex: r.length - 1,
|
|
242
|
+
isExpanded: p === o,
|
|
243
|
+
onChangeField: (n) => J(t, n),
|
|
244
|
+
onDeleteAtIndex: Q,
|
|
245
|
+
onDuplicateAtIndex: W,
|
|
246
|
+
onReorderFields: X,
|
|
247
|
+
onRequestExpand: () => f(o),
|
|
248
|
+
submitAttemptCount: y
|
|
249
|
+
}, o);
|
|
250
|
+
})
|
|
251
|
+
})
|
|
252
|
+
})
|
|
253
|
+
})
|
|
254
|
+
}), /* @__PURE__ */ l(ce, {
|
|
255
|
+
dropAnimation: null,
|
|
256
|
+
children: I && V ? /* @__PURE__ */ l(q, {
|
|
257
|
+
type: "single",
|
|
258
|
+
children: /* @__PURE__ */ l(q.Item, {
|
|
259
|
+
value: "ghost",
|
|
260
|
+
title: te,
|
|
261
|
+
startElement: /* @__PURE__ */ l(V, {
|
|
262
|
+
fontSize: "20px",
|
|
263
|
+
role: "presentation"
|
|
264
|
+
}),
|
|
265
|
+
children: null
|
|
266
|
+
})
|
|
267
|
+
}) : null
|
|
268
|
+
})]
|
|
269
|
+
})
|
|
270
|
+
});
|
|
271
|
+
return T !== void 0 ? /* @__PURE__ */ l(xe.Provider, {
|
|
272
|
+
value: T,
|
|
273
|
+
children: $
|
|
274
|
+
}) : $;
|
|
275
|
+
});
|
|
276
|
+
export {
|
|
277
|
+
Ze as MetadataFieldList,
|
|
278
|
+
Ze as default
|
|
279
|
+
};
|
package/dist/esm/lib/components/metadata-template-editor-form/metadata-template-editor-form.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { useFormikContext as V, Form as H } from "formik";
|
|
2
|
+
import { useRef as j, useMemo as w, useEffect as A } from "react";
|
|
3
|
+
import { TextInput as U, Text as G, Link as O, Button as b } from "@box/blueprint-web";
|
|
4
|
+
import { useIntl as P, FormattedMessage as N } from "react-intl";
|
|
5
|
+
import s from "../../messages.js";
|
|
6
|
+
import { FieldExtensionsContext as X } from "../metadata-field-configurator/context/field-extensions-context.js";
|
|
7
|
+
import { jsxs as a, jsx as e, Fragment as v } from "react/jsx-runtime";
|
|
8
|
+
import { FieldSelector as q } from "../field-selector/field-selector.js";
|
|
9
|
+
import { FieldTypeTiles as z } from "../field-type-tiles/field-type-tiles.js";
|
|
10
|
+
import { MetadataFieldList as J } from "../metadata-field-list/metadata-field-list.js";
|
|
11
|
+
import { FieldTypeDropdown as K } from "../field-type-dropdown/field-type-dropdown.js";
|
|
12
|
+
import { createDefaultFieldValues as Q } from "../metadata-field-configurator/utils.js";
|
|
13
|
+
import '../../../../styles/metadata-template-editor-form.css';const W = "_form_8cb30_1", Y = "_fields_8cb30_15", Z = "_actions_8cb30_21", $ = "_fieldsHeader_8cb30_28", l = {
|
|
14
|
+
form: W,
|
|
15
|
+
fields: Y,
|
|
16
|
+
actions: Z,
|
|
17
|
+
fieldsHeader: $
|
|
18
|
+
}, ee = "bodyDefaultBold", ie = "h2", se = "https://developer.box.com/guides/metadata/fields/", he = ({
|
|
19
|
+
formId: y,
|
|
20
|
+
onCancel: m,
|
|
21
|
+
taxonomyOptions: E,
|
|
22
|
+
fetchTaxonomies: M,
|
|
23
|
+
hideActions: x,
|
|
24
|
+
isEditMode: I,
|
|
25
|
+
onDirtyStateChange: f,
|
|
26
|
+
onValidationChange: c,
|
|
27
|
+
fieldExtensions: u
|
|
28
|
+
}) => {
|
|
29
|
+
const d = P(), {
|
|
30
|
+
errors: r,
|
|
31
|
+
values: t,
|
|
32
|
+
setFieldValue: p,
|
|
33
|
+
isSubmitting: o,
|
|
34
|
+
isValid: h,
|
|
35
|
+
touched: L,
|
|
36
|
+
handleChange: T,
|
|
37
|
+
handleBlur: D,
|
|
38
|
+
submitCount: B,
|
|
39
|
+
dirty: n
|
|
40
|
+
} = V(), F = j(null), C = w(() => {
|
|
41
|
+
if (!Array.isArray(r.fields))
|
|
42
|
+
return null;
|
|
43
|
+
const i = r.fields.findIndex(Boolean);
|
|
44
|
+
return i >= 0 ? i : null;
|
|
45
|
+
}, [r.fields]), _ = (i) => {
|
|
46
|
+
const S = Q(i.type);
|
|
47
|
+
p("fields", [...t.fields, S]);
|
|
48
|
+
}, k = (i) => {
|
|
49
|
+
p("fields", i);
|
|
50
|
+
};
|
|
51
|
+
A(() => {
|
|
52
|
+
f?.(n);
|
|
53
|
+
}, [n, f]), A(() => {
|
|
54
|
+
c?.(h);
|
|
55
|
+
}, [h, c]);
|
|
56
|
+
const R = o || I && !n, g = /* @__PURE__ */ a(H, {
|
|
57
|
+
noValidate: !0,
|
|
58
|
+
id: y,
|
|
59
|
+
className: l.form,
|
|
60
|
+
children: [/* @__PURE__ */ e("div", {
|
|
61
|
+
className: l.templateInfo,
|
|
62
|
+
children: /* @__PURE__ */ e(U, {
|
|
63
|
+
name: "displayName",
|
|
64
|
+
label: d.formatMessage(s.templateName),
|
|
65
|
+
placeholder: d.formatMessage(s.templateNameDescription),
|
|
66
|
+
value: t.displayName,
|
|
67
|
+
error: L.displayName && r.displayName ? r.displayName : void 0,
|
|
68
|
+
onChange: (i) => {
|
|
69
|
+
T(i);
|
|
70
|
+
},
|
|
71
|
+
onBlur: D
|
|
72
|
+
})
|
|
73
|
+
}), /* @__PURE__ */ a("div", {
|
|
74
|
+
className: l.fieldsHeader,
|
|
75
|
+
children: [/* @__PURE__ */ e(G, {
|
|
76
|
+
as: ie,
|
|
77
|
+
variant: ee,
|
|
78
|
+
children: /* @__PURE__ */ e(N, {
|
|
79
|
+
...t.fields.length === 0 ? s.fieldsAddFirst : s.fields
|
|
80
|
+
})
|
|
81
|
+
}), t.fields.length > 0 && /* @__PURE__ */ e(q, {
|
|
82
|
+
fields: t.fields,
|
|
83
|
+
onSelect: (i) => F.current?.scrollToAndExpand(i)
|
|
84
|
+
})]
|
|
85
|
+
}), /* @__PURE__ */ e("div", {
|
|
86
|
+
className: l.fields,
|
|
87
|
+
children: t.fields.length === 0 ? /* @__PURE__ */ a(v, {
|
|
88
|
+
children: [/* @__PURE__ */ e(z, {
|
|
89
|
+
onFieldAdd: _
|
|
90
|
+
}), /* @__PURE__ */ e(O, {
|
|
91
|
+
isExternal: !0,
|
|
92
|
+
className: l.fieldsLearnMoreLink,
|
|
93
|
+
href: se,
|
|
94
|
+
target: "_blank",
|
|
95
|
+
children: /* @__PURE__ */ e(N, {
|
|
96
|
+
...s.fieldsLearnMore
|
|
97
|
+
})
|
|
98
|
+
})]
|
|
99
|
+
}) : /* @__PURE__ */ a(v, {
|
|
100
|
+
children: [/* @__PURE__ */ e(J, {
|
|
101
|
+
ref: F,
|
|
102
|
+
fields: t.fields,
|
|
103
|
+
taxonomyOptions: E,
|
|
104
|
+
fetchTaxonomies: M,
|
|
105
|
+
onChangeFields: k,
|
|
106
|
+
firstInvalidFieldIndex: C,
|
|
107
|
+
submitAttemptCount: B
|
|
108
|
+
}), /* @__PURE__ */ e(K, {
|
|
109
|
+
onFieldAdd: _
|
|
110
|
+
})]
|
|
111
|
+
})
|
|
112
|
+
}), !x && /* @__PURE__ */ a("div", {
|
|
113
|
+
className: l.actions,
|
|
114
|
+
children: [m && /* @__PURE__ */ e(b, {
|
|
115
|
+
variant: "secondary",
|
|
116
|
+
type: "button",
|
|
117
|
+
onClick: m,
|
|
118
|
+
loading: o,
|
|
119
|
+
disabled: o,
|
|
120
|
+
loadingAriaLabel: d.formatMessage(s.submitting),
|
|
121
|
+
children: d.formatMessage(s.cancel)
|
|
122
|
+
}), /* @__PURE__ */ e(b, {
|
|
123
|
+
variant: "primary",
|
|
124
|
+
type: "submit",
|
|
125
|
+
disabled: R,
|
|
126
|
+
children: d.formatMessage(s.save)
|
|
127
|
+
})]
|
|
128
|
+
})]
|
|
129
|
+
});
|
|
130
|
+
return u !== void 0 ? /* @__PURE__ */ e(X.Provider, {
|
|
131
|
+
value: u,
|
|
132
|
+
children: g
|
|
133
|
+
}) : g;
|
|
134
|
+
};
|
|
135
|
+
export {
|
|
136
|
+
he as default
|
|
137
|
+
};
|