@companix/uikit 0.0.14 → 0.0.16

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,12 +1,20 @@
1
1
  import { Option } from '../types';
2
2
  import { SelectFormProps } from './SelectInput';
3
- interface SelectProps<T> extends Omit<SelectFormProps, 'value' | 'onChange'> {
4
- options: Option<T>[];
3
+ interface Cleanable<T> {
4
+ clearButton: true;
5
5
  onChange: (event: T | null) => void;
6
+ }
7
+ interface UnCleanable<T> {
8
+ clearButton?: false;
9
+ onChange: (event: T) => void;
10
+ }
11
+ type DependedValueType<T> = Cleanable<T> | UnCleanable<T>;
12
+ type SelectProps<T> = Omit<SelectFormProps, 'value' | 'onChange' | 'closeButton'> & DependedValueType<T> & {
6
13
  value: T | null;
14
+ options: Option<T>[];
7
15
  children?: React.ReactNode;
8
16
  minimalOptions?: boolean;
9
17
  matchTarget?: 'width' | 'min-width';
10
- }
18
+ };
11
19
  export declare const Select: <T>(props: SelectProps<T>) => import("react/jsx-runtime").JSX.Element;
12
20
  export {};
@@ -3,6 +3,7 @@
3
3
  .select-tags {
4
4
  display: flex;
5
5
  flex-direction: column;
6
+ width: 100%;
6
7
 
7
8
  .form-input {
8
9
  padding-left: var(--form_space, 0);
@@ -12,5 +12,6 @@ export interface SelectTagsProps<T> {
12
12
  size?: 'sm' | 'md' | 'lg';
13
13
  fill?: boolean;
14
14
  inputRef?: React.Ref<HTMLInputElement>;
15
+ required?: boolean;
15
16
  }
16
17
  export declare const SelectTags: <T extends string | number>(props: SelectTagsProps<T>) => import("react/jsx-runtime").JSX.Element;
@@ -1,94 +1,96 @@
1
1
  import { jsx as o, jsxs as c } from "react/jsx-runtime";
2
- import { useFroozeClosing as F } from "./bundle.es31.js";
3
- import { Popover as L } from "./bundle.es6.js";
4
- import { OptionItem as M } from "./bundle.es10.js";
5
- import { OptionsList as j } from "./bundle.es12.js";
6
- import { useState as V, useRef as d, useMemo as h } from "react";
2
+ import { useFroozeClosing as M } from "./bundle.es31.js";
3
+ import { Popover as j } from "./bundle.es6.js";
4
+ import { OptionItem as q } from "./bundle.es10.js";
5
+ import { OptionsList as V } from "./bundle.es12.js";
6
+ import { useState as B, useRef as d, useMemo as h } from "react";
7
7
  import { Icon as g } from "./bundle.es35.js";
8
- import { faClose as B, faChevronDown as H } from "@fortawesome/free-solid-svg-icons";
9
- import { attr as Q, getActiveElementByAnotherElement as q, contains as G } from "@companix/utils-browser";
10
- import { mergeRefs as J } from "react-merge-refs";
11
- const ne = (v) => {
8
+ import { faClose as H, faChevronDown as Q } from "@fortawesome/free-solid-svg-icons";
9
+ import { attr as v, getActiveElementByAnotherElement as G, contains as J } from "@companix/utils-browser";
10
+ import { mergeRefs as K } from "react-merge-refs";
11
+ const re = (x) => {
12
12
  const {
13
13
  options: r,
14
- closeAfterSelect: x,
15
- placeholder: C,
14
+ closeAfterSelect: C,
15
+ placeholder: N,
16
16
  onChange: l,
17
- emptyText: N = "Ничего не найдено",
17
+ emptyText: R = "Ничего не найдено",
18
18
  readOnly: m,
19
- size: R = "md",
19
+ size: z = "md",
20
20
  value: n,
21
- inputRef: z,
22
- disabled: f
23
- } = v, [i, A] = V(""), a = d(null), y = d(null), { popoverRef: u, froozePopoverPosition: D, handleAnimationEnd: b } = F(), w = h(() => {
21
+ inputRef: A,
22
+ disabled: f,
23
+ required: y
24
+ } = x, [i, D] = B(""), a = d(null), b = d(null), { popoverRef: u, froozePopoverPosition: w, handleAnimationEnd: E } = M(), O = h(() => {
24
25
  const e = {};
25
26
  return r.forEach((t) => {
26
27
  e[t.value] = t;
27
28
  }), e;
28
- }, [r]), E = (e) => n.includes(e) ? [...n] : [...n, e], O = (e) => n.filter((t) => e !== t), P = (e, t) => {
29
- x ? (D(), l(e), t()) : l(e);
29
+ }, [r]), P = (e) => n.includes(e) ? [...n] : [...n, e], T = (e) => n.filter((t) => e !== t), k = (e, t) => {
30
+ C ? (w(), l(e), t()) : l(e);
30
31
  }, p = h(() => i.trim() ? r.filter(({ title: e }) => {
31
32
  const t = e.toLowerCase(), s = i.trim().toLowerCase();
32
33
  return t.indexOf(s) >= 0;
33
- }) : r, [i, r]), T = (e) => {
34
+ }) : r, [i, r]), I = (e) => {
34
35
  if (f) return;
35
36
  u.current && u.current.getAttribute("data-state") === "open" && e.preventDefault();
36
- const t = q(e.currentTarget);
37
- e.defaultPrevented || G(e.currentTarget, t) || a.current && a.current.focus();
38
- }, k = (e) => {
37
+ const t = G(e.currentTarget);
38
+ e.defaultPrevented || J(e.currentTarget, t) || a.current && a.current.focus();
39
+ }, S = (e) => {
39
40
  e.target !== a.current && e.preventDefault();
40
- }, I = (e, t) => {
41
- e.stopPropagation(), l(O(t));
41
+ }, $ = (e, t) => {
42
+ e.stopPropagation(), l(T(t));
42
43
  };
43
44
  return /* @__PURE__ */ o(
44
- L,
45
+ j,
45
46
  {
46
47
  minimal: !0,
47
48
  ref: u,
48
49
  sideOffset: 0,
49
50
  matchTarget: "width",
50
- onAnimationEnd: b,
51
+ onAnimationEnd: E,
51
52
  onOpenAutoFocus: (e) => e.preventDefault(),
52
53
  onCloseAutoFocus: (e) => e.preventDefault(),
53
- content: ({ close: e }) => /* @__PURE__ */ c(j, { maxHeight: 300, children: [
54
- p.length === 0 && /* @__PURE__ */ o("div", { className: "select-tags-empty", children: N }),
55
- p.map(({ value: t, title: s, icon: S }, $) => /* @__PURE__ */ o(
56
- M,
54
+ content: ({ close: e }) => /* @__PURE__ */ c(V, { maxHeight: 300, children: [
55
+ p.length === 0 && /* @__PURE__ */ o("div", { className: "select-tags-empty", children: R }),
56
+ p.map(({ value: t, title: s, icon: F }, L) => /* @__PURE__ */ o(
57
+ q,
57
58
  {
58
59
  active: n.includes(t),
59
- onClick: () => P(E(t), e),
60
+ onClick: () => k(P(t), e),
60
61
  title: s,
61
- icon: S
62
+ icon: F
62
63
  },
63
- `option-item-${t}-${$}`
64
+ `option-item-${t}-${L}`
64
65
  ))
65
66
  ] }),
66
67
  children: /* @__PURE__ */ o(
67
68
  "div",
68
69
  {
69
70
  className: "form",
70
- onClick: T,
71
- onMouseDown: k,
72
- "data-size": R,
71
+ onClick: I,
72
+ onMouseDown: S,
73
+ "data-size": z,
74
+ "data-required": v(y),
73
75
  children: /* @__PURE__ */ c("div", { className: "select-tags-container", children: [
74
76
  /* @__PURE__ */ c("div", { className: "select-tags", children: [
75
77
  n.length > 0 && /* @__PURE__ */ o(
76
78
  "div",
77
79
  {
78
80
  className: "tag-container",
79
- ref: y,
81
+ ref: b,
80
82
  role: "listbox",
81
- "data-readonly": Q(m),
83
+ "data-readonly": v(m),
82
84
  children: n.map((e, t) => /* @__PURE__ */ c("div", { className: "tag", children: [
83
- /* @__PURE__ */ o("span", { className: "tag-name", children: w[e].title }),
84
- /* @__PURE__ */ o("button", { className: "tag-close-button", onClick: (s) => I(s, e), children: /* @__PURE__ */ o(g, { className: "tag-close-icon", icon: B, size: "xxxs" }) })
85
+ /* @__PURE__ */ o("span", { className: "tag-name", children: O[e].title }),
86
+ /* @__PURE__ */ o("button", { className: "tag-close-button", onClick: (s) => $(s, e), children: /* @__PURE__ */ o(g, { className: "tag-close-icon", icon: H, size: "xxxs" }) })
85
87
  ] }, `tag-option-${e}-${t}`))
86
88
  }
87
89
  ),
88
90
  (!m || n.length === 0) && /* @__PURE__ */ o(
89
91
  "input",
90
92
  {
91
- ref: J([z, a]),
93
+ ref: K([A, a]),
92
94
  type: "text",
93
95
  autoCapitalize: "none",
94
96
  autoComplete: "off",
@@ -98,12 +100,12 @@ const ne = (v) => {
98
100
  value: i,
99
101
  disabled: f,
100
102
  readOnly: m,
101
- placeholder: C,
102
- onChange: ({ target: e }) => A(e.value)
103
+ placeholder: N,
104
+ onChange: ({ target: e }) => D(e.value)
103
105
  }
104
106
  )
105
107
  ] }),
106
- /* @__PURE__ */ o(g, { className: "expand-icon", icon: H, size: "xxxs" })
108
+ /* @__PURE__ */ o(g, { className: "expand-icon", icon: Q, size: "xxxs" })
107
109
  ] })
108
110
  }
109
111
  )
@@ -111,5 +113,5 @@ const ne = (v) => {
111
113
  );
112
114
  };
113
115
  export {
114
- ne as SelectTags
116
+ re as SelectTags
115
117
  };
@@ -1,7 +1,7 @@
1
1
  import { jsxs as D, jsx as t } from "react/jsx-runtime";
2
- import { dateToFormat as $, weeks as g, createVoids as p, getDayIndex as b, getFirstDay as u, getMonthMaxDay as k } from "./bundle.es43.js";
3
- import { CalendarHeader as F } from "./bundle.es44.js";
4
- import { useCalendar as j } from "./bundle.es45.js";
2
+ import { dateToFormat as $, weeks as g, createVoids as p, getDayIndex as b, getFirstDay as u, getMonthMaxDay as k } from "./bundle.es44.js";
3
+ import { CalendarHeader as F } from "./bundle.es45.js";
4
+ import { useCalendar as j } from "./bundle.es46.js";
5
5
  import { attr as m } from "@companix/utils-browser";
6
6
  import { isSameDate as f } from "./bundle.es40.js";
7
7
  import { useLayoutEffect as I } from "react";
@@ -2,7 +2,7 @@ import { jsxs as T, jsx as $ } from "react/jsx-runtime";
2
2
  import { forwardRef as b, useState as I, useMemo as P, useImperativeHandle as R, useCallback as j, createElement as k } from "react";
3
3
  import * as c from "@radix-ui/react-toast";
4
4
  import { varToStyle as w } from "@companix/utils-browser";
5
- import { Toast as C } from "./bundle.es46.js";
5
+ import { Toast as C } from "./bundle.es43.js";
6
6
  var g = /* @__PURE__ */ ((e) => (e["top-center"] = "up", e["top-left"] = "left", e["top-right"] = "right", e["bottom-center"] = "down", e["bottom-left"] = "left", e["bottom-right"] = "right", e))(g || {});
7
7
  const M = b((e, h) => {
8
8
  const { side: f = "top", align: i = "center", gap: m = 14, duration: u, swipeThreshold: v, closeIcon: x } = e, [l, p] = I([]), o = P(() => ({}), []);
@@ -1,33 +1,45 @@
1
- import { clamp as a } from "@companix/utils-browser";
2
- const D = (t, e) => new Date(e, t, 0).getDate(), g = (t, e) => new Date(e, t - 1, 1).getDay(), i = (t) => t === 0 ? 6 : t - 1, u = (t) => new Array(t).fill(0), h = (t) => ({
3
- day: t.getDate(),
4
- month: t.getMonth() + 1,
5
- year: t.getFullYear()
6
- }), y = ["Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"], s = 9999, c = 100, f = (t, e) => {
7
- const o = [], n = a(t - e, c, s), l = a(t + e, c, s);
8
- for (let r = n; r <= l; r++)
9
- o.push({ title: String(r).padStart(4, "0"), value: r });
10
- return o;
11
- }, p = (t) => {
12
- const e = [], o = new Intl.DateTimeFormat(t, {
13
- month: "long"
14
- });
15
- for (let n = 0; n < 12; n++)
16
- e.push({
17
- title: o.format(new Date(2023, n, 15)),
18
- value: n
19
- });
20
- return e;
1
+ import { jsxs as n, jsx as e } from "react/jsx-runtime";
2
+ import * as t from "@radix-ui/react-toast";
3
+ import { attr as C } from "@companix/utils-browser";
4
+ import { useState as h, useRef as v, useEffect as N, useLayoutEffect as x } from "react";
5
+ import { RemoveListener as R } from "./bundle.es36.js";
6
+ const E = (i) => {
7
+ const [c, l] = h(!1), o = v(null), {
8
+ appearance: d = "neutral",
9
+ icon: r,
10
+ title: a,
11
+ description: s,
12
+ duration: m,
13
+ closeIcon: u,
14
+ onRemoving: p,
15
+ onRemoved: f,
16
+ onInitialized: L
17
+ } = i;
18
+ return N(() => {
19
+ l(!0);
20
+ }, []), x(() => {
21
+ o.current && L(o.current);
22
+ }, []), /* @__PURE__ */ n(
23
+ t.Root,
24
+ {
25
+ ref: o,
26
+ "data-expanded": !0,
27
+ "data-appearance": d,
28
+ "data-mounted": C(c),
29
+ className: "toaster",
30
+ duration: m,
31
+ children: [
32
+ /* @__PURE__ */ e(R, { callback: f }),
33
+ r && /* @__PURE__ */ e("div", { className: "toaster-icon", children: r }),
34
+ /* @__PURE__ */ n("div", { className: "toaster-content", children: [
35
+ a && /* @__PURE__ */ e(t.Title, { className: "toaster-title", children: a }),
36
+ s && /* @__PURE__ */ e(t.Description, { className: "toaster-description", children: s })
37
+ ] }),
38
+ /* @__PURE__ */ e(t.Close, { className: "toaster-close", onClick: p, children: u ?? /* @__PURE__ */ e("svg", { viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M2.96967 2.96967C3.26256 2.67678 3.73744 2.67678 4.03033 2.96967L8 6.939L11.9697 2.96967C12.2626 2.67678 12.7374 2.67678 13.0303 2.96967C13.3232 3.26256 13.3232 3.73744 13.0303 4.03033L9.061 8L13.0303 11.9697C13.2966 12.2359 13.3208 12.6526 13.1029 12.9462L13.0303 13.0303C12.7374 13.3232 12.2626 13.3232 11.9697 13.0303L8 9.061L4.03033 13.0303C3.73744 13.3232 3.26256 13.3232 2.96967 13.0303C2.67678 12.7374 2.67678 12.2626 2.96967 11.9697L6.939 8L2.96967 4.03033C2.7034 3.76406 2.6792 3.3474 2.89705 3.05379L2.96967 2.96967Z" }) }) })
39
+ ]
40
+ }
41
+ );
21
42
  };
22
43
  export {
23
- s as DEFAULT_MAX_YEAR,
24
- c as DEFAULT_MIN_YEAR,
25
- u as createVoids,
26
- h as dateToFormat,
27
- i as getDayIndex,
28
- g as getFirstDay,
29
- D as getMonthMaxDay,
30
- p as getMonths,
31
- f as getYears,
32
- y as weeks
44
+ E as Toast
33
45
  };
@@ -1,77 +1,33 @@
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.es8.js";
4
- import { getMonths as k, getYears as z, DEFAULT_MAX_YEAR as f, DEFAULT_MIN_YEAR as g } from "./bundle.es43.js";
5
- import { Icon as C } from "./bundle.es35.js";
6
- import { faChevronLeft as E, faChevronRight as T } from "@fortawesome/free-solid-svg-icons";
7
- import { setMonth as _, setYear as F } from "./bundle.es40.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 || 0)
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 || 0)
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 { clamp as a } from "@companix/utils-browser";
2
+ const D = (t, e) => new Date(e, t, 0).getDate(), g = (t, e) => new Date(e, t - 1, 1).getDay(), i = (t) => t === 0 ? 6 : t - 1, u = (t) => new Array(t).fill(0), h = (t) => ({
3
+ day: t.getDate(),
4
+ month: t.getMonth() + 1,
5
+ year: t.getFullYear()
6
+ }), y = ["Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"], s = 9999, c = 100, f = (t, e) => {
7
+ const o = [], n = a(t - e, c, s), l = a(t + e, c, s);
8
+ for (let r = n; r <= l; r++)
9
+ o.push({ title: String(r).padStart(4, "0"), value: r });
10
+ return o;
11
+ }, p = (t) => {
12
+ const e = [], o = new Intl.DateTimeFormat(t, {
13
+ month: "long"
14
+ });
15
+ for (let n = 0; n < 12; n++)
16
+ e.push({
17
+ title: o.format(new Date(2023, n, 15)),
18
+ value: n
19
+ });
20
+ return e;
74
21
  };
75
22
  export {
76
- y as CalendarHeader
23
+ s as DEFAULT_MAX_YEAR,
24
+ c as DEFAULT_MIN_YEAR,
25
+ u as createVoids,
26
+ h as dateToFormat,
27
+ i as getDayIndex,
28
+ g as getFirstDay,
29
+ D as getMonthMaxDay,
30
+ p as getMonths,
31
+ f as getYears,
32
+ y as weeks
77
33
  };
@@ -1,51 +1,77 @@
1
- import { subMonths as L, addMonths as N, useDayDisableCheker as R } from "./bundle.es40.js";
2
- import { DEFAULT_MIN_YEAR as w, DEFAULT_MAX_YEAR as A } from "./bundle.es43.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.es8.js";
4
+ import { getMonths as k, getYears as z, DEFAULT_MAX_YEAR as f, DEFAULT_MIN_YEAR as g } from "./bundle.es44.js";
5
+ import { Icon as C } from "./bundle.es35.js";
6
+ import { faChevronLeft as E, faChevronRight as T } from "@fortawesome/free-solid-svg-icons";
7
+ import { setMonth as _, setYear as F } from "./bundle.es40.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,45 +1,51 @@
1
- import { jsxs as n, jsx as e } from "react/jsx-runtime";
2
- import * as t from "@radix-ui/react-toast";
3
- import { attr as C } from "@companix/utils-browser";
4
- import { useState as h, useRef as v, useEffect as N, useLayoutEffect as x } from "react";
5
- import { RemoveListener as R } from "./bundle.es36.js";
6
- const E = (i) => {
7
- const [c, l] = h(!1), o = v(null), {
8
- appearance: d = "neutral",
9
- icon: r,
10
- title: a,
11
- description: s,
12
- duration: m,
13
- closeIcon: u,
14
- onRemoving: p,
15
- onRemoved: f,
16
- onInitialized: L
17
- } = i;
18
- return N(() => {
19
- l(!0);
20
- }, []), x(() => {
21
- o.current && L(o.current);
22
- }, []), /* @__PURE__ */ n(
23
- t.Root,
24
- {
25
- ref: o,
26
- "data-expanded": !0,
27
- "data-appearance": d,
28
- "data-mounted": C(c),
29
- className: "toaster",
30
- duration: m,
31
- children: [
32
- /* @__PURE__ */ e(R, { callback: f }),
33
- r && /* @__PURE__ */ e("div", { className: "toaster-icon", children: r }),
34
- /* @__PURE__ */ n("div", { className: "toaster-content", children: [
35
- a && /* @__PURE__ */ e(t.Title, { className: "toaster-title", children: a }),
36
- s && /* @__PURE__ */ e(t.Description, { className: "toaster-description", children: s })
37
- ] }),
38
- /* @__PURE__ */ e(t.Close, { className: "toaster-close", onClick: p, children: u ?? /* @__PURE__ */ e("svg", { viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M2.96967 2.96967C3.26256 2.67678 3.73744 2.67678 4.03033 2.96967L8 6.939L11.9697 2.96967C12.2626 2.67678 12.7374 2.67678 13.0303 2.96967C13.3232 3.26256 13.3232 3.73744 13.0303 4.03033L9.061 8L13.0303 11.9697C13.2966 12.2359 13.3208 12.6526 13.1029 12.9462L13.0303 13.0303C12.7374 13.3232 12.2626 13.3232 11.9697 13.0303L8 9.061L4.03033 13.0303C3.73744 13.3232 3.26256 13.3232 2.96967 13.0303C2.67678 12.7374 2.67678 12.2626 2.96967 11.9697L6.939 8L2.96967 4.03033C2.7034 3.76406 2.6792 3.3474 2.89705 3.05379L2.96967 2.96967Z" }) }) })
39
- ]
40
- }
1
+ import { subMonths as L, addMonths as N, useDayDisableCheker as R } from "./bundle.es40.js";
2
+ import { DEFAULT_MIN_YEAR as w, DEFAULT_MAX_YEAR as A } from "./bundle.es44.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]
41
38
  );
39
+ return {
40
+ viewDate: e,
41
+ setViewDate: u,
42
+ setPrevMonth: _,
43
+ setNextMonth: C,
44
+ isDayDisabled: D,
45
+ isMonthDisabled: k,
46
+ isYearDisabled: v
47
+ };
42
48
  };
43
49
  export {
44
- E as Toast
50
+ X as useCalendar
45
51
  };
@@ -1,83 +1,85 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import { useMemo as S, useEffect as A } from "react";
3
- import { OptionsList as E } from "./bundle.es12.js";
4
- import { OptionItem as b } from "./bundle.es10.js";
5
- import { Popover as F } from "./bundle.es6.js";
6
- import { useFroozeClosing as I } from "./bundle.es31.js";
7
- import { SelectInput as z } from "./bundle.es32.js";
1
+ import { jsx as r } from "react/jsx-runtime";
2
+ import { useMemo as A, useEffect as E } from "react";
3
+ import { OptionsList as b } from "./bundle.es12.js";
4
+ import { OptionItem as F } from "./bundle.es10.js";
5
+ import { Popover as I } from "./bundle.es6.js";
6
+ import { useFroozeClosing as z } from "./bundle.es31.js";
7
+ import { SelectInput as B } from "./bundle.es32.js";
8
8
  import { useScrollListController as D } from "./bundle.es33.js";
9
- const M = (c) => {
9
+ const q = (c) => {
10
10
  const {
11
- options: e,
12
- onChange: l,
13
- value: s,
11
+ options: t,
12
+ onChange: i,
13
+ value: l,
14
14
  minimalOptions: a,
15
15
  matchTarget: m = "width",
16
16
  children: u,
17
- disabled: p,
18
- ...n
19
- } = c, t = S(() => {
20
- const o = e.findIndex((r) => r.value === s);
17
+ disabled: s,
18
+ clearButton: e,
19
+ ...f
20
+ } = c, p = A(() => {
21
+ const o = t.findIndex((n) => n.value === l);
21
22
  return {
22
23
  index: o,
23
- option: e[o]
24
+ option: t[o]
24
25
  };
25
- }, [e, s]), f = t.option?.value ?? null, { popoverRef: d, froozePopoverPosition: v, handleAnimationEnd: h } = I(), { scrollToElement: x, optionsWrapperRef: O, scrollBoxRef: C } = D(), g = (o, r) => {
26
- v(), l(o), r();
27
- }, P = (o) => {
28
- o.stopPropagation(), l(null);
29
- }, R = () => {
30
- t.index !== -1 && x(t.index, !0);
26
+ }, [t, l]), d = p.option?.value ?? null, { popoverRef: v, froozePopoverPosition: h, handleAnimationEnd: x } = z(), { scrollToElement: O, optionsWrapperRef: C, scrollBoxRef: g } = D(), P = (o, n) => {
27
+ h(), i(o), n();
28
+ }, R = (o) => {
29
+ o.stopPropagation(), e && i(null);
30
+ }, S = () => {
31
+ p.index !== -1 && O(p.index, !0);
31
32
  };
32
- return /* @__PURE__ */ i(
33
- F,
33
+ return /* @__PURE__ */ r(
34
+ I,
34
35
  {
35
36
  minimal: !0,
36
- ref: d,
37
+ ref: v,
37
38
  sideOffset: 0,
38
39
  matchTarget: m,
39
- onAnimationEnd: h,
40
+ onAnimationEnd: x,
40
41
  onOpenAutoFocus: (o) => o.preventDefault(),
41
42
  onCloseAutoFocus: (o) => o.preventDefault(),
42
- disabled: p,
43
- content: ({ close: o }) => /* @__PURE__ */ i(
43
+ disabled: s,
44
+ content: ({ close: o }) => /* @__PURE__ */ r(
44
45
  L,
45
46
  {
46
- options: e,
47
- active: f,
48
- scrollboxRef: C,
49
- optionsWrapperRef: O,
47
+ options: t,
48
+ active: d,
49
+ scrollboxRef: g,
50
+ optionsWrapperRef: C,
50
51
  minimalOptions: a,
51
- onOpened: R,
52
- onSelect: (r) => g(r, o)
52
+ onOpened: S,
53
+ onSelect: (n) => P(n, o)
53
54
  }
54
55
  ),
55
- children: u ?? /* @__PURE__ */ i(
56
- z,
56
+ children: u ?? /* @__PURE__ */ r(
57
+ B,
57
58
  {
58
- ...n,
59
- disabled: p,
60
- value: t.option?.title ?? "",
61
- onClear: P
59
+ ...f,
60
+ disabled: s,
61
+ clearButton: e,
62
+ value: p.option?.title ?? "",
63
+ onClear: R
62
64
  }
63
65
  )
64
66
  }
65
67
  );
66
68
  }, L = (c) => {
67
- const { active: e, onOpened: l, scrollboxRef: s, optionsWrapperRef: a, options: m, onSelect: u, minimalOptions: p } = c;
68
- return A(() => {
69
- l?.();
70
- }, []), /* @__PURE__ */ i(E, { scrollboxRef: s, optionsWrapperRef: a, maxHeight: 300, children: m.map((n, t) => /* @__PURE__ */ i(
71
- b,
69
+ const { active: t, onOpened: i, scrollboxRef: l, optionsWrapperRef: a, options: m, onSelect: u, minimalOptions: s } = c;
70
+ return E(() => {
71
+ i?.();
72
+ }, []), /* @__PURE__ */ r(b, { scrollboxRef: l, optionsWrapperRef: a, maxHeight: 300, children: m.map((e, f) => /* @__PURE__ */ r(
73
+ F,
72
74
  {
73
- active: e === n.value,
74
- onClick: () => u?.(n.value),
75
- minimal: p,
76
- ...n
75
+ active: t === e.value,
76
+ onClick: () => u?.(e.value),
77
+ minimal: s,
78
+ ...e
77
79
  },
78
- `option-item-${n.value}-${t}`
80
+ `option-item-${e.value}-${f}`
79
81
  )) });
80
82
  };
81
83
  export {
82
- M as Select
84
+ q as Select
83
85
  };
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@companix/uikit",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "module": "./dist/bundle.es.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",
7
7
  "files": [
8
- "dist",
9
- "README.md"
8
+ "dist"
10
9
  ],
11
10
  "author": "Pavel Victorov",
12
11
  "scripts": {