smbls 3.6.1 → 3.6.3

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.
@@ -1 +1 @@
1
- {"name":"smbls","version":"3.6.0"}
1
+ {"name":"smbls","version":"3.6.1"}
@@ -22,9 +22,18 @@ __export(define_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(define_exports);
24
24
  var import_helmet = require("@symbo.ls/helmet");
25
+ var import_utils = require("@domql/utils");
26
+ const processCollectionParam = (param, state) => {
27
+ if ((0, import_utils.isString)(param)) {
28
+ if (param === "state") return state.parse();
29
+ return (0, import_utils.getChildStateInKey)(param, state);
30
+ }
31
+ if ((0, import_utils.isState)(param)) return param.parse();
32
+ if ((0, import_utils.isNot)(param)("array", "object")) return null;
33
+ return (0, import_utils.deepClone)(param);
34
+ };
25
35
  const defaultDefine = {
26
36
  routes: (param) => param,
27
- // deps: (param, el) => param || el.parent.deps,
28
37
  metadata: (param, el, state) => {
29
38
  if (!param) return;
30
39
  const doc = el.context?.document || typeof document !== "undefined" && document;
@@ -42,5 +51,120 @@ const defaultDefine = {
42
51
  window.requestAnimationFrame(set);
43
52
  } else await set();
44
53
  return obj;
54
+ },
55
+ $collection: async (param, el, state) => {
56
+ const { __ref: ref } = el;
57
+ const {
58
+ children: childrenProps,
59
+ childrenAs,
60
+ childExtends
61
+ } = el.props || {};
62
+ const children = childrenProps && await (0, import_utils.exec)(childrenProps, el, state);
63
+ const childrenAsDefault = childrenAs || "props";
64
+ if (children) {
65
+ if ((0, import_utils.isObject)(children)) {
66
+ param = (0, import_utils.deepClone)(children);
67
+ param = Object.keys(param).map((v) => {
68
+ const val = param[v];
69
+ return (0, import_utils.isObjectLike)(val) ? { ...val, extends: v } : { extends: v, value: val };
70
+ });
71
+ } else if ((0, import_utils.isArray)(children)) {
72
+ param = (0, import_utils.deepClone)(children);
73
+ if (childrenAsDefault && childrenAsDefault !== "element") {
74
+ param = param.map((v) => ({
75
+ ...childExtends && { extends: childExtends },
76
+ [childrenAsDefault]: (0, import_utils.isObjectLike)(v) ? v : childrenAsDefault === "state" ? { value: v } : { text: v }
77
+ }));
78
+ }
79
+ } else if ((0, import_utils.isString)(children) || (0, import_utils.isNumber)(children)) {
80
+ el.removeContent();
81
+ el.content = { text: param };
82
+ return;
83
+ }
84
+ }
85
+ if (!param) return;
86
+ param = processCollectionParam(param, state);
87
+ if (!param) return;
88
+ if (ref.__collectionCache) {
89
+ const equals = JSON.stringify(param) === JSON.stringify(ref.__collectionCache);
90
+ if (equals) {
91
+ ref.__noCollectionDifference = true;
92
+ return;
93
+ }
94
+ ref.__collectionCache = (0, import_utils.deepClone)(param);
95
+ delete ref.__noCollectionDifference;
96
+ } else {
97
+ ref.__collectionCache = (0, import_utils.deepClone)(param);
98
+ }
99
+ const obj = { tag: "fragment", ignoreChildProps: true, childProps: el.props && el.props.childProps };
100
+ for (const key in param) {
101
+ const value = param[key];
102
+ if (value) obj[key] = (0, import_utils.isObjectLike)(value) ? value : { value };
103
+ }
104
+ el.removeContent();
105
+ el.content = obj;
106
+ },
107
+ $setCollection: async (param, el, state) => {
108
+ if (!param) return;
109
+ param = processCollectionParam(param, state);
110
+ if (!param) return;
111
+ const data = ((0, import_utils.isArray)(param) ? param : (0, import_utils.isObject)(param) ? Object.values(param) : []).map((item) => !(0, import_utils.isObjectLike)(item) ? { value: item } : item);
112
+ if (data.length) {
113
+ const t = setTimeout(() => {
114
+ el.set({ tag: "fragment", ...data }, { preventDefineUpdate: "$setCollection" });
115
+ clearTimeout(t);
116
+ });
117
+ }
118
+ return data;
119
+ },
120
+ $stateCollection: async (param, el, state) => {
121
+ const { children, childrenAs } = el.props || {};
122
+ if (!param || children || childrenAs) return;
123
+ param = processCollectionParam(param, state);
124
+ if (!param) return;
125
+ const { __ref: ref } = el;
126
+ if (ref.__stateCollectionCache) {
127
+ const equals = JSON.stringify(param) === JSON.stringify(ref.__stateCollectionCache);
128
+ if (equals) {
129
+ ref.__noCollectionDifference = true;
130
+ return;
131
+ }
132
+ ref.__stateCollectionCache = (0, import_utils.deepClone)(param);
133
+ delete ref.__noCollectionDifference;
134
+ } else {
135
+ ref.__stateCollectionCache = (0, import_utils.deepClone)(param);
136
+ }
137
+ const obj = { tag: "fragment", ignoreChildProps: true, childProps: el.props && el.props.childProps };
138
+ for (const key in param) {
139
+ const value = param[key];
140
+ if (value) obj[key] = { state: (0, import_utils.isObjectLike)(value) ? value : { value } };
141
+ }
142
+ el.removeContent();
143
+ el.content = obj;
144
+ },
145
+ $propsCollection: async (param, el, state) => {
146
+ const { children, childrenAs } = el.props || {};
147
+ if (!param || children || childrenAs) return;
148
+ param = processCollectionParam(param, state);
149
+ if (!param) return;
150
+ const { __ref: ref } = el;
151
+ if (ref.__propsCollectionCache) {
152
+ const equals = JSON.stringify(param) === JSON.stringify(ref.__propsCollectionCache);
153
+ if (equals) {
154
+ ref.__noCollectionDifference = true;
155
+ return;
156
+ }
157
+ ref.__propsCollectionCache = (0, import_utils.deepClone)(param);
158
+ delete ref.__noCollectionDifference;
159
+ } else {
160
+ ref.__propsCollectionCache = (0, import_utils.deepClone)(param);
161
+ }
162
+ const obj = { tag: "fragment", ignoreChildProps: true, childProps: el.props && el.props.childProps };
163
+ for (const key in param) {
164
+ const value = param[key];
165
+ if (value) obj[key] = { props: (0, import_utils.isObjectLike)(value) ? value : { value } };
166
+ }
167
+ el.removeContent();
168
+ el.content = obj;
45
169
  }
46
170
  };
@@ -1 +1 @@
1
- {"name":"smbls","version":"3.6.0"}
1
+ {"name":"smbls","version":"3.6.1"}
@@ -1,7 +1,27 @@
1
1
  import { resolveMetadata, applyMetadata } from "@symbo.ls/helmet";
2
+ import {
3
+ isString,
4
+ isNumber,
5
+ isNot,
6
+ isArray,
7
+ isObject,
8
+ isObjectLike,
9
+ isState,
10
+ exec,
11
+ deepClone,
12
+ getChildStateInKey
13
+ } from "@domql/utils";
14
+ const processCollectionParam = (param, state) => {
15
+ if (isString(param)) {
16
+ if (param === "state") return state.parse();
17
+ return getChildStateInKey(param, state);
18
+ }
19
+ if (isState(param)) return param.parse();
20
+ if (isNot(param)("array", "object")) return null;
21
+ return deepClone(param);
22
+ };
2
23
  const defaultDefine = {
3
24
  routes: (param) => param,
4
- // deps: (param, el) => param || el.parent.deps,
5
25
  metadata: (param, el, state) => {
6
26
  if (!param) return;
7
27
  const doc = el.context?.document || typeof document !== "undefined" && document;
@@ -19,6 +39,121 @@ const defaultDefine = {
19
39
  window.requestAnimationFrame(set);
20
40
  } else await set();
21
41
  return obj;
42
+ },
43
+ $collection: async (param, el, state) => {
44
+ const { __ref: ref } = el;
45
+ const {
46
+ children: childrenProps,
47
+ childrenAs,
48
+ childExtends
49
+ } = el.props || {};
50
+ const children = childrenProps && await exec(childrenProps, el, state);
51
+ const childrenAsDefault = childrenAs || "props";
52
+ if (children) {
53
+ if (isObject(children)) {
54
+ param = deepClone(children);
55
+ param = Object.keys(param).map((v) => {
56
+ const val = param[v];
57
+ return isObjectLike(val) ? { ...val, extends: v } : { extends: v, value: val };
58
+ });
59
+ } else if (isArray(children)) {
60
+ param = deepClone(children);
61
+ if (childrenAsDefault && childrenAsDefault !== "element") {
62
+ param = param.map((v) => ({
63
+ ...childExtends && { extends: childExtends },
64
+ [childrenAsDefault]: isObjectLike(v) ? v : childrenAsDefault === "state" ? { value: v } : { text: v }
65
+ }));
66
+ }
67
+ } else if (isString(children) || isNumber(children)) {
68
+ el.removeContent();
69
+ el.content = { text: param };
70
+ return;
71
+ }
72
+ }
73
+ if (!param) return;
74
+ param = processCollectionParam(param, state);
75
+ if (!param) return;
76
+ if (ref.__collectionCache) {
77
+ const equals = JSON.stringify(param) === JSON.stringify(ref.__collectionCache);
78
+ if (equals) {
79
+ ref.__noCollectionDifference = true;
80
+ return;
81
+ }
82
+ ref.__collectionCache = deepClone(param);
83
+ delete ref.__noCollectionDifference;
84
+ } else {
85
+ ref.__collectionCache = deepClone(param);
86
+ }
87
+ const obj = { tag: "fragment", ignoreChildProps: true, childProps: el.props && el.props.childProps };
88
+ for (const key in param) {
89
+ const value = param[key];
90
+ if (value) obj[key] = isObjectLike(value) ? value : { value };
91
+ }
92
+ el.removeContent();
93
+ el.content = obj;
94
+ },
95
+ $setCollection: async (param, el, state) => {
96
+ if (!param) return;
97
+ param = processCollectionParam(param, state);
98
+ if (!param) return;
99
+ const data = (isArray(param) ? param : isObject(param) ? Object.values(param) : []).map((item) => !isObjectLike(item) ? { value: item } : item);
100
+ if (data.length) {
101
+ const t = setTimeout(() => {
102
+ el.set({ tag: "fragment", ...data }, { preventDefineUpdate: "$setCollection" });
103
+ clearTimeout(t);
104
+ });
105
+ }
106
+ return data;
107
+ },
108
+ $stateCollection: async (param, el, state) => {
109
+ const { children, childrenAs } = el.props || {};
110
+ if (!param || children || childrenAs) return;
111
+ param = processCollectionParam(param, state);
112
+ if (!param) return;
113
+ const { __ref: ref } = el;
114
+ if (ref.__stateCollectionCache) {
115
+ const equals = JSON.stringify(param) === JSON.stringify(ref.__stateCollectionCache);
116
+ if (equals) {
117
+ ref.__noCollectionDifference = true;
118
+ return;
119
+ }
120
+ ref.__stateCollectionCache = deepClone(param);
121
+ delete ref.__noCollectionDifference;
122
+ } else {
123
+ ref.__stateCollectionCache = deepClone(param);
124
+ }
125
+ const obj = { tag: "fragment", ignoreChildProps: true, childProps: el.props && el.props.childProps };
126
+ for (const key in param) {
127
+ const value = param[key];
128
+ if (value) obj[key] = { state: isObjectLike(value) ? value : { value } };
129
+ }
130
+ el.removeContent();
131
+ el.content = obj;
132
+ },
133
+ $propsCollection: async (param, el, state) => {
134
+ const { children, childrenAs } = el.props || {};
135
+ if (!param || children || childrenAs) return;
136
+ param = processCollectionParam(param, state);
137
+ if (!param) return;
138
+ const { __ref: ref } = el;
139
+ if (ref.__propsCollectionCache) {
140
+ const equals = JSON.stringify(param) === JSON.stringify(ref.__propsCollectionCache);
141
+ if (equals) {
142
+ ref.__noCollectionDifference = true;
143
+ return;
144
+ }
145
+ ref.__propsCollectionCache = deepClone(param);
146
+ delete ref.__noCollectionDifference;
147
+ } else {
148
+ ref.__propsCollectionCache = deepClone(param);
149
+ }
150
+ const obj = { tag: "fragment", ignoreChildProps: true, childProps: el.props && el.props.childProps };
151
+ for (const key in param) {
152
+ const value = param[key];
153
+ if (value) obj[key] = { props: isObjectLike(value) ? value : { value } };
154
+ }
155
+ el.removeContent();
156
+ el.content = obj;
22
157
  }
23
158
  };
24
159
  export {
@@ -62,7 +62,7 @@ var Smbls = (() => {
62
62
  __reExport(index_exports, __require("@symbo.ls/smbls-utils"));
63
63
 
64
64
  // src/index.js
65
- var import_utils14 = __require("@domql/utils");
65
+ var import_utils16 = __require("@domql/utils");
66
66
 
67
67
  // src/utilImports.js
68
68
  var utilImports_exports = {};
@@ -217,7 +217,7 @@ var Smbls = (() => {
217
217
  __reExport(utilImports_exports, __require("@domql/router"));
218
218
 
219
219
  // src/router.js
220
- var import_utils9 = __require("@domql/utils");
220
+ var import_utils10 = __require("@domql/utils");
221
221
  var import_router4 = __require("@domql/router");
222
222
 
223
223
  // dist/esm/index.js
@@ -247,7 +247,7 @@ var Smbls = (() => {
247
247
  __reExport(esm_exports, __require("@symbo.ls/smbls-utils"));
248
248
 
249
249
  // dist/esm/src/index.js
250
- var import_utils8 = __require("@domql/utils");
250
+ var import_utils9 = __require("@domql/utils");
251
251
 
252
252
  // dist/esm/src/utilImports.js
253
253
  var utilImports_exports2 = {};
@@ -496,9 +496,18 @@ var Smbls = (() => {
496
496
 
497
497
  // dist/esm/src/define.js
498
498
  var import_helmet = __require("@symbo.ls/helmet");
499
+ var import_utils5 = __require("@domql/utils");
500
+ var processCollectionParam = (param, state) => {
501
+ if ((0, import_utils5.isString)(param)) {
502
+ if (param === "state") return state.parse();
503
+ return (0, import_utils5.getChildStateInKey)(param, state);
504
+ }
505
+ if ((0, import_utils5.isState)(param)) return param.parse();
506
+ if ((0, import_utils5.isNot)(param)("array", "object")) return null;
507
+ return (0, import_utils5.deepClone)(param);
508
+ };
499
509
  var defaultDefine = {
500
510
  routes: (param) => param,
501
- // deps: (param, el) => param || el.parent.deps,
502
511
  metadata: (param, el, state) => {
503
512
  if (!param) return;
504
513
  const doc = el.context?.document || typeof document !== "undefined" && document;
@@ -516,6 +525,121 @@ var Smbls = (() => {
516
525
  window.requestAnimationFrame(set5);
517
526
  } else await set5();
518
527
  return obj;
528
+ },
529
+ $collection: async (param, el, state) => {
530
+ const { __ref: ref } = el;
531
+ const {
532
+ children: childrenProps,
533
+ childrenAs,
534
+ childExtends
535
+ } = el.props || {};
536
+ const children = childrenProps && await (0, import_utils5.exec)(childrenProps, el, state);
537
+ const childrenAsDefault = childrenAs || "props";
538
+ if (children) {
539
+ if ((0, import_utils5.isObject)(children)) {
540
+ param = (0, import_utils5.deepClone)(children);
541
+ param = Object.keys(param).map((v) => {
542
+ const val = param[v];
543
+ return (0, import_utils5.isObjectLike)(val) ? { ...val, extends: v } : { extends: v, value: val };
544
+ });
545
+ } else if ((0, import_utils5.isArray)(children)) {
546
+ param = (0, import_utils5.deepClone)(children);
547
+ if (childrenAsDefault && childrenAsDefault !== "element") {
548
+ param = param.map((v) => ({
549
+ ...childExtends && { extends: childExtends },
550
+ [childrenAsDefault]: (0, import_utils5.isObjectLike)(v) ? v : childrenAsDefault === "state" ? { value: v } : { text: v }
551
+ }));
552
+ }
553
+ } else if ((0, import_utils5.isString)(children) || (0, import_utils5.isNumber)(children)) {
554
+ el.removeContent();
555
+ el.content = { text: param };
556
+ return;
557
+ }
558
+ }
559
+ if (!param) return;
560
+ param = processCollectionParam(param, state);
561
+ if (!param) return;
562
+ if (ref.__collectionCache) {
563
+ const equals = JSON.stringify(param) === JSON.stringify(ref.__collectionCache);
564
+ if (equals) {
565
+ ref.__noCollectionDifference = true;
566
+ return;
567
+ }
568
+ ref.__collectionCache = (0, import_utils5.deepClone)(param);
569
+ delete ref.__noCollectionDifference;
570
+ } else {
571
+ ref.__collectionCache = (0, import_utils5.deepClone)(param);
572
+ }
573
+ const obj = { tag: "fragment", ignoreChildProps: true, childProps: el.props && el.props.childProps };
574
+ for (const key in param) {
575
+ const value = param[key];
576
+ if (value) obj[key] = (0, import_utils5.isObjectLike)(value) ? value : { value };
577
+ }
578
+ el.removeContent();
579
+ el.content = obj;
580
+ },
581
+ $setCollection: async (param, el, state) => {
582
+ if (!param) return;
583
+ param = processCollectionParam(param, state);
584
+ if (!param) return;
585
+ const data = ((0, import_utils5.isArray)(param) ? param : (0, import_utils5.isObject)(param) ? Object.values(param) : []).map((item) => !(0, import_utils5.isObjectLike)(item) ? { value: item } : item);
586
+ if (data.length) {
587
+ const t = setTimeout(() => {
588
+ el.set({ tag: "fragment", ...data }, { preventDefineUpdate: "$setCollection" });
589
+ clearTimeout(t);
590
+ });
591
+ }
592
+ return data;
593
+ },
594
+ $stateCollection: async (param, el, state) => {
595
+ const { children, childrenAs } = el.props || {};
596
+ if (!param || children || childrenAs) return;
597
+ param = processCollectionParam(param, state);
598
+ if (!param) return;
599
+ const { __ref: ref } = el;
600
+ if (ref.__stateCollectionCache) {
601
+ const equals = JSON.stringify(param) === JSON.stringify(ref.__stateCollectionCache);
602
+ if (equals) {
603
+ ref.__noCollectionDifference = true;
604
+ return;
605
+ }
606
+ ref.__stateCollectionCache = (0, import_utils5.deepClone)(param);
607
+ delete ref.__noCollectionDifference;
608
+ } else {
609
+ ref.__stateCollectionCache = (0, import_utils5.deepClone)(param);
610
+ }
611
+ const obj = { tag: "fragment", ignoreChildProps: true, childProps: el.props && el.props.childProps };
612
+ for (const key in param) {
613
+ const value = param[key];
614
+ if (value) obj[key] = { state: (0, import_utils5.isObjectLike)(value) ? value : { value } };
615
+ }
616
+ el.removeContent();
617
+ el.content = obj;
618
+ },
619
+ $propsCollection: async (param, el, state) => {
620
+ const { children, childrenAs } = el.props || {};
621
+ if (!param || children || childrenAs) return;
622
+ param = processCollectionParam(param, state);
623
+ if (!param) return;
624
+ const { __ref: ref } = el;
625
+ if (ref.__propsCollectionCache) {
626
+ const equals = JSON.stringify(param) === JSON.stringify(ref.__propsCollectionCache);
627
+ if (equals) {
628
+ ref.__noCollectionDifference = true;
629
+ return;
630
+ }
631
+ ref.__propsCollectionCache = (0, import_utils5.deepClone)(param);
632
+ delete ref.__noCollectionDifference;
633
+ } else {
634
+ ref.__propsCollectionCache = (0, import_utils5.deepClone)(param);
635
+ }
636
+ const obj = { tag: "fragment", ignoreChildProps: true, childProps: el.props && el.props.childProps };
637
+ for (const key in param) {
638
+ const value = param[key];
639
+ if (value) obj[key] = { props: (0, import_utils5.isObjectLike)(value) ? value : { value } };
640
+ }
641
+ el.removeContent();
642
+ el.content = obj;
519
643
  }
520
644
  };
521
645
 
@@ -563,21 +687,21 @@ var Smbls = (() => {
563
687
  var import_domql = __toESM(__require("domql"));
564
688
  var uikit2 = __toESM(__require("@symbo.ls/uikit"));
565
689
  var import_css_in_props = __require("css-in-props");
566
- var import_utils7 = __require("@domql/utils");
690
+ var import_utils8 = __require("@domql/utils");
567
691
  var import_element = __require("@domql/element");
568
692
 
569
693
  // dist/esm/src/syncExtend.js
570
- var import_utils5 = __require("@domql/utils");
694
+ var import_utils6 = __require("@domql/utils");
571
695
  var import_sync = __require("@symbo.ls/sync");
572
696
  var initializeExtend = (app, ctx) => {
573
- return (0, import_utils5.isObjectLike)(app.extends) ? app.extends : [];
697
+ return (0, import_utils6.isObjectLike)(app.extends) ? app.extends : [];
574
698
  };
575
699
  var initializeSync = (app, ctx) => {
576
700
  const { editor } = ctx;
577
701
  if (!editor) return;
578
- const liveSync = (0, import_utils5.isUndefined)(editor.liveSync) ? (0, import_utils5.isDevelopment)() : editor.liveSync;
702
+ const liveSync = (0, import_utils6.isUndefined)(editor.liveSync) ? (0, import_utils6.isDevelopment)() : editor.liveSync;
579
703
  if (liveSync) {
580
- if ((0, import_utils5.isArray)(app.extends)) app.extends.push(import_sync.SyncComponent);
704
+ if ((0, import_utils6.isArray)(app.extends)) app.extends.push(import_sync.SyncComponent);
581
705
  else if (app.extends) {
582
706
  app.extends = [app.extends, import_sync.SyncComponent];
583
707
  } else {
@@ -588,9 +712,9 @@ var Smbls = (() => {
588
712
  var initializeNotifications = (app, ctx) => {
589
713
  const { editor } = ctx;
590
714
  if (!editor) return;
591
- const verbose = (0, import_utils5.isUndefined)(editor.verbose) ? (0, import_utils5.isDevelopment)() || ctx.verbose : editor.verbose;
715
+ const verbose = (0, import_utils6.isUndefined)(editor.verbose) ? (0, import_utils6.isDevelopment)() || ctx.verbose : editor.verbose;
592
716
  if (verbose) {
593
- if ((0, import_utils5.isArray)(app.extends)) app.extends.push(import_sync.Notifications);
717
+ if ((0, import_utils6.isArray)(app.extends)) app.extends.push(import_sync.Notifications);
594
718
  else if (app.extends) {
595
719
  app.extends = [app.extends, import_sync.Notifications];
596
720
  } else {
@@ -600,7 +724,7 @@ var Smbls = (() => {
600
724
  };
601
725
 
602
726
  // dist/esm/src/prepare.js
603
- var import_utils6 = __require("@domql/utils");
727
+ var import_utils7 = __require("@domql/utils");
604
728
  var import_initEmotion = __require("@symbo.ls/emotion/initEmotion.js");
605
729
  var uikit = __toESM(__require("@symbo.ls/uikit"));
606
730
  var routerUtils = __toESM(__require("@domql/router"));
@@ -617,7 +741,7 @@ var Smbls = (() => {
617
741
  const newObj = {};
618
742
  for (const key in uikit) {
619
743
  if (Object.prototype.hasOwnProperty.call(uikit, key)) {
620
- if ((0, import_utils6.matchesComponentNaming)(key)) {
744
+ if ((0, import_utils7.matchesComponentNaming)(key)) {
621
745
  newObj[`smbls.${key}`] = uikit[key];
622
746
  } else {
623
747
  newObj[key] = uikit[key];
@@ -672,7 +796,7 @@ var Smbls = (() => {
672
796
  if (dependenciesOnDemand && dependenciesOnDemand[dependency]) {
673
797
  continue;
674
798
  }
675
- const random = (0, import_utils6.isDevelopment)() && preventCaching ? `?${Math.random()}` : "";
799
+ const random = (0, import_utils7.isDevelopment)() && preventCaching ? `?${Math.random()}` : "";
676
800
  const url = (0, import_smbls_utils.getCDNUrl)(dependency, version3, cdnProvider) + random;
677
801
  try {
678
802
  if (cachedDeps[dependency]) return;
@@ -712,7 +836,7 @@ var Smbls = (() => {
712
836
  const documentOpts = ctx2.document || document;
713
837
  const windowOpts2 = ctx2.window || window;
714
838
  if (!windowOpts2.packages[key]) {
715
- const random = (0, import_utils6.isDevelopment)() ? `?${Math.random()}` : "";
839
+ const random = (0, import_utils7.isDevelopment)() ? `?${Math.random()}` : "";
716
840
  if (dependenciesOnDemand && dependenciesOnDemand[key]) {
717
841
  const version3 = dependenciesOnDemand[key];
718
842
  const url = (0, import_smbls_utils.getCDNUrl)(key, version3, provider) + random;
@@ -754,7 +878,7 @@ var Smbls = (() => {
754
878
  return await windowOpts2.require(key, provider);
755
879
  };
756
880
  if (windowOpts.packages) {
757
- windowOpts.packages = (0, import_utils6.merge)(windowOpts.packages, packages);
881
+ windowOpts.packages = (0, import_utils7.merge)(windowOpts.packages, packages);
758
882
  } else {
759
883
  windowOpts.packages = packages;
760
884
  }
@@ -774,13 +898,13 @@ var Smbls = (() => {
774
898
  var prepareState = (app, context) => {
775
899
  const state = {};
776
900
  if (context.state) utilImports_exports2.deepMerge(state, context.state);
777
- if (app && app.state) (0, import_utils6.deepMerge)(state, app.state);
901
+ if (app && app.state) (0, import_utils7.deepMerge)(state, app.state);
778
902
  state.isRootState = true;
779
- return (0, import_utils6.deepClone)(state);
903
+ return (0, import_utils7.deepClone)(state);
780
904
  };
781
905
  var preparePages = (app, context) => {
782
- if ((0, import_utils6.isObject)(app.routes) && (0, import_utils6.isObject)(context.pages)) {
783
- (0, import_utils6.merge)(app.routes, context.pages);
906
+ if ((0, import_utils7.isObject)(app.routes) && (0, import_utils7.isObject)(context.pages)) {
907
+ (0, import_utils7.merge)(app.routes, context.pages);
784
908
  }
785
909
  const pages = app.routes || context.pages || {};
786
910
  for (const v in pages) {
@@ -797,16 +921,16 @@ var Smbls = (() => {
797
921
  const sharedLib = sharedLibraries[i];
798
922
  if (context.type === "template") {
799
923
  overwriteShallow(context.designSystem, sharedLib.designSystem);
800
- (0, import_utils6.deepMerge)(context, sharedLib, ["designSystem"], 1);
924
+ (0, import_utils7.deepMerge)(context, sharedLib, ["designSystem"], 1);
801
925
  } else {
802
- (0, import_utils6.deepMerge)(context, sharedLib, [], 1);
926
+ (0, import_utils7.deepMerge)(context, sharedLib, [], 1);
803
927
  }
804
928
  }
805
929
  };
806
930
 
807
931
  // dist/esm/src/createDomql.js
808
932
  var prepareContext = async (app, context = {}) => {
809
- const key = context.key = context.key || ((0, import_utils7.isString)(app) ? app : "smblsapp");
933
+ const key = context.key = context.key || ((0, import_utils8.isString)(app) ? app : "smblsapp");
810
934
  context.define = context.define || defaultDefine;
811
935
  context.cssPropsRegistry = import_css_in_props.CSS_PROPS_REGISTRY;
812
936
  context.window = prepareWindow(context);
@@ -836,14 +960,14 @@ var Smbls = (() => {
836
960
  return context;
837
961
  };
838
962
  var createDomqlElement = async (app, ctx) => {
839
- if (!(0, import_utils7.isObject)(ctx)) ctx = {};
840
- if ((0, import_utils7.isNode)(app)) {
963
+ if (!(0, import_utils8.isObject)(ctx)) ctx = {};
964
+ if ((0, import_utils8.isNode)(app)) {
841
965
  app = {};
842
966
  ctx.parent = app;
843
- } else if ((0, import_utils7.isString)(app)) {
967
+ } else if ((0, import_utils8.isString)(app)) {
844
968
  app = {};
845
969
  ctx.key = app;
846
- } else if (!(0, import_utils7.isObject)(app)) {
970
+ } else if (!(0, import_utils8.isObject)(app)) {
847
971
  app = {};
848
972
  }
849
973
  await prepareContext(app, ctx);
@@ -876,9 +1000,9 @@ var Smbls = (() => {
876
1000
  };
877
1001
 
878
1002
  // dist/esm/src/index.js
879
- var mergeWithLocalFile3 = (options, optionsExternalFile) => (0, import_utils8.deepMerge)(
1003
+ var mergeWithLocalFile3 = (options, optionsExternalFile) => (0, import_utils9.deepMerge)(
880
1004
  options,
881
- (0, import_utils8.isObject)(optionsExternalFile) ? optionsExternalFile : DYNAMIC_JSON2 || {}
1005
+ (0, import_utils9.isObject)(optionsExternalFile) ? optionsExternalFile : DYNAMIC_JSON2 || {}
882
1006
  );
883
1007
  var create = (App, options = options_default, optionsExternalFile) => {
884
1008
  const redefinedOptions = {
@@ -927,10 +1051,10 @@ var Smbls = (() => {
927
1051
  var createSkeleton = (App = {}, options = options_default, optionsExternalFile) => {
928
1052
  return create(
929
1053
  {
930
- deps: { isUndefined: import_utils8.isUndefined },
1054
+ deps: { isUndefined: import_utils9.isUndefined },
931
1055
  ...App
932
1056
  },
933
- (0, import_utils8.deepMerge)({ domqlOptions: { onlyResolveExtends: true } }, options),
1057
+ (0, import_utils9.deepMerge)({ domqlOptions: { onlyResolveExtends: true } }, options),
934
1058
  optionsExternalFile
935
1059
  );
936
1060
  };
@@ -944,15 +1068,15 @@ var Smbls = (() => {
944
1068
  var initRouter2 = (element, context) => {
945
1069
  if (context.router === false) return;
946
1070
  else if (context.router === true) context.router = DEFAULT_ROUTING_OPTIONS2;
947
- else context.router = (0, import_utils9.merge)(context.router || {}, DEFAULT_ROUTING_OPTIONS2);
1071
+ else context.router = (0, import_utils10.merge)(context.router || {}, DEFAULT_ROUTING_OPTIONS2);
948
1072
  const routerOptions = context.router;
949
1073
  const onRouterRenderDefault = async (el, s) => {
950
- if (!import_utils9.window.location) return;
951
- const { pathname, search, hash } = import_utils9.window.location;
1074
+ if (!import_utils10.window.location) return;
1075
+ const { pathname, search, hash } = import_utils10.window.location;
952
1076
  const url = pathname + search + hash;
953
1077
  if (el.routes) await (0, import_router4.router)(url, el, {}, { initialRender: true });
954
1078
  };
955
- const hasRenderRouter = element.on && !(0, import_utils9.isUndefined)(element.on.renderRouter) || !(0, import_utils9.isUndefined)(element.onRenderRouter);
1079
+ const hasRenderRouter = element.on && !(0, import_utils10.isUndefined)(element.on.renderRouter) || !(0, import_utils10.isUndefined)(element.onRenderRouter);
956
1080
  if (routerOptions && routerOptions.initRouter && !hasRenderRouter) {
957
1081
  if (element.on) {
958
1082
  element.on.renderRouter = onRouterRenderDefault;
@@ -972,8 +1096,8 @@ var Smbls = (() => {
972
1096
  const routerOptions = context.router || DEFAULT_ROUTING_OPTIONS2;
973
1097
  if (!routerOptions.popState) return;
974
1098
  const router = context.utils && context.utils.router ? context.utils.router : import_router4.router;
975
- import_utils9.window.onpopstate = async (e) => {
976
- const { pathname, search, hash } = import_utils9.window.location;
1099
+ import_utils10.window.onpopstate = async (e) => {
1100
+ const { pathname, search, hash } = import_utils10.window.location;
977
1101
  const url = pathname + search + hash;
978
1102
  await element.call(
979
1103
  "router",
@@ -987,7 +1111,7 @@ var Smbls = (() => {
987
1111
  var injectRouterInLinkComponent2 = (context, routerOptions) => {
988
1112
  const { components } = context;
989
1113
  if (routerOptions && routerOptions.injectRouterInLinkComponent) {
990
- return (0, import_utils9.deepMerge)(
1114
+ return (0, import_utils10.deepMerge)(
991
1115
  components["Link"] || components["smbls.Link"],
992
1116
  components["RouterLink"] || components["smbls.RouterLink"]
993
1117
  );
@@ -995,7 +1119,7 @@ var Smbls = (() => {
995
1119
  };
996
1120
 
997
1121
  // src/fetchOnCreate.js
998
- var import_utils10 = __require("@domql/utils");
1122
+ var import_utils11 = __require("@domql/utils");
999
1123
  var import_fetch2 = __require("@symbo.ls/fetch");
1000
1124
  var fetchSync2 = async (key, options) => {
1001
1125
  if (key && options.editor) {
@@ -1012,10 +1136,10 @@ var Smbls = (() => {
1012
1136
  if (options.editor.async) {
1013
1137
  (0, import_fetch2.fetchProjectAsync)(key, options, callback || ((data) => {
1014
1138
  const designSystem = data.designSystem;
1015
- if ((0, import_utils10.isObject)(designSystem)) {
1139
+ if ((0, import_utils11.isObject)(designSystem)) {
1016
1140
  options.utils.init(designSystem);
1017
1141
  }
1018
- if ((0, import_utils10.isObject)(data.state)) {
1142
+ if ((0, import_utils11.isObject)(data.state)) {
1019
1143
  app.state.set(data.state);
1020
1144
  }
1021
1145
  }));
@@ -1028,9 +1152,18 @@ var Smbls = (() => {
1028
1152
 
1029
1153
  // src/define.js
1030
1154
  var import_helmet2 = __require("@symbo.ls/helmet");
1155
+ var import_utils12 = __require("@domql/utils");
1156
+ var processCollectionParam2 = (param, state) => {
1157
+ if ((0, import_utils12.isString)(param)) {
1158
+ if (param === "state") return state.parse();
1159
+ return (0, import_utils12.getChildStateInKey)(param, state);
1160
+ }
1161
+ if ((0, import_utils12.isState)(param)) return param.parse();
1162
+ if ((0, import_utils12.isNot)(param)("array", "object")) return null;
1163
+ return (0, import_utils12.deepClone)(param);
1164
+ };
1031
1165
  var defaultDefine2 = {
1032
1166
  routes: (param) => param,
1033
- // deps: (param, el) => param || el.parent.deps,
1034
1167
  metadata: (param, el, state) => {
1035
1168
  if (!param) return;
1036
1169
  const doc = el.context?.document || typeof document !== "undefined" && document;
@@ -1048,6 +1181,121 @@ var Smbls = (() => {
1048
1181
  window.requestAnimationFrame(set5);
1049
1182
  } else await set5();
1050
1183
  return obj;
1184
+ },
1185
+ $collection: async (param, el, state) => {
1186
+ const { __ref: ref } = el;
1187
+ const {
1188
+ children: childrenProps,
1189
+ childrenAs,
1190
+ childExtends
1191
+ } = el.props || {};
1192
+ const children = childrenProps && await (0, import_utils12.exec)(childrenProps, el, state);
1193
+ const childrenAsDefault = childrenAs || "props";
1194
+ if (children) {
1195
+ if ((0, import_utils12.isObject)(children)) {
1196
+ param = (0, import_utils12.deepClone)(children);
1197
+ param = Object.keys(param).map((v) => {
1198
+ const val = param[v];
1199
+ return (0, import_utils12.isObjectLike)(val) ? { ...val, extends: v } : { extends: v, value: val };
1200
+ });
1201
+ } else if ((0, import_utils12.isArray)(children)) {
1202
+ param = (0, import_utils12.deepClone)(children);
1203
+ if (childrenAsDefault && childrenAsDefault !== "element") {
1204
+ param = param.map((v) => ({
1205
+ ...childExtends && { extends: childExtends },
1206
+ [childrenAsDefault]: (0, import_utils12.isObjectLike)(v) ? v : childrenAsDefault === "state" ? { value: v } : { text: v }
1207
+ }));
1208
+ }
1209
+ } else if ((0, import_utils12.isString)(children) || (0, import_utils12.isNumber)(children)) {
1210
+ el.removeContent();
1211
+ el.content = { text: param };
1212
+ return;
1213
+ }
1214
+ }
1215
+ if (!param) return;
1216
+ param = processCollectionParam2(param, state);
1217
+ if (!param) return;
1218
+ if (ref.__collectionCache) {
1219
+ const equals = JSON.stringify(param) === JSON.stringify(ref.__collectionCache);
1220
+ if (equals) {
1221
+ ref.__noCollectionDifference = true;
1222
+ return;
1223
+ }
1224
+ ref.__collectionCache = (0, import_utils12.deepClone)(param);
1225
+ delete ref.__noCollectionDifference;
1226
+ } else {
1227
+ ref.__collectionCache = (0, import_utils12.deepClone)(param);
1228
+ }
1229
+ const obj = { tag: "fragment", ignoreChildProps: true, childProps: el.props && el.props.childProps };
1230
+ for (const key in param) {
1231
+ const value = param[key];
1232
+ if (value) obj[key] = (0, import_utils12.isObjectLike)(value) ? value : { value };
1233
+ }
1234
+ el.removeContent();
1235
+ el.content = obj;
1236
+ },
1237
+ $setCollection: async (param, el, state) => {
1238
+ if (!param) return;
1239
+ param = processCollectionParam2(param, state);
1240
+ if (!param) return;
1241
+ const data = ((0, import_utils12.isArray)(param) ? param : (0, import_utils12.isObject)(param) ? Object.values(param) : []).map((item) => !(0, import_utils12.isObjectLike)(item) ? { value: item } : item);
1242
+ if (data.length) {
1243
+ const t = setTimeout(() => {
1244
+ el.set({ tag: "fragment", ...data }, { preventDefineUpdate: "$setCollection" });
1245
+ clearTimeout(t);
1246
+ });
1247
+ }
1248
+ return data;
1249
+ },
1250
+ $stateCollection: async (param, el, state) => {
1251
+ const { children, childrenAs } = el.props || {};
1252
+ if (!param || children || childrenAs) return;
1253
+ param = processCollectionParam2(param, state);
1254
+ if (!param) return;
1255
+ const { __ref: ref } = el;
1256
+ if (ref.__stateCollectionCache) {
1257
+ const equals = JSON.stringify(param) === JSON.stringify(ref.__stateCollectionCache);
1258
+ if (equals) {
1259
+ ref.__noCollectionDifference = true;
1260
+ return;
1261
+ }
1262
+ ref.__stateCollectionCache = (0, import_utils12.deepClone)(param);
1263
+ delete ref.__noCollectionDifference;
1264
+ } else {
1265
+ ref.__stateCollectionCache = (0, import_utils12.deepClone)(param);
1266
+ }
1267
+ const obj = { tag: "fragment", ignoreChildProps: true, childProps: el.props && el.props.childProps };
1268
+ for (const key in param) {
1269
+ const value = param[key];
1270
+ if (value) obj[key] = { state: (0, import_utils12.isObjectLike)(value) ? value : { value } };
1271
+ }
1272
+ el.removeContent();
1273
+ el.content = obj;
1274
+ },
1275
+ $propsCollection: async (param, el, state) => {
1276
+ const { children, childrenAs } = el.props || {};
1277
+ if (!param || children || childrenAs) return;
1278
+ param = processCollectionParam2(param, state);
1279
+ if (!param) return;
1280
+ const { __ref: ref } = el;
1281
+ if (ref.__propsCollectionCache) {
1282
+ const equals = JSON.stringify(param) === JSON.stringify(ref.__propsCollectionCache);
1283
+ if (equals) {
1284
+ ref.__noCollectionDifference = true;
1285
+ return;
1286
+ }
1287
+ ref.__propsCollectionCache = (0, import_utils12.deepClone)(param);
1288
+ delete ref.__noCollectionDifference;
1289
+ } else {
1290
+ ref.__propsCollectionCache = (0, import_utils12.deepClone)(param);
1291
+ }
1292
+ const obj = { tag: "fragment", ignoreChildProps: true, childProps: el.props && el.props.childProps };
1293
+ for (const key in param) {
1294
+ const value = param[key];
1295
+ if (value) obj[key] = { props: (0, import_utils12.isObjectLike)(value) ? value : { value } };
1296
+ }
1297
+ el.removeContent();
1298
+ el.content = obj;
1051
1299
  }
1052
1300
  };
1053
1301
 
@@ -1095,21 +1343,21 @@ var Smbls = (() => {
1095
1343
  var import_domql2 = __toESM(__require("domql"), 1);
1096
1344
  var uikit4 = __toESM(__require("@symbo.ls/uikit"), 1);
1097
1345
  var import_css_in_props2 = __require("css-in-props");
1098
- var import_utils13 = __require("@domql/utils");
1346
+ var import_utils15 = __require("@domql/utils");
1099
1347
  var import_element2 = __require("@domql/element");
1100
1348
 
1101
1349
  // src/syncExtend.js
1102
- var import_utils11 = __require("@domql/utils");
1350
+ var import_utils13 = __require("@domql/utils");
1103
1351
  var import_sync2 = __require("@symbo.ls/sync");
1104
1352
  var initializeExtend2 = (app, ctx) => {
1105
- return (0, import_utils11.isObjectLike)(app.extends) ? app.extends : [];
1353
+ return (0, import_utils13.isObjectLike)(app.extends) ? app.extends : [];
1106
1354
  };
1107
1355
  var initializeSync2 = (app, ctx) => {
1108
1356
  const { editor } = ctx;
1109
1357
  if (!editor) return;
1110
- const liveSync = (0, import_utils11.isUndefined)(editor.liveSync) ? (0, import_utils11.isDevelopment)() : editor.liveSync;
1358
+ const liveSync = (0, import_utils13.isUndefined)(editor.liveSync) ? (0, import_utils13.isDevelopment)() : editor.liveSync;
1111
1359
  if (liveSync) {
1112
- if ((0, import_utils11.isArray)(app.extends)) app.extends.push(import_sync2.SyncComponent);
1360
+ if ((0, import_utils13.isArray)(app.extends)) app.extends.push(import_sync2.SyncComponent);
1113
1361
  else if (app.extends) {
1114
1362
  app.extends = [app.extends, import_sync2.SyncComponent];
1115
1363
  } else {
@@ -1120,9 +1368,9 @@ var Smbls = (() => {
1120
1368
  var initializeNotifications2 = (app, ctx) => {
1121
1369
  const { editor } = ctx;
1122
1370
  if (!editor) return;
1123
- const verbose = (0, import_utils11.isUndefined)(editor.verbose) ? (0, import_utils11.isDevelopment)() || ctx.verbose : editor.verbose;
1371
+ const verbose = (0, import_utils13.isUndefined)(editor.verbose) ? (0, import_utils13.isDevelopment)() || ctx.verbose : editor.verbose;
1124
1372
  if (verbose) {
1125
- if ((0, import_utils11.isArray)(app.extends)) app.extends.push(import_sync2.Notifications);
1373
+ if ((0, import_utils13.isArray)(app.extends)) app.extends.push(import_sync2.Notifications);
1126
1374
  else if (app.extends) {
1127
1375
  app.extends = [app.extends, import_sync2.Notifications];
1128
1376
  } else {
@@ -1132,7 +1380,7 @@ var Smbls = (() => {
1132
1380
  };
1133
1381
 
1134
1382
  // src/prepare.js
1135
- var import_utils12 = __require("@domql/utils");
1383
+ var import_utils14 = __require("@domql/utils");
1136
1384
  var import_initEmotion2 = __require("@symbo.ls/emotion/initEmotion.js");
1137
1385
  var uikit3 = __toESM(__require("@symbo.ls/uikit"), 1);
1138
1386
  var routerUtils2 = __toESM(__require("@domql/router"), 1);
@@ -1149,7 +1397,7 @@ var Smbls = (() => {
1149
1397
  const newObj = {};
1150
1398
  for (const key in uikit3) {
1151
1399
  if (Object.prototype.hasOwnProperty.call(uikit3, key)) {
1152
- if ((0, import_utils12.matchesComponentNaming)(key)) {
1400
+ if ((0, import_utils14.matchesComponentNaming)(key)) {
1153
1401
  newObj[`smbls.${key}`] = uikit3[key];
1154
1402
  } else {
1155
1403
  newObj[key] = uikit3[key];
@@ -1204,7 +1452,7 @@ var Smbls = (() => {
1204
1452
  if (dependenciesOnDemand && dependenciesOnDemand[dependency]) {
1205
1453
  continue;
1206
1454
  }
1207
- const random = (0, import_utils12.isDevelopment)() && preventCaching ? `?${Math.random()}` : "";
1455
+ const random = (0, import_utils14.isDevelopment)() && preventCaching ? `?${Math.random()}` : "";
1208
1456
  const url = (0, import_smbls_utils2.getCDNUrl)(dependency, version3, cdnProvider) + random;
1209
1457
  try {
1210
1458
  if (cachedDeps2[dependency]) return;
@@ -1244,7 +1492,7 @@ var Smbls = (() => {
1244
1492
  const documentOpts = ctx2.document || document;
1245
1493
  const windowOpts2 = ctx2.window || window;
1246
1494
  if (!windowOpts2.packages[key]) {
1247
- const random = (0, import_utils12.isDevelopment)() ? `?${Math.random()}` : "";
1495
+ const random = (0, import_utils14.isDevelopment)() ? `?${Math.random()}` : "";
1248
1496
  if (dependenciesOnDemand && dependenciesOnDemand[key]) {
1249
1497
  const version3 = dependenciesOnDemand[key];
1250
1498
  const url = (0, import_smbls_utils2.getCDNUrl)(key, version3, provider) + random;
@@ -1286,7 +1534,7 @@ var Smbls = (() => {
1286
1534
  return await windowOpts2.require(key, provider);
1287
1535
  };
1288
1536
  if (windowOpts.packages) {
1289
- windowOpts.packages = (0, import_utils12.merge)(windowOpts.packages, packages);
1537
+ windowOpts.packages = (0, import_utils14.merge)(windowOpts.packages, packages);
1290
1538
  } else {
1291
1539
  windowOpts.packages = packages;
1292
1540
  }
@@ -1306,13 +1554,13 @@ var Smbls = (() => {
1306
1554
  var prepareState2 = (app, context) => {
1307
1555
  const state = {};
1308
1556
  if (context.state) utilImports_exports.deepMerge(state, context.state);
1309
- if (app && app.state) (0, import_utils12.deepMerge)(state, app.state);
1557
+ if (app && app.state) (0, import_utils14.deepMerge)(state, app.state);
1310
1558
  state.isRootState = true;
1311
- return (0, import_utils12.deepClone)(state);
1559
+ return (0, import_utils14.deepClone)(state);
1312
1560
  };
1313
1561
  var preparePages2 = (app, context) => {
1314
- if ((0, import_utils12.isObject)(app.routes) && (0, import_utils12.isObject)(context.pages)) {
1315
- (0, import_utils12.merge)(app.routes, context.pages);
1562
+ if ((0, import_utils14.isObject)(app.routes) && (0, import_utils14.isObject)(context.pages)) {
1563
+ (0, import_utils14.merge)(app.routes, context.pages);
1316
1564
  }
1317
1565
  const pages = app.routes || context.pages || {};
1318
1566
  for (const v in pages) {
@@ -1329,16 +1577,16 @@ var Smbls = (() => {
1329
1577
  const sharedLib = sharedLibraries[i];
1330
1578
  if (context.type === "template") {
1331
1579
  overwriteShallow(context.designSystem, sharedLib.designSystem);
1332
- (0, import_utils12.deepMerge)(context, sharedLib, ["designSystem"], 1);
1580
+ (0, import_utils14.deepMerge)(context, sharedLib, ["designSystem"], 1);
1333
1581
  } else {
1334
- (0, import_utils12.deepMerge)(context, sharedLib, [], 1);
1582
+ (0, import_utils14.deepMerge)(context, sharedLib, [], 1);
1335
1583
  }
1336
1584
  }
1337
1585
  };
1338
1586
 
1339
1587
  // src/createDomql.js
1340
1588
  var prepareContext2 = async (app, context = {}) => {
1341
- const key = context.key = context.key || ((0, import_utils13.isString)(app) ? app : "smblsapp");
1589
+ const key = context.key = context.key || ((0, import_utils15.isString)(app) ? app : "smblsapp");
1342
1590
  context.define = context.define || defaultDefine2;
1343
1591
  context.cssPropsRegistry = import_css_in_props2.CSS_PROPS_REGISTRY;
1344
1592
  context.window = prepareWindow2(context);
@@ -1368,14 +1616,14 @@ var Smbls = (() => {
1368
1616
  return context;
1369
1617
  };
1370
1618
  var createDomqlElement2 = async (app, ctx) => {
1371
- if (!(0, import_utils13.isObject)(ctx)) ctx = {};
1372
- if ((0, import_utils13.isNode)(app)) {
1619
+ if (!(0, import_utils15.isObject)(ctx)) ctx = {};
1620
+ if ((0, import_utils15.isNode)(app)) {
1373
1621
  app = {};
1374
1622
  ctx.parent = app;
1375
- } else if ((0, import_utils13.isString)(app)) {
1623
+ } else if ((0, import_utils15.isString)(app)) {
1376
1624
  app = {};
1377
1625
  ctx.key = app;
1378
- } else if (!(0, import_utils13.isObject)(app)) {
1626
+ } else if (!(0, import_utils15.isObject)(app)) {
1379
1627
  app = {};
1380
1628
  }
1381
1629
  await prepareContext2(app, ctx);
@@ -1408,9 +1656,9 @@ var Smbls = (() => {
1408
1656
  };
1409
1657
 
1410
1658
  // src/index.js
1411
- var mergeWithLocalFile4 = (options, optionsExternalFile) => (0, import_utils14.deepMerge)(
1659
+ var mergeWithLocalFile4 = (options, optionsExternalFile) => (0, import_utils16.deepMerge)(
1412
1660
  options,
1413
- (0, import_utils14.isObject)(optionsExternalFile) ? optionsExternalFile : DYNAMIC_JSON || {}
1661
+ (0, import_utils16.isObject)(optionsExternalFile) ? optionsExternalFile : DYNAMIC_JSON || {}
1414
1662
  );
1415
1663
  var create2 = (App, options = options_default2, optionsExternalFile) => {
1416
1664
  const redefinedOptions = {
@@ -1459,10 +1707,10 @@ var Smbls = (() => {
1459
1707
  var createSkeleton2 = (App = {}, options = options_default2, optionsExternalFile) => {
1460
1708
  return create2(
1461
1709
  {
1462
- deps: { isUndefined: import_utils14.isUndefined },
1710
+ deps: { isUndefined: import_utils16.isUndefined },
1463
1711
  ...App
1464
1712
  },
1465
- (0, import_utils14.deepMerge)({ domqlOptions: { onlyResolveExtends: true } }, options),
1713
+ (0, import_utils16.deepMerge)({ domqlOptions: { onlyResolveExtends: true } }, options),
1466
1714
  optionsExternalFile
1467
1715
  );
1468
1716
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "smbls",
3
- "version": "3.6.1",
3
+ "version": "3.6.3",
4
4
  "license": "MIT",
5
5
  "repository": "https://github.com/symbo-ls/smbls",
6
6
  "gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
@@ -28,21 +28,21 @@
28
28
  "src"
29
29
  ],
30
30
  "dependencies": {
31
- "@symbo.ls/emotion": "^3.6.1",
32
- "@symbo.ls/helmet": "^3.6.1",
33
- "@domql/report": "^3.6.1",
34
- "@domql/router": "^3.6.1",
35
- "@domql/utils": "^3.6.1",
36
- "@symbo.ls/cli": "^3.6.1",
37
- "@symbo.ls/default-config": "^3.6.1",
38
- "@symbo.ls/fetch": "^3.6.1",
39
- "@symbo.ls/scratch": "^3.6.1",
40
- "@symbo.ls/sync": "^3.6.1",
41
- "@symbo.ls/uikit": "^3.6.1",
42
- "@symbo.ls/smbls-utils": "^3.6.1",
43
- "attrs-in-props": "^3.6.1",
44
- "css-in-props": "^3.6.1",
45
- "domql": "^3.6.1"
31
+ "@symbo.ls/emotion": "^3.6.3",
32
+ "@symbo.ls/helmet": "^3.6.3",
33
+ "@domql/report": "^3.6.3",
34
+ "@domql/router": "^3.6.3",
35
+ "@domql/utils": "^3.6.3",
36
+ "@symbo.ls/cli": "^3.6.3",
37
+ "@symbo.ls/default-config": "^3.6.3",
38
+ "@symbo.ls/fetch": "^3.6.3",
39
+ "@symbo.ls/scratch": "^3.6.3",
40
+ "@symbo.ls/sync": "^3.6.3",
41
+ "@symbo.ls/uikit": "^3.6.3",
42
+ "@symbo.ls/smbls-utils": "^3.6.3",
43
+ "attrs-in-props": "^3.6.3",
44
+ "css-in-props": "^3.6.3",
45
+ "domql": "^3.6.3"
46
46
  },
47
47
  "publishConfig": {
48
48
  "access": "public"
package/src/define.js CHANGED
@@ -1,10 +1,31 @@
1
1
  'use strict'
2
2
 
3
3
  import { resolveMetadata, applyMetadata } from '@symbo.ls/helmet'
4
+ import {
5
+ isString,
6
+ isNumber,
7
+ isNot,
8
+ isArray,
9
+ isObject,
10
+ isObjectLike,
11
+ isState,
12
+ exec,
13
+ deepClone,
14
+ getChildStateInKey
15
+ } from '@domql/utils'
16
+
17
+ const processCollectionParam = (param, state) => {
18
+ if (isString(param)) {
19
+ if (param === 'state') return state.parse()
20
+ return getChildStateInKey(param, state)
21
+ }
22
+ if (isState(param)) return param.parse()
23
+ if (isNot(param)('array', 'object')) return null
24
+ return deepClone(param)
25
+ }
4
26
 
5
27
  export const defaultDefine = {
6
28
  routes: param => param,
7
- // deps: (param, el) => param || el.parent.deps,
8
29
 
9
30
  metadata: (param, el, state) => {
10
31
  if (!param) return
@@ -28,5 +49,130 @@ export const defaultDefine = {
28
49
  } else await set()
29
50
 
30
51
  return obj
52
+ },
53
+
54
+ $collection: async (param, el, state) => {
55
+ const { __ref: ref } = el
56
+ const {
57
+ children: childrenProps,
58
+ childrenAs,
59
+ childExtends
60
+ } = el.props || {}
61
+ const children = childrenProps && (await exec(childrenProps, el, state))
62
+ const childrenAsDefault = childrenAs || 'props'
63
+
64
+ if (children) {
65
+ if (isObject(children)) {
66
+ param = deepClone(children)
67
+ param = Object.keys(param).map(v => {
68
+ const val = param[v]
69
+ return isObjectLike(val) ? { ...val, extends: v } : { extends: v, value: val }
70
+ })
71
+ } else if (isArray(children)) {
72
+ param = deepClone(children)
73
+ if (childrenAsDefault && childrenAsDefault !== 'element') {
74
+ param = param.map(v => ({
75
+ ...(childExtends && { extends: childExtends }),
76
+ [childrenAsDefault]: isObjectLike(v)
77
+ ? v
78
+ : childrenAsDefault === 'state'
79
+ ? { value: v }
80
+ : { text: v }
81
+ }))
82
+ }
83
+ } else if (isString(children) || isNumber(children)) {
84
+ el.removeContent()
85
+ el.content = { text: param }
86
+ return
87
+ }
88
+ }
89
+
90
+ if (!param) return
91
+ param = processCollectionParam(param, state)
92
+ if (!param) return
93
+
94
+ if (ref.__collectionCache) {
95
+ const equals = JSON.stringify(param) === JSON.stringify(ref.__collectionCache)
96
+ if (equals) { ref.__noCollectionDifference = true; return }
97
+ ref.__collectionCache = deepClone(param)
98
+ delete ref.__noCollectionDifference
99
+ } else {
100
+ ref.__collectionCache = deepClone(param)
101
+ }
102
+
103
+ const obj = { tag: 'fragment', ignoreChildProps: true, childProps: el.props && el.props.childProps }
104
+ for (const key in param) {
105
+ const value = param[key]
106
+ if (value) obj[key] = isObjectLike(value) ? value : { value }
107
+ }
108
+ el.removeContent()
109
+ el.content = obj
110
+ },
111
+
112
+ $setCollection: async (param, el, state) => {
113
+ if (!param) return
114
+ param = processCollectionParam(param, state)
115
+ if (!param) return
116
+
117
+ const data = (isArray(param) ? param : isObject(param) ? Object.values(param) : [])
118
+ .map(item => (!isObjectLike(item) ? { value: item } : item))
119
+
120
+ if (data.length) {
121
+ const t = setTimeout(() => {
122
+ el.set({ tag: 'fragment', ...data }, { preventDefineUpdate: '$setCollection' })
123
+ clearTimeout(t)
124
+ })
125
+ }
126
+ return data
127
+ },
128
+
129
+ $stateCollection: async (param, el, state) => {
130
+ const { children, childrenAs } = el.props || {}
131
+ if (!param || children || childrenAs) return
132
+ param = processCollectionParam(param, state)
133
+ if (!param) return
134
+
135
+ const { __ref: ref } = el
136
+ if (ref.__stateCollectionCache) {
137
+ const equals = JSON.stringify(param) === JSON.stringify(ref.__stateCollectionCache)
138
+ if (equals) { ref.__noCollectionDifference = true; return }
139
+ ref.__stateCollectionCache = deepClone(param)
140
+ delete ref.__noCollectionDifference
141
+ } else {
142
+ ref.__stateCollectionCache = deepClone(param)
143
+ }
144
+
145
+ const obj = { tag: 'fragment', ignoreChildProps: true, childProps: el.props && el.props.childProps }
146
+ for (const key in param) {
147
+ const value = param[key]
148
+ if (value) obj[key] = { state: isObjectLike(value) ? value : { value } }
149
+ }
150
+ el.removeContent()
151
+ el.content = obj
152
+ },
153
+
154
+ $propsCollection: async (param, el, state) => {
155
+ const { children, childrenAs } = el.props || {}
156
+ if (!param || children || childrenAs) return
157
+ param = processCollectionParam(param, state)
158
+ if (!param) return
159
+
160
+ const { __ref: ref } = el
161
+ if (ref.__propsCollectionCache) {
162
+ const equals = JSON.stringify(param) === JSON.stringify(ref.__propsCollectionCache)
163
+ if (equals) { ref.__noCollectionDifference = true; return }
164
+ ref.__propsCollectionCache = deepClone(param)
165
+ delete ref.__noCollectionDifference
166
+ } else {
167
+ ref.__propsCollectionCache = deepClone(param)
168
+ }
169
+
170
+ const obj = { tag: 'fragment', ignoreChildProps: true, childProps: el.props && el.props.childProps }
171
+ for (const key in param) {
172
+ const value = param[key]
173
+ if (value) obj[key] = { props: isObjectLike(value) ? value : { value } }
174
+ }
175
+ el.removeContent()
176
+ el.content = obj
31
177
  }
32
178
  }