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