bonkers-ui 2.0.6 → 2.0.8
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/bonkers.css +329 -225
- package/components/UiInput/UiInputText.d.ts +2 -1
- package/components/UiInput/UiInputText.js.map +1 -1
- package/components/UiInputRange/UiInputRange.js +55 -45
- package/components/UiInputRange/UiInputRange.js.map +1 -1
- package/components/UiPlainRadio/UiPlainRadio.js +76 -56
- package/components/UiPlainRadio/UiPlainRadio.js.map +1 -1
- package/components/UiRadio/UiRadio.js +36 -35
- package/components/UiRadio/UiRadio.js.map +1 -1
- package/components/UiSkeleton/UiSkeleton.js +130 -207
- package/components/UiSkeleton/UiSkeleton.js.map +1 -1
- package/components/UiSkeleton/index.d.ts +1 -0
- package/components/UiSkeleton/index.js +2 -0
- package/components/UiSkeleton/index.js.map +1 -1
- package/components/UiStars/UiStars.d.ts +2 -1
- package/components/UiStars/UiStars.js +24 -23
- package/components/UiStars/UiStars.js.map +1 -1
- package/components/UiTabs/UiTabs.js +22 -17
- package/components/UiTabs/UiTabs.js.map +1 -1
- package/components/UiToggle/UiToggle.d.ts +2 -0
- package/components/UiToggle/UiToggle.js +116 -112
- package/components/UiToggle/UiToggle.js.map +1 -1
- package/helper.d.ts +6 -14
- package/package.json +19 -26
|
@@ -1,71 +1,81 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import '../../assets/UiInputRange.css';const
|
|
5
|
-
thumb:
|
|
6
|
-
},
|
|
7
|
-
value:
|
|
8
|
-
min:
|
|
9
|
-
max:
|
|
10
|
-
step:
|
|
11
|
-
onChangeHandler:
|
|
12
|
-
className:
|
|
1
|
+
import { jsxs as M, jsx as n } from "react/jsx-runtime";
|
|
2
|
+
import m, { useState as b, useCallback as O, useEffect as S } from "react";
|
|
3
|
+
import g from "classnames";
|
|
4
|
+
import '../../assets/UiInputRange.css';const j = "_thumb_hkko1_18", T = {
|
|
5
|
+
thumb: j
|
|
6
|
+
}, $ = ({
|
|
7
|
+
value: s,
|
|
8
|
+
min: r,
|
|
9
|
+
max: a,
|
|
10
|
+
step: x,
|
|
11
|
+
onChangeHandler: y,
|
|
12
|
+
className: v,
|
|
13
13
|
...l
|
|
14
14
|
}) => {
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
if (!
|
|
18
|
-
const t = parseFloat(String(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
const e = m.useRef(null), c = m.useRef(null), [k, R] = b(0), [w, N] = b(0), i = O(() => {
|
|
16
|
+
var h, f;
|
|
17
|
+
if (!e.current || !c.current) return;
|
|
18
|
+
const t = parseFloat(String(s)), o = parseFloat(String(r)), z = parseFloat(String(a)), C = ((h = c.current) == null ? void 0 : h.getBoundingClientRect().width) ?? 0, u = ((f = e.current) == null ? void 0 : f.getBoundingClientRect().width) ?? 0;
|
|
19
|
+
if (u === 0) return;
|
|
20
|
+
const F = (t - o) / (z - o) * 100, p = C / u * 100, d = Math.max(0, Math.min(100, F * (1 - p / 100)));
|
|
21
|
+
R(d), N(d + p / 2);
|
|
22
|
+
}, [r, a, s]);
|
|
23
|
+
S(() => {
|
|
24
|
+
i();
|
|
25
|
+
const t = new ResizeObserver(() => {
|
|
26
|
+
i();
|
|
27
|
+
});
|
|
28
|
+
return e.current && t.observe(e.current), () => {
|
|
29
|
+
t.disconnect();
|
|
30
|
+
};
|
|
31
|
+
}, [i]);
|
|
32
|
+
const P = (t) => {
|
|
33
|
+
if (t === s) return;
|
|
34
|
+
const o = parseFloat(t.toFixed(10));
|
|
35
|
+
y(o);
|
|
25
36
|
};
|
|
26
|
-
return /* @__PURE__ */
|
|
37
|
+
return /* @__PURE__ */ M(
|
|
27
38
|
"div",
|
|
28
39
|
{
|
|
29
|
-
className:
|
|
40
|
+
className: g(
|
|
30
41
|
"relative box-content h-xl py-xxs",
|
|
31
42
|
l.disabled && "opacity-60 cursor-default pointer-events-none",
|
|
32
|
-
|
|
43
|
+
v
|
|
33
44
|
),
|
|
34
45
|
children: [
|
|
35
|
-
/* @__PURE__ */
|
|
46
|
+
/* @__PURE__ */ n(
|
|
36
47
|
"input",
|
|
37
48
|
{
|
|
38
49
|
...l,
|
|
39
|
-
ref:
|
|
50
|
+
ref: e,
|
|
40
51
|
className: "absolute left-0 top-0 size-full cursor-pointer appearance-none bg-transparent",
|
|
41
52
|
style: {
|
|
42
53
|
touchAction: "none"
|
|
43
54
|
},
|
|
44
55
|
type: "range",
|
|
45
|
-
min:
|
|
46
|
-
max:
|
|
47
|
-
step:
|
|
48
|
-
value:
|
|
49
|
-
onChange: (t) =>
|
|
56
|
+
min: r,
|
|
57
|
+
max: a,
|
|
58
|
+
step: x,
|
|
59
|
+
value: s,
|
|
60
|
+
onChange: (t) => P(+t.target.value),
|
|
50
61
|
onTouchStart: (t) => t.stopPropagation(),
|
|
51
62
|
onTouchMove: (t) => t.stopPropagation()
|
|
52
63
|
}
|
|
53
64
|
),
|
|
54
|
-
/* @__PURE__ */
|
|
55
|
-
/* @__PURE__ */ e(
|
|
65
|
+
/* @__PURE__ */ n("div", { className: "pointer-events-none absolute left-0 top-1/2 h-xxs w-full -translate-y-1/2 rounded-sm bg-secondary-alt overflow-clip", children: /* @__PURE__ */ n(
|
|
56
66
|
"div",
|
|
57
67
|
{
|
|
58
|
-
className: "pointer-events-none absolute left-0 top-1/2 h-xxs -translate-y-1/2 rounded-sm bg-primary",
|
|
68
|
+
className: "pointer-events-none absolute left-0 top-1/2 h-xxs -translate-y-1/2 rounded-sm bg-primary-600",
|
|
59
69
|
style: {
|
|
60
|
-
width: `${
|
|
70
|
+
width: `${w}%`
|
|
61
71
|
}
|
|
62
72
|
}
|
|
63
|
-
),
|
|
64
|
-
/* @__PURE__ */
|
|
73
|
+
) }),
|
|
74
|
+
/* @__PURE__ */ n(
|
|
65
75
|
"div",
|
|
66
76
|
{
|
|
67
|
-
className:
|
|
68
|
-
|
|
77
|
+
className: g(
|
|
78
|
+
T.thumb,
|
|
69
79
|
"pointer-events-none",
|
|
70
80
|
"absolute",
|
|
71
81
|
"box-content",
|
|
@@ -73,13 +83,13 @@ import '../../assets/UiInputRange.css';const W = "_thumb_hkko1_18", F = {
|
|
|
73
83
|
"-translate-y-1/2",
|
|
74
84
|
"rounded-full",
|
|
75
85
|
"bg-white",
|
|
76
|
-
"border-primary"
|
|
86
|
+
"border-primary-600"
|
|
77
87
|
),
|
|
78
|
-
ref:
|
|
88
|
+
ref: c,
|
|
79
89
|
style: {
|
|
80
|
-
left: `${
|
|
90
|
+
left: `${k}%`
|
|
81
91
|
},
|
|
82
|
-
children: /* @__PURE__ */
|
|
92
|
+
children: /* @__PURE__ */ n("div", { className: "absolute left-1/2 top-1/2 size-xxs -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-600" })
|
|
83
93
|
}
|
|
84
94
|
)
|
|
85
95
|
]
|
|
@@ -87,6 +97,6 @@ import '../../assets/UiInputRange.css';const W = "_thumb_hkko1_18", F = {
|
|
|
87
97
|
);
|
|
88
98
|
};
|
|
89
99
|
export {
|
|
90
|
-
|
|
100
|
+
$ as UiInputRange
|
|
91
101
|
};
|
|
92
102
|
//# sourceMappingURL=UiInputRange.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiInputRange.js","sources":["../../../src/components/UiInputRange/UiInputRange.tsx"],"sourcesContent":["import React from \"react\";\nimport cx from \"classnames\";\nimport styles from \"./UiInputRange.module.css\";\n\nexport type TUiInputRangeProps = {\n\tvalue: number;\n\tmin: string | number;\n\tmax: string | number;\n\tstep: string | number;\n\tonChangeHandler: (value: number) => void;\n\tclassName?: string;\n} & React.HTMLProps<HTMLInputElement>;\n\nexport const UiInputRange: React.FC<TUiInputRangeProps> = ({\n\tvalue,\n\tmin,\n\tmax,\n\tstep,\n\tonChangeHandler,\n\tclassName,\n\t...rest\n}) => {\n\tconst track = React.useRef<HTMLInputElement>(null);\n\tconst thumb = React.useRef<HTMLDivElement>(null);\n\
|
|
1
|
+
{"version":3,"file":"UiInputRange.js","sources":["../../../src/components/UiInputRange/UiInputRange.tsx"],"sourcesContent":["import React, { useState, useEffect, useCallback } from \"react\";\nimport cx from \"classnames\";\nimport styles from \"./UiInputRange.module.css\";\n\nexport type TUiInputRangeProps = {\n\tvalue: number;\n\tmin: string | number;\n\tmax: string | number;\n\tstep: string | number;\n\tonChangeHandler: (value: number) => void;\n\tclassName?: string;\n} & React.HTMLProps<HTMLInputElement>;\n\nexport const UiInputRange: React.FC<TUiInputRangeProps> = ({\n\tvalue,\n\tmin,\n\tmax,\n\tstep,\n\tonChangeHandler,\n\tclassName,\n\t...rest\n}) => {\n\tconst track = React.useRef<HTMLInputElement>(null);\n\tconst thumb = React.useRef<HTMLDivElement>(null);\n\tconst [position, setPosition] = useState(0);\n\tconst [trackOffset, setTrackOffset] = useState(0);\n\n\tconst updatePositions = useCallback(() => {\n\t\tif (!track.current || !thumb.current) return;\n\n\t\tconst numValue = parseFloat(String(value));\n\t\tconst numMin = parseFloat(String(min));\n\t\tconst numMax = parseFloat(String(max));\n\n\t\tconst thumbWidth = thumb.current?.getBoundingClientRect().width ?? 0;\n\t\tconst trackWidth = track.current?.getBoundingClientRect().width ?? 0;\n\n\t\tif (trackWidth === 0) return;\n\n\t\tconst percentage = ((numValue - numMin) / (numMax - numMin)) * 100;\n\t\tconst thumbWidthPercentage = (thumbWidth / trackWidth) * 100;\n\n\t\tconst adjustedPercentage = Math.max(0, Math.min(100, percentage * (1 - thumbWidthPercentage / 100)));\n\n\t\tsetPosition(adjustedPercentage);\n\t\tsetTrackOffset(adjustedPercentage + (thumbWidthPercentage / 2));\n\t}, [min, max, value]);\n\n\tuseEffect(() => {\n\t\tupdatePositions();\n\n\t\tconst resizeObserver = new ResizeObserver(() => {\n\t\t\tupdatePositions();\n\t\t});\n\n\t\tif (track.current) {\n\t\t\tresizeObserver.observe(track.current);\n\t\t}\n\n\t\treturn () => {\n\t\t\tresizeObserver.disconnect();\n\t\t};\n\t}, [updatePositions]);\n\n\tconst handleOnChange = (newValue: number) => {\n\t\tif (newValue === value) return;\n\t\tconst preciseValue = parseFloat(newValue.toFixed(10));\n\t\tonChangeHandler(preciseValue);\n\t};\n\n\treturn (\n\t\t<div\n\t\t\tclassName={ cx(\n\t\t\t\t\"relative box-content h-xl py-xxs\",\n\t\t\t\trest.disabled && \"opacity-60 cursor-default pointer-events-none\",\n\t\t\t\tclassName\n\t\t\t) }\n\t\t>\n\t\t\t<input\n\t\t\t\t{ ...rest }\n\t\t\t\tref={ track }\n\t\t\t\tclassName=\"absolute left-0 top-0 size-full cursor-pointer appearance-none bg-transparent\"\n\t\t\t\tstyle={ {\n\t\t\t\t\ttouchAction: \"none\",\n\t\t\t\t} }\n\t\t\t\ttype=\"range\"\n\t\t\t\tmin={ min }\n\t\t\t\tmax={ max }\n\t\t\t\tstep={ step }\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ (e) => handleOnChange(+e.target.value) }\n\t\t\t\tonTouchStart={ (e) => e.stopPropagation() }\n\t\t\t\tonTouchMove={ (e) => e.stopPropagation() }\n\t\t\t/>\n\n\t\t\t<div className=\"pointer-events-none absolute left-0 top-1/2 h-xxs w-full -translate-y-1/2 rounded-sm bg-secondary-alt overflow-clip\">\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"pointer-events-none absolute left-0 top-1/2 h-xxs -translate-y-1/2 rounded-sm bg-primary-600\"\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\twidth: `${trackOffset}%`,\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t\t<div\n\t\t\t\tclassName={ cx(\n\t\t\t\t\tstyles.thumb,\n\t\t\t\t\t\"pointer-events-none\",\n\t\t\t\t\t\"absolute\",\n\t\t\t\t\t\"box-content\",\n\t\t\t\t\t\"size-md\",\n\t\t\t\t\t\"-translate-y-1/2\",\n\t\t\t\t\t\"rounded-full\",\n\t\t\t\t\t\"bg-white\",\n\t\t\t\t\t\"border-primary-600\",\n\t\t\t\t) }\n\t\t\t\tref={ thumb }\n\t\t\t\tstyle={ {\n\t\t\t\t\tleft: `${position}%`,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t<div className=\"absolute left-1/2 top-1/2 size-xxs -translate-x-1/2 -translate-y-1/2 rounded-full bg-primary-600\" />\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n"],"names":["UiInputRange","value","min","max","step","onChangeHandler","className","rest","track","React","thumb","position","setPosition","useState","trackOffset","setTrackOffset","updatePositions","useCallback","numValue","numMin","numMax","thumbWidth","_a","trackWidth","_b","percentage","thumbWidthPercentage","adjustedPercentage","useEffect","resizeObserver","handleOnChange","newValue","preciseValue","jsxs","cx","jsx","e","styles"],"mappings":"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"}
|
|
@@ -1,90 +1,110 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as a, jsx as n } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
children:
|
|
3
|
+
import i from "classnames";
|
|
4
|
+
const v = ({
|
|
5
|
+
id: p,
|
|
6
|
+
children: s,
|
|
7
7
|
disabled: r,
|
|
8
|
-
subHeader:
|
|
9
|
-
value:
|
|
10
|
-
name:
|
|
11
|
-
checked:
|
|
12
|
-
className:
|
|
13
|
-
onChange:
|
|
14
|
-
|
|
8
|
+
subHeader: t,
|
|
9
|
+
value: o,
|
|
10
|
+
name: l,
|
|
11
|
+
checked: e = !1,
|
|
12
|
+
className: g,
|
|
13
|
+
onChange: c,
|
|
14
|
+
...m
|
|
15
|
+
}) => /* @__PURE__ */ a(
|
|
15
16
|
"label",
|
|
16
17
|
{
|
|
17
|
-
className:
|
|
18
|
-
"ui-radio
|
|
18
|
+
className: i(
|
|
19
|
+
"ui-plain-radio",
|
|
19
20
|
"relative",
|
|
21
|
+
"group",
|
|
20
22
|
{
|
|
21
23
|
"pointer-events-none opacity-50": r
|
|
22
24
|
},
|
|
23
|
-
|
|
25
|
+
g
|
|
24
26
|
),
|
|
25
|
-
htmlFor: a + e,
|
|
26
27
|
children: [
|
|
27
28
|
/* @__PURE__ */ n(
|
|
28
29
|
"input",
|
|
29
30
|
{
|
|
30
|
-
className:
|
|
31
|
+
className: i(
|
|
31
32
|
" absolute",
|
|
32
33
|
"appearance-none",
|
|
33
|
-
"peer
|
|
34
|
+
"peer"
|
|
34
35
|
),
|
|
35
|
-
id:
|
|
36
|
+
id: p || `${l}-${o}`,
|
|
36
37
|
type: "radio",
|
|
37
|
-
value:
|
|
38
|
-
checked:
|
|
39
|
-
onChange: () =>
|
|
38
|
+
value: o,
|
|
39
|
+
checked: e,
|
|
40
|
+
onChange: () => c(o),
|
|
41
|
+
...m
|
|
40
42
|
}
|
|
41
43
|
),
|
|
42
|
-
/* @__PURE__ */
|
|
44
|
+
/* @__PURE__ */ a(
|
|
43
45
|
"div",
|
|
44
46
|
{
|
|
45
|
-
className:
|
|
47
|
+
className: i(
|
|
48
|
+
"bg-white",
|
|
46
49
|
"box-border",
|
|
47
|
-
"size-full",
|
|
48
50
|
"cursor-pointer",
|
|
49
|
-
"rounded-xl",
|
|
50
|
-
"border border-secondary-alt-600",
|
|
51
|
-
"peer-checked/plain-radio:border-primary-600",
|
|
52
|
-
"peer-checked/plain-radio:outline",
|
|
53
|
-
"peer-checked/plain-radio:outline",
|
|
54
|
-
"peer-checked/plain-radio:outline-primary-600",
|
|
55
|
-
"peer-hover/plain-radio:peer-checked/plain-radio:outline-primary-700",
|
|
56
|
-
"bg-white",
|
|
57
|
-
"peer-active/plain-radio:bg-secondary-alt-200",
|
|
58
|
-
"p-sm",
|
|
59
|
-
"peer-hover/plain-radio:border-primary-700",
|
|
60
|
-
"peer-focus/plain-radio:shadow-border-primary",
|
|
61
51
|
"flex",
|
|
62
|
-
"items-center",
|
|
63
52
|
"gap-sm",
|
|
53
|
+
"items-center",
|
|
54
|
+
"p-sm",
|
|
55
|
+
"peer-active:bg-secondary-alt-200",
|
|
56
|
+
"peer-active:ring-primary-800",
|
|
57
|
+
"peer-focus-within:outline-offset-4",
|
|
58
|
+
"peer-focus:outline-2",
|
|
59
|
+
"peer-focus:peer-checked:outline-primary-600",
|
|
60
|
+
"peer-hover:ring-primary-700",
|
|
61
|
+
"rounded-xl",
|
|
62
|
+
"size-full",
|
|
64
63
|
"text-sm",
|
|
64
|
+
r ? "ring-secondary-alt-300" : "peer-checked:ring-primary-600 peer-checked:outline peer-checked:outline-primary-600",
|
|
65
|
+
e ? "ring-2" : "ring",
|
|
65
66
|
{
|
|
66
|
-
"
|
|
67
|
-
"border-primary-300": r && o,
|
|
68
|
-
"border-secondary-alt-600": !r && !o,
|
|
69
|
-
"border-primary-600": !r && o
|
|
67
|
+
"ring-secondary-alt-600 hover:ring-secondary-500": !r && !e
|
|
70
68
|
}
|
|
71
69
|
),
|
|
72
70
|
children: [
|
|
73
|
-
/* @__PURE__ */ n(
|
|
74
|
-
|
|
71
|
+
/* @__PURE__ */ n("span", { className: i(
|
|
72
|
+
"bg-white",
|
|
73
|
+
"group-active:ring-primary-800",
|
|
74
|
+
"group-hover:ring-primary-700",
|
|
75
|
+
"pointer-events-none",
|
|
76
|
+
"relative",
|
|
77
|
+
"rounded-full",
|
|
78
|
+
"size-md",
|
|
79
|
+
e ? "ring-2" : "ring",
|
|
80
|
+
r ? "ring-secondary-alt-300" : "ring-primary-600",
|
|
81
|
+
{
|
|
82
|
+
"ring-secondary-alt-600 group-hover:ring-secondary-500 group-active:ring-secondary-500": !r && !e
|
|
83
|
+
}
|
|
84
|
+
), children: /* @__PURE__ */ n(
|
|
85
|
+
"span",
|
|
75
86
|
{
|
|
76
|
-
className:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
className: i(
|
|
88
|
+
"absolute",
|
|
89
|
+
"block",
|
|
90
|
+
"group-active:bg-primary-800",
|
|
91
|
+
"group-hover:bg-primary-700",
|
|
92
|
+
"left-xxs",
|
|
93
|
+
"pointer-events-none",
|
|
94
|
+
"rounded-full",
|
|
95
|
+
"size-xxs",
|
|
96
|
+
"top-xxs",
|
|
97
|
+
e ? "bg-primary-600" : "bg-white",
|
|
98
|
+
r ? "bg-secondary-alt-300" : "bg-primary-600",
|
|
99
|
+
{
|
|
100
|
+
"bg-white group-hover:bg-white group-active:bg-white": !r && !e
|
|
101
|
+
}
|
|
102
|
+
)
|
|
83
103
|
}
|
|
84
|
-
),
|
|
85
|
-
/* @__PURE__ */
|
|
86
|
-
|
|
87
|
-
/* @__PURE__ */ n("div", { className: "text-xs font-normal text-secondary-alt-400", children:
|
|
104
|
+
) }),
|
|
105
|
+
/* @__PURE__ */ a("div", { className: "flex flex-col", children: [
|
|
106
|
+
s,
|
|
107
|
+
t ? /* @__PURE__ */ n("div", { className: "text-xs font-normal text-secondary-alt-400", children: t }) : null
|
|
88
108
|
] })
|
|
89
109
|
]
|
|
90
110
|
}
|
|
@@ -93,6 +113,6 @@ const f = ({
|
|
|
93
113
|
}
|
|
94
114
|
);
|
|
95
115
|
export {
|
|
96
|
-
|
|
116
|
+
v as UiPlainRadio
|
|
97
117
|
};
|
|
98
118
|
//# sourceMappingURL=UiPlainRadio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiPlainRadio.js","sources":["../../../src/components/UiPlainRadio/UiPlainRadio.tsx"],"sourcesContent":["import React from \"react\";\nimport cx from \"classnames\";\
|
|
1
|
+
{"version":3,"file":"UiPlainRadio.js","sources":["../../../src/components/UiPlainRadio/UiPlainRadio.tsx"],"sourcesContent":["import React from \"react\";\nimport cx from \"classnames\";\n\nexport type TUiPlainRadio = {\n\tchildren?: React.ReactNode\n\tdisabled?: boolean;\n\tsubHeader?: string;\n\tvalue: string;\n\tname: string;\n\tclassName?: string\n\tchecked?: boolean\n\tonChange: (value: string) => void;\n\n} & Omit<React.InputHTMLAttributes<HTMLInputElement>, \"onChange\" | \"checked\" | \"value\" | \"name\">;\n\nexport const UiPlainRadio: React.FC<TUiPlainRadio> = ({\n\tid,\n\tchildren,\n\tdisabled,\n\tsubHeader,\n\tvalue,\n\tname,\n\tchecked = false,\n\tclassName,\n\tonChange,\n\t...rest\n\n}) => {\n\n\treturn (\n\t\t<label className={ cx(\n\t\t\t\"ui-plain-radio\",\n\t\t\t\"relative\",\n\t\t\t\"group\",\n\t\t\t{\n\t\t\t\t\"pointer-events-none opacity-50\": disabled\n\t\t\t},\n\t\t\tclassName\n\t\t) }\n\t\t>\n\t\t\t<input className={ cx(\n\t\t\t\t\" absolute\",\n\t\t\t\t\"appearance-none\",\n\t\t\t\t\"peer\",\n\t\t\t) }\n\t\t\tid={ id || `${name}-${value}` }\n\t\t\ttype=\"radio\"\n\t\t\tvalue={ value }\n\t\t\tchecked={ checked }\n\t\t\tonChange={ () => onChange(value) }\n\t\t\t{ ...rest }\n\t\t\t/>\n\n\t\t\t<div className={ cx(\n\t\t\t\t\"bg-white\",\n\t\t\t\t\"box-border\",\n\t\t\t\t\"cursor-pointer\",\n\t\t\t\t\"flex\",\n\t\t\t\t\"gap-sm\",\n\t\t\t\t\"items-center\",\n\t\t\t\t\"p-sm\",\n\t\t\t\t\"peer-active:bg-secondary-alt-200\",\n\t\t\t\t\"peer-active:ring-primary-800\",\n\t\t\t\t\"peer-focus-within:outline-offset-4\",\n\t\t\t\t\"peer-focus:outline-2\",\n\t\t\t\t\"peer-focus:peer-checked:outline-primary-600\",\n\t\t\t\t\"peer-hover:ring-primary-700\",\n\t\t\t\t\"rounded-xl\",\n\t\t\t\t\"size-full\",\n\t\t\t\t\"text-sm\",\n\t\t\t\tdisabled\n\t\t\t\t\t? \"ring-secondary-alt-300\"\n\t\t\t\t\t: \"peer-checked:ring-primary-600 peer-checked:outline peer-checked:outline-primary-600\",\n\t\t\t\tchecked\n\t\t\t\t\t? \"ring-2\"\n\t\t\t\t\t: \"ring\",\n\t\t\t\t{\n\t\t\t\t\t\"ring-secondary-alt-600 hover:ring-secondary-500\": !disabled && !checked,\n\t\t\t\t}\n\n\t\t\t) }\n\t\t\t>\n\n\t\t\t\t<span className={ cx(\n\t\t\t\t\t\"bg-white\",\n\t\t\t\t\t\"group-active:ring-primary-800\",\n\t\t\t\t\t\"group-hover:ring-primary-700\",\n\t\t\t\t\t\"pointer-events-none\",\n\t\t\t\t\t\"relative\",\n\t\t\t\t\t\"rounded-full\",\n\t\t\t\t\t\"size-md\",\n\t\t\t\t\tchecked\n\t\t\t\t\t\t? \"ring-2\"\n\t\t\t\t\t\t: \"ring\",\n\t\t\t\t\tdisabled\n\t\t\t\t\t\t? \"ring-secondary-alt-300\"\n\t\t\t\t\t\t: \"ring-primary-600\",\n\n\t\t\t\t\t{\n\t\t\t\t\t\t\"ring-secondary-alt-600 group-hover:ring-secondary-500 group-active:ring-secondary-500\": !disabled && !checked,\n\t\t\t\t\t}\n\n\t\t\t\t) }>\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName={ cx(\n\t\t\t\t\t\t\t\"absolute\",\n\t\t\t\t\t\t\t\"block\",\n\t\t\t\t\t\t\t\"group-active:bg-primary-800\",\n\t\t\t\t\t\t\t\"group-hover:bg-primary-700\",\n\t\t\t\t\t\t\t\"left-xxs\",\n\t\t\t\t\t\t\t\"pointer-events-none\",\n\t\t\t\t\t\t\t\"rounded-full\",\n\t\t\t\t\t\t\t\"size-xxs\",\n\t\t\t\t\t\t\t\"top-xxs\",\n\t\t\t\t\t\t\tchecked\n\t\t\t\t\t\t\t\t? \"bg-primary-600\"\n\t\t\t\t\t\t\t\t: \"bg-white\",\n\t\t\t\t\t\t\tdisabled\n\t\t\t\t\t\t\t\t? \"bg-secondary-alt-300\"\n\t\t\t\t\t\t\t\t: \"bg-primary-600\",\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\"bg-white group-hover:bg-white group-active:bg-white\": !disabled && !checked,\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t) }/>\n\n\t\t\t\t</span>\n\n\t\t\t\t<div className=\"flex flex-col\">\n\t\t\t\t\t{ children }\n\n\t\t\t\t\t{\n\t\t\t\t\t\tsubHeader\n\t\t\t\t\t\t\t? <div className=\"text-xs font-normal text-secondary-alt-400\">{ subHeader }</div>\n\t\t\t\t\t\t\t: null\n\t\t\t\t\t}\n\n\t\t\t\t</div>\n\n\t\t\t</div>\n\n\t\t</label>\n\n\t);\n};\n"],"names":["UiPlainRadio","id","children","disabled","subHeader","value","name","checked","className","onChange","rest","jsxs","cx","jsx"],"mappings":";;;AAeO,MAAMA,IAAwC,CAAC;AAAA,EACrD,IAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AAAA,EACA,MAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,WAAAC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGC;AAEJ,MAGE,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IAAM,WAAYC;AAAA,MAClB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,QACC,kCAAkCT;AAAA,MACnC;AAAA,MACAK;AAAA,IACD;AAAA,IAEC,UAAA;AAAA,MAAA,gBAAAK;AAAA,QAAC;AAAA,QAAA;AAAA,UAAM,WAAYD;AAAA,YAClB;AAAA,YACA;AAAA,YACA;AAAA,UACD;AAAA,UACA,IAAKX,KAAO,GAAGK,CAAI,IAAID,CAAK;AAAA,UAC5B,MAAK;AAAA,UACL,OAAAA;AAAA,UACA,SAAAE;AAAA,UACA,UAAW,MAAME,EAASJ,CAAK;AAAA,UAC7B,GAAGK;AAAA,QAAA;AAAA,MACL;AAAA,MAEA,gBAAAC;AAAA,QAAC;AAAA,QAAA;AAAA,UAAI,WAAYC;AAAA,YAChB;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACAT,IACG,2BACA;AAAA,YACHI,IACG,WACA;AAAA,YACH;AAAA,cACC,mDAAmD,CAACJ,KAAY,CAACI;AAAA,YAAA;AAAA,UAGnE;AAAA,UAGC,UAAA;AAAA,YAAA,gBAAAM,EAAC,UAAK,WAAYD;AAAA,cACjB;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cACAL,IACG,WACA;AAAA,cACHJ,IACG,2BACA;AAAA,cAEH;AAAA,gBACC,0FAA0F,CAACA,KAAY,CAACI;AAAA,cAAA;AAAA,YAIzG,GAAA,UAAA,gBAAAM;AAAA,cAAC;AAAA,cAAA;AAAA,gBACA,WAAYD;AAAA,kBACX;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA;AAAA,kBACA;AAAA,kBACAL,IACG,mBACA;AAAA,kBACHJ,IACG,yBACA;AAAA,kBACH;AAAA,oBACC,uDAAuD,CAACA,KAAY,CAACI;AAAA,kBAAA;AAAA,gBACtE;AAAA,cAED;AAAA,YAAA,GAEF;AAAA,YAEA,gBAAAI,EAAC,OAAI,EAAA,WAAU,iBACZ,UAAA;AAAA,cAAAT;AAAA,cAGDE,IACI,gBAAAS,EAAA,OAAA,EAAI,WAAU,8CAA+C,aAAW,IACzE;AAAA,YAAA,EAGL,CAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA;AAAA,IAED;AAAA,EAAA;AAED;"}
|
|
@@ -1,61 +1,62 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as b, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import "react";
|
|
3
|
-
import
|
|
3
|
+
import s from "classnames";
|
|
4
4
|
import { EJustify as e } from "../../_types/align.js";
|
|
5
|
-
import '../../assets/UiRadio.css';const
|
|
6
|
-
UiRadio__custom:
|
|
7
|
-
UiRadio__dot:
|
|
8
|
-
},
|
|
5
|
+
import '../../assets/UiRadio.css';const R = "_UiRadio__custom_wei69_1", g = "_UiRadio__dot_wei69_4", c = {
|
|
6
|
+
UiRadio__custom: R,
|
|
7
|
+
UiRadio__dot: g
|
|
8
|
+
}, h = {
|
|
9
9
|
[e.START]: "justify-start",
|
|
10
10
|
[e.END]: "justify-end",
|
|
11
11
|
[e.CENTER]: "justify-center",
|
|
12
12
|
[e.BETWEEN]: "justify-between",
|
|
13
13
|
[e.AROUND]: "justify-around",
|
|
14
14
|
[e.EVENLY]: "justify-evenly"
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
}, x = ({
|
|
16
|
+
id: n,
|
|
17
|
+
name: t,
|
|
18
|
+
value: a,
|
|
19
|
+
invertOrder: l = !1,
|
|
20
|
+
justify: p = e.START,
|
|
20
21
|
disabled: r = !1,
|
|
21
|
-
onChange:
|
|
22
|
-
checked:
|
|
23
|
-
children:
|
|
24
|
-
className:
|
|
25
|
-
tabIndex:
|
|
22
|
+
onChange: i,
|
|
23
|
+
checked: u = !1,
|
|
24
|
+
children: d,
|
|
25
|
+
className: m,
|
|
26
|
+
tabIndex: _
|
|
26
27
|
}) => {
|
|
27
|
-
const
|
|
28
|
-
!r &&
|
|
28
|
+
const f = (y) => {
|
|
29
|
+
!r && i && i(y.target.value);
|
|
29
30
|
};
|
|
30
|
-
return /* @__PURE__ */
|
|
31
|
+
return /* @__PURE__ */ b("label", { className: s(
|
|
31
32
|
"UiRadio",
|
|
32
33
|
"group",
|
|
33
34
|
"grid",
|
|
34
35
|
"grid-flow-col",
|
|
35
36
|
"cursor-pointer",
|
|
36
|
-
|
|
37
|
+
h[p],
|
|
37
38
|
{
|
|
38
39
|
"pointer-events-none": r,
|
|
39
|
-
"items-center gap-xxs":
|
|
40
|
+
"items-center gap-xxs": d
|
|
40
41
|
}
|
|
41
42
|
), children: [
|
|
42
43
|
/* @__PURE__ */ o(
|
|
43
44
|
"input",
|
|
44
45
|
{
|
|
45
|
-
id:
|
|
46
|
-
name:
|
|
46
|
+
id: n || `${t}-${a}`,
|
|
47
|
+
name: t.toString(),
|
|
47
48
|
type: "radio",
|
|
48
|
-
value:
|
|
49
|
+
value: a,
|
|
49
50
|
disabled: r,
|
|
50
|
-
checked:
|
|
51
|
-
onChange:
|
|
51
|
+
checked: u,
|
|
52
|
+
onChange: f,
|
|
52
53
|
className: "peer absolute appearance-none",
|
|
53
|
-
tabIndex:
|
|
54
|
+
tabIndex: _
|
|
54
55
|
}
|
|
55
56
|
),
|
|
56
|
-
/* @__PURE__ */ o("span", { className:
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
/* @__PURE__ */ o("span", { className: s(
|
|
58
|
+
c.UiRadio__custom,
|
|
59
|
+
l && "order-last",
|
|
59
60
|
"relative",
|
|
60
61
|
"block",
|
|
61
62
|
"size-md",
|
|
@@ -72,9 +73,9 @@ import '../../assets/UiRadio.css';const b = "_UiRadio__custom_wei69_1", R = "_Ui
|
|
|
72
73
|
"peer-focus:shadow-border-primary",
|
|
73
74
|
"peer-disabled:border-secondary-alt-400",
|
|
74
75
|
"peer-disabled:bg-secondary-alt-200",
|
|
75
|
-
|
|
76
|
-
), children: /* @__PURE__ */ o("span", { className:
|
|
77
|
-
|
|
76
|
+
m
|
|
77
|
+
), children: /* @__PURE__ */ o("span", { className: s(
|
|
78
|
+
c.UiRadio__dot,
|
|
78
79
|
"absolute",
|
|
79
80
|
"left-2/4",
|
|
80
81
|
"top-2/4",
|
|
@@ -83,10 +84,10 @@ import '../../assets/UiRadio.css';const b = "_UiRadio__custom_wei69_1", R = "_Ui
|
|
|
83
84
|
"rounded-full",
|
|
84
85
|
"bg-primary"
|
|
85
86
|
) }) }),
|
|
86
|
-
|
|
87
|
+
d
|
|
87
88
|
] });
|
|
88
89
|
};
|
|
89
90
|
export {
|
|
90
|
-
|
|
91
|
+
x as UiRadio
|
|
91
92
|
};
|
|
92
93
|
//# sourceMappingURL=UiRadio.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiRadio.js","sources":["../../../src/components/UiRadio/UiRadio.tsx"],"sourcesContent":["import React from \"react\";\nimport cx from \"classnames\";\nimport styles from \"./UiRadio.module.css\";\nimport { EJustify } from \"../../_types/align\";\n\nexport type TUiRadioProps = {\n\tchildren?: React.ReactNode;\n\tname: string;\n\tvalue: string;\n\tinvertOrder?: boolean;\n\tjustify?: EJustify;\n\tdisabled?: boolean;\n\tchecked?: boolean;\n\tonChange: (value: string) => void;\n} & Omit<React.InputHTMLAttributes<HTMLInputElement>, \"onChange\" | \"checked\" | \"value\" | \"name\">;\n\nconst justificationClasses = {\n\t[EJustify.START]: \"justify-start\",\n\t[EJustify.END]: \"justify-end\",\n\t[EJustify.CENTER]: \"justify-center\",\n\t[EJustify.BETWEEN]: \"justify-between\",\n\t[EJustify.AROUND]: \"justify-around\",\n\t[EJustify.EVENLY]: \"justify-evenly\"\n};\n\nexport const UiRadio: React.FC<TUiRadioProps> = ({\n\tname,\n\tvalue,\n\tinvertOrder = false,\n\tjustify = EJustify.START,\n\tdisabled = false,\n\tonChange,\n\tchecked = false,\n\tchildren,\n\tclassName,\n\ttabIndex\n}) => {\n\n\tconst handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n\t\tif (!disabled && onChange) {\n\t\t\tonChange(event.target.value);\n\t\t}\n\t};\n\n\treturn (\n\t\t<label className={\n\t\t\tcx(\"UiRadio\",\n\t\t\t\t\"group\",\n\t\t\t\t\"grid\",\n\t\t\t\t\"grid-flow-col\",\n\t\t\t\t\"cursor-pointer\",\n\t\t\t\tjustificationClasses[justify],\n\t\t\t\t{\n\t\t\t\t\t\"pointer-events-none\": disabled,\n\t\t\t\t\t\"items-center gap-xxs\": children\n\t\t\t\t}\n\t\t\t) }>\n\t\t\t<input\n\t\t\t\tid={ value }\n\t\t\t\tname={ name.toString() }\n\t\t\t\ttype=\"radio\"\n\t\t\t\tvalue={ value }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\tchecked={ checked }\n\t\t\t\tonChange={ handleChange }\n\t\t\t\tclassName=\"peer absolute appearance-none\"\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t/>\n\t\t\t<span className={ cx(\n\t\t\t\tstyles.UiRadio__custom,\n\t\t\t\tinvertOrder && \"order-last\",\n\t\t\t\t\"relative\",\n\t\t\t\t\"block\",\n\t\t\t\t\"size-md\",\n\t\t\t\t\"rounded-full\",\n\t\t\t\t\"border\",\n\t\t\t\t\"border-secondary-alt\",\n\t\t\t\t\"bg-white\",\n\t\t\t\t\"group-hover:border-secondary-alt-700\",\n\t\t\t\t\"group-focus:border-secondary-alt-700\",\n\t\t\t\t\"peer-checked:border-2\",\n\t\t\t\t\"peer-checked:border-primary\",\n\t\t\t\t\"hover:peer-checked:border-primary-600\",\n\t\t\t\t\"active:peer-checked:border-primary-800\",\n\t\t\t\t\"peer-focus:shadow-border-primary\",\n\t\t\t\t\"peer-disabled:border-secondary-alt-400\",\n\t\t\t\t\"peer-disabled:bg-secondary-alt-200\",\n\t\t\t\tclassName,\n\t\t\t) }>\n\t\t\t\t<span className={ cx(\n\t\t\t\t\tstyles.UiRadio__dot,\n\t\t\t\t\t\"absolute\",\n\t\t\t\t\t\"left-2/4\",\n\t\t\t\t\t\"top-2/4\",\n\t\t\t\t\t\"block\",\n\t\t\t\t\t\"size-xxs\",\n\t\t\t\t\t\"rounded-full\",\n\t\t\t\t\t\"bg-primary\",\n\t\t\t\t) } />\n\t\t\t</span>\n\t\t\t{ children }\n\t\t</label>\n\t);\n};\n"],"names":["justificationClasses","EJustify","UiRadio","name","value","invertOrder","justify","disabled","onChange","checked","children","className","tabIndex","handleChange","event","jsxs","cx","jsx","styles"],"mappings":";;;;;;;GAgBMA,IAAuB;AAAA,EAC5B,CAACC,EAAS,KAAK,GAAG;AAAA,EAClB,CAACA,EAAS,GAAG,GAAG;AAAA,EAChB,CAACA,EAAS,MAAM,GAAG;AAAA,EACnB,CAACA,EAAS,OAAO,GAAG;AAAA,EACpB,CAACA,EAAS,MAAM,GAAG;AAAA,EACnB,CAACA,EAAS,MAAM,GAAG;AACpB,GAEaC,IAAmC,CAAC;AAAA,EAChD,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,SAAAC,
|
|
1
|
+
{"version":3,"file":"UiRadio.js","sources":["../../../src/components/UiRadio/UiRadio.tsx"],"sourcesContent":["import React from \"react\";\nimport cx from \"classnames\";\nimport styles from \"./UiRadio.module.css\";\nimport { EJustify } from \"../../_types/align\";\n\nexport type TUiRadioProps = {\n\tchildren?: React.ReactNode;\n\tname: string;\n\tvalue: string;\n\tinvertOrder?: boolean;\n\tjustify?: EJustify;\n\tdisabled?: boolean;\n\tchecked?: boolean;\n\tonChange: (value: string) => void;\n} & Omit<React.InputHTMLAttributes<HTMLInputElement>, \"onChange\" | \"checked\" | \"value\" | \"name\">;\n\nconst justificationClasses = {\n\t[EJustify.START]: \"justify-start\",\n\t[EJustify.END]: \"justify-end\",\n\t[EJustify.CENTER]: \"justify-center\",\n\t[EJustify.BETWEEN]: \"justify-between\",\n\t[EJustify.AROUND]: \"justify-around\",\n\t[EJustify.EVENLY]: \"justify-evenly\"\n};\n\nexport const UiRadio: React.FC<TUiRadioProps> = ({\n\tid,\n\tname,\n\tvalue,\n\tinvertOrder = false,\n\tjustify = EJustify.START,\n\tdisabled = false,\n\tonChange,\n\tchecked = false,\n\tchildren,\n\tclassName,\n\ttabIndex\n}) => {\n\n\tconst handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {\n\t\tif (!disabled && onChange) {\n\t\t\tonChange(event.target.value);\n\t\t}\n\t};\n\n\treturn (\n\t\t<label className={\n\t\t\tcx(\"UiRadio\",\n\t\t\t\t\"group\",\n\t\t\t\t\"grid\",\n\t\t\t\t\"grid-flow-col\",\n\t\t\t\t\"cursor-pointer\",\n\t\t\t\tjustificationClasses[justify],\n\t\t\t\t{\n\t\t\t\t\t\"pointer-events-none\": disabled,\n\t\t\t\t\t\"items-center gap-xxs\": children\n\t\t\t\t}\n\t\t\t) }>\n\t\t\t<input\n\t\t\t\tid={ id || `${name}-${value}` }\n\t\t\t\tname={ name.toString() }\n\t\t\t\ttype=\"radio\"\n\t\t\t\tvalue={ value }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\tchecked={ checked }\n\t\t\t\tonChange={ handleChange }\n\t\t\t\tclassName=\"peer absolute appearance-none\"\n\t\t\t\ttabIndex={ tabIndex }\n\t\t\t/>\n\t\t\t<span className={ cx(\n\t\t\t\tstyles.UiRadio__custom,\n\t\t\t\tinvertOrder && \"order-last\",\n\t\t\t\t\"relative\",\n\t\t\t\t\"block\",\n\t\t\t\t\"size-md\",\n\t\t\t\t\"rounded-full\",\n\t\t\t\t\"border\",\n\t\t\t\t\"border-secondary-alt\",\n\t\t\t\t\"bg-white\",\n\t\t\t\t\"group-hover:border-secondary-alt-700\",\n\t\t\t\t\"group-focus:border-secondary-alt-700\",\n\t\t\t\t\"peer-checked:border-2\",\n\t\t\t\t\"peer-checked:border-primary\",\n\t\t\t\t\"hover:peer-checked:border-primary-600\",\n\t\t\t\t\"active:peer-checked:border-primary-800\",\n\t\t\t\t\"peer-focus:shadow-border-primary\",\n\t\t\t\t\"peer-disabled:border-secondary-alt-400\",\n\t\t\t\t\"peer-disabled:bg-secondary-alt-200\",\n\t\t\t\tclassName,\n\t\t\t) }>\n\t\t\t\t<span className={ cx(\n\t\t\t\t\tstyles.UiRadio__dot,\n\t\t\t\t\t\"absolute\",\n\t\t\t\t\t\"left-2/4\",\n\t\t\t\t\t\"top-2/4\",\n\t\t\t\t\t\"block\",\n\t\t\t\t\t\"size-xxs\",\n\t\t\t\t\t\"rounded-full\",\n\t\t\t\t\t\"bg-primary\",\n\t\t\t\t) } />\n\t\t\t</span>\n\t\t\t{ children }\n\t\t</label>\n\t);\n};\n"],"names":["justificationClasses","EJustify","UiRadio","id","name","value","invertOrder","justify","disabled","onChange","checked","children","className","tabIndex","handleChange","event","jsxs","cx","jsx","styles"],"mappings":";;;;;;;GAgBMA,IAAuB;AAAA,EAC5B,CAACC,EAAS,KAAK,GAAG;AAAA,EAClB,CAACA,EAAS,GAAG,GAAG;AAAA,EAChB,CAACA,EAAS,MAAM,GAAG;AAAA,EACnB,CAACA,EAAS,OAAO,GAAG;AAAA,EACpB,CAACA,EAAS,MAAM,GAAG;AAAA,EACnB,CAACA,EAAS,MAAM,GAAG;AACpB,GAEaC,IAAmC,CAAC;AAAA,EAChD,IAAAC;AAAA,EACA,MAAAC;AAAA,EACA,OAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,SAAAC,IAAUN,EAAS;AAAA,EACnB,UAAAO,IAAW;AAAA,EACX,UAAAC;AAAA,EACA,SAAAC,IAAU;AAAA,EACV,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,UAAAC;AACD,MAAM;AAEC,QAAAC,IAAe,CAACC,MAA+C;AAChE,IAAA,CAACP,KAAYC,KACPA,EAAAM,EAAM,OAAO,KAAK;AAAA,EAE7B;AAGC,SAAA,gBAAAC,EAAC,WAAM,WACNC;AAAA,IAAG;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACAjB,EAAqBO,CAAO;AAAA,IAC5B;AAAA,MACC,uBAAuBC;AAAA,MACvB,wBAAwBG;AAAA,IAAA;AAAA,EAG1B,GAAA,UAAA;AAAA,IAAA,gBAAAO;AAAA,MAAC;AAAA,MAAA;AAAA,QACA,IAAKf,KAAM,GAAGC,CAAI,IAAIC,CAAK;AAAA,QAC3B,MAAOD,EAAK,SAAS;AAAA,QACrB,MAAK;AAAA,QACL,OAAAC;AAAA,QACA,UAAAG;AAAA,QACA,SAAAE;AAAA,QACA,UAAWI;AAAA,QACX,WAAU;AAAA,QACV,UAAAD;AAAA,MAAA;AAAA,IACD;AAAA,IACA,gBAAAK,EAAC,UAAK,WAAYD;AAAA,MACjBE,EAAO;AAAA,MACPb,KAAe;AAAA,MACf;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACAM;AAAA,IACD,GACC,UAAC,gBAAAM,EAAA,QAAA,EAAK,WAAYD;AAAA,MACjBE,EAAO;AAAA,MACP;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,OACG,EACL,CAAA;AAAA,IACER;AAAA,EAAA,GACH;AAEF;"}
|