@companix/uikit 0.0.65 → 0.0.66

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,81 +1,85 @@
1
- import { jsx as e, jsxs as g } from "react/jsx-runtime";
2
- import { useMemo as h, useEffect as O } from "react";
3
- import { Spinner as L } from "./bundle.es6.js";
4
- import { OptionItem as u } from "./bundle.es15.js";
5
- import { OptionsList as C } from "./bundle.es17.js";
6
- import { Icon as R } from "./bundle.es33.js";
7
- import { faPlus as S } from "@companix/icons-solid";
8
- const b = () => ({ isLoading: !1, options: [] }), k = (s) => {
9
- const { onOptionsLoaded: n, useOptions: r = b, options: o } = s, t = r();
10
- return O(() => {
1
+ import { jsx as i, jsxs as L } from "react/jsx-runtime";
2
+ import { useMemo as C, useEffect as g } from "react";
3
+ import { Spinner as R } from "./bundle.es6.js";
4
+ import { OptionItem as x } from "./bundle.es15.js";
5
+ import { OptionsList as S } from "./bundle.es17.js";
6
+ import { Icon as b } from "./bundle.es33.js";
7
+ import { faPlus as k } from "@companix/icons-solid";
8
+ const y = () => ({ isLoading: !1, options: [] }), I = (s) => {
9
+ const { onOptionsLoaded: n, useOptions: r = y, options: o } = s, t = r();
10
+ return g(() => {
11
11
  t.options.length > 0 && n?.(t.options);
12
12
  }, [t.options]), o ? { options: o, isLoading: void 0 } : t;
13
- }, z = (s) => {
13
+ }, E = (s) => {
14
14
  const {
15
15
  isActive: n,
16
16
  emptyText: r,
17
17
  scrollboxRef: o,
18
18
  optionsWrapperRef: t,
19
- addOption: c,
19
+ addOption: a,
20
20
  onOpened: p,
21
- onSelect: a,
22
- minimalOptions: m,
23
- filterOptions: l,
24
- disableFiltering: i,
25
- ...d
26
- } = s, { options: f, isLoading: v } = k(d), x = h(() => l && !i ? f.filter(l) : f, [f, l, i]);
27
- return v ? /* @__PURE__ */ e("div", { className: "select-popover-loading", children: /* @__PURE__ */ e(L, { size: 24 }) }) : /* @__PURE__ */ e(
28
- y,
21
+ onSelect: d,
22
+ minimalOptions: f,
23
+ filterOptions: c,
24
+ disableFiltering: e,
25
+ ...m
26
+ } = s, { options: l, isLoading: O } = I(m), u = C(() => c && !e ? l.filter(c) : l, [l, c, e]);
27
+ return O ? /* @__PURE__ */ i("div", { className: "select-popover-loading", children: /* @__PURE__ */ i(R, { size: 24 }) }) : /* @__PURE__ */ i(
28
+ N,
29
29
  {
30
- options: x,
30
+ options: u,
31
31
  isActive: n,
32
32
  emptyText: r,
33
33
  scrollboxRef: o,
34
34
  optionsWrapperRef: t,
35
- minimalOptions: m,
36
- addOption: c,
35
+ minimalOptions: f,
36
+ addOption: a,
37
37
  onOpened: p,
38
- onSelect: a
38
+ onSelect: d
39
39
  }
40
40
  );
41
- }, y = (s) => {
41
+ }, N = (s) => {
42
42
  const {
43
43
  isActive: n,
44
44
  onOpened: r,
45
45
  addOption: o,
46
46
  scrollboxRef: t,
47
- optionsWrapperRef: c,
47
+ optionsWrapperRef: a,
48
48
  options: p,
49
- onSelect: a,
50
- minimalOptions: m,
51
- emptyText: l = "Ничего не найдено"
49
+ onSelect: d,
50
+ minimalOptions: f,
51
+ emptyText: c = "Ничего не найдено"
52
52
  } = s;
53
- return O(() => {
54
- r?.(p.findIndex(({ value: i }) => n(i)));
55
- }, []), /* @__PURE__ */ g(C, { scrollboxRef: t, optionsWrapperRef: c, maxHeight: 300, children: [
56
- o && /* @__PURE__ */ e(
57
- u,
53
+ return g(() => {
54
+ r?.(p.findIndex(({ value: e }) => n(e)));
55
+ }, []), /* @__PURE__ */ L(S, { scrollboxRef: t, optionsWrapperRef: a, maxHeight: 300, children: [
56
+ o && /* @__PURE__ */ i(
57
+ x,
58
58
  {
59
59
  className: "select-add-option",
60
- icon: /* @__PURE__ */ e(R, { icon: S }),
60
+ icon: /* @__PURE__ */ i(b, { icon: k }),
61
61
  title: o.text,
62
62
  onClick: o.onClick
63
63
  }
64
64
  ),
65
- p.length === 0 && !o && /* @__PURE__ */ e("div", { className: "select-tags-empty", children: l }),
66
- p.map((i, d) => /* @__PURE__ */ e(
67
- u,
65
+ p.length === 0 && !o && /* @__PURE__ */ i("div", { className: "select-tags-empty", children: c }),
66
+ p.map(({ title: e, value: m, className: l, icon: O, disabled: u, label: v }, h) => /* @__PURE__ */ i(
67
+ x,
68
68
  {
69
- active: n(i.value),
70
- onClick: () => a?.(i.value),
71
- minimal: m,
72
- ...i
69
+ active: n(m),
70
+ onClick: () => d?.(m),
71
+ minimal: f,
72
+ disabled: u,
73
+ className: l,
74
+ title: e,
75
+ label: v,
76
+ icon: O
73
77
  },
74
- `select-option-${d}`
78
+ `select-option-${h}`
75
79
  ))
76
80
  ] });
77
81
  };
78
82
  export {
79
- z as OptionsPopover,
80
- y as SelectOptionsList
83
+ E as OptionsPopover,
84
+ N as SelectOptionsList
81
85
  };
@@ -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.es64.js";
5
+ import { useInputPadding as N } from "./bundle.es66.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.es51.js";
3
- import { CalendarHeader as F } from "./bundle.es65.js";
4
- import { useCalendar as j } from "./bundle.es66.js";
3
+ import { CalendarHeader as F } from "./bundle.es64.js";
4
+ import { useCalendar as j } from "./bundle.es65.js";
5
5
  import { attr as m } from "@companix/utils-browser";
6
6
  import { isSameDate as f } from "./bundle.es58.js";
7
7
  import { useLayoutEffect as I } from "react";
@@ -1,16 +1,77 @@
1
- import { useRef as l, useCallback as p } from "react";
2
- import { useEffectWithLayout as d } from "./bundle.es67.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.es12.js";
4
+ import { getMonths as k, getYears as z, DEFAULT_MAX_YEAR as f, DEFAULT_MIN_YEAR as g } from "./bundle.es51.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.es58.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,77 +1,51 @@
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.es51.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.es58.js";
8
- const y = ({
9
- viewDate: n,
10
- onChange: c,
11
- isMonthDisabled: a,
12
- isYearDisabled: m,
13
- onNextMonth: N,
14
- onPrevMonth: v
1
+ import { subMonths as L, addMonths as N, useDayDisableCheker as R } from "./bundle.es58.js";
2
+ import { DEFAULT_MIN_YEAR as w, DEFAULT_MAX_YEAR as A } from "./bundle.es51.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
15
11
  }) => {
16
- const e = n.getFullYear(), r = n.getMonth(), s = "ru", M = u(
17
- (t) => {
18
- c(_(n, t));
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;
19
29
  },
20
- [c, n]
21
- ), x = u(
22
- (t) => {
23
- c(F(n, t));
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;
24
36
  },
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
- ] });
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
+ };
74
48
  };
75
49
  export {
76
- y as CalendarHeader
50
+ X as useCalendar
77
51
  };
@@ -1,51 +1,16 @@
1
- import { subMonths as L, addMonths as N, useDayDisableCheker as R } from "./bundle.es58.js";
2
- import { DEFAULT_MIN_YEAR as w, DEFAULT_MAX_YEAR as A } from "./bundle.es51.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
- };
1
+ import { useRef as l, useCallback as p } from "react";
2
+ import { useEffectWithLayout as d } from "./bundle.es67.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 };
48
13
  };
49
14
  export {
50
- X as useCalendar
15
+ g as useInputPadding
51
16
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@companix/uikit",
3
- "version": "0.0.65",
3
+ "version": "0.0.66",
4
4
  "main": "./dist/bundle.es.js",
5
5
  "module": "./dist/bundle.es.js",
6
6
  "types": "./dist/index.d.ts",