@konstructio/ui 0.1.2-alpha.73 → 0.1.2-alpha.75

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 (64) hide show
  1. package/dist/{Modal-CXRo8f-h.js → Modal-BTOXCb0Y.js} +1 -1
  2. package/dist/assets/icons/components/Home2.d.ts +3 -0
  3. package/dist/assets/icons/components/Home2.js +28 -0
  4. package/dist/assets/icons/components/Upload.d.ts +3 -0
  5. package/dist/assets/icons/components/Upload.js +28 -0
  6. package/dist/assets/icons/components/index.d.ts +2 -0
  7. package/dist/assets/icons/components/index.js +70 -66
  8. package/dist/assets/icons/index.js +70 -66
  9. package/dist/components/Alert/Alert.js +12 -12
  10. package/dist/components/Alert/Alert.types.d.ts +21 -6
  11. package/dist/components/Button/Button.variants.js +4 -5
  12. package/dist/components/ButtonGroup/ButtonGroup.js +1 -1
  13. package/dist/components/ButtonGroup/components/ButtonGroupItem/ButtonGroupItem.js +1 -1
  14. package/dist/components/DateRangePicker/components/CalendarPanel/components/IndependentModeCalendar/IndependentModeCalendar.js +1 -1
  15. package/dist/components/DateRangePicker/components/CalendarPanel/components/TogetherModeCalendar/TogetherModeCalendar.js +1 -1
  16. package/dist/components/Filter/Filter.js +24 -22
  17. package/dist/components/Filter/Filter.types.d.ts +8 -0
  18. package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.hook.d.ts +3 -1
  19. package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.hook.js +57 -41
  20. package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.js +75 -49
  21. package/dist/components/Filter/components/BadgeDropdown/BadgeMultiSelect.types.d.ts +2 -0
  22. package/dist/components/Filter/components/DateFilterDropdown/DateFilterDropdown.hook.js +38 -37
  23. package/dist/components/Filter/components/DateRangeFilterDropdown/DateRangeFilterDropdown.hook.js +31 -30
  24. package/dist/components/Filter/components/TextMultiSelect/TextMultiSelect.js +64 -47
  25. package/dist/components/Filter/components/TextMultiSelect/TextMultiSelect.types.d.ts +2 -0
  26. package/dist/components/Filter/components/TimeFilterDropdown/TimeFilterDropdown.hook.js +35 -34
  27. package/dist/components/Filter/contexts/filter.context.d.ts +4 -0
  28. package/dist/components/Filter/contexts/filter.context.js +7 -0
  29. package/dist/components/Filter/contexts/filter.hook.d.ts +2 -0
  30. package/dist/components/Filter/contexts/filter.hook.js +11 -0
  31. package/dist/components/Filter/contexts/filter.provider.d.ts +5 -0
  32. package/dist/components/Filter/contexts/filter.provider.js +6 -0
  33. package/dist/components/Filter/contexts/index.d.ts +3 -0
  34. package/dist/components/Filter/contexts/index.js +8 -0
  35. package/dist/components/LineChart/LineChart.js +55 -52
  36. package/dist/components/LineChart/LineChart.types.d.ts +2 -0
  37. package/dist/components/Modal/Modal.js +1 -1
  38. package/dist/components/Modal/components/Wrapper/Wrapper.js +2 -2
  39. package/dist/components/Modal/components/index.js +1 -1
  40. package/dist/components/PhoneNumberInput/components/FlagSelectorList/FlagSelectorList.js +394 -353
  41. package/dist/components/Select/Select.types.d.ts +1 -0
  42. package/dist/components/Select/Select.variants.js +1 -1
  43. package/dist/components/Select/components/List/List.js +64 -61
  44. package/dist/components/Select/components/List/List.types.d.ts +1 -0
  45. package/dist/components/Select/components/Wrapper.js +46 -44
  46. package/dist/components/Select/constants/index.d.ts +1 -0
  47. package/dist/components/Select/constants/index.js +3 -1
  48. package/dist/components/Select/constants/list.d.ts +1 -0
  49. package/dist/components/Select/constants/list.js +4 -0
  50. package/dist/components/Toast/Toast.js +192 -184
  51. package/dist/components/Toast/Toast.variants.js +6 -12
  52. package/dist/components/VirtualizedTable/VirtualizedTable.js +57 -55
  53. package/dist/components/VirtualizedTable/VirtualizedTable.types.d.ts +2 -0
  54. package/dist/components/VirtualizedTable/components/Filter/Filter.js +55 -54
  55. package/dist/components/VirtualizedTable/components/Filter/Filter.types.d.ts +1 -0
  56. package/dist/components/index.js +1 -1
  57. package/dist/icons.d.ts +1 -1
  58. package/dist/icons.js +70 -66
  59. package/dist/index.js +1 -1
  60. package/dist/package.json +10 -10
  61. package/dist/proxy-BvdTb_6B.js +4974 -0
  62. package/dist/styles.css +1 -1
  63. package/package.json +10 -10
  64. package/dist/proxy-0sbyKj-k.js +0 -4946
@@ -1,29 +1,31 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import { cn as m } from "../../utils/index.js";
3
- import { filterVariants as l } from "./Filter.variants.js";
4
- import { BadgeMultiSelect as p } from "./components/BadgeDropdown/BadgeMultiSelect.js";
5
- import { TextMultiSelect as a } from "./components/TextMultiSelect/TextMultiSelect.js";
6
- import { DateFilterDropdown as n } from "./components/DateFilterDropdown/DateFilterDropdown.js";
7
- import { DateRangeFilterDropdown as d } from "./components/DateRangeFilterDropdown/DateRangeFilterDropdown.js";
8
- import { TimeFilterDropdown as f } from "./components/TimeFilterDropdown/TimeFilterDropdown.js";
9
- import { ResetButton as D } from "./components/ResetButton/ResetButton.js";
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { cn as l } from "../../utils/index.js";
3
+ import { filterVariants as p } from "./Filter.variants.js";
4
+ import { FilterProvider as a } from "./contexts/filter.provider.js";
5
+ import { BadgeMultiSelect as n } from "./components/BadgeDropdown/BadgeMultiSelect.js";
6
+ import { TextMultiSelect as d } from "./components/TextMultiSelect/TextMultiSelect.js";
7
+ import { DateFilterDropdown as f } from "./components/DateFilterDropdown/DateFilterDropdown.js";
8
+ import { DateRangeFilterDropdown as c } from "./components/DateRangeFilterDropdown/DateRangeFilterDropdown.js";
9
+ import { TimeFilterDropdown as D } from "./components/TimeFilterDropdown/TimeFilterDropdown.js";
10
+ import { ResetButton as s } from "./components/ResetButton/ResetButton.js";
10
11
  const t = ({
11
12
  className: e,
12
13
  theme: o = "civo",
13
- children: r
14
- }) => /* @__PURE__ */ i("div", { className: m(l({ className: e })), "data-theme": o, children: r });
14
+ children: i,
15
+ closeOnApply: m = !0
16
+ }) => /* @__PURE__ */ r(a, { closeOnApply: m, children: /* @__PURE__ */ r("div", { className: l(p({ className: e })), "data-theme": o, children: i }) });
15
17
  t.displayName = "KonstructFilter";
16
- t.BadgeMultiSelect = p;
17
- t.TextMultiSelect = a;
18
- t.DateFilterDropdown = n;
19
- t.DateRangeFilterDropdown = d;
20
- t.TimeFilterDropdown = f;
21
- t.ResetButton = D;
18
+ t.BadgeMultiSelect = n;
19
+ t.TextMultiSelect = d;
20
+ t.DateFilterDropdown = f;
21
+ t.DateRangeFilterDropdown = c;
22
+ t.TimeFilterDropdown = D;
23
+ t.ResetButton = s;
22
24
  export {
23
- p as BadgeMultiSelect,
24
- n as DateFilterDropdown,
25
- d as DateRangeFilterDropdown,
25
+ n as BadgeMultiSelect,
26
+ f as DateFilterDropdown,
27
+ c as DateRangeFilterDropdown,
26
28
  t as Filter,
27
- a as TextMultiSelect,
28
- f as TimeFilterDropdown
29
+ d as TextMultiSelect,
30
+ D as TimeFilterDropdown
29
31
  };
@@ -14,6 +14,12 @@ export type Option = {
14
14
  label: string;
15
15
  /** Visual variant for the badge */
16
16
  variant?: BadgeProps['variant'];
17
+ /** Icon displayed on the left of the badge */
18
+ leftIcon?: BadgeProps['leftIcon'];
19
+ /** Icon displayed on the right of the badge */
20
+ rightIcon?: BadgeProps['rightIcon'];
21
+ /** Show loading spinner in the badge */
22
+ loading?: BadgeProps['loading'];
17
23
  };
18
24
  /**
19
25
  * Props for the Filter component.
@@ -41,6 +47,8 @@ export type FilterProps = VariantProps<typeof filterVariants> & PropsWithChildre
41
47
  className?: string;
42
48
  /** Theme override for this component */
43
49
  theme?: Theme;
50
+ /** Whether to close the filter dropdown automatically when Apply is clicked. Defaults to true. */
51
+ closeOnApply?: boolean;
44
52
  };
45
53
  /**
46
54
  * Filter compound component type with sub-components.
@@ -1,12 +1,14 @@
1
1
  import { Option } from '../../Filter.types';
2
2
  import { BadgeMultiSelectProps, SelectedOptions } from './BadgeMultiSelect.types';
3
- export declare const useBadgeMultiSelect: ({ onApply, }: Pick<BadgeMultiSelectProps, "onApply">) => {
3
+ export declare const useBadgeMultiSelect: ({ onApply, options, }: Pick<BadgeMultiSelectProps, "onApply" | "options">) => {
4
4
  isOpen: boolean;
5
+ isAllSelected: boolean;
5
6
  selectedCount: SelectedOptions[];
6
7
  selectedOptions: SelectedOptions[];
7
8
  wrapperRef: import('react').RefObject<HTMLDivElement | null>;
8
9
  handleApplyOptions: () => void;
9
10
  handleOpen: () => void;
10
11
  handleResetOptions: () => void;
12
+ handleSelectAll: (allOptions: Option[], checked: boolean) => void;
11
13
  handleSelectOption: (option: Option, checked: boolean) => void;
12
14
  };
@@ -1,21 +1,23 @@
1
- import { useId as b, useRef as C, useState as u, useEffect as m, useCallback as o, useMemo as w } from "react";
2
- import { FilterEvent as p, sendOpenFilterEvent as S } from "../../events/index.js";
3
- const k = ({
4
- onApply: l
1
+ import { useId as L, useRef as F, useState as m, useEffect as p, useCallback as d, useMemo as v } from "react";
2
+ import { FilterEvent as O, sendOpenFilterEvent as k } from "../../events/index.js";
3
+ import { useFilterContext as x } from "../../contexts/filter.hook.js";
4
+ const B = ({
5
+ onApply: l,
6
+ options: a = []
5
7
  }) => {
6
- const r = b(), a = C(null), [f, d] = u(!1), [s, i] = u([]);
7
- m(() => {
8
+ const { closeOnApply: r } = x(), c = L(), u = F(null), [g, o] = m(!1), [n, i] = m([]);
9
+ p(() => {
8
10
  const e = new AbortController();
9
11
  return document.addEventListener(
10
- p.OPEN,
12
+ O.OPEN,
11
13
  (t) => {
12
- t.detail !== r && d(!1);
14
+ t.detail !== c && o(!1);
13
15
  },
14
16
  {
15
17
  signal: e.signal
16
18
  }
17
19
  ), document.addEventListener(
18
- p.RESET,
20
+ O.RESET,
19
21
  () => {
20
22
  i([]), l?.([]);
21
23
  },
@@ -25,43 +27,55 @@ const k = ({
25
27
  ), () => {
26
28
  e.abort();
27
29
  };
28
- }, [r, l]);
29
- const v = o(
30
- () => d((e) => (e || (S(r), i(
31
- (t) => t.filter((n) => n.isApplied)
30
+ }, [c, l]);
31
+ const E = d(
32
+ () => o((e) => (e || (k(c), i(
33
+ (t) => t.filter((s) => s.isApplied)
32
34
  )), !e)),
33
- [r, d]
34
- ), c = o(() => d(!1), []), E = o(
35
+ [c, o]
36
+ ), f = d(() => o(!1), []), h = d(
35
37
  (e, t) => {
36
38
  i(t ? [
37
- ...s,
39
+ ...n,
38
40
  { ...e, isApplied: !1 }
39
- ] : s.map((n) => n.id === e.id ? { ...n, isRemoved: !0 } : n));
41
+ ] : n.map((s) => s.id === e.id ? { ...s, isRemoved: !0 } : s));
40
42
  },
41
- [i, s]
42
- ), O = o(() => {
43
- i([]), l?.([]);
44
- }, [l]), g = o(() => {
45
- const e = s?.filter((t) => !t.isRemoved).map((t) => ({ ...t, isApplied: !0 }));
43
+ [i, n]
44
+ ), R = d(() => {
45
+ i([]), l?.([]), r && o(!1);
46
+ }, [r, l]), A = d(() => {
47
+ const e = n?.filter((t) => !t.isRemoved).map((t) => ({ ...t, isApplied: !0 }));
46
48
  i(e), l?.(
47
49
  e.map(
48
- ({ isApplied: t, isRemoved: n, ...R }) => R
50
+ ({ isApplied: t, isRemoved: s, ...w }) => w
49
51
  )
50
- );
51
- }, [l, s, i]), h = w(
52
- () => s.filter((e) => e.isApplied),
53
- [s]
52
+ ), r && o(!1);
53
+ }, [r, l, n, i]), C = v(
54
+ () => n.filter((e) => e.isApplied),
55
+ [n]
56
+ ), S = v(
57
+ () => a.length > 0 && a.every(
58
+ (e) => n.some((t) => t.id === e.id && !t.isRemoved)
59
+ ),
60
+ [a, n]
61
+ ), b = d(
62
+ (e, t) => {
63
+ t && i(
64
+ e.map((s) => ({ ...s, isApplied: !1 }))
65
+ );
66
+ },
67
+ []
54
68
  );
55
- return m(() => {
56
- const e = new AbortController(), t = (n) => {
57
- a.current?.contains(n.target) || c();
69
+ return p(() => {
70
+ const e = new AbortController(), t = (s) => {
71
+ u.current?.contains(s.target) || f();
58
72
  };
59
73
  return document.addEventListener("mousedown", t, {
60
74
  signal: e.signal
61
75
  }), document.addEventListener(
62
76
  "visibilitychange",
63
77
  () => {
64
- document.hidden && c();
78
+ document.hidden && f();
65
79
  },
66
80
  {
67
81
  signal: e.signal
@@ -69,17 +83,19 @@ const k = ({
69
83
  ), () => {
70
84
  e.abort();
71
85
  };
72
- }, [c, a]), {
73
- isOpen: f,
74
- selectedCount: h,
75
- selectedOptions: s,
76
- wrapperRef: a,
77
- handleApplyOptions: g,
78
- handleOpen: v,
79
- handleResetOptions: O,
80
- handleSelectOption: E
86
+ }, [f, u]), {
87
+ isOpen: g,
88
+ isAllSelected: S,
89
+ selectedCount: C,
90
+ selectedOptions: n,
91
+ wrapperRef: u,
92
+ handleApplyOptions: A,
93
+ handleOpen: E,
94
+ handleResetOptions: R,
95
+ handleSelectAll: b,
96
+ handleSelectOption: h
81
97
  };
82
98
  };
83
99
  export {
84
- k as useBadgeMultiSelect
100
+ B as useBadgeMultiSelect
85
101
  };
@@ -1,50 +1,54 @@
1
- import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
- import { Badge as o } from "../../../Badge/Badge.js";
3
- import { Button as m } from "../../../Button/Button.js";
4
- import { Checkbox as k } from "../../../Checkbox/Checkbox.js";
5
- import { filterButtonIconVariants as C, filterButtonVariants as y } from "../../Filter.variants.js";
1
+ import { jsxs as a, jsx as l } from "react/jsx-runtime";
2
+ import { Badge as c } from "../../../Badge/Badge.js";
3
+ import { Button as h } from "../../../Button/Button.js";
4
+ import { Checkbox as f } from "../../../Checkbox/Checkbox.js";
5
+ import { filterButtonIconVariants as B, filterButtonVariants as O } from "../../Filter.variants.js";
6
6
  import { cn as r } from "../../../../utils/index.js";
7
- import { useBadgeMultiSelect as N } from "./BadgeMultiSelect.hook.js";
8
- import { C as B } from "../../../../chevron-down-BBFYYzZq.js";
9
- const $ = ({
10
- options: n,
7
+ import { useBadgeMultiSelect as A } from "./BadgeMultiSelect.hook.js";
8
+ import { C as I } from "../../../../chevron-down-BBFYYzZq.js";
9
+ const q = ({
10
+ options: t,
11
11
  label: p,
12
12
  position: i = "left",
13
- onApply: f
13
+ onApply: g,
14
+ showSelectAll: u = !0,
15
+ selectAllLabel: b = "All"
14
16
  }) => {
15
17
  const {
16
- wrapperRef: h,
17
- isOpen: l,
18
- selectedOptions: u,
19
- selectedCount: c,
20
- handleOpen: g,
21
- handleResetOptions: b,
22
- handleApplyOptions: x,
23
- handleSelectOption: v
24
- } = N({ onApply: f });
25
- return n.length === 0 ? null : /* @__PURE__ */ t("div", { ref: h, className: "relative", children: [
26
- /* @__PURE__ */ t(
18
+ wrapperRef: x,
19
+ isOpen: d,
20
+ isAllSelected: s,
21
+ selectedOptions: v,
22
+ selectedCount: m,
23
+ handleOpen: k,
24
+ handleResetOptions: C,
25
+ handleApplyOptions: N,
26
+ handleSelectAll: y,
27
+ handleSelectOption: S
28
+ } = A({ onApply: g, options: t });
29
+ return t.length === 0 ? null : /* @__PURE__ */ a("div", { ref: x, className: "relative", children: [
30
+ /* @__PURE__ */ a(
27
31
  "button",
28
32
  {
29
- className: r(y(), {
30
- "text-slate-700 dark:text-metal-50": l
33
+ className: r(O(), {
34
+ "text-slate-700 dark:text-metal-50": d
31
35
  }),
32
- onClick: g,
36
+ onClick: k,
33
37
  children: [
34
38
  p,
35
- c.length > 0 && /* @__PURE__ */ e(o, { label: c.length.toString() }),
36
- /* @__PURE__ */ e(
37
- B,
39
+ m.length > 0 && /* @__PURE__ */ l(c, { label: m.length.toString() }),
40
+ /* @__PURE__ */ l(
41
+ I,
38
42
  {
39
- className: r(C(), {
40
- "rotate-180 text-blue-600 dark:text-aurora-500": l
43
+ className: r(B(), {
44
+ "rotate-180 text-blue-600 dark:text-aurora-500": d
41
45
  })
42
46
  }
43
47
  )
44
48
  ]
45
49
  }
46
50
  ),
47
- l && /* @__PURE__ */ t(
51
+ d && /* @__PURE__ */ a(
48
52
  "div",
49
53
  {
50
54
  className: r(
@@ -67,24 +71,46 @@ const $ = ({
67
71
  }
68
72
  ),
69
73
  children: [
70
- /* @__PURE__ */ e("div", { className: "px-6 py-4", children: /* @__PURE__ */ e("div", { className: "flex flex-col gap-2", children: n.map((a) => {
71
- const s = !!u.find(
72
- (d) => d.id === a.id
73
- );
74
- return /* @__PURE__ */ t("div", { className: "flex gap-4", children: [
75
- /* @__PURE__ */ e(
76
- k,
74
+ /* @__PURE__ */ l("div", { className: "px-6 py-4", children: /* @__PURE__ */ a("div", { className: "flex flex-col gap-2", children: [
75
+ u && /* @__PURE__ */ a("div", { className: "flex gap-4", children: [
76
+ /* @__PURE__ */ l(
77
+ f,
77
78
  {
78
79
  defaultChecked: s,
79
- "data-label": a.id,
80
- onChange: (d) => v(a, d)
80
+ onChange: (e) => y(t, e)
81
81
  },
82
- `${a.id}-${s}`
82
+ `select-all-${s}`
83
83
  ),
84
- /* @__PURE__ */ e(o, { label: a.label, variant: a.variant })
85
- ] }, a.id);
86
- }) }) }),
87
- /* @__PURE__ */ t(
84
+ /* @__PURE__ */ l(c, { label: b })
85
+ ] }),
86
+ t.map((e) => {
87
+ const o = !!v.find(
88
+ (n) => n.id === e.id
89
+ );
90
+ return /* @__PURE__ */ a("div", { className: "flex gap-4", children: [
91
+ /* @__PURE__ */ l(
92
+ f,
93
+ {
94
+ defaultChecked: o,
95
+ "data-label": e.id,
96
+ onChange: (n) => S(e, n)
97
+ },
98
+ `${e.id}-${o}`
99
+ ),
100
+ /* @__PURE__ */ l(
101
+ c,
102
+ {
103
+ label: e.label,
104
+ variant: e.variant,
105
+ leftIcon: e.leftIcon,
106
+ rightIcon: e.rightIcon,
107
+ loading: e.loading
108
+ }
109
+ )
110
+ ] }, e.id);
111
+ })
112
+ ] }) }),
113
+ /* @__PURE__ */ a(
88
114
  "div",
89
115
  {
90
116
  className: r(
@@ -99,16 +125,16 @@ const $ = ({
99
125
  "dark:border-metal-700"
100
126
  ),
101
127
  children: [
102
- /* @__PURE__ */ e(
103
- m,
128
+ /* @__PURE__ */ l(
129
+ h,
104
130
  {
105
131
  variant: "secondary",
106
132
  appearance: "compact",
107
- onClick: b,
133
+ onClick: C,
108
134
  children: "Reset"
109
135
  }
110
136
  ),
111
- /* @__PURE__ */ e(m, { appearance: "compact", onClick: x, children: "Apply" })
137
+ /* @__PURE__ */ l(h, { appearance: "compact", onClick: N, children: "Apply" })
112
138
  ]
113
139
  }
114
140
  )
@@ -118,5 +144,5 @@ const $ = ({
118
144
  ] });
119
145
  };
120
146
  export {
121
- $ as BadgeMultiSelect
147
+ q as BadgeMultiSelect
122
148
  };
@@ -8,4 +8,6 @@ export type BadgeMultiSelectProps = {
8
8
  options: Option[];
9
9
  position?: 'left' | 'right';
10
10
  onApply?: (selectedOptions: Option[]) => void;
11
+ showSelectAll?: boolean;
12
+ selectAllLabel?: string;
11
13
  };
@@ -1,31 +1,32 @@
1
- import { useRef as w, useId as S, useState as m, useMemo as C, useCallback as s, useEffect as f } from "react";
2
- import { sendOpenFilterEvent as y, FilterEvent as E } from "../../events/index.js";
3
- import { getLocale as F } from "../../utils/index.js";
4
- const N = ({
1
+ import { useRef as C, useId as S, useState as f, useMemo as y, useCallback as r, useEffect as E } from "react";
2
+ import { sendOpenFilterEvent as F, FilterEvent as v } from "../../events/index.js";
3
+ import { getLocale as R } from "../../utils/index.js";
4
+ import { useFilterContext as k } from "../../contexts/filter.hook.js";
5
+ const A = ({
5
6
  onApply: n,
6
- countryCode: v = "US"
7
+ countryCode: g = "US"
7
8
  }) => {
8
- const i = w(null), t = S(), [h, a] = m(!1), [r, l] = m(), [g, c] = m(), p = C(
9
- () => g?.toLocaleDateString(F(v), {
9
+ const { closeOnApply: a } = k(), i = C(null), t = S(), [h, o] = f(!1), [l, c] = f(), [p, d] = f(), D = y(
10
+ () => p?.toLocaleDateString(R(g), {
10
11
  day: "numeric",
11
12
  month: "short",
12
13
  year: "numeric"
13
14
  }),
14
- [g, v]
15
- ), D = s(
16
- () => a((e) => (e || y(t), !e)),
15
+ [p, g]
16
+ ), b = r(
17
+ () => o((e) => (e || F(t), !e)),
17
18
  [t]
18
- ), b = s(() => {
19
- c(r), n?.(r);
20
- }, [n, r]), L = s((e) => l(e), []), d = s(() => a(!1), []), O = s(() => {
21
- l(void 0), c(void 0), n?.();
22
- }, [n]);
23
- return f(() => {
19
+ ), O = r(() => {
20
+ d(l), n?.(l), a && o(!1);
21
+ }, [a, n, l]), L = r((e) => c(e), []), u = r(() => o(!1), []), w = r(() => {
22
+ c(void 0), d(void 0), n?.(), a && o(!1);
23
+ }, [a, n]);
24
+ return E(() => {
24
25
  const e = new AbortController();
25
26
  return document.addEventListener(
26
- E.OPEN,
27
- ((o) => {
28
- o.detail !== t && a(!1);
27
+ v.OPEN,
28
+ ((s) => {
29
+ s.detail !== t && o(!1);
29
30
  }),
30
31
  {
31
32
  signal: e.signal
@@ -33,20 +34,20 @@ const N = ({
33
34
  ), () => {
34
35
  e.abort();
35
36
  };
36
- }, [t]), f(() => {
37
+ }, [t]), E(() => {
37
38
  const e = new AbortController();
38
39
  return document.addEventListener(
39
- E.OPEN,
40
- (o) => {
41
- o.detail !== t && a(!1);
40
+ v.OPEN,
41
+ (s) => {
42
+ s.detail !== t && o(!1);
42
43
  },
43
44
  {
44
45
  signal: e.signal
45
46
  }
46
47
  ), document.addEventListener(
47
- E.RESET,
48
+ v.RESET,
48
49
  () => {
49
- l(void 0), c(void 0), n?.();
50
+ c(void 0), d(void 0), n?.();
50
51
  },
51
52
  {
52
53
  signal: e.signal
@@ -54,16 +55,16 @@ const N = ({
54
55
  ), () => {
55
56
  e.abort();
56
57
  };
57
- }, [t, n]), f(() => {
58
- const e = new AbortController(), o = (u) => {
59
- i.current?.contains(u.target) || d();
58
+ }, [t, n]), E(() => {
59
+ const e = new AbortController(), s = (m) => {
60
+ i.current?.contains(m.target) || u();
60
61
  };
61
- return document.addEventListener("mousedown", o, {
62
+ return document.addEventListener("mousedown", s, {
62
63
  signal: e.signal
63
64
  }), document.addEventListener(
64
65
  "visibilitychange",
65
66
  () => {
66
- document.hidden && d();
67
+ document.hidden && u();
67
68
  },
68
69
  {
69
70
  signal: e.signal
@@ -71,18 +72,18 @@ const N = ({
71
72
  ), () => {
72
73
  e.abort();
73
74
  };
74
- }, [d, i]), {
75
+ }, [u, i]), {
75
76
  id: t,
76
- appliedDay: p,
77
+ appliedDay: D,
77
78
  isOpen: h,
78
- selectedDay: r,
79
+ selectedDay: l,
79
80
  wrapperRef: i,
80
- handleApply: b,
81
- handleOpen: D,
81
+ handleApply: O,
82
+ handleOpen: b,
82
83
  handleSelect: L,
83
- handleReset: O
84
+ handleReset: w
84
85
  };
85
86
  };
86
87
  export {
87
- N as useDateFilterDropdown
88
+ A as useDateFilterDropdown
88
89
  };
@@ -1,40 +1,41 @@
1
- import { useRef as w, useId as S, useState as u, useMemo as D, useCallback as s, useEffect as g } from "react";
2
- import { sendOpenFilterEvent as F, FilterEvent as v } from "../../events/index.js";
3
- import { getLocale as k } from "../../utils/index.js";
4
- const x = ({
1
+ import { useRef as F, useId as S, useState as u, useMemo as D, useCallback as a, useEffect as p } from "react";
2
+ import { sendOpenFilterEvent as k, FilterEvent as v } from "../../events/index.js";
3
+ import { getLocale as x } from "../../utils/index.js";
4
+ import { useFilterContext as I } from "../../contexts/filter.hook.js";
5
+ const P = ({
5
6
  defaultRange: h,
6
7
  onApply: t,
7
8
  countryCode: E = "US"
8
9
  }) => {
9
- const d = w(null), o = S(), [R, a] = u(!1), [i, l] = u(
10
+ const { closeOnApply: i } = I(), d = F(null), o = S(), [R, s] = u(!1), [l, c] = u(
10
11
  h
11
- ), [n, c] = u(), p = D(() => {
12
+ ), [n, f] = u(), C = D(() => {
12
13
  if (!n?.from) return;
13
- const e = (r) => r.toLocaleDateString(k(E), {
14
+ const e = (r) => r.toLocaleDateString(x(E), {
14
15
  day: "numeric",
15
16
  month: "short"
16
17
  });
17
18
  return n.to ? `${e(n.from)} - ${e(n.to)}` : e(n.from);
18
- }, [n]), b = s(
19
- () => a((e) => (e || F(o), !e)),
19
+ }, [n]), O = a(
20
+ () => s((e) => (e || k(o), !e)),
20
21
  [o]
21
- ), C = s(() => {
22
+ ), b = a(() => {
22
23
  const e = {
23
- from: i?.from,
24
- to: i?.to
24
+ from: l?.from,
25
+ to: l?.to
25
26
  };
26
- c(e), t?.(e), a(!1);
27
- }, [t, i]), L = s((e) => {
28
- l({ from: e.from, to: e.to });
29
- }, []), m = s(() => a(!1), []), O = s(() => {
30
- l(void 0), c(void 0), t?.();
31
- }, [t]);
32
- return g(() => {
27
+ f(e), t?.(e), i && s(!1);
28
+ }, [i, t, l]), L = a((e) => {
29
+ c({ from: e.from, to: e.to });
30
+ }, []), m = a(() => s(!1), []), w = a(() => {
31
+ c(void 0), f(void 0), t?.(), i && s(!1);
32
+ }, [i, t]);
33
+ return p(() => {
33
34
  const e = new AbortController();
34
35
  return document.addEventListener(
35
36
  v.OPEN,
36
37
  (r) => {
37
- r.detail !== o && a(!1);
38
+ r.detail !== o && s(!1);
38
39
  },
39
40
  {
40
41
  signal: e.signal
@@ -42,7 +43,7 @@ const x = ({
42
43
  ), document.addEventListener(
43
44
  v.RESET,
44
45
  () => {
45
- l(void 0), c(void 0), t?.();
46
+ c(void 0), f(void 0), t?.();
46
47
  },
47
48
  {
48
49
  signal: e.signal
@@ -50,9 +51,9 @@ const x = ({
50
51
  ), () => {
51
52
  e.abort();
52
53
  };
53
- }, [o, t]), g(() => {
54
- const e = new AbortController(), r = (f) => {
55
- d.current?.contains(f.target) || m();
54
+ }, [o, t]), p(() => {
55
+ const e = new AbortController(), r = (g) => {
56
+ d.current?.contains(g.target) || m();
56
57
  };
57
58
  return document.addEventListener("mousedown", r, {
58
59
  signal: e.signal
@@ -69,16 +70,16 @@ const x = ({
69
70
  };
70
71
  }, [m, d]), {
71
72
  id: o,
72
- appliedRange: p,
73
+ appliedRange: C,
73
74
  isOpen: R,
74
- selectedRange: i,
75
+ selectedRange: l,
75
76
  wrapperRef: d,
76
- handleApply: C,
77
- handleOpen: b,
77
+ handleApply: b,
78
+ handleOpen: O,
78
79
  handleRangeChange: L,
79
- handleReset: O
80
+ handleReset: w
80
81
  };
81
82
  };
82
83
  export {
83
- x as useDateRangeFilterDropdown
84
+ P as useDateRangeFilterDropdown
84
85
  };