elements-kit 0.21.0 → 0.22.1

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 (69) hide show
  1. package/README.md +23 -21
  2. package/dist/attributes.d.mts +1 -1
  3. package/dist/await.d.mts +6 -5
  4. package/dist/await.mjs +1 -37
  5. package/dist/{types-CUvFIgPa.d.mts → children-s3nFjpLA.d.mts} +124 -226
  6. package/dist/custom-elements-CdpilMDu.d.mts +87 -0
  7. package/dist/custom-elements.d.mts +2 -2
  8. package/dist/{element-D3om9yA6.mjs → element-Di0PYFX1.mjs} +15 -38
  9. package/dist/environment-CTAGxqz_.d.mts +19 -0
  10. package/dist/for.d.mts +9 -4
  11. package/dist/for.mjs +1 -1
  12. package/dist/{fragment-ROPRBJQd.mjs → fragment-Bvs1sGu1.mjs} +3 -3
  13. package/dist/hydrate/index.mjs +1 -1
  14. package/dist/{hydrate-6Qx4n4Su.mjs → hydrate-DvWdnV-e.mjs} +5 -5
  15. package/dist/integrations/astro-client.mjs +2 -2
  16. package/dist/integrations/astro-server.mjs +2 -2
  17. package/dist/integrations/astro-slots.d.mts +6 -5
  18. package/dist/integrations/astro-slots.mjs +9 -8
  19. package/dist/integrations/react.d.mts +1 -1
  20. package/dist/integrations/react.mjs +1 -1
  21. package/dist/jsx-runtime/index.d.mts +2 -2
  22. package/dist/jsx-runtime/index.mjs +2 -2
  23. package/dist/polyfill-BVNd6ogU.d.mts +9 -0
  24. package/dist/render.mjs +1 -1
  25. package/dist/server/index.mjs +1 -1
  26. package/dist/{server-iFSng50i.mjs → server-CTkyXTV6.mjs} +2 -2
  27. package/dist/signals/index.d.mts +1 -1
  28. package/dist/slot.d.mts +83 -2
  29. package/dist/slot.mjs +179 -2
  30. package/dist/ui/marketing/marketing.css +5 -3
  31. package/dist/ui/otp-input/index.d.mts +6 -5
  32. package/dist/ui/otp-input/index.mjs +5 -5
  33. package/dist/ui/styles/index.css +174 -172
  34. package/dist/ui/styles/unset.css +212 -210
  35. package/dist/utilities/active-element.d.mts +1 -1
  36. package/dist/utilities/async.d.mts +2 -2
  37. package/dist/utilities/async.mjs +13 -5
  38. package/dist/utilities/debounced.d.mts +1 -1
  39. package/dist/utilities/dom-lifecycle.bench.mjs +2 -2
  40. package/dist/utilities/element-rect.d.mts +1 -1
  41. package/dist/utilities/element-scroll.d.mts +1 -1
  42. package/dist/utilities/environment.d.mts +2 -7
  43. package/dist/utilities/environment.mjs +13 -1
  44. package/dist/utilities/event-driven.d.mts +1 -1
  45. package/dist/utilities/event-listener.d.mts +1 -1
  46. package/dist/utilities/focus-within.d.mts +1 -1
  47. package/dist/utilities/hover.d.mts +1 -1
  48. package/dist/utilities/interval.d.mts +1 -1
  49. package/dist/utilities/location.d.mts +1 -1
  50. package/dist/utilities/media-devices.d.mts +1 -1
  51. package/dist/utilities/media-player.d.mts +1 -1
  52. package/dist/utilities/media-query.d.mts +1 -1
  53. package/dist/utilities/network.d.mts +1 -1
  54. package/dist/utilities/orientation.d.mts +1 -1
  55. package/dist/utilities/previous.d.mts +1 -1
  56. package/dist/utilities/promise.d.mts +1 -1
  57. package/dist/utilities/routing.d.mts +1 -1
  58. package/dist/utilities/search-params.d.mts +1 -1
  59. package/dist/utilities/storage.d.mts +1 -1
  60. package/dist/utilities/throttled.d.mts +1 -1
  61. package/dist/utilities/timeout.d.mts +1 -1
  62. package/dist/utilities/window-focus.d.mts +1 -1
  63. package/dist/utilities/window-size.d.mts +1 -1
  64. package/package.json +3 -1
  65. package/dist/custom-elements-BGcU6ldL.d.mts +0 -57
  66. package/dist/slot-BFWXeFRl.d.mts +0 -77
  67. package/dist/slot-Dvf30O0B.mjs +0 -138
  68. /package/dist/{attributes-3r7Diua4.d.mts → attributes-DILeh3-s.d.mts} +0 -0
  69. /package/dist/{scope-zbEG299F.mjs → scope-C1vELXqP.mjs} +0 -0
@@ -1,11 +1,8 @@
1
- import { n as AttrChangeHandler, t as ATTRIBUTES } from "./attributes-3r7Diua4.mjs";
2
- import { n as Slot, r as PrimitiveNodeType, t as SLOTS } from "./slot-BFWXeFRl.mjs";
3
- import { t as CustomElementRegistry } from "./custom-elements-BGcU6ldL.mjs";
4
- import { JSX } from "dom-expressions/src/jsx-h";
1
+ import { n as AttrChangeHandler, t as ATTRIBUTES } from "./attributes-DILeh3-s.mjs";
2
+ import { i as PropertiesOf, n as CustomElementRegistry, r as EventsOf } from "./custom-elements-CdpilMDu.mjs";
3
+ import * as CSS from "csstype";
4
+ import { JSX } from "dom-expressions/src/jsx";
5
5
 
6
- //#region src/jsx-runtime/element.d.ts
7
- declare function createElement(type: string | Component, allProps?: JSX$1.IntrinsicAttributes & Record<string, unknown>): JSX$1.Element | null;
8
- //#endregion
9
6
  //#region src/signals/lib.d.ts
10
7
  declare const SIGNAL: unique symbol;
11
8
  declare const COMPUTED: unique symbol;
@@ -343,29 +340,9 @@ type MaybeReactive<T> = T | Computed<T>;
343
340
  * ```
344
341
  */
345
342
  declare function resolve<T>(value: MaybeReactive<T>): T;
346
- declare function resolveProps<P extends object>(raw: { [K in keyof P]: MaybeReactive<P[K]> }): ReactiveProps<P>;
343
+ declare function resolveProps<P extends object>(raw: { [K in keyof P]: MaybeReactive<P[K]> }): Props<P>;
347
344
  //#endregion
348
345
  //#region src/jsx-runtime/infer.d.ts
349
- type AnyElementCtor = abstract new (...args: any[]) => HTMLElement;
350
- type Inst<C> = C extends (abstract new (...args: any[]) => infer I) ? I : never;
351
- /**
352
- * When the instance extends `HTMLElement`, drop the DOM surface so only the
353
- * user's own fields remain. Plain class components also drop `render` — it's
354
- * the internal rendering method, not a JSX prop.
355
- */
356
- type PublicPropKeys<I> = I extends HTMLElement ? Exclude<keyof I, keyof HTMLElement | symbol> : Exclude<keyof I, symbol | "render">;
357
- /**
358
- * Instance fields typed as `Slot` are default-slot mounts at runtime — the JSX
359
- * consumer passes DOM content, which `applyChildren` routes via `applySlot`.
360
- * Surface them as `Child` in the JSX prop shape so callers type-check.
361
- */
362
- type PropValueFor<V> = V extends Slot ? Child : V;
363
- /**
364
- * Public instance fields of `I` — all optional. For `HTMLElement` subclasses
365
- * the DOM surface is excluded; for plain classes, all own keys are kept.
366
- * `Slot`-typed fields are mapped to `Child` (see {@link PropValueFor}).
367
- */
368
- type InstanceProps<I> = { [K in PublicPropKeys<I> & string]?: PropValueFor<I[K]> };
369
346
  /**
370
347
  * Promote keys `K` of `P` to required; leave the rest unchanged.
371
348
  *
@@ -380,78 +357,51 @@ type InstanceProps<I> = { [K in PublicPropKeys<I> & string]?: PropValueFor<I[K]>
380
357
  * ```
381
358
  */
382
359
  type Require<P, K extends keyof P> = { [X in K]-?: P[X] } & Omit<P, K>;
383
- /**
384
- * Wrap every non-function prop in {@link MaybeReactive} so callers may pass
385
- * either a plain value or a reactive getter. Function-typed props (event
386
- * handlers, render callbacks) are left as-is so inline arrow callbacks get
387
- * proper contextual typing for their parameters — wrapping them in
388
- * `MaybeReactive<F> = F | (() => F)` produces two callable alternatives and
389
- * TS falls back to implicit-any on the callback's params. Optionality is
390
- * preserved at the key level — the `| undefined` stays at the prop, not
391
- * inside the reactive.
392
- *
393
- * @template P — source prop object type.
394
- *
395
- * @example
396
- * ```ts
397
- * type Raw = { count: number; label?: string; onClick: (e: Event) => void };
398
- * type Wrapped = MaybeReactiveProps<Raw>;
399
- * // {
400
- * // count: MaybeReactive<number>;
401
- * // label?: MaybeReactive<string>;
402
- * // onClick: (e: Event) => void;
403
- * // }
404
- * ```
405
- *
406
- * @see {@link MaybeReactive}
407
- * @see {@link Props}
408
- */
409
- type MaybeReactiveProps<P> = { [K in keyof P]: undefined extends P[K] ? MaybeReactiveOrFn<Exclude<P[K], undefined>> | undefined : MaybeReactiveOrFn<P[K]> };
410
- type MaybeReactiveOrFn<T> = Extract<T, (...args: any[]) => any> extends never ? MaybeReactive<T> : T;
411
360
  declare const RAW_PROPS: unique symbol;
412
- type ReactiveProps<P> = { readonly [K in keyof P]: Computed<P[K]> } & {
361
+ type Props<P> = { readonly [K in keyof P]: Computed<P[K]> } & {
413
362
  readonly [RAW_PROPS]?: P;
414
363
  };
415
- /** Recover the raw prop shape `P` from a `ReactiveProps<P>`. */
364
+ /** Recover the raw prop shape `P` from a `Props<P>`. */
416
365
  type RawProps<R> = R extends {
417
366
  readonly [RAW_PROPS]?: infer P;
418
367
  } ? P : R;
419
368
  /**
420
- * Resolve the JSX call-site prop type for a component (function or class).
421
- * Wired into `JSX.LibraryManagedAttributes` so parents see the right shape:
422
- * - branded `ReactiveProps<P>` (function components) `MaybeReactiveProps<P>`
423
- * - empty constructor param (instance-field classes) `Props<C>`
424
- * - otherwise pass the constructor param shape through (preserves generic
425
- * inference for classes like `For<T>` whose param is already shaped).
426
- *
427
- * Component props only — custom-element attributes go through {@link ElementProps}.
369
+ * Caller-facing wrap: each key accepts a plain value OR a reactive getter.
370
+ * The JSX checker applies it automatically to component props; name it
371
+ * directly when typing a call-site shape by hand (e.g. a class component's
372
+ * constructor param, like `For`'s). Function-typed props are wrapped too
373
+ * (`Computed<F>` is zero-arg, so TS still picks the handler signature by
374
+ * arity for inline arrows). `Signal<F>` must never be added explicitly — its
375
+ * one-arg `Updater` half would collapse inline arrow params to implicit any.
428
376
  */
429
- type ResolveProps<C, P, NN = NonNullable<P>> = NN extends {
377
+ type MaybeReactiveProps<P> = { [K in keyof P]: undefined extends P[K] ? MaybeReactive<Exclude<P[K], undefined>> | undefined : MaybeReactive<P[K]> };
378
+ /**
379
+ * @internal Call-site prop resolution for `JSX.LibraryManagedAttributes`:
380
+ * - empty param (instance-field classes, no ctor) → wrap `PropsOf<C>`
381
+ * - branded `Props<P>` param (function components) → wrap the raw `P`
382
+ * - non-empty constructor param → pass through (preserves `For<T>` inference)
383
+ *
384
+ * Emptiness is checked FIRST: `{}` structurally matches the optional brand
385
+ * (`{} extends { [RAW_PROPS]?: infer Raw }` with `Raw = unknown`), which
386
+ * would silently type every no-ctor class as `MaybeReactiveProps<unknown>`
387
+ * (= `{}`, accepting anything). A real `Props<P>` is never empty — its
388
+ * `keyof` always contains the brand symbol.
389
+ */
390
+ type ResolveProps<C, P, NN = NonNullable<P>> = [keyof NN] extends [never] ? C extends JSX$1.ElementType | JSX$1.ElementClass ? MaybeReactiveProps<PropsOf<C>> : {} : NN extends {
430
391
  readonly [RAW_PROPS]?: infer Raw;
431
- } ? MaybeReactiveProps<Raw> : [keyof NN] extends [never] ? Props<C> : NN;
432
- type InstancePropsOf<C> = Inst<C> extends infer I ? InstanceProps<I> : {};
433
- type PropKeysOf<C> = keyof InstancePropsOf<C> & string;
392
+ } ? MaybeReactiveProps<Raw> : NN;
393
+ type PropKeysOf<C> = keyof PropertiesOf<C> & string;
434
394
  type AttrMap<C> = C extends {
435
395
  [ATTRIBUTES]: infer M;
436
396
  } ? M : {};
437
397
  type HandlerValue<H> = H extends AttrChangeHandler<any> ? string | null : H;
438
398
  type AttrsOf<C> = AttrMap<C> extends infer M ? M extends Record<string, unknown> ? string extends keyof M ? {} : { [K in Exclude<keyof M & string, PropKeysOf<C>>]?: HandlerValue<M[K]> } : {} : {};
439
- type FlatPropsOf<C> = InstancePropsOf<C>;
440
- type PropNamespacedOf<C> = { [K in PropKeysOf<C> as `prop:${K}`]?: NonNullable<InstancePropsOf<C>[K]> };
441
- type EventMapOf<C> = C extends {
442
- events: infer E;
443
- } ? E : {};
444
- type Capitalize1<S extends string> = S extends `${infer H}${infer R}` ? `${Uppercase<H>}${R}` : S;
445
- type EventsOf<C> = EventMapOf<C> extends infer E ? E extends Record<string, Event> ? { [K in keyof E & string as `on:${K}`]?: (ev: E[K]) => void } & { [K in keyof E & string as `on${Capitalize1<K>}`]?: (ev: E[K]) => void } : {} : {};
446
- type SlotKeys<I> = I extends {
447
- [SLOTS]: infer S;
448
- } ? Extract<keyof S, string> : never;
449
- type InstanceOf<C> = C extends (abstract new (...args: any[]) => infer I) ? I : C;
450
- type SlotsOf<C> = SlotKeys<InstanceOf<C>> extends infer K ? [K] extends [string] ? { [P in K as `slot:${P}`]?: Child } : {} : {};
399
+ type PropNamespacedOf<C> = { [K in PropKeysOf<C> as `prop:${K}`]?: NonNullable<PropertiesOf<C>[K]> };
400
+ type JsxEventsOf<C> = { [K in keyof EventsOf<C> & string as `on:${K}`]?: (ev: EventsOf<C>[K]) => void };
451
401
  type ChildrenOf<C> = C extends {
452
402
  children: never;
453
403
  } ? {} : {
454
- children?: Child;
404
+ children?: Children;
455
405
  };
456
406
  type BaseDOMAttrs = JSX.DOMAttributes<HTMLElement>;
457
407
  /**
@@ -462,9 +412,8 @@ type BaseDOMAttrs = JSX.DOMAttributes<HTMLElement>;
462
412
  * Keys also present on the instance are dropped here so the flat key carries the property type.
463
413
  * - **Flat properties** — public instance fields, wrapped in `MaybeReactive`.
464
414
  * - **`prop:*`** — explicit property assignment for every field.
465
- * - **Events** — keys from `declare static events: { ... }` produce both
466
- * `on:${K}` and `on${Capitalize<K>}` typed handlers.
467
- * - **Slots** — keys from `[SLOTS] = { ... } as const` produce `slot:${K}`.
415
+ * - **Events** — keys from `declare static events: { ... }` produce
416
+ * `on:${K}` typed handlers (the only event syntax the runtime attaches).
468
417
  * - **Children** — `children?: Child` unless `static children: never`.
469
418
  * - **DOM attrs** — the standard dom-expressions surface (`class`, `style`, `ref`, …).
470
419
  *
@@ -476,7 +425,9 @@ type BaseDOMAttrs = JSX.DOMAttributes<HTMLElement>;
476
425
  * class XRange extends HTMLElement {
477
426
  * static [ATTRIBUTES]: Attributes<XRange> = { min(v) { this.min = +v! } };
478
427
  * declare static events: { commit: CustomEvent<number> };
479
- * [SLOTS] = { label: new Slot() } as const;
428
+ * #slot = new Slot();
429
+ * get label() { return this.#slot.get(); }
430
+ * set label(value: Node) { this.#slot.set(value) }
480
431
  * \@reactive() min = 0;
481
432
  * }
482
433
  *
@@ -485,77 +436,62 @@ type BaseDOMAttrs = JSX.DOMAttributes<HTMLElement>;
485
436
  * // min?: MaybeReactive<number>;
486
437
  * // "prop:min"?: number;
487
438
  * // "on:commit"?: (e: CustomEvent<number>) => void;
488
- * // onCommit?: (e: CustomEvent<number>) => void;
489
- * // "slot:label"?: Child;
490
- * // children?: Child;
439
+ * // label?: Node
440
+ * // children?: Node;
491
441
  * // // …plus ref, class, class:*, style, style:*, standard DOM events
492
442
  * // }
493
443
  * ```
494
444
  *
495
- * @see {@link Props} for class-components / function components (no attr/event/slot synthesis).
496
- */
497
- type ElementProps<C extends AnyElementCtor> = BaseDOMAttrs & AttrsOf<C> & FlatPropsOf<C> & PropNamespacedOf<C> & EventsOf<C> & SlotsOf<C> & ChildrenOf<C>;
498
- /**
499
- * Props of a class component that receives them via its constructor:
500
- * `class Comp { constructor(props: P) }`. Reads `ConstructorParameters[0]`.
501
- *
502
- * Use this when the component's props live on a constructor parameter rather
503
- * than on public instance fields. For instance-field components, use {@link Props}.
504
- *
505
- * @template C — the class constructor type (e.g. `typeof Card`).
506
- *
507
- * @example
508
- * ```ts
509
- * class Card {
510
- * constructor(public props: { title: string; children?: Child }) {}
511
- * render() { return <div>{this.props.title}</div>; }
512
- * }
513
- *
514
- * type P = ComponentProps<typeof Card>;
515
- * // { title: string; children?: Child }
516
- * ```
517
- *
518
- * @see {@link Props}
445
+ * @see {@link PropsOf} for class-components / function components (no attr/event synthesis).
519
446
  */
520
- type ComponentProps<C extends ComponentClass<any>> = C extends ComponentClass<infer P> ? (P extends object ? P : {}) : {};
447
+ type ElementProps<C extends AnyElementCtor> = BaseDOMAttrs & AttrsOf<C> & PropertiesOf<C> & PropNamespacedOf<C> & JsxEventsOf<C> & ChildrenOf<C>;
521
448
  /**
522
- * Props for any component — class or function. Wraps every non-function
523
- * prop in {@link MaybeReactive} so callers may pass values or reactive getters.
524
- *
525
- * Branches by input shape:
526
- * - **Class constructor** (`typeof Cls`) → uses `InstanceProps<InstanceType<Cls>>`.
527
- * - **Function component** (`(props: P) => ...`) → uses the first parameter.
528
- * - **Class instance** (`Cls<T>`) → uses `InstanceProps<Cls<T>>` (useful when
529
- * generics need to flow through — see the `For` example below).
449
+ * Props for any component — class or function.
530
450
  *
531
- * Does **not** synthesize `on:*`, `slot:*`, or attribute surface. For custom
532
- * elements that need those, use {@link ElementProps}.
451
+ * The combination of the two specialised helpers:
452
+ * - **Custom-element constructor** (`typeof Cls`, `Cls extends HTMLElement`)
453
+ * → `ElementProps<Cls>` — the full JSX surface (attrs, `prop:*`, `on:*`,children).
454
+ * - **Everything else** (function component, class component ctor or
455
+ * instance) → `ComponentProps<T>` — the raw prop shape.
533
456
  *
534
- * @template C — constructor, function, or instance.
457
+ * @template T — constructor, function, or instance.
535
458
  *
536
459
  * @example
537
460
  * ```ts
538
461
  * // 1. Class instance (lets a generic flow)
539
462
  * class For<T> { each: T[] = []; render() { return null } }
540
- * type ForProps<T> = Props<For<T>>;
541
- * // ↑ { each?: MaybeReactive<T[]> }
463
+ * type ForProps<T> = PropsOf<For<T>>;
464
+ * // ↑ { each?: T[] }
542
465
  *
543
466
  * // 2. Function component
544
467
  * const Greeting = (_p: { name: string; excited?: boolean }) => null;
545
- * type GreetingProps = Props<typeof Greeting>;
546
- * // ↑ { name: MaybeReactive<string>; excited?: MaybeReactive<boolean> }
468
+ * type GreetingProps = PropsOf<typeof Greeting>;
469
+ * // ↑ { name: string; excited?: boolean }
547
470
  *
548
471
  * // 3. Class constructor
549
472
  * class Counter { count = 0; render() { return null } }
550
- * type CounterProps = Props<typeof Counter>;
551
- * // ↑ { count?: MaybeReactive<number> }
473
+ * type CounterProps = PropsOf<typeof Counter>;
474
+ * // ↑ { count?: number }
552
475
  * ```
553
- *
554
- * @see {@link ElementProps} — custom elements (`HTMLElement` subclasses).
555
- * @see {@link ComponentProps} — constructor-param-based class components.
556
- * @see {@link MaybeReactiveProps}
557
476
  */
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>;
477
+ type PropsOf<T extends JSX$1.ElementType | JSX$1.ElementClass | AnyElementCtor> = T extends AnyElementCtor ? ElementProps<T> : T extends JSX$1.ElementType | JSX$1.ElementClass ? ComponentProps<T> : never;
478
+ /**
479
+ * Raw props of a function or class COMPONENT (not a custom element):
480
+ * function components use the first parameter (`RawProps` unwraps a branded
481
+ * `Props<P>`); classes use their public instance fields. The custom-element half of `PropsOf` is `ElementProps`.
482
+ */
483
+ type ComponentProps<T extends JSX$1.ElementType | JSX$1.ElementClass> = T extends ((props: infer P, ...rest: any[]) => any) ? P extends object ? RawProps<P> : {} : PropertiesOf<T>;
484
+ type AnyElementCtor = abstract new (...args: any[]) => HTMLElement;
485
+ //#endregion
486
+ //#region src/jsx-runtime/element.d.ts
487
+ type UnsupportedDomKeys = "ref" | "children" | "classList" | "$ServerOnly" | keyof JSX.CustomEventHandlersCamelCase<any> | keyof JSX.CustomEventHandlersLowerCase<any> | keyof JSX.DirectiveAttributes | keyof JSX.DirectiveFunctionAttributes<any> | keyof JSX.AttrAttributes | keyof JSX.BoolAttributes | keyof JSX.OnCaptureAttributes<any>;
488
+ type DOMIntrinsicElements = { [K in keyof JSX.IntrinsicElements]: Omit<JSX.IntrinsicElements[K], UnsupportedDomKeys> };
489
+ type DOMElements = { [K in keyof JSX.IntrinsicElements]: JSX.IntrinsicElements[K] extends {
490
+ ref?: infer R | undefined;
491
+ } ? Extract<R, (el: any) => any> extends ((el: infer E) => any) ? E : Element : Element };
492
+ declare function createElement(type: JSX$1.ElementType, allProps?: {
493
+ ref?: (el: Element) => void;
494
+ } & Record<string, unknown>): JSX$1.Element | null;
559
495
  //#endregion
560
496
  //#region src/jsx-runtime/fragment.d.ts
561
497
  /**
@@ -575,109 +511,71 @@ type Props<C> = (C extends (abstract new (...args: any[]) => infer I) ? MaybeRea
575
511
  * untrusted input at the call site. `<script>` tags never execute.
576
512
  */
577
513
  declare function Fragment(props: Props<{
578
- children: Child;
514
+ children?: Children;
579
515
  }> | {
580
516
  html: true;
581
517
  children: MaybeReactive<string>;
582
518
  }): DocumentFragment;
583
519
  //#endregion
584
520
  //#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
521
  declare namespace JSX$1 {
653
522
  export type Element = globalThis.Element | globalThis.DocumentFragment;
654
- export type ElementType = Child | Component;
523
+ export type ElementClass = {
524
+ render(): JSX$1.Element | null;
525
+ };
526
+ export type ElementType = string | JSX$1.Element | (new (props: any) => JSX$1.ElementClass) | ((props: any) => JSX$1.Element | null);
655
527
  export interface ElementChildrenAttribute {
656
528
  children: {};
657
529
  }
658
- export interface IntrinsicAttributes {
659
- ref?: (el: Element) => void;
660
- }
530
+ export interface IntrinsicAttributes {}
661
531
  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;
532
+ type RegisteredElements = { [K in keyof CustomElementRegistry]: CustomElementRegistry[K] extends infer C extends AnyElementCtor ? MaybeReactiveProps<WithJsxNamespaces<Omit<ElementProps<C>, "children" | "ref">, InstanceType<C>>> & {
533
+ ref?: (el: InstanceType<C>) => void;
534
+ children?: Children;
535
+ } : never };
536
+ export type IntrinsicElements = { [K in keyof DOMIntrinsicElements]: MaybeReactiveProps<WithJsxNamespaces<DOMIntrinsicElements[K], DOMElements[K]>> & {
537
+ ref?: (el: DOMElements[K]) => void;
538
+ children?: Children;
539
+ } & (DOMElements[K] extends SVGElement ? SvgNamespaceAttrs : {}) } & RegisteredElements;
664
540
  export {};
665
541
  }
542
+ /** A class whose constructor returns a ComponentInstance. */
543
+ type ComponentClass<P extends Record<PropertyKey, unknown> = any> = new (props: P) => JSX$1.ElementClass;
544
+ type ComponentFn<P extends Record<PropertyKey, unknown> = any> = (props: Props<P>) => JSX$1.Element | null;
666
545
  //#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 | null;
546
+ //#region src/jsx-runtime/properties.d.ts
547
+ interface CSSProperties extends CSS.PropertiesHyphen {
548
+ [key: `-${string}`]: string | number | undefined;
671
549
  }
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 | null;
675
- /** Anything valid as the first arg to `createElement` / a JSX tag target. */
676
- type Component = JSX$1.Element | ComponentClass | ComponentFn;
677
- /** A resolved runtime node — what `applyProps` / `applyChildren` operate on. */
678
- type PropsTarget = 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;
550
+ type CssStyleKey = Extract<keyof CSSProperties, string> extends infer K ? K extends `-${string}` ? never : K : never;
551
+ type StyleNamespace = { [K in CssStyleKey as `style:${K}`]?: CSSProperties[K] | null };
552
+ type PropNamespace<E> = { [K in keyof E as K extends string ? `prop:${K}` : never]?: E[K] };
553
+ type XlinkAttrs = {
554
+ "xlink:href"?: string | undefined;
555
+ "xlink:title"?: string | undefined;
556
+ "xlink:show"?: "new" | "replace" | "embed" | "other" | "none" | undefined;
557
+ "xlink:role"?: string | undefined;
558
+ "xlink:type"?: "simple" | "extended" | "locator" | "arc" | "resource" | "title" | undefined;
559
+ "xlink:arcrole"?: string | undefined;
560
+ "xlink:actuate"?: "onLoad" | "onRequest" | "other" | "none" | undefined;
561
+ };
562
+ type ClassNamespace = { [K in `class:${string}`]?: boolean };
563
+ type XmlAttrs = {
564
+ "xml:lang"?: string | undefined;
565
+ "xml:space"?: "default" | "preserve" | undefined;
566
+ "xml:base"?: string | undefined;
567
+ };
568
+ type SvgNamespaceAttrs = XlinkAttrs & XmlAttrs;
569
+ interface StyleAttrObject extends CSS.Properties {}
570
+ type JsxNamespaces<E extends Element = Element> = (E extends ElementCSSInlineStyle ? {
571
+ style?: string | StyleAttrObject;
572
+ } & StyleNamespace : {}) & PropNamespace<Omit<E, "children">> & ClassNamespace;
573
+ type JsxNamespaceKeys = "style" | `class:${string}` | `style:${string}` | `prop:${string}`;
574
+ type WithJsxNamespaces<T, E extends Element = Element> = Omit<T, JsxNamespaceKeys> & JsxNamespaces<E>;
575
+ //#endregion
576
+ //#region src/jsx-runtime/children.d.ts
577
+ type PrimitiveNodeType = Node | string | boolean | number | bigint | symbol | Date | RegExp | null | undefined;
578
+ type AnyFn = (...args: any[]) => Children;
579
+ type Children = PrimitiveNodeType | AnyFn | Element | DocumentFragment | Children[];
682
580
  //#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 };
581
+ export { isComputed as A, EFFECT_SCOPE as C, computed as D, batch as E, signal as F, trigger as I, untracked as L, isEffectScope as M, isSignal as N, effect as O, onCleanup as P, EFFECT as S, SIGNAL as T, reactive as _, Fragment as a, CLAIM as b, Props as c, Require as d, Computed as f, isReactive as g, Updater as h, JSX$1 as i, isEffect as j, effectScope as k, PropsOf as l, Signal as m, ComponentClass as n, createElement as o, MaybeReactive as p, ComponentFn as r, MaybeReactiveProps as s, Children as t, RawProps as u, resolve as v, SEED as w, COMPUTED as x, resolveProps as y };
@@ -0,0 +1,87 @@
1
+ import { t as ATTRIBUTES } from "./attributes-DILeh3-s.mjs";
2
+
3
+ //#region src/custom-elements.d.ts
4
+ type RegisteredElementInstances = { [K in keyof ElementsKit.CustomElementRegistry]: ElementsKit.CustomElementRegistry[K] extends (abstract new (...args: any[]) => infer I) ? I : never };
5
+ declare global {
6
+ namespace ElementsKit {
7
+ interface CustomElementRegistry {}
8
+ }
9
+ interface HTMLElementTagNameMap extends RegisteredElementInstances {}
10
+ }
11
+ type CustomElementRegistry = ElementsKit.CustomElementRegistry;
12
+ type AnyCtor = CustomElementConstructor;
13
+ /**
14
+ * @internal Public instance keys of `I`: for `HTMLElement` subclasses the
15
+ * inherited DOM surface is dropped; for plain classes `render` is dropped.
16
+ * Shared by the raw extractors here and the JSX helpers in jsx-runtime.
17
+ */
18
+ type PublicPropKeys<I> = I extends HTMLElement ? Exclude<keyof I, keyof HTMLElement | symbol> : Exclude<keyof I, symbol | "render">;
19
+ type InstanceOfCtor<C> = C extends (abstract new (...args: any[]) => infer I) ? I : C;
20
+ /**
21
+ * Settable property surface of a custom-element class (or instance) — the
22
+ * user's public fields, all optional, without the inherited `HTMLElement`
23
+ * surface. Slot-backed props (`@slot()` accessors) appear here as their
24
+ * `Node | null` read type — assignment fills the slot.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * class XCounter extends HTMLElement { count = 0; }
29
+ * type P = PropertiesOf<typeof XCounter>; // { count?: number }
30
+ * ```
31
+ */
32
+ type PropertiesOf<C> = InstanceOfCtor<C> extends infer I ? { [K in PublicPropKeys<I> & string]?: I[K] } : never;
33
+ /**
34
+ * Observed attributes of a custom-element class — every key of
35
+ * `static [ATTRIBUTES]`, valued `string | null` (the raw HTML surface).
36
+ *
37
+ * @example
38
+ * ```ts
39
+ * type A = AttributesOf<typeof XRange>; // { min?: string | null; ... }
40
+ * ```
41
+ */
42
+ type AttributesOf<C> = C extends {
43
+ [ATTRIBUTES]: infer M;
44
+ } ? M extends Record<string, unknown> ? string extends keyof M ? {} : { [K in keyof M & string]?: string | null } : {} : {};
45
+ /**
46
+ * Raw event map of a custom-element class — `static events` verbatim.
47
+ * Shape it however your host needs: `addEventListener` typing, framework
48
+ * event bindings, or an `HTMLElementEventMap` augmentation.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * type E = EventsOf<typeof XRange>; // { commit: CustomEvent<number> }
53
+ * declare global {
54
+ * interface HTMLElementEventMap extends EventsOf<typeof XRange> {}
55
+ * }
56
+ * ```
57
+ */
58
+ type EventsOf<C> = C extends {
59
+ events: infer E;
60
+ } ? E extends Record<string, Event> ? E : {} : {};
61
+ /**
62
+ * Register a custom element with the browser and return its class.
63
+ * Pair with an augmentation of `ElementsKit.CustomElementRegistry` to get typed JSX.
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * import { defineElement } from "elements-kit/custom-elements";
68
+ *
69
+ * class XCounter extends HTMLElement {}
70
+ *
71
+ * defineElement("x-counter", XCounter);
72
+ *
73
+ * declare global {
74
+ * namespace ElementsKit {
75
+ * interface CustomElementRegistry {
76
+ * "x-counter": typeof XCounter;
77
+ * }
78
+ * }
79
+ * }
80
+ *
81
+ * // JSX now gets typed props + typed ref
82
+ * // <x-counter />
83
+ * ```
84
+ */
85
+ declare function defineElement<Tag extends `${string}-${string}`, C extends AnyCtor>(tag: Tag, cls: C, options?: ElementDefinitionOptions): C;
86
+ //#endregion
87
+ export { PublicPropKeys as a, PropertiesOf as i, CustomElementRegistry as n, defineElement as o, EventsOf as r, AttributesOf as t };
@@ -1,2 +1,2 @@
1
- import { n as defineElement, t as CustomElementRegistry } from "./custom-elements-BGcU6ldL.mjs";
2
- export { CustomElementRegistry, defineElement };
1
+ import { a as PublicPropKeys, i as PropertiesOf, n as CustomElementRegistry, o as defineElement, r as EventsOf, t as AttributesOf } from "./custom-elements-CdpilMDu.mjs";
2
+ export { AttributesOf, CustomElementRegistry, EventsOf, PropertiesOf, PublicPropKeys, defineElement };
@@ -2,7 +2,7 @@ import { C as untracked, _ as onCleanup, d as effectScope, u as effect } from ".
2
2
  import "./polyfill-CdZVCxdo.mjs";
3
3
  import { isReactive, resolveProps } from "./signals/index.mjs";
4
4
  import { on } from "./utilities/event-listener.mjs";
5
- import { n as Slot, r as resolveNode$1, t as SLOTS } from "./slot-Dvf30O0B.mjs";
5
+ import { Slot } from "./slot.mjs";
6
6
  //#region src/jsx-runtime/constants.ts
7
7
  /**
8
8
  * IDL properties that take precedence over the default `setAttribute` path.
@@ -267,46 +267,23 @@ const ReservedNameSpaces = new Set([
267
267
  ]);
268
268
  //#endregion
269
269
  //#region src/jsx-runtime/children.ts
270
- function hasSlots(node) {
271
- return SLOTS in node;
270
+ var UnsupportedChildError = class extends Error {
271
+ constructor(value) {
272
+ super(`Unsupported child type: ${typeof value}`);
273
+ this.name = "UnsupportedChildError";
274
+ }
275
+ };
276
+ function resolveNode$1(c) {
277
+ if (c instanceof Node) return c;
278
+ if (c === null || c === void 0 || typeof c === "boolean") return document.createComment("");
279
+ if (typeof c === "string" || typeof c === "number" || typeof c === "bigint" || typeof c === "symbol" || c instanceof Date || c instanceof RegExp) return document.createTextNode(String(c));
280
+ throw new UnsupportedChildError(c);
272
281
  }
273
282
  function isChildrenProperty(node, key) {
274
- if (key === "children" && (node instanceof Element || node instanceof DocumentFragment)) return true;
275
- if (hasSlots(node)) {
276
- if (key.replace(/^slot:/, "") in node[SLOTS]) return true;
277
- }
278
- return key in node && node[key] instanceof Slot;
283
+ return key === "children" && (node instanceof Element || node instanceof DocumentFragment);
279
284
  }
280
285
  function applyChildren(node, key, value) {
281
- if (hasSlots(node)) {
282
- const slotName = key.replace(/^slot:/, "");
283
- if (slotName in node[SLOTS]) {
284
- applySlot(node[SLOTS][slotName], value);
285
- return;
286
- }
287
- }
288
- if (key === "children" && (node instanceof Element || node instanceof DocumentFragment)) {
289
- mountChildren(node, value);
290
- return;
291
- }
292
- if (key in node) {
293
- const slot = node[key];
294
- if (!(slot instanceof Slot)) return;
295
- applySlot(slot, value);
296
- }
297
- }
298
- function applySlot(slot, value) {
299
- let dispose;
300
- if (typeof value === "function") effect(() => slot.set(resolveChild(value())));
301
- else {
302
- const node = resolveChild(value);
303
- dispose = node[Symbol.dispose];
304
- slot.set(node);
305
- }
306
- onCleanup(() => {
307
- dispose?.();
308
- slot.clear();
309
- });
286
+ if (key === "children" && (node instanceof Element || node instanceof DocumentFragment)) mountChildren(node, value);
310
287
  }
311
288
  const FRAGMENT_POOL_MAX = 4;
312
289
  const fragmentPool = [];
@@ -388,7 +365,7 @@ function mountStatic(el, list, kind) {
388
365
  function mountChild(el, child) {
389
366
  if (typeof child === "function") {
390
367
  const slot = new Slot();
391
- el.appendChild(slot.render());
368
+ el.appendChild(slot.get());
392
369
  effect(() => slot.set(resolveChild(child())));
393
370
  onCleanup(() => slot.clear());
394
371
  return;
@@ -0,0 +1,19 @@
1
+ //#region src/utilities/environment.d.ts
2
+ /** `true` when running in a browser (both `window` and `document` exist). */
3
+ declare const isBrowser: boolean;
4
+ /**
5
+ * `HTMLElement` in the browser; an empty stand-in on the server.
6
+ *
7
+ * A custom-element class evaluates its `extends` clause at module load, but
8
+ * `HTMLElement` is undefined in Node — so importing an element module during
9
+ * SSR (e.g. an Astro `client:load` island) throws `HTMLElement is not defined`
10
+ * before any `isBrowser` guard can run. Elements are never *constructed* on the
11
+ * server (the streaming renderer emits plain tags), so a stub base is enough to
12
+ * let the class definition load; the guarded `customElements.define` still only
13
+ * registers in a real browser.
14
+ */
15
+ declare const HTMLElementBase: typeof HTMLElement;
16
+ /** A shared `Disposable` whose `Symbol.dispose` is a no-op — useful as a safe default. */
17
+ declare const noopDisposable: Disposable;
18
+ //#endregion
19
+ export { isBrowser as n, noopDisposable as r, HTMLElementBase as t };