@funstack/ui 0.1.0-alpha.1 → 0.1.0-alpha.2
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/dist/combobox/combobox-clear.d.mts +34 -0
- package/dist/combobox/combobox-clear.d.mts.map +1 -0
- package/dist/combobox/combobox-clear.mjs +58 -0
- package/dist/combobox/combobox-clear.mjs.map +1 -0
- package/dist/combobox/combobox-context.mjs +23 -0
- package/dist/combobox/combobox-context.mjs.map +1 -0
- package/dist/combobox/combobox-group.d.mts +72 -0
- package/dist/combobox/combobox-group.d.mts.map +1 -0
- package/dist/combobox/combobox-group.mjs +104 -0
- package/dist/combobox/combobox-group.mjs.map +1 -0
- package/dist/combobox/combobox-input.d.mts +40 -0
- package/dist/combobox/combobox-input.d.mts.map +1 -0
- package/dist/combobox/combobox-input.mjs +88 -0
- package/dist/combobox/combobox-input.mjs.map +1 -0
- package/dist/combobox/combobox-label.d.mts +22 -0
- package/dist/combobox/combobox-label.d.mts.map +1 -0
- package/dist/combobox/combobox-label.mjs +32 -0
- package/dist/combobox/combobox-label.mjs.map +1 -0
- package/dist/combobox/combobox-list.d.mts +37 -0
- package/dist/combobox/combobox-list.d.mts.map +1 -0
- package/dist/combobox/combobox-list.mjs +70 -0
- package/dist/combobox/combobox-list.mjs.map +1 -0
- package/dist/combobox/combobox-option.d.mts +45 -0
- package/dist/combobox/combobox-option.d.mts.map +1 -0
- package/dist/combobox/combobox-option.mjs +88 -0
- package/dist/combobox/combobox-option.mjs.map +1 -0
- package/dist/combobox/combobox-popup.d.mts +49 -0
- package/dist/combobox/combobox-popup.d.mts.map +1 -0
- package/dist/combobox/combobox-popup.mjs +86 -0
- package/dist/combobox/combobox-popup.mjs.map +1 -0
- package/dist/combobox/combobox-root.d.mts +135 -0
- package/dist/combobox/combobox-root.d.mts.map +1 -0
- package/dist/combobox/combobox-root.mjs +508 -0
- package/dist/combobox/combobox-root.mjs.map +1 -0
- package/dist/combobox/combobox-trigger.d.mts +36 -0
- package/dist/combobox/combobox-trigger.d.mts.map +1 -0
- package/dist/combobox/combobox-trigger.mjs +92 -0
- package/dist/combobox/combobox-trigger.mjs.map +1 -0
- package/dist/combobox/index.d.mts +36 -0
- package/dist/combobox/index.d.mts.map +1 -0
- package/dist/combobox/index.mjs +36 -0
- package/dist/combobox/index.mjs.map +1 -0
- package/dist/index.d.mts +20 -2
- package/dist/index.mjs +3 -1
- package/dist/internal/platform-attributes.d.mts +12 -1
- package/dist/internal/platform-attributes.d.mts.map +1 -1
- package/dist/internal/types.d.mts +8 -0
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-controllable-action.mjs +5 -1
- package/dist/internal/use-controllable-action.mjs.map +1 -1
- package/dist/internal/use-form-reset.mjs +5 -1
- package/dist/internal/use-form-reset.mjs.map +1 -1
- package/dist/internal/use-hydrated-mount.mjs +21 -0
- package/dist/internal/use-hydrated-mount.mjs.map +1 -0
- package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
- package/dist/internal/use-native-select-value.mjs +182 -0
- package/dist/internal/use-native-select-value.mjs.map +1 -0
- package/dist/select/index.d.mts +30 -0
- package/dist/select/index.d.mts.map +1 -0
- package/dist/select/index.mjs +30 -0
- package/dist/select/index.mjs.map +1 -0
- package/dist/select/select-context.mjs +13 -0
- package/dist/select/select-context.mjs.map +1 -0
- package/dist/select/select-dom.mjs +44 -0
- package/dist/select/select-dom.mjs.map +1 -0
- package/dist/select/select-group-label.d.mts +22 -0
- package/dist/select/select-group-label.d.mts.map +1 -0
- package/dist/select/select-group-label.mjs +39 -0
- package/dist/select/select-group-label.mjs.map +1 -0
- package/dist/select/select-group.d.mts +28 -0
- package/dist/select/select-group.d.mts.map +1 -0
- package/dist/select/select-group.mjs +45 -0
- package/dist/select/select-group.mjs.map +1 -0
- package/dist/select/select-option.d.mts +42 -0
- package/dist/select/select-option.d.mts.map +1 -0
- package/dist/select/select-option.mjs +65 -0
- package/dist/select/select-option.mjs.map +1 -0
- package/dist/select/select-root.d.mts +66 -0
- package/dist/select/select-root.d.mts.map +1 -0
- package/dist/select/select-root.mjs +94 -0
- package/dist/select/select-root.mjs.map +1 -0
- package/dist/select/select-separator.d.mts +20 -0
- package/dist/select/select-separator.d.mts.map +1 -0
- package/dist/select/select-separator.mjs +30 -0
- package/dist/select/select-separator.mjs.map +1 -0
- package/dist/select/select-trigger.d.mts +29 -0
- package/dist/select/select-trigger.d.mts.map +1 -0
- package/dist/select/select-trigger.mjs +48 -0
- package/dist/select/select-trigger.mjs.map +1 -0
- package/dist/select/select-value.d.mts +31 -0
- package/dist/select/select-value.d.mts.map +1 -0
- package/dist/select/select-value.mjs +101 -0
- package/dist/select/select-value.mjs.map +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
|
+
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
3
|
+
//#region src/combobox/combobox-clear.d.ts
|
|
4
|
+
export interface ComboboxClearState {
|
|
5
|
+
/** Optimistic selection. */
|
|
6
|
+
readonly value: string | null;
|
|
7
|
+
readonly inputValue: string;
|
|
8
|
+
readonly disabled: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface ComboboxClearProps extends Omit<ComponentPropsWithRef<"button">, "onClick" | "onPointerDown" | "onMouseDown" | "tabIndex" | "disabled" | "className" | "style" | "children"> {
|
|
11
|
+
/** Disables this button; the Root's `disabled` does too. */
|
|
12
|
+
disabled?: boolean;
|
|
13
|
+
className?: StateValue<string | undefined, ComboboxClearState>;
|
|
14
|
+
style?: StateValue<CSSProperties | undefined, ComboboxClearState>;
|
|
15
|
+
children?: StateValue<ReactNode, ComboboxClearState>;
|
|
16
|
+
/** Should render a `<button>`. */
|
|
17
|
+
render?: RenderProp<ComponentPropsWithRef<"button">, ComboboxClearState>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* The optional button that clears the combobox: `<button type="button" tabindex="-1">`. A click
|
|
21
|
+
* empties the text (urgent) and dispatches `valueChangeAction(null)` unless nothing is selected;
|
|
22
|
+
* the input keeps focus. Always rendered: hide it with CSS (`:placeholder-shown`) or `state`.
|
|
23
|
+
* A click while the listbox is open closes it (the platform's light dismiss: the button is
|
|
24
|
+
* outside the popup).
|
|
25
|
+
*
|
|
26
|
+
* Owned keys: `type` (on a `<button>`), `tabIndex`, `disabled`, `onClick`, `onPointerDown`,
|
|
27
|
+
* `onMouseDown`, `data-disabled`.
|
|
28
|
+
*/
|
|
29
|
+
export declare function ComboboxClear({ disabled: ownDisabled, className, style, children, render, ...rest }: ComboboxClearProps): ReactNode;
|
|
30
|
+
export declare namespace ComboboxClear {
|
|
31
|
+
var displayName: string;
|
|
32
|
+
}
|
|
33
|
+
//#endregion
|
|
34
|
+
//# sourceMappingURL=combobox-clear.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox-clear.d.mts","names":[],"sources":["../../src/combobox/combobox-clear.tsx"],"mappings":";;;iBAeiB;;WAEN;WACA;WACA;;iBAGM,2BAA2B,KAC1C;;EAWA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,iCAAiC;;;;;;;;;;;;wBAavC,gBACd,UAAU,aACV,WACA,OACA,UACA,WACG,QACF,qBAAkB;yBAPL"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { dataAttr } from "../internal/data-attr.mjs";
|
|
3
|
+
import { rendersButton, useRender } from "../internal/use-render.mjs";
|
|
4
|
+
import { useComboboxContext } from "./combobox-context.mjs";
|
|
5
|
+
import { useNameWarning } from "./combobox-trigger.mjs";
|
|
6
|
+
//#region src/combobox/combobox-clear.tsx
|
|
7
|
+
/**
|
|
8
|
+
* The optional button that clears the combobox: `<button type="button" tabindex="-1">`. A click
|
|
9
|
+
* empties the text (urgent) and dispatches `valueChangeAction(null)` unless nothing is selected;
|
|
10
|
+
* the input keeps focus. Always rendered: hide it with CSS (`:placeholder-shown`) or `state`.
|
|
11
|
+
* A click while the listbox is open closes it (the platform's light dismiss: the button is
|
|
12
|
+
* outside the popup).
|
|
13
|
+
*
|
|
14
|
+
* Owned keys: `type` (on a `<button>`), `tabIndex`, `disabled`, `onClick`, `onPointerDown`,
|
|
15
|
+
* `onMouseDown`, `data-disabled`.
|
|
16
|
+
*/
|
|
17
|
+
function ComboboxClear({ disabled: ownDisabled = false, className, style, children, render, ...rest }) {
|
|
18
|
+
const ctx = useComboboxContext("Combobox.Clear");
|
|
19
|
+
const disabled = ownDisabled || ctx.disabled;
|
|
20
|
+
const ref = useNameWarning("Combobox.Clear");
|
|
21
|
+
const state = {
|
|
22
|
+
value: ctx.value,
|
|
23
|
+
inputValue: ctx.inputValue,
|
|
24
|
+
disabled
|
|
25
|
+
};
|
|
26
|
+
const libraryProps = {
|
|
27
|
+
...rendersButton(render) && { type: "button" },
|
|
28
|
+
tabIndex: -1,
|
|
29
|
+
disabled,
|
|
30
|
+
onPointerDown: (event) => {
|
|
31
|
+
event.preventDefault();
|
|
32
|
+
},
|
|
33
|
+
onMouseDown: (event) => {
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
},
|
|
36
|
+
onClick: (event) => {
|
|
37
|
+
if (disabled) return;
|
|
38
|
+
ctx.clear(event.nativeEvent);
|
|
39
|
+
},
|
|
40
|
+
"data-disabled": dataAttr(disabled)
|
|
41
|
+
};
|
|
42
|
+
return useRender({
|
|
43
|
+
defaultElement: "button",
|
|
44
|
+
render,
|
|
45
|
+
state,
|
|
46
|
+
className,
|
|
47
|
+
style,
|
|
48
|
+
children,
|
|
49
|
+
props: rest,
|
|
50
|
+
libraryProps,
|
|
51
|
+
ref
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
ComboboxClear.displayName = "ComboboxClear";
|
|
55
|
+
//#endregion
|
|
56
|
+
export { ComboboxClear };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=combobox-clear.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox-clear.mjs","names":[],"sources":["../../src/combobox/combobox-clear.tsx"],"sourcesContent":["\"use client\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n ReactNode,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { rendersButton, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { useComboboxContext } from \"./combobox-context.js\";\nimport { useNameWarning } from \"./combobox-trigger.js\";\n\nexport interface ComboboxClearState {\n /** Optimistic selection. */\n readonly value: string | null;\n readonly inputValue: string;\n readonly disabled: boolean;\n}\n\nexport interface ComboboxClearProps extends Omit<\n ComponentPropsWithRef<\"button\">,\n | \"onClick\"\n | \"onPointerDown\"\n | \"onMouseDown\"\n | \"tabIndex\"\n | \"disabled\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /** Disables this button; the Root's `disabled` does too. */\n disabled?: boolean;\n className?: StateValue<string | undefined, ComboboxClearState>;\n style?: StateValue<CSSProperties | undefined, ComboboxClearState>;\n children?: StateValue<ReactNode, ComboboxClearState>;\n /** Should render a `<button>`. */\n render?: RenderProp<ComponentPropsWithRef<\"button\">, ComboboxClearState>;\n}\n\n/**\n * The optional button that clears the combobox: `<button type=\"button\" tabindex=\"-1\">`. A click\n * empties the text (urgent) and dispatches `valueChangeAction(null)` unless nothing is selected;\n * the input keeps focus. Always rendered: hide it with CSS (`:placeholder-shown`) or `state`.\n * A click while the listbox is open closes it (the platform's light dismiss: the button is\n * outside the popup).\n *\n * Owned keys: `type` (on a `<button>`), `tabIndex`, `disabled`, `onClick`, `onPointerDown`,\n * `onMouseDown`, `data-disabled`.\n */\nexport function ComboboxClear({\n disabled: ownDisabled = false,\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxClearProps) {\n const ctx = useComboboxContext(\"Combobox.Clear\");\n const disabled = ownDisabled || ctx.disabled;\n const ref = useNameWarning(\"Combobox.Clear\");\n const state: ComboboxClearState = { value: ctx.value, inputValue: ctx.inputValue, disabled };\n\n const libraryProps: ComponentPropsWithRef<\"button\"> & DataAttributes = {\n ...(rendersButton(render) && { type: \"button\" as const }),\n tabIndex: -1,\n disabled,\n onPointerDown: (event: PointerEvent<HTMLButtonElement>) => {\n event.preventDefault();\n },\n onMouseDown: (event: MouseEvent<HTMLButtonElement>) => {\n event.preventDefault();\n },\n onClick: (event: MouseEvent<HTMLButtonElement>) => {\n if (disabled) return;\n ctx.clear(event.nativeEvent);\n },\n \"data-disabled\": dataAttr(disabled),\n };\n\n return useRender<ComponentPropsWithRef<\"button\">, ComboboxClearState>({\n defaultElement: \"button\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n libraryProps,\n ref,\n });\n}\n\nComboboxClear.displayName = \"ComboboxClear\";\n"],"mappings":";;;;;;;;;;;;;;;;AAoDA,SAAgB,cAAc,EAC5B,UAAU,cAAc,OACxB,WACA,OACA,UACA,QACA,GAAG,QACkB;CACrB,MAAM,MAAM,mBAAmB,gBAAgB;CAC/C,MAAM,WAAW,eAAe,IAAI;CACpC,MAAM,MAAM,eAAe,gBAAgB;CAC3C,MAAM,QAA4B;EAAE,OAAO,IAAI;EAAO,YAAY,IAAI;EAAY;CAAS;CAE3F,MAAM,eAAiE;EACrE,GAAI,cAAc,MAAM,KAAK,EAAE,MAAM,SAAkB;EACvD,UAAU;EACV;EACA,gBAAgB,UAA2C;GACzD,MAAM,eAAe;EACvB;EACA,cAAc,UAAyC;GACrD,MAAM,eAAe;EACvB;EACA,UAAU,UAAyC;GACjD,IAAI,UAAU;GACd,IAAI,MAAM,MAAM,WAAW;EAC7B;EACA,iBAAiB,SAAS,QAAQ;CACpC;CAEA,OAAO,UAA+D;EACpE,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;EACP;EACA;CACF,CAAC;AACH;AAEA,cAAc,cAAc"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, use } from "react";
|
|
3
|
+
//#region src/combobox/combobox-context.ts
|
|
4
|
+
const ComboboxContext = createContext(null);
|
|
5
|
+
function useComboboxContext(part) {
|
|
6
|
+
const context = use(ComboboxContext);
|
|
7
|
+
if (context === null) throw new Error(`${part} must be rendered inside a Combobox.Root.`);
|
|
8
|
+
return context;
|
|
9
|
+
}
|
|
10
|
+
/** Provided by `Combobox.Popup` (a List outside a Popup warns). */
|
|
11
|
+
const ComboboxPopupContext = createContext(false);
|
|
12
|
+
/** Provided by `Combobox.List` (an Option outside a List warns). */
|
|
13
|
+
const ComboboxListContext = createContext(false);
|
|
14
|
+
/** `Combobox.Group`: the id its `Combobox.GroupLabel` renders. */
|
|
15
|
+
const ComboboxGroupContext = createContext(null);
|
|
16
|
+
/** The id fragment of an option value: stable across result sets, no whitespace (design 3.5). */
|
|
17
|
+
function optionId(prefix, value) {
|
|
18
|
+
return `${prefix}${encodeURIComponent(value)}`;
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ComboboxContext, ComboboxGroupContext, ComboboxListContext, ComboboxPopupContext, optionId, useComboboxContext };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=combobox-context.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox-context.mjs","names":[],"sources":["../../src/combobox/combobox-context.ts"],"sourcesContent":["\"use client\";\nimport { createContext, use } from \"react\";\nimport type { RefObject } from \"react\";\nimport type { PopoverRootValue } from \"../internal/use-popover-root.js\";\n\n/** What a mounted `Combobox.Option` tells its Root (design 2, \"mounted options, labels\"). */\nexport interface ComboboxOptionEntry {\n readonly element: HTMLElement;\n /** The `label` prop; `undefined`: the element's trimmed `textContent` at the moment of use. */\n readonly label: string | undefined;\n readonly disabled: boolean;\n}\n\n/** One Combobox: what its Root provides to every part (design 14, `combobox-context.ts`). */\nexport interface ComboboxContextValue {\n /** The shared popover machinery (`usePopoverRoot`, library mode). */\n readonly popover: PopoverRootValue;\n readonly ids: {\n readonly input: string;\n readonly label: string;\n readonly list: string;\n /** `${root}-option-`: an Option's id is this plus `encodeURIComponent(value)`. */\n readonly optionPrefix: string;\n };\n /** Optimistic selection. */\n readonly value: string | null;\n /** The `valueChangeAction` transition is in flight. */\n readonly valuePending: boolean;\n /** `valuePending` or the open transition is in flight (the Root's `pending`). */\n readonly pending: boolean;\n /** The urgent text. */\n readonly inputValue: string;\n /** `useDeferredValue(inputValue)`: what the mounted results are for. */\n readonly query: string;\n readonly stale: boolean;\n /** The option `aria-activedescendant` points at (urgent virtual focus), or `null`. */\n readonly activeValue: string | null;\n /** No option is mounted and the results are settled (`Empty`, `data-empty`). */\n readonly empty: boolean;\n /** A `Combobox.Status` is mounted inside the List (a Suspense fallback): results are loading. */\n readonly loading: boolean;\n /** A `Combobox.Label` is mounted (the List's `aria-labelledby` names it only then). */\n readonly hasLabel: boolean;\n readonly disabled: boolean;\n readonly inputRef: RefObject<HTMLInputElement | null>;\n readonly listRef: RefObject<HTMLElement | null>;\n /** Registers a mounted Option; returns the unregistration. */\n readonly registerOption: (value: string, entry: ComboboxOptionEntry) => () => void;\n /** Registers a mounted `Combobox.Status`; while one is mounted the results count as loading. */\n readonly registerStatus: () => () => void;\n /** Registers a mounted `Combobox.Label`; returns the unregistration. */\n readonly registerLabel: () => () => void;\n /** Make `value` the active option (urgent; never dispatches). */\n readonly setActive: (value: string | null) => void;\n /** Accept an option (design 5.2): urgent text write, dispatch, close when it settles. */\n readonly accept: (value: string, event: Event) => void;\n /** `Combobox.Clear` (design 3.3). */\n readonly clear: (event: Event) => void;\n /** The `change` of the Input: urgent text write and an open request (design 2.2, 5.1). */\n readonly typed: (text: string, event: Event) => void;\n /** Keyboard model of design section 8, run by the Input's `onKeyDown`. */\n readonly keyDown: (event: KeyboardEvent) => boolean;\n /** Focus left the Input (design 5.4): close at once, then revert or commit free text. */\n readonly focusOut: (event: FocusEvent) => void;\n /** A pointer click in the Input (`openOnClick`). */\n readonly inputClick: (event: MouseEvent) => void;\n}\n\nexport const ComboboxContext = createContext<ComboboxContextValue | null>(null);\n\nexport function useComboboxContext(part: string): ComboboxContextValue {\n const context = use(ComboboxContext);\n if (context === null) {\n throw new Error(`${part} must be rendered inside a Combobox.Root.`);\n }\n return context;\n}\n\n/** Provided by `Combobox.Popup` (a List outside a Popup warns). */\nexport const ComboboxPopupContext = createContext<boolean>(false);\n\n/** Provided by `Combobox.List` (an Option outside a List warns). */\nexport const ComboboxListContext = createContext<boolean>(false);\n\n/** `Combobox.Group`: the id its `Combobox.GroupLabel` renders. */\nexport const ComboboxGroupContext = createContext<string | null>(null);\n\n/** The id fragment of an option value: stable across result sets, no whitespace (design 3.5). */\nexport function optionId(prefix: string, value: string): string {\n return `${prefix}${encodeURIComponent(value)}`;\n}\n"],"mappings":";;;AAoEA,MAAa,kBAAkB,cAA2C,IAAI;AAE9E,SAAgB,mBAAmB,MAAoC;CACrE,MAAM,UAAU,IAAI,eAAe;CACnC,IAAI,YAAY,MACd,MAAM,IAAI,MAAM,GAAG,KAAK,0CAA0C;CAEpE,OAAO;AACT;;AAGA,MAAa,uBAAuB,cAAuB,KAAK;;AAGhE,MAAa,sBAAsB,cAAuB,KAAK;;AAG/D,MAAa,uBAAuB,cAA6B,IAAI;;AAGrE,SAAgB,SAAS,QAAgB,OAAuB;CAC9D,OAAO,GAAG,SAAS,mBAAmB,KAAK;AAC7C"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
|
+
import { ComboboxListState } from "./combobox-list.mjs";
|
|
3
|
+
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
4
|
+
//#region src/combobox/combobox-group.d.ts
|
|
5
|
+
/** `Combobox.Group`, `Combobox.GroupLabel` and `Combobox.Status` have no state of their own. */
|
|
6
|
+
export type ComboboxGroupState = Record<string, never>;
|
|
7
|
+
export type ComboboxGroupLabelState = Record<string, never>;
|
|
8
|
+
export type ComboboxStatusState = Record<string, never>;
|
|
9
|
+
/** `Combobox.Empty` renders from the List's state. */
|
|
10
|
+
export type ComboboxEmptyState = ComboboxListState;
|
|
11
|
+
export interface ComboboxGroupProps extends Omit<ComponentPropsWithRef<"div">, "role" | "className" | "style" | "children"> {
|
|
12
|
+
className?: StateValue<string | undefined, ComboboxGroupState>;
|
|
13
|
+
style?: StateValue<CSSProperties | undefined, ComboboxGroupState>;
|
|
14
|
+
children?: StateValue<ReactNode, ComboboxGroupState>;
|
|
15
|
+
render?: RenderProp<ComponentPropsWithRef<"div">, ComboboxGroupState>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A labelled set of options: `<div role="group" aria-labelledby>` named by the
|
|
19
|
+
* `Combobox.GroupLabel` inside it. Owned keys: `role`, `aria-labelledby` (token-merged).
|
|
20
|
+
*/
|
|
21
|
+
export declare function ComboboxGroup({ className, style, children, render, ...rest }: ComboboxGroupProps): import("react").JSX.Element;
|
|
22
|
+
export declare namespace ComboboxGroup {
|
|
23
|
+
var displayName: string;
|
|
24
|
+
}
|
|
25
|
+
export interface ComboboxGroupLabelProps extends Omit<ComponentPropsWithRef<"div">, "id" | "className" | "style" | "children"> {
|
|
26
|
+
className?: StateValue<string | undefined, ComboboxGroupLabelState>;
|
|
27
|
+
style?: StateValue<CSSProperties | undefined, ComboboxGroupLabelState>;
|
|
28
|
+
children?: StateValue<ReactNode, ComboboxGroupLabelState>;
|
|
29
|
+
render?: RenderProp<ComponentPropsWithRef<"div">, ComboboxGroupLabelState>;
|
|
30
|
+
}
|
|
31
|
+
/** The name of the enclosing `Combobox.Group`: a `<div>` with the referenced id. Owned key: `id`. */
|
|
32
|
+
export declare function ComboboxGroupLabel({ className, style, children, render, ...rest }: ComboboxGroupLabelProps): ReactNode;
|
|
33
|
+
export declare namespace ComboboxGroupLabel {
|
|
34
|
+
var displayName: string;
|
|
35
|
+
}
|
|
36
|
+
export interface ComboboxEmptyProps extends Omit<ComponentPropsWithRef<"div">, "className" | "style" | "children"> {
|
|
37
|
+
className?: StateValue<string | undefined, ComboboxEmptyState>;
|
|
38
|
+
style?: StateValue<CSSProperties | undefined, ComboboxEmptyState>;
|
|
39
|
+
children?: StateValue<ReactNode, ComboboxEmptyState>;
|
|
40
|
+
render?: RenderProp<ComponentPropsWithRef<"div">, ComboboxEmptyState>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* "No results": renders a `<div>` with its children only when the List has **no mounted
|
|
44
|
+
* options, the results are not stale and none are loading** (no `Combobox.Status` mounted inside
|
|
45
|
+
* the List, i.e. no Suspense fallback showing); nothing otherwise (design 6.3). Place it in the
|
|
46
|
+
* Popup, outside the List (a listbox holds only options). Owns no keys.
|
|
47
|
+
*/
|
|
48
|
+
export declare function ComboboxEmpty({ className, style, children, render, ...rest }: ComboboxEmptyProps): ReactNode;
|
|
49
|
+
export declare namespace ComboboxEmpty {
|
|
50
|
+
var displayName: string;
|
|
51
|
+
}
|
|
52
|
+
export interface ComboboxStatusProps extends Omit<ComponentPropsWithRef<"div">, "role" | "className" | "style" | "children"> {
|
|
53
|
+
className?: StateValue<string | undefined, ComboboxStatusState>;
|
|
54
|
+
style?: StateValue<CSSProperties | undefined, ComboboxStatusState>;
|
|
55
|
+
children?: StateValue<ReactNode, ComboboxStatusState>;
|
|
56
|
+
render?: RenderProp<ComponentPropsWithRef<"div">, ComboboxStatusState>;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* A loading row or a hint. Rendered **inside the List** (the usual Suspense fallback,
|
|
60
|
+
* `<Suspense fallback={<Combobox.Status>Searching…</Combobox.Status>}>`), it marks the results
|
|
61
|
+
* as loading: `<div role="none">` (a listbox owns only options and groups, and a live region
|
|
62
|
+
* there would talk over the count; the List is `aria-busy` instead), `Empty` stays hidden and
|
|
63
|
+
* nothing is announced while it is mounted. Rendered in the Popup outside the List it is a plain
|
|
64
|
+
* hint, `<div role="status">`. No live-region work of its own either way (the result count is
|
|
65
|
+
* announced with `ariaNotify`). Owned key: `role`.
|
|
66
|
+
*/
|
|
67
|
+
export declare function ComboboxStatus({ className, style, children, render, ...rest }: ComboboxStatusProps): ReactNode;
|
|
68
|
+
export declare namespace ComboboxStatus {
|
|
69
|
+
var displayName: string;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//# sourceMappingURL=combobox-group.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox-group.d.mts","names":[],"sources":["../../src/combobox/combobox-group.tsx"],"mappings":";;;;;YAcY,qBAAqB;YACrB,0BAA0B;YAC1B,sBAAsB;;YAEtB,qBAAqB;iBAIhB,2BAA2B,KAC1C;EAGA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;wBAOpC,gBAAgB,WAAW,OAAO,UAAU,WAAW,QAAQ,qCAAkB,IAAA;yBAAjF;;;iBAkBC,gCAAgC,KAC/C;EAGA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;wBAIpC,qBACd,WACA,OACA,UACA,WACG,QACF,0BAAuB;yBANV;;;iBA0BC,2BAA2B,KAC1C;EAGA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;;;wBASpC,gBAAgB,WAAW,OAAO,UAAU,WAAW,QAAQ,qBAAkB;yBAAjF;;;iBAiBC,4BAA4B,KAC3C;EAGA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;wBAYpC,iBACd,WACA,OACA,UACA,WACG,QACF,sBAAmB;yBANN"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRender } from "../internal/use-render.mjs";
|
|
3
|
+
import { useDevWarning } from "../internal/use-dev-warning.mjs";
|
|
4
|
+
import { ComboboxGroupContext, ComboboxListContext, useComboboxContext } from "./combobox-context.mjs";
|
|
5
|
+
import { use, useId, useLayoutEffect } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
//#region src/combobox/combobox-group.tsx
|
|
8
|
+
const EMPTY = {};
|
|
9
|
+
/**
|
|
10
|
+
* A labelled set of options: `<div role="group" aria-labelledby>` named by the
|
|
11
|
+
* `Combobox.GroupLabel` inside it. Owned keys: `role`, `aria-labelledby` (token-merged).
|
|
12
|
+
*/
|
|
13
|
+
function ComboboxGroup({ className, style, children, render, ...rest }) {
|
|
14
|
+
useComboboxContext("Combobox.Group");
|
|
15
|
+
const labelId = `${useId()}-label`;
|
|
16
|
+
const element = useRender({
|
|
17
|
+
defaultElement: "div",
|
|
18
|
+
render,
|
|
19
|
+
state: EMPTY,
|
|
20
|
+
className,
|
|
21
|
+
style,
|
|
22
|
+
children,
|
|
23
|
+
props: rest,
|
|
24
|
+
libraryProps: {
|
|
25
|
+
role: "group",
|
|
26
|
+
"aria-labelledby": labelId
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
return /* @__PURE__ */ jsx(ComboboxGroupContext, {
|
|
30
|
+
value: labelId,
|
|
31
|
+
children: element
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
ComboboxGroup.displayName = "ComboboxGroup";
|
|
35
|
+
/** The name of the enclosing `Combobox.Group`: a `<div>` with the referenced id. Owned key: `id`. */
|
|
36
|
+
function ComboboxGroupLabel({ className, style, children, render, ...rest }) {
|
|
37
|
+
const labelId = use(ComboboxGroupContext);
|
|
38
|
+
useDevWarning(labelId === null, "Combobox.GroupLabel: rendered outside a Combobox.Group; it names nothing.");
|
|
39
|
+
return useRender({
|
|
40
|
+
defaultElement: "div",
|
|
41
|
+
render,
|
|
42
|
+
state: EMPTY,
|
|
43
|
+
className,
|
|
44
|
+
style,
|
|
45
|
+
children,
|
|
46
|
+
props: rest,
|
|
47
|
+
libraryProps: labelId === null ? {} : { id: labelId }
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
ComboboxGroupLabel.displayName = "ComboboxGroupLabel";
|
|
51
|
+
/**
|
|
52
|
+
* "No results": renders a `<div>` with its children only when the List has **no mounted
|
|
53
|
+
* options, the results are not stale and none are loading** (no `Combobox.Status` mounted inside
|
|
54
|
+
* the List, i.e. no Suspense fallback showing); nothing otherwise (design 6.3). Place it in the
|
|
55
|
+
* Popup, outside the List (a listbox holds only options). Owns no keys.
|
|
56
|
+
*/
|
|
57
|
+
function ComboboxEmpty({ className, style, children, render, ...rest }) {
|
|
58
|
+
const ctx = useComboboxContext("Combobox.Empty");
|
|
59
|
+
const state = {
|
|
60
|
+
query: ctx.query,
|
|
61
|
+
stale: ctx.stale,
|
|
62
|
+
empty: ctx.empty
|
|
63
|
+
};
|
|
64
|
+
const element = useRender({
|
|
65
|
+
defaultElement: "div",
|
|
66
|
+
render,
|
|
67
|
+
state,
|
|
68
|
+
className,
|
|
69
|
+
style,
|
|
70
|
+
children,
|
|
71
|
+
props: rest
|
|
72
|
+
});
|
|
73
|
+
return ctx.empty ? element : null;
|
|
74
|
+
}
|
|
75
|
+
ComboboxEmpty.displayName = "ComboboxEmpty";
|
|
76
|
+
/**
|
|
77
|
+
* A loading row or a hint. Rendered **inside the List** (the usual Suspense fallback,
|
|
78
|
+
* `<Suspense fallback={<Combobox.Status>Searching…</Combobox.Status>}>`), it marks the results
|
|
79
|
+
* as loading: `<div role="none">` (a listbox owns only options and groups, and a live region
|
|
80
|
+
* there would talk over the count; the List is `aria-busy` instead), `Empty` stays hidden and
|
|
81
|
+
* nothing is announced while it is mounted. Rendered in the Popup outside the List it is a plain
|
|
82
|
+
* hint, `<div role="status">`. No live-region work of its own either way (the result count is
|
|
83
|
+
* announced with `ariaNotify`). Owned key: `role`.
|
|
84
|
+
*/
|
|
85
|
+
function ComboboxStatus({ className, style, children, render, ...rest }) {
|
|
86
|
+
const { registerStatus } = useComboboxContext("Combobox.Status");
|
|
87
|
+
const inList = use(ComboboxListContext);
|
|
88
|
+
useLayoutEffect(() => inList ? registerStatus() : void 0, [inList, registerStatus]);
|
|
89
|
+
return useRender({
|
|
90
|
+
defaultElement: "div",
|
|
91
|
+
render,
|
|
92
|
+
state: EMPTY,
|
|
93
|
+
className,
|
|
94
|
+
style,
|
|
95
|
+
children,
|
|
96
|
+
props: rest,
|
|
97
|
+
libraryProps: { role: inList ? "none" : "status" }
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
ComboboxStatus.displayName = "ComboboxStatus";
|
|
101
|
+
//#endregion
|
|
102
|
+
export { ComboboxEmpty, ComboboxGroup, ComboboxGroupLabel, ComboboxStatus };
|
|
103
|
+
|
|
104
|
+
//# sourceMappingURL=combobox-group.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox-group.mjs","names":[],"sources":["../../src/combobox/combobox-group.tsx"],"sourcesContent":["\"use client\";\nimport { use, useId, useLayoutEffect } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useDevWarning } from \"../internal/use-dev-warning.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport {\n ComboboxGroupContext,\n ComboboxListContext,\n useComboboxContext,\n} from \"./combobox-context.js\";\nimport type { ComboboxListState } from \"./combobox-list.js\";\n\n/** `Combobox.Group`, `Combobox.GroupLabel` and `Combobox.Status` have no state of their own. */\nexport type ComboboxGroupState = Record<string, never>;\nexport type ComboboxGroupLabelState = Record<string, never>;\nexport type ComboboxStatusState = Record<string, never>;\n/** `Combobox.Empty` renders from the List's state. */\nexport type ComboboxEmptyState = ComboboxListState;\n\nconst EMPTY: Record<string, never> = {};\n\nexport interface ComboboxGroupProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"role\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, ComboboxGroupState>;\n style?: StateValue<CSSProperties | undefined, ComboboxGroupState>;\n children?: StateValue<ReactNode, ComboboxGroupState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxGroupState>;\n}\n\n/**\n * A labelled set of options: `<div role=\"group\" aria-labelledby>` named by the\n * `Combobox.GroupLabel` inside it. Owned keys: `role`, `aria-labelledby` (token-merged).\n */\nexport function ComboboxGroup({ className, style, children, render, ...rest }: ComboboxGroupProps) {\n useComboboxContext(\"Combobox.Group\");\n const labelId = `${useId()}-label`;\n const element = useRender<ComponentPropsWithRef<\"div\">, ComboboxGroupState>({\n defaultElement: \"div\",\n render,\n state: EMPTY,\n className,\n style,\n children,\n props: rest,\n libraryProps: { role: \"group\", \"aria-labelledby\": labelId },\n });\n return <ComboboxGroupContext value={labelId}>{element}</ComboboxGroupContext>;\n}\n\nComboboxGroup.displayName = \"ComboboxGroup\";\n\nexport interface ComboboxGroupLabelProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"id\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, ComboboxGroupLabelState>;\n style?: StateValue<CSSProperties | undefined, ComboboxGroupLabelState>;\n children?: StateValue<ReactNode, ComboboxGroupLabelState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxGroupLabelState>;\n}\n\n/** The name of the enclosing `Combobox.Group`: a `<div>` with the referenced id. Owned key: `id`. */\nexport function ComboboxGroupLabel({\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxGroupLabelProps) {\n const labelId = use(ComboboxGroupContext);\n useDevWarning(\n labelId === null,\n \"Combobox.GroupLabel: rendered outside a Combobox.Group; it names nothing.\",\n );\n return useRender<ComponentPropsWithRef<\"div\">, ComboboxGroupLabelState>({\n defaultElement: \"div\",\n render,\n state: EMPTY,\n className,\n style,\n children,\n props: rest,\n libraryProps: labelId === null ? {} : { id: labelId },\n });\n}\n\nComboboxGroupLabel.displayName = \"ComboboxGroupLabel\";\n\nexport interface ComboboxEmptyProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, ComboboxEmptyState>;\n style?: StateValue<CSSProperties | undefined, ComboboxEmptyState>;\n children?: StateValue<ReactNode, ComboboxEmptyState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxEmptyState>;\n}\n\n/**\n * \"No results\": renders a `<div>` with its children only when the List has **no mounted\n * options, the results are not stale and none are loading** (no `Combobox.Status` mounted inside\n * the List, i.e. no Suspense fallback showing); nothing otherwise (design 6.3). Place it in the\n * Popup, outside the List (a listbox holds only options). Owns no keys.\n */\nexport function ComboboxEmpty({ className, style, children, render, ...rest }: ComboboxEmptyProps) {\n const ctx = useComboboxContext(\"Combobox.Empty\");\n const state: ComboboxEmptyState = { query: ctx.query, stale: ctx.stale, empty: ctx.empty };\n const element = useRender<ComponentPropsWithRef<\"div\">, ComboboxEmptyState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n style,\n children,\n props: rest,\n });\n return ctx.empty ? element : null;\n}\n\nComboboxEmpty.displayName = \"ComboboxEmpty\";\n\nexport interface ComboboxStatusProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n \"role\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, ComboboxStatusState>;\n style?: StateValue<CSSProperties | undefined, ComboboxStatusState>;\n children?: StateValue<ReactNode, ComboboxStatusState>;\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxStatusState>;\n}\n\n/**\n * A loading row or a hint. Rendered **inside the List** (the usual Suspense fallback,\n * `<Suspense fallback={<Combobox.Status>Searching…</Combobox.Status>}>`), it marks the results\n * as loading: `<div role=\"none\">` (a listbox owns only options and groups, and a live region\n * there would talk over the count; the List is `aria-busy` instead), `Empty` stays hidden and\n * nothing is announced while it is mounted. Rendered in the Popup outside the List it is a plain\n * hint, `<div role=\"status\">`. No live-region work of its own either way (the result count is\n * announced with `ariaNotify`). Owned key: `role`.\n */\nexport function ComboboxStatus({\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxStatusProps) {\n const { registerStatus } = useComboboxContext(\"Combobox.Status\");\n const inList = use(ComboboxListContext);\n useLayoutEffect(() => (inList ? registerStatus() : undefined), [inList, registerStatus]);\n return useRender<ComponentPropsWithRef<\"div\">, ComboboxStatusState>({\n defaultElement: \"div\",\n render,\n state: EMPTY,\n className,\n style,\n children,\n props: rest,\n libraryProps: { role: inList ? \"none\" : \"status\" },\n });\n}\n\nComboboxStatus.displayName = \"ComboboxStatus\";\n"],"mappings":";;;;;;;AAoBA,MAAM,QAA+B,CAAC;;;;;AAgBtC,SAAgB,cAAc,EAAE,WAAW,OAAO,UAAU,QAAQ,GAAG,QAA4B;CACjG,mBAAmB,gBAAgB;CACnC,MAAM,UAAU,GAAG,MAAM,EAAE;CAC3B,MAAM,UAAU,UAA4D;EAC1E,gBAAgB;EAChB;EACA,OAAO;EACP;EACA;EACA;EACA,OAAO;EACP,cAAc;GAAE,MAAM;GAAS,mBAAmB;EAAQ;CAC5D,CAAC;CACD,OAAO,oBAAC,sBAAD;EAAsB,OAAO;EAAU,UAAA;CAA8B,CAAA;AAC9E;AAEA,cAAc,cAAc;;AAa5B,SAAgB,mBAAmB,EACjC,WACA,OACA,UACA,QACA,GAAG,QACuB;CAC1B,MAAM,UAAU,IAAI,oBAAoB;CACxC,cACE,YAAY,MACZ,2EACF;CACA,OAAO,UAAiE;EACtE,gBAAgB;EAChB;EACA,OAAO;EACP;EACA;EACA;EACA,OAAO;EACP,cAAc,YAAY,OAAO,CAAC,IAAI,EAAE,IAAI,QAAQ;CACtD,CAAC;AACH;AAEA,mBAAmB,cAAc;;;;;;;AAkBjC,SAAgB,cAAc,EAAE,WAAW,OAAO,UAAU,QAAQ,GAAG,QAA4B;CACjG,MAAM,MAAM,mBAAmB,gBAAgB;CAC/C,MAAM,QAA4B;EAAE,OAAO,IAAI;EAAO,OAAO,IAAI;EAAO,OAAO,IAAI;CAAM;CACzF,MAAM,UAAU,UAA4D;EAC1E,gBAAgB;EAChB;EACA;EACA;EACA;EACA;EACA,OAAO;CACT,CAAC;CACD,OAAO,IAAI,QAAQ,UAAU;AAC/B;AAEA,cAAc,cAAc;;;;;;;;;;AAqB5B,SAAgB,eAAe,EAC7B,WACA,OACA,UACA,QACA,GAAG,QACmB;CACtB,MAAM,EAAE,mBAAmB,mBAAmB,iBAAiB;CAC/D,MAAM,SAAS,IAAI,mBAAmB;CACtC,sBAAuB,SAAS,eAAe,IAAI,KAAA,GAAY,CAAC,QAAQ,cAAc,CAAC;CACvF,OAAO,UAA6D;EAClE,gBAAgB;EAChB;EACA,OAAO;EACP;EACA;EACA;EACA,OAAO;EACP,cAAc,EAAE,MAAM,SAAS,SAAS,SAAS;CACnD,CAAC;AACH;AAEA,eAAe,cAAc"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
|
+
import { CSSProperties, ComponentPropsWithRef } from "react";
|
|
3
|
+
//#region src/combobox/combobox-input.d.ts
|
|
4
|
+
export interface ComboboxInputState {
|
|
5
|
+
/** Optimistic selection. */
|
|
6
|
+
readonly value: string | null;
|
|
7
|
+
/** The urgent text. */
|
|
8
|
+
readonly inputValue: string;
|
|
9
|
+
/** Optimistic open state. */
|
|
10
|
+
readonly open: boolean;
|
|
11
|
+
/** The Root is pending (a selection or an open in flight). */
|
|
12
|
+
readonly pending: boolean;
|
|
13
|
+
/** The results shown are for an older text. */
|
|
14
|
+
readonly stale: boolean;
|
|
15
|
+
readonly disabled: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface ComboboxInputProps extends Omit<ComponentPropsWithRef<"input">, "value" | "defaultValue" | "onChange" | "onInput" | "onKeyDown" | "onBlur" | "onClick" | "role" | "aria-autocomplete" | "aria-expanded" | "aria-controls" | "aria-activedescendant" | "autoComplete" | "disabled" | "className" | "style" | "children"> {
|
|
18
|
+
/** Native `required`: empty text is `valueMissing`. */
|
|
19
|
+
required?: boolean;
|
|
20
|
+
className?: StateValue<string | undefined, ComboboxInputState>;
|
|
21
|
+
style?: StateValue<CSSProperties | undefined, ComboboxInputState>;
|
|
22
|
+
/** Must render an `<input>` of type `text` or `search`. */
|
|
23
|
+
render?: RenderProp<ComponentPropsWithRef<"input">, ComboboxInputState>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The text field: `<input role="combobox" aria-autocomplete="list" aria-expanded aria-controls
|
|
27
|
+
* aria-activedescendant autocomplete="off">`. DOM focus stays here while the active option moves
|
|
28
|
+
* virtually (design 7.1). Its text is the Root's urgent `inputValue`; typing opens the listbox.
|
|
29
|
+
*
|
|
30
|
+
* Owned keys (conventions 1.2): `id`, `type`, `role`, `value`, `autoComplete`,
|
|
31
|
+
* `aria-autocomplete`, `aria-expanded`, `aria-controls` (token-merged), `aria-activedescendant`,
|
|
32
|
+
* `disabled`, `onChange`, `onKeyDown`, `onBlur`, `onClick`, `data-open`, `data-pending`,
|
|
33
|
+
* `data-selected`, `data-stale`, `data-disabled`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function ComboboxInput({ className, style, render, ...rest }: ComboboxInputProps): import("react").ReactNode;
|
|
36
|
+
export declare namespace ComboboxInput {
|
|
37
|
+
var displayName: string;
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
//# sourceMappingURL=combobox-input.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox-input.d.mts","names":[],"sources":["../../src/combobox/combobox-input.tsx"],"mappings":";;;iBAgBiB;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;WACA;;iBAGM,2BAA2B,KAC1C;;EAoBA;EACA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;EAE9C,SAAS,WAAW,gCAAgC;;;;;;;;;;;;wBAetC,gBAAgB,WAAW,OAAO,WAAW,QAAQ,qCAAkB;yBAAvE"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { dataAttr } from "../internal/data-attr.mjs";
|
|
3
|
+
import { useRender } from "../internal/use-render.mjs";
|
|
4
|
+
import { optionId, useComboboxContext } from "./combobox-context.mjs";
|
|
5
|
+
import { isValidElement, useCallback } from "react";
|
|
6
|
+
//#region src/combobox/combobox-input.tsx
|
|
7
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
8
|
+
/**
|
|
9
|
+
* The text field: `<input role="combobox" aria-autocomplete="list" aria-expanded aria-controls
|
|
10
|
+
* aria-activedescendant autocomplete="off">`. DOM focus stays here while the active option moves
|
|
11
|
+
* virtually (design 7.1). Its text is the Root's urgent `inputValue`; typing opens the listbox.
|
|
12
|
+
*
|
|
13
|
+
* Owned keys (conventions 1.2): `id`, `type`, `role`, `value`, `autoComplete`,
|
|
14
|
+
* `aria-autocomplete`, `aria-expanded`, `aria-controls` (token-merged), `aria-activedescendant`,
|
|
15
|
+
* `disabled`, `onChange`, `onKeyDown`, `onBlur`, `onClick`, `data-open`, `data-pending`,
|
|
16
|
+
* `data-selected`, `data-stale`, `data-disabled`.
|
|
17
|
+
*/
|
|
18
|
+
function ComboboxInput({ className, style, render, ...rest }) {
|
|
19
|
+
const ctx = useComboboxContext("Combobox.Input");
|
|
20
|
+
const { popover, ids, inputRef } = ctx;
|
|
21
|
+
const { triggerRef } = popover;
|
|
22
|
+
const state = {
|
|
23
|
+
value: ctx.value,
|
|
24
|
+
inputValue: ctx.inputValue,
|
|
25
|
+
open: popover.optimistic,
|
|
26
|
+
pending: ctx.pending,
|
|
27
|
+
stale: ctx.stale,
|
|
28
|
+
disabled: ctx.disabled
|
|
29
|
+
};
|
|
30
|
+
const ref = useCallback((element) => {
|
|
31
|
+
if (isDev) {
|
|
32
|
+
const type = element.tagName === "INPUT" ? element.type : "";
|
|
33
|
+
if (type !== "text" && type !== "search") console.error(`Combobox.Input: rendered <${element.tagName.toLowerCase()}${type === "" ? "" : ` type="${type}"`}>. Render an <input> of type "text" or "search": \`role="combobox"\`, \`aria-activedescendant\` and the caret keys depend on it.`);
|
|
34
|
+
}
|
|
35
|
+
inputRef.current = element;
|
|
36
|
+
triggerRef.current = element;
|
|
37
|
+
return () => {
|
|
38
|
+
if (inputRef.current === element) inputRef.current = null;
|
|
39
|
+
if (triggerRef.current === element) triggerRef.current = null;
|
|
40
|
+
};
|
|
41
|
+
}, [inputRef, triggerRef]);
|
|
42
|
+
const searchType = isValidElement(render) && render.props.type === "search";
|
|
43
|
+
const libraryProps = {
|
|
44
|
+
id: ids.input,
|
|
45
|
+
type: searchType ? "search" : "text",
|
|
46
|
+
role: "combobox",
|
|
47
|
+
value: ctx.inputValue,
|
|
48
|
+
autoComplete: "off",
|
|
49
|
+
"aria-autocomplete": "list",
|
|
50
|
+
"aria-expanded": popover.optimistic,
|
|
51
|
+
"aria-controls": ids.list,
|
|
52
|
+
"aria-activedescendant": ctx.activeValue === null ? void 0 : optionId(ids.optionPrefix, ctx.activeValue),
|
|
53
|
+
disabled: ctx.disabled,
|
|
54
|
+
onChange: (event) => {
|
|
55
|
+
ctx.typed(event.currentTarget.value, event.nativeEvent);
|
|
56
|
+
},
|
|
57
|
+
onKeyDown: (event) => {
|
|
58
|
+
ctx.keyDown(event.nativeEvent);
|
|
59
|
+
},
|
|
60
|
+
onBlur: (event) => {
|
|
61
|
+
ctx.focusOut(event.nativeEvent);
|
|
62
|
+
},
|
|
63
|
+
onClick: (event) => {
|
|
64
|
+
ctx.inputClick(event.nativeEvent);
|
|
65
|
+
},
|
|
66
|
+
"data-open": dataAttr(popover.optimistic),
|
|
67
|
+
"data-pending": dataAttr(state.pending),
|
|
68
|
+
"data-selected": dataAttr(ctx.value !== null),
|
|
69
|
+
"data-stale": dataAttr(ctx.stale),
|
|
70
|
+
"data-disabled": dataAttr(ctx.disabled)
|
|
71
|
+
};
|
|
72
|
+
return useRender({
|
|
73
|
+
defaultElement: "input",
|
|
74
|
+
render,
|
|
75
|
+
state,
|
|
76
|
+
className,
|
|
77
|
+
style,
|
|
78
|
+
children: void 0,
|
|
79
|
+
props: rest,
|
|
80
|
+
libraryProps,
|
|
81
|
+
ref
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
ComboboxInput.displayName = "ComboboxInput";
|
|
85
|
+
//#endregion
|
|
86
|
+
export { ComboboxInput };
|
|
87
|
+
|
|
88
|
+
//# sourceMappingURL=combobox-input.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox-input.mjs","names":[],"sources":["../../src/combobox/combobox-input.tsx"],"sourcesContent":["\"use client\";\nimport { isValidElement, useCallback } from \"react\";\nimport type {\n ChangeEvent,\n ComponentPropsWithRef,\n CSSProperties,\n FocusEvent,\n KeyboardEvent,\n MouseEvent,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { optionId, useComboboxContext } from \"./combobox-context.js\";\n\nexport interface ComboboxInputState {\n /** Optimistic selection. */\n readonly value: string | null;\n /** The urgent text. */\n readonly inputValue: string;\n /** Optimistic open state. */\n readonly open: boolean;\n /** The Root is pending (a selection or an open in flight). */\n readonly pending: boolean;\n /** The results shown are for an older text. */\n readonly stale: boolean;\n readonly disabled: boolean;\n}\n\nexport interface ComboboxInputProps extends Omit<\n ComponentPropsWithRef<\"input\">,\n | \"value\"\n | \"defaultValue\"\n | \"onChange\"\n | \"onInput\"\n | \"onKeyDown\"\n | \"onBlur\"\n | \"onClick\"\n | \"role\"\n | \"aria-autocomplete\"\n | \"aria-expanded\"\n | \"aria-controls\"\n | \"aria-activedescendant\"\n | \"autoComplete\"\n | \"disabled\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /** Native `required`: empty text is `valueMissing`. */\n required?: boolean;\n className?: StateValue<string | undefined, ComboboxInputState>;\n style?: StateValue<CSSProperties | undefined, ComboboxInputState>;\n /** Must render an `<input>` of type `text` or `search`. */\n render?: RenderProp<ComponentPropsWithRef<\"input\">, ComboboxInputState>;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\n/**\n * The text field: `<input role=\"combobox\" aria-autocomplete=\"list\" aria-expanded aria-controls\n * aria-activedescendant autocomplete=\"off\">`. DOM focus stays here while the active option moves\n * virtually (design 7.1). Its text is the Root's urgent `inputValue`; typing opens the listbox.\n *\n * Owned keys (conventions 1.2): `id`, `type`, `role`, `value`, `autoComplete`,\n * `aria-autocomplete`, `aria-expanded`, `aria-controls` (token-merged), `aria-activedescendant`,\n * `disabled`, `onChange`, `onKeyDown`, `onBlur`, `onClick`, `data-open`, `data-pending`,\n * `data-selected`, `data-stale`, `data-disabled`.\n */\nexport function ComboboxInput({ className, style, render, ...rest }: ComboboxInputProps) {\n const ctx = useComboboxContext(\"Combobox.Input\");\n const { popover, ids, inputRef } = ctx;\n const { triggerRef } = popover;\n\n const state: ComboboxInputState = {\n value: ctx.value,\n inputValue: ctx.inputValue,\n open: popover.optimistic,\n pending: ctx.pending,\n stale: ctx.stale,\n disabled: ctx.disabled,\n };\n\n const ref = useCallback(\n (element: HTMLElement) => {\n if (isDev) {\n const type = element.tagName === \"INPUT\" ? (element as HTMLInputElement).type : \"\";\n if (type !== \"text\" && type !== \"search\") {\n console.error(\n `Combobox.Input: rendered <${element.tagName.toLowerCase()}` +\n `${type === \"\" ? \"\" : ` type=\"${type}\"`}>. Render an <input> of type \"text\" or ` +\n '\"search\": `role=\"combobox\"`, `aria-activedescendant` and the caret keys depend on it.',\n );\n }\n }\n inputRef.current = element as HTMLInputElement;\n // The popover's \"trigger\" is the input: `showPopover({ source: input })` anchors the\n // listbox to it and makes clicks on it not light-dismiss (design 5.1).\n triggerRef.current = element;\n return () => {\n if (inputRef.current === element) inputRef.current = null;\n if (triggerRef.current === element) triggerRef.current = null;\n };\n },\n [inputRef, triggerRef],\n );\n\n const searchType = isValidElement<{ type?: unknown }>(render) && render.props.type === \"search\";\n\n const libraryProps: ComponentPropsWithRef<\"input\"> & DataAttributes = {\n id: ids.input,\n type: searchType ? \"search\" : \"text\",\n role: \"combobox\",\n value: ctx.inputValue,\n autoComplete: \"off\",\n \"aria-autocomplete\": \"list\",\n \"aria-expanded\": popover.optimistic,\n \"aria-controls\": ids.list,\n \"aria-activedescendant\":\n ctx.activeValue === null ? undefined : optionId(ids.optionPrefix, ctx.activeValue),\n disabled: ctx.disabled,\n onChange: (event: ChangeEvent<HTMLInputElement>) => {\n ctx.typed(event.currentTarget.value, event.nativeEvent);\n },\n onKeyDown: (event: KeyboardEvent<HTMLInputElement>) => {\n ctx.keyDown(event.nativeEvent);\n },\n onBlur: (event: FocusEvent<HTMLInputElement>) => {\n ctx.focusOut(event.nativeEvent);\n },\n onClick: (event: MouseEvent<HTMLInputElement>) => {\n ctx.inputClick(event.nativeEvent);\n },\n \"data-open\": dataAttr(popover.optimistic),\n \"data-pending\": dataAttr(state.pending),\n \"data-selected\": dataAttr(ctx.value !== null),\n \"data-stale\": dataAttr(ctx.stale),\n \"data-disabled\": dataAttr(ctx.disabled),\n };\n\n return useRender<ComponentPropsWithRef<\"input\">, ComboboxInputState>({\n defaultElement: \"input\",\n render,\n state,\n className,\n style,\n children: undefined,\n props: rest,\n libraryProps,\n ref,\n });\n}\n\nComboboxInput.displayName = \"ComboboxInput\";\n"],"mappings":";;;;;;AA0DA,MAAM,QAAQ,QAAQ,IAAI,aAAa;;;;;;;;;;;AAYvC,SAAgB,cAAc,EAAE,WAAW,OAAO,QAAQ,GAAG,QAA4B;CACvF,MAAM,MAAM,mBAAmB,gBAAgB;CAC/C,MAAM,EAAE,SAAS,KAAK,aAAa;CACnC,MAAM,EAAE,eAAe;CAEvB,MAAM,QAA4B;EAChC,OAAO,IAAI;EACX,YAAY,IAAI;EAChB,MAAM,QAAQ;EACd,SAAS,IAAI;EACb,OAAO,IAAI;EACX,UAAU,IAAI;CAChB;CAEA,MAAM,MAAM,aACT,YAAyB;EACxB,IAAI,OAAO;GACT,MAAM,OAAO,QAAQ,YAAY,UAAW,QAA6B,OAAO;GAChF,IAAI,SAAS,UAAU,SAAS,UAC9B,QAAQ,MACN,6BAA6B,QAAQ,QAAQ,YAAY,IACpD,SAAS,KAAK,KAAK,UAAU,KAAK,GAAG,iIAE5C;EAEJ;EACA,SAAS,UAAU;EAGnB,WAAW,UAAU;EACrB,aAAa;GACX,IAAI,SAAS,YAAY,SAAS,SAAS,UAAU;GACrD,IAAI,WAAW,YAAY,SAAS,WAAW,UAAU;EAC3D;CACF,GACA,CAAC,UAAU,UAAU,CACvB;CAEA,MAAM,aAAa,eAAmC,MAAM,KAAK,OAAO,MAAM,SAAS;CAEvF,MAAM,eAAgE;EACpE,IAAI,IAAI;EACR,MAAM,aAAa,WAAW;EAC9B,MAAM;EACN,OAAO,IAAI;EACX,cAAc;EACd,qBAAqB;EACrB,iBAAiB,QAAQ;EACzB,iBAAiB,IAAI;EACrB,yBACE,IAAI,gBAAgB,OAAO,KAAA,IAAY,SAAS,IAAI,cAAc,IAAI,WAAW;EACnF,UAAU,IAAI;EACd,WAAW,UAAyC;GAClD,IAAI,MAAM,MAAM,cAAc,OAAO,MAAM,WAAW;EACxD;EACA,YAAY,UAA2C;GACrD,IAAI,QAAQ,MAAM,WAAW;EAC/B;EACA,SAAS,UAAwC;GAC/C,IAAI,SAAS,MAAM,WAAW;EAChC;EACA,UAAU,UAAwC;GAChD,IAAI,WAAW,MAAM,WAAW;EAClC;EACA,aAAa,SAAS,QAAQ,UAAU;EACxC,gBAAgB,SAAS,MAAM,OAAO;EACtC,iBAAiB,SAAS,IAAI,UAAU,IAAI;EAC5C,cAAc,SAAS,IAAI,KAAK;EAChC,iBAAiB,SAAS,IAAI,QAAQ;CACxC;CAEA,OAAO,UAA8D;EACnE,gBAAgB;EAChB;EACA;EACA;EACA;EACA,UAAU,KAAA;EACV,OAAO;EACP;EACA;CACF,CAAC;AACH;AAEA,cAAc,cAAc"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
|
+
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
3
|
+
//#region src/combobox/combobox-label.d.ts
|
|
4
|
+
export interface ComboboxLabelState {
|
|
5
|
+
readonly disabled: boolean;
|
|
6
|
+
}
|
|
7
|
+
export interface ComboboxLabelProps extends Omit<ComponentPropsWithRef<"label">, "id" | "htmlFor" | "className" | "style" | "children"> {
|
|
8
|
+
className?: StateValue<string | undefined, ComboboxLabelState>;
|
|
9
|
+
style?: StateValue<CSSProperties | undefined, ComboboxLabelState>;
|
|
10
|
+
children?: StateValue<ReactNode, ComboboxLabelState>;
|
|
11
|
+
render?: RenderProp<ComponentPropsWithRef<"label">, ComboboxLabelState>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The visible name of the combobox: `<label for={input}>`, whose id also names the listbox
|
|
15
|
+
* (`aria-labelledby` on `Combobox.List`, emitted only while a Label is mounted). Owned keys: `id`, `htmlFor`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function ComboboxLabel({ className, style, children, render, ...rest }: ComboboxLabelProps): ReactNode;
|
|
18
|
+
export declare namespace ComboboxLabel {
|
|
19
|
+
var displayName: string;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//# sourceMappingURL=combobox-label.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox-label.d.mts","names":[],"sources":["../../src/combobox/combobox-label.tsx"],"mappings":";;;iBAOiB;WACN;;iBAGM,2BAA2B,KAC1C;EAGA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,gCAAgC;;;;;;wBAOtC,gBAAgB,WAAW,OAAO,UAAU,WAAW,QAAQ,qBAAkB;yBAAjF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useRender } from "../internal/use-render.mjs";
|
|
3
|
+
import { useComboboxContext } from "./combobox-context.mjs";
|
|
4
|
+
import { useLayoutEffect } from "react";
|
|
5
|
+
//#region src/combobox/combobox-label.tsx
|
|
6
|
+
/**
|
|
7
|
+
* The visible name of the combobox: `<label for={input}>`, whose id also names the listbox
|
|
8
|
+
* (`aria-labelledby` on `Combobox.List`, emitted only while a Label is mounted). Owned keys: `id`, `htmlFor`.
|
|
9
|
+
*/
|
|
10
|
+
function ComboboxLabel({ className, style, children, render, ...rest }) {
|
|
11
|
+
const ctx = useComboboxContext("Combobox.Label");
|
|
12
|
+
const { registerLabel } = ctx;
|
|
13
|
+
useLayoutEffect(registerLabel, [registerLabel]);
|
|
14
|
+
return useRender({
|
|
15
|
+
defaultElement: "label",
|
|
16
|
+
render,
|
|
17
|
+
state: { disabled: ctx.disabled },
|
|
18
|
+
className,
|
|
19
|
+
style,
|
|
20
|
+
children,
|
|
21
|
+
props: rest,
|
|
22
|
+
libraryProps: {
|
|
23
|
+
id: ctx.ids.label,
|
|
24
|
+
htmlFor: ctx.ids.input
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
ComboboxLabel.displayName = "ComboboxLabel";
|
|
29
|
+
//#endregion
|
|
30
|
+
export { ComboboxLabel };
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=combobox-label.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox-label.mjs","names":[],"sources":["../../src/combobox/combobox-label.tsx"],"sourcesContent":["\"use client\";\nimport { useLayoutEffect } from \"react\";\nimport type { ComponentPropsWithRef, CSSProperties, ReactNode } from \"react\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { useRender } from \"../internal/use-render.js\";\nimport { useComboboxContext } from \"./combobox-context.js\";\n\nexport interface ComboboxLabelState {\n readonly disabled: boolean;\n}\n\nexport interface ComboboxLabelProps extends Omit<\n ComponentPropsWithRef<\"label\">,\n \"id\" | \"htmlFor\" | \"className\" | \"style\" | \"children\"\n> {\n className?: StateValue<string | undefined, ComboboxLabelState>;\n style?: StateValue<CSSProperties | undefined, ComboboxLabelState>;\n children?: StateValue<ReactNode, ComboboxLabelState>;\n render?: RenderProp<ComponentPropsWithRef<\"label\">, ComboboxLabelState>;\n}\n\n/**\n * The visible name of the combobox: `<label for={input}>`, whose id also names the listbox\n * (`aria-labelledby` on `Combobox.List`, emitted only while a Label is mounted). Owned keys: `id`, `htmlFor`.\n */\nexport function ComboboxLabel({ className, style, children, render, ...rest }: ComboboxLabelProps) {\n const ctx = useComboboxContext(\"Combobox.Label\");\n const { registerLabel } = ctx;\n useLayoutEffect(registerLabel, [registerLabel]);\n return useRender<ComponentPropsWithRef<\"label\">, ComboboxLabelState>({\n defaultElement: \"label\",\n render,\n state: { disabled: ctx.disabled },\n className,\n style,\n children,\n props: rest,\n libraryProps: { id: ctx.ids.label, htmlFor: ctx.ids.input },\n });\n}\n\nComboboxLabel.displayName = \"ComboboxLabel\";\n"],"mappings":";;;;;;;;;AAyBA,SAAgB,cAAc,EAAE,WAAW,OAAO,UAAU,QAAQ,GAAG,QAA4B;CACjG,MAAM,MAAM,mBAAmB,gBAAgB;CAC/C,MAAM,EAAE,kBAAkB;CAC1B,gBAAgB,eAAe,CAAC,aAAa,CAAC;CAC9C,OAAO,UAA8D;EACnE,gBAAgB;EAChB;EACA,OAAO,EAAE,UAAU,IAAI,SAAS;EAChC;EACA;EACA;EACA,OAAO;EACP,cAAc;GAAE,IAAI,IAAI,IAAI;GAAO,SAAS,IAAI,IAAI;EAAM;CAC5D,CAAC;AACH;AAEA,cAAc,cAAc"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
|
+
import { CSSProperties, ComponentPropsWithRef, ReactNode } from "react";
|
|
3
|
+
//#region src/combobox/combobox-list.d.ts
|
|
4
|
+
export interface ComboboxListState {
|
|
5
|
+
/** The deferred text the results are for: render the Options for it. */
|
|
6
|
+
readonly query: string;
|
|
7
|
+
/** The results shown are for an older text (`aria-busy`). */
|
|
8
|
+
readonly stale: boolean;
|
|
9
|
+
/** No option is mounted and the results are settled. */
|
|
10
|
+
readonly empty: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ComboboxListProps extends Omit<ComponentPropsWithRef<"div">, "id" | "role" | "aria-busy" | "className" | "style" | "children"> {
|
|
13
|
+
className?: StateValue<string | undefined, ComboboxListState>;
|
|
14
|
+
style?: StateValue<CSSProperties | undefined, ComboboxListState>;
|
|
15
|
+
/**
|
|
16
|
+
* Usually a function of `{ query }` rendering the Options for it, under your own `<Suspense>`
|
|
17
|
+
* for an async search. The previous results stay visible while the next ones load.
|
|
18
|
+
*/
|
|
19
|
+
children?: StateValue<ReactNode, ComboboxListState>;
|
|
20
|
+
render?: RenderProp<ComponentPropsWithRef<"div">, ComboboxListState>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The listbox: `<div role="listbox" aria-labelledby={label}>` (only while a `Combobox.Label` is
|
|
24
|
+
* mounted), the element the input's `aria-controls` names. Its children are the results for the
|
|
25
|
+
* deferred `query` (the library filters nothing, design 6.1); while they are for an older text it
|
|
26
|
+
* carries `aria-busy="true"` and `data-stale`. Contains only Options and Groups; a `Status`
|
|
27
|
+
* rendered as a Suspense fallback inside it marks the results as loading (`aria-busy="true"`).
|
|
28
|
+
*
|
|
29
|
+
* Owned keys (conventions 1.2): `id`, `role`, `aria-labelledby` (token-merged), `aria-busy`,
|
|
30
|
+
* `data-stale`, `data-empty`.
|
|
31
|
+
*/
|
|
32
|
+
export declare function ComboboxList({ className, style, children, render, ...rest }: ComboboxListProps): ReactNode;
|
|
33
|
+
export declare namespace ComboboxList {
|
|
34
|
+
var displayName: string;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//# sourceMappingURL=combobox-list.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox-list.d.mts","names":[],"sources":["../../src/combobox/combobox-list.tsx"],"mappings":";;;iBAgBiB;;WAEN;;WAEA;;WAEA;;iBAGM,0BAA0B,KACzC;EAGA,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;;;;;EAK9C,WAAW,WAAW,WAAW;EACjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;;wBAapC,eAAe,WAAW,OAAO,UAAU,WAAW,QAAQ,oBAAiB;yBAA/E"}
|