@box/metadata-filter 1.17.3 → 1.18.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,8 +1,8 @@
1
- import '../styles/metadata-date-field.css';const n = "_container_l85l9_1", t = "_daysSelect_l85l9_6", a = "_rangeInputsContainer_l85l9_9", e = "_verticalLayout_l85l9_13", o = "_inputContainer_l85l9_24", r = "_advancedDateContainer_l85l9_32", c = "_datePicker_l85l9_41", i = "_daysInputContainer_l85l9_45", _ = {
1
+ import '../styles/metadata-date-field.css';const n = "_container_10ye0_1", t = "_dateSelect_10ye0_6", e = "_rangeInputsContainer_10ye0_9", a = "_verticalLayout_10ye0_13", o = "_inputContainer_10ye0_23", r = "_advancedDateContainer_10ye0_31", c = "_datePicker_10ye0_40", i = "_daysInputContainer_10ye0_44", _ = {
2
2
  container: n,
3
- daysSelect: t,
4
- rangeInputsContainer: a,
5
- verticalLayout: e,
3
+ dateSelect: t,
4
+ rangeInputsContainer: e,
5
+ verticalLayout: a,
6
6
  inputContainer: o,
7
7
  advancedDateContainer: r,
8
8
  datePicker: c,
@@ -1,4 +1,4 @@
1
- import { DateI18nProvider as ue, Text as me, Radio as c, Select as x, DatePicker as H } from "@box/blueprint-web";
1
+ import { DateI18nProvider as ue, Text as me, Radio as d, Select as x, DatePicker as H } from "@box/blueprint-web";
2
2
  import fe from "clsx";
3
3
  import { useFormikContext as ge, getIn as q, Field as z } from "formik";
4
4
  import { useState as A, useRef as J, useCallback as he, useEffect as ve, useMemo as K } from "react";
@@ -6,7 +6,7 @@ import { useIntl as pe } from "react-intl";
6
6
  import { R as o } from "../../../../../../chunks/types.js";
7
7
  import { DEFAULT_MAX_DATE as Q } from "./constants.js";
8
8
  import { getRelativeFromToValues as Fe, convertToFormikValueRanged as W } from "./date-conversion-utils.js";
9
- import { s as d } from "../../../../../../chunks/metadata-date-field.module.js";
9
+ import { s as c } from "../../../../../../chunks/metadata-date-field.module.js";
10
10
  import { u as Me, E as L } from "../../../../../../chunks/use-date-validation.js";
11
11
  import { getDynamicMaxMinValue as Y } from "./utils.js";
12
12
  import a from "../../../../messages.js";
@@ -22,8 +22,8 @@ const ee = {
22
22
  locale: I,
23
23
  portalElement: M
24
24
  }) => {
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`, y = `${p}.value.relativeDays`, {
26
- values: V,
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
27
  setFieldTouched: ae,
28
28
  setFieldValue: i
29
29
  } = ge(), {
@@ -32,10 +32,10 @@ const ee = {
32
32
  toDatePickerValue: h,
33
33
  fromErrorType: B,
34
34
  toErrorType: w
35
- } = Me(V, m, f, I, !0), r = pe(), G = q(V, P), te = g || h;
35
+ } = Me(y, m, f, I, !0), r = pe(), G = q(y, P), te = g || h;
36
36
  let R = "anyTime";
37
37
  Z(G) ? R = G : te && (R = "customRange");
38
- const [v, re] = A(R), F = q(V, y), b = J(g), O = J(h), U = {
38
+ const [v, re] = A(R), F = q(y, V), b = J(g), O = J(h), U = {
39
39
  clearDatePickerAriaLabel: r.formatMessage(a.clearSelectedDate),
40
40
  nextMonthAriaLabel: r.formatMessage(a.switchToNextMonth),
41
41
  openCalendarDropdownAriaLabel: r.formatMessage(a.openCalendar),
@@ -51,7 +51,7 @@ const ee = {
51
51
  ae(t, !0), D(e);
52
52
  }, se = (e) => {
53
53
  let t;
54
- Z(e) && (t = e), i(P, t), re(e), i(y, void 0), T(!0);
54
+ Z(e) && (t = e), i(P, t), re(e), i(V, void 0), T(!0);
55
55
  }, X = he(() => {
56
56
  const {
57
57
  from: e,
@@ -75,11 +75,11 @@ const ee = {
75
75
  };
76
76
  }, s = De.map(t);
77
77
  return /* @__PURE__ */ l(x, {
78
- className: d.daysSelect,
78
+ className: c.dateSelect,
79
79
  defaultValue: F === void 0 ? "" : String(F),
80
80
  label: r.formatMessage(a.relativeDaysSelectLabel),
81
81
  onValueChange: (n) => {
82
- i(y, Number(n)), T(!0);
82
+ i(V, Number(n)), T(!0);
83
83
  },
84
84
  placeholder: r.formatMessage(a.selectValuePlaceholder),
85
85
  children: /* @__PURE__ */ l(x.Content, {
@@ -92,7 +92,7 @@ const ee = {
92
92
  })
93
93
  });
94
94
  }, ce = () => v !== "customRange" ? null : /* @__PURE__ */ S("div", {
95
- className: fe(d.rangeInputsContainer, d.verticalLayout),
95
+ className: fe(c.rangeInputsContainer, c.verticalLayout, c.dateSelect),
96
96
  children: [/* @__PURE__ */ l(z, {
97
97
  name: m,
98
98
  validate: (e) => $(b.current, O.current, o.FROM),
@@ -100,7 +100,7 @@ const ee = {
100
100
  field: e,
101
101
  meta: t
102
102
  }) => /* @__PURE__ */ l("div", {
103
- className: d.inputContainer,
103
+ className: c.inputContainer,
104
104
  children: /* @__PURE__ */ l(H, {
105
105
  ...e,
106
106
  ...U,
@@ -122,7 +122,7 @@ const ee = {
122
122
  field: e,
123
123
  meta: t
124
124
  }) => /* @__PURE__ */ l("div", {
125
- className: d.inputContainer,
125
+ className: c.inputContainer,
126
126
  children: /* @__PURE__ */ l(H, {
127
127
  ...e,
128
128
  ...U,
@@ -143,38 +143,38 @@ const ee = {
143
143
  return /* @__PURE__ */ l(ue, {
144
144
  locale: I,
145
145
  children: /* @__PURE__ */ S("div", {
146
- className: d.container,
146
+ className: c.container,
147
147
  "data-testid": `${N}-field`,
148
148
  children: [/* @__PURE__ */ l(me, {
149
149
  as: "span",
150
- className: d.rangeFieldLabel,
150
+ className: c.rangeFieldLabel,
151
151
  color: "textOnLightSecondary",
152
152
  variant: "bodyDefaultBold",
153
153
  children: N
154
- }), /* @__PURE__ */ S(c.Group, {
154
+ }), /* @__PURE__ */ S(d.Group, {
155
155
  disabled: u,
156
156
  loop: !1,
157
157
  onValueChange: se,
158
158
  value: v,
159
- children: [/* @__PURE__ */ l(c.Item, {
159
+ children: [/* @__PURE__ */ l(d.Item, {
160
160
  label: r.formatMessage(a.relativeDateFilterAnyTime),
161
161
  value: "anyTime"
162
- }), /* @__PURE__ */ l(c.Item, {
162
+ }), /* @__PURE__ */ l(d.Item, {
163
163
  label: r.formatMessage(a.relativeDateFilterToday),
164
164
  value: "today"
165
- }), /* @__PURE__ */ l(c.Item, {
165
+ }), /* @__PURE__ */ l(d.Item, {
166
166
  description: C("next"),
167
167
  label: r.formatMessage(a.relativeDateFilterNext),
168
168
  value: "next"
169
- }), /* @__PURE__ */ l(c.Item, {
169
+ }), /* @__PURE__ */ l(d.Item, {
170
170
  description: C("past"),
171
171
  label: r.formatMessage(a.relativeDateFilterPast),
172
172
  value: "past"
173
- }), /* @__PURE__ */ l(c.Item, {
173
+ }), /* @__PURE__ */ l(d.Item, {
174
174
  description: C("olderThan"),
175
175
  label: r.formatMessage(a.relativeDateFilterOlderThan),
176
176
  value: "olderThan"
177
- }), /* @__PURE__ */ l(c.Item, {
177
+ }), /* @__PURE__ */ l(d.Item, {
178
178
  description: ce(),
179
179
  label: r.formatMessage(a.relativeDateFilterCustomRange),
180
180
  value: "customRange"
@@ -1,114 +1,116 @@
1
- import { Text as _, DateI18nProvider as H, DatePicker as N } from "@box/blueprint-web";
2
- import { useFormikContext as U, Field as k } from "formik";
3
- import { useState as q, useRef as P, useMemo as E } from "react";
4
- import { useIntl as J } from "react-intl";
1
+ import { Text as J, DateI18nProvider as K, DatePicker as P } from "@box/blueprint-web";
2
+ import { useFormikContext as Q, Field as y } from "formik";
3
+ import { useState as W, useRef as E, useMemo as I } from "react";
4
+ import { useIntl as Y } from "react-intl";
5
5
  import n from "../../../../messages.js";
6
6
  import { R as a } from "../../../../../../chunks/types.js";
7
- import { DEFAULT_MAX_DATE as y } from "./constants.js";
8
- import { convertToFormikValue as I } from "./date-conversion-utils.js";
9
- import { MetadataDateFieldRelative as K } from "./metadata-date-field-relative.js";
10
- import { s as l } from "../../../../../../chunks/metadata-date-field.module.js";
11
- import { u as Q, E as g } from "../../../../../../chunks/use-date-validation.js";
12
- import { useDateInternationalization as W } from "./use-date-internationalization.js";
13
- import { getDynamicMaxMinValue as B } from "./utils.js";
14
- import { jsx as t, jsxs as w } from "react/jsx-runtime";
15
- const fe = ({
16
- canUseRelativeDates: m,
17
- ...i
18
- }) => m ? /* @__PURE__ */ t(K, {
19
- ...i
20
- }) : /* @__PURE__ */ t(Y, {
21
- ...i
22
- }), Y = ({
23
- disableForm: m,
24
- fieldNamePrefix: i,
25
- label: D,
7
+ import { DEFAULT_MAX_DATE as $ } from "./constants.js";
8
+ import { convertToFormikValue as B } from "./date-conversion-utils.js";
9
+ import { MetadataDateFieldRelative as Z } from "./metadata-date-field-relative.js";
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";
13
+ import { getDynamicMaxMinValue as w } from "./utils.js";
14
+ import { jsx as t, jsxs as z } from "react/jsx-runtime";
15
+ const pe = ({
16
+ canUseRelativeDates: f,
17
+ ...s
18
+ }) => f ? /* @__PURE__ */ t(Z, {
19
+ ...s
20
+ }) : /* @__PURE__ */ t(re, {
21
+ ...s
22
+ }), re = ({
23
+ customFieldLabels: f = [],
24
+ direction: s = "horizontal",
25
+ disableForm: v,
26
+ fieldNamePrefix: D,
27
+ label: O,
26
28
  locale: M,
27
- portalElement: v
29
+ portalElement: T
28
30
  }) => {
29
- const [O, h] = q(a.FROM), d = `${i}.value.range.gt`, c = `${i}.value.range.lt`, {
31
+ const [L, h] = W(a.FROM), m = `${D}.value.range.gt`, c = `${D}.value.range.lt`, {
30
32
  values: S,
31
- setFieldTouched: $,
32
- setFieldValue: T
33
- } = U(), {
34
- localTimezone: V
35
- } = W(M), {
36
- validateDates: R,
37
- fromDatePickerValue: u,
38
- toDatePickerValue: f,
39
- fromErrorType: L,
40
- toErrorType: b
41
- } = Q(S, d, c, M, !1), o = J(), F = P(u), p = P(f), x = {
33
+ setFieldTouched: j,
34
+ setFieldValue: V
35
+ } = Q(), {
36
+ localTimezone: R
37
+ } = ae(M), {
38
+ validateDates: b,
39
+ fromDatePickerValue: d,
40
+ toDatePickerValue: u,
41
+ fromErrorType: x,
42
+ toErrorType: A
43
+ } = ee(S, m, c, M, !1), o = Y(), F = E(d), p = E(u), C = {
42
44
  clearDatePickerAriaLabel: o.formatMessage(n.clearSelectedDate),
43
45
  nextMonthAriaLabel: o.formatMessage(n.switchToNextMonth),
44
46
  openCalendarDropdownAriaLabel: o.formatMessage(n.openCalendar),
45
47
  previousMonthAriaLabel: o.formatMessage(n.switchToNextMonth)
46
- }, j = (e) => {
47
- const r = I(e, V, a.FROM);
48
- F.current = e, T(d, r), h(a.FROM);
49
- }, z = (e) => {
50
- const r = I(e, V, a.TO);
51
- p.current = e, T(c, r), h(a.TO);
52
- }, A = (e) => {
53
- const r = e === a.FROM ? d : c;
54
- $(r, !0), h(e);
55
- }, G = E(() => B(f, y), [f]), X = E(() => B(u), [u]), C = (e, r, s) => !!(r === g.MAX && e === g.OVERLAPPING || e === g.OVERLAPPING && s);
56
- return /* @__PURE__ */ w("div", {
57
- className: l.container,
58
- "data-testid": `${D}-field`,
59
- children: [/* @__PURE__ */ t(_, {
48
+ }, [G, X] = f, _ = (e) => {
49
+ const r = B(e, R, a.FROM);
50
+ F.current = e, V(m, r), h(a.FROM);
51
+ }, H = (e) => {
52
+ const r = B(e, R, a.TO);
53
+ p.current = e, V(c, r), h(a.TO);
54
+ }, N = (e) => {
55
+ const r = e === a.FROM ? m : c;
56
+ j(r, !0), h(e);
57
+ }, U = I(() => w(u, $), [u]), q = I(() => w(d), [d]), k = (e, r, l) => !!(r === g.MAX && e === g.OVERLAPPING || e === g.OVERLAPPING && l);
58
+ return /* @__PURE__ */ z("div", {
59
+ className: i.container,
60
+ "data-testid": `${O}-field`,
61
+ children: [/* @__PURE__ */ t(J, {
60
62
  as: "span",
61
- className: l.rangeFieldLabel,
63
+ className: i.rangeFieldLabel,
62
64
  color: "textOnLightSecondary",
63
65
  variant: "bodyDefaultBold",
64
- children: D
65
- }), /* @__PURE__ */ t(H, {
66
+ children: O
67
+ }), /* @__PURE__ */ t(K, {
66
68
  locale: M,
67
- children: /* @__PURE__ */ w("div", {
68
- className: l.rangeInputsContainer,
69
- children: [/* @__PURE__ */ t(k, {
70
- name: d,
71
- validate: (e) => R(F.current, p.current, a.FROM),
69
+ children: /* @__PURE__ */ z("div", {
70
+ className: `${i.rangeInputsContainer} ${s === "vertical" ? i.verticalLayout : ""}`,
71
+ children: [/* @__PURE__ */ t(y, {
72
+ name: m,
73
+ validate: (e) => b(F.current, p.current, a.FROM),
72
74
  children: ({
73
75
  field: e,
74
76
  meta: r
75
77
  }) => /* @__PURE__ */ t("div", {
76
- className: l.inputContainer,
77
- children: /* @__PURE__ */ t(N, {
78
+ className: i.inputContainer,
79
+ children: /* @__PURE__ */ t(P, {
78
80
  ...e,
79
- ...x,
81
+ ...C,
80
82
  calendarAriaLabel: o.formatMessage(n.selectFromDate),
81
- error: C(L, b, O !== a.FROM) ? void 0 : r.error,
82
- isDisabled: m,
83
- label: o.formatMessage(n.fieldFromLabel),
84
- maxValue: G,
85
- onBlur: () => A(a.FROM),
86
- onChange: (s) => j(s),
87
- portalElement: v,
88
- value: u
83
+ error: k(x, A, L !== a.FROM) ? void 0 : r.error,
84
+ isDisabled: v,
85
+ label: G || o.formatMessage(n.fieldFromLabel),
86
+ maxValue: U,
87
+ onBlur: () => N(a.FROM),
88
+ onChange: (l) => _(l),
89
+ portalElement: T,
90
+ value: d
89
91
  })
90
92
  })
91
- }), /* @__PURE__ */ t(k, {
93
+ }), /* @__PURE__ */ t(y, {
92
94
  name: c,
93
- validate: (e) => R(F.current, p.current, a.TO),
95
+ validate: (e) => b(F.current, p.current, a.TO),
94
96
  children: ({
95
97
  field: e,
96
98
  meta: r
97
99
  }) => /* @__PURE__ */ t("div", {
98
- className: l.inputContainer,
99
- children: /* @__PURE__ */ t(N, {
100
+ className: i.inputContainer,
101
+ children: /* @__PURE__ */ t(P, {
100
102
  ...e,
101
- ...x,
103
+ ...C,
102
104
  calendarAriaLabel: o.formatMessage(n.selectToDate),
103
- error: C(b, L, O !== a.TO) ? void 0 : r.error,
104
- isDisabled: m,
105
- label: o.formatMessage(n.fieldToLabel),
106
- maxValue: y,
107
- minValue: X,
108
- onBlur: () => A(a.TO),
109
- onChange: (s) => z(s),
110
- portalElement: v,
111
- value: f
105
+ error: k(A, x, L !== a.TO) ? void 0 : r.error,
106
+ isDisabled: v,
107
+ label: X || o.formatMessage(n.fieldToLabel),
108
+ maxValue: $,
109
+ minValue: q,
110
+ onBlur: () => N(a.TO),
111
+ onChange: (l) => H(l),
112
+ portalElement: T,
113
+ value: u
112
114
  })
113
115
  })
114
116
  })]
@@ -117,7 +119,7 @@ const fe = ({
117
119
  });
118
120
  };
119
121
  export {
120
- fe as MetadataDateField,
121
- Y as MetadataDateFieldNonRelative,
122
- fe as default
122
+ pe as MetadataDateField,
123
+ re as MetadataDateFieldNonRelative,
124
+ pe as default
123
125
  };
@@ -35,7 +35,11 @@ const V = ({
35
35
  name: e.name,
36
36
  onValueChange: (p) => i(a, p),
37
37
  options: d,
38
- placeholder: ((t = e.value) == null ? void 0 : t.length) === 0 ? u.formatMessage(x.multiselectPlaceholder) : "",
38
+ placeholder: (
39
+ // Empty array must be substituded if there is no value found
40
+ // Otherwise an no placeholder appears despite no selection
41
+ ((t = e.value || []) == null ? void 0 : t.length) === 0 ? u.formatMessage(x.multiselectPlaceholder) : ""
42
+ ),
39
43
  portalElement: s,
40
44
  value: e.value
41
45
  })
@@ -1 +1 @@
1
- ._container_l85l9_1{display:flex;flex-direction:column;gap:var(--space-2)}._container_l85l9_1 ._daysSelect_l85l9_6{margin-top:var(--space-3)}._container_l85l9_1 ._rangeInputsContainer_l85l9_9{display:flex;gap:var(--space-2)}._container_l85l9_1 ._rangeInputsContainer_l85l9_9._verticalLayout_l85l9_13{flex-direction:column;gap:var(--space-4);margin-top:var(--space-3)}@media (max-width: 374px){._container_l85l9_1 ._rangeInputsContainer_l85l9_9{flex-direction:column;gap:var(--space-4)}}._container_l85l9_1 ._rangeInputsContainer_l85l9_9 ._inputContainer_l85l9_24{display:flex;flex-direction:column;flex-grow:0;width:100%;min-width:0}._advancedDateContainer_l85l9_32{display:flex;flex-direction:column}._advancedDateContainer_l85l9_32 ._rangeInputsContainer_l85l9_9{display:flex;flex-direction:column;gap:var(--space-2)}._advancedDateContainer_l85l9_32 ._rangeInputsContainer_l85l9_9 ._datePicker_l85l9_41{flex-grow:0;width:100%}._advancedDateContainer_l85l9_32 ._daysInputContainer_l85l9_45{width:100%}
1
+ ._container_10ye0_1{display:flex;flex-direction:column;gap:var(--space-2)}._container_10ye0_1 ._dateSelect_10ye0_6{margin-top:var(--space-3)}._container_10ye0_1 ._rangeInputsContainer_10ye0_9{display:flex;gap:var(--space-2)}._container_10ye0_1 ._rangeInputsContainer_10ye0_9._verticalLayout_10ye0_13{flex-direction:column;gap:var(--space-4)}@media (max-width: 374px){._container_10ye0_1 ._rangeInputsContainer_10ye0_9{flex-direction:column;gap:var(--space-4)}}._container_10ye0_1 ._rangeInputsContainer_10ye0_9 ._inputContainer_10ye0_23{display:flex;flex-direction:column;flex-grow:0;width:100%;min-width:0}._advancedDateContainer_10ye0_31{display:flex;flex-direction:column}._advancedDateContainer_10ye0_31 ._rangeInputsContainer_10ye0_9{display:flex;flex-direction:column;gap:var(--space-2)}._advancedDateContainer_10ye0_31 ._rangeInputsContainer_10ye0_9 ._datePicker_10ye0_40{flex-grow:0;width:100%}._advancedDateContainer_10ye0_31 ._daysInputContainer_10ye0_44{width:100%}
@@ -1,4 +1,4 @@
1
1
  import { MetadataFieldProps } from '../../types';
2
2
  export declare const MetadataDateField: ({ canUseRelativeDates, ...props }: MetadataFieldProps) => import("react/jsx-runtime").JSX.Element;
3
- export declare const MetadataDateFieldNonRelative: ({ disableForm, fieldNamePrefix, label, locale, portalElement, }: 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;
4
4
  export default MetadataDateField;
@@ -21,7 +21,7 @@ export type MetadataFieldProps = {
21
21
  portalElement?: HTMLElement;
22
22
  options?: Array<MetadataTemplateFieldOption>;
23
23
  locale: string;
24
- taxonomyOptionsFetcher: TaxonomyOptionsFetcher;
24
+ taxonomyOptionsFetcher?: TaxonomyOptionsFetcher;
25
25
  className?: string;
26
26
  canUseRelativeDates?: boolean;
27
27
  isAdvancedFilterEnabled?: boolean;
@@ -30,4 +30,6 @@ export type MetadataFieldProps = {
30
30
  filterOptionsMap?: [string, string][];
31
31
  onAdvancedFilterOptionChange?: (fieldKey: string, option: string) => void;
32
32
  fieldAdvancedFilterOptions?: string;
33
+ direction?: 'horizontal' | 'vertical';
34
+ customFieldLabels?: Array<string>;
33
35
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@box/metadata-filter",
3
- "version": "1.17.3",
3
+ "version": "1.18.0",
4
4
  "peerDependencies": {
5
5
  "@box/blueprint-web": "^7.8.0",
6
6
  "@box/blueprint-web-assets": "^4.16.0",