@box/metadata-template-editor 1.20.9 → 1.20.11

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,80 +1,63 @@
1
- import { useIntl as T } from "react-intl";
2
- import { Status as F, Tabs as l } from "@box/blueprint-web";
3
- import { Hidden as M, Pencil as C } from "@box/blueprint-web-assets/icons/Line";
4
- import { DragDots as L } from "@box/blueprint-web-assets/icons/Fill";
5
- import { SurfaceStatusSurfaceGray as w } from "@box/blueprint-web-assets/tokens/tokens";
6
- import { FieldContextMenu as x } from "../field-context-menu/field-context-menu.js";
7
- import { general as o } from "../../messages/configurator-messages.js";
8
- import { s as n } from "../../../../../../chunks/metadata-field-configurator.module.js";
9
- import { jsxs as s, Fragment as j, jsx as t } from "react/jsx-runtime";
10
- const B = ({
11
- isExpanded: h,
12
- isHidden: m,
13
- index: i,
14
- maxIndex: u,
15
- dndDragHandleProps: e,
16
- onDragStart: c,
17
- onDragEnd: b,
18
- onTouchStart: f,
19
- onReorderFields: p,
20
- onToggleVisibility: S,
21
- onRequestDelete: v,
22
- onRequestDuplicate: g,
23
- extensions: d
24
- }) => {
25
- const r = T();
26
- return /* @__PURE__ */ s(j, {
27
- children: [m && /* @__PURE__ */ t(F, {
28
- icon: M,
29
- iconPosition: "left",
30
- color: w,
31
- text: r.formatMessage(o.hiddenStatus).toUpperCase()
32
- }), h === !1 && /* @__PURE__ */ t("div", {
33
- draggable: !e,
34
- className: n.dragHandle,
35
- onDragStart: !e && c ? (a) => c(a, i) : void 0,
36
- onDragEnd: !e && b ? (a) => b(a, i) : void 0,
37
- onTouchStart: !e && f ? (a) => f(a, i) : void 0,
38
- ...e?.listeners ?? {},
39
- ...e?.attributes ?? {},
40
- "aria-label": r.formatMessage(o.dragAndDropFieldAriaLabel),
41
- tabIndex: e ? void 0 : -1,
42
- children: /* @__PURE__ */ t(L, {
43
- fontSize: 20,
44
- "aria-label": r.formatMessage(o.dragAndDropFieldAriaLabel)
45
- })
46
- }), /* @__PURE__ */ s("div", {
47
- className: n.expandedToolbarActions,
48
- children: [d.length > 0 && /* @__PURE__ */ s(l.TabList, {
49
- variant: "contentSwitcher",
50
- containerClassname: n.extensionTabsContainer,
51
- children: [/* @__PURE__ */ t(l.Tab, {
52
- id: "edit",
53
- variant: "contentSwitcher",
54
- "aria-label": r.formatMessage(o.editTabAriaLabel),
55
- children: /* @__PURE__ */ t(C, {
56
- "aria-hidden": "true"
57
- })
58
- }), d.map((a, A) => /* @__PURE__ */ t(l.Tab, {
59
- id: `ext-${A}`,
60
- variant: "contentSwitcher",
61
- "aria-label": a.label,
62
- children: /* @__PURE__ */ t(a.icon, {
63
- "aria-hidden": "true"
64
- })
65
- }, a.label))]
66
- }), /* @__PURE__ */ t(x, {
67
- index: i,
68
- maxIndex: u,
69
- isHidden: m,
70
- onReorderFields: p,
71
- onToggleVisibility: S,
72
- onRequestDelete: v,
73
- onRequestDuplicate: g
74
- })]
75
- })]
76
- });
77
- };
78
- export {
79
- B as FieldActionSlot
1
+ import { general as e } from "../../messages/configurator-messages.js";
2
+ import { t } from "../../../../../../chunks/metadata-field-configurator.module.js";
3
+ import { t as n } from "../../../../../../chunks/field-context-menu.js";
4
+ import { Status as r, Tabs as i } from "@box/blueprint-web";
5
+ import { useIntl as a } from "react-intl";
6
+ import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
7
+ import { DragDots as l } from "@box/blueprint-web-assets/icons/Fill";
8
+ import "react";
9
+ import { SurfaceStatusSurfaceGray as u } from "@box/blueprint-web-assets/tokens/tokens";
10
+ import { Hidden as d, Pencil as f } from "@box/blueprint-web-assets/icons/Line";
11
+ var p = ({ isExpanded: p, isHidden: m, index: h, maxIndex: g, dndDragHandleProps: _, onDragStart: v, onDragEnd: y, onTouchStart: b, onReorderFields: x, onToggleVisibility: S, onRequestDelete: C, onRequestDuplicate: w, extensions: T }) => {
12
+ let E = a();
13
+ return /* @__PURE__ */ c(o, { children: [
14
+ m && /* @__PURE__ */ s(r, {
15
+ icon: d,
16
+ iconPosition: "left",
17
+ color: u,
18
+ text: E.formatMessage(e.hiddenStatus).toUpperCase()
19
+ }),
20
+ p === !1 && /* @__PURE__ */ s("div", {
21
+ draggable: !_,
22
+ className: t.dragHandle,
23
+ onDragStart: !_ && v ? (e) => v(e, h) : void 0,
24
+ onDragEnd: !_ && y ? (e) => y(e, h) : void 0,
25
+ onTouchStart: !_ && b ? (e) => b(e, h) : void 0,
26
+ ..._?.listeners ?? {},
27
+ ..._?.attributes ?? {},
28
+ "aria-label": E.formatMessage(e.dragAndDropFieldAriaLabel),
29
+ tabIndex: _ ? void 0 : -1,
30
+ children: /* @__PURE__ */ s(l, {
31
+ fontSize: 20,
32
+ "aria-label": E.formatMessage(e.dragAndDropFieldAriaLabel)
33
+ })
34
+ }),
35
+ /* @__PURE__ */ c("div", {
36
+ className: t.expandedToolbarActions,
37
+ children: [T.length > 0 && /* @__PURE__ */ c(i.TabList, {
38
+ variant: "contentSwitcher",
39
+ containerClassname: t.extensionTabsContainer,
40
+ children: [/* @__PURE__ */ s(i.Tab, {
41
+ id: "edit",
42
+ variant: "contentSwitcher",
43
+ "aria-label": E.formatMessage(e.editTabAriaLabel),
44
+ children: /* @__PURE__ */ s(f, { "aria-hidden": "true" })
45
+ }), T.map((e, t) => /* @__PURE__ */ s(i.Tab, {
46
+ id: `ext-${t}`,
47
+ variant: "contentSwitcher",
48
+ "aria-label": e.label,
49
+ children: /* @__PURE__ */ s(e.icon, { "aria-hidden": "true" })
50
+ }, e.label))]
51
+ }), /* @__PURE__ */ s(n, {
52
+ index: h,
53
+ maxIndex: g,
54
+ isHidden: m,
55
+ onReorderFields: x,
56
+ onToggleVisibility: S,
57
+ onRequestDelete: C,
58
+ onRequestDuplicate: w
59
+ })]
60
+ })
61
+ ] });
80
62
  };
63
+ export { p as FieldActionSlot };
@@ -1,115 +1,2 @@
1
- import { DropdownMenu as t, IconButton as b, Divider as x, Text as _ } from "@box/blueprint-web";
2
- import { Ellipsis as w } from "@box/blueprint-web-assets/icons/Fill";
3
- import { ArrowUp as F, ArrowDown as C, TwoFiles as N, Visible as T, Hidden as A, Trash as L } from "@box/blueprint-web-assets/icons/Line";
4
- import { IconIconErrorOnLight as D } from "@box/blueprint-web-assets/tokens/tokens";
5
- import m from "react";
6
- import { useIntl as k, FormattedMessage as l } from "react-intl";
7
- import { general as n } from "../../messages/configurator-messages.js";
8
- import { jsxs as i, jsx as e } from "react/jsx-runtime";
9
- import '../../../../../../styles/field-context-menu.css';const O = "_contextMenuTrigger_102vn_1", U = "_menuItem_102vn_5", E = "_contextMenu_102vn_1", R = "_divider_102vn_14", r = {
10
- contextMenuTrigger: O,
11
- menuItem: U,
12
- contextMenu: E,
13
- divider: R
14
- }, J = ({
15
- index: a,
16
- maxIndex: d,
17
- isHidden: s,
18
- onReorderFields: c,
19
- onToggleVisibility: u,
20
- onRequestDelete: h,
21
- onRequestDuplicate: g
22
- }) => {
23
- const o = k(), [M, p] = m.useState(!1), f = m.useRef(null), v = () => {
24
- a > 0 && c(a, a - 1);
25
- }, I = () => {
26
- c(a, a + 1);
27
- };
28
- return /* @__PURE__ */ i(t.Root, {
29
- open: M,
30
- onOpenChange: p,
31
- modal: !1,
32
- children: [/* @__PURE__ */ e(t.Trigger, {
33
- className: r.contextMenuTrigger,
34
- children: /* @__PURE__ */ e(b, {
35
- icon: w,
36
- "aria-label": o.formatMessage(n.contextMenuAriaLabel),
37
- size: "large"
38
- })
39
- }), /* @__PURE__ */ i(t.Content, {
40
- ref: f,
41
- align: "end",
42
- className: r.contextMenu,
43
- children: [/* @__PURE__ */ e(t.Item, {
44
- disabled: a === 0,
45
- onClick: v,
46
- "aria-label": o.formatMessage(n.moveUpAriaLabel),
47
- children: /* @__PURE__ */ i("div", {
48
- className: r.menuItem,
49
- children: [/* @__PURE__ */ e(F, {
50
- "aria-hidden": "true"
51
- }), /* @__PURE__ */ e(l, {
52
- ...n.moveUp
53
- })]
54
- })
55
- }), /* @__PURE__ */ e(t.Item, {
56
- disabled: a === d,
57
- onClick: I,
58
- "aria-label": o.formatMessage(n.moveDownAriaLabel),
59
- children: /* @__PURE__ */ i("div", {
60
- className: r.menuItem,
61
- children: [/* @__PURE__ */ e(C, {
62
- "aria-hidden": "true"
63
- }), /* @__PURE__ */ e(l, {
64
- ...n.moveDown
65
- })]
66
- })
67
- }), /* @__PURE__ */ e(t.Item, {
68
- onClick: g,
69
- "aria-label": o.formatMessage(n.duplicateFieldAriaLabel),
70
- children: /* @__PURE__ */ i("div", {
71
- className: r.menuItem,
72
- children: [/* @__PURE__ */ e(N, {
73
- "aria-hidden": "true"
74
- }), /* @__PURE__ */ e(l, {
75
- ...n.duplicateField
76
- })]
77
- })
78
- }), /* @__PURE__ */ e(t.Item, {
79
- onClick: () => u(!s),
80
- "aria-label": o.formatMessage(s ? n.showField : n.hideField),
81
- children: /* @__PURE__ */ i("div", {
82
- className: r.menuItem,
83
- children: [s ? /* @__PURE__ */ e(T, {
84
- "aria-hidden": "true"
85
- }) : /* @__PURE__ */ e(A, {
86
- "aria-hidden": "true"
87
- }), /* @__PURE__ */ e(l, {
88
- ...s ? n.showField : n.hideField
89
- })]
90
- })
91
- }), /* @__PURE__ */ e(x, {
92
- className: r.divider
93
- }), /* @__PURE__ */ e(t.Item, {
94
- onClick: h,
95
- "aria-label": o.formatMessage(n.deleteFieldAriaLabel),
96
- children: /* @__PURE__ */ i("div", {
97
- className: r.menuItem,
98
- children: [/* @__PURE__ */ e(L, {
99
- color: D,
100
- "aria-hidden": "true"
101
- }), /* @__PURE__ */ e(_, {
102
- as: "span",
103
- color: "textOnLightError",
104
- children: /* @__PURE__ */ e(l, {
105
- ...n.deleteField
106
- })
107
- })]
108
- })
109
- })]
110
- })]
111
- });
112
- };
113
- export {
114
- J as FieldContextMenu
115
- };
1
+ import { t as e } from "../../../../../../chunks/field-context-menu.js";
2
+ export { e as FieldContextMenu };
@@ -1,101 +1,84 @@
1
- import { useMemo as x } from "react";
2
- import { useIntl as L } from "react-intl";
3
- import { TooltipProvider as B, TextWithInfoBadge as N, TextInput as u, Select as s } from "@box/blueprint-web";
4
- import { useFieldConfigurator as O } from "../../context/field-configurator-context.js";
5
- import { useFieldOptions as P } from "../../../../utils/field-options/useFieldOptions.js";
6
- import { F as h } from "../../../../../../chunks/types.js";
7
- import { getConfigurationByType as R } from "../../utils.js";
8
- import { general as i } from "../../messages/configurator-messages.js";
9
- import { s as o } from "../../../../../../chunks/metadata-field-configurator.module.js";
10
- import { jsx as e, jsxs as g } from "react/jsx-runtime";
11
- const z = ({
12
- nameInputId: b,
13
- descriptionInputId: t,
14
- isTypeEditable: d,
15
- externalErrors: c,
16
- externalTouched: y,
17
- handleTypeChange: v
18
- }) => {
19
- const r = L(), F = P(), {
20
- values: a,
21
- errors: M,
22
- touched: C,
23
- handleChange: m,
24
- handleBlur: p
25
- } = O(), f = (l) => {
26
- if (c && y?.[l])
27
- return c[l];
28
- const n = M[l];
29
- if (C[l] && n != null && typeof n == "string")
30
- return n;
31
- }, T = x(() => /* @__PURE__ */ e(B, {
32
- children: /* @__PURE__ */ e(N, {
33
- infoBadgeAriaLabel: r.formatMessage(i.descriptionLearnMoreBadgeAriaLabel),
34
- infoText: r.formatMessage(i.descriptionInfoTooltip),
35
- children: /* @__PURE__ */ e("label", {
36
- className: o.labelWithTooltip,
37
- htmlFor: t,
38
- children: r.formatMessage(i.fieldDescriptionLabel)
39
- })
40
- })
41
- }), [r, t]);
42
- return /* @__PURE__ */ e("fieldset", {
43
- disabled: a.isFieldReadOnly,
44
- className: o.fieldset,
45
- children: /* @__PURE__ */ g("div", {
46
- className: o.expandedContent,
47
- children: [/* @__PURE__ */ g("div", {
48
- className: o.basic,
49
- children: [/* @__PURE__ */ e(u, {
50
- name: "name",
51
- id: b,
52
- label: r.formatMessage(i.fieldNameLabel),
53
- placeholder: r.formatMessage(i.fieldNameInputPlaceholder),
54
- value: a.name,
55
- error: f("name"),
56
- onChange: m,
57
- onBlur: p,
58
- disabled: a.isFieldReadOnly,
59
- required: !0
60
- }), /* @__PURE__ */ e(s, {
61
- name: "type",
62
- label: r.formatMessage(i.fieldTypeLabel),
63
- placeholder: r.formatMessage(i.fieldTypePlaceholder),
64
- value: a.type,
65
- "aria-readonly": !d,
66
- readonly: !d,
67
- disabled: a.isFieldReadOnly,
68
- onValueChange: v,
69
- className: o.fieldTypeSelect,
70
- required: !0,
71
- children: /* @__PURE__ */ e(s.Content, {
72
- children: F.availableFieldTypes.map((l) => /* @__PURE__ */ e(s.Option, {
73
- text: typeof l.label == "string" ? l.label : String(l.label),
74
- value: l.type
75
- }, l.type))
76
- })
77
- })]
78
- }), [h.Dropdown, h.Taxonomy].includes(a.type) && /* @__PURE__ */ e("div", {
79
- className: o.typeSpecific,
80
- children: R(a.type)
81
- }), /* @__PURE__ */ e("div", {
82
- className: o.description,
83
- children: /* @__PURE__ */ e(u, {
84
- name: "description",
85
- id: t,
86
- label: T,
87
- placeholder: r.formatMessage(i.fieldDescriptionInputPlaceholder),
88
- value: a.description ?? "",
89
- error: f("description"),
90
- hideLabel: !0,
91
- disabled: a.isFieldReadOnly,
92
- onChange: m,
93
- onBlur: p
94
- })
95
- })]
96
- })
97
- });
98
- };
99
- export {
100
- z as FieldEditContent
1
+ import { a as e } from "../../../../../../chunks/types.js";
2
+ import { useFieldOptions as t } from "../../../../utils/field-options/useFieldOptions.js";
3
+ import { general as n } from "../../messages/configurator-messages.js";
4
+ import { useFieldConfigurator as r } from "../../context/field-configurator-context.js";
5
+ import { getConfigurationByType as i } from "../../utils.js";
6
+ import { t as a } from "../../../../../../chunks/metadata-field-configurator.module.js";
7
+ import { Select as o, TextInput as s, TextWithInfoBadge as c, TooltipProvider as l } from "@box/blueprint-web";
8
+ import { useIntl as u } from "react-intl";
9
+ import { jsx as d, jsxs as f } from "react/jsx-runtime";
10
+ import { useMemo as p } from "react";
11
+ var m = ({ nameInputId: m, descriptionInputId: h, isTypeEditable: g, externalErrors: _, externalTouched: v, handleTypeChange: y }) => {
12
+ let b = u(), x = t(), { values: S, errors: C, touched: w, handleChange: T, handleBlur: E } = r(), D = (e) => {
13
+ if (_ && v?.[e]) return _[e];
14
+ let t = C[e];
15
+ if (w[e] && t != null && typeof t == "string") return t;
16
+ }, O = p(() => /* @__PURE__ */ d(l, { children: /* @__PURE__ */ d(c, {
17
+ infoBadgeAriaLabel: b.formatMessage(n.descriptionLearnMoreBadgeAriaLabel),
18
+ infoText: b.formatMessage(n.descriptionInfoTooltip),
19
+ children: /* @__PURE__ */ d("label", {
20
+ className: a.labelWithTooltip,
21
+ htmlFor: h,
22
+ children: b.formatMessage(n.fieldDescriptionLabel)
23
+ })
24
+ }) }), [b, h]);
25
+ return /* @__PURE__ */ d("fieldset", {
26
+ disabled: S.isFieldReadOnly,
27
+ className: a.fieldset,
28
+ children: /* @__PURE__ */ f("div", {
29
+ className: a.expandedContent,
30
+ children: [
31
+ /* @__PURE__ */ f("div", {
32
+ className: a.basic,
33
+ children: [/* @__PURE__ */ d(s, {
34
+ name: "name",
35
+ id: m,
36
+ label: b.formatMessage(n.fieldNameLabel),
37
+ placeholder: b.formatMessage(n.fieldNameInputPlaceholder),
38
+ value: S.name,
39
+ error: D("name"),
40
+ onChange: T,
41
+ onBlur: E,
42
+ disabled: S.isFieldReadOnly,
43
+ required: !0
44
+ }), /* @__PURE__ */ d(o, {
45
+ name: "type",
46
+ label: b.formatMessage(n.fieldTypeLabel),
47
+ placeholder: b.formatMessage(n.fieldTypePlaceholder),
48
+ value: S.type,
49
+ "aria-readonly": !g,
50
+ readonly: !g,
51
+ disabled: S.isFieldReadOnly,
52
+ onValueChange: y,
53
+ className: a.fieldTypeSelect,
54
+ required: !0,
55
+ children: /* @__PURE__ */ d(o.Content, { children: x.availableFieldTypes.map((e) => /* @__PURE__ */ d(o.Option, {
56
+ text: typeof e.label == "string" ? e.label : String(e.label),
57
+ value: e.type
58
+ }, e.type)) })
59
+ })]
60
+ }),
61
+ [e.Dropdown, e.Taxonomy].includes(S.type) && /* @__PURE__ */ d("div", {
62
+ className: a.typeSpecific,
63
+ children: i(S.type)
64
+ }),
65
+ /* @__PURE__ */ d("div", {
66
+ className: a.description,
67
+ children: /* @__PURE__ */ d(s, {
68
+ name: "description",
69
+ id: h,
70
+ label: O,
71
+ placeholder: b.formatMessage(n.fieldDescriptionInputPlaceholder),
72
+ value: S.description ?? "",
73
+ error: D("description"),
74
+ hideLabel: !0,
75
+ disabled: S.isFieldReadOnly,
76
+ onChange: T,
77
+ onBlur: E
78
+ })
79
+ })
80
+ ]
81
+ })
82
+ });
101
83
  };
84
+ export { m as FieldEditContent };
@@ -1,33 +1,2 @@
1
- import { Text as n } from "@box/blueprint-web";
2
- import i from "clsx";
3
- import { useIntl as a } from "react-intl";
4
- import c from "../../messages/levels-chain-messages.js";
5
- import { jsx as d } from "react/jsx-runtime";
6
- import '../../../../../../styles/chip.css';const m = "_chip_x2zx9_1", p = "_selected_x2zx9_12", l = {
7
- chip: m,
8
- selected: p
9
- };
10
- let o = /* @__PURE__ */ (function(e) {
11
- return e.Selected = "selected", e.Unselected = "unselected", e;
12
- })({});
13
- const S = ({
14
- value: e,
15
- selected: t = !1
16
- }) => {
17
- const {
18
- formatMessage: s
19
- } = a(), r = s(t ? c.chipSelected : c.chipNotSelected);
20
- return /* @__PURE__ */ d(n, {
21
- as: "span",
22
- className: i(l.chip, {
23
- [l.selected]: t
24
- }),
25
- "data-state": t ? o.Selected : o.Unselected,
26
- "aria-label": `${e}: ${r}`,
27
- children: e
28
- });
29
- };
30
- export {
31
- S as Chip,
32
- o as ChipState
33
- };
1
+ import { n as e, t } from "../../../../../../chunks/chip.js";
2
+ export { t as Chip, e as ChipState };
@@ -1,4 +1,2 @@
1
- import { LevelsChain as r } from "./levels-chain.js";
2
- export {
3
- r as LevelsChain
4
- };
1
+ import { t as e } from "../../../../../../chunks/levels-chain.js";
2
+ export { e as LevelsChain };
@@ -1,118 +1,2 @@
1
- import { Tooltip as N, Text as P } from "@box/blueprint-web";
2
- import { ArrowRight as _ } from "@box/blueprint-web-assets/icons/Line";
3
- import { IconIconOnLightSecondary as k } from "@box/blueprint-web-assets/tokens/tokens";
4
- import { useState as u, useRef as b, useMemo as v, useEffect as A, useLayoutEffect as q } from "react";
5
- import { FormattedMessage as F } from "react-intl";
6
- import O from "../../messages/levels-chain-messages.js";
7
- import { Chip as L } from "./chip.js";
8
- import { getHideCounts as $ } from "./utils.js";
9
- import { jsx as l, jsxs as m } from "react/jsx-runtime";
10
- import '../../../../../../styles/levels-chain.css';const D = "_levelsChain_1wuki_1", y = {
11
- levelsChain: D
12
- };
13
- function G(t) {
14
- const a = Math.ceil(t.length / 2);
15
- return [t.slice(0, a), t.slice(a)];
16
- }
17
- const te = ({
18
- levels: t = [],
19
- selectedLevels: a = []
20
- }) => {
21
- const [n, h] = G(t), [r, C] = u(!1), [w, E] = u([]), [R, M] = u([]), [W, H] = u(0), [x, I] = u(0), s = b(null), g = b(null), S = v(() => {
22
- const e = s.current ? window.getComputedStyle(s.current) : {
23
- gap: "11px"
24
- };
25
- return parseInt(e.gap, 10);
26
- }, [s.current]), f = /* @__PURE__ */ l(_, {
27
- color: k,
28
- "aria-hidden": "true"
29
- });
30
- A(() => {
31
- C(!1);
32
- }, [t]), q(() => {
33
- if (s.current && !r && t.length > 0) {
34
- const e = s.current;
35
- I(e.clientWidth);
36
- const i = e.querySelectorAll("li"), o = Array.from(i).slice(0, n.length), z = Array.from(i).slice(n.length + 1);
37
- E(o.map((p) => p.getBoundingClientRect().width)), M(z.map((p) => p.getBoundingClientRect().width)), g.current && H(g.current.getBoundingClientRect().width), C(!0);
38
- }
39
- }, [n, h, r, t.length]), A(() => {
40
- const e = () => {
41
- s.current && I(s.current.clientWidth);
42
- };
43
- return window.addEventListener("resize", e), () => {
44
- window.removeEventListener("resize", e);
45
- };
46
- }, []);
47
- const [d, c] = v(() => $({
48
- isMeasured: r,
49
- leftLevelWidths: w,
50
- rightLevelWidths: R,
51
- containerWidthPx: x,
52
- buttonWidthPx: W,
53
- gapBetweenItems: S
54
- }), [r, w, R, x, W, S]), B = v(() => {
55
- const e = n.slice(n.length - d), i = h.slice(0, c);
56
- return [...e, ...i];
57
- }, [d, c, n, h]), T = B.some((e) => a.includes(e.level)), j = () => r ? d > 0 || c > 0 ? {} : {
58
- display: "none"
59
- } : {
60
- position: "absolute",
61
- visibility: "hidden"
62
- };
63
- return t.length === 0 ? /* @__PURE__ */ l("div", {
64
- role: "alert",
65
- children: /* @__PURE__ */ l(F, {
66
- ...O.noLevels
67
- })
68
- }) : /* @__PURE__ */ m("ul", {
69
- ref: s,
70
- className: y.levelsChain,
71
- "data-testid": "taxonomy-levels-chain",
72
- children: [n.map((e, i) => {
73
- const o = r && i >= n.length - d;
74
- return /* @__PURE__ */ m("li", {
75
- className: y.left,
76
- style: {
77
- display: o ? "none" : void 0
78
- },
79
- "aria-hidden": o,
80
- children: [/* @__PURE__ */ l(L, {
81
- value: e.name,
82
- selected: a.includes(e.level)
83
- }), n.length + h.length > 1 ? f : null]
84
- }, e.level);
85
- }), /* @__PURE__ */ m("li", {
86
- ref: g,
87
- style: j(),
88
- "aria-hidden": !(d > 0 || c > 0),
89
- tabIndex: r && (d > 0 || c > 0) ? 0 : -1,
90
- children: [/* @__PURE__ */ l(N, {
91
- content: B.map((e) => e.name).join(" > "),
92
- children: /* @__PURE__ */ l(P, {
93
- as: "span",
94
- children: /* @__PURE__ */ l(L, {
95
- value: `+${d + c}`,
96
- selected: T
97
- })
98
- })
99
- }), f]
100
- }), h.map((e, i) => {
101
- const o = r && i < c;
102
- return /* @__PURE__ */ m("li", {
103
- className: y.right,
104
- style: {
105
- display: o ? "none" : void 0
106
- },
107
- "aria-hidden": o,
108
- children: [/* @__PURE__ */ l(L, {
109
- value: e.name,
110
- selected: a.includes(e.level)
111
- }), i < h.length - 1 && f]
112
- }, e.level);
113
- })]
114
- });
115
- };
116
- export {
117
- te as LevelsChain
118
- };
1
+ import { t as e } from "../../../../../../chunks/levels-chain.js";
2
+ export { e as LevelsChain };