@konstructio/ui 0.1.0-alpha.7 → 0.1.0-alpha.8

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.
@@ -0,0 +1,20 @@
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { cn as m } from "../../utils/index.js";
3
+ import { filterVariants as a } from "./Filter.variants.js";
4
+ import { BadgeMultiSelect as l } from "./components/BadgeDropdown/BadgeMultiSelect.js";
5
+ import { DateFilterDropdown as p } from "./components/DateFilterDropdown/DateFilterDropdown.js";
6
+ import { ResetButton as s } from "./components/ResetButton/ResetButton.js";
7
+ const t = ({
8
+ className: e,
9
+ theme: o = "civo",
10
+ children: r
11
+ }) => /* @__PURE__ */ i("div", { className: m(a({ className: e })), "data-theme": o, children: r });
12
+ t.displayName = "Filter";
13
+ t.BadgeMultiSelect = l;
14
+ t.DateFilterDropdown = p;
15
+ t.ResetButton = s;
16
+ export {
17
+ l as BadgeMultiSelect,
18
+ p as DateFilterDropdown,
19
+ t as Filter
20
+ };
@@ -0,0 +1,22 @@
1
+ import { c as t } from "../../index-BNmRGtA6.js";
2
+ const a = t(["flex", "gap-8", "items-center"]), n = t([
3
+ "flex",
4
+ "items-center",
5
+ "gap-1",
6
+ "text-slate-500",
7
+ "cursor-pointer",
8
+ "text-sm",
9
+ "w-max"
10
+ ]), r = t([
11
+ "text-slate-400",
12
+ "h-[20px]",
13
+ "w-[20px]",
14
+ "transition-all",
15
+ "duration-150",
16
+ "ease-in-out"
17
+ ]);
18
+ export {
19
+ r as filterButtonIconVariants,
20
+ n as filterButtonVariants,
21
+ a as filterVariants
22
+ };
@@ -0,0 +1,87 @@
1
+ import { useId as C, useRef as S, useState as m, useEffect as f, useCallback as r, useMemo as w } from "react";
2
+ import { FilterEvent as E, sendOpenFilterEvent as L } from "../../events/index.js";
3
+ const I = ({
4
+ onApply: t
5
+ }) => {
6
+ const a = C(), c = S(null), [g, l] = m(!1), [n, d] = m([]);
7
+ f(() => {
8
+ const e = new AbortController();
9
+ return document.addEventListener(
10
+ E.OPEN,
11
+ (s) => {
12
+ s.detail !== a && l(!1);
13
+ },
14
+ {
15
+ signal: e.signal
16
+ }
17
+ ), document.addEventListener(
18
+ E.RESET,
19
+ () => {
20
+ d([]), t == null || t([]);
21
+ },
22
+ {
23
+ signal: e.signal
24
+ }
25
+ ), () => {
26
+ e.abort();
27
+ };
28
+ }, [a, t]);
29
+ const O = r(
30
+ () => l((e) => (e || (L(a), d(
31
+ (s) => s.filter((i) => i.isApplied)
32
+ )), !e)),
33
+ [a, l]
34
+ ), o = r(() => l(!1), []), h = r(
35
+ (e, s) => {
36
+ d(s ? [
37
+ ...n,
38
+ { ...e, isApplied: !1 }
39
+ ] : n.map((i) => i.id === e.id ? { ...i, isRemoved: !0 } : i));
40
+ },
41
+ [d, n]
42
+ ), v = r(() => {
43
+ d([]), t == null || t([]);
44
+ }, [t]), R = r(() => {
45
+ d(
46
+ (e) => e == null ? void 0 : e.filter((s) => !s.isRemoved).map((s) => ({ ...s, isApplied: !0 }))
47
+ ), t == null || t(
48
+ n.map(
49
+ ({ isApplied: e, isRemoved: s, ...i }) => i
50
+ )
51
+ );
52
+ }, [t, n, d]), b = w(
53
+ () => n.filter((e) => e.isApplied),
54
+ [n]
55
+ );
56
+ return f(() => {
57
+ const e = new AbortController(), s = (i) => {
58
+ var u;
59
+ (u = c.current) != null && u.contains(i.target) || o();
60
+ };
61
+ return document.addEventListener("mousedown", s, {
62
+ signal: e.signal
63
+ }), document.addEventListener(
64
+ "visibilitychange",
65
+ () => {
66
+ document.hidden && o();
67
+ },
68
+ {
69
+ signal: e.signal
70
+ }
71
+ ), () => {
72
+ e.abort();
73
+ };
74
+ }, [o, c]), {
75
+ isOpen: g,
76
+ selectedCount: b,
77
+ selectedOptions: n,
78
+ wrapperRef: c,
79
+ handleApplyOptions: R,
80
+ handleOpen: O,
81
+ handleResetOptions: v,
82
+ handleSelectOption: h
83
+ };
84
+ };
85
+ export {
86
+ I as useBadgeMultiSelect
87
+ };
@@ -0,0 +1,82 @@
1
+ import { jsxs as t, jsx as e } from "react/jsx-runtime";
2
+ import { Badge as c } from "../../../Badge/Badge.js";
3
+ import { Button as s } from "../../../Button/Button.js";
4
+ import { Checkbox as x } from "../../../Checkbox/Checkbox.js";
5
+ import { cn as o } from "../../../../utils/index.js";
6
+ import { filterButtonIconVariants as C, filterButtonVariants as y } from "../../Filter.variants.js";
7
+ import { useBadgeMultiSelect as N } from "./BadgeMultiSelect.hook.js";
8
+ import { C as B } from "../../../../chevron-down-UW8ts6wI.js";
9
+ const V = ({
10
+ options: n,
11
+ label: m,
12
+ onApply: p
13
+ }) => {
14
+ const {
15
+ wrapperRef: f,
16
+ isOpen: l,
17
+ selectedOptions: h,
18
+ selectedCount: i,
19
+ handleOpen: u,
20
+ handleResetOptions: g,
21
+ handleApplyOptions: b,
22
+ handleSelectOption: v
23
+ } = N({ onApply: p });
24
+ return n.length === 0 ? null : /* @__PURE__ */ t("div", { ref: f, className: "relative", children: [
25
+ /* @__PURE__ */ t(
26
+ "button",
27
+ {
28
+ className: o(y(), {
29
+ "text-slate-700": l
30
+ }),
31
+ onClick: u,
32
+ children: [
33
+ m,
34
+ i.length > 0 && /* @__PURE__ */ e(c, { label: i.length.toString() }),
35
+ /* @__PURE__ */ e(
36
+ B,
37
+ {
38
+ className: o(C(), {
39
+ "rotate-180": l,
40
+ "text-blue-600": l
41
+ })
42
+ }
43
+ )
44
+ ]
45
+ }
46
+ ),
47
+ l && /* @__PURE__ */ t("div", { className: "absolute top-full mt-1 left-0 bg-white rounded-md shadow-md animate-in fade-in-0 z-10 border border-gray-200", children: [
48
+ /* @__PURE__ */ e("div", { className: "py-4", children: /* @__PURE__ */ e("div", { className: "flex flex-col gap-2", children: n.map((a) => {
49
+ const d = !!h.find(
50
+ (r) => r.id === a.id
51
+ );
52
+ return /* @__PURE__ */ t("div", { className: "flex gap-4 px-6", children: [
53
+ /* @__PURE__ */ e(
54
+ x,
55
+ {
56
+ defaultChecked: d,
57
+ "data-label": a.id,
58
+ onChange: (r) => v(a, r)
59
+ },
60
+ `${a.id}-${d}`
61
+ ),
62
+ /* @__PURE__ */ e(c, { label: a.label, variant: a.variant })
63
+ ] }, a.id);
64
+ }) }) }),
65
+ /* @__PURE__ */ t("div", { className: "flex justify-center items-center gap-4 py-4 border-t border-gray-200", children: [
66
+ /* @__PURE__ */ e(
67
+ s,
68
+ {
69
+ variant: "secondary",
70
+ appearance: "compact",
71
+ onClick: g,
72
+ children: "Reset"
73
+ }
74
+ ),
75
+ /* @__PURE__ */ e(s, { appearance: "compact", onClick: b, children: "Apply" })
76
+ ] })
77
+ ] })
78
+ ] });
79
+ };
80
+ export {
81
+ V as BadgeMultiSelect
82
+ };
@@ -0,0 +1,87 @@
1
+ import { useRef as L, useId as S, useState as E, useMemo as F, useCallback as r, useEffect as f } from "react";
2
+ import { sendOpenFilterEvent as R, FilterEvent as v } from "../../events/index.js";
3
+ const N = ({
4
+ onApply: t
5
+ }) => {
6
+ const c = L(null), n = S(), [h, o] = E(!1), [a, d] = E(), [i, l] = E(), b = F(
7
+ () => i == null ? void 0 : i.toLocaleDateString("en-GB", {
8
+ day: "numeric",
9
+ month: "short",
10
+ year: "numeric"
11
+ }),
12
+ [i]
13
+ ), D = r(
14
+ () => o((e) => (e || R(n), !e)),
15
+ [n]
16
+ ), O = r(() => {
17
+ l(a), t == null || t(a);
18
+ }, [t, a]), w = r((e) => d(e), []), u = r(() => o(!1), []), C = r(() => {
19
+ d(void 0), l(void 0), t == null || t();
20
+ }, [t]);
21
+ return f(() => {
22
+ const e = new AbortController();
23
+ return document.addEventListener(
24
+ v.OPEN,
25
+ (s) => {
26
+ s.detail !== n && o(!1);
27
+ },
28
+ {
29
+ signal: e.signal
30
+ }
31
+ ), () => {
32
+ e.abort();
33
+ };
34
+ }, [n]), f(() => {
35
+ const e = new AbortController();
36
+ return document.addEventListener(
37
+ v.OPEN,
38
+ (s) => {
39
+ s.detail !== n && o(!1);
40
+ },
41
+ {
42
+ signal: e.signal
43
+ }
44
+ ), document.addEventListener(
45
+ v.RESET,
46
+ () => {
47
+ d(void 0), l(void 0), t == null || t();
48
+ },
49
+ {
50
+ signal: e.signal
51
+ }
52
+ ), () => {
53
+ e.abort();
54
+ };
55
+ }, [n, t]), f(() => {
56
+ const e = new AbortController(), s = (m) => {
57
+ var g;
58
+ (g = c.current) != null && g.contains(m.target) || u();
59
+ };
60
+ return document.addEventListener("mousedown", s, {
61
+ signal: e.signal
62
+ }), document.addEventListener(
63
+ "visibilitychange",
64
+ () => {
65
+ document.hidden && u();
66
+ },
67
+ {
68
+ signal: e.signal
69
+ }
70
+ ), () => {
71
+ e.abort();
72
+ };
73
+ }, [u, c]), {
74
+ id: n,
75
+ appliedDay: b,
76
+ isOpen: h,
77
+ selectedDay: a,
78
+ wrapperRef: c,
79
+ handleApply: O,
80
+ handleOpen: D,
81
+ handleSelect: w,
82
+ handleReset: C
83
+ };
84
+ };
85
+ export {
86
+ N as useDateFilterDropdown
87
+ };
@@ -0,0 +1,77 @@
1
+ import { jsxs as r, jsx as t } from "react/jsx-runtime";
2
+ import { Badge as u } from "../../../Badge/Badge.js";
3
+ import { Button as n } from "../../../Button/Button.js";
4
+ import { DatePicker as w } from "../../../Datepicker/DatePicker.js";
5
+ import { cn as l } from "../../../../utils/index.js";
6
+ import { filterButtonIconVariants as x, filterButtonVariants as N } from "../../Filter.variants.js";
7
+ import { useDateFilterDropdown as b } from "./DateFilterDropdown.hook.js";
8
+ import { C as g } from "../../../../chevron-down-UW8ts6wI.js";
9
+ const O = ({
10
+ label: i,
11
+ onApply: p
12
+ }) => {
13
+ const {
14
+ id: s,
15
+ appliedDay: o,
16
+ isOpen: a,
17
+ selectedDay: e,
18
+ wrapperRef: m,
19
+ handleApply: c,
20
+ handleOpen: d,
21
+ handleSelect: f,
22
+ handleReset: h
23
+ } = b({ onApply: p });
24
+ return /* @__PURE__ */ r("div", { ref: m, className: "relative", children: [
25
+ /* @__PURE__ */ r(
26
+ "button",
27
+ {
28
+ className: l(N(), {
29
+ "text-slate-700": a
30
+ }),
31
+ onClick: d,
32
+ children: [
33
+ i,
34
+ o && /* @__PURE__ */ t(u, { label: o }),
35
+ /* @__PURE__ */ t(
36
+ g,
37
+ {
38
+ className: l(x(), {
39
+ "rotate-180": a,
40
+ "text-blue-600": a
41
+ })
42
+ }
43
+ )
44
+ ]
45
+ }
46
+ ),
47
+ a && /* @__PURE__ */ r("div", { className: "absolute top-full mt-1 left-0 bg-white rounded-md shadow-md animate-in fade-in-0 z-10 border border-gray-200 flex flex-col gap-4 py-4 px-6", children: [
48
+ /* @__PURE__ */ t(
49
+ w,
50
+ {
51
+ className: "p-0",
52
+ arrowClassName: "-top-1 right-0",
53
+ monthsClassName: "shadow-none p-0 w-auto",
54
+ defaultSelected: e,
55
+ defaultMonth: e,
56
+ onSelect: f
57
+ },
58
+ (e == null ? void 0 : e.toISOString()) ?? s
59
+ ),
60
+ /* @__PURE__ */ r("div", { className: "flex justify-end items-center gap-4 py-2", children: [
61
+ /* @__PURE__ */ t(
62
+ n,
63
+ {
64
+ variant: "secondary",
65
+ appearance: "compact",
66
+ onClick: h,
67
+ children: "Reset"
68
+ }
69
+ ),
70
+ /* @__PURE__ */ t(n, { appearance: "compact", onClick: c, children: "Apply" })
71
+ ] })
72
+ ] })
73
+ ] });
74
+ };
75
+ export {
76
+ O as DateFilterDropdown
77
+ };
@@ -0,0 +1,18 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { Button as o } from "../../../Button/Button.js";
3
+ import { resetEvent as r } from "../../events/index.js";
4
+ const i = ({ disabled: t }) => /* @__PURE__ */ e(
5
+ o,
6
+ {
7
+ type: "button",
8
+ variant: "text",
9
+ appearance: "compact",
10
+ version: "alternate",
11
+ onClick: r,
12
+ disabled: t,
13
+ children: "Reset"
14
+ }
15
+ );
16
+ export {
17
+ i as ResetButton
18
+ };
@@ -0,0 +1,8 @@
1
+ import { BadgeMultiSelect as o } from "./BadgeDropdown/BadgeMultiSelect.js";
2
+ import { DateFilterDropdown as p } from "./DateFilterDropdown/DateFilterDropdown.js";
3
+ import { ResetButton as l } from "./ResetButton/ResetButton.js";
4
+ export {
5
+ o as BadgeMultiSelect,
6
+ p as DateFilterDropdown,
7
+ l as ResetButton
8
+ };
@@ -0,0 +1,12 @@
1
+ var e = /* @__PURE__ */ ((t) => (t.OPEN = "@konstrtuctio/Filter/event-OPEN", t.RESET = "@konstrtuctio/Filter/event-RESET", t))(e || {});
2
+ const n = (t) => document.dispatchEvent(
3
+ new CustomEvent("@konstrtuctio/Filter/event-OPEN", { detail: t })
4
+ ), o = () => document.dispatchEvent(new CustomEvent(
5
+ "@konstrtuctio/Filter/event-RESET"
6
+ /* RESET */
7
+ ));
8
+ export {
9
+ e as FilterEvent,
10
+ o as resetEvent,
11
+ n as sendOpenFilterEvent
12
+ };
@@ -1,9 +1,9 @@
1
1
  import { jsx as e } from "react/jsx-runtime";
2
2
  import { cn as c } from "../../utils/index.js";
3
3
  import { loadingVariants as i } from "./Loading.variants.js";
4
- import { c as t } from "../../createLucideIcon-vyksFS6P.js";
4
+ import { c as t } from "../../createLucideIcon-ByJ0JZvK.js";
5
5
  /**
6
- * @license lucide-react v0.511.0 - ISC
6
+ * @license lucide-react v0.513.0 - ISC
7
7
  *
8
8
  * This source code is licensed under the ISC license.
9
9
  * See the LICENSE file in the root directory of this source tree.
@@ -1,37 +1,31 @@
1
1
  import { jsxs as t, jsx as a } from "react/jsx-runtime";
2
- import { useId as C, useState as E, useRef as I, useCallback as L, useEffect as O } from "react";
3
- import { cn as m } from "../../../../utils/index.js";
2
+ import { useId as y, useState as E, useRef as O, useCallback as I, useEffect as L } from "react";
3
+ import { cn as d } from "../../../../utils/index.js";
4
4
  import { timePickerVariants as j } from "../../TimePicker.variants.js";
5
5
  import { WrapperList as P } from "../WrapperList/WrapperList.js";
6
- import { c as R } from "../../../../createLucideIcon-vyksFS6P.js";
6
+ import { C as R } from "../../../../chevron-down-UW8ts6wI.js";
7
7
  import { useTimePickerContext as T } from "../../contexts/time-picker.hook.js";
8
- /**
9
- * @license lucide-react v0.511.0 - ISC
10
- *
11
- * This source code is licensed under the ISC license.
12
- * See the LICENSE file in the root directory of this source tree.
13
- */
14
- const W = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], _ = R("chevron-down", W), $ = ({
8
+ const $ = ({
15
9
  name: p,
16
10
  label: i,
17
- required: u,
18
- scrollBehavior: f,
19
- className: h,
20
- listClassName: x,
11
+ required: f,
12
+ scrollBehavior: u,
13
+ className: x,
14
+ listClassName: h,
21
15
  listItemClassName: w,
22
16
  listItemButtonClassName: b
23
17
  }) => {
24
- const k = C(), [n, o] = E(!1), l = I(null), { format: v, formattedTime: c } = T(), r = p ?? `time-${k}`, N = L(() => o((e) => !e), []);
25
- return O(() => {
26
- const e = new AbortController(), g = (s) => {
27
- s.key === "Escape" && o(!1);
28
- }, y = (s) => {
29
- var d;
30
- (d = l.current) != null && d.contains(s.target) || o(!1);
18
+ const g = y(), [n, r] = E(!1), l = O(null), { format: k, formattedTime: c } = T(), s = p ?? `time-${g}`, v = I(() => r((e) => !e), []);
19
+ return L(() => {
20
+ const e = new AbortController(), C = (o) => {
21
+ o.key === "Escape" && r(!1);
22
+ }, N = (o) => {
23
+ var m;
24
+ (m = l.current) != null && m.contains(o.target) || r(!1);
31
25
  };
32
- return document.addEventListener("mousedown", y, {
26
+ return document.addEventListener("mousedown", N, {
33
27
  signal: e.signal
34
- }), document.addEventListener("keydown", g, {
28
+ }), document.addEventListener("keydown", C, {
35
29
  signal: e.signal
36
30
  }), () => {
37
31
  e.abort();
@@ -40,31 +34,31 @@ const W = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], _ = R("chevron-down"
40
34
  "div",
41
35
  {
42
36
  ref: l,
43
- className: m(
37
+ className: d(
44
38
  "w-max text-slate-800 text-sm flex flex-col gap-2",
45
- v === "12" ? "w-[208px]" : "w-[140px]"
39
+ k === "12" ? "w-[208px]" : "w-[140px]"
46
40
  ),
47
41
  children: [
48
- i ? /* @__PURE__ */ t("label", { htmlFor: r, className: "text-slate-500 font-medium", children: [
42
+ i ? /* @__PURE__ */ t("label", { htmlFor: s, className: "text-slate-500 font-medium", children: [
49
43
  i,
50
44
  " ",
51
- u && /* @__PURE__ */ a("span", { className: "text-red-600", children: "*" })
45
+ f && /* @__PURE__ */ a("span", { className: "text-red-600", children: "*" })
52
46
  ] }) : null,
53
47
  /* @__PURE__ */ t("div", { className: "relative", children: [
54
48
  /* @__PURE__ */ t(
55
49
  "button",
56
50
  {
57
- "aria-label": r,
51
+ "aria-label": s,
58
52
  "aria-haspopup": "listbox",
59
53
  "aria-expanded": "true",
60
54
  "aria-controls": "time-options",
61
- className: m(j({ className: h })),
55
+ className: d(j({ className: x })),
62
56
  "data-open": n,
63
- onClick: N,
57
+ onClick: v,
64
58
  children: [
65
59
  c,
66
60
  /* @__PURE__ */ a(
67
- _,
61
+ R,
68
62
  {
69
63
  className: "w-4 h-4 transition-all text-gray-400 data-[open=true]:rotate-180",
70
64
  "data-open": n
@@ -77,8 +71,8 @@ const W = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], _ = R("chevron-down"
77
71
  P,
78
72
  {
79
73
  isOpen: n,
80
- scrollBehavior: f,
81
- listClassName: x,
74
+ scrollBehavior: u,
75
+ listClassName: h,
82
76
  listItemClassName: w,
83
77
  listItemButtonClassName: b
84
78
  }
@@ -88,7 +82,7 @@ const W = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], _ = R("chevron-down"
88
82
  "input",
89
83
  {
90
84
  type: "hidden",
91
- name: r,
85
+ name: s,
92
86
  value: c,
93
87
  className: "hidden"
94
88
  }