@box/metadata-filter 1.23.0 → 1.23.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/dist/chunks/types2.js +6 -0
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/constants.js +1 -1
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/date-conversion-utils.js +43 -49
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field-advanced.js +143 -136
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field-relative.js +44 -43
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field.js +8 -7
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/use-date-internationalization.js +7 -8
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/use-date-validation.js +35 -10
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/use-integer-validation.js +21 -0
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-float-field/metadata-float-field-advanced.js +59 -61
- package/dist/esm/lib/components/metadata-filter-fields/metadata-filter-fields.js +42 -42
- package/dist/esm/lib/messages.js +12 -0
- package/dist/i18n/bn-IN.js +3 -0
- package/dist/i18n/da-DK.js +3 -0
- package/dist/i18n/de-DE.js +3 -0
- package/dist/i18n/en-AU.js +3 -0
- package/dist/i18n/en-CA.js +3 -0
- package/dist/i18n/en-GB.js +3 -0
- package/dist/i18n/en-US.js +3 -0
- package/dist/i18n/en-US.properties +6 -0
- package/dist/i18n/en-x-pseudo.js +3 -0
- package/dist/i18n/es-419.js +3 -0
- package/dist/i18n/es-ES.js +3 -0
- package/dist/i18n/fi-FI.js +3 -0
- package/dist/i18n/fr-CA.js +3 -0
- package/dist/i18n/fr-FR.js +3 -0
- package/dist/i18n/hi-IN.js +3 -0
- package/dist/i18n/it-IT.js +3 -0
- package/dist/i18n/ja-JP.js +3 -0
- package/dist/i18n/json/src/lib/messages.json +1 -1
- package/dist/i18n/ko-KR.js +3 -0
- package/dist/i18n/nb-NO.js +3 -0
- package/dist/i18n/nl-NL.js +3 -0
- package/dist/i18n/pl-PL.js +3 -0
- package/dist/i18n/pt-BR.js +3 -0
- package/dist/i18n/ru-RU.js +3 -0
- package/dist/i18n/sv-SE.js +3 -0
- package/dist/i18n/tr-TR.js +3 -0
- package/dist/i18n/zh-CN.js +3 -0
- package/dist/i18n/zh-TW.js +3 -0
- package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/types.d.ts +3 -2
- package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/use-integer-validation.d.ts +6 -0
- package/dist/types/lib/messages.d.ts +15 -0
- package/package.json +1 -1
- package/dist/chunks/use-date-validation.js +0 -40
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DateI18nProvider as Oe, Text as xe, Radio as i, Select as p, DatePicker as
|
|
1
|
+
import { DateI18nProvider as Oe, Text as xe, Radio as i, Select as p, DatePicker as se } from "@box/blueprint-web";
|
|
2
2
|
import Ae from "clsx";
|
|
3
3
|
import { useFormikContext as Le, getIn as O, Field as oe } from "formik";
|
|
4
4
|
import { useState as x, useRef as A, useCallback as Ie, useEffect as ie, useMemo as ce } from "react";
|
|
@@ -7,7 +7,8 @@ import { R as c } from "../../../../../../chunks/types.js";
|
|
|
7
7
|
import { DEFAULT_MAX_DATE as ue } from "./constants.js";
|
|
8
8
|
import { getRelativeFromToValues as ke, convertToFormikValueRanged as me, getCustomFromToValues as de } from "./date-conversion-utils.js";
|
|
9
9
|
import { s as f } from "../../../../../../chunks/metadata-date-field.module.js";
|
|
10
|
-
import {
|
|
10
|
+
import { E as G } from "../../../../../../chunks/types2.js";
|
|
11
|
+
import { useDateValidation as Ee } from "./use-date-validation.js";
|
|
11
12
|
import { getDynamicMaxMinValue as fe } from "./utils.js";
|
|
12
13
|
import r from "../../../../messages.js";
|
|
13
14
|
import { jsx as l, jsxs as L } from "react/jsx-runtime";
|
|
@@ -15,7 +16,7 @@ const ve = {
|
|
|
15
16
|
next: r.nextDaysAmt,
|
|
16
17
|
past: r.pastDaysAmt,
|
|
17
18
|
olderThan: r.olderThanDaysAmt
|
|
18
|
-
}, Pe = [1, 3, 15, 45, 60, 120, 365], ge = (u) => u in ve || u === "today" || u === "customRange",
|
|
19
|
+
}, Pe = [1, 3, 15, 45, 60, 120, 365], ge = (u) => u in ve || u === "today" || u === "customRange", We = ({
|
|
19
20
|
customDateFilterOptions: u,
|
|
20
21
|
disableForm: C,
|
|
21
22
|
fieldNamePrefix: h,
|
|
@@ -26,52 +27,52 @@ const ve = {
|
|
|
26
27
|
const [X, I] = x(c.FROM), [_, N] = x(!1), m = `${h}.value.range.gt`, d = `${h}.value.range.lt`, H = `${h}.value.relativeType`, k = `${h}.value.relativeDays`, q = `${h}.value.customType`, E = `${h}.value.customDays`, {
|
|
27
28
|
values: F,
|
|
28
29
|
setFieldTouched: he,
|
|
29
|
-
setFieldValue:
|
|
30
|
+
setFieldValue: s
|
|
30
31
|
} = Le(), {
|
|
31
32
|
validateDates: z,
|
|
32
33
|
fromDatePickerValue: T,
|
|
33
34
|
toDatePickerValue: y,
|
|
34
35
|
fromErrorType: J,
|
|
35
36
|
toErrorType: K
|
|
36
|
-
} = Ee(F, m, d, j, !0),
|
|
37
|
+
} = Ee(F, m, d, j, !0), n = Ne(), g = O(F, H), v = O(F, q), pe = T || y;
|
|
37
38
|
let P = "anyTime", $ = "anyTime";
|
|
38
39
|
ge(g) ? P = g : v ? $ = v : pe && (P = "customRange", $ = "customRange");
|
|
39
40
|
const [D, Q] = x(P), W = A(g), Y = A(v), S = O(F, k), Z = O(F, E), [w, ee] = x($), V = A(T), M = A(y), ae = {
|
|
40
|
-
clearDatePickerAriaLabel:
|
|
41
|
-
nextMonthAriaLabel:
|
|
42
|
-
openCalendarDropdownAriaLabel:
|
|
43
|
-
previousMonthAriaLabel:
|
|
41
|
+
clearDatePickerAriaLabel: n.formatMessage(r.clearSelectedDate),
|
|
42
|
+
nextMonthAriaLabel: n.formatMessage(r.switchToNextMonth),
|
|
43
|
+
openCalendarDropdownAriaLabel: n.formatMessage(r.openCalendar),
|
|
44
|
+
previousMonthAriaLabel: n.formatMessage(r.switchToNextMonth)
|
|
44
45
|
}, Fe = () => {
|
|
45
|
-
|
|
46
|
+
s(m, void 0), s(d, void 0), V.current = void 0, M.current = void 0;
|
|
46
47
|
}, Te = (e) => {
|
|
47
48
|
const a = me(e, c.FROM);
|
|
48
|
-
V.current = e,
|
|
49
|
+
V.current = e, s(m, a), I(c.FROM);
|
|
49
50
|
}, ye = (e) => {
|
|
50
51
|
const a = me(e, c.TO);
|
|
51
|
-
M.current = e,
|
|
52
|
+
M.current = e, s(d, a), I(c.TO);
|
|
52
53
|
}, te = (e) => {
|
|
53
54
|
const a = e === c.FROM ? m : d;
|
|
54
55
|
he(a, !0), I(e);
|
|
55
56
|
}, De = (e) => {
|
|
56
57
|
let a;
|
|
57
|
-
ge(e) && (a = e), e === "customRange" && (V.current = void 0, M.current = void 0),
|
|
58
|
+
ge(e) && (a = e), e === "customRange" && (V.current = void 0, M.current = void 0), s(H, a), Q(e), s(k, void 0), N(!0);
|
|
58
59
|
}, Ve = (e) => {
|
|
59
|
-
|
|
60
|
+
s(q, e), ee(e), s(E, void 0), Fe();
|
|
60
61
|
const a = u.find((t) => t.name === e);
|
|
61
62
|
if (a && a.type === "text") {
|
|
62
63
|
const {
|
|
63
64
|
from: t,
|
|
64
65
|
to: o
|
|
65
66
|
} = de(a.from, a.to);
|
|
66
|
-
|
|
67
|
+
s(m, t), s(d, o);
|
|
67
68
|
}
|
|
68
69
|
}, le = Ie(() => {
|
|
69
70
|
const {
|
|
70
71
|
from: e,
|
|
71
72
|
to: a
|
|
72
73
|
} = ke(D, S);
|
|
73
|
-
|
|
74
|
-
}, [m, S, D,
|
|
74
|
+
s(m, e), s(d, a);
|
|
75
|
+
}, [m, S, D, s, d]);
|
|
75
76
|
ie(() => {
|
|
76
77
|
_ && (le(), N(!1));
|
|
77
78
|
}, [_, le]), ie(() => {
|
|
@@ -85,7 +86,7 @@ const ve = {
|
|
|
85
86
|
const R = ve[e];
|
|
86
87
|
return {
|
|
87
88
|
value: String(o),
|
|
88
|
-
label:
|
|
89
|
+
label: n.formatMessage(R, {
|
|
89
90
|
count: o
|
|
90
91
|
})
|
|
91
92
|
};
|
|
@@ -93,11 +94,11 @@ const ve = {
|
|
|
93
94
|
return /* @__PURE__ */ l(p, {
|
|
94
95
|
className: f.dateSelect,
|
|
95
96
|
defaultValue: S === void 0 ? "" : String(S),
|
|
96
|
-
label:
|
|
97
|
+
label: n.formatMessage(r.relativeDaysSelectLabel),
|
|
97
98
|
onValueChange: (o) => {
|
|
98
|
-
|
|
99
|
+
s(k, Number(o)), N(!0);
|
|
99
100
|
},
|
|
100
|
-
placeholder:
|
|
101
|
+
placeholder: n.formatMessage(r.selectValuePlaceholder),
|
|
101
102
|
children: /* @__PURE__ */ l(p.Content, {
|
|
102
103
|
container: b,
|
|
103
104
|
children: t == null ? void 0 : t.map((o) => /* @__PURE__ */ l(p.Option, {
|
|
@@ -110,7 +111,7 @@ const ve = {
|
|
|
110
111
|
}, Ce = (e, a) => e !== w ? null : /* @__PURE__ */ l(p, {
|
|
111
112
|
className: f.dateSelect,
|
|
112
113
|
defaultValue: Z === void 0 ? "" : String(Z),
|
|
113
|
-
label:
|
|
114
|
+
label: n.formatMessage(r.relativeDaysSelectLabel),
|
|
114
115
|
onValueChange: (t) => {
|
|
115
116
|
const o = a.find((R) => R.name === t);
|
|
116
117
|
if (o) {
|
|
@@ -118,10 +119,10 @@ const ve = {
|
|
|
118
119
|
from: R,
|
|
119
120
|
to: Se
|
|
120
121
|
} = de(o.from, o.to);
|
|
121
|
-
|
|
122
|
+
s(m, R), s(d, Se), s(E, o.name);
|
|
122
123
|
}
|
|
123
124
|
},
|
|
124
|
-
placeholder:
|
|
125
|
+
placeholder: n.formatMessage(r.selectValuePlaceholder),
|
|
125
126
|
children: /* @__PURE__ */ l(p.Content, {
|
|
126
127
|
container: b,
|
|
127
128
|
children: a.map((t) => /* @__PURE__ */ l(p.Option, {
|
|
@@ -136,7 +137,7 @@ const ve = {
|
|
|
136
137
|
onValueChange: Ve,
|
|
137
138
|
value: w,
|
|
138
139
|
children: [/* @__PURE__ */ l(i.Item, {
|
|
139
|
-
label:
|
|
140
|
+
label: n.formatMessage(r.relativeDateFilterAnyTime),
|
|
140
141
|
value: "anyTime"
|
|
141
142
|
}), u.map((e) => {
|
|
142
143
|
if (e.type === "text")
|
|
@@ -154,11 +155,11 @@ const ve = {
|
|
|
154
155
|
value: a
|
|
155
156
|
}, a);
|
|
156
157
|
}), /* @__PURE__ */ l(i.Item, {
|
|
157
|
-
description:
|
|
158
|
-
label:
|
|
158
|
+
description: ne(),
|
|
159
|
+
label: n.formatMessage(r.relativeDateFilterCustomRange),
|
|
159
160
|
value: "customRange"
|
|
160
161
|
})]
|
|
161
|
-
}),
|
|
162
|
+
}), ne = () => !u && D !== "customRange" || u && w !== "customRange" ? null : /* @__PURE__ */ L("div", {
|
|
162
163
|
className: Ae(f.rangeInputsContainer, f.verticalLayout, f.dateSelect),
|
|
163
164
|
children: [/* @__PURE__ */ l(oe, {
|
|
164
165
|
name: m,
|
|
@@ -168,13 +169,13 @@ const ve = {
|
|
|
168
169
|
meta: a
|
|
169
170
|
}) => /* @__PURE__ */ l("div", {
|
|
170
171
|
className: f.inputContainer,
|
|
171
|
-
children: /* @__PURE__ */ l(
|
|
172
|
+
children: /* @__PURE__ */ l(se, {
|
|
172
173
|
...e,
|
|
173
174
|
...ae,
|
|
174
|
-
calendarAriaLabel:
|
|
175
|
+
calendarAriaLabel: n.formatMessage(r.selectStartDate),
|
|
175
176
|
error: re(J, K, X !== c.FROM) ? void 0 : a.error,
|
|
176
177
|
isDisabled: C,
|
|
177
|
-
label:
|
|
178
|
+
label: n.formatMessage(r.fieldStartDateLabel),
|
|
178
179
|
maxValue: Me,
|
|
179
180
|
onBlur: () => te(c.FROM),
|
|
180
181
|
onChange: (t) => Te(t),
|
|
@@ -190,13 +191,13 @@ const ve = {
|
|
|
190
191
|
meta: a
|
|
191
192
|
}) => /* @__PURE__ */ l("div", {
|
|
192
193
|
className: f.inputContainer,
|
|
193
|
-
children: /* @__PURE__ */ l(
|
|
194
|
+
children: /* @__PURE__ */ l(se, {
|
|
194
195
|
...e,
|
|
195
196
|
...ae,
|
|
196
|
-
calendarAriaLabel:
|
|
197
|
+
calendarAriaLabel: n.formatMessage(r.selectEndDate),
|
|
197
198
|
error: re(K, J, X !== c.TO) ? void 0 : a.error,
|
|
198
199
|
isDisabled: C,
|
|
199
|
-
label:
|
|
200
|
+
label: n.formatMessage(r.fieldEndDateLabel),
|
|
200
201
|
maxValue: ue,
|
|
201
202
|
minValue: Re,
|
|
202
203
|
onBlur: () => te(c.TO),
|
|
@@ -224,26 +225,26 @@ const ve = {
|
|
|
224
225
|
onValueChange: De,
|
|
225
226
|
value: D,
|
|
226
227
|
children: [/* @__PURE__ */ l(i.Item, {
|
|
227
|
-
label:
|
|
228
|
+
label: n.formatMessage(r.relativeDateFilterAnyTime),
|
|
228
229
|
value: "anyTime"
|
|
229
230
|
}), /* @__PURE__ */ l(i.Item, {
|
|
230
|
-
label:
|
|
231
|
+
label: n.formatMessage(r.relativeDateFilterToday),
|
|
231
232
|
value: "today"
|
|
232
233
|
}), /* @__PURE__ */ l(i.Item, {
|
|
233
234
|
description: B("next"),
|
|
234
|
-
label:
|
|
235
|
+
label: n.formatMessage(r.relativeDateFilterNext),
|
|
235
236
|
value: "next"
|
|
236
237
|
}), /* @__PURE__ */ l(i.Item, {
|
|
237
238
|
description: B("past"),
|
|
238
|
-
label:
|
|
239
|
+
label: n.formatMessage(r.relativeDateFilterPast),
|
|
239
240
|
value: "past"
|
|
240
241
|
}), /* @__PURE__ */ l(i.Item, {
|
|
241
242
|
description: B("olderThan"),
|
|
242
|
-
label:
|
|
243
|
+
label: n.formatMessage(r.relativeDateFilterOlderThan),
|
|
243
244
|
value: "olderThan"
|
|
244
245
|
}), /* @__PURE__ */ l(i.Item, {
|
|
245
|
-
description:
|
|
246
|
-
label:
|
|
246
|
+
description: ne(),
|
|
247
|
+
label: n.formatMessage(r.relativeDateFilterCustomRange),
|
|
247
248
|
value: "customRange"
|
|
248
249
|
})]
|
|
249
250
|
})]
|
|
@@ -251,6 +252,6 @@ const ve = {
|
|
|
251
252
|
});
|
|
252
253
|
};
|
|
253
254
|
export {
|
|
254
|
-
|
|
255
|
-
|
|
255
|
+
We as MetadataDateFieldRelative,
|
|
256
|
+
We as default
|
|
256
257
|
};
|
|
@@ -8,11 +8,12 @@ import { DEFAULT_MAX_DATE as $ } from "./constants.js";
|
|
|
8
8
|
import { convertToFormikValue as B } from "./date-conversion-utils.js";
|
|
9
9
|
import { MetadataDateFieldRelative as Z } from "./metadata-date-field-relative.js";
|
|
10
10
|
import { s as i } from "../../../../../../chunks/metadata-date-field.module.js";
|
|
11
|
-
import {
|
|
12
|
-
import { useDateInternationalization as
|
|
11
|
+
import { E as g } from "../../../../../../chunks/types2.js";
|
|
12
|
+
import { useDateInternationalization as ee } from "./use-date-internationalization.js";
|
|
13
|
+
import { useDateValidation as ae } from "./use-date-validation.js";
|
|
13
14
|
import { getDynamicMaxMinValue as w } from "./utils.js";
|
|
14
15
|
import { jsx as t, jsxs as z } from "react/jsx-runtime";
|
|
15
|
-
const
|
|
16
|
+
const ge = ({
|
|
16
17
|
canUseRelativeDates: f,
|
|
17
18
|
...s
|
|
18
19
|
}) => f ? /* @__PURE__ */ t(Z, {
|
|
@@ -34,13 +35,13 @@ const pe = ({
|
|
|
34
35
|
setFieldValue: V
|
|
35
36
|
} = Q(), {
|
|
36
37
|
localTimezone: R
|
|
37
|
-
} =
|
|
38
|
+
} = ee(M), {
|
|
38
39
|
validateDates: b,
|
|
39
40
|
fromDatePickerValue: d,
|
|
40
41
|
toDatePickerValue: u,
|
|
41
42
|
fromErrorType: x,
|
|
42
43
|
toErrorType: A
|
|
43
|
-
} =
|
|
44
|
+
} = ae(S, m, c, M, !1), o = Y(), F = E(d), p = E(u), C = {
|
|
44
45
|
clearDatePickerAriaLabel: o.formatMessage(n.clearSelectedDate),
|
|
45
46
|
nextMonthAriaLabel: o.formatMessage(n.switchToNextMonth),
|
|
46
47
|
openCalendarDropdownAriaLabel: o.formatMessage(n.openCalendar),
|
|
@@ -119,7 +120,7 @@ const pe = ({
|
|
|
119
120
|
});
|
|
120
121
|
};
|
|
121
122
|
export {
|
|
122
|
-
|
|
123
|
+
ge as MetadataDateField,
|
|
123
124
|
re as MetadataDateFieldNonRelative,
|
|
124
|
-
|
|
125
|
+
ge as default
|
|
125
126
|
};
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const e = a(() => new n(t), [t]), o = m();
|
|
1
|
+
import { DateFormatter as a, getLocalTimeZone as n } from "@box/blueprint-web";
|
|
2
|
+
import { useMemo as m } from "react";
|
|
3
|
+
const D = (t) => {
|
|
4
|
+
const o = m(() => new a(t), [t]), e = n();
|
|
6
5
|
return {
|
|
7
6
|
locale: t,
|
|
8
|
-
localTimezone:
|
|
9
|
-
formatCalendarDate: (r) =>
|
|
7
|
+
localTimezone: e,
|
|
8
|
+
formatCalendarDate: (r) => o.format(r.toDate(e))
|
|
10
9
|
};
|
|
11
10
|
};
|
|
12
11
|
export {
|
|
13
|
-
|
|
12
|
+
D as useDateInternationalization
|
|
14
13
|
};
|
|
@@ -1,12 +1,37 @@
|
|
|
1
|
-
import "formik";
|
|
2
|
-
import "react";
|
|
3
|
-
import "react-intl";
|
|
4
|
-
import "../../../../../../chunks/types.js";
|
|
5
|
-
import "./constants.js";
|
|
6
|
-
import "./date-conversion-utils.js";
|
|
7
|
-
import {
|
|
8
|
-
import "./use-date-internationalization.js";
|
|
9
|
-
import "../../../../messages.js";
|
|
1
|
+
import { getIn as E } from "formik";
|
|
2
|
+
import { useMemo as V, useState as c } from "react";
|
|
3
|
+
import { useIntl as _ } from "react-intl";
|
|
4
|
+
import { R as M } from "../../../../../../chunks/types.js";
|
|
5
|
+
import { DEFAULT_MAX_DATE as F } from "./constants.js";
|
|
6
|
+
import { convertToDatePickerValue as D } from "./date-conversion-utils.js";
|
|
7
|
+
import { E as A } from "../../../../../../chunks/types2.js";
|
|
8
|
+
import { useDateInternationalization as x } from "./use-date-internationalization.js";
|
|
9
|
+
import i from "../../../../messages.js";
|
|
10
|
+
const B = (f, R, d, I, t) => {
|
|
11
|
+
const {
|
|
12
|
+
formatCalendarDate: a
|
|
13
|
+
} = x(I), s = _(), l = E(f, R), u = E(f, d), T = V(() => D(l, t), [t, l]), g = V(() => D(u, t), [t, u]), [v, y] = c(null), [O, X] = c(null), m = (r, o) => r === M.FROM ? y(o) : X(o);
|
|
14
|
+
return {
|
|
15
|
+
validateDates: (r, o, e) => {
|
|
16
|
+
const p = e === M.FROM, n = p ? r : o;
|
|
17
|
+
if ((n == null ? void 0 : n.compare(F)) > 0)
|
|
18
|
+
return m(e, A.MAX), s.formatMessage(i.beforeDateValidationError, {
|
|
19
|
+
date: a(F)
|
|
20
|
+
});
|
|
21
|
+
if (r && o && r.compare(o) > 0)
|
|
22
|
+
return m(e, A.OVERLAPPING), p ? s.formatMessage(i.beforeDateValidationError, {
|
|
23
|
+
date: a(o)
|
|
24
|
+
}) : s.formatMessage(i.afterDateValidationError, {
|
|
25
|
+
date: a(r)
|
|
26
|
+
});
|
|
27
|
+
m(e, null);
|
|
28
|
+
},
|
|
29
|
+
fromDatePickerValue: T,
|
|
30
|
+
toDatePickerValue: g,
|
|
31
|
+
fromErrorType: v,
|
|
32
|
+
toErrorType: O
|
|
33
|
+
};
|
|
34
|
+
};
|
|
10
35
|
export {
|
|
11
|
-
|
|
36
|
+
B as useDateValidation
|
|
12
37
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { useState as n } from "react";
|
|
2
|
+
import { useIntl as m } from "react-intl";
|
|
3
|
+
import s from "../../../../messages.js";
|
|
4
|
+
import { E as i } from "../../../../../../chunks/types2.js";
|
|
5
|
+
const a = (r) => r != null && r.length ? /^[-+]?\d+$/.test(r.trim()) : !0, c = () => {
|
|
6
|
+
const r = m(), [o, t] = n(null);
|
|
7
|
+
return {
|
|
8
|
+
validatePositiveInteger: (e) => {
|
|
9
|
+
if (!a(e))
|
|
10
|
+
return t(i.INVALID), r.formatMessage(s.mustBeANumber);
|
|
11
|
+
if (e && parseInt(e, 10) <= 0)
|
|
12
|
+
return t(i.INVALID), r.formatMessage(s.mustBePositiveNumber);
|
|
13
|
+
t(null);
|
|
14
|
+
},
|
|
15
|
+
errorType: o
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
export {
|
|
19
|
+
a as isIntegerOrBlank,
|
|
20
|
+
c as useIntegerValidation
|
|
21
|
+
};
|
|
@@ -1,84 +1,82 @@
|
|
|
1
|
-
import { TextInput as
|
|
2
|
-
import {
|
|
3
|
-
import { useState as
|
|
1
|
+
import { TextInput as N } from "@box/blueprint-web";
|
|
2
|
+
import { Field as B } from "formik";
|
|
3
|
+
import { useState as S, useCallback as F } from "react";
|
|
4
4
|
import { useIntl as $ } from "react-intl";
|
|
5
|
-
import
|
|
6
|
-
import { R as
|
|
7
|
-
import { fieldDefaultProps as
|
|
8
|
-
import { createAdvancedFilterOptionHandler as
|
|
9
|
-
import { s as
|
|
10
|
-
import { u as
|
|
11
|
-
import { FloatAdvancedFilterOption as
|
|
12
|
-
import { jsx as
|
|
13
|
-
import { A as
|
|
14
|
-
const
|
|
15
|
-
label:
|
|
5
|
+
import u from "../../../../messages.js";
|
|
6
|
+
import { R as d } from "../../../../../../chunks/types.js";
|
|
7
|
+
import { fieldDefaultProps as b } from "../constants.js";
|
|
8
|
+
import { createAdvancedFilterOptionHandler as k, createInputChangeHandler as V } from "./handlers.js";
|
|
9
|
+
import { s as c } from "../../../../../../chunks/metadata-float-field.module.js";
|
|
10
|
+
import { u as G } from "../../../../../../chunks/use-float-validation.js";
|
|
11
|
+
import { FloatAdvancedFilterOption as Q, getInputValues as y, getInputDisplayState as U, FloatInputDisplayState as I } from "./utils.js";
|
|
12
|
+
import { jsx as n, jsxs as A, Fragment as q } from "react/jsx-runtime";
|
|
13
|
+
import { A as z } from "../../../../../../chunks/index.js";
|
|
14
|
+
const le = ({
|
|
15
|
+
label: m,
|
|
16
16
|
fieldNamePrefix: C,
|
|
17
17
|
disableForm: p,
|
|
18
18
|
onAdvancedFilterOptionChange: h,
|
|
19
19
|
fieldAdvancedFilterOptions: O,
|
|
20
|
-
filterOptionsMap:
|
|
20
|
+
filterOptionsMap: E
|
|
21
21
|
}) => {
|
|
22
|
-
const s = $(),
|
|
23
|
-
|
|
24
|
-
} =
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const e = V(B(A, a), !0);
|
|
34
|
-
return R(e.from, e.to, f, !0);
|
|
22
|
+
const s = $(), o = `${C}.value.enum[0]`, [R, L] = S(d.FROM), [l, M] = S(O || Q.EQUALS), {
|
|
23
|
+
validateFloats: f
|
|
24
|
+
} = G(), w = F((r, t, a, e) => k(o, h, M)(r, t, a, e), [o, h, M]), x = F((r, t, a) => V(o, l, L, d.FROM)(r, t, a), [o, l]), D = F((r, t, a) => V(o, l, L, d.TO)(r, t, a), [o, l]);
|
|
25
|
+
return /* @__PURE__ */ n("div", {
|
|
26
|
+
className: c.advancedFilterContainer,
|
|
27
|
+
"data-testid": `${m}-field`,
|
|
28
|
+
children: /* @__PURE__ */ n(B, {
|
|
29
|
+
name: o,
|
|
30
|
+
validate: (r) => {
|
|
31
|
+
const t = y(r, !0);
|
|
32
|
+
return f(t.from, t.to, R, !0);
|
|
35
33
|
},
|
|
36
34
|
children: ({
|
|
37
|
-
field:
|
|
38
|
-
meta:
|
|
39
|
-
form:
|
|
35
|
+
field: r,
|
|
36
|
+
meta: t,
|
|
37
|
+
form: a
|
|
40
38
|
}) => {
|
|
41
|
-
const
|
|
42
|
-
return /* @__PURE__ */
|
|
43
|
-
children: [/* @__PURE__ */
|
|
39
|
+
const e = y(r.value, !0), g = U(l), H = g !== I.NONE, T = g === I.SINGLE, v = g === I.BOTH, P = f(e.from, e.to, d.FROM, !0), j = f(e.from, e.to, d.TO, !0);
|
|
40
|
+
return /* @__PURE__ */ A(q, {
|
|
41
|
+
children: [/* @__PURE__ */ n(z, {
|
|
44
42
|
disableForm: p,
|
|
45
43
|
fieldAdvancedFilterOptions: O,
|
|
46
44
|
fieldNamePrefix: C,
|
|
47
|
-
filterOptionsMap:
|
|
48
|
-
label:
|
|
45
|
+
filterOptionsMap: E,
|
|
46
|
+
label: m,
|
|
49
47
|
onAdvancedFilterOptionChange: h,
|
|
50
|
-
onValueChange: (i) => w(i,
|
|
48
|
+
onValueChange: (i) => w(i, e.from, e.to, a),
|
|
51
49
|
showLabel: !0,
|
|
52
50
|
value: l
|
|
53
|
-
}), H && /* @__PURE__ */
|
|
54
|
-
className:
|
|
55
|
-
children: [(
|
|
56
|
-
className:
|
|
57
|
-
children: /* @__PURE__ */
|
|
58
|
-
...
|
|
51
|
+
}), H && /* @__PURE__ */ A("div", {
|
|
52
|
+
className: c.rangeInputsContainer,
|
|
53
|
+
children: [(T || v) && /* @__PURE__ */ n("div", {
|
|
54
|
+
className: c.inputContainer,
|
|
55
|
+
children: /* @__PURE__ */ n(N, {
|
|
56
|
+
...b,
|
|
59
57
|
disabled: p,
|
|
60
|
-
error:
|
|
58
|
+
error: T ? t.error : P,
|
|
61
59
|
hideLabel: !0,
|
|
62
|
-
label: s.formatMessage(
|
|
63
|
-
label:
|
|
60
|
+
label: s.formatMessage(u.fieldFromLabel, {
|
|
61
|
+
label: m
|
|
64
62
|
}),
|
|
65
|
-
onChange: (i) =>
|
|
66
|
-
placeholder: v ? s.formatMessage(
|
|
67
|
-
value:
|
|
63
|
+
onChange: (i) => x(i.currentTarget.value, e.to, a),
|
|
64
|
+
placeholder: v ? s.formatMessage(u.minValuePlaceholder) : s.formatMessage(u.enterNumberPlaceholder),
|
|
65
|
+
value: e.from
|
|
68
66
|
})
|
|
69
|
-
}), v && /* @__PURE__ */
|
|
70
|
-
className:
|
|
71
|
-
children: /* @__PURE__ */
|
|
72
|
-
...
|
|
67
|
+
}), v && /* @__PURE__ */ n("div", {
|
|
68
|
+
className: c.inputContainer,
|
|
69
|
+
children: /* @__PURE__ */ n(N, {
|
|
70
|
+
...b,
|
|
73
71
|
disabled: p,
|
|
74
|
-
error:
|
|
72
|
+
error: j,
|
|
75
73
|
hideLabel: !0,
|
|
76
|
-
label: s.formatMessage(
|
|
77
|
-
label:
|
|
74
|
+
label: s.formatMessage(u.fieldToLabel, {
|
|
75
|
+
label: m
|
|
78
76
|
}),
|
|
79
|
-
onChange: (i) =>
|
|
80
|
-
placeholder: s.formatMessage(
|
|
81
|
-
value:
|
|
77
|
+
onChange: (i) => D(i.currentTarget.value, e.from, a),
|
|
78
|
+
placeholder: s.formatMessage(u.maxValuePlaceholder),
|
|
79
|
+
value: e.to
|
|
82
80
|
})
|
|
83
81
|
})]
|
|
84
82
|
})]
|
|
@@ -88,6 +86,6 @@ const se = ({
|
|
|
88
86
|
});
|
|
89
87
|
};
|
|
90
88
|
export {
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
le as MetadataFloatFieldAdvanced,
|
|
90
|
+
le as default
|
|
93
91
|
};
|
|
@@ -1,45 +1,45 @@
|
|
|
1
|
-
import { Text as
|
|
2
|
-
import { useFormikContext as
|
|
3
|
-
import { FormattedMessage as
|
|
4
|
-
import
|
|
5
|
-
import { filterFieldTypes as
|
|
6
|
-
import { s as
|
|
7
|
-
import { jsx as
|
|
8
|
-
const
|
|
1
|
+
import { Text as c } from "@box/blueprint-web";
|
|
2
|
+
import { useFormikContext as v, getIn as N, FieldArray as D } from "formik";
|
|
3
|
+
import { useIntl as C, FormattedMessage as j } from "react-intl";
|
|
4
|
+
import t from "../../messages.js";
|
|
5
|
+
import { filterFieldTypes as d, advancedFilterFieldTypes as I } from "./filter-field-types.js";
|
|
6
|
+
import { s as L } from "../../../../chunks/index.js";
|
|
7
|
+
import { jsx as r, jsxs as P } from "react/jsx-runtime";
|
|
8
|
+
const q = ({
|
|
9
9
|
disableForm: p,
|
|
10
|
-
locale:
|
|
11
|
-
portalElement:
|
|
12
|
-
taxonomyOptionsFetcher:
|
|
13
|
-
canUseRelativeDates:
|
|
14
|
-
isAdvancedFilterEnabled:
|
|
15
|
-
onAdvancedFilterOptionChange:
|
|
16
|
-
fieldAdvancedFilterOptions:
|
|
17
|
-
isMultilevelTaxonomyFieldEnabled:
|
|
18
|
-
filterOptionsMap:
|
|
10
|
+
locale: y,
|
|
11
|
+
portalElement: g,
|
|
12
|
+
taxonomyOptionsFetcher: F,
|
|
13
|
+
canUseRelativeDates: T,
|
|
14
|
+
isAdvancedFilterEnabled: s,
|
|
15
|
+
onAdvancedFilterOptionChange: f,
|
|
16
|
+
fieldAdvancedFilterOptions: o,
|
|
17
|
+
isMultilevelTaxonomyFieldEnabled: h,
|
|
18
|
+
filterOptionsMap: i
|
|
19
19
|
}) => {
|
|
20
20
|
const {
|
|
21
|
-
values:
|
|
22
|
-
} =
|
|
23
|
-
return
|
|
24
|
-
name:
|
|
21
|
+
values: u
|
|
22
|
+
} = v(), a = C(), m = "metadata.fields", n = N(u, m);
|
|
23
|
+
return n.length ? /* @__PURE__ */ r(D, {
|
|
24
|
+
name: m,
|
|
25
25
|
validateOnChange: !1,
|
|
26
|
-
children: () =>
|
|
27
|
-
const
|
|
28
|
-
return
|
|
29
|
-
children: [/* @__PURE__ */
|
|
30
|
-
canUseRelativeDates:
|
|
26
|
+
children: () => n.map((e, x) => {
|
|
27
|
+
const l = (s ? I : d)[e.type] || d[e.type], M = l && !e.hidden, k = () => e.key === "modified_at" && s ? [["selectFilterType", a.formatMessage(t.selectAdvancedFilterType)], ["isNotBlank", a.formatMessage(t.modifiedAtFilterAnyTime)], ["today", a.formatMessage(t.relativeDateFilterToday)], ["past", a.formatMessage(t.relativeDateFilterPast)], ["olderThan", a.formatMessage(t.relativeDateFilterOlderThan)], ["customRange", a.formatMessage(t.relativeDateFilterCustomRange)]] : (i == null ? void 0 : i[e.type]) || [];
|
|
28
|
+
return M && /* @__PURE__ */ P("div", {
|
|
29
|
+
children: [/* @__PURE__ */ r(l, {
|
|
30
|
+
canUseRelativeDates: T,
|
|
31
31
|
disableForm: p,
|
|
32
|
-
fieldAdvancedFilterOptions:
|
|
33
|
-
fieldNamePrefix: `metadata.fields[${
|
|
34
|
-
filterOptionsMap:
|
|
35
|
-
isAdvancedFilterEnabled:
|
|
36
|
-
isMultilevelTaxonomyFieldEnabled:
|
|
32
|
+
fieldAdvancedFilterOptions: o == null ? void 0 : o[e.key],
|
|
33
|
+
fieldNamePrefix: `metadata.fields[${x}]`,
|
|
34
|
+
filterOptionsMap: k(),
|
|
35
|
+
isAdvancedFilterEnabled: s,
|
|
36
|
+
isMultilevelTaxonomyFieldEnabled: h,
|
|
37
37
|
label: e.displayName,
|
|
38
|
-
locale:
|
|
39
|
-
onAdvancedFilterOptionChange:
|
|
40
|
-
portalElement:
|
|
41
|
-
taxonomyOptionsFetcher:
|
|
42
|
-
}), !!e.description && /* @__PURE__ */
|
|
38
|
+
locale: y,
|
|
39
|
+
onAdvancedFilterOptionChange: f,
|
|
40
|
+
portalElement: g,
|
|
41
|
+
taxonomyOptionsFetcher: F
|
|
42
|
+
}), !!e.description && /* @__PURE__ */ r(c, {
|
|
43
43
|
as: "span",
|
|
44
44
|
color: "textOnLightSecondary",
|
|
45
45
|
variant: "caption",
|
|
@@ -47,16 +47,16 @@ const z = ({
|
|
|
47
47
|
})]
|
|
48
48
|
}, e.key);
|
|
49
49
|
})
|
|
50
|
-
}) : /* @__PURE__ */
|
|
50
|
+
}) : /* @__PURE__ */ r(c, {
|
|
51
51
|
as: "span",
|
|
52
|
-
className:
|
|
52
|
+
className: L.noAttributesText,
|
|
53
53
|
color: "textOnLightSecondary",
|
|
54
|
-
children: /* @__PURE__ */
|
|
55
|
-
...
|
|
54
|
+
children: /* @__PURE__ */ r(j, {
|
|
55
|
+
...t.noTemplateAtributesError
|
|
56
56
|
})
|
|
57
57
|
});
|
|
58
58
|
};
|
|
59
59
|
export {
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
q as MetadataFilterFields,
|
|
61
|
+
q as default
|
|
62
62
|
};
|