@companix/uikit 0.0.18 → 0.0.19

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,7 +1,7 @@
1
1
  import { InputContainerProps } from './InputContainer';
2
2
  export interface InputProps extends Omit<InputContainerProps, 'inputRef' | 'children'> {
3
3
  placeholder?: string;
4
- value?: string | number;
4
+ value?: string;
5
5
  readOnly?: boolean;
6
6
  onValueChange?: (value: string, targetElement: HTMLInputElement) => void;
7
7
  onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
@@ -1,4 +1,6 @@
1
- interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'children'> {
1
+ interface InputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'children' | 'value' | 'defaultValue'> {
2
+ defaultValue?: string;
3
+ value?: string;
2
4
  mask?: string;
3
5
  maskChar?: string;
4
6
  onValueChange?: (value: string, targetElement: HTMLInputElement) => void;
@@ -1,6 +1,23 @@
1
- import { InputProps } from '../Input/Input';
2
- export interface NumberInputProps extends Omit<InputProps, 'value' | 'onChange'> {
3
- value: number | null;
4
- onChange: (value: number | null) => void;
1
+ import { InputContainerProps } from '../Input/InputContainer';
2
+ export interface ReactNumberFormatParams {
3
+ thousandSeparator?: boolean | string;
4
+ decimalSeparator?: string;
5
+ allowedDecimalSeparators?: Array<string>;
6
+ thousandsGroupStyle?: 'thousand' | 'lakh' | 'wan' | 'none';
7
+ decimalScale?: number;
8
+ fixedDecimalScale?: boolean;
9
+ allowNegative?: boolean;
10
+ allowLeadingZeros?: boolean;
11
+ suffix?: string;
12
+ prefix?: string;
5
13
  }
6
- export declare const NumberInput: ({ value, onChange, ...props }: NumberInputProps) => import("react/jsx-runtime").JSX.Element;
14
+ export interface NumberInputProps extends Omit<InputContainerProps, 'inputRef' | 'children'>, ReactNumberFormatParams {
15
+ placeholder?: string;
16
+ value?: number | null;
17
+ readOnly?: boolean;
18
+ onValueChange?: (value: number | null) => void;
19
+ onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
20
+ inputRef?: React.Ref<HTMLInputElement>;
21
+ inputClassName?: string;
22
+ }
23
+ export declare const NumberInput: import('react').ForwardRefExoticComponent<NumberInputProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -1,4 +1,4 @@
1
- interface RadioOption<T> {
1
+ export interface RadioOption<T> {
2
2
  value: T;
3
3
  label: React.ReactNode;
4
4
  }
@@ -1,33 +1,58 @@
1
- import { jsx as f } from "react/jsx-runtime";
2
- import { useState as p, useRef as m } from "react";
3
- import { Input as l } from "./bundle.es9.js";
4
- const N = ({ value: r, onChange: u, ...e }) => {
5
- const [, t] = p([]), n = m(i(r));
6
- return +n.current !== r && (n.current = i(r)), /* @__PURE__ */ f(
7
- l,
8
- {
9
- ...e,
10
- value: n.current,
11
- onChange: (o) => {
12
- const s = o.currentTarget.value.trim();
13
- if (s === "")
14
- return n.current = "", u(null);
15
- if (!(s.startsWith(".") || s.replace(".", "").split("").some((c) => isNaN(parseInt(c))))) {
16
- if (n.current = a(s.split("")), +n.current === r)
17
- return t([]);
18
- u(+n.current);
19
- }
1
+ import { jsx as t } from "react/jsx-runtime";
2
+ import C from "classnames";
3
+ import { forwardRef as j, useRef as w } from "react";
4
+ import { mergeRefs as y } from "react-merge-refs";
5
+ import { InputContainer as F } from "./bundle.es38.js";
6
+ import { NumericFormat as V } from "react-number-format";
7
+ const D = j(
8
+ ({
9
+ onChange: m,
10
+ onValueChange: o,
11
+ readOnly: i,
12
+ inputClassName: f,
13
+ value: n,
14
+ placeholder: u,
15
+ thousandSeparator: p,
16
+ decimalSeparator: a,
17
+ allowedDecimalSeparators: l,
18
+ thousandsGroupStyle: d,
19
+ decimalScale: s,
20
+ fixedDecimalScale: b,
21
+ allowNegative: R,
22
+ allowLeadingZeros: c,
23
+ suffix: g,
24
+ prefix: x,
25
+ inputRef: I,
26
+ ...e
27
+ }, N) => {
28
+ const r = w(null);
29
+ return /* @__PURE__ */ t(F, { ref: N, inputRef: r, ...e, children: /* @__PURE__ */ t(
30
+ V,
31
+ {
32
+ type: "text",
33
+ getInputRef: y([r, I]),
34
+ className: C("form-input form-input-base", f),
35
+ "aria-disabled": e.disabled,
36
+ onChange: m,
37
+ onValueChange: ({ floatValue: h }) => o?.(h ?? null),
38
+ value: n,
39
+ placeholder: u,
40
+ disabled: e.disabled,
41
+ readOnly: i,
42
+ thousandSeparator: p,
43
+ decimalSeparator: a,
44
+ allowedDecimalSeparators: l,
45
+ thousandsGroupStyle: d,
46
+ decimalScale: s,
47
+ fixedDecimalScale: b,
48
+ allowNegative: R,
49
+ allowLeadingZeros: c,
50
+ suffix: g,
51
+ prefix: x
20
52
  }
21
- }
22
- );
23
- }, i = (r) => r === null ? "" : r.toString(), a = (r) => {
24
- const u = [...r], e = [...r];
25
- if (e.every((t) => t === "0"))
26
- return "0";
27
- for (let t = 0; t < e.length && e[t] === "0"; t++)
28
- e[t] === "0" && e[t + 1] !== "." && u.shift();
29
- return u.join("");
30
- };
53
+ ) });
54
+ }
55
+ );
31
56
  export {
32
- N as NumberInput
57
+ D as NumberInput
33
58
  };
@@ -2,7 +2,7 @@ import { jsx as u } from "react/jsx-runtime";
2
2
  import { forwardRef as m, useCallback as i } from "react";
3
3
  import c from "react-input-mask";
4
4
  const I = m(
5
- ({ mask: r, maskChar: f, onChange: n, onValueChange: o, ...a }, e) => {
5
+ ({ mask: r, maskChar: f = "_", onChange: n, onValueChange: o, ...a }, e) => {
6
6
  const p = i(
7
7
  (t) => {
8
8
  n?.(t), o?.(t.target.value, t.target);
@@ -2,7 +2,7 @@ import { jsxs as b, jsx as o } from "react/jsx-runtime";
2
2
  import h from "classnames";
3
3
  import { attr as e } from "@companix/utils-browser";
4
4
  import { forwardRef as x } from "react";
5
- import { useInputPadding as N } from "./bundle.es52.js";
5
+ import { useInputPadding as N } from "./bundle.es50.js";
6
6
  const v = x(
7
7
  ({
8
8
  required: s,
@@ -1,7 +1,7 @@
1
1
  import { jsxs as D, jsx as t } from "react/jsx-runtime";
2
2
  import { dateToFormat as $, weeks as g, createVoids as p, getDayIndex as b, getFirstDay as u, getMonthMaxDay as k } from "./bundle.es45.js";
3
- import { CalendarHeader as F } from "./bundle.es50.js";
4
- import { useCalendar as j } from "./bundle.es51.js";
3
+ import { CalendarHeader as F } from "./bundle.es52.js";
4
+ import { useCalendar as j } from "./bundle.es53.js";
5
5
  import { attr as m } from "@companix/utils-browser";
6
6
  import { isSameDate as f } from "./bundle.es44.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.es53.js";
5
+ import { Toast as C } from "./bundle.es51.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,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.es8.js";
4
- import { getMonths as k, getYears as z, DEFAULT_MAX_YEAR as f, DEFAULT_MIN_YEAR as g } from "./bundle.es45.js";
5
- import { Icon as C } from "./bundle.es39.js";
6
- import { faChevronLeft as E, faChevronRight as T } from "@fortawesome/free-solid-svg-icons";
7
- import { setMonth as _, setYear as F } from "./bundle.es44.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.es54.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,45 @@
1
- import { subMonths as L, addMonths as N, useDayDisableCheker as R } from "./bundle.es44.js";
2
- import { DEFAULT_MIN_YEAR as w, DEFAULT_MAX_YEAR as A } from "./bundle.es45.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]
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.es40.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
+ }
38
41
  );
39
- return {
40
- viewDate: e,
41
- setViewDate: u,
42
- setPrevMonth: _,
43
- setNextMonth: C,
44
- isDayDisabled: D,
45
- isMonthDisabled: k,
46
- isYearDisabled: v
47
- };
48
42
  };
49
43
  export {
50
- X as useCalendar
44
+ E as Toast
51
45
  };
@@ -1,16 +1,77 @@
1
- import { useRef as l, useCallback as p } from "react";
2
- import { useEffectWithLayout as d } from "./bundle.es54.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 };
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.es45.js";
5
+ import { Icon as C } from "./bundle.es39.js";
6
+ import { faChevronLeft as E, faChevronRight as T } from "@fortawesome/free-solid-svg-icons";
7
+ import { setMonth as _, setYear as F } from "./bundle.es44.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
+ ] });
13
74
  };
14
75
  export {
15
- g as useInputPadding
76
+ y as CalendarHeader
16
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.es40.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.es44.js";
2
+ import { DEFAULT_MIN_YEAR as w, DEFAULT_MAX_YEAR as A } from "./bundle.es45.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
  };
package/dist/index.d.ts CHANGED
@@ -26,8 +26,10 @@ export { DateInput } from './DateInput';
26
26
  export { FileOverlay } from './File';
27
27
  export { FormGroup } from './FormGroup';
28
28
  export { TimePicker } from './TimePicker';
29
- export * from './__hooks/use-local-storage';
29
+ export { useLocalStorage } from './__hooks/use-local-storage';
30
30
  export { createAlertAgent } from './DialogAlert';
31
31
  export { createToaster } from './Toaster';
32
32
  export * from './types';
33
33
  export type { Appearance } from './Button';
34
+ export type { RadioOption } from './Radio';
35
+ export type { NumberInputProps, ReactNumberFormatParams } from './NumberInput';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companix/uikit",
3
- "version": "0.0.18",
3
+ "version": "0.0.19",
4
4
  "module": "./dist/bundle.es.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "type": "module",
@@ -37,7 +37,8 @@
37
37
  "@radix-ui/react-visually-hidden": "^1.2.4",
38
38
  "classnames": "^2.5.1",
39
39
  "react-input-mask": "^2.0.4",
40
- "react-merge-refs": "^3.0.2"
40
+ "react-merge-refs": "^3.0.2",
41
+ "react-number-format": "^5.4.4"
41
42
  },
42
43
  "devDependencies": {
43
44
  "@blueprintjs/core": "^6.2.1",
@@ -1,35 +0,0 @@
1
- .number-input-container {
2
- display: flex;
3
- gap: 4px;
4
- }
5
-
6
- .number-stepper {
7
- display: flex;
8
- flex-direction: column;
9
- height: 30px;
10
- min-height: 30px;
11
- line-height: 30px;
12
- border: 1px solid var(--border-color);
13
- box-shadow: 0 1px 2px rgb(0 0 0 / 47%);
14
- border-radius: 4px;
15
-
16
- &-splitter {
17
- height: 1px;
18
- background-color: var(--border-color);
19
- }
20
-
21
- &-slot {
22
- border-radius: 0px;
23
- height: 13.5px;
24
-
25
- &[data-slot='decrement'] {
26
- border-bottom-left-radius: 3px;
27
- border-bottom-right-radius: 3px;
28
- }
29
-
30
- &[data-slot='increment'] {
31
- border-top-left-radius: 3px;
32
- border-top-right-radius: 3px;
33
- }
34
- }
35
- }
@@ -1,8 +0,0 @@
1
- import { StepperInputOptions } from '../__hooks/use-stepper-input';
2
- interface StepperInputProps extends StepperInputOptions {
3
- buttons?: boolean;
4
- placeholder?: string;
5
- inputStyle?: React.CSSProperties;
6
- }
7
- export declare const StepperInput: ({ inputStyle, placeholder, buttons, ...options }: StepperInputProps) => import("react/jsx-runtime").JSX.Element;
8
- export {};
@@ -1,13 +0,0 @@
1
- export interface StepperInputOptions {
2
- value: number;
3
- onChange: (value: number) => void;
4
- step: number;
5
- minValue?: number;
6
- }
7
- export declare const useStepperInput: ({ minValue, value, onChange, step }: StepperInputOptions) => {
8
- inputRef: import('react').RefObject<HTMLInputElement>;
9
- value: string;
10
- increment: () => void;
11
- decrement: () => void;
12
- handleChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
13
- };