@symbo.ls/atoms 2.11.523 → 3.0.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/Block.js +16 -375
- package/Box.js +53 -0
- package/Hgroup.js +8 -11
- package/Iframe.js +4 -5
- package/InteractiveComponent.js +2 -2
- package/Picture.js +2 -2
- package/Shape/index.js +13 -14
- package/Shape/style.js +2 -2
- package/Text.js +1 -45
- package/Theme.js +3 -188
- package/Video.js +1 -1
- package/index.js +1 -13
- package/package.json +6 -6
- package/Animation.js +0 -57
- package/Collection.js +0 -210
- package/Direction.js +0 -10
- package/Flex.js +0 -29
- package/Grid.js +0 -29
- package/Interaction.js +0 -17
- package/Media.js +0 -217
- package/Overflow.js +0 -19
- package/Position.js +0 -42
- package/Pseudo.js +0 -7
- package/Timing.js +0 -39
- package/Transform.js +0 -12
- package/XYZ.js +0 -11
package/Media.js
DELETED
|
@@ -1,217 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { merge, isArray, overwriteDeep, overwriteShallow } from '@domql/utils'
|
|
4
|
-
import { getSystemGlobalTheme } from './Theme'
|
|
5
|
-
|
|
6
|
-
export const keySetters = {
|
|
7
|
-
'@': (key, props, result, element, isSubtree) => applyMediaProps(
|
|
8
|
-
key, props, isSubtree ? result : (result && result.media), element
|
|
9
|
-
),
|
|
10
|
-
':': (key, props, result, element, isSubtree) => applySelectorProps(
|
|
11
|
-
key, props, isSubtree ? result : (result && result.selector), element
|
|
12
|
-
),
|
|
13
|
-
'[': (key, props, result, element, isSubtree) => applySelectorProps(
|
|
14
|
-
key, props, isSubtree ? result : (result && result.selector), element
|
|
15
|
-
),
|
|
16
|
-
'*': (key, props, result, element, isSubtree) => applySelectorProps(
|
|
17
|
-
key, props, isSubtree ? result : (result && result.selector), element
|
|
18
|
-
),
|
|
19
|
-
'+': (key, props, result, element, isSubtree) => applySelectorProps(
|
|
20
|
-
key, props, isSubtree ? result : (result && result.selector), element
|
|
21
|
-
),
|
|
22
|
-
'~': (key, props, result, element, isSubtree) => applySelectorProps(
|
|
23
|
-
key, props, isSubtree ? result : (result && result.selector), element
|
|
24
|
-
),
|
|
25
|
-
'&': (key, props, result, element, isSubtree) => applyAndProps(
|
|
26
|
-
key, props, isSubtree ? result : (result && result.selector), element
|
|
27
|
-
),
|
|
28
|
-
'>': (key, props, result, element, isSubtree) => applyAndProps(
|
|
29
|
-
key, props, isSubtree ? result : (result && result.selector), element
|
|
30
|
-
),
|
|
31
|
-
$: (key, props, result, element, isSubtree) => applyCaseProps(
|
|
32
|
-
key, props, isSubtree ? result : (result && result.case), element
|
|
33
|
-
),
|
|
34
|
-
'-': (key, props, result, element, isSubtree) => applyVariableProps(
|
|
35
|
-
key, props, isSubtree ? result : (result && result.variable), element
|
|
36
|
-
),
|
|
37
|
-
'.': (key, props, result, element, isSubtree) => applyConditionalCaseProps(
|
|
38
|
-
key, props, isSubtree ? result : (result && result.case), element
|
|
39
|
-
),
|
|
40
|
-
'!': (key, props, result, element, isSubtree) => applyConditionalFalsyProps(
|
|
41
|
-
key, props, isSubtree ? result : (result && result.case), element
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const execClass = (key, props, result, element) => {
|
|
46
|
-
const { class: className } = element
|
|
47
|
-
const classnameExec = className[key]
|
|
48
|
-
|
|
49
|
-
if (typeof classnameExec !== 'function') return
|
|
50
|
-
|
|
51
|
-
let classExec = classnameExec({
|
|
52
|
-
props,
|
|
53
|
-
context: element.context,
|
|
54
|
-
state: element.state,
|
|
55
|
-
deps: element.deps
|
|
56
|
-
}, element.state, element.context)
|
|
57
|
-
|
|
58
|
-
if (isArray(classExec)) classExec = classExec.reduce((a, c) => merge(a, c), {})
|
|
59
|
-
|
|
60
|
-
for (const finalProp in classExec) {
|
|
61
|
-
result[finalProp] = classExec[finalProp]
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return classExec
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const convertPropsToClass = (props, result, element) => {
|
|
68
|
-
const propsClassObj = {}
|
|
69
|
-
|
|
70
|
-
for (const key in props) {
|
|
71
|
-
const setter = keySetters[key.slice(0, 1)]
|
|
72
|
-
if (setter) {
|
|
73
|
-
setter(key, props[key], propsClassObj, element, true)
|
|
74
|
-
continue
|
|
75
|
-
} else {
|
|
76
|
-
execClass(key, props, propsClassObj, element)
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return propsClassObj
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const applyMediaProps = (key, props, result, element) => {
|
|
84
|
-
const { context } = element
|
|
85
|
-
if (!context.designSystem || !context.designSystem.MEDIA) return
|
|
86
|
-
const globalTheme = getSystemGlobalTheme(element)
|
|
87
|
-
const { MEDIA } = context.designSystem
|
|
88
|
-
const mediaValue = MEDIA[key.slice(1)]
|
|
89
|
-
const generatedClass = convertPropsToClass(props, result, element)
|
|
90
|
-
|
|
91
|
-
const name = key.slice(1)
|
|
92
|
-
const isTheme = ['dark', 'light'].includes(name)
|
|
93
|
-
const matchesGlobal = name === globalTheme
|
|
94
|
-
|
|
95
|
-
if (globalTheme && isTheme) {
|
|
96
|
-
if (matchesGlobal) return merge(result, generatedClass)
|
|
97
|
-
return
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const printValue = '@media ' + (mediaValue === 'print' ? `${mediaValue}` : `screen and ${mediaValue}`)
|
|
101
|
-
const mediaKey = mediaValue ? printValue : key
|
|
102
|
-
result[mediaKey] = generatedClass
|
|
103
|
-
return result[mediaKey]
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const applyAndProps = (key, props, result, element) => {
|
|
107
|
-
result[key] = convertPropsToClass(props, result, element)
|
|
108
|
-
return result[key]
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
const applySelectorProps = (key, props, result, element) => {
|
|
112
|
-
const selectorKey = `&${key}`
|
|
113
|
-
result[selectorKey] = convertPropsToClass(props, result, element)
|
|
114
|
-
return result[selectorKey]
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
const applyCaseProps = (key, props, result, element) => {
|
|
118
|
-
const { CASES } = element.context && element.context.designSystem
|
|
119
|
-
const caseKey = key.slice(1)
|
|
120
|
-
const isPropTrue = element.props[caseKey]
|
|
121
|
-
if (!CASES[caseKey] && !isPropTrue) return
|
|
122
|
-
return merge(result, convertPropsToClass(props, result, element))
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const applyVariableProps = (key, props, result, element) => {
|
|
126
|
-
result[key] = props
|
|
127
|
-
return result
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const applyConditionalCaseProps = (key, props, result, element) => {
|
|
131
|
-
const caseKey = key.slice(1)
|
|
132
|
-
const isPropTrue = element.props[caseKey] === true || element.state[caseKey] || element[caseKey]
|
|
133
|
-
if (!isPropTrue) return // remove classname if not here
|
|
134
|
-
return overwriteDeep(result, convertPropsToClass(props, result, element))
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const applyConditionalFalsyProps = (key, props, result, element) => {
|
|
138
|
-
const caseKey = key.slice(1)
|
|
139
|
-
const isPropTrue = element.props[caseKey] === true || element.state[caseKey] || element[caseKey]
|
|
140
|
-
if (!isPropTrue) return overwriteDeep(result, convertPropsToClass(props, result, element))
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const applyTrueProps = (props, result, element) => merge(result, convertPropsToClass(props, result, element))
|
|
144
|
-
|
|
145
|
-
const beforeClassAssign = (element, s, ctx) => {
|
|
146
|
-
const { props, class: className, context } = element
|
|
147
|
-
|
|
148
|
-
const CLASS_NAMES = {
|
|
149
|
-
media: {},
|
|
150
|
-
selector: {},
|
|
151
|
-
case: {},
|
|
152
|
-
variable: {}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
if (!context) return
|
|
156
|
-
const globalTheme = context.designSystem.globalTheme
|
|
157
|
-
|
|
158
|
-
for (const key in props) {
|
|
159
|
-
const setter = keySetters[key.slice(0, 1)]
|
|
160
|
-
if (globalTheme) {
|
|
161
|
-
if (key === 'theme' && !props.themeModifier) {
|
|
162
|
-
props.update({
|
|
163
|
-
themeModifier: globalTheme
|
|
164
|
-
}, {
|
|
165
|
-
preventListeners: true,
|
|
166
|
-
preventRecursive: true,
|
|
167
|
-
isForced: true,
|
|
168
|
-
preventDefineUpdate: true
|
|
169
|
-
})
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
if (setter) setter(key, props[key], CLASS_NAMES, element)
|
|
173
|
-
else if (key === 'class') {
|
|
174
|
-
const value = element.props.class
|
|
175
|
-
if (!element.call('isString', value)) return
|
|
176
|
-
const classArr = value.split(' ')
|
|
177
|
-
const scratchClasses = ctx.designSystem.CLASS
|
|
178
|
-
CLASS_NAMES.class = classArr.reduce((accumulator, current) => {
|
|
179
|
-
const scratchClass = scratchClasses[current]
|
|
180
|
-
return merge(accumulator, scratchClass)
|
|
181
|
-
}, {})
|
|
182
|
-
} else if (key === 'true') applyTrueProps(props[key], CLASS_NAMES, element)
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// override props
|
|
186
|
-
// if (props['^']) {
|
|
187
|
-
// for (const key in props['^']) {
|
|
188
|
-
// execClass(key, props, CLASS_NAMES, element)
|
|
189
|
-
// }
|
|
190
|
-
// }
|
|
191
|
-
|
|
192
|
-
const parentProps = element.parent && element.parent.props
|
|
193
|
-
if (parentProps && parentProps.spacingRatio && parentProps.inheritSpacingRatio) {
|
|
194
|
-
element.setProps({
|
|
195
|
-
spacingRatio: parentProps.spacingRatio,
|
|
196
|
-
inheritSpacingRatio: true
|
|
197
|
-
}, {
|
|
198
|
-
preventListeners: true,
|
|
199
|
-
preventRecursive: true,
|
|
200
|
-
isForced: true,
|
|
201
|
-
preventDefineUpdate: true
|
|
202
|
-
})
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
overwriteShallow(className, CLASS_NAMES)
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
export const Media = {
|
|
209
|
-
class: {
|
|
210
|
-
case: (el, s) => {
|
|
211
|
-
return {
|
|
212
|
-
//
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
on: { beforeClassAssign }
|
|
217
|
-
}
|
package/Overflow.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
export const Overflow = {
|
|
4
|
-
class: {
|
|
5
|
-
overflow: ({ props, deps }) => !deps.isUndefined(props.overflow) && ({
|
|
6
|
-
overflow: props.overflow,
|
|
7
|
-
scrollBehavior: 'smooth'
|
|
8
|
-
}),
|
|
9
|
-
overflowX: ({ props, deps }) => !deps.isUndefined(props.overflowX) && ({
|
|
10
|
-
overflowX: props.overflowX
|
|
11
|
-
}),
|
|
12
|
-
overflowY: ({ props, deps }) => !deps.isUndefined(props.overflowY) && ({
|
|
13
|
-
overflowY: props.overflowY
|
|
14
|
-
}),
|
|
15
|
-
overscrollBehavior: ({ props, deps }) => !deps.isUndefined(props.overscrollBehavior) && ({
|
|
16
|
-
overscrollBehavior: props.overscrollBehavior
|
|
17
|
-
})
|
|
18
|
-
}
|
|
19
|
-
}
|
package/Position.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { getSpacingByKey } from '@symbo.ls/scratch'
|
|
4
|
-
|
|
5
|
-
export const Position = {
|
|
6
|
-
deps: { getSpacingByKey },
|
|
7
|
-
|
|
8
|
-
class: {
|
|
9
|
-
position: ({ props }) => props.position && ({ position: props.position }),
|
|
10
|
-
inset: ({ props, deps, context }) => {
|
|
11
|
-
const { inset } = props
|
|
12
|
-
if (context.utils.isNumber(inset)) return ({ inset })
|
|
13
|
-
if (!context.utils.isString(inset)) return
|
|
14
|
-
return { inset: inset.split(' ').map(v => deps.getSpacingByKey(v, 'k').k).join(' ') }
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
left: ({ props, deps }) => deps.getSpacingByKey(props.left, 'left'),
|
|
18
|
-
top: ({ props, deps }) => deps.getSpacingByKey(props.top, 'top'),
|
|
19
|
-
right: ({ props, deps }) => deps.getSpacingByKey(props.right, 'right'),
|
|
20
|
-
bottom: ({ props, deps }) => deps.getSpacingByKey(props.bottom, 'bottom'),
|
|
21
|
-
|
|
22
|
-
verticalInset: ({ props, deps }) => {
|
|
23
|
-
const { verticalInset } = props
|
|
24
|
-
if (typeof verticalInset !== 'string') return
|
|
25
|
-
const vi = verticalInset.split(' ').map(v => deps.getSpacingByKey(v, 'k').k)
|
|
26
|
-
return {
|
|
27
|
-
top: vi[0],
|
|
28
|
-
bottom: vi[1] || vi[0]
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
horizontalInset: ({ props, deps }) => {
|
|
33
|
-
const { horizontalInset } = props
|
|
34
|
-
if (typeof horizontalInset !== 'string') return
|
|
35
|
-
const vi = horizontalInset.split(' ').map(v => deps.getSpacingByKey(v, 'k').k)
|
|
36
|
-
return {
|
|
37
|
-
left: vi[0],
|
|
38
|
-
right: vi[1] || vi[0]
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
package/Pseudo.js
DELETED
package/Timing.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
getTimingFunction,
|
|
5
|
-
splitTransition,
|
|
6
|
-
transformDuration
|
|
7
|
-
} from '@symbo.ls/scratch'
|
|
8
|
-
|
|
9
|
-
import { isUndefined } from '@domql/utils'
|
|
10
|
-
|
|
11
|
-
export const Timing = {
|
|
12
|
-
deps: {
|
|
13
|
-
getTimingFunction,
|
|
14
|
-
splitTransition,
|
|
15
|
-
transformDuration
|
|
16
|
-
},
|
|
17
|
-
|
|
18
|
-
class: {
|
|
19
|
-
transition: ({ props, deps }) => !isUndefined(props.transition) && ({
|
|
20
|
-
transition: deps.splitTransition(props.transition)
|
|
21
|
-
}),
|
|
22
|
-
willChange: ({ props }) => !isUndefined(props.willChange) && ({
|
|
23
|
-
willChange: props.willChange
|
|
24
|
-
}),
|
|
25
|
-
transitionDuration: ({ props, deps }) => !isUndefined(props.transitionDuration) && ({
|
|
26
|
-
transitionDuration: deps.transformDuration(props.transitionDuration)
|
|
27
|
-
}),
|
|
28
|
-
transitionDelay: ({ props, deps }) => !isUndefined(props.transitionDelay) && ({
|
|
29
|
-
transitionDelay: deps.transformDuration(props.transitionDelay)
|
|
30
|
-
}),
|
|
31
|
-
transitionTimingFunction: ({ props, deps }) => !isUndefined(props.transitionTimingFunction) && ({
|
|
32
|
-
transitionTimingFunction: deps.getTimingFunction(props.transitionTimingFunction)
|
|
33
|
-
}),
|
|
34
|
-
transitionProperty: ({ props }) => !isUndefined(props.transitionProperty) && ({
|
|
35
|
-
transitionProperty: props.transitionProperty,
|
|
36
|
-
willChange: props.transitionProperty
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
}
|
package/Transform.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { isUndefined } from '@domql/utils'
|
|
4
|
-
|
|
5
|
-
export const Transform = {
|
|
6
|
-
class: {
|
|
7
|
-
zoom: ({ props }) => !isUndefined(props.zoom) && ({ zoom: props.zoom }),
|
|
8
|
-
transform: ({ props }) => !isUndefined(props.transform) && ({ transform: props.transform }),
|
|
9
|
-
transformOrigin: ({ props }) => !isUndefined(props.transformOrigin) && ({ transformOrigin: props.transformOrigin }),
|
|
10
|
-
backfaceVisibility: ({ props }) => !isUndefined(props.backfaceVisibility) && ({ backfaceVisibility: props.backfaceVisibility })
|
|
11
|
-
}
|
|
12
|
-
}
|
package/XYZ.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { isUndefined } from '@domql/utils'
|
|
4
|
-
|
|
5
|
-
export const XYZ = {
|
|
6
|
-
class: {
|
|
7
|
-
zIndex: ({ props }) => !isUndefined(props.zIndex) && ({ zIndex: props.zIndex }),
|
|
8
|
-
perspective: ({ props }) => !isUndefined(props.perspective) && ({ perspective: props.perspective }),
|
|
9
|
-
perspectiveOrigin: ({ props }) => !isUndefined(props.perspectiveOrigin) && ({ perspectiveOrigin: props.perspectiveOrigin })
|
|
10
|
-
}
|
|
11
|
-
}
|