@symbo.ls/atoms 2.28.41 → 2.28.44
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/Collection.js +45 -21
- package/package.json +6 -6
package/Collection.js
CHANGED
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { isState, getChildStateInKey } from '@domql/state'
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
isString,
|
|
6
|
+
isNumber,
|
|
7
|
+
isNot,
|
|
8
|
+
isArray,
|
|
9
|
+
isObject,
|
|
10
|
+
isObjectLike,
|
|
11
|
+
exec,
|
|
12
|
+
deepClone,
|
|
13
|
+
addAdditionalExtend
|
|
14
|
+
} from '@domql/utils'
|
|
5
15
|
|
|
6
16
|
export const Collection = {
|
|
7
17
|
define: {
|
|
8
|
-
$collection: (param, el, state) => {
|
|
18
|
+
$collection: async (param, el, state) => {
|
|
9
19
|
const { __ref: ref } = el
|
|
10
|
-
const {
|
|
11
|
-
|
|
20
|
+
const {
|
|
21
|
+
children: childrenProps,
|
|
22
|
+
childrenAs,
|
|
23
|
+
childExtends
|
|
24
|
+
} = el.props || {}
|
|
25
|
+
const children = childrenProps && (await exec(childrenProps, el, state))
|
|
12
26
|
|
|
13
27
|
const childrenAsDefault = childrenAs || 'props'
|
|
14
28
|
|
|
@@ -22,10 +36,14 @@ export const Collection = {
|
|
|
22
36
|
})
|
|
23
37
|
} else if (isArray(children)) {
|
|
24
38
|
param = deepClone(children)
|
|
25
|
-
if (childrenAsDefault
|
|
39
|
+
if (childrenAsDefault && childrenAsDefault !== 'element') {
|
|
26
40
|
param = param.map(v => ({
|
|
27
|
-
extend: childExtends,
|
|
28
|
-
[childrenAsDefault]: isObjectLike(v)
|
|
41
|
+
...(childExtends && { extend: childExtends }),
|
|
42
|
+
[childrenAsDefault]: isObjectLike(v)
|
|
43
|
+
? v
|
|
44
|
+
: childrenAsDefault === 'state'
|
|
45
|
+
? { value: v }
|
|
46
|
+
: { text: v }
|
|
29
47
|
}))
|
|
30
48
|
}
|
|
31
49
|
} else if (isString(children) || isNumber(children)) {
|
|
@@ -41,7 +59,8 @@ export const Collection = {
|
|
|
41
59
|
if (filterReact.length !== param.length) {
|
|
42
60
|
const extractedReactComponents = param.filter(v => v.$$typeof)
|
|
43
61
|
el.call('renderReact', extractedReactComponents, el)
|
|
44
|
-
}
|
|
62
|
+
}
|
|
63
|
+
param = filterReact
|
|
45
64
|
|
|
46
65
|
if (isString(param)) {
|
|
47
66
|
if (param === 'state') param = state.parse()
|
|
@@ -53,7 +72,8 @@ export const Collection = {
|
|
|
53
72
|
param = deepClone(param)
|
|
54
73
|
|
|
55
74
|
if (ref.__collectionCache) {
|
|
56
|
-
const equals =
|
|
75
|
+
const equals =
|
|
76
|
+
JSON.stringify(param) === JSON.stringify(ref.__collectionCache)
|
|
57
77
|
if (equals) {
|
|
58
78
|
ref.__noCollectionDifference = true
|
|
59
79
|
return
|
|
@@ -84,7 +104,7 @@ export const Collection = {
|
|
|
84
104
|
// return deepClone(param)
|
|
85
105
|
},
|
|
86
106
|
|
|
87
|
-
$setCollection: (param, el, state) => {
|
|
107
|
+
$setCollection: async (param, el, state) => {
|
|
88
108
|
if (!param) return
|
|
89
109
|
|
|
90
110
|
if (isString(param)) {
|
|
@@ -92,14 +112,16 @@ export const Collection = {
|
|
|
92
112
|
else param = getChildStateInKey(param, state)
|
|
93
113
|
}
|
|
94
114
|
|
|
95
|
-
const data = (
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
: item)
|
|
115
|
+
const data = (
|
|
116
|
+
isArray(param) ? param : isObject(param) ? Object.values(param) : []
|
|
117
|
+
).map(item => (!isObjectLike(item) ? { props: { value: item } } : item))
|
|
99
118
|
|
|
100
119
|
if (data.length) {
|
|
101
120
|
const t = setTimeout(() => {
|
|
102
|
-
el.set(
|
|
121
|
+
el.set(
|
|
122
|
+
{ tag: 'fragment', ...data },
|
|
123
|
+
{ preventDefineUpdate: '$setCollection' }
|
|
124
|
+
)
|
|
103
125
|
clearTimeout(t)
|
|
104
126
|
})
|
|
105
127
|
}
|
|
@@ -107,8 +129,8 @@ export const Collection = {
|
|
|
107
129
|
return data
|
|
108
130
|
},
|
|
109
131
|
|
|
110
|
-
$stateCollection: (param, el, state, ctx) => {
|
|
111
|
-
const { children, childrenAs } =
|
|
132
|
+
$stateCollection: async (param, el, state, ctx) => {
|
|
133
|
+
const { children, childrenAs } = el.props || {}
|
|
112
134
|
if (!param || children || childrenAs) return
|
|
113
135
|
|
|
114
136
|
if (isString(param)) {
|
|
@@ -122,7 +144,8 @@ export const Collection = {
|
|
|
122
144
|
param = deepClone(param)
|
|
123
145
|
|
|
124
146
|
if (ref.__stateCollectionCache) {
|
|
125
|
-
const equals =
|
|
147
|
+
const equals =
|
|
148
|
+
JSON.stringify(param) === JSON.stringify(ref.__stateCollectionCache)
|
|
126
149
|
if (equals) {
|
|
127
150
|
ref.__noCollectionDifference = true
|
|
128
151
|
return
|
|
@@ -153,8 +176,8 @@ export const Collection = {
|
|
|
153
176
|
// return deepClone(param)
|
|
154
177
|
},
|
|
155
178
|
|
|
156
|
-
$propsCollection: (param, el, state) => {
|
|
157
|
-
const { children, childrenAs } =
|
|
179
|
+
$propsCollection: async (param, el, state) => {
|
|
180
|
+
const { children, childrenAs } = el.props || {}
|
|
158
181
|
if (!param || children || childrenAs) return
|
|
159
182
|
|
|
160
183
|
if (isString(param)) {
|
|
@@ -168,7 +191,8 @@ export const Collection = {
|
|
|
168
191
|
param = deepClone(param)
|
|
169
192
|
|
|
170
193
|
if (ref.__propsCollectionCache) {
|
|
171
|
-
const equals =
|
|
194
|
+
const equals =
|
|
195
|
+
JSON.stringify(param) === JSON.stringify(ref.__propsCollectionCache) // eslint-disable-line
|
|
172
196
|
if (equals) {
|
|
173
197
|
ref.__noCollectionDifference = true
|
|
174
198
|
return
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/atoms",
|
|
3
|
-
"version": "2.28.
|
|
3
|
+
"version": "2.28.44",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "70519611a6e66b84b628e807c95227a516a40b03",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@domql/state": "^2.28.
|
|
9
|
-
"@domql/utils": "^2.28.
|
|
10
|
-
"@symbo.ls/emotion": "^2.28.
|
|
11
|
-
"@symbo.ls/scratch": "^2.28.
|
|
8
|
+
"@domql/state": "^2.28.44",
|
|
9
|
+
"@domql/utils": "^2.28.44",
|
|
10
|
+
"@symbo.ls/emotion": "^2.28.44",
|
|
11
|
+
"@symbo.ls/scratch": "^2.28.44"
|
|
12
12
|
},
|
|
13
13
|
"source": "src/index.js",
|
|
14
14
|
"devDependencies": {
|