@companix/uikit 0.1.15 → 0.1.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.
Files changed (83) hide show
  1. package/dist/DrawerMobile/MobileDrawer.scss +71 -0
  2. package/dist/DrawerMobile/constants.d.ts +9 -0
  3. package/dist/DrawerMobile/context.d.ts +18 -0
  4. package/dist/DrawerMobile/helpers.d.ts +13 -0
  5. package/dist/DrawerMobile/index.d.ts +17 -0
  6. package/dist/DrawerMobile/types.d.ts +5 -0
  7. package/dist/DrawerMobile/use-prevent-scroll.d.ts +5 -0
  8. package/dist/Popup/index.d.ts +4 -2
  9. package/dist/__helpers/createPopupRegistry.d.ts +4 -0
  10. package/dist/bundle.es.js +112 -109
  11. package/dist/bundle.es10.js +1 -1
  12. package/dist/bundle.es13.js +4 -4
  13. package/dist/bundle.es14.js +4 -4
  14. package/dist/bundle.es15.js +2 -2
  15. package/dist/bundle.es16.js +1 -1
  16. package/dist/bundle.es17.js +1 -1
  17. package/dist/bundle.es19.js +1 -1
  18. package/dist/bundle.es22.js +1 -1
  19. package/dist/bundle.es23.js +260 -13
  20. package/dist/bundle.es24.js +14 -21
  21. package/dist/bundle.es25.js +20 -37
  22. package/dist/bundle.es26.js +38 -21
  23. package/dist/bundle.es27.js +20 -18
  24. package/dist/bundle.es28.js +18 -20
  25. package/dist/bundle.es29.js +20 -43
  26. package/dist/bundle.es30.js +37 -114
  27. package/dist/bundle.es31.js +119 -72
  28. package/dist/bundle.es32.js +68 -38
  29. package/dist/bundle.es33.js +42 -10
  30. package/dist/bundle.es34.js +11 -85
  31. package/dist/bundle.es35.js +85 -19
  32. package/dist/bundle.es36.js +20 -7
  33. package/dist/bundle.es37.js +7 -3
  34. package/dist/bundle.es38.js +3 -23
  35. package/dist/bundle.es39.js +16 -45
  36. package/dist/bundle.es40.js +51 -56
  37. package/dist/bundle.es41.js +57 -162
  38. package/dist/bundle.es42.js +160 -79
  39. package/dist/bundle.es43.js +81 -7
  40. package/dist/bundle.es44.js +7 -35
  41. package/dist/bundle.es45.js +33 -20
  42. package/dist/bundle.es46.js +19 -47
  43. package/dist/bundle.es47.js +49 -11
  44. package/dist/bundle.es48.js +11 -13
  45. package/dist/bundle.es49.js +13 -13
  46. package/dist/bundle.es50.js +13 -30
  47. package/dist/bundle.es51.js +29 -25
  48. package/dist/bundle.es52.js +17 -29
  49. package/dist/bundle.es53.js +36 -48
  50. package/dist/bundle.es54.js +49 -50
  51. package/dist/bundle.es55.js +56 -8
  52. package/dist/bundle.es56.js +8 -26
  53. package/dist/bundle.es57.js +27 -5
  54. package/dist/bundle.es58.js +5 -66
  55. package/dist/bundle.es59.js +66 -23
  56. package/dist/bundle.es60.js +22 -23
  57. package/dist/bundle.es61.js +24 -88
  58. package/dist/bundle.es62.js +88 -18
  59. package/dist/bundle.es63.js +17 -92
  60. package/dist/bundle.es64.js +92 -73
  61. package/dist/bundle.es65.js +73 -23
  62. package/dist/bundle.es66.js +20 -35
  63. package/dist/bundle.es67.js +37 -68
  64. package/dist/bundle.es68.js +23 -10
  65. package/dist/bundle.es69.js +78 -42
  66. package/dist/bundle.es70.js +93 -33
  67. package/dist/bundle.es71.js +10 -66
  68. package/dist/bundle.es72.js +69 -40
  69. package/dist/bundle.es73.js +10 -14
  70. package/dist/bundle.es74.js +43 -32
  71. package/dist/bundle.es75.js +32 -69
  72. package/dist/bundle.es76.js +65 -74
  73. package/dist/bundle.es77.js +39 -47
  74. package/dist/bundle.es78.js +14 -13
  75. package/dist/bundle.es79.js +32 -14
  76. package/dist/bundle.es80.js +72 -0
  77. package/dist/bundle.es81.js +77 -0
  78. package/dist/bundle.es82.js +51 -0
  79. package/dist/bundle.es83.js +16 -0
  80. package/dist/bundle.es84.js +16 -0
  81. package/dist/index.d.ts +3 -1
  82. package/dist/index.scss +1 -0
  83. package/package.json +1 -1
@@ -1,25 +1,68 @@
1
- import { useState as u, useEffect as d } from "react";
2
- const v = ({ baseId: r, value: e, containerRef: o }) => {
3
- const [l, n] = u({});
4
- return d(() => {
5
- const t = { observer: null };
6
- if (o.current) {
7
- const c = `#${h(r, e)}`, s = o.current.querySelector(c);
8
- s != null ? (t.observer = new ResizeObserver(() => {
9
- const { clientHeight: i, clientWidth: a, offsetLeft: f, offsetTop: b } = s;
10
- n({
11
- width: a,
12
- height: i,
13
- transform: `translateX(${Math.floor(f)}px) translateY(${Math.floor(b)}px)`
14
- });
15
- }), t.observer.observe(s)) : n({ display: "none" });
16
- }
17
- return () => {
18
- t.observer && t.observer.disconnect();
19
- };
20
- }, [e]), l;
21
- }, h = (r, e) => `uikit-tab-${r}-trigger-${e}`;
1
+ import { useMemo as i, useCallback as f } from "react";
2
+ const D = (e, t) => e.getDate() === t.getDate() && e.getMonth() === t.getMonth() && e.getFullYear() === t.getFullYear(), l = 1, y = (e, { weekStartsOn: t = l }) => {
3
+ const n = new Date(e), s = n.getDay(), r = (s < t ? 7 : 0) + s - t;
4
+ return n.setDate(n.getDate() - r), n.setHours(0, 0, 0, 0), n;
5
+ }, F = (e, { weekStartsOn: t = l }) => {
6
+ const n = new Date(e), s = n.getDay(), r = (s < t ? -7 : 0) + 6 - (s - t);
7
+ return n.setDate(n.getDate() + r), n.setHours(23, 59, 59, 999), n;
8
+ }, h = (e) => {
9
+ const t = new Date(e);
10
+ return t.setHours(0, 0, 0, 0), t;
11
+ }, M = (e) => {
12
+ const t = new Date(e);
13
+ return t.setHours(23, 59, 59, 999), t;
14
+ };
15
+ function g(e, t = {}) {
16
+ const { min: n, max: s, withTime: r = !1 } = t;
17
+ return !r && (n && D(e, n) || s && D(e, s)) ? !1 : !!(n && e < n || s && e > s);
18
+ }
19
+ const m = (e, t) => {
20
+ const n = new Date(e);
21
+ if (!t)
22
+ return n;
23
+ const s = n.getDate(), r = new Date(e);
24
+ r.setMonth(n.getMonth() + t + 1, 0);
25
+ const a = r.getDate();
26
+ return s >= a ? r : (n.setFullYear(r.getFullYear(), r.getMonth(), s), n);
27
+ }, Y = (e, t) => m(e, -t), w = (e) => {
28
+ const t = new Date(e), n = new Date(t);
29
+ return n.setFullYear(t.getFullYear(), t.getMonth() + 1, 0), n.setHours(0, 0, 0, 0), n.getDate();
30
+ }, x = (e, t) => {
31
+ const n = new Date(e);
32
+ return n.setFullYear(t), n;
33
+ }, H = (e, t) => {
34
+ const n = new Date(e), s = n.getFullYear(), r = n.getDate(), a = new Date(e);
35
+ a.setFullYear(s, t, 15), a.setHours(0, 0, 0, 0);
36
+ const o = w(a);
37
+ return n.setMonth(t, Math.min(r, o)), n;
38
+ }, b = (e) => {
39
+ const { disableFuture: t, disablePast: n, maxDateTime: s, minDateTime: r, shouldDisableDate: a } = e;
40
+ return (o, c) => {
41
+ const u = /* @__PURE__ */ new Date();
42
+ return a ? a(o) : t ? h(o) > u : n ? M(o) < u : r || s ? g(o, { min: r, max: s, withTime: c }) : !1;
43
+ };
44
+ }, O = (e) => {
45
+ const t = i(() => b(e), [
46
+ e.disableFuture,
47
+ e.disablePast,
48
+ e.shouldDisableDate,
49
+ e.minDateTime,
50
+ e.maxDateTime
51
+ ]);
52
+ return f(t, [t]);
53
+ };
22
54
  export {
23
- h as makeTabId,
24
- v as useTabSlider
55
+ l as MONDAY,
56
+ m as addMonths,
57
+ b as createDayDisableChecker,
58
+ M as endOfDay,
59
+ F as endOfWeek,
60
+ g as isDayMinMaxRestricted,
61
+ D as isSameDate,
62
+ H as setMonth,
63
+ x as setYear,
64
+ h as startOfDay,
65
+ y as startOfWeek,
66
+ Y as subMonths,
67
+ O as useDayDisableCheker
25
68
  };
@@ -1,26 +1,25 @@
1
- import { useRef as s, useCallback as c } from "react";
2
- const p = () => {
3
- const t = s(null), r = s({ cb: null }), i = c(() => {
4
- if (t.current && t.current.parentElement) {
5
- const e = t.current.parentElement, u = e.style.getPropertyValue("--radix-popper-anchor-width"), n = e.style.getPropertyValue("transform"), o = new MutationObserver(() => {
6
- e.style.transform !== n && e.style.setProperty("transform", n);
7
- });
8
- o.observe(e, {
9
- attributes: !0,
10
- attributeFilter: ["style"]
11
- }), r.current.cb = () => {
12
- o.disconnect();
13
- }, t.current.style.setProperty("--radix-popover-trigger-width", u);
1
+ import { useState as u, useEffect as d } from "react";
2
+ const v = ({ baseId: r, value: e, containerRef: o }) => {
3
+ const [l, n] = u({});
4
+ return d(() => {
5
+ const t = { observer: null };
6
+ if (o.current) {
7
+ const c = `#${h(r, e)}`, s = o.current.querySelector(c);
8
+ s != null ? (t.observer = new ResizeObserver(() => {
9
+ const { clientHeight: i, clientWidth: a, offsetLeft: f, offsetTop: b } = s;
10
+ n({
11
+ width: a,
12
+ height: i,
13
+ transform: `translateX(${Math.floor(f)}px) translateY(${Math.floor(b)}px)`
14
+ });
15
+ }), t.observer.observe(s)) : n({ display: "none" });
14
16
  }
15
- }, []), l = c(() => {
16
- r.current.cb && (r.current.cb(), r.current.cb = null);
17
- }, []);
18
- return {
19
- popoverRef: t,
20
- handleAnimationEnd: l,
21
- froozePopoverPosition: i
22
- };
23
- };
17
+ return () => {
18
+ t.observer && t.observer.disconnect();
19
+ };
20
+ }, [e]), l;
21
+ }, h = (r, e) => `uikit-tab-${r}-trigger-${e}`;
24
22
  export {
25
- p as useFroozeClosing
23
+ h as makeTabId,
24
+ v as useTabSlider
26
25
  };
@@ -1,90 +1,26 @@
1
- import { jsxs as o, jsx as n } from "react/jsx-runtime";
2
- import w from "classnames";
3
- import { attr as s } from "@companix/utils-browser";
4
- import { forwardRef as y, useRef as D, useCallback as S } from "react";
5
- import { VisuallyHidden as T } from "@radix-ui/react-visually-hidden";
6
- import { mergeRefs as j } from "react-merge-refs";
7
- import { SelectRightElements as z } from "./bundle.es68.js";
8
- const W = y(
9
- ({
10
- required: a,
11
- size: i,
12
- fill: u,
13
- leftElement: l,
14
- className: d,
15
- value: c,
16
- clearButton: m,
17
- placeholder: p,
18
- clearButtonIcon: f,
19
- disabled: r,
20
- onClear: h,
21
- inputRef: C,
22
- onClick: I,
23
- ...N
24
- }, k) => {
25
- const e = D(null), v = S(
26
- (t) => {
27
- if (!e.current || !document)
28
- return;
29
- t.target !== e.current && (e.current.click(), document.activeElement !== e.current && e.current.focus());
30
- },
31
- [e]
32
- ), F = (t) => {
33
- document && document.activeElement === e.current && t.preventDefault();
34
- }, g = (t) => {
35
- r || v(t);
36
- }, R = (t) => {
37
- F(t);
38
- }, x = (t) => {
39
- e.current && e.current.focus(), h?.(t);
40
- };
41
- return /* @__PURE__ */ o(
42
- "div",
43
- {
44
- ref: k,
45
- className: w("form select", d),
46
- "data-size": i ?? "md",
47
- "data-fill": s(u),
48
- "data-required": s(a),
49
- "data-disabled": s(r),
50
- onMouseDown: R,
51
- onClick: g,
52
- ...N,
53
- children: [
54
- /* @__PURE__ */ o("div", { className: "select-layout form-input", children: [
55
- l && /* @__PURE__ */ n("div", { className: "select-element", children: l }),
56
- /* @__PURE__ */ n("div", { className: "select-content", children: /* @__PURE__ */ o("div", { className: "select-content-text", "aria-disabled": r, children: [
57
- !c && /* @__PURE__ */ n("span", { className: "select-placeholder", children: p }),
58
- c
59
- ] }) }),
60
- /* @__PURE__ */ n("div", { className: "select-element", children: /* @__PURE__ */ n(
61
- z,
62
- {
63
- clearButton: m,
64
- value: !!c,
65
- clearButtonIcon: f,
66
- onClear: x
67
- }
68
- ) })
69
- ] }),
70
- /* @__PURE__ */ n(T, { asChild: !0, children: /* @__PURE__ */ n(
71
- "input",
72
- {
73
- ref: j([C, e]),
74
- autoComplete: "off",
75
- autoCapitalize: "none",
76
- autoCorrect: "off",
77
- spellCheck: "false",
78
- "aria-autocomplete": "none",
79
- onClick: I,
80
- readOnly: !0
81
- }
82
- ) })
83
- ]
84
- }
85
- );
86
- }
87
- );
1
+ import { useRef as s, useCallback as c } from "react";
2
+ const p = () => {
3
+ const t = s(null), r = s({ cb: null }), i = c(() => {
4
+ if (t.current && t.current.parentElement) {
5
+ const e = t.current.parentElement, u = e.style.getPropertyValue("--radix-popper-anchor-width"), n = e.style.getPropertyValue("transform"), o = new MutationObserver(() => {
6
+ e.style.transform !== n && e.style.setProperty("transform", n);
7
+ });
8
+ o.observe(e, {
9
+ attributes: !0,
10
+ attributeFilter: ["style"]
11
+ }), r.current.cb = () => {
12
+ o.disconnect();
13
+ }, t.current.style.setProperty("--radix-popover-trigger-width", u);
14
+ }
15
+ }, []), l = c(() => {
16
+ r.current.cb && (r.current.cb(), r.current.cb = null);
17
+ }, []);
18
+ return {
19
+ popoverRef: t,
20
+ handleAnimationEnd: l,
21
+ froozePopoverPosition: i
22
+ };
23
+ };
88
24
  export {
89
- W as SelectInput
25
+ p as useFroozeClosing
90
26
  };
@@ -1,20 +1,90 @@
1
- import { useRef as u, useCallback as T } from "react";
2
- const g = () => {
3
- const l = u(null), t = u(null);
4
- return { scrollToElement: T(
5
- (r, f) => {
6
- const o = l.current, s = t.current;
7
- if (!o || !s || r < 0 || r > s.children.length)
8
- return;
9
- const c = s.children[r];
10
- if (!c)
11
- return;
12
- const n = o.offsetHeight, i = o.scrollTop, e = c.offsetTop, p = c.offsetHeight;
13
- f === "center" ? o.scrollTop = e - n / 2 + p / 2 : f === "top" ? o.scrollTop = e : e + p > n + i ? o.scrollTop = e - n + p : e < i && (o.scrollTop = e);
14
- },
15
- [t, l]
16
- ), scrollBoxRef: l, optionsWrapperRef: t };
17
- };
1
+ import { jsxs as o, jsx as n } from "react/jsx-runtime";
2
+ import w from "classnames";
3
+ import { attr as s } from "@companix/utils-browser";
4
+ import { forwardRef as y, useRef as D, useCallback as S } from "react";
5
+ import { VisuallyHidden as T } from "@radix-ui/react-visually-hidden";
6
+ import { mergeRefs as j } from "react-merge-refs";
7
+ import { SelectRightElements as z } from "./bundle.es73.js";
8
+ const W = y(
9
+ ({
10
+ required: a,
11
+ size: i,
12
+ fill: u,
13
+ leftElement: l,
14
+ className: d,
15
+ value: c,
16
+ clearButton: m,
17
+ placeholder: p,
18
+ clearButtonIcon: f,
19
+ disabled: r,
20
+ onClear: h,
21
+ inputRef: C,
22
+ onClick: I,
23
+ ...N
24
+ }, k) => {
25
+ const e = D(null), v = S(
26
+ (t) => {
27
+ if (!e.current || !document)
28
+ return;
29
+ t.target !== e.current && (e.current.click(), document.activeElement !== e.current && e.current.focus());
30
+ },
31
+ [e]
32
+ ), F = (t) => {
33
+ document && document.activeElement === e.current && t.preventDefault();
34
+ }, g = (t) => {
35
+ r || v(t);
36
+ }, R = (t) => {
37
+ F(t);
38
+ }, x = (t) => {
39
+ e.current && e.current.focus(), h?.(t);
40
+ };
41
+ return /* @__PURE__ */ o(
42
+ "div",
43
+ {
44
+ ref: k,
45
+ className: w("form select", d),
46
+ "data-size": i ?? "md",
47
+ "data-fill": s(u),
48
+ "data-required": s(a),
49
+ "data-disabled": s(r),
50
+ onMouseDown: R,
51
+ onClick: g,
52
+ ...N,
53
+ children: [
54
+ /* @__PURE__ */ o("div", { className: "select-layout form-input", children: [
55
+ l && /* @__PURE__ */ n("div", { className: "select-element", children: l }),
56
+ /* @__PURE__ */ n("div", { className: "select-content", children: /* @__PURE__ */ o("div", { className: "select-content-text", "aria-disabled": r, children: [
57
+ !c && /* @__PURE__ */ n("span", { className: "select-placeholder", children: p }),
58
+ c
59
+ ] }) }),
60
+ /* @__PURE__ */ n("div", { className: "select-element", children: /* @__PURE__ */ n(
61
+ z,
62
+ {
63
+ clearButton: m,
64
+ value: !!c,
65
+ clearButtonIcon: f,
66
+ onClear: x
67
+ }
68
+ ) })
69
+ ] }),
70
+ /* @__PURE__ */ n(T, { asChild: !0, children: /* @__PURE__ */ n(
71
+ "input",
72
+ {
73
+ ref: j([C, e]),
74
+ autoComplete: "off",
75
+ autoCapitalize: "none",
76
+ autoCorrect: "off",
77
+ spellCheck: "false",
78
+ "aria-autocomplete": "none",
79
+ onClick: I,
80
+ readOnly: !0
81
+ }
82
+ ) })
83
+ ]
84
+ }
85
+ );
86
+ }
87
+ );
18
88
  export {
19
- g as useScrollListController
89
+ W as SelectInput
20
90
  };
@@ -1,95 +1,20 @@
1
- import { jsx as i, jsxs as k } from "react/jsx-runtime";
2
- import { useMemo as y, useEffect as C } from "react";
3
- import { Spinner as P } from "./bundle.es7.js";
4
- import { OptionItem as L } from "./bundle.es16.js";
5
- import { OptionsList as T } from "./bundle.es18.js";
6
- import { Icon as R } from "./bundle.es35.js";
7
- import { faPlus as S } from "@companix/icons-solid";
8
- const b = () => ({ isLoading: !1, options: [] }), I = (e) => {
9
- const { onOptionsLoaded: n, useOptions: s = b, options: o } = e, t = s();
10
- return C(() => {
11
- t.options.length > 0 && n?.(t.options);
12
- }, [t.options]), o ? { options: o, isLoading: !1 } : t;
13
- }, H = (e) => {
14
- const {
15
- isActive: n,
16
- emptyText: s,
17
- isLoading: o,
18
- scrollboxRef: t,
19
- optionsWrapperRef: d,
20
- addOption: p,
21
- onOpened: f,
22
- onSelect: O,
23
- minimalOptions: u,
24
- filterOptions: r,
25
- disableFiltering: l,
26
- close: c,
27
- ...m
28
- } = e, { emptyText: x, options: a, isLoading: g } = I(m), v = y(() => r && !l ? a.filter(r) : a, [a, r, l]);
29
- return g ?? o ? /* @__PURE__ */ i("div", { className: "select-popover-loading", children: /* @__PURE__ */ i(P, { size: 24 }) }) : /* @__PURE__ */ i(
30
- N,
31
- {
32
- options: v,
33
- isActive: n,
34
- emptyText: x ?? s,
35
- scrollboxRef: t,
36
- optionsWrapperRef: d,
37
- minimalOptions: u,
38
- addOption: p,
39
- onOpened: f,
40
- onSelect: O,
41
- close: c
42
- }
43
- );
44
- }, N = (e) => {
45
- const {
46
- isActive: n,
47
- onOpened: s,
48
- addOption: o,
49
- scrollboxRef: t,
50
- optionsWrapperRef: d,
51
- options: p,
52
- onSelect: f,
53
- minimalOptions: O,
54
- emptyText: u = "Ничего не найдено",
55
- close: r
56
- } = e;
57
- C(() => {
58
- s?.(p.findIndex(({ value: c }) => n(c)));
59
- }, []);
60
- const l = o ? /* @__PURE__ */ i(
61
- L,
62
- {
63
- className: "select-add-option",
64
- icon: /* @__PURE__ */ i(R, { icon: S }),
65
- title: o.text,
66
- onClick: o.onClick,
67
- onClickCapture: () => {
68
- o.closeOnClick && r();
69
- }
70
- }
71
- ) : void 0;
72
- return /* @__PURE__ */ k(T, { scrollboxRef: t, optionsWrapperRef: d, maxHeight: 300, children: [
73
- (o?.position === void 0 || o?.position === "first") && l,
74
- p.length === 0 && !o && /* @__PURE__ */ i("div", { className: "select-tags-noneresults", children: u }),
75
- p.map(({ title: c, value: m, className: x, icon: a, disabled: g, label: v }, h) => /* @__PURE__ */ i(
76
- L,
77
- {
78
- active: n(m),
79
- onClick: () => f?.(m),
80
- minimal: O,
81
- disabled: g,
82
- className: x,
83
- title: c,
84
- label: v,
85
- icon: a
86
- },
87
- `select-option-${h}`
88
- )),
89
- o?.position === "last" && l
90
- ] });
1
+ import { useRef as u, useCallback as T } from "react";
2
+ const g = () => {
3
+ const l = u(null), t = u(null);
4
+ return { scrollToElement: T(
5
+ (r, f) => {
6
+ const o = l.current, s = t.current;
7
+ if (!o || !s || r < 0 || r > s.children.length)
8
+ return;
9
+ const c = s.children[r];
10
+ if (!c)
11
+ return;
12
+ const n = o.offsetHeight, i = o.scrollTop, e = c.offsetTop, p = c.offsetHeight;
13
+ f === "center" ? o.scrollTop = e - n / 2 + p / 2 : f === "top" ? o.scrollTop = e : e + p > n + i ? o.scrollTop = e - n + p : e < i && (o.scrollTop = e);
14
+ },
15
+ [t, l]
16
+ ), scrollBoxRef: l, optionsWrapperRef: t };
91
17
  };
92
18
  export {
93
- H as OptionsPopover,
94
- N as SelectOptionsList
19
+ g as useScrollListController
95
20
  };
@@ -1,76 +1,95 @@
1
- import { clamp as m } from "@companix/utils-browser";
2
- import { formatTime as i } from "@companix/utils-js";
3
- const d = (n, r) => new Date(r, n, 0).getDate(), u = (n, r) => new Date(r, n - 1, 1).getDay(), g = (n) => n === 0 ? 6 : n - 1, D = (n) => new Array(n).fill(0), T = {
4
- add: (n, r) => n.includes(r) ? [...n] : [...n, r],
5
- remove: (n, r) => n.filter((t) => r !== t)
6
- }, p = (n) => ({
7
- day: n.getDate(),
8
- month: n.getMonth() + 1,
9
- year: n.getFullYear()
10
- }), A = ({ min: n, max: r }) => (t) => {
11
- if (n.year === t.year) {
12
- if (t.month !== 0 && t.month < n.month)
13
- return t.month = 0, t.day = 0, t;
14
- if (t.month === n.month && t.day < n.day && t.day !== 0)
15
- return t.day = 0, t;
16
- }
17
- if (r.year === t.year) {
18
- if (t.month !== 0 && t.month > r.month)
19
- return t.month = 0, t.day = 0, t;
20
- if (t.month === r.month && t.day > r.day && t.day !== 0)
21
- return t.day = 0, t;
22
- }
23
- }, M = ["Пн", "Вт", "Ср", "Чт", "Пт", "Сб", "Вс"], w = [
24
- "Январь",
25
- "Февраль",
26
- "Март",
27
- "Апрель",
28
- "Май",
29
- "Июнь",
30
- "Июль",
31
- "Август",
32
- "Сентябрь",
33
- "Октябрь",
34
- "Ноябрь",
35
- "Декабрь"
36
- ], c = 9999, a = 100, F = (n, r) => {
37
- const t = [], o = m(n - r, a, c), e = m(n + r, a, c);
38
- for (let s = o; s <= e; s++)
39
- t.push({ title: String(s).padStart(4, "0"), value: s });
40
- return t;
41
- }, Y = (n) => {
42
- const r = [], t = new Intl.DateTimeFormat(n, {
43
- month: "long"
44
- });
45
- for (let o = 0; o < 12; o++)
46
- r.push({
47
- title: t.format(new Date(2023, o, 15)),
48
- value: o
49
- });
50
- return r;
51
- }, E = (n, r) => r.reduce((t, o) => t.replaceAll(o, ""), n.trim()), _ = ({ hours: n, minutes: r }, t = ":") => [i(n), i(r)].join(t), h = (n, r = ":") => {
52
- const [t, o] = [i(n.hours), i(n.minutes)], e = [t, o].join(r);
53
- return { title: e, value: e, hours: t, minutes: o };
54
- }, I = (n, r = ":") => {
55
- const t = { minutes: -n, hours: 0 };
56
- return Array.from({ length: 1440 / n }).map(() => (t.minutes += n, t.minutes === 60 && (t.minutes = 0, t.hours++), h(t, r)));
1
+ import { jsx as i, jsxs as k } from "react/jsx-runtime";
2
+ import { useMemo as y, useEffect as C } from "react";
3
+ import { Spinner as P } from "./bundle.es7.js";
4
+ import { OptionItem as L } from "./bundle.es16.js";
5
+ import { OptionsList as T } from "./bundle.es18.js";
6
+ import { Icon as R } from "./bundle.es36.js";
7
+ import { faPlus as S } from "@companix/icons-solid";
8
+ const b = () => ({ isLoading: !1, options: [] }), I = (e) => {
9
+ const { onOptionsLoaded: n, useOptions: s = b, options: o } = e, t = s();
10
+ return C(() => {
11
+ t.options.length > 0 && n?.(t.options);
12
+ }, [t.options]), o ? { options: o, isLoading: !1 } : t;
13
+ }, H = (e) => {
14
+ const {
15
+ isActive: n,
16
+ emptyText: s,
17
+ isLoading: o,
18
+ scrollboxRef: t,
19
+ optionsWrapperRef: d,
20
+ addOption: p,
21
+ onOpened: f,
22
+ onSelect: O,
23
+ minimalOptions: u,
24
+ filterOptions: r,
25
+ disableFiltering: l,
26
+ close: c,
27
+ ...m
28
+ } = e, { emptyText: x, options: a, isLoading: g } = I(m), v = y(() => r && !l ? a.filter(r) : a, [a, r, l]);
29
+ return g ?? o ? /* @__PURE__ */ i("div", { className: "select-popover-loading", children: /* @__PURE__ */ i(P, { size: 24 }) }) : /* @__PURE__ */ i(
30
+ N,
31
+ {
32
+ options: v,
33
+ isActive: n,
34
+ emptyText: x ?? s,
35
+ scrollboxRef: t,
36
+ optionsWrapperRef: d,
37
+ minimalOptions: u,
38
+ addOption: p,
39
+ onOpened: f,
40
+ onSelect: O,
41
+ close: c
42
+ }
43
+ );
44
+ }, N = (e) => {
45
+ const {
46
+ isActive: n,
47
+ onOpened: s,
48
+ addOption: o,
49
+ scrollboxRef: t,
50
+ optionsWrapperRef: d,
51
+ options: p,
52
+ onSelect: f,
53
+ minimalOptions: O,
54
+ emptyText: u = "Ничего не найдено",
55
+ close: r
56
+ } = e;
57
+ C(() => {
58
+ s?.(p.findIndex(({ value: c }) => n(c)));
59
+ }, []);
60
+ const l = o ? /* @__PURE__ */ i(
61
+ L,
62
+ {
63
+ className: "select-add-option",
64
+ icon: /* @__PURE__ */ i(R, { icon: S }),
65
+ title: o.text,
66
+ onClick: o.onClick,
67
+ onClickCapture: () => {
68
+ o.closeOnClick && r();
69
+ }
70
+ }
71
+ ) : void 0;
72
+ return /* @__PURE__ */ k(T, { scrollboxRef: t, optionsWrapperRef: d, maxHeight: 300, children: [
73
+ (o?.position === void 0 || o?.position === "first") && l,
74
+ p.length === 0 && !o && /* @__PURE__ */ i("div", { className: "select-tags-noneresults", children: u }),
75
+ p.map(({ title: c, value: m, className: x, icon: a, disabled: g, label: v }, h) => /* @__PURE__ */ i(
76
+ L,
77
+ {
78
+ active: n(m),
79
+ onClick: () => f?.(m),
80
+ minimal: O,
81
+ disabled: g,
82
+ className: x,
83
+ title: c,
84
+ label: v,
85
+ icon: a
86
+ },
87
+ `select-option-${h}`
88
+ )),
89
+ o?.position === "last" && l
90
+ ] });
57
91
  };
58
92
  export {
59
- c as DEFAULT_MAX_YEAR,
60
- a as DEFAULT_MIN_YEAR,
61
- w as DefaultMonths,
62
- T as arrays,
63
- _ as convertTimeToOption,
64
- A as createDateValidation,
65
- D as createVoids,
66
- p as dateToFormat,
67
- g as getDayIndex,
68
- u as getFirstDay,
69
- d as getMonthMaxDay,
70
- Y as getMonths,
71
- h as getTimeValue,
72
- I as getTimesOptions,
73
- F as getYears,
74
- E as removeDigits,
75
- M as weeks
93
+ H as OptionsPopover,
94
+ N as SelectOptionsList
76
95
  };