menhir 0.1.4 → 0.1.6
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/README.md +2 -2
- package/dist/combobox/clear/ComboboxClear.js +39 -0
- package/dist/combobox/filter/includesText.js +24 -0
- package/dist/combobox/group/ComboboxGroup.js +32 -0
- package/dist/combobox/group/ComboboxGroupContext.js +10 -0
- package/dist/combobox/group-label/ComboboxGroupLabel.js +26 -0
- package/dist/combobox/index.js +3 -0
- package/dist/combobox/index.parts.js +12 -0
- package/dist/combobox/input/ComboboxInput.js +160 -0
- package/dist/combobox/item/ComboboxItem.js +98 -0
- package/dist/combobox/item/ComboboxItemContext.js +10 -0
- package/dist/combobox/item-indicator/ComboboxItemIndicator.js +22 -0
- package/dist/combobox/list/ComboboxList.js +26 -0
- package/dist/combobox/popup/ComboboxPopup.js +78 -0
- package/dist/combobox/root/ComboboxContext.js +137 -0
- package/dist/combobox/root/ComboboxRoot.js +21 -0
- package/dist/combobox/status/ComboboxStatus.js +31 -0
- package/dist/combobox/trigger/ComboboxTrigger.js +47 -0
- package/dist/context-menu/index.js +2 -0
- package/dist/context-menu/index.parts.js +13 -0
- package/dist/context-menu/popup/ContextMenuPopup.js +30 -0
- package/dist/context-menu/root/ContextMenuContext.js +11 -0
- package/dist/context-menu/root/ContextMenuRoot.js +23 -0
- package/dist/context-menu/trigger/ContextMenuTrigger.js +47 -0
- package/dist/core/mergeElementProps.js +7 -1
- package/dist/menu/checkbox-item/MenuCheckboxItem.js +28 -0
- package/dist/menu/group/MenuGroup.js +40 -0
- package/dist/menu/group/MenuGroupContext.js +10 -0
- package/dist/menu/group-label/MenuGroupLabel.js +27 -0
- package/dist/menu/index.js +2 -0
- package/dist/menu/index.parts.js +13 -0
- package/dist/menu/item/MenuItem.js +30 -0
- package/dist/menu/item/menuItemProps.js +77 -0
- package/dist/menu/item/renderCheckedItem.js +52 -0
- package/dist/menu/item-indicator/MenuItemIndicator.js +23 -0
- package/dist/menu/item-indicator/MenuItemIndicatorContext.js +10 -0
- package/dist/menu/popup/MenuPopup.js +123 -0
- package/dist/menu/radio-group/MenuRadioGroup.js +39 -0
- package/dist/menu/radio-item/MenuRadioItem.js +21 -0
- package/dist/menu/root/MenuContext.js +114 -0
- package/dist/menu/root/MenuRoot.js +19 -0
- package/dist/menu/submenu/MenuSubmenu.js +18 -0
- package/dist/menu/submenu-trigger/MenuSubmenuTrigger.js +114 -0
- package/dist/menu/trigger/MenuTrigger.js +67 -0
- package/dist/menubar/index.js +2 -0
- package/dist/menubar/index.parts.js +14 -0
- package/dist/menubar/menu/MenubarMenu.js +30 -0
- package/dist/menubar/root/MenubarContext.js +10 -0
- package/dist/menubar/root/MenubarRoot.js +68 -0
- package/dist/menubar/trigger/MenubarTrigger.js +73 -0
- package/dist/select/group/SelectGroup.js +32 -0
- package/dist/select/group/SelectGroupContext.js +10 -0
- package/dist/select/group-label/SelectGroupLabel.js +26 -0
- package/dist/select/index.js +2 -0
- package/dist/select/index.parts.js +9 -0
- package/dist/select/item/SelectItem.js +97 -0
- package/dist/select/item/SelectItemContext.js +10 -0
- package/dist/select/item-indicator/SelectItemIndicator.js +22 -0
- package/dist/select/popup/SelectPopup.js +92 -0
- package/dist/select/root/SelectContext.js +99 -0
- package/dist/select/root/SelectRoot.js +21 -0
- package/dist/select/trigger/SelectTrigger.js +163 -0
- package/dist/select/value/SelectValue.js +32 -0
- package/dist/source/combobox/clear/ComboboxClear.d.ts +12 -0
- package/dist/source/combobox/clear/ComboboxClear.jsx +36 -0
- package/dist/source/combobox/filter/includesText.d.ts +12 -0
- package/dist/source/combobox/filter/includesText.js +26 -0
- package/dist/source/combobox/group/ComboboxGroup.d.ts +10 -0
- package/dist/source/combobox/group/ComboboxGroup.jsx +23 -0
- package/dist/source/combobox/group/ComboboxGroupContext.d.ts +10 -0
- package/dist/source/combobox/group/ComboboxGroupContext.js +12 -0
- package/dist/source/combobox/group-label/ComboboxGroupLabel.d.ts +10 -0
- package/dist/source/combobox/group-label/ComboboxGroupLabel.jsx +24 -0
- package/dist/source/combobox/index.d.ts +2 -0
- package/dist/source/combobox/index.js +4 -0
- package/dist/source/combobox/index.parts.d.ts +11 -0
- package/dist/source/combobox/index.parts.js +11 -0
- package/dist/source/combobox/input/ComboboxInput.d.ts +19 -0
- package/dist/source/combobox/input/ComboboxInput.jsx +174 -0
- package/dist/source/combobox/item/ComboboxItem.d.ts +25 -0
- package/dist/source/combobox/item/ComboboxItem.jsx +93 -0
- package/dist/source/combobox/item/ComboboxItemContext.d.ts +11 -0
- package/dist/source/combobox/item/ComboboxItemContext.js +12 -0
- package/dist/source/combobox/item-indicator/ComboboxItemIndicator.d.ts +11 -0
- package/dist/source/combobox/item-indicator/ComboboxItemIndicator.jsx +16 -0
- package/dist/source/combobox/list/ComboboxList.d.ts +12 -0
- package/dist/source/combobox/list/ComboboxList.jsx +17 -0
- package/dist/source/combobox/popup/ComboboxPopup.d.ts +34 -0
- package/dist/source/combobox/popup/ComboboxPopup.jsx +76 -0
- package/dist/source/combobox/root/ComboboxContext.d.ts +132 -0
- package/dist/source/combobox/root/ComboboxContext.js +156 -0
- package/dist/source/combobox/root/ComboboxRoot.d.ts +13 -0
- package/dist/source/combobox/root/ComboboxRoot.jsx +13 -0
- package/dist/source/combobox/status/ComboboxStatus.d.ts +19 -0
- package/dist/source/combobox/status/ComboboxStatus.jsx +27 -0
- package/dist/source/combobox/trigger/ComboboxTrigger.d.ts +13 -0
- package/dist/source/combobox/trigger/ComboboxTrigger.jsx +40 -0
- package/dist/source/context-menu/index.d.ts +1 -0
- package/dist/source/context-menu/index.js +1 -0
- package/dist/source/context-menu/index.parts.d.ts +12 -0
- package/dist/source/context-menu/index.parts.js +13 -0
- package/dist/source/context-menu/popup/ContextMenuPopup.d.ts +12 -0
- package/dist/source/context-menu/popup/ContextMenuPopup.jsx +36 -0
- package/dist/source/context-menu/root/ContextMenuContext.d.ts +18 -0
- package/dist/source/context-menu/root/ContextMenuContext.js +12 -0
- package/dist/source/context-menu/root/ContextMenuRoot.d.ts +12 -0
- package/dist/source/context-menu/root/ContextMenuRoot.jsx +16 -0
- package/dist/source/context-menu/trigger/ContextMenuTrigger.d.ts +15 -0
- package/dist/source/context-menu/trigger/ContextMenuTrigger.jsx +46 -0
- package/dist/source/core/mergeElementProps.d.ts +8 -0
- package/dist/source/core/mergeElementProps.js +7 -1
- package/dist/source/floating/dismissal/reason.d.ts +12 -2
- package/dist/source/menu/checkbox-item/MenuCheckboxItem.d.ts +20 -0
- package/dist/source/menu/checkbox-item/MenuCheckboxItem.jsx +26 -0
- package/dist/source/menu/group/MenuGroup.d.ts +16 -0
- package/dist/source/menu/group/MenuGroup.jsx +31 -0
- package/dist/source/menu/group/MenuGroupContext.d.ts +10 -0
- package/dist/source/menu/group/MenuGroupContext.js +12 -0
- package/dist/source/menu/group-label/MenuGroupLabel.d.ts +11 -0
- package/dist/source/menu/group-label/MenuGroupLabel.jsx +25 -0
- package/dist/source/menu/index.d.ts +1 -0
- package/dist/source/menu/index.js +1 -0
- package/dist/source/menu/index.parts.d.ts +12 -0
- package/dist/source/menu/index.parts.js +12 -0
- package/dist/source/menu/item/MenuItem.d.ts +11 -0
- package/dist/source/menu/item/MenuItem.jsx +21 -0
- package/dist/source/menu/item/menuItemProps.d.ts +35 -0
- package/dist/source/menu/item/menuItemProps.js +78 -0
- package/dist/source/menu/item/renderCheckedItem.d.ts +22 -0
- package/dist/source/menu/item/renderCheckedItem.jsx +41 -0
- package/dist/source/menu/item-indicator/MenuItemIndicator.d.ts +12 -0
- package/dist/source/menu/item-indicator/MenuItemIndicator.jsx +17 -0
- package/dist/source/menu/item-indicator/MenuItemIndicatorContext.d.ts +11 -0
- package/dist/source/menu/item-indicator/MenuItemIndicatorContext.js +12 -0
- package/dist/source/menu/popup/MenuPopup.d.ts +41 -0
- package/dist/source/menu/popup/MenuPopup.jsx +156 -0
- package/dist/source/menu/radio-group/MenuRadioGroup.d.ts +27 -0
- package/dist/source/menu/radio-group/MenuRadioGroup.jsx +36 -0
- package/dist/source/menu/radio-item/MenuRadioItem.d.ts +14 -0
- package/dist/source/menu/radio-item/MenuRadioItem.jsx +19 -0
- package/dist/source/menu/root/MenuContext.d.ts +114 -0
- package/dist/source/menu/root/MenuContext.js +123 -0
- package/dist/source/menu/root/MenuRoot.d.ts +11 -0
- package/dist/source/menu/root/MenuRoot.jsx +9 -0
- package/dist/source/menu/submenu/MenuSubmenu.d.ts +22 -0
- package/dist/source/menu/submenu/MenuSubmenu.jsx +10 -0
- package/dist/source/menu/submenu-trigger/MenuSubmenuTrigger.d.ts +14 -0
- package/dist/source/menu/submenu-trigger/MenuSubmenuTrigger.jsx +121 -0
- package/dist/source/menu/trigger/MenuTrigger.d.ts +13 -0
- package/dist/source/menu/trigger/MenuTrigger.jsx +73 -0
- package/dist/source/menubar/index.d.ts +1 -0
- package/dist/source/menubar/index.js +1 -0
- package/dist/source/menubar/index.parts.d.ts +13 -0
- package/dist/source/menubar/index.parts.js +14 -0
- package/dist/source/menubar/menu/MenubarMenu.d.ts +11 -0
- package/dist/source/menubar/menu/MenubarMenu.jsx +24 -0
- package/dist/source/menubar/root/MenubarContext.d.ts +30 -0
- package/dist/source/menubar/root/MenubarContext.js +12 -0
- package/dist/source/menubar/root/MenubarRoot.d.ts +11 -0
- package/dist/source/menubar/root/MenubarRoot.jsx +77 -0
- package/dist/source/menubar/trigger/MenubarTrigger.d.ts +11 -0
- package/dist/source/menubar/trigger/MenubarTrigger.jsx +78 -0
- package/dist/source/select/group/SelectGroup.d.ts +10 -0
- package/dist/source/select/group/SelectGroup.jsx +23 -0
- package/dist/source/select/group/SelectGroupContext.d.ts +10 -0
- package/dist/source/select/group/SelectGroupContext.js +12 -0
- package/dist/source/select/group-label/SelectGroupLabel.d.ts +10 -0
- package/dist/source/select/group-label/SelectGroupLabel.jsx +24 -0
- package/dist/source/select/index.d.ts +1 -0
- package/dist/source/select/index.js +1 -0
- package/dist/source/select/index.parts.d.ts +8 -0
- package/dist/source/select/index.parts.js +8 -0
- package/dist/source/select/item/SelectItem.d.ts +24 -0
- package/dist/source/select/item/SelectItem.jsx +92 -0
- package/dist/source/select/item/SelectItemContext.d.ts +11 -0
- package/dist/source/select/item/SelectItemContext.js +12 -0
- package/dist/source/select/item-indicator/SelectItemIndicator.d.ts +11 -0
- package/dist/source/select/item-indicator/SelectItemIndicator.jsx +16 -0
- package/dist/source/select/popup/SelectPopup.d.ts +32 -0
- package/dist/source/select/popup/SelectPopup.jsx +97 -0
- package/dist/source/select/root/SelectContext.d.ts +106 -0
- package/dist/source/select/root/SelectContext.js +119 -0
- package/dist/source/select/root/SelectRoot.d.ts +13 -0
- package/dist/source/select/root/SelectRoot.jsx +11 -0
- package/dist/source/select/trigger/SelectTrigger.d.ts +15 -0
- package/dist/source/select/trigger/SelectTrigger.jsx +181 -0
- package/dist/source/select/value/SelectValue.d.ts +20 -0
- package/dist/source/select/value/SelectValue.jsx +27 -0
- package/package.json +26 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { merge, onSettled } from "solid-js";
|
|
2
|
+
import { callHandler } from "../../core/mergeElementProps.js";
|
|
3
|
+
import { useMenuContext } from "../../menu/root/MenuContext.js";
|
|
4
|
+
import { MenuTrigger } from "../../menu/trigger/MenuTrigger.jsx";
|
|
5
|
+
import { useMenubarContext } from "../root/MenubarContext.js";
|
|
6
|
+
/**
|
|
7
|
+
* An item of the bar, which opens its menu: Menu's `<button type="button"
|
|
8
|
+
* aria-haspopup="menu">`, with the `menuitem` role and the bar's roving
|
|
9
|
+
* `tabindex`. Down Arrow, Enter and Space open the menu with focus on its
|
|
10
|
+
* first item, Up Arrow on its last. While a menu of the bar is open, moving
|
|
11
|
+
* to another item, by a key or the pointer, opens that item's menu instead.
|
|
12
|
+
* Place it inside `Menubar.Menu`, right before `Menubar.Popup`.
|
|
13
|
+
*/
|
|
14
|
+
export function MenubarTrigger(props) {
|
|
15
|
+
const bar = useMenubarContext();
|
|
16
|
+
const menu = useMenuContext();
|
|
17
|
+
// Its element is the menu's trigger, which Menu's Trigger sets.
|
|
18
|
+
const item = {
|
|
19
|
+
get element() {
|
|
20
|
+
return menu.trigger;
|
|
21
|
+
},
|
|
22
|
+
menu,
|
|
23
|
+
};
|
|
24
|
+
// Read once: the tab stop of the server HTML, and of the first render.
|
|
25
|
+
const first = bar.claimTabStop();
|
|
26
|
+
onSettled(() => bar.list.register(item));
|
|
27
|
+
return MenuTrigger(merge(props, {
|
|
28
|
+
role: "menuitem",
|
|
29
|
+
// The item that last had focus, else the first (README, "Decisions").
|
|
30
|
+
get tabindex() {
|
|
31
|
+
const stop = bar.list.active() ?? bar.list.items()[0];
|
|
32
|
+
return (stop ? stop === item : first) ? 0 : -1;
|
|
33
|
+
},
|
|
34
|
+
// Called here, not merged, so the consumer's handlers run too, first,
|
|
35
|
+
// as in a merge.
|
|
36
|
+
onFocus: (event) => {
|
|
37
|
+
callHandler(props.onFocus, event);
|
|
38
|
+
if (bar.list.active() !== item)
|
|
39
|
+
bar.list.move(item);
|
|
40
|
+
},
|
|
41
|
+
onKeyDown: (event) => {
|
|
42
|
+
callHandler(props.onKeyDown, event);
|
|
43
|
+
const open = bar.openMenu();
|
|
44
|
+
if (bar.typeahead.onKeyDown(event) || bar.list.onKeyDown(event)) {
|
|
45
|
+
bar.follow(open, { reason: "arrow-key", event });
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const { key } = event;
|
|
49
|
+
if (event.altKey || event.ctrlKey || event.metaKey || !menu.open())
|
|
50
|
+
return;
|
|
51
|
+
// Tab leaves the bar, and closes its menu.
|
|
52
|
+
if (key === "Tab")
|
|
53
|
+
menu.close({ reason: "focus-out", event });
|
|
54
|
+
// Enter and Space open the menu, which is open already: focus moves
|
|
55
|
+
// into it, where Menu's Trigger would close it.
|
|
56
|
+
if ((key === "Enter" || key === " ") && !event.shiftKey) {
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
menu.list.move(menu.list.items()[0]);
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
// While another menu of the bar is open, the pointer moving onto this
|
|
62
|
+
// item opens its menu. Only a pointer that moves counts, and no touch.
|
|
63
|
+
onPointerMove: (event) => {
|
|
64
|
+
callHandler(props.onPointerMove, event);
|
|
65
|
+
const open = bar.openMenu();
|
|
66
|
+
if (event.pointerType === "touch" || !open || open === menu)
|
|
67
|
+
return;
|
|
68
|
+
bar.moveTo(item, { reason: "trigger-hover", event });
|
|
69
|
+
// A press it was on its way to keeps the menu open (README,
|
|
70
|
+
// "Decisions").
|
|
71
|
+
menu.hoverOpened = true;
|
|
72
|
+
},
|
|
73
|
+
onPointerLeave: (event) => {
|
|
74
|
+
callHandler(props.onPointerLeave, event);
|
|
75
|
+
menu.hoverOpened = false;
|
|
76
|
+
},
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import type { RenderProp } from "../../core/renderElement.tsx";
|
|
3
|
+
export interface SelectGroupProps extends JSX.HTMLAttributes<HTMLElement> {
|
|
4
|
+
render?: RenderProp;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Items that belong together: a `<div role="group">` named by its
|
|
8
|
+
* `Select.GroupLabel`. Place it inside `Select.Popup`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function SelectGroup(props: SelectGroupProps): JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { omit } from "solid-js";
|
|
2
|
+
import { mergeElementProps } from "../../core/mergeElementProps.js";
|
|
3
|
+
import { renderElement } from "../../core/renderElement.jsx";
|
|
4
|
+
import { createIdSlot } from "../../core/slot.js";
|
|
5
|
+
import { SelectGroupContext } from "./SelectGroupContext.js";
|
|
6
|
+
/**
|
|
7
|
+
* Items that belong together: a `<div role="group">` named by its
|
|
8
|
+
* `Select.GroupLabel`. Place it inside `Select.Popup`.
|
|
9
|
+
*/
|
|
10
|
+
export function SelectGroup(props) {
|
|
11
|
+
const [labelId, registerLabelId] = createIdSlot();
|
|
12
|
+
const elementProps = mergeElementProps({
|
|
13
|
+
role: "group",
|
|
14
|
+
// The consumer's, else the GroupLabel's id, while one is rendered.
|
|
15
|
+
// Kept out of the merge ("`undefined` is a value", PLAN.md section 8).
|
|
16
|
+
get "aria-labelledby"() {
|
|
17
|
+
return props["aria-labelledby"] ?? labelId();
|
|
18
|
+
},
|
|
19
|
+
}, omit(props, "render", "aria-labelledby"));
|
|
20
|
+
return (<SelectGroupContext value={{ registerLabelId }}>
|
|
21
|
+
{renderElement(props, elementProps, (p) => (<div {...p}/>))}
|
|
22
|
+
</SelectGroupContext>);
|
|
23
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** What a group shares with its label. */
|
|
2
|
+
export interface SelectGroupContextValue {
|
|
3
|
+
/**
|
|
4
|
+
* Registers the `id` of a mounted GroupLabel, as a getter. Returns what
|
|
5
|
+
* unregisters it, for the label's disposal.
|
|
6
|
+
*/
|
|
7
|
+
registerLabelId(id: () => string | false): () => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const SelectGroupContext: import("solid-js").Context<SelectGroupContextValue | null>;
|
|
10
|
+
export declare function useSelectGroupContext(): SelectGroupContextValue;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext, useContext } from "solid-js";
|
|
2
|
+
import { isDev } from "@solidjs/web";
|
|
3
|
+
// `null` outside a group, so that the part can name what is missing.
|
|
4
|
+
export const SelectGroupContext = createContext(null);
|
|
5
|
+
export function useSelectGroupContext() {
|
|
6
|
+
const context = useContext(SelectGroupContext);
|
|
7
|
+
// Production builds drop the check, and its message, with `isDev`.
|
|
8
|
+
if (isDev && !context) {
|
|
9
|
+
throw new Error("[menhir] Select.GroupLabel must be placed within <Select.Group>.");
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import type { RenderProp } from "../../core/renderElement.tsx";
|
|
3
|
+
export interface SelectGroupLabelProps extends JSX.HTMLAttributes<HTMLElement> {
|
|
4
|
+
render?: RenderProp;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The label of a group, which names it in `aria-labelledby`: a `<div>`,
|
|
8
|
+
* not reached by the keys. Place it inside `Select.Group`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function SelectGroupLabel(props: SelectGroupLabelProps): JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { createUniqueId, omit, onSettled } from "solid-js";
|
|
2
|
+
import { mergeElementProps } from "../../core/mergeElementProps.js";
|
|
3
|
+
import { renderElement } from "../../core/renderElement.jsx";
|
|
4
|
+
import { useSelectGroupContext } from "../group/SelectGroupContext.js";
|
|
5
|
+
/**
|
|
6
|
+
* The label of a group, which names it in `aria-labelledby`: a `<div>`,
|
|
7
|
+
* not reached by the keys. Place it inside `Select.Group`.
|
|
8
|
+
*/
|
|
9
|
+
export function SelectGroupLabel(props) {
|
|
10
|
+
const group = useSelectGroupContext();
|
|
11
|
+
const generated = createUniqueId();
|
|
12
|
+
// The consumer's `id`, else the generated one. Kept out of the merge,
|
|
13
|
+
// where a wrapper's `id={undefined}` would remove it.
|
|
14
|
+
const id = () => props.id ?? generated;
|
|
15
|
+
// Named once mounted, so the group names only a label that is rendered,
|
|
16
|
+
// and none in the server HTML, as a popup's Title.
|
|
17
|
+
onSettled(() => group.registerLabelId(id));
|
|
18
|
+
const elementProps = mergeElementProps({
|
|
19
|
+
get id() {
|
|
20
|
+
return id();
|
|
21
|
+
},
|
|
22
|
+
}, omit(props, "render", "id"));
|
|
23
|
+
return renderElement(props, elementProps, (p) => <div {...p}/>);
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Select from "./index.parts.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Select from "./index.parts.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { SelectRoot as Root } from "./root/SelectRoot.tsx";
|
|
2
|
+
export { SelectTrigger as Trigger } from "./trigger/SelectTrigger.tsx";
|
|
3
|
+
export { SelectValue as Value } from "./value/SelectValue.tsx";
|
|
4
|
+
export { SelectPopup as Popup } from "./popup/SelectPopup.tsx";
|
|
5
|
+
export { SelectItem as Item } from "./item/SelectItem.tsx";
|
|
6
|
+
export { SelectItemIndicator as ItemIndicator } from "./item-indicator/SelectItemIndicator.tsx";
|
|
7
|
+
export { SelectGroup as Group } from "./group/SelectGroup.tsx";
|
|
8
|
+
export { SelectGroupLabel as GroupLabel } from "./group-label/SelectGroupLabel.tsx";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { SelectRoot as Root } from "./root/SelectRoot.jsx";
|
|
2
|
+
export { SelectTrigger as Trigger } from "./trigger/SelectTrigger.jsx";
|
|
3
|
+
export { SelectValue as Value } from "./value/SelectValue.jsx";
|
|
4
|
+
export { SelectPopup as Popup } from "./popup/SelectPopup.jsx";
|
|
5
|
+
export { SelectItem as Item } from "./item/SelectItem.jsx";
|
|
6
|
+
export { SelectItemIndicator as ItemIndicator } from "./item-indicator/SelectItemIndicator.jsx";
|
|
7
|
+
export { SelectGroup as Group } from "./group/SelectGroup.jsx";
|
|
8
|
+
export { SelectGroupLabel as GroupLabel } from "./group-label/SelectGroupLabel.jsx";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import type { RenderProp } from "../../core/renderElement.tsx";
|
|
3
|
+
export interface SelectItemProps extends JSX.HTMLAttributes<HTMLElement> {
|
|
4
|
+
/** What the Select's value is while this item is selected. Not `""`. */
|
|
5
|
+
value: string;
|
|
6
|
+
/**
|
|
7
|
+
* Whether the item is disabled: still reached by the keys and the
|
|
8
|
+
* pointer, but not selected.
|
|
9
|
+
*/
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* The item's text, when its content is not its label, such as an icon
|
|
13
|
+
* beside it: what typeahead matches and `Select.Value` shows.
|
|
14
|
+
*/
|
|
15
|
+
label?: string;
|
|
16
|
+
render?: RenderProp;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A value to select: a `<div role="option">` with `aria-selected`. A click
|
|
20
|
+
* selects it and closes the list, and so do Enter, Space and Tab while it
|
|
21
|
+
* is the active item; a disabled item is not selected. Place it inside
|
|
22
|
+
* `Select.Popup`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function SelectItem(props: SelectItemProps): JSX.Element;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { createUniqueId, merge, omit, onSettled } from "solid-js";
|
|
2
|
+
import { mergeElementProps } from "../../core/mergeElementProps.js";
|
|
3
|
+
import { renderElement } from "../../core/renderElement.jsx";
|
|
4
|
+
import { useSelectContext } from "../root/SelectContext.js";
|
|
5
|
+
import { SelectItemContext } from "./SelectItemContext.js";
|
|
6
|
+
/**
|
|
7
|
+
* A value to select: a `<div role="option">` with `aria-selected`. A click
|
|
8
|
+
* selects it and closes the list, and so do Enter, Space and Tab while it
|
|
9
|
+
* is the active item; a disabled item is not selected. Place it inside
|
|
10
|
+
* `Select.Popup`.
|
|
11
|
+
*/
|
|
12
|
+
export function SelectItem(props) {
|
|
13
|
+
const select = useSelectContext();
|
|
14
|
+
let element;
|
|
15
|
+
const generated = createUniqueId();
|
|
16
|
+
// The consumer's `id`, else the generated one, which the Trigger names
|
|
17
|
+
// while the item is active, so `false` does not remove it. Kept out of
|
|
18
|
+
// the merge ("`undefined` is a value", PLAN.md section 8).
|
|
19
|
+
const id = () => props.id || generated;
|
|
20
|
+
const item = {
|
|
21
|
+
get element() {
|
|
22
|
+
return element;
|
|
23
|
+
},
|
|
24
|
+
get id() {
|
|
25
|
+
return id();
|
|
26
|
+
},
|
|
27
|
+
get text() {
|
|
28
|
+
return props.label ?? labelOf(element);
|
|
29
|
+
},
|
|
30
|
+
get value() {
|
|
31
|
+
return props.value;
|
|
32
|
+
},
|
|
33
|
+
get disabled() {
|
|
34
|
+
return props.disabled;
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
onSettled(() => select.list.register(item));
|
|
38
|
+
const selected = () => select.value() === props.value;
|
|
39
|
+
const attributes = {
|
|
40
|
+
get "data-selected"() {
|
|
41
|
+
return selected() ? "" : undefined;
|
|
42
|
+
},
|
|
43
|
+
get "data-unselected"() {
|
|
44
|
+
return selected() ? undefined : "";
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
const ownProps = merge(attributes, {
|
|
48
|
+
role: "option",
|
|
49
|
+
get id() {
|
|
50
|
+
return id();
|
|
51
|
+
},
|
|
52
|
+
// Solid 2.0 removes an attribute set to false, so spell the value out.
|
|
53
|
+
get "aria-selected"() {
|
|
54
|
+
return selected() ? "true" : "false";
|
|
55
|
+
},
|
|
56
|
+
get "data-active"() {
|
|
57
|
+
return select.isActive(item) ? "" : undefined;
|
|
58
|
+
},
|
|
59
|
+
get "aria-disabled"() {
|
|
60
|
+
return props.disabled ? "true" : undefined;
|
|
61
|
+
},
|
|
62
|
+
get "data-disabled"() {
|
|
63
|
+
return props.disabled ? "" : undefined;
|
|
64
|
+
},
|
|
65
|
+
onPointerMove: (event) => select.list.onPointerMove(item, event),
|
|
66
|
+
onClick: (event) => {
|
|
67
|
+
if (select.select(item))
|
|
68
|
+
select.setOpen(false, { reason: "item-press", event });
|
|
69
|
+
},
|
|
70
|
+
ref: (el) => {
|
|
71
|
+
element = el;
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
const elementProps = mergeElementProps(ownProps, omit(props, "render", "value", "disabled", "label", "id"));
|
|
75
|
+
return (<SelectItemContext value={attributes}>
|
|
76
|
+
{renderElement(props, elementProps, (p) => (<div {...p}/>))}
|
|
77
|
+
</SelectItemContext>);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* An item's own text: its text content without what is `aria-hidden`, such
|
|
81
|
+
* as its ItemIndicator's check mark, which is no part of its name either.
|
|
82
|
+
*/
|
|
83
|
+
function labelOf(node) {
|
|
84
|
+
let text = "";
|
|
85
|
+
for (const child of node.childNodes) {
|
|
86
|
+
if (child.nodeType === 3)
|
|
87
|
+
text += child.nodeValue;
|
|
88
|
+
else if (child.getAttribute?.("aria-hidden") !== "true")
|
|
89
|
+
text += labelOf(child);
|
|
90
|
+
}
|
|
91
|
+
return text;
|
|
92
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether an item is selected, as `data-*` attributes, each `""` when it
|
|
3
|
+
* applies and absent otherwise: what the item and its
|
|
4
|
+
* `Select.ItemIndicator` carry.
|
|
5
|
+
*/
|
|
6
|
+
export type SelectItemAttributes = {
|
|
7
|
+
readonly "data-selected": "" | undefined;
|
|
8
|
+
readonly "data-unselected": "" | undefined;
|
|
9
|
+
};
|
|
10
|
+
export declare const SelectItemContext: import("solid-js").Context<SelectItemAttributes | null>;
|
|
11
|
+
export declare function useSelectItemContext(): SelectItemAttributes;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createContext, useContext } from "solid-js";
|
|
2
|
+
import { isDev } from "@solidjs/web";
|
|
3
|
+
// `null` outside an Item, so that the part can say so.
|
|
4
|
+
export const SelectItemContext = createContext(null);
|
|
5
|
+
export function useSelectItemContext() {
|
|
6
|
+
const context = useContext(SelectItemContext);
|
|
7
|
+
// Production builds drop the check, and its message, with `isDev`.
|
|
8
|
+
if (isDev && !context) {
|
|
9
|
+
throw new Error("[menhir] Select.ItemIndicator must be placed within <Select.Item>.");
|
|
10
|
+
}
|
|
11
|
+
return context;
|
|
12
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import type { RenderProp } from "../../core/renderElement.tsx";
|
|
3
|
+
export interface SelectItemIndicatorProps extends JSX.HTMLAttributes<HTMLElement> {
|
|
4
|
+
render?: RenderProp;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The check mark of an item: an `aria-hidden` `<span>` with its item's
|
|
8
|
+
* `data-selected` or `data-unselected`, always rendered, so that CSS shows
|
|
9
|
+
* it by state. Place it inside `Select.Item`.
|
|
10
|
+
*/
|
|
11
|
+
export declare function SelectItemIndicator(props: SelectItemIndicatorProps): JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { merge, omit } from "solid-js";
|
|
2
|
+
import { mergeElementProps } from "../../core/mergeElementProps.js";
|
|
3
|
+
import { renderElement } from "../../core/renderElement.jsx";
|
|
4
|
+
import { useSelectItemContext } from "../item/SelectItemContext.js";
|
|
5
|
+
/**
|
|
6
|
+
* The check mark of an item: an `aria-hidden` `<span>` with its item's
|
|
7
|
+
* `data-selected` or `data-unselected`, always rendered, so that CSS shows
|
|
8
|
+
* it by state. Place it inside `Select.Item`.
|
|
9
|
+
*/
|
|
10
|
+
export function SelectItemIndicator(props) {
|
|
11
|
+
const ownProps = merge(useSelectItemContext(), {
|
|
12
|
+
"aria-hidden": "true",
|
|
13
|
+
});
|
|
14
|
+
const elementProps = mergeElementProps(ownProps, omit(props, "render"));
|
|
15
|
+
return renderElement(props, elementProps, (p) => <span {...p}/>);
|
|
16
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { JSX } from "@solidjs/web";
|
|
2
|
+
import type { RenderProp } from "../../core/renderElement.tsx";
|
|
3
|
+
import type { Align, Side, VirtualElement } from "../../floating/positioning/createPosition.ts";
|
|
4
|
+
/** What the Popup is placed against: an element, or a virtual one. */
|
|
5
|
+
export type SelectAnchor = Element | VirtualElement;
|
|
6
|
+
export interface SelectPopupProps extends Omit<JSX.HTMLAttributes<HTMLElement>, "id"> {
|
|
7
|
+
/** The side of the anchor it is placed against. Default `"bottom"`. */
|
|
8
|
+
side?: Side;
|
|
9
|
+
/** Where along that side, following the writing direction. Default `"start"`. */
|
|
10
|
+
align?: Align;
|
|
11
|
+
/** The gap from the anchor, in pixels. Default 0. */
|
|
12
|
+
sideOffset?: number;
|
|
13
|
+
/** The shift along the anchor's side, in pixels. Default 0. */
|
|
14
|
+
alignOffset?: number;
|
|
15
|
+
/** The space kept from the viewport's edges, in pixels. Default 5. */
|
|
16
|
+
collisionPadding?: number;
|
|
17
|
+
/**
|
|
18
|
+
* What it is placed against instead of the Trigger: an element, a virtual
|
|
19
|
+
* element, or a function returning one.
|
|
20
|
+
*/
|
|
21
|
+
anchor?: SelectAnchor | (() => SelectAnchor | undefined);
|
|
22
|
+
render?: RenderProp;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The list itself: a `<div popover="auto" role="listbox">` in the top
|
|
26
|
+
* layer, placed against the Trigger and labelled by it. It takes no focus:
|
|
27
|
+
* the Trigger keeps it. Escape, a press outside, Tab and selecting an item
|
|
28
|
+
* close it. Its CSS variables `--anchor-width` and `--available-height`
|
|
29
|
+
* are for its `min-width` and `max-height`. Place it inside `Select.Root`,
|
|
30
|
+
* right after `Select.Trigger`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function SelectPopup(props: SelectPopupProps): JSX.Element;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { createEffect, merge, omit } from "solid-js";
|
|
2
|
+
import { mergeElementProps } from "../../core/mergeElementProps.js";
|
|
3
|
+
import { renderElement } from "../../core/renderElement.jsx";
|
|
4
|
+
import { createPopoverClose } from "../../floating/dismissal/popoverClose.js";
|
|
5
|
+
import { createPosition } from "../../floating/positioning/createPosition.js";
|
|
6
|
+
import { flip } from "../../floating/positioning/flip.js";
|
|
7
|
+
import { offset } from "../../floating/positioning/offset.js";
|
|
8
|
+
import { shift } from "../../floating/positioning/shift.js";
|
|
9
|
+
import { size } from "../../floating/positioning/size.js";
|
|
10
|
+
import { createPresence } from "../../floating/presence/presence.js";
|
|
11
|
+
import { useSelectContext } from "../root/SelectContext.js";
|
|
12
|
+
/**
|
|
13
|
+
* The list itself: a `<div popover="auto" role="listbox">` in the top
|
|
14
|
+
* layer, placed against the Trigger and labelled by it. It takes no focus:
|
|
15
|
+
* the Trigger keeps it. Escape, a press outside, Tab and selecting an item
|
|
16
|
+
* close it. Its CSS variables `--anchor-width` and `--available-height`
|
|
17
|
+
* are for its `min-width` and `max-height`. Place it inside `Select.Root`,
|
|
18
|
+
* right after `Select.Trigger`.
|
|
19
|
+
*/
|
|
20
|
+
export function SelectPopup(props) {
|
|
21
|
+
const select = useSelectContext();
|
|
22
|
+
let popup;
|
|
23
|
+
const options = {
|
|
24
|
+
get popup() {
|
|
25
|
+
return popup;
|
|
26
|
+
},
|
|
27
|
+
get trigger() {
|
|
28
|
+
return select.trigger;
|
|
29
|
+
},
|
|
30
|
+
get open() {
|
|
31
|
+
return select.open();
|
|
32
|
+
},
|
|
33
|
+
onDismiss: (details) => select.setOpen(false, details),
|
|
34
|
+
};
|
|
35
|
+
// Presence first: the popover is shown before it is placed.
|
|
36
|
+
createPresence(options);
|
|
37
|
+
createPopoverClose(options);
|
|
38
|
+
// The item the list opens on is scrolled into view, as list navigation
|
|
39
|
+
// scrolls one the keys move to: once the popover is shown, after its own
|
|
40
|
+
// `showPopover()` in this flush, whichever effect runs first.
|
|
41
|
+
createEffect(() => select.initial(), (item) => {
|
|
42
|
+
if (item)
|
|
43
|
+
queueMicrotask(() => item.element.scrollIntoView({ block: "nearest" }));
|
|
44
|
+
});
|
|
45
|
+
createPosition({
|
|
46
|
+
get anchor() {
|
|
47
|
+
const anchor = props.anchor;
|
|
48
|
+
return ((typeof anchor === "function" ? anchor() : anchor) ?? select.trigger);
|
|
49
|
+
},
|
|
50
|
+
get popup() {
|
|
51
|
+
return popup;
|
|
52
|
+
},
|
|
53
|
+
get open() {
|
|
54
|
+
return select.open();
|
|
55
|
+
},
|
|
56
|
+
get side() {
|
|
57
|
+
return props.side ?? "bottom";
|
|
58
|
+
},
|
|
59
|
+
get align() {
|
|
60
|
+
return props.align ?? "start";
|
|
61
|
+
},
|
|
62
|
+
get middleware() {
|
|
63
|
+
const padding = props.collisionPadding ?? 5;
|
|
64
|
+
return [
|
|
65
|
+
offset({
|
|
66
|
+
mainAxis: props.sideOffset ?? 0,
|
|
67
|
+
alignmentAxis: props.alignOffset ?? 0,
|
|
68
|
+
}),
|
|
69
|
+
flip({ padding }),
|
|
70
|
+
shift({ padding }),
|
|
71
|
+
// A list is often longer than the space beside its Trigger.
|
|
72
|
+
size({ padding }),
|
|
73
|
+
];
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
const ownProps = merge(select.attributes, {
|
|
77
|
+
id: select.popupId,
|
|
78
|
+
popover: "auto",
|
|
79
|
+
role: "listbox",
|
|
80
|
+
// The consumer's, else the Trigger's id. Kept out of the merge, where a
|
|
81
|
+
// wrapper's `aria-labelledby={undefined}` would remove the Trigger's
|
|
82
|
+
// ("`undefined` is a value", PLAN.md section 8).
|
|
83
|
+
get "aria-labelledby"() {
|
|
84
|
+
return props["aria-labelledby"] ?? select.triggerId();
|
|
85
|
+
},
|
|
86
|
+
// A press in the list would take focus from the Trigger, which holds
|
|
87
|
+
// it for the keys.
|
|
88
|
+
onMouseDown: (event) => event.preventDefault(),
|
|
89
|
+
ref: (element) => {
|
|
90
|
+
popup = element;
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
const elementProps = mergeElementProps(ownProps, omit(props, "render", "side", "align", "sideOffset", "alignOffset", "collisionPadding", "anchor", "aria-labelledby",
|
|
94
|
+
// Kept out, as typed: a stray one would break `popovertarget`.
|
|
95
|
+
"id"));
|
|
96
|
+
return renderElement(props, elementProps, (p) => <div {...p}/>);
|
|
97
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { OpenChangeDetails } from "../../floating/dismissal/reason.ts";
|
|
2
|
+
import type { ActiveDescendantItem, ActiveDescendantList } from "../../floating/list-navigation/activeDescendant.ts";
|
|
3
|
+
import type { Typeahead } from "../../floating/typeahead/typeahead.ts";
|
|
4
|
+
/**
|
|
5
|
+
* A select's state as `data-*` attributes, each `""` when it applies and
|
|
6
|
+
* absent otherwise: one of `data-open` and `data-closed`, `data-disabled`
|
|
7
|
+
* and `data-required`.
|
|
8
|
+
*/
|
|
9
|
+
export type SelectStateAttributes = {
|
|
10
|
+
readonly "data-open": "" | undefined;
|
|
11
|
+
readonly "data-closed": "" | undefined;
|
|
12
|
+
readonly "data-disabled": "" | undefined;
|
|
13
|
+
readonly "data-required": "" | undefined;
|
|
14
|
+
};
|
|
15
|
+
/** An item of a select, as its list navigation knows it. */
|
|
16
|
+
export interface SelectItemEntry extends ActiveDescendantItem {
|
|
17
|
+
/** What the Select's value is while this item is selected. */
|
|
18
|
+
readonly value: string;
|
|
19
|
+
/** Whether the item is disabled: reached, but not selected. */
|
|
20
|
+
readonly disabled?: boolean;
|
|
21
|
+
}
|
|
22
|
+
/** The props of `Select.Root`, less its children. */
|
|
23
|
+
export interface SelectStateProps {
|
|
24
|
+
/** The selected item's `value`, or `null` for none, when controlled. */
|
|
25
|
+
value?: string | null;
|
|
26
|
+
/** The item selected at first, when uncontrolled. */
|
|
27
|
+
defaultValue?: string | null;
|
|
28
|
+
/**
|
|
29
|
+
* Called with the new value when the user selects an item, the browser
|
|
30
|
+
* fills one in, or its form is reset. When controlled, the selection
|
|
31
|
+
* changes only if `value` does.
|
|
32
|
+
*/
|
|
33
|
+
onValueChange?: (value: string | null) => void;
|
|
34
|
+
/** Whether the list is open, when controlled. */
|
|
35
|
+
open?: boolean;
|
|
36
|
+
/** Whether the list is open at first, when uncontrolled. */
|
|
37
|
+
defaultOpen?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Called with the new value, and why, when the user opens or closes the
|
|
40
|
+
* list. When controlled, the list changes only if `open` does.
|
|
41
|
+
*/
|
|
42
|
+
onOpenChange?: (open: boolean, details: OpenChangeDetails) => void;
|
|
43
|
+
/** Submitted with the form, as the hidden input's `name`. */
|
|
44
|
+
name?: string;
|
|
45
|
+
/** The `id` of the form the Select belongs to, when it is not inside it. */
|
|
46
|
+
form?: string;
|
|
47
|
+
/** Whether the form can be submitted only once an item is selected. */
|
|
48
|
+
required?: boolean;
|
|
49
|
+
/** Whether the Select ignores the user. It cannot be focused either. */
|
|
50
|
+
disabled?: boolean;
|
|
51
|
+
/** What the browser may fill in, as the hidden input's `autocomplete`. */
|
|
52
|
+
autocomplete?: string;
|
|
53
|
+
}
|
|
54
|
+
/** What `Select.Root` shares with its parts through context. */
|
|
55
|
+
export interface Select {
|
|
56
|
+
/** Whether the list is open. */
|
|
57
|
+
open(): boolean;
|
|
58
|
+
/** Asks to open or close the list, saying why. */
|
|
59
|
+
setOpen(open: boolean, details: OpenChangeDetails): void;
|
|
60
|
+
/** The selected item's `value`, or `null`. */
|
|
61
|
+
value(): string | null;
|
|
62
|
+
/** Asks for a value, as the hidden input's `change` and a reset do. */
|
|
63
|
+
setValue(value: string | null): void;
|
|
64
|
+
/**
|
|
65
|
+
* Selects `item` through the hidden input, which fires `input` and
|
|
66
|
+
* `change` for the form. A disabled item, and the item already selected,
|
|
67
|
+
* change nothing. Returns whether the item can be selected.
|
|
68
|
+
*/
|
|
69
|
+
select(item: SelectItemEntry | undefined): boolean;
|
|
70
|
+
/** The selected item, once it has mounted. */
|
|
71
|
+
selectedItem(): SelectItemEntry | undefined;
|
|
72
|
+
/**
|
|
73
|
+
* The active item: the one the keys or the pointer moved to, else, while
|
|
74
|
+
* the list is open, the selected item, else the first. The Trigger names
|
|
75
|
+
* it only while the list is open.
|
|
76
|
+
*/
|
|
77
|
+
active(): SelectItemEntry | undefined;
|
|
78
|
+
/** Whether `item` is the active one of an open list, for its `data-active`. */
|
|
79
|
+
isActive(item: SelectItemEntry): boolean;
|
|
80
|
+
/**
|
|
81
|
+
* The item a list just opened starts on, until a key or the pointer
|
|
82
|
+
* moves: the selected item, else the first.
|
|
83
|
+
*/
|
|
84
|
+
initial(): SelectItemEntry | undefined;
|
|
85
|
+
readonly list: ActiveDescendantList<SelectItemEntry>;
|
|
86
|
+
readonly typeahead: Typeahead;
|
|
87
|
+
/**
|
|
88
|
+
* The Popup's `id`, which the Trigger names in `popovertarget` and
|
|
89
|
+
* `aria-controls` before the Popup is rendered.
|
|
90
|
+
*/
|
|
91
|
+
readonly popupId: string;
|
|
92
|
+
/** The Trigger's `id`, which labels the Popup; set by the Trigger. */
|
|
93
|
+
triggerId(): string | false | undefined;
|
|
94
|
+
/** The Trigger's element, once rendered: the anchor by default. */
|
|
95
|
+
trigger: HTMLElement | undefined;
|
|
96
|
+
/** The hidden input, once rendered: the form's view of the value. */
|
|
97
|
+
input: HTMLInputElement | undefined;
|
|
98
|
+
/** The `data-*` attributes of the Trigger and the Popup. */
|
|
99
|
+
readonly attributes: SelectStateAttributes;
|
|
100
|
+
/** The Root's props, for the Trigger's button and hidden input. */
|
|
101
|
+
readonly props: SelectStateProps;
|
|
102
|
+
}
|
|
103
|
+
/** Creates a select's state, its list navigation and its typeahead. */
|
|
104
|
+
export declare function createSelect(props: SelectStateProps): Select;
|
|
105
|
+
export declare const SelectContext: import("solid-js").Context<Select | null>;
|
|
106
|
+
export declare function useSelectContext(): Select;
|