@funstack/ui 0.1.0-alpha.1 → 0.1.0-alpha.3
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/accordion/accordion-context.mjs.map +1 -1
- package/dist/accordion/accordion-item.mjs +18 -4
- package/dist/accordion/accordion-item.mjs.map +1 -1
- package/dist/accordion/accordion-panel.mjs +2 -3
- package/dist/accordion/accordion-panel.mjs.map +1 -1
- package/dist/accordion/accordion-root.d.mts.map +1 -1
- package/dist/accordion/accordion-root.mjs +32 -14
- package/dist/accordion/accordion-root.mjs.map +1 -1
- package/dist/accordion/accordion-trigger.mjs +4 -5
- package/dist/accordion/accordion-trigger.mjs.map +1 -1
- package/dist/checkbox/checkbox.d.mts +5 -3
- package/dist/checkbox/checkbox.d.mts.map +1 -1
- package/dist/checkbox/checkbox.mjs +25 -9
- package/dist/checkbox/checkbox.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-context.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts +2 -1
- package/dist/checkbox-group/checkbox-group-item.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-item.mjs +3 -1
- package/dist/checkbox-group/checkbox-group-item.mjs.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.d.mts +5 -2
- package/dist/checkbox-group/checkbox-group-root.d.mts.map +1 -1
- package/dist/checkbox-group/checkbox-group-root.mjs +24 -5
- package/dist/checkbox-group/checkbox-group-root.mjs.map +1 -1
- 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 +42 -0
- package/dist/combobox/combobox-input.d.mts.map +1 -0
- package/dist/combobox/combobox-input.mjs +102 -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 +523 -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/dialog/dialog-close.d.mts +17 -10
- package/dist/dialog/dialog-close.d.mts.map +1 -1
- package/dist/dialog/dialog-close.mjs +31 -20
- package/dist/dialog/dialog-close.mjs.map +1 -1
- package/dist/dialog/dialog-context.mjs.map +1 -1
- package/dist/dialog/dialog-form.d.mts +12 -5
- package/dist/dialog/dialog-form.d.mts.map +1 -1
- package/dist/dialog/dialog-form.mjs +16 -28
- package/dist/dialog/dialog-form.mjs.map +1 -1
- package/dist/dialog/dialog-popup.d.mts +10 -4
- package/dist/dialog/dialog-popup.d.mts.map +1 -1
- package/dist/dialog/dialog-popup.mjs +106 -41
- package/dist/dialog/dialog-popup.mjs.map +1 -1
- package/dist/dialog/dialog-root.d.mts +14 -8
- package/dist/dialog/dialog-root.d.mts.map +1 -1
- package/dist/dialog/dialog-root.mjs +66 -11
- package/dist/dialog/dialog-root.mjs.map +1 -1
- package/dist/dialog/dialog-trigger.d.mts +3 -2
- package/dist/dialog/dialog-trigger.d.mts.map +1 -1
- package/dist/dialog/dialog-trigger.mjs.map +1 -1
- package/dist/dialog/index.d.mts +4 -2
- package/dist/dialog/index.d.mts.map +1 -1
- package/dist/dialog/index.mjs +4 -2
- package/dist/dialog/index.mjs.map +1 -1
- package/dist/field/field-control.d.mts +33 -0
- package/dist/field/field-control.d.mts.map +1 -0
- package/dist/field/field-control.mjs +68 -0
- package/dist/field/field-control.mjs.map +1 -0
- package/dist/field/field-description.d.mts +24 -0
- package/dist/field/field-description.d.mts.map +1 -0
- package/dist/field/field-description.mjs +34 -0
- package/dist/field/field-description.mjs.map +1 -0
- package/dist/field/field-error.d.mts +30 -0
- package/dist/field/field-error.d.mts.map +1 -0
- package/dist/field/field-error.mjs +42 -0
- package/dist/field/field-error.mjs.map +1 -0
- package/dist/field/field-label.d.mts +25 -0
- package/dist/field/field-label.d.mts.map +1 -0
- package/dist/field/field-label.mjs +46 -0
- package/dist/field/field-label.mjs.map +1 -0
- package/dist/field/field-root.d.mts +53 -0
- package/dist/field/field-root.d.mts.map +1 -0
- package/dist/field/field-root.mjs +317 -0
- package/dist/field/field-root.mjs.map +1 -0
- package/dist/field/index.d.mts +18 -0
- package/dist/field/index.d.mts.map +1 -0
- package/dist/field/index.mjs +17 -0
- package/dist/field/index.mjs.map +1 -0
- package/dist/form/form-root.d.mts +58 -0
- package/dist/form/form-root.d.mts.map +1 -0
- package/dist/form/form-root.mjs +146 -0
- package/dist/form/form-root.mjs.map +1 -0
- package/dist/form/form-submit.d.mts +31 -0
- package/dist/form/form-submit.d.mts.map +1 -0
- package/dist/form/form-submit.mjs +52 -0
- package/dist/form/form-submit.mjs.map +1 -0
- package/dist/form/index.d.mts +11 -0
- package/dist/form/index.d.mts.map +1 -0
- package/dist/form/index.mjs +11 -0
- package/dist/form/index.mjs.map +1 -0
- package/dist/index.d.mts +46 -2
- package/dist/index.mjs +8 -1
- package/dist/internal/content-focus-probe.mjs +42 -0
- package/dist/internal/content-focus-probe.mjs.map +1 -0
- package/dist/internal/field-context.d.mts +19 -0
- package/dist/internal/field-context.d.mts.map +1 -0
- package/dist/internal/field-context.mjs +14 -0
- package/dist/internal/field-context.mjs.map +1 -0
- package/dist/internal/focus-first-invalid.mjs +67 -0
- package/dist/internal/focus-first-invalid.mjs.map +1 -0
- package/dist/internal/form-status-watcher.mjs +31 -0
- package/dist/internal/form-status-watcher.mjs.map +1 -0
- package/dist/internal/modal-registry.mjs +39 -0
- package/dist/internal/modal-registry.mjs.map +1 -0
- 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 +11 -1
- package/dist/internal/types.d.mts.map +1 -1
- package/dist/internal/use-controllable-action.mjs +35 -13
- package/dist/internal/use-controllable-action.mjs.map +1 -1
- package/dist/internal/use-field-control.mjs +107 -0
- package/dist/internal/use-field-control.mjs.map +1 -0
- package/dist/internal/use-form-owner-event.mjs +44 -0
- package/dist/internal/use-form-owner-event.mjs.map +1 -0
- package/dist/internal/use-form-reset.mjs +12 -31
- 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-latest.mjs +32 -0
- package/dist/internal/use-latest.mjs.map +1 -0
- package/dist/internal/use-modal-registration.mjs +47 -0
- package/dist/internal/use-modal-registration.mjs.map +1 -0
- package/dist/internal/use-native-group-reconciliation.mjs +6 -5
- package/dist/internal/use-native-group-reconciliation.mjs.map +1 -1
- package/dist/internal/use-native-select-value.mjs +184 -0
- package/dist/internal/use-native-select-value.mjs.map +1 -0
- package/dist/internal/use-popover-popup.mjs +8 -22
- package/dist/internal/use-popover-popup.mjs.map +1 -1
- package/dist/internal/use-popover-root.mjs +58 -23
- package/dist/internal/use-popover-root.mjs.map +1 -1
- package/dist/internal/validity.d.mts +24 -0
- package/dist/internal/validity.d.mts.map +1 -0
- package/dist/internal/validity.mjs +108 -0
- package/dist/internal/validity.mjs.map +1 -0
- package/dist/menu/menu-group.d.mts.map +1 -1
- package/dist/menu/menu-group.mjs +3 -2
- package/dist/menu/menu-group.mjs.map +1 -1
- package/dist/menu/menu-radio-group.mjs +9 -4
- package/dist/menu/menu-radio-group.mjs.map +1 -1
- package/dist/menu/menu-root.mjs.map +1 -1
- package/dist/radio-group/radio-group-root.d.mts +4 -2
- package/dist/radio-group/radio-group-root.d.mts.map +1 -1
- package/dist/radio-group/radio-group-root.mjs +34 -8
- package/dist/radio-group/radio-group-root.mjs.map +1 -1
- 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 +47 -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 +68 -0
- package/dist/select/select-root.d.mts.map +1 -0
- package/dist/select/select-root.mjs +114 -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/dist/slider/index.d.mts +32 -0
- package/dist/slider/index.d.mts.map +1 -0
- package/dist/slider/index.mjs +27 -0
- package/dist/slider/index.mjs.map +1 -0
- package/dist/slider/slider-arithmetic.mjs +120 -0
- package/dist/slider/slider-arithmetic.mjs.map +1 -0
- package/dist/slider/slider-context.mjs +13 -0
- package/dist/slider/slider-context.mjs.map +1 -0
- package/dist/slider/slider-indicator.d.mts +22 -0
- package/dist/slider/slider-indicator.d.mts.map +1 -0
- package/dist/slider/slider-indicator.mjs +36 -0
- package/dist/slider/slider-indicator.mjs.map +1 -0
- package/dist/slider/slider-label.d.mts +23 -0
- package/dist/slider/slider-label.d.mts.map +1 -0
- package/dist/slider/slider-label.mjs +44 -0
- package/dist/slider/slider-label.mjs.map +1 -0
- package/dist/slider/slider-root.d.mts +111 -0
- package/dist/slider/slider-root.d.mts.map +1 -0
- package/dist/slider/slider-root.mjs +582 -0
- package/dist/slider/slider-root.mjs.map +1 -0
- package/dist/slider/slider-thumb.d.mts +58 -0
- package/dist/slider/slider-thumb.d.mts.map +1 -0
- package/dist/slider/slider-thumb.mjs +145 -0
- package/dist/slider/slider-thumb.mjs.map +1 -0
- package/dist/slider/slider-track.d.mts +29 -0
- package/dist/slider/slider-track.d.mts.map +1 -0
- package/dist/slider/slider-track.mjs +54 -0
- package/dist/slider/slider-track.mjs.map +1 -0
- package/dist/slider/slider-value.d.mts +34 -0
- package/dist/slider/slider-value.d.mts.map +1 -0
- package/dist/slider/slider-value.mjs +38 -0
- package/dist/slider/slider-value.mjs.map +1 -0
- package/dist/switch/switch.d.mts +5 -3
- package/dist/switch/switch.d.mts.map +1 -1
- package/dist/switch/switch.mjs +24 -8
- package/dist/switch/switch.mjs.map +1 -1
- package/dist/tabs/tabs-root.mjs +13 -3
- package/dist/tabs/tabs-root.mjs.map +1 -1
- package/dist/toast/index.d.mts +25 -0
- package/dist/toast/index.d.mts.map +1 -0
- package/dist/toast/index.mjs +26 -0
- package/dist/toast/index.mjs.map +1 -0
- package/dist/toast/toast-action.d.mts +39 -0
- package/dist/toast/toast-action.d.mts.map +1 -0
- package/dist/toast/toast-action.mjs +64 -0
- package/dist/toast/toast-action.mjs.map +1 -0
- package/dist/toast/toast-close.d.mts +25 -0
- package/dist/toast/toast-close.d.mts.map +1 -0
- package/dist/toast/toast-close.mjs +46 -0
- package/dist/toast/toast-close.mjs.map +1 -0
- package/dist/toast/toast-context.mjs +19 -0
- package/dist/toast/toast-context.mjs.map +1 -0
- package/dist/toast/toast-description.d.mts +24 -0
- package/dist/toast/toast-description.d.mts.map +1 -0
- package/dist/toast/toast-description.mjs +35 -0
- package/dist/toast/toast-description.mjs.map +1 -0
- package/dist/toast/toast-root.d.mts +43 -0
- package/dist/toast/toast-root.d.mts.map +1 -0
- package/dist/toast/toast-root.mjs +204 -0
- package/dist/toast/toast-root.mjs.map +1 -0
- package/dist/toast/toast-title.d.mts +24 -0
- package/dist/toast/toast-title.d.mts.map +1 -0
- package/dist/toast/toast-title.mjs +33 -0
- package/dist/toast/toast-title.mjs.map +1 -0
- package/dist/toast/toast-viewport.d.mts +52 -0
- package/dist/toast/toast-viewport.d.mts.map +1 -0
- package/dist/toast/toast-viewport.mjs +621 -0
- package/dist/toast/toast-viewport.mjs.map +1 -0
- package/dist/toast/toast.d.mts +119 -0
- package/dist/toast/toast.d.mts.map +1 -0
- package/dist/toast/toast.mjs +153 -0
- package/dist/toast/toast.mjs.map +1 -0
- package/package.json +7 -1
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { RenderProp, StateValue } from "../internal/types.mjs";
|
|
2
|
+
import { CSSProperties, ComponentPropsWithRef, ReactNode, ViewTransitionClass } from "react";
|
|
3
|
+
//#region src/combobox/combobox-popup.d.ts
|
|
4
|
+
export interface ComboboxPopupState {
|
|
5
|
+
/** Committed open state. Read `:popover-open` for the DOM truth. */
|
|
6
|
+
readonly open: boolean;
|
|
7
|
+
/** The results shown are for an older text. */
|
|
8
|
+
readonly stale: boolean;
|
|
9
|
+
/** The deferred text the results are for. */
|
|
10
|
+
readonly query: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ComboboxPopupProps extends Omit<ComponentPropsWithRef<"div">, "id" | "popover" | "onToggle" | "onBeforeToggle" | "onPointerDown" | "onMouseDown" | "className" | "style" | "children"> {
|
|
13
|
+
/**
|
|
14
|
+
* `false` (default): the children are not rendered while the listbox is closed. `true`: they
|
|
15
|
+
* stay mounted inside `<Activity mode="hidden">`.
|
|
16
|
+
*/
|
|
17
|
+
keepMounted?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Forwarded to the `<ViewTransition default>` around the popover element itself. Animates
|
|
20
|
+
* library-driven opens and closes (typing, the Trigger, an accepted option) in every engine;
|
|
21
|
+
* dismissals are the browser's (CSS only). **A deferred results render also activates the
|
|
22
|
+
* boundary** (React: updates from `useDeferredValue` animate), so use a type map with
|
|
23
|
+
* `default: "none"` unless every result change should cross-fade. Static.
|
|
24
|
+
*/
|
|
25
|
+
transition?: ViewTransitionClass;
|
|
26
|
+
className?: StateValue<string | undefined, ComboboxPopupState>;
|
|
27
|
+
style?: StateValue<CSSProperties | undefined, ComboboxPopupState>;
|
|
28
|
+
children?: StateValue<ReactNode, ComboboxPopupState>;
|
|
29
|
+
/** Must render a `<div>`: a `<dialog>` would pull focus out of the input. */
|
|
30
|
+
render?: RenderProp<ComponentPropsWithRef<"div">, ComboboxPopupState>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* The listbox's container: `<div popover="auto">`, opened by the library with
|
|
34
|
+
* `showPopover({ source: input })` and placed below (or, flipped, above) the input with CSS
|
|
35
|
+
* Anchor Positioning, at least as wide as the input. Focus never enters it: a press anywhere in
|
|
36
|
+
* it is `preventDefault()`ed so the input keeps focus (design 7.1). Holds the `List` and, outside
|
|
37
|
+
* it, `Empty` and `Status`. Style it with `:popover-open`; it emits `data-stale` but no
|
|
38
|
+
* `data-open`.
|
|
39
|
+
*
|
|
40
|
+
* Owned keys (conventions 1.2): `id`, `popover`, `onPointerDown`, `onMouseDown`, `data-stale`.
|
|
41
|
+
* Inline `position-area`, `position-try-fallbacks` and `min-width` sit under the consumer's
|
|
42
|
+
* `style` (`style={{ positionTryFallbacks: "none" }}` removes the flip).
|
|
43
|
+
*/
|
|
44
|
+
export declare function ComboboxPopup({ keepMounted, transition, className, style, children, render, ...rest }: ComboboxPopupProps): ReactNode;
|
|
45
|
+
export declare namespace ComboboxPopup {
|
|
46
|
+
var displayName: string;
|
|
47
|
+
}
|
|
48
|
+
//#endregion
|
|
49
|
+
//# sourceMappingURL=combobox-popup.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox-popup.d.mts","names":[],"sources":["../../src/combobox/combobox-popup.tsx"],"mappings":";;;iBAmBiB;;WAEN;;WAEA;;WAEA;;iBAGM,2BAA2B,KAC1C;;;;;EAeA;;;;;;;;EAQA,aAAa;EACb,YAAY,+BAA+B;EAC3C,QAAQ,WAAW,2BAA2B;EAC9C,WAAW,WAAW,WAAW;;EAEjC,SAAS,WAAW,8BAA8B;;;;;;;;;;;;;;wBAmBpC,gBACd,aACA,YACA,WACA,OACA,UACA,WACG,QACF,qBAAkB;yBARL"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useTransitionBoundary } from "../internal/transition-boundary.mjs";
|
|
3
|
+
import { dataAttr } from "../internal/data-attr.mjs";
|
|
4
|
+
import { mergeRefs } from "../internal/merge-props.mjs";
|
|
5
|
+
import { resolveStateValue, useRender } from "../internal/use-render.mjs";
|
|
6
|
+
import { usePopoverPopup } from "../internal/use-popover-popup.mjs";
|
|
7
|
+
import { ComboboxPopupContext, useComboboxContext } from "./combobox-context.mjs";
|
|
8
|
+
import { Activity, useCallback, useMemo } from "react";
|
|
9
|
+
import { jsx } from "react/jsx-runtime";
|
|
10
|
+
//#region src/combobox/combobox-popup.tsx
|
|
11
|
+
const isDev = process.env.NODE_ENV !== "production";
|
|
12
|
+
const preventDefault = (event) => event.preventDefault();
|
|
13
|
+
/**
|
|
14
|
+
* The listbox's container: `<div popover="auto">`, opened by the library with
|
|
15
|
+
* `showPopover({ source: input })` and placed below (or, flipped, above) the input with CSS
|
|
16
|
+
* Anchor Positioning, at least as wide as the input. Focus never enters it: a press anywhere in
|
|
17
|
+
* it is `preventDefault()`ed so the input keeps focus (design 7.1). Holds the `List` and, outside
|
|
18
|
+
* it, `Empty` and `Status`. Style it with `:popover-open`; it emits `data-stale` but no
|
|
19
|
+
* `data-open`.
|
|
20
|
+
*
|
|
21
|
+
* Owned keys (conventions 1.2): `id`, `popover`, `onPointerDown`, `onMouseDown`, `data-stale`.
|
|
22
|
+
* Inline `position-area`, `position-try-fallbacks` and `min-width` sit under the consumer's
|
|
23
|
+
* `style` (`style={{ positionTryFallbacks: "none" }}` removes the flip).
|
|
24
|
+
*/
|
|
25
|
+
function ComboboxPopup({ keepMounted, transition, className, style, children, render, ...rest }) {
|
|
26
|
+
const ctx = useComboboxContext("Combobox.Popup");
|
|
27
|
+
const { popover } = ctx;
|
|
28
|
+
const { setElement, visible, wrapContent } = usePopoverPopup(popover, {
|
|
29
|
+
part: "Combobox.Popup",
|
|
30
|
+
initialFocus: void 0,
|
|
31
|
+
resolveInitialFocus: () => null,
|
|
32
|
+
keepMounted,
|
|
33
|
+
transition
|
|
34
|
+
});
|
|
35
|
+
const devRef = useCallback((element) => {
|
|
36
|
+
if (isDev && element.tagName !== "DIV") console.error(`Combobox.Popup: rendered a <${element.tagName.toLowerCase()}>. Render a <div>: a <dialog popover> runs the dialog focusing steps and takes focus out of the input.`);
|
|
37
|
+
return () => {};
|
|
38
|
+
}, []);
|
|
39
|
+
const ref = useMemo(() => mergeRefs(setElement, devRef), [setElement, devRef]);
|
|
40
|
+
const state = {
|
|
41
|
+
open: popover.committed,
|
|
42
|
+
stale: ctx.stale,
|
|
43
|
+
query: ctx.query
|
|
44
|
+
};
|
|
45
|
+
const libraryProps = {
|
|
46
|
+
id: popover.ids.popup,
|
|
47
|
+
popover: "auto",
|
|
48
|
+
onPointerDown: (event) => preventDefault(event),
|
|
49
|
+
onMouseDown: (event) => preventDefault(event),
|
|
50
|
+
"data-stale": dataAttr(ctx.stale)
|
|
51
|
+
};
|
|
52
|
+
const content = (s) => {
|
|
53
|
+
let node;
|
|
54
|
+
if (keepMounted === true) node = /* @__PURE__ */ jsx(Activity, {
|
|
55
|
+
mode: visible ? "visible" : "hidden",
|
|
56
|
+
children: wrapContent(resolveStateValue(children, s))
|
|
57
|
+
});
|
|
58
|
+
else node = visible ? wrapContent(resolveStateValue(children, s)) : null;
|
|
59
|
+
return /* @__PURE__ */ jsx(ComboboxPopupContext, {
|
|
60
|
+
value: true,
|
|
61
|
+
children: node
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
const element = useRender({
|
|
65
|
+
defaultElement: "div",
|
|
66
|
+
render,
|
|
67
|
+
state,
|
|
68
|
+
className,
|
|
69
|
+
style: (s) => ({
|
|
70
|
+
positionArea: "block-end span-inline-end",
|
|
71
|
+
positionTryFallbacks: "flip-block",
|
|
72
|
+
minWidth: "anchor-size(width)",
|
|
73
|
+
...resolveStateValue(style, s)
|
|
74
|
+
}),
|
|
75
|
+
children: content,
|
|
76
|
+
props: rest,
|
|
77
|
+
libraryProps,
|
|
78
|
+
ref
|
|
79
|
+
});
|
|
80
|
+
return useTransitionBoundary("Combobox.Popup", transition, element);
|
|
81
|
+
}
|
|
82
|
+
ComboboxPopup.displayName = "ComboboxPopup";
|
|
83
|
+
//#endregion
|
|
84
|
+
export { ComboboxPopup };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=combobox-popup.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox-popup.mjs","names":[],"sources":["../../src/combobox/combobox-popup.tsx"],"sourcesContent":["\"use client\";\nimport { Activity, useCallback, useMemo } from \"react\";\nimport type {\n ComponentPropsWithRef,\n CSSProperties,\n MouseEvent,\n PointerEvent,\n ReactNode,\n ViewTransitionClass,\n} from \"react\";\nimport { dataAttr } from \"../internal/data-attr.js\";\nimport { mergeRefs } from \"../internal/merge-props.js\";\nimport { useTransitionBoundary } from \"../internal/transition-boundary.js\";\nimport type { RenderProp, StateValue } from \"../internal/types.js\";\nimport { usePopoverPopup } from \"../internal/use-popover-popup.js\";\nimport { resolveStateValue, useRender } from \"../internal/use-render.js\";\nimport type { DataAttributes } from \"../internal/use-render.js\";\nimport { ComboboxPopupContext, useComboboxContext } from \"./combobox-context.js\";\n\nexport interface ComboboxPopupState {\n /** Committed open state. Read `:popover-open` for the DOM truth. */\n readonly open: boolean;\n /** The results shown are for an older text. */\n readonly stale: boolean;\n /** The deferred text the results are for. */\n readonly query: string;\n}\n\nexport interface ComboboxPopupProps extends Omit<\n ComponentPropsWithRef<\"div\">,\n | \"id\"\n | \"popover\"\n | \"onToggle\"\n | \"onBeforeToggle\"\n | \"onPointerDown\"\n | \"onMouseDown\"\n | \"className\"\n | \"style\"\n | \"children\"\n> {\n /**\n * `false` (default): the children are not rendered while the listbox is closed. `true`: they\n * stay mounted inside `<Activity mode=\"hidden\">`.\n */\n keepMounted?: boolean;\n /**\n * Forwarded to the `<ViewTransition default>` around the popover element itself. Animates\n * library-driven opens and closes (typing, the Trigger, an accepted option) in every engine;\n * dismissals are the browser's (CSS only). **A deferred results render also activates the\n * boundary** (React: updates from `useDeferredValue` animate), so use a type map with\n * `default: \"none\"` unless every result change should cross-fade. Static.\n */\n transition?: ViewTransitionClass;\n className?: StateValue<string | undefined, ComboboxPopupState>;\n style?: StateValue<CSSProperties | undefined, ComboboxPopupState>;\n children?: StateValue<ReactNode, ComboboxPopupState>;\n /** Must render a `<div>`: a `<dialog>` would pull focus out of the input. */\n render?: RenderProp<ComponentPropsWithRef<\"div\">, ComboboxPopupState>;\n}\n\nconst isDev = process.env.NODE_ENV !== \"production\";\n\nconst preventDefault = (event: { preventDefault(): void }) => event.preventDefault();\n\n/**\n * The listbox's container: `<div popover=\"auto\">`, opened by the library with\n * `showPopover({ source: input })` and placed below (or, flipped, above) the input with CSS\n * Anchor Positioning, at least as wide as the input. Focus never enters it: a press anywhere in\n * it is `preventDefault()`ed so the input keeps focus (design 7.1). Holds the `List` and, outside\n * it, `Empty` and `Status`. Style it with `:popover-open`; it emits `data-stale` but no\n * `data-open`.\n *\n * Owned keys (conventions 1.2): `id`, `popover`, `onPointerDown`, `onMouseDown`, `data-stale`.\n * Inline `position-area`, `position-try-fallbacks` and `min-width` sit under the consumer's\n * `style` (`style={{ positionTryFallbacks: \"none\" }}` removes the flip).\n */\nexport function ComboboxPopup({\n keepMounted,\n transition,\n className,\n style,\n children,\n render,\n ...rest\n}: ComboboxPopupProps) {\n const ctx = useComboboxContext(\"Combobox.Popup\");\n const { popover } = ctx;\n\n const { setElement, visible, wrapContent } = usePopoverPopup(popover, {\n part: \"Combobox.Popup\",\n initialFocus: undefined,\n // Focus stays in the input: nothing inside the popup is ever focused.\n resolveInitialFocus: () => null,\n keepMounted,\n transition,\n });\n\n const devRef = useCallback((element: HTMLElement) => {\n if (isDev && element.tagName !== \"DIV\") {\n console.error(\n `Combobox.Popup: rendered a <${element.tagName.toLowerCase()}>. Render a <div>: a ` +\n \"<dialog popover> runs the dialog focusing steps and takes focus out of the input.\",\n );\n }\n return () => {};\n }, []);\n const ref = useMemo(() => mergeRefs(setElement, devRef), [setElement, devRef]);\n\n const state: ComboboxPopupState = {\n open: popover.committed,\n stale: ctx.stale,\n query: ctx.query,\n };\n\n const libraryProps: ComponentPropsWithRef<\"div\"> & DataAttributes = {\n id: popover.ids.popup,\n popover: \"auto\",\n onPointerDown: (event: PointerEvent<HTMLDivElement>) => preventDefault(event),\n onMouseDown: (event: MouseEvent<HTMLDivElement>) => preventDefault(event),\n \"data-stale\": dataAttr(ctx.stale),\n };\n\n const content = (s: ComboboxPopupState): ReactNode => {\n let node: ReactNode;\n if (keepMounted === true) {\n node = (\n <Activity mode={visible ? \"visible\" : \"hidden\"}>\n {wrapContent(resolveStateValue(children, s))}\n </Activity>\n );\n } else {\n node = visible ? wrapContent(resolveStateValue(children, s)) : null;\n }\n return <ComboboxPopupContext value={true}>{node}</ComboboxPopupContext>;\n };\n\n const element = useRender<ComponentPropsWithRef<\"div\">, ComboboxPopupState>({\n defaultElement: \"div\",\n render,\n state,\n className,\n // Logical keywords: right under `direction: rtl` with no JS (design 7.2). The consumer wins.\n style: (s) => ({\n positionArea: \"block-end span-inline-end\",\n positionTryFallbacks: \"flip-block\",\n minWidth: \"anchor-size(width)\",\n ...resolveStateValue(style, s),\n }),\n children: content,\n props: rest,\n libraryProps,\n ref,\n });\n\n return useTransitionBoundary(\"Combobox.Popup\", transition, element);\n}\n\nComboboxPopup.displayName = \"ComboboxPopup\";\n"],"mappings":";;;;;;;;;;AA4DA,MAAM,QAAQ,QAAQ,IAAI,aAAa;AAEvC,MAAM,kBAAkB,UAAsC,MAAM,eAAe;;;;;;;;;;;;;AAcnF,SAAgB,cAAc,EAC5B,aACA,YACA,WACA,OACA,UACA,QACA,GAAG,QACkB;CACrB,MAAM,MAAM,mBAAmB,gBAAgB;CAC/C,MAAM,EAAE,YAAY;CAEpB,MAAM,EAAE,YAAY,SAAS,gBAAgB,gBAAgB,SAAS;EACpE,MAAM;EACN,cAAc,KAAA;EAEd,2BAA2B;EAC3B;EACA;CACF,CAAC;CAED,MAAM,SAAS,aAAa,YAAyB;EACnD,IAAI,SAAS,QAAQ,YAAY,OAC/B,QAAQ,MACN,+BAA+B,QAAQ,QAAQ,YAAY,EAAE,uGAE/D;EAEF,aAAa,CAAC;CAChB,GAAG,CAAC,CAAC;CACL,MAAM,MAAM,cAAc,UAAU,YAAY,MAAM,GAAG,CAAC,YAAY,MAAM,CAAC;CAE7E,MAAM,QAA4B;EAChC,MAAM,QAAQ;EACd,OAAO,IAAI;EACX,OAAO,IAAI;CACb;CAEA,MAAM,eAA8D;EAClE,IAAI,QAAQ,IAAI;EAChB,SAAS;EACT,gBAAgB,UAAwC,eAAe,KAAK;EAC5E,cAAc,UAAsC,eAAe,KAAK;EACxE,cAAc,SAAS,IAAI,KAAK;CAClC;CAEA,MAAM,WAAW,MAAqC;EACpD,IAAI;EACJ,IAAI,gBAAgB,MAClB,OACE,oBAAC,UAAD;GAAU,MAAM,UAAU,YAAY;GACnC,UAAA,YAAY,kBAAkB,UAAU,CAAC,CAAC;EACnC,CAAA;OAGZ,OAAO,UAAU,YAAY,kBAAkB,UAAU,CAAC,CAAC,IAAI;EAEjE,OAAO,oBAAC,sBAAD;GAAsB,OAAO;GAAO,UAAA;EAA2B,CAAA;CACxE;CAEA,MAAM,UAAU,UAA4D;EAC1E,gBAAgB;EAChB;EACA;EACA;EAEA,QAAQ,OAAO;GACb,cAAc;GACd,sBAAsB;GACtB,UAAU;GACV,GAAG,kBAAkB,OAAO,CAAC;EAC/B;EACA,UAAU;EACV,OAAO;EACP;EACA;CACF,CAAC;CAED,OAAO,sBAAsB,kBAAkB,YAAY,OAAO;AACpE;AAEA,cAAc,cAAc"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { ActionDetails, ChangeAction, ChangeReason, StateValue, UrgentChangeAction } from "../internal/types.mjs";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
//#region src/combobox/combobox-root.d.ts
|
|
4
|
+
/** Details passed as the second argument of `Combobox.Root`'s `valueChangeAction`. */
|
|
5
|
+
export interface ComboboxValueChangeDetails extends ActionDetails {
|
|
6
|
+
/**
|
|
7
|
+
* `"activate"`: the user accepted an option (Enter, click; `details.event` is the `keydown` or
|
|
8
|
+
* `click`), committed free text with `allowCustomValue` (Enter: the `keydown`; focus leaving:
|
|
9
|
+
* the `focusout`), or pressed Clear (`click`).
|
|
10
|
+
* `"platform"`: a form reset (`details.event` is the `reset` event).
|
|
11
|
+
*/
|
|
12
|
+
readonly reason: ChangeReason;
|
|
13
|
+
/** `true` when `next` is free text committed under `allowCustomValue`, not an option's value. */
|
|
14
|
+
readonly custom: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Details passed as the second argument of `Combobox.Root`'s `inputValueChangeAction`. */
|
|
17
|
+
export interface ComboboxInputValueChangeDetails extends ActionDetails {
|
|
18
|
+
/**
|
|
19
|
+
* `"activate"`: typing (the `input` event), an accepted option's label, Clear.
|
|
20
|
+
* `"dismiss"`: a revert: focus left with unmatched text, or the selection rolled back.
|
|
21
|
+
* `"platform"`: form reset (the `reset` event), or text found in the input at mount
|
|
22
|
+
* (`undefined`).
|
|
23
|
+
*/
|
|
24
|
+
readonly reason: ChangeReason;
|
|
25
|
+
}
|
|
26
|
+
/** Details passed as the second argument of `Combobox.Root`'s `openChangeAction`. */
|
|
27
|
+
export interface ComboboxOpenChangeDetails extends ActionDetails {
|
|
28
|
+
/**
|
|
29
|
+
* `"activate"`: typing, ArrowDown / ArrowUp / Alt+ArrowDown, the Trigger, a click on the input
|
|
30
|
+
* with `openOnClick`, an accepted option (the close after it), a foreign `showPopover()`.
|
|
31
|
+
* `"dismiss"`: Escape, light dismiss, focus leaving the combobox, another top-layer element.
|
|
32
|
+
* `"platform"`: the popup was found open on mount (only script can cause it).
|
|
33
|
+
*/
|
|
34
|
+
readonly reason: ChangeReason;
|
|
35
|
+
}
|
|
36
|
+
export interface ComboboxRootState {
|
|
37
|
+
/** Optimistic selection. Content rendered from it must not suspend. */
|
|
38
|
+
readonly value: string | null;
|
|
39
|
+
/** The text in the input (urgent). */
|
|
40
|
+
readonly inputValue: string;
|
|
41
|
+
/** The deferred text the mounted results are for. */
|
|
42
|
+
readonly query: string;
|
|
43
|
+
/** `inputValue !== query`: the results shown are for an older text. */
|
|
44
|
+
readonly stale: boolean;
|
|
45
|
+
/** The value of the option `aria-activedescendant` points at, or `null`. */
|
|
46
|
+
readonly activeValue: string | null;
|
|
47
|
+
/** Optimistic open state. */
|
|
48
|
+
readonly open: boolean;
|
|
49
|
+
/** A `valueChangeAction` or `openChangeAction` dispatched through this Combobox is in flight. */
|
|
50
|
+
readonly pending: boolean;
|
|
51
|
+
readonly disabled: boolean;
|
|
52
|
+
}
|
|
53
|
+
export interface ComboboxRootProps {
|
|
54
|
+
/** Controlled selection. `null`: nothing selected. `undefined`: uncontrolled. */
|
|
55
|
+
value?: string | null;
|
|
56
|
+
/** Initial selection in uncontrolled mode. Default `null`. */
|
|
57
|
+
defaultValue?: string | null;
|
|
58
|
+
/**
|
|
59
|
+
* Runs inside the Root's transition when the user accepts an option, commits free text
|
|
60
|
+
* (`allowCustomValue`), presses Clear, or the form resets. Awaited; the listbox closes in the
|
|
61
|
+
* commit that ends it; a rejection rolls the input text and `data-selected` back and leaves
|
|
62
|
+
* the listbox open. May be a Server Function. A `setState` after your own `await` needs
|
|
63
|
+
* `startTransition`.
|
|
64
|
+
*/
|
|
65
|
+
valueChangeAction?: ChangeAction<string | null, ComboboxValueChangeDetails>;
|
|
66
|
+
/** Controlled input text. `undefined`: uncontrolled. */
|
|
67
|
+
inputValue?: string;
|
|
68
|
+
/**
|
|
69
|
+
* Initial input text. Default `""`. Pass the selected value's label when `defaultValue` is
|
|
70
|
+
* set: the library never derives the text from the value.
|
|
71
|
+
*/
|
|
72
|
+
defaultInputValue?: string;
|
|
73
|
+
/**
|
|
74
|
+
* The urgent lane: called synchronously, outside any Transition, on every change of the text
|
|
75
|
+
* (typing, and the library's own writes: an accepted option's label, a revert, Clear, a form
|
|
76
|
+
* reset, text typed before hydration). Not awaited; nothing is pending for it. A controlled
|
|
77
|
+
* parent updates its state in the body (an urgent update, which is what a controlled text
|
|
78
|
+
* input needs).
|
|
79
|
+
*/
|
|
80
|
+
inputValueChangeAction?: UrgentChangeAction<string, ComboboxInputValueChangeDetails>;
|
|
81
|
+
/** Controlled open state. `undefined`: uncontrolled. */
|
|
82
|
+
open?: boolean;
|
|
83
|
+
/** Initial open state when uncontrolled. Opens after hydration. */
|
|
84
|
+
defaultOpen?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Awaited for opens and for the close after an accepted option (or the Trigger); a
|
|
87
|
+
* notification for dismissals (Escape, a click outside, focus leaving).
|
|
88
|
+
*/
|
|
89
|
+
openChangeAction?: ChangeAction<boolean, ComboboxOpenChangeDetails>;
|
|
90
|
+
/**
|
|
91
|
+
* Free text is a value: Enter with no active option, or focus leaving with text that is not
|
|
92
|
+
* the selected option's label, dispatches the text with `details.custom: true` (empty text
|
|
93
|
+
* dispatches `null`). Default `false`: unmatched text reverts to the selection's label when
|
|
94
|
+
* focus leaves.
|
|
95
|
+
*/
|
|
96
|
+
allowCustomValue?: boolean;
|
|
97
|
+
/**
|
|
98
|
+
* Make the first enabled option active when the results for an open or an edit settle (APG
|
|
99
|
+
* "automatic selection"). Stale results are never highlighted. Default `false`.
|
|
100
|
+
*/
|
|
101
|
+
autoHighlight?: boolean;
|
|
102
|
+
/** Open the listbox on a pointer click in the input (not on focus). Default `false`. */
|
|
103
|
+
openOnClick?: boolean;
|
|
104
|
+
/** Wrap from the last option to the first and back with the arrow keys. Default `false`. */
|
|
105
|
+
loop?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* The message `ariaNotify()` announces on the List when the results settle, from the number
|
|
108
|
+
* of mounted options. Default (English): `"No results"`, `"1 result"`, `"N results"`. Override
|
|
109
|
+
* for localisation or a richer message; return `null` to announce nothing. Ignored where
|
|
110
|
+
* `ariaNotify` is missing.
|
|
111
|
+
*/
|
|
112
|
+
announce?: (count: number, state: ComboboxRootState) => string | null;
|
|
113
|
+
/** Form participation through a hidden input with this name (value `""` for `null`). */
|
|
114
|
+
name?: string;
|
|
115
|
+
/** The `form` attribute of the hidden input. */
|
|
116
|
+
form?: string;
|
|
117
|
+
/** Disables the Input, Trigger and Clear; nothing dispatches for user interaction. */
|
|
118
|
+
disabled?: boolean;
|
|
119
|
+
children?: StateValue<ReactNode, ComboboxRootState>;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Owns the two states of a combobox (design/components/combobox.md 2): the selection (`value`,
|
|
123
|
+
* a transition with `useOptimistic`, like every other value) and the text (`inputValue`, the
|
|
124
|
+
* library's **urgent** lane: `inputValueChangeAction` is called synchronously, outside any
|
|
125
|
+
* transition). The results render from `useDeferredValue(inputValue)`; the active option is
|
|
126
|
+
* urgent virtual focus (`aria-activedescendant`); the listbox is a `popover="auto"` opened by the
|
|
127
|
+
* library with the input as `source`. Renders no DOM, except one `<input type="hidden">` when
|
|
128
|
+
* `name` is given.
|
|
129
|
+
*/
|
|
130
|
+
export declare function ComboboxRoot(props: ComboboxRootProps): import("react").JSX.Element;
|
|
131
|
+
export declare namespace ComboboxRoot {
|
|
132
|
+
var displayName: string;
|
|
133
|
+
}
|
|
134
|
+
//#endregion
|
|
135
|
+
//# sourceMappingURL=combobox-root.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"combobox-root.d.mts","names":[],"sources":["../../src/combobox/combobox-root.tsx"],"mappings":";;;;iBAmCiB,mCAAmC;;;;;;;WAOzC,QAAQ;;WAER;;;iBAIM,wCAAwC;;;;;;;WAO9C,QAAQ;;;iBAIF,kCAAkC;;;;;;;WAOxC,QAAQ;;iBAGF;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;;WAEA;WACA;;iBAGM;;EAEf;;EAEA;;;;;;;;EAQA,oBAAoB,4BAA4B;;EAGhD;;;;;EAKA;;;;;;;;EAQA,yBAAyB,2BAA2B;;EAGpD;;EAEA;;;;;EAKA,mBAAmB,sBAAsB;;;;;;;EAQzC;;;;;EAKA;;EAEA;;EAEA;;;;;;;EAOA,YAAY,eAAe,OAAO;;EAGlC;;EAEA;;EAEA;EACA,WAAW,WAAW,WAAW;;;;;;;;;;;wBA+DnB,aAAa,OAAO,oCAAiB,IAAA;yBAArC"}
|