cradova 2.1.1 → 2.1.2
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.d.ts +1 -5
- package/dist/index.js +51 -92
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -153,7 +153,6 @@ declare module "cradova" {
|
|
|
153
153
|
text?: string;
|
|
154
154
|
stateID?: string;
|
|
155
155
|
shouldUpdate?: boolean;
|
|
156
|
-
assert?: any;
|
|
157
156
|
}
|
|
158
157
|
)[]
|
|
159
158
|
) => T;
|
|
@@ -525,10 +524,7 @@ css(".btn:hover",
|
|
|
525
524
|
* @param {expression} condition
|
|
526
525
|
* @param {function} callback
|
|
527
526
|
*/
|
|
528
|
-
export function assert(
|
|
529
|
-
condition: any,
|
|
530
|
-
...callback: (() => any)[]
|
|
531
|
-
): "" | (() => any)[];
|
|
527
|
+
export function assert(condition: any, ...elements: any): undefined | any;
|
|
532
528
|
|
|
533
529
|
export function loop(
|
|
534
530
|
datalist: any[],
|
package/dist/index.js
CHANGED
|
@@ -17,6 +17,35 @@ function uuid() {
|
|
|
17
17
|
return ("x" === e ? r : 7 & r | 8).toString(16);
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
+
function Rhoda(l) {
|
|
21
|
+
const fg = new DocumentFragment();
|
|
22
|
+
for (let ch of l) {
|
|
23
|
+
if (Array.isArray(ch)) {
|
|
24
|
+
fg.appendChild(Rhoda(ch));
|
|
25
|
+
} else {
|
|
26
|
+
if (typeof ch === "function") {
|
|
27
|
+
ch = ch();
|
|
28
|
+
}
|
|
29
|
+
if (typeof ch === "function") {
|
|
30
|
+
ch = ch();
|
|
31
|
+
}
|
|
32
|
+
if (typeof ch === "string" || typeof ch === "number") {
|
|
33
|
+
fg.appendChild(document.createTextNode(ch));
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (isNode(ch)) {
|
|
37
|
+
fg.appendChild(ch);
|
|
38
|
+
} else {
|
|
39
|
+
if (typeof ch !== "undefined") {
|
|
40
|
+
throw new Error(
|
|
41
|
+
" \u2718 Cradova err: invalid child type: " + ch + " (" + typeof ch + ")"
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return fg;
|
|
48
|
+
}
|
|
20
49
|
function css(identifier, properties) {
|
|
21
50
|
if (typeof identifier === "string" && typeof properties === "undefined") {
|
|
22
51
|
let styTag = document.querySelector("style");
|
|
@@ -57,14 +86,19 @@ function css(identifier, properties) {
|
|
|
57
86
|
styleTag.innerHTML = totalStyle;
|
|
58
87
|
document.head.appendChild(styleTag);
|
|
59
88
|
}
|
|
60
|
-
function assert(condition, ...
|
|
89
|
+
function assert(condition, ...elements) {
|
|
61
90
|
if (condition) {
|
|
62
|
-
return
|
|
91
|
+
return elements;
|
|
63
92
|
}
|
|
64
|
-
return
|
|
93
|
+
return void 0;
|
|
65
94
|
}
|
|
66
95
|
function loop(datalist2, component) {
|
|
67
|
-
|
|
96
|
+
if (typeof component !== "function") {
|
|
97
|
+
throw new Error(
|
|
98
|
+
" \u2718 Cradova err : Invalid component type, must be a function that returns html "
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
return Array.isArray(datalist2) ? datalist2.map(component) : void 0;
|
|
68
102
|
}
|
|
69
103
|
function assertOr(condition, ifTrue, ifFalse) {
|
|
70
104
|
if (condition) {
|
|
@@ -934,51 +968,14 @@ var cra = (element_initials) => {
|
|
|
934
968
|
continue;
|
|
935
969
|
}
|
|
936
970
|
if (Array.isArray(child)) {
|
|
937
|
-
|
|
938
|
-
const fg = new DocumentFragment();
|
|
939
|
-
for (let ch of l) {
|
|
940
|
-
if (Array.isArray(ch)) {
|
|
941
|
-
fg.appendChild(rload2(ch));
|
|
942
|
-
} else {
|
|
943
|
-
if (typeof ch === "function") {
|
|
944
|
-
ch = ch();
|
|
945
|
-
}
|
|
946
|
-
if (typeof ch === "function") {
|
|
947
|
-
ch = ch();
|
|
948
|
-
}
|
|
949
|
-
fg.appendChild(ch);
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
return fg;
|
|
953
|
-
};
|
|
954
|
-
var rload = rload2;
|
|
955
|
-
const arrCXLength = child.length;
|
|
956
|
-
for (let p2 = 0; p2 < arrCXLength; p2++) {
|
|
957
|
-
let childly = child[p2];
|
|
958
|
-
if (typeof childly === "function") {
|
|
959
|
-
childly = childly();
|
|
960
|
-
}
|
|
961
|
-
if (typeof childly === "function") {
|
|
962
|
-
childly = childly();
|
|
963
|
-
}
|
|
964
|
-
if (Array.isArray(childly)) {
|
|
965
|
-
childly = rload2(childly);
|
|
966
|
-
}
|
|
967
|
-
if (isNode(childly)) {
|
|
968
|
-
element.appendChild(childly);
|
|
969
|
-
} else {
|
|
970
|
-
throw new Error(
|
|
971
|
-
" \u2718 Cradova err: invalid child type: " + childly + " (" + typeof childly + ")"
|
|
972
|
-
);
|
|
973
|
-
}
|
|
974
|
-
}
|
|
971
|
+
element.appendChild(Rhoda(child));
|
|
975
972
|
continue;
|
|
976
973
|
}
|
|
977
974
|
if (typeof child === "string" || typeof child === "number") {
|
|
978
975
|
text = child;
|
|
979
976
|
continue;
|
|
980
977
|
}
|
|
981
|
-
if (typeof child === "object"
|
|
978
|
+
if (typeof child === "object") {
|
|
982
979
|
if (!props) {
|
|
983
980
|
props = child;
|
|
984
981
|
} else {
|
|
@@ -986,10 +983,12 @@ var cra = (element_initials) => {
|
|
|
986
983
|
}
|
|
987
984
|
continue;
|
|
988
985
|
}
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
986
|
+
if (typeof child !== "undefined") {
|
|
987
|
+
console.error(" \u2718 Cradova err: got", { child });
|
|
988
|
+
throw new Error(
|
|
989
|
+
" \u2718 Cradova err: invalid child type: (" + typeof child + ")"
|
|
990
|
+
);
|
|
991
|
+
}
|
|
993
992
|
}
|
|
994
993
|
}
|
|
995
994
|
if (typeof props === "object" && element) {
|
|
@@ -1315,63 +1314,23 @@ var _ = (...element_initials) => {
|
|
|
1315
1314
|
let child = ElementChildrenAndPropertyList[i2];
|
|
1316
1315
|
if (typeof child === "function") {
|
|
1317
1316
|
child = child();
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1317
|
+
}
|
|
1318
|
+
if (typeof child === "function") {
|
|
1319
|
+
child = child();
|
|
1321
1320
|
}
|
|
1322
1321
|
if (isNode(child)) {
|
|
1323
1322
|
element.appendChild(child);
|
|
1324
1323
|
continue;
|
|
1325
1324
|
}
|
|
1326
1325
|
if (Array.isArray(child)) {
|
|
1327
|
-
|
|
1328
|
-
const fg = new DocumentFragment();
|
|
1329
|
-
for (let ch of l) {
|
|
1330
|
-
if (Array.isArray(ch)) {
|
|
1331
|
-
fg.appendChild(rload2(ch));
|
|
1332
|
-
} else {
|
|
1333
|
-
if (typeof ch === "function") {
|
|
1334
|
-
ch = ch();
|
|
1335
|
-
}
|
|
1336
|
-
if (typeof ch === "function") {
|
|
1337
|
-
ch = ch();
|
|
1338
|
-
}
|
|
1339
|
-
fg.appendChild(ch);
|
|
1340
|
-
}
|
|
1341
|
-
}
|
|
1342
|
-
return fg;
|
|
1343
|
-
};
|
|
1344
|
-
var rload = rload2;
|
|
1345
|
-
const arrCXLength = child.length;
|
|
1346
|
-
for (let p2 = 0; p2 < arrCXLength; p2++) {
|
|
1347
|
-
let childly = child[p2];
|
|
1348
|
-
if (typeof childly === "function") {
|
|
1349
|
-
childly = childly();
|
|
1350
|
-
}
|
|
1351
|
-
if (typeof childly === "function") {
|
|
1352
|
-
childly = childly();
|
|
1353
|
-
}
|
|
1354
|
-
if (Array.isArray(childly)) {
|
|
1355
|
-
childly = rload2(childly);
|
|
1356
|
-
}
|
|
1357
|
-
if (isNode(childly)) {
|
|
1358
|
-
element.appendChild(childly);
|
|
1359
|
-
} else {
|
|
1360
|
-
console.log(childly);
|
|
1361
|
-
if (typeof childly !== "undefined") {
|
|
1362
|
-
throw new Error(
|
|
1363
|
-
" \u2718 Cradova err: invalid child type: " + childly + " (" + typeof childly + ")"
|
|
1364
|
-
);
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
}
|
|
1326
|
+
element.appendChild(Rhoda(child));
|
|
1368
1327
|
continue;
|
|
1369
1328
|
}
|
|
1370
1329
|
if (typeof child === "string" || typeof child === "number") {
|
|
1371
1330
|
text = child;
|
|
1372
1331
|
continue;
|
|
1373
1332
|
}
|
|
1374
|
-
if (typeof child === "object"
|
|
1333
|
+
if (typeof child === "object") {
|
|
1375
1334
|
if (!props) {
|
|
1376
1335
|
props = child;
|
|
1377
1336
|
} else {
|