Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 677
chore: add ActionList primitives exports#7755
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
1a70c2bfaf702582f780abb702e50b87ed68b9b750b3ccc6e59281105abd23809fe81f47ba43a935b9c8e4ff662ecd5679ce9843ed36541c1155eff9ea6a8da8e325a068e2e04a792c6de6fea8fc61226c35899542191f745175439d0a4230e5c2a6d2eb122e0db3f6fbcdc30c582d9fbb7762b5bd47a4732e2cf01b0cd978c44c530fe2c4File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "@primer/react": minor | ||
| --- | ||
| feat: add ActionList, SelectPanel primitives exports and new FilteredActionList.Input components |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -4,7 +4,6 @@ import type {KeyboardEventHandler, JSX} from 'react' | ||
| import type React from 'react' | ||
| import {forwardRef, useCallback, useEffect, useMemo, useRef, useState} from 'react' | ||
| import type {TextInputProps} from '../TextInput' | ||
| import TextInput from '../TextInput' | ||
| import {ActionList, type ActionListProps} from '../ActionList' | ||
| import type {GroupedListProps, ListPropsBase, ItemInput, RenderItemFn} from './' | ||
| import {useFocusZone} from '../hooks/useFocusZone' | ||
| @@ -22,6 +21,7 @@ import {isValidElementType} from 'react-is' | ||
| import {useAnnouncements} from './useAnnouncements' | ||
| import {clsx} from 'clsx' | ||
| import {useVirtualizer} from '@tanstack/react-virtual' | ||
| import {FilteredActionListInput} from './FilteredActionListInput' | ||
| const menuScrollMargins: ScrollIntoViewOptions = {startMargin: 0, endMargin: 8} | ||
| @@ -543,39 +543,26 @@ export function FilteredActionList({ | ||
| } | ||
| } | ||
| const {className: textInputClassName, ...restTextInputProps} = textInputProps || {} | ||
| return ( | ||
| <div | ||
| ref={inputAndListContainerRef} | ||
| className={clsx(className, classes.Root)} | ||
| data-testid="filtered-action-list" | ||
| data-component="FilteredActionList" | ||
| > | ||
| <div className={classes.Header} data-component="FilteredActionList.Header"> | ||
| <TextInput | ||
| // @ts-expect-error it needs a non nullable ref | ||
| ref={inputRef} | ||
| block | ||
| width="auto" | ||
| color="fg.default" | ||
| value={filterValue} | ||
| onChange={onInputChange} | ||
| onKeyPress={onInputKeyPress} | ||
| onKeyDown={usingRovingTabindex ? onInputKeyDown : () => {}} | ||
| placeholder={placeholderText} | ||
| role="combobox" | ||
| aria-expanded="true" | ||
| aria-autocomplete="list" | ||
| aria-controls={listId} | ||
| aria-label={placeholderText} | ||
| aria-describedby={inputDescriptionTextId} | ||
| loaderPosition={'leading'} | ||
| loading={loading && !loadingType.appearsInBody} | ||
| className={clsx(textInputClassName, {[classes.FullScreenTextInput]: fullScreenOnNarrow})} | ||
| {...restTextInputProps} | ||
| /> | ||
| </div> | ||
| <FilteredActionListInput | ||
| inputRef={inputRef} | ||
| value={filterValue} | ||
| onInputChange={onInputChange} | ||
| onInputKeyPress={onInputKeyPress} | ||
| onInputKeyDown={usingRovingTabindex ? onInputKeyDown : undefined} | ||
| placeholderText={placeholderText} | ||
| listId={listId} | ||
| inputDescriptionTextId={inputDescriptionTextId} | ||
| loading={loading && !loadingType.appearsInBody} | ||
| fullScreenOnNarrow={fullScreenOnNarrow} | ||
| {...textInputProps} | ||
| /> | ||
francinelucca marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| <VisuallyHidden id={inputDescriptionTextId}>Items will be filtered as you type</VisuallyHidden> | ||
| {onSelectAllChange !== undefined && ( | ||
| <div className={classes.SelectAllContainer} data-component="FilteredActionList.SelectAll"> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import type React from 'react' | ||
| import {clsx} from 'clsx' | ||
| import TextInput from '../TextInput' | ||
| import type {TextInputProps} from '../TextInput' | ||
| import classes from './FilteredActionList.module.css' | ||
| export interface FilteredActionListInputProps extends Partial<Omit<TextInputProps, 'onChange' | 'onKeyDown'>> { | ||
| inputRef: React.RefObject<HTMLInputElement | null> | ||
| onInputChange?: (e: React.ChangeEvent<HTMLInputElement>) => void | ||
| onInputKeyPress?: React.KeyboardEventHandler<HTMLInputElement> | ||
| onInputKeyDown?: React.KeyboardEventHandler<HTMLInputElement> | ||
| placeholderText?: string | ||
| listId: string | ||
| inputDescriptionTextId: string | ||
| loading: boolean | ||
| fullScreenOnNarrow?: boolean | ||
| } | ||
| export function FilteredActionListInput({ | ||
| inputRef, | ||
| value, | ||
| onInputChange, | ||
| onInputKeyPress, | ||
| onInputKeyDown, | ||
| placeholderText, | ||
| listId, | ||
| inputDescriptionTextId, | ||
| loading, | ||
| fullScreenOnNarrow, | ||
| className, | ||
| ...restTextInputProps | ||
| }: FilteredActionListInputProps): React.JSX.Element { | ||
| return ( | ||
| <div className={classes.Header} data-component="FilteredActionList.Header"> | ||
| <TextInput | ||
| // @ts-expect-error it needs a non nullable ref | ||
| ref={inputRef} | ||
| block | ||
francinelucca marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| width="auto" | ||
| color="fg.default" | ||
| value={value} | ||
| onChange={onInputChange} | ||
| onKeyPress={onInputKeyPress} | ||
| onKeyDown={onInputKeyDown} | ||
| placeholder={placeholderText} | ||
| role="combobox" | ||
| aria-expanded="true" | ||
| aria-autocomplete="list" | ||
| aria-controls={listId} | ||
| aria-label={placeholderText} | ||
| aria-describedby={inputDescriptionTextId} | ||
| loaderPosition={'leading'} | ||
| loading={loading} | ||
| className={clsx(className, {[classes.FullScreenTextInput]: fullScreenOnNarrow})} | ||
| {...restTextInputProps} | ||
| /> | ||
francinelucca marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| </div> | ||
| ) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| export {SelectPanel} from './SelectPanel' | ||
| export {SelectPanelMessage} from './SelectPanelMessage' | ||
| export type {SelectPanelProps} from './SelectPanel' | ||
| export type {ItemProps, ItemInput, GroupedListProps, ListPropsBase} from '../FilteredActionList' | ||
francinelucca marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -7,6 +7,7 @@ exports[`@primer/react > should not update exports without a semver change 1`] = | ||
| "ActionList", | ||
| "type ActionListDescriptionProps", | ||
| "type ActionListDividerProps", | ||
| "type ActionListGroupHeadingProps", | ||
| "type ActionListGroupProps", | ||
| "type ActionListItemProps", | ||
| "type ActionListLeadingVisualProps", | ||
| @@ -68,6 +69,7 @@ exports[`@primer/react > should not update exports without a semver change 1`] = | ||
| "type DialogWidth", | ||
| "Flash", | ||
| "type FlashProps", | ||
| "FocusKeys", | ||
| "type FocusTrapHookSettings", | ||
| "type FocusZoneHookSettings", | ||
| "FormControl", | ||
| @@ -308,6 +310,8 @@ exports[`@primer/react/experimental > should not update exports without a semver | ||
| "FeatureFlags", | ||
| "type FeatureFlagsProps", | ||
| "FilteredActionList", | ||
| "type FilteredActionListInputProps", | ||
| "FilteredActionListLoadingTypes", | ||
francinelucca marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| "type FilteredActionListProps", | ||
| "getAccessibleKeybindingHintString", | ||
| "Hidden", | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we envision splitting up more of
FilteredActionList?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We definitely could. I assume that'd come with the SelectPanel separation work if we ever get to it 🙏🏽. Just added what I needed for now