@versini/ui-toggle 4.0.1 → 4.0.3
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/components/Toggle/Toggle.js +108 -3
- package/dist/index.js +6 -111
- package/package.json +4 -4
|
@@ -1,5 +1,110 @@
|
|
|
1
|
-
import "react/jsx-runtime";
|
|
2
|
-
import
|
|
1
|
+
import { jsxs as p, jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import t from "clsx";
|
|
3
|
+
const b = "av-toggle", k = () => t("peer", "h-6", "w-11", "rounded-full"), h = ({
|
|
4
|
+
focusMode: e
|
|
5
|
+
}) => t(
|
|
6
|
+
"peer-focus:outline",
|
|
7
|
+
"peer-focus:outline-2",
|
|
8
|
+
"peer-focus:outline-offset-2",
|
|
9
|
+
{
|
|
10
|
+
"peer-focus:outline-focus-dark": e === "dark",
|
|
11
|
+
"peer-focus:outline-focus-light": e === "light",
|
|
12
|
+
"peer-focus:outline-focus-light dark:peer-focus:outline-focus-dark": e === "alt-system",
|
|
13
|
+
"peer-focus:outline-focus-dark dark:peer-focus:outline-focus-light": e === "system"
|
|
14
|
+
}
|
|
15
|
+
), m = () => t(
|
|
16
|
+
"peer-checked:after:translate-x-full",
|
|
17
|
+
// background color when checked
|
|
18
|
+
"peer-checked:bg-violet-500",
|
|
19
|
+
// knob circle and border color when checked
|
|
20
|
+
"peer-checked:after:bg-white",
|
|
21
|
+
"peer-checked:after:border-white"
|
|
22
|
+
), y = () => t(
|
|
23
|
+
"after:left-[2px]",
|
|
24
|
+
"after:top-[2px]",
|
|
25
|
+
"after:border",
|
|
26
|
+
"after:border-surface-light dark:after:border-surface-medium",
|
|
27
|
+
"after:bg-surface-light dark:after:bg-surface-medium",
|
|
28
|
+
"after:absolute",
|
|
29
|
+
"after:h-5",
|
|
30
|
+
"after:w-5",
|
|
31
|
+
"after:rounded-full",
|
|
32
|
+
"after:transition-all",
|
|
33
|
+
"after:content-['']"
|
|
34
|
+
), x = ({
|
|
35
|
+
mode: e,
|
|
36
|
+
noBorder: r
|
|
37
|
+
}) => t({
|
|
38
|
+
border: !r,
|
|
39
|
+
"border-border-dark bg-surface-medium": e === "light",
|
|
40
|
+
"border-border-light bg-surface-darker": e === "dark",
|
|
41
|
+
"border-border-light bg-surface-darker dark:border-border-dark dark:bg-surface-medium": e === "alt-system",
|
|
42
|
+
"border-border-dark bg-surface-medium dark:border-border-light dark:bg-surface-darker": e === "system"
|
|
43
|
+
}), C = ({
|
|
44
|
+
mode: e,
|
|
45
|
+
labelHidden: r
|
|
46
|
+
}) => r ? "sr-only" : t("ml-2 text-sm", {
|
|
47
|
+
"text-copy-dark": e === "light",
|
|
48
|
+
"text-copy-lighter": e === "dark",
|
|
49
|
+
"text-copy-lighter dark:text-copy-dark": e === "alt-system",
|
|
50
|
+
"text-copy-dark dark:text-copy-lighter": e === "system"
|
|
51
|
+
}), T = ({ className: e }) => t(
|
|
52
|
+
b,
|
|
53
|
+
"relative flex cursor-pointer items-center",
|
|
54
|
+
e
|
|
55
|
+
), w = ({
|
|
56
|
+
mode: e,
|
|
57
|
+
focusMode: r,
|
|
58
|
+
labelHidden: a,
|
|
59
|
+
className: l,
|
|
60
|
+
noBorder: o
|
|
61
|
+
}) => ({
|
|
62
|
+
toggle: t(
|
|
63
|
+
k(),
|
|
64
|
+
x({ mode: e, noBorder: o }),
|
|
65
|
+
h({ focusMode: r }),
|
|
66
|
+
y(),
|
|
67
|
+
m()
|
|
68
|
+
),
|
|
69
|
+
label: C({ mode: e, labelHidden: a }),
|
|
70
|
+
input: "peer sr-only",
|
|
71
|
+
wrapper: T({ className: l })
|
|
72
|
+
}), K = ({
|
|
73
|
+
checked: e = !1,
|
|
74
|
+
onChange: r,
|
|
75
|
+
label: a,
|
|
76
|
+
labelHidden: l = !1,
|
|
77
|
+
name: o,
|
|
78
|
+
mode: u = "system",
|
|
79
|
+
focusMode: g = "system",
|
|
80
|
+
className: f,
|
|
81
|
+
noBorder: d = !1
|
|
82
|
+
}) => {
|
|
83
|
+
const s = w({
|
|
84
|
+
mode: u,
|
|
85
|
+
focusMode: g,
|
|
86
|
+
labelHidden: l,
|
|
87
|
+
className: f,
|
|
88
|
+
noBorder: d
|
|
89
|
+
}), n = (i) => {
|
|
90
|
+
r == null || r(i.target.checked);
|
|
91
|
+
};
|
|
92
|
+
return /* @__PURE__ */ p("label", { className: s.wrapper, children: [
|
|
93
|
+
/* @__PURE__ */ c(
|
|
94
|
+
"input",
|
|
95
|
+
{
|
|
96
|
+
name: o,
|
|
97
|
+
checked: e,
|
|
98
|
+
type: "checkbox",
|
|
99
|
+
className: s.input,
|
|
100
|
+
onChange: n
|
|
101
|
+
}
|
|
102
|
+
),
|
|
103
|
+
/* @__PURE__ */ c("div", { className: s.toggle }),
|
|
104
|
+
/* @__PURE__ */ c("span", { className: s.label, children: a })
|
|
105
|
+
] });
|
|
106
|
+
};
|
|
3
107
|
export {
|
|
4
|
-
|
|
108
|
+
b as TOGGLE_CLASSNAME,
|
|
109
|
+
K as Toggle
|
|
5
110
|
};
|
package/dist/index.js
CHANGED
|
@@ -1,123 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import t from "clsx";
|
|
1
|
+
import { TOGGLE_CLASSNAME as o, Toggle as r } from "./components/Toggle/Toggle.js";
|
|
3
2
|
/*!
|
|
4
|
-
@versini/ui-toggle v4.0.
|
|
3
|
+
@versini/ui-toggle v4.0.3
|
|
5
4
|
© 2025 gizmette.com
|
|
6
5
|
*/
|
|
7
6
|
try {
|
|
8
7
|
window.__VERSINI_UI_TOGGLE__ || (window.__VERSINI_UI_TOGGLE__ = {
|
|
9
|
-
version: "4.0.
|
|
10
|
-
buildTime: "
|
|
8
|
+
version: "4.0.3",
|
|
9
|
+
buildTime: "05/26/2025 03:48 PM EDT",
|
|
11
10
|
homepage: "https://github.com/aversini/ui-components",
|
|
12
11
|
license: "MIT"
|
|
13
12
|
});
|
|
14
13
|
} catch {
|
|
15
14
|
}
|
|
16
|
-
const b = "av-toggle", k = () => t("peer", "h-6", "w-11", "rounded-full"), h = ({
|
|
17
|
-
focusMode: e
|
|
18
|
-
}) => t(
|
|
19
|
-
"peer-focus:outline",
|
|
20
|
-
"peer-focus:outline-2",
|
|
21
|
-
"peer-focus:outline-offset-2",
|
|
22
|
-
{
|
|
23
|
-
"peer-focus:outline-focus-dark": e === "dark",
|
|
24
|
-
"peer-focus:outline-focus-light": e === "light",
|
|
25
|
-
"peer-focus:outline-focus-light dark:peer-focus:outline-focus-dark": e === "alt-system",
|
|
26
|
-
"peer-focus:outline-focus-dark dark:peer-focus:outline-focus-light": e === "system"
|
|
27
|
-
}
|
|
28
|
-
), m = () => t(
|
|
29
|
-
"peer-checked:after:translate-x-full",
|
|
30
|
-
// background color when checked
|
|
31
|
-
"peer-checked:bg-violet-500",
|
|
32
|
-
// knob circle and border color when checked
|
|
33
|
-
"peer-checked:after:bg-white",
|
|
34
|
-
"peer-checked:after:border-white"
|
|
35
|
-
), y = () => t(
|
|
36
|
-
"after:left-[2px]",
|
|
37
|
-
"after:top-[2px]",
|
|
38
|
-
"after:border",
|
|
39
|
-
"after:border-surface-light dark:after:border-surface-medium",
|
|
40
|
-
"after:bg-surface-light dark:after:bg-surface-medium",
|
|
41
|
-
"after:absolute",
|
|
42
|
-
"after:h-5",
|
|
43
|
-
"after:w-5",
|
|
44
|
-
"after:rounded-full",
|
|
45
|
-
"after:transition-all",
|
|
46
|
-
"after:content-['']"
|
|
47
|
-
), x = ({
|
|
48
|
-
mode: e,
|
|
49
|
-
noBorder: r
|
|
50
|
-
}) => t({
|
|
51
|
-
border: !r,
|
|
52
|
-
"border-border-dark bg-surface-medium": e === "light",
|
|
53
|
-
"border-border-light bg-surface-darker": e === "dark",
|
|
54
|
-
"border-border-light bg-surface-darker dark:border-border-dark dark:bg-surface-medium": e === "alt-system",
|
|
55
|
-
"border-border-dark bg-surface-medium dark:border-border-light dark:bg-surface-darker": e === "system"
|
|
56
|
-
}), T = ({
|
|
57
|
-
mode: e,
|
|
58
|
-
labelHidden: r
|
|
59
|
-
}) => r ? "sr-only" : t("ml-2 text-sm", {
|
|
60
|
-
"text-copy-dark": e === "light",
|
|
61
|
-
"text-copy-lighter": e === "dark",
|
|
62
|
-
"text-copy-lighter dark:text-copy-dark": e === "alt-system",
|
|
63
|
-
"text-copy-dark dark:text-copy-lighter": e === "system"
|
|
64
|
-
}), _ = ({ className: e }) => t(
|
|
65
|
-
b,
|
|
66
|
-
"relative flex cursor-pointer items-center",
|
|
67
|
-
e
|
|
68
|
-
), w = ({
|
|
69
|
-
mode: e,
|
|
70
|
-
focusMode: r,
|
|
71
|
-
labelHidden: a,
|
|
72
|
-
className: o,
|
|
73
|
-
noBorder: l
|
|
74
|
-
}) => ({
|
|
75
|
-
toggle: t(
|
|
76
|
-
k(),
|
|
77
|
-
x({ mode: e, noBorder: l }),
|
|
78
|
-
h({ focusMode: r }),
|
|
79
|
-
y(),
|
|
80
|
-
m()
|
|
81
|
-
),
|
|
82
|
-
label: T({ mode: e, labelHidden: a }),
|
|
83
|
-
input: "peer sr-only",
|
|
84
|
-
wrapper: _({ className: o })
|
|
85
|
-
}), I = ({
|
|
86
|
-
checked: e = !1,
|
|
87
|
-
onChange: r,
|
|
88
|
-
label: a,
|
|
89
|
-
labelHidden: o = !1,
|
|
90
|
-
name: l,
|
|
91
|
-
mode: u = "system",
|
|
92
|
-
focusMode: g = "system",
|
|
93
|
-
className: i,
|
|
94
|
-
noBorder: n = !1
|
|
95
|
-
}) => {
|
|
96
|
-
const s = w({
|
|
97
|
-
mode: u,
|
|
98
|
-
focusMode: g,
|
|
99
|
-
labelHidden: o,
|
|
100
|
-
className: i,
|
|
101
|
-
noBorder: n
|
|
102
|
-
}), d = (f) => {
|
|
103
|
-
r == null || r(f.target.checked);
|
|
104
|
-
};
|
|
105
|
-
return /* @__PURE__ */ p("label", { className: s.wrapper, children: [
|
|
106
|
-
/* @__PURE__ */ c(
|
|
107
|
-
"input",
|
|
108
|
-
{
|
|
109
|
-
name: l,
|
|
110
|
-
checked: e,
|
|
111
|
-
type: "checkbox",
|
|
112
|
-
className: s.input,
|
|
113
|
-
onChange: d
|
|
114
|
-
}
|
|
115
|
-
),
|
|
116
|
-
/* @__PURE__ */ c("div", { className: s.toggle }),
|
|
117
|
-
/* @__PURE__ */ c("span", { className: s.label, children: a })
|
|
118
|
-
] });
|
|
119
|
-
};
|
|
120
15
|
export {
|
|
121
|
-
|
|
122
|
-
|
|
16
|
+
o as TOGGLE_CLASSNAME,
|
|
17
|
+
r as Toggle
|
|
123
18
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/ui-toggle",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -39,15 +39,15 @@
|
|
|
39
39
|
"react-dom": "^18.3.1 || ^19.0.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@versini/ui-types": "5.0.
|
|
42
|
+
"@versini/ui-types": "5.0.3"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@tailwindcss/typography": "0.5.16",
|
|
46
46
|
"clsx": "2.1.1",
|
|
47
|
-
"tailwindcss": "4.1.
|
|
47
|
+
"tailwindcss": "4.1.7"
|
|
48
48
|
},
|
|
49
49
|
"sideEffects": [
|
|
50
50
|
"**/*.css"
|
|
51
51
|
],
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "863a399128080a19f2668e458d495110aa0f68f8"
|
|
53
53
|
}
|