@box/metadata-template-editor 1.21.12 → 1.22.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/chunks/field-context-menu.js +35 -32
- package/dist/chunks/metadata-field-configurator.module.js +19 -15
- package/dist/chunks/metadata-field-list.js +20 -20
- package/dist/chunks/metadata-template-editor-form.js +4 -4
- package/dist/chunks/sortable-option-list.js +47 -47
- package/dist/esm/index.js +3 -3
- package/dist/esm/lib/components/metadata-field-configurator/components/field-action-slot/field-action-slot.js +57 -56
- package/dist/esm/lib/components/metadata-field-configurator/components/field-edit-content/field-edit-content.js +12 -12
- package/dist/esm/lib/components/metadata-field-configurator/hooks/useFieldConfiguratorBehavior.js +77 -76
- package/dist/esm/lib/components/metadata-field-configurator/index.js +3 -3
- package/dist/esm/lib/components/metadata-field-configurator/metadata-field-configurator.js +79 -76
- package/dist/i18n/en-x-pseudo.js +106 -106
- package/dist/i18n/en-x-pseudo.properties +106 -106
- package/dist/styles/metadata-field-configurator.css +1 -1
- package/dist/types/lib/components/metadata-field-configurator/components/field-action-slot/field-action-slot.d.ts +3 -10
- package/dist/types/lib/components/metadata-field-configurator/components/field-context-menu/field-context-menu.d.ts +5 -1
- package/dist/types/lib/components/metadata-field-configurator/hooks/useFieldConfiguratorBehavior.d.ts +1 -0
- package/dist/types/lib/components/metadata-field-configurator/metadata-field-configurator.d.ts +6 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
# metadata-template-editor
|
|
13
13
|
|
|
14
|
-
This library was generated with @box/automation. General overview on how to perform tasks on the generated library can be found in [run-tasks](https://nx.dev/core-features/run-tasks) Nx documentation.
|
|
14
|
+
This library was generated with [@box/automation](../../automation//README.md). General overview on how to perform tasks on the generated library can be found in [run-tasks](https://nx.dev/core-features/run-tasks) Nx documentation.
|
|
15
15
|
|
|
16
16
|
## Running commands
|
|
17
17
|
|
|
@@ -43,7 +43,7 @@ All commands used with Nx can be found in `project.json` file within your packag
|
|
|
43
43
|
- `nx test-jest metadata-template-editor` - runs jest unit tests, producing code coverage at the end.
|
|
44
44
|
- `nx sonar metadata-template-editor` - performs static analysis of code using SonarQube tooling, to detect bugs and code smells. Integrated as one of the steps in CI process.
|
|
45
45
|
- `nx chromatic metadata-template-editor` - uploads storybook build for review to [box chromatic](https://box.chromatic.com/) , and performs visual comparison of the UI changes against baseline.
|
|
46
|
-
- `nx prepare metadata-template-editor` - command run during package publication process orchestrated by
|
|
46
|
+
- `nx prepare metadata-template-editor` - command run during package publication process orchestrated by Nx Release.
|
|
47
47
|
|
|
48
48
|
## Ownership
|
|
49
49
|
|
|
@@ -51,7 +51,7 @@ Code of the feature belongs to metadata-experience. Responsibilities of owning t
|
|
|
51
51
|
|
|
52
52
|
## Translations
|
|
53
53
|
|
|
54
|
-
For translations this package will be leveraging `@box/frontend` as it has the required scripts to do translations the Box way, for more information on this checkout their i18n docs.
|
|
54
|
+
For translations this package will be leveraging `@box/frontend` as it has the required scripts to do translations the Box way, for more information on this checkout their i18n docs [here](https://git.dev.box.net/Box/frontend/tree/master/i18n)
|
|
55
55
|
|
|
56
|
-
The `i18n/` dir is bundled with this package to enable the consuming app to use the translations included in this component it need to adjust it's TranslationsPlugin,
|
|
57
|
-
see EUA's webpack.base.config.js and i18n.config.js for reference.
|
|
56
|
+
The `i18n/` dir is bundled with this package to enable the consuming app to use the translations included in this component it need to adjust it's [TranslationsPlugin](https://git.dev.box.net/Box/frontend/blob/master/webpack/README.md#translationsplugin),
|
|
57
|
+
see EUA's [webpack.base.config.js](https://git.dev.box.net/Box/EndUserApp/blob/master/conf/webpack/webpack.base.js#L270-L273) and [i18n.config.js](https://git.dev.box.net/Box/EndUserApp/blob/master/i18n.config.js) for reference.
|
|
@@ -6,73 +6,76 @@ import { Ellipsis as l } from "@box/blueprint-web-assets/icons/Fill";
|
|
|
6
6
|
import u from "react";
|
|
7
7
|
import { IconIconErrorOnLight as d } from "@box/blueprint-web-assets/tokens/tokens";
|
|
8
8
|
import { ArrowDown as f, ArrowUp as p, Hidden as m, Trash as h, TwoFiles as g, Visible as _ } from "@box/blueprint-web-assets/icons/Line";
|
|
9
|
-
import
|
|
9
|
+
import v from "clsx";
|
|
10
|
+
import '../styles/field-context-menu.css';var y = {
|
|
10
11
|
contextMenuTrigger: "_contextMenuTrigger_102vn_1",
|
|
11
12
|
menuItem: "_menuItem_102vn_5",
|
|
12
13
|
contextMenu: "_contextMenu_102vn_1",
|
|
13
14
|
divider: "_divider_102vn_14"
|
|
14
|
-
},
|
|
15
|
-
let
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
|
|
15
|
+
}, b = ({ className: b, index: x, maxIndex: S, isHidden: C, onReorderFields: w, onToggleVisibility: T, onRequestDelete: E, onRequestDuplicate: D, onOpenChange: O }) => {
|
|
16
|
+
let k = o(), [A, j] = u.useState(!1), M = u.useRef(null), N = (e) => {
|
|
17
|
+
j(e), O?.(e);
|
|
18
|
+
}, P = () => {
|
|
19
|
+
x > 0 && w(x, x - 1);
|
|
20
|
+
}, F = () => {
|
|
21
|
+
w(x, x + 1);
|
|
19
22
|
};
|
|
20
23
|
return /* @__PURE__ */ c(n.Root, {
|
|
21
|
-
open:
|
|
22
|
-
onOpenChange:
|
|
24
|
+
open: A,
|
|
25
|
+
onOpenChange: N,
|
|
23
26
|
modal: !1,
|
|
24
27
|
children: [/* @__PURE__ */ s(n.Trigger, {
|
|
25
|
-
className: v.contextMenuTrigger,
|
|
28
|
+
className: v(y.contextMenuTrigger, b),
|
|
26
29
|
children: /* @__PURE__ */ s(r, {
|
|
27
30
|
icon: l,
|
|
28
|
-
"aria-label":
|
|
31
|
+
"aria-label": k.formatMessage(e.contextMenuAriaLabel),
|
|
29
32
|
size: "large"
|
|
30
33
|
})
|
|
31
34
|
}), /* @__PURE__ */ c(n.Content, {
|
|
32
|
-
ref:
|
|
35
|
+
ref: M,
|
|
33
36
|
align: "end",
|
|
34
|
-
className:
|
|
37
|
+
className: y.contextMenu,
|
|
35
38
|
children: [
|
|
36
39
|
/* @__PURE__ */ s(n.Item, {
|
|
37
|
-
disabled:
|
|
38
|
-
onClick:
|
|
39
|
-
"aria-label":
|
|
40
|
+
disabled: x === 0,
|
|
41
|
+
onClick: P,
|
|
42
|
+
"aria-label": k.formatMessage(e.moveUpAriaLabel),
|
|
40
43
|
children: /* @__PURE__ */ c("div", {
|
|
41
|
-
className:
|
|
44
|
+
className: y.menuItem,
|
|
42
45
|
children: [/* @__PURE__ */ s(p, { "aria-hidden": "true" }), /* @__PURE__ */ s(a, { ...e.moveUp })]
|
|
43
46
|
})
|
|
44
47
|
}),
|
|
45
48
|
/* @__PURE__ */ s(n.Item, {
|
|
46
|
-
disabled:
|
|
47
|
-
onClick:
|
|
48
|
-
"aria-label":
|
|
49
|
+
disabled: x === S,
|
|
50
|
+
onClick: F,
|
|
51
|
+
"aria-label": k.formatMessage(e.moveDownAriaLabel),
|
|
49
52
|
children: /* @__PURE__ */ c("div", {
|
|
50
|
-
className:
|
|
53
|
+
className: y.menuItem,
|
|
51
54
|
children: [/* @__PURE__ */ s(f, { "aria-hidden": "true" }), /* @__PURE__ */ s(a, { ...e.moveDown })]
|
|
52
55
|
})
|
|
53
56
|
}),
|
|
54
57
|
/* @__PURE__ */ s(n.Item, {
|
|
55
|
-
onClick:
|
|
56
|
-
"aria-label":
|
|
58
|
+
onClick: D,
|
|
59
|
+
"aria-label": k.formatMessage(e.duplicateFieldAriaLabel),
|
|
57
60
|
children: /* @__PURE__ */ c("div", {
|
|
58
|
-
className:
|
|
61
|
+
className: y.menuItem,
|
|
59
62
|
children: [/* @__PURE__ */ s(g, { "aria-hidden": "true" }), /* @__PURE__ */ s(a, { ...e.duplicateField })]
|
|
60
63
|
})
|
|
61
64
|
}),
|
|
62
65
|
/* @__PURE__ */ s(n.Item, {
|
|
63
|
-
onClick: () =>
|
|
64
|
-
"aria-label":
|
|
66
|
+
onClick: () => T(!C),
|
|
67
|
+
"aria-label": k.formatMessage(C ? e.showField : e.hideField),
|
|
65
68
|
children: /* @__PURE__ */ c("div", {
|
|
66
|
-
className:
|
|
67
|
-
children: [s(
|
|
69
|
+
className: y.menuItem,
|
|
70
|
+
children: [s(C ? _ : m, { "aria-hidden": "true" }), /* @__PURE__ */ s(a, { ...C ? e.showField : e.hideField })]
|
|
68
71
|
})
|
|
69
72
|
}),
|
|
70
|
-
/* @__PURE__ */ s(t, { className:
|
|
73
|
+
/* @__PURE__ */ s(t, { className: y.divider }),
|
|
71
74
|
/* @__PURE__ */ s(n.Item, {
|
|
72
|
-
onClick:
|
|
73
|
-
"aria-label":
|
|
75
|
+
onClick: E,
|
|
76
|
+
"aria-label": k.formatMessage(e.deleteFieldAriaLabel),
|
|
74
77
|
children: /* @__PURE__ */ c("div", {
|
|
75
|
-
className:
|
|
78
|
+
className: y.menuItem,
|
|
76
79
|
children: [/* @__PURE__ */ s(h, {
|
|
77
80
|
color: d,
|
|
78
81
|
"aria-hidden": "true"
|
|
@@ -87,4 +90,4 @@ import '../styles/field-context-menu.css';var v = {
|
|
|
87
90
|
})]
|
|
88
91
|
});
|
|
89
92
|
};
|
|
90
|
-
export {
|
|
93
|
+
export { b as t };
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import '../styles/metadata-field-configurator.css';var e = {
|
|
2
|
-
fieldset: "
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
validationErrors: "
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
2
|
+
fieldset: "_fieldset_ireyr_1",
|
|
3
|
+
fieldAccordionItem: "_fieldAccordionItem_ireyr_7",
|
|
4
|
+
expandedContent: "_expandedContent_ireyr_11",
|
|
5
|
+
basic: "_basic_ireyr_17",
|
|
6
|
+
fieldTypeSelect: "_fieldTypeSelect_ireyr_22",
|
|
7
|
+
typeSpecific: "_typeSpecific_ireyr_26",
|
|
8
|
+
description: "_description_ireyr_33",
|
|
9
|
+
labelWithTooltip: "_labelWithTooltip_ireyr_38",
|
|
10
|
+
validationErrors: "_validationErrors_ireyr_49",
|
|
11
|
+
errorIcon: "_errorIcon_ireyr_53",
|
|
12
|
+
fieldActionSlot: "_fieldActionSlot_ireyr_59",
|
|
13
|
+
expandedToolbarActions: "_expandedToolbarActions_ireyr_65",
|
|
14
|
+
fieldCollapsedText: "_fieldCollapsedText_ireyr_71",
|
|
15
|
+
extensionTabsContainer: "_extensionTabsContainer_ireyr_76",
|
|
16
|
+
extensionContent: "_extensionContent_ireyr_82",
|
|
17
|
+
menuOpen: "_menuOpen_ireyr_94",
|
|
18
|
+
fieldContextMenu: "_fieldContextMenu_ireyr_97",
|
|
19
|
+
hiddenBadge: "_hiddenBadge_ireyr_112",
|
|
20
|
+
contextMenuWithCollapsedText: "_contextMenuWithCollapsedText_ireyr_115"
|
|
17
21
|
};
|
|
18
22
|
export { e as t };
|
|
@@ -11,12 +11,12 @@ import { useIntl as l } from "react-intl";
|
|
|
11
11
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
12
12
|
import { forwardRef as f, useCallback as p, useEffect as m, useImperativeHandle as h, useRef as g, useState as _ } from "react";
|
|
13
13
|
import * as v from "yup";
|
|
14
|
+
import y from "clsx";
|
|
14
15
|
import ee from "lodash/cloneDeep";
|
|
15
|
-
import
|
|
16
|
-
import { DndContext as te, DragOverlay as
|
|
17
|
-
import { SortableContext as
|
|
18
|
-
import { CSS as
|
|
19
|
-
import O from "clsx";
|
|
16
|
+
import b from "lodash/uniqueId";
|
|
17
|
+
import { DndContext as te, DragOverlay as x, KeyboardSensor as S, PointerSensor as ne, TouchSensor as re, closestCenter as ie, useSensor as C, useSensors as w } from "@dnd-kit/core";
|
|
18
|
+
import { SortableContext as T, arrayMove as E, sortableKeyboardCoordinates as ae, useSortable as D, verticalListSortingStrategy as oe } from "@dnd-kit/sortable";
|
|
19
|
+
import { CSS as O } from "@dnd-kit/utilities";
|
|
20
20
|
import '../styles/metadata-field-list.css';var k = {
|
|
21
21
|
fieldList: "_fieldList_18x5c_1",
|
|
22
22
|
fieldItem: "_fieldItem_18x5c_11",
|
|
@@ -28,15 +28,15 @@ function j(e) {
|
|
|
28
28
|
}
|
|
29
29
|
var M = 150;
|
|
30
30
|
function N({ field: e, index: t, maxIndex: n, isExpanded: r, onChangeField: i, onDeleteAtIndex: a, onDuplicateAtIndex: o, onReorderFields: c, onRequestExpand: l, submitAttemptCount: d }) {
|
|
31
|
-
let f = j(e), { attributes: p, listeners: m, setNodeRef: h, transform: g, transition: _, isDragging: v } =
|
|
31
|
+
let f = j(e), { attributes: p, listeners: m, setNodeRef: h, transform: g, transition: _, isDragging: v } = D({ id: f });
|
|
32
32
|
return /* @__PURE__ */ u("li", {
|
|
33
33
|
ref: h,
|
|
34
34
|
style: {
|
|
35
|
-
transform:
|
|
35
|
+
transform: O.Translate.toString(g),
|
|
36
36
|
transition: _
|
|
37
37
|
},
|
|
38
38
|
"data-field-id": f,
|
|
39
|
-
className:
|
|
39
|
+
className: y(k.fieldItem, { [k.dragging]: v }),
|
|
40
40
|
children: /* @__PURE__ */ u(s, {
|
|
41
41
|
values: e,
|
|
42
42
|
onValuesChange: i,
|
|
@@ -57,7 +57,7 @@ function N({ field: e, index: t, maxIndex: n, isExpanded: r, onChangeField: i, o
|
|
|
57
57
|
})
|
|
58
58
|
});
|
|
59
59
|
}
|
|
60
|
-
var P = /* @__PURE__ */ f(function({ fields: s, onChangeFields: f, onDeleteFieldAtIndex:
|
|
60
|
+
var P = /* @__PURE__ */ f(function({ fields: s, onChangeFields: f, onDeleteFieldAtIndex: y, onDuplicateField: D, taxonomyOptions: O, fetchTaxonomies: P, firstInvalidFieldIndex: F, submitAttemptCount: I, fieldExtensions: L, onValidationChange: R }, z) {
|
|
61
61
|
let { formatMessage: B } = l(), V = o(P, O), H = g(null), U = g(null), W = g(new Set(s.map((e) => j(e)))), G = r(), K = g(null);
|
|
62
62
|
m(() => {
|
|
63
63
|
K.current = null;
|
|
@@ -117,17 +117,17 @@ var P = /* @__PURE__ */ f(function({ fields: s, onChangeFields: f, onDeleteField
|
|
|
117
117
|
}, M);
|
|
118
118
|
return () => clearTimeout(t);
|
|
119
119
|
}, [q]);
|
|
120
|
-
let [Y, X] = _(null), se =
|
|
120
|
+
let [Y, X] = _(null), se = w(C(ne, { activationConstraint: { distance: 8 } }), C(re, { activationConstraint: {
|
|
121
121
|
delay: 250,
|
|
122
122
|
tolerance: 5
|
|
123
|
-
} }), C(
|
|
123
|
+
} }), C(S, { coordinateGetter: ae })), ce = p((e) => {
|
|
124
124
|
X(String(e.active.id));
|
|
125
125
|
}, []), le = p((e) => {
|
|
126
126
|
X(null);
|
|
127
127
|
let { active: t, over: n } = e;
|
|
128
128
|
if (n && t.id !== n.id) {
|
|
129
129
|
let e = s.findIndex((e) => j(e) === t.id), r = s.findIndex((e) => j(e) === n.id);
|
|
130
|
-
e !== -1 && r !== -1 && f?.(
|
|
130
|
+
e !== -1 && r !== -1 && f?.(E(s, e, r));
|
|
131
131
|
}
|
|
132
132
|
}, [s, f]), ue = p(() => {
|
|
133
133
|
X(null);
|
|
@@ -135,16 +135,16 @@ var P = /* @__PURE__ */ f(function({ fields: s, onChangeFields: f, onDeleteField
|
|
|
135
135
|
f?.(s.map((n, r) => r === e ? t : n));
|
|
136
136
|
}, [s, f]), fe = p((e) => {
|
|
137
137
|
let t = s[e], n = j(t);
|
|
138
|
-
J((e) => e === n ? null : e), f?.(s.filter((t, n) => n !== e)),
|
|
138
|
+
J((e) => e === n ? null : e), f?.(s.filter((t, n) => n !== e)), y?.(e, t);
|
|
139
139
|
}, [
|
|
140
140
|
s,
|
|
141
141
|
f,
|
|
142
|
-
|
|
142
|
+
y
|
|
143
143
|
]), pe = p((t) => {
|
|
144
144
|
let n = s[t], r = ee(n);
|
|
145
|
-
r.id =
|
|
145
|
+
r.id = b("field-"), r.key = "", r.isFieldNew = !0, r.type === e.Dropdown && (r.dropdown.options = r.dropdown.options.map((e) => ({
|
|
146
146
|
...e,
|
|
147
|
-
id:
|
|
147
|
+
id: b()
|
|
148
148
|
})));
|
|
149
149
|
let i = [...s];
|
|
150
150
|
i.splice(t + 1, 0, r), f?.(i), D?.(r);
|
|
@@ -153,7 +153,7 @@ var P = /* @__PURE__ */ f(function({ fields: s, onChangeFields: f, onDeleteField
|
|
|
153
153
|
f,
|
|
154
154
|
D
|
|
155
155
|
]), me = p((e, t) => {
|
|
156
|
-
t < 0 || t >= s.length || f?.(
|
|
156
|
+
t < 0 || t >= s.length || f?.(E(s, e, t));
|
|
157
157
|
}, [s, f]), he = p((e) => {
|
|
158
158
|
let t = e || null;
|
|
159
159
|
J(t), t && setTimeout(() => {
|
|
@@ -169,7 +169,7 @@ var P = /* @__PURE__ */ f(function({ fields: s, onChangeFields: f, onDeleteField
|
|
|
169
169
|
value: V,
|
|
170
170
|
children: /* @__PURE__ */ d(te, {
|
|
171
171
|
sensors: se,
|
|
172
|
-
collisionDetection:
|
|
172
|
+
collisionDetection: ie,
|
|
173
173
|
onDragStart: ce,
|
|
174
174
|
onDragEnd: le,
|
|
175
175
|
onDragCancel: ue,
|
|
@@ -180,7 +180,7 @@ var P = /* @__PURE__ */ f(function({ fields: s, onChangeFields: f, onDeleteField
|
|
|
180
180
|
collapsible: !0,
|
|
181
181
|
value: q ?? "",
|
|
182
182
|
onValueChange: he,
|
|
183
|
-
children: /* @__PURE__ */ u(
|
|
183
|
+
children: /* @__PURE__ */ u(T, {
|
|
184
184
|
items: ge,
|
|
185
185
|
strategy: oe,
|
|
186
186
|
children: /* @__PURE__ */ u("ul", {
|
|
@@ -204,7 +204,7 @@ var P = /* @__PURE__ */ f(function({ fields: s, onChangeFields: f, onDeleteField
|
|
|
204
204
|
})
|
|
205
205
|
})
|
|
206
206
|
})
|
|
207
|
-
}), /* @__PURE__ */ u(
|
|
207
|
+
}), /* @__PURE__ */ u(x, {
|
|
208
208
|
dropAnimation: null,
|
|
209
209
|
children: Z && Q ? /* @__PURE__ */ u(c, {
|
|
210
210
|
type: "single",
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as e } from "./field-selector.js";
|
|
2
2
|
import { t } from "./field-type-dropdown.js";
|
|
3
3
|
import { FieldTypeTiles as n } from "../esm/lib/components/field-type-tiles/field-type-tiles.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { createDefaultFieldValues as r } from "../esm/lib/components/metadata-field-configurator/utils.js";
|
|
5
|
+
import { FieldExtensionsContext as i } from "../esm/lib/components/metadata-field-configurator/context/field-extensions-context.js";
|
|
6
6
|
import { t as a } from "./metadata-field-list.js";
|
|
7
7
|
import o from "../esm/lib/messages.js";
|
|
8
8
|
import { Button as s, Link as c, Text as l, TextInput as u } from "@box/blueprint-web";
|
|
@@ -22,7 +22,7 @@ import '../styles/metadata-template-editor-form.css';var x = {
|
|
|
22
22
|
let e = F.fields.findIndex(Boolean);
|
|
23
23
|
return e >= 0 ? e : null;
|
|
24
24
|
}, [F.fields]), q = (e) => {
|
|
25
|
-
let t =
|
|
25
|
+
let t = r(e.type);
|
|
26
26
|
L("fields", [...I.fields, t]);
|
|
27
27
|
}, J = (e) => {
|
|
28
28
|
L("fields", e);
|
|
@@ -99,7 +99,7 @@ import '../styles/metadata-template-editor-form.css';var x = {
|
|
|
99
99
|
})
|
|
100
100
|
]
|
|
101
101
|
});
|
|
102
|
-
return N === void 0 ? X : /* @__PURE__ */ m(
|
|
102
|
+
return N === void 0 ? X : /* @__PURE__ */ m(i.Provider, {
|
|
103
103
|
value: N,
|
|
104
104
|
children: X
|
|
105
105
|
});
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import t from "../esm/lib/components/metadata-field-configurator/
|
|
3
|
-
import n from "../esm/lib/components/metadata-field-configurator/
|
|
1
|
+
import e from "../esm/lib/components/metadata-field-configurator/components/confirmation-modal/confirmation-modal.js";
|
|
2
|
+
import { useFieldConfigurator as t } from "../esm/lib/components/metadata-field-configurator/context/field-configurator-context.js";
|
|
3
|
+
import n from "../esm/lib/components/metadata-field-configurator/messages/dropdown-messages.js";
|
|
4
4
|
import { IconButton as r, TextInput as i } from "@box/blueprint-web";
|
|
5
5
|
import { useIntl as a } from "react-intl";
|
|
6
6
|
import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
7
7
|
import { DragDots as l } from "@box/blueprint-web-assets/icons/Fill";
|
|
8
8
|
import { useCallback as u, useEffect as d, useRef as f, useState as p } from "react";
|
|
9
|
-
import m from "
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import O from "
|
|
9
|
+
import { Trash as m } from "@box/blueprint-web-assets/icons/Line";
|
|
10
|
+
import h from "clsx";
|
|
11
|
+
import g from "lodash/uniqueId";
|
|
12
|
+
import { DndContext as _, DragOverlay as v, KeyboardSensor as y, PointerSensor as b, TouchSensor as x, closestCenter as S, useSensor as C, useSensors as w } from "@dnd-kit/core";
|
|
13
|
+
import { SortableContext as ee, arrayMove as T, sortableKeyboardCoordinates as te, useSortable as E, verticalListSortingStrategy as D } from "@dnd-kit/sortable";
|
|
14
|
+
import { CSS as O } from "@dnd-kit/utilities";
|
|
15
15
|
import '../styles/sortable-option-list.css';var k = {
|
|
16
16
|
sortableOptionList: "_sortableOptionList_1cieq_1",
|
|
17
17
|
option: "_option_1cieq_9",
|
|
@@ -32,24 +32,24 @@ function ne(e, t, n, r, i, a) {
|
|
|
32
32
|
}
|
|
33
33
|
return o;
|
|
34
34
|
}
|
|
35
|
-
function re({ option: e, index: t, isFieldReadOnly: n, onInputChange: a, onDelete: o, onInputRef: u, error: d, handleBlur: f, canDelete: p, dragAriaLabel:
|
|
36
|
-
let { attributes:
|
|
35
|
+
function re({ option: e, index: t, isFieldReadOnly: n, onInputChange: a, onDelete: o, onInputRef: u, error: d, handleBlur: f, canDelete: p, dragAriaLabel: g, inputPlaceholder: _, deleteAriaLabel: v }) {
|
|
36
|
+
let { attributes: y, listeners: b, setNodeRef: x, transform: S, transition: C, isDragging: w } = E({ id: e.id });
|
|
37
37
|
return /* @__PURE__ */ c("li", {
|
|
38
|
-
ref:
|
|
38
|
+
ref: x,
|
|
39
39
|
style: {
|
|
40
|
-
transform:
|
|
41
|
-
transition:
|
|
40
|
+
transform: O.Translate.toString(S),
|
|
41
|
+
transition: C
|
|
42
42
|
},
|
|
43
|
-
className:
|
|
44
|
-
[k.dragging]:
|
|
43
|
+
className: h(k.option, {
|
|
44
|
+
[k.dragging]: w,
|
|
45
45
|
[k.editable]: !n
|
|
46
46
|
}),
|
|
47
47
|
children: [
|
|
48
48
|
!n && /* @__PURE__ */ s("div", {
|
|
49
49
|
className: k.dragHandle,
|
|
50
|
+
...b,
|
|
50
51
|
...y,
|
|
51
|
-
|
|
52
|
-
"aria-label": m,
|
|
52
|
+
"aria-label": g,
|
|
53
53
|
tabIndex: -1,
|
|
54
54
|
children: /* @__PURE__ */ s(l, {
|
|
55
55
|
fontSize: 20,
|
|
@@ -58,8 +58,8 @@ function re({ option: e, index: t, isFieldReadOnly: n, onInputChange: a, onDelet
|
|
|
58
58
|
}),
|
|
59
59
|
/* @__PURE__ */ s(i, {
|
|
60
60
|
disabled: n,
|
|
61
|
-
placeholder:
|
|
62
|
-
label:
|
|
61
|
+
placeholder: _,
|
|
62
|
+
label: _,
|
|
63
63
|
hideLabel: !0,
|
|
64
64
|
onBlur: f,
|
|
65
65
|
id: `dropdown.options.${t}.key`,
|
|
@@ -74,8 +74,8 @@ function re({ option: e, index: t, isFieldReadOnly: n, onInputChange: a, onDelet
|
|
|
74
74
|
className: k.deleteButtonContainer,
|
|
75
75
|
children: /* @__PURE__ */ s(r, {
|
|
76
76
|
onClick: () => o(e),
|
|
77
|
-
"aria-label":
|
|
78
|
-
icon:
|
|
77
|
+
"aria-label": v,
|
|
78
|
+
icon: m,
|
|
79
79
|
size: "x-small",
|
|
80
80
|
variant: "default",
|
|
81
81
|
tabIndex: -1,
|
|
@@ -87,11 +87,11 @@ function re({ option: e, index: t, isFieldReadOnly: n, onInputChange: a, onDelet
|
|
|
87
87
|
]
|
|
88
88
|
});
|
|
89
89
|
}
|
|
90
|
-
function A({ shouldFocusLastOption: E = !1, onFocusConsumed:
|
|
91
|
-
let { formatMessage: A } = a(), { values: j, errors: ie, touched: M, setFieldValue: N, setFieldTouched: ae, setTouched: P, handleBlur: oe } =
|
|
90
|
+
function A({ shouldFocusLastOption: E = !1, onFocusConsumed: O }) {
|
|
91
|
+
let { formatMessage: A } = a(), { values: j, errors: ie, touched: M, setFieldValue: N, setFieldTouched: ae, setTouched: P, handleBlur: oe } = t(), F = w(C(b, { activationConstraint: { distance: 8 } }), C(x, { activationConstraint: {
|
|
92
92
|
delay: 250,
|
|
93
93
|
tolerance: 5
|
|
94
|
-
} }),
|
|
94
|
+
} }), C(y, { coordinateGetter: te })), { options: I } = j.dropdown, { isFieldReadOnly: L } = j, [R, z] = p(I), [B, V] = p(null), H = f(null), [U, W] = p(null), [G, K] = p(!1), [q, J] = p(null);
|
|
95
95
|
d(() => {
|
|
96
96
|
z(I);
|
|
97
97
|
}, [I]), d(() => () => {
|
|
@@ -119,7 +119,7 @@ function A({ shouldFocusLastOption: E = !1, onFocusConsumed: D }) {
|
|
|
119
119
|
r?.options && (r.options = r.options.filter((t, n) => R[n]?.id !== e)), P(n), t.length === 0 && N("dropdown", {
|
|
120
120
|
...j.dropdown,
|
|
121
121
|
options: [{
|
|
122
|
-
id:
|
|
122
|
+
id: g(),
|
|
123
123
|
key: "",
|
|
124
124
|
isNew: !0
|
|
125
125
|
}]
|
|
@@ -136,57 +136,57 @@ function A({ shouldFocusLastOption: E = !1, onFocusConsumed: D }) {
|
|
|
136
136
|
if (n && t.id !== n.id) {
|
|
137
137
|
let e = R.findIndex((e) => e.id === t.id), r = R.findIndex((e) => e.id === n.id);
|
|
138
138
|
if (e !== -1 && r !== -1) {
|
|
139
|
-
let t =
|
|
139
|
+
let t = T(R, e, r);
|
|
140
140
|
z(t), Y(t);
|
|
141
141
|
let n = M?.dropdown?.options;
|
|
142
142
|
n && n.length > 0 && P({
|
|
143
143
|
...M,
|
|
144
144
|
dropdown: {
|
|
145
145
|
...M.dropdown ?? {},
|
|
146
|
-
options:
|
|
146
|
+
options: T(n, e, r)
|
|
147
147
|
}
|
|
148
148
|
});
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
}, de = u((e, t) => {
|
|
152
152
|
e && E && t === R.length - 1 && (H.current && clearTimeout(H.current), H.current = setTimeout(() => {
|
|
153
|
-
e.focus(),
|
|
153
|
+
e.focus(), O(), H.current = null;
|
|
154
154
|
}, 0));
|
|
155
155
|
}, [
|
|
156
156
|
E,
|
|
157
|
-
|
|
157
|
+
O,
|
|
158
158
|
R.length
|
|
159
159
|
]), $ = U ? R.find((e) => e.id === U) : null;
|
|
160
|
-
return /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ c(
|
|
160
|
+
return /* @__PURE__ */ c(o, { children: [/* @__PURE__ */ c(_, {
|
|
161
161
|
sensors: F,
|
|
162
|
-
collisionDetection:
|
|
162
|
+
collisionDetection: S,
|
|
163
163
|
onDragStart: le,
|
|
164
164
|
onDragEnd: Q,
|
|
165
165
|
onDragCancel: ue,
|
|
166
166
|
children: [/* @__PURE__ */ s(ee, {
|
|
167
167
|
items: R.map((e) => e.id),
|
|
168
|
-
strategy:
|
|
168
|
+
strategy: D,
|
|
169
169
|
children: /* @__PURE__ */ s("ul", {
|
|
170
170
|
className: k.sortableOptionList,
|
|
171
|
-
children: R.map((e,
|
|
171
|
+
children: R.map((e, t) => /* @__PURE__ */ s(re, {
|
|
172
172
|
option: e,
|
|
173
|
-
index:
|
|
173
|
+
index: t,
|
|
174
174
|
isFieldReadOnly: !!L,
|
|
175
175
|
onInputChange: se,
|
|
176
176
|
onDelete: ce,
|
|
177
177
|
onInputRef: de,
|
|
178
|
-
error: ne(ie, M,
|
|
178
|
+
error: ne(ie, M, t, e, R, B),
|
|
179
179
|
handleBlur: oe,
|
|
180
180
|
canDelete: R.length >= 2,
|
|
181
|
-
dragAriaLabel: A(
|
|
182
|
-
inputPlaceholder: A(
|
|
183
|
-
deleteAriaLabel: A(
|
|
181
|
+
dragAriaLabel: A(n.dragAndDropOptionAriaLabel),
|
|
182
|
+
inputPlaceholder: A(n.addAnOptionOptionPlaceholder),
|
|
183
|
+
deleteAriaLabel: A(n.deleteDropdownOptionAriaLabel)
|
|
184
184
|
}, e.id))
|
|
185
185
|
})
|
|
186
|
-
}), /* @__PURE__ */ s(
|
|
186
|
+
}), /* @__PURE__ */ s(v, {
|
|
187
187
|
dropAnimation: null,
|
|
188
188
|
children: $ ? /* @__PURE__ */ c("li", {
|
|
189
|
-
className:
|
|
189
|
+
className: h(k.option, k.optionDragOverlay, { [k.editable]: !L }),
|
|
190
190
|
children: [
|
|
191
191
|
!L && /* @__PURE__ */ s("div", {
|
|
192
192
|
className: k.dragHandle,
|
|
@@ -197,8 +197,8 @@ function A({ shouldFocusLastOption: E = !1, onFocusConsumed: D }) {
|
|
|
197
197
|
}),
|
|
198
198
|
/* @__PURE__ */ s(i, {
|
|
199
199
|
disabled: L,
|
|
200
|
-
placeholder: A(
|
|
201
|
-
label: A(
|
|
200
|
+
placeholder: A(n.addAnOptionOptionPlaceholder),
|
|
201
|
+
label: A(n.addAnOptionOptionPlaceholder),
|
|
202
202
|
hideLabel: !0,
|
|
203
203
|
id: "drag-overlay-option",
|
|
204
204
|
name: "drag-overlay-option",
|
|
@@ -208,7 +208,7 @@ function A({ shouldFocusLastOption: E = !1, onFocusConsumed: D }) {
|
|
|
208
208
|
!L && /* @__PURE__ */ s("div", {
|
|
209
209
|
className: k.deleteButtonContainer,
|
|
210
210
|
children: /* @__PURE__ */ s(r, {
|
|
211
|
-
icon:
|
|
211
|
+
icon: m,
|
|
212
212
|
size: "x-small",
|
|
213
213
|
variant: "default",
|
|
214
214
|
tabIndex: -1,
|
|
@@ -221,11 +221,11 @@ function A({ shouldFocusLastOption: E = !1, onFocusConsumed: D }) {
|
|
|
221
221
|
]
|
|
222
222
|
}) : null
|
|
223
223
|
})]
|
|
224
|
-
}), G && /* @__PURE__ */ s(
|
|
224
|
+
}), G && /* @__PURE__ */ s(e, {
|
|
225
225
|
onClose: X,
|
|
226
226
|
onConfirm: () => Z(q?.id ?? null),
|
|
227
|
-
title: A(
|
|
228
|
-
body: A(
|
|
227
|
+
title: A(n.deleteOptionTitle, { optionName: q?.key ?? "" }),
|
|
228
|
+
body: A(n.deleteOptionDescription)
|
|
229
229
|
})] });
|
|
230
230
|
}
|
|
231
231
|
export { A as t };
|
package/dist/esm/index.js
CHANGED
|
@@ -3,11 +3,11 @@ import { a as t, c as n, i as r, l as i, n as a, o, r as s, s as c, t as l } fro
|
|
|
3
3
|
import { t as u } from "../chunks/field-type-dropdown.js";
|
|
4
4
|
import { FieldTypeTiles as d } from "./lib/components/field-type-tiles/field-type-tiles.js";
|
|
5
5
|
import { useTemplateFieldSchema as f } from "./lib/components/metadata-field-configurator/hooks/useTemplateFieldSchema.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
6
|
+
import { createDefaultFieldValues as p } from "./lib/components/metadata-field-configurator/utils.js";
|
|
7
|
+
import { FieldExtensionsContext as m, useFieldExtensions as h } from "./lib/components/metadata-field-configurator/context/field-extensions-context.js";
|
|
8
8
|
import { MetadataFieldConfigurator as g } from "./lib/components/metadata-field-configurator/metadata-field-configurator.js";
|
|
9
9
|
import { t as _ } from "../chunks/metadata-field-list.js";
|
|
10
10
|
import { t as v } from "../chunks/metadata-template-editor.js";
|
|
11
11
|
import { t as y } from "../chunks/metadata-template-editor-modal.js";
|
|
12
12
|
import "./lib/components/metadata-template-editor-modal/index.js";
|
|
13
|
-
export { l as AllOps, a as ApiMetadataTemplateFieldType, s as EnumOperations,
|
|
13
|
+
export { l as AllOps, a as ApiMetadataTemplateFieldType, s as EnumOperations, m as FieldExtensionsContext, r as FieldOperations, e as FieldSelector, t as FieldType, u as FieldTypeDropdown, d as FieldTypeTiles, g as MetadataFieldConfigurator, _ as MetadataFieldList, _ as MetadataFieldListDefault, v as MetadataTemplateEditor, y as MetadataTemplateEditorModal, o as MetadataTemplateEditorMode, c as MultiSelectOperations, n as TaxonomySelection, i as TemplateOperations, p as createDefaultFieldValues, h as useFieldExtensions, f as useTemplateFieldSchema };
|