@domql/emotion 3.0.1 → 3.0.6
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/index.js +19 -9
- package/package.json +3 -3
package/index.js
CHANGED
|
@@ -5,26 +5,36 @@ import { isObjectLike, isString, isNumber, isBoolean, exec } from '@domql/utils'
|
|
|
5
5
|
import { applyClassListOnNode } from '@domql/classlist'
|
|
6
6
|
import createEmotion from '@emotion/css/create-instance'
|
|
7
7
|
|
|
8
|
-
export const transformEmotionStyle =
|
|
8
|
+
export const transformEmotionStyle = emotion => {
|
|
9
9
|
return (params, element, state) => {
|
|
10
10
|
const execParams = exec(params, element)
|
|
11
11
|
if (params) {
|
|
12
|
-
if (isObjectLike(element.
|
|
13
|
-
|
|
12
|
+
if (isObjectLike(element.classlist))
|
|
13
|
+
element.classlist.elementStyle = execParams
|
|
14
|
+
else element.classlist = { elementStyle: execParams }
|
|
14
15
|
}
|
|
15
|
-
transformEmotionClass(emotion)(
|
|
16
|
+
transformEmotionClass(emotion)(
|
|
17
|
+
element.classlist,
|
|
18
|
+
element,
|
|
19
|
+
element.state,
|
|
20
|
+
true
|
|
21
|
+
)
|
|
16
22
|
}
|
|
17
23
|
}
|
|
18
24
|
|
|
19
|
-
export const transformEmotionClass =
|
|
25
|
+
export const transformEmotionClass = emotion => {
|
|
20
26
|
return (params, element, state, flag) => {
|
|
21
27
|
if (element.style && !flag) return
|
|
22
28
|
const { __ref } = element
|
|
23
29
|
const { __class, __classNames } = __ref
|
|
24
30
|
|
|
25
31
|
if (!isObjectLike(params)) return
|
|
26
|
-
if (element.props.class) {
|
|
27
|
-
|
|
32
|
+
if (element.props.class) {
|
|
33
|
+
__classNames.classProps = element.props.class
|
|
34
|
+
}
|
|
35
|
+
if (element.attr?.class) {
|
|
36
|
+
__classNames.class = element.attr.class
|
|
37
|
+
}
|
|
28
38
|
|
|
29
39
|
// for (const key in params) {
|
|
30
40
|
// const prop = exec(params[key], element)
|
|
@@ -58,7 +68,7 @@ export const transformDOMQLEmotion = (emotion, options) => {
|
|
|
58
68
|
if (!emotion) emotion = createEmotion(options || { key: 'smbls' })
|
|
59
69
|
|
|
60
70
|
return {
|
|
61
|
-
|
|
62
|
-
|
|
71
|
+
styles: transformEmotionStyle(emotion),
|
|
72
|
+
classlist: transformEmotionClass(emotion)
|
|
63
73
|
}
|
|
64
74
|
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/emotion",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.6",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@domql/classlist": "latest",
|
|
8
|
-
"@domql/utils": "^3.0.
|
|
8
|
+
"@domql/utils": "^3.0.6"
|
|
9
9
|
},
|
|
10
10
|
"peerDependencies": {
|
|
11
11
|
"@emotion/css": "*"
|
|
12
12
|
},
|
|
13
|
-
"gitHead": "
|
|
13
|
+
"gitHead": "ef6f7abdb0a8cdaa28559e377bc10a12e76ef8f0",
|
|
14
14
|
"source": "index.js"
|
|
15
15
|
}
|