@symbo.ls/atoms 3.1.2 → 3.3.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/Collection.js +228 -0
- package/Form.js +0 -5
- package/Grid.js +37 -0
- package/Iframe.js +4 -12
- package/Img.js +1 -2
- package/InteractiveComponent.js +3 -7
- package/Media.js +280 -0
- package/Picture.js +3 -3
- package/{Shape/style.js → Shape.js} +27 -9
- package/Text.js +1 -0
- package/Theme.js +3 -2
- package/Video.js +12 -14
- package/index.js +1 -0
- package/package.json +15 -7
package/Collection.js
ADDED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { isState, getChildStateInKey } from '@domql/state'
|
|
4
|
+
import {
|
|
5
|
+
isString,
|
|
6
|
+
isNumber,
|
|
7
|
+
isNot,
|
|
8
|
+
isArray,
|
|
9
|
+
isObject,
|
|
10
|
+
isObjectLike,
|
|
11
|
+
exec,
|
|
12
|
+
deepClone,
|
|
13
|
+
addAdditionalExtend
|
|
14
|
+
} from '@domql/utils'
|
|
15
|
+
|
|
16
|
+
export const Collection = {
|
|
17
|
+
define: {
|
|
18
|
+
$collection: async (param, el, state) => {
|
|
19
|
+
const { __ref: ref } = el
|
|
20
|
+
const {
|
|
21
|
+
children: childrenProps,
|
|
22
|
+
childrenAs,
|
|
23
|
+
childExtends
|
|
24
|
+
} = el.props || {}
|
|
25
|
+
const children = childrenProps && (await exec(childrenProps, el, state))
|
|
26
|
+
|
|
27
|
+
const childrenAsDefault = childrenAs || 'props'
|
|
28
|
+
|
|
29
|
+
if (children) {
|
|
30
|
+
if (isObject(children)) {
|
|
31
|
+
if (children.$$typeof) return el.call('renderReact', children, el)
|
|
32
|
+
param = deepClone(children)
|
|
33
|
+
param = Object.keys(param).map(v => {
|
|
34
|
+
const val = param[v]
|
|
35
|
+
return addAdditionalExtend(v, val)
|
|
36
|
+
})
|
|
37
|
+
} else if (isArray(children)) {
|
|
38
|
+
param = deepClone(children)
|
|
39
|
+
if (childrenAsDefault && childrenAsDefault !== 'element') {
|
|
40
|
+
param = param.map(v => ({
|
|
41
|
+
...(childExtends && { extends: childExtends }),
|
|
42
|
+
[childrenAsDefault]: isObjectLike(v)
|
|
43
|
+
? v
|
|
44
|
+
: childrenAsDefault === 'state'
|
|
45
|
+
? { value: v }
|
|
46
|
+
: { text: v }
|
|
47
|
+
}))
|
|
48
|
+
}
|
|
49
|
+
} else if (isString(children) || isNumber(children)) {
|
|
50
|
+
el.removeContent()
|
|
51
|
+
el.content = { text: param }
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!param) return
|
|
57
|
+
|
|
58
|
+
const filterReact = param.filter(v => !v.$$typeof)
|
|
59
|
+
if (filterReact.length !== param.length) {
|
|
60
|
+
const extractedReactComponents = param.filter(v => v.$$typeof)
|
|
61
|
+
el.call('renderReact', extractedReactComponents, el)
|
|
62
|
+
}
|
|
63
|
+
param = filterReact
|
|
64
|
+
|
|
65
|
+
if (isString(param)) {
|
|
66
|
+
if (param === 'state') param = state.parse()
|
|
67
|
+
else param = getChildStateInKey(param, state)
|
|
68
|
+
}
|
|
69
|
+
if (isState(param)) param = param.parse()
|
|
70
|
+
if (isNot(param)('array', 'object')) return
|
|
71
|
+
|
|
72
|
+
param = deepClone(param)
|
|
73
|
+
|
|
74
|
+
if (ref.__collectionCache) {
|
|
75
|
+
const equals =
|
|
76
|
+
JSON.stringify(param) === JSON.stringify(ref.__collectionCache)
|
|
77
|
+
if (equals) {
|
|
78
|
+
ref.__noCollectionDifference = true
|
|
79
|
+
return
|
|
80
|
+
} else {
|
|
81
|
+
ref.__collectionCache = deepClone(param)
|
|
82
|
+
delete ref.__noCollectionDifference
|
|
83
|
+
}
|
|
84
|
+
} else {
|
|
85
|
+
ref.__collectionCache = deepClone(param)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const obj = {
|
|
89
|
+
tag: 'fragment',
|
|
90
|
+
ignoreChildProps: true,
|
|
91
|
+
childProps: el.props && el.props.childProps
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
for (const key in param) {
|
|
95
|
+
const value = param[key]
|
|
96
|
+
if (value) obj[key] = isObjectLike(value) ? value : { value }
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
el.removeContent()
|
|
100
|
+
el.content = obj
|
|
101
|
+
|
|
102
|
+
// return deepClone(param)
|
|
103
|
+
},
|
|
104
|
+
|
|
105
|
+
$setCollection: async (param, el, state) => {
|
|
106
|
+
if (!param) return
|
|
107
|
+
|
|
108
|
+
if (isString(param)) {
|
|
109
|
+
if (param === 'state') param = state.parse()
|
|
110
|
+
else param = getChildStateInKey(param, state)
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const data = (
|
|
114
|
+
isArray(param) ? param : isObject(param) ? Object.values(param) : []
|
|
115
|
+
).map(item => (!isObjectLike(item) ? { value: item } : item))
|
|
116
|
+
|
|
117
|
+
if (data.length) {
|
|
118
|
+
const t = setTimeout(() => {
|
|
119
|
+
el.set(
|
|
120
|
+
{ tag: 'fragment', ...data },
|
|
121
|
+
{ preventDefineUpdate: '$setCollection' }
|
|
122
|
+
)
|
|
123
|
+
clearTimeout(t)
|
|
124
|
+
})
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return data
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
$stateCollection: async (param, el, state, ctx) => {
|
|
131
|
+
const { children, childrenAs } = el.props || {}
|
|
132
|
+
if (!param || children || childrenAs) return
|
|
133
|
+
|
|
134
|
+
if (isString(param)) {
|
|
135
|
+
if (param === 'state') param = state.parse()
|
|
136
|
+
else param = getChildStateInKey(param, state)
|
|
137
|
+
}
|
|
138
|
+
if (isState(param)) param = param.parse()
|
|
139
|
+
if (isNot(param)('array', 'object')) return
|
|
140
|
+
|
|
141
|
+
const { __ref: ref } = el
|
|
142
|
+
param = deepClone(param)
|
|
143
|
+
|
|
144
|
+
if (ref.__stateCollectionCache) {
|
|
145
|
+
const equals =
|
|
146
|
+
JSON.stringify(param) === JSON.stringify(ref.__stateCollectionCache)
|
|
147
|
+
if (equals) {
|
|
148
|
+
ref.__noCollectionDifference = true
|
|
149
|
+
return
|
|
150
|
+
} else {
|
|
151
|
+
ref.__stateCollectionCache = deepClone(param)
|
|
152
|
+
delete ref.__noCollectionDifference
|
|
153
|
+
}
|
|
154
|
+
} else {
|
|
155
|
+
ref.__stateCollectionCache = deepClone(param)
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const obj = {
|
|
159
|
+
tag: 'fragment',
|
|
160
|
+
ignoreChildProps: true,
|
|
161
|
+
childProps: el.props && el.props.childProps
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
for (const key in param) {
|
|
165
|
+
const value = param[key]
|
|
166
|
+
if (value) obj[key] = { state: isObjectLike(value) ? value : { value } }
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
el.removeContent()
|
|
170
|
+
el.content = obj
|
|
171
|
+
|
|
172
|
+
// return deepClone(param)
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
$propsCollection: async (param, el, state) => {
|
|
176
|
+
const { children, childrenAs } = el.props || {}
|
|
177
|
+
if (!param || children || childrenAs) return
|
|
178
|
+
|
|
179
|
+
if (isString(param)) {
|
|
180
|
+
if (param === 'state') param = state.parse()
|
|
181
|
+
else param = getChildStateInKey(param, state)
|
|
182
|
+
}
|
|
183
|
+
if (isState(param)) param = param.parse()
|
|
184
|
+
if (isNot(param)('array', 'object')) return
|
|
185
|
+
|
|
186
|
+
const { __ref: ref } = el
|
|
187
|
+
param = deepClone(param)
|
|
188
|
+
|
|
189
|
+
if (ref.__propsCollectionCache) {
|
|
190
|
+
const equals =
|
|
191
|
+
JSON.stringify(param) === JSON.stringify(ref.__propsCollectionCache) // eslint-disable-line
|
|
192
|
+
if (equals) {
|
|
193
|
+
ref.__noCollectionDifference = true
|
|
194
|
+
return
|
|
195
|
+
} else {
|
|
196
|
+
ref.__propsCollectionCache = deepClone(param)
|
|
197
|
+
delete ref.__noCollectionDifference
|
|
198
|
+
}
|
|
199
|
+
} else {
|
|
200
|
+
ref.__propsCollectionCache = deepClone(param)
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const obj = {
|
|
204
|
+
tag: 'fragment',
|
|
205
|
+
ignoreChildProps: true,
|
|
206
|
+
childProps: el.props && el.props.childProps
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
for (const key in param) {
|
|
210
|
+
const value = param[key]
|
|
211
|
+
if (value) obj[key] = { props: isObjectLike(value) ? value : { value } }
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
el.removeContent()
|
|
215
|
+
el.content = obj
|
|
216
|
+
|
|
217
|
+
// const set = () => {
|
|
218
|
+
// el.set(obj, { preventDefineUpdate: '$propsCollection' })
|
|
219
|
+
// }
|
|
220
|
+
|
|
221
|
+
// if (el.props && el.props.lazyLoad) {
|
|
222
|
+
// window.requestAnimationFrame(set)
|
|
223
|
+
// } else set()
|
|
224
|
+
|
|
225
|
+
// return deepClone(param)
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
package/Form.js
CHANGED
package/Grid.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
export const Grid = {
|
|
4
|
+
props: { display: 'grid' },
|
|
5
|
+
|
|
6
|
+
class: {
|
|
7
|
+
area: ({ props }) => (props.area ? { gridArea: props.area } : null),
|
|
8
|
+
template: ({ props }) =>
|
|
9
|
+
props.template ? { gridTemplate: props.template } : null,
|
|
10
|
+
templateAreas: ({ props }) =>
|
|
11
|
+
props.templateAreas ? { gridTemplateAreas: props.templateAreas } : null,
|
|
12
|
+
|
|
13
|
+
column: ({ props }) => (props.column ? { gridColumn: props.column } : null),
|
|
14
|
+
columns: ({ props }) =>
|
|
15
|
+
props.columns ? { gridTemplateColumns: props.columns } : null,
|
|
16
|
+
templateColumns: ({ props }) =>
|
|
17
|
+
props.templateColumns
|
|
18
|
+
? { gridTemplateColumns: props.templateColumns }
|
|
19
|
+
: null,
|
|
20
|
+
autoColumns: ({ props }) =>
|
|
21
|
+
props.autoColumns ? { gridAutoColumns: props.autoColumns } : null,
|
|
22
|
+
columnStart: ({ props }) =>
|
|
23
|
+
props.columnStart ? { gridColumnStart: props.columnStart } : null,
|
|
24
|
+
|
|
25
|
+
row: ({ props }) => (props.row ? { gridRow: props.row } : null),
|
|
26
|
+
rows: ({ props }) => (props.rows ? { gridTemplateRows: props.rows } : null),
|
|
27
|
+
templateRows: ({ props }) =>
|
|
28
|
+
props.templateRows ? { gridTemplateRows: props.templateRows } : null,
|
|
29
|
+
autoRows: ({ props }) =>
|
|
30
|
+
props.autoRows ? { gridAutoRows: props.autoRows } : null,
|
|
31
|
+
rowStart: ({ props }) =>
|
|
32
|
+
props.rowStart ? { gridRowStart: props.rowStart } : null,
|
|
33
|
+
|
|
34
|
+
autoFlow: ({ props }) =>
|
|
35
|
+
props.autoFlow ? { gridAutoFlow: props.autoFlow } : null
|
|
36
|
+
}
|
|
37
|
+
}
|
package/Iframe.js
CHANGED
|
@@ -10,21 +10,13 @@ export const Iframe = {
|
|
|
10
10
|
src: (el, s) => {
|
|
11
11
|
let src = el.call('exec', el.props.src, el)
|
|
12
12
|
|
|
13
|
+
if (!src) return
|
|
14
|
+
|
|
13
15
|
if (el.call('isString', src) && src.includes('{{')) {
|
|
14
16
|
src = el.call('replaceLiteralsWithObjectFields', src)
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (isUrl) return src
|
|
20
|
-
},
|
|
21
|
-
srcdoc: ({ props }) => props.srcdoc,
|
|
22
|
-
sandbox: ({ props }) => props.sandbox,
|
|
23
|
-
seamless: ({ props }) => props.seamless,
|
|
24
|
-
loading: ({ props }) => props.loading,
|
|
25
|
-
allowfullscreen: ({ props }) => props.allowfullscreen,
|
|
26
|
-
frameborder: ({ props }) => props.frameborder,
|
|
27
|
-
allow: ({ props }) => props.allow,
|
|
28
|
-
referrerpolicy: ({ props }) => props.referrerpolicy
|
|
19
|
+
return src
|
|
20
|
+
}
|
|
29
21
|
}
|
|
30
22
|
}
|
package/Img.js
CHANGED
|
@@ -13,12 +13,11 @@ export const Img = {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
let isUrl
|
|
16
|
-
try { isUrl = new URL(src) } catch (e) {}
|
|
16
|
+
try { isUrl = new URL(src) } catch (e) { }
|
|
17
17
|
if (isUrl) return src
|
|
18
18
|
const file = context.files && context.files[src]
|
|
19
19
|
if (file) return file.content && file.content.src
|
|
20
20
|
},
|
|
21
|
-
alt: ({ props }) => props.alt,
|
|
22
21
|
title: ({ props }) => props.title || props.alt
|
|
23
22
|
}
|
|
24
23
|
}
|
package/InteractiveComponent.js
CHANGED
|
@@ -41,14 +41,13 @@ export const Clickable = {
|
|
|
41
41
|
|
|
42
42
|
export const Focusable = {
|
|
43
43
|
border: 'none',
|
|
44
|
-
outline: 'solid
|
|
44
|
+
outline: 'solid 0 blue.3',
|
|
45
45
|
':focus-visible': {
|
|
46
46
|
opacity: 1,
|
|
47
|
-
outline: 'solid
|
|
47
|
+
outline: 'solid X blue.3'
|
|
48
48
|
},
|
|
49
49
|
|
|
50
50
|
attr: {
|
|
51
|
-
placeholder: ({ props }) => props.placeholder,
|
|
52
51
|
tabIndex: ({ props }) => props.tabIndex
|
|
53
52
|
}
|
|
54
53
|
}
|
|
@@ -63,8 +62,5 @@ export const FocusableComponent = {
|
|
|
63
62
|
lineHeight: '1',
|
|
64
63
|
whiteSpace: 'nowrap',
|
|
65
64
|
fontFamily: 'inherit',
|
|
66
|
-
style
|
|
67
|
-
attr: {
|
|
68
|
-
type: ({ props }) => props.type
|
|
69
|
-
}
|
|
65
|
+
style
|
|
70
66
|
}
|
package/Media.js
ADDED
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { merge, isArray, overwriteDeep, overwriteShallow } from '@domql/utils'
|
|
4
|
+
import { getSystemGlobalTheme } from './Theme.js'
|
|
5
|
+
|
|
6
|
+
export const keySetters = {
|
|
7
|
+
'@': (key, props, result, element, isSubtree) =>
|
|
8
|
+
applyMediaProps(
|
|
9
|
+
key,
|
|
10
|
+
props,
|
|
11
|
+
isSubtree ? result : result && result.media,
|
|
12
|
+
element
|
|
13
|
+
),
|
|
14
|
+
':': (key, props, result, element, isSubtree) =>
|
|
15
|
+
applySelectorProps(
|
|
16
|
+
key,
|
|
17
|
+
props,
|
|
18
|
+
isSubtree ? result : result && result.selector,
|
|
19
|
+
element
|
|
20
|
+
),
|
|
21
|
+
'[': (key, props, result, element, isSubtree) =>
|
|
22
|
+
applySelectorProps(
|
|
23
|
+
key,
|
|
24
|
+
props,
|
|
25
|
+
isSubtree ? result : result && result.selector,
|
|
26
|
+
element
|
|
27
|
+
),
|
|
28
|
+
'*': (key, props, result, element, isSubtree) =>
|
|
29
|
+
applySelectorProps(
|
|
30
|
+
key,
|
|
31
|
+
props,
|
|
32
|
+
isSubtree ? result : result && result.selector,
|
|
33
|
+
element
|
|
34
|
+
),
|
|
35
|
+
'+': (key, props, result, element, isSubtree) =>
|
|
36
|
+
applySelectorProps(
|
|
37
|
+
key,
|
|
38
|
+
props,
|
|
39
|
+
isSubtree ? result : result && result.selector,
|
|
40
|
+
element
|
|
41
|
+
),
|
|
42
|
+
'~': (key, props, result, element, isSubtree) =>
|
|
43
|
+
applySelectorProps(
|
|
44
|
+
key,
|
|
45
|
+
props,
|
|
46
|
+
isSubtree ? result : result && result.selector,
|
|
47
|
+
element
|
|
48
|
+
),
|
|
49
|
+
'&': (key, props, result, element, isSubtree) =>
|
|
50
|
+
applyAndProps(
|
|
51
|
+
key,
|
|
52
|
+
props,
|
|
53
|
+
isSubtree ? result : result && result.selector,
|
|
54
|
+
element
|
|
55
|
+
),
|
|
56
|
+
'>': (key, props, result, element, isSubtree) =>
|
|
57
|
+
applyAndProps(
|
|
58
|
+
key,
|
|
59
|
+
props,
|
|
60
|
+
isSubtree ? result : result && result.selector,
|
|
61
|
+
element
|
|
62
|
+
),
|
|
63
|
+
$: (key, props, result, element, isSubtree) =>
|
|
64
|
+
applyCaseProps(
|
|
65
|
+
key,
|
|
66
|
+
props,
|
|
67
|
+
isSubtree ? result : result && result.case,
|
|
68
|
+
element
|
|
69
|
+
),
|
|
70
|
+
'-': (key, props, result, element, isSubtree) =>
|
|
71
|
+
applyVariableProps(
|
|
72
|
+
key,
|
|
73
|
+
props,
|
|
74
|
+
isSubtree ? result : result && result.variable,
|
|
75
|
+
element
|
|
76
|
+
),
|
|
77
|
+
'.': (key, props, result, element, isSubtree) =>
|
|
78
|
+
applyConditionalCaseProps(
|
|
79
|
+
key,
|
|
80
|
+
props,
|
|
81
|
+
isSubtree ? result : result && result.case,
|
|
82
|
+
element
|
|
83
|
+
),
|
|
84
|
+
'!': (key, props, result, element, isSubtree) =>
|
|
85
|
+
applyConditionalFalsyProps(
|
|
86
|
+
key,
|
|
87
|
+
props,
|
|
88
|
+
isSubtree ? result : result && result.case,
|
|
89
|
+
element
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const execClass = (key, props, result, element) => {
|
|
94
|
+
const { class: className } = element
|
|
95
|
+
const classnameExec = className[key]
|
|
96
|
+
|
|
97
|
+
if (typeof classnameExec !== 'function') return
|
|
98
|
+
|
|
99
|
+
let classExec = classnameExec(
|
|
100
|
+
{
|
|
101
|
+
props,
|
|
102
|
+
context: element.context,
|
|
103
|
+
state: element.state,
|
|
104
|
+
deps: element.deps
|
|
105
|
+
},
|
|
106
|
+
element.state,
|
|
107
|
+
element.context
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
if (isArray(classExec))
|
|
111
|
+
classExec = classExec.reduce((a, c) => merge(a, c), {})
|
|
112
|
+
|
|
113
|
+
for (const finalProp in classExec) {
|
|
114
|
+
result[finalProp] = classExec[finalProp]
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return classExec
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const convertPropsToClass = (props, result, element) => {
|
|
121
|
+
const propsClassObj = {}
|
|
122
|
+
|
|
123
|
+
for (const key in props) {
|
|
124
|
+
const setter = keySetters[key.slice(0, 1)]
|
|
125
|
+
if (setter) {
|
|
126
|
+
setter(key, props[key], propsClassObj, element, true)
|
|
127
|
+
continue
|
|
128
|
+
} else {
|
|
129
|
+
execClass(key, props, propsClassObj, element)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return propsClassObj
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const applyMediaProps = (key, props, result, element) => {
|
|
137
|
+
const { context } = element
|
|
138
|
+
if (!context.designSystem || !context.designSystem.MEDIA) return
|
|
139
|
+
const globalTheme = getSystemGlobalTheme(element)
|
|
140
|
+
const { MEDIA } = context.designSystem
|
|
141
|
+
const mediaValue = MEDIA[key.slice(1)]
|
|
142
|
+
const generatedClass = convertPropsToClass(props, result, element)
|
|
143
|
+
|
|
144
|
+
const name = key.slice(1)
|
|
145
|
+
const isTheme = ['dark', 'light'].includes(name)
|
|
146
|
+
const matchesGlobal = name === globalTheme
|
|
147
|
+
|
|
148
|
+
if (globalTheme && isTheme) {
|
|
149
|
+
if (matchesGlobal) return merge(result, generatedClass)
|
|
150
|
+
return
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const printValue =
|
|
154
|
+
'@media ' +
|
|
155
|
+
(mediaValue === 'print' ? `${mediaValue}` : `screen and ${mediaValue}`)
|
|
156
|
+
const mediaKey = mediaValue ? printValue : key
|
|
157
|
+
result[mediaKey] = generatedClass
|
|
158
|
+
return result[mediaKey]
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const applyAndProps = (key, props, result, element) => {
|
|
162
|
+
result[key] = convertPropsToClass(props, result, element)
|
|
163
|
+
return result[key]
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const applySelectorProps = (key, props, result, element) => {
|
|
167
|
+
const selectorKey = `&${key}`
|
|
168
|
+
result[selectorKey] = convertPropsToClass(props, result, element)
|
|
169
|
+
return result[selectorKey]
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const applyCaseProps = (key, props, result, element) => {
|
|
173
|
+
const { CASES } = element.context && element.context.designSystem
|
|
174
|
+
const caseKey = key.slice(1)
|
|
175
|
+
const isPropTrue = element.props[caseKey]
|
|
176
|
+
if (!CASES[caseKey] && !isPropTrue) return
|
|
177
|
+
return merge(result, convertPropsToClass(props, result, element))
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const applyVariableProps = (key, props, result, element) => {
|
|
181
|
+
result[key] = props
|
|
182
|
+
return result
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const applyConditionalCaseProps = (key, props, result, element) => {
|
|
186
|
+
const caseKey = key.slice(1)
|
|
187
|
+
const isPropTrue =
|
|
188
|
+
element.props[caseKey] === true ||
|
|
189
|
+
element.state[caseKey] ||
|
|
190
|
+
element[caseKey]
|
|
191
|
+
if (!isPropTrue) return // remove classname if not here
|
|
192
|
+
return overwriteDeep(result, convertPropsToClass(props, result, element))
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const applyConditionalFalsyProps = (key, props, result, element) => {
|
|
196
|
+
const caseKey = key.slice(1)
|
|
197
|
+
const isPropTrue =
|
|
198
|
+
element.props[caseKey] === true ||
|
|
199
|
+
element.state[caseKey] ||
|
|
200
|
+
element[caseKey]
|
|
201
|
+
if (!isPropTrue)
|
|
202
|
+
return overwriteDeep(result, convertPropsToClass(props, result, element))
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
const applyTrueProps = (props, result, element) =>
|
|
206
|
+
merge(result, convertPropsToClass(props, result, element))
|
|
207
|
+
|
|
208
|
+
export const beforeClassAssign = (element, s, ctx) => {
|
|
209
|
+
const { props, class: className, context } = element
|
|
210
|
+
|
|
211
|
+
const CLASS_NAMES = {
|
|
212
|
+
media: {},
|
|
213
|
+
selector: {},
|
|
214
|
+
case: {},
|
|
215
|
+
variable: {}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (!context) return
|
|
219
|
+
const globalTheme = context.designSystem.globalTheme
|
|
220
|
+
|
|
221
|
+
for (const key in props) {
|
|
222
|
+
const setter = keySetters[key.slice(0, 1)]
|
|
223
|
+
if (globalTheme) {
|
|
224
|
+
if (key === 'theme' && !props.themeModifier) {
|
|
225
|
+
props.themeModifier = globalTheme
|
|
226
|
+
// props.update(
|
|
227
|
+
// {
|
|
228
|
+
// themeModifier: globalTheme
|
|
229
|
+
// },
|
|
230
|
+
// {
|
|
231
|
+
// preventListeners: true,
|
|
232
|
+
// preventRecursive: true,
|
|
233
|
+
// isForced: true,
|
|
234
|
+
// preventDefineUpdate: true
|
|
235
|
+
// }
|
|
236
|
+
// )
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (setter) setter(key, props[key], CLASS_NAMES, element)
|
|
240
|
+
else if (key === 'class') {
|
|
241
|
+
const value = element.props.class
|
|
242
|
+
if (!element.call('isString', value)) return
|
|
243
|
+
const classArr = value.split(' ')
|
|
244
|
+
const scratchClasses = ctx.designSystem.CLASS
|
|
245
|
+
CLASS_NAMES.class = classArr.reduce((accumulator, current) => {
|
|
246
|
+
const scratchClass = scratchClasses[current]
|
|
247
|
+
return merge(accumulator, scratchClass)
|
|
248
|
+
}, {})
|
|
249
|
+
} else if (key === 'true') applyTrueProps(props[key], CLASS_NAMES, element)
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
// override props
|
|
253
|
+
// if (props['^']) {
|
|
254
|
+
// for (const key in props['^']) {
|
|
255
|
+
// execClass(key, props, CLASS_NAMES, element)
|
|
256
|
+
// }
|
|
257
|
+
// }
|
|
258
|
+
|
|
259
|
+
const parentProps = element.parent && element.parent.props
|
|
260
|
+
if (
|
|
261
|
+
parentProps &&
|
|
262
|
+
parentProps.spacingRatio &&
|
|
263
|
+
parentProps.inheritSpacingRatio
|
|
264
|
+
) {
|
|
265
|
+
element.setProps(
|
|
266
|
+
{
|
|
267
|
+
spacingRatio: parentProps.spacingRatio,
|
|
268
|
+
inheritSpacingRatio: true
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
preventListeners: true,
|
|
272
|
+
preventRecursive: true,
|
|
273
|
+
isForced: true,
|
|
274
|
+
preventDefineUpdate: true
|
|
275
|
+
}
|
|
276
|
+
)
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
overwriteShallow(className, CLASS_NAMES)
|
|
280
|
+
}
|
package/Picture.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { getSystemGlobalTheme } from './Theme'
|
|
3
|
+
import { getSystemGlobalTheme } from './Theme.js'
|
|
4
4
|
|
|
5
5
|
export const Picture = {
|
|
6
6
|
deps: { getSystemGlobalTheme },
|
|
@@ -16,11 +16,11 @@ export const Picture = {
|
|
|
16
16
|
const mediaName = (props.media || key).slice(1)
|
|
17
17
|
|
|
18
18
|
if (mediaName === globalTheme) return '(min-width: 0px)'
|
|
19
|
-
else if (mediaName === 'dark' || mediaName === 'light')
|
|
19
|
+
else if (mediaName === 'dark' || mediaName === 'light')
|
|
20
|
+
return '(max-width: 0px)'
|
|
20
21
|
|
|
21
22
|
return MEDIA[mediaName]
|
|
22
23
|
},
|
|
23
|
-
srcset: ({ props }) => props.srcset
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
|
|
@@ -6,19 +6,33 @@ import { TIMING_PROPS } from 'css-in-props/src/props'
|
|
|
6
6
|
const CONFIG = getActiveConfig()
|
|
7
7
|
|
|
8
8
|
export const depth = {
|
|
9
|
-
4: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
4: {
|
|
10
|
+
boxShadow: `rgba(0,0,0,.10) 0 2${CONFIG.UNIT.default} 4${CONFIG.UNIT.default}`
|
|
11
|
+
},
|
|
12
|
+
6: {
|
|
13
|
+
boxShadow: `rgba(0,0,0,.10) 0 3${CONFIG.UNIT.default} 6${CONFIG.UNIT.default}`
|
|
14
|
+
},
|
|
15
|
+
10: {
|
|
16
|
+
boxShadow: `rgba(0,0,0,.10) 0 4${CONFIG.UNIT.default} 10${CONFIG.UNIT.default}`
|
|
17
|
+
},
|
|
18
|
+
16: {
|
|
19
|
+
boxShadow: `rgba(0,0,0,.10) 0 8${CONFIG.UNIT.default} 16${CONFIG.UNIT.default}`
|
|
20
|
+
},
|
|
21
|
+
26: {
|
|
22
|
+
boxShadow: `rgba(0,0,0,.10) 0 14${CONFIG.UNIT.default} 26${CONFIG.UNIT.default}`
|
|
23
|
+
},
|
|
24
|
+
42: {
|
|
25
|
+
boxShadow: `rgba(0,0,0,.10) 0 20${CONFIG.UNIT.default} 42${CONFIG.UNIT.default}`
|
|
26
|
+
}
|
|
15
27
|
}
|
|
16
28
|
|
|
17
29
|
const getComputedBackgroundColor = ({ props }) => {
|
|
18
|
-
return
|
|
30
|
+
return (
|
|
31
|
+
getColor(props.shapeDirectionColor) ||
|
|
19
32
|
getColor(props.borderColor) ||
|
|
20
33
|
getColor(props.backgroundColor) ||
|
|
21
34
|
getColor(props.background)
|
|
35
|
+
)
|
|
22
36
|
}
|
|
23
37
|
|
|
24
38
|
const inheritTransition = ({ props, deps }) => {
|
|
@@ -168,10 +182,14 @@ export const SHAPES = {
|
|
|
168
182
|
transformOrigin: '50% 50%',
|
|
169
183
|
transition: inheritTransition({ props, deps }),
|
|
170
184
|
transitionProperty: 'background'
|
|
171
|
-
|
|
172
185
|
},
|
|
173
186
|
'&:before': {
|
|
174
|
-
background: `linear-gradient(225deg, ${getComputedBackgroundColor({
|
|
187
|
+
background: `linear-gradient(225deg, ${getComputedBackgroundColor({
|
|
188
|
+
props,
|
|
189
|
+
deps
|
|
190
|
+
})} 25%, transparent 25%), linear-gradient(315deg, ${getComputedBackgroundColor(
|
|
191
|
+
{ props, deps }
|
|
192
|
+
)} 25%, transparent 25%)`
|
|
175
193
|
},
|
|
176
194
|
'&:after': {
|
|
177
195
|
background: getComputedBackgroundColor({ props, deps }),
|
package/Text.js
CHANGED
package/Theme.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { depth } from './Shape
|
|
3
|
+
import { depth } from './Shape'
|
|
4
4
|
import { isUndefined } from '@domql/utils'
|
|
5
5
|
|
|
6
6
|
export const getSystemGlobalTheme = ({ context, state }) => {
|
|
7
7
|
const rootState = state && state.root
|
|
8
|
-
|
|
8
|
+
const theme = (rootState && rootState.globalTheme) || (context.designSystem && context.designSystem.globalTheme)
|
|
9
|
+
return theme === 'auto' ? null : theme
|
|
9
10
|
}
|
|
10
11
|
|
|
11
12
|
export const Theme = {
|
package/Video.js
CHANGED
|
@@ -6,22 +6,20 @@ export const Video = {
|
|
|
6
6
|
controls: true,
|
|
7
7
|
|
|
8
8
|
childExtends: {
|
|
9
|
-
tag: 'source'
|
|
10
|
-
attr: {
|
|
11
|
-
src: ({ props }) => props.src,
|
|
12
|
-
type: ({ props }) => props.type,
|
|
13
|
-
controls: ({ props }) => props.controls
|
|
14
|
-
}
|
|
9
|
+
tag: 'source'
|
|
15
10
|
},
|
|
16
11
|
|
|
17
12
|
attr: {
|
|
18
|
-
src: (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
src: (el, s) => {
|
|
14
|
+
let src = el.call('exec', el.props.src, el)
|
|
15
|
+
|
|
16
|
+
if (!src) return
|
|
17
|
+
|
|
18
|
+
if (el.call('isString', src) && src.includes('{{')) {
|
|
19
|
+
src = el.call('replaceLiteralsWithObjectFields', src)
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return src
|
|
23
|
+
}
|
|
26
24
|
}
|
|
27
25
|
}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/atoms",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@domql/state": "^3.
|
|
9
|
-
"@domql/utils": "^3.
|
|
10
|
-
"
|
|
11
|
-
"@symbo.ls/scratch": "^3.
|
|
8
|
+
"@domql/state": "^3.2.3",
|
|
9
|
+
"@domql/utils": "^3.2.3",
|
|
10
|
+
"smbls": "^3.2.3",
|
|
11
|
+
"@symbo.ls/scratch": "^3.2.3"
|
|
12
12
|
},
|
|
13
|
-
"source": "
|
|
13
|
+
"source": "index.js",
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@babel/core": "^7.26.0"
|
|
16
|
+
},
|
|
17
|
+
"type": "module",
|
|
18
|
+
"module": "index.js",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"import": "./index.js",
|
|
22
|
+
"default": "./index.js"
|
|
23
|
+
}
|
|
16
24
|
}
|
|
17
25
|
}
|