@box/metadata-filter 1.18.11 → 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.
@@ -1,37 +1,42 @@
1
- import { Time as f } from "@box/blueprint-web/lib-esm/primitives/calendar/classes.util";
2
- import { fromAbsolute as p } from "@box/blueprint-web/lib-esm/primitives/calendar/from-absolute.util";
3
- import { parseAbsoluteToLocal as b } from "@box/blueprint-web/lib-esm/primitives/calendar/parse-absolute-to-local.util";
4
- import { parseAbsolute as F } from "@box/blueprint-web/lib-esm/primitives/calendar/parse-absolute.util";
5
- import { toCalendarDateTime as T } from "@box/blueprint-web/lib-esm/primitives/calendar/to-calendar-date-time.util";
6
- import { toCalendarDate as R } from "@box/blueprint-web/lib-esm/primitives/calendar/to-calendar-date.util";
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 g = (o, r) => {
9
+ const l = (o, n) => {
10
10
  try {
11
- const n = r ? T(F(o, "UTC")) : b(o);
12
- return R(n);
11
+ const e = n ? c(w(o, "UTC")) : F(o);
12
+ return D(e);
13
13
  } catch {
14
14
  return null;
15
15
  }
16
- }, h = (o, r, n) => {
17
- let e = "";
16
+ }, x = (o, n, e) => {
17
+ let r = "";
18
18
  if (o) {
19
- const t = n === a.FROM ? o : T(o, new f(23, 59, 59, 999));
20
- e = C(t, r).toAbsoluteString();
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 e;
23
- }, v = (o, r) => {
24
- let n = "";
22
+ return r;
23
+ }, f = (o, n) => {
24
+ let e = "";
25
25
  if (o) {
26
- const e = r === a.FROM ? T(o, new f(0, 0, 0, 0)) : T(o, new f(23, 59, 59, 999));
27
- n = C(e, "UTC").toAbsoluteString();
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 n;
30
- }, x = (o, r, n = (/* @__PURE__ */ new Date()).getTime()) => {
31
- var l;
32
- const e = (i) => i === void 0 ? void 0 : i, t = e(p(n, "UTC")), s = (i) => e(t == null ? void 0 : t.add({
33
- days: i * r
34
- })), c = {
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: e(p(0, "UTC")),
53
+ from: r(v(0, "UTC")),
49
54
  to: s(-1)
50
55
  })
51
- }, m = (l = c[o]) == null ? void 0 : l.call(c), d = m == null ? void 0 : m.from, u = m == null ? void 0 : m.to;
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: d ? v(d, a.FROM) : void 0,
54
- to: u ? v(u, a.TO) : void 0
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
- g as convertToDatePickerValue,
59
- h as convertToFormikValue,
60
- v as convertToFormikValueRanged,
61
- x as getRelativeFromToValues
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 ue, Text as me, Radio as d, Select as x, DatePicker as H } from "@box/blueprint-web";
2
- import fe from "clsx";
3
- import { useFormikContext as ge, getIn as q, Field as z } from "formik";
4
- import { useState as A, useRef as J, useCallback as he, useEffect as ve, useMemo as K } from "react";
5
- import { useIntl as pe } from "react-intl";
6
- import { R as o } from "../../../../../../chunks/types.js";
7
- import { DEFAULT_MAX_DATE as Q } from "./constants.js";
8
- import { getRelativeFromToValues as Fe, convertToFormikValueRanged as W } from "./date-conversion-utils.js";
9
- import { s as c } from "../../../../../../chunks/metadata-date-field.module.js";
10
- import { u as Me, E as L } from "../../../../../../chunks/use-date-validation.js";
11
- import { getDynamicMaxMinValue as Y } from "./utils.js";
12
- import a from "../../../../messages.js";
13
- import { jsx as l, jsxs as S } from "react/jsx-runtime";
14
- const ee = {
15
- next: a.nextDaysAmt,
16
- past: a.pastDaysAmt,
17
- olderThan: a.olderThanDaysAmt
18
- }, De = [1, 3, 15, 45, 60, 120, 365], Z = (u) => u in ee || u === "today", ke = ({
19
- disableForm: u,
20
- fieldNamePrefix: p,
21
- label: N,
22
- locale: I,
23
- portalElement: M
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 [k, D] = A(o.FROM), [E, T] = A(!1), m = `${p}.value.range.gt`, f = `${p}.value.range.lt`, P = `${p}.value.relativeType`, V = `${p}.value.relativeDays`, {
26
- values: y,
27
- setFieldTouched: ae,
28
- setFieldValue: i
29
- } = ge(), {
30
- validateDates: $,
31
- fromDatePickerValue: g,
32
- toDatePickerValue: h,
33
- fromErrorType: B,
34
- toErrorType: w
35
- } = Me(y, m, f, I, !0), r = pe(), G = q(y, P), te = g || h;
36
- let R = "anyTime";
37
- Z(G) ? R = G : te && (R = "customRange");
38
- const [v, re] = A(R), F = q(y, V), b = J(g), O = J(h), U = {
39
- clearDatePickerAriaLabel: r.formatMessage(a.clearSelectedDate),
40
- nextMonthAriaLabel: r.formatMessage(a.switchToNextMonth),
41
- openCalendarDropdownAriaLabel: r.formatMessage(a.openCalendar),
42
- previousMonthAriaLabel: r.formatMessage(a.switchToNextMonth)
43
- }, le = (e) => {
44
- const t = W(e, o.FROM);
45
- b.current = e, i(m, t), D(o.FROM);
46
- }, oe = (e) => {
47
- const t = W(e, o.TO);
48
- O.current = e, i(f, t), D(o.TO);
49
- }, j = (e) => {
50
- const t = e === o.FROM ? m : f;
51
- ae(t, !0), D(e);
52
- }, se = (e) => {
53
- let t;
54
- Z(e) && (t = e), i(P, t), re(e), i(V, void 0), T(!0);
55
- }, X = he(() => {
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: t
59
- } = Fe(v, F);
60
- i(m, e), i(f, t);
61
- }, [m, F, v, i, f]);
62
- ve(() => {
63
- E && (X(), T(!1));
64
- }, [E, X]);
65
- const ne = K(() => Y(h, Q), [h]), ie = K(() => Y(g), [g]), _ = (e, t, s) => !!(t === L.MAX && e === L.OVERLAPPING || e === L.OVERLAPPING && s), C = (e) => {
66
- if (e !== v)
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 t = (n) => {
69
- const de = ee[e];
84
+ const a = (o) => {
85
+ const R = ve[e];
70
86
  return {
71
- value: String(n),
72
- label: r.formatMessage(de, {
73
- count: n
87
+ value: String(o),
88
+ label: s.formatMessage(R, {
89
+ count: o
74
90
  })
75
91
  };
76
- }, s = De.map(t);
77
- return /* @__PURE__ */ l(x, {
78
- className: c.dateSelect,
79
- defaultValue: F === void 0 ? "" : String(F),
80
- label: r.formatMessage(a.relativeDaysSelectLabel),
81
- onValueChange: (n) => {
82
- i(V, Number(n)), T(!0);
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: r.formatMessage(a.selectValuePlaceholder),
85
- children: /* @__PURE__ */ l(x.Content, {
86
- container: M,
87
- children: s == null ? void 0 : s.map((n) => /* @__PURE__ */ l(x.Option, {
88
- text: n.label,
89
- value: n.value,
90
- children: n.label
91
- }, n.value))
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
- }, ce = () => v !== "customRange" ? null : /* @__PURE__ */ S("div", {
95
- className: fe(c.rangeInputsContainer, c.verticalLayout, c.dateSelect),
96
- children: [/* @__PURE__ */ l(z, {
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) => $(b.current, O.current, o.FROM),
165
+ validate: (e) => z(V.current, M.current, c.FROM),
99
166
  children: ({
100
167
  field: e,
101
- meta: t
168
+ meta: a
102
169
  }) => /* @__PURE__ */ l("div", {
103
- className: c.inputContainer,
104
- children: /* @__PURE__ */ l(H, {
170
+ className: f.inputContainer,
171
+ children: /* @__PURE__ */ l(ne, {
105
172
  ...e,
106
- ...U,
107
- calendarAriaLabel: r.formatMessage(a.selectStartDate),
108
- error: _(B, w, k !== o.FROM) ? void 0 : t.error,
109
- isDisabled: u,
110
- label: r.formatMessage(a.fieldStartDateLabel),
111
- maxValue: ne,
112
- onBlur: () => j(o.FROM),
113
- onChange: (s) => le(s),
114
- portalElement: M,
115
- value: g
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(z, {
119
- name: f,
120
- validate: (e) => $(b.current, O.current, o.TO),
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: t
190
+ meta: a
124
191
  }) => /* @__PURE__ */ l("div", {
125
- className: c.inputContainer,
126
- children: /* @__PURE__ */ l(H, {
192
+ className: f.inputContainer,
193
+ children: /* @__PURE__ */ l(ne, {
127
194
  ...e,
128
- ...U,
129
- calendarAriaLabel: r.formatMessage(a.selectEndDate),
130
- error: _(w, B, k !== o.TO) ? void 0 : t.error,
131
- isDisabled: u,
132
- label: r.formatMessage(a.fieldEndDateLabel),
133
- maxValue: Q,
134
- minValue: ie,
135
- onBlur: () => j(o.TO),
136
- onChange: (s) => oe(s),
137
- portalElement: M,
138
- value: h
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(ue, {
144
- locale: I,
145
- children: /* @__PURE__ */ S("div", {
146
- className: c.container,
147
- "data-testid": `${N}-field`,
148
- children: [/* @__PURE__ */ l(me, {
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: c.rangeFieldLabel,
217
+ className: f.rangeFieldLabel,
151
218
  color: "textOnLightSecondary",
152
219
  variant: "bodyDefaultBold",
153
- children: N
154
- }), /* @__PURE__ */ S(d.Group, {
155
- disabled: u,
220
+ children: U
221
+ }), u ? be() : /* @__PURE__ */ L(i.Group, {
222
+ disabled: C,
156
223
  loop: !1,
157
- onValueChange: se,
158
- value: v,
159
- children: [/* @__PURE__ */ l(d.Item, {
160
- label: r.formatMessage(a.relativeDateFilterAnyTime),
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(d.Item, {
163
- label: r.formatMessage(a.relativeDateFilterToday),
229
+ }), /* @__PURE__ */ l(i.Item, {
230
+ label: s.formatMessage(r.relativeDateFilterToday),
164
231
  value: "today"
165
- }), /* @__PURE__ */ l(d.Item, {
166
- description: C("next"),
167
- label: r.formatMessage(a.relativeDateFilterNext),
232
+ }), /* @__PURE__ */ l(i.Item, {
233
+ description: B("next"),
234
+ label: s.formatMessage(r.relativeDateFilterNext),
168
235
  value: "next"
169
- }), /* @__PURE__ */ l(d.Item, {
170
- description: C("past"),
171
- label: r.formatMessage(a.relativeDateFilterPast),
236
+ }), /* @__PURE__ */ l(i.Item, {
237
+ description: B("past"),
238
+ label: s.formatMessage(r.relativeDateFilterPast),
172
239
  value: "past"
173
- }), /* @__PURE__ */ l(d.Item, {
174
- description: C("olderThan"),
175
- label: r.formatMessage(a.relativeDateFilterOlderThan),
240
+ }), /* @__PURE__ */ l(i.Item, {
241
+ description: B("olderThan"),
242
+ label: s.formatMessage(r.relativeDateFilterOlderThan),
176
243
  value: "olderThan"
177
- }), /* @__PURE__ */ l(d.Item, {
178
- description: ce(),
179
- label: r.formatMessage(a.relativeDateFilterCustomRange),
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
- ke as MetadataDateFieldRelative,
188
- ke as default
254
+ Qe as MetadataDateFieldRelative,
255
+ Qe as default
189
256
  };
@@ -6,7 +6,7 @@ const a = {
6
6
  id: e,
7
7
  hidden: !1,
8
8
  fields: []
9
- }, l = {
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
- relativeDays: void 0,
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
- l as defaultMetadataValueMap
39
+ i as defaultMetadataValueMap
39
40
  };
@@ -11,3 +11,7 @@ export declare const getRelativeFromToValues: (selectedRelValue: RelDateTypeUi,
11
11
  from: string;
12
12
  to: string;
13
13
  };
14
+ export declare const getCustomFromToValues: (from: number, to: number) => {
15
+ from: string;
16
+ to: string;
17
+ };
@@ -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.18.11",
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",