@box/metadata-filter 1.18.10 → 1.19.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/esm/lib/components/metadata-filter-fields/components/metadata-date-field/date-conversion-utils.js +46 -32
- package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field-relative.js +214 -147
- package/dist/esm/lib/defaults.js +6 -5
- package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/date-conversion-utils.d.ts +4 -0
- 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 +2 -2
- package/dist/types/lib/components/metadata-filter-fields/types.d.ts +13 -0
- package/dist/types/lib/types.d.ts +2 -0
- package/package.json +2 -2
|
@@ -1,37 +1,42 @@
|
|
|
1
|
-
import { Time as
|
|
2
|
-
import { fromAbsolute as
|
|
3
|
-
import { parseAbsoluteToLocal as
|
|
4
|
-
import { parseAbsolute as
|
|
5
|
-
import { toCalendarDateTime as
|
|
6
|
-
import { toCalendarDate as
|
|
1
|
+
import { Time as u } from "@box/blueprint-web/lib-esm/primitives/calendar/classes.util";
|
|
2
|
+
import { fromAbsolute as v } from "@box/blueprint-web/lib-esm/primitives/calendar/from-absolute.util";
|
|
3
|
+
import { parseAbsoluteToLocal as F } from "@box/blueprint-web/lib-esm/primitives/calendar/parse-absolute-to-local.util";
|
|
4
|
+
import { parseAbsolute as w } from "@box/blueprint-web/lib-esm/primitives/calendar/parse-absolute.util";
|
|
5
|
+
import { toCalendarDateTime as c } from "@box/blueprint-web/lib-esm/primitives/calendar/to-calendar-date-time.util";
|
|
6
|
+
import { toCalendarDate as D } from "@box/blueprint-web/lib-esm/primitives/calendar/to-calendar-date.util";
|
|
7
7
|
import { toZoned as C } from "@box/blueprint-web/lib-esm/primitives/calendar/to-zoned.util";
|
|
8
8
|
import { R as a } from "../../../../../../chunks/types.js";
|
|
9
|
-
const
|
|
9
|
+
const l = (o, n) => {
|
|
10
10
|
try {
|
|
11
|
-
const
|
|
12
|
-
return
|
|
11
|
+
const e = n ? c(w(o, "UTC")) : F(o);
|
|
12
|
+
return D(e);
|
|
13
13
|
} catch {
|
|
14
14
|
return null;
|
|
15
15
|
}
|
|
16
|
-
},
|
|
17
|
-
let
|
|
16
|
+
}, x = (o, n, e) => {
|
|
17
|
+
let r = "";
|
|
18
18
|
if (o) {
|
|
19
|
-
const t =
|
|
20
|
-
|
|
19
|
+
const t = e === a.FROM ? o : c(o, new u(23, 59, 59, 999));
|
|
20
|
+
r = C(t, n).toAbsoluteString();
|
|
21
21
|
}
|
|
22
|
-
return
|
|
23
|
-
},
|
|
24
|
-
let
|
|
22
|
+
return r;
|
|
23
|
+
}, f = (o, n) => {
|
|
24
|
+
let e = "";
|
|
25
25
|
if (o) {
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const r = n === a.FROM ? c(o, new u(0, 0, 0, 0)) : c(o, new u(23, 59, 59, 999));
|
|
27
|
+
e = C(r, "UTC").toAbsoluteString();
|
|
28
28
|
}
|
|
29
|
-
return
|
|
30
|
-
},
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
return e;
|
|
30
|
+
}, y = (o, n, e = (/* @__PURE__ */ new Date()).getTime()) => {
|
|
31
|
+
var b;
|
|
32
|
+
if ((o === "next" || o === "past" || o === "olderThan") && (n === void 0 || isNaN(n)))
|
|
33
|
+
return {
|
|
34
|
+
from: void 0,
|
|
35
|
+
to: void 0
|
|
36
|
+
};
|
|
37
|
+
const r = (d) => d === void 0 ? void 0 : d, t = r(v(e, "UTC")), s = (d) => r(t == null ? void 0 : t.add({
|
|
38
|
+
days: d * n
|
|
39
|
+
})), i = {
|
|
35
40
|
today: () => ({
|
|
36
41
|
from: t,
|
|
37
42
|
to: t
|
|
@@ -45,18 +50,27 @@ const g = (o, r) => {
|
|
|
45
50
|
to: t
|
|
46
51
|
}),
|
|
47
52
|
olderThan: () => ({
|
|
48
|
-
from:
|
|
53
|
+
from: r(v(0, "UTC")),
|
|
49
54
|
to: s(-1)
|
|
50
55
|
})
|
|
51
|
-
}, m = (
|
|
56
|
+
}, m = (b = i[o]) == null ? void 0 : b.call(i), T = m == null ? void 0 : m.from, p = m == null ? void 0 : m.to;
|
|
57
|
+
return {
|
|
58
|
+
from: T ? f(T, a.FROM) : void 0,
|
|
59
|
+
to: p ? f(p, a.TO) : void 0
|
|
60
|
+
};
|
|
61
|
+
}, L = (o, n) => {
|
|
62
|
+
const e = (m) => m === void 0 ? void 0 : m, r = e(v((/* @__PURE__ */ new Date()).getTime(), "UTC")), t = (m, T) => e(r == null ? void 0 : r.add({
|
|
63
|
+
days: m * T
|
|
64
|
+
})), s = t(o < 1 ? -1 : 1, Math.abs(o)), i = t(n < 1 ? -1 : 1, Math.abs(n));
|
|
52
65
|
return {
|
|
53
|
-
from:
|
|
54
|
-
to:
|
|
66
|
+
from: s ? f(s, a.FROM) : void 0,
|
|
67
|
+
to: i ? f(i, a.TO) : void 0
|
|
55
68
|
};
|
|
56
69
|
};
|
|
57
70
|
export {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
71
|
+
l as convertToDatePickerValue,
|
|
72
|
+
x as convertToFormikValue,
|
|
73
|
+
f as convertToFormikValueRanged,
|
|
74
|
+
L as getCustomFromToValues,
|
|
75
|
+
y as getRelativeFromToValues
|
|
62
76
|
};
|
|
@@ -1,182 +1,249 @@
|
|
|
1
|
-
import { DateI18nProvider as
|
|
2
|
-
import
|
|
3
|
-
import { useFormikContext as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useIntl as
|
|
6
|
-
import { R as
|
|
7
|
-
import { DEFAULT_MAX_DATE as
|
|
8
|
-
import { getRelativeFromToValues as
|
|
9
|
-
import { s as
|
|
10
|
-
import { u as
|
|
11
|
-
import { getDynamicMaxMinValue as
|
|
12
|
-
import
|
|
13
|
-
import { jsx as l, jsxs as
|
|
14
|
-
const
|
|
15
|
-
next:
|
|
16
|
-
past:
|
|
17
|
-
olderThan:
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { DateI18nProvider as Oe, Text as xe, Radio as i, Select as p, DatePicker as ne } from "@box/blueprint-web";
|
|
2
|
+
import Ae from "clsx";
|
|
3
|
+
import { useFormikContext as Le, getIn as O, Field as oe } from "formik";
|
|
4
|
+
import { useState as x, useRef as A, useCallback as Ie, useEffect as ie, useMemo as ce } from "react";
|
|
5
|
+
import { useIntl as Ne } from "react-intl";
|
|
6
|
+
import { R as c } from "../../../../../../chunks/types.js";
|
|
7
|
+
import { DEFAULT_MAX_DATE as ue } from "./constants.js";
|
|
8
|
+
import { getRelativeFromToValues as ke, convertToFormikValueRanged as me, getCustomFromToValues as de } from "./date-conversion-utils.js";
|
|
9
|
+
import { s as f } from "../../../../../../chunks/metadata-date-field.module.js";
|
|
10
|
+
import { u as Ee, E as G } from "../../../../../../chunks/use-date-validation.js";
|
|
11
|
+
import { getDynamicMaxMinValue as fe } from "./utils.js";
|
|
12
|
+
import r from "../../../../messages.js";
|
|
13
|
+
import { jsx as l, jsxs as L } from "react/jsx-runtime";
|
|
14
|
+
const ve = {
|
|
15
|
+
next: r.nextDaysAmt,
|
|
16
|
+
past: r.pastDaysAmt,
|
|
17
|
+
olderThan: r.olderThanDaysAmt
|
|
18
|
+
}, Pe = [1, 3, 15, 45, 60, 120, 365], ge = (u) => u in ve || u === "today" || u === "customRange", Qe = ({
|
|
19
|
+
customDateFilterOptions: u,
|
|
20
|
+
disableForm: C,
|
|
21
|
+
fieldNamePrefix: h,
|
|
22
|
+
label: U,
|
|
23
|
+
locale: j,
|
|
24
|
+
portalElement: b
|
|
24
25
|
}) => {
|
|
25
|
-
const [
|
|
26
|
-
values:
|
|
27
|
-
setFieldTouched:
|
|
28
|
-
setFieldValue:
|
|
29
|
-
} =
|
|
30
|
-
validateDates:
|
|
31
|
-
fromDatePickerValue:
|
|
32
|
-
toDatePickerValue:
|
|
33
|
-
fromErrorType:
|
|
34
|
-
toErrorType:
|
|
35
|
-
} =
|
|
36
|
-
let
|
|
37
|
-
|
|
38
|
-
const [
|
|
39
|
-
clearDatePickerAriaLabel:
|
|
40
|
-
nextMonthAriaLabel:
|
|
41
|
-
openCalendarDropdownAriaLabel:
|
|
42
|
-
previousMonthAriaLabel:
|
|
43
|
-
},
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
26
|
+
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
|
+
values: F,
|
|
28
|
+
setFieldTouched: he,
|
|
29
|
+
setFieldValue: n
|
|
30
|
+
} = Le(), {
|
|
31
|
+
validateDates: z,
|
|
32
|
+
fromDatePickerValue: T,
|
|
33
|
+
toDatePickerValue: y,
|
|
34
|
+
fromErrorType: J,
|
|
35
|
+
toErrorType: K
|
|
36
|
+
} = Ee(F, m, d, j, !0), s = Ne(), g = O(F, H), v = O(F, q), pe = T || y;
|
|
37
|
+
let P = "anyTime", $ = "anyTime";
|
|
38
|
+
ge(g) ? P = g : v ? $ = v : pe && (P = "customRange", $ = "customRange");
|
|
39
|
+
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: s.formatMessage(r.clearSelectedDate),
|
|
41
|
+
nextMonthAriaLabel: s.formatMessage(r.switchToNextMonth),
|
|
42
|
+
openCalendarDropdownAriaLabel: s.formatMessage(r.openCalendar),
|
|
43
|
+
previousMonthAriaLabel: s.formatMessage(r.switchToNextMonth)
|
|
44
|
+
}, Fe = () => {
|
|
45
|
+
n(m, void 0), n(d, void 0), V.current = void 0, M.current = void 0;
|
|
46
|
+
}, Te = (e) => {
|
|
47
|
+
const a = me(e, c.FROM);
|
|
48
|
+
V.current = e, n(m, a), I(c.FROM);
|
|
49
|
+
}, ye = (e) => {
|
|
50
|
+
const a = me(e, c.TO);
|
|
51
|
+
M.current = e, n(d, a), I(c.TO);
|
|
52
|
+
}, te = (e) => {
|
|
53
|
+
const a = e === c.FROM ? m : d;
|
|
54
|
+
he(a, !0), I(e);
|
|
55
|
+
}, De = (e) => {
|
|
56
|
+
let a;
|
|
57
|
+
ge(e) && (a = e), e === "customRange" && (V.current = void 0, M.current = void 0), n(H, a), Q(e), n(k, void 0), N(!0);
|
|
58
|
+
}, Ve = (e) => {
|
|
59
|
+
n(q, e), ee(e), n(E, void 0), Fe();
|
|
60
|
+
const a = u.find((t) => t.name === e);
|
|
61
|
+
if (a && a.type === "text") {
|
|
62
|
+
const {
|
|
63
|
+
from: t,
|
|
64
|
+
to: o
|
|
65
|
+
} = de(a.from, a.to);
|
|
66
|
+
n(m, t), n(d, o);
|
|
67
|
+
}
|
|
68
|
+
}, le = Ie(() => {
|
|
56
69
|
const {
|
|
57
70
|
from: e,
|
|
58
|
-
to:
|
|
59
|
-
} =
|
|
60
|
-
|
|
61
|
-
}, [m,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}, [
|
|
65
|
-
|
|
66
|
-
|
|
71
|
+
to: a
|
|
72
|
+
} = ke(D, S);
|
|
73
|
+
n(m, e), n(d, a);
|
|
74
|
+
}, [m, S, D, n, d]);
|
|
75
|
+
ie(() => {
|
|
76
|
+
_ && (le(), N(!1));
|
|
77
|
+
}, [_, le]), ie(() => {
|
|
78
|
+
const e = W.current !== g, a = Y.current !== v;
|
|
79
|
+
(e || a) && (Q(g ?? "anyTime"), ee(v), W.current = g, Y.current = v);
|
|
80
|
+
}, [g, v]);
|
|
81
|
+
const Me = ce(() => fe(y, ue), [y]), Re = ce(() => fe(T), [T]), re = (e, a, t) => !!(a === G.MAX && e === G.OVERLAPPING || e === G.OVERLAPPING && t), B = (e) => {
|
|
82
|
+
if (e !== D)
|
|
67
83
|
return null;
|
|
68
|
-
const
|
|
69
|
-
const
|
|
84
|
+
const a = (o) => {
|
|
85
|
+
const R = ve[e];
|
|
70
86
|
return {
|
|
71
|
-
value: String(
|
|
72
|
-
label:
|
|
73
|
-
count:
|
|
87
|
+
value: String(o),
|
|
88
|
+
label: s.formatMessage(R, {
|
|
89
|
+
count: o
|
|
74
90
|
})
|
|
75
91
|
};
|
|
76
|
-
},
|
|
77
|
-
return /* @__PURE__ */ l(
|
|
78
|
-
className:
|
|
79
|
-
defaultValue:
|
|
80
|
-
label:
|
|
81
|
-
onValueChange: (
|
|
82
|
-
|
|
92
|
+
}, t = Pe.map(a);
|
|
93
|
+
return /* @__PURE__ */ l(p, {
|
|
94
|
+
className: f.dateSelect,
|
|
95
|
+
defaultValue: S === void 0 ? "" : String(S),
|
|
96
|
+
label: s.formatMessage(r.relativeDaysSelectLabel),
|
|
97
|
+
onValueChange: (o) => {
|
|
98
|
+
n(k, Number(o)), N(!0);
|
|
83
99
|
},
|
|
84
|
-
placeholder:
|
|
85
|
-
children: /* @__PURE__ */ l(
|
|
86
|
-
container:
|
|
87
|
-
children:
|
|
88
|
-
text:
|
|
89
|
-
value:
|
|
90
|
-
children:
|
|
91
|
-
},
|
|
100
|
+
placeholder: s.formatMessage(r.selectValuePlaceholder),
|
|
101
|
+
children: /* @__PURE__ */ l(p.Content, {
|
|
102
|
+
container: b,
|
|
103
|
+
children: t == null ? void 0 : t.map((o) => /* @__PURE__ */ l(p.Option, {
|
|
104
|
+
text: o.label,
|
|
105
|
+
value: o.value,
|
|
106
|
+
children: o.label
|
|
107
|
+
}, o.value))
|
|
92
108
|
})
|
|
93
109
|
});
|
|
94
|
-
},
|
|
95
|
-
className:
|
|
96
|
-
|
|
110
|
+
}, Ce = (e, a) => e !== w ? null : /* @__PURE__ */ l(p, {
|
|
111
|
+
className: f.dateSelect,
|
|
112
|
+
defaultValue: Z === void 0 ? "" : String(Z),
|
|
113
|
+
label: s.formatMessage(r.relativeDaysSelectLabel),
|
|
114
|
+
onValueChange: (t) => {
|
|
115
|
+
const o = a.find((R) => R.name === t);
|
|
116
|
+
if (o) {
|
|
117
|
+
const {
|
|
118
|
+
from: R,
|
|
119
|
+
to: Se
|
|
120
|
+
} = de(o.from, o.to);
|
|
121
|
+
n(m, R), n(d, Se), n(E, o.name);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
placeholder: s.formatMessage(r.selectValuePlaceholder),
|
|
125
|
+
children: /* @__PURE__ */ l(p.Content, {
|
|
126
|
+
container: b,
|
|
127
|
+
children: a.map((t) => /* @__PURE__ */ l(p.Option, {
|
|
128
|
+
text: t.name,
|
|
129
|
+
value: t.name,
|
|
130
|
+
children: t.name
|
|
131
|
+
}, t.name))
|
|
132
|
+
})
|
|
133
|
+
}), be = () => /* @__PURE__ */ L(i.Group, {
|
|
134
|
+
disabled: C,
|
|
135
|
+
loop: !1,
|
|
136
|
+
onValueChange: Ve,
|
|
137
|
+
value: w,
|
|
138
|
+
children: [/* @__PURE__ */ l(i.Item, {
|
|
139
|
+
label: s.formatMessage(r.relativeDateFilterAnyTime),
|
|
140
|
+
value: "anyTime"
|
|
141
|
+
}), u.map((e) => {
|
|
142
|
+
if (e.type === "text")
|
|
143
|
+
return /* @__PURE__ */ l(i.Item, {
|
|
144
|
+
label: e.name,
|
|
145
|
+
value: e.name
|
|
146
|
+
}, e.name);
|
|
147
|
+
const {
|
|
148
|
+
name: a,
|
|
149
|
+
options: t
|
|
150
|
+
} = e;
|
|
151
|
+
return /* @__PURE__ */ l(i.Item, {
|
|
152
|
+
description: t ? Ce(a, t) : void 0,
|
|
153
|
+
label: a,
|
|
154
|
+
value: a
|
|
155
|
+
}, a);
|
|
156
|
+
}), /* @__PURE__ */ l(i.Item, {
|
|
157
|
+
description: se(),
|
|
158
|
+
label: s.formatMessage(r.relativeDateFilterCustomRange),
|
|
159
|
+
value: "customRange"
|
|
160
|
+
})]
|
|
161
|
+
}), se = () => !u && D !== "customRange" || u && w !== "customRange" ? null : /* @__PURE__ */ L("div", {
|
|
162
|
+
className: Ae(f.rangeInputsContainer, f.verticalLayout, f.dateSelect),
|
|
163
|
+
children: [/* @__PURE__ */ l(oe, {
|
|
97
164
|
name: m,
|
|
98
|
-
validate: (e) =>
|
|
165
|
+
validate: (e) => z(V.current, M.current, c.FROM),
|
|
99
166
|
children: ({
|
|
100
167
|
field: e,
|
|
101
|
-
meta:
|
|
168
|
+
meta: a
|
|
102
169
|
}) => /* @__PURE__ */ l("div", {
|
|
103
|
-
className:
|
|
104
|
-
children: /* @__PURE__ */ l(
|
|
170
|
+
className: f.inputContainer,
|
|
171
|
+
children: /* @__PURE__ */ l(ne, {
|
|
105
172
|
...e,
|
|
106
|
-
...
|
|
107
|
-
calendarAriaLabel:
|
|
108
|
-
error:
|
|
109
|
-
isDisabled:
|
|
110
|
-
label:
|
|
111
|
-
maxValue:
|
|
112
|
-
onBlur: () =>
|
|
113
|
-
onChange: (
|
|
114
|
-
portalElement:
|
|
115
|
-
value:
|
|
173
|
+
...ae,
|
|
174
|
+
calendarAriaLabel: s.formatMessage(r.selectStartDate),
|
|
175
|
+
error: re(J, K, X !== c.FROM) ? void 0 : a.error,
|
|
176
|
+
isDisabled: C,
|
|
177
|
+
label: s.formatMessage(r.fieldStartDateLabel),
|
|
178
|
+
maxValue: Me,
|
|
179
|
+
onBlur: () => te(c.FROM),
|
|
180
|
+
onChange: (t) => Te(t),
|
|
181
|
+
portalElement: b,
|
|
182
|
+
value: T
|
|
116
183
|
})
|
|
117
184
|
})
|
|
118
|
-
}), /* @__PURE__ */ l(
|
|
119
|
-
name:
|
|
120
|
-
validate: (e) =>
|
|
185
|
+
}), /* @__PURE__ */ l(oe, {
|
|
186
|
+
name: d,
|
|
187
|
+
validate: (e) => z(V.current, M.current, c.TO),
|
|
121
188
|
children: ({
|
|
122
189
|
field: e,
|
|
123
|
-
meta:
|
|
190
|
+
meta: a
|
|
124
191
|
}) => /* @__PURE__ */ l("div", {
|
|
125
|
-
className:
|
|
126
|
-
children: /* @__PURE__ */ l(
|
|
192
|
+
className: f.inputContainer,
|
|
193
|
+
children: /* @__PURE__ */ l(ne, {
|
|
127
194
|
...e,
|
|
128
|
-
...
|
|
129
|
-
calendarAriaLabel:
|
|
130
|
-
error:
|
|
131
|
-
isDisabled:
|
|
132
|
-
label:
|
|
133
|
-
maxValue:
|
|
134
|
-
minValue:
|
|
135
|
-
onBlur: () =>
|
|
136
|
-
onChange: (
|
|
137
|
-
portalElement:
|
|
138
|
-
value:
|
|
195
|
+
...ae,
|
|
196
|
+
calendarAriaLabel: s.formatMessage(r.selectEndDate),
|
|
197
|
+
error: re(K, J, X !== c.TO) ? void 0 : a.error,
|
|
198
|
+
isDisabled: C,
|
|
199
|
+
label: s.formatMessage(r.fieldEndDateLabel),
|
|
200
|
+
maxValue: ue,
|
|
201
|
+
minValue: Re,
|
|
202
|
+
onBlur: () => te(c.TO),
|
|
203
|
+
onChange: (t) => ye(t),
|
|
204
|
+
portalElement: b,
|
|
205
|
+
value: y
|
|
139
206
|
})
|
|
140
207
|
})
|
|
141
208
|
})]
|
|
142
209
|
});
|
|
143
|
-
return /* @__PURE__ */ l(
|
|
144
|
-
locale:
|
|
145
|
-
children: /* @__PURE__ */
|
|
146
|
-
className:
|
|
147
|
-
"data-testid": `${
|
|
148
|
-
children: [/* @__PURE__ */ l(
|
|
210
|
+
return /* @__PURE__ */ l(Oe, {
|
|
211
|
+
locale: j,
|
|
212
|
+
children: /* @__PURE__ */ L("div", {
|
|
213
|
+
className: f.container,
|
|
214
|
+
"data-testid": `${U}-field`,
|
|
215
|
+
children: [/* @__PURE__ */ l(xe, {
|
|
149
216
|
as: "span",
|
|
150
|
-
className:
|
|
217
|
+
className: f.rangeFieldLabel,
|
|
151
218
|
color: "textOnLightSecondary",
|
|
152
219
|
variant: "bodyDefaultBold",
|
|
153
|
-
children:
|
|
154
|
-
}), /* @__PURE__ */
|
|
155
|
-
disabled:
|
|
220
|
+
children: U
|
|
221
|
+
}), u ? be() : /* @__PURE__ */ L(i.Group, {
|
|
222
|
+
disabled: C,
|
|
156
223
|
loop: !1,
|
|
157
|
-
onValueChange:
|
|
158
|
-
value:
|
|
159
|
-
children: [/* @__PURE__ */ l(
|
|
160
|
-
label:
|
|
224
|
+
onValueChange: De,
|
|
225
|
+
value: D,
|
|
226
|
+
children: [/* @__PURE__ */ l(i.Item, {
|
|
227
|
+
label: s.formatMessage(r.relativeDateFilterAnyTime),
|
|
161
228
|
value: "anyTime"
|
|
162
|
-
}), /* @__PURE__ */ l(
|
|
163
|
-
label:
|
|
229
|
+
}), /* @__PURE__ */ l(i.Item, {
|
|
230
|
+
label: s.formatMessage(r.relativeDateFilterToday),
|
|
164
231
|
value: "today"
|
|
165
|
-
}), /* @__PURE__ */ l(
|
|
166
|
-
description:
|
|
167
|
-
label:
|
|
232
|
+
}), /* @__PURE__ */ l(i.Item, {
|
|
233
|
+
description: B("next"),
|
|
234
|
+
label: s.formatMessage(r.relativeDateFilterNext),
|
|
168
235
|
value: "next"
|
|
169
|
-
}), /* @__PURE__ */ l(
|
|
170
|
-
description:
|
|
171
|
-
label:
|
|
236
|
+
}), /* @__PURE__ */ l(i.Item, {
|
|
237
|
+
description: B("past"),
|
|
238
|
+
label: s.formatMessage(r.relativeDateFilterPast),
|
|
172
239
|
value: "past"
|
|
173
|
-
}), /* @__PURE__ */ l(
|
|
174
|
-
description:
|
|
175
|
-
label:
|
|
240
|
+
}), /* @__PURE__ */ l(i.Item, {
|
|
241
|
+
description: B("olderThan"),
|
|
242
|
+
label: s.formatMessage(r.relativeDateFilterOlderThan),
|
|
176
243
|
value: "olderThan"
|
|
177
|
-
}), /* @__PURE__ */ l(
|
|
178
|
-
description:
|
|
179
|
-
label:
|
|
244
|
+
}), /* @__PURE__ */ l(i.Item, {
|
|
245
|
+
description: se(),
|
|
246
|
+
label: s.formatMessage(r.relativeDateFilterCustomRange),
|
|
180
247
|
value: "customRange"
|
|
181
248
|
})]
|
|
182
249
|
})]
|
|
@@ -184,6 +251,6 @@ const ee = {
|
|
|
184
251
|
});
|
|
185
252
|
};
|
|
186
253
|
export {
|
|
187
|
-
|
|
188
|
-
|
|
254
|
+
Qe as MetadataDateFieldRelative,
|
|
255
|
+
Qe as default
|
|
189
256
|
};
|
package/dist/esm/lib/defaults.js
CHANGED
|
@@ -6,7 +6,7 @@ const a = {
|
|
|
6
6
|
id: e,
|
|
7
7
|
hidden: !1,
|
|
8
8
|
fields: []
|
|
9
|
-
},
|
|
9
|
+
}, i = {
|
|
10
10
|
string: {
|
|
11
11
|
enum: [""]
|
|
12
12
|
},
|
|
@@ -21,8 +21,7 @@ const a = {
|
|
|
21
21
|
gt: "",
|
|
22
22
|
lt: ""
|
|
23
23
|
},
|
|
24
|
-
|
|
25
|
-
relativeType: void 0
|
|
24
|
+
advancedFilterOption: ""
|
|
26
25
|
},
|
|
27
26
|
date: {
|
|
28
27
|
range: {
|
|
@@ -30,10 +29,12 @@ const a = {
|
|
|
30
29
|
lt: ""
|
|
31
30
|
},
|
|
32
31
|
relativeDays: void 0,
|
|
33
|
-
relativeType: void 0
|
|
32
|
+
relativeType: void 0,
|
|
33
|
+
customType: "anyTime",
|
|
34
|
+
customDays: void 0
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
37
|
export {
|
|
37
38
|
a as defaultInitialValues,
|
|
38
|
-
|
|
39
|
+
i as defaultMetadataValueMap
|
|
39
40
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { MetadataFieldProps } from '../../types';
|
|
2
|
-
export declare const MetadataDateFieldRelative: ({ disableForm, fieldNamePrefix, label, locale, portalElement, }: MetadataFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const MetadataDateFieldRelative: ({ customDateFilterOptions, disableForm, fieldNamePrefix, label, locale, portalElement, }: Omit<MetadataFieldProps, "taxonomyOptionsFetcher">) => import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default MetadataDateFieldRelative;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { MetadataFieldProps } from '../../types';
|
|
2
|
-
export declare const MetadataDateField: ({ canUseRelativeDates, ...props }: MetadataFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
-
export declare const MetadataDateFieldNonRelative: ({ customFieldLabels, direction, disableForm, fieldNamePrefix, label, locale, portalElement, }: MetadataFieldProps) => import("react/jsx-runtime").JSX.Element;
|
|
2
|
+
export declare const MetadataDateField: ({ canUseRelativeDates, ...props }: Omit<MetadataFieldProps, "taxonomyOptionsFetcher">) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare const MetadataDateFieldNonRelative: ({ customFieldLabels, direction, disableForm, fieldNamePrefix, label, locale, portalElement, }: Omit<MetadataFieldProps, "taxonomyOptionsFetcher">) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
export default MetadataDateField;
|
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { Level } from '@box/combobox-with-api';
|
|
2
2
|
import { FilterOption, MetadataTemplateFieldOption } from '../../types';
|
|
3
3
|
import { TaxonomyOptionsFetcher } from './components/metadata-taxonomy-field/types';
|
|
4
|
+
export type CustomDateFilterOption = {
|
|
5
|
+
name: string;
|
|
6
|
+
from: number;
|
|
7
|
+
to: number;
|
|
8
|
+
};
|
|
9
|
+
export type CustomDateFilterOptionsProps = {
|
|
10
|
+
name: string;
|
|
11
|
+
type: string;
|
|
12
|
+
options?: Array<CustomDateFilterOption>;
|
|
13
|
+
from?: number;
|
|
14
|
+
to?: number;
|
|
15
|
+
};
|
|
4
16
|
export type MetadataFilterFieldsProps = {
|
|
5
17
|
disableForm?: boolean;
|
|
6
18
|
portalElement?: HTMLElement;
|
|
@@ -32,4 +44,5 @@ export type MetadataFieldProps = {
|
|
|
32
44
|
fieldAdvancedFilterOptions?: string;
|
|
33
45
|
direction?: 'horizontal' | 'vertical';
|
|
34
46
|
customFieldLabels?: Array<string>;
|
|
47
|
+
customDateFilterOptions?: Array<CustomDateFilterOptionsProps>;
|
|
35
48
|
};
|
|
@@ -8,6 +8,8 @@ export type RelativeRangeType = 'today' | 'next' | 'past' | 'olderThan';
|
|
|
8
8
|
export type RelDateTypeUi = RelativeRangeType | 'customRange' | 'anyTime';
|
|
9
9
|
export interface RangeType {
|
|
10
10
|
advancedFilterOption?: string;
|
|
11
|
+
customDays: string | undefined;
|
|
12
|
+
customType: string | undefined;
|
|
11
13
|
range: RangeValue;
|
|
12
14
|
relativeType: RelativeRangeType | undefined;
|
|
13
15
|
relativeDays: number | undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@box/metadata-filter",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.19.0",
|
|
4
4
|
"peerDependencies": {
|
|
5
5
|
"@box/blueprint-web": "^7.8.0",
|
|
6
6
|
"@box/blueprint-web-assets": "^4.16.0",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"react-intl": "6.4.2"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
|
-
"@box/blueprint-web": "^12.57.
|
|
14
|
+
"@box/blueprint-web": "^12.57.1",
|
|
15
15
|
"@box/blueprint-web-assets": "^4.63.0",
|
|
16
16
|
"@box/storybook-utils": "^0.13.18",
|
|
17
17
|
"react": "^18.3.0",
|