@leve-ui/select 0.0.0-stage → 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/lib/index.qwik.cjs +4 -0
- package/lib/index.qwik.mjs +4 -0
- package/lib/select-content.qwik.cjs +65 -0
- package/lib/select-content.qwik.mjs +65 -0
- package/lib/select-context.qwik.cjs +38 -0
- package/lib/select-context.qwik.mjs +38 -0
- package/lib/select-group-label.qwik.cjs +15 -0
- package/lib/select-group-label.qwik.mjs +15 -0
- package/lib/select-group.qwik.cjs +22 -0
- package/lib/select-group.qwik.mjs +22 -0
- package/lib/select-hidden-input.qwik.cjs +37 -0
- package/lib/select-hidden-input.qwik.mjs +37 -0
- package/lib/select-item-indicator.qwik.cjs +17 -0
- package/lib/select-item-indicator.qwik.mjs +17 -0
- package/lib/select-item-text.qwik.cjs +14 -0
- package/lib/select-item-text.qwik.mjs +14 -0
- package/lib/select-item.qwik.cjs +52 -0
- package/lib/select-item.qwik.mjs +52 -0
- package/lib/select-label.qwik.cjs +18 -0
- package/lib/select-label.qwik.mjs +18 -0
- package/lib/select-list.qwik.cjs +18 -0
- package/lib/select-list.qwik.mjs +18 -0
- package/lib/select-root.qwik.cjs +90 -0
- package/lib/select-root.qwik.mjs +90 -0
- package/lib/select-trigger.qwik.cjs +189 -0
- package/lib/select-trigger.qwik.mjs +189 -0
- package/lib/select-value.qwik.cjs +17 -0
- package/lib/select-value.qwik.mjs +17 -0
- package/lib/select.qwik.cjs +26 -0
- package/lib/select.qwik.mjs +26 -0
- package/lib-types/index.d.ts +14 -0
- package/lib-types/select-content.d.ts +42 -0
- package/lib-types/select-context.d.ts +48 -0
- package/lib-types/select-group-label.d.ts +8 -0
- package/lib-types/select-group.d.ts +8 -0
- package/lib-types/select-hidden-input.d.ts +12 -0
- package/lib-types/select-item-indicator.d.ts +7 -0
- package/lib-types/select-item-text.d.ts +6 -0
- package/lib-types/select-item.d.ts +17 -0
- package/lib-types/select-label.d.ts +11 -0
- package/lib-types/select-list.d.ts +8 -0
- package/lib-types/select-root.d.ts +47 -0
- package/lib-types/select-trigger.d.ts +15 -0
- package/lib-types/select-value.d.ts +9 -0
- package/lib-types/select.d.ts +12 -0
- package/package.json +58 -3
- package/README.md +0 -3
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type PropsOf } from '@builder.io/qwik';
|
|
2
|
+
import { type FloatingAlign, type FloatingSide } from '@leve-ui/utils';
|
|
3
|
+
export type SelectContentProps = PropsOf<'div'> & {
|
|
4
|
+
/**
|
|
5
|
+
* The side of the Trigger to place the listbox on. It flips when there is no room.
|
|
6
|
+
* @default 'bottom'
|
|
7
|
+
*/
|
|
8
|
+
side?: FloatingSide;
|
|
9
|
+
/**
|
|
10
|
+
* The alignment along that side.
|
|
11
|
+
* @default 'start'
|
|
12
|
+
*/
|
|
13
|
+
align?: FloatingAlign;
|
|
14
|
+
/**
|
|
15
|
+
* The distance from the Trigger in px.
|
|
16
|
+
* @default 0
|
|
17
|
+
*/
|
|
18
|
+
sideOffset?: number;
|
|
19
|
+
/**
|
|
20
|
+
* The offset along the side in px.
|
|
21
|
+
* @default 0
|
|
22
|
+
*/
|
|
23
|
+
alignOffset?: number;
|
|
24
|
+
/**
|
|
25
|
+
* Whether to flip and shift the listbox to keep it in the viewport.
|
|
26
|
+
* @default true
|
|
27
|
+
*/
|
|
28
|
+
avoidCollisions?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The padding from the viewport edges when avoiding collisions, in px.
|
|
31
|
+
* @default 0
|
|
32
|
+
*/
|
|
33
|
+
collisionPadding?: number;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Top-layer popup (`popover="manual"`) that contains `Select.List` and positions it next to `Select.Trigger`.
|
|
37
|
+
*
|
|
38
|
+
* Exposes `--leve-select-anchor-width`, `--leve-select-anchor-height`,
|
|
39
|
+
* `--leve-select-available-width`, `--leve-select-available-height`, and `data-side` / `data-align`.
|
|
40
|
+
* Keeps focus on `Trigger` and scrolls the highlighted option into view.
|
|
41
|
+
*/
|
|
42
|
+
export declare const SelectContent: import("@builder.io/qwik").Component<SelectContentProps>;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type QRL, type ReadonlySignal, type Signal } from '@builder.io/qwik';
|
|
2
|
+
export interface SelectIds {
|
|
3
|
+
label: string;
|
|
4
|
+
trigger: string;
|
|
5
|
+
list: string;
|
|
6
|
+
}
|
|
7
|
+
/** Which item to highlight when the listbox opens */
|
|
8
|
+
export type SelectHighlight = 'first' | 'last' | 'selected' | 'selected-last' | null;
|
|
9
|
+
export interface SelectContext {
|
|
10
|
+
ids: SelectIds;
|
|
11
|
+
open: ReadonlySignal<boolean>;
|
|
12
|
+
value: ReadonlySignal<string | null>;
|
|
13
|
+
/** The value of the highlighted item (`aria-activedescendant`) */
|
|
14
|
+
highlighted: Signal<string | null>;
|
|
15
|
+
/** The display text of the selected item */
|
|
16
|
+
selectedText: Signal<string>;
|
|
17
|
+
disabled: ReadonlySignal<boolean>;
|
|
18
|
+
required: ReadonlySignal<boolean>;
|
|
19
|
+
loop: ReadonlySignal<boolean>;
|
|
20
|
+
/** Opens or closes the listbox; opening highlights an item */
|
|
21
|
+
setOpen$: QRL<(open: boolean, highlight?: SelectHighlight) => Promise<void>>;
|
|
22
|
+
/** Selects an item: sets the value, updates the displayed text, and closes */
|
|
23
|
+
select$: QRL<(value: string, text: string) => Promise<void>>;
|
|
24
|
+
/** Resets the uncontrolled value to its initial defaultValue */
|
|
25
|
+
reset$: QRL<() => Promise<void>>;
|
|
26
|
+
}
|
|
27
|
+
export declare const selectContextId: import("@builder.io/qwik").ContextId<SelectContext>;
|
|
28
|
+
export interface SelectItemContext {
|
|
29
|
+
value: string;
|
|
30
|
+
selected: ReadonlySignal<boolean>;
|
|
31
|
+
highlighted: ReadonlySignal<boolean>;
|
|
32
|
+
disabled: ReadonlySignal<boolean>;
|
|
33
|
+
}
|
|
34
|
+
export declare const selectItemContextId: import("@builder.io/qwik").ContextId<SelectItemContext>;
|
|
35
|
+
export interface SelectGroupContext {
|
|
36
|
+
labelId: string;
|
|
37
|
+
}
|
|
38
|
+
export declare const selectGroupContextId: import("@builder.io/qwik").ContextId<SelectGroupContext>;
|
|
39
|
+
/** The item elements of the listbox, in DOM order */
|
|
40
|
+
export declare const ITEM_SELECTOR = "[data-leve-select-item]";
|
|
41
|
+
/** The display text of an item: its ItemText, its textValue, or its text */
|
|
42
|
+
export declare function getItemText(item: Element): string;
|
|
43
|
+
/** The text used for typeahead matching: `textValue` first, then `getItemText` */
|
|
44
|
+
export declare function getItemTypeaheadText(item: Element): string;
|
|
45
|
+
/** Finds the Select trigger element by id first, falling back to `[data-leve-select-trigger]` inside Root. */
|
|
46
|
+
export declare function getSelectTrigger(anchor: HTMLElement | null | undefined, triggerId: string): HTMLButtonElement | null;
|
|
47
|
+
/** Resolves the display text of the currently selected value from the rendered list items in the DOM. */
|
|
48
|
+
export declare function resolveSelectedText(anchor: HTMLElement | undefined, listId: string, value: string | null): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PropsOf } from '@builder.io/qwik';
|
|
2
|
+
export type SelectGroupLabelProps = PropsOf<'div'>;
|
|
3
|
+
/**
|
|
4
|
+
* Label for a `Select.Group`. Not selectable or navigable with arrow keys.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SelectGroupLabel: import("@builder.io/qwik").Component<{
|
|
7
|
+
align?: string | undefined;
|
|
8
|
+
} & import("@builder.io/qwik").HTMLElementAttrs & import("@builder.io/qwik").QwikAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PropsOf } from '@builder.io/qwik';
|
|
2
|
+
export type SelectGroupProps = PropsOf<'div'>;
|
|
3
|
+
/**
|
|
4
|
+
* Group of related options (`role="group"`), named by its `Select.GroupLabel`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SelectGroup: import("@builder.io/qwik").Component<{
|
|
7
|
+
align?: string | undefined;
|
|
8
|
+
} & import("@builder.io/qwik").HTMLElementAttrs & import("@builder.io/qwik").QwikAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type PropsOf } from '@builder.io/qwik';
|
|
2
|
+
export type SelectHiddenInputProps = PropsOf<'input'> & {
|
|
3
|
+
/** The `id` of the form element to associate the input with. */
|
|
4
|
+
form?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Visually hidden native `<input>` for submitting the selected value in a `<form>` (`adr/0026`).
|
|
8
|
+
*
|
|
9
|
+
* Positioned absolutely so native `required` validation and `<form>` reset work; set
|
|
10
|
+
* `position: relative` on `Select.Root` when using this part.
|
|
11
|
+
*/
|
|
12
|
+
export declare const SelectHiddenInput: import("@builder.io/qwik").Component<SelectHiddenInputProps>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type PropsOf } from '@builder.io/qwik';
|
|
2
|
+
export type SelectItemIndicatorProps = PropsOf<'span'>;
|
|
3
|
+
/**
|
|
4
|
+
* Visual indicator shown when the parent `Select.Item` is selected, hidden otherwise.
|
|
5
|
+
* Hidden from assistive technologies because `aria-selected` communicates the state.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SelectItemIndicator: import("@builder.io/qwik").Component<{} & import("@builder.io/qwik").HTMLElementAttrs & import("@builder.io/qwik").QwikAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type PropsOf } from '@builder.io/qwik';
|
|
2
|
+
export type SelectItemTextProps = PropsOf<'span'>;
|
|
3
|
+
/**
|
|
4
|
+
* Text label of an option. Displayed in `Select.Value` when the option is selected.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SelectItemText: import("@builder.io/qwik").Component<{} & import("@builder.io/qwik").HTMLElementAttrs & import("@builder.io/qwik").QwikAttributes<HTMLSpanElement>>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type PropsOf } from '@builder.io/qwik';
|
|
2
|
+
export type SelectItemProps = PropsOf<'div'> & {
|
|
3
|
+
/** The value of the item. Must be unique within the select. */
|
|
4
|
+
value: string;
|
|
5
|
+
/**
|
|
6
|
+
* Whether the item cannot be selected. Arrow keys and typeahead skip it.
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** The display and typeahead text for the item, when it differs from `ItemText` or its text content. */
|
|
11
|
+
textValue?: string;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Selectable option (`role="option"`). Exposes `aria-selected` for selection and
|
|
15
|
+
* `data-highlighted` for visual focus while DOM focus stays on `Select.Trigger`.
|
|
16
|
+
*/
|
|
17
|
+
export declare const SelectItem: import("@builder.io/qwik").Component<SelectItemProps>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type PropsOf } from '@builder.io/qwik';
|
|
2
|
+
export type SelectLabelProps = PropsOf<'label'>;
|
|
3
|
+
/**
|
|
4
|
+
* Accessible label (`<label for>`) for the Select trigger and listbox.
|
|
5
|
+
* Inside a `Field`, `Field.Label` can be used instead.
|
|
6
|
+
*/
|
|
7
|
+
export declare const SelectLabel: import("@builder.io/qwik").Component<{
|
|
8
|
+
form?: string | undefined | undefined;
|
|
9
|
+
for?: string | undefined | undefined;
|
|
10
|
+
htmlFor?: string | undefined | undefined;
|
|
11
|
+
} & import("@builder.io/qwik").HTMLElementAttrs & import("@builder.io/qwik").QwikAttributes<HTMLLabelElement>>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PropsOf } from '@builder.io/qwik';
|
|
2
|
+
export type SelectListProps = PropsOf<'div'>;
|
|
3
|
+
/**
|
|
4
|
+
* Listbox container (`role="listbox"`) for `Select.Item` and `Select.Group`, labelled by `Select.Label`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SelectList: import("@builder.io/qwik").Component<{
|
|
7
|
+
align?: string | undefined;
|
|
8
|
+
} & import("@builder.io/qwik").HTMLElementAttrs & import("@builder.io/qwik").QwikAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type PropsOf, type QRL, type Signal } from '@builder.io/qwik';
|
|
2
|
+
import { type SelectIds } from './select-context';
|
|
3
|
+
export type SelectRootProps = PropsOf<'div'> & {
|
|
4
|
+
/** Overrides the element IDs of the parts. Inside a Field, the Field's IDs are used for the label and trigger. */
|
|
5
|
+
ids?: Partial<SelectIds>;
|
|
6
|
+
/**
|
|
7
|
+
* The value of the selected item initially (uncontrolled).
|
|
8
|
+
* @default null
|
|
9
|
+
*/
|
|
10
|
+
defaultValue?: string | null;
|
|
11
|
+
/** A signal with the value of the selected item (controlled). `null` when nothing is selected. */
|
|
12
|
+
'bind:value'?: Signal<string | null>;
|
|
13
|
+
/** Called when the selected value changes. */
|
|
14
|
+
onValueChange$?: QRL<(value: string | null) => void>;
|
|
15
|
+
/**
|
|
16
|
+
* Whether the listbox is open initially (uncontrolled).
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
defaultOpen?: boolean;
|
|
20
|
+
/** A signal with the open state of the listbox (controlled). */
|
|
21
|
+
'bind:open'?: Signal<boolean>;
|
|
22
|
+
/** Called when the listbox opens or closes. */
|
|
23
|
+
onOpenChange$?: QRL<(open: boolean) => void>;
|
|
24
|
+
/**
|
|
25
|
+
* Whether the select is disabled. Inside a Field or Fieldset, inherited `disabled` also applies.
|
|
26
|
+
* @default false
|
|
27
|
+
*/
|
|
28
|
+
disabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Whether a value is required in a form. Inside a Field, the Field's `required` also applies.
|
|
31
|
+
* @default false
|
|
32
|
+
*/
|
|
33
|
+
required?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Whether ArrowDown on the last item moves to the first one, and ArrowUp on the first to the last.
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
loop?: boolean;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Root container for the Select component. Holds selection and open state and provides context.
|
|
42
|
+
*
|
|
43
|
+
* Follows the WAI-ARIA APG Select-Only Combobox pattern. Focus stays on `Trigger`, while the
|
|
44
|
+
* highlighted option is exposed via `aria-activedescendant` (`adr/0035`). `Content` renders in
|
|
45
|
+
* the top layer with `popover="manual"` (`adr/0029`) and is positioned via Floating UI (`adr/0030`).
|
|
46
|
+
*/
|
|
47
|
+
export declare const SelectRoot: import("@builder.io/qwik").Component<SelectRootProps>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type PropsOf } from '@builder.io/qwik';
|
|
2
|
+
export type SelectTriggerProps = PropsOf<'button'> & {
|
|
3
|
+
/**
|
|
4
|
+
* Whether the select value is invalid. Inside a Field, the Field's `invalid` also applies.
|
|
5
|
+
* @default false
|
|
6
|
+
*/
|
|
7
|
+
invalid?: boolean;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Button (`role="combobox"`) that toggles the listbox and keeps DOM focus while open.
|
|
11
|
+
*
|
|
12
|
+
* Exposes `aria-activedescendant` for the highlighted option and handles APG Select-Only
|
|
13
|
+
* keyboard navigation, including Arrow keys, Home/End, Enter/Space, Escape, Tab, and typeahead.
|
|
14
|
+
*/
|
|
15
|
+
export declare const SelectTrigger: import("@builder.io/qwik").Component<SelectTriggerProps>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type PropsOf } from '@builder.io/qwik';
|
|
2
|
+
export type SelectValueProps = PropsOf<'span'> & {
|
|
3
|
+
/** Text displayed when no item is selected. */
|
|
4
|
+
placeholder?: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Displays the selected option's text, or the `placeholder` when no option is selected.
|
|
8
|
+
*/
|
|
9
|
+
export declare const SelectValue: import("@builder.io/qwik").Component<SelectValueProps>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { SelectContent as Content } from './select-content';
|
|
2
|
+
export { SelectGroup as Group } from './select-group';
|
|
3
|
+
export { SelectGroupLabel as GroupLabel } from './select-group-label';
|
|
4
|
+
export { SelectHiddenInput as HiddenInput } from './select-hidden-input';
|
|
5
|
+
export { SelectItem as Item } from './select-item';
|
|
6
|
+
export { SelectItemIndicator as ItemIndicator } from './select-item-indicator';
|
|
7
|
+
export { SelectItemText as ItemText } from './select-item-text';
|
|
8
|
+
export { SelectLabel as Label } from './select-label';
|
|
9
|
+
export { SelectList as List } from './select-list';
|
|
10
|
+
export { SelectRoot as Root } from './select-root';
|
|
11
|
+
export { SelectTrigger as Trigger } from './select-trigger';
|
|
12
|
+
export { SelectValue as Value } from './select-value';
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leve-ui/select",
|
|
3
|
-
"version": "0.0.0
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Headless, WAI-ARIA compliant Select component for Qwik. Bring your own styles.",
|
|
5
|
+
"homepage": "https://leve-ui.dev/components/select/",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/leve-ui/leve-ui/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/leve-ui/leve-ui.git",
|
|
12
|
+
"directory": "packages/components/select"
|
|
13
|
+
},
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"main": "./lib/index.qwik.cjs",
|
|
18
|
+
"module": "./lib/index.qwik.mjs",
|
|
19
|
+
"qwik": "./lib/index.qwik.mjs",
|
|
20
|
+
"types": "./lib-types/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"@leve-ui/source": "./src/index.ts",
|
|
24
|
+
"types": "./lib-types/index.d.ts",
|
|
25
|
+
"import": "./lib/index.qwik.mjs",
|
|
26
|
+
"require": "./lib/index.qwik.cjs"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"files": [
|
|
30
|
+
"lib",
|
|
31
|
+
"lib-types"
|
|
32
|
+
],
|
|
33
|
+
"keywords": [
|
|
34
|
+
"qwik",
|
|
35
|
+
"headless-ui",
|
|
36
|
+
"accessibility",
|
|
37
|
+
"wai-aria",
|
|
38
|
+
"select"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@leve-ui/utils": "0.3.0"
|
|
42
|
+
},
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@builder.io/qwik": "^1.20.4"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@builder.io/qwik": "1.20.4",
|
|
48
|
+
"typescript": "~5.9.3",
|
|
49
|
+
"vite": "^7.3.8",
|
|
50
|
+
"vitest": "^5.1.0",
|
|
51
|
+
"@leve-ui/tsconfig": "0.0.0",
|
|
52
|
+
"@leve-ui/vite-config": "0.0.0"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "pnpm build:lib && pnpm build:types",
|
|
56
|
+
"build:lib": "vite build --mode lib",
|
|
57
|
+
"build:types": "tsc -p tsconfig.build.json",
|
|
58
|
+
"typecheck": "tsc --noEmit",
|
|
59
|
+
"test": "vitest run"
|
|
60
|
+
}
|
|
6
61
|
}
|
package/README.md
DELETED