@versini/ui-toggle 6.2.3 → 7.0.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/README.md +0 -1
- package/dist/index.d.ts +7 -6
- package/dist/index.js +17 -18
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -139,7 +139,6 @@ function SettingsPanel() {
|
|
|
139
139
|
| `name` | `string` | - | Form field name (required). |
|
|
140
140
|
| `onChange` | `(checked: boolean) => void` | - | Callback fired when checked state changes. |
|
|
141
141
|
| `checked` | `boolean` | `false` | Controlled checked state. |
|
|
142
|
-
| `focusMode` | `"dark" \| "light" \| "system" \| "alt-system"` | `"system"` | Focus ring color mode. |
|
|
143
142
|
| `labelHidden` | `boolean` | `false` | Visually hide the label (still accessible). |
|
|
144
143
|
| `labelPosition` | `"left" \| "right"` | `"right"` | Position of the label relative to the toggle. |
|
|
145
144
|
| `mode` | `"dark" \| "light" \| "system" \| "alt-system"` | `"system"` | Color mode/theme. |
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JSX } from 'react/jsx-runtime';
|
|
2
2
|
|
|
3
|
-
export declare const Toggle: ({ checked, onChange, label, labelHidden, name, mode,
|
|
3
|
+
export declare const Toggle: ({ checked, onChange, label, labelHidden, name, mode, labelMode, className, noBorder, narrow, noHaptic, labelPosition, subLabel, splitBackground, }: ToggleProps) => JSX.Element;
|
|
4
4
|
|
|
5
5
|
export declare const TOGGLE_CLASSNAME = "av-toggle";
|
|
6
6
|
|
|
@@ -27,11 +27,6 @@ declare type ToggleProps = {
|
|
|
27
27
|
* @default false
|
|
28
28
|
*/
|
|
29
29
|
checked?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* The type of focus for the Button. This will change the color
|
|
32
|
-
* of the focus ring around the Button.
|
|
33
|
-
*/
|
|
34
|
-
focusMode?: "dark" | "light" | "system" | "alt-system";
|
|
35
30
|
/**
|
|
36
31
|
* Whether or not to render the label and sub-label.
|
|
37
32
|
* @default false
|
|
@@ -70,6 +65,12 @@ declare type ToggleProps = {
|
|
|
70
65
|
* @default "right"
|
|
71
66
|
*/
|
|
72
67
|
labelPosition?: "left" | "right";
|
|
68
|
+
/**
|
|
69
|
+
* Whether or not to render the toggle track with a split background
|
|
70
|
+
* gradient overlay (aqua-style).
|
|
71
|
+
* @default false
|
|
72
|
+
*/
|
|
73
|
+
splitBackground?: boolean;
|
|
73
74
|
};
|
|
74
75
|
|
|
75
76
|
export { }
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-toggle
|
|
2
|
+
@versini/ui-toggle v7.0.0
|
|
3
3
|
© 2026 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -21,20 +21,20 @@ const getToggleBaseClasses = ({ narrow })=>{
|
|
|
21
21
|
}, // Smooth background/border transition when toggling
|
|
22
22
|
"transition-colors duration-300 ease-in-out motion-reduce:transition-none");
|
|
23
23
|
};
|
|
24
|
-
const getToggleKnobFocusClasses = (
|
|
25
|
-
return clsx("peer-focus:outline", "peer-focus:outline-2", "peer-focus:outline-offset-2",
|
|
26
|
-
"peer-focus:outline-focus-dark": focusMode === "dark",
|
|
27
|
-
"peer-focus:outline-focus-light": focusMode === "light",
|
|
28
|
-
"peer-focus:outline-focus-light dark:peer-focus:outline-focus-dark": focusMode === "alt-system",
|
|
29
|
-
"peer-focus:outline-focus-dark dark:peer-focus:outline-focus-light": focusMode === "system"
|
|
30
|
-
});
|
|
24
|
+
const getToggleKnobFocusClasses = ()=>{
|
|
25
|
+
return clsx("peer-focus:outline", "peer-focus:outline-2", "peer-focus:outline-offset-2", "peer-focus:outline-focus-dark");
|
|
31
26
|
};
|
|
32
|
-
|
|
27
|
+
// Aqua-style split background overlay for the toggle knob:
|
|
28
|
+
// - Top half: flat white overlay (light, uniform)
|
|
29
|
+
// - Bottom half: starts darker, gradually lightens toward the bottom edge
|
|
30
|
+
const KNOB_SPLIT_OVERLAY = "after:bg-[linear-gradient(to_bottom,oklch(1_0_0/0.2)_50%,oklch(0_0_0/0.1)_50%,oklch(1_0_0/0.05)_100%)]";
|
|
31
|
+
const getToggleKnobOnClasses = ({ narrow, splitBackground })=>{
|
|
33
32
|
return clsx({
|
|
34
33
|
"peer-checked:after:translate-x-full": !narrow,
|
|
35
34
|
"peer-checked:after:translate-x-4": narrow
|
|
36
35
|
}, // background color when checked
|
|
37
|
-
"peer-checked:bg-action-light", //
|
|
36
|
+
"peer-checked:bg-action-light", // split background overlay on the knob (both states)
|
|
37
|
+
splitBackground && KNOB_SPLIT_OVERLAY, // knob circle and border color when checked
|
|
38
38
|
"peer-checked:after:bg-white", "peer-checked:after:border-white");
|
|
39
39
|
};
|
|
40
40
|
const getToggleKnobOffClasses = ({ narrow })=>{
|
|
@@ -79,19 +79,18 @@ const getWrapperClasses = ({ className })=>{
|
|
|
79
79
|
const getToggleWrapperClasses = ()=>{
|
|
80
80
|
return "relative inline-block";
|
|
81
81
|
};
|
|
82
|
-
const getToggleClasses = ({ mode,
|
|
82
|
+
const getToggleClasses = ({ mode, labelHidden, className, noBorder, narrow, labelMode, labelPosition = "right", subLabel, splitBackground })=>{
|
|
83
83
|
return {
|
|
84
84
|
toggle: clsx(getToggleBaseClasses({
|
|
85
85
|
narrow
|
|
86
86
|
}), getToggleColorClasses({
|
|
87
87
|
mode,
|
|
88
88
|
noBorder
|
|
89
|
-
}), getToggleKnobFocusClasses({
|
|
90
|
-
focusMode
|
|
91
|
-
}), getToggleKnobOffClasses({
|
|
89
|
+
}), getToggleKnobFocusClasses(), getToggleKnobOffClasses({
|
|
92
90
|
narrow
|
|
93
91
|
}), getToggleKnobOnClasses({
|
|
94
|
-
narrow
|
|
92
|
+
narrow,
|
|
93
|
+
splitBackground
|
|
95
94
|
})),
|
|
96
95
|
label: getLabelClasses({
|
|
97
96
|
labelHidden,
|
|
@@ -117,18 +116,18 @@ const getToggleClasses = ({ mode, focusMode, labelHidden, className, noBorder, n
|
|
|
117
116
|
|
|
118
117
|
|
|
119
118
|
|
|
120
|
-
const Toggle = ({ checked = false, onChange, label, labelHidden = false, name, mode = "system",
|
|
119
|
+
const Toggle = ({ checked = false, onChange, label, labelHidden = false, name, mode = "system", labelMode, className, noBorder = false, narrow = false, noHaptic = false, labelPosition = "right", subLabel, splitBackground = false })=>{
|
|
121
120
|
const { haptic } = useHaptic();
|
|
122
121
|
const toggleClasses = getToggleClasses({
|
|
123
122
|
mode,
|
|
124
|
-
focusMode,
|
|
125
123
|
labelHidden,
|
|
126
124
|
className,
|
|
127
125
|
noBorder,
|
|
128
126
|
narrow,
|
|
129
127
|
labelMode,
|
|
130
128
|
labelPosition,
|
|
131
|
-
subLabel: !!subLabel
|
|
129
|
+
subLabel: !!subLabel,
|
|
130
|
+
splitBackground
|
|
132
131
|
});
|
|
133
132
|
const handleChange = (e)=>{
|
|
134
133
|
if (!noHaptic) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/ui-toggle",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"test": "vitest run"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@versini/ui-types": "
|
|
40
|
+
"@versini/ui-types": "9.0.0"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@versini/ui-hooks": "6.1.1",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"sideEffects": [
|
|
48
48
|
"**/*.css"
|
|
49
49
|
],
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "a295349019d1512796f266bba535de383f12b6ee"
|
|
51
51
|
}
|