@cognitap/radiant 0.0.35 → 0.0.37
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 +18 -6
- package/dist/library/ContextMenu.d.ts +38 -0
- package/dist/library/ContextMenu.d.ts.map +1 -0
- package/dist/library/ContextMenu.js +169 -0
- package/dist/library/ContextMenu.js.map +1 -0
- package/dist/library/Menu.d.ts +88 -4
- package/dist/library/Menu.d.ts.map +1 -1
- package/dist/library/Menu.js +215 -27
- package/dist/library/Menu.js.map +1 -1
- package/dist/library/Menubar.d.ts +53 -0
- package/dist/library/Menubar.d.ts.map +1 -0
- package/dist/library/Menubar.js +246 -0
- package/dist/library/Menubar.js.map +1 -0
- package/dist/library/Popover.d.ts +18 -2
- package/dist/library/Popover.d.ts.map +1 -1
- package/dist/library/Popover.js +24 -4
- package/dist/library/Popover.js.map +1 -1
- package/dist/library/cn.d.ts.map +1 -1
- package/dist/library/cn.js +4 -0
- package/dist/library/cn.js.map +1 -1
- package/dist/library/index.d.ts +6 -0
- package/dist/library/index.d.ts.map +1 -1
- package/dist/library/index.js +3 -0
- package/dist/library/index.js.map +1 -1
- package/dist/library/react/usePopoverSurface.d.ts +4 -0
- package/dist/library/react/usePopoverSurface.d.ts.map +1 -1
- package/dist/library/react/usePopoverSurface.js +13 -4
- package/dist/library/react/usePopoverSurface.js.map +1 -1
- package/dist/library/react/useRovingFocus.d.ts +3 -1
- package/dist/library/react/useRovingFocus.d.ts.map +1 -1
- package/dist/library/react/useRovingFocus.js +3 -2
- package/dist/library/react/useRovingFocus.js.map +1 -1
- package/dist/library/styles.css +1 -1
- package/dist/library/themes/components.d.ts +9 -0
- package/dist/library/themes/components.d.ts.map +1 -1
- package/dist/library/themes/components.js +2 -0
- package/dist/library/themes/components.js.map +1 -1
- package/docs/architecture.md +36 -31
- package/package.json +1 -1
- package/src/ContextMenu.tsx +354 -0
- package/src/Menu.tsx +516 -43
- package/src/Menubar.tsx +496 -0
- package/src/Popover.tsx +46 -4
- package/src/cn.ts +4 -0
- package/src/index.ts +95 -0
- package/src/react/usePopoverSurface.ts +17 -4
- package/src/react/useRovingFocus.ts +5 -2
- package/src/themes/components.ts +2 -0
package/src/index.ts
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
export {
|
|
2
|
+
MenuGroup,
|
|
3
|
+
MenuLabel,
|
|
4
|
+
MenuSeparator,
|
|
5
|
+
MenuCheckboxItem,
|
|
6
|
+
MenuRadioGroup,
|
|
7
|
+
MenuRadioItem,
|
|
8
|
+
MenuSub,
|
|
9
|
+
MenuSubTrigger,
|
|
10
|
+
MenuSubContent
|
|
11
|
+
} from './Menu.js'
|
|
12
|
+
export type {
|
|
13
|
+
MenuGroupProps,
|
|
14
|
+
MenuLabelProps,
|
|
15
|
+
MenuSeparatorProps,
|
|
16
|
+
MenuCheckboxItemProps,
|
|
17
|
+
MenuRadioGroupProps,
|
|
18
|
+
MenuRadioItemProps,
|
|
19
|
+
MenuSubProps,
|
|
20
|
+
MenuSubTriggerProps,
|
|
21
|
+
MenuSubContentProps
|
|
22
|
+
} from './Menu.js'
|
|
1
23
|
export {
|
|
2
24
|
HoverCard,
|
|
3
25
|
HoverCardTrigger,
|
|
@@ -412,3 +434,76 @@ export type {
|
|
|
412
434
|
|
|
413
435
|
export { Toolbar } from './Toolbar.js'
|
|
414
436
|
export type { ToolbarProps, ToolbarOrientation } from './Toolbar.js'
|
|
437
|
+
|
|
438
|
+
export {
|
|
439
|
+
ContextMenu,
|
|
440
|
+
ContextMenuTrigger,
|
|
441
|
+
ContextMenuPortal,
|
|
442
|
+
ContextMenuContent,
|
|
443
|
+
ContextMenuItem,
|
|
444
|
+
ContextMenuGroup,
|
|
445
|
+
ContextMenuLabel,
|
|
446
|
+
ContextMenuSeparator,
|
|
447
|
+
ContextMenuCheckboxItem,
|
|
448
|
+
ContextMenuRadioGroup,
|
|
449
|
+
ContextMenuRadioItem,
|
|
450
|
+
ContextMenuSub,
|
|
451
|
+
ContextMenuSubTrigger,
|
|
452
|
+
ContextMenuSubContent,
|
|
453
|
+
useContextMenu
|
|
454
|
+
} from './ContextMenu.js'
|
|
455
|
+
export type {
|
|
456
|
+
ContextMenuProps,
|
|
457
|
+
ContextMenuTriggerProps,
|
|
458
|
+
ContextMenuPortalProps,
|
|
459
|
+
ContextMenuContentProps,
|
|
460
|
+
ContextMenuItemProps,
|
|
461
|
+
ContextMenuGroupProps,
|
|
462
|
+
ContextMenuLabelProps,
|
|
463
|
+
ContextMenuSeparatorProps,
|
|
464
|
+
ContextMenuCheckboxItemProps,
|
|
465
|
+
ContextMenuRadioGroupProps,
|
|
466
|
+
ContextMenuRadioItemProps,
|
|
467
|
+
ContextMenuSubProps,
|
|
468
|
+
ContextMenuSubTriggerProps,
|
|
469
|
+
ContextMenuSubContentProps,
|
|
470
|
+
ContextMenuState
|
|
471
|
+
} from './ContextMenu.js'
|
|
472
|
+
|
|
473
|
+
export {
|
|
474
|
+
Menubar,
|
|
475
|
+
MenubarMenu,
|
|
476
|
+
MenubarTrigger,
|
|
477
|
+
MenubarPortal,
|
|
478
|
+
MenubarContent,
|
|
479
|
+
MenubarItem,
|
|
480
|
+
MenubarGroup,
|
|
481
|
+
MenubarLabel,
|
|
482
|
+
MenubarSeparator,
|
|
483
|
+
MenubarCheckboxItem,
|
|
484
|
+
MenubarRadioGroup,
|
|
485
|
+
MenubarRadioItem,
|
|
486
|
+
MenubarSub,
|
|
487
|
+
MenubarSubTrigger,
|
|
488
|
+
MenubarSubContent,
|
|
489
|
+
useMenubar
|
|
490
|
+
} from './Menubar.js'
|
|
491
|
+
export type {
|
|
492
|
+
MenubarProps,
|
|
493
|
+
MenubarMenuProps,
|
|
494
|
+
MenubarTriggerProps,
|
|
495
|
+
MenubarPortalProps,
|
|
496
|
+
MenubarContentProps,
|
|
497
|
+
MenubarItemProps,
|
|
498
|
+
MenubarGroupProps,
|
|
499
|
+
MenubarLabelProps,
|
|
500
|
+
MenubarSeparatorProps,
|
|
501
|
+
MenubarCheckboxItemProps,
|
|
502
|
+
MenubarRadioGroupProps,
|
|
503
|
+
MenubarRadioItemProps,
|
|
504
|
+
MenubarSubProps,
|
|
505
|
+
MenubarSubTriggerProps,
|
|
506
|
+
MenubarSubContentProps,
|
|
507
|
+
MenubarState,
|
|
508
|
+
MenubarRenderProps
|
|
509
|
+
} from './Menubar.js'
|
|
@@ -13,6 +13,7 @@ export function usePopoverSurface<Node extends HTMLElement>(
|
|
|
13
13
|
close: (restore: boolean) => void,
|
|
14
14
|
restoreFocus: RefObject<boolean>,
|
|
15
15
|
options: {
|
|
16
|
+
anchorPoint?: { x: number; y: number }
|
|
16
17
|
initialFocusRef?: RefObject<HTMLElement | null>
|
|
17
18
|
onFocusOutside?: () => void
|
|
18
19
|
side: PopoverSide
|
|
@@ -28,7 +29,7 @@ export function usePopoverSurface<Node extends HTMLElement>(
|
|
|
28
29
|
useLayoutEffect(() => {
|
|
29
30
|
latest.current = { ...options, open, close }
|
|
30
31
|
})
|
|
31
|
-
const { side, align, sideOffset, collisionPadding } = options
|
|
32
|
+
const { side, align, sideOffset, collisionPadding, anchorPoint } = options
|
|
32
33
|
|
|
33
34
|
useLayoutEffect(() => {
|
|
34
35
|
const node = nodeRef.current
|
|
@@ -66,7 +67,7 @@ export function usePopoverSurface<Node extends HTMLElement>(
|
|
|
66
67
|
const shouldRestore = () => restoreFocus.current
|
|
67
68
|
const place = () => {
|
|
68
69
|
if (!node.isConnected || !node.matches(':popover-open')) return
|
|
69
|
-
const { side, align, sideOffset, collisionPadding } = latest.current
|
|
70
|
+
const { side, align, sideOffset, collisionPadding, anchorPoint } = latest.current
|
|
70
71
|
const viewport = win.visualViewport
|
|
71
72
|
const view = {
|
|
72
73
|
top: viewport?.offsetTop ?? 0,
|
|
@@ -84,7 +85,16 @@ export function usePopoverSurface<Node extends HTMLElement>(
|
|
|
84
85
|
)
|
|
85
86
|
const css = win.getComputedStyle(node)
|
|
86
87
|
const next = positionPopover({
|
|
87
|
-
anchor:
|
|
88
|
+
anchor: anchorPoint
|
|
89
|
+
? {
|
|
90
|
+
top: anchorPoint.y,
|
|
91
|
+
bottom: anchorPoint.y,
|
|
92
|
+
left: anchorPoint.x,
|
|
93
|
+
right: anchorPoint.x,
|
|
94
|
+
width: 0,
|
|
95
|
+
height: 0
|
|
96
|
+
}
|
|
97
|
+
: trigger.getBoundingClientRect(),
|
|
88
98
|
width: node.offsetWidth,
|
|
89
99
|
height:
|
|
90
100
|
node.scrollHeight + parseFloat(css.borderTopWidth) + parseFloat(css.borderBottomWidth),
|
|
@@ -217,5 +227,8 @@ export function usePopoverSurface<Node extends HTMLElement>(
|
|
|
217
227
|
reposition.current = () => {}
|
|
218
228
|
}
|
|
219
229
|
}, [nodeRef, trigger, open, generation, restoreFocus])
|
|
220
|
-
useLayoutEffect(
|
|
230
|
+
useLayoutEffect(
|
|
231
|
+
() => reposition.current(),
|
|
232
|
+
[side, align, sideOffset, collisionPadding, anchorPoint?.x, anchorPoint?.y]
|
|
233
|
+
)
|
|
221
234
|
}
|
|
@@ -20,6 +20,7 @@ type Options<Node extends HTMLElement> = {
|
|
|
20
20
|
loop: boolean
|
|
21
21
|
active?: boolean
|
|
22
22
|
deferTo?: string
|
|
23
|
+
includeAriaDisabled?: boolean
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
/** Native hosts and DOM order stay authoritative, including dynamic disabled items. */
|
|
@@ -31,7 +32,8 @@ export function useRovingFocus<Node extends HTMLElement>({
|
|
|
31
32
|
orientation,
|
|
32
33
|
loop,
|
|
33
34
|
active = true,
|
|
34
|
-
deferTo
|
|
35
|
+
deferTo,
|
|
36
|
+
includeAriaDisabled = false
|
|
35
37
|
}: Options<Node>) {
|
|
36
38
|
const ownsFocus = (node: Node) => {
|
|
37
39
|
if (!active) return false
|
|
@@ -50,7 +52,7 @@ export function useRovingFocus<Node extends HTMLElement>({
|
|
|
50
52
|
return items(node).filter(
|
|
51
53
|
item =>
|
|
52
54
|
!item.matches(':disabled') &&
|
|
53
|
-
item.getAttribute('aria-disabled') !== 'true' &&
|
|
55
|
+
(includeAriaDisabled || item.getAttribute('aria-disabled') !== 'true') &&
|
|
54
56
|
!item.closest('[inert], [hidden]') &&
|
|
55
57
|
item.getClientRects().length > 0 &&
|
|
56
58
|
!['hidden', 'collapse'].includes(view.getComputedStyle(item).visibility)
|
|
@@ -123,6 +125,7 @@ export function useRovingFocus<Node extends HTMLElement>({
|
|
|
123
125
|
}
|
|
124
126
|
})
|
|
125
127
|
return {
|
|
128
|
+
items: enabled,
|
|
126
129
|
onFocus(event: FocusEvent<Node>) {
|
|
127
130
|
if (
|
|
128
131
|
ownsFocus(event.currentTarget) &&
|
package/src/themes/components.ts
CHANGED
|
@@ -2,6 +2,8 @@ import { kebabCase } from './tokens.js'
|
|
|
2
2
|
|
|
3
3
|
/** Explicit component slots; omitted slots reset to CSS fallback semantics. */
|
|
4
4
|
export const componentRegistry = {
|
|
5
|
+
menubar: { gap: 'css', padding: 'css', radius: 'css', background: 'css' },
|
|
6
|
+
contextMenu: { width: 'css' },
|
|
5
7
|
hoverCard: { width: 'css' },
|
|
6
8
|
button: {
|
|
7
9
|
radius: 'css',
|