@symbo.ls/atoms 2.11.522 → 3.0.1

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/Theme.js CHANGED
@@ -1,17 +1,7 @@
1
1
  'use strict'
2
2
 
3
- import {
4
- getMediaTheme,
5
- getMediaColor,
6
- transformTextStroke,
7
- transformShadow,
8
- transformBoxShadow,
9
- transformBorder,
10
- transformBackgroundImage
11
- } from '@symbo.ls/scratch'
12
-
13
3
  import { depth } from './Shape/style'
14
- import { isUndefined, isString } from '@domql/utils'
4
+ import { isUndefined } from '@domql/utils'
15
5
 
16
6
  export const getSystemGlobalTheme = ({ context, state }) => {
17
7
  const rootState = state && state.root
@@ -20,185 +10,10 @@ export const getSystemGlobalTheme = ({ context, state }) => {
20
10
 
21
11
  export const Theme = {
22
12
  deps: {
23
- depth,
24
- getSystemGlobalTheme,
25
- getMediaTheme,
26
- getMediaColor,
27
- transformTextStroke,
28
- transformShadow,
29
- transformBoxShadow,
30
- transformBorder,
31
- transformBackgroundImage
13
+ depth
32
14
  },
33
15
 
34
16
  class: {
35
- depth: ({ props, deps }) => !isUndefined(props.depth) && deps.depth[props.depth],
36
-
37
- theme: (element) => {
38
- const { props, deps } = element
39
- const globalTheme = deps.getSystemGlobalTheme(element)
40
- if (!props.theme) return
41
- const hasSubtheme = props.theme.includes(' ') && !props.theme.includes('@')
42
- const globalThemeForced = `@${props.themeModifier || globalTheme}`
43
- if (hasSubtheme) {
44
- const themeAppliedInVal = props.theme.split(' ')
45
- themeAppliedInVal.splice(1, 0, globalThemeForced)
46
- return deps.getMediaTheme(themeAppliedInVal)
47
- } else if (props.theme.includes('@{globalTheme}')) props.theme.replace('@{globalTheme}', globalThemeForced)
48
- return deps.getMediaTheme(props.theme, `@${props.themeModifier || globalTheme}`)
49
- },
50
-
51
- color: (element) => {
52
- const { props, deps } = element
53
- const globalTheme = deps.getSystemGlobalTheme(element)
54
- if (!props.color) return
55
- return {
56
- color: deps.getMediaColor(props.color, globalTheme)
57
- }
58
- },
59
-
60
- background: (element) => {
61
- const { props, deps } = element
62
- const globalTheme = deps.getSystemGlobalTheme(element)
63
- if (!props.background) return
64
- return {
65
- background: deps.getMediaColor(props.background, globalTheme)
66
- }
67
- },
68
-
69
- backgroundColor: (element) => {
70
- const { props, deps } = element
71
- const globalTheme = deps.getSystemGlobalTheme(element)
72
- if (!props.backgroundColor) return
73
- return {
74
- backgroundColor: deps.getMediaColor(props.backgroundColor, globalTheme)
75
- }
76
- },
77
-
78
- backgroundImage: (element, s, context) => {
79
- const { props, deps } = element
80
- const globalTheme = deps.getSystemGlobalTheme(element)
81
- let val = props.backgroundImage
82
- if (!val) return
83
- const file = context.files && context.files[val]
84
- if (file && file.content) val = file.content.src
85
- return ({
86
- backgroundImage: deps.transformBackgroundImage(val, globalTheme)
87
- })
88
- },
89
- backgroundSize: ({ props }) => !isUndefined(props.backgroundSize)
90
- ? ({
91
- backgroundSize: props.backgroundSize
92
- })
93
- : null,
94
- backgroundPosition: ({ props }) => !isUndefined(props.backgroundPosition)
95
- ? ({
96
- backgroundPosition: props.backgroundPosition
97
- })
98
- : null,
99
- backgroundRepeat: ({ props }) => !isUndefined(props.backgroundRepeat)
100
- ? ({
101
- backgroundRepeat: props.backgroundRepeat
102
- })
103
- : null,
104
-
105
- textStroke: ({ props, deps }) => !isUndefined(props.textStroke)
106
- ? ({
107
- WebkitTextStroke: deps.transformTextStroke(props.textStroke)
108
- })
109
- : null,
110
-
111
- outline: ({ props, deps }) => !isUndefined(props.outline) && ({
112
- outline: deps.transformBorder(props.outline)
113
- }),
114
- outlineOffset: ({ props, deps }) => deps.transformSizeRatio('outlineOffset', props),
115
-
116
- border: ({ props, deps }) => !isUndefined(props.border) && ({
117
- border: deps.transformBorder(props.border)
118
- }),
119
-
120
- borderColor: (element) => {
121
- const { props, deps } = element
122
- const globalTheme = deps.getSystemGlobalTheme(element)
123
- if (!props.borderColor) return
124
- return {
125
- borderColor: deps.getMediaColor(props.borderColor, globalTheme)
126
- }
127
- },
128
- borderStyle: ({ props }) => !isUndefined(props.borderStyle) && ({
129
- borderStyle: props.borderStyle
130
- }),
131
-
132
- borderLeft: ({ props, deps }) => !isUndefined(props.borderLeft) && ({
133
- borderLeft: deps.transformBorder(props.borderLeft)
134
- }),
135
- borderTop: ({ props, deps }) => !isUndefined(props.borderTop) && ({
136
- borderTop: deps.transformBorder(props.borderTop)
137
- }),
138
- borderRight: ({ props, deps }) => !isUndefined(props.borderRight) && ({
139
- borderRight: deps.transformBorder(props.borderRight)
140
- }),
141
- borderBottom: ({ props, deps }) => !isUndefined(props.borderBottom) && ({
142
- borderBottom: deps.transformBorder(props.borderBottom)
143
- }),
144
-
145
- shadow: (element) => {
146
- const { props, deps } = element
147
- const globalTheme = deps.getSystemGlobalTheme(element)
148
- if (!props.backgroundImage) return
149
- return ({
150
- boxShadow: deps.transformShadow(props.shadow, globalTheme)
151
- })
152
- },
153
-
154
- // boxShadow: ({ props, deps }) => isString(props.boxShadow) && ({
155
- // boxShadow: deps.transformBoxShadow(props.boxShadow)
156
- // }),
157
-
158
- boxShadow: (element, state, context) => {
159
- const { props, deps } = element
160
- if (!isString(props.boxShadow)) return
161
- const [val, hasImportant] = props.boxShadow.split('!importan')
162
- const globalTheme = getSystemGlobalTheme(element)
163
- const important = hasImportant ? ' !important' : ''
164
- return {
165
- boxShadow: deps.transformBoxShadow(val.trim(), globalTheme) + important
166
- }
167
- },
168
-
169
- textShadow: ({ props, deps, context }) => !isUndefined(props.textShadow) && ({
170
- textShadow: deps.transformBoxShadow(props.textShadow, context.designSystem.globalTheme)
171
- }),
172
-
173
- backdropFilter: ({ props, deps }) => !isUndefined(props.backdropFilter) && ({
174
- backdropFilter: props.backdropFilter
175
- }),
176
-
177
- caretColor: ({ props }) => !isUndefined(props.caretColor) && ({
178
- caretColor: props.caretColor
179
- }),
180
-
181
- opacity: ({ props }) => !isUndefined(props.opacity) && ({
182
- opacity: props.opacity
183
- }),
184
- visibility: ({ props }) => !isUndefined(props.visibility) && ({
185
- visibility: props.visibility
186
- }),
187
-
188
- columnRule: ({ props, deps }) => !isUndefined(props.columnRule) && ({
189
- columnRule: deps.transformBorder(props.columnRule)
190
- }),
191
-
192
- filter: ({ props, deps }) => !isUndefined(props.filter) && ({
193
- filter: props.filter
194
- }),
195
-
196
- mixBlendMode: ({ props, deps }) => !isUndefined(props.mixBlendMode) && ({
197
- mixBlendMode: props.mixBlendMode
198
- }),
199
-
200
- appearance: ({ props }) => !isUndefined(props.appearance) && ({
201
- appearance: props.appearance
202
- })
17
+ depth: ({ props, deps }) => !isUndefined(props.depth) && deps.depth[props.depth]
203
18
  }
204
19
  }
package/Video.js CHANGED
@@ -3,7 +3,7 @@
3
3
  export const Video = {
4
4
  tag: 'video',
5
5
 
6
- childExtend: {
6
+ childExtends: {
7
7
  tag: 'source',
8
8
  attr: {
9
9
  src: ({ props }) => props.src,
package/index.js CHANGED
@@ -1,26 +1,14 @@
1
1
  'use strict'
2
2
 
3
3
  export * from './Block'
4
- export * from './Direction'
5
- export * from './Flex'
6
- export * from './Grid'
7
4
  export * from './Img'
8
5
  export * from './Form'
9
- export * from './Media'
10
6
  export * from './Iframe'
11
- export * from './Interaction'
12
7
  export * from './InteractiveComponent'
13
- export * from './Overflow'
14
- export * from './Collection'
15
- export * from './Position'
16
8
  export * from './Picture'
17
- export * from './Pseudo'
18
9
  export * from './Svg'
19
10
  export * from './Shape'
20
11
  export * from './Video'
21
12
  export * from './Theme'
22
13
  export * from './Text'
23
- export * from './Timing'
24
- export * from './Transform'
25
- export * from './XYZ'
26
- export * from './Animation'
14
+ export * from './Box'
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@symbo.ls/atoms",
3
- "version": "2.11.522",
3
+ "version": "3.0.1",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
- "gitHead": "f0cf0f8e16c7cac278886a322e85cb8d8188ca24",
6
+ "gitHead": "a4e7f586f7e4f60bd7b6a8388bdacc3ae1879433",
7
7
  "dependencies": {
8
8
  "@domql/state": "^2.5.0",
9
9
  "@domql/utils": "^2.5.0",
10
- "@symbo.ls/emotion": "^2.11.515",
11
- "@symbo.ls/scratch": "^2.11.522"
10
+ "@symbo.ls/emotion": "^3.0.1",
11
+ "@symbo.ls/scratch": "^3.0.1"
12
12
  },
13
13
  "source": "src/index.js",
14
14
  "devDependencies": {
package/Animation.js DELETED
@@ -1,57 +0,0 @@
1
- 'use strict'
2
-
3
- import { getTimingByKey, getTimingFunction } from '@symbo.ls/scratch'
4
- import { isObject } from '@domql/utils'
5
- import { emotion } from '@symbo.ls/emotion'
6
-
7
- const applyAnimationProps = (animation, element) => {
8
- const { emotion: ctxEmotion } = element.context
9
- const { keyframes } = ctxEmotion || emotion
10
- if (isObject(animation)) return { animationName: keyframes(animation) }
11
- const { ANIMATION } = element.context && element.context.designSystem
12
- const record = ANIMATION[animation]
13
- return keyframes(record)
14
- }
15
-
16
- const props = {
17
- animation: (el) => el.props.animation && {
18
- animationName: el.deps.applyAnimationProps(el.props.animation, el),
19
- animationDuration: el.deps.getTimingByKey(el.props.animationDuration || 'A').timing,
20
- animationDelay: el.deps.getTimingByKey(el.props.animationDelay || '0s').timing,
21
- animationTimingFunction: el.deps.getTimingFunction(el.props.animationTimingFunction || 'ease'),
22
- animationFillMode: el.props.animationFillMode || 'both',
23
- animationPlayState: el.props.animationPlayState,
24
- animationDirection: el.props.animationDirection
25
- },
26
- animationName: (el) => el.props.animationName && {
27
- animationName: el.deps.applyAnimationProps(el.props.animationName, el)
28
- },
29
- animationDuration: ({ props, deps }) => props.animationDuration && ({
30
- animationDuration: deps.getTimingByKey(props.animationDuration).timing
31
- }),
32
- animationDelay: ({ props, deps }) => props.animationDelay && ({
33
- animationDelay: deps.getTimingByKey(props.animationDelay).timing
34
- }),
35
- animationTimingFunction: ({ props, deps }) => props.animationTimingFunction && ({
36
- animationTimingFunction: deps.getTimingFunction(props.animationTimingFunction)
37
- })
38
- }
39
-
40
- export const Animation = {
41
- deps: { isObject, getTimingByKey, getTimingFunction, applyAnimationProps },
42
- class: {
43
- ...props,
44
- animationFillMode: ({ props }) => props.animationFillMode && ({
45
- animationFillMode: props.animationFillMode
46
- }),
47
- animationPlayState: ({ props }) => props.animationPlayState && ({
48
- animationPlayState: props.animationPlayState
49
- }),
50
- animationIterationCount: ({ props }) => props.animationIterationCount && ({
51
- animationIterationCount: props.animationIterationCount || 1
52
- }),
53
- animationDirection: ({ props }) => props.animationDirection && ({
54
- animationDirection: props.animationDirection
55
- })
56
- }
57
- }
package/Collection.js DELETED
@@ -1,210 +0,0 @@
1
- 'use strict'
2
-
3
- import { isState, getChildStateInKey } from '@domql/state'
4
- import { isString, isNumber, isNot, isArray, isObject, isObjectLike, exec, deepClone, addAdditionalExtend } from '@domql/utils'
5
-
6
- export const Collection = {
7
- define: {
8
- $collection: (param, el, state) => {
9
- const { __ref: ref } = el
10
- const { children: childrenProps, childrenAs, childExtends } = (el.props || {})
11
- const children = childrenProps && exec(childrenProps, el, state)
12
-
13
- const childrenAsDefault = childrenAs || 'props'
14
-
15
- if (children) {
16
- if (isObject(children)) {
17
- if (children.$$typeof) return el.call('renderReact', children, el)
18
- param = deepClone(children)
19
- param = Object.keys(param).map(v => {
20
- const val = param[v]
21
- return addAdditionalExtend(v, val)
22
- })
23
- } else if (isArray(children)) {
24
- param = deepClone(children)
25
- if (childrenAsDefault || childrenAsDefault !== 'element') {
26
- param = param.map(v => ({
27
- extend: childExtends,
28
- [childrenAsDefault]: isObjectLike(v) ? v : childrenAsDefault === 'state' ? { value: v } : { text: v }
29
- }))
30
- }
31
- } else if (isString(children) || isNumber(children)) {
32
- el.removeContent()
33
- el.content = { text: param }
34
- return
35
- }
36
- }
37
-
38
- if (!param) return
39
-
40
- const filterReact = param.filter(v => !v.$$typeof)
41
- if (filterReact.length !== param.length) {
42
- const extractedReactComponents = param.filter(v => v.$$typeof)
43
- el.call('renderReact', extractedReactComponents, el)
44
- } param = filterReact
45
-
46
- if (isString(param)) {
47
- if (param === 'state') param = state.parse()
48
- else param = getChildStateInKey(param, state)
49
- }
50
- if (isState(param)) param = param.parse()
51
- if (isNot(param)('array', 'object')) return
52
-
53
- param = deepClone(param)
54
-
55
- if (ref.__collectionCache) {
56
- const equals = JSON.stringify(param) === JSON.stringify(ref.__collectionCache)
57
- if (equals) {
58
- ref.__noCollectionDifference = true
59
- return
60
- } else {
61
- ref.__collectionCache = deepClone(param)
62
- delete ref.__noCollectionDifference
63
- }
64
- } else {
65
- ref.__collectionCache = deepClone(param)
66
- }
67
-
68
- const obj = {
69
- tag: 'fragment',
70
- props: {
71
- ignoreChildProps: true,
72
- childProps: el.props && el.props.childProps
73
- }
74
- }
75
-
76
- for (const key in param) {
77
- const value = param[key]
78
- if (value) obj[key] = isObjectLike(value) ? value : { value }
79
- }
80
-
81
- el.removeContent()
82
- el.content = obj
83
-
84
- // return deepClone(param)
85
- },
86
-
87
- $setCollection: (param, el, state) => {
88
- if (!param) return
89
-
90
- if (isString(param)) {
91
- if (param === 'state') param = state.parse()
92
- else param = getChildStateInKey(param, state)
93
- }
94
-
95
- const data = (isArray(param) ? param : isObject(param) ? Object.values(param) : [])
96
- .map(item => !isObjectLike(item)
97
- ? { props: { value: item } }
98
- : item)
99
-
100
- if (data.length) {
101
- const t = setTimeout(() => {
102
- el.set({ tag: 'fragment', ...data }, { preventDefineUpdate: '$setCollection' })
103
- clearTimeout(t)
104
- })
105
- }
106
-
107
- return data
108
- },
109
-
110
- $stateCollection: (param, el, state, ctx) => {
111
- const { children, childrenAs } = (el.props || {})
112
- if (!param || children || childrenAs) return
113
-
114
- if (isString(param)) {
115
- if (param === 'state') param = state.parse()
116
- else param = getChildStateInKey(param, state)
117
- }
118
- if (isState(param)) param = param.parse()
119
- if (isNot(param)('array', 'object')) return
120
-
121
- const { __ref: ref } = el
122
- param = deepClone(param)
123
-
124
- if (ref.__stateCollectionCache) {
125
- const equals = JSON.stringify(param) === JSON.stringify(ref.__stateCollectionCache)
126
- if (equals) {
127
- ref.__noCollectionDifference = true
128
- return
129
- } else {
130
- ref.__stateCollectionCache = deepClone(param)
131
- delete ref.__noCollectionDifference
132
- }
133
- } else {
134
- ref.__stateCollectionCache = deepClone(param)
135
- }
136
-
137
- const obj = {
138
- tag: 'fragment',
139
- props: {
140
- ignoreChildProps: true,
141
- childProps: el.props && el.props.childProps
142
- }
143
- }
144
-
145
- for (const key in param) {
146
- const value = param[key]
147
- if (value) obj[key] = { state: isObjectLike(value) ? value : { value } }
148
- }
149
-
150
- el.removeContent()
151
- el.content = obj
152
-
153
- // return deepClone(param)
154
- },
155
-
156
- $propsCollection: (param, el, state) => {
157
- const { children, childrenAs } = (el.props || {})
158
- if (!param || children || childrenAs) return
159
-
160
- if (isString(param)) {
161
- if (param === 'state') param = state.parse()
162
- else param = getChildStateInKey(param, state)
163
- }
164
- if (isState(param)) param = param.parse()
165
- if (isNot(param)('array', 'object')) return
166
-
167
- const { __ref: ref } = el
168
- param = deepClone(param)
169
-
170
- if (ref.__propsCollectionCache) {
171
- const equals = JSON.stringify(param) === JSON.stringify(ref.__propsCollectionCache) // eslint-disable-line
172
- if (equals) {
173
- ref.__noCollectionDifference = true
174
- return
175
- } else {
176
- ref.__propsCollectionCache = deepClone(param)
177
- delete ref.__noCollectionDifference
178
- }
179
- } else {
180
- ref.__propsCollectionCache = deepClone(param)
181
- }
182
-
183
- const obj = {
184
- tag: 'fragment',
185
- props: {
186
- ignoreChildProps: true,
187
- childProps: el.props && el.props.childProps
188
- }
189
- }
190
-
191
- for (const key in param) {
192
- const value = param[key]
193
- if (value) obj[key] = { props: isObjectLike(value) ? value : { value } }
194
- }
195
-
196
- el.removeContent()
197
- el.content = obj
198
-
199
- // const set = () => {
200
- // el.set(obj, { preventDefineUpdate: '$propsCollection' })
201
- // }
202
-
203
- // if (el.props && el.props.lazyLoad) {
204
- // window.requestAnimationFrame(set)
205
- // } else set()
206
-
207
- // return deepClone(param)
208
- }
209
- }
210
- }
package/Direction.js DELETED
@@ -1,10 +0,0 @@
1
- 'use strict'
2
-
3
- export const Direction = {
4
- props: {
5
- direction: 'ltr'
6
- },
7
- class: {
8
- direction: ({ props }) => ({ direction: props.direction })
9
- }
10
- }
package/Flex.js DELETED
@@ -1,29 +0,0 @@
1
- 'use strict'
2
-
3
- import { isString } from '@domql/utils'
4
-
5
- export const Flex = {
6
- props: {
7
- display: 'flex'
8
- },
9
-
10
- class: {
11
- flow: ({ props }) => {
12
- const { flow, reverse } = props
13
- if (!isString(flow)) return
14
- let [direction, wrap] = (flow || 'row').split(' ')
15
- if (flow.startsWith('x') || flow === 'row') direction = 'row'
16
- if (flow.startsWith('y') || flow === 'column') direction = 'column'
17
- return {
18
- flexFlow: (direction || '') + (!direction.includes('-reverse') && reverse ? '-reverse' : '') + ' ' + (wrap || '')
19
- }
20
- },
21
-
22
- wrap: ({ props }) => props.wrap && ({ flexWrap: props.wrap }),
23
- align: ({ props }) => {
24
- if (!isString(props.align)) return
25
- const [alignItems, justifyContent] = props.align.split(' ')
26
- return { alignItems, justifyContent }
27
- }
28
- }
29
- }
package/Grid.js DELETED
@@ -1,29 +0,0 @@
1
- 'use strict'
2
-
3
- import { getSpacingBasedOnRatio } from '@symbo.ls/scratch'
4
-
5
- export const Grid = {
6
- deps: { getSpacingBasedOnRatio },
7
-
8
- props: { display: 'grid' },
9
-
10
- class: {
11
- area: ({ props }) => props.area ? ({ gridArea: props.area }) : null,
12
- template: ({ props }) => props.template ? ({ gridTemplate: props.template }) : null,
13
- templateAreas: ({ props }) => props.templateAreas ? ({ gridTemplateAreas: props.templateAreas }) : null,
14
-
15
- column: ({ props }) => props.column ? ({ gridColumn: props.column }) : null,
16
- columns: ({ props }) => props.columns ? ({ gridTemplateColumns: props.columns }) : null,
17
- templateColumns: ({ props }) => props.templateColumns ? ({ gridTemplateColumns: props.templateColumns }) : null,
18
- autoColumns: ({ props }) => props.autoColumns ? ({ gridAutoColumns: props.autoColumns }) : null,
19
- columnStart: ({ props }) => props.columnStart ? ({ gridColumnStart: props.columnStart }) : null,
20
-
21
- row: ({ props }) => props.row ? ({ gridRow: props.row }) : null,
22
- rows: ({ props }) => props.rows ? ({ gridTemplateRows: props.rows }) : null,
23
- templateRows: ({ props }) => props.templateRows ? ({ gridTemplateRows: props.templateRows }) : null,
24
- autoRows: ({ props }) => props.autoRows ? ({ gridAutoRows: props.autoRows }) : null,
25
- rowStart: ({ props }) => props.rowStart ? ({ gridRowStart: props.rowStart }) : null,
26
-
27
- autoFlow: ({ props }) => props.autoFlow ? ({ gridAutoFlow: props.autoFlow }) : null
28
- }
29
- }
package/Interaction.js DELETED
@@ -1,17 +0,0 @@
1
- 'use strict'
2
-
3
- export const Interaction = {
4
- class: {
5
- userSelect: ({ props }) => props.userSelect && ({ userSelect: props.userSelect }),
6
- pointerEvents: ({ props }) => props.pointerEvents && ({ pointerEvents: props.pointerEvents }),
7
- cursor: (el, s, ctx) => {
8
- let val = el.props.cursor
9
- if (!val) return
10
-
11
- const file = ctx.files && ctx.files[val]
12
- if (file && file.content) val = `url(${file.content.src})`
13
-
14
- return ({ cursor: val })
15
- }
16
- }
17
- }