elements-kit 0.0.18 → 0.0.19
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/README.md +17 -17
- package/dist/attributes.d.mts +1 -1
- package/dist/{define-CjbTZ3VG.d.mts → custom-elements-bVYOkHKt.d.mts} +2 -2
- package/dist/custom-elements.d.mts +2 -74
- package/dist/custom-elements.mjs +2 -91
- package/dist/{element-CGVy_8TW.mjs → element-DxmInKJw.mjs} +32 -20
- package/dist/for.d.mts +1 -1
- package/dist/for.mjs +3 -2
- package/dist/infer-Dv5Wk-7E.d.mts +618 -0
- package/dist/integrations/react.d.mts +1 -1
- package/dist/integrations/react.mjs +6 -4
- package/dist/jsx-runtime/index.d.mts +2 -73
- package/dist/jsx-runtime/index.mjs +8 -14
- package/dist/{signals-J8dK_rA4.mjs → lib-D6duEs38.mjs} +1 -105
- package/dist/render.d.mts +21 -0
- package/dist/render.mjs +32 -0
- package/dist/scope-DM2gzOkb.mjs +45 -0
- package/dist/signals/index.d.mts +1 -1
- package/dist/signals/index.mjs +115 -1
- package/dist/{slot-C7GQZe-r.d.mts → slot-B5_VHB7E.d.mts} +10 -0
- package/dist/slot.d.mts +1 -1
- package/dist/{test.BmQO5GaM-DfGStnii.mjs → test.BmQO5GaM-BeO5pvCo.mjs} +1 -1
- package/dist/utilities/_observe.mjs +2 -1
- package/dist/utilities/active-element.d.mts +1 -1
- package/dist/utilities/active-element.mjs +2 -1
- package/dist/utilities/active-element.test.mjs +1 -1
- package/dist/utilities/async.d.mts +1 -1
- package/dist/utilities/async.mjs +2 -1
- package/dist/utilities/async.test.mjs +3 -2
- package/dist/utilities/debounced.d.mts +1 -1
- package/dist/utilities/debounced.mjs +2 -1
- package/dist/utilities/debounced.test.mjs +3 -2
- package/dist/utilities/element-rect.d.mts +1 -1
- package/dist/utilities/element-rect.mjs +2 -1
- package/dist/utilities/element-rect.test.mjs +3 -2
- package/dist/utilities/element-scroll.d.mts +1 -1
- package/dist/utilities/element-scroll.test.mjs +3 -2
- package/dist/utilities/event-driven.d.mts +1 -1
- package/dist/utilities/event-driven.mjs +2 -1
- package/dist/utilities/event-listener.d.mts +1 -1
- package/dist/utilities/event-listener.mjs +2 -1
- package/dist/utilities/event-listener.test.mjs +3 -2
- package/dist/utilities/focus-within.d.mts +1 -1
- package/dist/utilities/focus-within.mjs +2 -1
- package/dist/utilities/focus-within.test.mjs +3 -2
- package/dist/utilities/hover.d.mts +1 -1
- package/dist/utilities/hover.mjs +2 -1
- package/dist/utilities/hover.test.mjs +3 -2
- package/dist/utilities/intersection-observer.test.mjs +3 -2
- package/dist/utilities/interval.d.mts +1 -1
- package/dist/utilities/interval.mjs +2 -1
- package/dist/utilities/interval.test.mjs +3 -2
- package/dist/utilities/location.d.mts +1 -1
- package/dist/utilities/location.mjs +2 -1
- package/dist/utilities/location.test.mjs +1 -1
- package/dist/utilities/long-press.test.mjs +3 -2
- package/dist/utilities/media-devices.d.mts +1 -1
- package/dist/utilities/media-devices.mjs +2 -1
- package/dist/utilities/media-devices.test.mjs +3 -2
- package/dist/utilities/media-player.d.mts +1 -1
- package/dist/utilities/media-player.test.mjs +3 -2
- package/dist/utilities/media-query.d.mts +1 -1
- package/dist/utilities/media-query.mjs +2 -1
- package/dist/utilities/mutation-observer.test.mjs +3 -2
- package/dist/utilities/network.d.mts +1 -1
- package/dist/utilities/network.mjs +2 -1
- package/dist/utilities/network.test.mjs +1 -1
- package/dist/utilities/on-click-outside.test.mjs +3 -2
- package/dist/utilities/orientation.d.mts +1 -1
- package/dist/utilities/orientation.mjs +2 -1
- package/dist/utilities/previous.d.mts +1 -1
- package/dist/utilities/previous.mjs +2 -1
- package/dist/utilities/previous.test.mjs +3 -2
- package/dist/utilities/promise.d.mts +1 -1
- package/dist/utilities/promise.mjs +2 -1
- package/dist/utilities/promise.test.mjs +3 -2
- package/dist/utilities/retry.mjs +2 -1
- package/dist/utilities/retry.test.mjs +3 -2
- package/dist/utilities/routing.d.mts +1 -1
- package/dist/utilities/routing.mjs +2 -1
- package/dist/utilities/routing.test.mjs +1 -1
- package/dist/utilities/search-params.d.mts +1 -1
- package/dist/utilities/search-params.test.mjs +3 -2
- package/dist/utilities/ssr.test.mjs +1 -1
- package/dist/utilities/storage.d.mts +1 -1
- package/dist/utilities/storage.test.mjs +3 -2
- package/dist/utilities/throttled.d.mts +1 -1
- package/dist/utilities/throttled.mjs +2 -1
- package/dist/utilities/throttled.test.mjs +3 -2
- package/dist/utilities/timeout.d.mts +1 -1
- package/dist/utilities/timeout.mjs +2 -1
- package/dist/utilities/timeout.test.mjs +3 -2
- package/dist/utilities/window-focus.d.mts +1 -1
- package/dist/utilities/window-focus.mjs +2 -1
- package/dist/utilities/window-size.d.mts +1 -1
- package/dist/utilities/window-size.mjs +2 -1
- package/dist/utilities/window-size.test.mjs +1 -1
- package/package.json +1 -1
- package/dist/index-DydGTqZU.d.mts +0 -315
- package/dist/infer-BfzRJoCn.d.mts +0 -203
- package/dist/polyfill-BVNd6ogU.d.mts +0 -9
- /package/dist/{attributes-Dtn68R1u.d.mts → attributes-aiRoArZz.d.mts} +0 -0
- /package/dist/{magic-string.es-i62WTP6J.mjs → magic-string.es-cTgJnTCj.mjs} +0 -0
package/README.md
CHANGED
|
@@ -25,8 +25,8 @@ class CounterElement extends HTMLElement {
|
|
|
25
25
|
this.appendChild(
|
|
26
26
|
<section>
|
|
27
27
|
<p>Count: <strong>{() => this.count}</strong> — Doubled: <strong>{this.doubled}</strong></p>
|
|
28
|
-
<button
|
|
29
|
-
<button
|
|
28
|
+
<button on:click={() => this.count++}>+1</button>{" "}
|
|
29
|
+
<button on:click={() => this.count--}>−1</button>
|
|
30
30
|
</section> as Element,
|
|
31
31
|
);
|
|
32
32
|
}
|
|
@@ -50,7 +50,7 @@ Every feature is a separate subpath export — import only what you use.
|
|
|
50
50
|
| `elements-kit/slot` | `Slot`, `Slots`, `SLOTS` symbol — comment-marker DOM regions |
|
|
51
51
|
| `elements-kit/custom-elements` | `defineElement`, `CustomElementRegistry` |
|
|
52
52
|
| `elements-kit/for` | `For` keyed-list component |
|
|
53
|
-
| `elements-kit/jsx-runtime` | JSX factory + type helpers (`ElementProps`, `Props`, `ComponentProps`, `MaybeReactiveProps`, `Require`) — configure via `jsxImportSource` |
|
|
53
|
+
| `elements-kit/jsx-runtime` | JSX factory + type helpers (`ElementProps`, `Props`, `ComponentProps`, `MaybeReactiveProps`, `ReactiveProps`, `Require`) — configure via `jsxImportSource` |
|
|
54
54
|
| `elements-kit/integrations/react` | `useSignal`, `useScope` React bridge hooks |
|
|
55
55
|
| `elements-kit/utilities/*` | Reactive browser-API utilities — see [src/utilities/README.md](src/utilities/README.md) |
|
|
56
56
|
|
|
@@ -169,7 +169,7 @@ JSX compiles directly to `document.createElement`. No virtual DOM, no diffing.
|
|
|
169
169
|
|
|
170
170
|
```tsx
|
|
171
171
|
// This:
|
|
172
|
-
const el = <button
|
|
172
|
+
const el = <button on:click={() => count(count() + 1)}>{count}</button>;
|
|
173
173
|
|
|
174
174
|
// Is equivalent to:
|
|
175
175
|
const el = document.createElement("button");
|
|
@@ -193,8 +193,7 @@ const name = signal("Alice");
|
|
|
193
193
|
| Syntax | Effect |
|
|
194
194
|
|--------|--------|
|
|
195
195
|
| `{signal}` / `{() => fn()}` | Live-bound reactive child |
|
|
196
|
-
| `
|
|
197
|
-
| `on:click={fn}` | Explicit event namespace |
|
|
196
|
+
| `on:click={fn}` | Event listener (case-preserving event name) |
|
|
198
197
|
| `class:active={bool}` | Reactive `classList.toggle` |
|
|
199
198
|
| `style:color={value}` | Reactive inline style property |
|
|
200
199
|
| `prop:foo={val}` | Force property assignment (skips `setAttribute`) |
|
|
@@ -217,7 +216,7 @@ class Counter {
|
|
|
217
216
|
return (
|
|
218
217
|
<section>
|
|
219
218
|
<p>{() => this.count} × 2 = {this.doubled}</p>
|
|
220
|
-
<button
|
|
219
|
+
<button on:click={() => this.count++}>+1</button>
|
|
221
220
|
</section>
|
|
222
221
|
) as Element;
|
|
223
222
|
}
|
|
@@ -254,7 +253,7 @@ class CounterElement extends HTMLElement {
|
|
|
254
253
|
this.#unmount = render(this, () => (
|
|
255
254
|
<section>
|
|
256
255
|
<p>{() => this.count} × 2 = {this.doubled}</p>
|
|
257
|
-
<button
|
|
256
|
+
<button on:click={() => this.count++}>+1</button>
|
|
258
257
|
</section>
|
|
259
258
|
));
|
|
260
259
|
}
|
|
@@ -288,7 +287,7 @@ declare module "elements-kit/custom-elements" {
|
|
|
288
287
|
// Now `<x-counter count={5} />` is fully typed — no hand-written `declare global` block.
|
|
289
288
|
```
|
|
290
289
|
|
|
291
|
-
See [Types](docs/src/content/docs/
|
|
290
|
+
See [Types](docs/src/content/docs/elements/types.mdx) for the full set of prop-inference helpers.
|
|
292
291
|
|
|
293
292
|
---
|
|
294
293
|
|
|
@@ -461,29 +460,30 @@ import { For } from "elements-kit/for";
|
|
|
461
460
|
|
|
462
461
|
## Prop types
|
|
463
462
|
|
|
464
|
-
Six type helpers derive JSX prop shapes from your components — no parallel `declare global` block to maintain. Full guide at [docs/src/content/docs/
|
|
463
|
+
Six type helpers derive JSX prop shapes from your components — no parallel `declare global` block to maintain. Full guide at [docs/src/content/docs/elements/types.mdx](docs/src/content/docs/elements/types.mdx).
|
|
465
464
|
|
|
466
465
|
| Helper | For |
|
|
467
466
|
| ------ | --- |
|
|
468
467
|
| `ElementProps<typeof Cls>` | `HTMLElement` subclass — full surface (attrs, events, slots, children) |
|
|
469
468
|
| `Props<C>` | Class instance, constructor, or function component — unified |
|
|
470
469
|
| `ComponentProps<typeof Cls>` | Class components with `constructor(props: P)` |
|
|
471
|
-
| `MaybeReactiveProps<P>` |
|
|
470
|
+
| `MaybeReactiveProps<P>` | Caller-facing — wrap every prop in `MaybeReactive` (what parents pass) |
|
|
471
|
+
| `ReactiveProps<P>` | Component-facing — every prop becomes a `Computed<T>` getter (what function components receive) |
|
|
472
472
|
| `MaybeReactive<T>` | Scalar value-or-getter (from `elements-kit/signals`) |
|
|
473
473
|
| `Require<P, K>` | Promote optional keys to required |
|
|
474
474
|
|
|
475
|
-
|
|
475
|
+
The JSX runtime auto-wraps function-component props — each key arrives as a callable getter that subscribes on read. Pair the signature with `ReactiveProps<P>` and read `props.x()`:
|
|
476
476
|
|
|
477
477
|
```tsx
|
|
478
|
-
import {
|
|
479
|
-
import type { MaybeReactiveProps } from "elements-kit/jsx-runtime";
|
|
478
|
+
import type { ReactiveProps } from "elements-kit/jsx-runtime";
|
|
480
479
|
|
|
481
|
-
function Greeting(
|
|
482
|
-
const props = resolveProps(raw);
|
|
480
|
+
function Greeting(props: ReactiveProps<{ name: string }>) {
|
|
483
481
|
return <p>Hello, {props.name}</p>;
|
|
484
482
|
}
|
|
485
483
|
```
|
|
486
484
|
|
|
485
|
+
`resolveProps` stays exported for non-JSX call sites or nested prop bags.
|
|
486
|
+
|
|
487
487
|
---
|
|
488
488
|
|
|
489
489
|
## `@reactive()` Decorator
|
|
@@ -541,7 +541,7 @@ For typed events, declare a `static events` map:
|
|
|
541
541
|
class XPicker extends HTMLElement {
|
|
542
542
|
declare static events: { commit: CustomEvent<number> };
|
|
543
543
|
}
|
|
544
|
-
// ElementProps<typeof XPicker> now includes `on:commit`
|
|
544
|
+
// ElementProps<typeof XPicker> now includes `on:commit`
|
|
545
545
|
```
|
|
546
546
|
|
|
547
547
|
---
|
package/dist/attributes.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as Attributes, c as observedAttributes, i as AttributeTarget, n as AttrChangeHandler, o as attributes, r as AttributeDecorated, s as dispatchAttrChange, t as ATTRIBUTES } from "./attributes-
|
|
1
|
+
import { a as Attributes, c as observedAttributes, i as AttributeTarget, n as AttrChangeHandler, o as attributes, r as AttributeDecorated, s as dispatchAttrChange, t as ATTRIBUTES } from "./attributes-aiRoArZz.mjs";
|
|
2
2
|
export { ATTRIBUTES, AttrChangeHandler, AttributeDecorated, AttributeTarget, Attributes, attributes, dispatchAttrChange, observedAttributes };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
//#region src/
|
|
1
|
+
//#region src/custom-elements.d.ts
|
|
2
2
|
/**
|
|
3
3
|
* Registry of custom-element tags to their constructors.
|
|
4
4
|
* Users augment this interface to add typed JSX support for their elements:
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts
|
|
8
|
-
* declare module "elements-kit" {
|
|
8
|
+
* declare module "elements-kit/custom-elements" {
|
|
9
9
|
* interface CustomElementRegistry {
|
|
10
10
|
* "x-range": typeof XRange;
|
|
11
11
|
* }
|
|
@@ -1,74 +1,2 @@
|
|
|
1
|
-
import { n as defineElement, t as CustomElementRegistry } from "./
|
|
2
|
-
|
|
3
|
-
//#region src/custom-elements.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Runs `setup` inside a fresh `effectScope` and returns both its result and
|
|
6
|
-
* the scope's dispose handle.
|
|
7
|
-
*
|
|
8
|
-
* Use this wherever you need to run reactive code with an explicit lifetime
|
|
9
|
-
* outside the JSX element flow — most commonly inside a custom element's
|
|
10
|
-
* `connectedCallback`. `onCleanup`, nested `effect`s and any other
|
|
11
|
-
* scope-bound registrations made in `setup` are owned by the returned
|
|
12
|
-
* `dispose`.
|
|
13
|
-
*
|
|
14
|
-
* `untracked` detaches the new scope from any enclosing effect so it isn't
|
|
15
|
-
* torn down when that effect re-runs — its lifetime is solely the caller's
|
|
16
|
-
* responsibility.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* class Clock extends HTMLElement {
|
|
21
|
-
* #dispose?: () => void;
|
|
22
|
-
*
|
|
23
|
-
* connectedCallback() {
|
|
24
|
-
* const { dispose } = renderScope(() => {
|
|
25
|
-
* const id = setInterval(() => (this.textContent = String(Date.now())), 1000);
|
|
26
|
-
* onCleanup(() => clearInterval(id));
|
|
27
|
-
* });
|
|
28
|
-
* this.#dispose = dispose;
|
|
29
|
-
* }
|
|
30
|
-
*
|
|
31
|
-
* disconnectedCallback() {
|
|
32
|
-
* this.#dispose?.();
|
|
33
|
-
* this.#dispose = undefined;
|
|
34
|
-
* }
|
|
35
|
-
* }
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
declare function renderScope<T>(setup: () => T): {
|
|
39
|
-
result: T;
|
|
40
|
-
dispose: () => void;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Runs `setup` inside an `effectScope` tied to `el`'s connected lifetime.
|
|
44
|
-
*
|
|
45
|
-
* Call from `connectedCallback`. Effects, `onCleanup` registrations, and
|
|
46
|
-
* reactive reads inside `setup` belong to this scope. Pair with
|
|
47
|
-
* {@link disconnectedScope} from `disconnectedCallback` to dispose.
|
|
48
|
-
*
|
|
49
|
-
* Safe to call more than once (e.g. if the element is reconnected after
|
|
50
|
-
* disconnection): the previous scope is disposed first.
|
|
51
|
-
*
|
|
52
|
-
* @example
|
|
53
|
-
* ```ts
|
|
54
|
-
* class Clock extends HTMLElement {
|
|
55
|
-
* connectedCallback() {
|
|
56
|
-
* connectedScope(this, () => {
|
|
57
|
-
* const id = setInterval(() => this.textContent = String(Date.now()), 1000);
|
|
58
|
-
* onCleanup(() => clearInterval(id));
|
|
59
|
-
* });
|
|
60
|
-
* }
|
|
61
|
-
* disconnectedCallback() {
|
|
62
|
-
* disconnectedScope(this);
|
|
63
|
-
* }
|
|
64
|
-
* }
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
declare function connectedScope(el: HTMLElement, setup: () => void): void;
|
|
68
|
-
/**
|
|
69
|
-
* Disposes the scope previously created by {@link connectedScope} for `el`.
|
|
70
|
-
* No-op if there is no active scope.
|
|
71
|
-
*/
|
|
72
|
-
declare function disconnectedScope(el: HTMLElement): void;
|
|
73
|
-
//#endregion
|
|
74
|
-
export { type CustomElementRegistry, connectedScope, defineElement, disconnectedScope, renderScope };
|
|
1
|
+
import { n as defineElement, t as CustomElementRegistry } from "./custom-elements-bVYOkHKt.mjs";
|
|
2
|
+
export { CustomElementRegistry, defineElement };
|
package/dist/custom-elements.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/define.ts
|
|
1
|
+
//#region src/custom-elements.ts
|
|
3
2
|
/**
|
|
4
3
|
* Register a custom element with the browser and return its class.
|
|
5
4
|
* Pair with a module augmentation of `CustomElementRegistry` to get typed JSX.
|
|
@@ -9,92 +8,4 @@ function defineElement(tag, cls, options) {
|
|
|
9
8
|
return cls;
|
|
10
9
|
}
|
|
11
10
|
//#endregion
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Runs `setup` inside a fresh `effectScope` and returns both its result and
|
|
15
|
-
* the scope's dispose handle.
|
|
16
|
-
*
|
|
17
|
-
* Use this wherever you need to run reactive code with an explicit lifetime
|
|
18
|
-
* outside the JSX element flow — most commonly inside a custom element's
|
|
19
|
-
* `connectedCallback`. `onCleanup`, nested `effect`s and any other
|
|
20
|
-
* scope-bound registrations made in `setup` are owned by the returned
|
|
21
|
-
* `dispose`.
|
|
22
|
-
*
|
|
23
|
-
* `untracked` detaches the new scope from any enclosing effect so it isn't
|
|
24
|
-
* torn down when that effect re-runs — its lifetime is solely the caller's
|
|
25
|
-
* responsibility.
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* class Clock extends HTMLElement {
|
|
30
|
-
* #dispose?: () => void;
|
|
31
|
-
*
|
|
32
|
-
* connectedCallback() {
|
|
33
|
-
* const { dispose } = renderScope(() => {
|
|
34
|
-
* const id = setInterval(() => (this.textContent = String(Date.now())), 1000);
|
|
35
|
-
* onCleanup(() => clearInterval(id));
|
|
36
|
-
* });
|
|
37
|
-
* this.#dispose = dispose;
|
|
38
|
-
* }
|
|
39
|
-
*
|
|
40
|
-
* disconnectedCallback() {
|
|
41
|
-
* this.#dispose?.();
|
|
42
|
-
* this.#dispose = undefined;
|
|
43
|
-
* }
|
|
44
|
-
* }
|
|
45
|
-
* ```
|
|
46
|
-
*/
|
|
47
|
-
function renderScope(setup) {
|
|
48
|
-
let result;
|
|
49
|
-
let dispose;
|
|
50
|
-
untracked(() => {
|
|
51
|
-
dispose = effectScope(() => {
|
|
52
|
-
result = setup();
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
return {
|
|
56
|
-
result,
|
|
57
|
-
dispose
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
const scopes = /* @__PURE__ */ new WeakMap();
|
|
61
|
-
/**
|
|
62
|
-
* Runs `setup` inside an `effectScope` tied to `el`'s connected lifetime.
|
|
63
|
-
*
|
|
64
|
-
* Call from `connectedCallback`. Effects, `onCleanup` registrations, and
|
|
65
|
-
* reactive reads inside `setup` belong to this scope. Pair with
|
|
66
|
-
* {@link disconnectedScope} from `disconnectedCallback` to dispose.
|
|
67
|
-
*
|
|
68
|
-
* Safe to call more than once (e.g. if the element is reconnected after
|
|
69
|
-
* disconnection): the previous scope is disposed first.
|
|
70
|
-
*
|
|
71
|
-
* @example
|
|
72
|
-
* ```ts
|
|
73
|
-
* class Clock extends HTMLElement {
|
|
74
|
-
* connectedCallback() {
|
|
75
|
-
* connectedScope(this, () => {
|
|
76
|
-
* const id = setInterval(() => this.textContent = String(Date.now()), 1000);
|
|
77
|
-
* onCleanup(() => clearInterval(id));
|
|
78
|
-
* });
|
|
79
|
-
* }
|
|
80
|
-
* disconnectedCallback() {
|
|
81
|
-
* disconnectedScope(this);
|
|
82
|
-
* }
|
|
83
|
-
* }
|
|
84
|
-
* ```
|
|
85
|
-
*/
|
|
86
|
-
function connectedScope(el, setup) {
|
|
87
|
-
scopes.get(el)?.();
|
|
88
|
-
const { dispose } = renderScope(setup);
|
|
89
|
-
scopes.set(el, dispose);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Disposes the scope previously created by {@link connectedScope} for `el`.
|
|
93
|
-
* No-op if there is no active scope.
|
|
94
|
-
*/
|
|
95
|
-
function disconnectedScope(el) {
|
|
96
|
-
scopes.get(el)?.();
|
|
97
|
-
scopes.delete(el);
|
|
98
|
-
}
|
|
99
|
-
//#endregion
|
|
100
|
-
export { connectedScope, defineElement, disconnectedScope, renderScope };
|
|
11
|
+
export { defineElement };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as effectScope, g as untracked, p as onCleanup, s as effect } from "./lib-D6duEs38.mjs";
|
|
2
2
|
import "./polyfill-B1lNNcum.mjs";
|
|
3
|
+
import { isReactive, resolveProps } from "./signals/index.mjs";
|
|
3
4
|
import { on } from "./utilities/event-listener.mjs";
|
|
4
5
|
import { i as resolveNode$1, n as Slot, r as Slots, t as SLOTS } from "./slot-Kb61AcgW.mjs";
|
|
5
6
|
//#region \0rolldown/runtime.js
|
|
@@ -85,23 +86,34 @@ function applySlot(slot, value) {
|
|
|
85
86
|
});
|
|
86
87
|
}
|
|
87
88
|
function mountChildren(el, value) {
|
|
88
|
-
for (const child of ensureFlatArray(value))
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
89
|
+
for (const child of ensureFlatArray(value)) mountChild(el, child);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Mounts a single child into `el`. Reactive functions become live slots; other
|
|
93
|
+
* values append as-is. Each child owns its own `effectScope` so sibling
|
|
94
|
+
* `onCleanup` registrations don't overwrite each other (the signals lib
|
|
95
|
+
* supports only one onCleanup per subscriber).
|
|
96
|
+
*
|
|
97
|
+
* Also used by `createFunctionElement` when a component returns a reactive
|
|
98
|
+
* getter or primitive — keeps the component's `effectScope` alive for the
|
|
99
|
+
* lifetime of the fragment it mounts into.
|
|
100
|
+
*/
|
|
101
|
+
function mountChild(el, child) {
|
|
102
|
+
if (typeof child === "function") {
|
|
103
|
+
const slot = Slot.new();
|
|
104
|
+
el.appendChild(slot());
|
|
105
|
+
effectScope(() => {
|
|
106
|
+
effect(() => slot.set(resolveChild(child())));
|
|
107
|
+
onCleanup(() => slot.clear());
|
|
103
108
|
});
|
|
109
|
+
return;
|
|
104
110
|
}
|
|
111
|
+
const node = resolveChild(child);
|
|
112
|
+
const dispose = node[Symbol.dispose];
|
|
113
|
+
el.appendChild(node);
|
|
114
|
+
if (dispose) effectScope(() => {
|
|
115
|
+
onCleanup(dispose);
|
|
116
|
+
});
|
|
105
117
|
}
|
|
106
118
|
function resolveChild(value) {
|
|
107
119
|
if (Array.isArray(value)) {
|
|
@@ -209,10 +221,10 @@ function setAttribute(el, key, value) {
|
|
|
209
221
|
else el.setAttribute(key, value === true ? "" : String(value));
|
|
210
222
|
}
|
|
211
223
|
function isEventKey(key) {
|
|
212
|
-
return key.startsWith("on:")
|
|
224
|
+
return key.startsWith("on:");
|
|
213
225
|
}
|
|
214
226
|
function eventName(key) {
|
|
215
|
-
return key.
|
|
227
|
+
return key.slice(3);
|
|
216
228
|
}
|
|
217
229
|
//#endregion
|
|
218
230
|
//#region src/jsx-runtime/element.ts
|
|
@@ -229,7 +241,7 @@ function createFunctionElement(type, props, ref) {
|
|
|
229
241
|
let dispose;
|
|
230
242
|
untracked(() => {
|
|
231
243
|
dispose = effectScope(() => {
|
|
232
|
-
el = type(props);
|
|
244
|
+
el = type(resolveProps(props));
|
|
233
245
|
if (typeof ref === "function" && el instanceof Element) ref(el);
|
|
234
246
|
});
|
|
235
247
|
});
|
|
@@ -280,4 +292,4 @@ function attachDisposables(el, disposables) {
|
|
|
280
292
|
});
|
|
281
293
|
}
|
|
282
294
|
//#endregion
|
|
283
|
-
export { disposeElement as n, createElement as t };
|
|
295
|
+
export { disposeElement as n, mountChild as r, createElement as t };
|
package/dist/for.d.mts
CHANGED
package/dist/for.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { n as disposeElement } from "./element-
|
|
2
|
-
import {
|
|
1
|
+
import { n as disposeElement } from "./element-DxmInKJw.mjs";
|
|
2
|
+
import { c as effectScope, g as untracked, h as trigger, m as signal, p as onCleanup, s as effect } from "./lib-D6duEs38.mjs";
|
|
3
|
+
import "./signals/index.mjs";
|
|
3
4
|
//#region src/for.ts
|
|
4
5
|
var For = class {
|
|
5
6
|
constructor(_props) {}
|