@cognitap/radiant 0.0.64 → 0.0.66
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/CHANGELOG.md +20 -0
- package/dist/library/Button.d.ts +2 -7
- package/dist/library/Button.d.ts.map +1 -1
- package/dist/library/Button.js.map +1 -1
- package/dist/library/ButtonGroup.d.ts +4 -1
- package/dist/library/ButtonGroup.d.ts.map +1 -1
- package/dist/library/ButtonGroup.js +2 -1
- package/dist/library/ButtonGroup.js.map +1 -1
- package/dist/library/CheckboxGroup.d.ts +6 -4
- package/dist/library/CheckboxGroup.d.ts.map +1 -1
- package/dist/library/CheckboxGroup.js +17 -21
- package/dist/library/CheckboxGroup.js.map +1 -1
- package/dist/library/Command.d.ts +1 -2
- package/dist/library/Command.d.ts.map +1 -1
- package/dist/library/Command.js +1 -1
- package/dist/library/Command.js.map +1 -1
- package/dist/library/ContextMenu.d.ts +2 -1
- package/dist/library/ContextMenu.d.ts.map +1 -1
- package/dist/library/ContextMenu.js.map +1 -1
- package/dist/library/Drawer.d.ts +8 -17
- package/dist/library/Drawer.d.ts.map +1 -1
- package/dist/library/Drawer.js +2 -2
- package/dist/library/Drawer.js.map +1 -1
- package/dist/library/Field.d.ts.map +1 -1
- package/dist/library/Field.js +1 -1
- package/dist/library/Field.js.map +1 -1
- package/dist/library/Menu.d.ts +4 -10
- package/dist/library/Menu.d.ts.map +1 -1
- package/dist/library/Menu.js +2 -2
- package/dist/library/Menu.js.map +1 -1
- package/dist/library/Menubar.d.ts +1 -1
- package/dist/library/Menubar.d.ts.map +1 -1
- package/dist/library/Menubar.js.map +1 -1
- package/dist/library/PasswordInput.d.ts.map +1 -1
- package/dist/library/PasswordInput.js +1 -1
- package/dist/library/PasswordInput.js.map +1 -1
- package/dist/library/Popover.d.ts +1 -1
- package/dist/library/Popover.d.ts.map +1 -1
- package/dist/library/Popover.js +1 -1
- package/dist/library/Popover.js.map +1 -1
- package/dist/library/ScrollArea.d.ts +2 -2
- package/dist/library/ScrollArea.d.ts.map +1 -1
- package/dist/library/ToggleGroup.d.ts +12 -22
- package/dist/library/ToggleGroup.d.ts.map +1 -1
- package/dist/library/ToggleGroup.js +6 -6
- package/dist/library/ToggleGroup.js.map +1 -1
- package/dist/library/Toolbar.d.ts +2 -2
- package/dist/library/Toolbar.d.ts.map +1 -1
- package/dist/library/index.d.ts +3 -3
- package/dist/library/index.d.ts.map +1 -1
- package/dist/library/index.js.map +1 -1
- package/docs/architecture.md +1 -1
- package/package.json +1 -1
- package/src/Button.tsx +2 -4
- package/src/ButtonGroup.tsx +6 -2
- package/src/CheckboxGroup.tsx +33 -25
- package/src/Command.tsx +2 -13
- package/src/ContextMenu.tsx +3 -1
- package/src/Drawer.tsx +10 -14
- package/src/Field.tsx +5 -1
- package/src/Menu.tsx +7 -20
- package/src/Menubar.tsx +1 -7
- package/src/PasswordInput.tsx +1 -2
- package/src/Popover.tsx +5 -1
- package/src/ScrollArea.tsx +3 -3
- package/src/ToggleGroup.tsx +21 -24
- package/src/Toolbar.tsx +2 -2
- package/src/index.ts +5 -4
package/src/ToggleGroup.tsx
CHANGED
|
@@ -9,24 +9,20 @@ import {
|
|
|
9
9
|
useState,
|
|
10
10
|
type ComponentProps
|
|
11
11
|
} from 'react'
|
|
12
|
-
import { Button, type ButtonProps } from './Button.js'
|
|
12
|
+
import { Button, type ButtonProps, type ButtonRenderProps } from './Button.js'
|
|
13
13
|
import { requireAccessibleName, type AccessibleName } from './internal/accessibleName.js'
|
|
14
14
|
import { cn } from './cn.js'
|
|
15
15
|
import { joinIds } from './internal/ids.js'
|
|
16
16
|
import { isItemOpen, nextSelection, sameSelection, type Selection } from './internal/selection.js'
|
|
17
17
|
import { useComposedRefs } from './react/useComposedRefs.js'
|
|
18
18
|
import { useControllableState } from './react/useControllableState.js'
|
|
19
|
+
import type { ValueOwner } from './react/useNativeOwner.js'
|
|
19
20
|
import { CompositeFocusContext, useRovingFocus } from './react/useRovingFocus.js'
|
|
20
21
|
import { useTransitionHost } from './motion/host.js'
|
|
21
|
-
import type { ControlSize } from './presentation.js'
|
|
22
|
+
import type { ControlSize, Orientation, PartStyle } from './presentation.js'
|
|
22
23
|
import type { ThemeStyle } from './themes/defineTheme.js'
|
|
23
24
|
|
|
24
|
-
type
|
|
25
|
-
| { value: Value; defaultValue?: never }
|
|
26
|
-
| { value?: undefined; defaultValue?: Value }
|
|
27
|
-
type PartStyle = { className?: string; style?: ThemeStyle }
|
|
28
|
-
export type ToggleGroupOrientation = 'horizontal' | 'vertical'
|
|
29
|
-
export type ToggleGroupAppearance = 'buttons' | 'segmented'
|
|
25
|
+
export type ToggleGroupVariant = 'buttons' | 'segmented'
|
|
30
26
|
export type ToggleGroupValue = Selection
|
|
31
27
|
type Base = Omit<
|
|
32
28
|
ComponentProps<'div'>,
|
|
@@ -34,7 +30,7 @@ type Base = Omit<
|
|
|
34
30
|
> &
|
|
35
31
|
AccessibleName & {
|
|
36
32
|
style?: ThemeStyle
|
|
37
|
-
orientation?:
|
|
33
|
+
orientation?: Orientation
|
|
38
34
|
loop?: boolean
|
|
39
35
|
disabled?: boolean
|
|
40
36
|
controlSize?: ControlSize
|
|
@@ -44,14 +40,14 @@ type Base = Omit<
|
|
|
44
40
|
}
|
|
45
41
|
export type ToggleGroupProps = Base &
|
|
46
42
|
(
|
|
47
|
-
| (
|
|
43
|
+
| (ValueOwner<string | null> & {
|
|
48
44
|
type?: 'single'
|
|
49
|
-
|
|
45
|
+
variant?: ToggleGroupVariant
|
|
50
46
|
onValueChange?: (value: string | null) => void
|
|
51
47
|
})
|
|
52
|
-
| (
|
|
48
|
+
| (ValueOwner<string[]> & {
|
|
53
49
|
type: 'multiple'
|
|
54
|
-
|
|
50
|
+
variant?: 'buttons'
|
|
55
51
|
onValueChange?: (value: string[]) => void
|
|
56
52
|
})
|
|
57
53
|
)
|
|
@@ -66,15 +62,16 @@ export type ToggleGroupItemProps = Omit<
|
|
|
66
62
|
| 'role'
|
|
67
63
|
| 'tabIndex'
|
|
68
64
|
> & { value: string }
|
|
65
|
+
export type ToggleGroupRenderProps = ButtonRenderProps
|
|
69
66
|
export type ToggleGroupState = {
|
|
70
67
|
type: 'single' | 'multiple'
|
|
71
68
|
value: ToggleGroupValue
|
|
72
69
|
controlled: boolean
|
|
73
70
|
disabled: boolean
|
|
74
|
-
orientation:
|
|
71
|
+
orientation: Orientation
|
|
75
72
|
loop: boolean
|
|
76
73
|
controlSize: ControlSize
|
|
77
|
-
|
|
74
|
+
variant: ToggleGroupVariant
|
|
78
75
|
motion: 'inherit' | 'off'
|
|
79
76
|
setItemPressed: (value: string, pressed: boolean) => void
|
|
80
77
|
}
|
|
@@ -99,7 +96,7 @@ export function ToggleGroup(allProps: ToggleGroupProps) {
|
|
|
99
96
|
value,
|
|
100
97
|
defaultValue,
|
|
101
98
|
onValueChange: _onValueChange,
|
|
102
|
-
|
|
99
|
+
variant = 'buttons',
|
|
103
100
|
orientation = 'horizontal',
|
|
104
101
|
loop = true,
|
|
105
102
|
disabled = false,
|
|
@@ -117,7 +114,7 @@ export function ToggleGroup(allProps: ToggleGroupProps) {
|
|
|
117
114
|
if (type !== initialType)
|
|
118
115
|
throw new TypeError('ToggleGroup cannot change type during a mount. Remount with a new key.')
|
|
119
116
|
requireAccessibleName('ToggleGroup', props)
|
|
120
|
-
if (type === 'multiple' &&
|
|
117
|
+
if (type === 'multiple' && variant === 'segmented')
|
|
121
118
|
throw new TypeError('The segmented indicator requires single selection.')
|
|
122
119
|
const {
|
|
123
120
|
value: current,
|
|
@@ -164,7 +161,7 @@ export function ToggleGroup(allProps: ToggleGroupProps) {
|
|
|
164
161
|
orientation,
|
|
165
162
|
loop,
|
|
166
163
|
controlSize,
|
|
167
|
-
|
|
164
|
+
variant,
|
|
168
165
|
motion,
|
|
169
166
|
setItemPressed(item, pressed) {
|
|
170
167
|
if (!disabled) request(current => nextSelection(current, item, pressed))
|
|
@@ -183,12 +180,12 @@ export function ToggleGroup(allProps: ToggleGroupProps) {
|
|
|
183
180
|
className={cn(
|
|
184
181
|
rootClass,
|
|
185
182
|
orientation === 'vertical' ? 'flex-col items-stretch' : 'items-center',
|
|
186
|
-
|
|
183
|
+
variant === 'segmented' && segmentedClass,
|
|
187
184
|
className
|
|
188
185
|
)}
|
|
189
186
|
data-slot={joinIds('toggle-group', props['data-slot'])}
|
|
190
187
|
data-type={type}
|
|
191
|
-
data-
|
|
188
|
+
data-variant={variant}
|
|
192
189
|
data-orientation={orientation}
|
|
193
190
|
data-control-size={controlSize}
|
|
194
191
|
data-disabled={disabled ? '' : undefined}
|
|
@@ -205,7 +202,7 @@ export function ToggleGroup(allProps: ToggleGroupProps) {
|
|
|
205
202
|
roving.onKeyDown(event)
|
|
206
203
|
}}
|
|
207
204
|
>
|
|
208
|
-
{
|
|
205
|
+
{variant === 'segmented' ? (
|
|
209
206
|
<Indicator
|
|
210
207
|
value={current}
|
|
211
208
|
motion={motion}
|
|
@@ -243,16 +240,16 @@ export function ToggleGroupItem({
|
|
|
243
240
|
aria-pressed={undefined}
|
|
244
241
|
onPressedChange={next => group.setItemPressed(value, next)}
|
|
245
242
|
controlSize={controlSize ?? group.controlSize}
|
|
246
|
-
variant={group.
|
|
243
|
+
variant={group.variant === 'segmented' ? 'ghost' : variant}
|
|
247
244
|
tone={tone}
|
|
248
245
|
motion={group.motion === 'off' ? 'off' : props.motion}
|
|
249
246
|
data-slot={joinIds('toggle-group-item', props['data-slot'])}
|
|
250
247
|
data-value={value}
|
|
251
|
-
data-
|
|
248
|
+
data-selected={pressed ? '' : undefined}
|
|
252
249
|
data-disabled={unavailable ? '' : undefined}
|
|
253
250
|
className={cn(
|
|
254
251
|
'relative z-10',
|
|
255
|
-
group.
|
|
252
|
+
group.variant === 'segmented' &&
|
|
256
253
|
'bg-transparent hover:bg-transparent active:bg-transparent disabled:bg-transparent aria-busy:bg-transparent [background-image:none] shadow-none inset-shadow-none [border-color:transparent]',
|
|
257
254
|
className
|
|
258
255
|
)}
|
package/src/Toolbar.tsx
CHANGED
|
@@ -5,15 +5,15 @@ import { joinIds } from './internal/ids.js'
|
|
|
5
5
|
import { requireAccessibleName, type AccessibleName } from './internal/accessibleName.js'
|
|
6
6
|
import { useComposedRefs } from './react/useComposedRefs.js'
|
|
7
7
|
import { CompositeFocusContext, useRovingFocus } from './react/useRovingFocus.js'
|
|
8
|
+
import type { Orientation } from './presentation.js'
|
|
8
9
|
import type { ThemeStyle } from './themes/defineTheme.js'
|
|
9
10
|
|
|
10
|
-
export type ToolbarOrientation = 'horizontal' | 'vertical'
|
|
11
11
|
export type ToolbarProps = Omit<
|
|
12
12
|
ComponentProps<'div'>,
|
|
13
13
|
'role' | 'aria-orientation' | 'tabIndex' | 'style' | 'contentEditable' | 'dangerouslySetInnerHTML'
|
|
14
14
|
> &
|
|
15
15
|
AccessibleName & {
|
|
16
|
-
orientation?:
|
|
16
|
+
orientation?: Orientation
|
|
17
17
|
loop?: boolean
|
|
18
18
|
style?: ThemeStyle
|
|
19
19
|
'data-slot'?: string
|
package/src/index.ts
CHANGED
|
@@ -431,12 +431,12 @@ export type {
|
|
|
431
431
|
ToggleGroupItemProps,
|
|
432
432
|
ToggleGroupState,
|
|
433
433
|
ToggleGroupValue,
|
|
434
|
-
|
|
435
|
-
|
|
434
|
+
ToggleGroupVariant,
|
|
435
|
+
ToggleGroupRenderProps
|
|
436
436
|
} from './ToggleGroup.js'
|
|
437
437
|
|
|
438
438
|
export { Toolbar } from './Toolbar.js'
|
|
439
|
-
export type { ToolbarProps
|
|
439
|
+
export type { ToolbarProps } from './Toolbar.js'
|
|
440
440
|
|
|
441
441
|
export {
|
|
442
442
|
ContextMenu,
|
|
@@ -470,7 +470,8 @@ export type {
|
|
|
470
470
|
ContextMenuSubProps,
|
|
471
471
|
ContextMenuSubTriggerProps,
|
|
472
472
|
ContextMenuSubContentProps,
|
|
473
|
-
ContextMenuState
|
|
473
|
+
ContextMenuState,
|
|
474
|
+
ContextMenuRenderProps
|
|
474
475
|
} from './ContextMenu.js'
|
|
475
476
|
|
|
476
477
|
export {
|