@box/metadata-template-editor 2.2.24 → 2.2.25

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 (83) hide show
  1. package/dist/chunks/chip.js +1 -22
  2. package/dist/chunks/dropdown-field-configuration.js +1 -62
  3. package/dist/chunks/field-context-menu.js +1 -91
  4. package/dist/chunks/field-selector.js +1 -23
  5. package/dist/chunks/field-type-dropdown.js +1 -31
  6. package/dist/chunks/levels-chain.js +1 -120
  7. package/dist/chunks/metadata-field-configurator.module.js +1 -21
  8. package/dist/chunks/metadata-field-list.js +1 -280
  9. package/dist/chunks/metadata-template-editor-form.js +1 -132
  10. package/dist/chunks/metadata-template-editor-modal.js +1 -90
  11. package/dist/chunks/metadata-template-editor.js +1 -161
  12. package/dist/chunks/sortable-option-list.js +1 -230
  13. package/dist/chunks/taxonomy-field-configuration.js +1 -123
  14. package/dist/chunks/taxonomy-field-configurator-initial-state.js +1 -49
  15. package/dist/chunks/taxonomy-selector.js +1 -89
  16. package/dist/chunks/types.js +1 -23
  17. package/dist/esm/index.js +1 -22
  18. package/dist/esm/lib/components/field-selector/field-selector.js +1 -2
  19. package/dist/esm/lib/components/field-selector/index.js +1 -2
  20. package/dist/esm/lib/components/field-selector/messages.js +1 -12
  21. package/dist/esm/lib/components/field-type-dropdown/field-type-dropdown.js +1 -2
  22. package/dist/esm/lib/components/field-type-dropdown/index.js +1 -2
  23. package/dist/esm/lib/components/field-type-dropdown/messages.js +1 -12
  24. package/dist/esm/lib/components/field-type-tiles/field-type-tiles.js +1 -33
  25. package/dist/esm/lib/components/field-type-tiles/index.js +1 -2
  26. package/dist/esm/lib/components/field-type-tiles/messages.js +1 -12
  27. package/dist/esm/lib/components/metadata-field-configurator/components/confirmation-modal/confirmation-modal.js +1 -33
  28. package/dist/esm/lib/components/metadata-field-configurator/components/confirmation-modal/messages.js +1 -16
  29. package/dist/esm/lib/components/metadata-field-configurator/components/field-action-slot/field-action-slot.js +1 -67
  30. package/dist/esm/lib/components/metadata-field-configurator/components/field-context-menu/field-context-menu.js +1 -2
  31. package/dist/esm/lib/components/metadata-field-configurator/components/field-edit-content/field-edit-content.js +1 -84
  32. package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/chip.js +1 -2
  33. package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/index.js +1 -2
  34. package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/levels-chain.js +1 -2
  35. package/dist/esm/lib/components/metadata-field-configurator/components/levels-chain/utils.js +1 -17
  36. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/__mocks__/getInitialValues.js +1 -35
  37. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/dropdown-default-values.js +1 -11
  38. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/dropdown-field-configuration.js +1 -2
  39. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/dropdown/sortable-option-list.js +1 -2
  40. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/index.js +1 -3
  41. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-default-values.js +1 -11
  42. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-field-configuration.js +1 -2
  43. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-field-configurator-initial-state.js +1 -2
  44. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector-messages.js +1 -36
  45. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/taxonomy-selector.js +1 -2
  46. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/useTaxonomySelect.js +1 -15
  47. package/dist/esm/lib/components/metadata-field-configurator/components/type-specific-configuration/taxonomy/utils.js +1 -2
  48. package/dist/esm/lib/components/metadata-field-configurator/context/editor-config-context.js +1 -3
  49. package/dist/esm/lib/components/metadata-field-configurator/context/field-configurator-context.js +1 -62
  50. package/dist/esm/lib/components/metadata-field-configurator/context/field-extensions-context.js +1 -6
  51. package/dist/esm/lib/components/metadata-field-configurator/context/taxonomy-options-context.js +1 -17
  52. package/dist/esm/lib/components/metadata-field-configurator/hooks/useFieldConfiguratorBehavior.js +1 -102
  53. package/dist/esm/lib/components/metadata-field-configurator/hooks/useFieldValidation.js +1 -54
  54. package/dist/esm/lib/components/metadata-field-configurator/hooks/useTaxonomyFetch.js +1 -24
  55. package/dist/esm/lib/components/metadata-field-configurator/hooks/useTemplateFieldSchema.js +1 -35
  56. package/dist/esm/lib/components/metadata-field-configurator/index.js +1 -14
  57. package/dist/esm/lib/components/metadata-field-configurator/messages/configurator-messages.js +1 -133
  58. package/dist/esm/lib/components/metadata-field-configurator/messages/dropdown-messages.js +1 -36
  59. package/dist/esm/lib/components/metadata-field-configurator/messages/levels-chain-messages.js +1 -16
  60. package/dist/esm/lib/components/metadata-field-configurator/messages/taxonomy-messages.js +1 -36
  61. package/dist/esm/lib/components/metadata-field-configurator/metadata-field-configurator.js +1 -106
  62. package/dist/esm/lib/components/metadata-field-configurator/utils.js +1 -46
  63. package/dist/esm/lib/components/metadata-field-list/index.js +1 -2
  64. package/dist/esm/lib/components/metadata-field-list/metadata-field-list.js +1 -2
  65. package/dist/esm/lib/components/metadata-template-editor-form/metadata-template-editor-form.js +1 -2
  66. package/dist/esm/lib/components/metadata-template-editor-modal/index.js +1 -2
  67. package/dist/esm/lib/components/metadata-template-editor-modal/metadata-template-editor-modal.js +1 -2
  68. package/dist/esm/lib/hooks/useMetadataTemplateFormSchema.js +1 -14
  69. package/dist/esm/lib/hooks/useTemplateNameSchema.js +1 -10
  70. package/dist/esm/lib/index.js +1 -8
  71. package/dist/esm/lib/messages.js +1 -128
  72. package/dist/esm/lib/metadata-template-editor.js +1 -2
  73. package/dist/esm/lib/utils/constants.js +1 -2
  74. package/dist/esm/lib/utils/field-options/field-type-icon.js +1 -15
  75. package/dist/esm/lib/utils/field-options/index.js +1 -4
  76. package/dist/esm/lib/utils/field-options/messages.js +1 -45
  77. package/dist/esm/lib/utils/field-options/useFieldOptions.js +1 -16
  78. package/dist/esm/lib/utils/key-generation.js +1 -18
  79. package/dist/esm/lib/utils/template-type-conversion/convertLocalConfiguratorToTemplateField.js +1 -64
  80. package/dist/esm/lib/utils/template-type-conversion/convertTemplateFieldToLocalConfigurator.js +1 -70
  81. package/dist/esm/lib/utils/template-type-conversion/generateJSONPatchTemplateOperations.js +1 -160
  82. package/dist/esm/lib/utils/template-type-conversion/mapFieldsWithUniqueKeys.js +1 -9
  83. package/package.json +7 -7
@@ -1,22 +1 @@
1
- import e from "../esm/lib/components/metadata-field-configurator/messages/levels-chain-messages.js";
2
- import { Text as t } from "@box/blueprint-web";
3
- import { useIntl as n } from "react-intl";
4
- import { jsx as r } from "react/jsx-runtime";
5
- import i from "clsx";
6
- import '../styles/chip.css';var a = {
7
- chip: "_chip_plmye_1",
8
- selected: "_selected_plmye_8"
9
- }, o = /* @__PURE__ */ function(e) {
10
- return e.Selected = "selected", e.Unselected = "unselected", e;
11
- }({}), s = ({ value: o, selected: s = !1 }) => {
12
- let { formatMessage: c } = n(), l = c(s ? e.chipSelected : e.chipNotSelected);
13
- return /* @__PURE__ */ r(t, {
14
- as: "span",
15
- className: i(a.chip, { [a.selected]: s }),
16
- color: s ? "textOnDarkDefault" : "textOnLightDefault",
17
- "data-state": s ? "selected" : "unselected",
18
- "aria-label": `${o}: ${l}`,
19
- children: o
20
- });
21
- };
22
- export { o as n, s as t };
1
+ import levels_chain_messages_default from"../esm/lib/components/metadata-field-configurator/messages/levels-chain-messages.js";import{Text}from"@box/blueprint-web";import{useIntl}from"react-intl";import{jsx}from"react/jsx-runtime";import clsx from"clsx";import '../styles/chip.css';var chip_module_default={chip:`_chip_plmye_1`,selected:`_selected_plmye_8`},ChipState=function(ChipState){return ChipState.Selected=`selected`,ChipState.Unselected=`unselected`,ChipState}({}),Chip=({value,selected=!1})=>{let{formatMessage}=useIntl(),selectedLabel=formatMessage(selected?levels_chain_messages_default.chipSelected:levels_chain_messages_default.chipNotSelected);return jsx(Text,{as:`span`,className:clsx(chip_module_default.chip,{[chip_module_default.selected]:selected}),color:selected?`textOnDarkDefault`:`textOnLightDefault`,"data-state":selected?`selected`:`unselected`,"aria-label":`${value}: ${selectedLabel}`,children:value})};export{ChipState as n,Chip as t};
@@ -1,62 +1 @@
1
- import { useFieldConfigurator as e } from "../esm/lib/components/metadata-field-configurator/context/field-configurator-context.js";
2
- import t from "../esm/lib/components/metadata-field-configurator/messages/dropdown-messages.js";
3
- import { t as n } from "./sortable-option-list.js";
4
- import { InlineNotice as r, Switch as i, TextButton as a } from "@box/blueprint-web";
5
- import { useIntl as o } from "react-intl";
6
- import { jsx as s, jsxs as c } from "react/jsx-runtime";
7
- import { useCallback as l, useEffect as u, useState as d } from "react";
8
- import f from "lodash/uniqueId";
9
- import '../styles/dropdown-field-configuration.css';var p = {
10
- dropdownFieldConfiguration: "_dropdownFieldConfiguration_rjv8w_1",
11
- addOptionButton: "_addOptionButton_rjv8w_7"
12
- }, m = () => {
13
- let { formatMessage: m } = o(), { values: h, errors: g, touched: _, setFieldValue: v } = e(), [y, b] = d(!1), x = h.dropdown.options.length > 0, S = g.dropdown, C = _.dropdown, w = S?.options?.some((e, t) => e?.key && C?.options?.[t]), T = l((e = !1) => {
14
- v("dropdown", {
15
- ...h.dropdown,
16
- options: [...h.dropdown.options, {
17
- id: f(),
18
- key: "",
19
- isNew: !0
20
- }]
21
- }), b(e);
22
- }, [h.dropdown, v]), E = l(() => {
23
- T(!0);
24
- }, [T]);
25
- u(() => {
26
- x || T(!1);
27
- }, [x, T]);
28
- let D = l(() => {
29
- b(!1);
30
- }, []);
31
- return /* @__PURE__ */ c("div", {
32
- className: p.dropdownFieldConfiguration,
33
- children: [
34
- w && /* @__PURE__ */ s(r, {
35
- variant: "error",
36
- variantIconAriaLabel: m(t.optionListValidationError),
37
- children: m(t.optionListValidationError)
38
- }),
39
- x && /* @__PURE__ */ s(n, {
40
- shouldFocusLastOption: y,
41
- onFocusConsumed: D
42
- }),
43
- !h.isFieldReadOnly && /* @__PURE__ */ s(a, {
44
- className: p.addOptionButton,
45
- onClick: E,
46
- children: m(t.addOption)
47
- }),
48
- /* @__PURE__ */ s(i.Item, {
49
- name: "dropdown.allowMultipleSelections",
50
- checked: h.dropdown.allowMultipleSelections,
51
- disabled: !h.isFieldNew || h.isFieldReadOnly,
52
- label: m(t.allowMultipleSelection),
53
- onCheckedChange: (e) => v("dropdown", {
54
- ...h.dropdown,
55
- allowMultipleSelections: e
56
- }),
57
- value: "true"
58
- })
59
- ]
60
- });
61
- };
62
- export { m as t };
1
+ import{useFieldConfigurator}from"../esm/lib/components/metadata-field-configurator/context/field-configurator-context.js";import dropdown_messages_default from"../esm/lib/components/metadata-field-configurator/messages/dropdown-messages.js";import{t as SortableOptionList}from"./sortable-option-list.js";import{InlineNotice,Switch,TextButton}from"@box/blueprint-web";import{useIntl}from"react-intl";import{jsx,jsxs}from"react/jsx-runtime";import{useCallback,useEffect,useState}from"react";import uniqueId from"lodash/uniqueId";import '../styles/dropdown-field-configuration.css';var dropdown_field_configuration_module_default={dropdownFieldConfiguration:`_dropdownFieldConfiguration_rjv8w_1`,addOptionButton:`_addOptionButton_rjv8w_7`},DropdownFieldConfiguration=()=>{let{formatMessage}=useIntl(),{values,errors,touched,setFieldValue}=useFieldConfigurator(),[shouldFocusLastOption,setShouldFocusLastOption]=useState(!1),isAnyOptionDefined=values.dropdown.options.length>0,dropdownErrors=errors.dropdown,dropdownTouched=touched.dropdown,hasTouchedOptionErrors=dropdownErrors?.options?.some((opt,index)=>opt?.key&&dropdownTouched?.options?.[index]),handleAddOption=useCallback((shouldFocus=!1)=>{setFieldValue(`dropdown`,{...values.dropdown,options:[...values.dropdown.options,{id:uniqueId(),key:``,isNew:!0}]}),setShouldFocusLastOption(shouldFocus)},[values.dropdown,setFieldValue]),handleUserAddOption=useCallback(()=>{handleAddOption(!0)},[handleAddOption]);useEffect(()=>{isAnyOptionDefined||handleAddOption(!1)},[isAnyOptionDefined,handleAddOption]);let handleFocusConsumed=useCallback(()=>{setShouldFocusLastOption(!1)},[]);return jsxs(`div`,{className:dropdown_field_configuration_module_default.dropdownFieldConfiguration,children:[hasTouchedOptionErrors&&jsx(InlineNotice,{variant:`error`,variantIconAriaLabel:formatMessage(dropdown_messages_default.optionListValidationError),children:formatMessage(dropdown_messages_default.optionListValidationError)}),isAnyOptionDefined&&jsx(SortableOptionList,{shouldFocusLastOption,onFocusConsumed:handleFocusConsumed}),!values.isFieldReadOnly&&jsx(TextButton,{className:dropdown_field_configuration_module_default.addOptionButton,onClick:handleUserAddOption,children:formatMessage(dropdown_messages_default.addOption)}),jsx(Switch.Item,{name:`dropdown.allowMultipleSelections`,checked:values.dropdown.allowMultipleSelections,disabled:!values.isFieldNew||values.isFieldReadOnly,label:formatMessage(dropdown_messages_default.allowMultipleSelection),onCheckedChange:allowMultipleSelections=>setFieldValue(`dropdown`,{...values.dropdown,allowMultipleSelections}),value:`true`})]})};export{DropdownFieldConfiguration as t};
@@ -1,91 +1 @@
1
- import { general as e } from "../esm/lib/components/metadata-field-configurator/messages/configurator-messages.js";
2
- import { Divider as t, DropdownMenu as n, IconButton as r, Text as i } from "@box/blueprint-web";
3
- import { FormattedMessage as a, useIntl as o } from "react-intl";
4
- import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
5
- import { Ellipsis as u } from "@box/blueprint-web-assets/icons/Fill";
6
- import d from "react";
7
- import { IconIconErrorOnLight as f } from "@box/blueprint-web-assets/tokens/tokens";
8
- import { ArrowDown as p, ArrowUp as m, Hidden as h, Trash as g, TwoFiles as _, Visible as v } from "@box/blueprint-web-assets/icons/Line";
9
- import y from "clsx";
10
- import '../styles/field-context-menu.css';var b = {
11
- contextMenuTrigger: "_contextMenuTrigger_102vn_1",
12
- menuItem: "_menuItem_102vn_5",
13
- contextMenu: "_contextMenu_102vn_1",
14
- divider: "_divider_102vn_14"
15
- }, x = ({ className: x, index: S, maxIndex: C, isHidden: w = !1, onReorderFields: T, onToggleVisibility: E, onRequestDelete: D, onRequestDuplicate: O, onOpenChange: k }) => {
16
- let A = o(), [j, M] = d.useState(!1), N = d.useRef(null), P = (e) => {
17
- M(e), k?.(e);
18
- }, F = () => {
19
- S > 0 && T?.(S, S - 1);
20
- }, I = () => {
21
- T?.(S, S + 1);
22
- }, L = !!(T || O || E);
23
- return /* @__PURE__ */ l(n.Root, {
24
- open: j,
25
- onOpenChange: P,
26
- modal: !1,
27
- children: [/* @__PURE__ */ c(n.Trigger, {
28
- className: y(b.contextMenuTrigger, x),
29
- children: /* @__PURE__ */ c(r, {
30
- icon: u,
31
- "aria-label": A.formatMessage(e.contextMenuAriaLabel),
32
- size: "large"
33
- })
34
- }), /* @__PURE__ */ l(n.Content, {
35
- ref: N,
36
- align: "end",
37
- className: b.contextMenu,
38
- children: [
39
- T && /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(n.Item, {
40
- disabled: S === 0,
41
- onClick: F,
42
- "aria-label": A.formatMessage(e.moveUpAriaLabel),
43
- children: /* @__PURE__ */ l("div", {
44
- className: b.menuItem,
45
- children: [/* @__PURE__ */ c(m, { "aria-hidden": "true" }), /* @__PURE__ */ c(a, { ...e.moveUp })]
46
- })
47
- }), /* @__PURE__ */ c(n.Item, {
48
- disabled: S === C,
49
- onClick: I,
50
- "aria-label": A.formatMessage(e.moveDownAriaLabel),
51
- children: /* @__PURE__ */ l("div", {
52
- className: b.menuItem,
53
- children: [/* @__PURE__ */ c(p, { "aria-hidden": "true" }), /* @__PURE__ */ c(a, { ...e.moveDown })]
54
- })
55
- })] }),
56
- O && /* @__PURE__ */ c(n.Item, {
57
- onClick: O,
58
- "aria-label": A.formatMessage(e.duplicateFieldAriaLabel),
59
- children: /* @__PURE__ */ l("div", {
60
- className: b.menuItem,
61
- children: [/* @__PURE__ */ c(_, { "aria-hidden": "true" }), /* @__PURE__ */ c(a, { ...e.duplicateField })]
62
- })
63
- }),
64
- E && /* @__PURE__ */ c(n.Item, {
65
- onClick: () => E(!w),
66
- "aria-label": A.formatMessage(w ? e.showField : e.hideField),
67
- children: /* @__PURE__ */ l("div", {
68
- className: b.menuItem,
69
- children: [c(w ? v : h, { "aria-hidden": "true" }), /* @__PURE__ */ c(a, { ...w ? e.showField : e.hideField })]
70
- })
71
- }),
72
- D && /* @__PURE__ */ l(s, { children: [L && /* @__PURE__ */ c(t, { className: b.divider }), /* @__PURE__ */ c(n.Item, {
73
- onClick: D,
74
- "aria-label": A.formatMessage(e.deleteFieldAriaLabel),
75
- children: /* @__PURE__ */ l("div", {
76
- className: b.menuItem,
77
- children: [/* @__PURE__ */ c(g, {
78
- color: f,
79
- "aria-hidden": "true"
80
- }), /* @__PURE__ */ c(i, {
81
- as: "span",
82
- color: "textOnLightError",
83
- children: /* @__PURE__ */ c(a, { ...e.deleteField })
84
- })]
85
- })
86
- })] })
87
- ]
88
- })]
89
- });
90
- };
91
- export { x as t };
1
+ import{general}from"../esm/lib/components/metadata-field-configurator/messages/configurator-messages.js";import{Divider,DropdownMenu,IconButton,Text}from"@box/blueprint-web";import{FormattedMessage,useIntl}from"react-intl";import{Fragment,jsx,jsxs}from"react/jsx-runtime";import{Ellipsis}from"@box/blueprint-web-assets/icons/Fill";import React from"react";import{IconIconErrorOnLight}from"@box/blueprint-web-assets/tokens/tokens";import{ArrowDown,ArrowUp,Hidden,Trash,TwoFiles,Visible}from"@box/blueprint-web-assets/icons/Line";import clsx from"clsx";import '../styles/field-context-menu.css';var field_context_menu_module_default={contextMenuTrigger:`_contextMenuTrigger_102vn_1`,menuItem:`_menuItem_102vn_5`,contextMenu:`_contextMenu_102vn_1`,divider:`_divider_102vn_14`},FieldContextMenu=({className,index,maxIndex,isHidden=!1,onReorderFields,onToggleVisibility,onRequestDelete,onRequestDuplicate,onOpenChange})=>{let intl=useIntl(),[contextMenuOpen,setContextMenuOpen]=React.useState(!1),contextMenuRef=React.useRef(null),handleOpenChange=open=>{setContextMenuOpen(open),onOpenChange?.(open)},handleMoveUp=()=>{index>0&&onReorderFields?.(index,index-1)},handleMoveDown=()=>{onReorderFields?.(index,index+1)},hasItemsAboveDelete=!!(onReorderFields||onRequestDuplicate||onToggleVisibility);return jsxs(DropdownMenu.Root,{open:contextMenuOpen,onOpenChange:handleOpenChange,modal:!1,children:[jsx(DropdownMenu.Trigger,{className:clsx(field_context_menu_module_default.contextMenuTrigger,className),children:jsx(IconButton,{icon:Ellipsis,"aria-label":intl.formatMessage(general.contextMenuAriaLabel),size:`large`})}),jsxs(DropdownMenu.Content,{ref:contextMenuRef,align:`end`,className:field_context_menu_module_default.contextMenu,children:[onReorderFields&&jsxs(Fragment,{children:[jsx(DropdownMenu.Item,{disabled:index===0,onClick:handleMoveUp,"aria-label":intl.formatMessage(general.moveUpAriaLabel),children:jsxs(`div`,{className:field_context_menu_module_default.menuItem,children:[jsx(ArrowUp,{"aria-hidden":`true`}),jsx(FormattedMessage,{...general.moveUp})]})}),jsx(DropdownMenu.Item,{disabled:index===maxIndex,onClick:handleMoveDown,"aria-label":intl.formatMessage(general.moveDownAriaLabel),children:jsxs(`div`,{className:field_context_menu_module_default.menuItem,children:[jsx(ArrowDown,{"aria-hidden":`true`}),jsx(FormattedMessage,{...general.moveDown})]})})]}),onRequestDuplicate&&jsx(DropdownMenu.Item,{onClick:onRequestDuplicate,"aria-label":intl.formatMessage(general.duplicateFieldAriaLabel),children:jsxs(`div`,{className:field_context_menu_module_default.menuItem,children:[jsx(TwoFiles,{"aria-hidden":`true`}),jsx(FormattedMessage,{...general.duplicateField})]})}),onToggleVisibility&&jsx(DropdownMenu.Item,{onClick:()=>onToggleVisibility(!isHidden),"aria-label":intl.formatMessage(isHidden?general.showField:general.hideField),children:jsxs(`div`,{className:field_context_menu_module_default.menuItem,children:[jsx(isHidden?Visible:Hidden,{"aria-hidden":`true`}),jsx(FormattedMessage,{...isHidden?general.showField:general.hideField})]})}),onRequestDelete&&jsxs(Fragment,{children:[hasItemsAboveDelete&&jsx(Divider,{className:field_context_menu_module_default.divider}),jsx(DropdownMenu.Item,{onClick:onRequestDelete,"aria-label":intl.formatMessage(general.deleteFieldAriaLabel),children:jsxs(`div`,{className:field_context_menu_module_default.menuItem,children:[jsx(Trash,{color:IconIconErrorOnLight,"aria-hidden":`true`}),jsx(Text,{as:`span`,color:`textOnLightError`,children:jsx(FormattedMessage,{...general.deleteField})})]})})]})]})]})};export{FieldContextMenu as t};
@@ -1,23 +1 @@
1
- import e from "../esm/lib/components/field-selector/messages.js";
2
- import { DropdownMenu as t, TextButton as n } from "@box/blueprint-web";
3
- import { useIntl as r } from "react-intl";
4
- import { ChevronDown as i } from "@box/blueprint-web-assets/icons/Medium";
5
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
6
- import '../styles/field-selector.css';var s = { fieldSelectorTrigger: "_fieldSelectorTrigger_cj5ij_1" };
7
- function c({ fields: c, onSelect: l }) {
8
- let { formatMessage: u } = r();
9
- return /* @__PURE__ */ o(t.Root, {
10
- modal: !1,
11
- children: [/* @__PURE__ */ a(t.Trigger, { children: /* @__PURE__ */ a(n, {
12
- icon: i,
13
- className: s.fieldSelectorTrigger,
14
- variant: "bodyDefaultSemibold",
15
- color: "textOnLightSecondary",
16
- children: u(e.selectField)
17
- }) }), /* @__PURE__ */ a(t.Content, { children: c.map((n) => /* @__PURE__ */ a(t.Item, {
18
- onClick: () => l(n.id),
19
- children: /* @__PURE__ */ a(t.Item.MainContent, { label: n.name || u(e.unnamedField) })
20
- }, n.id)) })]
21
- });
22
- }
23
- export { c as t };
1
+ import messages_default from"../esm/lib/components/field-selector/messages.js";import{DropdownMenu,TextButton}from"@box/blueprint-web";import{useIntl}from"react-intl";import{ChevronDown}from"@box/blueprint-web-assets/icons/Medium";import{jsx,jsxs}from"react/jsx-runtime";import '../styles/field-selector.css';var field_selector_module_default={fieldSelectorTrigger:`_fieldSelectorTrigger_cj5ij_1`};function FieldSelector({fields,onSelect}){let{formatMessage}=useIntl();return jsxs(DropdownMenu.Root,{modal:!1,children:[jsx(DropdownMenu.Trigger,{children:jsx(TextButton,{icon:ChevronDown,className:field_selector_module_default.fieldSelectorTrigger,variant:`bodyDefaultSemibold`,color:`textOnLightSecondary`,children:formatMessage(messages_default.selectField)})}),jsx(DropdownMenu.Content,{children:fields.map(field=>jsx(DropdownMenu.Item,{onClick:()=>onSelect(field.id),children:jsx(DropdownMenu.Item.MainContent,{label:field.name||formatMessage(messages_default.unnamedField)})},field.id))})]})}export{FieldSelector as t};
@@ -1,31 +1 @@
1
- import { useFieldOptions as e } from "../esm/lib/utils/field-options/useFieldOptions.js";
2
- import { fieldTypeDropdownMessages as t } from "../esm/lib/components/field-type-dropdown/messages.js";
3
- import { Button as n, DropdownMenu as r } from "@box/blueprint-web";
4
- import { useIntl as i } from "react-intl";
5
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
6
- import { Plus as s } from "@box/blueprint-web-assets/icons/Fill";
7
- import '../styles/field-type-dropdown.css';var c = { addField: "_addField_1bl6g_1" };
8
- function l({ onFieldAdd: l, trigger: u }) {
9
- let { formatMessage: d } = i(), f = e();
10
- return /* @__PURE__ */ o(r.Root, {
11
- modal: !1,
12
- children: [/* @__PURE__ */ a(r.Trigger, { children: u ?? /* @__PURE__ */ a(n, {
13
- className: c.addField,
14
- variant: "secondary",
15
- size: "large",
16
- startIcon: s,
17
- "aria-label": d(t.addFieldAriaLabel),
18
- children: d(t.addField)
19
- }) }), /* @__PURE__ */ a(r.Content, { children: f.availableFieldTypes.map((e) => /* @__PURE__ */ o(r.Item, {
20
- onClick: () => l(e),
21
- children: [/* @__PURE__ */ a(r.Item.StartElement, { children: /* @__PURE__ */ a(e.Icon, {
22
- fontSize: "15px",
23
- "aria-hidden": "true"
24
- }) }), /* @__PURE__ */ a(r.Item.MainContent, {
25
- caption: e.description,
26
- label: String(e.label)
27
- })]
28
- }, e.type)) })]
29
- });
30
- }
31
- export { l as t };
1
+ import{useFieldOptions}from"../esm/lib/utils/field-options/useFieldOptions.js";import{fieldTypeDropdownMessages}from"../esm/lib/components/field-type-dropdown/messages.js";import{Button,DropdownMenu}from"@box/blueprint-web";import{useIntl}from"react-intl";import{jsx,jsxs}from"react/jsx-runtime";import{Plus}from"@box/blueprint-web-assets/icons/Fill";import '../styles/field-type-dropdown.css';var field_type_dropdown_module_default={addField:`_addField_1bl6g_1`};function FieldTypeDropdown({onFieldAdd,trigger}){let{formatMessage}=useIntl(),fieldTypes=useFieldOptions();return jsxs(DropdownMenu.Root,{modal:!1,children:[jsx(DropdownMenu.Trigger,{children:trigger??jsx(Button,{className:field_type_dropdown_module_default.addField,variant:`secondary`,size:`large`,startIcon:Plus,"aria-label":formatMessage(fieldTypeDropdownMessages.addFieldAriaLabel),children:formatMessage(fieldTypeDropdownMessages.addField)})}),jsx(DropdownMenu.Content,{children:fieldTypes.availableFieldTypes.map(fieldType=>jsxs(DropdownMenu.Item,{onClick:()=>onFieldAdd(fieldType),children:[jsx(DropdownMenu.Item.StartElement,{children:jsx(fieldType.Icon,{fontSize:`15px`,"aria-hidden":`true`})}),jsx(DropdownMenu.Item.MainContent,{caption:fieldType.description,label:String(fieldType.label)})]},fieldType.type))})]})}export{FieldTypeDropdown as t};
@@ -1,120 +1 @@
1
- import e from "../esm/lib/components/metadata-field-configurator/messages/levels-chain-messages.js";
2
- import { t } from "./chip.js";
3
- import { getHideCounts as n } from "../esm/lib/components/metadata-field-configurator/components/levels-chain/utils.js";
4
- import { Text as r, Tooltip as i } from "@box/blueprint-web";
5
- import { FormattedMessage as a } from "react-intl";
6
- import { jsx as o, jsxs as s } from "react/jsx-runtime";
7
- import { useEffect as c, useLayoutEffect as l, useMemo as u, useRef as d, useState as f } from "react";
8
- import { IconIconOnLightSecondary as p } from "@box/blueprint-web-assets/tokens/tokens";
9
- import { ArrowRight as m } from "@box/blueprint-web-assets/icons/Line";
10
- import '../styles/levels-chain.css';var h = { levelsChain: "_levelsChain_bbgph_1" };
11
- function g(e) {
12
- let t = Math.ceil(e.length / 2);
13
- return [e.slice(0, t), e.slice(t)];
14
- }
15
- var _ = ({ levels: _ = [], selectedLevels: v = [] }) => {
16
- let [y, b] = g(_), [x, S] = f(!1), [C, w] = f([]), [T, E] = f([]), [D, O] = f(0), [k, A] = f(0), j = d(null), M = d(null), N = u(() => {
17
- let e = j.current ? window.getComputedStyle(j.current) : { gap: "11px" };
18
- return parseInt(e.gap, 10);
19
- }, [j.current]), P = /* @__PURE__ */ o(m, {
20
- color: p,
21
- "aria-hidden": "true"
22
- });
23
- c(() => {
24
- S(!1);
25
- }, [_]), l(() => {
26
- if (j.current && !x && _.length > 0) {
27
- let e = j.current;
28
- A(e.clientWidth);
29
- let t = e.querySelectorAll("li"), n = Array.from(t).slice(0, y.length), r = Array.from(t).slice(y.length + 1);
30
- w(n.map((e) => e.getBoundingClientRect().width)), E(r.map((e) => e.getBoundingClientRect().width)), M.current && O(M.current.getBoundingClientRect().width), S(!0);
31
- }
32
- }, [
33
- y,
34
- b,
35
- x,
36
- _.length
37
- ]), c(() => {
38
- let e = () => {
39
- j.current && A(j.current.clientWidth);
40
- };
41
- return window.addEventListener("resize", e), () => {
42
- window.removeEventListener("resize", e);
43
- };
44
- }, []);
45
- let [F, I] = u(() => n({
46
- isMeasured: x,
47
- leftLevelWidths: C,
48
- rightLevelWidths: T,
49
- containerWidthPx: k,
50
- buttonWidthPx: D,
51
- gapBetweenItems: N
52
- }), [
53
- x,
54
- C,
55
- T,
56
- k,
57
- D,
58
- N
59
- ]), L = u(() => {
60
- let e = y.slice(y.length - F), t = b.slice(0, I);
61
- return [...e, ...t];
62
- }, [
63
- F,
64
- I,
65
- y,
66
- b
67
- ]), R = L.some((e) => v.includes(e.level));
68
- return _.length === 0 ? /* @__PURE__ */ o("div", {
69
- role: "alert",
70
- children: /* @__PURE__ */ o(a, { ...e.noLevels })
71
- }) : /* @__PURE__ */ s("ul", {
72
- ref: j,
73
- className: h.levelsChain,
74
- "data-testid": "taxonomy-levels-chain",
75
- children: [
76
- y.map((e, n) => {
77
- let r = x && n >= y.length - F;
78
- return /* @__PURE__ */ s("li", {
79
- "aria-hidden": r,
80
- style: { display: r ? "none" : void 0 },
81
- children: [/* @__PURE__ */ o(t, {
82
- value: e.name,
83
- selected: v.includes(e.level)
84
- }), y.length + b.length > 1 ? P : null]
85
- }, e.level);
86
- }),
87
- /* @__PURE__ */ s("li", {
88
- ref: M,
89
- style: x ? F > 0 || I > 0 ? {} : { display: "none" } : {
90
- position: "absolute",
91
- visibility: "hidden"
92
- },
93
- "aria-hidden": !(F > 0 || I > 0),
94
- tabIndex: x && (F > 0 || I > 0) ? 0 : -1,
95
- children: [/* @__PURE__ */ o(i, {
96
- content: L.map((e) => e.name).join(" > "),
97
- children: /* @__PURE__ */ o(r, {
98
- as: "span",
99
- children: /* @__PURE__ */ o(t, {
100
- value: `+${F + I}`,
101
- selected: R
102
- })
103
- })
104
- }), P]
105
- }),
106
- b.map((e, n) => {
107
- let r = x && n < I;
108
- return /* @__PURE__ */ s("li", {
109
- "aria-hidden": r,
110
- style: { display: r ? "none" : void 0 },
111
- children: [/* @__PURE__ */ o(t, {
112
- value: e.name,
113
- selected: v.includes(e.level)
114
- }), n < b.length - 1 && P]
115
- }, e.level);
116
- })
117
- ]
118
- });
119
- };
120
- export { _ as t };
1
+ import levels_chain_messages_default from"../esm/lib/components/metadata-field-configurator/messages/levels-chain-messages.js";import{t as Chip}from"./chip.js";import{getHideCounts}from"../esm/lib/components/metadata-field-configurator/components/levels-chain/utils.js";import{Text,Tooltip}from"@box/blueprint-web";import{FormattedMessage}from"react-intl";import{jsx,jsxs}from"react/jsx-runtime";import{useEffect,useLayoutEffect,useMemo,useRef,useState}from"react";import{IconIconOnLightSecondary}from"@box/blueprint-web-assets/tokens/tokens";import{ArrowRight}from"@box/blueprint-web-assets/icons/Line";import '../styles/levels-chain.css';var levels_chain_module_default={levelsChain:`_levelsChain_bbgph_1`};function divideIntoTwo(levels){let half=Math.ceil(levels.length/2);return[levels.slice(0,half),levels.slice(half)]}var LevelsChain=({levels=[],selectedLevels=[]})=>{let[levelsLeft,levelsRight]=divideIntoTwo(levels),[isMeasured,setIsMeasured]=useState(!1),[leftLevelWidths,setLeftLevelWidths]=useState([]),[rightLevelWidths,setRightLevelWidths]=useState([]),[toggleButtonWidth,setToggleButtonWidth]=useState(0),[containerWidthPx,setContainerWidthPx]=useState(0),ulRef=useRef(null),buttonRef=useRef(null),gap=useMemo(()=>{let computedStyle=ulRef.current?window.getComputedStyle(ulRef.current):{gap:`11px`};return parseInt(computedStyle.gap,10)},[ulRef.current]),arrowRight=jsx(ArrowRight,{color:IconIconOnLightSecondary,"aria-hidden":`true`});useEffect(()=>{setIsMeasured(!1)},[levels]),useLayoutEffect(()=>{if(ulRef.current&&!isMeasured&&levels.length>0){let ulElement=ulRef.current;setContainerWidthPx(ulElement.clientWidth);let allLi=ulElement.querySelectorAll(`li`),leftLis=Array.from(allLi).slice(0,levelsLeft.length),rightLis=Array.from(allLi).slice(levelsLeft.length+1);setLeftLevelWidths(leftLis.map(li=>li.getBoundingClientRect().width)),setRightLevelWidths(rightLis.map(li=>li.getBoundingClientRect().width)),buttonRef.current&&setToggleButtonWidth(buttonRef.current.getBoundingClientRect().width),setIsMeasured(!0)}},[levelsLeft,levelsRight,isMeasured,levels.length]),useEffect(()=>{let handleResize=()=>{ulRef.current&&setContainerWidthPx(ulRef.current.clientWidth)};return window.addEventListener(`resize`,handleResize),()=>{window.removeEventListener(`resize`,handleResize)}},[]);let[hideLeftCount,hideRightCount]=useMemo(()=>getHideCounts({isMeasured,leftLevelWidths,rightLevelWidths,containerWidthPx,buttonWidthPx:toggleButtonWidth,gapBetweenItems:gap}),[isMeasured,leftLevelWidths,rightLevelWidths,containerWidthPx,toggleButtonWidth,gap]),hiddenLevelsList=useMemo(()=>{let hiddenLeft=levelsLeft.slice(levelsLeft.length-hideLeftCount),hiddenRight=levelsRight.slice(0,hideRightCount);return[...hiddenLeft,...hiddenRight]},[hideLeftCount,hideRightCount,levelsLeft,levelsRight]),isAnyHiddenLevelSelected=hiddenLevelsList.some(level=>selectedLevels.includes(level.level));return levels.length===0?jsx(`div`,{role:`alert`,children:jsx(FormattedMessage,{...levels_chain_messages_default.noLevels})}):jsxs(`ul`,{ref:ulRef,className:levels_chain_module_default.levelsChain,"data-testid":`taxonomy-levels-chain`,children:[levelsLeft.map((level,index)=>{let isHidden=isMeasured&&index>=levelsLeft.length-hideLeftCount;return jsxs(`li`,{"aria-hidden":isHidden,style:{display:isHidden?`none`:void 0},children:[jsx(Chip,{value:level.name,selected:selectedLevels.includes(level.level)}),levelsLeft.length+levelsRight.length>1?arrowRight:null]},level.level)}),jsxs(`li`,{ref:buttonRef,style:isMeasured?hideLeftCount>0||hideRightCount>0?{}:{display:`none`}:{position:`absolute`,visibility:`hidden`},"aria-hidden":!(hideLeftCount>0||hideRightCount>0),tabIndex:isMeasured&&(hideLeftCount>0||hideRightCount>0)?0:-1,children:[jsx(Tooltip,{content:hiddenLevelsList.map(level=>level.name).join(` > `),children:jsx(Text,{as:`span`,children:jsx(Chip,{value:`+${hideLeftCount+hideRightCount}`,selected:isAnyHiddenLevelSelected})})}),arrowRight]}),levelsRight.map((level,index)=>{let isHidden=isMeasured&&index<hideRightCount;return jsxs(`li`,{"aria-hidden":isHidden,style:{display:isHidden?`none`:void 0},children:[jsx(Chip,{value:level.name,selected:selectedLevels.includes(level.level)}),index<levelsRight.length-1&&arrowRight]},level.level)})]})};export{LevelsChain as t};
@@ -1,21 +1 @@
1
- import '../styles/metadata-field-configurator.css';var e = {
2
- fieldset: "_fieldset_vz23z_1",
3
- expandedContent: "_expandedContent_vz23z_7",
4
- basic: "_basic_vz23z_13",
5
- fieldTypeSelect: "_fieldTypeSelect_vz23z_18",
6
- typeSpecific: "_typeSpecific_vz23z_22",
7
- description: "_description_vz23z_29",
8
- labelWithTooltip: "_labelWithTooltip_vz23z_34",
9
- fieldActionSlot: "_fieldActionSlot_vz23z_39",
10
- expandedToolbarActions: "_expandedToolbarActions_vz23z_46",
11
- extensionTabsContainer: "_extensionTabsContainer_vz23z_52",
12
- extensionContent: "_extensionContent_vz23z_58",
13
- fieldCollapsedText: "_fieldCollapsedText_vz23z_62",
14
- expanded: "_expanded_vz23z_7",
15
- contextMenuWithCollapsedText: "_contextMenuWithCollapsedText_vz23z_71",
16
- fieldAccordionItem: "_fieldAccordionItem_vz23z_77",
17
- fieldContextMenu: "_fieldContextMenu_vz23z_84",
18
- menuOpen: "_menuOpen_vz23z_87",
19
- hiddenBadge: "_hiddenBadge_vz23z_106"
20
- };
21
- export { e as t };
1
+ import '../styles/metadata-field-configurator.css';var metadata_field_configurator_module_default={fieldset:`_fieldset_vz23z_1`,expandedContent:`_expandedContent_vz23z_7`,basic:`_basic_vz23z_13`,fieldTypeSelect:`_fieldTypeSelect_vz23z_18`,typeSpecific:`_typeSpecific_vz23z_22`,description:`_description_vz23z_29`,labelWithTooltip:`_labelWithTooltip_vz23z_34`,fieldActionSlot:`_fieldActionSlot_vz23z_39`,expandedToolbarActions:`_expandedToolbarActions_vz23z_46`,extensionTabsContainer:`_extensionTabsContainer_vz23z_52`,extensionContent:`_extensionContent_vz23z_58`,fieldCollapsedText:`_fieldCollapsedText_vz23z_62`,expanded:`_expanded_vz23z_7`,contextMenuWithCollapsedText:`_contextMenuWithCollapsedText_vz23z_71`,fieldAccordionItem:`_fieldAccordionItem_vz23z_77`,fieldContextMenu:`_fieldContextMenu_vz23z_84`,menuOpen:`_menuOpen_vz23z_87`,hiddenBadge:`_hiddenBadge_vz23z_106`};export{metadata_field_configurator_module_default as t};