qcobjects 2.5.109-beta → 2.5.111-beta

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/VERSION CHANGED
@@ -1 +1 @@
1
- 2.5.109-beta
1
+ 2.5.111-beta
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._DOMCreateElement = void 0;
3
+ exports._DOMCreateComplexElement = exports._DOMCreateElement = void 0;
4
4
  const platform_1 = require("./platform");
5
- const _DOMCreateElement = function (elementName) {
5
+ const _DOMCreateElement = function (elementName, props, children) {
6
6
  let _ret_;
7
7
  if (platform_1.isBrowser) {
8
- _ret_ = document.createElement(elementName);
8
+ _ret_ = (0, exports._DOMCreateComplexElement)(elementName, props, children);
9
9
  }
10
10
  else {
11
11
  _ret_ = {};
@@ -13,3 +13,35 @@ const _DOMCreateElement = function (elementName) {
13
13
  return _ret_;
14
14
  };
15
15
  exports._DOMCreateElement = _DOMCreateElement;
16
+ const ComplexTypeCall = (_type, { props, children }) => {
17
+ return _type({ props, children });
18
+ };
19
+ const _DOMCreateComplexElement = (_type, props, children) => {
20
+ if (typeof _type !== "string") {
21
+ return ComplexTypeCall(_type, { props, children });
22
+ }
23
+ const element = document.createElement(_type);
24
+ if (props) {
25
+ Object.entries(props).forEach(([key, value]) => {
26
+ if (typeof value === "string" || typeof value === "number") {
27
+ element.setAttribute(key, value.toString());
28
+ }
29
+ else if (typeof value === "function" && key.toLowerCase().startsWith("on")) {
30
+ element.addEventListener(key.slice(2).toLowerCase(), value.bind(element));
31
+ }
32
+ });
33
+ }
34
+ if (Array.isArray(children)) {
35
+ children.filter((child => child instanceof Node)).forEach(child => {
36
+ element.appendChild(child);
37
+ });
38
+ }
39
+ else if (children instanceof Node) {
40
+ element.appendChild(children);
41
+ }
42
+ else if (typeof children === "string") {
43
+ element.innerHTML = children;
44
+ }
45
+ return element;
46
+ };
47
+ exports._DOMCreateComplexElement = _DOMCreateComplexElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qcobjects",
3
- "version": "2.5.109-beta",
3
+ "version": "2.5.111-beta",
4
4
  "description": "QCObjects is an Open-source framework that empowers full-stack developers to make micro-services and micro-frontends into an N-Tier architecture.",
5
5
  "main": "public/cjs/QCObjects.cjs",
6
6
  "module": "public/esm/QCObjects.mjs",
@@ -272,20 +272,48 @@ var global = (() => {
272
272
  });
273
273
 
274
274
  // src/DOMCreateElement.ts
275
- var _DOMCreateElement;
275
+ var _DOMCreateElement, ComplexTypeCall, _DOMCreateComplexElement;
276
276
  var init_DOMCreateElement = __esm({
277
277
  "src/DOMCreateElement.ts"() {
278
278
  "use strict";
279
279
  init_platform();
280
- _DOMCreateElement = /* @__PURE__ */ __name(function(elementName) {
280
+ _DOMCreateElement = /* @__PURE__ */ __name(function(elementName, props, children) {
281
281
  let _ret_;
282
282
  if (isBrowser) {
283
- _ret_ = document.createElement(elementName);
283
+ _ret_ = _DOMCreateComplexElement(elementName, props, children);
284
284
  } else {
285
285
  _ret_ = {};
286
286
  }
287
287
  return _ret_;
288
288
  }, "_DOMCreateElement");
289
+ ComplexTypeCall = /* @__PURE__ */ __name((_type, { props, children }) => {
290
+ return _type({ props, children });
291
+ }, "ComplexTypeCall");
292
+ _DOMCreateComplexElement = /* @__PURE__ */ __name((_type, props, children) => {
293
+ if (typeof _type !== "string") {
294
+ return ComplexTypeCall(_type, { props, children });
295
+ }
296
+ const element = document.createElement(_type);
297
+ if (props) {
298
+ Object.entries(props).forEach(([key, value]) => {
299
+ if (typeof value === "string" || typeof value === "number") {
300
+ element.setAttribute(key, value.toString());
301
+ } else if (typeof value === "function" && key.toLowerCase().startsWith("on")) {
302
+ element.addEventListener(key.slice(2).toLowerCase(), value.bind(element));
303
+ }
304
+ });
305
+ }
306
+ if (Array.isArray(children)) {
307
+ children.filter((child) => child instanceof Node).forEach((child) => {
308
+ element.appendChild(child);
309
+ });
310
+ } else if (children instanceof Node) {
311
+ element.appendChild(children);
312
+ } else if (typeof children === "string") {
313
+ element.innerHTML = children;
314
+ }
315
+ return element;
316
+ }, "_DOMCreateComplexElement");
289
317
  }
290
318
  });
291
319