thunderous 0.4.3 → 0.5.0
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.cjs +13 -6
- package/dist/index.d.cts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +13 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
@@ -1468,7 +1468,15 @@ You must set an initial value before calling a property signal's getter.
|
|
1468
1468
|
}
|
1469
1469
|
}
|
1470
1470
|
let _tagname = null;
|
1471
|
-
|
1471
|
+
let _registry = null;
|
1472
|
+
let _registered = false;
|
1473
|
+
const register = () => {
|
1474
|
+
if (_tagname === null || _registry === null || _registered) return;
|
1475
|
+
_registry.register(_tagname, CustomElement);
|
1476
|
+
_registry.register(_tagname, elementResult);
|
1477
|
+
_registered = true;
|
1478
|
+
};
|
1479
|
+
const elementResult = {
|
1472
1480
|
define(tagname) {
|
1473
1481
|
if (customElements.get(tagname) !== void 0) {
|
1474
1482
|
console.warn(`Custom element "${tagname}" was already defined. Skipping...`);
|
@@ -1476,18 +1484,17 @@ You must set an initial value before calling a property signal's getter.
|
|
1476
1484
|
}
|
1477
1485
|
customElements.define(tagname, CustomElement);
|
1478
1486
|
_tagname = tagname;
|
1487
|
+
register();
|
1479
1488
|
return this;
|
1480
1489
|
},
|
1481
1490
|
register(registry) {
|
1482
|
-
|
1483
|
-
|
1484
|
-
return this;
|
1485
|
-
}
|
1486
|
-
registry.register(_tagname, CustomElement);
|
1491
|
+
_registry = registry;
|
1492
|
+
register();
|
1487
1493
|
return this;
|
1488
1494
|
},
|
1489
1495
|
eject: () => CustomElement
|
1490
1496
|
};
|
1497
|
+
return elementResult;
|
1491
1498
|
};
|
1492
1499
|
var createRegistry = () => {
|
1493
1500
|
const registry = /* @__PURE__ */ new Map();
|
package/dist/index.d.cts
CHANGED
@@ -98,11 +98,16 @@ type RenderFunction<Props extends CustomElementProps> = (args: RenderArgs<Props>
|
|
98
98
|
*/
|
99
99
|
declare const customElement: <Props extends CustomElementProps>(render: RenderFunction<Props>, options?: Partial<RenderOptions>) => ElementResult;
|
100
100
|
type Registry = {
|
101
|
-
register: (tagName: string, element: CustomElementConstructor) => void;
|
102
|
-
getTagName: (element: CustomElementConstructor) => string | undefined;
|
101
|
+
register: (tagName: string, element: CustomElementConstructor | ElementResult) => void;
|
102
|
+
getTagName: (element: CustomElementConstructor | ElementResult) => string | undefined;
|
103
103
|
};
|
104
104
|
/**
|
105
105
|
* Create a registry for custom elements.
|
106
|
+
*
|
107
|
+
* This allows you to delegate custom element definitions to the consumer of your library,
|
108
|
+
* by using their associated classes to look up tag names dynamically.
|
109
|
+
*
|
110
|
+
* This can be useful when you need to select a custom element whose tag name is variable.
|
106
111
|
* @example
|
107
112
|
* ```ts
|
108
113
|
* const registry = createRegistry();
|
package/dist/index.d.ts
CHANGED
@@ -98,11 +98,16 @@ type RenderFunction<Props extends CustomElementProps> = (args: RenderArgs<Props>
|
|
98
98
|
*/
|
99
99
|
declare const customElement: <Props extends CustomElementProps>(render: RenderFunction<Props>, options?: Partial<RenderOptions>) => ElementResult;
|
100
100
|
type Registry = {
|
101
|
-
register: (tagName: string, element: CustomElementConstructor) => void;
|
102
|
-
getTagName: (element: CustomElementConstructor) => string | undefined;
|
101
|
+
register: (tagName: string, element: CustomElementConstructor | ElementResult) => void;
|
102
|
+
getTagName: (element: CustomElementConstructor | ElementResult) => string | undefined;
|
103
103
|
};
|
104
104
|
/**
|
105
105
|
* Create a registry for custom elements.
|
106
|
+
*
|
107
|
+
* This allows you to delegate custom element definitions to the consumer of your library,
|
108
|
+
* by using their associated classes to look up tag names dynamically.
|
109
|
+
*
|
110
|
+
* This can be useful when you need to select a custom element whose tag name is variable.
|
106
111
|
* @example
|
107
112
|
* ```ts
|
108
113
|
* const registry = createRegistry();
|
package/dist/index.js
CHANGED
@@ -1436,7 +1436,15 @@ You must set an initial value before calling a property signal's getter.
|
|
1436
1436
|
}
|
1437
1437
|
}
|
1438
1438
|
let _tagname = null;
|
1439
|
-
|
1439
|
+
let _registry = null;
|
1440
|
+
let _registered = false;
|
1441
|
+
const register = () => {
|
1442
|
+
if (_tagname === null || _registry === null || _registered) return;
|
1443
|
+
_registry.register(_tagname, CustomElement);
|
1444
|
+
_registry.register(_tagname, elementResult);
|
1445
|
+
_registered = true;
|
1446
|
+
};
|
1447
|
+
const elementResult = {
|
1440
1448
|
define(tagname) {
|
1441
1449
|
if (customElements.get(tagname) !== void 0) {
|
1442
1450
|
console.warn(`Custom element "${tagname}" was already defined. Skipping...`);
|
@@ -1444,18 +1452,17 @@ You must set an initial value before calling a property signal's getter.
|
|
1444
1452
|
}
|
1445
1453
|
customElements.define(tagname, CustomElement);
|
1446
1454
|
_tagname = tagname;
|
1455
|
+
register();
|
1447
1456
|
return this;
|
1448
1457
|
},
|
1449
1458
|
register(registry) {
|
1450
|
-
|
1451
|
-
|
1452
|
-
return this;
|
1453
|
-
}
|
1454
|
-
registry.register(_tagname, CustomElement);
|
1459
|
+
_registry = registry;
|
1460
|
+
register();
|
1455
1461
|
return this;
|
1456
1462
|
},
|
1457
1463
|
eject: () => CustomElement
|
1458
1464
|
};
|
1465
|
+
return elementResult;
|
1459
1466
|
};
|
1460
1467
|
var createRegistry = () => {
|
1461
1468
|
const registry = /* @__PURE__ */ new Map();
|