@companix/uikit 0.1.38 → 0.1.40

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.
@@ -2,9 +2,10 @@ import { PopupLayotProps } from '../Popup';
2
2
  export interface DrawerProps extends Omit<PopupLayotProps, 'content' | 'overlay'> {
3
3
  direction?: 'bottom' | 'top' | 'left' | 'right';
4
4
  className?: string;
5
+ overlayClassName?: string;
5
6
  size?: string;
6
7
  }
7
8
  export declare const Drawer: {
8
- ({ direction, children, size, className, ...props }: DrawerProps): import("react/jsx-runtime").JSX.Element;
9
+ ({ direction, children, size, overlayClassName, className, ...props }: DrawerProps): import("react/jsx-runtime").JSX.Element;
9
10
  Close: import('react').ForwardRefExoticComponent<import('@radix-ui/react-dialog').DialogCloseProps & import('react').RefAttributes<HTMLButtonElement>>;
10
11
  };
@@ -6,6 +6,8 @@ export interface PopupLayotProps {
6
6
  defaultOpen?: boolean;
7
7
  disableEsc?: boolean;
8
8
  onClosed?: () => void;
9
+ modal?: boolean;
10
+ container?: HTMLElement | null;
9
11
  overlay?: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>;
10
12
  overlayRef?: React.Ref<HTMLDivElement>;
11
13
  content?: React.ComponentPropsWithoutRef<typeof DialogPrimitive.Content> & {
@@ -1,21 +1,28 @@
1
- import { jsx as s } from "react/jsx-runtime";
2
- import p from "classnames";
3
- import { customCSS as c } from "@companix/utils-browser";
4
- import { PopupLayout as r } from "./bundle.es25.js";
5
- const i = ({ direction: o, children: e, size: t, className: a, ...m }) => /* @__PURE__ */ s(
6
- r,
1
+ import { jsx as c } from "react/jsx-runtime";
2
+ import r from "classnames";
3
+ import { customCSS as i } from "@companix/utils-browser";
4
+ import { PopupLayout as o } from "./bundle.es25.js";
5
+ const l = ({
6
+ direction: e,
7
+ children: t,
8
+ size: a,
9
+ overlayClassName: m,
10
+ className: s,
11
+ ...p
12
+ }) => /* @__PURE__ */ c(
13
+ o,
7
14
  {
8
- ...m,
9
- overlay: { className: "drawer-overlay" },
15
+ ...p,
16
+ overlay: { className: r("drawer-overlay", m) },
10
17
  content: {
11
- className: p("popup drawer", a),
12
- style: c({ "--drawer-size": t ?? "50%" }),
13
- "data-direction": o
18
+ className: r("popup drawer", s),
19
+ style: i({ "--drawer-size": a ?? "50%" }),
20
+ "data-direction": e
14
21
  },
15
- children: e
22
+ children: t
16
23
  }
17
24
  );
18
- i.Close = r.Close;
25
+ l.Close = o.Close;
19
26
  export {
20
- i as Drawer
27
+ l as Drawer
21
28
  };
@@ -1,23 +1,23 @@
1
- import { jsx as e, jsxs as n } from "react/jsx-runtime";
2
- import y from "classnames";
1
+ import { jsx as e, jsxs as r } from "react/jsx-runtime";
2
+ import C from "classnames";
3
3
  import * as o from "@radix-ui/react-dialog";
4
4
  import { VisuallyHidden as l } from "@radix-ui/react-visually-hidden";
5
- import { RemoveListener as u } from "./bundle.es60.js";
6
- const C = (t) => {
7
- const { open: i, onOpenChange: a, children: s, onClosed: c, disableEsc: p, overlay: r = {}, overlayRef: m, content: d = {}, contentRef: f } = t, h = (v) => {
8
- p && v.preventDefault();
5
+ import { RemoveListener as D } from "./bundle.es60.js";
6
+ const R = (t) => {
7
+ const { open: i, onOpenChange: a, children: c, onClosed: s, disableEsc: p, modal: m, container: d, overlay: n = {}, overlayRef: f, content: h = {}, contentRef: v } = t, y = (u) => {
8
+ p && u.preventDefault();
9
9
  };
10
- return /* @__PURE__ */ e(o.Root, { open: i, onOpenChange: a, children: /* @__PURE__ */ n(o.Portal, { children: [
11
- /* @__PURE__ */ e(o.Overlay, { ...r, ref: m, className: y("popup-overlay", r.className) }),
12
- /* @__PURE__ */ n(o.Content, { ...d, ref: f, onEscapeKeyDown: h, children: [
13
- /* @__PURE__ */ e(u, { callback: c }),
10
+ return /* @__PURE__ */ e(o.Root, { open: i, onOpenChange: a, modal: m, children: /* @__PURE__ */ r(o.Portal, { container: d, children: [
11
+ /* @__PURE__ */ e(o.Overlay, { ...n, ref: f, className: C("popup-overlay", n.className) }),
12
+ /* @__PURE__ */ r(o.Content, { ...h, ref: v, onEscapeKeyDown: y, children: [
13
+ /* @__PURE__ */ e(D, { callback: s }),
14
14
  /* @__PURE__ */ e(l, { children: /* @__PURE__ */ e(o.Title, {}) }),
15
15
  /* @__PURE__ */ e(l, { children: /* @__PURE__ */ e(o.Description, {}) }),
16
- s
16
+ c
17
17
  ] })
18
18
  ] }) });
19
19
  };
20
- C.Close = o.Close;
20
+ R.Close = o.Close;
21
21
  export {
22
- C as PopupLayout
22
+ R as PopupLayout
23
23
  };
@@ -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.es86.js";
5
+ import { useInputPadding as N } from "./bundle.es84.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.es67.js";
3
- import { CalendarHeader as F } from "./bundle.es84.js";
4
- import { useCalendar as j } from "./bundle.es85.js";
3
+ import { CalendarHeader as F } from "./bundle.es85.js";
4
+ import { useCalendar as j } from "./bundle.es86.js";
5
5
  import { attr as m } from "@companix/utils-browser";
6
6
  import { isSameDate as f } from "./bundle.es61.js";
7
7
  import { useLayoutEffect as I } from "react";
@@ -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.es13.js";
4
- import { getMonths as k, getYears as z, DEFAULT_MAX_YEAR as f, DEFAULT_MIN_YEAR as g } from "./bundle.es67.js";
5
- import { Icon as C } from "./bundle.es36.js";
6
- import { faChevronLeft as E, faChevronRight as T } from "@companix/icons-solid";
7
- import { setMonth as _, setYear as F } from "./bundle.es61.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.es87.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.es61.js";
2
- import { DEFAULT_MIN_YEAR as w, DEFAULT_MAX_YEAR as A } from "./bundle.es67.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.es13.js";
4
+ import { getMonths as k, getYears as z, DEFAULT_MAX_YEAR as f, DEFAULT_MIN_YEAR as g } from "./bundle.es67.js";
5
+ import { Icon as C } from "./bundle.es36.js";
6
+ import { faChevronLeft as E, faChevronRight as T } from "@companix/icons-solid";
7
+ import { setMonth as _, setYear as F } from "./bundle.es61.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, 1));
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 l, useCallback as p } from "react";
2
- import { useEffectWithLayout as d } from "./bundle.es87.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 { subMonths as L, addMonths as N, useDayDisableCheker as R } from "./bundle.es61.js";
2
+ import { DEFAULT_MIN_YEAR as w, DEFAULT_MAX_YEAR as A } from "./bundle.es67.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, 1));
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
- g as useInputPadding
50
+ X as useCalendar
16
51
  };
package/dist/index.d.ts CHANGED
@@ -97,7 +97,7 @@ export { createToaster } from './Toaster';
97
97
  export { Toast } from './Toaster/Toast';
98
98
  export * from './types';
99
99
  export type { CalendarProps } from './Calendar/Calendar';
100
- export type { OptionsSource, UseOptionsResponse } from './Select/OptionsPopover';
100
+ export type { OptionsSource, OptionsPopover, UseOptionsResponse } from './Select/OptionsPopover';
101
101
  export { createPopupRegistry, DialogShell, DrawerShell, MobileDrawerShell, usePopup } from './__helpers/createPopupRegistry';
102
102
  export { createPopoversRegistry } from './__helpers/createPopoversRegistry';
103
103
  export { createScope, createStaticScope } from './__helpers/createScope';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companix/uikit",
3
- "version": "0.1.38",
3
+ "version": "0.1.40",
4
4
  "main": "./dist/bundle.es.js",
5
5
  "module": "./dist/bundle.es.js",
6
6
  "types": "./dist/index.d.ts",