@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.
- package/dist/Select/index.d.ts +11 -3
- package/dist/SelectTags/SelectTags.scss +1 -0
- package/dist/SelectTags/index.d.ts +1 -0
- package/dist/bundle.es24.js +47 -45
- package/dist/bundle.es39.js +3 -3
- package/dist/bundle.es42.js +1 -1
- package/dist/bundle.es43.js +42 -30
- package/dist/bundle.es44.js +30 -74
- package/dist/bundle.es45.js +71 -45
- package/dist/bundle.es46.js +47 -41
- package/dist/bundle.es8.js +53 -51
- package/package.json +2 -3
package/dist/Select/index.d.ts
CHANGED
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { Option } from '../types';
|
|
2
2
|
import { SelectFormProps } from './SelectInput';
|
|
3
|
-
interface
|
|
4
|
-
|
|
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 {};
|
|
@@ -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;
|
package/dist/bundle.es24.js
CHANGED
|
@@ -1,94 +1,96 @@
|
|
|
1
1
|
import { jsx as o, jsxs as c } from "react/jsx-runtime";
|
|
2
|
-
import { useFroozeClosing as
|
|
3
|
-
import { Popover as
|
|
4
|
-
import { OptionItem as
|
|
5
|
-
import { OptionsList as
|
|
6
|
-
import { useState as
|
|
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
|
|
9
|
-
import { attr as
|
|
10
|
-
import { mergeRefs as
|
|
11
|
-
const
|
|
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:
|
|
15
|
-
placeholder:
|
|
14
|
+
closeAfterSelect: C,
|
|
15
|
+
placeholder: N,
|
|
16
16
|
onChange: l,
|
|
17
|
-
emptyText:
|
|
17
|
+
emptyText: R = "Ничего не найдено",
|
|
18
18
|
readOnly: m,
|
|
19
|
-
size:
|
|
19
|
+
size: z = "md",
|
|
20
20
|
value: n,
|
|
21
|
-
inputRef:
|
|
22
|
-
disabled: f
|
|
23
|
-
|
|
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]),
|
|
29
|
-
|
|
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]),
|
|
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 =
|
|
37
|
-
e.defaultPrevented ||
|
|
38
|
-
},
|
|
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
|
-
},
|
|
41
|
-
e.stopPropagation(), l(
|
|
41
|
+
}, $ = (e, t) => {
|
|
42
|
+
e.stopPropagation(), l(T(t));
|
|
42
43
|
};
|
|
43
44
|
return /* @__PURE__ */ o(
|
|
44
|
-
|
|
45
|
+
j,
|
|
45
46
|
{
|
|
46
47
|
minimal: !0,
|
|
47
48
|
ref: u,
|
|
48
49
|
sideOffset: 0,
|
|
49
50
|
matchTarget: "width",
|
|
50
|
-
onAnimationEnd:
|
|
51
|
+
onAnimationEnd: E,
|
|
51
52
|
onOpenAutoFocus: (e) => e.preventDefault(),
|
|
52
53
|
onCloseAutoFocus: (e) => e.preventDefault(),
|
|
53
|
-
content: ({ close: e }) => /* @__PURE__ */ c(
|
|
54
|
-
p.length === 0 && /* @__PURE__ */ o("div", { className: "select-tags-empty", children:
|
|
55
|
-
p.map(({ value: t, title: s, icon:
|
|
56
|
-
|
|
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(
|
|
60
|
+
onClick: () => k(P(t), e),
|
|
60
61
|
title: s,
|
|
61
|
-
icon:
|
|
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:
|
|
71
|
-
onMouseDown:
|
|
72
|
-
"data-size":
|
|
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:
|
|
81
|
+
ref: b,
|
|
80
82
|
role: "listbox",
|
|
81
|
-
"data-readonly":
|
|
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:
|
|
84
|
-
/* @__PURE__ */ o("button", { className: "tag-close-button", onClick: (s) =>
|
|
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:
|
|
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:
|
|
102
|
-
onChange: ({ target: e }) =>
|
|
103
|
+
placeholder: N,
|
|
104
|
+
onChange: ({ target: e }) => D(e.value)
|
|
103
105
|
}
|
|
104
106
|
)
|
|
105
107
|
] }),
|
|
106
|
-
/* @__PURE__ */ o(g, { className: "expand-icon", icon:
|
|
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
|
-
|
|
116
|
+
re as SelectTags
|
|
115
117
|
};
|
package/dist/bundle.es39.js
CHANGED
|
@@ -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.
|
|
3
|
-
import { CalendarHeader as F } from "./bundle.
|
|
4
|
-
import { useCalendar as j } from "./bundle.
|
|
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";
|
package/dist/bundle.es42.js
CHANGED
|
@@ -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.
|
|
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(() => ({}), []);
|
package/dist/bundle.es43.js
CHANGED
|
@@ -1,33 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
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
|
};
|
package/dist/bundle.es44.js
CHANGED
|
@@ -1,77 +1,33 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
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
|
-
|
|
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
|
};
|
package/dist/bundle.es45.js
CHANGED
|
@@ -1,51 +1,77 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
13
|
-
|
|
14
|
-
|
|
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,
|
|
31
|
-
),
|
|
32
|
-
(
|
|
33
|
-
|
|
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,
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
76
|
+
y as CalendarHeader
|
|
51
77
|
};
|
package/dist/bundle.es46.js
CHANGED
|
@@ -1,45 +1,51 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
t
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
50
|
+
X as useCalendar
|
|
45
51
|
};
|
package/dist/bundle.es8.js
CHANGED
|
@@ -1,83 +1,85 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { OptionsList as
|
|
4
|
-
import { OptionItem as
|
|
5
|
-
import { Popover as
|
|
6
|
-
import { useFroozeClosing as
|
|
7
|
-
import { SelectInput as
|
|
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
|
|
9
|
+
const q = (c) => {
|
|
10
10
|
const {
|
|
11
|
-
options:
|
|
12
|
-
onChange:
|
|
13
|
-
value:
|
|
11
|
+
options: t,
|
|
12
|
+
onChange: i,
|
|
13
|
+
value: l,
|
|
14
14
|
minimalOptions: a,
|
|
15
15
|
matchTarget: m = "width",
|
|
16
16
|
children: u,
|
|
17
|
-
disabled:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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:
|
|
24
|
+
option: t[o]
|
|
24
25
|
};
|
|
25
|
-
}, [
|
|
26
|
-
|
|
27
|
-
},
|
|
28
|
-
o.stopPropagation(),
|
|
29
|
-
},
|
|
30
|
-
|
|
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__ */
|
|
33
|
-
|
|
33
|
+
return /* @__PURE__ */ r(
|
|
34
|
+
I,
|
|
34
35
|
{
|
|
35
36
|
minimal: !0,
|
|
36
|
-
ref:
|
|
37
|
+
ref: v,
|
|
37
38
|
sideOffset: 0,
|
|
38
39
|
matchTarget: m,
|
|
39
|
-
onAnimationEnd:
|
|
40
|
+
onAnimationEnd: x,
|
|
40
41
|
onOpenAutoFocus: (o) => o.preventDefault(),
|
|
41
42
|
onCloseAutoFocus: (o) => o.preventDefault(),
|
|
42
|
-
disabled:
|
|
43
|
-
content: ({ close: o }) => /* @__PURE__ */
|
|
43
|
+
disabled: s,
|
|
44
|
+
content: ({ close: o }) => /* @__PURE__ */ r(
|
|
44
45
|
L,
|
|
45
46
|
{
|
|
46
|
-
options:
|
|
47
|
-
active:
|
|
48
|
-
scrollboxRef:
|
|
49
|
-
optionsWrapperRef:
|
|
47
|
+
options: t,
|
|
48
|
+
active: d,
|
|
49
|
+
scrollboxRef: g,
|
|
50
|
+
optionsWrapperRef: C,
|
|
50
51
|
minimalOptions: a,
|
|
51
|
-
onOpened:
|
|
52
|
-
onSelect: (
|
|
52
|
+
onOpened: S,
|
|
53
|
+
onSelect: (n) => P(n, o)
|
|
53
54
|
}
|
|
54
55
|
),
|
|
55
|
-
children: u ?? /* @__PURE__ */
|
|
56
|
-
|
|
56
|
+
children: u ?? /* @__PURE__ */ r(
|
|
57
|
+
B,
|
|
57
58
|
{
|
|
58
|
-
...
|
|
59
|
-
disabled:
|
|
60
|
-
|
|
61
|
-
|
|
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:
|
|
68
|
-
return
|
|
69
|
-
|
|
70
|
-
}, []), /* @__PURE__ */
|
|
71
|
-
|
|
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:
|
|
74
|
-
onClick: () => u?.(
|
|
75
|
-
minimal:
|
|
76
|
-
...
|
|
75
|
+
active: t === e.value,
|
|
76
|
+
onClick: () => u?.(e.value),
|
|
77
|
+
minimal: s,
|
|
78
|
+
...e
|
|
77
79
|
},
|
|
78
|
-
`option-item-${
|
|
80
|
+
`option-item-${e.value}-${f}`
|
|
79
81
|
)) });
|
|
80
82
|
};
|
|
81
83
|
export {
|
|
82
|
-
|
|
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.
|
|
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": {
|