@askrjs/askr 0.0.21 → 0.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/README.md +160 -46
- package/dist/_virtual/___vite-browser-external.js +1 -0
- package/dist/_virtual/__vite-browser-external.js +1 -0
- package/dist/_virtual/_commonjsHelpers.js +1 -0
- package/dist/_virtual/main.js +1 -0
- package/dist/_virtual/preload-helper.js +1 -0
- package/dist/{benchmark.d.ts → bench/benchmark-entry.d.ts} +3 -3
- package/dist/bench/benchmark-entry.d.ts.map +1 -0
- package/dist/benchmark.js +1 -1
- package/dist/boot/index.d.ts +70 -0
- package/dist/boot/index.d.ts.map +1 -0
- package/dist/boot/index.js +2 -0
- package/dist/common/component.d.ts +16 -0
- package/dist/common/component.d.ts.map +1 -0
- package/dist/common/errors.d.ts +53 -0
- package/dist/common/errors.d.ts.map +1 -0
- package/dist/common/index.d.ts +14 -0
- package/dist/common/index.d.ts.map +1 -0
- package/dist/common/jsx.d.ts +17 -0
- package/dist/common/jsx.d.ts.map +1 -0
- package/dist/common/jsx.js +1 -0
- package/dist/{jsx-CPjsGyEg.d.ts → common/props.d.ts} +6 -18
- package/dist/common/props.d.ts.map +1 -0
- package/dist/{router-DaGtH1Sq.d.ts → common/router.d.ts} +10 -7
- package/dist/common/router.d.ts.map +1 -0
- package/dist/common/ssr-errors.d.ts +8 -0
- package/dist/common/ssr-errors.d.ts.map +1 -0
- package/dist/common/ssr-errors.js +1 -0
- package/dist/common/ssr.d.ts +17 -0
- package/dist/common/ssr.d.ts.map +1 -0
- package/dist/common/vnode.d.ts +17 -0
- package/dist/common/vnode.d.ts.map +1 -0
- package/dist/common/vnode.js +1 -0
- package/dist/components/link.d.ts +56 -0
- package/dist/components/link.d.ts.map +1 -0
- package/dist/components/link.js +1 -0
- package/dist/dev/invariant.d.ts +83 -0
- package/dist/dev/invariant.d.ts.map +1 -0
- package/dist/dev/invariant.js +2 -0
- package/dist/dev/logger.d.ts +13 -0
- package/dist/dev/logger.d.ts.map +1 -0
- package/dist/dev/logger.js +1 -0
- package/dist/dev/vite-plugin-askr.d.ts +18 -0
- package/dist/dev/vite-plugin-askr.d.ts.map +1 -0
- package/dist/dev/warnings.d.ts +5 -0
- package/dist/dev/warnings.d.ts.map +1 -0
- package/dist/for/for.d.ts +16 -0
- package/dist/for/for.d.ts.map +1 -0
- package/dist/for/for.js +1 -0
- package/dist/for/index.d.ts +2 -63
- package/dist/for/index.d.ts.map +1 -0
- package/dist/for/index.js +1 -1
- package/dist/foundations/core.d.ts +23 -0
- package/dist/foundations/core.d.ts.map +1 -0
- package/dist/foundations/core.js +1 -0
- package/dist/foundations/index.d.ts +3 -669
- package/dist/foundations/index.d.ts.map +1 -0
- package/dist/foundations/index.js +1 -1
- package/dist/foundations/interactions/dismissable.d.ts +58 -0
- package/dist/foundations/interactions/dismissable.d.ts.map +1 -0
- package/dist/foundations/interactions/dismissable.js +1 -0
- package/dist/foundations/interactions/focusable.d.ts +16 -0
- package/dist/foundations/interactions/focusable.d.ts.map +1 -0
- package/dist/foundations/interactions/focusable.js +1 -0
- package/dist/foundations/interactions/hoverable.d.ts +19 -0
- package/dist/foundations/interactions/hoverable.d.ts.map +1 -0
- package/dist/foundations/interactions/hoverable.js +1 -0
- package/dist/foundations/interactions/index.d.ts +5 -0
- package/dist/foundations/interactions/index.d.ts.map +1 -0
- package/dist/foundations/interactions/interaction-policy.d.ts +96 -0
- package/dist/foundations/interactions/interaction-policy.d.ts.map +1 -0
- package/dist/foundations/interactions/interaction-policy.js +1 -0
- package/dist/foundations/interactions/pressable.d.ts +54 -0
- package/dist/foundations/interactions/pressable.d.ts.map +1 -0
- package/dist/foundations/interactions/pressable.js +1 -0
- package/dist/foundations/interactions/roving-focus.d.ts +117 -0
- package/dist/foundations/interactions/roving-focus.d.ts.map +1 -0
- package/dist/foundations/interactions/roving-focus.js +1 -0
- package/dist/foundations/state/controllable.d.ts +53 -0
- package/dist/foundations/state/controllable.d.ts.map +1 -0
- package/dist/foundations/state/controllable.js +1 -0
- package/dist/foundations/state/index.d.ts +2 -0
- package/dist/foundations/state/index.d.ts.map +1 -0
- package/dist/foundations/structures/collection.d.ts +67 -0
- package/dist/foundations/structures/collection.d.ts.map +1 -0
- package/dist/foundations/structures/collection.js +1 -0
- package/dist/foundations/structures/index.d.ts +5 -0
- package/dist/foundations/structures/index.d.ts.map +1 -0
- package/dist/foundations/structures/layer.d.ts +102 -0
- package/dist/foundations/structures/layer.d.ts.map +1 -0
- package/dist/foundations/structures/layer.js +1 -0
- package/dist/{layout-BINPv-nz.d.ts → foundations/structures/layout.d.ts} +3 -4
- package/dist/foundations/structures/layout.d.ts.map +1 -0
- package/dist/foundations/structures/layout.js +1 -0
- package/dist/foundations/structures/portal.d.ts +33 -0
- package/dist/foundations/structures/portal.d.ts.map +1 -0
- package/dist/foundations/structures/portal.js +1 -0
- package/dist/foundations/structures/presence.d.ts +30 -0
- package/dist/foundations/structures/presence.d.ts.map +1 -0
- package/dist/foundations/structures/presence.js +1 -0
- package/dist/foundations/structures/slot.d.ts +31 -0
- package/dist/foundations/structures/slot.d.ts.map +1 -0
- package/dist/foundations/structures/slot.js +1 -0
- package/dist/foundations/structures.d.ts +14 -0
- package/dist/foundations/structures.d.ts.map +1 -0
- package/dist/foundations/structures.js +1 -0
- package/dist/foundations/utilities/aria.d.ts +13 -0
- package/dist/foundations/utilities/aria.d.ts.map +1 -0
- package/dist/foundations/utilities/aria.js +1 -0
- package/dist/foundations/utilities/compose-handlers.d.ts +34 -0
- package/dist/foundations/utilities/compose-handlers.d.ts.map +1 -0
- package/dist/foundations/utilities/compose-handlers.js +1 -0
- package/dist/foundations/utilities/compose-ref.d.ts +24 -0
- package/dist/foundations/utilities/compose-ref.d.ts.map +1 -0
- package/dist/foundations/utilities/compose-ref.js +1 -0
- package/dist/foundations/utilities/event-types.d.ts +17 -0
- package/dist/foundations/utilities/event-types.d.ts.map +1 -0
- package/dist/foundations/utilities/index.d.ts +7 -0
- package/dist/foundations/utilities/index.d.ts.map +1 -0
- package/dist/foundations/utilities/merge-props.d.ts +2 -0
- package/dist/foundations/utilities/merge-props.d.ts.map +1 -0
- package/dist/foundations/utilities/merge-props.js +1 -0
- package/dist/foundations/utilities/use-id.d.ts +29 -0
- package/dist/foundations/utilities/use-id.d.ts.map +1 -0
- package/dist/foundations/utilities/use-id.js +1 -0
- package/dist/fx/fx.d.ts +30 -0
- package/dist/fx/fx.d.ts.map +1 -0
- package/dist/fx/fx.js +1 -0
- package/dist/fx/index.d.ts +5 -184
- package/dist/fx/index.d.ts.map +1 -0
- package/dist/fx/index.js +1 -1
- package/dist/fx/noop.d.ts +12 -0
- package/dist/fx/noop.d.ts.map +1 -0
- package/dist/fx/noop.js +1 -0
- package/dist/fx/timing.d.ts +155 -0
- package/dist/fx/timing.d.ts.map +1 -0
- package/dist/fx/timing.js +1 -0
- package/dist/index.d.ts +18 -37
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -1
- package/dist/jsx/index.d.ts +4 -0
- package/dist/jsx/index.d.ts.map +1 -0
- package/dist/jsx/index.js +1 -0
- package/dist/jsx/jsx-dev-runtime.d.ts +4 -0
- package/dist/jsx/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx/jsx-runtime.d.ts +10 -0
- package/dist/jsx/jsx-runtime.d.ts.map +1 -0
- package/dist/{types-BTT0Fc9S.d.ts → jsx/types.d.ts} +6 -3
- package/dist/jsx/types.d.ts.map +1 -0
- package/dist/jsx/types.js +1 -0
- package/dist/jsx/utils.d.ts +4 -0
- package/dist/jsx/utils.d.ts.map +1 -0
- package/dist/jsx/utils.js +1 -0
- package/dist/jsx-dev-runtime.js +1 -1
- package/dist/jsx-runtime.js +1 -1
- package/dist/node_modules/esbuild/lib/main.js +65 -0
- package/dist/renderer/cleanup.d.ts +25 -0
- package/dist/renderer/cleanup.d.ts.map +1 -0
- package/dist/renderer/cleanup.js +1 -0
- package/dist/renderer/dom.d.ts +44 -0
- package/dist/renderer/dom.d.ts.map +1 -0
- package/dist/renderer/dom.js +1 -0
- package/dist/renderer/evaluate.d.ts +4 -0
- package/dist/renderer/evaluate.d.ts.map +1 -0
- package/dist/renderer/evaluate.js +1 -0
- package/dist/renderer/fastpath.d.ts +7 -0
- package/dist/renderer/fastpath.d.ts.map +1 -0
- package/dist/renderer/fastpath.js +1 -0
- package/dist/renderer/index.d.ts +6 -0
- package/dist/renderer/index.d.ts.map +1 -0
- package/dist/renderer/index.js +1 -0
- package/dist/renderer/keyed.d.ts +23 -0
- package/dist/renderer/keyed.d.ts.map +1 -0
- package/dist/renderer/keyed.js +1 -0
- package/dist/renderer/reconcile.d.ts +88 -0
- package/dist/renderer/reconcile.d.ts.map +1 -0
- package/dist/renderer/reconcile.js +1 -0
- package/dist/renderer/types.d.ts +3 -0
- package/dist/renderer/types.d.ts.map +1 -0
- package/dist/renderer/types.js +1 -0
- package/dist/renderer/utils.d.ts +63 -0
- package/dist/renderer/utils.d.ts.map +1 -0
- package/dist/renderer/utils.js +1 -0
- package/dist/resources/index.d.ts +7 -22
- package/dist/resources/index.d.ts.map +1 -0
- package/dist/resources/index.js +1 -1
- package/dist/router/index.d.ts +8 -87
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +1 -1
- package/dist/router/match.d.ts +22 -0
- package/dist/router/match.d.ts.map +1 -0
- package/dist/router/match.js +1 -0
- package/dist/router/navigate.d.ts +20 -0
- package/dist/router/navigate.d.ts.map +1 -0
- package/dist/router/navigate.js +1 -0
- package/dist/router/route.d.ts +52 -0
- package/dist/router/route.d.ts.map +1 -0
- package/dist/router/route.js +1 -0
- package/dist/runtime/component.d.ts +123 -0
- package/dist/runtime/component.d.ts.map +1 -0
- package/dist/runtime/component.js +1 -0
- package/dist/runtime/context.d.ts +80 -0
- package/dist/runtime/context.d.ts.map +1 -0
- package/dist/runtime/context.js +1 -0
- package/dist/runtime/derive.d.ts +7 -0
- package/dist/runtime/derive.d.ts.map +1 -0
- package/dist/runtime/derive.js +1 -0
- package/dist/runtime/dev-namespace.d.ts +31 -0
- package/dist/runtime/dev-namespace.d.ts.map +1 -0
- package/dist/runtime/dev-namespace.js +1 -0
- package/dist/runtime/events.d.ts +52 -0
- package/dist/runtime/events.d.ts.map +1 -0
- package/dist/runtime/events.js +1 -0
- package/dist/runtime/execution-model.d.ts +4 -0
- package/dist/runtime/execution-model.d.ts.map +1 -0
- package/dist/runtime/execution-model.js +1 -0
- package/dist/runtime/fastlane.d.ts +27 -0
- package/dist/runtime/fastlane.d.ts.map +1 -0
- package/dist/runtime/fastlane.js +1 -0
- package/dist/runtime/for.d.ts +52 -0
- package/dist/runtime/for.d.ts.map +1 -0
- package/dist/runtime/for.js +1 -0
- package/dist/runtime/hydration.d.ts +25 -0
- package/dist/runtime/hydration.d.ts.map +1 -0
- package/dist/runtime/operations.d.ts +39 -0
- package/dist/runtime/operations.d.ts.map +1 -0
- package/dist/runtime/operations.js +1 -0
- package/dist/runtime/resource-cell.d.ts +35 -0
- package/dist/runtime/resource-cell.d.ts.map +1 -0
- package/dist/runtime/resource-cell.js +1 -0
- package/dist/runtime/scheduler.d.ts +48 -0
- package/dist/runtime/scheduler.d.ts.map +1 -0
- package/dist/runtime/scheduler.js +1 -0
- package/dist/runtime/snapshot.d.ts +25 -0
- package/dist/runtime/snapshot.d.ts.map +1 -0
- package/dist/runtime/ssr-bridge.d.ts +10 -0
- package/dist/runtime/ssr-bridge.d.ts.map +1 -0
- package/dist/runtime/ssr-bridge.js +1 -0
- package/dist/runtime/state.d.ts +56 -0
- package/dist/runtime/state.d.ts.map +1 -0
- package/dist/runtime/state.js +1 -0
- package/dist/ssr/attrs.d.ts +26 -0
- package/dist/ssr/attrs.d.ts.map +1 -0
- package/dist/ssr/attrs.js +1 -0
- package/dist/ssr/context.d.ts +47 -0
- package/dist/ssr/context.d.ts.map +1 -0
- package/dist/ssr/context.js +1 -0
- package/dist/ssr/create-ssr.d.ts +19 -0
- package/dist/ssr/create-ssr.d.ts.map +1 -0
- package/dist/ssr/errors.d.ts +6 -0
- package/dist/ssr/errors.d.ts.map +1 -0
- package/dist/ssr/errors.js +1 -0
- package/dist/ssr/escape.d.ts +38 -0
- package/dist/ssr/escape.d.ts.map +1 -0
- package/dist/ssr/escape.js +1 -0
- package/dist/ssr/index.d.ts +18 -94
- package/dist/ssr/index.d.ts.map +1 -0
- package/dist/ssr/index.js +1 -1
- package/dist/ssr/render-keys.d.ts +39 -0
- package/dist/ssr/render-keys.d.ts.map +1 -0
- package/dist/ssr/render-keys.js +1 -0
- package/dist/ssr/sink.d.ts +23 -0
- package/dist/ssr/sink.d.ts.map +1 -0
- package/dist/ssr/sink.js +1 -0
- package/dist/ssr/stream-render.d.ts +7 -0
- package/dist/ssr/stream-render.d.ts.map +1 -0
- package/dist/ssr/stream-render.js +1 -0
- package/dist/ssr/types.d.ts +21 -0
- package/dist/ssr/types.d.ts.map +1 -0
- package/dist/vite/index.js +3 -1
- package/package.json +11 -10
- package/dist/chunk-37RC6ZT3.js +0 -1
- package/dist/chunk-3L6PFAJ3.js +0 -1
- package/dist/chunk-47D5SNYH.js +0 -1
- package/dist/chunk-4RTKQ7SC.js +0 -1
- package/dist/chunk-5PLQPS3O.js +0 -1
- package/dist/chunk-62D2TNHX.js +0 -1
- package/dist/chunk-BP2CKUO6.js +0 -1
- package/dist/chunk-D2JSJKCW.js +0 -1
- package/dist/chunk-EQ5S5GU4.js +0 -1
- package/dist/chunk-HGMOQ3I7.js +0 -1
- package/dist/chunk-HZKAD5DE.js +0 -1
- package/dist/chunk-ILZCMHZM.js +0 -2
- package/dist/chunk-NL44ANML.js +0 -2
- package/dist/chunk-YRY4OLQF.js +0 -1
- package/dist/component-AJMg1Gmv.d.ts +0 -177
- package/dist/jsx-dev-runtime.d.ts +0 -7
- package/dist/jsx-runtime.d.ts +0 -14
- package/dist/logger-NGZDJLVS.js +0 -1
- package/dist/main-EPE35NMW.js +0 -65
- package/dist/navigate-4VAVLF3A.js +0 -1
- package/dist/route-IVG3V65Y.js +0 -1
- package/dist/vite/index.d.ts +0 -17
|
@@ -1,669 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
import { J as JSXElement } from '../jsx-CPjsGyEg.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* composeHandlers
|
|
8
|
-
*
|
|
9
|
-
* Compose two event handlers into one. The first handler runs, and unless it
|
|
10
|
-
* calls `event.preventDefault()` (or sets `defaultPrevented`), the second
|
|
11
|
-
* handler runs. This prevents accidental clobbering of child handlers when
|
|
12
|
-
* injecting props.
|
|
13
|
-
*
|
|
14
|
-
* POLICY DECISIONS (LOCKED):
|
|
15
|
-
*
|
|
16
|
-
* 1. Execution Order
|
|
17
|
-
* First handler runs before second (injected before base).
|
|
18
|
-
* This allows injected handlers to prevent default behavior.
|
|
19
|
-
*
|
|
20
|
-
* 2. Default Prevention Check
|
|
21
|
-
* By default, checks `defaultPrevented` on first argument.
|
|
22
|
-
* Can be disabled via options.checkDefaultPrevented = false.
|
|
23
|
-
*
|
|
24
|
-
* 3. Undefined Handler Support
|
|
25
|
-
* Undefined handlers are skipped (no-op). This simplifies usage
|
|
26
|
-
* where handlers are optional.
|
|
27
|
-
*
|
|
28
|
-
* 4. Type Safety
|
|
29
|
-
* Args are readonly to prevent mutation. Return type matches input.
|
|
30
|
-
*/
|
|
31
|
-
interface ComposeHandlersOptions {
|
|
32
|
-
/**
|
|
33
|
-
* When true (default), do not run the second handler if the first prevented default.
|
|
34
|
-
* When false, always run both handlers.
|
|
35
|
-
*/
|
|
36
|
-
checkDefaultPrevented?: boolean;
|
|
37
|
-
}
|
|
38
|
-
declare function composeHandlers<A extends readonly unknown[]>(first?: (...args: A) => void, second?: (...args: A) => void, options?: ComposeHandlersOptions): (...args: A) => void;
|
|
39
|
-
|
|
40
|
-
declare function mergeProps<TBase extends object, TInjected extends object>(base: TBase, injected: TInjected): TInjected & TBase;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Tiny aria helpers
|
|
44
|
-
*/
|
|
45
|
-
declare function ariaDisabled(disabled?: boolean): {
|
|
46
|
-
'aria-disabled'?: 'true';
|
|
47
|
-
};
|
|
48
|
-
declare function ariaExpanded(expanded?: boolean): {
|
|
49
|
-
'aria-expanded'?: 'true' | 'false';
|
|
50
|
-
};
|
|
51
|
-
declare function ariaSelected(selected?: boolean): {
|
|
52
|
-
'aria-selected'?: 'true' | 'false';
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Ref composition utilities
|
|
57
|
-
*
|
|
58
|
-
* POLICY DECISIONS (LOCKED):
|
|
59
|
-
*
|
|
60
|
-
* 1. Ref Types Supported
|
|
61
|
-
* - Callback refs: (value: T | null) => void
|
|
62
|
-
* - Object refs: { current: T | null }
|
|
63
|
-
* - null/undefined (no-op)
|
|
64
|
-
*
|
|
65
|
-
* 2. Write Failure Handling
|
|
66
|
-
* setRef catches write failures (readonly refs) and ignores them.
|
|
67
|
-
* This is intentional — refs may be readonly in some contexts.
|
|
68
|
-
*
|
|
69
|
-
* 3. Composition Order
|
|
70
|
-
* composeRefs applies refs in array order (left to right).
|
|
71
|
-
* All refs are called even if one fails.
|
|
72
|
-
*/
|
|
73
|
-
type Ref<T> = ((value: T | null) => void) | {
|
|
74
|
-
current: T | null;
|
|
75
|
-
} | null | undefined;
|
|
76
|
-
declare function setRef<T>(ref: Ref<T>, value: T | null): void;
|
|
77
|
-
declare function composeRefs<T>(...refs: Array<Ref<T>>): (value: T | null) => void;
|
|
78
|
-
|
|
79
|
-
interface FormatIdOptions {
|
|
80
|
-
/** Defaults to 'askr' */
|
|
81
|
-
prefix?: string;
|
|
82
|
-
/** Stable, caller-provided identity */
|
|
83
|
-
id: string | number;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* formatId
|
|
87
|
-
*
|
|
88
|
-
* Formats a stable ID from a caller-provided identity.
|
|
89
|
-
* - Pure and deterministic (no time/randomness/global counters)
|
|
90
|
-
* - SSR-safe
|
|
91
|
-
*
|
|
92
|
-
* POLICY DECISIONS (LOCKED):
|
|
93
|
-
*
|
|
94
|
-
* 1. No Auto-Generation
|
|
95
|
-
* Caller must provide the `id`. No random/sequential generation.
|
|
96
|
-
* This ensures determinism and SSR safety.
|
|
97
|
-
*
|
|
98
|
-
* 2. Format Convention
|
|
99
|
-
* IDs are formatted as `{prefix}-{id}`.
|
|
100
|
-
* Default prefix is "askr".
|
|
101
|
-
*
|
|
102
|
-
* 3. Type Coercion
|
|
103
|
-
* Numbers are coerced to strings via String().
|
|
104
|
-
* This is deterministic and consistent.
|
|
105
|
-
*/
|
|
106
|
-
declare function formatId(options: FormatIdOptions): string;
|
|
107
|
-
|
|
108
|
-
interface DefaultPreventable {
|
|
109
|
-
defaultPrevented?: boolean;
|
|
110
|
-
preventDefault?: () => void;
|
|
111
|
-
}
|
|
112
|
-
interface PropagationStoppable {
|
|
113
|
-
stopPropagation?: () => void;
|
|
114
|
-
}
|
|
115
|
-
interface KeyboardLikeEvent extends DefaultPreventable, PropagationStoppable {
|
|
116
|
-
key: string;
|
|
117
|
-
}
|
|
118
|
-
interface PointerLikeEvent extends DefaultPreventable, PropagationStoppable {
|
|
119
|
-
target?: unknown;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* pressable
|
|
124
|
-
*
|
|
125
|
-
* Interaction helper that produces VNode props for 'press' semantics.
|
|
126
|
-
* - Pure and deterministic: no DOM construction or mutation here
|
|
127
|
-
* - The runtime owns event attachment and scheduling
|
|
128
|
-
* - This helper returns plain props (handlers) intended to be attached by the runtime
|
|
129
|
-
*
|
|
130
|
-
* Behaviour:
|
|
131
|
-
* - For native buttons: only an `onClick` prop is provided (no ARIA or keyboard shims)
|
|
132
|
-
* - For non-button elements: add `role="button"` and `tabIndex` and keyboard handlers
|
|
133
|
-
* - Activation: `Enter` activates on keydown, `Space` activates on keyup (matches native button)
|
|
134
|
-
* - Disabled: handlers short-circuit and `aria-disabled` is set for all hosts
|
|
135
|
-
*
|
|
136
|
-
* POLICY DECISIONS (LOCKED):
|
|
137
|
-
*
|
|
138
|
-
* 1. Activation Timing (Platform Parity)
|
|
139
|
-
* - Enter fires on keydown (immediate response)
|
|
140
|
-
* - Space fires on keyup (allows cancel by moving focus, matches native)
|
|
141
|
-
* - Space keydown prevents scroll (matches native button behavior)
|
|
142
|
-
*
|
|
143
|
-
* 2. Disabled Enforcement Strategy
|
|
144
|
-
* - Native buttons: Use HTML `disabled` attribute (platform-enforced non-interactivity)
|
|
145
|
-
* AND `aria-disabled` (consistent a11y signaling)
|
|
146
|
-
* - Non-native: Use `tabIndex=-1` (removes from tab order)
|
|
147
|
-
* AND `aria-disabled` (signals disabled state to AT)
|
|
148
|
-
* - Click handler short-circuits as defense-in-depth (prevents leaked focus issues)
|
|
149
|
-
*
|
|
150
|
-
* 3. Key Repeat Behavior
|
|
151
|
-
* - Held Enter/Space will fire onPress repeatedly (matches native button)
|
|
152
|
-
* - No debouncing or repeat prevention (platform parity)
|
|
153
|
-
*/
|
|
154
|
-
interface PressableOptions {
|
|
155
|
-
disabled?: boolean;
|
|
156
|
-
onPress?: (e: PressEvent) => void;
|
|
157
|
-
/**
|
|
158
|
-
* Whether the host is a native button. Defaults to false.
|
|
159
|
-
*/
|
|
160
|
-
isNativeButton?: boolean;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
type PressEvent = DefaultPreventable & PropagationStoppable;
|
|
164
|
-
interface PressableResult {
|
|
165
|
-
onClick: (e: PressEvent) => void;
|
|
166
|
-
disabled?: true;
|
|
167
|
-
role?: 'button';
|
|
168
|
-
tabIndex?: number;
|
|
169
|
-
onKeyDown?: (e: KeyboardLikeEvent) => void;
|
|
170
|
-
onKeyUp?: (e: KeyboardLikeEvent) => void;
|
|
171
|
-
'aria-disabled'?: 'true';
|
|
172
|
-
}
|
|
173
|
-
declare function pressable({ disabled, onPress, isNativeButton, }: PressableOptions): PressableResult;
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* dismissable
|
|
177
|
-
*
|
|
178
|
-
* THE dismissal primitive. Handles Escape key and outside interactions.
|
|
179
|
-
*
|
|
180
|
-
* INVARIANTS:
|
|
181
|
-
* 1. Returns props that compose via mergeProps (no factories)
|
|
182
|
-
* 2. Disabled state respected exactly once, here
|
|
183
|
-
* 3. No side effects - pure props generation
|
|
184
|
-
* 4. Outside detection requires explicit node reference
|
|
185
|
-
* 5. This is the ONLY dismissal primitive - do not create alternatives
|
|
186
|
-
*
|
|
187
|
-
* DESIGN:
|
|
188
|
-
* - Returns standard event handler props (onKeyDown, onPointerDownCapture)
|
|
189
|
-
* - Composable via mergeProps with other foundations
|
|
190
|
-
* - Caller provides node reference for outside detection
|
|
191
|
-
* - Single onDismiss callback for all dismiss triggers
|
|
192
|
-
*
|
|
193
|
-
* PIT OF SUCCESS:
|
|
194
|
-
* ✓ Can't accidentally bypass (only way to get dismiss behavior)
|
|
195
|
-
* ✓ Can't duplicate (disabled checked once)
|
|
196
|
-
* ✓ Composes via mergeProps (standard props)
|
|
197
|
-
* ✓ Wrong usage is hard (no factories to misuse)
|
|
198
|
-
*
|
|
199
|
-
* USAGE:
|
|
200
|
-
* const props = dismissable({
|
|
201
|
-
* node: elementRef,
|
|
202
|
-
* disabled: false,
|
|
203
|
-
* onDismiss: () => close()
|
|
204
|
-
* });
|
|
205
|
-
*
|
|
206
|
-
* <div ref={elementRef} {...props}>Content</div>
|
|
207
|
-
*
|
|
208
|
-
* MISUSE EXAMPLE (PREVENTED):
|
|
209
|
-
* ❌ Can't forget to check disabled - checked inside dismissable
|
|
210
|
-
* ❌ Can't create custom escape handler - this is the only one
|
|
211
|
-
* ❌ Can't bypass via direct event listeners - mergeProps composes correctly
|
|
212
|
-
*/
|
|
213
|
-
interface DismissableOptions {
|
|
214
|
-
/**
|
|
215
|
-
* Reference to the element for outside click detection
|
|
216
|
-
*/
|
|
217
|
-
node?: Node | null;
|
|
218
|
-
/**
|
|
219
|
-
* Whether dismiss is disabled
|
|
220
|
-
*/
|
|
221
|
-
disabled?: boolean;
|
|
222
|
-
/**
|
|
223
|
-
* Called when dismiss is triggered (Escape or outside click)
|
|
224
|
-
*/
|
|
225
|
-
onDismiss?: (trigger: 'escape' | 'outside') => void;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
declare function dismissable({ node, disabled, onDismiss }: DismissableOptions): {
|
|
229
|
-
onKeyDown: (e: KeyboardLikeEvent) => void;
|
|
230
|
-
onPointerDownCapture: (e: PointerLikeEvent) => void;
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* focusable
|
|
235
|
-
*
|
|
236
|
-
* Normalize focus-related props for hosts.
|
|
237
|
-
* - No DOM manipulation here; returns props that the runtime may attach.
|
|
238
|
-
*/
|
|
239
|
-
interface FocusableOptions {
|
|
240
|
-
disabled?: boolean;
|
|
241
|
-
tabIndex?: number | undefined;
|
|
242
|
-
}
|
|
243
|
-
interface FocusableResult {
|
|
244
|
-
tabIndex?: number;
|
|
245
|
-
'aria-disabled'?: 'true';
|
|
246
|
-
}
|
|
247
|
-
declare function focusable({ disabled, tabIndex, }: FocusableOptions): FocusableResult;
|
|
248
|
-
|
|
249
|
-
/**
|
|
250
|
-
* hoverable
|
|
251
|
-
*
|
|
252
|
-
* Produces props for pointer enter/leave handling. Pure and deterministic.
|
|
253
|
-
*/
|
|
254
|
-
interface HoverableOptions {
|
|
255
|
-
disabled?: boolean;
|
|
256
|
-
onEnter?: (e: HoverEvent) => void;
|
|
257
|
-
onLeave?: (e: HoverEvent) => void;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
type HoverEvent = DefaultPreventable & PropagationStoppable;
|
|
261
|
-
interface HoverableResult {
|
|
262
|
-
onPointerEnter?: (e: HoverEvent) => void;
|
|
263
|
-
onPointerLeave?: (e: HoverEvent) => void;
|
|
264
|
-
}
|
|
265
|
-
declare function hoverable({ disabled, onEnter, onLeave, }: HoverableOptions): HoverableResult;
|
|
266
|
-
|
|
267
|
-
/**
|
|
268
|
-
* rovingFocus
|
|
269
|
-
*
|
|
270
|
-
* Single tab stop navigation with arrow-key control.
|
|
271
|
-
*
|
|
272
|
-
* INVARIANTS:
|
|
273
|
-
* 1. Only one item in the group is reachable via Tab (single tab stop)
|
|
274
|
-
* 2. Arrow keys move focus within the group
|
|
275
|
-
* 3. Orientation determines which arrow keys are active
|
|
276
|
-
* 4. Looping is opt-in
|
|
277
|
-
* 5. Disabled items are skipped
|
|
278
|
-
* 6. Returns props objects, never factories (composes via mergeProps)
|
|
279
|
-
*
|
|
280
|
-
* DESIGN:
|
|
281
|
-
* - Container gets onKeyDown for arrow navigation
|
|
282
|
-
* - Each item gets tabIndex based on current selection
|
|
283
|
-
* - Navigation logic is pure - caller controls focus application
|
|
284
|
-
* - Disabled check happens per-item via predicate
|
|
285
|
-
*
|
|
286
|
-
* PIT OF SUCCESS:
|
|
287
|
-
* ✓ Can't accidentally break tab order (tabIndex assigned correctly)
|
|
288
|
-
* ✓ Can't duplicate navigation logic (single source)
|
|
289
|
-
* ✓ Composes via mergeProps (all standard props)
|
|
290
|
-
* ✓ Type-safe - invalid indices caught at call site
|
|
291
|
-
*
|
|
292
|
-
* USAGE:
|
|
293
|
-
* const nav = rovingFocus({
|
|
294
|
-
* currentIndex: 0,
|
|
295
|
-
* itemCount: 3,
|
|
296
|
-
* orientation: 'horizontal',
|
|
297
|
-
* onNavigate: setIndex
|
|
298
|
-
* });
|
|
299
|
-
*
|
|
300
|
-
* <div {...nav.container}>
|
|
301
|
-
* <button {...nav.item(0)}>First</button>
|
|
302
|
-
* <button {...nav.item(1)}>Second</button>
|
|
303
|
-
* </div>
|
|
304
|
-
*
|
|
305
|
-
* MISUSE EXAMPLE (PREVENTED):
|
|
306
|
-
* ❌ Can't forget to set tabIndex - returned in item props
|
|
307
|
-
* ❌ Can't create conflicting arrow handlers - mergeProps composes
|
|
308
|
-
* ❌ Can't skip disabled items incorrectly - logic is internal
|
|
309
|
-
*/
|
|
310
|
-
|
|
311
|
-
type Orientation = 'horizontal' | 'vertical' | 'both';
|
|
312
|
-
interface RovingFocusOptions {
|
|
313
|
-
/**
|
|
314
|
-
* Current focused index
|
|
315
|
-
*/
|
|
316
|
-
currentIndex: number;
|
|
317
|
-
/**
|
|
318
|
-
* Total number of items
|
|
319
|
-
*/
|
|
320
|
-
itemCount: number;
|
|
321
|
-
/**
|
|
322
|
-
* Navigation orientation
|
|
323
|
-
* - horizontal: ArrowLeft/ArrowRight
|
|
324
|
-
* - vertical: ArrowUp/ArrowDown
|
|
325
|
-
* - both: all arrow keys
|
|
326
|
-
*/
|
|
327
|
-
orientation?: Orientation;
|
|
328
|
-
/**
|
|
329
|
-
* Whether to loop when reaching the end
|
|
330
|
-
*/
|
|
331
|
-
loop?: boolean;
|
|
332
|
-
/**
|
|
333
|
-
* Callback when navigation occurs
|
|
334
|
-
*/
|
|
335
|
-
onNavigate?: (index: number) => void;
|
|
336
|
-
/**
|
|
337
|
-
* Optional disabled state check per index
|
|
338
|
-
*/
|
|
339
|
-
isDisabled?: (index: number) => boolean;
|
|
340
|
-
}
|
|
341
|
-
interface RovingFocusResult {
|
|
342
|
-
/**
|
|
343
|
-
* Props for the container element (composes via mergeProps)
|
|
344
|
-
*/
|
|
345
|
-
container: {
|
|
346
|
-
onKeyDown: (e: KeyboardLikeEvent) => void;
|
|
347
|
-
};
|
|
348
|
-
/**
|
|
349
|
-
* Generate props for an item at the given index (composes via mergeProps)
|
|
350
|
-
*/
|
|
351
|
-
item: (index: number) => {
|
|
352
|
-
tabIndex: number;
|
|
353
|
-
'data-roving-index': number;
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
declare function rovingFocus(options: RovingFocusOptions): RovingFocusResult;
|
|
357
|
-
|
|
358
|
-
interface InteractionPolicyInput {
|
|
359
|
-
/** Whether the host element is a native interactive element (button, a, etc) */
|
|
360
|
-
isNative: boolean;
|
|
361
|
-
/** Disabled state - checked ONLY here, never in components */
|
|
362
|
-
disabled: boolean;
|
|
363
|
-
/** User-provided press handler - semantic action, not DOM event */
|
|
364
|
-
onPress?: (e: Event) => void;
|
|
365
|
-
/** Optional ref to compose */
|
|
366
|
-
ref?: Ref<unknown>;
|
|
367
|
-
}
|
|
368
|
-
/**
|
|
369
|
-
* THE interaction policy. Components MUST use this, NEVER implement
|
|
370
|
-
* interaction logic directly.
|
|
371
|
-
*/
|
|
372
|
-
declare function applyInteractionPolicy({ isNative, disabled, onPress, ref, }: InteractionPolicyInput): {
|
|
373
|
-
disabled: true | undefined;
|
|
374
|
-
onClick: (e: Event) => void;
|
|
375
|
-
ref: Ref<unknown>;
|
|
376
|
-
} | {
|
|
377
|
-
'aria-disabled': true | undefined;
|
|
378
|
-
tabIndex: number;
|
|
379
|
-
ref: Ref<unknown>;
|
|
380
|
-
onClick: (e: DefaultPreventable & PropagationStoppable) => void;
|
|
381
|
-
disabled?: true;
|
|
382
|
-
role?: "button";
|
|
383
|
-
onKeyDown?: (e: KeyboardLikeEvent) => void;
|
|
384
|
-
onKeyUp?: (e: KeyboardLikeEvent) => void;
|
|
385
|
-
};
|
|
386
|
-
/**
|
|
387
|
-
* Merge rule for Slot / asChild
|
|
388
|
-
*
|
|
389
|
-
* Precedence:
|
|
390
|
-
* policy → user → child
|
|
391
|
-
*
|
|
392
|
-
* Event handlers are composed (policy first).
|
|
393
|
-
* Refs are always composed.
|
|
394
|
-
* Policy props MUST take precedence to enforce invariants.
|
|
395
|
-
*/
|
|
396
|
-
declare function mergeInteractionProps(childProps: Record<string, unknown>, policyProps: Record<string, unknown>, userProps?: Record<string, unknown>): Record<string, unknown>;
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* controllable
|
|
400
|
-
*
|
|
401
|
-
* Small utilities for controlled vs uncontrolled components. These helpers are
|
|
402
|
-
* intentionally minimal and do not manage state themselves; they help component
|
|
403
|
-
* implementations make correct decisions about when to call `onChange` vs
|
|
404
|
-
* update internal state.
|
|
405
|
-
*
|
|
406
|
-
* POLICY DECISIONS (LOCKED):
|
|
407
|
-
*
|
|
408
|
-
* 1. Controlled Detection
|
|
409
|
-
* A value is "controlled" if it is not `undefined`.
|
|
410
|
-
* This matches React conventions and is SSR-safe.
|
|
411
|
-
*
|
|
412
|
-
* 2. onChange Timing
|
|
413
|
-
* - Controlled mode: onChange called immediately, no internal update
|
|
414
|
-
* - Uncontrolled mode: internal state updated first, then onChange called
|
|
415
|
-
* This ensures onChange sees the new value in both modes.
|
|
416
|
-
*
|
|
417
|
-
* 3. Value Equality
|
|
418
|
-
* controllableState uses Object.is() to prevent unnecessary onChange calls.
|
|
419
|
-
* This is intentional — strict equality, no deep comparison.
|
|
420
|
-
*/
|
|
421
|
-
|
|
422
|
-
declare function isControlled<T>(value: T | undefined): value is T;
|
|
423
|
-
declare function resolveControllable<T>(value: T | undefined, defaultValue: T): {
|
|
424
|
-
value: T;
|
|
425
|
-
isControlled: boolean;
|
|
426
|
-
};
|
|
427
|
-
declare function makeControllable<T>(options: {
|
|
428
|
-
value: T | undefined;
|
|
429
|
-
defaultValue: T;
|
|
430
|
-
onChange?: (next: T) => void;
|
|
431
|
-
setInternal?: (next: T) => void;
|
|
432
|
-
}): {
|
|
433
|
-
set: (next: T) => void;
|
|
434
|
-
isControlled: boolean;
|
|
435
|
-
};
|
|
436
|
-
type ControllableState<T> = State<T> & {
|
|
437
|
-
isControlled: boolean;
|
|
438
|
-
};
|
|
439
|
-
/**
|
|
440
|
-
* controllableState
|
|
441
|
-
*
|
|
442
|
-
* Hook-like primitive that mirrors `state()` semantics while supporting
|
|
443
|
-
* controlled/uncontrolled behavior.
|
|
444
|
-
*/
|
|
445
|
-
declare function controllableState<T>(options: {
|
|
446
|
-
value: T | undefined;
|
|
447
|
-
defaultValue: T;
|
|
448
|
-
onChange?: (next: T) => void;
|
|
449
|
-
}): ControllableState<T>;
|
|
450
|
-
|
|
451
|
-
type SlotProps = {
|
|
452
|
-
asChild: true;
|
|
453
|
-
children: JSXElement;
|
|
454
|
-
[key: string]: unknown;
|
|
455
|
-
} | {
|
|
456
|
-
asChild?: false;
|
|
457
|
-
children?: unknown;
|
|
458
|
-
};
|
|
459
|
-
/**
|
|
460
|
-
* Slot
|
|
461
|
-
*
|
|
462
|
-
* Structural primitive for prop forwarding patterns.
|
|
463
|
-
*
|
|
464
|
-
* POLICY DECISIONS (LOCKED):
|
|
465
|
-
*
|
|
466
|
-
* 1. asChild Pattern
|
|
467
|
-
* When asChild=true, merges props into the single child element.
|
|
468
|
-
* Child must be a valid JSXElement; non-element children return null.
|
|
469
|
-
* **Slot props override child props** (injection pattern).
|
|
470
|
-
*
|
|
471
|
-
* 2. Fallback Behavior
|
|
472
|
-
* When asChild=false, returns a Fragment (structural no-op).
|
|
473
|
-
* No DOM element is introduced.
|
|
474
|
-
*
|
|
475
|
-
* 3. Type Safety
|
|
476
|
-
* asChild=true requires exactly one JSXElement child (enforced by type).
|
|
477
|
-
* Runtime validates with isElement() check.
|
|
478
|
-
*/
|
|
479
|
-
declare function Slot(props: SlotProps): JSXElement | null;
|
|
480
|
-
|
|
481
|
-
interface PresenceProps {
|
|
482
|
-
present: boolean | (() => boolean);
|
|
483
|
-
children?: unknown;
|
|
484
|
-
}
|
|
485
|
-
/**
|
|
486
|
-
* Presence
|
|
487
|
-
*
|
|
488
|
-
* Structural policy primitive for conditional mount/unmount.
|
|
489
|
-
* - No timers
|
|
490
|
-
* - No animation coupling
|
|
491
|
-
* - No DOM side-effects
|
|
492
|
-
*
|
|
493
|
-
* POLICY DECISIONS (LOCKED):
|
|
494
|
-
*
|
|
495
|
-
* 1. Present as Function
|
|
496
|
-
* Accepts boolean OR function to support lazy evaluation patterns.
|
|
497
|
-
* Function is called once per render. Use boolean form for static values.
|
|
498
|
-
*
|
|
499
|
-
* 2. Children Type
|
|
500
|
-
* `children` is intentionally `unknown` to remain runtime-agnostic.
|
|
501
|
-
* The runtime owns child normalization and validation.
|
|
502
|
-
*
|
|
503
|
-
* 3. Immediate Mount/Unmount
|
|
504
|
-
* No exit animations or transitions. When `present` becomes false,
|
|
505
|
-
* children are removed immediately. Animation must be layered above
|
|
506
|
-
* this primitive.
|
|
507
|
-
*/
|
|
508
|
-
declare function Presence({ present, children, }: PresenceProps): JSXElement | null;
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* Portal / Host primitive.
|
|
512
|
-
*
|
|
513
|
-
* Foundations remain runtime-agnostic: a portal is an explicit read/write slot.
|
|
514
|
-
* Scheduling and attachment are owned by the runtime when `createPortalSlot`
|
|
515
|
-
* exists; otherwise this falls back to a local slot (deterministic, but does
|
|
516
|
-
* not schedule updates).
|
|
517
|
-
*
|
|
518
|
-
* POLICY DECISIONS (LOCKED):
|
|
519
|
-
*
|
|
520
|
-
* 1. Local Mutable State
|
|
521
|
-
* Foundations may use local mutable state ONLY to model deterministic slots,
|
|
522
|
-
* never to coordinate timing, effects, or ordering. The fallback mode uses
|
|
523
|
-
* closure-local `mounted` and `value` variables which are non-escaping and
|
|
524
|
-
* deterministic.
|
|
525
|
-
*
|
|
526
|
-
* 2. Return Type Philosophy
|
|
527
|
-
* Portal call signatures return `unknown` (intentionally opaque). The runtime
|
|
528
|
-
* owns the concrete type. This prevents foundations from assuming JSX.Element
|
|
529
|
-
* or DOM node types, maintaining runtime-agnostic portability.
|
|
530
|
-
*/
|
|
531
|
-
interface Portal<T = unknown> {
|
|
532
|
-
/** Mount point — rendered exactly once */
|
|
533
|
-
(): unknown;
|
|
534
|
-
/** Render content into the portal */
|
|
535
|
-
render(props: {
|
|
536
|
-
children?: T;
|
|
537
|
-
}): unknown;
|
|
538
|
-
}
|
|
539
|
-
declare function definePortal<T = unknown>(): Portal<T>;
|
|
540
|
-
declare const DefaultPortal: Portal<unknown>;
|
|
541
|
-
|
|
542
|
-
/**
|
|
543
|
-
* createCollection
|
|
544
|
-
*
|
|
545
|
-
* Ordered descendant registry for coordinating items without DOM queries.
|
|
546
|
-
*
|
|
547
|
-
* INVARIANTS:
|
|
548
|
-
* 1. Registration order determines item order (no DOM queries)
|
|
549
|
-
* 2. Stable ordering across renders (insertion order preserved)
|
|
550
|
-
* 3. Each item may have metadata (type-safe, user-defined)
|
|
551
|
-
* 4. No implicit global state (explicit collection instances)
|
|
552
|
-
* 5. No automatic cleanup (caller controls lifecycle)
|
|
553
|
-
*
|
|
554
|
-
* DESIGN:
|
|
555
|
-
* - Returns a registry API ({ register, items, clear })
|
|
556
|
-
* - Items are stored in insertion order
|
|
557
|
-
* - Registration returns an unregister function
|
|
558
|
-
* - No side effects on registration (pure data structure)
|
|
559
|
-
*
|
|
560
|
-
* USAGE:
|
|
561
|
-
* const collection = createCollection<HTMLElement, { disabled: boolean }>();
|
|
562
|
-
* const unregister = collection.register(element, { disabled: false });
|
|
563
|
-
* const allItems = collection.items();
|
|
564
|
-
* unregister();
|
|
565
|
-
*/
|
|
566
|
-
type CollectionItem<TNode, TMetadata = unknown> = {
|
|
567
|
-
node: TNode;
|
|
568
|
-
metadata: TMetadata;
|
|
569
|
-
};
|
|
570
|
-
interface Collection<TNode, TMetadata = unknown> {
|
|
571
|
-
/**
|
|
572
|
-
* Register a node with optional metadata.
|
|
573
|
-
* Returns an unregister function.
|
|
574
|
-
*/
|
|
575
|
-
register(node: TNode, metadata: TMetadata): () => void;
|
|
576
|
-
/**
|
|
577
|
-
* Get all registered items in insertion order.
|
|
578
|
-
*/
|
|
579
|
-
items(): ReadonlyArray<CollectionItem<TNode, TMetadata>>;
|
|
580
|
-
/**
|
|
581
|
-
* Clear all registered items.
|
|
582
|
-
*/
|
|
583
|
-
clear(): void;
|
|
584
|
-
/**
|
|
585
|
-
* Get the count of registered items.
|
|
586
|
-
*/
|
|
587
|
-
size(): number;
|
|
588
|
-
}
|
|
589
|
-
declare function createCollection<TNode, TMetadata = unknown>(): Collection<TNode, TMetadata>;
|
|
590
|
-
|
|
591
|
-
/**
|
|
592
|
-
* createLayer
|
|
593
|
-
*
|
|
594
|
-
* Manages stacking order and coordination for overlays (modals, popovers, etc).
|
|
595
|
-
*
|
|
596
|
-
* INVARIANTS:
|
|
597
|
-
* 1. Layers are ordered by registration time (FIFO)
|
|
598
|
-
* 2. Only the top layer handles Escape key
|
|
599
|
-
* 3. Only the top layer handles outside pointer events
|
|
600
|
-
* 4. Nested layers are supported
|
|
601
|
-
* 5. Does not implement portals (orthogonal concern)
|
|
602
|
-
* 6. No automatic DOM insertion (caller controls mounting)
|
|
603
|
-
*
|
|
604
|
-
* DESIGN:
|
|
605
|
-
* - Returns a layer manager with register/unregister API
|
|
606
|
-
* - Each layer has a unique ID and can query if it's the top layer
|
|
607
|
-
* - Escape and outside pointer coordination via callbacks
|
|
608
|
-
* - No z-index management (CSS concern)
|
|
609
|
-
*
|
|
610
|
-
* USAGE:
|
|
611
|
-
* const manager = createLayer();
|
|
612
|
-
*
|
|
613
|
-
* const layer = manager.register({
|
|
614
|
-
* onEscape: () => { ... },
|
|
615
|
-
* onOutsidePointer: () => { ... }
|
|
616
|
-
* });
|
|
617
|
-
*
|
|
618
|
-
* layer.isTop(); // true if this is the topmost layer
|
|
619
|
-
* layer.unregister();
|
|
620
|
-
*/
|
|
621
|
-
interface LayerOptions {
|
|
622
|
-
/**
|
|
623
|
-
* Called when Escape is pressed and this is the top layer
|
|
624
|
-
*/
|
|
625
|
-
onEscape?: () => void;
|
|
626
|
-
/**
|
|
627
|
-
* Called when pointer event occurs outside and this is the top layer
|
|
628
|
-
*/
|
|
629
|
-
onOutsidePointer?: (e: PointerEvent) => void;
|
|
630
|
-
/**
|
|
631
|
-
* Optional node reference for outside pointer detection
|
|
632
|
-
*/
|
|
633
|
-
node?: Node | null;
|
|
634
|
-
}
|
|
635
|
-
interface Layer {
|
|
636
|
-
/**
|
|
637
|
-
* Unique layer ID
|
|
638
|
-
*/
|
|
639
|
-
id: number;
|
|
640
|
-
/**
|
|
641
|
-
* Check if this layer is the topmost
|
|
642
|
-
*/
|
|
643
|
-
isTop(): boolean;
|
|
644
|
-
/**
|
|
645
|
-
* Remove this layer from the stack
|
|
646
|
-
*/
|
|
647
|
-
unregister(): void;
|
|
648
|
-
}
|
|
649
|
-
interface LayerManager {
|
|
650
|
-
/**
|
|
651
|
-
* Register a new layer
|
|
652
|
-
*/
|
|
653
|
-
register(options: LayerOptions): Layer;
|
|
654
|
-
/**
|
|
655
|
-
* Get all active layers in order
|
|
656
|
-
*/
|
|
657
|
-
layers(): ReadonlyArray<Layer>;
|
|
658
|
-
/**
|
|
659
|
-
* Manually trigger escape handling on the top layer
|
|
660
|
-
*/
|
|
661
|
-
handleEscape(): void;
|
|
662
|
-
/**
|
|
663
|
-
* Manually trigger outside pointer handling on the top layer
|
|
664
|
-
*/
|
|
665
|
-
handleOutsidePointer(e: PointerEvent): void;
|
|
666
|
-
}
|
|
667
|
-
declare function createLayer(): LayerManager;
|
|
668
|
-
|
|
669
|
-
export { type Collection, type CollectionItem, type ComposeHandlersOptions, type ControllableState, DefaultPortal, type DismissableOptions, type FocusableOptions, type FocusableResult, type FormatIdOptions, type HoverableOptions, type HoverableResult, type InteractionPolicyInput, JSXElement, type Layer, type LayerManager, type LayerOptions, type Orientation, type Portal, Presence, type PresenceProps, type PressableOptions, type PressableResult, type Ref, type RovingFocusOptions, type RovingFocusResult, Slot, type SlotProps, applyInteractionPolicy, ariaDisabled, ariaExpanded, ariaSelected, composeHandlers, composeRefs, controllableState, createCollection, createLayer, definePortal, dismissable, focusable, formatId, hoverable, isControlled, makeControllable, mergeInteractionProps, mergeProps, pressable, resolveControllable, rovingFocus, setRef };
|
|
1
|
+
export * from './core';
|
|
2
|
+
export * from './structures';
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/foundations/index.ts"],"names":[],"mappings":"AAKA,cAAc,QAAQ,CAAC;AACvB,cAAc,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import"./core.js";import"./structures.js";import{DefaultPortal as a,definePortal as l}from"./structures/portal.js";import{Presence as m}from"./structures/presence.js";import{Slot as x}from"./structures/slot.js";import{applyInteractionPolicy as i,mergeInteractionProps as n}from"./interactions/interaction-policy.js";import{ariaDisabled as d,ariaExpanded as b,ariaSelected as P}from"./utilities/aria.js";import{composeHandlers as y}from"./utilities/compose-handlers.js";import{composeRefs as g,setRef as v}from"./utilities/compose-ref.js";import{controllableState as S,isControlled as D,makeControllable as R,resolveControllable as h}from"./state/controllable.js";import{createCollection as E}from"./structures/collection.js";import{createLayer as H}from"./structures/layer.js";import{dismissable as j}from"./interactions/dismissable.js";import{focusable as w}from"./interactions/focusable.js";import{formatId as A}from"./utilities/use-id.js";import{hoverable as G}from"./interactions/hoverable.js";import{layout as K}from"./structures/layout.js";import{mergeProps as N}from"./utilities/merge-props.js";import{pressable as Q}from"./interactions/pressable.js";import{rovingFocus as U}from"./interactions/roving-focus.js";export{a as DefaultPortal,m as Presence,x as Slot,i as applyInteractionPolicy,d as ariaDisabled,b as ariaExpanded,P as ariaSelected,y as composeHandlers,g as composeRefs,S as controllableState,E as createCollection,H as createLayer,l as definePortal,j as dismissable,w as focusable,A as formatId,G as hoverable,D as isControlled,K as layout,R as makeControllable,n as mergeInteractionProps,N as mergeProps,Q as pressable,h as resolveControllable,U as rovingFocus,v as setRef};
|