-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(TreeSelect): added error state view and hasClear prop (#1885)
- Loading branch information
1 parent
523caf8
commit 9849e4b
Showing
4 changed files
with
109 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/components/TreeSelect/__stories__/components/ErrorStateExample.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import React from 'react'; | ||
|
||
import {Flex} from '../../../layout'; | ||
import type {ListItemType} from '../../../useList'; | ||
import {TreeSelect} from '../../TreeSelect'; | ||
import type {TreeSelectProps} from '../../types'; | ||
|
||
type Entity = string; | ||
|
||
export interface ErrorStateExampleProps | ||
extends Omit<TreeSelectProps<Entity>, 'items' | 'mapItemDataToContentProps'> {} | ||
|
||
const items: ListItemType<Entity>[] = ['one', 'two', 'free']; | ||
const errorMessage = 'A validation error has occurred'; | ||
|
||
export const ErrorStateExample = ({...props}: ErrorStateExampleProps) => { | ||
const containerRef = React.useRef<HTMLDivElement>(null); | ||
|
||
return ( | ||
<Flex gap="5"> | ||
<TreeSelect | ||
{...props} | ||
items={items} | ||
getItemId={(id) => id} | ||
placeholder="-" | ||
containerRef={containerRef} | ||
mapItemDataToContentProps={(title) => ({title})} | ||
errorMessage={errorMessage} | ||
errorPlacement="outside" | ||
validationState="invalid" | ||
hasClear | ||
/> | ||
<TreeSelect | ||
{...props} | ||
items={items} | ||
getItemId={(id) => id} | ||
placeholder="-" | ||
containerRef={containerRef} | ||
mapItemDataToContentProps={(title) => ({title})} | ||
errorMessage={errorMessage} | ||
errorPlacement="inside" | ||
validationState="invalid" | ||
hasClear | ||
/> | ||
</Flex> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters