@lazar-ui/kit 0.3.0 → 0.5.0
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/CHANGELOG.md +57 -0
- package/dist/Button-BYnrV9av.mjs +52 -0
- package/dist/Button.css +1 -0
- package/dist/Chip-DLfYGIQG.mjs +51 -0
- package/dist/Chip.css +1 -0
- package/dist/button.js +2 -50
- package/dist/chip.d.ts +37 -0
- package/dist/chip.js +4 -0
- package/dist/dialog.js +2 -2
- package/dist/drawer.js +21 -21
- package/dist/input.css +1 -1
- package/dist/input.d.ts +16 -0
- package/dist/input.js +167 -76
- package/dist/lazar-ui-provider.d.ts +29 -9
- package/dist/lazar-ui-provider.js +2 -2
- package/dist/pagination.js +19 -19
- package/dist/radio.css +1 -0
- package/dist/radio.d.ts +51 -0
- package/dist/radio.js +113 -0
- package/dist/select.js +28 -28
- package/dist/table.css +1 -1
- package/dist/table.d.ts +59 -9
- package/dist/table.js +71 -32
- package/dist/useLocale-CJh-krrY.mjs +106 -0
- package/package.json +3 -5
- package/dist/button.css +0 -1
- package/dist/useLocale-DdHNhmvT.mjs +0 -70
package/dist/input.js
CHANGED
|
@@ -1,120 +1,211 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { useState as
|
|
4
|
-
import { g as
|
|
5
|
-
import { I as
|
|
6
|
-
import { u as
|
|
1
|
+
import { jsxs as v, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import z from "clsx";
|
|
3
|
+
import { useState as N, useCallback as _ } from "react";
|
|
4
|
+
import { g as S } from "./getVariantClassName-D7Nhpuec.mjs";
|
|
5
|
+
import { I as Y } from "./Icon-DsTlU3j3.mjs";
|
|
6
|
+
import { u as A } from "./useLocale-CJh-krrY.mjs";
|
|
7
7
|
import './input.css';const m = {
|
|
8
8
|
INPUT: "Input",
|
|
9
|
+
INPUT_DATE: "InputDate",
|
|
9
10
|
INPUT_EMAIL: "InputEmail",
|
|
10
11
|
INPUT_NUMBER: "InputNumber",
|
|
11
12
|
INPUT_PASSWORD: "InputPassword",
|
|
12
13
|
INPUT_PHONE: "InputPhone"
|
|
13
|
-
},
|
|
14
|
-
root:
|
|
15
|
-
invalid:
|
|
16
|
-
disabled:
|
|
17
|
-
sizeSm:
|
|
18
|
-
sizeMd:
|
|
19
|
-
sizeLg:
|
|
14
|
+
}, E = "_root_8a405_17", U = "_invalid_8a405_36", C = "_disabled_8a405_42", B = "_sizeSm_8a405_56", L = "_sizeMd_8a405_60", k = "_sizeLg_8a405_64", x = "_control_8a405_68", O = "_before_8a405_100", $ = "_after_8a405_101", H = "_togglePassword_8a405_109", p = {
|
|
15
|
+
root: E,
|
|
16
|
+
invalid: U,
|
|
17
|
+
disabled: C,
|
|
18
|
+
sizeSm: B,
|
|
19
|
+
sizeMd: L,
|
|
20
|
+
sizeLg: k,
|
|
20
21
|
control: x,
|
|
21
|
-
before:
|
|
22
|
-
after:
|
|
23
|
-
togglePassword:
|
|
24
|
-
},
|
|
25
|
-
const { ref: e, invalid:
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
before: O,
|
|
23
|
+
after: $,
|
|
24
|
+
togglePassword: H
|
|
25
|
+
}, f = (s) => {
|
|
26
|
+
const { ref: e, invalid: t = !1, size: o = "md", before: r, after: n, className: a, onChange: l, onBlur: c, onFocus: u, ...d } = s, g = z(
|
|
27
|
+
p.root,
|
|
28
|
+
S("size", o, p),
|
|
28
29
|
{
|
|
29
|
-
[
|
|
30
|
-
[
|
|
30
|
+
[p.disabled]: d.disabled === !0,
|
|
31
|
+
[p.invalid]: t
|
|
31
32
|
},
|
|
32
|
-
|
|
33
|
-
),
|
|
34
|
-
|
|
33
|
+
a
|
|
34
|
+
), I = (h) => {
|
|
35
|
+
l?.(h.target.value);
|
|
35
36
|
};
|
|
36
|
-
return /* @__PURE__ */
|
|
37
|
-
r && /* @__PURE__ */
|
|
38
|
-
/* @__PURE__ */
|
|
39
|
-
|
|
37
|
+
return /* @__PURE__ */ v("div", { className: g, children: [
|
|
38
|
+
r && /* @__PURE__ */ i("span", { className: p.before, children: r }),
|
|
39
|
+
/* @__PURE__ */ i("input", { ref: e, className: p.control, onChange: I, onBlur: c, onFocus: u, ...d }),
|
|
40
|
+
n && /* @__PURE__ */ i("span", { className: p.after, children: n })
|
|
40
41
|
] });
|
|
41
42
|
};
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
f.displayName = m.INPUT;
|
|
44
|
+
const R = 8;
|
|
45
|
+
function j(s, e) {
|
|
46
|
+
const t = s.replace(/\D/g, "").slice(0, R);
|
|
47
|
+
if (!t)
|
|
48
|
+
return "";
|
|
49
|
+
const o = e.replace(/[A-Z]/g, "").charAt(0), r = F(e);
|
|
50
|
+
let n = "";
|
|
51
|
+
for (let a = 0; a < t.length; a++)
|
|
52
|
+
r.has(a) && (n += o), n += t[a];
|
|
53
|
+
return n;
|
|
54
|
+
}
|
|
55
|
+
function F(s) {
|
|
56
|
+
switch (s) {
|
|
57
|
+
case "DD/MM/YYYY":
|
|
58
|
+
case "MM/DD/YYYY":
|
|
59
|
+
case "DD.MM.YYYY":
|
|
60
|
+
case "MM.DD.YYYY":
|
|
61
|
+
return /* @__PURE__ */ new Set([2, 4]);
|
|
62
|
+
case "YYYY-MM-DD":
|
|
63
|
+
return /* @__PURE__ */ new Set([4, 6]);
|
|
64
|
+
default:
|
|
65
|
+
return /* @__PURE__ */ new Set([2, 4]);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function V(s) {
|
|
69
|
+
const e = s.replace(/\D/g, "").slice(0, 11);
|
|
45
70
|
if (!e)
|
|
46
71
|
return "";
|
|
47
|
-
let
|
|
48
|
-
return e.length > 1 && (
|
|
72
|
+
let t = "+7";
|
|
73
|
+
return e.length > 1 && (t += ` (${e.slice(1, 4)}`), e.length >= 4 && (t += `) ${e.slice(4, 7)}`), e.length >= 7 && (t += `-${e.slice(7, 9)}`), e.length >= 9 && (t += `-${e.slice(9, 11)}`), t;
|
|
74
|
+
}
|
|
75
|
+
const W = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
76
|
+
function Z(s, e) {
|
|
77
|
+
const o = e.replace(/[A-Z]/g, "").charAt(0);
|
|
78
|
+
if (!o)
|
|
79
|
+
return !1;
|
|
80
|
+
const r = s.split(o);
|
|
81
|
+
if (r.length !== 3)
|
|
82
|
+
return !1;
|
|
83
|
+
const [n, a, l] = r;
|
|
84
|
+
if (!n || !a || !l)
|
|
85
|
+
return !1;
|
|
86
|
+
let c = 0, u = 0, d = 0;
|
|
87
|
+
switch (e) {
|
|
88
|
+
case "DD/MM/YYYY":
|
|
89
|
+
case "DD.MM.YYYY":
|
|
90
|
+
c = parseInt(n, 10), u = parseInt(a, 10), d = parseInt(l, 10);
|
|
91
|
+
break;
|
|
92
|
+
case "MM/DD/YYYY":
|
|
93
|
+
case "MM.DD.YYYY":
|
|
94
|
+
u = parseInt(n, 10), c = parseInt(a, 10), d = parseInt(l, 10);
|
|
95
|
+
break;
|
|
96
|
+
case "YYYY-MM-DD":
|
|
97
|
+
c = parseInt(l, 10), u = parseInt(a, 10), d = parseInt(n, 10);
|
|
98
|
+
break;
|
|
99
|
+
default:
|
|
100
|
+
return !1;
|
|
101
|
+
}
|
|
102
|
+
if (u < 1 || u > 12 || d < 1)
|
|
103
|
+
return !1;
|
|
104
|
+
const I = u === 2 && G(d) ? 29 : W[u] ?? 0;
|
|
105
|
+
return c >= 1 && c <= I;
|
|
49
106
|
}
|
|
50
|
-
function
|
|
51
|
-
return
|
|
107
|
+
function G(s) {
|
|
108
|
+
return s % 4 === 0 && s % 100 !== 0 || s % 400 === 0;
|
|
52
109
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
110
|
+
function X(s) {
|
|
111
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(s);
|
|
112
|
+
}
|
|
113
|
+
const M = (s) => {
|
|
114
|
+
const { ref: e, format: t, before: o, value: r, onChange: n, onBlur: a, invalid: l, ...c } = s, [u, d] = N(!1), g = _(
|
|
115
|
+
(D) => {
|
|
116
|
+
const T = j(D, t);
|
|
117
|
+
n?.(T);
|
|
118
|
+
},
|
|
119
|
+
[t, n]
|
|
120
|
+
), I = _(
|
|
121
|
+
(D) => {
|
|
122
|
+
d(!0), a?.(D);
|
|
57
123
|
},
|
|
58
124
|
[a]
|
|
59
|
-
),
|
|
60
|
-
return /* @__PURE__ */
|
|
61
|
-
|
|
125
|
+
), h = l || u && typeof r == "string" && r.length > 0 && !Z(r, t);
|
|
126
|
+
return /* @__PURE__ */ i(
|
|
127
|
+
f,
|
|
128
|
+
{
|
|
129
|
+
ref: e,
|
|
130
|
+
type: "text",
|
|
131
|
+
inputMode: "numeric",
|
|
132
|
+
before: o ?? /* @__PURE__ */ i(Y, { name: "calendar", size: 16 }),
|
|
133
|
+
maxLength: 10,
|
|
134
|
+
value: r,
|
|
135
|
+
onChange: g,
|
|
136
|
+
onBlur: I,
|
|
137
|
+
invalid: h,
|
|
138
|
+
...c
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
};
|
|
142
|
+
M.displayName = m.INPUT_DATE;
|
|
143
|
+
const b = (s) => {
|
|
144
|
+
const { ref: e, before: t, onBlur: o, invalid: r, ...n } = s, [a, l] = N(!1), c = _(
|
|
145
|
+
(d) => {
|
|
146
|
+
l(!0), o?.(d);
|
|
147
|
+
},
|
|
148
|
+
[o]
|
|
149
|
+
), u = r || a && n.value != null && !X(n.value);
|
|
150
|
+
return /* @__PURE__ */ i(
|
|
151
|
+
f,
|
|
62
152
|
{
|
|
63
153
|
ref: e,
|
|
64
154
|
type: "email",
|
|
65
|
-
before:
|
|
66
|
-
invalid:
|
|
67
|
-
onBlur:
|
|
68
|
-
...
|
|
155
|
+
before: t ?? /* @__PURE__ */ i(Y, { name: "mail", size: 16 }),
|
|
156
|
+
invalid: u,
|
|
157
|
+
onBlur: c,
|
|
158
|
+
...n
|
|
69
159
|
}
|
|
70
160
|
);
|
|
71
161
|
};
|
|
72
|
-
|
|
73
|
-
const P = (
|
|
74
|
-
const { ref: e, ...
|
|
75
|
-
return /* @__PURE__ */
|
|
162
|
+
b.displayName = m.INPUT_EMAIL;
|
|
163
|
+
const P = (s) => {
|
|
164
|
+
const { ref: e, ...t } = s;
|
|
165
|
+
return /* @__PURE__ */ i(f, { ref: e, type: "number", inputMode: "numeric", ...t });
|
|
76
166
|
};
|
|
77
167
|
P.displayName = m.INPUT_NUMBER;
|
|
78
|
-
const
|
|
79
|
-
const { ref: e, after:
|
|
80
|
-
return /* @__PURE__ */
|
|
81
|
-
|
|
168
|
+
const w = (s) => {
|
|
169
|
+
const { ref: e, after: t, ...o } = s, r = A(), [n, a] = N(!1), l = _(() => a((c) => !c), []);
|
|
170
|
+
return /* @__PURE__ */ i(
|
|
171
|
+
f,
|
|
82
172
|
{
|
|
83
173
|
ref: e,
|
|
84
|
-
type:
|
|
85
|
-
after:
|
|
174
|
+
type: n ? "text" : "password",
|
|
175
|
+
after: t ?? /* @__PURE__ */ i(
|
|
86
176
|
"button",
|
|
87
177
|
{
|
|
88
178
|
type: "button",
|
|
89
|
-
className:
|
|
90
|
-
onClick:
|
|
179
|
+
className: p.togglePassword,
|
|
180
|
+
onClick: l,
|
|
91
181
|
tabIndex: -1,
|
|
92
|
-
"aria-label":
|
|
93
|
-
children:
|
|
182
|
+
"aria-label": n ? r.Input.Password.passwordHide : r.Input.Password.passwordShow,
|
|
183
|
+
children: n ? /* @__PURE__ */ i(Y, { name: "eye-off", size: 16 }) : /* @__PURE__ */ i(Y, { name: "eye", size: 16 })
|
|
94
184
|
}
|
|
95
185
|
),
|
|
96
|
-
...
|
|
186
|
+
...o
|
|
97
187
|
}
|
|
98
188
|
);
|
|
99
189
|
};
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
const { ref: e, before:
|
|
103
|
-
(
|
|
104
|
-
const
|
|
105
|
-
|
|
190
|
+
w.displayName = m.INPUT_PASSWORD;
|
|
191
|
+
const y = (s) => {
|
|
192
|
+
const { ref: e, before: t, onChange: o, ...r } = s, n = _(
|
|
193
|
+
(a) => {
|
|
194
|
+
const l = V(a);
|
|
195
|
+
o?.(l);
|
|
106
196
|
},
|
|
107
|
-
[
|
|
197
|
+
[o]
|
|
108
198
|
);
|
|
109
|
-
return /* @__PURE__ */
|
|
199
|
+
return /* @__PURE__ */ i(f, { ref: e, type: "tel", before: t ?? /* @__PURE__ */ i(Y, { name: "phone", size: 16 }), onChange: n, ...r });
|
|
110
200
|
};
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
201
|
+
y.displayName = m.INPUT_PHONE;
|
|
202
|
+
const te = Object.assign(f, {
|
|
203
|
+
Date: M,
|
|
204
|
+
Email: b,
|
|
114
205
|
Number: P,
|
|
115
|
-
Password:
|
|
116
|
-
Phone:
|
|
206
|
+
Password: w,
|
|
207
|
+
Phone: y
|
|
117
208
|
});
|
|
118
209
|
export {
|
|
119
|
-
|
|
210
|
+
te as Input
|
|
120
211
|
};
|
|
@@ -6,24 +6,44 @@ export declare interface IConfigContext {
|
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
export declare interface ILocaleMessages {
|
|
9
|
-
|
|
9
|
+
Chip: {
|
|
10
|
+
remove: string;
|
|
11
|
+
};
|
|
12
|
+
Dialog: {
|
|
10
13
|
close: string;
|
|
11
14
|
};
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
Drawer: {
|
|
16
|
+
Header: {
|
|
17
|
+
close: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
Input: {
|
|
21
|
+
Password: {
|
|
22
|
+
passwordHide: string;
|
|
23
|
+
passwordShow: string;
|
|
24
|
+
};
|
|
15
25
|
};
|
|
16
|
-
|
|
26
|
+
Pagination: {
|
|
27
|
+
items: string;
|
|
28
|
+
label: string;
|
|
17
29
|
next: string;
|
|
18
|
-
|
|
19
|
-
pagination: string;
|
|
30
|
+
of: string;
|
|
20
31
|
prev: string;
|
|
32
|
+
Item: {
|
|
33
|
+
page: string;
|
|
34
|
+
};
|
|
21
35
|
};
|
|
22
|
-
|
|
36
|
+
Select: {
|
|
23
37
|
clear: string;
|
|
24
38
|
noOptions: string;
|
|
25
39
|
placeholder: string;
|
|
26
40
|
};
|
|
41
|
+
Table: {
|
|
42
|
+
ActiveFilters: {
|
|
43
|
+
clearAll: string;
|
|
44
|
+
remove: string;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
27
47
|
}
|
|
28
48
|
|
|
29
49
|
declare interface IProps extends default_2.PropsWithChildren {
|
|
@@ -58,7 +78,7 @@ declare interface IProps extends default_2.PropsWithChildren {
|
|
|
58
78
|
* // With custom locale and theme target
|
|
59
79
|
* <LazarUiProvider
|
|
60
80
|
* theme="dark"
|
|
61
|
-
* locale={{
|
|
81
|
+
* locale={{ Dialog: { close: 'Закрыть' } }}
|
|
62
82
|
* themeTarget={document.getElementById('root')}
|
|
63
83
|
* >
|
|
64
84
|
* <YourApp />
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as t } from "./useLocale-
|
|
2
|
-
import { L as u, u as x } from "./useLocale-
|
|
1
|
+
import { C as t } from "./useLocale-CJh-krrY.mjs";
|
|
2
|
+
import { L as u, u as x } from "./useLocale-CJh-krrY.mjs";
|
|
3
3
|
import { useContext as o } from "react";
|
|
4
4
|
const i = () => {
|
|
5
5
|
const r = o(t);
|
package/dist/pagination.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { jsx as c, jsxs as N } from "react/jsx-runtime";
|
|
2
2
|
import { createContext as L, useContext as S, useMemo as y, useCallback as R } from "react";
|
|
3
3
|
import f from "clsx";
|
|
4
|
-
import { u as v } from "./useLocale-
|
|
4
|
+
import { u as v } from "./useLocale-CJh-krrY.mjs";
|
|
5
5
|
import { g as C } from "./getVariantClassName-D7Nhpuec.mjs";
|
|
6
6
|
import { I as z } from "./Icon-DsTlU3j3.mjs";
|
|
7
|
-
import './pagination.css';const P = L(null),
|
|
7
|
+
import './pagination.css';const P = L(null), I = P.Provider, w = () => {
|
|
8
8
|
const n = S(P);
|
|
9
9
|
if (!n)
|
|
10
10
|
throw new Error("Pagination sub-component must be used within a Pagination");
|
|
11
11
|
return n;
|
|
12
|
-
}, $ = "_button_nl5gc_14", E = "_active_nl5gc_40", A = "_prevNext_nl5gc_44", j = "_sizeSm_nl5gc_49", k = "_sizeMd_nl5gc_55", B = "_sizeLg_nl5gc_61",
|
|
12
|
+
}, $ = "_button_nl5gc_14", E = "_active_nl5gc_40", A = "_prevNext_nl5gc_44", j = "_sizeSm_nl5gc_49", k = "_sizeMd_nl5gc_55", B = "_sizeLg_nl5gc_61", _ = {
|
|
13
13
|
button: $,
|
|
14
14
|
active: E,
|
|
15
15
|
prevNext: A,
|
|
@@ -17,12 +17,12 @@ import './pagination.css';const P = L(null), w = P.Provider, I = () => {
|
|
|
17
17
|
sizeMd: k,
|
|
18
18
|
sizeLg: B
|
|
19
19
|
}, x = (n) => {
|
|
20
|
-
const { page: e, type: a = "page", children: t } = n, { currentPage:
|
|
21
|
-
let d,
|
|
22
|
-
a === "prev" ? (d = i.
|
|
23
|
-
const M = f(
|
|
24
|
-
[
|
|
25
|
-
[
|
|
20
|
+
const { page: e, type: a = "page", children: t } = n, { currentPage: l, totalPages: r, disabled: s, onChange: p, size: u } = w(), i = v(), g = e === l, o = s || e < 1 || e > r || g;
|
|
21
|
+
let d, m;
|
|
22
|
+
a === "prev" ? (d = i.Pagination.prev, m = t ?? /* @__PURE__ */ c(z, { name: "chevron-left", size: 14 })) : a === "next" ? (d = i.Pagination.next, m = t ?? /* @__PURE__ */ c(z, { name: "chevron-right", size: 14 })) : (d = i.Pagination.Item.page.replace("{page}", String(e)), m = t ?? e);
|
|
23
|
+
const M = f(_.button, C("size", u, _), {
|
|
24
|
+
[_.active]: g,
|
|
25
|
+
[_.prevNext]: a !== "page"
|
|
26
26
|
});
|
|
27
27
|
return /* @__PURE__ */ c(
|
|
28
28
|
"button",
|
|
@@ -33,22 +33,22 @@ import './pagination.css';const P = L(null), w = P.Provider, I = () => {
|
|
|
33
33
|
disabled: o,
|
|
34
34
|
onClick: () => p(e),
|
|
35
35
|
type: "button",
|
|
36
|
-
children:
|
|
36
|
+
children: m
|
|
37
37
|
}
|
|
38
38
|
);
|
|
39
39
|
}, D = "Pagination", b = (n, e) => Array.from({ length: e - n + 1 }, (a, t) => n + t), V = (n, e) => {
|
|
40
40
|
if (e <= 7)
|
|
41
41
|
return b(1, e);
|
|
42
|
-
const
|
|
42
|
+
const l = Math.max(n - 1, 1), r = Math.min(n + 1, e), s = l > 2, p = r < e - 1;
|
|
43
43
|
if (!s && p) {
|
|
44
|
-
const i = Math.min(
|
|
44
|
+
const i = Math.min(r + 1, e);
|
|
45
45
|
return [...b(1, i), "ellipsis", e];
|
|
46
46
|
}
|
|
47
47
|
if (s && !p) {
|
|
48
|
-
const i = Math.max(
|
|
48
|
+
const i = Math.max(l - 1, 1);
|
|
49
49
|
return [1, "ellipsis", ...b(i, e)];
|
|
50
50
|
}
|
|
51
|
-
return [1, "ellipsis", ...b(
|
|
51
|
+
return [1, "ellipsis", ...b(l, r), "ellipsis", e];
|
|
52
52
|
}, Y = "_root_60eox_6", q = "_disabled_60eox_13", F = "_ellipsis_60eox_18", G = "_sizeSm_60eox_27", H = "_sizeMd_60eox_33", J = "_sizeLg_60eox_39", h = {
|
|
53
53
|
root: Y,
|
|
54
54
|
disabled: q,
|
|
@@ -57,16 +57,16 @@ import './pagination.css';const P = L(null), w = P.Provider, I = () => {
|
|
|
57
57
|
sizeMd: H,
|
|
58
58
|
sizeLg: J
|
|
59
59
|
}, K = (n) => {
|
|
60
|
-
const { disabled: e = !1, onChange: a, page: t, showPrevNext:
|
|
60
|
+
const { disabled: e = !1, onChange: a, page: t, showPrevNext: l = !0, size: r = "md", totalPages: s } = n, p = v(), u = y(() => V(t, s), [t, s]), i = R(
|
|
61
61
|
(o) => {
|
|
62
62
|
e || o < 1 || o > s || a?.(o);
|
|
63
63
|
},
|
|
64
64
|
[e, a, s]
|
|
65
|
-
), g = f(h.root, C("size",
|
|
66
|
-
return /* @__PURE__ */ c(
|
|
67
|
-
|
|
65
|
+
), g = f(h.root, C("size", r, h), { [h.disabled]: e });
|
|
66
|
+
return /* @__PURE__ */ c(I, { value: { currentPage: t, disabled: e, onChange: i, size: r, totalPages: s }, children: /* @__PURE__ */ N("nav", { "aria-label": p.Pagination.label, className: g, children: [
|
|
67
|
+
l && /* @__PURE__ */ c(x, { page: t - 1, type: "prev" }),
|
|
68
68
|
u.map((o, d) => o === "ellipsis" ? /* @__PURE__ */ c("span", { "aria-hidden": "true", className: h.ellipsis, children: "…" }, `ellipsis-${d}`) : /* @__PURE__ */ c(x, { page: o, type: "page" }, o)),
|
|
69
|
-
|
|
69
|
+
l && /* @__PURE__ */ c(x, { page: t + 1, type: "next" })
|
|
70
70
|
] }) });
|
|
71
71
|
};
|
|
72
72
|
K.displayName = D;
|
package/dist/radio.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@charset "UTF-8";._item_1mf7l_3{align-items:flex-start;cursor:pointer;display:inline-flex;gap:var(--radio-gap);position:relative;-webkit-user-select:none;user-select:none;vertical-align:middle}._item_1mf7l_3._disabled_1mf7l_12{cursor:not-allowed;opacity:.5}._item_1mf7l_3._invalid_1mf7l_17 ._radio_1mf7l_17{border-color:var(--radio-error-border)}._item_1mf7l_3._invalid_1mf7l_17 ._input_1mf7l_20:checked+._radio_1mf7l_17{background-color:var(--radio-error-checked-bg);border-color:var(--radio-error-checked-border)}._input_1mf7l_20{border:0;clip:rect(0 0 0 0);clip-path:inset(50%);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;white-space:nowrap;width:1px}._radio_1mf7l_17{align-items:center;background:var(--radio-bg);border:1px solid var(--radio-border);border-radius:var(--radio-radius);display:flex;flex-shrink:0;justify-content:center;position:relative;transition:background var(--radio-transition-duration) var(--radio-transition-timing),border-color var(--radio-transition-duration) var(--radio-transition-timing)}._radio_1mf7l_17:after{background:var(--radio-dot-color);border-radius:50%;content:"";opacity:0;position:absolute;transition:opacity var(--radio-transition-duration) var(--radio-transition-timing),transform var(--radio-transition-duration) var(--radio-transition-timing)}._content_1mf7l_63{display:flex;flex-direction:column;gap:var(--radio-content-gap);padding-top:var(--radio-content-padding-top)}._label_1mf7l_70{color:var(--radio-label-color);font-weight:var(--radio-label-font-weight)}._description_1mf7l_75{color:var(--radio-description-color);font-weight:var(--lui-font-weight-normal)}._item_1mf7l_3:not(._disabled_1mf7l_12) ._input_1mf7l_20:not(:checked):hover+._radio_1mf7l_17{border-color:var(--radio-hover-border)}._input_1mf7l_20:focus-visible+._radio_1mf7l_17{box-shadow:var(--radio-focus-shadow)}._input_1mf7l_20:checked+._radio_1mf7l_17{background:var(--radio-checked-bg);border-color:var(--radio-checked-border)}._input_1mf7l_20:checked+._radio_1mf7l_17:after{opacity:1}._disabled_1mf7l_12 ._input_1mf7l_20:checked+._radio_1mf7l_17{background:var(--radio-disabled-bg);border-color:var(--radio-disabled-border)}._disabled_1mf7l_12 ._input_1mf7l_20:checked+._radio_1mf7l_17:after{background:var(--radio-disabled-dot)}._disabled_1mf7l_12 ._input_1mf7l_20:not(:checked)+._radio_1mf7l_17{background:var(--radio-disabled-bg);border-color:var(--radio-disabled-border)}._sizeSm_1mf7l_113 ._radio_1mf7l_17{height:16px;width:16px}._sizeSm_1mf7l_113 ._radio_1mf7l_17:after{height:6px;width:6px}._sizeSm_1mf7l_113 ._label_1mf7l_70{font-size:var(--lui-font-size-sm);line-height:var(--line-height-sm)}._sizeSm_1mf7l_113 ._description_1mf7l_75{font-size:var(--lui-font-size-xs);line-height:var(--line-height-xs)}._sizeMd_1mf7l_130 ._radio_1mf7l_17{height:20px;width:20px}._sizeMd_1mf7l_130 ._radio_1mf7l_17:after{height:8px;width:8px}._sizeMd_1mf7l_130 ._label_1mf7l_70{font-size:var(--lui-font-size-md);line-height:var(--line-height-md)}._sizeMd_1mf7l_130 ._description_1mf7l_75{font-size:var(--lui-font-size-sm);line-height:var(--line-height-sm)}._sizeLg_1mf7l_147 ._radio_1mf7l_17{height:24px;width:24px}._sizeLg_1mf7l_147 ._radio_1mf7l_17:after{height:10px;width:10px}._sizeLg_1mf7l_147 ._label_1mf7l_70{font-size:var(--lui-font-size-lg);line-height:var(--line-height-lg)}._sizeLg_1mf7l_147 ._description_1mf7l_75{font-size:var(--lui-font-size-md);line-height:var(--line-height-md)}:root{--radio-bg: var(--lui-color-background-primary);--radio-border: var(--lui-color-border-primary);--radio-checked-bg: var(--lui-color-background-brand);--radio-checked-border: var(--lui-color-background-brand);--radio-dot-color: var(--lui-color-text-on-brand);--radio-disabled-bg: var(--lui-color-background-disabled);--radio-disabled-border: var(--lui-color-border-disabled);--radio-disabled-dot: var(--lui-color-text-disabled);--radio-error-border: var(--lui-color-border-focus-error);--radio-error-checked-bg: var(--lui-color-background-error);--radio-error-checked-border: var(--lui-color-background-error);--radio-radius: var(--lui-radius-full);--radio-hover-border: var(--lui-palette-gray-400);--radio-focus-shadow: 0 0 0 2px var(--lui-palette-brand-secondary);--radio-label-color: var(--lui-color-text-primary);--radio-description-color: var(--lui-color-text-tertiary);--radio-label-font-weight: var(--lui-font-weight-medium);--radio-gap: var(--lui-space-2);--radio-content-gap: 2px;--radio-content-padding-top: 1px;--radio-group-gap: var(--lui-space-2);--radio-transition-duration: .15s;--radio-transition-timing: cubic-bezier(.4, 0, .2, 1)}._root_pott0_33{border:none;display:flex;flex-direction:column;margin:0;padding:0}._root_pott0_33._vertical_pott0_40 ._group_pott0_40{flex-direction:column}._root_pott0_33._horizontal_pott0_43 ._group_pott0_40{flex-direction:row}._group_pott0_40{display:flex;gap:var(--radio-group-gap)}
|
package/dist/radio.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { default as default_2 } from 'react';
|
|
2
|
+
|
|
3
|
+
export declare enum ERadioSize {
|
|
4
|
+
SM = "sm",
|
|
5
|
+
MD = "md",
|
|
6
|
+
LG = "lg"
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export declare interface IItemProps extends TNativeInputProps, default_2.PropsWithChildren {
|
|
10
|
+
/** The value of the radio button. Required for group integration. */
|
|
11
|
+
value: string;
|
|
12
|
+
/** Description text displayed below the option label. */
|
|
13
|
+
description?: default_2.ReactNode;
|
|
14
|
+
/** Ref to the native input element. */
|
|
15
|
+
ref?: default_2.Ref<HTMLInputElement>;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export declare interface IRadioProps extends default_2.PropsWithChildren {
|
|
19
|
+
/** Name attribute passed to all radio inputs in the group. */
|
|
20
|
+
name?: string;
|
|
21
|
+
/** Controlled selected value. */
|
|
22
|
+
value?: string;
|
|
23
|
+
/** Default selected value for uncontrolled mode. */
|
|
24
|
+
defaultValue?: string;
|
|
25
|
+
/** Callback when the selected value changes. */
|
|
26
|
+
onChange?: (value: string) => void;
|
|
27
|
+
/** Vertical layout. Set false for horizontal. Default: true. */
|
|
28
|
+
vertical?: boolean;
|
|
29
|
+
/** Radio size: sm, md, lg. Default: 'md'. Applied to all items in the group. */
|
|
30
|
+
size?: TRadioSize;
|
|
31
|
+
/** When true, all radios in the group are disabled. */
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
/** When true, all radio items show error styling. */
|
|
34
|
+
invalid?: boolean;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
declare const Item: default_2.FC<IItemProps>;
|
|
38
|
+
|
|
39
|
+
export declare const Radio: TRadioCompoundComponent;
|
|
40
|
+
|
|
41
|
+
declare const Radio_2: default_2.FC<IRadioProps>;
|
|
42
|
+
|
|
43
|
+
declare type TNativeInputProps = Omit<default_2.InputHTMLAttributes<HTMLInputElement>, 'type' | 'name' | 'checked' | 'size' | 'className'>;
|
|
44
|
+
|
|
45
|
+
declare type TRadioCompoundComponent = typeof Radio_2 & {
|
|
46
|
+
Item: typeof Item;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
declare type TRadioSize = `${ERadioSize.SM | ERadioSize.MD | ERadioSize.LG}`;
|
|
50
|
+
|
|
51
|
+
export { }
|
package/dist/radio.js
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { jsx as s, jsxs as z } from "react/jsx-runtime";
|
|
2
|
+
import L, { createContext as S, useContext as E, useId as P, useState as T, useCallback as x, useRef as $ } from "react";
|
|
3
|
+
import I from "clsx";
|
|
4
|
+
import { g as k } from "./getVariantClassName-D7Nhpuec.mjs";
|
|
5
|
+
import { i as A } from "./isValidReactNode-CmYwTWCE.mjs";
|
|
6
|
+
import "./camelCase-PtIYufW8.mjs";
|
|
7
|
+
import './radio.css';const M = S(null), D = () => {
|
|
8
|
+
const e = E(M);
|
|
9
|
+
if (!e)
|
|
10
|
+
throw new Error("useRadioContext should be used inside Radio component");
|
|
11
|
+
return e;
|
|
12
|
+
}, j = (e) => {
|
|
13
|
+
const { children: n, name: a, value: i, defaultValue: l, onChange: r, size: m, disabled: _, invalid: t } = e, p = P(), v = a ?? p, c = i !== void 0, [d, f] = T(l), g = c ? i : d, N = x(
|
|
14
|
+
(h) => {
|
|
15
|
+
c || f(h), r?.(h);
|
|
16
|
+
},
|
|
17
|
+
[c, r]
|
|
18
|
+
);
|
|
19
|
+
return /* @__PURE__ */ s(M.Provider, { value: { disabled: _, invalid: t, name: v, onChange: N, size: m, value: g }, children: n });
|
|
20
|
+
}, b = "Radio", w = "_item_1mf7l_3", B = "_disabled_1mf7l_12", O = "_invalid_1mf7l_17", U = "_radio_1mf7l_17", G = "_input_1mf7l_20", Y = "_content_1mf7l_63", q = "_label_1mf7l_70", F = "_description_1mf7l_75", H = "_sizeSm_1mf7l_113", J = "_sizeMd_1mf7l_130", K = "_sizeLg_1mf7l_147", o = {
|
|
21
|
+
item: w,
|
|
22
|
+
disabled: B,
|
|
23
|
+
invalid: O,
|
|
24
|
+
radio: U,
|
|
25
|
+
input: G,
|
|
26
|
+
content: Y,
|
|
27
|
+
label: q,
|
|
28
|
+
description: F,
|
|
29
|
+
sizeSm: H,
|
|
30
|
+
sizeMd: J,
|
|
31
|
+
sizeLg: K
|
|
32
|
+
}, R = (e) => {
|
|
33
|
+
const { ref: n, children: a, value: i, description: l, disabled: r, onChange: m, ..._ } = e, t = D(), p = $(null), v = t.size ?? "md", c = t.value !== void 0 ? i === t.value : void 0, d = r !== void 0 ? r : t.disabled, f = t.invalid === !0, g = x(
|
|
34
|
+
(u) => {
|
|
35
|
+
p.current = u, typeof n == "function" ? n(u) : n && (n.current = u);
|
|
36
|
+
},
|
|
37
|
+
[n]
|
|
38
|
+
), N = (u) => {
|
|
39
|
+
t.onChange?.(u.target.value), m?.(u);
|
|
40
|
+
}, h = I(
|
|
41
|
+
o.item,
|
|
42
|
+
k("size", v, o),
|
|
43
|
+
{
|
|
44
|
+
[o.disabled]: d,
|
|
45
|
+
[o.invalid]: f
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
return /* @__PURE__ */ z("label", { className: h, children: [
|
|
49
|
+
/* @__PURE__ */ s(
|
|
50
|
+
"input",
|
|
51
|
+
{
|
|
52
|
+
ref: g,
|
|
53
|
+
className: o.input,
|
|
54
|
+
type: "radio",
|
|
55
|
+
checked: c,
|
|
56
|
+
disabled: d,
|
|
57
|
+
"aria-invalid": f || void 0,
|
|
58
|
+
name: t.name,
|
|
59
|
+
value: i,
|
|
60
|
+
onChange: N,
|
|
61
|
+
..._
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
/* @__PURE__ */ s("span", { className: o.radio, "aria-hidden": "true" }),
|
|
65
|
+
(a || l) && /* @__PURE__ */ z("span", { className: o.content, children: [
|
|
66
|
+
a && /* @__PURE__ */ s("span", { className: o.label, children: a }),
|
|
67
|
+
l && /* @__PURE__ */ s("span", { className: o.description, children: l })
|
|
68
|
+
] })
|
|
69
|
+
] });
|
|
70
|
+
};
|
|
71
|
+
R.displayName = `${b}.Item`;
|
|
72
|
+
var V = ((e) => (e.ITEM = `${b}.Item`, e))(V || {}), Q = /* @__PURE__ */ ((e) => (e.SM = "sm", e.MD = "md", e.LG = "lg", e))(Q || {});
|
|
73
|
+
const W = "_root_pott0_33", X = "_vertical_pott0_40", Z = "_group_pott0_40", ee = "_horizontal_pott0_43", C = {
|
|
74
|
+
root: W,
|
|
75
|
+
vertical: X,
|
|
76
|
+
group: Z,
|
|
77
|
+
horizontal: ee
|
|
78
|
+
}, te = [V.ITEM], y = (e) => {
|
|
79
|
+
const {
|
|
80
|
+
children: n,
|
|
81
|
+
name: a,
|
|
82
|
+
value: i,
|
|
83
|
+
defaultValue: l,
|
|
84
|
+
onChange: r,
|
|
85
|
+
vertical: m = !0,
|
|
86
|
+
size: _ = "md",
|
|
87
|
+
disabled: t = !1,
|
|
88
|
+
invalid: p = !1
|
|
89
|
+
} = e, v = (d) => A(te, d) ? d : null, c = I(C.root, {
|
|
90
|
+
[C.horizontal]: !m,
|
|
91
|
+
[C.vertical]: m
|
|
92
|
+
});
|
|
93
|
+
return /* @__PURE__ */ s(
|
|
94
|
+
j,
|
|
95
|
+
{
|
|
96
|
+
name: a,
|
|
97
|
+
value: i,
|
|
98
|
+
defaultValue: l,
|
|
99
|
+
onChange: r,
|
|
100
|
+
size: _,
|
|
101
|
+
disabled: t,
|
|
102
|
+
invalid: p,
|
|
103
|
+
children: /* @__PURE__ */ s("fieldset", { className: c, children: /* @__PURE__ */ s("div", { className: C.group, children: L.Children.map(n, v) }) })
|
|
104
|
+
}
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
y.displayName = b;
|
|
108
|
+
const ne = y;
|
|
109
|
+
ne.Item = R;
|
|
110
|
+
export {
|
|
111
|
+
Q as ERadioSize,
|
|
112
|
+
ne as Radio
|
|
113
|
+
};
|