@targoninc/jess-components 0.0.3 → 0.0.4
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/dist/index.js +6 -6
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -68,7 +68,7 @@ function compute(valueFunction, ...signals) {
|
|
|
68
68
|
return out;
|
|
69
69
|
}
|
|
70
70
|
function isSignal(obj) {
|
|
71
|
-
return obj?.constructor ===
|
|
71
|
+
return obj?.subscribe?.constructor === Function;
|
|
72
72
|
}
|
|
73
73
|
function asSignal(obj) {
|
|
74
74
|
return obj;
|
|
@@ -86,7 +86,7 @@ function when(condition, element, inverted = false) {
|
|
|
86
86
|
}
|
|
87
87
|
return element;
|
|
88
88
|
}
|
|
89
|
-
if (condition && condition
|
|
89
|
+
if (condition && isSignal(condition)) {
|
|
90
90
|
const state = signal(condition.value ? inverted ? nullElement() : getElement() : inverted ? getElement() : nullElement());
|
|
91
91
|
condition.subscribe((newValue) => {
|
|
92
92
|
if (newValue) {
|
|
@@ -170,7 +170,7 @@ class DomNode {
|
|
|
170
170
|
}
|
|
171
171
|
classes(...classes) {
|
|
172
172
|
for (let cls of classes) {
|
|
173
|
-
if (cls && cls.constructor
|
|
173
|
+
if (cls && isSignal(cls.constructor)) {
|
|
174
174
|
const sig = cls;
|
|
175
175
|
let previousValue = sig.value;
|
|
176
176
|
this._node.classList.add(previousValue);
|
|
@@ -193,7 +193,7 @@ class DomNode {
|
|
|
193
193
|
for (let i = 0;i < arguments.length; i += 2) {
|
|
194
194
|
const key = arguments[i];
|
|
195
195
|
const value = arguments[i + 1];
|
|
196
|
-
if (value && value
|
|
196
|
+
if (value && isSignal(value)) {
|
|
197
197
|
this._node.setAttribute(key, value.value);
|
|
198
198
|
value.onUpdate = (newValue) => {
|
|
199
199
|
this._node.setAttribute(key, newValue);
|
|
@@ -229,7 +229,7 @@ class DomNode {
|
|
|
229
229
|
this._node.appendChild(node);
|
|
230
230
|
} else if (node instanceof DomNode) {
|
|
231
231
|
this._node.appendChild(node.build());
|
|
232
|
-
} else if (node && node
|
|
232
|
+
} else if (node && isSignal(node)) {
|
|
233
233
|
node.subscribe((newValue) => {
|
|
234
234
|
if (isValidElement(newValue)) {
|
|
235
235
|
this._node.replaceChild(newValue, childNode);
|
|
@@ -550,7 +550,7 @@ class DomNode {
|
|
|
550
550
|
if (key.constructor !== String) {
|
|
551
551
|
throw new Error("Invalid key type for styles. Must be a string.");
|
|
552
552
|
}
|
|
553
|
-
if (value && value
|
|
553
|
+
if (value && isSignal(value)) {
|
|
554
554
|
this._node.style[key] = value.value;
|
|
555
555
|
value.onUpdate = (newValue) => {
|
|
556
556
|
this._node.style[key] = newValue;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@targoninc/jess-components",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.4",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"prepublishOnly": "bun run build"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@targoninc/jess": "^0.0.
|
|
20
|
+
"@targoninc/jess": "^0.0.8"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/bun": "latest",
|