-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Add support for custom collection renderers (e.g. virtualization) #5912
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
11e152d
3b483bd
085ec8c
a31e0a0
b606a45
3227437
7db6818
57c12f2
d7e3b10
0b6a2d3
da871e0
39db25f
74827d3
13475a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,16 +13,19 @@ | |
| import {AriaMenuItemProps} from './useMenuItem'; | ||
| import {AriaMenuOptions} from './useMenu'; | ||
| import type {AriaPopoverProps, OverlayProps} from '@react-aria/overlays'; | ||
| import {FocusableElement, FocusStrategy, KeyboardEvent, PressEvent, Node as RSNode} from '@react-types/shared'; | ||
| import {FocusableElement, FocusStrategy, KeyboardEvent, Node, PressEvent} from '@react-types/shared'; | ||
| import {RefObject, useCallback, useRef} from 'react'; | ||
| import type {SubmenuTriggerState} from '@react-stately/menu'; | ||
| import {useEffectEvent, useId, useLayoutEffect} from '@react-aria/utils'; | ||
| import {useLocale} from '@react-aria/i18n'; | ||
| import {useSafelyMouseToSubmenu} from './useSafelyMouseToSubmenu'; | ||
|
|
||
| export interface AriaSubmenuTriggerProps { | ||
| /** An object representing the submenu trigger menu item. Contains all the relevant information that makes up the menu item. */ | ||
| node: RSNode<unknown>, | ||
| /** | ||
| * An object representing the submenu trigger menu item. Contains all the relevant information that makes up the menu item. | ||
| * @deprecated | ||
| */ | ||
| node?: Node<unknown>, | ||
| /** Whether the submenu trigger is disabled. */ | ||
| isDisabled?: boolean, | ||
| /** The type of the contents that the submenu trigger opens. */ | ||
|
|
@@ -64,7 +67,7 @@ export interface SubmenuTriggerAria<T> { | |
| * @param ref - Ref to the submenu trigger element. | ||
| */ | ||
| export function useSubmenuTrigger<T>(props: AriaSubmenuTriggerProps, state: SubmenuTriggerState, ref: RefObject<FocusableElement>): SubmenuTriggerAria<T> { | ||
| let {parentMenuRef, submenuRef, type = 'menu', isDisabled, node, delay = 200} = props; | ||
| let {parentMenuRef, submenuRef, type = 'menu', isDisabled, delay = 200} = props; | ||
| let submenuTriggerId = useId(); | ||
| let overlayId = useId(); | ||
| let {direction} = useLocale(); | ||
|
|
@@ -117,7 +120,7 @@ export function useSubmenuTrigger<T>(props: AriaSubmenuTriggerProps, state: Subm | |
|
|
||
| let submenuProps = { | ||
| id: overlayId, | ||
| 'aria-label': node.textValue, | ||
| 'aria-labelledby': submenuTriggerId, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This avoids needing to pass in the menu item node. In RAC's case, the node is the |
||
| submenuLevel: state.submenuLevel, | ||
| ...(type === 'menu' && { | ||
| onClose: state.closeAll, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,11 +38,13 @@ export interface SpectrumTreeViewProps<T> extends Omit<AriaTreeGridListProps<T>, | |
| children?: ReactNode | ((item: T) => ReactNode) | ||
| } | ||
|
|
||
| export interface SpectrumTreeViewItemProps extends Omit<TreeItemProps, 'className' | 'style' | 'value'> { | ||
| export interface SpectrumTreeViewItemProps<T extends object = object> extends Omit<TreeItemProps, 'className' | 'style' | 'value'> { | ||
| /** Rendered contents of the tree item or child items. */ | ||
| children: ReactNode, | ||
| /** Whether this item has children, even if not loaded yet. */ | ||
| hasChildItems?: boolean | ||
| hasChildItems?: boolean, | ||
| /** A list of child tree item objects used when dynamically rendering the tree item children. */ | ||
| childItems?: Iterable<T> | ||
|
Comment on lines
+46
to
+47
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For posterity in case we need to find the related ticket/discussion: RSP Component Milestones (view) We will want to possibly change TreeView to a more RAC Tree like api instead of mimicking the same api of other current RSP collection components (e.g. using |
||
| } | ||
|
|
||
| interface TreeRendererContextValue { | ||
|
|
@@ -220,7 +222,7 @@ const treeRowOutline = style({ | |
| } | ||
| }); | ||
|
|
||
| export const TreeViewItem = (props: SpectrumTreeViewItemProps) => { | ||
| export const TreeViewItem = <T extends object>(props: SpectrumTreeViewItemProps<T>) => { | ||
| let { | ||
| children, | ||
| childItems, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.