elements-kit 0.27.3 → 0.27.5
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 +1 -0
- package/dist/await.d.mts +1 -1
- package/dist/{children-CB8W0ANY.d.mts → children-_cMdyX7Q.d.mts} +1 -1
- package/dist/for.d.mts +1 -1
- package/dist/{index-B1FHAd5T.d.mts → index-BrVMftR8.d.mts} +4 -0
- package/dist/integrations/astro-server.mjs +1 -1
- package/dist/integrations/react.d.mts +1 -1
- package/dist/jsx-runtime/dev.d.mts +2 -2
- package/dist/jsx-runtime/index.d.mts +2 -2
- package/dist/signals/index.d.mts +1 -1
- package/dist/signals/index.mjs +4 -0
- package/dist/ui/overlay/index.d.mts +3 -3
- package/dist/ui/overlay/index.mjs +6 -1
- package/dist/utilities/active-element.d.mts +1 -1
- package/dist/utilities/async.d.mts +7 -1
- package/dist/utilities/async.mjs +12 -0
- package/dist/utilities/debounced.d.mts +1 -1
- package/dist/utilities/element-rect.d.mts +15 -15
- package/dist/utilities/element-rect.mjs +39 -36
- package/dist/utilities/element-scroll.d.mts +1 -1
- package/dist/utilities/event-driven.d.mts +1 -1
- package/dist/utilities/event-listener.d.mts +1 -1
- package/dist/utilities/focus-within.d.mts +1 -1
- package/dist/utilities/hover.d.mts +1 -1
- package/dist/utilities/interval.d.mts +1 -1
- package/dist/utilities/location.d.mts +1 -1
- package/dist/utilities/media-devices.d.mts +1 -1
- package/dist/utilities/media-player.d.mts +1 -1
- package/dist/utilities/media-query.d.mts +1 -1
- package/dist/utilities/network.d.mts +1 -1
- package/dist/utilities/orientation.d.mts +1 -1
- package/dist/utilities/previous.d.mts +1 -1
- package/dist/utilities/promise.d.mts +1 -1
- package/dist/utilities/routing.d.mts +1 -1
- package/dist/utilities/search-params.d.mts +1 -1
- package/dist/utilities/storage.d.mts +1 -1
- package/dist/utilities/throttled.d.mts +1 -1
- package/dist/utilities/timeout.d.mts +1 -1
- package/dist/utilities/window-focus.d.mts +1 -1
- package/dist/utilities/window-size.d.mts +1 -1
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -339,6 +339,7 @@ const op = async(() => fetch("/api/items").then((r) => r.json()));
|
|
|
339
339
|
op.start(); // run with reactive tracking — reruns when tracked signals change
|
|
340
340
|
await op; // awaitable (delegates to .then/.catch/.finally via .raw)
|
|
341
341
|
op.stop(); // halt reruns + fire registered cleanup
|
|
342
|
+
op.reset(); // stop + clear state back to `idle`
|
|
342
343
|
```
|
|
343
344
|
|
|
344
345
|
Reactive state getters: `.state` (`"idle" | "pending" | "fulfilled" | "rejected"` — `idle` before the first run, so `.pending` is `false` until you trigger one), `.value`, `.reason`, `.result`, `.pending`, `.raw` (the underlying `ComputedPromise`).
|
package/dist/await.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as AttrChangeHandler, t as ATTRIBUTES } from "./attributes-3r7Diua4.mjs";
|
|
2
2
|
import { i as PropertiesOf, n as CustomElementRegistry, r as EventsOf } from "./custom-elements-C7oiqw-y.mjs";
|
|
3
|
-
import { r as MaybeReactive } from "./index-
|
|
3
|
+
import { r as MaybeReactive } from "./index-BrVMftR8.mjs";
|
|
4
4
|
import * as CSS from "csstype";
|
|
5
5
|
import { JSX } from "dom-expressions/src/jsx";
|
|
6
6
|
|
package/dist/for.d.mts
CHANGED
|
@@ -333,6 +333,10 @@ type MaybeReactive<T> = T | Computed<T>;
|
|
|
333
333
|
* the runtime hands props over exactly as the caller wrote them, so the value
|
|
334
334
|
* may be either form. Reading inside an effect or a JSX getter subscribes.
|
|
335
335
|
*
|
|
336
|
+
* Only branded handles created by `signal`/`computed` are called — a
|
|
337
|
+
* plain function is treated as a static VALUE and returned as-is (so
|
|
338
|
+
* `T` itself may be a function type).
|
|
339
|
+
*
|
|
336
340
|
* @example
|
|
337
341
|
* ```ts
|
|
338
342
|
* resolve(5); // 5
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { y as setInertEffects } from "../lib-DYypKhxk.mjs";
|
|
2
2
|
import { i as setRenderer, t as createElement } from "../element-DgQvp-49.mjs";
|
|
3
|
-
import { i as serverJsx, n as renderToString, r as SNode } from "../server-CoEm-C0I.mjs";
|
|
4
3
|
import { withSlotProps } from "./astro-slots.mjs";
|
|
4
|
+
import { i as serverJsx, n as renderToString, r as SNode } from "../server-CoEm-C0I.mjs";
|
|
5
5
|
//#region src/integrations/astro-server.ts
|
|
6
6
|
/**
|
|
7
7
|
* Decide whether `Component` is an elements-kit component. Invoked by Astro
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as Fragment, c as PropsOf, i as JSX, l as Require, n as ComponentClass, o as MaybeReactiveProps, r as ComponentFn, s as Props, t as Children } from "../children-
|
|
2
|
-
import { n as ComputedProps, r as MaybeReactive } from "../index-
|
|
1
|
+
import { a as Fragment, c as PropsOf, i as JSX, l as Require, n as ComponentClass, o as MaybeReactiveProps, r as ComponentFn, s as Props, t as Children } from "../children-_cMdyX7Q.mjs";
|
|
2
|
+
import { n as ComputedProps, r as MaybeReactive } from "../index-BrVMftR8.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/jsx-runtime/hot.d.ts
|
|
5
5
|
/**
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as Fragment, c as PropsOf, i as JSX, l as Require, n as ComponentClass, o as MaybeReactiveProps, r as ComponentFn, s as Props, t as Children, u as createElement } from "../children-
|
|
2
|
-
import { n as ComputedProps, r as MaybeReactive } from "../index-
|
|
1
|
+
import { a as Fragment, c as PropsOf, i as JSX, l as Require, n as ComponentClass, o as MaybeReactiveProps, r as ComponentFn, s as Props, t as Children, u as createElement } from "../children-_cMdyX7Q.mjs";
|
|
2
|
+
import { n as ComputedProps, r as MaybeReactive } from "../index-BrVMftR8.mjs";
|
|
3
3
|
export { type Children, ComponentClass, ComponentFn, type ComputedProps, Fragment, JSX, type MaybeReactive, type MaybeReactiveProps, type Props, type PropsOf, type Require, createElement as h, createElement as jsx, createElement as jsxDEV, createElement as jsxs };
|
package/dist/signals/index.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as isSignal, D as untracked, E as trigger, S as isEffectScope, T as signal, _ as computed, a as Updater, b as isComputed, c as reactive, d as COMPUTED, f as EFFECT, g as batch, h as SIGNAL, i as Signal, l as resolve, m as SEED, n as ComputedProps, o as computedProps, p as EFFECT_SCOPE, r as MaybeReactive, s as isReactive, t as Computed, u as CLAIM, v as effect, w as onCleanup, x as isEffect, y as effectScope } from "../index-
|
|
1
|
+
import { C as isSignal, D as untracked, E as trigger, S as isEffectScope, T as signal, _ as computed, a as Updater, b as isComputed, c as reactive, d as COMPUTED, f as EFFECT, g as batch, h as SIGNAL, i as Signal, l as resolve, m as SEED, n as ComputedProps, o as computedProps, p as EFFECT_SCOPE, r as MaybeReactive, s as isReactive, t as Computed, u as CLAIM, v as effect, w as onCleanup, x as isEffect, y as effectScope } from "../index-BrVMftR8.mjs";
|
|
2
2
|
export { CLAIM, COMPUTED, Computed, ComputedProps, EFFECT, EFFECT_SCOPE, MaybeReactive, SEED, SIGNAL, Signal, Updater, batch, computed, computedProps, effect, effectScope, isComputed, isEffect, isEffectScope, isReactive, isSignal, onCleanup, reactive, resolve, signal, trigger, untracked };
|
package/dist/signals/index.mjs
CHANGED
|
@@ -83,6 +83,10 @@ function reactive(source) {
|
|
|
83
83
|
* the runtime hands props over exactly as the caller wrote them, so the value
|
|
84
84
|
* may be either form. Reading inside an effect or a JSX getter subscribes.
|
|
85
85
|
*
|
|
86
|
+
* Only branded handles created by `signal`/`computed` are called — a
|
|
87
|
+
* plain function is treated as a static VALUE and returned as-is (so
|
|
88
|
+
* `T` itself may be a function type).
|
|
89
|
+
*
|
|
86
90
|
* @example
|
|
87
91
|
* ```ts
|
|
88
92
|
* resolve(5); // 5
|
|
@@ -11,9 +11,9 @@ import { Placement } from "@floating-ui/dom";
|
|
|
11
11
|
* viewport defaults). Derived values build on regions — `detents()`
|
|
12
12
|
* quantizes one, `rubber()` resists at its edges.
|
|
13
13
|
*/
|
|
14
|
-
/** A reactive rect
|
|
15
|
-
*
|
|
16
|
-
* area) can be supplied too. */
|
|
14
|
+
/** A reactive rect. `createElementRect` returns one reactive `DOMRect`,
|
|
15
|
+
* so the element branch projects its fields onto this shape; custom
|
|
16
|
+
* rects (a static region, a virtual area) can be supplied too. */
|
|
17
17
|
interface Region {
|
|
18
18
|
top(): number;
|
|
19
19
|
left(): number;
|
|
@@ -19,7 +19,12 @@ function constraint(source) {
|
|
|
19
19
|
if (source instanceof Element) {
|
|
20
20
|
const rect = createElementRect(source);
|
|
21
21
|
onCleanup(() => rect[Symbol.dispose]());
|
|
22
|
-
return
|
|
22
|
+
return {
|
|
23
|
+
top: () => rect().top,
|
|
24
|
+
left: () => rect().left,
|
|
25
|
+
width: () => rect().width,
|
|
26
|
+
height: () => rect().height
|
|
27
|
+
};
|
|
23
28
|
}
|
|
24
29
|
return {
|
|
25
30
|
top: () => source.top,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { m as SEED, r as MaybeReactive, u as CLAIM } from "../index-
|
|
1
|
+
import { m as SEED, r as MaybeReactive, u as CLAIM } from "../index-BrVMftR8.mjs";
|
|
2
2
|
import { ComputedPromise } from "./promise.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/utilities/async.d.ts
|
|
@@ -68,6 +68,12 @@ declare class Async<TInput = undefined, TOutput = unknown> {
|
|
|
68
68
|
* Stops the current async operation and run cleanup effects.
|
|
69
69
|
*/
|
|
70
70
|
stop(): this;
|
|
71
|
+
/**
|
|
72
|
+
* Stops the current operation and returns to the idle state — `state` is
|
|
73
|
+
* `"idle"` again and `value` / `reason` / `result` read `undefined`. Unlike
|
|
74
|
+
* {@link stop}, which leaves the last settled operation in place.
|
|
75
|
+
*/
|
|
76
|
+
reset(): this;
|
|
71
77
|
[Symbol.dispose](): void;
|
|
72
78
|
/**
|
|
73
79
|
* Starts a new reactive async operation, stopping any currently active one.
|
package/dist/utilities/async.mjs
CHANGED
|
@@ -138,6 +138,17 @@ var Async = class {
|
|
|
138
138
|
this.#cleanup = () => {};
|
|
139
139
|
return this;
|
|
140
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Stops the current operation and returns to the idle state — `state` is
|
|
143
|
+
* `"idle"` again and `value` / `reason` / `result` read `undefined`. Unlike
|
|
144
|
+
* {@link stop}, which leaves the last settled operation in place.
|
|
145
|
+
*/
|
|
146
|
+
reset() {
|
|
147
|
+
this.stop();
|
|
148
|
+
deferredRuns.delete(this);
|
|
149
|
+
this.#current(IDLE);
|
|
150
|
+
return this;
|
|
151
|
+
}
|
|
141
152
|
[Symbol.dispose]() {
|
|
142
153
|
this.stop();
|
|
143
154
|
}
|
|
@@ -170,6 +181,7 @@ const ASYNC_KEYS = new Set([
|
|
|
170
181
|
"pending",
|
|
171
182
|
"start",
|
|
172
183
|
"stop",
|
|
184
|
+
"reset",
|
|
173
185
|
"run",
|
|
174
186
|
"fn",
|
|
175
187
|
"raw",
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { t as Computed } from "../index-
|
|
1
|
+
import { r as MaybeReactive, t as Computed } from "../index-BrVMftR8.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/utilities/element-rect.d.ts
|
|
4
|
-
type RectResult = {
|
|
5
|
-
x: Computed<number>;
|
|
6
|
-
y: Computed<number>;
|
|
7
|
-
width: Computed<number>;
|
|
8
|
-
height: Computed<number>;
|
|
9
|
-
top: Computed<number>;
|
|
10
|
-
right: Computed<number>;
|
|
11
|
-
bottom: Computed<number>;
|
|
12
|
-
left: Computed<number>;
|
|
13
|
-
} & Disposable;
|
|
14
4
|
/**
|
|
15
|
-
* Observes the full bounding rect of `target`
|
|
16
|
-
*
|
|
17
|
-
*
|
|
5
|
+
* Observes the full bounding rect of `target` and returns it as ONE reactive
|
|
6
|
+
* `DOMRect`, so every field a reader sees was measured at the same instant.
|
|
7
|
+
* Change sources: a `ResizeObserver` for size, plus capture-phase `scroll` and
|
|
8
|
+
* window `resize` for position — a `ResizeObserver` stays silent when an
|
|
9
|
+
* element merely moves.
|
|
10
|
+
*
|
|
11
|
+
* `target` may be a getter, in which case the observer follows it: the previous
|
|
12
|
+
* element is unobserved before the new one is observed. The returned computed
|
|
13
|
+
* keeps its identity across a swap, so consumers never rebind.
|
|
14
|
+
*
|
|
15
|
+
* The value is CACHED, not measured per read: it refreshes when one of the
|
|
16
|
+
* sources above fires, not at the moment you read it. Dispose explicitly, or
|
|
17
|
+
* let the enclosing scope do it.
|
|
18
18
|
*/
|
|
19
|
-
declare function createElementRect(target: Element):
|
|
19
|
+
declare function createElementRect(target: MaybeReactive<Element>): Computed<DOMRect> & Disposable;
|
|
20
20
|
//#endregion
|
|
21
21
|
export { createElementRect };
|
|
@@ -1,47 +1,50 @@
|
|
|
1
|
-
import { x as signal } from "../lib-DYypKhxk.mjs";
|
|
2
|
-
import "../signals/index.mjs";
|
|
1
|
+
import { _ as onCleanup, d as effectScope, l as computed, u as effect, x as signal } from "../lib-DYypKhxk.mjs";
|
|
2
|
+
import { resolve } from "../signals/index.mjs";
|
|
3
3
|
import { createResizeObserver } from "./resize-observer.mjs";
|
|
4
4
|
//#region src/utilities/element-rect.ts
|
|
5
5
|
/**
|
|
6
|
-
* Observes the full bounding rect of `target`
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Observes the full bounding rect of `target` and returns it as ONE reactive
|
|
7
|
+
* `DOMRect`, so every field a reader sees was measured at the same instant.
|
|
8
|
+
* Change sources: a `ResizeObserver` for size, plus capture-phase `scroll` and
|
|
9
|
+
* window `resize` for position — a `ResizeObserver` stays silent when an
|
|
10
|
+
* element merely moves.
|
|
11
|
+
*
|
|
12
|
+
* `target` may be a getter, in which case the observer follows it: the previous
|
|
13
|
+
* element is unobserved before the new one is observed. The returned computed
|
|
14
|
+
* keeps its identity across a swap, so consumers never rebind.
|
|
15
|
+
*
|
|
16
|
+
* The value is CACHED, not measured per read: it refreshes when one of the
|
|
17
|
+
* sources above fires, not at the moment you read it. Dispose explicitly, or
|
|
18
|
+
* let the enclosing scope do it.
|
|
9
19
|
*/
|
|
10
20
|
function createElementRect(target) {
|
|
11
|
-
const
|
|
12
|
-
const y = signal(0);
|
|
13
|
-
const width = signal(0);
|
|
14
|
-
const height = signal(0);
|
|
15
|
-
const top = signal(0);
|
|
16
|
-
const right = signal(0);
|
|
17
|
-
const bottom = signal(0);
|
|
18
|
-
const left = signal(0);
|
|
21
|
+
const cache = signal(resolve(target).getBoundingClientRect());
|
|
19
22
|
const updateRect = (el) => {
|
|
20
|
-
|
|
21
|
-
x(rect.x);
|
|
22
|
-
y(rect.y);
|
|
23
|
-
width(rect.width);
|
|
24
|
-
height(rect.height);
|
|
25
|
-
top(rect.top);
|
|
26
|
-
right(rect.right);
|
|
27
|
-
bottom(rect.bottom);
|
|
28
|
-
left(rect.left);
|
|
23
|
+
cache(el.getBoundingClientRect());
|
|
29
24
|
};
|
|
30
|
-
const
|
|
31
|
-
|
|
25
|
+
const stop = effectScope(() => {
|
|
26
|
+
effect(() => {
|
|
27
|
+
const el = resolve(target);
|
|
28
|
+
createResizeObserver(el, (entries) => {
|
|
29
|
+
for (const entry of entries) updateRect(entry.target);
|
|
30
|
+
});
|
|
31
|
+
const remeasure = () => updateRect(el);
|
|
32
|
+
window.addEventListener("scroll", remeasure, {
|
|
33
|
+
capture: true,
|
|
34
|
+
passive: true
|
|
35
|
+
});
|
|
36
|
+
window.addEventListener("resize", remeasure, { passive: true });
|
|
37
|
+
onCleanup(() => {
|
|
38
|
+
window.removeEventListener("scroll", remeasure, { capture: true });
|
|
39
|
+
window.removeEventListener("resize", remeasure);
|
|
40
|
+
});
|
|
41
|
+
updateRect(el);
|
|
42
|
+
});
|
|
32
43
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
width,
|
|
38
|
-
height,
|
|
39
|
-
top,
|
|
40
|
-
right,
|
|
41
|
-
bottom,
|
|
42
|
-
left,
|
|
43
|
-
[Symbol.dispose]: observer[Symbol.dispose]
|
|
44
|
-
};
|
|
44
|
+
onCleanup(stop);
|
|
45
|
+
const rect = computed(() => cache());
|
|
46
|
+
rect[Symbol.dispose] = stop;
|
|
47
|
+
return rect;
|
|
45
48
|
}
|
|
46
49
|
//#endregion
|
|
47
50
|
export { createElementRect };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elements-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.27.
|
|
4
|
+
"version": "0.27.5",
|
|
5
5
|
"description": "A lightweight reactive UI library that transforms native HTMLElements into reactive components with signals. Ideal for framework-agnostic applications and web components.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"webcomponents",
|
|
@@ -127,7 +127,7 @@
|
|
|
127
127
|
"test:watch": "vitest",
|
|
128
128
|
"test:engines": "node scripts/engine-matrix.mjs"
|
|
129
129
|
},
|
|
130
|
-
"packageManager": "pnpm@
|
|
130
|
+
"packageManager": "pnpm@11.25.0",
|
|
131
131
|
"devDependencies": {
|
|
132
132
|
"@tsdown/css": "^0.22.0",
|
|
133
133
|
"@types/react": "^19.2.14",
|
|
@@ -139,8 +139,7 @@
|
|
|
139
139
|
"react-dom": "^19.2.5",
|
|
140
140
|
"tsdown": "0.22.0",
|
|
141
141
|
"typescript": "^6.0.3",
|
|
142
|
-
"vitest": "^4.1.2"
|
|
143
|
-
"puppeteer-core": "^24.0.0"
|
|
142
|
+
"vitest": "^4.1.2"
|
|
144
143
|
},
|
|
145
144
|
"dependencies": {
|
|
146
145
|
"@floating-ui/dom": "^1.7.6",
|