Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions .changeset/new-mangos-fold.md

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion e2e/components/SelectPanel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const scenarios = matrix({
name: 'With Placeholder for Search Input',
},
{id: 'components-selectpanel-examples--above-tall-body', name: 'Above Tall Body'},
{id: 'components-selectpanel-examples--height-variations-and-scroll', name: 'Height Variations and Scroll'},
{id: 'components-selectpanel-examples--height-variantions-and-scroll', name: 'Height Variantions and Scroll'},
{
id: 'components-selectpanel-examples--height-initial-with-overflowing-items-story',
name: 'Height Initial with Overflowing Items',
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {VisuallyHidden} from '../VisuallyHidden'
import type {SxProp} from '../sx'
import type {FilteredActionListLoadingType} from './FilteredActionListLoaders'
import {FilteredActionListLoadingTypes, FilteredActionListBodyLoader} from './FilteredActionListLoaders'
import classes from './FilteredActionList.module.css'
import {ActionListContainerContext} from '../ActionList/ActionListContainerContext'

import {isValidElementType} from 'react-is'
Expand All @@ -33,7 +32,6 @@ export interface FilteredActionListProps
onInputRefChanged?: (ref: React.RefObject<HTMLInputElement>) => void
textInputProps?: Partial<Omit<TextInputProps, 'onChange'>>
inputRef?: React.RefObject<HTMLInputElement>
message?: React.ReactNode
className?: string
announcementsEnabled?: boolean
}
Expand All @@ -56,7 +54,6 @@ export function FilteredActionList({
sx,
groupMetadata,
showItemDividers,
message,
className,
selectionVariant,
announcementsEnabled = true,
Expand Down Expand Up @@ -153,47 +150,6 @@ export function FilteredActionList({
return itemsInGroup
}

function getBodyContent() {
if (loading && scrollContainerRef.current && loadingType.appearsInBody) {
return <FilteredActionListBodyLoader loadingType={loadingType} height={scrollContainerRef.current.clientHeight} />
}
if (message) {
return message
}

return (
<ActionListContainerContext.Provider
value={{
container: 'FilteredActionList',
listRole: 'listbox',
selectionAttribute: 'aria-selected',
selectionVariant,
enableFocusZone: true,
}}
>
<ActionList ref={listRef} showDividers={showItemDividers} {...listProps} id={listId} sx={{flexGrow: 1}}>
{groupMetadata?.length
? groupMetadata.map((group, index) => {
return (
<ActionList.Group key={index}>
<ActionList.GroupHeading variant={group.header?.variant ? group.header.variant : undefined}>
{group.header?.title ? group.header.title : `Group ${group.groupId}`}
</ActionList.GroupHeading>
{getItemListForEachGroup(group.groupId).map((item, index) => {
const key = item.key ?? item.id?.toString() ?? index.toString()
return <MappedActionListItem key={key} {...item} renderItem={listProps.renderItem} />
})}
</ActionList.Group>
)
})
: items.map((item, index) => {
const key = item.key ?? item.id?.toString() ?? index.toString()
return <MappedActionListItem key={key} {...item} renderItem={listProps.renderItem} />
})}
</ActionList>
</ActionListContainerContext.Provider>
)
}
useAnnouncements(items, listRef, inputRef, enableAnnouncements)

return (
Expand Down Expand Up @@ -227,9 +183,42 @@ export function FilteredActionList({
/>
</StyledHeader>
<VisuallyHidden id={inputDescriptionTextId}>Items will be filtered as you type</VisuallyHidden>
<div ref={scrollContainerRef} className={classes.Container}>
{getBodyContent()}
</div>
<Box ref={scrollContainerRef} overflow="auto" display="flex" flexGrow={1}>
{loading && scrollContainerRef.current && loadingType.appearsInBody ? (
<FilteredActionListBodyLoader loadingType={loadingType} height={scrollContainerRef.current.clientHeight} />
) : (
<ActionListContainerContext.Provider
value={{
container: 'FilteredActionList',
listRole: 'listbox',
selectionAttribute: 'aria-selected',
selectionVariant,
enableFocusZone: true,
}}
>
<ActionList ref={listRef} showDividers={showItemDividers} {...listProps} id={listId} sx={{flexGrow: 1}}>
{groupMetadata?.length
? groupMetadata.map((group, index) => {
return (
<ActionList.Group key={index}>
<ActionList.GroupHeading variant={group.header?.variant ? group.header.variant : undefined}>
{group.header?.title ? group.header.title : `Group ${group.groupId}`}
</ActionList.GroupHeading>
{getItemListForEachGroup(group.groupId).map((item, index) => {
const key = item.key ?? item.id?.toString() ?? index.toString()
return <MappedActionListItem key={key} {...item} renderItem={listProps.renderItem} />
})}
</ActionList.Group>
)
})
: items.map((item, index) => {
const key = item.key ?? item.id?.toString() ?? index.toString()
return <MappedActionListItem key={key} {...item} renderItem={listProps.renderItem} />
})}
</ActionList>
</ActionListContainerContext.Provider>
)}
</Box>
</Box>
)
}
Expand Down
13 changes: 1 addition & 12 deletions packages/react/src/SelectPanel/SelectPanel.dev.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,13 @@ import type {ItemInput} from '../deprecated/ActionList/List'
import {FeatureFlags} from '../FeatureFlags'
import FormControl from '../FormControl'

const meta: Meta<typeof SelectPanel> = {
const meta = {
title: 'Components/SelectPanel/Dev',
component: SelectPanel,
} satisfies Meta<typeof SelectPanel>

export default meta

const NoResultsMessage = (filter: string): {variant: 'empty'; title: string; body: string} => {
return {
variant: 'empty',
title: `No language found for \`${filter}\``,
body: 'Adjust your search term to find other languages',
}
}

function getColorCircle(color: string) {
return function () {
return (
Expand Down Expand Up @@ -116,7 +108,6 @@ export const WithCss = () => {
onSelectedChange={setSelected}
onFilterChange={setFilter}
className="testCustomClassnameMono"
message={selectedItemsSortedFirst.length === 0 ? NoResultsMessage(filter) : undefined}
/>
</FormControl>
</FeatureFlags>
Expand Down Expand Up @@ -168,7 +159,6 @@ export const WithSx = () => {
onSelectedChange={setSelected}
onFilterChange={setFilter}
sx={{fontFamily: 'Times New Roman'}}
message={selectedItemsSortedFirst.length === 0 ? NoResultsMessage(filter) : undefined}
/>
</FormControl>
</FeatureFlags>
Expand Down Expand Up @@ -221,7 +211,6 @@ export const WithSxAndCSS = () => {
onFilterChange={setFilter}
sx={{fontFamily: 'Times New Roman'}}
className="testCustomClassnameMono"
message={selectedItemsSortedFirst.length === 0 ? NoResultsMessage(filter) : undefined}
/>
</FormControl>
</FeatureFlags>
Expand Down
43 changes: 1 addition & 42 deletions packages/react/src/SelectPanel/SelectPanel.docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -150,48 +150,7 @@
"type": "string | React.ReactElement",
"defaultValue": "null",
"description": "Footer rendered at the end of the panel"
},
{
"name": "message",
"type": "{title: string | React.ReactElement; variant: 'empty' | 'error' | 'warning'; body: React.ReactNode;}",
"defaultValue": "A default empty message is provided by default if this option is not supplied",
"description": "Message to display in the panel in case of error or empty results"
},
{
"name": "notice",
"type": "{text: string | React.ReactElement; variant: 'empty' | 'error' | 'warning';}",
"description": "Optional notice to display on top of the panel"
}
],
"subcomponents": [
{
"name": "SelectPanel.Message",
"props": [
{
"name": "title",
"type": "string",
"description": "A title for the message"
},
{
"name": "variant",
"type": "'empty' | 'error' | 'warning'",
"description": "The variant of the message",
"required": true
},
{
"name": "className",
"type": "string",
"defaultValue": "",
"description": "Custom className"
},
{
"name": "children",
"type": "React.ReactNode",
"defaultValue": "",
"required": true,
"description": "The message to display"
}
]
}
]
"subcomponents": []
}
26 changes: 4 additions & 22 deletions packages/react/src/SelectPanel/SelectPanel.examples.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,13 @@ import FormControl from '../FormControl'
import {Stack} from '../Stack'
import {Dialog} from '../experimental'

const meta: Meta<typeof SelectPanel> = {
const meta = {
title: 'Components/SelectPanel/Examples',
component: SelectPanel,
} satisfies Meta<typeof SelectPanel>

export default meta

const NoResultsMessage = (filter: string): {variant: 'empty'; title: string; body: string} => {
return {
variant: 'empty',
title: `No language found for \`${filter}\``,
body: 'Adjust your search term to find other languages',
}
}

function getColorCircle(color: string) {
return function () {
return (
Expand Down Expand Up @@ -90,7 +82,6 @@ export const HeightInitialWithOverflowingItemsStory = () => {
onSelectedChange={setSelected}
onFilterChange={setFilter}
overlayProps={{width: 'small', height: 'initial', maxHeight: 'xsmall'}}
message={selectedItemsSortedFirst.length === 0 ? NoResultsMessage(filter) : undefined}
/>
</FormControl>
)
Expand Down Expand Up @@ -136,7 +127,6 @@ export const HeightInitialWithUnderflowingItemsStory = () => {
onFilterChange={setFilter}
showItemDividers={true}
overlayProps={{width: 'small', height: 'initial', maxHeight: 'xsmall'}}
message={selectedItemsSortedFirst.length === 0 ? NoResultsMessage(filter) : undefined}
/>
</FormControl>
)
Expand All @@ -159,7 +149,7 @@ export const HeightInitialWithUnderflowingItemsAfterFetch = () => {
[fetchedItems, filter, selected],
)
// design guidelines say to sort selected items first
const selectedItemsSortedFirst = filteredItems.sort((a, b) => {
const selectedItemsSortedFirst = fetchedItems.sort((a, b) => {
const aIsSelected = selected.some(selectedItem => selectedItem.text === a.text)
const bIsSelected = selected.some(selectedItem => selectedItem.text === b.text)
if (aIsSelected && !bIsSelected) return -1
Expand Down Expand Up @@ -189,14 +179,13 @@ export const HeightInitialWithUnderflowingItemsAfterFetch = () => {
placeholder="Select labels" // button text when no items are selected
open={open}
onOpenChange={onOpenChange}
loading={filteredItems.length === 0 && !filter}
loading={filteredItems.length === 0}
items={selectedItemsSortedFirst}
selected={selected}
onSelectedChange={setSelected}
onFilterChange={setFilter}
showItemDividers={true}
overlayProps={{width: 'small', height, maxHeight: 'xsmall'}}
message={selectedItemsSortedFirst.length === 0 ? NoResultsMessage(filter) : undefined}
/>
</FormControl>
)
Expand Down Expand Up @@ -239,7 +228,6 @@ export const AboveTallBody = () => {
onSelectedChange={setSelected}
onFilterChange={setFilter}
showItemDividers={true}
message={selectedItemsSortedFirst.length === 0 ? NoResultsMessage(filter) : undefined}
/>
<div
style={{
Expand All @@ -257,7 +245,7 @@ export const AboveTallBody = () => {
)
}

export const HeightVariationsAndScroll = () => {
export const HeightVariantionsAndScroll = () => {
const longItems = [...items, ...items, ...items, ...items, ...items, ...items, ...items, ...items]
const [filter, setFilter] = useState('')
// Example A
Expand Down Expand Up @@ -305,7 +293,6 @@ export const HeightVariationsAndScroll = () => {
onFilterChange={setFilter}
showItemDividers={true}
overlayProps={{height: 'medium'}}
message={selectedItemsSortedFirstA.length === 0 ? NoResultsMessage(filter) : undefined}
/>
</FormControl>
<br />
Expand All @@ -329,7 +316,6 @@ export const HeightVariationsAndScroll = () => {
height: 'auto',
maxHeight: 'medium',
}}
message={selectedItemsSortedFirstB.length === 0 ? NoResultsMessage(filter) : undefined}
/>
</FormControl>
</>
Expand Down Expand Up @@ -404,7 +390,6 @@ export const CustomItemRenderer = () => {
</Box>
</ActionList.Item>
)}
message={selectedItemsSortedFirst.length === 0 ? NoResultsMessage(filter) : undefined}
/>
</FormControl>
)
Expand Down Expand Up @@ -454,7 +439,6 @@ export const ItemsInScope = () => {
selected={selected}
onSelectedChange={setSelected}
onFilterChange={setFilter}
message={selectedItemsSortedFirst.length === 0 ? NoResultsMessage(filter) : undefined}
/>
</FormControl>
)
Expand Down Expand Up @@ -500,7 +484,6 @@ export const RepositionAfterLoading = () => {
selected={selected}
onSelectedChange={setSelected}
onFilterChange={setFilter}
message={filteredItems.length === 0 ? NoResultsMessage(filter) : undefined}
/>
</Stack>
</>
Expand Down Expand Up @@ -548,7 +531,6 @@ export const SelectPanelRepositionInsideDialog = () => {
onSelectedChange={setSelected}
onFilterChange={setFilter}
overlayProps={{anchorSide: 'outside-top'}}
message={filteredItems.length === 0 ? NoResultsMessage(filter) : undefined}
/>
</Stack>
</Dialog>
Expand Down
Loading
Loading