@companix/uikit 0.0.50 → 0.0.52

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,45 +1,13 @@
1
- import { DefaultMonths as f, getMonthMaxDay as i } from "./bundle.es56.js";
2
- import { useMemo as s } from "react";
3
- import { range as l } from "@companix/utils-js";
4
- const p = { day: 31, month: 12, year: 2050 }, u = { day: 1, month: 1, year: 1900 }, I = ({ min: t = u, max: e = p, now: r }) => {
5
- const h = s(() => l(e.year, t.year).map((n) => ({
6
- title: n.toString(),
7
- value: n
8
- })), [e.year, t.year]), d = s(() => {
9
- const n = f.map((o, a) => ({
10
- title: o,
11
- value: a + 1
12
- }));
13
- if (t.month && r.year === t.year) {
14
- const o = n.findIndex(({ value: a }) => a === t.month);
15
- n.splice(0, o);
16
- }
17
- if (e.month && r.year === e.year) {
18
- const o = n.findIndex(({ value: a }) => a === e.month);
19
- n.splice(o + 1, n.length);
20
- }
21
- return n;
22
- }, [r.year, t.year, t.month, e.year, e.month]), c = s(() => {
23
- if (r.month === 0)
24
- return [];
25
- const n = i(r.month, r.year), o = Array.from({ length: n }, (a, y) => ({
26
- title: `${y + 1}`,
27
- value: y + 1
28
- }));
29
- if (t.day && r.month === t.month && r.year === t.year) {
30
- const a = o.findIndex(({ value: y }) => y === t.day);
31
- o.splice(0, a);
32
- }
33
- if (e.day && r.month === e.month && r.year === e.year) {
34
- const a = o.findIndex(({ value: y }) => y === e.day);
35
- o.splice(a + 1, o.length);
36
- }
37
- return o;
38
- }, [r.month, r.year, t, e]);
39
- return { years: h, months: d, days: c };
1
+ import { jsxs as r, Fragment as a, jsx as e } from "react/jsx-runtime";
2
+ import { faXmark as i, faChevronDown as m } from "@companix/icons-solid";
3
+ import { Icon as o } from "./bundle.es33.js";
4
+ const f = (n) => {
5
+ const { clearButton: c, clearButtonIcon: t, value: s, onClear: l } = n;
6
+ return /* @__PURE__ */ r(a, { children: [
7
+ c && s && /* @__PURE__ */ e("button", { className: "select-close-button", onClick: l, children: t ?? /* @__PURE__ */ e(o, { className: "select-close-icon", icon: i, size: "xxxs" }) }),
8
+ /* @__PURE__ */ e(o, { className: "expand-icon select-expand", icon: m, size: "xxxs" })
9
+ ] });
40
10
  };
41
11
  export {
42
- p as defaultMax,
43
- u as defaultMin,
44
- I as useCalendarOptions
12
+ f as SelectRightElements
45
13
  };
@@ -1,17 +1,45 @@
1
- const r = (e, o) => {
2
- let t;
3
- try {
4
- t = localStorage.getItem(e) || void 0;
5
- } catch {
6
- }
7
- return t ?? o;
8
- }, m = (e) => (e || (e = window.matchMedia("(prefers-color-scheme: dark)")), e.matches ? "dark" : "light"), s = (e) => {
9
- const [o, t] = ["theme-light", "theme-dark"];
10
- let c = e;
11
- e === "system" && (c = m()), document.documentElement.classList.remove(o, t), document.documentElement.classList.add(c === "dark" ? t : o), document.documentElement.style.colorScheme = c;
1
+ import { DefaultMonths as f, getMonthMaxDay as i } from "./bundle.es57.js";
2
+ import { useMemo as s } from "react";
3
+ import { range as l } from "@companix/utils-js";
4
+ const p = { day: 31, month: 12, year: 2050 }, u = { day: 1, month: 1, year: 1900 }, I = ({ min: t = u, max: e = p, now: r }) => {
5
+ const h = s(() => l(e.year, t.year).map((n) => ({
6
+ title: n.toString(),
7
+ value: n
8
+ })), [e.year, t.year]), d = s(() => {
9
+ const n = f.map((o, a) => ({
10
+ title: o,
11
+ value: a + 1
12
+ }));
13
+ if (t.month && r.year === t.year) {
14
+ const o = n.findIndex(({ value: a }) => a === t.month);
15
+ n.splice(0, o);
16
+ }
17
+ if (e.month && r.year === e.year) {
18
+ const o = n.findIndex(({ value: a }) => a === e.month);
19
+ n.splice(o + 1, n.length);
20
+ }
21
+ return n;
22
+ }, [r.year, t.year, t.month, e.year, e.month]), c = s(() => {
23
+ if (r.month === 0)
24
+ return [];
25
+ const n = i(r.month, r.year), o = Array.from({ length: n }, (a, y) => ({
26
+ title: `${y + 1}`,
27
+ value: y + 1
28
+ }));
29
+ if (t.day && r.month === t.month && r.year === t.year) {
30
+ const a = o.findIndex(({ value: y }) => y === t.day);
31
+ o.splice(0, a);
32
+ }
33
+ if (e.day && r.month === e.month && r.year === e.year) {
34
+ const a = o.findIndex(({ value: y }) => y === e.day);
35
+ o.splice(a + 1, o.length);
36
+ }
37
+ return o;
38
+ }, [r.month, r.year, t, e]);
39
+ return { years: h, months: d, days: c };
12
40
  };
13
41
  export {
14
- r as getColorScheme,
15
- m as getSystemColorScheme,
16
- s as updateDOM
42
+ p as defaultMax,
43
+ u as defaultMin,
44
+ I as useCalendarOptions
17
45
  };
@@ -1,34 +1,17 @@
1
- import { jsx as s, Fragment as p } from "react/jsx-runtime";
2
- import { forwardRef as f, useState as u, useImperativeHandle as c } from "react";
3
- import { AlertDialog as x } from "./bundle.es22.js";
4
- const g = f((a, l) => {
5
- const [i, n] = u([]);
6
- c(
7
- l,
8
- () => ({
9
- showAlert: (e) => {
10
- n((t) => [...t, e]);
11
- }
12
- }),
13
- []
14
- );
15
- const d = (e) => {
16
- n((t) => {
17
- const r = [...t], o = r.findIndex((m) => m.id === e);
18
- return o !== -1 && r.splice(o, 1), r;
19
- });
20
- };
21
- return /* @__PURE__ */ s(p, { children: i.map(({ id: e, ...t }) => /* @__PURE__ */ s(
22
- x,
23
- {
24
- defaultOpen: !0,
25
- onUnMounted: () => d(e),
26
- ...a,
27
- ...t
28
- },
29
- `alert-${e}`
30
- )) });
31
- });
1
+ const r = (e, o) => {
2
+ let t;
3
+ try {
4
+ t = localStorage.getItem(e) || void 0;
5
+ } catch {
6
+ }
7
+ return t ?? o;
8
+ }, m = (e) => (e || (e = window.matchMedia("(prefers-color-scheme: dark)")), e.matches ? "dark" : "light"), s = (e) => {
9
+ const [o, t] = ["theme-light", "theme-dark"];
10
+ let c = e;
11
+ e === "system" && (c = m()), document.documentElement.classList.remove(o, t), document.documentElement.classList.add(c === "dark" ? t : o), document.documentElement.style.colorScheme = c;
12
+ };
32
13
  export {
33
- g as Viewport
14
+ r as getColorScheme,
15
+ m as getSystemColorScheme,
16
+ s as updateDOM
34
17
  };
@@ -1,72 +1,34 @@
1
- import { jsxs as y, jsx as I } from "react/jsx-runtime";
2
- import { forwardRef as $, useState as b, useMemo as C, useImperativeHandle as w, useCallback as P, createElement as j } from "react";
3
- import * as c from "@radix-ui/react-toast";
4
- import { customCSS as k } from "@companix/utils-browser";
5
- import { Toast as E } from "./bundle.es40.js";
6
- var u = /* @__PURE__ */ ((r) => (r["top-center"] = "up", r["top-left"] = "left", r["top-right"] = "right", r["bottom-center"] = "down", r["bottom-left"] = "left", r["bottom-right"] = "right", r))(u || {});
7
- const M = $((r, h) => {
8
- const { side: l = "top", align: f = "center", gap: d = 14, duration: g, swipeThreshold: x, closeIcon: T } = r, [i, p] = b([]), a = C(() => ({}), []);
9
- w(
10
- h,
1
+ import { jsx as s, Fragment as p } from "react/jsx-runtime";
2
+ import { forwardRef as f, useState as u, useImperativeHandle as c } from "react";
3
+ import { AlertDialog as x } from "./bundle.es22.js";
4
+ const g = f((a, l) => {
5
+ const [i, n] = u([]);
6
+ c(
7
+ l,
11
8
  () => ({
12
- showToast: (t) => {
13
- p((o) => {
14
- const e = [...o], n = o.findIndex((s) => s.id === t.id);
15
- return n === -1 ? e.push(t) : e[n] = t, e;
16
- });
9
+ showAlert: (e) => {
10
+ n((t) => [...t, e]);
17
11
  }
18
12
  }),
19
13
  []
20
14
  );
21
- const m = P((t) => {
22
- t.forEach(({ id: o }, e) => {
23
- let n = 0;
24
- for (let s = e + 1; s < t.length; s++)
25
- a[t[s].id] && (n += a[t[s].id].clientHeight + d);
26
- a[o] && a[o].style.setProperty("--offset", `${n}px`);
27
- });
28
- }, []), v = (t) => {
29
- p((o) => {
30
- const e = [...o], n = e.findIndex((s) => s.id === t);
31
- return n !== -1 && e.splice(n, 1), e;
15
+ const d = (e) => {
16
+ n((t) => {
17
+ const r = [...t], o = r.findIndex((m) => m.id === e);
18
+ return o !== -1 && r.splice(o, 1), r;
32
19
  });
33
20
  };
34
- return /* @__PURE__ */ y(
35
- c.Provider,
21
+ return /* @__PURE__ */ s(p, { children: i.map(({ id: e, ...t }) => /* @__PURE__ */ s(
22
+ x,
36
23
  {
37
- swipeThreshold: x,
38
- swipeDirection: u[`${l}-${f}`],
39
- children: [
40
- i.map(({ id: t, ...o }) => /* @__PURE__ */ j(
41
- E,
42
- {
43
- ...o,
44
- id: t,
45
- key: `toaster-${t}`,
46
- duration: o.duration ?? g,
47
- closeIcon: T,
48
- onInitialized: (e) => {
49
- a[t] = e, m(i);
50
- },
51
- onClosing: () => {
52
- delete a[t], m(i);
53
- },
54
- onClosed: () => v(t)
55
- }
56
- )),
57
- /* @__PURE__ */ I(
58
- c.Viewport,
59
- {
60
- "data-side": l,
61
- "data-align": f,
62
- className: "toaster-viewport",
63
- style: k({ "--toasters-gap": `${d}px` })
64
- }
65
- )
66
- ]
67
- }
68
- );
24
+ defaultOpen: !0,
25
+ onUnMounted: () => d(e),
26
+ ...a,
27
+ ...t
28
+ },
29
+ `alert-${e}`
30
+ )) });
69
31
  });
70
32
  export {
71
- M as Viewport
33
+ g as Viewport
72
34
  };
@@ -1,16 +1,72 @@
1
- import { useRef as l, useCallback as p } from "react";
2
- import { useEffectWithLayout as d } from "./bundle.es65.js";
3
- const g = (r, f) => {
4
- const c = l(null), i = l(null), o = { Right: c, Left: i }, u = p((t) => {
5
- if (r.current) {
6
- const n = r.current.style, e = o[t];
7
- e.current && e.current.clientWidth ? n[`padding${t}`] !== `${e.current.clientWidth}px` && (n[`padding${t}`] = `${e.current.clientWidth}px`) : n[`padding${t}`] && (n[`padding${t}`] = "");
1
+ import { jsxs as y, jsx as I } from "react/jsx-runtime";
2
+ import { forwardRef as $, useState as b, useMemo as C, useImperativeHandle as w, useCallback as P, createElement as j } from "react";
3
+ import * as c from "@radix-ui/react-toast";
4
+ import { customCSS as k } from "@companix/utils-browser";
5
+ import { Toast as E } from "./bundle.es40.js";
6
+ var u = /* @__PURE__ */ ((r) => (r["top-center"] = "up", r["top-left"] = "left", r["top-right"] = "right", r["bottom-center"] = "down", r["bottom-left"] = "left", r["bottom-right"] = "right", r))(u || {});
7
+ const M = $((r, h) => {
8
+ const { side: l = "top", align: f = "center", gap: d = 14, duration: g, swipeThreshold: x, closeIcon: T } = r, [i, p] = b([]), a = C(() => ({}), []);
9
+ w(
10
+ h,
11
+ () => ({
12
+ showToast: (t) => {
13
+ p((o) => {
14
+ const e = [...o], n = o.findIndex((s) => s.id === t.id);
15
+ return n === -1 ? e.push(t) : e[n] = t, e;
16
+ });
17
+ }
18
+ }),
19
+ []
20
+ );
21
+ const m = P((t) => {
22
+ t.forEach(({ id: o }, e) => {
23
+ let n = 0;
24
+ for (let s = e + 1; s < t.length; s++)
25
+ a[t[s].id] && (n += a[t[s].id].clientHeight + d);
26
+ a[o] && a[o].style.setProperty("--offset", `${n}px`);
27
+ });
28
+ }, []), v = (t) => {
29
+ p((o) => {
30
+ const e = [...o], n = e.findIndex((s) => s.id === t);
31
+ return n !== -1 && e.splice(n, 1), e;
32
+ });
33
+ };
34
+ return /* @__PURE__ */ y(
35
+ c.Provider,
36
+ {
37
+ swipeThreshold: x,
38
+ swipeDirection: u[`${l}-${f}`],
39
+ children: [
40
+ i.map(({ id: t, ...o }) => /* @__PURE__ */ j(
41
+ E,
42
+ {
43
+ ...o,
44
+ id: t,
45
+ key: `toaster-${t}`,
46
+ duration: o.duration ?? g,
47
+ closeIcon: T,
48
+ onInitialized: (e) => {
49
+ a[t] = e, m(i);
50
+ },
51
+ onClosing: () => {
52
+ delete a[t], m(i);
53
+ },
54
+ onClosed: () => v(t)
55
+ }
56
+ )),
57
+ /* @__PURE__ */ I(
58
+ c.Viewport,
59
+ {
60
+ "data-side": l,
61
+ "data-align": f,
62
+ className: "toaster-viewport",
63
+ style: k({ "--toasters-gap": `${d}px` })
64
+ }
65
+ )
66
+ ]
8
67
  }
9
- }, []);
10
- return d(() => {
11
- u("Left"), u("Right");
12
- }, f), { rightRef: c, leftRef: i };
13
- };
68
+ );
69
+ });
14
70
  export {
15
- g as useInputPadding
71
+ M as Viewport
16
72
  };
@@ -1,77 +1,16 @@
1
- import { jsxs as d, jsx as o } from "react/jsx-runtime";
2
- import { useCallback as u, useMemo as h } from "react";
3
- import { Select as p } from "./bundle.es12.js";
4
- import { getMonths as k, getYears as z, DEFAULT_MAX_YEAR as f, DEFAULT_MIN_YEAR as g } from "./bundle.es56.js";
5
- import { Icon as C } from "./bundle.es33.js";
6
- import { faChevronLeft as E, faChevronRight as T } from "@companix/icons-solid";
7
- import { setMonth as _, setYear as F } from "./bundle.es55.js";
8
- const y = ({
9
- viewDate: n,
10
- onChange: c,
11
- isMonthDisabled: a,
12
- isYearDisabled: m,
13
- onNextMonth: N,
14
- onPrevMonth: v
15
- }) => {
16
- const e = n.getFullYear(), r = n.getMonth(), s = "ru", M = u(
17
- (t) => {
18
- c(_(n, t));
19
- },
20
- [c, n]
21
- ), x = u(
22
- (t) => {
23
- c(F(n, t));
24
- },
25
- [c, n]
26
- ), A = h(() => k(s).map((t) => ({
27
- ...t,
28
- className: "capitalize",
29
- disabled: a && a(t.value)
30
- })), [s, a]), Y = h(() => z(e, 100).map((t) => ({
31
- ...t,
32
- disabled: m && m(t.value)
33
- })), [e, m]);
34
- let l = r === 11 && e === f;
35
- a && !l && (l = a(
36
- r === 11 ? 0 : r + 1,
37
- r === 11 ? Math.min(e + 1, f) : e
38
- ));
39
- let i = r === 0 && e === g;
40
- return a && !i && (i = a(
41
- r === 0 ? 11 : r - 1,
42
- r === 0 ? Math.max(e - 1, g) : e
43
- )), /* @__PURE__ */ d("div", { className: "calendar-header", children: [
44
- !i && /* @__PURE__ */ o("button", { className: "calendar-navigation", "data-side": "left", onClick: v, children: /* @__PURE__ */ o(C, { icon: E }) }),
45
- /* @__PURE__ */ d("div", { className: "calendar-pickers", children: [
46
- /* @__PURE__ */ o(
47
- p,
48
- {
49
- fill: !0,
50
- options: Y,
51
- size: "sm",
52
- value: e,
53
- minimalOptions: !0,
54
- matchTarget: "min-width",
55
- onChange: (t) => x(t)
56
- }
57
- ),
58
- /* @__PURE__ */ o(
59
- p,
60
- {
61
- fill: !0,
62
- options: A,
63
- size: "sm",
64
- className: "capitalize",
65
- value: r,
66
- minimalOptions: !0,
67
- matchTarget: "min-width",
68
- onChange: (t) => M(t)
69
- }
70
- )
71
- ] }),
72
- !l && /* @__PURE__ */ o("button", { className: "calendar-navigation", "data-side": "right", onClick: N, children: /* @__PURE__ */ o(C, { icon: T }) })
73
- ] });
1
+ import { useRef as l, useCallback as p } from "react";
2
+ import { useEffectWithLayout as d } from "./bundle.es66.js";
3
+ const g = (r, f) => {
4
+ const c = l(null), i = l(null), o = { Right: c, Left: i }, u = p((t) => {
5
+ if (r.current) {
6
+ const n = r.current.style, e = o[t];
7
+ e.current && e.current.clientWidth ? n[`padding${t}`] !== `${e.current.clientWidth}px` && (n[`padding${t}`] = `${e.current.clientWidth}px`) : n[`padding${t}`] && (n[`padding${t}`] = "");
8
+ }
9
+ }, []);
10
+ return d(() => {
11
+ u("Left"), u("Right");
12
+ }, f), { rightRef: c, leftRef: i };
74
13
  };
75
14
  export {
76
- y as CalendarHeader
15
+ g as useInputPadding
77
16
  };
@@ -1,51 +1,77 @@
1
- import { subMonths as L, addMonths as N, useDayDisableCheker as R } from "./bundle.es55.js";
2
- import { DEFAULT_MIN_YEAR as w, DEFAULT_MAX_YEAR as A } from "./bundle.es56.js";
3
- import { useState as U, useCallback as M } from "react";
4
- const X = ({
5
- value: p,
6
- disablePast: r,
7
- disableFuture: c,
8
- shouldDisableDate: E,
9
- minDateTime: l,
10
- maxDateTime: s
1
+ import { jsxs as d, jsx as o } from "react/jsx-runtime";
2
+ import { useCallback as u, useMemo as h } from "react";
3
+ import { Select as p } from "./bundle.es12.js";
4
+ import { getMonths as k, getYears as z, DEFAULT_MAX_YEAR as f, DEFAULT_MIN_YEAR as g } from "./bundle.es57.js";
5
+ import { Icon as C } from "./bundle.es33.js";
6
+ import { faChevronLeft as E, faChevronRight as T } from "@companix/icons-solid";
7
+ import { setMonth as _, setYear as F } from "./bundle.es56.js";
8
+ const y = ({
9
+ viewDate: n,
10
+ onChange: c,
11
+ isMonthDisabled: a,
12
+ isYearDisabled: m,
13
+ onNextMonth: N,
14
+ onPrevMonth: v
11
15
  }) => {
12
- const [e, u] = U(p || /* @__PURE__ */ new Date()), _ = M(() => {
13
- u(L(e));
14
- }, [e]), C = M(() => {
15
- u(N(e, 1));
16
- }, [e]), D = R({
17
- disableFuture: c,
18
- disablePast: r,
19
- shouldDisableDate: E,
20
- minDateTime: l,
21
- maxDateTime: s
22
- }), k = M(
23
- (o, t) => {
24
- const n = /* @__PURE__ */ new Date();
25
- t = t || e.getFullYear();
26
- const h = l ? l.getMonth() : 0, Y = s ? s.getMonth() : 11, F = l?.getFullYear() || w, f = s?.getFullYear() || A;
27
- let g = t >= F && t <= f ? t === F && h > o || t === f && o > Y : !0;
28
- return c && (g = g || (t === n.getFullYear() ? o > n.getMonth() : t > n.getFullYear())), r && (g = g || (t === n.getFullYear() ? o < n.getMonth() : t < n.getFullYear())), g;
16
+ const e = n.getFullYear(), r = n.getMonth(), s = "ru", M = u(
17
+ (t) => {
18
+ c(_(n, t));
29
19
  },
30
- [c, r, e, l, s]
31
- ), v = M(
32
- (o) => {
33
- const t = /* @__PURE__ */ new Date(), n = l?.getFullYear() || w, h = s?.getFullYear() || A;
34
- let Y = n > o || o > h;
35
- return c && (Y = Y || o > t.getFullYear()), r && (Y = Y || o < t.getFullYear()), Y;
20
+ [c, n]
21
+ ), x = u(
22
+ (t) => {
23
+ c(F(n, t));
36
24
  },
37
- [c, r, l, s]
38
- );
39
- return {
40
- viewDate: e,
41
- setViewDate: u,
42
- setPrevMonth: _,
43
- setNextMonth: C,
44
- isDayDisabled: D,
45
- isMonthDisabled: k,
46
- isYearDisabled: v
47
- };
25
+ [c, n]
26
+ ), A = h(() => k(s).map((t) => ({
27
+ ...t,
28
+ className: "capitalize",
29
+ disabled: a && a(t.value)
30
+ })), [s, a]), Y = h(() => z(e, 100).map((t) => ({
31
+ ...t,
32
+ disabled: m && m(t.value)
33
+ })), [e, m]);
34
+ let l = r === 11 && e === f;
35
+ a && !l && (l = a(
36
+ r === 11 ? 0 : r + 1,
37
+ r === 11 ? Math.min(e + 1, f) : e
38
+ ));
39
+ let i = r === 0 && e === g;
40
+ return a && !i && (i = a(
41
+ r === 0 ? 11 : r - 1,
42
+ r === 0 ? Math.max(e - 1, g) : e
43
+ )), /* @__PURE__ */ d("div", { className: "calendar-header", children: [
44
+ !i && /* @__PURE__ */ o("button", { className: "calendar-navigation", "data-side": "left", onClick: v, children: /* @__PURE__ */ o(C, { icon: E }) }),
45
+ /* @__PURE__ */ d("div", { className: "calendar-pickers", children: [
46
+ /* @__PURE__ */ o(
47
+ p,
48
+ {
49
+ fill: !0,
50
+ options: Y,
51
+ size: "sm",
52
+ value: e,
53
+ minimalOptions: !0,
54
+ matchTarget: "min-width",
55
+ onChange: (t) => x(t)
56
+ }
57
+ ),
58
+ /* @__PURE__ */ o(
59
+ p,
60
+ {
61
+ fill: !0,
62
+ options: A,
63
+ size: "sm",
64
+ className: "capitalize",
65
+ value: r,
66
+ minimalOptions: !0,
67
+ matchTarget: "min-width",
68
+ onChange: (t) => M(t)
69
+ }
70
+ )
71
+ ] }),
72
+ !l && /* @__PURE__ */ o("button", { className: "calendar-navigation", "data-side": "right", onClick: N, children: /* @__PURE__ */ o(C, { icon: T }) })
73
+ ] });
48
74
  };
49
75
  export {
50
- X as useCalendar
76
+ y as CalendarHeader
51
77
  };
@@ -1,16 +1,51 @@
1
- import { useRef as f, useLayoutEffect as u, useEffect as s } from "react";
2
- const o = (t, r) => {
3
- const e = f(!1);
4
- u(() => {
5
- e.current = !0, t();
6
- }, []), s(() => {
7
- if (e.current) {
8
- e.current = !1;
9
- return;
10
- }
11
- t();
12
- }, r);
1
+ import { subMonths as L, addMonths as N, useDayDisableCheker as R } from "./bundle.es56.js";
2
+ import { DEFAULT_MIN_YEAR as w, DEFAULT_MAX_YEAR as A } from "./bundle.es57.js";
3
+ import { useState as U, useCallback as M } from "react";
4
+ const X = ({
5
+ value: p,
6
+ disablePast: r,
7
+ disableFuture: c,
8
+ shouldDisableDate: E,
9
+ minDateTime: l,
10
+ maxDateTime: s
11
+ }) => {
12
+ const [e, u] = U(p || /* @__PURE__ */ new Date()), _ = M(() => {
13
+ u(L(e));
14
+ }, [e]), C = M(() => {
15
+ u(N(e, 1));
16
+ }, [e]), D = R({
17
+ disableFuture: c,
18
+ disablePast: r,
19
+ shouldDisableDate: E,
20
+ minDateTime: l,
21
+ maxDateTime: s
22
+ }), k = M(
23
+ (o, t) => {
24
+ const n = /* @__PURE__ */ new Date();
25
+ t = t || e.getFullYear();
26
+ const h = l ? l.getMonth() : 0, Y = s ? s.getMonth() : 11, F = l?.getFullYear() || w, f = s?.getFullYear() || A;
27
+ let g = t >= F && t <= f ? t === F && h > o || t === f && o > Y : !0;
28
+ return c && (g = g || (t === n.getFullYear() ? o > n.getMonth() : t > n.getFullYear())), r && (g = g || (t === n.getFullYear() ? o < n.getMonth() : t < n.getFullYear())), g;
29
+ },
30
+ [c, r, e, l, s]
31
+ ), v = M(
32
+ (o) => {
33
+ const t = /* @__PURE__ */ new Date(), n = l?.getFullYear() || w, h = s?.getFullYear() || A;
34
+ let Y = n > o || o > h;
35
+ return c && (Y = Y || o > t.getFullYear()), r && (Y = Y || o < t.getFullYear()), Y;
36
+ },
37
+ [c, r, l, s]
38
+ );
39
+ return {
40
+ viewDate: e,
41
+ setViewDate: u,
42
+ setPrevMonth: _,
43
+ setNextMonth: C,
44
+ isDayDisabled: D,
45
+ isMonthDisabled: k,
46
+ isYearDisabled: v
47
+ };
13
48
  };
14
49
  export {
15
- o as useEffectWithLayout
50
+ X as useCalendar
16
51
  };
@@ -0,0 +1,16 @@
1
+ import { useRef as f, useLayoutEffect as u, useEffect as s } from "react";
2
+ const o = (t, r) => {
3
+ const e = f(!1);
4
+ u(() => {
5
+ e.current = !0, t();
6
+ }, []), s(() => {
7
+ if (e.current) {
8
+ e.current = !1;
9
+ return;
10
+ }
11
+ t();
12
+ }, r);
13
+ };
14
+ export {
15
+ o as useEffectWithLayout
16
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companix/uikit",
3
- "version": "0.0.50",
3
+ "version": "0.0.52",
4
4
  "main": "./dist/bundle.es.js",
5
5
  "module": "./dist/bundle.es.js",
6
6
  "types": "./dist/index.d.ts",