@leve-ui/select 0.0.0-stage → 0.1.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.
Files changed (48) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +26 -2
  3. package/lib/index.qwik.cjs +4 -0
  4. package/lib/index.qwik.mjs +4 -0
  5. package/lib/select-content.qwik.cjs +65 -0
  6. package/lib/select-content.qwik.mjs +65 -0
  7. package/lib/select-context.qwik.cjs +38 -0
  8. package/lib/select-context.qwik.mjs +38 -0
  9. package/lib/select-group-label.qwik.cjs +15 -0
  10. package/lib/select-group-label.qwik.mjs +15 -0
  11. package/lib/select-group.qwik.cjs +22 -0
  12. package/lib/select-group.qwik.mjs +22 -0
  13. package/lib/select-hidden-input.qwik.cjs +37 -0
  14. package/lib/select-hidden-input.qwik.mjs +37 -0
  15. package/lib/select-item-indicator.qwik.cjs +17 -0
  16. package/lib/select-item-indicator.qwik.mjs +17 -0
  17. package/lib/select-item-text.qwik.cjs +14 -0
  18. package/lib/select-item-text.qwik.mjs +14 -0
  19. package/lib/select-item.qwik.cjs +52 -0
  20. package/lib/select-item.qwik.mjs +52 -0
  21. package/lib/select-label.qwik.cjs +18 -0
  22. package/lib/select-label.qwik.mjs +18 -0
  23. package/lib/select-list.qwik.cjs +18 -0
  24. package/lib/select-list.qwik.mjs +18 -0
  25. package/lib/select-root.qwik.cjs +90 -0
  26. package/lib/select-root.qwik.mjs +90 -0
  27. package/lib/select-trigger.qwik.cjs +189 -0
  28. package/lib/select-trigger.qwik.mjs +189 -0
  29. package/lib/select-value.qwik.cjs +17 -0
  30. package/lib/select-value.qwik.mjs +17 -0
  31. package/lib/select.qwik.cjs +26 -0
  32. package/lib/select.qwik.mjs +26 -0
  33. package/lib-types/index.d.ts +14 -0
  34. package/lib-types/select-content.d.ts +42 -0
  35. package/lib-types/select-context.d.ts +48 -0
  36. package/lib-types/select-group-label.d.ts +8 -0
  37. package/lib-types/select-group.d.ts +8 -0
  38. package/lib-types/select-hidden-input.d.ts +12 -0
  39. package/lib-types/select-item-indicator.d.ts +7 -0
  40. package/lib-types/select-item-text.d.ts +6 -0
  41. package/lib-types/select-item.d.ts +17 -0
  42. package/lib-types/select-label.d.ts +11 -0
  43. package/lib-types/select-list.d.ts +8 -0
  44. package/lib-types/select-root.d.ts +47 -0
  45. package/lib-types/select-trigger.d.ts +15 -0
  46. package/lib-types/select-value.d.ts +9 -0
  47. package/lib-types/select.d.ts +12 -0
  48. package/package.json +58 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 leve-ui contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,27 @@
1
- # Temporary Holding Version
1
+ <!-- Generated from package.json by .github/scripts/package-readmes.mjs. Do not edit. -->
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ <p align="center">
4
+ <img src="https://raw.githubusercontent.com/leve-ui/leve-ui/main/.github/assets/logo-dark.svg" alt="leve-ui" width="240">
5
+ </p>
6
+
7
+ # @leve-ui/select
8
+
9
+ Headless, WAI-ARIA compliant Select component for Qwik: a dropdown list for picking an option from a set of choices.
10
+
11
+ Part of [leve-ui](https://leve-ui.dev). It ships no CSS: style each part with classes or `data-*` attributes.
12
+
13
+ ## Installation
14
+
15
+ ```sh
16
+ pnpm add @leve-ui/select
17
+ ```
18
+
19
+ This component is also included in [`@leve-ui/core`](https://www.npmjs.com/package/@leve-ui/core), which bundles every component.
20
+
21
+ ## Documentation
22
+
23
+ Usage, examples, and the API reference: https://leve-ui.dev/components/select/
24
+
25
+ ## License
26
+
27
+ [MIT](https://github.com/leve-ui/leve-ui/blob/main/LICENSE)
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const select = require("./select.qwik.cjs");
4
+ exports.Select = select;
@@ -0,0 +1,4 @@
1
+ import * as select from "./select.qwik.mjs";
2
+ export {
3
+ select as Select
4
+ };
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
4
+ const qwik = require("@builder.io/qwik");
5
+ const utils = require("@leve-ui/utils");
6
+ const selectContext = require("./select-context.qwik.cjs");
7
+ const SelectContent = qwik.component$(({ side, align, sideOffset, alignOffset, avoidCollisions, collisionPadding, ...props }) => {
8
+ const context = qwik.useContext(selectContext.selectContextId);
9
+ const ref = qwik.useSignal();
10
+ const always = qwik.useComputed$(() => true);
11
+ const floating = qwik.useComputed$(() => ({
12
+ side: side ?? "bottom",
13
+ align: align ?? "start",
14
+ sideOffset: sideOffset ?? 0,
15
+ alignOffset: alignOffset ?? 0,
16
+ avoidCollisions: avoidCollisions ?? true,
17
+ collisionPadding: collisionPadding ?? 0
18
+ }));
19
+ qwik.useVisibleTask$(({ track, cleanup }) => {
20
+ const open = track(() => context.open.value);
21
+ const options = track(() => floating.value);
22
+ const element = ref.value;
23
+ if (!element || !open) return;
24
+ const trigger = selectContext.getSelectTrigger(element, context.ids.trigger);
25
+ cleanup(utils.openPopoverElement(element, {
26
+ open: context.open,
27
+ setOpen$: context.setOpen$,
28
+ trigger,
29
+ floating: {
30
+ ...options,
31
+ cssVarPrefix: "--leve-select"
32
+ },
33
+ moveFocus: false,
34
+ closeOnEscape: always,
35
+ closeOnOutsideClick: always
36
+ }));
37
+ }, {
38
+ strategy: "document-ready"
39
+ });
40
+ qwik.useVisibleTask$(({ track }) => {
41
+ const open = track(() => context.open.value);
42
+ const highlighted = track(() => context.highlighted.value);
43
+ const list = ref.value && utils.getElementByIdInContainer(ref.value, context.ids.list);
44
+ if (!list || !open) return;
45
+ const items = utils.getCollectionItems(list, selectContext.ITEM_SELECTOR);
46
+ const item = items.find((element) => element.getAttribute("data-value") === highlighted);
47
+ if (highlighted !== null && !item) {
48
+ context.highlighted.value = null;
49
+ return;
50
+ }
51
+ item?.scrollIntoView?.({
52
+ block: "nearest"
53
+ });
54
+ });
55
+ return /* @__PURE__ */ jsxRuntime.jsx("div", {
56
+ ...props,
57
+ ref,
58
+ popover: "manual",
59
+ tabIndex: props.tabIndex ?? -1,
60
+ "data-leve-select-content": "",
61
+ "data-state": context.open.value ? "open" : "closed",
62
+ children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {})
63
+ });
64
+ });
65
+ exports.SelectContent = SelectContent;
@@ -0,0 +1,65 @@
1
+ import { jsx } from "@builder.io/qwik/jsx-runtime";
2
+ import { component$, useContext, useSignal, useComputed$, useVisibleTask$, Slot } from "@builder.io/qwik";
3
+ import { openPopoverElement, getElementByIdInContainer, getCollectionItems } from "@leve-ui/utils";
4
+ import { selectContextId, getSelectTrigger, ITEM_SELECTOR } from "./select-context.qwik.mjs";
5
+ const SelectContent = component$(({ side, align, sideOffset, alignOffset, avoidCollisions, collisionPadding, ...props }) => {
6
+ const context = useContext(selectContextId);
7
+ const ref = useSignal();
8
+ const always = useComputed$(() => true);
9
+ const floating = useComputed$(() => ({
10
+ side: side ?? "bottom",
11
+ align: align ?? "start",
12
+ sideOffset: sideOffset ?? 0,
13
+ alignOffset: alignOffset ?? 0,
14
+ avoidCollisions: avoidCollisions ?? true,
15
+ collisionPadding: collisionPadding ?? 0
16
+ }));
17
+ useVisibleTask$(({ track, cleanup }) => {
18
+ const open = track(() => context.open.value);
19
+ const options = track(() => floating.value);
20
+ const element = ref.value;
21
+ if (!element || !open) return;
22
+ const trigger = getSelectTrigger(element, context.ids.trigger);
23
+ cleanup(openPopoverElement(element, {
24
+ open: context.open,
25
+ setOpen$: context.setOpen$,
26
+ trigger,
27
+ floating: {
28
+ ...options,
29
+ cssVarPrefix: "--leve-select"
30
+ },
31
+ moveFocus: false,
32
+ closeOnEscape: always,
33
+ closeOnOutsideClick: always
34
+ }));
35
+ }, {
36
+ strategy: "document-ready"
37
+ });
38
+ useVisibleTask$(({ track }) => {
39
+ const open = track(() => context.open.value);
40
+ const highlighted = track(() => context.highlighted.value);
41
+ const list = ref.value && getElementByIdInContainer(ref.value, context.ids.list);
42
+ if (!list || !open) return;
43
+ const items = getCollectionItems(list, ITEM_SELECTOR);
44
+ const item = items.find((element) => element.getAttribute("data-value") === highlighted);
45
+ if (highlighted !== null && !item) {
46
+ context.highlighted.value = null;
47
+ return;
48
+ }
49
+ item?.scrollIntoView?.({
50
+ block: "nearest"
51
+ });
52
+ });
53
+ return /* @__PURE__ */ jsx("div", {
54
+ ...props,
55
+ ref,
56
+ popover: "manual",
57
+ tabIndex: props.tabIndex ?? -1,
58
+ "data-leve-select-content": "",
59
+ "data-state": context.open.value ? "open" : "closed",
60
+ children: /* @__PURE__ */ jsx(Slot, {})
61
+ });
62
+ });
63
+ export {
64
+ SelectContent
65
+ };
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const qwik = require("@builder.io/qwik");
4
+ const utils = require("@leve-ui/utils");
5
+ const selectContextId = qwik.createContextId("leve-ui.select");
6
+ const selectItemContextId = qwik.createContextId("leve-ui.select-item");
7
+ const selectGroupContextId = qwik.createContextId("leve-ui.select-group");
8
+ const ITEM_SELECTOR = "[data-leve-select-item]";
9
+ function getItemText(item) {
10
+ const text = item.querySelector("[data-leve-select-item-text]")?.textContent?.trim();
11
+ return text || item.getAttribute("data-text-value") || item.textContent?.trim() || "";
12
+ }
13
+ function getItemTypeaheadText(item) {
14
+ return item.getAttribute("data-text-value") || getItemText(item);
15
+ }
16
+ function getSelectTrigger(anchor, triggerId) {
17
+ if (!anchor) return null;
18
+ const byId = utils.getElementByIdInContainer(anchor, triggerId);
19
+ if (byId) return byId;
20
+ const root = anchor.closest("[data-leve-select]");
21
+ return root?.querySelector("[data-leve-select-trigger]") ?? null;
22
+ }
23
+ function resolveSelectedText(anchor, listId, value) {
24
+ if (!anchor || value === null) return "";
25
+ const list = utils.getElementByIdInContainer(anchor, listId);
26
+ if (!list) return "";
27
+ const items = utils.getCollectionItems(list, ITEM_SELECTOR);
28
+ const matched = items.find((element) => element.getAttribute("data-value") === value);
29
+ return matched ? getItemText(matched) : "";
30
+ }
31
+ exports.ITEM_SELECTOR = ITEM_SELECTOR;
32
+ exports.getItemText = getItemText;
33
+ exports.getItemTypeaheadText = getItemTypeaheadText;
34
+ exports.getSelectTrigger = getSelectTrigger;
35
+ exports.resolveSelectedText = resolveSelectedText;
36
+ exports.selectContextId = selectContextId;
37
+ exports.selectGroupContextId = selectGroupContextId;
38
+ exports.selectItemContextId = selectItemContextId;
@@ -0,0 +1,38 @@
1
+ import { createContextId } from "@builder.io/qwik";
2
+ import { getElementByIdInContainer, getCollectionItems } from "@leve-ui/utils";
3
+ const selectContextId = createContextId("leve-ui.select");
4
+ const selectItemContextId = createContextId("leve-ui.select-item");
5
+ const selectGroupContextId = createContextId("leve-ui.select-group");
6
+ const ITEM_SELECTOR = "[data-leve-select-item]";
7
+ function getItemText(item) {
8
+ const text = item.querySelector("[data-leve-select-item-text]")?.textContent?.trim();
9
+ return text || item.getAttribute("data-text-value") || item.textContent?.trim() || "";
10
+ }
11
+ function getItemTypeaheadText(item) {
12
+ return item.getAttribute("data-text-value") || getItemText(item);
13
+ }
14
+ function getSelectTrigger(anchor, triggerId) {
15
+ if (!anchor) return null;
16
+ const byId = getElementByIdInContainer(anchor, triggerId);
17
+ if (byId) return byId;
18
+ const root = anchor.closest("[data-leve-select]");
19
+ return root?.querySelector("[data-leve-select-trigger]") ?? null;
20
+ }
21
+ function resolveSelectedText(anchor, listId, value) {
22
+ if (!anchor || value === null) return "";
23
+ const list = getElementByIdInContainer(anchor, listId);
24
+ if (!list) return "";
25
+ const items = getCollectionItems(list, ITEM_SELECTOR);
26
+ const matched = items.find((element) => element.getAttribute("data-value") === value);
27
+ return matched ? getItemText(matched) : "";
28
+ }
29
+ export {
30
+ ITEM_SELECTOR,
31
+ getItemText,
32
+ getItemTypeaheadText,
33
+ getSelectTrigger,
34
+ resolveSelectedText,
35
+ selectContextId,
36
+ selectGroupContextId,
37
+ selectItemContextId
38
+ };
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
4
+ const qwik = require("@builder.io/qwik");
5
+ const selectContext = require("./select-context.qwik.cjs");
6
+ const SelectGroupLabel = qwik.component$((props) => {
7
+ const group = qwik.useContext(selectContext.selectGroupContextId);
8
+ return /* @__PURE__ */ jsxRuntime.jsx("div", {
9
+ ...props,
10
+ id: group.labelId,
11
+ "data-leve-select-group-label": "",
12
+ children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {})
13
+ });
14
+ });
15
+ exports.SelectGroupLabel = SelectGroupLabel;
@@ -0,0 +1,15 @@
1
+ import { jsx } from "@builder.io/qwik/jsx-runtime";
2
+ import { component$, useContext, Slot } from "@builder.io/qwik";
3
+ import { selectGroupContextId } from "./select-context.qwik.mjs";
4
+ const SelectGroupLabel = component$((props) => {
5
+ const group = useContext(selectGroupContextId);
6
+ return /* @__PURE__ */ jsx("div", {
7
+ ...props,
8
+ id: group.labelId,
9
+ "data-leve-select-group-label": "",
10
+ children: /* @__PURE__ */ jsx(Slot, {})
11
+ });
12
+ });
13
+ export {
14
+ SelectGroupLabel
15
+ };
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
4
+ const qwik = require("@builder.io/qwik");
5
+ const selectContext = require("./select-context.qwik.cjs");
6
+ const SelectGroup = qwik.component$((props) => {
7
+ const labelId = `${qwik.useId()}-label`;
8
+ qwik.useContextProvider(selectContext.selectGroupContextId, {
9
+ labelId
10
+ });
11
+ return (
12
+ // biome-ignore lint/a11y/useSemanticElements: a <fieldset> is for form controls; the APG Combobox uses role="group" for groups of options
13
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
14
+ ...props,
15
+ role: "group",
16
+ "aria-labelledby": props["aria-labelledby"] ?? (props["aria-label"] ? void 0 : labelId),
17
+ "data-leve-select-group": "",
18
+ children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {})
19
+ })
20
+ );
21
+ });
22
+ exports.SelectGroup = SelectGroup;
@@ -0,0 +1,22 @@
1
+ import { jsx } from "@builder.io/qwik/jsx-runtime";
2
+ import { component$, useId, useContextProvider, Slot } from "@builder.io/qwik";
3
+ import { selectGroupContextId } from "./select-context.qwik.mjs";
4
+ const SelectGroup = component$((props) => {
5
+ const labelId = `${useId()}-label`;
6
+ useContextProvider(selectGroupContextId, {
7
+ labelId
8
+ });
9
+ return (
10
+ // biome-ignore lint/a11y/useSemanticElements: a <fieldset> is for form controls; the APG Combobox uses role="group" for groups of options
11
+ /* @__PURE__ */ jsx("div", {
12
+ ...props,
13
+ role: "group",
14
+ "aria-labelledby": props["aria-labelledby"] ?? (props["aria-label"] ? void 0 : labelId),
15
+ "data-leve-select-group": "",
16
+ children: /* @__PURE__ */ jsx(Slot, {})
17
+ })
18
+ );
19
+ });
20
+ export {
21
+ SelectGroup
22
+ };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
4
+ const qwik = require("@builder.io/qwik");
5
+ const utils = require("@leve-ui/utils");
6
+ const selectContext = require("./select-context.qwik.cjs");
7
+ const SelectHiddenInput = qwik.component$((props) => {
8
+ const context = qwik.useContext(selectContext.selectContextId);
9
+ const internalRef = qwik.useSignal();
10
+ const inputRef = props.ref ?? internalRef;
11
+ utils.useFormReset(inputRef, qwik.$(async () => {
12
+ await context.reset$();
13
+ if (inputRef.value) {
14
+ inputRef.value.value = context.value.value ?? "";
15
+ }
16
+ }));
17
+ return /* @__PURE__ */ jsxRuntime.jsx("input", {
18
+ ...props,
19
+ ref: inputRef,
20
+ type: "text",
21
+ value: context.value.value ?? "",
22
+ required: context.required.value,
23
+ disabled: context.disabled.value,
24
+ "aria-hidden": "true",
25
+ tabIndex: -1,
26
+ // functional inline style per adr/0026, keeps native required validation working, unlike hidden
27
+ style: {
28
+ position: "absolute",
29
+ opacity: 0,
30
+ pointerEvents: "none",
31
+ margin: 0,
32
+ width: 0
33
+ },
34
+ "data-leve-select-hidden-input": ""
35
+ });
36
+ });
37
+ exports.SelectHiddenInput = SelectHiddenInput;
@@ -0,0 +1,37 @@
1
+ import { jsx } from "@builder.io/qwik/jsx-runtime";
2
+ import { component$, useContext, useSignal, $ } from "@builder.io/qwik";
3
+ import { useFormReset } from "@leve-ui/utils";
4
+ import { selectContextId } from "./select-context.qwik.mjs";
5
+ const SelectHiddenInput = component$((props) => {
6
+ const context = useContext(selectContextId);
7
+ const internalRef = useSignal();
8
+ const inputRef = props.ref ?? internalRef;
9
+ useFormReset(inputRef, $(async () => {
10
+ await context.reset$();
11
+ if (inputRef.value) {
12
+ inputRef.value.value = context.value.value ?? "";
13
+ }
14
+ }));
15
+ return /* @__PURE__ */ jsx("input", {
16
+ ...props,
17
+ ref: inputRef,
18
+ type: "text",
19
+ value: context.value.value ?? "",
20
+ required: context.required.value,
21
+ disabled: context.disabled.value,
22
+ "aria-hidden": "true",
23
+ tabIndex: -1,
24
+ // functional inline style per adr/0026, keeps native required validation working, unlike hidden
25
+ style: {
26
+ position: "absolute",
27
+ opacity: 0,
28
+ pointerEvents: "none",
29
+ margin: 0,
30
+ width: 0
31
+ },
32
+ "data-leve-select-hidden-input": ""
33
+ });
34
+ });
35
+ export {
36
+ SelectHiddenInput
37
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
4
+ const qwik = require("@builder.io/qwik");
5
+ const selectContext = require("./select-context.qwik.cjs");
6
+ const SelectItemIndicator = qwik.component$((props) => {
7
+ const item = qwik.useContext(selectContext.selectItemContextId);
8
+ return /* @__PURE__ */ jsxRuntime.jsx("span", {
9
+ ...props,
10
+ hidden: !item.selected.value,
11
+ "aria-hidden": "true",
12
+ "data-leve-select-item-indicator": "",
13
+ "data-state": item.selected.value ? "checked" : "unchecked",
14
+ children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {})
15
+ });
16
+ });
17
+ exports.SelectItemIndicator = SelectItemIndicator;
@@ -0,0 +1,17 @@
1
+ import { jsx } from "@builder.io/qwik/jsx-runtime";
2
+ import { component$, useContext, Slot } from "@builder.io/qwik";
3
+ import { selectItemContextId } from "./select-context.qwik.mjs";
4
+ const SelectItemIndicator = component$((props) => {
5
+ const item = useContext(selectItemContextId);
6
+ return /* @__PURE__ */ jsx("span", {
7
+ ...props,
8
+ hidden: !item.selected.value,
9
+ "aria-hidden": "true",
10
+ "data-leve-select-item-indicator": "",
11
+ "data-state": item.selected.value ? "checked" : "unchecked",
12
+ children: /* @__PURE__ */ jsx(Slot, {})
13
+ });
14
+ });
15
+ export {
16
+ SelectItemIndicator
17
+ };
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
4
+ const qwik = require("@builder.io/qwik");
5
+ const selectContext = require("./select-context.qwik.cjs");
6
+ const SelectItemText = qwik.component$((props) => {
7
+ qwik.useContext(selectContext.selectItemContextId);
8
+ return /* @__PURE__ */ jsxRuntime.jsx("span", {
9
+ ...props,
10
+ "data-leve-select-item-text": "",
11
+ children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {})
12
+ });
13
+ });
14
+ exports.SelectItemText = SelectItemText;
@@ -0,0 +1,14 @@
1
+ import { jsx } from "@builder.io/qwik/jsx-runtime";
2
+ import { component$, useContext, Slot } from "@builder.io/qwik";
3
+ import { selectItemContextId } from "./select-context.qwik.mjs";
4
+ const SelectItemText = component$((props) => {
5
+ useContext(selectItemContextId);
6
+ return /* @__PURE__ */ jsx("span", {
7
+ ...props,
8
+ "data-leve-select-item-text": "",
9
+ children: /* @__PURE__ */ jsx(Slot, {})
10
+ });
11
+ });
12
+ export {
13
+ SelectItemText
14
+ };
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
4
+ const qwik = require("@builder.io/qwik");
5
+ const utils = require("@leve-ui/utils");
6
+ const selectContext = require("./select-context.qwik.cjs");
7
+ const SelectItem = qwik.component$(({ value, disabled, textValue, onClick$, onPointerMove$, ...props }) => {
8
+ const context = qwik.useContext(selectContext.selectContextId);
9
+ const selected = qwik.useComputed$(() => context.value.value === value);
10
+ const highlighted = qwik.useComputed$(() => context.highlighted.value === value);
11
+ const isDisabled = qwik.useComputed$(() => Boolean(disabled));
12
+ qwik.useContextProvider(selectContext.selectItemContextId, {
13
+ value,
14
+ selected,
15
+ highlighted,
16
+ disabled: isDisabled
17
+ });
18
+ const highlight$ = qwik.$(() => {
19
+ if (!isDisabled.value && !highlighted.value) context.highlighted.value = value;
20
+ });
21
+ const select$ = qwik.$((_event, element) => {
22
+ if (isDisabled.value) return;
23
+ return context.select$(value, selectContext.getItemText(element));
24
+ });
25
+ return (
26
+ // biome-ignore lint/a11y/useFocusableInteractive: focus stays on the trigger; the option is highlighted with aria-activedescendant (adr/0035)
27
+ /* @__PURE__ */ jsxRuntime.jsx("div", {
28
+ ...props,
29
+ id: utils.itemId(context.ids.list, value),
30
+ role: "option",
31
+ "aria-selected": selected.value ? "true" : "false",
32
+ "aria-disabled": isDisabled.value ? "true" : void 0,
33
+ "preventdefault:mousedown": true,
34
+ onPointerMove$: [
35
+ highlight$,
36
+ onPointerMove$
37
+ ],
38
+ onClick$: [
39
+ select$,
40
+ onClick$
41
+ ],
42
+ "data-leve-select-item": "",
43
+ "data-value": value,
44
+ "data-text-value": textValue,
45
+ "data-state": selected.value ? "checked" : "unchecked",
46
+ "data-highlighted": utils.dataAttr(highlighted.value),
47
+ "data-disabled": utils.dataAttr(isDisabled.value),
48
+ children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {})
49
+ })
50
+ );
51
+ });
52
+ exports.SelectItem = SelectItem;
@@ -0,0 +1,52 @@
1
+ import { jsx } from "@builder.io/qwik/jsx-runtime";
2
+ import { component$, useContext, useComputed$, useContextProvider, $, Slot } from "@builder.io/qwik";
3
+ import { dataAttr, itemId } from "@leve-ui/utils";
4
+ import { selectContextId, selectItemContextId, getItemText } from "./select-context.qwik.mjs";
5
+ const SelectItem = component$(({ value, disabled, textValue, onClick$, onPointerMove$, ...props }) => {
6
+ const context = useContext(selectContextId);
7
+ const selected = useComputed$(() => context.value.value === value);
8
+ const highlighted = useComputed$(() => context.highlighted.value === value);
9
+ const isDisabled = useComputed$(() => Boolean(disabled));
10
+ useContextProvider(selectItemContextId, {
11
+ value,
12
+ selected,
13
+ highlighted,
14
+ disabled: isDisabled
15
+ });
16
+ const highlight$ = $(() => {
17
+ if (!isDisabled.value && !highlighted.value) context.highlighted.value = value;
18
+ });
19
+ const select$ = $((_event, element) => {
20
+ if (isDisabled.value) return;
21
+ return context.select$(value, getItemText(element));
22
+ });
23
+ return (
24
+ // biome-ignore lint/a11y/useFocusableInteractive: focus stays on the trigger; the option is highlighted with aria-activedescendant (adr/0035)
25
+ /* @__PURE__ */ jsx("div", {
26
+ ...props,
27
+ id: itemId(context.ids.list, value),
28
+ role: "option",
29
+ "aria-selected": selected.value ? "true" : "false",
30
+ "aria-disabled": isDisabled.value ? "true" : void 0,
31
+ "preventdefault:mousedown": true,
32
+ onPointerMove$: [
33
+ highlight$,
34
+ onPointerMove$
35
+ ],
36
+ onClick$: [
37
+ select$,
38
+ onClick$
39
+ ],
40
+ "data-leve-select-item": "",
41
+ "data-value": value,
42
+ "data-text-value": textValue,
43
+ "data-state": selected.value ? "checked" : "unchecked",
44
+ "data-highlighted": dataAttr(highlighted.value),
45
+ "data-disabled": dataAttr(isDisabled.value),
46
+ children: /* @__PURE__ */ jsx(Slot, {})
47
+ })
48
+ );
49
+ });
50
+ export {
51
+ SelectItem
52
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
4
+ const qwik = require("@builder.io/qwik");
5
+ const utils = require("@leve-ui/utils");
6
+ const selectContext = require("./select-context.qwik.cjs");
7
+ const SelectLabel = qwik.component$((props) => {
8
+ const context = qwik.useContext(selectContext.selectContextId);
9
+ return /* @__PURE__ */ jsxRuntime.jsx("label", {
10
+ ...props,
11
+ id: context.ids.label,
12
+ for: context.ids.trigger,
13
+ "data-leve-select-label": "",
14
+ "data-disabled": utils.dataAttr(context.disabled.value),
15
+ children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {})
16
+ });
17
+ });
18
+ exports.SelectLabel = SelectLabel;
@@ -0,0 +1,18 @@
1
+ import { jsx } from "@builder.io/qwik/jsx-runtime";
2
+ import { component$, useContext, Slot } from "@builder.io/qwik";
3
+ import { dataAttr } from "@leve-ui/utils";
4
+ import { selectContextId } from "./select-context.qwik.mjs";
5
+ const SelectLabel = component$((props) => {
6
+ const context = useContext(selectContextId);
7
+ return /* @__PURE__ */ jsx("label", {
8
+ ...props,
9
+ id: context.ids.label,
10
+ for: context.ids.trigger,
11
+ "data-leve-select-label": "",
12
+ "data-disabled": dataAttr(context.disabled.value),
13
+ children: /* @__PURE__ */ jsx(Slot, {})
14
+ });
15
+ });
16
+ export {
17
+ SelectLabel
18
+ };
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("@builder.io/qwik/jsx-runtime");
4
+ const qwik = require("@builder.io/qwik");
5
+ const selectContext = require("./select-context.qwik.cjs");
6
+ const SelectList = qwik.component$((props) => {
7
+ const context = qwik.useContext(selectContext.selectContextId);
8
+ return /* @__PURE__ */ jsxRuntime.jsx("div", {
9
+ ...props,
10
+ id: context.ids.list,
11
+ role: "listbox",
12
+ tabIndex: props.tabIndex ?? -1,
13
+ "aria-labelledby": props["aria-labelledby"] ?? (props["aria-label"] ? void 0 : context.ids.label),
14
+ "data-leve-select-list": "",
15
+ children: /* @__PURE__ */ jsxRuntime.jsx(qwik.Slot, {})
16
+ });
17
+ });
18
+ exports.SelectList = SelectList;