@versini/ui-toggle 1.1.0 → 1.2.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/dist/index.d.ts +2 -2
- package/dist/index.js +41 -27
- package/package.json +6 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import {
|
|
2
|
+
import { SpacingTypes } from '@versini/ui-spacing-types';
|
|
3
3
|
|
|
4
4
|
declare const TOGGLE_CLASSNAME = "av-toggle";
|
|
5
5
|
|
|
@@ -41,7 +41,7 @@ type ToggleProps = {
|
|
|
41
41
|
* @default false
|
|
42
42
|
*/
|
|
43
43
|
noBorder?: boolean;
|
|
44
|
-
} &
|
|
44
|
+
} & SpacingTypes.Props;
|
|
45
45
|
|
|
46
46
|
declare const Toggle: ({ checked, onChange, label, labelHidden, name, mode, focusMode, spacing, noBorder, }: ToggleProps) => react_jsx_runtime.JSX.Element;
|
|
47
47
|
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,33 @@
|
|
|
1
|
-
import { jsxs as p, jsx as
|
|
1
|
+
import { jsxs as p, jsx as i } from "react/jsx-runtime";
|
|
2
2
|
import s from "clsx";
|
|
3
3
|
/*!
|
|
4
|
-
@versini/ui-toggle v1.
|
|
4
|
+
@versini/ui-toggle v1.2.0
|
|
5
5
|
© 2024 gizmette.com
|
|
6
6
|
*/
|
|
7
7
|
try {
|
|
8
8
|
window.__VERSINI_UI_TOGGLE__ || (window.__VERSINI_UI_TOGGLE__ = {
|
|
9
|
-
version: "1.
|
|
10
|
-
buildTime: "12/
|
|
9
|
+
version: "1.2.0",
|
|
10
|
+
buildTime: "12/24/2024 06:47 PM EST",
|
|
11
11
|
homepage: "https://github.com/aversini/ui-components",
|
|
12
12
|
license: "MIT"
|
|
13
13
|
});
|
|
14
14
|
} catch {
|
|
15
15
|
}
|
|
16
|
-
const b = "av-toggle"
|
|
16
|
+
const b = "av-toggle";
|
|
17
|
+
/*!
|
|
18
|
+
@versini/ui-spacing v1.0.0
|
|
19
|
+
© 2024 gizmette.com
|
|
20
|
+
*/
|
|
21
|
+
try {
|
|
22
|
+
window.__VERSINI_UI_SPACING__ || (window.__VERSINI_UI_SPACING__ = {
|
|
23
|
+
version: "1.0.0",
|
|
24
|
+
buildTime: "12/24/2024 06:47 PM EST",
|
|
25
|
+
homepage: "https://github.com/aversini/ui-components",
|
|
26
|
+
license: "MIT"
|
|
27
|
+
});
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
const h = (e) => {
|
|
17
31
|
let r = "";
|
|
18
32
|
if (typeof e == "number" || typeof e == "string")
|
|
19
33
|
r = "m-" + e;
|
|
@@ -34,14 +48,14 @@ const b = "av-toggle", h = (e) => {
|
|
|
34
48
|
"peer-focus:outline-focus-light dark:peer-focus:outline-focus-dark": e === "alt-system",
|
|
35
49
|
"peer-focus:outline-focus-dark dark:peer-focus:outline-focus-light": e === "system"
|
|
36
50
|
}
|
|
37
|
-
),
|
|
51
|
+
), _ = () => s(
|
|
38
52
|
"peer-checked:after:translate-x-full",
|
|
39
53
|
// background color when checked
|
|
40
54
|
"peer-checked:bg-violet-500",
|
|
41
55
|
// knob circle and border color when checked
|
|
42
56
|
"peer-checked:after:bg-white",
|
|
43
57
|
"peer-checked:after:border-white"
|
|
44
|
-
),
|
|
58
|
+
), y = () => s(
|
|
45
59
|
"after:left-[2px]",
|
|
46
60
|
"after:top-[2px]",
|
|
47
61
|
"after:border",
|
|
@@ -62,7 +76,7 @@ const b = "av-toggle", h = (e) => {
|
|
|
62
76
|
"border-border-light bg-surface-darker": e === "dark",
|
|
63
77
|
"border-border-light bg-surface-darker dark:border-border-dark dark:bg-surface-medium": e === "alt-system",
|
|
64
78
|
"border-border-dark bg-surface-medium dark:border-border-light dark:bg-surface-darker": e === "system"
|
|
65
|
-
}),
|
|
79
|
+
}), x = ({
|
|
66
80
|
mode: e,
|
|
67
81
|
labelHidden: r
|
|
68
82
|
}) => r ? "sr-only" : s("ml-2 text-sm", {
|
|
@@ -70,11 +84,11 @@ const b = "av-toggle", h = (e) => {
|
|
|
70
84
|
"text-copy-lighter": e === "dark",
|
|
71
85
|
"text-copy-lighter dark:text-copy-dark": e === "alt-system",
|
|
72
86
|
"text-copy-dark dark:text-copy-lighter": e === "system"
|
|
73
|
-
}),
|
|
87
|
+
}), I = ({ spacing: e }) => s(
|
|
74
88
|
b,
|
|
75
89
|
"relative flex cursor-pointer items-center",
|
|
76
90
|
h(e)
|
|
77
|
-
),
|
|
91
|
+
), T = ({
|
|
78
92
|
mode: e,
|
|
79
93
|
focusMode: r,
|
|
80
94
|
labelHidden: t,
|
|
@@ -85,48 +99,48 @@ const b = "av-toggle", h = (e) => {
|
|
|
85
99
|
m(),
|
|
86
100
|
v({ mode: e, noBorder: a }),
|
|
87
101
|
k({ focusMode: r }),
|
|
88
|
-
|
|
89
|
-
|
|
102
|
+
y(),
|
|
103
|
+
_()
|
|
90
104
|
),
|
|
91
|
-
label:
|
|
105
|
+
label: x({ mode: e, labelHidden: t }),
|
|
92
106
|
input: "peer sr-only",
|
|
93
|
-
wrapper:
|
|
94
|
-
}),
|
|
107
|
+
wrapper: I({ spacing: l })
|
|
108
|
+
}), N = ({
|
|
95
109
|
checked: e = !1,
|
|
96
110
|
onChange: r,
|
|
97
111
|
label: t,
|
|
98
112
|
labelHidden: l = !1,
|
|
99
113
|
name: a,
|
|
100
|
-
mode:
|
|
101
|
-
focusMode:
|
|
114
|
+
mode: c = "system",
|
|
115
|
+
focusMode: u = "system",
|
|
102
116
|
spacing: n,
|
|
103
117
|
noBorder: d = !1
|
|
104
118
|
}) => {
|
|
105
|
-
const o =
|
|
106
|
-
mode:
|
|
107
|
-
focusMode:
|
|
119
|
+
const o = T({
|
|
120
|
+
mode: c,
|
|
121
|
+
focusMode: u,
|
|
108
122
|
labelHidden: l,
|
|
109
123
|
spacing: n,
|
|
110
124
|
noBorder: d
|
|
111
|
-
}),
|
|
112
|
-
r == null || r(
|
|
125
|
+
}), g = (f) => {
|
|
126
|
+
r == null || r(f.target.checked);
|
|
113
127
|
};
|
|
114
128
|
return /* @__PURE__ */ p("label", { className: o.wrapper, children: [
|
|
115
|
-
/* @__PURE__ */
|
|
129
|
+
/* @__PURE__ */ i(
|
|
116
130
|
"input",
|
|
117
131
|
{
|
|
118
132
|
name: a,
|
|
119
133
|
checked: e,
|
|
120
134
|
type: "checkbox",
|
|
121
135
|
className: o.input,
|
|
122
|
-
onChange:
|
|
136
|
+
onChange: g
|
|
123
137
|
}
|
|
124
138
|
),
|
|
125
|
-
/* @__PURE__ */
|
|
126
|
-
/* @__PURE__ */
|
|
139
|
+
/* @__PURE__ */ i("div", { className: o.toggle }),
|
|
140
|
+
/* @__PURE__ */ i("span", { className: o.label, children: t })
|
|
127
141
|
] });
|
|
128
142
|
};
|
|
129
143
|
export {
|
|
130
144
|
b as TOGGLE_CLASSNAME,
|
|
131
|
-
|
|
145
|
+
N as Toggle
|
|
132
146
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/ui-toggle",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -39,12 +39,14 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@tailwindcss/typography": "0.5.15",
|
|
42
|
-
"@versini/ui-private": "1.
|
|
42
|
+
"@versini/ui-private": "1.6.0",
|
|
43
|
+
"@versini/ui-spacing": "1.0.0",
|
|
44
|
+
"@versini/ui-spacing-types": "1.0.0",
|
|
43
45
|
"clsx": "2.1.1",
|
|
44
|
-
"tailwindcss": "3.4.
|
|
46
|
+
"tailwindcss": "3.4.17"
|
|
45
47
|
},
|
|
46
48
|
"sideEffects": [
|
|
47
49
|
"**/*.css"
|
|
48
50
|
],
|
|
49
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "cb948414a675c01f3328ed6470ccf4b58f73534f"
|
|
50
52
|
}
|