@box/metadata-filter 1.25.3 → 1.26.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/use-float-validation.js +21 -18
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field-advanced.js +37 -36
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field-relative.js +42 -41
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field.js +34 -33
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-enum-field/metadata-enum-field.js +21 -19
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-float-field/metadata-float-field-advanced.js +30 -29
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-float-field/metadata-float-field.js +20 -19
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-multi-select-field/metadata-multi-select-field-advanced.js +35 -34
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-multi-select-field/metadata-multi-select-field.js +25 -23
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-string-field/metadata-string-field.js +47 -46
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-taxonomy-field/metadata-taxonomy-field.js +40 -38
- package/dist/esm/lib/components/metadata-filter-fields/field-processing-utils.js +19 -0
- package/dist/esm/lib/components/metadata-filter-fields/metadata-filter-fields-accordion.js +82 -0
- package/dist/esm/lib/components/metadata-filter-fields/metadata-filter-fields.js +52 -43
- package/dist/esm/lib/messages.js +8 -0
- package/dist/esm/lib/metadata-filter.js +45 -42
- package/dist/i18n/bn-IN.js +2 -0
- package/dist/i18n/da-DK.js +2 -0
- package/dist/i18n/de-DE.js +2 -0
- package/dist/i18n/en-AU.js +2 -0
- package/dist/i18n/en-CA.js +2 -0
- package/dist/i18n/en-GB.js +2 -0
- package/dist/i18n/en-US.js +2 -0
- package/dist/i18n/en-US.properties +4 -0
- package/dist/i18n/en-x-pseudo.js +2 -0
- package/dist/i18n/es-419.js +2 -0
- package/dist/i18n/es-ES.js +2 -0
- package/dist/i18n/fi-FI.js +2 -0
- package/dist/i18n/fr-CA.js +2 -0
- package/dist/i18n/fr-FR.js +2 -0
- package/dist/i18n/hi-IN.js +2 -0
- package/dist/i18n/it-IT.js +2 -0
- package/dist/i18n/ja-JP.js +2 -0
- package/dist/i18n/json/src/lib/messages.json +1 -1
- package/dist/i18n/ko-KR.js +2 -0
- package/dist/i18n/nb-NO.js +2 -0
- package/dist/i18n/nl-NL.js +2 -0
- package/dist/i18n/pl-PL.js +2 -0
- package/dist/i18n/pt-BR.js +2 -0
- package/dist/i18n/ru-RU.js +2 -0
- package/dist/i18n/sv-SE.js +2 -0
- package/dist/i18n/tr-TR.js +2 -0
- package/dist/i18n/zh-CN.js +2 -0
- package/dist/i18n/zh-TW.js +2 -0
- package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field-advanced.d.ts +1 -1
- package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field-relative.d.ts +1 -1
- package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field.d.ts +1 -1
- package/dist/types/lib/components/metadata-filter-fields/components/metadata-enum-field/metadata-enum-field.d.ts +1 -1
- package/dist/types/lib/components/metadata-filter-fields/components/metadata-float-field/metadata-float-field-advanced.d.ts +1 -1
- package/dist/types/lib/components/metadata-filter-fields/components/metadata-float-field/metadata-float-field.d.ts +1 -1
- package/dist/types/lib/components/metadata-filter-fields/components/metadata-multi-select-field/metadata-multi-select-field-advanced.d.ts +1 -1
- package/dist/types/lib/components/metadata-filter-fields/components/metadata-multi-select-field/metadata-multi-select-field.d.ts +1 -1
- package/dist/types/lib/components/metadata-filter-fields/components/metadata-string-field/metadata-string-field.d.ts +1 -1
- package/dist/types/lib/components/metadata-filter-fields/components/metadata-taxonomy-field/metadata-taxonomy-field.d.ts +1 -1
- package/dist/types/lib/components/metadata-filter-fields/field-processing-utils.d.ts +26 -0
- package/dist/types/lib/components/metadata-filter-fields/metadata-filter-fields-accordion.d.ts +3 -0
- package/dist/types/lib/components/metadata-filter-fields/types.d.ts +2 -0
- package/dist/types/lib/messages.d.ts +10 -0
- package/dist/types/lib/metadata-filter.d.ts +1 -1
- package/dist/types/lib/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { useIntl as
|
|
3
|
-
import
|
|
4
|
-
import { R as
|
|
5
|
-
let
|
|
1
|
+
import { useState as I } from "react";
|
|
2
|
+
import { useIntl as d } from "react-intl";
|
|
3
|
+
import e from "../esm/lib/messages.js";
|
|
4
|
+
import { R as p } from "./types.js";
|
|
5
|
+
let V = /* @__PURE__ */ function(t) {
|
|
6
6
|
return t[t.INVALID = 0] = "INVALID", t[t.OVERLAPPING = 1] = "OVERLAPPING", t;
|
|
7
7
|
}({});
|
|
8
|
-
const
|
|
9
|
-
const
|
|
8
|
+
const c = (t, r = !1) => t != null && t.length ? r ? /^[-+]?(\d+(\.\d*)?|\.\d+)$/.test(t) : /^[-+]?\d+(\.\d+)?$/.test(t) : !0, R = (t, r, a) => {
|
|
9
|
+
const n = parseFloat(t), l = parseFloat(r);
|
|
10
|
+
return a ? l <= n : l < n;
|
|
11
|
+
}, O = (t, r, a) => r ? t ? a.formatMessage(e.floatFieldInvalidMinValueRange) : a.formatMessage(e.floatFieldInvalidMaxValueRange) : t ? a.formatMessage(e.floatFieldInvalidFromValueRange) : a.formatMessage(e.floatFieldInvalidToValueRange), M = (t, r, a) => r ? a.formatMessage(e.mustBeANumber) : t ? a.formatMessage(e.floatFieldInvalidFromValue) : a.formatMessage(e.floatFieldInvalidToValue), A = () => {
|
|
12
|
+
const t = d(), [r, a] = I(null), [n, l] = I(null), u = (i, s) => i === p.FROM ? a(s) : l(s);
|
|
10
13
|
return {
|
|
11
|
-
validateFloats: (
|
|
12
|
-
const
|
|
13
|
-
if (!(
|
|
14
|
-
return
|
|
15
|
-
if (
|
|
16
|
-
return
|
|
14
|
+
validateFloats: (i, s, f, o = !1) => {
|
|
15
|
+
const g = f === p.FROM, m = c(i, o), F = c(s, o);
|
|
16
|
+
if (!(g ? m : F))
|
|
17
|
+
return u(f, V.INVALID), M(g, o, t);
|
|
18
|
+
if (m && F && R(i, s, o))
|
|
19
|
+
return u(f, V.OVERLAPPING), O(g, o, t);
|
|
17
20
|
},
|
|
18
|
-
fromErrorType:
|
|
19
|
-
toErrorType:
|
|
21
|
+
fromErrorType: r,
|
|
22
|
+
toErrorType: n
|
|
20
23
|
};
|
|
21
24
|
};
|
|
22
25
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
+
V as E,
|
|
27
|
+
c as i,
|
|
28
|
+
A as u
|
|
26
29
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { DateI18nProvider as
|
|
2
|
-
import
|
|
3
|
-
import { useFormikContext as
|
|
4
|
-
import { useState as L, useRef as X, useCallback as v, useEffect as
|
|
5
|
-
import { useIntl as
|
|
1
|
+
import { DateI18nProvider as de, DatePicker as H, TextInput as ue } from "@box/blueprint-web";
|
|
2
|
+
import me from "clsx";
|
|
3
|
+
import { useFormikContext as fe, getIn as ve, Field as b } from "formik";
|
|
4
|
+
import { useState as L, useRef as X, useCallback as v, useEffect as pe, useMemo as q } from "react";
|
|
5
|
+
import { useIntl as he } from "react-intl";
|
|
6
6
|
import { R as n } from "../../../../../../chunks/types.js";
|
|
7
7
|
import { DEFAULT_MAX_DATE as z } from "./constants.js";
|
|
8
8
|
import { getRelativeFromToValues as J, convertToFormikValueRanged as K } from "./date-conversion-utils.js";
|
|
9
9
|
import { s as p } from "../../../../../../chunks/metadata-date-field.module.js";
|
|
10
10
|
import { E as A } from "../../../../../../chunks/types2.js";
|
|
11
|
-
import { useDateValidation as
|
|
12
|
-
import { useIntegerValidation as
|
|
11
|
+
import { useDateValidation as ge } from "./use-date-validation.js";
|
|
12
|
+
import { useIntegerValidation as Fe } from "./use-integer-validation.js";
|
|
13
13
|
import { getDynamicMaxMinValue as Q } from "./utils.js";
|
|
14
14
|
import i from "../../../../messages.js";
|
|
15
15
|
import { jsx as s, jsxs as W } from "react/jsx-runtime";
|
|
16
|
-
import { A as
|
|
17
|
-
const
|
|
16
|
+
import { A as Me } from "../../../../../../chunks/index.js";
|
|
17
|
+
const Ue = ({
|
|
18
18
|
disableForm: h,
|
|
19
19
|
fieldNamePrefix: d,
|
|
20
20
|
label: N,
|
|
@@ -22,21 +22,22 @@ const Pe = ({
|
|
|
22
22
|
portalElement: D,
|
|
23
23
|
filterOptionsMap: Y,
|
|
24
24
|
onAdvancedFilterOptionChange: g,
|
|
25
|
-
fieldAdvancedFilterOptions: I
|
|
25
|
+
fieldAdvancedFilterOptions: I,
|
|
26
|
+
hasAccordion: Z
|
|
26
27
|
}) => {
|
|
27
28
|
const T = `${d}.value.advancedFilterOption`, u = `${d}.value.relativeDays`, r = `${d}.value.range.gt`, o = `${d}.value.range.lt`, {
|
|
28
29
|
values: E,
|
|
29
30
|
setFieldValue: a,
|
|
30
31
|
setFieldTouched: B
|
|
31
|
-
} =
|
|
32
|
+
} = fe(), {
|
|
32
33
|
validateDates: S,
|
|
33
34
|
fromDatePickerValue: F,
|
|
34
35
|
toDatePickerValue: M,
|
|
35
36
|
fromErrorType: x,
|
|
36
37
|
toErrorType: P
|
|
37
|
-
} =
|
|
38
|
-
validatePositiveInteger:
|
|
39
|
-
} =
|
|
38
|
+
} = ge(E, r, o, C, !0), {
|
|
39
|
+
validatePositiveInteger: ee
|
|
40
|
+
} = Fe(), l = he(), [m, te] = L(I || ""), [U, V] = L(!1), c = ve(E, u), [_, O] = L(n.FROM), R = X(F), k = X(M), $ = {
|
|
40
41
|
clearDatePickerAriaLabel: l.formatMessage(i.clearSelectedDate),
|
|
41
42
|
nextMonthAriaLabel: l.formatMessage(i.switchToNextMonth),
|
|
42
43
|
openCalendarDropdownAriaLabel: l.formatMessage(i.openCalendar),
|
|
@@ -62,31 +63,31 @@ const Pe = ({
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
}, [m, c, r, o, a]);
|
|
65
|
-
|
|
66
|
+
pe(() => {
|
|
66
67
|
U && (w(), V(!1));
|
|
67
68
|
}, [U, w]);
|
|
68
|
-
const
|
|
69
|
+
const ae = v((e) => {
|
|
69
70
|
const t = e;
|
|
70
|
-
|
|
71
|
+
te(t), a(T, t), g && g(d, t);
|
|
71
72
|
const f = () => {
|
|
72
73
|
a(u, void 0), a(r, void 0), a(o, void 0);
|
|
73
74
|
}, y = () => {
|
|
74
75
|
a(r, void 0), a(o, void 0);
|
|
75
76
|
};
|
|
76
77
|
["isBlank", "isNotBlank", "selectFilterType"].includes(t) || !t || t === "customRange" ? f() : t === "today" ? (a(u, void 0), V(!0)) : y();
|
|
77
|
-
}, [d, g, a, T, u, r, o]),
|
|
78
|
+
}, [d, g, a, T, u, r, o]), re = v((e) => {
|
|
78
79
|
a(u, e), Number(e) > 0 && V(!0);
|
|
79
|
-
}, [a, u]),
|
|
80
|
+
}, [a, u]), oe = v((e) => {
|
|
80
81
|
const t = K(e, n.FROM);
|
|
81
82
|
R.current = e, a(r, t), O(n.FROM);
|
|
82
|
-
}, [a, r]),
|
|
83
|
+
}, [a, r]), ne = v((e) => {
|
|
83
84
|
const t = K(e, n.TO);
|
|
84
85
|
k.current = e, a(o, t), O(n.TO);
|
|
85
86
|
}, [a, o]), j = v((e) => {
|
|
86
87
|
const t = e === n.FROM ? r : o;
|
|
87
88
|
B(t, !0), O(e);
|
|
88
|
-
}, [B, r, o]),
|
|
89
|
-
className:
|
|
89
|
+
}, [B, r, o]), se = q(() => Q(M, z), [M]), le = q(() => Q(F), [F]), G = (e, t, f) => !!(t === A.MAX && e === A.OVERLAPPING || e === A.OVERLAPPING && f), ie = ["isBlank", "isNotBlank", "selectFilterType", "today"], ce = () => !m || ie.includes(m) ? null : m === "customRange" ? /* @__PURE__ */ W("div", {
|
|
90
|
+
className: me(p.rangeInputsContainer, p.verticalLayout),
|
|
90
91
|
children: [/* @__PURE__ */ s(b, {
|
|
91
92
|
name: r,
|
|
92
93
|
validate: (e) => S(R.current, k.current, n.FROM),
|
|
@@ -102,9 +103,9 @@ const Pe = ({
|
|
|
102
103
|
error: !G(x, P, _ !== n.FROM) && t.error,
|
|
103
104
|
isDisabled: h,
|
|
104
105
|
label: l.formatMessage(i.afterDate),
|
|
105
|
-
maxValue:
|
|
106
|
+
maxValue: se,
|
|
106
107
|
onBlur: () => j(n.FROM),
|
|
107
|
-
onChange:
|
|
108
|
+
onChange: oe,
|
|
108
109
|
portalElement: D,
|
|
109
110
|
value: F
|
|
110
111
|
})
|
|
@@ -125,9 +126,9 @@ const Pe = ({
|
|
|
125
126
|
isDisabled: h,
|
|
126
127
|
label: l.formatMessage(i.beforeDate),
|
|
127
128
|
maxValue: z,
|
|
128
|
-
minValue:
|
|
129
|
+
minValue: le,
|
|
129
130
|
onBlur: () => j(n.TO),
|
|
130
|
-
onChange:
|
|
131
|
+
onChange: ne,
|
|
131
132
|
portalElement: D,
|
|
132
133
|
value: M
|
|
133
134
|
})
|
|
@@ -135,30 +136,30 @@ const Pe = ({
|
|
|
135
136
|
})]
|
|
136
137
|
}) : /* @__PURE__ */ s(b, {
|
|
137
138
|
name: u,
|
|
138
|
-
validate: (e) =>
|
|
139
|
+
validate: (e) => ee((e == null ? void 0 : e.toString()) || ""),
|
|
139
140
|
children: ({
|
|
140
141
|
field: e,
|
|
141
142
|
meta: t
|
|
142
143
|
}) => /* @__PURE__ */ s("div", {
|
|
143
144
|
className: p.daysInputContainer,
|
|
144
|
-
children: /* @__PURE__ */ s(
|
|
145
|
+
children: /* @__PURE__ */ s(ue, {
|
|
145
146
|
...e,
|
|
146
147
|
disabled: h,
|
|
147
148
|
error: t.touched && t.error,
|
|
148
149
|
hideLabel: !0,
|
|
149
150
|
label: l.formatMessage(i.relativeDaysSelectLabel),
|
|
150
|
-
onChange: (f) =>
|
|
151
|
+
onChange: (f) => re(f.target.value),
|
|
151
152
|
placeholder: l.formatMessage(i.numberOfDays),
|
|
152
153
|
value: (c == null ? void 0 : c.toString()) || ""
|
|
153
154
|
})
|
|
154
155
|
})
|
|
155
156
|
});
|
|
156
|
-
return /* @__PURE__ */ s(
|
|
157
|
+
return /* @__PURE__ */ s(de, {
|
|
157
158
|
locale: C,
|
|
158
159
|
children: /* @__PURE__ */ W("div", {
|
|
159
160
|
className: p.advancedDateContainer,
|
|
160
161
|
"data-testid": `${N}-advanced-field`,
|
|
161
|
-
children: [/* @__PURE__ */ s(
|
|
162
|
+
children: [/* @__PURE__ */ s(Me, {
|
|
162
163
|
advancedFilterFieldName: T,
|
|
163
164
|
disableForm: h,
|
|
164
165
|
fieldAdvancedFilterOptions: I,
|
|
@@ -166,15 +167,15 @@ const Pe = ({
|
|
|
166
167
|
filterOptionsMap: Y,
|
|
167
168
|
label: N,
|
|
168
169
|
onAdvancedFilterOptionChange: g,
|
|
169
|
-
onValueChange:
|
|
170
|
+
onValueChange: ae,
|
|
170
171
|
portalElement: D,
|
|
171
|
-
showLabel: !
|
|
172
|
+
showLabel: !Z,
|
|
172
173
|
value: m
|
|
173
|
-
}),
|
|
174
|
+
}), ce()]
|
|
174
175
|
})
|
|
175
176
|
});
|
|
176
177
|
};
|
|
177
178
|
export {
|
|
178
|
-
|
|
179
|
-
|
|
179
|
+
Ue as MetadataDateFieldAdvanced,
|
|
180
|
+
Ue as default
|
|
180
181
|
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { DateI18nProvider as
|
|
2
|
-
import
|
|
3
|
-
import { useFormikContext as
|
|
4
|
-
import { useState as x, useRef as A, useCallback as
|
|
5
|
-
import { useIntl as
|
|
1
|
+
import { DateI18nProvider as xe, Text as Ae, Radio as i, Select as p, DatePicker as se } from "@box/blueprint-web";
|
|
2
|
+
import Le from "clsx";
|
|
3
|
+
import { useFormikContext as Ie, getIn as O, Field as oe } from "formik";
|
|
4
|
+
import { useState as x, useRef as A, useCallback as Ne, useEffect as ie, useMemo as ce } from "react";
|
|
5
|
+
import { useIntl as ke } from "react-intl";
|
|
6
6
|
import { R as c } from "../../../../../../chunks/types.js";
|
|
7
7
|
import { DEFAULT_MAX_DATE as ue } from "./constants.js";
|
|
8
|
-
import { getRelativeFromToValues as
|
|
8
|
+
import { getRelativeFromToValues as Ee, 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
10
|
import { E as G } from "../../../../../../chunks/types2.js";
|
|
11
|
-
import { useDateValidation as
|
|
11
|
+
import { useDateValidation as Pe } from "./use-date-validation.js";
|
|
12
12
|
import { getDynamicMaxMinValue as fe } from "./utils.js";
|
|
13
13
|
import r from "../../../../messages.js";
|
|
14
14
|
import { jsx as l, jsxs as L } from "react/jsx-runtime";
|
|
@@ -16,48 +16,49 @@ const ve = {
|
|
|
16
16
|
next: r.nextDaysAmt,
|
|
17
17
|
past: r.pastDaysAmt,
|
|
18
18
|
olderThan: r.olderThanDaysAmt
|
|
19
|
-
},
|
|
19
|
+
}, $e = [1, 3, 15, 45, 60, 120, 365], ge = (u) => u in ve || u === "today" || u === "customRange", Ye = ({
|
|
20
20
|
customDateFilterOptions: u,
|
|
21
21
|
disableForm: C,
|
|
22
22
|
fieldNamePrefix: h,
|
|
23
23
|
label: U,
|
|
24
24
|
locale: j,
|
|
25
|
-
portalElement: b
|
|
25
|
+
portalElement: b,
|
|
26
|
+
hasAccordion: he
|
|
26
27
|
}) => {
|
|
27
28
|
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`, {
|
|
28
29
|
values: F,
|
|
29
|
-
setFieldTouched:
|
|
30
|
+
setFieldTouched: pe,
|
|
30
31
|
setFieldValue: s
|
|
31
|
-
} =
|
|
32
|
+
} = Ie(), {
|
|
32
33
|
validateDates: z,
|
|
33
34
|
fromDatePickerValue: T,
|
|
34
35
|
toDatePickerValue: y,
|
|
35
36
|
fromErrorType: J,
|
|
36
37
|
toErrorType: K
|
|
37
|
-
} =
|
|
38
|
+
} = Pe(F, m, d, j, !0), n = ke(), g = O(F, H), v = O(F, q), Fe = T || y;
|
|
38
39
|
let P = "anyTime", $ = "anyTime";
|
|
39
|
-
ge(g) ? P = g : v ? $ = v :
|
|
40
|
+
ge(g) ? P = g : v ? $ = v : Fe && (P = "customRange", $ = "customRange");
|
|
40
41
|
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 = {
|
|
41
42
|
clearDatePickerAriaLabel: n.formatMessage(r.clearSelectedDate),
|
|
42
43
|
nextMonthAriaLabel: n.formatMessage(r.switchToNextMonth),
|
|
43
44
|
openCalendarDropdownAriaLabel: n.formatMessage(r.openCalendar),
|
|
44
45
|
previousMonthAriaLabel: n.formatMessage(r.switchToNextMonth)
|
|
45
|
-
},
|
|
46
|
+
}, Te = () => {
|
|
46
47
|
s(m, void 0), s(d, void 0), V.current = void 0, M.current = void 0;
|
|
47
|
-
},
|
|
48
|
+
}, ye = (e) => {
|
|
48
49
|
const a = me(e, c.FROM);
|
|
49
50
|
V.current = e, s(m, a), I(c.FROM);
|
|
50
|
-
},
|
|
51
|
+
}, De = (e) => {
|
|
51
52
|
const a = me(e, c.TO);
|
|
52
53
|
M.current = e, s(d, a), I(c.TO);
|
|
53
54
|
}, te = (e) => {
|
|
54
55
|
const a = e === c.FROM ? m : d;
|
|
55
|
-
|
|
56
|
-
},
|
|
56
|
+
pe(a, !0), I(e);
|
|
57
|
+
}, Ve = (e) => {
|
|
57
58
|
let a;
|
|
58
59
|
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);
|
|
59
|
-
},
|
|
60
|
-
s(q, e), ee(e), s(E, void 0),
|
|
60
|
+
}, Me = (e) => {
|
|
61
|
+
s(q, e), ee(e), s(E, void 0), Te();
|
|
61
62
|
const a = u.find((t) => t.name === e);
|
|
62
63
|
if (a && a.type === "text") {
|
|
63
64
|
const {
|
|
@@ -66,11 +67,11 @@ const ve = {
|
|
|
66
67
|
} = de(a.from, a.to);
|
|
67
68
|
s(m, t), s(d, o);
|
|
68
69
|
}
|
|
69
|
-
}, le =
|
|
70
|
+
}, le = Ne(() => {
|
|
70
71
|
const {
|
|
71
72
|
from: e,
|
|
72
73
|
to: a
|
|
73
|
-
} =
|
|
74
|
+
} = Ee(D, S);
|
|
74
75
|
s(m, e), s(d, a);
|
|
75
76
|
}, [m, S, D, s, d]);
|
|
76
77
|
ie(() => {
|
|
@@ -79,7 +80,7 @@ const ve = {
|
|
|
79
80
|
const e = W.current !== g, a = Y.current !== v;
|
|
80
81
|
(e || a) && (Q(g ?? "anyTime"), ee(v), W.current = g, Y.current = v);
|
|
81
82
|
}, [g, v]);
|
|
82
|
-
const
|
|
83
|
+
const Re = ce(() => fe(y, ue), [y]), Ce = ce(() => fe(T), [T]), re = (e, a, t) => !!(a === G.MAX && e === G.OVERLAPPING || e === G.OVERLAPPING && t), B = (e) => {
|
|
83
84
|
if (e !== D)
|
|
84
85
|
return null;
|
|
85
86
|
const a = (o) => {
|
|
@@ -90,7 +91,7 @@ const ve = {
|
|
|
90
91
|
count: o
|
|
91
92
|
})
|
|
92
93
|
};
|
|
93
|
-
}, t =
|
|
94
|
+
}, t = $e.map(a);
|
|
94
95
|
return /* @__PURE__ */ l(p, {
|
|
95
96
|
className: f.dateSelect,
|
|
96
97
|
defaultValue: S === void 0 ? "" : String(S),
|
|
@@ -108,7 +109,7 @@ const ve = {
|
|
|
108
109
|
}, o.value))
|
|
109
110
|
})
|
|
110
111
|
});
|
|
111
|
-
},
|
|
112
|
+
}, be = (e, a) => e !== w ? null : /* @__PURE__ */ l(p, {
|
|
112
113
|
className: f.dateSelect,
|
|
113
114
|
defaultValue: Z === void 0 ? "" : String(Z),
|
|
114
115
|
label: n.formatMessage(r.relativeDaysSelectLabel),
|
|
@@ -117,9 +118,9 @@ const ve = {
|
|
|
117
118
|
if (o) {
|
|
118
119
|
const {
|
|
119
120
|
from: R,
|
|
120
|
-
to:
|
|
121
|
+
to: Oe
|
|
121
122
|
} = de(o.from, o.to);
|
|
122
|
-
s(m, R), s(d,
|
|
123
|
+
s(m, R), s(d, Oe), s(E, o.name);
|
|
123
124
|
}
|
|
124
125
|
},
|
|
125
126
|
placeholder: n.formatMessage(r.selectValuePlaceholder),
|
|
@@ -131,10 +132,10 @@ const ve = {
|
|
|
131
132
|
children: t.name
|
|
132
133
|
}, t.name))
|
|
133
134
|
})
|
|
134
|
-
}),
|
|
135
|
+
}), Se = () => /* @__PURE__ */ L(i.Group, {
|
|
135
136
|
disabled: C,
|
|
136
137
|
loop: !1,
|
|
137
|
-
onValueChange:
|
|
138
|
+
onValueChange: Me,
|
|
138
139
|
value: w,
|
|
139
140
|
children: [/* @__PURE__ */ l(i.Item, {
|
|
140
141
|
label: n.formatMessage(r.relativeDateFilterAnyTime),
|
|
@@ -150,7 +151,7 @@ const ve = {
|
|
|
150
151
|
options: t
|
|
151
152
|
} = e;
|
|
152
153
|
return /* @__PURE__ */ l(i.Item, {
|
|
153
|
-
description: t ?
|
|
154
|
+
description: t ? be(a, t) : void 0,
|
|
154
155
|
label: a,
|
|
155
156
|
value: a
|
|
156
157
|
}, a);
|
|
@@ -160,7 +161,7 @@ const ve = {
|
|
|
160
161
|
value: "customRange"
|
|
161
162
|
})]
|
|
162
163
|
}), ne = () => !u && D !== "customRange" || u && w !== "customRange" ? null : /* @__PURE__ */ L("div", {
|
|
163
|
-
className:
|
|
164
|
+
className: Le(f.rangeInputsContainer, f.verticalLayout, f.dateSelect),
|
|
164
165
|
children: [/* @__PURE__ */ l(oe, {
|
|
165
166
|
name: m,
|
|
166
167
|
validate: (e) => z(V.current, M.current, c.FROM),
|
|
@@ -176,9 +177,9 @@ const ve = {
|
|
|
176
177
|
error: re(J, K, X !== c.FROM) ? void 0 : a.error,
|
|
177
178
|
isDisabled: C,
|
|
178
179
|
label: n.formatMessage(r.fieldStartDateLabel),
|
|
179
|
-
maxValue:
|
|
180
|
+
maxValue: Re,
|
|
180
181
|
onBlur: () => te(c.FROM),
|
|
181
|
-
onChange: (t) =>
|
|
182
|
+
onChange: (t) => ye(t),
|
|
182
183
|
portalElement: b,
|
|
183
184
|
value: T
|
|
184
185
|
})
|
|
@@ -199,30 +200,30 @@ const ve = {
|
|
|
199
200
|
isDisabled: C,
|
|
200
201
|
label: n.formatMessage(r.fieldEndDateLabel),
|
|
201
202
|
maxValue: ue,
|
|
202
|
-
minValue:
|
|
203
|
+
minValue: Ce,
|
|
203
204
|
onBlur: () => te(c.TO),
|
|
204
|
-
onChange: (t) =>
|
|
205
|
+
onChange: (t) => De(t),
|
|
205
206
|
portalElement: b,
|
|
206
207
|
value: y
|
|
207
208
|
})
|
|
208
209
|
})
|
|
209
210
|
})]
|
|
210
211
|
});
|
|
211
|
-
return /* @__PURE__ */ l(
|
|
212
|
+
return /* @__PURE__ */ l(xe, {
|
|
212
213
|
locale: j,
|
|
213
214
|
children: /* @__PURE__ */ L("div", {
|
|
214
215
|
className: f.container,
|
|
215
216
|
"data-testid": `${U}-field`,
|
|
216
|
-
children: [/* @__PURE__ */ l(
|
|
217
|
+
children: [!he && /* @__PURE__ */ l(Ae, {
|
|
217
218
|
as: "span",
|
|
218
219
|
className: f.rangeFieldLabel,
|
|
219
220
|
color: "textOnLightSecondary",
|
|
220
221
|
variant: "bodyDefaultBold",
|
|
221
222
|
children: U
|
|
222
|
-
}), u ?
|
|
223
|
+
}), u ? Se() : /* @__PURE__ */ L(i.Group, {
|
|
223
224
|
disabled: C,
|
|
224
225
|
loop: !1,
|
|
225
|
-
onValueChange:
|
|
226
|
+
onValueChange: Ve,
|
|
226
227
|
value: D,
|
|
227
228
|
children: [/* @__PURE__ */ l(i.Item, {
|
|
228
229
|
label: n.formatMessage(r.relativeDateFilterAnyTime),
|
|
@@ -252,6 +253,6 @@ const ve = {
|
|
|
252
253
|
});
|
|
253
254
|
};
|
|
254
255
|
export {
|
|
255
|
-
|
|
256
|
-
|
|
256
|
+
Ye as MetadataDateFieldRelative,
|
|
257
|
+
Ye as default
|
|
257
258
|
};
|
|
@@ -1,71 +1,72 @@
|
|
|
1
|
-
import { Text as
|
|
2
|
-
import { useFormikContext as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { useIntl as
|
|
1
|
+
import { Text as K, DateI18nProvider as Q, DatePicker as P } from "@box/blueprint-web";
|
|
2
|
+
import { useFormikContext as W, Field as y } from "formik";
|
|
3
|
+
import { useState as Y, useRef as E, useMemo as I } from "react";
|
|
4
|
+
import { useIntl as Z } from "react-intl";
|
|
5
5
|
import n from "../../../../messages.js";
|
|
6
6
|
import { R as a } from "../../../../../../chunks/types.js";
|
|
7
7
|
import { DEFAULT_MAX_DATE as $ } from "./constants.js";
|
|
8
8
|
import { convertToFormikValue as B } from "./date-conversion-utils.js";
|
|
9
|
-
import { MetadataDateFieldRelative as
|
|
9
|
+
import { MetadataDateFieldRelative as ee } from "./metadata-date-field-relative.js";
|
|
10
10
|
import { s as i } from "../../../../../../chunks/metadata-date-field.module.js";
|
|
11
11
|
import { E as g } from "../../../../../../chunks/types2.js";
|
|
12
|
-
import { useDateInternationalization as
|
|
13
|
-
import { useDateValidation as
|
|
12
|
+
import { useDateInternationalization as ae } from "./use-date-internationalization.js";
|
|
13
|
+
import { useDateValidation as re } from "./use-date-validation.js";
|
|
14
14
|
import { getDynamicMaxMinValue as w } from "./utils.js";
|
|
15
15
|
import { jsx as t, jsxs as z } from "react/jsx-runtime";
|
|
16
|
-
const
|
|
16
|
+
const ve = ({
|
|
17
17
|
canUseRelativeDates: f,
|
|
18
18
|
...s
|
|
19
|
-
}) => f ? /* @__PURE__ */ t(
|
|
19
|
+
}) => f ? /* @__PURE__ */ t(ee, {
|
|
20
20
|
...s
|
|
21
|
-
}) : /* @__PURE__ */ t(
|
|
21
|
+
}) : /* @__PURE__ */ t(te, {
|
|
22
22
|
...s
|
|
23
|
-
}),
|
|
23
|
+
}), te = ({
|
|
24
24
|
customFieldLabels: f = [],
|
|
25
25
|
direction: s = "horizontal",
|
|
26
26
|
disableForm: v,
|
|
27
27
|
fieldNamePrefix: D,
|
|
28
28
|
label: O,
|
|
29
29
|
locale: M,
|
|
30
|
-
portalElement: T
|
|
30
|
+
portalElement: T,
|
|
31
|
+
hasAccordion: S
|
|
31
32
|
}) => {
|
|
32
|
-
const [L, h] =
|
|
33
|
-
values:
|
|
34
|
-
setFieldTouched:
|
|
33
|
+
const [L, h] = Y(a.FROM), m = `${D}.value.range.gt`, c = `${D}.value.range.lt`, {
|
|
34
|
+
values: j,
|
|
35
|
+
setFieldTouched: G,
|
|
35
36
|
setFieldValue: V
|
|
36
|
-
} =
|
|
37
|
+
} = W(), {
|
|
37
38
|
localTimezone: R
|
|
38
|
-
} =
|
|
39
|
+
} = ae(M), {
|
|
39
40
|
validateDates: b,
|
|
40
41
|
fromDatePickerValue: d,
|
|
41
42
|
toDatePickerValue: u,
|
|
42
43
|
fromErrorType: x,
|
|
43
44
|
toErrorType: A
|
|
44
|
-
} =
|
|
45
|
+
} = re(j, m, c, M, !1), o = Z(), F = E(d), p = E(u), C = {
|
|
45
46
|
clearDatePickerAriaLabel: o.formatMessage(n.clearSelectedDate),
|
|
46
47
|
nextMonthAriaLabel: o.formatMessage(n.switchToNextMonth),
|
|
47
48
|
openCalendarDropdownAriaLabel: o.formatMessage(n.openCalendar),
|
|
48
49
|
previousMonthAriaLabel: o.formatMessage(n.switchToNextMonth)
|
|
49
|
-
}, [
|
|
50
|
+
}, [X, _] = f, H = (e) => {
|
|
50
51
|
const r = B(e, R, a.FROM);
|
|
51
52
|
F.current = e, V(m, r), h(a.FROM);
|
|
52
|
-
},
|
|
53
|
+
}, U = (e) => {
|
|
53
54
|
const r = B(e, R, a.TO);
|
|
54
55
|
p.current = e, V(c, r), h(a.TO);
|
|
55
56
|
}, N = (e) => {
|
|
56
57
|
const r = e === a.FROM ? m : c;
|
|
57
|
-
|
|
58
|
-
},
|
|
58
|
+
G(r, !0), h(e);
|
|
59
|
+
}, q = I(() => w(u, $), [u]), J = I(() => w(d), [d]), k = (e, r, l) => !!(r === g.MAX && e === g.OVERLAPPING || e === g.OVERLAPPING && l);
|
|
59
60
|
return /* @__PURE__ */ z("div", {
|
|
60
61
|
className: i.container,
|
|
61
62
|
"data-testid": `${O}-field`,
|
|
62
|
-
children: [/* @__PURE__ */ t(
|
|
63
|
+
children: [!S && /* @__PURE__ */ t(K, {
|
|
63
64
|
as: "span",
|
|
64
65
|
className: i.rangeFieldLabel,
|
|
65
66
|
color: "textOnLightSecondary",
|
|
66
67
|
variant: "bodyDefaultBold",
|
|
67
68
|
children: O
|
|
68
|
-
}), /* @__PURE__ */ t(
|
|
69
|
+
}), /* @__PURE__ */ t(Q, {
|
|
69
70
|
locale: M,
|
|
70
71
|
children: /* @__PURE__ */ z("div", {
|
|
71
72
|
className: `${i.rangeInputsContainer} ${s === "vertical" ? i.verticalLayout : ""}`,
|
|
@@ -83,10 +84,10 @@ const ge = ({
|
|
|
83
84
|
calendarAriaLabel: o.formatMessage(n.selectFromDate),
|
|
84
85
|
error: k(x, A, L !== a.FROM) ? void 0 : r.error,
|
|
85
86
|
isDisabled: v,
|
|
86
|
-
label:
|
|
87
|
-
maxValue:
|
|
87
|
+
label: X || o.formatMessage(n.fieldFromLabel),
|
|
88
|
+
maxValue: q,
|
|
88
89
|
onBlur: () => N(a.FROM),
|
|
89
|
-
onChange: (l) =>
|
|
90
|
+
onChange: (l) => H(l),
|
|
90
91
|
portalElement: T,
|
|
91
92
|
value: d
|
|
92
93
|
})
|
|
@@ -105,11 +106,11 @@ const ge = ({
|
|
|
105
106
|
calendarAriaLabel: o.formatMessage(n.selectToDate),
|
|
106
107
|
error: k(A, x, L !== a.TO) ? void 0 : r.error,
|
|
107
108
|
isDisabled: v,
|
|
108
|
-
label:
|
|
109
|
+
label: _ || o.formatMessage(n.fieldToLabel),
|
|
109
110
|
maxValue: $,
|
|
110
|
-
minValue:
|
|
111
|
+
minValue: J,
|
|
111
112
|
onBlur: () => N(a.TO),
|
|
112
|
-
onChange: (l) =>
|
|
113
|
+
onChange: (l) => U(l),
|
|
113
114
|
portalElement: T,
|
|
114
115
|
value: u
|
|
115
116
|
})
|
|
@@ -120,7 +121,7 @@ const ge = ({
|
|
|
120
121
|
});
|
|
121
122
|
};
|
|
122
123
|
export {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
124
|
+
ve as MetadataDateField,
|
|
125
|
+
te as MetadataDateFieldNonRelative,
|
|
126
|
+
ve as default
|
|
126
127
|
};
|
|
@@ -1,42 +1,44 @@
|
|
|
1
1
|
import { Select as l, SELECT_EMPTY_VALUE as n } from "@box/blueprint-web";
|
|
2
|
-
import { useFormikContext as
|
|
3
|
-
import { useIntl as
|
|
4
|
-
import
|
|
5
|
-
import { jsx as t, jsxs as
|
|
6
|
-
const
|
|
7
|
-
disableForm:
|
|
2
|
+
import { useFormikContext as g, getIn as x, Field as E } from "formik";
|
|
3
|
+
import { useIntl as F, FormattedMessage as M } from "react-intl";
|
|
4
|
+
import m from "../../../../messages.js";
|
|
5
|
+
import { jsx as t, jsxs as V } from "react/jsx-runtime";
|
|
6
|
+
const O = ({
|
|
7
|
+
disableForm: u,
|
|
8
8
|
fieldNamePrefix: o,
|
|
9
9
|
label: d,
|
|
10
|
-
portalElement: h
|
|
10
|
+
portalElement: h,
|
|
11
|
+
hasAccordion: p
|
|
11
12
|
}) => {
|
|
12
13
|
const {
|
|
13
14
|
setFieldValue: c,
|
|
14
|
-
values:
|
|
15
|
-
} =
|
|
15
|
+
values: v
|
|
16
|
+
} = g(), f = F(), s = `${o}.value.enum[0]`, r = x(v, `${o}.options`, []).map(({
|
|
16
17
|
key: a
|
|
17
|
-
}) => a),
|
|
18
|
+
}) => a), i = f.formatMessage(m.selectValuePlaceholder);
|
|
18
19
|
return /* @__PURE__ */ t("div", {
|
|
19
20
|
"data-testid": `${d}-field`,
|
|
20
|
-
children: /* @__PURE__ */ t(
|
|
21
|
+
children: /* @__PURE__ */ t(E, {
|
|
21
22
|
name: s,
|
|
22
23
|
children: ({
|
|
23
24
|
field: a
|
|
24
25
|
}) => /* @__PURE__ */ t(l, {
|
|
25
|
-
disabled:
|
|
26
|
+
disabled: u,
|
|
27
|
+
hideLabel: p,
|
|
26
28
|
label: d,
|
|
27
29
|
onValueChange: (e) => {
|
|
28
30
|
e === n ? c(s, "") : c(s, e);
|
|
29
31
|
},
|
|
30
|
-
placeholder:
|
|
32
|
+
placeholder: i,
|
|
31
33
|
...a,
|
|
32
34
|
value: a.value === n ? "" : a.value,
|
|
33
|
-
children: /* @__PURE__ */
|
|
35
|
+
children: /* @__PURE__ */ V(l.Content, {
|
|
34
36
|
container: h,
|
|
35
37
|
children: [/* @__PURE__ */ t(l.Option, {
|
|
36
|
-
text:
|
|
38
|
+
text: i,
|
|
37
39
|
value: n,
|
|
38
|
-
children: /* @__PURE__ */ t(
|
|
39
|
-
...
|
|
40
|
+
children: /* @__PURE__ */ t(M, {
|
|
41
|
+
...m.selectValuePlaceholder
|
|
40
42
|
})
|
|
41
43
|
}), r == null ? void 0 : r.map((e) => /* @__PURE__ */ t(l.Option, {
|
|
42
44
|
text: e,
|
|
@@ -49,6 +51,6 @@ const L = ({
|
|
|
49
51
|
});
|
|
50
52
|
};
|
|
51
53
|
export {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
O as MetadataEnumField,
|
|
55
|
+
O as default
|
|
54
56
|
};
|