@box/metadata-editor 0.61.0 → 0.61.2
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/chunks/metadata-editor-field-wrapper.js +34 -32
- package/esm/lib/components/combobox-with-api-pagination/use-async-list.js +60 -48
- package/esm/lib/components/metadata-editor-fields/components/metadata-date-field/metadata-date-field.js +33 -32
- package/esm/lib/components/metadata-editor-fields/components/metadata-enum-field/metadata-enum-field.js +27 -25
- package/esm/lib/components/metadata-editor-fields/components/metadata-float-field/metadata-float-field.js +26 -25
- package/esm/lib/components/metadata-editor-fields/components/metadata-multi-select-field/metadata-multi-select-field.js +33 -31
- package/esm/lib/components/metadata-editor-fields/components/metadata-string-field/metadata-string-field.js +32 -30
- package/esm/lib/components/metadata-editor-fields/editor-field-types.js +28 -22
- package/esm/lib/components/metadata-editor-fields/metadata-editor-fields.js +27 -22
- package/package.json +2 -2
- package/types/lib/components/metadata-editor-fields/components/metadata-date-field/metadata-date-field.d.ts +1 -1
- package/types/lib/components/metadata-editor-fields/components/metadata-enum-field/metadata-enum-field.d.ts +1 -1
- package/types/lib/components/metadata-editor-fields/components/metadata-float-field/metadata-float-field.d.ts +1 -1
- package/types/lib/components/metadata-editor-fields/components/metadata-multi-select-field/metadata-multi-select-field.d.ts +1 -1
- package/types/lib/components/metadata-editor-fields/components/metadata-string-field/metadata-string-field.d.ts +1 -4
- package/types/lib/components/metadata-editor-fields/editor-field-types.d.ts +5 -5
- package/types/lib/components/metadata-editor-fields/metadata-editor-field-wrapper.d.ts +4 -2
- package/types/lib/test-utils/sample-data.d.ts +2 -1
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
import "../styles/metadata-editor-field-wrapper.css";
|
|
2
|
-
import
|
|
3
|
-
import { useFormikContext as
|
|
4
|
-
import
|
|
5
|
-
import { useState as
|
|
6
|
-
import { AiSuggestionField as
|
|
7
|
-
import { UpdateModeFieldWrapper as
|
|
8
|
-
import { editorFieldTypes as
|
|
9
|
-
import { jsx as o, jsxs as
|
|
10
|
-
const
|
|
11
|
-
noAttributesText:
|
|
12
|
-
fieldWrapper:
|
|
13
|
-
hasSuggestion:
|
|
14
|
-
error:
|
|
15
|
-
dateField:
|
|
16
|
-
},
|
|
2
|
+
import y from "clsx";
|
|
3
|
+
import { useFormikContext as F } from "formik";
|
|
4
|
+
import h from "lodash/isUndefined";
|
|
5
|
+
import { forwardRef as A, useState as W } from "react";
|
|
6
|
+
import { AiSuggestionField as M } from "../esm/lib/components/metadata-editor-fields/components/ai-suggestion-field/ai-suggestion-field.js";
|
|
7
|
+
import { UpdateModeFieldWrapper as N } from "../esm/lib/components/metadata-editor-fields/components/update-mode-field-wrapper/update-mode-field-wrapper.js";
|
|
8
|
+
import { editorFieldTypes as q } from "../esm/lib/components/metadata-editor-fields/editor-field-types.js";
|
|
9
|
+
import { jsx as o, jsxs as T } from "react/jsx-runtime";
|
|
10
|
+
const b = "_noAttributesText_1xlmq_1", v = "_fieldWrapper_1xlmq_5", P = "_hasSuggestion_1xlmq_5", $ = "_error_1xlmq_13", k = "_dateField_1xlmq_25", a = {
|
|
11
|
+
noAttributesText: b,
|
|
12
|
+
fieldWrapper: v,
|
|
13
|
+
hasSuggestion: P,
|
|
14
|
+
error: $,
|
|
15
|
+
dateField: k
|
|
16
|
+
}, B = /* @__PURE__ */ A(({
|
|
17
17
|
disableForm: n,
|
|
18
18
|
portalElement: p,
|
|
19
19
|
field: e,
|
|
20
20
|
index: d
|
|
21
|
-
}) => {
|
|
21
|
+
}, l) => {
|
|
22
22
|
const {
|
|
23
|
-
setFieldValue:
|
|
24
|
-
} =
|
|
25
|
-
if (!
|
|
23
|
+
setFieldValue: m
|
|
24
|
+
} = F(), [c, i] = W(!0), r = q[e.type], g = r && !e.hidden, f = !h(e.updateMode), s = `metadata.fields[${d}]`;
|
|
25
|
+
if (!g)
|
|
26
26
|
return null;
|
|
27
|
-
if (
|
|
28
|
-
return /* @__PURE__ */ o(
|
|
27
|
+
if (f)
|
|
28
|
+
return /* @__PURE__ */ o(N, {
|
|
29
29
|
fieldNamePrefix: s,
|
|
30
30
|
fieldType: e.type,
|
|
31
31
|
children: /* @__PURE__ */ o(r, {
|
|
32
|
+
ref: l,
|
|
32
33
|
description: e.description,
|
|
33
34
|
disableForm: n,
|
|
34
35
|
fieldNamePrefix: s,
|
|
@@ -39,13 +40,14 @@ const q = "_noAttributesText_1xlmq_1", T = "_fieldWrapper_1xlmq_5", b = "_hasSug
|
|
|
39
40
|
const {
|
|
40
41
|
aiSuggestion: t,
|
|
41
42
|
type: _,
|
|
42
|
-
value:
|
|
43
|
-
} = e,
|
|
44
|
-
return /* @__PURE__ */
|
|
43
|
+
value: x
|
|
44
|
+
} = e, u = t && c;
|
|
45
|
+
return /* @__PURE__ */ T("div", {
|
|
45
46
|
className: a.fieldWrapper,
|
|
46
47
|
children: [/* @__PURE__ */ o(r, {
|
|
47
|
-
|
|
48
|
-
|
|
48
|
+
ref: l,
|
|
49
|
+
className: y({
|
|
50
|
+
[a.hasSuggestions]: u,
|
|
49
51
|
[a.dateField]: e.type === "date"
|
|
50
52
|
}),
|
|
51
53
|
description: e.description,
|
|
@@ -53,21 +55,21 @@ const q = "_noAttributesText_1xlmq_1", T = "_fieldWrapper_1xlmq_5", b = "_hasSug
|
|
|
53
55
|
fieldNamePrefix: `metadata.fields[${d}]`,
|
|
54
56
|
label: e.displayName,
|
|
55
57
|
portalElement: p
|
|
56
|
-
}),
|
|
58
|
+
}), u && /* @__PURE__ */ o(M, {
|
|
57
59
|
aiSuggestion: t,
|
|
58
60
|
onAiSuggestionAppend: () => {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
+
const S = e.type === "multiSelect" ? [x, t].flat() : t;
|
|
62
|
+
m(`${s}.value`, S), i(!1);
|
|
61
63
|
},
|
|
62
64
|
onAiSuggestionIgnore: () => i(!1),
|
|
63
65
|
onAiSuggestionReplace: () => {
|
|
64
|
-
|
|
66
|
+
m(`${s}.value`, t), i(!1);
|
|
65
67
|
},
|
|
66
68
|
type: _
|
|
67
69
|
})]
|
|
68
70
|
}, e.key);
|
|
69
|
-
};
|
|
71
|
+
});
|
|
70
72
|
export {
|
|
71
|
-
|
|
73
|
+
B as M,
|
|
72
74
|
a as s
|
|
73
75
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useReducer as
|
|
1
|
+
import { useReducer as i } from "react";
|
|
2
2
|
import { RequestStates as u } from "./request.js";
|
|
3
3
|
var s = /* @__PURE__ */ function(r) {
|
|
4
4
|
return r.LOAD_MORE = "LOAD_MORE", r.RELOAD = "RELOAD", r.SEARCH = "SEARCH", r.SET_ERROR = "SET_ERROR", r.SET_LOADING = "SET_LOADING", r;
|
|
5
5
|
}(s || {});
|
|
6
|
-
function
|
|
6
|
+
function I(r, e) {
|
|
7
7
|
switch (e.type) {
|
|
8
8
|
case s.LOAD_MORE:
|
|
9
9
|
return {
|
|
@@ -52,50 +52,64 @@ function i(r, e) {
|
|
|
52
52
|
throw new Error(`Invalid action type "${e.type}"`);
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
55
|
+
function E(r, e) {
|
|
56
|
+
return r.type === s.SEARCH && e.requestState === u.IN_PROGRESS;
|
|
57
|
+
}
|
|
58
|
+
function S(r, e) {
|
|
59
|
+
return e.requestInitiator === s.LOAD_MORE && e.requestState === u.IN_PROGRESS && r.type === s.LOAD_MORE;
|
|
60
|
+
}
|
|
61
|
+
function a(r, e) {
|
|
62
|
+
return E(r, e) || S(r, e);
|
|
63
|
+
}
|
|
64
|
+
function m(r, e) {
|
|
65
|
+
var t;
|
|
66
|
+
E(r, e) && e.abortController.abort(), S(r, e) && ((t = r.abortController) == null || t.abort());
|
|
67
|
+
}
|
|
68
|
+
function p(r, e) {
|
|
69
|
+
return S(r, e);
|
|
70
|
+
}
|
|
71
|
+
async function R(r, e, t, n) {
|
|
72
|
+
const l = new AbortController();
|
|
73
|
+
if (a(r, t) && m(r, t), !p(r, t)) {
|
|
74
|
+
n({
|
|
75
|
+
type: s.SET_LOADING,
|
|
76
|
+
requestInitiator: r.type,
|
|
77
|
+
abortController: l
|
|
78
|
+
});
|
|
67
79
|
try {
|
|
68
|
-
|
|
69
|
-
(E = o.abortController) == null || E.abort();
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
l({
|
|
73
|
-
type: s.SET_LOADING,
|
|
74
|
-
requestInitiator: o.type,
|
|
75
|
-
abortController: R
|
|
76
|
-
});
|
|
77
|
-
const n = await S({
|
|
80
|
+
const o = await e({
|
|
78
81
|
items: t.items.slice(),
|
|
79
|
-
signal:
|
|
80
|
-
marker:
|
|
81
|
-
searchInput:
|
|
82
|
-
}), O =
|
|
83
|
-
|
|
84
|
-
type:
|
|
85
|
-
...
|
|
82
|
+
signal: l.signal,
|
|
83
|
+
marker: r.type === s.LOAD_MORE ? t.marker : null,
|
|
84
|
+
searchInput: r.searchInput ?? t.searchInput
|
|
85
|
+
}), O = o.searchInput ?? r.searchInput ?? t.searchInput;
|
|
86
|
+
n({
|
|
87
|
+
type: r.type,
|
|
88
|
+
...o,
|
|
86
89
|
searchInput: O,
|
|
87
|
-
abortController:
|
|
90
|
+
abortController: l
|
|
88
91
|
});
|
|
89
|
-
} catch (
|
|
90
|
-
if ((
|
|
92
|
+
} catch (o) {
|
|
93
|
+
if ((o == null ? void 0 : o.name) === "AbortError")
|
|
91
94
|
return;
|
|
92
|
-
|
|
95
|
+
n({
|
|
93
96
|
type: s.SET_ERROR,
|
|
94
|
-
error:
|
|
95
|
-
abortController:
|
|
97
|
+
error: o,
|
|
98
|
+
abortController: l
|
|
96
99
|
});
|
|
97
100
|
}
|
|
98
|
-
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function C(r) {
|
|
104
|
+
const {
|
|
105
|
+
load: e
|
|
106
|
+
} = r, [t, n] = i(I, {
|
|
107
|
+
error: null,
|
|
108
|
+
items: [],
|
|
109
|
+
requestInitiator: null,
|
|
110
|
+
requestState: u.NOT_STARTED,
|
|
111
|
+
searchInput: ""
|
|
112
|
+
});
|
|
99
113
|
return {
|
|
100
114
|
hasError: t.requestState === u.ERROR,
|
|
101
115
|
hasNextPage: t.requestState === u.ERROR ? !1 : t.marker != null,
|
|
@@ -103,20 +117,18 @@ function C(r) {
|
|
|
103
117
|
isLoading: t.requestState === u.IN_PROGRESS,
|
|
104
118
|
isReloading: t.requestState === u.IN_PROGRESS && (t.requestInitiator === s.RELOAD || t.requestInitiator === s.SEARCH),
|
|
105
119
|
items: t.items,
|
|
106
|
-
loadMore: () =>
|
|
120
|
+
loadMore: () => R({
|
|
107
121
|
type: s.LOAD_MORE
|
|
108
|
-
}, e),
|
|
109
|
-
reload: () => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}, e);
|
|
113
|
-
},
|
|
122
|
+
}, e, t, n),
|
|
123
|
+
reload: () => R({
|
|
124
|
+
type: s.RELOAD
|
|
125
|
+
}, e, t, n),
|
|
114
126
|
requestInitiator: t.requestInitiator,
|
|
115
127
|
searchInput: t.searchInput,
|
|
116
|
-
search: (
|
|
128
|
+
search: (l) => R({
|
|
117
129
|
type: s.SEARCH,
|
|
118
|
-
searchInput:
|
|
119
|
-
}, e)
|
|
130
|
+
searchInput: l
|
|
131
|
+
}, e, t, n)
|
|
120
132
|
};
|
|
121
133
|
}
|
|
122
134
|
export {
|
|
@@ -1,71 +1,72 @@
|
|
|
1
|
-
import { DateI18nProvider as
|
|
2
|
-
import { useFormikContext as
|
|
3
|
-
import { useMemo as
|
|
4
|
-
import { useIntl as
|
|
5
|
-
import { convertToDatePickerValue as
|
|
6
|
-
import { useDateInternationalization as
|
|
1
|
+
import { DateI18nProvider as P, DatePicker as F } from "@box/blueprint-web";
|
|
2
|
+
import { useFormikContext as V, getIn as b, Field as A } from "formik";
|
|
3
|
+
import { forwardRef as C, useMemo as I } from "react";
|
|
4
|
+
import { useIntl as L } from "react-intl";
|
|
5
|
+
import { convertToDatePickerValue as w, convertToFormikValue as N } from "./date-conversion-utils.js";
|
|
6
|
+
import { useDateInternationalization as z } from "./use-date-internationalization.js";
|
|
7
7
|
import a from "../../../../messages.js";
|
|
8
|
-
import
|
|
8
|
+
import B from "../../../interactive-text/interactive-text.js";
|
|
9
9
|
import { jsx as o } from "react/jsx-runtime";
|
|
10
|
-
const
|
|
10
|
+
const H = /* @__PURE__ */ C(({
|
|
11
11
|
description: s,
|
|
12
12
|
disableForm: m,
|
|
13
13
|
fieldNamePrefix: d,
|
|
14
14
|
label: r,
|
|
15
15
|
portalElement: f,
|
|
16
16
|
className: u
|
|
17
|
-
}) => {
|
|
18
|
-
const t = `${d}.value`, e =
|
|
19
|
-
values:
|
|
20
|
-
setFieldTouched:
|
|
21
|
-
setFieldValue:
|
|
22
|
-
} =
|
|
23
|
-
localTimezone:
|
|
24
|
-
} =
|
|
17
|
+
}, h) => {
|
|
18
|
+
const t = `${d}.value`, e = L(), {
|
|
19
|
+
values: p,
|
|
20
|
+
setFieldTouched: D,
|
|
21
|
+
setFieldValue: M
|
|
22
|
+
} = V(), {
|
|
23
|
+
localTimezone: g
|
|
24
|
+
} = z(e.locale), c = b(p, t), k = I(() => w(c), [c]), v = {
|
|
25
25
|
clearDatePickerAriaLabel: e.formatMessage(a.clearSelectedDate),
|
|
26
26
|
nextMonthAriaLabel: e.formatMessage(a.switchToNextMonth),
|
|
27
27
|
openCalendarDropdownAriaLabel: e.formatMessage(a.openCalendar),
|
|
28
28
|
previousMonthAriaLabel: e.formatMessage(a.switchToNextMonth)
|
|
29
|
-
},
|
|
30
|
-
const l =
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
|
|
29
|
+
}, x = (n) => {
|
|
30
|
+
const l = N(n, g);
|
|
31
|
+
M(t, l);
|
|
32
|
+
}, T = () => {
|
|
33
|
+
D(t, !0);
|
|
34
34
|
};
|
|
35
35
|
return /* @__PURE__ */ o("div", {
|
|
36
36
|
"data-testid": `${r}-field`,
|
|
37
|
-
children: /* @__PURE__ */ o(
|
|
37
|
+
children: /* @__PURE__ */ o(P, {
|
|
38
38
|
locale: e.locale,
|
|
39
|
-
children: /* @__PURE__ */ o(
|
|
39
|
+
children: /* @__PURE__ */ o(A, {
|
|
40
40
|
name: t,
|
|
41
41
|
children: ({
|
|
42
42
|
field: n,
|
|
43
43
|
meta: l
|
|
44
|
-
}) => /* @__PURE__ */ o(
|
|
44
|
+
}) => /* @__PURE__ */ o(F, {
|
|
45
45
|
...n,
|
|
46
|
-
...
|
|
46
|
+
...v,
|
|
47
|
+
ref: h,
|
|
47
48
|
calendarAriaLabel: e.formatMessage(a.selectDate),
|
|
48
49
|
className: u,
|
|
49
50
|
error: l.error,
|
|
50
51
|
isDisabled: m,
|
|
51
52
|
label: s ? ({
|
|
52
53
|
...i
|
|
53
|
-
}) =>
|
|
54
|
+
}) => B({
|
|
54
55
|
as: "span",
|
|
55
56
|
tooltipText: s,
|
|
56
57
|
children: r,
|
|
57
58
|
...i
|
|
58
59
|
}) : r,
|
|
59
|
-
onBlur: () =>
|
|
60
|
-
onChange: (i) =>
|
|
60
|
+
onBlur: () => T(),
|
|
61
|
+
onChange: (i) => x(i),
|
|
61
62
|
portalElement: f,
|
|
62
|
-
value:
|
|
63
|
+
value: k
|
|
63
64
|
})
|
|
64
65
|
})
|
|
65
66
|
})
|
|
66
67
|
});
|
|
67
|
-
};
|
|
68
|
+
});
|
|
68
69
|
export {
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
H as MetadataDateField,
|
|
71
|
+
H as default
|
|
71
72
|
};
|
|
@@ -1,54 +1,56 @@
|
|
|
1
1
|
import { Select as l, SELECT_EMPTY_VALUE as s } from "@box/blueprint-web";
|
|
2
|
-
import { useFormikContext as
|
|
3
|
-
import { useIntl as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
2
|
+
import { useFormikContext as F, getIn as M, Field as V } from "formik";
|
|
3
|
+
import { useIntl as C, FormattedMessage as T } from "react-intl";
|
|
4
|
+
import { forwardRef as I } from "react";
|
|
5
|
+
import u from "../../../../messages.js";
|
|
6
|
+
import $ from "../../../interactive-text/interactive-text.js";
|
|
7
|
+
import { jsx as t, jsxs as j } from "react/jsx-runtime";
|
|
8
|
+
const R = /* @__PURE__ */ I(({
|
|
8
9
|
className: i,
|
|
9
10
|
description: n,
|
|
10
11
|
disableForm: h,
|
|
11
|
-
fieldNamePrefix:
|
|
12
|
+
fieldNamePrefix: m,
|
|
12
13
|
label: r,
|
|
13
14
|
options: v,
|
|
14
|
-
portalElement:
|
|
15
|
-
}) => {
|
|
15
|
+
portalElement: f
|
|
16
|
+
}, p) => {
|
|
16
17
|
const {
|
|
17
18
|
setFieldValue: x,
|
|
18
|
-
values:
|
|
19
|
-
} =
|
|
19
|
+
values: g
|
|
20
|
+
} = F(), E = C(), c = `${m}.value`, o = v || M(g, `${m}.options`, []).map(({
|
|
20
21
|
key: a
|
|
21
|
-
}) => a),
|
|
22
|
+
}) => a), d = E.formatMessage(u.selectValuePlaceholder);
|
|
22
23
|
return /* @__PURE__ */ t("div", {
|
|
23
24
|
"data-testid": `${r}-field`,
|
|
24
|
-
children: /* @__PURE__ */ t(
|
|
25
|
-
name:
|
|
25
|
+
children: /* @__PURE__ */ t(V, {
|
|
26
|
+
name: c,
|
|
26
27
|
children: ({
|
|
27
28
|
field: a
|
|
28
29
|
}) => /* @__PURE__ */ t(l, {
|
|
30
|
+
ref: p,
|
|
29
31
|
className: i,
|
|
30
32
|
disabled: h,
|
|
31
33
|
label: n ? ({
|
|
32
34
|
...e
|
|
33
|
-
}) =>
|
|
35
|
+
}) => $({
|
|
34
36
|
as: "label",
|
|
35
37
|
tooltipText: n,
|
|
36
38
|
children: r,
|
|
37
39
|
...e
|
|
38
40
|
}) : r,
|
|
39
41
|
onValueChange: (e) => {
|
|
40
|
-
x(
|
|
42
|
+
x(c, e === s ? "" : e);
|
|
41
43
|
},
|
|
42
|
-
placeholder:
|
|
44
|
+
placeholder: d,
|
|
43
45
|
...a,
|
|
44
46
|
value: a.value === s ? "" : a.value,
|
|
45
|
-
children: /* @__PURE__ */
|
|
46
|
-
container:
|
|
47
|
+
children: /* @__PURE__ */ j(l.Content, {
|
|
48
|
+
container: f,
|
|
47
49
|
children: [/* @__PURE__ */ t(l.Option, {
|
|
48
|
-
text:
|
|
50
|
+
text: d,
|
|
49
51
|
value: s,
|
|
50
|
-
children: /* @__PURE__ */ t(
|
|
51
|
-
...
|
|
52
|
+
children: /* @__PURE__ */ t(T, {
|
|
53
|
+
...u.selectValuePlaceholder
|
|
52
54
|
})
|
|
53
55
|
}), o == null ? void 0 : o.map((e) => /* @__PURE__ */ t(l.Option, {
|
|
54
56
|
text: e,
|
|
@@ -59,8 +61,8 @@ const A = ({
|
|
|
59
61
|
})
|
|
60
62
|
})
|
|
61
63
|
});
|
|
62
|
-
};
|
|
64
|
+
});
|
|
63
65
|
export {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
+
R as MetadataEnumField,
|
|
67
|
+
R as default
|
|
66
68
|
};
|
|
@@ -1,59 +1,60 @@
|
|
|
1
|
-
import { TextInput as
|
|
2
|
-
import { useFormikContext as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import
|
|
5
|
-
import { fieldDefaultProps as
|
|
6
|
-
import { useFloatValidation as
|
|
1
|
+
import { TextInput as T } from "@box/blueprint-web";
|
|
2
|
+
import { useFormikContext as g, getIn as C, Field as I } from "formik";
|
|
3
|
+
import { forwardRef as R, useRef as V } from "react";
|
|
4
|
+
import $ from "../../../interactive-text/interactive-text.js";
|
|
5
|
+
import { fieldDefaultProps as b } from "../constants.js";
|
|
6
|
+
import { useFloatValidation as B } from "./use-float-validation.js";
|
|
7
7
|
import { jsx as a } from "react/jsx-runtime";
|
|
8
|
-
const
|
|
8
|
+
const N = /* @__PURE__ */ R(({
|
|
9
9
|
className: i,
|
|
10
10
|
description: l,
|
|
11
11
|
label: r,
|
|
12
12
|
fieldNamePrefix: d,
|
|
13
13
|
disableForm: s
|
|
14
|
-
}) => {
|
|
14
|
+
}, u) => {
|
|
15
15
|
const {
|
|
16
|
-
values:
|
|
16
|
+
values: f,
|
|
17
17
|
setFieldValue: m,
|
|
18
18
|
setFieldTouched: c
|
|
19
|
-
} =
|
|
20
|
-
validateFloats:
|
|
21
|
-
} =
|
|
19
|
+
} = g(), t = `${d}.value`, p = C(f, t), n = V(p), {
|
|
20
|
+
validateFloats: h
|
|
21
|
+
} = B(), F = (e) => {
|
|
22
22
|
n.current = e, m(t, e);
|
|
23
|
-
},
|
|
23
|
+
}, v = (e) => {
|
|
24
24
|
c(e, !0);
|
|
25
25
|
};
|
|
26
26
|
return /* @__PURE__ */ a("div", {
|
|
27
27
|
"data-testid": `${r}-field`,
|
|
28
|
-
children: /* @__PURE__ */ a(
|
|
28
|
+
children: /* @__PURE__ */ a(I, {
|
|
29
29
|
name: `${t}`,
|
|
30
|
-
validate: () =>
|
|
30
|
+
validate: () => h(n.current),
|
|
31
31
|
children: ({
|
|
32
32
|
field: e,
|
|
33
|
-
meta:
|
|
34
|
-
}) => /* @__PURE__ */ a(
|
|
35
|
-
|
|
33
|
+
meta: x
|
|
34
|
+
}) => /* @__PURE__ */ a(T, {
|
|
35
|
+
...b,
|
|
36
36
|
...e,
|
|
37
|
+
ref: u,
|
|
37
38
|
className: i,
|
|
38
39
|
disabled: s,
|
|
39
|
-
error:
|
|
40
|
+
error: x.error,
|
|
40
41
|
label: l ? ({
|
|
41
42
|
...o
|
|
42
|
-
}) =>
|
|
43
|
+
}) => $({
|
|
43
44
|
as: "label",
|
|
44
45
|
tooltipText: l,
|
|
45
46
|
children: r,
|
|
46
47
|
...o
|
|
47
48
|
}) : r,
|
|
48
|
-
onBlur: () =>
|
|
49
|
-
onChange: (o) =>
|
|
49
|
+
onBlur: () => v(t),
|
|
50
|
+
onChange: (o) => F(o.currentTarget.value),
|
|
50
51
|
placeholder: "0",
|
|
51
52
|
type: "number"
|
|
52
53
|
})
|
|
53
54
|
})
|
|
54
55
|
});
|
|
55
|
-
};
|
|
56
|
+
});
|
|
56
57
|
export {
|
|
57
|
-
|
|
58
|
-
|
|
58
|
+
N as MetadataFloatField,
|
|
59
|
+
N as default
|
|
59
60
|
};
|
|
@@ -1,62 +1,64 @@
|
|
|
1
|
-
import { TooltipProvider as
|
|
2
|
-
import { useFormikContext as
|
|
1
|
+
import { TooltipProvider as g, Combobox as x } from "@box/blueprint-web";
|
|
2
|
+
import { useFormikContext as C, getIn as b, Field as w } from "formik";
|
|
3
3
|
import { useIntl as I } from "react-intl";
|
|
4
|
-
import M from "
|
|
5
|
-
import T from "
|
|
6
|
-
import
|
|
4
|
+
import { forwardRef as M } from "react";
|
|
5
|
+
import T from "../../../../messages.js";
|
|
6
|
+
import $ from "../../../interactive-text/interactive-text.js";
|
|
7
|
+
import { fieldDefaultProps as L } from "../constants.js";
|
|
7
8
|
import { jsx as o } from "react/jsx-runtime";
|
|
8
|
-
const
|
|
9
|
+
const q = /* @__PURE__ */ M(({
|
|
9
10
|
className: s,
|
|
10
11
|
description: a,
|
|
11
12
|
disableForm: m,
|
|
12
13
|
fieldNamePrefix: i,
|
|
13
|
-
label:
|
|
14
|
-
portalElement:
|
|
15
|
-
options:
|
|
16
|
-
}) => {
|
|
14
|
+
label: r,
|
|
15
|
+
portalElement: d,
|
|
16
|
+
options: u
|
|
17
|
+
}, p) => {
|
|
17
18
|
const {
|
|
18
19
|
setFieldValue: c,
|
|
19
|
-
values:
|
|
20
|
-
} =
|
|
20
|
+
values: f
|
|
21
|
+
} = C(), h = I(), n = `${i}.value`, v = u || b(f, `${i}.options`, []).map(({
|
|
21
22
|
key: e
|
|
22
|
-
}) => e),
|
|
23
|
+
}) => e), F = (e, t) => t.toLowerCase().includes(e.toLowerCase());
|
|
23
24
|
return /* @__PURE__ */ o("div", {
|
|
24
|
-
"data-testid": `${
|
|
25
|
-
children: /* @__PURE__ */ o(
|
|
25
|
+
"data-testid": `${r}-field`,
|
|
26
|
+
children: /* @__PURE__ */ o(w, {
|
|
26
27
|
name: n,
|
|
27
28
|
children: ({
|
|
28
29
|
field: e
|
|
29
30
|
}) => {
|
|
30
31
|
var t;
|
|
31
|
-
return /* @__PURE__ */ o(
|
|
32
|
-
children: /* @__PURE__ */ o(
|
|
33
|
-
|
|
32
|
+
return /* @__PURE__ */ o(g, {
|
|
33
|
+
children: /* @__PURE__ */ o(x, {
|
|
34
|
+
...L,
|
|
35
|
+
ref: p,
|
|
34
36
|
as: "input",
|
|
35
37
|
className: s,
|
|
36
38
|
disabled: m,
|
|
37
|
-
filterFn:
|
|
39
|
+
filterFn: F,
|
|
38
40
|
label: a ? ({
|
|
39
|
-
...
|
|
40
|
-
}) =>
|
|
41
|
+
...l
|
|
42
|
+
}) => $({
|
|
41
43
|
as: "label",
|
|
42
44
|
tooltipText: a,
|
|
43
|
-
children:
|
|
44
|
-
...
|
|
45
|
-
}) :
|
|
45
|
+
children: r,
|
|
46
|
+
...l
|
|
47
|
+
}) : r,
|
|
46
48
|
multiselect: !0,
|
|
47
49
|
name: e.name,
|
|
48
|
-
onValueChange: (
|
|
49
|
-
options:
|
|
50
|
-
placeholder: ((t = e.value) == null ? void 0 : t.length) === 0 ?
|
|
51
|
-
portalElement:
|
|
50
|
+
onValueChange: (l) => c(n, l),
|
|
51
|
+
options: v,
|
|
52
|
+
placeholder: ((t = e.value) == null ? void 0 : t.length) === 0 ? h.formatMessage(T.multiselectPlaceholder) : "",
|
|
53
|
+
portalElement: d,
|
|
52
54
|
value: e.value
|
|
53
55
|
})
|
|
54
56
|
});
|
|
55
57
|
}
|
|
56
58
|
})
|
|
57
59
|
});
|
|
58
|
-
};
|
|
60
|
+
});
|
|
59
61
|
export {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
+
q as MetadataMultiSelectField,
|
|
63
|
+
q as default
|
|
62
64
|
};
|
|
@@ -1,46 +1,48 @@
|
|
|
1
|
-
import { TextInput as
|
|
2
|
-
import { Field as
|
|
3
|
-
import { useIntl as
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { TextInput as p } from "@box/blueprint-web";
|
|
2
|
+
import { Field as c } from "formik";
|
|
3
|
+
import { useIntl as u } from "react-intl";
|
|
4
|
+
import { forwardRef as h } from "react";
|
|
5
|
+
import x from "../../../../messages.js";
|
|
6
|
+
import g from "../../../interactive-text/interactive-text.js";
|
|
7
|
+
import { fieldDefaultProps as v } from "../constants.js";
|
|
8
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
9
|
+
const F = /* @__PURE__ */ h(({
|
|
10
|
+
description: t,
|
|
10
11
|
label: e,
|
|
11
|
-
fieldNamePrefix:
|
|
12
|
-
disableForm:
|
|
12
|
+
fieldNamePrefix: o,
|
|
13
|
+
disableForm: a,
|
|
13
14
|
className: i
|
|
14
|
-
}) => {
|
|
15
|
-
const
|
|
16
|
-
return /* @__PURE__ */
|
|
15
|
+
}, l) => {
|
|
16
|
+
const m = u(), d = `${o}.value`;
|
|
17
|
+
return /* @__PURE__ */ r("div", {
|
|
17
18
|
"data-testid": `${e}-field`,
|
|
18
|
-
children: /* @__PURE__ */
|
|
19
|
+
children: /* @__PURE__ */ r(c, {
|
|
19
20
|
name: d,
|
|
20
21
|
children: ({
|
|
21
|
-
field:
|
|
22
|
+
field: f,
|
|
22
23
|
meta: s
|
|
23
|
-
}) => /* @__PURE__ */
|
|
24
|
-
...
|
|
25
|
-
...
|
|
24
|
+
}) => /* @__PURE__ */ r(p, {
|
|
25
|
+
...v,
|
|
26
|
+
...f,
|
|
27
|
+
ref: l,
|
|
26
28
|
className: i,
|
|
27
|
-
disabled:
|
|
29
|
+
disabled: a,
|
|
28
30
|
error: s.error,
|
|
29
|
-
label:
|
|
30
|
-
...
|
|
31
|
-
}) =>
|
|
31
|
+
label: t ? ({
|
|
32
|
+
...n
|
|
33
|
+
}) => g({
|
|
32
34
|
as: "label",
|
|
33
|
-
tooltipText:
|
|
35
|
+
tooltipText: t,
|
|
34
36
|
children: e,
|
|
35
|
-
...
|
|
37
|
+
...n
|
|
36
38
|
}) : e,
|
|
37
|
-
placeholder:
|
|
39
|
+
placeholder: m.formatMessage(x.setValuePlaceholder)
|
|
38
40
|
})
|
|
39
41
|
})
|
|
40
42
|
});
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
+
});
|
|
44
|
+
F.displayName = "MetadataStringField";
|
|
43
45
|
export {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
F as MetadataStringField,
|
|
47
|
+
F as default
|
|
46
48
|
};
|
|
@@ -1,26 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { forwardRef as r } from "react";
|
|
2
|
+
import { MetadataDateField as o } from "./components/metadata-date-field/metadata-date-field.js";
|
|
2
3
|
import { MetadataEnumField as i } from "./components/metadata-enum-field/metadata-enum-field.js";
|
|
3
|
-
import { MetadataFloatField as
|
|
4
|
-
import { MetadataMultiSelectField as
|
|
5
|
-
import { MetadataStringField as
|
|
6
|
-
import { jsx as
|
|
7
|
-
const
|
|
8
|
-
date: (t) => /* @__PURE__ */
|
|
9
|
-
...t
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}),
|
|
20
|
-
|
|
21
|
-
...t
|
|
22
|
-
|
|
4
|
+
import { MetadataFloatField as m } from "./components/metadata-float-field/metadata-float-field.js";
|
|
5
|
+
import { MetadataMultiSelectField as f } from "./components/metadata-multi-select-field/metadata-multi-select-field.js";
|
|
6
|
+
import { MetadataStringField as d } from "./components/metadata-string-field/metadata-string-field.js";
|
|
7
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
8
|
+
const c = {
|
|
9
|
+
date: /* @__PURE__ */ r((t, e) => /* @__PURE__ */ a(o, {
|
|
10
|
+
...t,
|
|
11
|
+
ref: e
|
|
12
|
+
})),
|
|
13
|
+
enum: /* @__PURE__ */ r((t, e) => /* @__PURE__ */ a(i, {
|
|
14
|
+
...t,
|
|
15
|
+
ref: e
|
|
16
|
+
})),
|
|
17
|
+
float: /* @__PURE__ */ r((t, e) => /* @__PURE__ */ a(m, {
|
|
18
|
+
...t,
|
|
19
|
+
ref: e
|
|
20
|
+
})),
|
|
21
|
+
multiSelect: /* @__PURE__ */ r((t, e) => /* @__PURE__ */ a(f, {
|
|
22
|
+
...t,
|
|
23
|
+
ref: e
|
|
24
|
+
})),
|
|
25
|
+
string: /* @__PURE__ */ r((t, e) => /* @__PURE__ */ a(d, {
|
|
26
|
+
...t,
|
|
27
|
+
ref: e
|
|
28
|
+
}))
|
|
23
29
|
};
|
|
24
30
|
export {
|
|
25
|
-
|
|
31
|
+
c as editorFieldTypes
|
|
26
32
|
};
|
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
|
|
1
|
+
import { useRef as f, useEffect as l } from "react";
|
|
2
|
+
import { Text as c } from "@box/blueprint-web";
|
|
3
|
+
import { useFormikContext as d, getIn as u, FieldArray as p } from "formik";
|
|
4
|
+
import { FormattedMessage as x } from "react-intl";
|
|
5
|
+
import g from "../../messages.js";
|
|
6
|
+
import { M as h, s as F } from "../../../../chunks/metadata-editor-field-wrapper.js";
|
|
7
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
8
|
+
const k = (m) => {
|
|
8
9
|
const {
|
|
9
|
-
values:
|
|
10
|
-
} =
|
|
11
|
-
return
|
|
12
|
-
|
|
10
|
+
values: i
|
|
11
|
+
} = d(), o = "metadata.fields", r = u(i, o), s = f(null), a = r.findIndex((e) => !e.hidden);
|
|
12
|
+
return l(() => {
|
|
13
|
+
var e;
|
|
14
|
+
a > -1 && ((e = s.current) == null || e.focus());
|
|
15
|
+
}, []), r.length ? /* @__PURE__ */ t(p, {
|
|
16
|
+
name: o,
|
|
13
17
|
validateOnChange: !1,
|
|
14
|
-
children: () =>
|
|
15
|
-
...
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
children: () => r.map((e, n) => /* @__PURE__ */ t(h, {
|
|
19
|
+
...m,
|
|
20
|
+
ref: n === a ? s : null,
|
|
21
|
+
field: e,
|
|
22
|
+
index: n
|
|
23
|
+
}, e.key))
|
|
24
|
+
}) : /* @__PURE__ */ t(c, {
|
|
20
25
|
as: "span",
|
|
21
|
-
className:
|
|
26
|
+
className: F.noAttributesText,
|
|
22
27
|
color: "textOnLightSecondary",
|
|
23
|
-
children: /* @__PURE__ */
|
|
24
|
-
...
|
|
28
|
+
children: /* @__PURE__ */ t(x, {
|
|
29
|
+
...g.noTemplateAtributesError
|
|
25
30
|
})
|
|
26
31
|
});
|
|
27
32
|
};
|
|
28
33
|
export {
|
|
29
|
-
|
|
30
|
-
|
|
34
|
+
k as TemplateInstance,
|
|
35
|
+
k as default
|
|
31
36
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/metadata-editor",
|
|
3
|
-
"version": "0.61.
|
|
3
|
+
"version": "0.61.2",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@ariakit/react": "0.4.5",
|
|
6
6
|
"@box/blueprint-web": "^7.30.3",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"**/*.css"
|
|
54
54
|
],
|
|
55
55
|
"license": "SEE LICENSE IN LICENSE",
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "1a9265fe9212f894e9e9a8d86c1969ef1d602004"
|
|
57
57
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type MetadataFieldProps } from '../../types';
|
|
2
|
-
export declare const MetadataDateField: (
|
|
2
|
+
export declare const MetadataDateField: import("react").ForwardRefExoticComponent<MetadataFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
3
3
|
export default MetadataDateField;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type MetadataFieldProps } from '../../types';
|
|
2
|
-
export declare const MetadataEnumField: (
|
|
2
|
+
export declare const MetadataEnumField: import("react").ForwardRefExoticComponent<MetadataFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
3
3
|
export default MetadataEnumField;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type MetadataFieldProps } from '../../types';
|
|
2
|
-
export declare const MetadataFloatField: (
|
|
2
|
+
export declare const MetadataFloatField: import("react").ForwardRefExoticComponent<MetadataFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
3
3
|
export default MetadataFloatField;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { type MetadataFieldProps } from '../../types';
|
|
2
|
-
export declare const MetadataMultiSelectField: (
|
|
2
|
+
export declare const MetadataMultiSelectField: import("react").ForwardRefExoticComponent<MetadataFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
3
3
|
export default MetadataMultiSelectField;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import { type MetadataFieldProps } from '../../types';
|
|
2
|
-
export declare const MetadataStringField:
|
|
3
|
-
({ description, label, fieldNamePrefix, disableForm, className, }: MetadataFieldProps): import("react/jsx-runtime").JSX.Element;
|
|
4
|
-
displayName: string;
|
|
5
|
-
};
|
|
2
|
+
export declare const MetadataStringField: import("react").ForwardRefExoticComponent<MetadataFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
6
3
|
export default MetadataStringField;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type MetadataFieldProps } from './types';
|
|
2
2
|
export declare const editorFieldTypes: {
|
|
3
|
-
date: (
|
|
4
|
-
enum: (
|
|
5
|
-
float: (
|
|
6
|
-
multiSelect: (
|
|
7
|
-
string: (
|
|
3
|
+
date: import("react").ForwardRefExoticComponent<MetadataFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
4
|
+
enum: import("react").ForwardRefExoticComponent<MetadataFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
5
|
+
float: import("react").ForwardRefExoticComponent<MetadataFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
6
|
+
multiSelect: import("react").ForwardRefExoticComponent<MetadataFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
7
|
+
string: import("react").ForwardRefExoticComponent<MetadataFieldProps & import("react").RefAttributes<HTMLInputElement>>;
|
|
8
8
|
};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export declare const MetadataEditorFieldWrapper: import("react").ForwardRefExoticComponent<import("./types").TemplateInstanceProps & {
|
|
2
|
+
field: import("../../types").MetadataTemplateField;
|
|
3
|
+
index: number;
|
|
4
|
+
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -4,6 +4,7 @@ declare const dateField: MetadataTemplateField;
|
|
|
4
4
|
declare const enumField: MetadataTemplateField;
|
|
5
5
|
declare const floatField: MetadataTemplateField;
|
|
6
6
|
declare const multiSelectField: MetadataTemplateField;
|
|
7
|
+
declare const hiddenField: MetadataTemplateField;
|
|
7
8
|
declare const noValueField: MetadataTemplateField;
|
|
8
9
|
declare const allFieldsTemplate: MetadataTemplate;
|
|
9
10
|
declare const nonHiddenFieldsTemplate: MetadataTemplate;
|
|
@@ -29,4 +30,4 @@ declare const firstTemplateInstanceFieldsWithSuggestions: MetadataTemplateField[
|
|
|
29
30
|
declare const secondTemplateInstance: MetadataTemplate;
|
|
30
31
|
declare const secondTemplateSuggestions: AutofillSuggestions;
|
|
31
32
|
declare const secondTemplateInstanceFieldsWithSuggestions: MetadataTemplateField[];
|
|
32
|
-
export { allFieldsTemplate, allFieldsTemplateInstance, customTemplate, customTemplateInstance, customTemplateInstanceWithAllFieldsEmpty, customTemplateInstanceWithoutEmptyValues, dateField, emptyCustomTemplateInstance, emptyTemplateInstance, enumField, fields, floatField, multiSelectField, noFieldsTemplate, nonHiddenFieldsTemplate, noValueField, stringField, templateInstancesList, templateInstanceWithAllFieldsEmpty, templateInstanceWithoutEmptyValues, templateOptions, templates, allFieldsWithAiSuggestions, allFieldsSuggestions, firstTemplateInstance, firstTemplateInstanceFieldsWithSuggestions, secondTemplateInstance, firstTemplateSuggestions, secondTemplateSuggestions, secondTemplateInstanceFieldsWithSuggestions, };
|
|
33
|
+
export { allFieldsTemplate, allFieldsTemplateInstance, customTemplate, customTemplateInstance, customTemplateInstanceWithAllFieldsEmpty, customTemplateInstanceWithoutEmptyValues, dateField, emptyCustomTemplateInstance, emptyTemplateInstance, enumField, fields, floatField, hiddenField, multiSelectField, noFieldsTemplate, nonHiddenFieldsTemplate, noValueField, stringField, templateInstancesList, templateInstanceWithAllFieldsEmpty, templateInstanceWithoutEmptyValues, templateOptions, templates, allFieldsWithAiSuggestions, allFieldsSuggestions, firstTemplateInstance, firstTemplateInstanceFieldsWithSuggestions, secondTemplateInstance, firstTemplateSuggestions, secondTemplateSuggestions, secondTemplateInstanceFieldsWithSuggestions, };
|