-
Notifications
You must be signed in to change notification settings - Fork 2
Add combo box #88
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
Merged
joshunrau
merged 16 commits into
DouglasNeuroInformatics:main
from
david-roper:add-combo-box
Mar 13, 2026
Merged
Add combo box #88
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
e1e5526
feat: add pakages for combo box and input group
david-roper 9ad4480
feat: add input group component
david-roper 0ed5367
feat: add combobox component and story
david-roper 2c5e1ec
feat: add story for input group
david-roper df33546
feat: format inputGroup story
david-roper bfc31d7
fix: adjust size of comboBox button
david-roper faf3920
fix: fix render type issue
david-roper b03fb23
fix: type error in combobox
david-roper 02df77b
fix: remove redundant onclick method
david-roper 6f65cf5
chore: remove floating string
david-roper d5c8290
refactor: move components of input group into their own files
david-roper 113b2fe
chore: put all Combo box components into separate files
david-roper 33ce281
refactor: adjust combo box to use object assign method
david-roper a04ed44
chore: add combobox value to object assignment
david-roper eaa1e59
fix: add code rabbit change to input group button
david-roper d9de35f
fix: separate combobox use hook from object assign export
david-roper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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,31 @@ | ||
| import type { Meta, StoryObj } from '@storybook/react-vite'; | ||
|
|
||
| import { ComboBox } from './ComboBox.tsx'; | ||
|
|
||
| type Story = StoryObj<typeof ComboBox>; | ||
|
|
||
| const frameworks: string[] = ['Next.js', 'SvelteKit', 'Nuxt.js', 'Remix', 'Astro']; | ||
|
|
||
| export default { | ||
| args: { | ||
| children: ( | ||
| <ComboBox items={frameworks}> | ||
| <ComboBox.Input placeholder="Select a framework" /> | ||
| <ComboBox.Content> | ||
| <ComboBox.Empty>No items found.</ComboBox.Empty> | ||
| <ComboBox.List> | ||
| {(item: string) => ( | ||
| <ComboBox.Item key={item} value={item}> | ||
| {item} | ||
| </ComboBox.Item> | ||
| )} | ||
| </ComboBox.List> | ||
| </ComboBox.Content> | ||
| </ComboBox> | ||
| ) | ||
| }, | ||
| component: ComboBox, | ||
| tags: ['autodocs'] | ||
| } as Meta<typeof ComboBox>; | ||
|
|
||
| export const Default: Story = {}; | ||
This file contains hidden or 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,41 @@ | ||
| import * as React from 'react'; | ||
|
|
||
| import { Combobox as ComboboxPrimitive } from '@base-ui/react'; | ||
|
|
||
| import { ComboboxChip, ComboboxChips, ComboboxChipsInput } from './ComboBoxChips.tsx'; | ||
| import { ComboboxClear } from './ComboBoxClear.tsx'; | ||
| import { ComboboxCollection } from './ComboBoxCollection.tsx'; | ||
| import { ComboboxContent } from './ComboBoxContent.tsx'; | ||
| import { ComboboxEmpty } from './ComboBoxEmpty.tsx'; | ||
| import { ComboboxGroup } from './ComboBoxGroup.tsx'; | ||
| import { ComboboxInput } from './ComboBoxInput.tsx'; | ||
| import { ComboboxItem } from './ComboBoxItem.tsx'; | ||
| import { ComboboxLabel } from './ComboBoxLabel.tsx'; | ||
| import { ComboboxList } from './ComboBoxList.tsx'; | ||
| import { ComboboxSeparator } from './ComboBoxSeparator.tsx'; | ||
| import { ComboboxTrigger } from './ComboBoxTrigger.tsx'; | ||
| import { ComboboxValue } from './ComboBoxValue.tsx'; | ||
|
|
||
| function useComboboxAnchor() { | ||
| return React.useRef<HTMLDivElement | null>(null); | ||
| } | ||
|
|
||
| export { useComboboxAnchor }; | ||
|
|
||
| export const ComboBox = Object.assign(ComboboxPrimitive.Root.bind(null), { | ||
| Chip: ComboboxChip, | ||
| Chips: ComboboxChips, | ||
| ChipsInput: ComboboxChipsInput, | ||
| Clear: ComboboxClear, | ||
| Collection: ComboboxCollection, | ||
| Content: ComboboxContent, | ||
| Empty: ComboboxEmpty, | ||
| Group: ComboboxGroup, | ||
| Input: ComboboxInput, | ||
| Item: ComboboxItem, | ||
| Label: ComboboxLabel, | ||
| List: ComboboxList, | ||
| Separator: ComboboxSeparator, | ||
| Trigger: ComboboxTrigger, | ||
| Value: ComboboxValue | ||
| }); |
This file contains hidden or 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,69 @@ | ||
| import * as React from 'react'; | ||
|
|
||
| import { Combobox as ComboboxPrimitive } from '@base-ui/react'; | ||
| import { XIcon } from 'lucide-react'; | ||
|
|
||
| import { cn } from '#utils'; | ||
|
|
||
| import { Button } from '../Button/Button.tsx'; | ||
|
|
||
| const ComboboxChips = ({ | ||
| className, | ||
| ...props | ||
| }: ComboboxPrimitive.Chips.Props & React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips>) => { | ||
| return ( | ||
| <ComboboxPrimitive.Chips | ||
| className={cn( | ||
| 'dark:bg-input/30 border-input focus-within:border-ring focus-within:ring-ring/50 has-aria-invalid:ring-destructive/20 dark:has-aria-invalid:ring-destructive/40 has-aria-invalid:border-destructive dark:has-aria-invalid:border-destructive/50 flex min-h-8 flex-wrap items-center gap-1 rounded-lg border bg-transparent bg-clip-padding px-2.5 py-1 text-sm transition-colors focus-within:ring-3 has-aria-invalid:ring-3 has-data-[slot=combobox-chip]:px-1', | ||
| className | ||
| )} | ||
| data-slot="combobox-chips" | ||
| {...props} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| const ComboboxChip = ({ | ||
| children, | ||
| className, | ||
| showRemove = true, | ||
| ...props | ||
| }: ComboboxPrimitive.Chip.Props & { | ||
| showRemove?: boolean; | ||
| }) => { | ||
| return ( | ||
| <ComboboxPrimitive.Chip | ||
| className={cn( | ||
| 'bg-muted text-foreground flex h-[calc(--spacing(5.25))] w-fit items-center justify-center gap-1 rounded-sm px-1.5 text-xs font-medium whitespace-nowrap has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0', | ||
| className | ||
| )} | ||
| data-slot="combobox-chip" | ||
| {...props} | ||
| > | ||
| {children} | ||
| {showRemove && ( | ||
| <ComboboxPrimitive.ChipRemove | ||
| className="-ml-1 opacity-50 hover:opacity-100" | ||
| data-slot="combobox-chip-remove" | ||
| render={ | ||
| <Button size="sm" variant="ghost"> | ||
| <XIcon className="pointer-events-none" /> | ||
| </Button> | ||
| } | ||
| /> | ||
| )} | ||
| </ComboboxPrimitive.Chip> | ||
| ); | ||
| }; | ||
|
|
||
| const ComboboxChipsInput = ({ className, ...props }: ComboboxPrimitive.Input.Props) => { | ||
| return ( | ||
| <ComboboxPrimitive.Input | ||
| className={cn('min-w-16 flex-1 outline-none', className)} | ||
| data-slot="combobox-chip-input" | ||
| {...props} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| export { ComboboxChip, ComboboxChips, ComboboxChipsInput }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.