@versini/ui-togglegroup 6.0.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 CHANGED
@@ -20,7 +20,6 @@ The ToggleGroup component provides grouped toggle buttons for single-select usag
20
20
  - **🔢 Grouped Selection**: Manage a set of related options with single selection
21
21
  - **♿ Accessible**: Built atop Radix primitives with robust a11y patterns
22
22
  - **🎨 Theming & Sizes**: Supports light/dark/system modes & `small | medium | large` sizes
23
- - **🎯 Focus Styles**: Independent `focusMode` to align with design tokens
24
23
  - **⌨️ Keyboard Friendly**: Arrow key navigation & typeahead labeling
25
24
  - **🧪 Type Safe**: Strongly typed props and context sharing
26
25
 
@@ -88,12 +87,7 @@ function App() {
88
87
  ### Themed Group (Dark)
89
88
 
90
89
  ```tsx
91
- <ToggleGroup
92
- mode="dark"
93
- focusMode="light"
94
- value={theme}
95
- onValueChange={setTheme}
96
- >
90
+ <ToggleGroup mode="dark" value={theme} onValueChange={setTheme}>
97
91
  <ToggleGroupItem value="auto" />
98
92
  <ToggleGroupItem value="light" />
99
93
  <ToggleGroupItem value="dark" />
@@ -105,13 +99,12 @@ function App() {
105
99
  ### ToggleGroup Props
106
100
 
107
101
  | Prop | Type | Default | Description |
108
- | --------------- | ------------------------- | -------- | ----------------------------------------- | ------------- | --------------------- | -------------------------- |
102
+ | --------------- | ------------------------- | -------- | ----------------------------------------- | ------------- | --------------------- | ------------------- |
109
103
  | `value` | `string` | - | Current selected value (controlled). |
110
104
  | `defaultValue` | `string` | - | Initial value (uncontrolled). |
111
105
  | `onValueChange` | `(value: string) => void` | - | Fired when selection changes. |
112
106
  | `disabled` | `boolean` | - | Disable the entire group. |
113
- | `mode` | `"dark" | "light" | "system" | "alt-system"` | `"system"` | Color / theme mode. |
114
- | `focusMode` | `"dark" | "light" | "system" | "alt-system"` | `"system"` | Color mode for focus ring. |
107
+ | `mode` | `"dark" | "light" | "system" | "alt-system"` | `"system"` | Color / theme mode. |
115
108
  | `size` | `"small" | "medium" | "large"` | `"medium"` | Visual size of items. |
116
109
  | `className` | `string` | - | Extra class(es) applied to container. |
117
110
  | `children` | `React.ReactNode` | - | One or more `ToggleGroupItem` components. |
@@ -1,8 +1,9 @@
1
1
  import { JSX } from 'react/jsx-runtime';
2
- import type { ToggleGroupItemProps } from './ToggleGroupTypes';
3
- import type { ToggleGroupProps } from './ToggleGroupTypes';
2
+ import type * as ToggleGroupRadix from '@radix-ui/react-toggle-group';
4
3
 
5
- export declare const ToggleGroup: ({ children, value, onValueChange, disabled, size, defaultValue, className, ...otherProps }: ToggleGroupProps) => JSX.Element;
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 { }
@@ -1,5 +1,5 @@
1
1
  /*!
2
- @versini/ui-togglegroup v6.0.3
2
+ @versini/ui-togglegroup v7.0.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
- const getToggleGroupItemActiveClasses = ()=>{
30
- 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");
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, ...otherProps })=>{
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",
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": "8.4.0"
40
+ "@versini/ui-types": "9.0.0"
41
41
  },
42
42
  "dependencies": {
43
43
  "@radix-ui/react-toggle-group": "1.1.11",
@@ -47,5 +47,5 @@
47
47
  "sideEffects": [
48
48
  "**/*.css"
49
49
  ],
50
- "gitHead": "08f46d8b356d5cfbb4e58dca300428ed6bb03789"
50
+ "gitHead": "a295349019d1512796f266bba535de383f12b6ee"
51
51
  }