@domql/emotion 3.2.3 → 3.2.7
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/dist/cjs/index.js +17 -0
- package/dist/esm/index.js +1 -0
- package/dist/iife/index.js +27 -0
- package/index.js +2 -73
- package/package.json +31 -7
- package/classList.js +0 -54
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __copyProps = (to, from, except, desc) => {
|
|
6
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
7
|
+
for (let key of __getOwnPropNames(from))
|
|
8
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
9
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
10
|
+
}
|
|
11
|
+
return to;
|
|
12
|
+
};
|
|
13
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
+
var index_exports = {};
|
|
16
|
+
module.exports = __toCommonJS(index_exports);
|
|
17
|
+
__reExport(index_exports, require("@symbo.ls/emotion"), module.exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@symbo.ls/emotion";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var DomqlEmotion = (() => {
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
7
|
+
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
8
|
+
}) : x)(function(x) {
|
|
9
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
10
|
+
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
11
|
+
});
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
|
|
23
|
+
// index.js
|
|
24
|
+
var index_exports = {};
|
|
25
|
+
__reExport(index_exports, __require("@symbo.ls/emotion"));
|
|
26
|
+
return __toCommonJS(index_exports);
|
|
27
|
+
})();
|
package/index.js
CHANGED
|
@@ -1,73 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
// import DOM from '../../src'
|
|
4
|
-
import { isObjectLike, isString, isNumber, isBoolean, exec } from '@domql/utils'
|
|
5
|
-
import { applyClassListOnNode } from './classList'
|
|
6
|
-
import createEmotion from '@emotion/css/create-instance'
|
|
7
|
-
|
|
8
|
-
export const transformEmotionStyle = emotion => {
|
|
9
|
-
return (params, element, state) => {
|
|
10
|
-
const execParams = exec(params, element)
|
|
11
|
-
if (params) {
|
|
12
|
-
const { __ref: ref } = element
|
|
13
|
-
ref.__class.style = execParams
|
|
14
|
-
}
|
|
15
|
-
transformEmotionClass(emotion)(
|
|
16
|
-
element.classlist,
|
|
17
|
-
element,
|
|
18
|
-
element.state,
|
|
19
|
-
true
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const transformEmotionClass = emotion => {
|
|
25
|
-
return (params, element, state, flag) => {
|
|
26
|
-
if (element.style && !flag) return
|
|
27
|
-
const { __ref } = element
|
|
28
|
-
const { __class, __classNames } = __ref
|
|
29
|
-
|
|
30
|
-
if (!isObjectLike(params)) return
|
|
31
|
-
if (element.props.class) {
|
|
32
|
-
__classNames.classProps = element.props.class
|
|
33
|
-
}
|
|
34
|
-
if (element.attr?.class) {
|
|
35
|
-
__classNames.class = element.attr.class
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// for (const key in params) {
|
|
39
|
-
// const prop = exec(params[key], element)
|
|
40
|
-
|
|
41
|
-
// if (!prop) {
|
|
42
|
-
// delete __class[key]
|
|
43
|
-
// continue
|
|
44
|
-
// }
|
|
45
|
-
// }
|
|
46
|
-
|
|
47
|
-
for (const key in __class) {
|
|
48
|
-
const prop = __class[key]
|
|
49
|
-
if (!prop) {
|
|
50
|
-
delete __classNames[key]
|
|
51
|
-
continue
|
|
52
|
-
}
|
|
53
|
-
// console.log(prop, key, element)
|
|
54
|
-
let className
|
|
55
|
-
if (isString(prop) || isNumber(prop)) className = prop
|
|
56
|
-
else if (isBoolean(prop)) className = element.key
|
|
57
|
-
else className = emotion.css(prop)
|
|
58
|
-
// console.log(className)
|
|
59
|
-
__classNames[key] = className
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
applyClassListOnNode(__classNames, element, element.node)
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export const transformDOMQLEmotion = (emotion, options) => {
|
|
67
|
-
if (!emotion) emotion = createEmotion(options || { key: 'smbls' })
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
style: transformEmotionStyle(emotion),
|
|
71
|
-
classlist: transformEmotionClass(emotion)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
1
|
+
// @deprecated — use @symbo.ls/emotion instead
|
|
2
|
+
export * from '@symbo.ls/emotion'
|
package/package.json
CHANGED
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/emotion",
|
|
3
|
-
"version": "3.2.
|
|
4
|
-
"main": "index.js",
|
|
3
|
+
"version": "3.2.7",
|
|
4
|
+
"main": "./dist/cjs/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
+
"deprecated": "Use @symbo.ls/emotion instead",
|
|
6
7
|
"dependencies": {
|
|
7
|
-
"@
|
|
8
|
-
},
|
|
9
|
-
"peerDependencies": {
|
|
10
|
-
"@emotion/css": "*"
|
|
8
|
+
"@symbo.ls/emotion": "^3.2.3"
|
|
11
9
|
},
|
|
12
10
|
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
|
|
13
|
-
"source": "index.js"
|
|
11
|
+
"source": "index.js",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"module": "./dist/esm/index.js",
|
|
14
|
+
"browser": "./dist/iife/index.js",
|
|
15
|
+
"unpkg": "./dist/iife/index.js",
|
|
16
|
+
"jsdelivr": "./dist/iife/index.js",
|
|
17
|
+
"sideEffects": false,
|
|
18
|
+
"exports": {
|
|
19
|
+
".": {
|
|
20
|
+
"import": "./dist/esm/index.js",
|
|
21
|
+
"require": "./dist/cjs/index.js",
|
|
22
|
+
"browser": "./dist/iife/index.js",
|
|
23
|
+
"default": "./dist/esm/index.js"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist",
|
|
28
|
+
"*.js"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build:esm": "cross-env NODE_ENV=$NODE_ENV esbuild index.js --target=es2020 --format=esm --outdir=dist/esm --define:process.env.NODE_ENV=process.env.NODE_ENV",
|
|
32
|
+
"build:cjs": "cross-env NODE_ENV=$NODE_ENV esbuild index.js --target=node18 --format=cjs --outdir=dist/cjs --define:process.env.NODE_ENV=process.env.NODE_ENV",
|
|
33
|
+
"build:iife": "cross-env NODE_ENV=$NODE_ENV esbuild index.js --bundle --target=es2020 --format=iife --global-name=DomqlEmotion --outfile=dist/iife/index.js --define:process.env.NODE_ENV=process.env.NODE_ENV --external:@symbo.ls/emotion",
|
|
34
|
+
"build": "node ../../build/build.js",
|
|
35
|
+
"copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
|
|
36
|
+
"prepublish": "npm run build && npm run copy:package:cjs"
|
|
37
|
+
}
|
|
14
38
|
}
|
package/classList.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { exec, isObject, isString } from '@domql/utils'
|
|
4
|
-
|
|
5
|
-
export const assignKeyAsClassname = element => {
|
|
6
|
-
const { key } = element
|
|
7
|
-
if (element.classlist === true) element.classlist = key
|
|
8
|
-
else if (
|
|
9
|
-
!element.classlist &&
|
|
10
|
-
typeof key === 'string' &&
|
|
11
|
-
key.charAt(0) === '_' &&
|
|
12
|
-
key.charAt(1) !== '_'
|
|
13
|
-
) {
|
|
14
|
-
element.classlist = key.slice(1)
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// stringifies class object
|
|
19
|
-
export const classify = (obj, element) => {
|
|
20
|
-
let className = ''
|
|
21
|
-
for (const item in obj) {
|
|
22
|
-
const param = obj[item]
|
|
23
|
-
if (typeof param === 'boolean' && param) className += ` ${item}`
|
|
24
|
-
else if (typeof param === 'string') className += ` ${param}`
|
|
25
|
-
else if (typeof param === 'function') {
|
|
26
|
-
className += ` ${exec(param, element)}`
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return className
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const classList = (params, element) => {
|
|
33
|
-
if (!params) return
|
|
34
|
-
const { key } = element
|
|
35
|
-
if (params === true) params = element.classlist = { key }
|
|
36
|
-
if (isString(params)) params = element.classlist = { default: params }
|
|
37
|
-
if (isObject(params)) params = classify(params, element)
|
|
38
|
-
// TODO: fails on string
|
|
39
|
-
const className = params.replace(/\s+/g, ' ').trim()
|
|
40
|
-
return className
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// LEGACY (still needed in old domql)
|
|
44
|
-
export const applyClassListOnNode = (params, element, node) => {
|
|
45
|
-
const className = classList(params, element)
|
|
46
|
-
node.classList = className
|
|
47
|
-
return className
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export function applyClasslist (params, element, node) {
|
|
51
|
-
applyClassListOnNode(params, element, node)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export default applyClasslist
|