@versini/ui-togglegroup 6.0.3 → 6.1.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/components/index.d.ts +43 -3
- package/dist/components/index.js +19 -11
- package/package.json +2 -2
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { JSX } from 'react/jsx-runtime';
|
|
2
|
-
import type
|
|
3
|
-
import type { ToggleGroupProps } from './ToggleGroupTypes';
|
|
2
|
+
import type * as ToggleGroupRadix from '@radix-ui/react-toggle-group';
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
declare type Size = "small" | "medium" | "large";
|
|
5
|
+
|
|
6
|
+
export declare const ToggleGroup: ({ children, value, onValueChange, disabled, size, defaultValue, className, splitBackground, }: ToggleGroupProps) => JSX.Element;
|
|
6
7
|
|
|
7
8
|
export declare const TOGGLEGROUP_CLASSNAME = "av-togglegroup";
|
|
8
9
|
|
|
@@ -12,4 +13,43 @@ export declare const TOGGLEGROUP_ITEM_WRAPPER_CLASSNAME = "av-togglegroup-item-w
|
|
|
12
13
|
|
|
13
14
|
export declare const ToggleGroupItem: ({ value, disabled, children, }: ToggleGroupItemProps) => JSX.Element;
|
|
14
15
|
|
|
16
|
+
declare type ToggleGroupItemProps = ToggleGroupRadix.ToggleGroupItemProps;
|
|
17
|
+
|
|
18
|
+
declare type ToggleGroupProps = {
|
|
19
|
+
/**
|
|
20
|
+
* The content of the component (ToggleGroupItem elements).
|
|
21
|
+
*/
|
|
22
|
+
children: React.ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* The controlled value of the pressed item.
|
|
25
|
+
*/
|
|
26
|
+
value?: string;
|
|
27
|
+
/**
|
|
28
|
+
* The value of the item to show as pressed when initially rendered.
|
|
29
|
+
*/
|
|
30
|
+
defaultValue?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Callback fired when the value changes.
|
|
33
|
+
*/
|
|
34
|
+
onValueChange?: (value: string) => void;
|
|
35
|
+
/**
|
|
36
|
+
* Whether or not the component is disabled.
|
|
37
|
+
*/
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The size of the component.
|
|
41
|
+
*/
|
|
42
|
+
size?: Size;
|
|
43
|
+
/**
|
|
44
|
+
* The classes to apply to the component.
|
|
45
|
+
*/
|
|
46
|
+
className?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Whether or not to render the active item with a split background
|
|
49
|
+
* gradient overlay (aqua-style).
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
splitBackground?: boolean;
|
|
53
|
+
};
|
|
54
|
+
|
|
15
55
|
export { }
|
package/dist/components/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
@versini/ui-togglegroup v6.0
|
|
2
|
+
@versini/ui-togglegroup v6.1.0
|
|
3
3
|
© 2026 gizmette.com
|
|
4
4
|
*/
|
|
5
5
|
|
|
@@ -17,7 +17,8 @@ const TOGGLEGROUP_ITEM_CLASSNAME = "av-togglegroup-item";
|
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
const ToggleGroupContext = react.createContext({
|
|
20
|
-
size: "medium"
|
|
20
|
+
size: "medium",
|
|
21
|
+
splitBackground: false
|
|
21
22
|
});
|
|
22
23
|
|
|
23
24
|
|
|
@@ -26,8 +27,12 @@ const ToggleGroupContext = react.createContext({
|
|
|
26
27
|
const getToggleGroupItemFocusClasses = ()=>{
|
|
27
28
|
return clsx("focus:outline-none", "focus:ring-2", "focus:ring-inset", "focus:ring-focus-dark");
|
|
28
29
|
};
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
// Aqua-style split background overlay:
|
|
31
|
+
// - Top half: flat white overlay (light, uniform)
|
|
32
|
+
// - Bottom half: starts darker, gradually lightens toward the bottom edge
|
|
33
|
+
const BG_SPLIT_OVERLAY = "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%)]";
|
|
34
|
+
const getToggleGroupItemActiveClasses = ({ splitBackground })=>{
|
|
35
|
+
return clsx("data-[state=on]:bg-surface-lightest data-[state=on]:text-copy-dark", "dark:data-[state=on]:bg-surface-dark dark:data-[state=on]:text-copy-light", splitBackground && BG_SPLIT_OVERLAY);
|
|
31
36
|
};
|
|
32
37
|
const getToggleGroupItemSizeClasses = ({ size })=>{
|
|
33
38
|
return clsx({
|
|
@@ -46,12 +51,14 @@ const getToggleGroupSizeClasses = ({ size })=>{
|
|
|
46
51
|
const getToggleGroupItemWrapperClasses = ()=>{
|
|
47
52
|
return clsx(TOGGLEGROUP_ITEM_WRAPPER_CLASSNAME, "relative", "[&>button]:rounded-none", "first:[&>button]:rounded-l-md", "last:[&>button]:rounded-r-md", "border-r border-border-medium last:border-r-0");
|
|
48
53
|
};
|
|
49
|
-
const getToggleGroupItemClasses = ({ size })=>{
|
|
54
|
+
const getToggleGroupItemClasses = ({ size, splitBackground })=>{
|
|
50
55
|
return {
|
|
51
56
|
wrapperClass: getToggleGroupItemWrapperClasses(),
|
|
52
57
|
itemClass: clsx(TOGGLEGROUP_ITEM_CLASSNAME, "text-sm cursor-pointer", "flex items-center justify-center bg-transparent", "transition duration-200 ease", getToggleGroupItemSizeClasses({
|
|
53
58
|
size
|
|
54
|
-
}), getToggleGroupItemFocusClasses(), getToggleGroupItemActiveClasses(
|
|
59
|
+
}), getToggleGroupItemFocusClasses(), getToggleGroupItemActiveClasses({
|
|
60
|
+
splitBackground
|
|
61
|
+
}))
|
|
55
62
|
};
|
|
56
63
|
};
|
|
57
64
|
const getToggleGroupClasses = ({ className, size })=>{
|
|
@@ -65,13 +72,14 @@ const getToggleGroupClasses = ({ className, size })=>{
|
|
|
65
72
|
|
|
66
73
|
|
|
67
74
|
|
|
68
|
-
const ToggleGroup = ({ children, value, onValueChange, disabled, size = "medium", defaultValue, className,
|
|
75
|
+
const ToggleGroup = ({ children, value, onValueChange, disabled, size = "medium", defaultValue, className, splitBackground = false })=>{
|
|
69
76
|
const toggleGroupClasses = getToggleGroupClasses({
|
|
70
77
|
className,
|
|
71
78
|
size
|
|
72
79
|
});
|
|
73
80
|
const contextValue = {
|
|
74
|
-
size
|
|
81
|
+
size,
|
|
82
|
+
splitBackground
|
|
75
83
|
};
|
|
76
84
|
return /*#__PURE__*/ jsx(ToggleGroupContext.Provider, {
|
|
77
85
|
value: contextValue,
|
|
@@ -81,16 +89,16 @@ const ToggleGroup = ({ children, value, onValueChange, disabled, size = "medium"
|
|
|
81
89
|
value: value,
|
|
82
90
|
defaultValue: defaultValue,
|
|
83
91
|
onValueChange: onValueChange,
|
|
84
|
-
...otherProps,
|
|
85
92
|
type: "single",
|
|
86
93
|
children: children
|
|
87
94
|
})
|
|
88
95
|
});
|
|
89
96
|
};
|
|
90
97
|
const ToggleGroupItem = ({ value, disabled, children })=>{
|
|
91
|
-
const { size } = useContext(ToggleGroupContext);
|
|
98
|
+
const { size, splitBackground } = useContext(ToggleGroupContext);
|
|
92
99
|
const { itemClass, wrapperClass } = getToggleGroupItemClasses({
|
|
93
|
-
size
|
|
100
|
+
size,
|
|
101
|
+
splitBackground
|
|
94
102
|
});
|
|
95
103
|
return /*#__PURE__*/ jsx("div", {
|
|
96
104
|
className: wrapperClass,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@versini/ui-togglegroup",
|
|
3
|
-
"version": "6.0
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Arno Versini",
|
|
6
6
|
"publishConfig": {
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"sideEffects": [
|
|
48
48
|
"**/*.css"
|
|
49
49
|
],
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "af3ee18b6fc3d57977ec331df0ce151794e29342"
|
|
51
51
|
}
|