@box/metadata-filter 1.23.0 → 1.23.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/chunks/types2.js +6 -0
  2. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/constants.js +1 -1
  3. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/date-conversion-utils.js +43 -49
  4. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field-advanced.js +143 -136
  5. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field-relative.js +44 -43
  6. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/metadata-date-field.js +8 -7
  7. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/use-date-internationalization.js +7 -8
  8. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/use-date-validation.js +35 -10
  9. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-date-field/use-integer-validation.js +21 -0
  10. package/dist/esm/lib/components/metadata-filter-fields/components/metadata-float-field/metadata-float-field-advanced.js +59 -61
  11. package/dist/esm/lib/components/metadata-filter-fields/metadata-filter-fields.js +42 -42
  12. package/dist/esm/lib/messages.js +12 -0
  13. package/dist/i18n/bn-IN.js +3 -0
  14. package/dist/i18n/da-DK.js +3 -0
  15. package/dist/i18n/de-DE.js +3 -0
  16. package/dist/i18n/en-AU.js +3 -0
  17. package/dist/i18n/en-CA.js +3 -0
  18. package/dist/i18n/en-GB.js +3 -0
  19. package/dist/i18n/en-US.js +3 -0
  20. package/dist/i18n/en-US.properties +6 -0
  21. package/dist/i18n/en-x-pseudo.js +3 -0
  22. package/dist/i18n/es-419.js +3 -0
  23. package/dist/i18n/es-ES.js +3 -0
  24. package/dist/i18n/fi-FI.js +3 -0
  25. package/dist/i18n/fr-CA.js +3 -0
  26. package/dist/i18n/fr-FR.js +3 -0
  27. package/dist/i18n/hi-IN.js +3 -0
  28. package/dist/i18n/it-IT.js +3 -0
  29. package/dist/i18n/ja-JP.js +3 -0
  30. package/dist/i18n/json/src/lib/messages.json +1 -1
  31. package/dist/i18n/ko-KR.js +3 -0
  32. package/dist/i18n/nb-NO.js +3 -0
  33. package/dist/i18n/nl-NL.js +3 -0
  34. package/dist/i18n/pl-PL.js +3 -0
  35. package/dist/i18n/pt-BR.js +3 -0
  36. package/dist/i18n/ru-RU.js +3 -0
  37. package/dist/i18n/sv-SE.js +3 -0
  38. package/dist/i18n/tr-TR.js +3 -0
  39. package/dist/i18n/zh-CN.js +3 -0
  40. package/dist/i18n/zh-TW.js +3 -0
  41. package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/types.d.ts +3 -2
  42. package/dist/types/lib/components/metadata-filter-fields/components/metadata-date-field/use-integer-validation.d.ts +6 -0
  43. package/dist/types/lib/messages.d.ts +15 -0
  44. package/package.json +2 -2
  45. 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 ne } from "@box/blueprint-web";
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 { u as Ee, E as G } from "../../../../../../chunks/use-date-validation.js";
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", Qe = ({
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: n
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), s = Ne(), g = O(F, H), v = O(F, q), pe = T || y;
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: s.formatMessage(r.clearSelectedDate),
41
- nextMonthAriaLabel: s.formatMessage(r.switchToNextMonth),
42
- openCalendarDropdownAriaLabel: s.formatMessage(r.openCalendar),
43
- previousMonthAriaLabel: s.formatMessage(r.switchToNextMonth)
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
- n(m, void 0), n(d, void 0), V.current = void 0, M.current = void 0;
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, n(m, a), I(c.FROM);
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, n(d, a), I(c.TO);
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), n(H, a), Q(e), n(k, void 0), N(!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
- n(q, e), ee(e), n(E, void 0), Fe();
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
- n(m, t), n(d, o);
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
- n(m, e), n(d, a);
74
- }, [m, S, D, n, 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: s.formatMessage(R, {
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: s.formatMessage(r.relativeDaysSelectLabel),
97
+ label: n.formatMessage(r.relativeDaysSelectLabel),
97
98
  onValueChange: (o) => {
98
- n(k, Number(o)), N(!0);
99
+ s(k, Number(o)), N(!0);
99
100
  },
100
- placeholder: s.formatMessage(r.selectValuePlaceholder),
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: s.formatMessage(r.relativeDaysSelectLabel),
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
- n(m, R), n(d, Se), n(E, o.name);
122
+ s(m, R), s(d, Se), s(E, o.name);
122
123
  }
123
124
  },
124
- placeholder: s.formatMessage(r.selectValuePlaceholder),
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: s.formatMessage(r.relativeDateFilterAnyTime),
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: se(),
158
- label: s.formatMessage(r.relativeDateFilterCustomRange),
158
+ description: ne(),
159
+ label: n.formatMessage(r.relativeDateFilterCustomRange),
159
160
  value: "customRange"
160
161
  })]
161
- }), se = () => !u && D !== "customRange" || u && w !== "customRange" ? null : /* @__PURE__ */ L("div", {
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(ne, {
172
+ children: /* @__PURE__ */ l(se, {
172
173
  ...e,
173
174
  ...ae,
174
- calendarAriaLabel: s.formatMessage(r.selectStartDate),
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: s.formatMessage(r.fieldStartDateLabel),
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(ne, {
194
+ children: /* @__PURE__ */ l(se, {
194
195
  ...e,
195
196
  ...ae,
196
- calendarAriaLabel: s.formatMessage(r.selectEndDate),
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: s.formatMessage(r.fieldEndDateLabel),
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: s.formatMessage(r.relativeDateFilterAnyTime),
228
+ label: n.formatMessage(r.relativeDateFilterAnyTime),
228
229
  value: "anyTime"
229
230
  }), /* @__PURE__ */ l(i.Item, {
230
- label: s.formatMessage(r.relativeDateFilterToday),
231
+ label: n.formatMessage(r.relativeDateFilterToday),
231
232
  value: "today"
232
233
  }), /* @__PURE__ */ l(i.Item, {
233
234
  description: B("next"),
234
- label: s.formatMessage(r.relativeDateFilterNext),
235
+ label: n.formatMessage(r.relativeDateFilterNext),
235
236
  value: "next"
236
237
  }), /* @__PURE__ */ l(i.Item, {
237
238
  description: B("past"),
238
- label: s.formatMessage(r.relativeDateFilterPast),
239
+ label: n.formatMessage(r.relativeDateFilterPast),
239
240
  value: "past"
240
241
  }), /* @__PURE__ */ l(i.Item, {
241
242
  description: B("olderThan"),
242
- label: s.formatMessage(r.relativeDateFilterOlderThan),
243
+ label: n.formatMessage(r.relativeDateFilterOlderThan),
243
244
  value: "olderThan"
244
245
  }), /* @__PURE__ */ l(i.Item, {
245
- description: se(),
246
- label: s.formatMessage(r.relativeDateFilterCustomRange),
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
- Qe as MetadataDateFieldRelative,
255
- Qe as default
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 { u as ee, E as g } from "../../../../../../chunks/use-date-validation.js";
12
- import { useDateInternationalization as ae } from "./use-date-internationalization.js";
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 pe = ({
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
- } = ae(M), {
38
+ } = ee(M), {
38
39
  validateDates: b,
39
40
  fromDatePickerValue: d,
40
41
  toDatePickerValue: u,
41
42
  fromErrorType: x,
42
43
  toErrorType: A
43
- } = ee(S, m, c, M, !1), o = Y(), F = E(d), p = E(u), C = {
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
- pe as MetadataDateField,
123
+ ge as MetadataDateField,
123
124
  re as MetadataDateFieldNonRelative,
124
- pe as default
125
+ ge as default
125
126
  };
@@ -1,14 +1,13 @@
1
- import { useMemo as a } from "react";
2
- import { DateFormatter as n } from "@box/blueprint-web/lib-esm/primitives/calendar/classes.util";
3
- import { getLocalTimeZone as m } from "@box/blueprint-web/lib-esm/primitives/calendar/get-local-timezone.util";
4
- const c = (t) => {
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: o,
9
- formatCalendarDate: (r) => e.format(r.toDate(o))
7
+ localTimezone: e,
8
+ formatCalendarDate: (r) => o.format(r.toDate(e))
10
9
  };
11
10
  };
12
11
  export {
13
- c as useDateInternationalization
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 { u as d } from "../../../../../../chunks/use-date-validation.js";
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
- d as useDateValidation
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 T } from "@box/blueprint-web";
2
- import { useFormikContext as j, Field as k, getIn as B } from "formik";
3
- import { useState as N, useCallback as F } from "react";
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 d from "../../../../messages.js";
6
- import { R as u } from "../../../../../../chunks/types.js";
7
- import { fieldDefaultProps as S } from "../constants.js";
8
- import { createAdvancedFilterOptionHandler as G, createInputChangeHandler as b } from "./handlers.js";
9
- import { s as m } from "../../../../../../chunks/metadata-float-field.module.js";
10
- import { u as Q } from "../../../../../../chunks/use-float-validation.js";
11
- import { FloatAdvancedFilterOption as U, getInputValues as V, getInputDisplayState as q, FloatInputDisplayState as I } from "./utils.js";
12
- import { jsx as o, jsxs as x, Fragment as z } from "react/jsx-runtime";
13
- import { A as J } from "../../../../../../chunks/index.js";
14
- const se = ({
15
- label: c,
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: y
20
+ filterOptionsMap: E
21
21
  }) => {
22
- const s = $(), a = `${C}.value.enum[0]`, {
23
- values: A
24
- } = j(), [f, L] = N(u.FROM), [l, M] = N(O || U.EQUALS), {
25
- validateFloats: R
26
- } = Q(), w = F((e, r, t, n) => G(a, h, M)(e, r, t, n), [a, h, M]), D = F((e, r, t) => b(a, l, L, u.FROM)(e, r, t), [a, l]), E = F((e, r, t) => b(a, l, L, u.TO)(e, r, t), [a, l]);
27
- return /* @__PURE__ */ o("div", {
28
- className: m.advancedFilterContainer,
29
- "data-testid": `${c}-field`,
30
- children: /* @__PURE__ */ o(k, {
31
- name: a,
32
- validate: () => {
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: e,
38
- meta: r,
39
- form: t
35
+ field: r,
36
+ meta: t,
37
+ form: a
40
38
  }) => {
41
- const n = V(e.value, !0), g = q(l), H = g !== I.NONE, P = g === I.SINGLE, v = g === I.BOTH;
42
- return /* @__PURE__ */ x(z, {
43
- children: [/* @__PURE__ */ o(J, {
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: y,
48
- label: c,
45
+ filterOptionsMap: E,
46
+ label: m,
49
47
  onAdvancedFilterOptionChange: h,
50
- onValueChange: (i) => w(i, n.from, n.to, t),
48
+ onValueChange: (i) => w(i, e.from, e.to, a),
51
49
  showLabel: !0,
52
50
  value: l
53
- }), H && /* @__PURE__ */ x("div", {
54
- className: m.rangeInputsContainer,
55
- children: [(P || v) && /* @__PURE__ */ o("div", {
56
- className: m.inputContainer,
57
- children: /* @__PURE__ */ o(T, {
58
- ...S,
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: f === u.FROM ? r.error : void 0,
58
+ error: T ? t.error : P,
61
59
  hideLabel: !0,
62
- label: s.formatMessage(d.fieldFromLabel, {
63
- label: c
60
+ label: s.formatMessage(u.fieldFromLabel, {
61
+ label: m
64
62
  }),
65
- onChange: (i) => D(i.currentTarget.value, n.to, t),
66
- placeholder: v ? s.formatMessage(d.minValuePlaceholder) : s.formatMessage(d.enterNumberPlaceholder),
67
- value: n.from
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__ */ o("div", {
70
- className: m.inputContainer,
71
- children: /* @__PURE__ */ o(T, {
72
- ...S,
67
+ }), v && /* @__PURE__ */ n("div", {
68
+ className: c.inputContainer,
69
+ children: /* @__PURE__ */ n(N, {
70
+ ...b,
73
71
  disabled: p,
74
- error: f === u.TO ? r.error : void 0,
72
+ error: j,
75
73
  hideLabel: !0,
76
- label: s.formatMessage(d.fieldToLabel, {
77
- label: c
74
+ label: s.formatMessage(u.fieldToLabel, {
75
+ label: m
78
76
  }),
79
- onChange: (i) => E(i.currentTarget.value, n.from, t),
80
- placeholder: s.formatMessage(d.maxValuePlaceholder),
81
- value: n.to
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
- se as MetadataFloatFieldAdvanced,
92
- se as default
89
+ le as MetadataFloatFieldAdvanced,
90
+ le as default
93
91
  };
@@ -1,45 +1,45 @@
1
- import { Text as m } from "@box/blueprint-web";
2
- import { useFormikContext as u, getIn as T, FieldArray as M } from "formik";
3
- import { FormattedMessage as N } from "react-intl";
4
- import k from "../../messages.js";
5
- import { filterFieldTypes as n, advancedFilterFieldTypes as b } from "./filter-field-types.js";
6
- import { s as j } from "../../../../chunks/index.js";
7
- import { jsx as t, jsxs as w } from "react/jsx-runtime";
8
- const z = ({
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: l,
11
- portalElement: c,
12
- taxonomyOptionsFetcher: d,
13
- canUseRelativeDates: y,
14
- isAdvancedFilterEnabled: r,
15
- onAdvancedFilterOptionChange: h,
16
- fieldAdvancedFilterOptions: a,
17
- isMultilevelTaxonomyFieldEnabled: x,
18
- filterOptionsMap: f
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: F
22
- } = u(), s = "metadata.fields", o = T(F, s);
23
- return o.length ? /* @__PURE__ */ t(M, {
24
- name: s,
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: () => o.map((e, g) => {
27
- const i = (r ? b : n)[e.type] || n[e.type];
28
- return i && !e.hidden && /* @__PURE__ */ w("div", {
29
- children: [/* @__PURE__ */ t(i, {
30
- canUseRelativeDates: y,
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: a == null ? void 0 : a[e.key],
33
- fieldNamePrefix: `metadata.fields[${g}]`,
34
- filterOptionsMap: f[e.type] || [],
35
- isAdvancedFilterEnabled: r,
36
- isMultilevelTaxonomyFieldEnabled: x,
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: l,
39
- onAdvancedFilterOptionChange: h,
40
- portalElement: c,
41
- taxonomyOptionsFetcher: d
42
- }), !!e.description && /* @__PURE__ */ t(m, {
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__ */ t(m, {
50
+ }) : /* @__PURE__ */ r(c, {
51
51
  as: "span",
52
- className: j.noAttributesText,
52
+ className: L.noAttributesText,
53
53
  color: "textOnLightSecondary",
54
- children: /* @__PURE__ */ t(N, {
55
- ...k.noTemplateAtributesError
54
+ children: /* @__PURE__ */ r(j, {
55
+ ...t.noTemplateAtributesError
56
56
  })
57
57
  });
58
58
  };
59
59
  export {
60
- z as MetadataFilterFields,
61
- z as default
60
+ q as MetadataFilterFields,
61
+ q as default
62
62
  };