@box/metadata-editor 2.0.1 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/combobox-with-api-pagination.js +2 -2
- package/dist/chunks/metadata-instance-form-autofill-button.js +1 -1
- package/dist/chunks/update-mode-field-wrapper.js +1 -1
- package/dist/chunks/utils.js +12 -5
- package/dist/esm/lib/components/combobox-with-api-pagination/use-async-list.js +48 -51
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-date-field/metadata-date-field.js +1 -1
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-enum-field/metadata-enum-field.js +1 -1
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-float-field/metadata-float-field.js +1 -1
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-multi-select-field/metadata-multi-select-field.js +1 -1
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-string-field/metadata-string-field.js +1 -1
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/legacy-metadata-taxonomy-field.js +67 -0
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-field.js +15 -66
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-picker-field/metadata-taxonomy-picker-field.js +53 -0
- package/dist/esm/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-picker-field/value-mapping.js +30 -0
- package/dist/esm/lib/components/metadata-editor-fields/editor-field-types.js +5 -5
- package/dist/esm/lib/components/metadata-editor-fields/metadata-editor-field-wrapper.js +122 -118
- package/dist/esm/lib/components/metadata-editor-fields/metadata-editor-fields.js +1 -1
- package/dist/esm/lib/components/metadata-editor-fields/utils.js +2 -2
- package/dist/esm/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/metadata-instance-form.js +67 -63
- package/dist/esm/lib/utils/analytics/analytics-context.js +1 -1
- package/dist/esm/lib/utils/autofill-context.js +1 -1
- package/dist/esm/lib/utils/convertDate.js +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/legacy-metadata-taxonomy-field.d.ts +9 -0
- package/dist/types/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-field.d.ts +7 -0
- package/dist/types/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-picker-field/metadata-taxonomy-picker-field.d.ts +15 -0
- package/dist/types/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/metadata-taxonomy-picker-field/value-mapping.d.ts +28 -0
- package/dist/types/lib/components/metadata-editor-fields/components/metadata-taxonomy-field/types.d.ts +12 -0
- package/dist/types/lib/components/metadata-editor-fields/types.d.ts +9 -1
- package/dist/types/lib/components/metadata-editor-fields/utils.d.ts +8 -0
- package/dist/types/lib/components/metadata-instance-editor/subcomponents/metadata-instance-form/types.d.ts +5 -1
- package/dist/types/lib/test-utils/index.d.ts +1 -0
- package/dist/types/lib/test-utils/taxonomy-items-service.mock.d.ts +7 -0
- package/package.json +13 -11
|
@@ -18,7 +18,7 @@ import '../styles/combobox-with-api-pagination.css';var E = {
|
|
|
18
18
|
option: "_option_5alez_38",
|
|
19
19
|
errorComboboxOption: "_errorComboboxOption_5alez_42",
|
|
20
20
|
errorComboboxOptionText: "_errorComboboxOptionText_5alez_47"
|
|
21
|
-
}, D =
|
|
21
|
+
}, D = /*#__PURE__*/ d(({ onTryAgain: t }, n) => {
|
|
22
22
|
let { formatMessage: r } = _();
|
|
23
23
|
return /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b(a, {
|
|
24
24
|
variant: "error",
|
|
@@ -49,7 +49,7 @@ import '../styles/combobox-with-api-pagination.css';var E = {
|
|
|
49
49
|
boxSizing: "border-box"
|
|
50
50
|
},
|
|
51
51
|
width: T
|
|
52
|
-
}), M =
|
|
52
|
+
}), M = /*#__PURE__*/ d(function(a, s) {
|
|
53
53
|
let { defaultFetcher: l, onInputValueChange: u, value: d, onValueChange: g, noResultMessage: y, defaultValue: x = [], loadingAriaLabel: C, multiselect: w = !1, disabled: T, className: M, displaySingleSelectionAsChip: N = !0, ...P } = a, { formatMessage: F } = _(), I = h(null), L = h(!0), R = t({ async load({ marker: e, searchInput: t, signal: n }) {
|
|
54
54
|
let r = await l({
|
|
55
55
|
signal: n,
|
|
@@ -14,7 +14,7 @@ import '../styles/metadata-instance-form-autofill-button.css';var T = {
|
|
|
14
14
|
loadingIndicator: "_loadingIndicator_zhzu0_1",
|
|
15
15
|
actionMenuItem: "_actionMenuItem_zhzu0_11",
|
|
16
16
|
splitButtonIcon: "_splitButtonIcon_zhzu0_17"
|
|
17
|
-
}, E =
|
|
17
|
+
}, E = /*#__PURE__*/ p(({ isButtonDisabled: t, onAutofill: n, onAgentChange: r, storedAgent: i, icon: o, ...c }, l) => {
|
|
18
18
|
let f = _(), [p, m] = g(i || "standard"), h = (e) => {
|
|
19
19
|
m(e), r(e), setTimeout(() => {
|
|
20
20
|
n(e);
|
|
@@ -67,7 +67,7 @@ import '../styles/update-mode-field-wrapper.css';var h = {
|
|
|
67
67
|
})
|
|
68
68
|
}), g(E) && D && /* @__PURE__ */ l("div", {
|
|
69
69
|
className: h.additionalFieldContainer,
|
|
70
|
-
children:
|
|
70
|
+
children: /*#__PURE__*/ s.cloneElement(D, {
|
|
71
71
|
updateModePrefix: `${y}.updateMode`,
|
|
72
72
|
options: O,
|
|
73
73
|
label: w.formatMessage(n.with)
|
package/dist/chunks/utils.js
CHANGED
|
@@ -26,7 +26,7 @@ function g({ as: e, fieldDescription: t, fieldName: r, labelClassName: i, labelR
|
|
|
26
26
|
let g = u(null), _ = o(g, l);
|
|
27
27
|
return /* @__PURE__ */ f(a, {
|
|
28
28
|
content: s(g) ? /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("div", { children: r }), /* @__PURE__ */ f("div", { children: t })] }) : t,
|
|
29
|
-
children: /* @__PURE__ */ f(d, { render:
|
|
29
|
+
children: /* @__PURE__ */ f(d, { render: /*#__PURE__*/ c(e, {
|
|
30
30
|
className: m(i, n.interactiveTextHint),
|
|
31
31
|
...h,
|
|
32
32
|
ref: _
|
|
@@ -34,7 +34,7 @@ function g({ as: e, fieldDescription: t, fieldName: r, labelClassName: i, labelR
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
function _({ as: e, fieldName: t, labelClassName: n, labelRef: r, ...i }) {
|
|
37
|
-
let l = u(null), p = o(l, r), m = s(l) ? t : void 0, h =
|
|
37
|
+
let l = u(null), p = o(l, r), m = s(l) ? t : void 0, h = /*#__PURE__*/ c(e, {
|
|
38
38
|
className: n,
|
|
39
39
|
...i,
|
|
40
40
|
ref: p
|
|
@@ -44,7 +44,7 @@ function _({ as: e, fieldName: t, labelClassName: n, labelRef: r, ...i }) {
|
|
|
44
44
|
children: /* @__PURE__ */ f(d, { render: h })
|
|
45
45
|
}) : h;
|
|
46
46
|
}
|
|
47
|
-
var v =
|
|
47
|
+
var v = /*#__PURE__*/ l(function({ fieldName: t, fieldDescription: n, isAiSuggestionApplied: a, as: o, confidenceScore: s, labelProps: c }) {
|
|
48
48
|
let { className: l, ref: u, ...d } = c, v = m(l || h.labelText, h.labelTruncated), y = !!s && e(s), b = () => s && y ? /* @__PURE__ */ f(i, {}) : a || s ? /* @__PURE__ */ f(r, { confidenceScore: s }) : null, x = n ? /* @__PURE__ */ f(g, {
|
|
49
49
|
as: o,
|
|
50
50
|
fieldDescription: n,
|
|
@@ -73,7 +73,14 @@ var v = /* @__PURE__ */ l(function({ fieldName: t, fieldDescription: n, isAiSugg
|
|
|
73
73
|
fieldName: e,
|
|
74
74
|
isAiSuggestionApplied: n,
|
|
75
75
|
labelProps: a
|
|
76
|
-
}), b = (e) => {
|
|
76
|
+
}), b = (e, t, n = !1, r) => /* @__PURE__ */ f(v, {
|
|
77
|
+
as: "span",
|
|
78
|
+
confidenceScore: r,
|
|
79
|
+
fieldDescription: t,
|
|
80
|
+
fieldName: e,
|
|
81
|
+
isAiSuggestionApplied: n,
|
|
82
|
+
labelProps: {}
|
|
83
|
+
}), x = (e) => {
|
|
77
84
|
try {
|
|
78
85
|
let n = t(e), r = new Date(n);
|
|
79
86
|
return isNaN(r.getTime()) ? null : n;
|
|
@@ -81,4 +88,4 @@ var v = /* @__PURE__ */ l(function({ fieldName: t, fieldDescription: n, isAiSugg
|
|
|
81
88
|
return null;
|
|
82
89
|
}
|
|
83
90
|
};
|
|
84
|
-
export { b as n,
|
|
91
|
+
export { h as i, b as n, x as r, y as t };
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { RequestStates as e } from "./request.js";
|
|
2
2
|
import { isAbortError as t } from "./utils/is-abort-error.js";
|
|
3
3
|
import { useReducer as n } from "react";
|
|
4
|
-
|
|
5
|
-
return e.LOAD_MORE = "LOAD_MORE", e.RELOAD = "RELOAD", e.SEARCH = "SEARCH", e.SET_ERROR = "SET_ERROR", e.SET_LOADING = "SET_LOADING", e;
|
|
6
|
-
}(r || {});
|
|
7
|
-
function i(t, n) {
|
|
4
|
+
function r(t, n) {
|
|
8
5
|
switch (n.type) {
|
|
9
|
-
case
|
|
6
|
+
case "LOAD_MORE": return {
|
|
10
7
|
...t,
|
|
11
8
|
abortController: n.abortController,
|
|
12
9
|
error: null,
|
|
@@ -14,7 +11,7 @@ function i(t, n) {
|
|
|
14
11
|
marker: n.marker,
|
|
15
12
|
requestState: e.SUCCESS
|
|
16
13
|
};
|
|
17
|
-
case
|
|
14
|
+
case "RELOAD": return n.abortController === t.abortController ? {
|
|
18
15
|
...t,
|
|
19
16
|
abortController: null,
|
|
20
17
|
error: null,
|
|
@@ -23,7 +20,7 @@ function i(t, n) {
|
|
|
23
20
|
requestState: e.SUCCESS,
|
|
24
21
|
searchInput: ""
|
|
25
22
|
} : t;
|
|
26
|
-
case
|
|
23
|
+
case "SEARCH": return {
|
|
27
24
|
...t,
|
|
28
25
|
abortController: n.abortController,
|
|
29
26
|
error: null,
|
|
@@ -32,13 +29,13 @@ function i(t, n) {
|
|
|
32
29
|
requestState: e.SUCCESS,
|
|
33
30
|
searchInput: n.searchInput ?? t.searchInput
|
|
34
31
|
};
|
|
35
|
-
case
|
|
32
|
+
case "SET_ERROR": return {
|
|
36
33
|
...t,
|
|
37
|
-
items:
|
|
34
|
+
items: t.items,
|
|
38
35
|
error: n.error,
|
|
39
36
|
requestState: e.ERROR
|
|
40
37
|
};
|
|
41
|
-
case
|
|
38
|
+
case "SET_LOADING": return {
|
|
42
39
|
...t,
|
|
43
40
|
requestInitiator: n.requestInitiator,
|
|
44
41
|
requestState: e.IN_PROGRESS,
|
|
@@ -47,54 +44,54 @@ function i(t, n) {
|
|
|
47
44
|
default: throw Error(`Invalid action type "${n.type}"`);
|
|
48
45
|
}
|
|
49
46
|
}
|
|
47
|
+
function i(t, n) {
|
|
48
|
+
return t.type === "SEARCH" && n.requestState === e.IN_PROGRESS;
|
|
49
|
+
}
|
|
50
50
|
function a(t, n) {
|
|
51
|
-
return
|
|
51
|
+
return n.requestInitiator === "LOAD_MORE" && n.requestState === e.IN_PROGRESS && t.type === "LOAD_MORE";
|
|
52
52
|
}
|
|
53
|
-
function o(
|
|
54
|
-
return
|
|
53
|
+
function o(e, t) {
|
|
54
|
+
return i(e, t) || a(e, t);
|
|
55
55
|
}
|
|
56
56
|
function s(e, t) {
|
|
57
|
-
|
|
57
|
+
i(e, t) && t.abortController.abort(), a(e, t) && e.abortController?.abort();
|
|
58
58
|
}
|
|
59
59
|
function c(e, t) {
|
|
60
|
-
a(e, t)
|
|
61
|
-
}
|
|
62
|
-
function l(e, t) {
|
|
63
|
-
return o(e, t);
|
|
60
|
+
return a(e, t);
|
|
64
61
|
}
|
|
65
|
-
async function
|
|
66
|
-
let
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
type:
|
|
62
|
+
async function l(e, n, r, i) {
|
|
63
|
+
let a = new AbortController();
|
|
64
|
+
if (o(e, r) && s(e, r), !c(e, r)) {
|
|
65
|
+
i({
|
|
66
|
+
type: "SET_LOADING",
|
|
70
67
|
requestInitiator: e.type,
|
|
71
|
-
abortController:
|
|
68
|
+
abortController: a
|
|
72
69
|
});
|
|
73
70
|
try {
|
|
74
71
|
let t = await n({
|
|
75
|
-
items:
|
|
76
|
-
signal:
|
|
77
|
-
marker: e.type ===
|
|
78
|
-
searchInput: e.searchInput ??
|
|
79
|
-
}),
|
|
80
|
-
|
|
72
|
+
items: r.items.slice(),
|
|
73
|
+
signal: a.signal,
|
|
74
|
+
marker: e.type === "LOAD_MORE" ? r.marker : null,
|
|
75
|
+
searchInput: e.searchInput ?? r.searchInput
|
|
76
|
+
}), o = t.searchInput ?? e.searchInput ?? r.searchInput;
|
|
77
|
+
i({
|
|
81
78
|
type: e.type,
|
|
82
79
|
...t,
|
|
83
|
-
searchInput:
|
|
84
|
-
abortController:
|
|
80
|
+
searchInput: o,
|
|
81
|
+
abortController: a
|
|
85
82
|
});
|
|
86
83
|
} catch (e) {
|
|
87
84
|
if (t(e)) return;
|
|
88
|
-
|
|
89
|
-
type:
|
|
85
|
+
i({
|
|
86
|
+
type: "SET_ERROR",
|
|
90
87
|
error: e,
|
|
91
|
-
abortController:
|
|
88
|
+
abortController: a
|
|
92
89
|
});
|
|
93
90
|
}
|
|
94
91
|
}
|
|
95
92
|
}
|
|
96
|
-
function
|
|
97
|
-
let { load:
|
|
93
|
+
function u(t) {
|
|
94
|
+
let { load: i } = t, [a, o] = n(r, {
|
|
98
95
|
error: null,
|
|
99
96
|
items: [],
|
|
100
97
|
requestInitiator: null,
|
|
@@ -102,20 +99,20 @@ function d(t) {
|
|
|
102
99
|
searchInput: ""
|
|
103
100
|
});
|
|
104
101
|
return {
|
|
105
|
-
hasError:
|
|
106
|
-
hasNextPage:
|
|
107
|
-
isEmpty:
|
|
108
|
-
isLoading:
|
|
109
|
-
isReloading:
|
|
110
|
-
items:
|
|
111
|
-
loadMore: () =>
|
|
112
|
-
reload: () =>
|
|
113
|
-
requestInitiator:
|
|
114
|
-
searchInput:
|
|
115
|
-
search: (e) =>
|
|
116
|
-
type:
|
|
102
|
+
hasError: a.requestState === e.ERROR,
|
|
103
|
+
hasNextPage: a.requestState === e.ERROR ? !1 : a.marker != null,
|
|
104
|
+
isEmpty: a.items.length === 0,
|
|
105
|
+
isLoading: a.requestState === e.IN_PROGRESS,
|
|
106
|
+
isReloading: a.requestState === e.IN_PROGRESS && (a.requestInitiator === "RELOAD" || a.requestInitiator === "SEARCH"),
|
|
107
|
+
items: a.items,
|
|
108
|
+
loadMore: () => l({ type: "LOAD_MORE" }, i, a, o),
|
|
109
|
+
reload: () => l({ type: "RELOAD" }, i, a, o),
|
|
110
|
+
requestInitiator: a.requestInitiator,
|
|
111
|
+
searchInput: a.searchInput,
|
|
112
|
+
search: (e) => l({
|
|
113
|
+
type: "SEARCH",
|
|
117
114
|
searchInput: e
|
|
118
|
-
}, a, o
|
|
115
|
+
}, i, a, o)
|
|
119
116
|
};
|
|
120
117
|
}
|
|
121
|
-
export {
|
|
118
|
+
export { u as useAsyncList };
|
|
@@ -6,7 +6,7 @@ import { forwardRef as o, memo as s, useCallback as c, useMemo as l } from "reac
|
|
|
6
6
|
import { useIntl as u } from "react-intl";
|
|
7
7
|
import { jsx as d } from "react/jsx-runtime";
|
|
8
8
|
import { getIn as f, useFormikContext as p } from "formik";
|
|
9
|
-
var m =
|
|
9
|
+
var m = /*#__PURE__*/ s(a), h = /*#__PURE__*/ o(({ className: a, description: o, isAiSuggestionApplied: s, confidenceScore: h, disableForm: g, fieldNamePrefix: _, label: v, onValueEdited: y, portalElement: b, updateModePrefix: x }, S) => {
|
|
10
10
|
let C = `${x ?? _}.value`, w = u(), { values: T, errors: E, touched: D, setFieldTouched: O, setFieldValue: k } = p(), A = f(T, C), j = l(() => n(A), [A]), M = f(D, C) ? f(E, C) : void 0, N = r(v, o, s, "span", h), P = c((e) => {
|
|
11
11
|
k(C, t(e)), y();
|
|
12
12
|
}, [
|
|
@@ -7,7 +7,7 @@ import { forwardRef as a } from "react";
|
|
|
7
7
|
import { FormattedMessage as o, useIntl as s } from "react-intl";
|
|
8
8
|
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
9
9
|
import { Field as u, getIn as d, useFormikContext as f } from "formik";
|
|
10
|
-
var p =
|
|
10
|
+
var p = /*#__PURE__*/ a(({ className: a, isAiSuggestionApplied: p, confidenceScore: m, description: h, disableForm: g, fieldNamePrefix: _, updateModePrefix: v, label: y, onValueEdited: b, options: x, portalElement: S }, C) => {
|
|
11
11
|
let { setFieldValue: w, values: T } = f(), { formatMessage: E } = s(), D = `${v ?? _}.value`, O = E(t.multipleValues), k = (x || d(T, `${_}.options`, [])).map((e) => typeof e == "string" ? e : e.key), A = E(e.selectValuePlaceholder), j = n(y, h, p, "label", m), M = (e) => e === "Multiple values" ? O : e;
|
|
12
12
|
return /* @__PURE__ */ c("div", {
|
|
13
13
|
"data-testid": `${y}-field`,
|
|
@@ -4,7 +4,7 @@ import { TextInput as n } from "@box/blueprint-web";
|
|
|
4
4
|
import { forwardRef as r, useRef as i } from "react";
|
|
5
5
|
import { jsx as a } from "react/jsx-runtime";
|
|
6
6
|
import { Field as o, getIn as s, useFormikContext as c } from "formik";
|
|
7
|
-
var l =
|
|
7
|
+
var l = /*#__PURE__*/ r(({ className: r, description: l, isAiSuggestionApplied: u, confidenceScore: d, label: f, fieldNamePrefix: p, disableForm: m, onValueEdited: h, updateModePrefix: g }, _) => {
|
|
8
8
|
let { values: v, setFieldValue: y, setFieldTouched: b } = c(), x = `${g ?? p}.value`, S = i(s(v, x)), { validateFloats: C } = t(), w = e(f, l, u, "label", d), T = (e) => {
|
|
9
9
|
S.current = e, y(x, e), h();
|
|
10
10
|
}, E = (e) => {
|
|
@@ -7,7 +7,7 @@ import { forwardRef as i } from "react";
|
|
|
7
7
|
import { useIntl as a } from "react-intl";
|
|
8
8
|
import { jsx as o } from "react/jsx-runtime";
|
|
9
9
|
import { Field as s, getIn as c, useFormikContext as l } from "formik";
|
|
10
|
-
var u =
|
|
10
|
+
var u = /*#__PURE__*/ i(({ className: i, isAiSuggestionApplied: u, confidenceScore: d, description: f, disableForm: p, fieldNamePrefix: m, label: h, onValueEdited: g, options: _, portalElement: v, updateModePrefix: y }, b) => {
|
|
11
11
|
let { setFieldValue: x, values: S } = l(), { formatMessage: C } = a(), w = `${y ?? m}.value`, T = C(t.multipleValues), E = (_ || c(S, `${m}.options`, [])).map((e) => typeof e == "string" ? e : e.key), D = n(h, f, u, "label", d), O = (e, t) => t.toLowerCase().includes(e.toLowerCase());
|
|
12
12
|
return /* @__PURE__ */ o("div", {
|
|
13
13
|
"data-testid": `${h}-field`,
|
|
@@ -5,7 +5,7 @@ import { forwardRef as r } from "react";
|
|
|
5
5
|
import { useIntl as i } from "react-intl";
|
|
6
6
|
import { jsx as a } from "react/jsx-runtime";
|
|
7
7
|
import { Field as o } from "formik";
|
|
8
|
-
var s =
|
|
8
|
+
var s = /*#__PURE__*/ r(({ className: r, description: s, isAiSuggestionApplied: c, confidenceScore: l, disableForm: u, fieldNamePrefix: d, label: f, onValueEdited: p, updateModePrefix: m }, h) => {
|
|
9
9
|
let g = i(), _ = `${m ?? d}.value`, v = t(f, s, c, "label", l);
|
|
10
10
|
return /* @__PURE__ */ a("div", {
|
|
11
11
|
"data-testid": `${f}-field`,
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import e from "../../../../messages.js";
|
|
2
|
+
import "../update-mode-field-wrapper/mulitple-values-utils.js";
|
|
3
|
+
import { messages as t } from "../update-mode-field-wrapper/messages.js";
|
|
4
|
+
import { useMemoizedFieldLabel as n } from "../../hooks/use-memoized-field-label.js";
|
|
5
|
+
import { Tooltip as r } from "@box/blueprint-web";
|
|
6
|
+
import { forwardRef as i, useCallback as a } from "react";
|
|
7
|
+
import { useIntl as o } from "react-intl";
|
|
8
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
9
|
+
import { Field as c, getIn as l, useFormikContext as u } from "formik";
|
|
10
|
+
import { ComboboxWithApiPagination as d, ComboboxWithApiTreeView as f } from "@box/combobox-with-api";
|
|
11
|
+
var p = (e, t) => e === "Multiple values" ? t : e, m = /*#__PURE__*/ i(({ description: i, disableForm: m, isAiSuggestionApplied: h, confidenceScore: g, fieldNamePrefix: _, label: v, onValueEdited: y, portalElement: b, taxonomyOptionsFetcher: x, updateModePrefix: S, className: C, isExternallyOwned: w, isMultilevelTaxonomyFieldEnabled: T }, E) => {
|
|
12
|
+
let { formatMessage: D } = o(), O = `${S ?? _}.value`, { setFieldValue: k, values: A } = u(), { metadata: { templateKey: j, scope: M } } = A, { key: N, optionsRules: { multiSelect: P, selectableLevels: F }, levels: I } = l(A, _), L = D(t.multipleValues), R = T && F?.some((e) => e > 1), z = m || w, B = n(v, i, h, "label", g), V = a((e) => x(M, j, N, F?.[0], e), [
|
|
13
|
+
N,
|
|
14
|
+
M,
|
|
15
|
+
F,
|
|
16
|
+
x,
|
|
17
|
+
j
|
|
18
|
+
]), H = (t) => P || !t?.length ? D(e.taxonomyPlaceholder) : void 0, U = (e) => {
|
|
19
|
+
k(O, e), y();
|
|
20
|
+
}, W = /* @__PURE__ */ s("div", {
|
|
21
|
+
"data-testid": `${v}-field`,
|
|
22
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
23
|
+
role: "presentation",
|
|
24
|
+
children: /* @__PURE__ */ s(c, {
|
|
25
|
+
name: O,
|
|
26
|
+
children: ({ field: e }) => {
|
|
27
|
+
let t = Array.isArray(e.value) ? e.value.map((e) => ({
|
|
28
|
+
...e,
|
|
29
|
+
displayValue: p(e.displayValue, L)
|
|
30
|
+
})) : e.value;
|
|
31
|
+
return R ? /* @__PURE__ */ s(f, {
|
|
32
|
+
ref: E,
|
|
33
|
+
className: C,
|
|
34
|
+
closeOnSelection: R,
|
|
35
|
+
dataTargetId: "ComboboxWithApiTreeView-MetadataEditorTaxonomyField",
|
|
36
|
+
defaultFetcher: V,
|
|
37
|
+
disabled: z,
|
|
38
|
+
label: B,
|
|
39
|
+
levels: I,
|
|
40
|
+
multiselect: P,
|
|
41
|
+
onValueChange: U,
|
|
42
|
+
placeholder: H(e.value),
|
|
43
|
+
portalElement: b,
|
|
44
|
+
selectableLevels: F,
|
|
45
|
+
value: t
|
|
46
|
+
}) : /* @__PURE__ */ s(d, {
|
|
47
|
+
ref: E,
|
|
48
|
+
className: C,
|
|
49
|
+
dataTargetId: "ComboboxWithApiPagination-MetadataEditorTaxonomyField",
|
|
50
|
+
defaultFetcher: V,
|
|
51
|
+
disabled: z,
|
|
52
|
+
label: B,
|
|
53
|
+
multiselect: P,
|
|
54
|
+
onValueChange: U,
|
|
55
|
+
placeholder: H(e.value),
|
|
56
|
+
portalElement: b,
|
|
57
|
+
value: t
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
});
|
|
62
|
+
return w ? /* @__PURE__ */ s(r, {
|
|
63
|
+
content: D(e.taxonomyExternallyOwned),
|
|
64
|
+
children: W
|
|
65
|
+
}) : W;
|
|
66
|
+
});
|
|
67
|
+
export { m as LegacyMetadataTaxonomyField };
|
|
@@ -1,67 +1,16 @@
|
|
|
1
|
-
import e from "
|
|
2
|
-
import "
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
F,
|
|
16
|
-
x,
|
|
17
|
-
j
|
|
18
|
-
]), H = (t) => P || !t?.length ? D(e.taxonomyPlaceholder) : void 0, U = (e) => {
|
|
19
|
-
k(O, e), y();
|
|
20
|
-
}, W = /* @__PURE__ */ s("div", {
|
|
21
|
-
"data-testid": `${v}-field`,
|
|
22
|
-
onKeyDown: (e) => e.stopPropagation(),
|
|
23
|
-
role: "presentation",
|
|
24
|
-
children: /* @__PURE__ */ s(c, {
|
|
25
|
-
name: O,
|
|
26
|
-
children: ({ field: e }) => {
|
|
27
|
-
let t = Array.isArray(e.value) ? e.value.map((e) => ({
|
|
28
|
-
...e,
|
|
29
|
-
displayValue: p(e.displayValue, L)
|
|
30
|
-
})) : e.value;
|
|
31
|
-
return R ? /* @__PURE__ */ s(f, {
|
|
32
|
-
ref: E,
|
|
33
|
-
className: C,
|
|
34
|
-
closeOnSelection: R,
|
|
35
|
-
dataTargetId: "ComboboxWithApiTreeView-MetadataEditorTaxonomyField",
|
|
36
|
-
defaultFetcher: V,
|
|
37
|
-
disabled: z,
|
|
38
|
-
label: B,
|
|
39
|
-
levels: I,
|
|
40
|
-
multiselect: P,
|
|
41
|
-
onValueChange: U,
|
|
42
|
-
placeholder: H(e.value),
|
|
43
|
-
portalElement: b,
|
|
44
|
-
selectableLevels: F,
|
|
45
|
-
value: t
|
|
46
|
-
}) : /* @__PURE__ */ s(d, {
|
|
47
|
-
ref: E,
|
|
48
|
-
className: C,
|
|
49
|
-
dataTargetId: "ComboboxWithApiPagination-MetadataEditorTaxonomyField",
|
|
50
|
-
defaultFetcher: V,
|
|
51
|
-
disabled: z,
|
|
52
|
-
label: B,
|
|
53
|
-
multiselect: P,
|
|
54
|
-
onValueChange: U,
|
|
55
|
-
placeholder: H(e.value),
|
|
56
|
-
portalElement: b,
|
|
57
|
-
value: t
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
})
|
|
61
|
-
});
|
|
62
|
-
return w ? /* @__PURE__ */ s(r, {
|
|
63
|
-
content: D(e.taxonomyExternallyOwned),
|
|
64
|
-
children: W
|
|
65
|
-
}) : W;
|
|
1
|
+
import { LegacyMetadataTaxonomyField as e } from "./legacy-metadata-taxonomy-field.js";
|
|
2
|
+
import { MetadataTaxonomyPickerField as t } from "./metadata-taxonomy-picker-field/metadata-taxonomy-picker-field.js";
|
|
3
|
+
import { forwardRef as n } from "react";
|
|
4
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
5
|
+
var i = /*#__PURE__*/ n((n, i) => {
|
|
6
|
+
let { isTaxonomyPickerEnabled: a, createTaxonomyItemsService: o } = n;
|
|
7
|
+
return a && o ? /* @__PURE__ */ r(t, {
|
|
8
|
+
...n,
|
|
9
|
+
ref: i,
|
|
10
|
+
createTaxonomyItemsService: o
|
|
11
|
+
}) : (a && process.env.NODE_ENV !== "production" && console.error("[metadata-editor] isTaxonomyPickerEnabled is true but createTaxonomyItemsService was not provided; falling back to the legacy taxonomy field."), /* @__PURE__ */ r(e, {
|
|
12
|
+
...n,
|
|
13
|
+
ref: i
|
|
14
|
+
}));
|
|
66
15
|
});
|
|
67
|
-
export {
|
|
16
|
+
export { i as MetadataTaxonomyField };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import e from "../../../../../messages.js";
|
|
2
|
+
import { messages as t } from "../../update-mode-field-wrapper/messages.js";
|
|
3
|
+
import { n } from "../../../../../../../chunks/utils.js";
|
|
4
|
+
import { getTaxonomyPickerMode as r, mapFormValueToTaxonomyValues as i, mapLevelsToTaxonomyLevels as a, mapTaxonomyValuesToFormValue as o } from "./value-mapping.js";
|
|
5
|
+
import { Tooltip as s } from "@box/blueprint-web";
|
|
6
|
+
import { forwardRef as c, useMemo as l } from "react";
|
|
7
|
+
import { useIntl as u } from "react-intl";
|
|
8
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
9
|
+
import { Field as f, getIn as p, useFormikContext as m } from "formik";
|
|
10
|
+
import { MetadataTaxonomyPicker as h } from "@box/metadata-taxonomy-picker";
|
|
11
|
+
var g = /*#__PURE__*/ c(({ description: c, disableForm: g, isAiSuggestionApplied: _, confidenceScore: v, fieldNamePrefix: y, label: b, onValueEdited: x, portalElement: S, updateModePrefix: C, className: w, isExternallyOwned: T, createTaxonomyItemsService: E }, D) => {
|
|
12
|
+
let { formatMessage: O } = u(), k = `${C ?? y}.value`, { setFieldValue: A, values: j } = m(), { metadata: { templateKey: M, scope: N } } = j, { key: P, optionsRules: { multiSelect: F, selectableLevels: I }, levels: L } = p(j, y), R = O(t.multipleValues), z = g || T, B = l(() => E({
|
|
13
|
+
scope: N,
|
|
14
|
+
templateKey: M,
|
|
15
|
+
fieldKey: P
|
|
16
|
+
}), [
|
|
17
|
+
E,
|
|
18
|
+
N,
|
|
19
|
+
M,
|
|
20
|
+
P
|
|
21
|
+
]), V = r(I), H = l(() => a(L, I), [L, I]), U = n(b, c ?? void 0, _, v), W = (t) => F || !t.length ? O(e.taxonomyPlaceholder) : void 0, G = (e) => {
|
|
22
|
+
A(k, o(e)), x();
|
|
23
|
+
}, K = /* @__PURE__ */ d("div", {
|
|
24
|
+
"data-testid": `${b}-field`,
|
|
25
|
+
onKeyDown: (e) => e.stopPropagation(),
|
|
26
|
+
role: "presentation",
|
|
27
|
+
children: /* @__PURE__ */ d(f, {
|
|
28
|
+
name: k,
|
|
29
|
+
children: ({ field: e }) => {
|
|
30
|
+
let t = i(e.value, R);
|
|
31
|
+
return /* @__PURE__ */ d(h, {
|
|
32
|
+
ref: D,
|
|
33
|
+
containerClassName: w,
|
|
34
|
+
disabled: z,
|
|
35
|
+
itemsService: B,
|
|
36
|
+
label: U,
|
|
37
|
+
levels: H,
|
|
38
|
+
mode: V,
|
|
39
|
+
multiSelect: F,
|
|
40
|
+
onValueChange: G,
|
|
41
|
+
placeholder: W(t),
|
|
42
|
+
portalElement: S,
|
|
43
|
+
value: t
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
});
|
|
48
|
+
return T ? /* @__PURE__ */ d(s, {
|
|
49
|
+
content: O(e.taxonomyExternallyOwned),
|
|
50
|
+
children: K
|
|
51
|
+
}) : K;
|
|
52
|
+
});
|
|
53
|
+
export { g as MetadataTaxonomyPickerField };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import "../../update-mode-field-wrapper/mulitple-values-utils.js";
|
|
2
|
+
import { TaxonomyPickerMode as e } from "@box/metadata-taxonomy-picker";
|
|
3
|
+
function t(e, t) {
|
|
4
|
+
return Array.isArray(e) ? e.map((e) => ({
|
|
5
|
+
id: e.value,
|
|
6
|
+
displayName: e.value === "Multiple values" ? t : e.displayValue ?? "",
|
|
7
|
+
level: e.level,
|
|
8
|
+
ancestors: e.ancestors
|
|
9
|
+
})) : [];
|
|
10
|
+
}
|
|
11
|
+
function n(e) {
|
|
12
|
+
return e.map((e) => ({
|
|
13
|
+
value: e.id,
|
|
14
|
+
displayValue: e.displayName,
|
|
15
|
+
level: e.level,
|
|
16
|
+
selectable: !0,
|
|
17
|
+
ancestors: e.ancestors
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
function r(t) {
|
|
21
|
+
return t && t.length > 1 ? e.MultiLevel : e.SingleLevel;
|
|
22
|
+
}
|
|
23
|
+
function i(e, t) {
|
|
24
|
+
return e?.map((e) => ({
|
|
25
|
+
level: e.level,
|
|
26
|
+
displayName: e.displayName,
|
|
27
|
+
selectable: !!t?.includes(e.level)
|
|
28
|
+
})) ?? [];
|
|
29
|
+
}
|
|
30
|
+
export { r as getTaxonomyPickerMode, t as mapFormValueToTaxonomyValues, i as mapLevelsToTaxonomyLevels, n as mapTaxonomyValuesToFormValue };
|
|
@@ -7,23 +7,23 @@ import { MetadataTaxonomyField as a } from "./components/metadata-taxonomy-field
|
|
|
7
7
|
import { forwardRef as o } from "react";
|
|
8
8
|
import { jsx as s } from "react/jsx-runtime";
|
|
9
9
|
var c = {
|
|
10
|
-
date:
|
|
10
|
+
date: /*#__PURE__*/ o((t, n) => /* @__PURE__ */ s(e, {
|
|
11
11
|
...t,
|
|
12
12
|
ref: n
|
|
13
13
|
})),
|
|
14
|
-
enum:
|
|
14
|
+
enum: /*#__PURE__*/ o((e, n) => /* @__PURE__ */ s(t, {
|
|
15
15
|
...e,
|
|
16
16
|
ref: n
|
|
17
17
|
})),
|
|
18
|
-
float:
|
|
18
|
+
float: /*#__PURE__*/ o((e, t) => /* @__PURE__ */ s(n, {
|
|
19
19
|
...e,
|
|
20
20
|
ref: t
|
|
21
21
|
})),
|
|
22
|
-
multiSelect:
|
|
22
|
+
multiSelect: /*#__PURE__*/ o((e, t) => /* @__PURE__ */ s(r, {
|
|
23
23
|
...e,
|
|
24
24
|
ref: t
|
|
25
25
|
})),
|
|
26
|
-
string:
|
|
26
|
+
string: /*#__PURE__*/ o((e, t) => /* @__PURE__ */ s(i, {
|
|
27
27
|
...e,
|
|
28
28
|
ref: t
|
|
29
29
|
})),
|