@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.
Files changed (95) hide show
  1. package/dist/chunks/chip.js +21 -0
  2. package/dist/chunks/dropdown-field-configuration.js +62 -0
  3. package/dist/chunks/field-context-menu.js +90 -0
  4. package/dist/chunks/field-selector.js +23 -0
  5. package/dist/chunks/field-type-dropdown.js +31 -0
  6. package/dist/chunks/levels-chain.js +125 -0
  7. package/dist/chunks/metadata-field-configurator.module.js +17 -16
  8. package/dist/chunks/metadata-field-list.js +229 -0
  9. package/dist/chunks/metadata-template-editor-form.js +107 -0
  10. package/dist/chunks/metadata-template-editor-modal.js +77 -0
  11. package/dist/chunks/metadata-template-editor.js +157 -0
  12. package/dist/chunks/sortable-option-list.js +231 -0
  13. package/dist/chunks/taxonomy-field-configuration.js +126 -0
  14. package/dist/chunks/taxonomy-field-configurator-initial-state.js +48 -0
  15. package/dist/chunks/taxonomy-selector.js +90 -0
  16. package/dist/chunks/types.js +22 -33
  17. package/dist/esm/index.js +13 -34
  18. package/dist/esm/lib/components/field-selector/field-selector.js +2 -39
  19. package/dist/esm/lib/components/field-selector/index.js +2 -4
  20. package/dist/esm/lib/components/field-selector/messages.js +10 -12
  21. package/dist/esm/lib/components/field-type-dropdown/field-type-dropdown.js +2 -47
  22. package/dist/esm/lib/components/field-type-dropdown/index.js +2 -4
  23. package/dist/esm/lib/components/field-type-dropdown/messages.js +10 -12
  24. package/dist/esm/lib/components/field-type-tiles/field-type-tiles.js +32 -39
  25. package/dist/esm/lib/components/field-type-tiles/index.js +2 -4
  26. package/dist/esm/lib/components/field-type-tiles/messages.js +10 -12
  27. package/dist/esm/lib/components/metadata-field-configurator/components/confirmation-modal/confirmation-modal.js +32 -45
  28. package/dist/esm/lib/components/metadata-field-configurator/components/confirmation-modal/messages.js +14 -16
  29. package/dist/esm/lib/components/metadata-field-configurator/components/field-action-slot/field-action-slot.js +62 -79
  30. package/dist/esm/lib/components/metadata-field-configurator/components/field-context-menu/field-context-menu.js +2 -115
  31. package/dist/esm/lib/components/metadata-field-configurator/components/field-edit-content/field-edit-content.js +83 -100
  32. package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/chip.js +2 -33
  33. package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/index.js +2 -4
  34. package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/levels-chain.js +2 -118
  35. package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/utils.js +16 -33
  36. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/__mocks__/getInitialValues.js +34 -32
  37. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/dropdown-default-values.js +10 -14
  38. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/dropdown-field-configuration.js +2 -66
  39. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/sortable-option-list.js +2 -294
  40. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/index.js +3 -6
  41. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-default-values.js +11 -15
  42. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-field-configuration.js +2 -149
  43. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-field-configurator-initial-state.js +2 -54
  44. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector-messages.js +34 -36
  45. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector.js +2 -103
  46. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/useTaxonomySelect.js +15 -19
  47. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/utils.js +2 -4
  48. package/dist/esm/lib/components/metadata-field-configurator/context/field-configurator-context.js +60 -66
  49. package/dist/esm/lib/components/metadata-field-configurator/context/field-extensions-context.js +5 -8
  50. package/dist/esm/lib/components/metadata-field-configurator/context/taxonomy-options-context.js +14 -20
  51. package/dist/esm/lib/components/metadata-field-configurator/hooks/useFieldConfiguratorBehavior.js +99 -118
  52. package/dist/esm/lib/components/metadata-field-configurator/hooks/useFieldValidation.js +52 -66
  53. package/dist/esm/lib/components/metadata-field-configurator/hooks/useTaxonomyFetch.js +23 -26
  54. package/dist/esm/lib/components/metadata-field-configurator/hooks/useTemplateFieldSchema.js +34 -43
  55. package/dist/esm/lib/components/metadata-field-configurator/index.js +5 -11
  56. package/dist/esm/lib/components/metadata-field-configurator/messages/configurator-messages.js +131 -134
  57. package/dist/esm/lib/components/metadata-field-configurator/messages/dropdown-messages.js +34 -36
  58. package/dist/esm/lib/components/metadata-field-configurator/messages/levels-chain-messages.js +14 -16
  59. package/dist/esm/lib/components/metadata-field-configurator/messages/taxonomy-messages.js +34 -36
  60. package/dist/esm/lib/components/metadata-field-configurator/metadata-field-configurator.js +94 -153
  61. package/dist/esm/lib/components/metadata-field-configurator/utils.js +42 -49
  62. package/dist/esm/lib/components/metadata-field-list/index.js +2 -5
  63. package/dist/esm/lib/components/metadata-field-list/metadata-field-list.js +2 -279
  64. package/dist/esm/lib/components/metadata-template-editor-form/metadata-template-editor-form.js +2 -137
  65. package/dist/esm/lib/components/metadata-template-editor-modal/index.js +2 -4
  66. package/dist/esm/lib/components/metadata-template-editor-modal/metadata-template-editor-modal.js +2 -103
  67. package/dist/esm/lib/hooks/useMetadataTemplateFormSchema.js +13 -15
  68. package/dist/esm/lib/hooks/useTemplateNameSchema.js +8 -10
  69. package/dist/esm/lib/index.js +7 -14
  70. package/dist/esm/lib/messages.js +114 -116
  71. package/dist/esm/lib/metadata-template-editor.js +2 -182
  72. package/dist/esm/lib/utils/constants.js +2 -8
  73. package/dist/esm/lib/utils/field-options/field-type-icon.js +14 -33
  74. package/dist/esm/lib/utils/field-options/index.js +4 -9
  75. package/dist/esm/lib/utils/field-options/messages.js +43 -46
  76. package/dist/esm/lib/utils/field-options/useFieldOptions.js +14 -18
  77. package/dist/esm/lib/utils/key-generation.js +16 -27
  78. package/dist/esm/lib/utils/template-type-conversion/convertLocalConfiguratorToTemplateField.js +63 -77
  79. package/dist/esm/lib/utils/template-type-conversion/convertTemplateFieldToLocalConfigurator.js +69 -89
  80. package/dist/esm/lib/utils/template-type-conversion/generateJSONPatchTemplateOperations.js +150 -169
  81. package/dist/esm/lib/utils/template-type-conversion/mapFieldsWithUniqueKeys.js +8 -13
  82. package/dist/styles/chip.css +1 -1
  83. package/dist/styles/dropdown-field-configuration.css +1 -1
  84. package/dist/styles/field-context-menu.css +1 -1
  85. package/dist/styles/levels-chain.css +1 -1
  86. package/dist/styles/metadata-field-configurator.css +1 -1
  87. package/dist/styles/metadata-field-list.css +1 -1
  88. package/dist/styles/metadata-template-editor-form.css +1 -1
  89. package/dist/styles/metadata-template-editor-modal.css +1 -1
  90. package/dist/styles/metadata-template-editor.css +1 -1
  91. package/dist/styles/sortable-option-list.css +1 -1
  92. package/dist/styles/taxonomy-field-configuration.css +1 -1
  93. package/dist/styles/taxonomy-field-configurator-initial-state.css +1 -1
  94. package/dist/styles/taxonomy-selector.css +1 -1
  95. package/package.json +6 -6
@@ -1,182 +1,2 @@
1
- import { forwardRef as Q, useState as n, useCallback as b, useImperativeHandle as W, useEffect as L, useMemo as G } 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__ */ Q(function({
27
- onCancel: m,
28
- onDirtyStateChange: h,
29
- onValidationChange: F,
30
- onSubmitError: I,
31
- onTemplateLoad: y,
32
- taxonomyOptions: S,
33
- fetchTaxonomies: K,
34
- formId: _,
35
- hideActions: B = !1,
36
- fieldExtensions: U,
37
- ...l
38
- }, w) {
39
- const x = oe(), {
40
- formatMessage: t
41
- } = Y(), {
42
- addNotification: g
43
- } = Z(), c = l.mode === ae.Edit, [v, k] = n(!1), [D, f] = n(!1), p = b(() => {
44
- v ? f(!0) : m?.();
45
- }, [v, m]);
46
- W(w, () => ({
47
- requestClose: p
48
- }), [p]);
49
- const O = b((e) => {
50
- k(e), h?.(e);
51
- }, [h]), [V, C] = n(c), [H, T] = n(!1), [R, j] = n(0), [o, E] = n(void 0), u = c ? l.fetchTemplate : void 0, q = () => {
52
- j((e) => e + 1);
53
- };
54
- L(() => {
55
- if (!u)
56
- return;
57
- let e = !1;
58
- return C(!0), T(!1), E(void 0), (async () => {
59
- try {
60
- const s = await u();
61
- e || E(s);
62
- } catch {
63
- e || T(!0);
64
- } finally {
65
- e || C(!1);
66
- }
67
- })(), () => {
68
- e = !0;
69
- };
70
- }, [u, R]), L(() => {
71
- o !== void 0 && y?.(o);
72
- }, [o, y]);
73
- const N = c ? void 0 : l.namespace, d = G(() => 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: N ?? ""
82
- }, [o, N]), z = async (e) => {
83
- try {
84
- if (c) {
85
- const i = se(d, e);
86
- await l.onEditTemplate(i, {
87
- namespaceFQN: d.namespace,
88
- templateKey: d.templateKey
89
- });
90
- } else {
91
- const i = re(e.fields), s = {
92
- namespace: e.namespace,
93
- templateKey: e.templateKey,
94
- displayName: e.displayName,
95
- hidden: e.hidden,
96
- fields: i
97
- };
98
- await l.onCreateTemplate(s);
99
- }
100
- g({
101
- sensitivity: "foreground",
102
- variant: "success",
103
- styledText: t(a.saveSuccessNotification),
104
- typeIconAriaLabel: t(a.notificationSuccessIconAriaLabel),
105
- closeButtonAriaLabel: t(a.notificationCloseButtonAriaLabel)
106
- });
107
- } catch (i) {
108
- let s;
109
- if (i instanceof Error && "status" in i) {
110
- const {
111
- status: J
112
- } = i;
113
- s = t(J === ce ? a.displayNameUsedBefore : a.saveErrorNotification);
114
- } else
115
- s = t(a.saveErrorNotification);
116
- g({
117
- sensitivity: "foreground",
118
- variant: "error",
119
- styledText: s,
120
- typeIconAriaLabel: t(a.notificationErrorIconAriaLabel),
121
- closeButtonAriaLabel: t(a.notificationCloseButtonAriaLabel)
122
- });
123
- try {
124
- I?.(i);
125
- } catch {
126
- }
127
- throw i;
128
- }
129
- };
130
- return V ? /* @__PURE__ */ r("div", {
131
- className: A.loading,
132
- children: /* @__PURE__ */ r($, {
133
- size: "large",
134
- "aria-label": t(a.loading)
135
- })
136
- }) : H ? /* @__PURE__ */ r("div", {
137
- className: A.error,
138
- children: /* @__PURE__ */ r(M, {
139
- body: /* @__PURE__ */ r(P, {
140
- as: "p",
141
- children: t(a.fetchError)
142
- }),
143
- illustration: ee,
144
- size: "large",
145
- children: /* @__PURE__ */ r(M.PrimaryAction, {
146
- startIcon: te,
147
- onClick: q,
148
- children: t(a.reload)
149
- })
150
- })
151
- }) : /* @__PURE__ */ de(me, {
152
- children: [/* @__PURE__ */ r(X, {
153
- initialValues: d,
154
- validationSchema: x,
155
- onSubmit: z,
156
- children: /* @__PURE__ */ r(ne, {
157
- formId: _,
158
- onCancel: p,
159
- taxonomyOptions: S,
160
- fetchTaxonomies: K,
161
- hideActions: B,
162
- isEditMode: c,
163
- onDirtyStateChange: O,
164
- onValidationChange: F,
165
- fieldExtensions: U
166
- })
167
- }), D && /* @__PURE__ */ r(le, {
168
- onClose: () => f(!1),
169
- onConfirm: () => {
170
- f(!1), m?.();
171
- },
172
- title: t(a.unsavedChangesTitle),
173
- body: t(a.unsavedChangesBody),
174
- confirmLabel: t(a.unsavedChangesDiscard),
175
- cancelLabel: t(a.unsavedChangesKeepEditing)
176
- })]
177
- });
178
- });
179
- export {
180
- Ue as MetadataTemplateEditor,
181
- Ue as default
182
- };
1
+ import { t as e } from "../../chunks/metadata-template-editor.js";
2
+ export { e as MetadataTemplateEditor, e as default };
@@ -1,8 +1,2 @@
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
- };
1
+ var e = 4096, t = 256, n = 64, r = 4096, i = 409;
2
+ export { i as CONFLICT_HTTP_STATUS, t as METADATA_TEMPLATE_FIELD_KEY_MAX_LENGTH, e as METADATA_TEMPLATE_FIELD_NAME_MAX_LENGTH, n as METADATA_TEMPLATE_KEY_MAX_LENGTH, r as METADATA_TEMPLATE_NAME_MAX_LENGTH };
@@ -1,34 +1,15 @@
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
1
+ import { a as e } from "../../../../chunks/types.js";
2
+ import { Calendar as t, Numbers as n, Section as r, Taxonomy as i, TextInput as a } from "@box/blueprint-web-assets/icons/Medium";
3
+ import { jsx as o } from "react/jsx-runtime";
4
+ import "react";
5
+ var s = (s) => (c) => {
6
+ switch (s) {
7
+ case e.Text: return /* @__PURE__ */ o(a, { ...c });
8
+ case e.Number: return /* @__PURE__ */ o(n, { ...c });
9
+ case e.Date: return /* @__PURE__ */ o(t, { ...c });
10
+ case e.Dropdown: return /* @__PURE__ */ o(r, { ...c });
11
+ case e.Taxonomy: return /* @__PURE__ */ o(i, { ...c });
12
+ default: return /* @__PURE__ */ o(a, { ...c });
13
+ }
34
14
  };
15
+ export { s as FieldTypeIcon };
@@ -1,9 +1,4 @@
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
- };
1
+ import { FieldTypeIcon as e } from "./field-type-icon.js";
2
+ import { fieldTypeDescriptionMessages as t, fieldTypesTitleMessages as n } from "./messages.js";
3
+ import { useFieldOptions as r } from "./useFieldOptions.js";
4
+ export { e as FieldTypeIcon, t as fieldTypeDescriptionMessages, n as fieldTypesTitleMessages, r as useFieldOptions };
@@ -1,48 +1,45 @@
1
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
- }
2
+ var 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
+ }), n = 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
44
  });
45
- export {
46
- d as fieldTypeDescriptionMessages,
47
- t as fieldTypesTitleMessages
48
- };
45
+ export { n as fieldTypeDescriptionMessages, t as fieldTypesTitleMessages };
@@ -1,19 +1,15 @@
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
- };
1
+ import { a as e } from "../../../../chunks/types.js";
2
+ import { FieldTypeIcon as t } from "./field-type-icon.js";
3
+ import { fieldTypeDescriptionMessages as n, fieldTypesTitleMessages as r } from "./messages.js";
4
+ import { useIntl as i } from "react-intl";
5
+ import { useMemo as a } from "react";
6
+ function o() {
7
+ let o = i();
8
+ return { availableFieldTypes: a(() => Object.values(e).map((e) => ({
9
+ type: e,
10
+ label: o.formatMessage(r[e]),
11
+ description: o.formatMessage(n[e]),
12
+ Icon: t(e)
13
+ })), [o]) };
16
14
  }
17
- export {
18
- T as useFieldOptions
19
- };
15
+ export { o as useFieldOptions };
@@ -1,29 +1,18 @@
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;
1
+ var e = 3, t = 1e3;
2
+ function n(e, t) {
3
+ let n = e.replace(/[^a-zA-Z0-9\s]/g, "").replace(/\w*/g, (e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).replace(/\s/g, ""), r = n.charAt(0).toLowerCase() + n.slice(1);
4
+ return r.length === 0 ? t : /^\d/.test(r) ? t + r : r;
4
5
  }
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
6
+ var r = (e, t) => !t.includes(e), i = ({ displayName: i, existingKeys: a, defaultKey: o, maxKeyLength: s }) => {
7
+ if (s <= e) throw Error("max key length is too short");
8
+ let c = s - e, l = n(i, o).substring(0, c);
9
+ if (r(l, a)) return l;
10
+ let u = 1, d = 0, f;
11
+ do {
12
+ if (d >= t) throw Error("Exceeded maximum iterations while generating unique key");
13
+ f = `${l}${u}`, u += 1, d += 1;
14
+ } while (!r(f, a));
15
+ if (f.length > s) throw Error("could not generate unique key less than max key length");
16
+ return f;
29
17
  };
18
+ export { n as displayNameToKey, i as generateKey };
@@ -1,78 +1,64 @@
1
- import { F as s, A as l, T as i } 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
1
+ import { a as e, c as t, n } from "../../../../chunks/types.js";
2
+ import "../constants.js";
3
+ import { generateKey as r } from "../key-generation.js";
4
+ var i = (e) => {
5
+ let { taxonomy: n } = e, r = n.availableTaxonomies.find((e) => e.taxonomyKey === n.taxonomyKey)?.levels.map((e) => e.level) || [];
6
+ return n.selection === t.AllowAny ? r : n.selectedLevels || [];
7
+ }, a = (t, a = []) => {
8
+ let { name: o, description: s, hidden: c, type: l } = t, u = r({
9
+ displayName: o,
10
+ existingKeys: a,
11
+ defaultKey: "field",
12
+ maxKeyLength: 256
13
+ }), d = {
14
+ key: u,
15
+ displayName: o,
16
+ description: s,
17
+ hidden: c
18
+ }, f;
19
+ switch (l) {
20
+ case e.Text:
21
+ f = {
22
+ ...d,
23
+ type: n.String
24
+ };
25
+ break;
26
+ case e.Number:
27
+ f = {
28
+ ...d,
29
+ type: n.Float
30
+ };
31
+ break;
32
+ case e.Date:
33
+ f = {
34
+ ...d,
35
+ type: n.Date
36
+ };
37
+ break;
38
+ case e.Dropdown:
39
+ f = {
40
+ ...d,
41
+ type: t.dropdown.allowMultipleSelections ? n.MultiSelect : n.Enum,
42
+ options: t.dropdown.options.map((e) => ({ key: e.key }))
43
+ };
44
+ break;
45
+ case e.Taxonomy:
46
+ f = {
47
+ ...d,
48
+ type: n.Taxonomy,
49
+ taxonomyKey: t.taxonomy.taxonomyKey,
50
+ optionsRules: {
51
+ selectableLevels: i(t),
52
+ multiSelect: t.taxonomy.allowMultipleSelections
53
+ },
54
+ namespace: t.taxonomy.namespace
55
+ };
56
+ break;
57
+ default: throw Error(`Unsupported field type: ${l}`);
58
+ }
59
+ return {
60
+ field: f,
61
+ updatedKeys: [...a, u]
62
+ };
78
63
  };
64
+ export { a as convertLocalConfiguratorToTemplateField, i as resolveSelectableLevels };