Commit fb77fae0 authored by tom's avatar tom

lg size for select

parent 9800d2d4
'use client'; 'use client';
import type { CollectionItem, ListCollection } from '@chakra-ui/react'; import type { CollectionItem, ListCollection } from '@chakra-ui/react';
import { Select as ChakraSelect, createListCollection, Portal, useSelectContext } from '@chakra-ui/react'; import { Box, Select as ChakraSelect, createListCollection, Flex, Portal, useSelectContext } from '@chakra-ui/react';
import { useDebounce } from '@uidotdev/usehooks'; import { useDebounce } from '@uidotdev/usehooks';
import * as React from 'react'; import * as React from 'react';
...@@ -111,54 +111,78 @@ export const SelectItem = React.forwardRef< ...@@ -111,54 +111,78 @@ export const SelectItem = React.forwardRef<
); );
}); });
interface SelectValueTextProps interface SelectValueTextProps extends Omit<ChakraSelect.ValueTextProps, 'children'> {
extends Omit<ChakraSelect.ValueTextProps, 'children'> {
children?(items: Array<CollectionItem>): React.ReactNode; children?(items: Array<CollectionItem>): React.ReactNode;
size?: SelectRootProps['size'];
required?: boolean;
invalid?: boolean;
errorText?: string;
} }
export const SelectValueText = React.forwardRef< export const SelectValueText = React.forwardRef<
HTMLSpanElement, HTMLSpanElement,
SelectValueTextProps SelectValueTextProps
>(function SelectValueText(props, ref) { >(function SelectValueText(props, ref) {
const { children, ...rest } = props; const { children, size, required, invalid, errorText, ...rest } = props;
const context = useSelectContext();
const content = (() => {
const items = context.selectedItems;
const placeholder = `${ props.placeholder }${ required ? '*' : '' }${ invalid && errorText ? ` - ${ errorText }` : '' }`;
if (items.length === 0) return placeholder;
if (children) return children(items);
if (items.length === 1) {
const item = items[0] as CollectionItem & { icon?: React.ReactNode };
const icon = (() => {
if (item.icon) {
return typeof item.icon === 'string' ? <IconSvg name={ item.icon } boxSize={ 5 } flexShrink={ 0 } mr={ 1 }/> : item.icon;
}
return null;
})();
const label = size === 'lg' ? (
<Box
textStyle="xs"
color={ invalid ? 'field.placeholder.error' : 'field.placeholder' }
display="-webkit-box"
>
{ placeholder }
</Box>
) : null;
return (
<>
{ label }
<Flex display="inline-flex" alignItems="center" flexWrap="nowrap">
{ icon }
<span style={{
WebkitLineClamp: 1,
WebkitBoxOrient: 'vertical',
display: '-webkit-box',
}}>
{ context.collection.stringifyItem(item) }
</span>
</Flex>
</>
);
}
// FIXME: we don't have multiple selection in the select yet
return `${ items.length } selected`;
})();
return ( return (
<ChakraSelect.ValueText { ...rest } display="inline-flex" alignItems="center" flexWrap="nowrap" ref={ ref }> <ChakraSelect.ValueText
<ChakraSelect.Context> ref={ ref }
{ (select) => { { ...rest }
const items = select.selectedItems; >
if (items.length === 0) return props.placeholder; { content }
if (children) return children(items);
if (items.length === 1) {
const item = items[0] as CollectionItem & { icon?: React.ReactNode };
const icon = (() => {
if (item.icon) {
return typeof item.icon === 'string' ? <IconSvg name={ item.icon } boxSize={ 5 } flexShrink={ 0 } mr={ 1 }/> : item.icon;
}
return null;
})();
return (
<>
{ icon }
<span style={{
WebkitLineClamp: 1,
WebkitBoxOrient: 'vertical',
display: '-webkit-box',
}}>
{ select.collection.stringifyItem(item) }
</span>
</>
);
}
// FIXME: we don't have multiple selection in the select yet
return `${ items.length } selected`;
} }
</ChakraSelect.Context>
</ChakraSelect.ValueText> </ChakraSelect.ValueText>
); );
}); });
...@@ -169,11 +193,14 @@ export const SelectRoot = React.forwardRef< ...@@ -169,11 +193,14 @@ export const SelectRoot = React.forwardRef<
HTMLDivElement, HTMLDivElement,
ChakraSelect.RootProps ChakraSelect.RootProps
>(function SelectRoot(props, ref) { >(function SelectRoot(props, ref) {
const { lazyMount = true, unmountOnExit = true, ...rest } = props;
return ( return (
<ChakraSelect.Root <ChakraSelect.Root
{ ...props }
ref={ ref } ref={ ref }
positioning={{ sameWidth: false, ...props.positioning, offset: { mainAxis: 4, ...props.positioning?.offset } }} lazyMount={ lazyMount }
unmountOnExit={ unmountOnExit }
{ ...rest }
positioning={{ sameWidth: true, ...props.positioning, offset: { mainAxis: 4, ...props.positioning?.offset } }}
> >
{ props.asChild ? ( { props.asChild ? (
props.children props.children
...@@ -212,19 +239,25 @@ export interface SelectProps extends SelectRootProps { ...@@ -212,19 +239,25 @@ export interface SelectProps extends SelectRootProps {
placeholder: string; placeholder: string;
portalled?: boolean; portalled?: boolean;
loading?: boolean; loading?: boolean;
errorText?: string;
} }
export const Select = React.forwardRef<HTMLDivElement, SelectProps>((props, ref) => { export const Select = React.forwardRef<HTMLDivElement, SelectProps>((props, ref) => {
const { collection, placeholder, portalled = true, loading, ...rest } = props; const { collection, placeholder, portalled = true, loading, errorText, ...rest } = props;
return ( return (
<SelectRoot <SelectRoot
ref={ ref } ref={ ref }
collection={ collection } collection={ collection }
variant="outline"
{ ...rest } { ...rest }
> >
<SelectControl loading={ loading }> <SelectControl loading={ loading }>
<SelectValueText placeholder={ placeholder }/> <SelectValueText
placeholder={ placeholder }
size={ props.size }
required={ props.required }
invalid={ props.invalid }
errorText={ errorText }
/>
</SelectControl> </SelectControl>
<SelectContent portalled={ portalled }> <SelectContent portalled={ portalled }>
{ collection.items.map((item) => ( { collection.items.map((item) => (
...@@ -237,7 +270,7 @@ export const Select = React.forwardRef<HTMLDivElement, SelectProps>((props, ref) ...@@ -237,7 +270,7 @@ export const Select = React.forwardRef<HTMLDivElement, SelectProps>((props, ref)
); );
}); });
export interface SelectAsyncProps extends Omit<SelectRootProps, 'collection'> { export interface SelectAsyncProps extends Omit<SelectProps, 'collection'> {
placeholder: string; placeholder: string;
portalled?: boolean; portalled?: boolean;
loading?: boolean; loading?: boolean;
...@@ -246,7 +279,7 @@ export interface SelectAsyncProps extends Omit<SelectRootProps, 'collection'> { ...@@ -246,7 +279,7 @@ export interface SelectAsyncProps extends Omit<SelectRootProps, 'collection'> {
} }
export const SelectAsync = React.forwardRef<HTMLDivElement, SelectAsyncProps>((props, ref) => { export const SelectAsync = React.forwardRef<HTMLDivElement, SelectAsyncProps>((props, ref) => {
const { placeholder, portalled = true, loading, loadOptions, extraControls, onValueChange, ...rest } = props; const { placeholder, portalled = true, loading, loadOptions, extraControls, onValueChange, errorText, ...rest } = props;
const [ collection, setCollection ] = React.useState<ListCollection<CollectionItem>>(createListCollection({ items: [] })); const [ collection, setCollection ] = React.useState<ListCollection<CollectionItem>>(createListCollection({ items: [] }));
const [ inputValue, setInputValue ] = React.useState(''); const [ inputValue, setInputValue ] = React.useState('');
...@@ -271,20 +304,28 @@ export const SelectAsync = React.forwardRef<HTMLDivElement, SelectAsyncProps>((p ...@@ -271,20 +304,28 @@ export const SelectAsync = React.forwardRef<HTMLDivElement, SelectAsyncProps>((p
<SelectRoot <SelectRoot
ref={ ref } ref={ ref }
collection={ collection } collection={ collection }
variant="outline"
onValueChange={ handleValueChange } onValueChange={ handleValueChange }
{ ...rest } { ...rest }
> >
<SelectControl loading={ loading }> <SelectControl loading={ loading }>
<SelectValueText placeholder={ placeholder }/> <SelectValueText
placeholder={ placeholder }
size={ props.size }
required={ props.required }
invalid={ props.invalid }
errorText={ errorText }
/>
</SelectControl> </SelectControl>
<SelectContent portalled={ portalled }> <SelectContent portalled={ portalled }>
<FilterInput <Box px="4">
placeholder="Search" <FilterInput
initialValue={ inputValue } placeholder="Search"
onChange={ handleFilterChange } initialValue={ inputValue }
/> onChange={ handleFilterChange }
{ extraControls } inputProps={{ pl: '9' }}
/>
{ extraControls }
</Box>
{ collection.items.map((item) => ( { collection.items.map((item) => (
<SelectItem item={ item } key={ item.value }> <SelectItem item={ item } key={ item.value }>
{ item.label } { item.label }
......
...@@ -289,7 +289,6 @@ const semanticTokens: ThemingConfig['semanticTokens'] = { ...@@ -289,7 +289,6 @@ const semanticTokens: ThemingConfig['semanticTokens'] = {
trigger: { trigger: {
outline: { outline: {
fg: { value: { _light: '{colors.blackAlpha.800}', _dark: '{colors.whiteAlpha.800}' } }, fg: { value: { _light: '{colors.blackAlpha.800}', _dark: '{colors.whiteAlpha.800}' } },
border: { value: { _light: '{colors.gray.200}', _dark: '{colors.gray.600}' } },
}, },
}, },
item: { item: {
...@@ -297,6 +296,17 @@ const semanticTokens: ThemingConfig['semanticTokens'] = { ...@@ -297,6 +296,17 @@ const semanticTokens: ThemingConfig['semanticTokens'] = {
highlighted: { value: { _light: '{colors.blue.50}', _dark: '{colors.whiteAlpha.100}' } }, highlighted: { value: { _light: '{colors.blue.50}', _dark: '{colors.whiteAlpha.100}' } },
}, },
}, },
indicator: {
fg: {
DEFAULT: { value: '{colors.gray.500}' },
},
},
placeholder: {
fg: {
DEFAULT: { value: '{colors.gray.500}' },
error: { value: '{colors.red.500}' },
},
},
}, },
menu: { menu: {
item: { item: {
......
...@@ -7,7 +7,7 @@ export const recipe = defineSlotRecipe({ ...@@ -7,7 +7,7 @@ export const recipe = defineSlotRecipe({
display: 'flex', display: 'flex',
flexDirection: 'column', flexDirection: 'column',
gap: '1.5', gap: '1.5',
width: 'fit-content', width: '100%',
}, },
trigger: { trigger: {
display: 'flex', display: 'flex',
...@@ -26,6 +26,11 @@ export const recipe = defineSlotRecipe({ ...@@ -26,6 +26,11 @@ export const recipe = defineSlotRecipe({
_disabled: { _disabled: {
opacity: 'control.disabled', opacity: 'control.disabled',
}, },
_placeholderShown: {
'& [data-part=value-text]': {
display: '-webkit-box',
},
},
}, },
indicatorGroup: { indicatorGroup: {
display: 'flex', display: 'flex',
...@@ -37,14 +42,12 @@ export const recipe = defineSlotRecipe({ ...@@ -37,14 +42,12 @@ export const recipe = defineSlotRecipe({
bottom: '0', bottom: '0',
px: '0', px: '0',
pointerEvents: 'none', pointerEvents: 'none',
_peerHover: {
color: 'link.primary.hover',
},
}, },
indicator: { indicator: {
display: 'flex', display: 'flex',
alignItems: 'center', alignItems: 'center',
justifyContent: 'center', justifyContent: 'center',
boxSize: '5',
color: 'inherit', color: 'inherit',
_open: { _open: {
color: 'link.primary.hover', color: 'link.primary.hover',
...@@ -62,7 +65,6 @@ export const recipe = defineSlotRecipe({ ...@@ -62,7 +65,6 @@ export const recipe = defineSlotRecipe({
boxShadowColor: 'colors.popover.shadow', boxShadowColor: 'colors.popover.shadow',
maxH: '96', maxH: '96',
overflowY: 'auto', overflowY: 'auto',
width: 'max-content',
minWidth: '150px', minWidth: '150px',
rowGap: '2', rowGap: '2',
_open: { _open: {
...@@ -115,8 +117,11 @@ export const recipe = defineSlotRecipe({ ...@@ -115,8 +117,11 @@ export const recipe = defineSlotRecipe({
}, },
}, },
valueText: { valueText: {
display: 'flex',
flexDirection: 'column',
lineClamp: '1', lineClamp: '1',
maxW: '100%', maxW: '100%',
wordBreak: 'break-all',
}, },
}, },
...@@ -127,20 +132,67 @@ export const recipe = defineSlotRecipe({ ...@@ -127,20 +132,67 @@ export const recipe = defineSlotRecipe({
borderWidth: '2px', borderWidth: '2px',
color: 'select.trigger.outline.fg', color: 'select.trigger.outline.fg',
bgColor: 'transparent', bgColor: 'transparent',
borderColor: 'select.trigger.outline.border', borderColor: 'input.border.filled',
_expanded: { _expanded: {
color: 'link.primary.hover', color: 'link.primary.hover',
borderColor: 'link.primary.hover', borderColor: 'link.primary.hover',
_hover: {
color: 'link.primary.hover',
borderColor: 'link.primary.hover',
},
}, },
_hover: { _hover: {
color: 'link.primary.hover', color: 'select.trigger.outline.fg',
borderColor: 'link.primary.hover', borderColor: 'input.border.hover',
}, },
_focusVisible: { _focusVisible: {
borderColor: 'link.primary.hover', borderColor: 'input.border.focus',
},
_readOnly: {
userSelect: 'all',
pointerEvents: 'none',
cursor: 'default',
bg: 'input.bg.readOnly',
borderColor: 'input.border.readOnly',
_focus: {
borderColor: 'input.border.readOnly',
},
_hover: {
borderColor: 'input.border.readOnly',
},
}, },
_invalid: { _invalid: {
borderColor: 'border.error', borderColor: 'input.border.error',
_hover: {
borderColor: 'input.border.error',
},
_expanded: {
color: 'link.primary.hover',
borderColor: 'link.primary.hover',
_hover: {
color: 'link.primary.hover',
borderColor: 'link.primary.hover',
},
},
},
_placeholderShown: {
color: 'select.placeholder.fg',
borderColor: 'input.border',
_hover: {
color: 'select.placeholder.fg',
},
_invalid: {
color: 'select.placeholder.fg.error',
_hover: {
color: 'select.placeholder.fg.error',
},
},
},
},
indicatorGroup: {
color: 'select.indicator.fg',
_peerDisabled: {
opacity: 'control.disabled',
}, },
}, },
}, },
...@@ -162,10 +214,6 @@ export const recipe = defineSlotRecipe({ ...@@ -162,10 +214,6 @@ export const recipe = defineSlotRecipe({
textStyle: 'sm', textStyle: 'sm',
gap: '1', gap: '1',
}, },
indicator: {
width: '5',
height: '5',
},
indicatorGroup: { indicatorGroup: {
pr: '2', pr: '2',
pl: '1', pl: '1',
...@@ -174,17 +222,47 @@ export const recipe = defineSlotRecipe({ ...@@ -174,17 +222,47 @@ export const recipe = defineSlotRecipe({
py: '5px', py: '5px',
px: '4', px: '4',
}, },
itemGroup: { },
mt: '1', lg: {
root: {
'--select-trigger-height': '60px',
'--select-trigger-padding-right': '44px',
'--select-trigger-padding-left': 'spacing.4',
}, },
itemGroupLabel: { content: {
py: '1', px: '0',
px: '1.5', py: '4',
textStyle: 'md',
},
trigger: {
py: '2',
},
item: {
py: '5px',
px: '4',
},
indicatorGroup: {
pr: '4',
pl: '2',
}, },
}, },
}, },
}, },
compoundVariants: [
{
size: 'sm',
variant: 'outline',
css: {
trigger: {
_placeholderShown: {
color: 'select.trigger.outline.fg',
},
},
},
},
],
defaultVariants: { defaultVariants: {
size: 'sm', size: 'sm',
variant: 'outline', variant: 'outline',
......
...@@ -67,10 +67,11 @@ const ContractVerificationFieldCompiler = ({ isVyper, isStylus }: Props) => { ...@@ -67,10 +67,11 @@ const ContractVerificationFieldCompiler = ({ isVyper, isStylus }: Props) => {
const extraControls = !isVyper && !isStylus ? ( const extraControls = !isVyper && !isStylus ? (
<Checkbox <Checkbox
mb={ 2 } mt={ 2 }
checked={ isNightly } checked={ isNightly }
onCheckedChange={ handleCheckboxChange } onCheckedChange={ handleCheckboxChange }
disabled={ formState.isSubmitting } disabled={ formState.isSubmitting }
size="sm"
> >
Include nightly builds Include nightly builds
</Checkbox> </Checkbox>
......
...@@ -26,6 +26,7 @@ const PopoverFilterRadio = ({ name, hasActiveFilter, collection, isLoading, onCh ...@@ -26,6 +26,7 @@ const PopoverFilterRadio = ({ name, hasActiveFilter, collection, isLoading, onCh
collection={ collection } collection={ collection }
defaultValue={ initialValue ? [ initialValue ] : [ collection.items[0].value ] } defaultValue={ initialValue ? [ initialValue ] : [ collection.items[0].value ] }
onValueChange={ handleValueChange } onValueChange={ handleValueChange }
positioning={{ sameWidth: false }}
> >
<SelectControl <SelectControl
triggerProps={{ asChild: true, px: { base: 1, lg: 2 } }} triggerProps={{ asChild: true, px: { base: 1, lg: 2 } }}
......
...@@ -4,19 +4,21 @@ import { useController, useFormContext } from 'react-hook-form'; ...@@ -4,19 +4,21 @@ import { useController, useFormContext } from 'react-hook-form';
import type { FormFieldPropsBase } from './types'; import type { FormFieldPropsBase } from './types';
import type { SelectRootProps } from 'toolkit/chakra/select'; import type { SelectProps } from 'toolkit/chakra/select';
import { SelectContent, SelectControl, SelectItem, SelectRoot, SelectValueText } from 'toolkit/chakra/select'; import { Select } from 'toolkit/chakra/select';
import getFieldErrorText from '../utils/getFieldErrorText';
type Props< type Props<
FormFields extends FieldValues, FormFields extends FieldValues,
Name extends Path<FormFields>, Name extends Path<FormFields>,
> = FormFieldPropsBase<FormFields, Name> & SelectRootProps; > = FormFieldPropsBase<FormFields, Name> & SelectProps;
const FormFieldSelect = < const FormFieldSelect = <
FormFields extends FieldValues, FormFields extends FieldValues,
Name extends Path<FormFields>, Name extends Path<FormFields>,
>(props: Props<FormFields, Name>) => { >(props: Props<FormFields, Name>) => {
const { name, rules, collection, placeholder, ...rest } = props; const { name, rules, size = 'lg', ...rest } = props;
const { control } = useFormContext<FormFields>(); const { control } = useFormContext<FormFields>();
const { field, fieldState, formState } = useController<FormFields, typeof name>({ const { field, fieldState, formState } = useController<FormFields, typeof name>({
...@@ -36,28 +38,19 @@ const FormFieldSelect = < ...@@ -36,28 +38,19 @@ const FormFieldSelect = <
}, [ field ]); }, [ field ]);
return ( return (
<SelectRoot <Select
ref={ field.ref } ref={ field.ref }
name={ field.name } name={ field.name }
value={ field.value } value={ field.value }
onBlur={ field.onBlur }
onValueChange={ handleChange } onValueChange={ handleChange }
onInteractOutside={ handleBlur } onInteractOutside={ handleBlur }
collection={ collection }
disabled={ isDisabled } disabled={ isDisabled }
invalid={ Boolean(fieldState.error) } invalid={ Boolean(fieldState.error) }
errorText={ getFieldErrorText(fieldState.error) }
size={ size }
{ ...rest } { ...rest }
> />
<SelectControl>
<SelectValueText placeholder={ placeholder }/>
</SelectControl>
<SelectContent>
{ collection.items.map((item) => (
<SelectItem item={ item } key={ item.value }>
{ item.label }
</SelectItem>
)) }
</SelectContent>
</SelectRoot>
); );
}; };
......
...@@ -7,6 +7,8 @@ import type { FormFieldPropsBase } from './types'; ...@@ -7,6 +7,8 @@ import type { FormFieldPropsBase } from './types';
import type { SelectAsyncProps } from 'toolkit/chakra/select'; import type { SelectAsyncProps } from 'toolkit/chakra/select';
import { SelectAsync } from 'toolkit/chakra/select'; import { SelectAsync } from 'toolkit/chakra/select';
import getFieldErrorText from '../utils/getFieldErrorText';
type Props< type Props<
FormFields extends FieldValues, FormFields extends FieldValues,
Name extends Path<FormFields>, Name extends Path<FormFields>,
...@@ -16,7 +18,7 @@ const FormFieldSelectAsync = < ...@@ -16,7 +18,7 @@ const FormFieldSelectAsync = <
FormFields extends FieldValues, FormFields extends FieldValues,
Name extends Path<FormFields>, Name extends Path<FormFields>,
>(props: Props<FormFields, Name>) => { >(props: Props<FormFields, Name>) => {
const { name, rules, ...rest } = props; const { name, rules, size = 'lg', ...rest } = props;
const { control } = useFormContext<FormFields>(); const { control } = useFormContext<FormFields>();
const { field, fieldState, formState } = useController<FormFields, typeof name>({ const { field, fieldState, formState } = useController<FormFields, typeof name>({
...@@ -40,10 +42,13 @@ const FormFieldSelectAsync = < ...@@ -40,10 +42,13 @@ const FormFieldSelectAsync = <
ref={ field.ref } ref={ field.ref }
name={ field.name } name={ field.name }
value={ field.value } value={ field.value }
onBlur={ field.onBlur }
onValueChange={ handleChange } onValueChange={ handleChange }
onInteractOutside={ handleBlur } onInteractOutside={ handleBlur }
disabled={ isDisabled } disabled={ isDisabled }
invalid={ Boolean(fieldState.error) } invalid={ Boolean(fieldState.error) }
errorText={ getFieldErrorText(fieldState.error) }
size={ size }
{ ...rest } { ...rest }
/> />
); );
......
...@@ -55,7 +55,7 @@ const Sort = (props: Props) => { ...@@ -55,7 +55,7 @@ const Sort = (props: Props) => {
})(); })();
return ( return (
<SelectRoot collection={ collection } { ...rest }> <SelectRoot collection={ collection } positioning={{ sameWidth: false }} { ...rest }>
{ trigger } { trigger }
<SelectContent> <SelectContent>
{ collection.items.map((item) => ( { collection.items.map((item) => (
......
...@@ -2,8 +2,9 @@ import { createListCollection } from '@chakra-ui/react'; ...@@ -2,8 +2,9 @@ import { createListCollection } from '@chakra-ui/react';
import { noop } from 'es-toolkit'; import { noop } from 'es-toolkit';
import React from 'react'; import React from 'react';
import { Checkbox } from 'toolkit/chakra/checkbox';
import { NativeSelectField, NativeSelectRoot } from 'toolkit/chakra/native-select'; import { NativeSelectField, NativeSelectRoot } from 'toolkit/chakra/native-select';
import { SelectContent, SelectItem, SelectRoot, SelectControl, SelectValueText } from 'toolkit/chakra/select'; import { Select, SelectAsync } from 'toolkit/chakra/select';
import PopoverFilterRadio from 'ui/shared/filters/PopoverFilterRadio'; import PopoverFilterRadio from 'ui/shared/filters/PopoverFilterRadio';
import Sort from 'ui/shared/sort/Sort'; import Sort from 'ui/shared/sort/Sort';
import TokenTransferFilter from 'ui/shared/TokenTransfer/TokenTransferFilter'; import TokenTransferFilter from 'ui/shared/TokenTransfer/TokenTransferFilter';
...@@ -36,18 +37,91 @@ const SelectShowcase = () => { ...@@ -36,18 +37,91 @@ const SelectShowcase = () => {
<SectionHeader>Variant</SectionHeader> <SectionHeader>Variant</SectionHeader>
<SamplesStack> <SamplesStack>
<Sample label="variant: outline"> <Sample label="variant: outline">
<SelectRoot collection={ frameworks } variant="outline" defaultValue={ [ frameworks.items[0].value ] }> <Select
<SelectControl w="200px"> collection={ frameworks }
<SelectValueText placeholder="Select framework"/> placeholder="Select framework"
</SelectControl> size="sm"
<SelectContent> w="200px"
{ frameworks.items.map((framework) => ( />
<SelectItem item={ framework } key={ framework.value }> </Sample>
{ framework.label } </SamplesStack>
</SelectItem> </Section>
)) }
</SelectContent> <Section>
</SelectRoot> <SectionHeader>Size</SectionHeader>
<SamplesStack>
{ [ 'sm' as const, 'lg' as const ].map((size) => {
return (
<Sample label={ `size: ${ size }` } key={ size }>
<Select
collection={ frameworks }
placeholder="Select framework"
size={ size }
w="300px"
/>
<Select
collection={ frameworks }
placeholder="Select framework"
defaultValue={ [ frameworks.items[0].value ] }
size={ size }
w="300px"
/>
<Select
collection={ frameworks }
placeholder="Select framework"
defaultValue={ [ frameworks.items[0].value ] }
size={ size }
w="300px"
readOnly
/>
<Select
collection={ frameworks }
placeholder="Select framework"
defaultValue={ [ frameworks.items[0].value ] }
size={ size }
w="300px"
disabled
/>
<Select
collection={ frameworks }
placeholder="Select framework"
size={ size }
w="300px"
required
invalid
errorText="Error message"
/>
<Select
collection={ frameworks }
placeholder="Select framework"
defaultValue={ [ frameworks.items[0].value ] }
size={ size }
w="300px"
required
invalid
errorText="Error message"
/>
</Sample>
);
}) }
</SamplesStack>
</Section>
<Section>
<SectionHeader>With search (async)</SectionHeader>
<SamplesStack>
<Sample label="variant: outline">
<SelectAsync
placeholder="Select framework"
size="lg"
w="300px"
// eslint-disable-next-line react/jsx-no-bind
loadOptions={ () => {
return Promise.resolve(frameworks);
} }
extraControls={ <Checkbox mt={ 2 } size="sm">Include nightly builds</Checkbox> }
/>
</Sample> </Sample>
</SamplesStack> </SamplesStack>
</Section> </Section>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment