@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.
Files changed (215) hide show
  1. package/LICENSE +379 -0
  2. package/README.md +57 -0
  3. package/dist/chunks/metadata-field-configurator.module.js +17 -0
  4. package/dist/chunks/types.js +34 -0
  5. package/dist/esm/index.js +34 -0
  6. package/dist/esm/lib/components/field-selector/field-selector.js +39 -0
  7. package/dist/esm/lib/components/field-selector/index.js +4 -0
  8. package/dist/esm/lib/components/field-selector/messages.js +14 -0
  9. package/dist/esm/lib/components/field-type-dropdown/field-type-dropdown.js +47 -0
  10. package/dist/esm/lib/components/field-type-dropdown/index.js +4 -0
  11. package/dist/esm/lib/components/field-type-dropdown/messages.js +14 -0
  12. package/dist/esm/lib/components/field-type-tiles/field-type-tiles.js +40 -0
  13. package/dist/esm/lib/components/field-type-tiles/index.js +4 -0
  14. package/dist/esm/lib/components/field-type-tiles/messages.js +14 -0
  15. package/dist/esm/lib/components/metadata-field-configurator/components/confirmation-modal/confirmation-modal.js +46 -0
  16. package/dist/esm/lib/components/metadata-field-configurator/components/confirmation-modal/messages.js +18 -0
  17. package/dist/esm/lib/components/metadata-field-configurator/components/field-action-slot/field-action-slot.js +80 -0
  18. package/dist/esm/lib/components/metadata-field-configurator/components/field-context-menu/field-context-menu.js +115 -0
  19. package/dist/esm/lib/components/metadata-field-configurator/components/field-edit-content/field-edit-content.js +101 -0
  20. package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/chip.js +33 -0
  21. package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/index.js +4 -0
  22. package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/levels-chain.js +118 -0
  23. package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/utils.js +34 -0
  24. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/__mocks__/getInitialValues.js +33 -0
  25. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/dropdown-default-values.js +15 -0
  26. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/dropdown-field-configuration.js +66 -0
  27. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/sortable-option-list.js +294 -0
  28. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/index.js +6 -0
  29. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-default-values.js +15 -0
  30. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-field-configuration.js +149 -0
  31. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-field-configurator-initial-state.js +54 -0
  32. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector-messages.js +38 -0
  33. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector.js +103 -0
  34. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/useTaxonomySelect.js +19 -0
  35. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/utils.js +4 -0
  36. package/dist/esm/lib/components/metadata-field-configurator/context/field-configurator-context.js +68 -0
  37. package/dist/esm/lib/components/metadata-field-configurator/context/field-extensions-context.js +9 -0
  38. package/dist/esm/lib/components/metadata-field-configurator/context/taxonomy-options-context.js +23 -0
  39. package/dist/esm/lib/components/metadata-field-configurator/hooks/useFieldConfiguratorBehavior.js +119 -0
  40. package/dist/esm/lib/components/metadata-field-configurator/hooks/useFieldValidation.js +68 -0
  41. package/dist/esm/lib/components/metadata-field-configurator/hooks/useTaxonomyFetch.js +27 -0
  42. package/dist/esm/lib/components/metadata-field-configurator/hooks/useTemplateFieldSchema.js +44 -0
  43. package/dist/esm/lib/components/metadata-field-configurator/index.js +11 -0
  44. package/dist/esm/lib/components/metadata-field-configurator/messages/configurator-messages.js +136 -0
  45. package/dist/esm/lib/components/metadata-field-configurator/messages/dropdown-messages.js +38 -0
  46. package/dist/esm/lib/components/metadata-field-configurator/messages/levels-chain-messages.js +18 -0
  47. package/dist/esm/lib/components/metadata-field-configurator/messages/taxonomy-messages.js +38 -0
  48. package/dist/esm/lib/components/metadata-field-configurator/metadata-field-configurator.js +154 -0
  49. package/dist/esm/lib/components/metadata-field-configurator/utils.js +53 -0
  50. package/dist/esm/lib/components/metadata-field-list/index.js +5 -0
  51. package/dist/esm/lib/components/metadata-field-list/metadata-field-list.js +279 -0
  52. package/dist/esm/lib/components/metadata-template-editor-form/metadata-template-editor-form.js +137 -0
  53. package/dist/esm/lib/components/metadata-template-editor-modal/index.js +4 -0
  54. package/dist/esm/lib/components/metadata-template-editor-modal/metadata-template-editor-modal.js +103 -0
  55. package/dist/esm/lib/hooks/useMetadataTemplateFormSchema.js +16 -0
  56. package/dist/esm/lib/hooks/useTemplateNameSchema.js +12 -0
  57. package/dist/esm/lib/index.js +14 -0
  58. package/dist/esm/lib/messages.js +118 -0
  59. package/dist/esm/lib/metadata-template-editor.js +179 -0
  60. package/dist/esm/lib/utils/constants.js +8 -0
  61. package/dist/esm/lib/utils/field-options/field-type-icon.js +34 -0
  62. package/dist/esm/lib/utils/field-options/index.js +9 -0
  63. package/dist/esm/lib/utils/field-options/messages.js +48 -0
  64. package/dist/esm/lib/utils/field-options/useFieldOptions.js +19 -0
  65. package/dist/esm/lib/utils/key-generation.js +29 -0
  66. package/dist/esm/lib/utils/template-type-conversion/convertLocalConfiguratorToTemplateField.js +78 -0
  67. package/dist/esm/lib/utils/template-type-conversion/convertTemplateFieldToLocalConfigurator.js +90 -0
  68. package/dist/esm/lib/utils/template-type-conversion/generateJSONPatchTemplateOperations.js +179 -0
  69. package/dist/esm/lib/utils/template-type-conversion/mapFieldsWithUniqueKeys.js +14 -0
  70. package/dist/i18n/bn-IN.js +108 -0
  71. package/dist/i18n/bn-IN.properties +196 -0
  72. package/dist/i18n/da-DK.js +108 -0
  73. package/dist/i18n/da-DK.properties +196 -0
  74. package/dist/i18n/de-DE.js +108 -0
  75. package/dist/i18n/de-DE.properties +196 -0
  76. package/dist/i18n/en-AU.js +108 -0
  77. package/dist/i18n/en-AU.properties +196 -0
  78. package/dist/i18n/en-CA.js +108 -0
  79. package/dist/i18n/en-CA.properties +196 -0
  80. package/dist/i18n/en-GB.js +108 -0
  81. package/dist/i18n/en-GB.properties +196 -0
  82. package/dist/i18n/en-US.js +108 -0
  83. package/dist/i18n/en-US.properties +212 -0
  84. package/dist/i18n/en-x-pseudo.js +108 -0
  85. package/dist/i18n/en-x-pseudo.properties +196 -0
  86. package/dist/i18n/es-419.js +108 -0
  87. package/dist/i18n/es-419.properties +196 -0
  88. package/dist/i18n/es-ES.js +108 -0
  89. package/dist/i18n/es-ES.properties +196 -0
  90. package/dist/i18n/fi-FI.js +108 -0
  91. package/dist/i18n/fi-FI.properties +196 -0
  92. package/dist/i18n/fr-CA.js +108 -0
  93. package/dist/i18n/fr-CA.properties +196 -0
  94. package/dist/i18n/fr-FR.js +108 -0
  95. package/dist/i18n/fr-FR.properties +196 -0
  96. package/dist/i18n/hi-IN.js +108 -0
  97. package/dist/i18n/hi-IN.properties +196 -0
  98. package/dist/i18n/it-IT.js +108 -0
  99. package/dist/i18n/it-IT.properties +196 -0
  100. package/dist/i18n/ja-JP.js +108 -0
  101. package/dist/i18n/ja-JP.properties +196 -0
  102. package/dist/i18n/json/src/lib/components/field-selector/messages.json +1 -0
  103. package/dist/i18n/json/src/lib/components/field-type-dropdown/messages.json +1 -0
  104. package/dist/i18n/json/src/lib/components/field-type-tiles/messages.json +1 -0
  105. package/dist/i18n/json/src/lib/components/metadata-field-configurator/components/confirmation-modal/messages.json +1 -0
  106. package/dist/i18n/json/src/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector-messages.json +1 -0
  107. package/dist/i18n/json/src/lib/components/metadata-field-configurator/messages/configurator-messages.json +1 -0
  108. package/dist/i18n/json/src/lib/components/metadata-field-configurator/messages/dropdown-messages.json +1 -0
  109. package/dist/i18n/json/src/lib/components/metadata-field-configurator/messages/levels-chain-messages.json +1 -0
  110. package/dist/i18n/json/src/lib/components/metadata-field-configurator/messages/taxonomy-messages.json +1 -0
  111. package/dist/i18n/json/src/lib/messages.json +1 -0
  112. package/dist/i18n/json/src/lib/utils/field-options/messages.json +1 -0
  113. package/dist/i18n/ko-KR.js +108 -0
  114. package/dist/i18n/ko-KR.properties +196 -0
  115. package/dist/i18n/nb-NO.js +108 -0
  116. package/dist/i18n/nb-NO.properties +196 -0
  117. package/dist/i18n/nl-NL.js +108 -0
  118. package/dist/i18n/nl-NL.properties +196 -0
  119. package/dist/i18n/pl-PL.js +108 -0
  120. package/dist/i18n/pl-PL.properties +196 -0
  121. package/dist/i18n/pt-BR.js +108 -0
  122. package/dist/i18n/pt-BR.properties +196 -0
  123. package/dist/i18n/ru-RU.js +108 -0
  124. package/dist/i18n/ru-RU.properties +196 -0
  125. package/dist/i18n/sv-SE.js +108 -0
  126. package/dist/i18n/sv-SE.properties +196 -0
  127. package/dist/i18n/tr-TR.js +108 -0
  128. package/dist/i18n/tr-TR.properties +196 -0
  129. package/dist/i18n/zh-CN.js +108 -0
  130. package/dist/i18n/zh-CN.properties +196 -0
  131. package/dist/i18n/zh-TW.js +108 -0
  132. package/dist/i18n/zh-TW.properties +196 -0
  133. package/dist/styles/chip.css +1 -0
  134. package/dist/styles/dropdown-field-configuration.css +1 -0
  135. package/dist/styles/field-context-menu.css +1 -0
  136. package/dist/styles/field-selector.css +1 -0
  137. package/dist/styles/field-type-dropdown.css +1 -0
  138. package/dist/styles/levels-chain.css +1 -0
  139. package/dist/styles/metadata-field-configurator.css +1 -0
  140. package/dist/styles/metadata-field-list.css +1 -0
  141. package/dist/styles/metadata-template-editor-form.css +1 -0
  142. package/dist/styles/metadata-template-editor-modal.css +1 -0
  143. package/dist/styles/metadata-template-editor.css +1 -0
  144. package/dist/styles/sortable-option-list.css +1 -0
  145. package/dist/styles/taxonomy-field-configuration.css +1 -0
  146. package/dist/styles/taxonomy-field-configurator-initial-state.css +1 -0
  147. package/dist/styles/taxonomy-selector.css +1 -0
  148. package/dist/types/index.d.ts +8 -0
  149. package/dist/types/lib/components/field-selector/field-selector.d.ts +16 -0
  150. package/dist/types/lib/components/field-selector/index.d.ts +1 -0
  151. package/dist/types/lib/components/field-selector/messages.d.ts +13 -0
  152. package/dist/types/lib/components/field-type-dropdown/field-type-dropdown.d.ts +15 -0
  153. package/dist/types/lib/components/field-type-dropdown/index.d.ts +2 -0
  154. package/dist/types/lib/components/field-type-dropdown/messages.d.ts +12 -0
  155. package/dist/types/lib/components/field-type-tiles/field-type-tiles.d.ts +12 -0
  156. package/dist/types/lib/components/field-type-tiles/index.d.ts +2 -0
  157. package/dist/types/lib/components/field-type-tiles/messages.d.ts +12 -0
  158. package/dist/types/lib/components/metadata-field-configurator/components/confirmation-modal/confirmation-modal.d.ts +31 -0
  159. package/dist/types/lib/components/metadata-field-configurator/components/confirmation-modal/messages.d.ts +18 -0
  160. package/dist/types/lib/components/metadata-field-configurator/components/field-action-slot/field-action-slot.d.ts +30 -0
  161. package/dist/types/lib/components/metadata-field-configurator/components/field-context-menu/field-context-menu.d.ts +23 -0
  162. package/dist/types/lib/components/metadata-field-configurator/components/field-edit-content/field-edit-content.d.ts +20 -0
  163. package/dist/types/lib/components/metadata-field-configurator/components/levels-chain/chip.d.ts +17 -0
  164. package/dist/types/lib/components/metadata-field-configurator/components/levels-chain/index.d.ts +1 -0
  165. package/dist/types/lib/components/metadata-field-configurator/components/levels-chain/levels-chain.d.ts +31 -0
  166. package/dist/types/lib/components/metadata-field-configurator/components/levels-chain/utils.d.ts +10 -0
  167. package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/__mocks__/getInitialValues.d.ts +2 -0
  168. package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/dropdown-default-values.d.ts +2 -0
  169. package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/dropdown-field-configuration.d.ts +1 -0
  170. package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/sortable-option-list.d.ts +6 -0
  171. package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/index.d.ts +2 -0
  172. package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-default-values.d.ts +2 -0
  173. package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-field-configuration.d.ts +1 -0
  174. package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-field-configurator-initial-state.d.ts +1 -0
  175. package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector-messages.d.ts +43 -0
  176. package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector.d.ts +12 -0
  177. package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/useTaxonomySelect.d.ts +5 -0
  178. package/dist/types/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/utils.d.ts +2 -0
  179. package/dist/types/lib/components/metadata-field-configurator/context/field-configurator-context.d.ts +57 -0
  180. package/dist/types/lib/components/metadata-field-configurator/context/field-extensions-context.d.ts +52 -0
  181. package/dist/types/lib/components/metadata-field-configurator/context/taxonomy-options-context.d.ts +21 -0
  182. package/dist/types/lib/components/metadata-field-configurator/hooks/useFieldConfiguratorBehavior.d.ts +57 -0
  183. package/dist/types/lib/components/metadata-field-configurator/hooks/useFieldValidation.d.ts +27 -0
  184. package/dist/types/lib/components/metadata-field-configurator/hooks/useTaxonomyFetch.d.ts +19 -0
  185. package/dist/types/lib/components/metadata-field-configurator/hooks/useTemplateFieldSchema.d.ts +15 -0
  186. package/dist/types/lib/components/metadata-field-configurator/index.d.ts +6 -0
  187. package/dist/types/lib/components/metadata-field-configurator/messages/configurator-messages.d.ts +164 -0
  188. package/dist/types/lib/components/metadata-field-configurator/messages/dropdown-messages.d.ts +43 -0
  189. package/dist/types/lib/components/metadata-field-configurator/messages/levels-chain-messages.d.ts +18 -0
  190. package/dist/types/lib/components/metadata-field-configurator/messages/taxonomy-messages.d.ts +43 -0
  191. package/dist/types/lib/components/metadata-field-configurator/metadata-field-configurator.d.ts +191 -0
  192. package/dist/types/lib/components/metadata-field-configurator/stories/story-fixtures.d.ts +5 -0
  193. package/dist/types/lib/components/metadata-field-configurator/utils.d.ts +24 -0
  194. package/dist/types/lib/components/metadata-field-list/index.d.ts +2 -0
  195. package/dist/types/lib/components/metadata-field-list/metadata-field-list.d.ts +109 -0
  196. package/dist/types/lib/components/metadata-template-editor-form/metadata-template-editor-form.d.ts +20 -0
  197. package/dist/types/lib/components/metadata-template-editor-modal/index.d.ts +1 -0
  198. package/dist/types/lib/components/metadata-template-editor-modal/metadata-template-editor-modal.d.ts +56 -0
  199. package/dist/types/lib/hooks/useMetadataTemplateFormSchema.d.ts +17 -0
  200. package/dist/types/lib/hooks/useTemplateNameSchema.d.ts +2 -0
  201. package/dist/types/lib/index.d.ts +7 -0
  202. package/dist/types/lib/messages.d.ts +143 -0
  203. package/dist/types/lib/metadata-template-editor.d.ts +290 -0
  204. package/dist/types/lib/types.d.ts +311 -0
  205. package/dist/types/lib/utils/constants.d.ts +9 -0
  206. package/dist/types/lib/utils/field-options/field-type-icon.d.ts +6 -0
  207. package/dist/types/lib/utils/field-options/index.d.ts +4 -0
  208. package/dist/types/lib/utils/field-options/messages.d.ts +60 -0
  209. package/dist/types/lib/utils/field-options/useFieldOptions.d.ts +34 -0
  210. package/dist/types/lib/utils/key-generation.d.ts +24 -0
  211. package/dist/types/lib/utils/template-type-conversion/convertLocalConfiguratorToTemplateField.d.ts +25 -0
  212. package/dist/types/lib/utils/template-type-conversion/convertTemplateFieldToLocalConfigurator.d.ts +8 -0
  213. package/dist/types/lib/utils/template-type-conversion/generateJSONPatchTemplateOperations.d.ts +16 -0
  214. package/dist/types/lib/utils/template-type-conversion/mapFieldsWithUniqueKeys.d.ts +8 -0
  215. package/package.json +61 -0
@@ -0,0 +1,17 @@
1
+ /** Reflects the selection state of a Chip, surfaced as a `data-state` attribute for styling. */
2
+ export declare enum ChipState {
3
+ Selected = "selected",
4
+ Unselected = "unselected"
5
+ }
6
+ type ChipProps = {
7
+ /** Text content displayed inside the chip. */
8
+ value: string;
9
+ /** Whether this chip represents a selected taxonomy level. Defaults to `false`. */
10
+ selected?: boolean;
11
+ };
12
+ /**
13
+ * A small inline label used inside `LevelsChain` to represent a single taxonomy level.
14
+ * Applies selected/unselected visual styles and exposes an accessible aria-label.
15
+ */
16
+ export declare const Chip: ({ value, selected }: ChipProps) => import("react/jsx-runtime").JSX.Element;
17
+ export {};
@@ -0,0 +1 @@
1
+ export { LevelsChain } from './levels-chain';
@@ -0,0 +1,31 @@
1
+ import { TaxonomyLevel } from '../../../../types';
2
+ interface LevelsChainProps {
3
+ /** The full ordered list of taxonomy levels to display. Defaults to `[]`. */
4
+ levels?: TaxonomyLevel[];
5
+ /** The `.level` values of the currently selected levels. */
6
+ selectedLevels: number[];
7
+ }
8
+ /**
9
+ * Renders a chain of levels, splitting them into two halves and managing their visibility
10
+ * based on the available container width. Levels that do not fit within the container are hidden
11
+ * and represented by a counter chip in the middle.
12
+ *
13
+ * The `selected` state of each level is determined by checking if its `.level` property exists in the `selectedLevels` array.
14
+ *
15
+ * @param {LevelsChainProps} props - The props for the LevelsChain component.
16
+ * @param {TaxonomyLevel[]} [props.levels=[]] - The array of levels to be displayed.
17
+ * @param {number[]} props.selectedLevels - The level numbers of the selected levels.
18
+ *
19
+ * @returns {JSX.Element} The rendered LevelsChain component.
20
+ *
21
+ * @example
22
+ * // Example usage of LevelsChain component
23
+ * <LevelsChain levels={[{ name: 'Level 1', level: 1 }, { name: 'Level 2', level: 2 }]} selectedLevels={[1]} />
24
+ *
25
+ * @remarks
26
+ * - The component measures the widths of the levels and dynamically hides levels that do not fit within the container.
27
+ * - The hidden levels are represented by a counter chip in the middle of the chain.
28
+ * - The component re-measures the container width on window resize.
29
+ */
30
+ export declare const LevelsChain: ({ levels, selectedLevels }: LevelsChainProps) => import("react/jsx-runtime").JSX.Element;
31
+ export {};
@@ -0,0 +1,10 @@
1
+ interface HideCountsInputs {
2
+ isMeasured: boolean;
3
+ leftLevelWidths: number[];
4
+ rightLevelWidths: number[];
5
+ containerWidthPx: number;
6
+ buttonWidthPx: number;
7
+ gapBetweenItems: number;
8
+ }
9
+ export declare const getHideCounts: ({ isMeasured, leftLevelWidths, rightLevelWidths, containerWidthPx, buttonWidthPx, gapBetweenItems, }: HideCountsInputs) => [number, number];
10
+ export {};
@@ -0,0 +1,2 @@
1
+ import { FieldData } from '../../../../../../types';
2
+ export declare const getInitialValues: () => FieldData;
@@ -0,0 +1,2 @@
1
+ import { DropdownField } from '../../../../../types';
2
+ export declare const getDropdownDefaultValues: () => DropdownField;
@@ -0,0 +1 @@
1
+ export declare const DropdownFieldConfiguration: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,6 @@
1
+ type SortableOptionListProps = {
2
+ readonly shouldFocusLastOption: boolean;
3
+ readonly onFocusConsumed: () => void;
4
+ };
5
+ export declare function SortableOptionList({ shouldFocusLastOption, onFocusConsumed }: SortableOptionListProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
@@ -0,0 +1,2 @@
1
+ export { DropdownFieldConfiguration } from './dropdown/dropdown-field-configuration';
2
+ export { TaxonomyFieldConfiguration } from './taxonomy/taxonomy-field-configuration';
@@ -0,0 +1,2 @@
1
+ import { TaxonomyField } from '../../../../../types';
2
+ export declare const taxonomyDefaultValues: TaxonomyField;
@@ -0,0 +1 @@
1
+ export declare const TaxonomyFieldConfiguration: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1 @@
1
+ export declare const TaxonomyFieldConfiguratorInitialState: () => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,43 @@
1
+ declare const _default: {
2
+ taxonomySelectorAriaLabel: {
3
+ defaultMessage: string;
4
+ description: string;
5
+ id: string;
6
+ };
7
+ taxonomySelector: {
8
+ defaultMessage: string;
9
+ description: string;
10
+ id: string;
11
+ };
12
+ recentlyUsedTaxonomies: {
13
+ defaultMessage: string;
14
+ description: string;
15
+ id: string;
16
+ };
17
+ allTaxonomies: {
18
+ defaultMessage: string;
19
+ description: string;
20
+ id: string;
21
+ };
22
+ searchTaxonomiesInputPlaceholder: {
23
+ defaultMessage: string;
24
+ description: string;
25
+ id: string;
26
+ };
27
+ loadingTaxonomies: {
28
+ defaultMessage: string;
29
+ description: string;
30
+ id: string;
31
+ };
32
+ loadTaxonomiesError: {
33
+ defaultMessage: string;
34
+ description: string;
35
+ id: string;
36
+ };
37
+ retryLoadTaxonomies: {
38
+ defaultMessage: string;
39
+ description: string;
40
+ id: string;
41
+ };
42
+ };
43
+ export default _default;
@@ -0,0 +1,12 @@
1
+ import { default as React } from 'react';
2
+ import { TaxonomyOption } from '../../../../../types';
3
+ type TaxonomySelectorProps = {
4
+ data: TaxonomyOption[];
5
+ onClick: (option: TaxonomyOption) => void;
6
+ onSearchValue: (value: string) => void;
7
+ triggerButton?: React.ReactNode;
8
+ disabled?: boolean;
9
+ resetValueOnHide?: boolean;
10
+ };
11
+ export declare const TaxonomySelector: ({ data, onClick, onSearchValue, triggerButton, disabled, resetValueOnHide, }: TaxonomySelectorProps) => React.ReactElement;
12
+ export {};
@@ -0,0 +1,5 @@
1
+ import { FieldConfiguratorContextValue } from '../../../context/field-configurator-context';
2
+ import { TaxonomyOption } from '../../../../../types';
3
+ export declare const useTaxonomySelect: (ctx: Pick<FieldConfiguratorContextValue, "values" | "setFieldValue">) => {
4
+ onTaxonomySelect: (option: TaxonomyOption) => void;
5
+ };
@@ -0,0 +1,2 @@
1
+ import { TaxonomyOption } from '../../../../../types';
2
+ export declare const filterTaxonomiesByValue: (taxonomies: TaxonomyOption[], value: string) => TaxonomyOption[];
@@ -0,0 +1,57 @@
1
+ import { default as React } from 'react';
2
+ import { FieldData, BasicField } from '../../../types';
3
+ /**
4
+ * Form-library-agnostic interface for field configurator state and mutations.
5
+ * Sub-components consume this via {@link useFieldConfigurator} instead of
6
+ * coupling to any specific form library.
7
+ *
8
+ * The context is provided by {@link MetadataFieldConfigurator},
9
+ * which bridges parent-owned controlled state into these callbacks.
10
+ * In stories/tests, {@link FieldConfiguratorProvider} offers a self-contained
11
+ * alternative with its own internal state.
12
+ */
13
+ export interface FieldConfiguratorContextValue {
14
+ /** Current field data (name, type, dropdown options, taxonomy config, etc.). */
15
+ values: FieldData;
16
+ /** Validation errors keyed by field path (e.g. `{ name: "Required" }`). */
17
+ errors: Record<string, unknown>;
18
+ /** Tracks which fields have been interacted with, keyed by field path. */
19
+ touched: Record<string, unknown>;
20
+ /** Whether the current field data passes validation. */
21
+ isValid: boolean;
22
+ /** Set a top-level field value by key. Enforces that the value matches the field's type. */
23
+ setFieldValue<K extends keyof BasicField>(field: K, value: BasicField[K]): void;
24
+ /** Replace the entire values object. */
25
+ setValues(values: FieldData): void;
26
+ /** Mark a single field as touched by dot-path. */
27
+ setFieldTouched(field: string, isTouched?: boolean): void;
28
+ /** Replace the entire touched map. */
29
+ setTouched(touched: Record<string, unknown>): void;
30
+ /** onChange handler for native `<input>` elements. Reads `name` from `e.target` as a dot-path. */
31
+ handleChange(e: React.ChangeEvent<HTMLInputElement>): void;
32
+ /** onBlur handler that marks the blurred field as touched via `e.target.name`. */
33
+ handleBlur(e: React.FocusEvent<unknown>): void;
34
+ /** Trigger validation. The parent decides the validation strategy. */
35
+ validateForm(): Promise<void>;
36
+ }
37
+ export declare const FieldConfiguratorContext: React.Context<FieldConfiguratorContextValue | null>;
38
+ /**
39
+ * Returns the nearest {@link FieldConfiguratorContextValue}.
40
+ * Must be called inside a `<FieldConfiguratorContext.Provider>` (production)
41
+ * or `<FieldConfiguratorProvider>` (stories/tests).
42
+ */
43
+ export declare function useFieldConfigurator(): FieldConfiguratorContextValue;
44
+ /**
45
+ * Self-contained provider that manages form state internally.
46
+ * Intended for stories, tests, and standalone sub-component usage
47
+ * where no external form library drives the state.
48
+ *
49
+ * `initialErrors` and `initialTouched` let stories pre-seed validation state
50
+ * so error UI can be displayed on first paint without running the full validation schema.
51
+ */
52
+ export declare const FieldConfiguratorProvider: React.FC<{
53
+ initialValues: FieldData;
54
+ initialErrors?: Record<string, unknown>;
55
+ initialTouched?: Record<string, unknown>;
56
+ children: React.ReactNode;
57
+ }>;
@@ -0,0 +1,52 @@
1
+ import { FunctionComponent, PropsWithChildren, SVGProps } from 'react';
2
+ import { FieldData } from '../../../types';
3
+ /**
4
+ * A single domain-specific extension that can be injected into a field configurator.
5
+ *
6
+ * When one or more extensions are provided, the field configurator gains a tab switcher
7
+ * in its header action area. The first tab always shows the built-in Edit UI; subsequent
8
+ * tabs render the extension's content panel with the current field data.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * const myExtension: FieldConfiguratorExtension = {
13
+ * icon: MyCustomIcon,
14
+ * label: 'My settings',
15
+ * renderContent: field => <MyFieldSettings field={field} />,
16
+ * };
17
+ *
18
+ * <MetadataFieldList fields={fields} fieldExtensions={[myExtension]} />
19
+ * ```
20
+ */
21
+ export interface FieldConfiguratorExtension {
22
+ /**
23
+ * Icon displayed as the tab trigger button.
24
+ * Use the same SVG icon component format as the rest of the blueprint-web icon system.
25
+ */
26
+ icon: FunctionComponent<PropsWithChildren<SVGProps<SVGSVGElement>>>;
27
+ /**
28
+ * Accessible label for the tab trigger button (used as `aria-label`).
29
+ */
30
+ label: string;
31
+ /**
32
+ * Renders the extension's content panel.
33
+ * Receives the current field's data snapshot — read-only.
34
+ * To mutate the field, consume `useFieldConfigurator()` from within the rendered subtree.
35
+ */
36
+ renderContent: (field: FieldData) => React.ReactNode;
37
+ }
38
+ /**
39
+ * Provides the list of field configurator extensions to the subtree.
40
+ * Consumed by `MetadataFieldConfigurator` via `useFieldExtensions()`.
41
+ *
42
+ * Any component in the tree (`MetadataTemplateEditor`, `MetadataTemplateEditorForm`,
43
+ * `MetadataFieldList`, `MetadataFieldConfigurator`) can be the provider — the nearest
44
+ * one wins. When no provider is present, the default empty array is used and the
45
+ * configurator renders its standard Edit UI without any tabs.
46
+ */
47
+ export declare const FieldExtensionsContext: import('react').Context<FieldConfiguratorExtension[]>;
48
+ /**
49
+ * Returns the nearest list of field configurator extensions.
50
+ * Returns an empty array when no `FieldExtensionsContext.Provider` is present.
51
+ */
52
+ export declare function useFieldExtensions(): FieldConfiguratorExtension[];
@@ -0,0 +1,21 @@
1
+ import { TaxonomyOption } from '../../../types';
2
+ export type TaxonomyFetchStatus = 'idle' | 'loading' | 'success' | 'error';
3
+ export type TaxonomyContextValue = {
4
+ /** Currently available taxonomy options. Empty while loading. */
5
+ options: TaxonomyOption[];
6
+ /** Fetch lifecycle state. `'idle'` before first open, `'success'` once loaded. */
7
+ status: TaxonomyFetchStatus;
8
+ /**
9
+ * Called when the taxonomy selector popover opens.
10
+ * Triggers a lazy fetch (if `fetchTaxonomies` was provided) or is a no-op for static options.
11
+ * On error, calling this again retries the fetch.
12
+ */
13
+ onSelectorOpen: () => void;
14
+ };
15
+ export declare const TaxonomyOptionsContext: import('react').Context<TaxonomyContextValue>;
16
+ export declare function useTaxonomyOptions(): TaxonomyContextValue;
17
+ /**
18
+ * Creates a static (pre-fetched) taxonomy context value.
19
+ * Use in stories, tests, or when you already have the options available.
20
+ */
21
+ export declare function createStaticTaxonomyContext(options: TaxonomyOption[]): TaxonomyContextValue;
@@ -0,0 +1,57 @@
1
+ import { FieldConfiguratorExtension } from '../context/field-extensions-context';
2
+ import { FieldConfiguratorContextValue } from '../context/field-configurator-context';
3
+ import { TaxonomyContextValue } from '../context/taxonomy-options-context';
4
+ import { FieldData, TaxonomyOption } from '../../../types';
5
+ export type UseFieldConfiguratorBehaviorParams = {
6
+ values: FieldData;
7
+ onValuesChange: (values: FieldData) => void;
8
+ onDelete?: (key: string) => void;
9
+ isExpanded?: boolean;
10
+ onExpandedChange?: (expanded: boolean) => void;
11
+ submitAttemptCount?: number;
12
+ taxonomyOptions?: TaxonomyOption[];
13
+ fetchTaxonomies?: () => Promise<TaxonomyOption[]>;
14
+ fieldExtensionsProp?: FieldConfiguratorExtension[];
15
+ onValidationChange?: (isValid: boolean) => void;
16
+ };
17
+ export type FieldConfiguratorBehavior = {
18
+ /** Value for `FieldConfiguratorContext.Provider`. */
19
+ contextValue: FieldConfiguratorContextValue;
20
+ /** Value for `TaxonomyOptionsContext.Provider` (only used in standalone mode). */
21
+ taxonomyContextValue: TaxonomyContextValue;
22
+ /** Resolved extension list (prop wins over context). */
23
+ extensions: FieldConfiguratorExtension[];
24
+ /** Whether the accordion item is currently open. */
25
+ isActive: boolean;
26
+ /** Change handler for the standalone Accordion root's `onValueChange`. */
27
+ handleAccordionValueChange: (value: string) => void;
28
+ isDeleteConfirmationModalOpen: boolean;
29
+ openConfirmationModal: () => void;
30
+ closeConfirmationModal: () => void;
31
+ handleDeleteField: () => void;
32
+ /** Controlled tab ID for the ContentSwitcher (`'edit'` | `'ext-N'`). */
33
+ activeTabId: string;
34
+ setActiveTabId: (id: string) => void;
35
+ /** The active extension, or `null` when the Edit tab is selected. */
36
+ activeExtension: FieldConfiguratorExtension | null;
37
+ isTypeEditable: boolean;
38
+ /** Stable client-side ID used as the Accordion item value and DOM ID prefix. */
39
+ uniqueKey: string;
40
+ nameInputId: string;
41
+ descriptionInputId: string;
42
+ accordionTitle: string;
43
+ TitleIcon: (props: React.SVGProps<SVGSVGElement>) => React.JSX.Element;
44
+ /** Whether there are visible (touched) validation errors on the field. */
45
+ hasErrors: boolean;
46
+ /** Called when the user picks a new field type from the Select. */
47
+ handleTypeChange: (fieldType: FieldData['type']) => void;
48
+ /** Called by FieldContextMenu when the user toggles field visibility. */
49
+ handleChangeVisibility: (hidden: boolean) => void;
50
+ };
51
+ /**
52
+ * Encapsulates all state, effects, and callbacks for `MetadataFieldConfigurator`.
53
+ *
54
+ * Separated from the rendering layer so the component file stays focused on
55
+ * structure and the hook can be read, tested, and reasoned about in isolation.
56
+ */
57
+ export declare function useFieldConfiguratorBehavior({ values, onValuesChange, onDelete, isExpanded, onExpandedChange, submitAttemptCount, taxonomyOptions, fetchTaxonomies, fieldExtensionsProp, onValidationChange, }: UseFieldConfiguratorBehaviorParams): FieldConfiguratorBehavior;
@@ -0,0 +1,27 @@
1
+ import { FocusEvent } from 'react';
2
+ import { FieldData } from '../../../types';
3
+ export type FieldValidationResult = {
4
+ errors: Record<string, unknown>;
5
+ touched: Record<string, unknown>;
6
+ isValid: boolean;
7
+ /** Trigger validation against the current values. */
8
+ validateForm: () => Promise<void>;
9
+ /**
10
+ * Marks every leaf in the current values tree as touched.
11
+ * Call this on collapse to surface all pending errors immediately.
12
+ */
13
+ touchAll: () => void;
14
+ /** Mark a single field path as touched. */
15
+ setFieldTouched: (field: string, isTouched?: boolean) => void;
16
+ /** Replace the entire touched map. */
17
+ setTouched: (touched: Record<string, unknown>) => void;
18
+ /** onBlur handler that marks the blurred field as touched via `e.target.name`. */
19
+ handleBlur: (e: FocusEvent<unknown>) => void;
20
+ };
21
+ /**
22
+ * Runs the metadata field Yup schema against `values` and keeps
23
+ * `errors` / `isValid` / `touched` in sync.
24
+ *
25
+ * Used internally by `MetadataFieldConfigurator` — not intended for direct use.
26
+ */
27
+ export declare function useFieldValidation(values: FieldData): FieldValidationResult;
@@ -0,0 +1,19 @@
1
+ import { TaxonomyOption } from '../../../types';
2
+ import { TaxonomyContextValue } from '../context/taxonomy-options-context';
3
+ /**
4
+ * Manages lazy, on-demand fetching of taxonomy options for use with `TaxonomyOptionsContext`.
5
+ *
6
+ * When `fetchTaxonomies` is not provided, returns a static no-fetch context (status `'success'`,
7
+ * empty options, no-op `onSelectorOpen`) so the taxonomy selector renders normally with whatever
8
+ * options were pre-supplied via the `taxonomyOptions` prop.
9
+ *
10
+ * When `fetchTaxonomies` is provided:
11
+ * - Fetch is deferred until `onSelectorOpen` is called (i.e. the popover opens).
12
+ * - Results are cached: a successful fetch is never repeated on subsequent opens.
13
+ * - On error, calling `onSelectorOpen` again (via the retry button) restarts the fetch.
14
+ *
15
+ * @param fetchTaxonomies - An async function that resolves to an array of taxonomy options.
16
+ * The function is called by the shared feature — consumers do not need to manage loading state.
17
+ * @param staticOptions - Fallback options used when `fetchTaxonomies` is not provided.
18
+ */
19
+ export declare function useTaxonomyFetch(fetchTaxonomies?: () => Promise<TaxonomyOption[]>, staticOptions?: TaxonomyOption[]): TaxonomyContextValue;
@@ -0,0 +1,15 @@
1
+ import { FieldType } from '../../../types';
2
+ import * as Yup from 'yup';
3
+ /**
4
+ * Returns a memoized Yup validation schema for a metadata template field.
5
+ *
6
+ * The schema is lazily evaluated so that type-specific rules (dropdown options,
7
+ * taxonomy configuration) are only applied when the field type matches.
8
+ * Error messages are localised via `react-intl`.
9
+ */
10
+ export declare const useTemplateFieldSchema: () => Yup.Lazy<{
11
+ description?: string | null | undefined;
12
+ name: string;
13
+ type: NonNullable<FieldType | undefined>;
14
+ hidden: NonNullable<boolean | undefined>;
15
+ }, Yup.AnyObject, any>;
@@ -0,0 +1,6 @@
1
+ export { useTemplateFieldSchema } from './hooks/useTemplateFieldSchema';
2
+ export { MetadataFieldConfigurator, } from './metadata-field-configurator';
3
+ export type { GeneralComponentProps, MetadataFieldConfiguratorProps } from './metadata-field-configurator';
4
+ export { createDefaultFieldValues } from './utils';
5
+ export { FieldExtensionsContext, useFieldExtensions } from './context/field-extensions-context';
6
+ export type { FieldConfiguratorExtension } from './context/field-extensions-context';
@@ -0,0 +1,164 @@
1
+ export declare const general: {
2
+ fieldTypeLabel: {
3
+ defaultMessage: string;
4
+ description: string;
5
+ id: string;
6
+ };
7
+ fieldTypePlaceholder: {
8
+ defaultMessage: string;
9
+ description: string;
10
+ id: string;
11
+ };
12
+ fieldNameLabel: {
13
+ defaultMessage: string;
14
+ description: string;
15
+ id: string;
16
+ };
17
+ fieldNameInputPlaceholder: {
18
+ defaultMessage: string;
19
+ description: string;
20
+ id: string;
21
+ };
22
+ fieldDescriptionLabel: {
23
+ defaultMessage: string;
24
+ description: string;
25
+ id: string;
26
+ };
27
+ fieldDescriptionInputPlaceholder: {
28
+ defaultMessage: string;
29
+ description: string;
30
+ id: string;
31
+ };
32
+ descriptionInfoTooltip: {
33
+ defaultMessage: string;
34
+ description: string;
35
+ id: string;
36
+ };
37
+ descriptionLearnMoreBadgeAriaLabel: {
38
+ defaultMessage: string;
39
+ description: string;
40
+ id: string;
41
+ };
42
+ dragAndDropFieldAriaLabel: {
43
+ defaultMessage: string;
44
+ description: string;
45
+ id: string;
46
+ };
47
+ hideField: {
48
+ defaultMessage: string;
49
+ description: string;
50
+ id: string;
51
+ };
52
+ showField: {
53
+ defaultMessage: string;
54
+ description: string;
55
+ id: string;
56
+ };
57
+ hiddenStatus: {
58
+ defaultMessage: string;
59
+ description: string;
60
+ id: string;
61
+ };
62
+ deleteFieldTitle: {
63
+ defaultMessage: string;
64
+ description: string;
65
+ id: string;
66
+ };
67
+ deleteFieldDescription: {
68
+ defaultMessage: string;
69
+ description: string;
70
+ id: string;
71
+ };
72
+ cancelDeleteField: {
73
+ defaultMessage: string;
74
+ description: string;
75
+ id: string;
76
+ };
77
+ confirmDeleteField: {
78
+ defaultMessage: string;
79
+ description: string;
80
+ id: string;
81
+ };
82
+ moveUp: {
83
+ defaultMessage: string;
84
+ description: string;
85
+ id: string;
86
+ };
87
+ moveUpAriaLabel: {
88
+ defaultMessage: string;
89
+ description: string;
90
+ id: string;
91
+ };
92
+ moveDown: {
93
+ defaultMessage: string;
94
+ description: string;
95
+ id: string;
96
+ };
97
+ moveDownAriaLabel: {
98
+ defaultMessage: string;
99
+ description: string;
100
+ id: string;
101
+ };
102
+ deleteField: {
103
+ defaultMessage: string;
104
+ description: string;
105
+ id: string;
106
+ };
107
+ deleteFieldAriaLabel: {
108
+ defaultMessage: string;
109
+ description: string;
110
+ id: string;
111
+ };
112
+ contextMenuAriaLabel: {
113
+ defaultMessage: string;
114
+ description: string;
115
+ id: string;
116
+ };
117
+ editTabAriaLabel: {
118
+ defaultMessage: string;
119
+ description: string;
120
+ id: string;
121
+ };
122
+ duplicateField: {
123
+ defaultMessage: string;
124
+ description: string;
125
+ id: string;
126
+ };
127
+ duplicateFieldAriaLabel: {
128
+ defaultMessage: string;
129
+ description: string;
130
+ id: string;
131
+ };
132
+ };
133
+ export declare const validationErrors: {
134
+ fieldNameCannotBeEmpty: {
135
+ defaultMessage: string;
136
+ description: string;
137
+ id: string;
138
+ };
139
+ fieldNameTooLong: {
140
+ defaultMessage: string;
141
+ description: string;
142
+ id: string;
143
+ };
144
+ duplicateOption: {
145
+ defaultMessage: string;
146
+ description: string;
147
+ id: string;
148
+ };
149
+ optionKeyCannotBeEmpty: {
150
+ defaultMessage: string;
151
+ description: string;
152
+ id: string;
153
+ };
154
+ selectedLevelRequired: {
155
+ defaultMessage: string;
156
+ description: string;
157
+ id: string;
158
+ };
159
+ thisFieldContainsErrors: {
160
+ defaultMessage: string;
161
+ description: string;
162
+ id: string;
163
+ };
164
+ };
@@ -0,0 +1,43 @@
1
+ declare const _default: {
2
+ addOption: {
3
+ defaultMessage: string;
4
+ description: string;
5
+ id: string;
6
+ };
7
+ deleteDropdownOptionAriaLabel: {
8
+ defaultMessage: string;
9
+ description: string;
10
+ id: string;
11
+ };
12
+ dragAndDropOptionAriaLabel: {
13
+ defaultMessage: string;
14
+ description: string;
15
+ id: string;
16
+ };
17
+ allowMultipleSelection: {
18
+ defaultMessage: string;
19
+ description: string;
20
+ id: string;
21
+ };
22
+ addAnOptionOptionPlaceholder: {
23
+ defaultMessage: string;
24
+ description: string;
25
+ id: string;
26
+ };
27
+ deleteOptionTitle: {
28
+ id: string;
29
+ description: string;
30
+ defaultMessage: string;
31
+ };
32
+ deleteOptionDescription: {
33
+ id: string;
34
+ description: string;
35
+ defaultMessage: string;
36
+ };
37
+ optionListValidationError: {
38
+ id: string;
39
+ description: string;
40
+ defaultMessage: string;
41
+ };
42
+ };
43
+ export default _default;
@@ -0,0 +1,18 @@
1
+ declare const _default: {
2
+ noLevels: {
3
+ defaultMessage: string;
4
+ description: string;
5
+ id: string;
6
+ };
7
+ chipSelected: {
8
+ defaultMessage: string;
9
+ description: string;
10
+ id: string;
11
+ };
12
+ chipNotSelected: {
13
+ defaultMessage: string;
14
+ description: string;
15
+ id: string;
16
+ };
17
+ };
18
+ export default _default;