elements-kit 0.18.2 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/README.md +14 -0
  2. package/dist/await.d.mts +53 -0
  3. package/dist/await.mjs +70 -0
  4. package/dist/custom-elements.d.mts +1 -1
  5. package/dist/{element-xQwq4ulc.mjs → element-D3om9yA6.mjs} +71 -4
  6. package/dist/for.d.mts +20 -26
  7. package/dist/for.mjs +29 -4
  8. package/dist/fragment-ROPRBJQd.mjs +61 -0
  9. package/dist/hydrate/index.d.mts +41 -0
  10. package/dist/hydrate/index.mjs +2 -0
  11. package/dist/hydrate-6Qx4n4Su.mjs +380 -0
  12. package/dist/integrations/astro-client.d.mts +17 -0
  13. package/dist/integrations/astro-client.mjs +23 -0
  14. package/dist/integrations/astro-server.d.mts +15 -0
  15. package/dist/integrations/astro-server.mjs +39 -0
  16. package/dist/integrations/astro-slots.d.mts +12 -0
  17. package/dist/integrations/astro-slots.mjs +30 -0
  18. package/dist/integrations/astro.d.mts +46 -0
  19. package/dist/integrations/astro.mjs +64 -0
  20. package/dist/integrations/react.d.mts +1 -1
  21. package/dist/integrations/react.mjs +2 -2
  22. package/dist/jsx-runtime/index.d.mts +1 -1
  23. package/dist/jsx-runtime/index.mjs +2 -20
  24. package/dist/{lib-Dkc7cV5F.mjs → lib-DYypKhxk.mjs} +63 -5
  25. package/dist/render.mjs +1 -1
  26. package/dist/{scope-CnEvL9Nd.mjs → scope-zbEG299F.mjs} +1 -1
  27. package/dist/server/index.d.mts +43 -0
  28. package/dist/server/index.mjs +2 -0
  29. package/dist/server-iFSng50i.mjs +385 -0
  30. package/dist/signals/index.d.mts +2 -2
  31. package/dist/signals/index.mjs +5 -3
  32. package/dist/{slot-B8y0aEoz.d.mts → slot-BFWXeFRl.d.mts} +6 -0
  33. package/dist/{slot-Cne__au7.mjs → slot-Dvf30O0B.mjs} +12 -1
  34. package/dist/slot.d.mts +1 -1
  35. package/dist/slot.mjs +1 -1
  36. package/dist/{infer-B7T5hi_D.d.mts → types-ncUK9rki.d.mts} +140 -141
  37. package/dist/ui/overlay/index.css +70 -0
  38. package/dist/ui/overlay/index.d.mts +209 -0
  39. package/dist/ui/overlay/index.mjs +1001 -0
  40. package/dist/ui/overlay/overlay.css +332 -0
  41. package/dist/utilities/_observe.mjs +1 -1
  42. package/dist/utilities/active-element.d.mts +1 -1
  43. package/dist/utilities/active-element.mjs +1 -1
  44. package/dist/utilities/async.d.mts +19 -2
  45. package/dist/utilities/async.mjs +49 -2
  46. package/dist/utilities/context.mjs +1 -1
  47. package/dist/utilities/debounced.d.mts +1 -1
  48. package/dist/utilities/debounced.mjs +1 -1
  49. package/dist/utilities/dom-lifecycle.bench.mjs +3255 -1
  50. package/dist/utilities/dom-lifecycle.mjs +1 -1
  51. package/dist/utilities/element-rect.d.mts +1 -1
  52. package/dist/utilities/element-rect.mjs +1 -1
  53. package/dist/utilities/element-scroll.d.mts +1 -1
  54. package/dist/utilities/event-driven.d.mts +1 -1
  55. package/dist/utilities/event-driven.mjs +1 -1
  56. package/dist/utilities/event-listener.d.mts +1 -1
  57. package/dist/utilities/event-listener.mjs +1 -1
  58. package/dist/utilities/focus-within.d.mts +1 -1
  59. package/dist/utilities/focus-within.mjs +1 -1
  60. package/dist/utilities/form-object.d.mts +96 -0
  61. package/dist/utilities/form-object.mjs +285 -0
  62. package/dist/utilities/hover.d.mts +1 -1
  63. package/dist/utilities/hover.mjs +1 -1
  64. package/dist/utilities/interval.d.mts +1 -1
  65. package/dist/utilities/interval.mjs +1 -1
  66. package/dist/utilities/location.d.mts +1 -1
  67. package/dist/utilities/location.mjs +1 -1
  68. package/dist/utilities/media-devices.d.mts +1 -1
  69. package/dist/utilities/media-devices.mjs +1 -1
  70. package/dist/utilities/media-player.d.mts +1 -1
  71. package/dist/utilities/media-query.d.mts +1 -1
  72. package/dist/utilities/media-query.mjs +1 -1
  73. package/dist/utilities/network.d.mts +1 -1
  74. package/dist/utilities/network.mjs +1 -1
  75. package/dist/utilities/orientation.d.mts +1 -1
  76. package/dist/utilities/orientation.mjs +1 -1
  77. package/dist/utilities/previous.d.mts +1 -1
  78. package/dist/utilities/previous.mjs +1 -1
  79. package/dist/utilities/promise.d.mts +19 -2
  80. package/dist/utilities/promise.mjs +33 -3
  81. package/dist/utilities/retry.mjs +1 -1
  82. package/dist/utilities/routing.d.mts +1 -1
  83. package/dist/utilities/routing.mjs +1 -1
  84. package/dist/utilities/search-params.d.mts +1 -1
  85. package/dist/utilities/storage.d.mts +1 -1
  86. package/dist/utilities/throttled.d.mts +1 -1
  87. package/dist/utilities/throttled.mjs +1 -1
  88. package/dist/utilities/timeout.d.mts +1 -1
  89. package/dist/utilities/timeout.mjs +1 -1
  90. package/dist/utilities/window-focus.d.mts +1 -1
  91. package/dist/utilities/window-focus.mjs +1 -1
  92. package/dist/utilities/window-size.d.mts +1 -1
  93. package/dist/utilities/window-size.mjs +1 -1
  94. package/package.json +20 -5
  95. package/dist/benchmark.CX_oY03V-CSLAXL5f.mjs +0 -5145
  96. package/dist/magic-string.es-CXefOmkB.mjs +0 -1011
  97. package/dist/test.BmQO5GaM-Ddz9cDxc.mjs +0 -8266
  98. package/dist/utilities/active-element.test.d.mts +0 -1
  99. package/dist/utilities/active-element.test.mjs +0 -25
  100. package/dist/utilities/async.test.d.mts +0 -1
  101. package/dist/utilities/async.test.mjs +0 -275
  102. package/dist/utilities/context.test.d.mts +0 -1
  103. package/dist/utilities/context.test.mjs +0 -171
  104. package/dist/utilities/debounced.test.d.mts +0 -1
  105. package/dist/utilities/debounced.test.mjs +0 -68
  106. package/dist/utilities/dom-lifecycle.test.d.mts +0 -1
  107. package/dist/utilities/dom-lifecycle.test.mjs +0 -228
  108. package/dist/utilities/element-rect.test.d.mts +0 -1
  109. package/dist/utilities/element-rect.test.mjs +0 -101
  110. package/dist/utilities/element-scroll.test.d.mts +0 -1
  111. package/dist/utilities/element-scroll.test.mjs +0 -27
  112. package/dist/utilities/event-listener.test.d.mts +0 -1
  113. package/dist/utilities/event-listener.test.mjs +0 -60
  114. package/dist/utilities/focus-within.test.d.mts +0 -1
  115. package/dist/utilities/focus-within.test.mjs +0 -51
  116. package/dist/utilities/hover.test.d.mts +0 -1
  117. package/dist/utilities/hover.test.mjs +0 -54
  118. package/dist/utilities/intersection-observer.test.d.mts +0 -1
  119. package/dist/utilities/intersection-observer.test.mjs +0 -46
  120. package/dist/utilities/interval.test.d.mts +0 -1
  121. package/dist/utilities/interval.test.mjs +0 -115
  122. package/dist/utilities/location.test.d.mts +0 -1
  123. package/dist/utilities/location.test.mjs +0 -61
  124. package/dist/utilities/long-press.test.d.mts +0 -1
  125. package/dist/utilities/long-press.test.mjs +0 -54
  126. package/dist/utilities/media-devices.test.d.mts +0 -1
  127. package/dist/utilities/media-devices.test.mjs +0 -44
  128. package/dist/utilities/media-player.test.d.mts +0 -1
  129. package/dist/utilities/media-player.test.mjs +0 -102
  130. package/dist/utilities/mutation-observer.test.d.mts +0 -1
  131. package/dist/utilities/mutation-observer.test.mjs +0 -48
  132. package/dist/utilities/network.test.d.mts +0 -1
  133. package/dist/utilities/network.test.mjs +0 -30
  134. package/dist/utilities/on-click-outside.test.d.mts +0 -1
  135. package/dist/utilities/on-click-outside.test.mjs +0 -45
  136. package/dist/utilities/previous.test.d.mts +0 -1
  137. package/dist/utilities/previous.test.mjs +0 -90
  138. package/dist/utilities/promise.test.d.mts +0 -1
  139. package/dist/utilities/promise.test.mjs +0 -158
  140. package/dist/utilities/retry.test.d.mts +0 -1
  141. package/dist/utilities/retry.test.mjs +0 -85
  142. package/dist/utilities/routing.test.d.mts +0 -1
  143. package/dist/utilities/routing.test.mjs +0 -129
  144. package/dist/utilities/search-params.test.d.mts +0 -1
  145. package/dist/utilities/search-params.test.mjs +0 -37
  146. package/dist/utilities/ssr.test.d.mts +0 -1
  147. package/dist/utilities/ssr.test.mjs +0 -65
  148. package/dist/utilities/storage.test.d.mts +0 -1
  149. package/dist/utilities/storage.test.mjs +0 -139
  150. package/dist/utilities/throttled.test.d.mts +0 -1
  151. package/dist/utilities/throttled.test.mjs +0 -58
  152. package/dist/utilities/timeout.test.d.mts +0 -1
  153. package/dist/utilities/timeout.test.mjs +0 -121
  154. package/dist/utilities/window-size.test.d.mts +0 -1
  155. package/dist/utilities/window-size.test.mjs +0 -43
  156. /package/dist/{custom-elements-D5CgfNKc.d.mts → custom-elements-DK5VUcWA.d.mts} +0 -0
@@ -1,13 +1,10 @@
1
1
  import { n as AttrChangeHandler, t as ATTRIBUTES } from "./attributes-3r7Diua4.mjs";
2
- import { t as CustomElementRegistry } from "./custom-elements-D5CgfNKc.mjs";
3
- import { n as Slot, r as PrimitiveNodeType, t as SLOTS } from "./slot-B8y0aEoz.mjs";
2
+ import { n as Slot, r as PrimitiveNodeType, t as SLOTS } from "./slot-BFWXeFRl.mjs";
3
+ import { t as CustomElementRegistry } from "./custom-elements-DK5VUcWA.mjs";
4
4
  import { JSX } from "dom-expressions/src/jsx-h";
5
5
 
6
6
  //#region src/jsx-runtime/element.d.ts
7
- declare function createElement(type: string | Component, {
8
- ref,
9
- ...props
10
- }?: JSX$1.IntrinsicAttributes & Record<string, unknown>): JSX$1.Element;
7
+ declare function createElement(type: string | Component, allProps?: JSX$1.IntrinsicAttributes & Record<string, unknown>): JSX$1.Element;
11
8
  //#endregion
12
9
  //#region src/signals/lib.d.ts
13
10
  declare const SIGNAL: unique symbol;
@@ -111,6 +108,19 @@ declare function computed<T>(getter: (previousValue?: T) => T): () => T;
111
108
  * stop(); // final cleanup: abort the last fetch
112
109
  * ```
113
110
  */
111
+ /**
112
+ * @internal Method key for settling a reactive async wrapper from a
113
+ * serialized server snapshot (hydration seeding). Lives here so
114
+ * `utilities/promise`, `utilities/async` and `hydrate` can share it without
115
+ * a utility-to-utility dependency.
116
+ */
117
+ declare const SEED: unique symbol;
118
+ /**
119
+ * @internal Method key for the hydrate claim protocol: the claim walk hands
120
+ * each async wrapper its ek-data record (or undefined). The wrapper decides —
121
+ * seed and discard any deferred run, or execute the deferred run now.
122
+ */
123
+ declare const CLAIM: unique symbol;
114
124
  declare function effect(fn: () => void): () => void;
115
125
  /**
116
126
  * Creates an ownership scope that groups reactive effects so they can all be
@@ -333,142 +343,8 @@ type MaybeReactive<T> = T | Computed<T>;
333
343
  * ```
334
344
  */
335
345
  declare function resolve<T>(value: MaybeReactive<T>): T;
336
- /**
337
- * Turn a reactive-props object into a bag of per-key getters. Callers may
338
- * pass values or reactive sources (`signal`, `computed`); reading
339
- * `props.name()` inside an effect or JSX getter subscribes to whatever
340
- * drives it. Static values become stable thunks, signals and computed pass
341
- * through unchanged — so identity is preserved (`props.name === props.name`).
342
- *
343
- * The JSX runtime auto-applies this to function-component props — call
344
- * directly only for non-JSX call sites or nested prop bags.
345
- *
346
- * @example
347
- * ```ts
348
- * import { resolveProps } from "elements-kit/signals";
349
- * import { signal } from "elements-kit/signals";
350
- *
351
- * const count = signal(0);
352
- * const props = resolveProps({ count, label: "n" });
353
- * props.count(); // 0 — subscribes to count
354
- * props.label(); // "n"
355
- * ```
356
- */
357
346
  declare function resolveProps<P extends object>(raw: { [K in keyof P]: MaybeReactive<P[K]> }): ReactiveProps<P>;
358
347
  //#endregion
359
- //#region src/jsx-runtime/fragment.d.ts
360
- /**
361
- * Used by the JSX transform for `<>...</>` fragments.
362
- *
363
- * Each child is routed through `mountChild`, which handles Nodes, strings,
364
- * numbers, arrays, and reactive getters — matching the behavior of any other
365
- * JSX container. `mountChild` also wires each child's cleanup via its own
366
- * `effectScope`, which links to the enclosing `effectScope` created by
367
- * `createElement(Fragment, ...)` for disposal propagation.
368
- */
369
- declare function Fragment(props: {
370
- children?: () => Child;
371
- }): DocumentFragment;
372
- //#endregion
373
- //#region src/jsx-runtime/index.d.ts
374
- /**
375
- * Maps slot names to `Child` content.
376
- * Use this to type `slot:name` JSX props on a custom component.
377
- *
378
- * @example
379
- * ```tsx
380
- * function Card(props: { title: string } & SlotProps<"header" | "footer">) { … }
381
- * // caller: <Card title="…" slot:header={<h1>…</h1>} slot:footer={<p>…</p>} />
382
- * ```
383
- */
384
- type SlotProps<K extends string> = { [P in K as `slot:${P}`]?: Child };
385
- /**
386
- * Get the full JSX prop types for a given tag name, including reactive
387
- * attributes, events, and all our namespace extensions.
388
- *
389
- * @example
390
- * ```ts
391
- * type InputProps = Attrs<"input">; // typed props for <input>
392
- * type DivProps = Attrs<"div">; // typed props for <div>
393
- * ```
394
- */
395
- type Attrs<K extends keyof JSX$1.IntrinsicElements> = JSX$1.IntrinsicElements[K];
396
- /**
397
- * Namespaced JSX props added by elements-kit on top of dom-expressions.
398
- * All four are tag-aware via the element type `E`.
399
- *
400
- * - `ref` — callback invoked with the mounted element, typed as the concrete
401
- * element class for intrinsics and registered custom elements.
402
- * - `class:foo` — open string + `MaybeReactive<boolean>`. Class names are
403
- * user-defined CSS so the key stays open (no autocomplete possible).
404
- * - `style:cssProp` — keys mapped from `DomJSX.CSSProperties` (csstype's
405
- * hyphenated property names) for autocomplete; value typed per-property.
406
- * - `prop:K` — inferred from `keyof E`. On `<div>` exposes
407
- * `prop:className`, `prop:id`, etc. (from `HTMLDivElement`); on a
408
- * registered custom element exposes its public fields too.
409
- *
410
- * `slot:foo` is NOT here — it's emitted per-element via `SlotsOf<C>` only
411
- * for elements that declare `[SLOTS]`. Plain HTML intrinsics don't accept
412
- * slot props (the runtime ignores them).
413
- */
414
- type CssStyleKey = Extract<keyof JSX.CSSProperties, string> extends infer K ? K extends `-${string}` ? never : K : never;
415
- type StyleNamespace = { [K in CssStyleKey as `style:${K}`]?: MaybeReactive<JSX.CSSProperties[K] | null> };
416
- type PropNamespace<E> = { [K in keyof E as K extends string ? `prop:${K}` : never]?: MaybeReactive<E[K]> };
417
- type JsxNamespaces<E extends Element = Element> = {
418
- ref?: (el: E) => void;
419
- [cls: `class:${string}`]: MaybeReactive<boolean>;
420
- } & StyleNamespace & PropNamespace<E>;
421
- type XlinkAttrs = {
422
- "xlink:href"?: MaybeReactive<string | undefined>;
423
- "xlink:title"?: MaybeReactive<string | undefined>;
424
- "xlink:show"?: MaybeReactive<"new" | "replace" | "embed" | "other" | "none" | undefined>;
425
- "xlink:role"?: MaybeReactive<string | undefined>;
426
- "xlink:type"?: MaybeReactive<"simple" | "extended" | "locator" | "arc" | "resource" | "title" | undefined>;
427
- "xlink:arcrole"?: MaybeReactive<string | undefined>;
428
- "xlink:actuate"?: MaybeReactive<"onLoad" | "onRequest" | "other" | "none" | undefined>;
429
- };
430
- type XmlAttrs = {
431
- "xml:lang"?: MaybeReactive<string | undefined>;
432
- "xml:space"?: MaybeReactive<"default" | "preserve" | undefined>;
433
- "xml:base"?: MaybeReactive<string | undefined>;
434
- };
435
- type SvgNamespaceAttrs = XlinkAttrs & XmlAttrs;
436
- type JsxNamespaceKeys = "ref" | `class:${string}` | `style:${string}` | `prop:${string}`;
437
- type WithJsxNamespaces<T, E extends Element = Element> = Omit<T, JsxNamespaceKeys> & JsxNamespaces<E>;
438
- type IntrinsicElementOf<T> = T extends {
439
- ref?: infer R | undefined;
440
- } ? Extract<R, (el: any) => any> extends ((el: infer E) => any) ? E : Element : Element;
441
- declare namespace JSX$1 {
442
- export type Element = globalThis.Element | globalThis.DocumentFragment | null;
443
- export type ElementType = Child | Component;
444
- export interface ElementChildrenAttribute {
445
- children: {};
446
- }
447
- export interface IntrinsicAttributes {
448
- ref?: (el: Element) => void;
449
- }
450
- export type LibraryManagedAttributes<C, P> = ResolveProps<C, P>;
451
- type RegisteredElements = { [K in keyof CustomElementRegistry]: CustomElementRegistry[K] extends infer C extends AnyElementCtor ? WithJsxNamespaces<MaybeReactiveProps<ElementProps<C>>, InstanceType<C>> : never };
452
- export type IntrinsicElements = { [K in keyof JSX.IntrinsicElements]: WithJsxNamespaces<JSX.IntrinsicElements[K], IntrinsicElementOf<JSX.IntrinsicElements[K]>> & (IntrinsicElementOf<JSX.IntrinsicElements[K]> extends SVGElement ? SvgNamespaceAttrs : {}) } & RegisteredElements;
453
- export {};
454
- }
455
- //#endregion
456
- //#region src/jsx-runtime/types.d.ts
457
- /** An instance created by a component class — must expose `render()`. */
458
- interface ComponentInstance {
459
- render(): JSX$1.Element;
460
- }
461
- /** A class whose constructor returns a ComponentInstance. */
462
- type ComponentClass<P extends Record<PropertyKey, unknown> = any> = new (props: P) => ComponentInstance;
463
- type ComponentFn<P extends Record<PropertyKey, unknown> = any> = (props: ReactiveProps<P>) => JSX$1.Element;
464
- /** Anything valid as the first arg to `createElement` / a JSX tag target. */
465
- type Component = NonNullable<JSX$1.Element> | ComponentClass | ComponentFn;
466
- /** A resolved runtime node — what `applyProps` / `applyChildren` operate on. */
467
- type PropsTarget = NonNullable<JSX$1.Element> | ComponentInstance;
468
- /** Anything that can appear as a JSX child. */
469
- type Child = PrimitiveNodeType | JSX$1.Element | AnyFn | Child[];
470
- type AnyFn = (...args: any[]) => Child;
471
- //#endregion
472
348
  //#region src/jsx-runtime/infer.d.ts
473
349
  type AnyElementCtor = abstract new (...args: any[]) => HTMLElement;
474
350
  type Inst<C> = C extends (abstract new (...args: any[]) => infer I) ? I : never;
@@ -681,4 +557,127 @@ type ComponentProps<C extends ComponentClass<any>> = C extends ComponentClass<in
681
557
  */
682
558
  type Props<C> = (C extends (abstract new (...args: any[]) => infer I) ? MaybeReactiveProps<InstanceProps<I>> : C extends ((props: infer P, ...rest: any[]) => any) ? P extends object ? MaybeReactiveProps<RawProps<P>> : {} : MaybeReactiveProps<InstanceProps<C>>) & SlotsOf<C>;
683
559
  //#endregion
684
- export { SIGNAL as A, signal as B, isReactive as C, COMPUTED as D, resolveProps as E, isComputed as F, untracked as H, isEffect as I, isEffectScope as L, computed as M, effect as N, EFFECT as O, effectScope as P, isSignal as R, Updater as S, resolve as T, createElement as U, trigger as V, SlotProps as _, RawProps as a, MaybeReactive as b, ResolveProps as c, ComponentClass as d, ComponentFn as f, JSX$1 as g, Attrs as h, Props as i, batch as j, EFFECT_SCOPE as k, Child as l, PropsTarget as m, ElementProps as n, ReactiveProps as o, ComponentInstance as p, MaybeReactiveProps as r, Require as s, ComponentProps as t, Component as u, Fragment as v, reactive as w, Signal as x, Computed as y, onCleanup as z };
560
+ //#region src/jsx-runtime/fragment.d.ts
561
+ /**
562
+ * Used by the JSX transform for `<>...</>` fragments.
563
+ *
564
+ * Each child is routed through `mountChild`, which handles Nodes, strings,
565
+ * numbers, arrays, and reactive getters — matching the behavior of any other
566
+ * JSX container. `mountChild` also wires each child's cleanup via its own
567
+ * `effectScope`, which links to the enclosing `effectScope` created by
568
+ * `createElement(Fragment, ...)` for disposal propagation.
569
+ *
570
+ * **Raw HTML mode** — `<Fragment html>{markup}</Fragment>`: the child is a
571
+ * `MaybeReactive<string>` rendered as markup inside a Slot region (comment
572
+ * markers), so the server renderer and the hydration claim pass share the
573
+ * region boundary. Reactive sources re-render the region on change. This is
574
+ * the library's only raw-HTML sink: the string is NOT escaped — sanitize
575
+ * untrusted input at the call site. `<script>` tags never execute.
576
+ */
577
+ declare function Fragment(props: Props<{
578
+ children: Child;
579
+ }> | {
580
+ html: true;
581
+ children: MaybeReactive<string>;
582
+ }): DocumentFragment;
583
+ //#endregion
584
+ //#region src/jsx-runtime/index.d.ts
585
+ /**
586
+ * Maps slot names to `Child` content.
587
+ * Use this to type `slot:name` JSX props on a custom component.
588
+ *
589
+ * @example
590
+ * ```tsx
591
+ * function Card(props: { title: string } & SlotProps<"header" | "footer">) { … }
592
+ * // caller: <Card title="…" slot:header={<h1>…</h1>} slot:footer={<p>…</p>} />
593
+ * ```
594
+ */
595
+ type SlotProps<K extends string> = { [P in K as `slot:${P}`]?: Child };
596
+ /**
597
+ * Get the full JSX prop types for a given tag name, including reactive
598
+ * attributes, events, and all our namespace extensions.
599
+ *
600
+ * @example
601
+ * ```ts
602
+ * type InputProps = Attrs<"input">; // typed props for <input>
603
+ * type DivProps = Attrs<"div">; // typed props for <div>
604
+ * ```
605
+ */
606
+ type Attrs<K extends keyof JSX$1.IntrinsicElements> = JSX$1.IntrinsicElements[K];
607
+ /**
608
+ * Namespaced JSX props added by elements-kit on top of dom-expressions.
609
+ * All four are tag-aware via the element type `E`.
610
+ *
611
+ * - `ref` — callback invoked with the mounted element, typed as the concrete
612
+ * element class for intrinsics and registered custom elements.
613
+ * - `class:foo` — open string + `MaybeReactive<boolean>`. Class names are
614
+ * user-defined CSS so the key stays open (no autocomplete possible).
615
+ * - `style:cssProp` — keys mapped from `DomJSX.CSSProperties` (csstype's
616
+ * hyphenated property names) for autocomplete; value typed per-property.
617
+ * - `prop:K` — inferred from `keyof E`. On `<div>` exposes
618
+ * `prop:className`, `prop:id`, etc. (from `HTMLDivElement`); on a
619
+ * registered custom element exposes its public fields too.
620
+ *
621
+ * `slot:foo` is NOT here — it's emitted per-element via `SlotsOf<C>` only
622
+ * for elements that declare `[SLOTS]`. Plain HTML intrinsics don't accept
623
+ * slot props (the runtime ignores them).
624
+ */
625
+ type CssStyleKey = Extract<keyof JSX.CSSProperties, string> extends infer K ? K extends `-${string}` ? never : K : never;
626
+ type StyleNamespace = { [K in CssStyleKey as `style:${K}`]?: MaybeReactive<JSX.CSSProperties[K] | null> };
627
+ type PropNamespace<E> = { [K in keyof E as K extends string ? `prop:${K}` : never]?: MaybeReactive<E[K]> };
628
+ type JsxNamespaces<E extends Element = Element> = {
629
+ ref?: (el: E) => void;
630
+ [cls: `class:${string}`]: MaybeReactive<boolean>;
631
+ } & StyleNamespace & PropNamespace<E>;
632
+ type XlinkAttrs = {
633
+ "xlink:href"?: MaybeReactive<string | undefined>;
634
+ "xlink:title"?: MaybeReactive<string | undefined>;
635
+ "xlink:show"?: MaybeReactive<"new" | "replace" | "embed" | "other" | "none" | undefined>;
636
+ "xlink:role"?: MaybeReactive<string | undefined>;
637
+ "xlink:type"?: MaybeReactive<"simple" | "extended" | "locator" | "arc" | "resource" | "title" | undefined>;
638
+ "xlink:arcrole"?: MaybeReactive<string | undefined>;
639
+ "xlink:actuate"?: MaybeReactive<"onLoad" | "onRequest" | "other" | "none" | undefined>;
640
+ };
641
+ type XmlAttrs = {
642
+ "xml:lang"?: MaybeReactive<string | undefined>;
643
+ "xml:space"?: MaybeReactive<"default" | "preserve" | undefined>;
644
+ "xml:base"?: MaybeReactive<string | undefined>;
645
+ };
646
+ type SvgNamespaceAttrs = XlinkAttrs & XmlAttrs;
647
+ type JsxNamespaceKeys = "ref" | `class:${string}` | `style:${string}` | `prop:${string}`;
648
+ type WithJsxNamespaces<T, E extends Element = Element> = Omit<T, JsxNamespaceKeys> & JsxNamespaces<E>;
649
+ type IntrinsicElementOf<T> = T extends {
650
+ ref?: infer R | undefined;
651
+ } ? Extract<R, (el: any) => any> extends ((el: infer E) => any) ? E : Element : Element;
652
+ declare namespace JSX$1 {
653
+ export type Element = globalThis.Element | globalThis.DocumentFragment | null;
654
+ export type ElementType = Child | Component;
655
+ export interface ElementChildrenAttribute {
656
+ children: {};
657
+ }
658
+ export interface IntrinsicAttributes {
659
+ ref?: (el: Element) => void;
660
+ }
661
+ export type LibraryManagedAttributes<C, P> = ResolveProps<C, P>;
662
+ type RegisteredElements = { [K in keyof CustomElementRegistry]: CustomElementRegistry[K] extends infer C extends AnyElementCtor ? WithJsxNamespaces<MaybeReactiveProps<ElementProps<C>>, InstanceType<C>> : never };
663
+ export type IntrinsicElements = { [K in keyof JSX.IntrinsicElements]: WithJsxNamespaces<JSX.IntrinsicElements[K], IntrinsicElementOf<JSX.IntrinsicElements[K]>> & (IntrinsicElementOf<JSX.IntrinsicElements[K]> extends SVGElement ? SvgNamespaceAttrs : {}) } & RegisteredElements;
664
+ export {};
665
+ }
666
+ //#endregion
667
+ //#region src/jsx-runtime/types.d.ts
668
+ /** An instance created by a component class — must expose `render()`. */
669
+ interface ComponentInstance {
670
+ render(): JSX$1.Element;
671
+ }
672
+ /** A class whose constructor returns a ComponentInstance. */
673
+ type ComponentClass<P extends Record<PropertyKey, unknown> = any> = new (props: P) => ComponentInstance;
674
+ type ComponentFn<P extends Record<PropertyKey, unknown> = any> = (props: ReactiveProps<P>) => JSX$1.Element;
675
+ /** Anything valid as the first arg to `createElement` / a JSX tag target. */
676
+ type Component = NonNullable<JSX$1.Element> | ComponentClass | ComponentFn;
677
+ /** A resolved runtime node — what `applyProps` / `applyChildren` operate on. */
678
+ type PropsTarget = NonNullable<JSX$1.Element> | ComponentInstance;
679
+ /** Anything that can appear as a JSX child. */
680
+ type Child = PrimitiveNodeType | JSX$1.Element | AnyFn | Child[];
681
+ type AnyFn = (...args: any[]) => Child;
682
+ //#endregion
683
+ export { EFFECT_SCOPE as A, isSignal as B, isReactive as C, CLAIM as D, resolveProps as E, effect as F, createElement as G, signal as H, effectScope as I, isComputed as L, SIGNAL as M, batch as N, COMPUTED as O, computed as P, isEffect as R, Updater as S, resolve as T, trigger as U, onCleanup as V, untracked as W, Require as _, ComponentInstance as a, MaybeReactive as b, JSX$1 as c, ComponentProps as d, ElementProps as f, ReactiveProps as g, RawProps as h, ComponentFn as i, SEED as j, EFFECT as k, SlotProps as l, Props as m, Component as n, PropsTarget as o, MaybeReactiveProps as p, ComponentClass as r, Attrs as s, Child as t, Fragment as u, ResolveProps as v, reactive as w, Signal as x, Computed as y, isEffectScope as z };
@@ -0,0 +1,70 @@
1
+ .x-overlay {
2
+ --overlay-constraint-top: 0px;
3
+ --overlay-constraint-left: 0px;
4
+ --overlay-constraint-width: 100vw;
5
+ --overlay-constraint-height: 100vh;
6
+ --_ct: var(--overlay-constraint-top, 0px);
7
+ --_cl: var(--overlay-constraint-left, 0px);
8
+ --_cw: var(--overlay-constraint-width, 100vw);
9
+ --_ch: var(--overlay-constraint-height, 100vh);
10
+ }
11
+
12
+ @supports (height: 1svh) {
13
+ .x-overlay {
14
+ --overlay-constraint-width: 100svw;
15
+ --overlay-constraint-height: 100svh;
16
+ }
17
+ }
18
+
19
+ .x-overlay {
20
+ top: var(--_ct);
21
+ left: var(--_cl);
22
+ translate: calc(-50% + var(--_ex, 0px) + var(--overlay-dx, 0px) +
23
+ clamp(50%,
24
+ var(--overlay-x, calc(var(--_cw) / 2)),
25
+ calc(-50% + var(--_cw))))
26
+ calc(-50% + var(--_ey, 0px) + var(--overlay-dy, 0px) +
27
+ clamp(50%,
28
+ var(--overlay-y, calc(var(--_ch) / 2)),
29
+ calc(-50% + var(--_ch))));
30
+ --overlay-width: 480px;
31
+ width: var(--overlay-w, var(--overlay-width));
32
+ max-width: var(--_cw);
33
+ height: var(--overlay-h, fit-content);
34
+ max-height: var(--_ch);
35
+ --overlay-duration: .3s;
36
+ --overlay-easing: cubic-bezier(.32, .72, 0, 1);
37
+ transition: top var(--overlay-duration) var(--overlay-easing),
38
+ left var(--overlay-duration) var(--overlay-easing),
39
+ translate var(--overlay-duration) var(--overlay-easing),
40
+ width var(--overlay-duration) var(--overlay-easing),
41
+ height var(--overlay-duration) var(--overlay-easing);
42
+ grid-template-rows: minmax(0, 1fr);
43
+ }
44
+
45
+ .x-overlay:not([open], :popover-open) {
46
+ pointer-events: none;
47
+ }
48
+
49
+ .x-overlay:where([popover]) {
50
+ display: none;
51
+ }
52
+
53
+ .x-overlay:where([open], :popover-open) {
54
+ display: grid;
55
+ }
56
+
57
+ @supports not (translate: 0px) {
58
+ .x-overlay {
59
+ top: auto;
60
+ left: auto;
61
+ margin: auto;
62
+ inset: 0;
63
+ }
64
+ }
65
+
66
+ @supports (interpolate-size: allow-keywords) {
67
+ .x-overlay {
68
+ interpolate-size: allow-keywords;
69
+ }
70
+ }
@@ -0,0 +1,209 @@
1
+ //#region src/ui/overlay/constrain.d.ts
2
+ /**
3
+ * The overlay constraint — the rect an `.x-overlay` lives in. Every
4
+ * location clamp and gesture bound derives from the
5
+ * `--overlay-constraint-top/-left/-width/-height` variables (declared in
6
+ * index.css with viewport defaults). This module is the JS side of that
7
+ * interface: syncing a rect into the variables and resolving them back to
8
+ * pixels for the gesture bounds.
9
+ */
10
+ interface OverlayConstraint {
11
+ dispose(): void;
12
+ [Symbol.dispose](): void;
13
+ }
14
+ /**
15
+ * A reactive source of the constraint rect — the shape `createElementRect`
16
+ * returns, so an `Element` works directly and custom rects (a non-element
17
+ * region, a virtual anchor) can be supplied too.
18
+ */
19
+ interface ConstraintRect {
20
+ top(): number;
21
+ left(): number;
22
+ width(): number;
23
+ height(): number;
24
+ }
25
+ /** Resolves the constraint rect every gesture bound derives from. */
26
+ declare function resolveConstraint(overlay: HTMLElement): {
27
+ top: number;
28
+ left: number;
29
+ width: number;
30
+ height: number;
31
+ };
32
+ /**
33
+ * Confines an overlay to a rect source by syncing it into the
34
+ * `--overlay-constraint-*` variables. Pass an `Element` (observed via
35
+ * `ResizeObserver` through `createElementRect`) or a custom
36
+ * {@link ConstraintRect}. Every location clamp and gesture bound derives
37
+ * from those variables, so the overlay re-clamps when the rect changes.
38
+ *
39
+ * Caveat: `ResizeObserver` fires on size changes — a container that moves
40
+ * without resizing (e.g. page scroll) does not retrigger the sync.
41
+ *
42
+ * Registers its cleanup with the current scope (`onCleanup`) and also
43
+ * returns it as `dispose` / `Symbol.dispose`; disposing removes the
44
+ * variables, restoring the viewport constraint.
45
+ *
46
+ * @example
47
+ * ```ts
48
+ * import { constrainOverlay } from "elements-kit/ui/overlay";
49
+ *
50
+ * const panel = document.querySelector("dialog.x-overlay")!;
51
+ * constrainOverlay(panel, document.querySelector("main")!);
52
+ * ```
53
+ */
54
+ declare function constrainOverlay(overlay: HTMLElement, source: Element | ConstraintRect): OverlayConstraint;
55
+ //#endregion
56
+ //#region src/ui/overlay/resize-strategy.d.ts
57
+ /**
58
+ * Resize strategies — pluggable policy for a resize drag's live bounds
59
+ * and resting size. Pure (no DOM); the gesture injects the context.
60
+ * Built-ins: `freeResize` (default), `detents`.
61
+ */
62
+ /** How far (ms) a release velocity is projected when picking a rest. */
63
+ declare const PROJECTION_MS = 160;
64
+ /** Clamp `value` into `[min, max]`. */
65
+ declare function clamp(value: number, min: number, max: number): number;
66
+ /**
67
+ * The release context a `ResizeStrategy` decides against. The gesture
68
+ * builds it per drag; `resolve` turns a step value into pixels.
69
+ */
70
+ interface ResizeContext {
71
+ /** Dragged size along the axis (px, before clamping). */
72
+ size: number;
73
+ /** Size at the gesture's start (px). */
74
+ startSize: number;
75
+ /** Release velocity along the axis (px/ms; positive = shrinking). */
76
+ velocity: number;
77
+ /** Resize axis. */
78
+ axis: "width" | "height";
79
+ /** Hard room the surface may occupy on the axis (px). */
80
+ min: number;
81
+ max: number;
82
+ /** Whether a drag/flick past the minimum may dismiss. */
83
+ dismissible: boolean;
84
+ /** Release velocity (px/ms) past which a sub-minimum release dismisses. */
85
+ velocityThreshold: number;
86
+ /** Resolves a step to px — a number is a fraction of the constraint
87
+ * along the axis; a string is any CSS length. */
88
+ resolve(value: number | string): number;
89
+ }
90
+ /**
91
+ * Decides where a resize drag rests. The gesture calls `bounds()` for the
92
+ * live rubber-band and `rest()` on release (the resting size, or `null`
93
+ * to dismiss). Built-ins: `freeResize` (default), `detents`.
94
+ */
95
+ interface ResizeStrategy {
96
+ /** Soft `[lo, hi]` bounds for the live drag — rubber-band past these.
97
+ * Defaults to the hard room when omitted. */
98
+ bounds?(ctx: ResizeContext): [number, number];
99
+ /** Resting size (px) on release, or `null` to dismiss. */
100
+ rest(ctx: ResizeContext): number | null;
101
+ }
102
+ /**
103
+ * Picks the index of the detent closest to the released size, projected
104
+ * along the release velocity (px/ms, positive = shrinking). Returns `-1`
105
+ * when the gesture should dismiss instead.
106
+ */
107
+ declare function closestDetent(sizePx: number, detentsPx: readonly number[], velocityPxPerMs?: number, dismissible?: boolean, velocityThreshold?: number): number;
108
+ /**
109
+ * Free resize: drag to any size within the room; a flick or shrink past
110
+ * the minimum dismisses. The default strategy.
111
+ */
112
+ declare function freeResize(opts?: {
113
+ min?: number;
114
+ }): ResizeStrategy;
115
+ /**
116
+ * Snap to discrete steps — each a fraction of the constraint along the
117
+ * axis (number `0–1`) or a CSS length (string). Flick-aware; shrinking
118
+ * past the smallest step dismisses.
119
+ */
120
+ declare function detents(steps: readonly (number | string)[]): ResizeStrategy;
121
+ //#endregion
122
+ //#region src/ui/overlay/gestures.d.ts
123
+ interface OverlayGestureOptions {
124
+ /** How a resize drag rests. Default: `freeResize()`. */
125
+ resize?: ResizeStrategy;
126
+ /** Allow a drag/flick past the minimum to close. Default `true`. */
127
+ dismissible?: boolean;
128
+ /** Release velocity (px/ms, shrinking) that dismisses. Default `0.5`. */
129
+ velocityThreshold?: number;
130
+ }
131
+ interface OverlayGestures {
132
+ /** Resize to a size (px) along the resize axis — animated by CSS. */
133
+ resize(size: number): void;
134
+ dispose(): void;
135
+ [Symbol.dispose](): void;
136
+ }
137
+ /**
138
+ * Opt-in pointer gestures for `.x-overlay`, dispatched by the gesture
139
+ * attributes (structure stays in markup; policy is options):
140
+ *
141
+ * - An edge word (`block-*` / `inline-*`) is a whole-surface size drag
142
+ * along that axis — block drags the height (sheets), inline the width
143
+ * (drawers), `:dir(rtl)` flips the inline sign. The side names the
144
+ * handle; the opposite edge stays put.
145
+ * - A corner word (`start-start` / … — block side first) is a desktop-
146
+ * window resize from a square zone at that corner, anchored at the
147
+ * opposite corner so the surface never grows past the constraint. The
148
+ * width follows the `resize` strategy; the height is a free clamp.
149
+ * - `data-draggable` moves the surface in x/y from the top strip,
150
+ * rubber-banding at the edges; flinging it off the constraint dismisses
151
+ * (when `dismissible`).
152
+ *
153
+ * Layered for testability: `gesture-model` owns the pure mode reducers +
154
+ * math, and `overlay-dom` owns all DOM contact (pointer plumbing + channel
155
+ * I/O). This function is the wiring — it picks a pure `Session` from
156
+ * `detectEngagement` and adapts it to the recognizer through the io.
157
+ * The `resize` strategy (`freeResize` by default, or `detents`) decides the
158
+ * rested size, written to the public `--overlay-w`/`--overlay-h` channels;
159
+ * CSS renders and animates them. JS never touches `translate`/`top`/`left`.
160
+ *
161
+ * Registers its cleanup with the current scope (`onCleanup`) and also
162
+ * returns it as `dispose` / `Symbol.dispose`.
163
+ *
164
+ * @example
165
+ * ```ts
166
+ * import { createOverlayGestures, detents } from "elements-kit/ui/overlay";
167
+ *
168
+ * const el = document.querySelector("dialog.x-overlay")!;
169
+ * createOverlayGestures(el, { resize: detents([0.25, 0.6, 0.9]) });
170
+ * el.addEventListener("resizechange", (e) => console.log(e.detail));
171
+ * ```
172
+ */
173
+ declare function createOverlayGestures(overlay: HTMLElement, options?: OverlayGestureOptions): OverlayGestures;
174
+ //#endregion
175
+ //#region src/ui/overlay/overlay.d.ts
176
+ interface OverlayConfig extends OverlayGestureOptions {
177
+ /** Confine the overlay to an element's rect (or a custom
178
+ * {@link ConstraintRect}). Omit for the default viewport constraint. */
179
+ constrain?: Element | ConstraintRect;
180
+ }
181
+ interface OverlayController {
182
+ /** Resize to a size (px) along the resize axis — animated by CSS. */
183
+ resize(size: number): void;
184
+ dispose(): void;
185
+ [Symbol.dispose](): void;
186
+ }
187
+ /**
188
+ * One-call wiring for an interactive `.x-overlay`: optional constraint
189
+ * sync + pointer gestures, under a single disposable. Structure stays in
190
+ * markup (`data-resize` / `data-draggable`); policy is config.
191
+ *
192
+ * Registers its cleanup with the current scope (`onCleanup`) and also
193
+ * returns it as `dispose` / `Symbol.dispose`.
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * import { overlay, detents } from "elements-kit/ui/overlay";
198
+ *
199
+ * const el = document.querySelector("dialog.x-overlay")!;
200
+ * const o = overlay(el, {
201
+ * constrain: document.querySelector("main")!,
202
+ * resize: detents([0.25, 0.6, 0.9]),
203
+ * onResize: (size) => console.log(size),
204
+ * });
205
+ * ```
206
+ */
207
+ declare function overlay(el: HTMLElement, config?: OverlayConfig): OverlayController;
208
+ //#endregion
209
+ export { ConstraintRect, OverlayConfig, OverlayConstraint, OverlayController, OverlayGestureOptions, OverlayGestures, PROJECTION_MS, ResizeContext, ResizeStrategy, clamp, closestDetent, constrainOverlay, createOverlayGestures, detents, freeResize, overlay, resolveConstraint };