-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #722 from thejackshelton/multi-select
Initial multi-select capabilities
- Loading branch information
Showing
24 changed files
with
328 additions
and
157 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
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
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
31 changes: 31 additions & 0 deletions
31
apps/website/src/routes/docs/headless/select/examples/multiple.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,31 @@ | ||
import { component$, useSignal, useStyles$ } from '@builder.io/qwik'; | ||
import { | ||
Select, | ||
SelectListbox, | ||
SelectOption, | ||
SelectPopover, | ||
SelectTrigger, | ||
SelectValue, | ||
} from '@qwik-ui/headless'; | ||
import styles from '../snippets/select.css?inline'; | ||
|
||
export default component$(() => { | ||
useStyles$(styles); | ||
const users = ['Tim', 'Ryan', 'Jim', 'Jessie', 'Abby']; | ||
const selected = useSignal<string[]>([]); | ||
|
||
return ( | ||
<Select multiple bind:value={selected} class="select"> | ||
<SelectTrigger class="select-trigger"> | ||
<SelectValue>{selected.value}</SelectValue> | ||
</SelectTrigger> | ||
<SelectPopover class="select-popover"> | ||
<SelectListbox class="select-listbox"> | ||
{users.map((user) => ( | ||
<SelectOption key={user}>{user}</SelectOption> | ||
))} | ||
</SelectListbox> | ||
</SelectPopover> | ||
</Select> | ||
); | ||
}); |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
export * from './select'; | ||
export * from './select-label'; | ||
export * from './select-inline'; | ||
export * from './select-listbox'; | ||
export * from './select-option'; | ||
export * from './select-popover'; | ||
export * from './select-trigger'; | ||
export * from './select-value'; | ||
export * from './select-group'; | ||
export * from './select-label'; | ||
export * from './select-group-label'; | ||
export * from './hidden-select'; |
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
14 changes: 14 additions & 0 deletions
14
packages/kit-headless/src/components/select/select-group-label.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,14 @@ | ||
import { PropsOf, Slot, component$, useContext } from '@builder.io/qwik'; | ||
import { groupContextId } from './select-context'; | ||
|
||
type SelectLabelProps = PropsOf<'li'>; | ||
|
||
export const SelectGroupLabel = component$<SelectLabelProps>((props) => { | ||
const groupContext = useContext(groupContextId); | ||
|
||
return ( | ||
<li id={groupContext.groupLabelId} {...props}> | ||
<Slot /> | ||
</li> | ||
); | ||
}); |
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
13 changes: 6 additions & 7 deletions
13
packages/kit-headless/src/components/select/select-label.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 |
---|---|---|
@@ -1,14 +1,13 @@ | ||
import { PropsOf, Slot, component$, useContext } from '@builder.io/qwik'; | ||
import { groupContextId } from './select-context'; | ||
import SelectContextId from './select-context'; | ||
|
||
type SelectLabelProps = PropsOf<'li'>; | ||
|
||
export const SelectLabel = component$<SelectLabelProps>((props) => { | ||
const groupContext = useContext(groupContextId); | ||
export const SelectLabel = component$((props: PropsOf<'div'>) => { | ||
const context = useContext(SelectContextId); | ||
const labelId = `${context.localId}-label`; | ||
|
||
return ( | ||
<li id={groupContext.labelId} {...props}> | ||
<div ref={context.labelRef} id={labelId} {...props}> | ||
<Slot /> | ||
</li> | ||
</div> | ||
); | ||
}); |
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
Oops, something went wrong.