elements-kit 0.0.2 → 0.0.3
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 +228 -154
- package/dist/attributes.mjs +1 -2
- package/dist/builder/dom.d.mts +1 -2
- package/dist/builder/dom.mjs +1 -4
- package/dist/builder/index.d.mts +1 -88
- package/dist/builder/index.mjs +3 -5
- package/dist/{element-B3gwJmBr.mjs → element-CCHXkEsj.mjs} +16 -31
- package/dist/index-C6xwOPCO.d.mts +263 -0
- package/dist/index-DJejH8Ff.d.mts +89 -0
- package/dist/index.mjs +3 -6
- package/dist/jsx-runtime/index.d.mts +1 -1
- package/dist/jsx-runtime/index.mjs +2 -4
- package/dist/{polyfill-DAalJpCO.mjs → lib-B2drrxlV.mjs} +1 -6
- package/dist/signals/index.d.mts +2 -0
- package/dist/signals/index.mjs +2 -0
- package/dist/signals/lib/media.d.mts +14 -0
- package/dist/signals/lib/media.mjs +26 -0
- package/dist/signals/lib/react.d.mts +62 -0
- package/dist/signals/lib/react.mjs +82 -0
- package/dist/signals-Cr7xgAJH.mjs +966 -0
- package/dist/slot.d.mts +2 -3
- package/dist/slot.mjs +1 -2
- package/package.json +33 -5
- package/dist/signals.d.mts +0 -40
- package/dist/signals.mjs +0 -76
- /package/dist/{polyfill-Bvo2e52W.d.mts → polyfill-BEL-HWkO.d.mts} +0 -0
package/dist/slot.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import { ElementBuilder } from "./builder/index.mjs";
|
|
1
|
+
import { o as ElementBuilder } from "./index-DJejH8Ff.mjs";
|
|
3
2
|
|
|
4
3
|
//#region src/slot.d.ts
|
|
5
4
|
/**
|
|
@@ -22,7 +21,7 @@ declare class Slot {
|
|
|
22
21
|
set(element: Node): void;
|
|
23
22
|
get(): DocumentFragment | null;
|
|
24
23
|
/** Returns the parent node if the slot is mounted, otherwise `null`. */
|
|
25
|
-
parent(): ParentNode;
|
|
24
|
+
parent(): ParentNode | null;
|
|
26
25
|
/** Whether the slot's comment markers are attached to the DOM. */
|
|
27
26
|
isMounted(): boolean;
|
|
28
27
|
private isSame;
|
package/dist/slot.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elements-kit",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.3",
|
|
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",
|
|
@@ -24,54 +24,82 @@
|
|
|
24
24
|
],
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
|
+
"source": "./src/index.ts",
|
|
27
28
|
"import": "./dist/index.mjs",
|
|
28
29
|
"types": "./dist/index.d.ts"
|
|
29
30
|
},
|
|
30
31
|
"./signals": {
|
|
31
|
-
"
|
|
32
|
-
"
|
|
32
|
+
"source": "./src/signals/index.ts",
|
|
33
|
+
"import": "./dist/signals/index.mjs",
|
|
34
|
+
"types": "./dist/signals/index.d.ts"
|
|
35
|
+
},
|
|
36
|
+
"./signals/*": {
|
|
37
|
+
"source": "./src/signals/lib/*.ts",
|
|
38
|
+
"import": "./dist/signals/lib/*.mjs",
|
|
39
|
+
"types": "./dist/signals/lib/*.d.ts"
|
|
33
40
|
},
|
|
34
41
|
"./slot": {
|
|
42
|
+
"source": "./src/slot.ts",
|
|
35
43
|
"import": "./dist/slot.mjs",
|
|
36
44
|
"types": "./dist/slot.d.ts"
|
|
37
45
|
},
|
|
38
46
|
"./attributes": {
|
|
47
|
+
"source": "./src/attributes.ts",
|
|
39
48
|
"import": "./dist/attributes.mjs",
|
|
40
49
|
"types": "./dist/attributes.d.ts"
|
|
41
50
|
},
|
|
42
51
|
"./builder": {
|
|
52
|
+
"source": "./src/builder/index.ts",
|
|
43
53
|
"import": "./dist/builder/index.mjs",
|
|
44
54
|
"types": "./dist/builder/index.d.ts"
|
|
45
55
|
},
|
|
46
56
|
"./builder/dom": {
|
|
57
|
+
"source": "./src/builder/dom.ts",
|
|
47
58
|
"import": "./dist/builder/dom.mjs",
|
|
48
59
|
"types": "./dist/builder/dom.d.ts"
|
|
49
60
|
},
|
|
50
61
|
"./jsx-runtime": {
|
|
62
|
+
"source": "./src/jsx-runtime/index.ts",
|
|
51
63
|
"import": "./dist/jsx-runtime/index.mjs",
|
|
52
64
|
"types": "./dist/jsx-runtime/index.d.ts"
|
|
53
65
|
},
|
|
54
66
|
"./jsx-dev-runtime": {
|
|
67
|
+
"source": "./src/jsx-runtime/index.ts",
|
|
55
68
|
"import": "./dist/jsx-runtime/index.mjs",
|
|
56
69
|
"types": "./dist/jsx-runtime/index.d.ts"
|
|
57
70
|
}
|
|
58
71
|
},
|
|
59
72
|
"scripts": {
|
|
60
|
-
"demo": "pnpx vite ./demo -c demo/vite.config.ts",
|
|
61
73
|
"build": "tsdown",
|
|
74
|
+
"build:docs": "pnpm build && pnpm --filter elements-kit-docs build",
|
|
62
75
|
"watch": "tsdown -w",
|
|
63
76
|
"test": "vitest run",
|
|
64
77
|
"test:watch": "vitest"
|
|
65
78
|
},
|
|
66
79
|
"packageManager": "pnpm@10.33.0",
|
|
67
80
|
"devDependencies": {
|
|
81
|
+
"@types/react": "^19.2.14",
|
|
82
|
+
"@types/react-dom": "^19.2.3",
|
|
68
83
|
"happy-dom": "^20.8.9",
|
|
84
|
+
"react": "^19.2.5",
|
|
85
|
+
"react-dom": "^19.2.5",
|
|
69
86
|
"tsdown": "0.21.7",
|
|
70
87
|
"typescript": "^6.0.2",
|
|
71
88
|
"vitest": "^4.1.2"
|
|
72
89
|
},
|
|
73
90
|
"dependencies": {
|
|
74
|
-
"alien-signals": "^3.1.2",
|
|
75
91
|
"dom-expressions": "^0.40.6"
|
|
92
|
+
},
|
|
93
|
+
"peerDependencies": {
|
|
94
|
+
"react": "^19.0.0",
|
|
95
|
+
"react-dom": "^19.0.0"
|
|
96
|
+
},
|
|
97
|
+
"peerDependenciesMeta": {
|
|
98
|
+
"react": {
|
|
99
|
+
"optional": true
|
|
100
|
+
},
|
|
101
|
+
"react-dom": {
|
|
102
|
+
"optional": true
|
|
103
|
+
}
|
|
76
104
|
}
|
|
77
105
|
}
|
package/dist/signals.d.mts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import "./polyfill-Bvo2e52W.mjs";
|
|
2
|
-
import { ValueOrReactive } from "./builder/index.mjs";
|
|
3
|
-
import { computed, effect, effectScope, isComputed, isEffect, isEffectScope, isSignal, signal, signal as signal$1, trigger } from "alien-signals";
|
|
4
|
-
|
|
5
|
-
//#region src/signals.d.ts
|
|
6
|
-
declare function isReactive<T>(value: ValueOrReactive<T>): value is () => T;
|
|
7
|
-
type Signal<T> = ReturnType<typeof signal$1<T>>;
|
|
8
|
-
declare const batch: (fn: () => void) => void;
|
|
9
|
-
declare const untracked: <T>(fn: () => T) => T;
|
|
10
|
-
/**
|
|
11
|
-
* A decorator that makes a class field reactive by automatically wrapping its value in a signal.
|
|
12
|
-
*
|
|
13
|
-
* The field behaves like a normal property (get/set) but reactivity is tracked under the hood.
|
|
14
|
-
* Any reads will subscribe to the signal and any writes will trigger updates.
|
|
15
|
-
*
|
|
16
|
-
* @example
|
|
17
|
-
* ```ts
|
|
18
|
-
* class Counter {
|
|
19
|
-
* @reactive()
|
|
20
|
-
* count: number = 0;
|
|
21
|
-
* }
|
|
22
|
-
*
|
|
23
|
-
* const counter = new Counter();
|
|
24
|
-
* counter.count++; // Triggers reactivity
|
|
25
|
-
* console.log(counter.count); // Subscribes to changes
|
|
26
|
-
* ```
|
|
27
|
-
*
|
|
28
|
-
* @remarks
|
|
29
|
-
* Equivalent to manually creating a private signal and getter/setter:
|
|
30
|
-
* ```ts
|
|
31
|
-
* class Counter {
|
|
32
|
-
* #count = signal(0);
|
|
33
|
-
* get count() { return this.#count(); }
|
|
34
|
-
* set count(value) { this.#count(value); }
|
|
35
|
-
* }
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
declare function reactive<This extends object, Value>(source?: (self: This) => Signal<Value>): (_target: unknown, context: ClassFieldDecoratorContext<This, Value>) => (this: This, initialValue: Value) => Value;
|
|
39
|
-
//#endregion
|
|
40
|
-
export { Signal, batch, computed, effect, effectScope, isComputed, isEffect, isEffectScope, isReactive, isSignal, reactive, signal, trigger, untracked };
|
package/dist/signals.mjs
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { computed, effect, effectScope, endBatch, isComputed, isComputed as isComputed$1, isEffect, isEffectScope, isSignal, isSignal as isSignal$1, setActiveSub, signal, signal as signal$1, startBatch, trigger } from "alien-signals";
|
|
2
|
-
|
|
3
|
-
//#region src/signals.ts
|
|
4
|
-
function isReactive(value) {
|
|
5
|
-
return isSignal$1(value) || isComputed$1(value);
|
|
6
|
-
}
|
|
7
|
-
const batch = (fn) => {
|
|
8
|
-
startBatch();
|
|
9
|
-
try {
|
|
10
|
-
fn();
|
|
11
|
-
} finally {
|
|
12
|
-
endBatch();
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
const untracked = (fn) => {
|
|
16
|
-
const sub = setActiveSub(void 0);
|
|
17
|
-
try {
|
|
18
|
-
return fn();
|
|
19
|
-
} finally {
|
|
20
|
-
setActiveSub(sub);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* A decorator that makes a class field reactive by automatically wrapping its value in a signal.
|
|
25
|
-
*
|
|
26
|
-
* The field behaves like a normal property (get/set) but reactivity is tracked under the hood.
|
|
27
|
-
* Any reads will subscribe to the signal and any writes will trigger updates.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```ts
|
|
31
|
-
* class Counter {
|
|
32
|
-
* @reactive()
|
|
33
|
-
* count: number = 0;
|
|
34
|
-
* }
|
|
35
|
-
*
|
|
36
|
-
* const counter = new Counter();
|
|
37
|
-
* counter.count++; // Triggers reactivity
|
|
38
|
-
* console.log(counter.count); // Subscribes to changes
|
|
39
|
-
* ```
|
|
40
|
-
*
|
|
41
|
-
* @remarks
|
|
42
|
-
* Equivalent to manually creating a private signal and getter/setter:
|
|
43
|
-
* ```ts
|
|
44
|
-
* class Counter {
|
|
45
|
-
* #count = signal(0);
|
|
46
|
-
* get count() { return this.#count(); }
|
|
47
|
-
* set count(value) { this.#count(value); }
|
|
48
|
-
* }
|
|
49
|
-
* ```
|
|
50
|
-
*/
|
|
51
|
-
function reactive(source) {
|
|
52
|
-
const signalStore = /* @__PURE__ */ new WeakMap();
|
|
53
|
-
return (_target, context) => {
|
|
54
|
-
context.addInitializer(function() {
|
|
55
|
-
const sig = signalStore.get(this);
|
|
56
|
-
const writable = !isComputed$1(sig);
|
|
57
|
-
Object.defineProperty(this, context.name, {
|
|
58
|
-
get() {
|
|
59
|
-
return sig();
|
|
60
|
-
},
|
|
61
|
-
...writable && { set(value) {
|
|
62
|
-
sig(value);
|
|
63
|
-
} },
|
|
64
|
-
enumerable: true,
|
|
65
|
-
configurable: true
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
return function(initialValue) {
|
|
69
|
-
signalStore.set(this, source ? source(this) : signal$1(initialValue));
|
|
70
|
-
return initialValue;
|
|
71
|
-
};
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
//#endregion
|
|
76
|
-
export { batch, computed, effect, effectScope, isComputed, isEffect, isEffectScope, isReactive, isSignal, reactive, signal, trigger, untracked };
|
|
File without changes
|