diff --git a/src/components/ComboBox.tsx b/src/components/ComboBox.tsx index 592fee86..901dc6de 100644 --- a/src/components/ComboBox.tsx +++ b/src/components/ComboBox.tsx @@ -57,7 +57,9 @@ type ComboBoxProps = Exclude & { inputProps?: InputProps filter?: ComboBoxStateOptions['defaultFilter'] loading?: boolean -} & Omit< + titleContent?: ReactNode +} & Pick & + Omit< ComboBoxStateOptions, 'onLoadMore' | 'isLoading' | 'validationState' | 'placeholder' > @@ -152,6 +154,7 @@ function ComboBoxInput({ isOpen, onInputClick, loading, + ...props }: ComboBoxInputProps & InputProps) { outerInputProps = { ...outerInputProps, @@ -170,37 +173,16 @@ function ComboBoxInput({ let themeExtension: any = {} - if (startIcon) { - themeExtension = mergeTheme(themeExtension, { - Input: { - Root: [ - { - position: 'relative', - paddingLeft: 0, - }, - ], - InputBase: [{ paddingLeft: theme.spacing.xxlarge }], - StartIcon: [ - { - position: 'absolute', - top: 0, - left: 0, - bottom: 0, - pointerEvents: 'none', - }, - ], - }, - }) - } - if (showArrow) { themeExtension = mergeTheme(themeExtension, { Input: { Root: [{ paddingRight: 0 }], + InputBase: [{ paddingRight: 0 }], EndIcon: [ { alignSelf: 'stretch', - paddingHorizontal: 0, + paddingLeft: 0, + paddingRight: 0, marginLeft: 0, marginRight: 0, }, @@ -230,6 +212,7 @@ function ComboBoxInput({ ...innerInputProps, }} {...outerInputProps} + {...props} /> ) } @@ -258,6 +241,10 @@ function ComboBox({ maxHeight, inputProps: outerInputProps = {}, loading, + suffix, + prefix, + titleContent, + showClearButton, ...props }: ComboBoxProps) { const nextFocusedKeyRef = useRef(null) @@ -406,6 +393,10 @@ function ComboBox({ buttonProps={buttonProps} showArrow={showArrow} isOpen={state.isOpen} + suffix={suffix} + prefix={prefix} + titleContent={titleContent} + showClearButton={showClearButton} setIsOpen={setIsOpen} startIcon={startIcon} outerInputProps={outerInputProps} diff --git a/src/components/Table.tsx b/src/components/Table.tsx index dda09753..8db448c7 100644 --- a/src/components/Table.tsx +++ b/src/components/Table.tsx @@ -54,7 +54,7 @@ export type TableProps = Omit< | 'scrollTopMargin' | 'virtualizeRows' | 'virtualizerOptions' - | 'lockColumnsOnFirstScroll' + | 'lockColumnsOnScroll' | 'reactVirtualOptions' | 'reactTableOptions' | 'onRowClick' diff --git a/src/stories/ComboBox.stories.tsx b/src/stories/ComboBox.stories.tsx index 951db516..743e70f2 100644 --- a/src/stories/ComboBox.stories.tsx +++ b/src/stories/ComboBox.stories.tsx @@ -5,6 +5,7 @@ import Fuse from 'fuse.js' import { AppIcon, + BrowseAppsIcon, Card, Chip, ComboBox, @@ -171,14 +172,24 @@ const itemsByKey = items.reduce( ) const itemKeys = items.map((item) => item.key) -const TagPicker = styled.div(({ theme: _theme }) => ({})) +const TagPicker = styled.div(({ theme }) => ({ + display: 'flex', + flexDirection: 'column', + gap: theme.spacing.small, +})) -const ChipList = styled(ListBoxItemChipList)(({ theme }) => ({ - marginTop: theme.spacing.small, +const ChipList = styled(ListBoxItemChipList)(({ theme: _ }) => ({ justifyContent: 'start', })) -function Template({ onFillLevel, ...args }: { onFillLevel: any }) { +function Template({ + onFillLevel, + withTitleContent, + ...args +}: { + onFillLevel: any + withTitleContent: boolean +}) { const [selectedKeys, setSelectedKeys] = useState(new Set()) const [inputValue, setInputValue] = useState('') @@ -241,7 +252,19 @@ function Template({ onFillLevel, ...args }: { onFillLevel: any }) { inputValue={inputValue} onSelectionChange={onSelectionChange} onInputChange={onInputChange} - inputProps={{ placeholder: 'Pick something' }} + inputProps={{ + placeholder: 'Pick something', + }} + {...(withTitleContent + ? { + titleContent: ( + <> + + Marketplace + + ), + } + : {})} {...args} > {searchResults.map( @@ -257,31 +280,40 @@ function Template({ onFillLevel, ...args }: { onFillLevel: any }) { ) )} - ( - { - const newKeys = new Set(selectedKeys) - - newKeys.delete(key) - setSelectedKeys(newKeys) - }} - closeButton - > - {(itemsByKey as any)[key]?.label} - - ))} - /> + {!(selectedKeys.size === 0) && ( + ( + { + const newKeys = new Set(selectedKeys) + + newKeys.delete(key) + setSelectedKeys(newKeys) + }} + closeButton + > + {(itemsByKey as any)[key]?.label} + + ))} + /> + )} ) } -function TagsTemplate({ ...args }: any) { +function TagsTemplate({ + onFillLevel, + withTitleContent, + ...args +}: { + onFillLevel: any + withTitleContent: boolean +}) { const [selectedKeys, setSelectedKeys] = useState(new Set()) const [inputValue, setInputValue] = useState('') const [isOpen, setIsOpen] = useState(false) @@ -344,64 +376,93 @@ function TagsTemplate({ ...args }: any) { } return ( - 0} + wrapper={ + + } > - - { - setSelectedKeys(new Set([...selectedKeys, newKey])) - setInputValue('') - setIsOpen(false) - }} - onInputChange={onInputChange} - inputProps={{ placeholder: 'Pick something' }} - onOpenChange={(isOpen, _trigger) => { - setIsOpen(isOpen) - }} - dropdownFooter={ - newKey ? ( - Create new tag, '{newKey}' - ) : undefined - } - maxHeight={232} - allowsEmptyCollection={!!newKey} - {...args} - > - {searchResults.map(({ item, score: _score, refIndex: _refIndex }) => ( - + + { + setSelectedKeys(new Set([...selectedKeys, newKey])) + setInputValue('') + setIsOpen(false) + }} + onInputChange={onInputChange} + inputProps={{ placeholder: 'Pick something' }} + onOpenChange={(isOpen, _trigger) => { + setIsOpen(isOpen) + }} + dropdownFooter={ + newKey ? ( + + Create new tag, '{newKey}' + + ) : undefined + } + maxHeight={232} + allowsEmptyCollection={!!newKey} + {...(withTitleContent + ? { + titleContent: ( + <> + + Marketplace + + ), + } + : {})} + {...args} + > + {searchResults.map( + ({ item, score: _score, refIndex: _refIndex }) => ( + + ) + )} + + {!(selectedKeys.size === 0) && ( + ( + { + const newKeys = new Set(selectedKeys) + + newKeys.delete(key) + setSelectedKeys(newKeys) + }} + closeButton + > + {key} + + ))} /> - ))} - - ( - { - const newKeys = new Set(selectedKeys) - - newKeys.delete(key) - setSelectedKeys(newKeys) - }} - closeButton - > - {key} - - ))} - /> - - + )} + + + ) } @@ -409,9 +470,11 @@ export const Default = Template.bind({}) Default.args = { loading: false, + withTitleContent: false, } export const Tags = TagsTemplate.bind({}) -Default.args = { +Tags.args = { loading: false, + withTitleContent: false, }