css-in-props 3.8.9 → 3.14.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/README.md +6 -22
- package/dist/cjs/{props/defaults.js → defaults.js} +2 -2
- package/dist/cjs/index.js +19 -2
- package/dist/cjs/package.json +4 -0
- package/dist/cjs/props/animation.js +16 -80
- package/dist/cjs/props/block.js +71 -89
- package/dist/cjs/props/font.js +8 -7
- package/dist/cjs/props/index.js +0 -32
- package/dist/cjs/props/misc.js +9 -8
- package/dist/cjs/props/position.js +17 -14
- package/dist/cjs/props/theme.js +73 -70
- package/dist/cjs/props/timing.js +11 -11
- package/dist/cjs/registry.js +39 -0
- package/dist/cjs/set.js +1 -1
- package/dist/cjs/transform.js +80 -0
- package/index.js +1 -0
- package/package.json +13 -15
- package/src/index.js +4 -4
- package/src/props/animation.js +28 -23
- package/src/props/block.js +49 -57
- package/src/props/flex.js +4 -5
- package/src/props/index.js +18 -19
- package/src/props/misc.js +10 -3
- package/src/props/theme.js +10 -7
- package/src/set.js +11 -4
- package/src/transform/executors.js +60 -52
- package/src/transform/index.js +2 -2
- package/src/transform/transformers.js +85 -23
- package/dist/cjs/_transform.js +0 -30
- package/dist/cjs/props/flex.js +0 -45
- package/dist/cjs/props/grid.js +0 -39
- package/dist/cjs/transform/executors.js +0 -124
- package/dist/cjs/transform/index.js +0 -19
- package/dist/cjs/transform/transformers.js +0 -107
- package/dist/esm/_transform.js +0 -10
- package/dist/esm/emotion.js +0 -9
- package/dist/esm/index.js +0 -4
- package/dist/esm/props/animation.js +0 -101
- package/dist/esm/props/block.js +0 -171
- package/dist/esm/props/defaults.js +0 -321
- package/dist/esm/props/flex.js +0 -25
- package/dist/esm/props/font.js +0 -16
- package/dist/esm/props/grid.js +0 -19
- package/dist/esm/props/index.js +0 -35
- package/dist/esm/props/misc.js +0 -15
- package/dist/esm/props/position.js +0 -31
- package/dist/esm/props/theme.js +0 -134
- package/dist/esm/props/timing.js +0 -26
- package/dist/esm/set.js +0 -9
- package/dist/esm/transform/executors.js +0 -104
- package/dist/esm/transform/index.js +0 -2
- package/dist/esm/transform/transformers.js +0 -87
- package/dist/iife/index.js +0 -1084
- package/src/_transform.js +0 -10
- package/src/emotion.js +0 -9
package/dist/cjs/_transform.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var transform_exports = {};
|
|
20
|
-
__export(transform_exports, {
|
|
21
|
-
transformClassname: () => transformClassname
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(transform_exports);
|
|
24
|
-
var import_utils = require("@domql/utils");
|
|
25
|
-
var import_transform = require("./transform");
|
|
26
|
-
const transformClassname = (element) => {
|
|
27
|
-
const { props } = element;
|
|
28
|
-
if (!(0, import_utils.isObject)(props)) return;
|
|
29
|
-
return (0, import_transform.useCssInProps)(props, element);
|
|
30
|
-
};
|
package/dist/cjs/props/flex.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var flex_exports = {};
|
|
20
|
-
__export(flex_exports, {
|
|
21
|
-
FLEX_PROPS: () => FLEX_PROPS
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(flex_exports);
|
|
24
|
-
var import_utils = require("@domql/utils");
|
|
25
|
-
const FLEX_PROPS = {
|
|
26
|
-
flow: (value, el) => {
|
|
27
|
-
const { props } = el;
|
|
28
|
-
const { reverse } = props;
|
|
29
|
-
if (!(0, import_utils.isString)(value)) return;
|
|
30
|
-
let [direction, wrap] = (value || "row").split(" ");
|
|
31
|
-
if (value.startsWith("x") || value === "row") direction = "row";
|
|
32
|
-
if (value.startsWith("y") || value === "column") direction = "column";
|
|
33
|
-
return {
|
|
34
|
-
display: "flex",
|
|
35
|
-
flexFlow: (direction || "") + (!direction.includes("-reverse") && reverse ? "-reverse" : "") + " " + (wrap || "")
|
|
36
|
-
};
|
|
37
|
-
},
|
|
38
|
-
wrap: (value, { props }) => {
|
|
39
|
-
return { display: "flex", flexWrap: value };
|
|
40
|
-
},
|
|
41
|
-
align: (value, { props }) => {
|
|
42
|
-
const [alignItems, justifyContent] = value.split(" ");
|
|
43
|
-
return { display: "flex", alignItems, justifyContent };
|
|
44
|
-
}
|
|
45
|
-
};
|
package/dist/cjs/props/grid.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var grid_exports = {};
|
|
20
|
-
__export(grid_exports, {
|
|
21
|
-
GRID_PROPS: () => GRID_PROPS
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(grid_exports);
|
|
24
|
-
const GRID_PROPS = {
|
|
25
|
-
area: (value) => ({ gridArea: value }),
|
|
26
|
-
template: (value) => ({ gridTemplate: value }),
|
|
27
|
-
templateAreas: (value) => ({ gridTemplateAreas: value }),
|
|
28
|
-
column: (value) => ({ gridColumn: value }),
|
|
29
|
-
columns: (value) => ({ gridTemplateColumns: value }),
|
|
30
|
-
templateColumns: (value) => ({ gridTemplateColumns: value }),
|
|
31
|
-
autoColumns: (value) => ({ gridAutoColumns: value }),
|
|
32
|
-
columnStart: (value) => ({ gridColumnStart: value }),
|
|
33
|
-
row: (value) => ({ gridRow: value }),
|
|
34
|
-
rows: (value) => ({ gridTemplateRows: value }),
|
|
35
|
-
templateRows: (value) => ({ gridTemplateRows: value }),
|
|
36
|
-
autoRows: (value) => ({ gridAutoRows: value }),
|
|
37
|
-
rowStart: (value) => ({ gridRowStart: value }),
|
|
38
|
-
autoFlow: (value) => ({ gridAutoFlow: value })
|
|
39
|
-
};
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var executors_exports = {};
|
|
20
|
-
__export(executors_exports, {
|
|
21
|
-
exetuteClassPerComponent: () => exetuteClassPerComponent,
|
|
22
|
-
useCssInProps: () => useCssInProps,
|
|
23
|
-
usePropsAsCSS: () => usePropsAsCSS,
|
|
24
|
-
useSelectorsAsCSS: () => useSelectorsAsCSS
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(executors_exports);
|
|
27
|
-
var import_utils = require("@domql/utils");
|
|
28
|
-
var import_props = require("../props");
|
|
29
|
-
var import_defaults = require("../props/defaults");
|
|
30
|
-
var import_transformers = require("./transformers");
|
|
31
|
-
const isProd = (0, import_utils.isProduction)();
|
|
32
|
-
const usePropsAsCSS = (sourceObj, element, opts) => {
|
|
33
|
-
let obj = {};
|
|
34
|
-
const rest = {};
|
|
35
|
-
const setToObj = (key, val) => {
|
|
36
|
-
if (opts.unpack) {
|
|
37
|
-
obj = { ...obj, ...val };
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
obj[key] = val;
|
|
41
|
-
};
|
|
42
|
-
for (const key in sourceObj) {
|
|
43
|
-
const value = sourceObj[key];
|
|
44
|
-
if (key === "class" && element.call("isString", sourceObj.class)) {
|
|
45
|
-
const val = value.split(" ");
|
|
46
|
-
if (val.length) {
|
|
47
|
-
const CLASS = element.context.designSystem.class;
|
|
48
|
-
const result = val.reduce((acc, curr) => (0, import_utils.merge)(acc, CLASS[curr]), {});
|
|
49
|
-
obj.designSystemClass = result;
|
|
50
|
-
}
|
|
51
|
-
} else if (key === "true") {
|
|
52
|
-
const val = (0, import_utils.exec)(value, element);
|
|
53
|
-
(0, import_utils.merge)(obj, (0, import_transformers.applyTrueProps)(val, element));
|
|
54
|
-
} else if (element.classlist[key]) {
|
|
55
|
-
const originalFromClass = element.classlist[key];
|
|
56
|
-
const result = (0, import_utils.isFunction)(originalFromClass) ? originalFromClass(element, element.state, element.context) : originalFromClass;
|
|
57
|
-
if (result) setToObj(key, result);
|
|
58
|
-
if (!isProd && (0, import_utils.isObject)(obj[key])) obj[key].label = key;
|
|
59
|
-
} else if (import_props.CSS_PROPS_REGISTRY[key]) {
|
|
60
|
-
let val = (0, import_utils.exec)(value, element);
|
|
61
|
-
if ((0, import_utils.isArray)(val)) {
|
|
62
|
-
val = val.reduce((a, c) => (0, import_utils.merge)(a, c), {});
|
|
63
|
-
}
|
|
64
|
-
let result = import_props.CSS_PROPS_REGISTRY[key](val, element, element.state, element.context);
|
|
65
|
-
if ((0, import_utils.isArray)(result)) result = result.reduce((a, c) => (0, import_utils.merge)(a, c), {});
|
|
66
|
-
if (result) setToObj(key, result);
|
|
67
|
-
if (!isProd && (0, import_utils.isObject)(obj[key])) obj[key].label = key;
|
|
68
|
-
} else if (import_defaults.DEFAULT_CSS_PROPERTIES_LIST.has(key)) {
|
|
69
|
-
let result = (0, import_utils.exec)(value, element);
|
|
70
|
-
if (typeof result === "string" && result.charCodeAt(0) === 45 && result.charCodeAt(1) === 45) {
|
|
71
|
-
result = `var(${result})`;
|
|
72
|
-
}
|
|
73
|
-
setToObj(key, { [key]: result });
|
|
74
|
-
if (!isProd && (0, import_utils.isObject)(obj[key])) obj[key].label = key;
|
|
75
|
-
} else {
|
|
76
|
-
rest[key] = value;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return [obj, rest];
|
|
80
|
-
};
|
|
81
|
-
const useSelectorsAsCSS = (sourceObj, element) => {
|
|
82
|
-
const obj = {};
|
|
83
|
-
for (const key in sourceObj) {
|
|
84
|
-
const selectroSetter = import_transformers.transformersByPrefix[key.slice(0, 1)];
|
|
85
|
-
if (selectroSetter) {
|
|
86
|
-
const result = selectroSetter(key, sourceObj[key], element);
|
|
87
|
-
if (result) {
|
|
88
|
-
for (const k in result) {
|
|
89
|
-
if (Object.prototype.hasOwnProperty.call(result, k)) {
|
|
90
|
-
if (obj[k] && typeof obj[k] === "object" && typeof result[k] === "object") {
|
|
91
|
-
(0, import_utils.overwriteDeep)(obj[k], result[k]);
|
|
92
|
-
} else {
|
|
93
|
-
obj[k] = result[k];
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
return obj;
|
|
101
|
-
};
|
|
102
|
-
const useCssInProps = (selectorProps, element, opts = { unpack: true }) => {
|
|
103
|
-
const [cssObj, restProps] = usePropsAsCSS(selectorProps, element, opts);
|
|
104
|
-
const selectorsObj = useSelectorsAsCSS(restProps, element);
|
|
105
|
-
let hasSelectors = false;
|
|
106
|
-
for (const _k in selectorsObj) {
|
|
107
|
-
hasSelectors = true;
|
|
108
|
-
break;
|
|
109
|
-
}
|
|
110
|
-
if (hasSelectors) {
|
|
111
|
-
if (opts.unpack) return (0, import_utils.overwrite)(cssObj, selectorsObj);
|
|
112
|
-
cssObj._selectors = selectorsObj;
|
|
113
|
-
}
|
|
114
|
-
return cssObj;
|
|
115
|
-
};
|
|
116
|
-
const exetuteClassPerComponent = (component, element) => {
|
|
117
|
-
const classObj = {};
|
|
118
|
-
if (component.class) {
|
|
119
|
-
for (const classProp in component.class) {
|
|
120
|
-
classObj[classProp] = component.class[classProp](element);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return classObj;
|
|
124
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var transform_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(transform_exports);
|
|
18
|
-
__reExport(transform_exports, require("./executors"), module.exports);
|
|
19
|
-
__reExport(transform_exports, require("./transformers"), module.exports);
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var transformers_exports = {};
|
|
20
|
-
__export(transformers_exports, {
|
|
21
|
-
applyTrueProps: () => applyTrueProps,
|
|
22
|
-
transformersByPrefix: () => transformersByPrefix
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(transformers_exports);
|
|
25
|
-
var import_utils = require("@domql/utils");
|
|
26
|
-
var import_executors = require("./executors");
|
|
27
|
-
const applyMediaProps = (key, selectorProps, element) => {
|
|
28
|
-
const { context } = element;
|
|
29
|
-
if (!context.designSystem?.media) return;
|
|
30
|
-
const mediaValue = context.designSystem.media[key.slice(1)];
|
|
31
|
-
const generatedClass = (0, import_executors.useCssInProps)(selectorProps, element);
|
|
32
|
-
let mediaKey;
|
|
33
|
-
if (!mediaValue) {
|
|
34
|
-
mediaKey = key;
|
|
35
|
-
} else if (mediaValue === "print") {
|
|
36
|
-
mediaKey = "@media print";
|
|
37
|
-
} else if (mediaValue[0] === "(") {
|
|
38
|
-
mediaKey = `@media screen and ${mediaValue}`;
|
|
39
|
-
} else {
|
|
40
|
-
mediaKey = `${mediaValue} &`;
|
|
41
|
-
}
|
|
42
|
-
return { [mediaKey]: generatedClass };
|
|
43
|
-
};
|
|
44
|
-
const applyAndProps = (key, selectorProps, element) => {
|
|
45
|
-
return { [key]: (0, import_executors.useCssInProps)(selectorProps, element) };
|
|
46
|
-
};
|
|
47
|
-
const applySelectorProps = (key, selectorProps, element) => {
|
|
48
|
-
const selectorKey = `&${key}`;
|
|
49
|
-
return { [selectorKey]: (0, import_executors.useCssInProps)(selectorProps, element) };
|
|
50
|
-
};
|
|
51
|
-
const resolveCase = (caseKey, element) => {
|
|
52
|
-
const caseFn = element.context?.cases?.[caseKey];
|
|
53
|
-
if (caseFn === void 0) return void 0;
|
|
54
|
-
if ((0, import_utils.isFunction)(caseFn)) return caseFn.call(element, element);
|
|
55
|
-
return !!caseFn;
|
|
56
|
-
};
|
|
57
|
-
const applyCaseProps = (key, selectorProps, element) => {
|
|
58
|
-
const caseKey = key.slice(1);
|
|
59
|
-
let isCaseTrue = resolveCase(caseKey, element);
|
|
60
|
-
if (isCaseTrue === void 0) {
|
|
61
|
-
isCaseTrue = !!element.props?.[caseKey];
|
|
62
|
-
}
|
|
63
|
-
if (!isCaseTrue) return;
|
|
64
|
-
return (0, import_executors.useCssInProps)(selectorProps, element);
|
|
65
|
-
};
|
|
66
|
-
const applyVariableProps = (key, selectorVal, element) => {
|
|
67
|
-
return { [key]: selectorVal };
|
|
68
|
-
};
|
|
69
|
-
const applyConditionalCaseProps = (key, selectorProps, element) => {
|
|
70
|
-
const caseKey = key.slice(1);
|
|
71
|
-
let isCaseTrue = element.props[caseKey] === true || element.state[caseKey] || element[caseKey];
|
|
72
|
-
if (!isCaseTrue) {
|
|
73
|
-
const caseResult = resolveCase(caseKey, element);
|
|
74
|
-
if (caseResult !== void 0) isCaseTrue = caseResult;
|
|
75
|
-
}
|
|
76
|
-
if (!isCaseTrue) return;
|
|
77
|
-
return (0, import_executors.useCssInProps)(selectorProps, element);
|
|
78
|
-
};
|
|
79
|
-
const applyConditionalFalsyProps = (key, selectorProps, element) => {
|
|
80
|
-
const caseKey = key.slice(1);
|
|
81
|
-
let isCaseTrue = element.props[caseKey] === true || element.state[caseKey] || element[caseKey];
|
|
82
|
-
if (!isCaseTrue) {
|
|
83
|
-
const caseResult = resolveCase(caseKey, element);
|
|
84
|
-
if (caseResult !== void 0) isCaseTrue = caseResult;
|
|
85
|
-
}
|
|
86
|
-
if (isCaseTrue) return;
|
|
87
|
-
return (0, import_executors.useCssInProps)(selectorProps, element);
|
|
88
|
-
};
|
|
89
|
-
const applyTrueProps = (selectorProps, element) => {
|
|
90
|
-
return (0, import_executors.useCssInProps)(selectorProps, element);
|
|
91
|
-
};
|
|
92
|
-
const transformersByPrefix = {
|
|
93
|
-
"@": applyMediaProps,
|
|
94
|
-
// Selector handlers
|
|
95
|
-
":": applySelectorProps,
|
|
96
|
-
"[": applySelectorProps,
|
|
97
|
-
"*": applySelectorProps,
|
|
98
|
-
"+": applySelectorProps,
|
|
99
|
-
"~": applySelectorProps,
|
|
100
|
-
"&": applyAndProps,
|
|
101
|
-
">": applyAndProps,
|
|
102
|
-
// Conditional and variable handlers
|
|
103
|
-
$: applyCaseProps,
|
|
104
|
-
"-": applyVariableProps,
|
|
105
|
-
".": applyConditionalCaseProps,
|
|
106
|
-
"!": applyConditionalFalsyProps
|
|
107
|
-
};
|
package/dist/esm/_transform.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { isObject } from "@domql/utils";
|
|
2
|
-
import { useCssInProps } from "./transform";
|
|
3
|
-
const transformClassname = (element) => {
|
|
4
|
-
const { props } = element;
|
|
5
|
-
if (!isObject(props)) return;
|
|
6
|
-
return useCssInProps(props, element);
|
|
7
|
-
};
|
|
8
|
-
export {
|
|
9
|
-
transformClassname
|
|
10
|
-
};
|
package/dist/esm/emotion.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { isFunction } from "@domql/utils";
|
|
2
|
-
import { emotion } from "@symbo.ls/emotion";
|
|
3
|
-
const { css } = emotion;
|
|
4
|
-
const transformEmotion = (props, callback) => {
|
|
5
|
-
return isFunction(callback) ? callback(props) : css(props);
|
|
6
|
-
};
|
|
7
|
-
export {
|
|
8
|
-
transformEmotion
|
|
9
|
-
};
|
package/dist/esm/index.js
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { isObject, isString } from "@domql/utils";
|
|
2
|
-
import { emotion } from "@symbo.ls/emotion";
|
|
3
|
-
import { getTimingByKey, getTimingFunction } from "@symbo.ls/scratch";
|
|
4
|
-
const TIMING_FUNCTIONS = ["ease", "linear", "ease-in", "ease-out", "ease-in-out", "step-start", "step-end"];
|
|
5
|
-
const FILL_MODES = ["none", "forwards", "backwards", "both"];
|
|
6
|
-
const DIRECTIONS = ["normal", "reverse", "alternate", "alternate-reverse"];
|
|
7
|
-
const PLAY_STATES = ["running", "paused"];
|
|
8
|
-
const isDuration = (v) => /^[\d.]+m?s$/.test(v);
|
|
9
|
-
const applyAnimationProps = (animation, element) => {
|
|
10
|
-
const { emotion: ctxEmotion } = element.context;
|
|
11
|
-
const { keyframes } = ctxEmotion || emotion;
|
|
12
|
-
if (isObject(animation)) return { animationName: keyframes(animation) };
|
|
13
|
-
const { ANIMATION } = element.context && element.context.designSystem;
|
|
14
|
-
const record = ANIMATION[animation];
|
|
15
|
-
return keyframes(record);
|
|
16
|
-
};
|
|
17
|
-
const parseAnimationShorthand = (val, el) => {
|
|
18
|
-
const { ANIMATION } = el.context && el.context.designSystem || {};
|
|
19
|
-
const tokens = val.split(/\s+/);
|
|
20
|
-
let name = null;
|
|
21
|
-
const durations = [];
|
|
22
|
-
let timingFunction = null;
|
|
23
|
-
let iterationCount = null;
|
|
24
|
-
let direction = null;
|
|
25
|
-
let fillMode = null;
|
|
26
|
-
let playState = null;
|
|
27
|
-
for (const token of tokens) {
|
|
28
|
-
if (ANIMATION && ANIMATION[token]) {
|
|
29
|
-
name = token;
|
|
30
|
-
} else if (isDuration(token)) {
|
|
31
|
-
durations.push(token);
|
|
32
|
-
} else if (TIMING_FUNCTIONS.includes(token) || token.startsWith("cubic-bezier") || token.startsWith("steps(")) {
|
|
33
|
-
timingFunction = token;
|
|
34
|
-
} else if (token === "infinite" || /^\d+$/.test(token)) {
|
|
35
|
-
iterationCount = token === "infinite" ? token : Number(token);
|
|
36
|
-
} else if (DIRECTIONS.includes(token)) {
|
|
37
|
-
direction = token;
|
|
38
|
-
} else if (FILL_MODES.includes(token)) {
|
|
39
|
-
fillMode = token;
|
|
40
|
-
} else if (PLAY_STATES.includes(token)) {
|
|
41
|
-
playState = token;
|
|
42
|
-
} else if (!name) {
|
|
43
|
-
name = token;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
return { name, durations, timingFunction, iterationCount, direction, fillMode, playState };
|
|
47
|
-
};
|
|
48
|
-
const ANIMATION_PROPS = {
|
|
49
|
-
animation: (val, el) => {
|
|
50
|
-
if (isString(val) && val.includes(" ")) {
|
|
51
|
-
const parsed = parseAnimationShorthand(val, el);
|
|
52
|
-
return {
|
|
53
|
-
animationName: applyAnimationProps(parsed.name || val, el),
|
|
54
|
-
animationDuration: parsed.durations[0] || getTimingByKey(el.props.animationDuration || "A").timing,
|
|
55
|
-
animationDelay: parsed.durations[1] || getTimingByKey(el.props.animationDelay || "0s").timing,
|
|
56
|
-
animationTimingFunction: parsed.timingFunction || getTimingFunction(el.props.animationTimingFunction || "ease"),
|
|
57
|
-
animationFillMode: parsed.fillMode || el.props.animationFillMode || "both",
|
|
58
|
-
animationIterationCount: parsed.iterationCount != null ? parsed.iterationCount : el.props.animationIterationCount || 1,
|
|
59
|
-
animationPlayState: parsed.playState || el.props.animationPlayState,
|
|
60
|
-
animationDirection: parsed.direction || el.props.animationDirection
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
animationName: applyAnimationProps(val, el),
|
|
65
|
-
animationDuration: getTimingByKey(el.props.animationDuration || "A").timing,
|
|
66
|
-
animationDelay: getTimingByKey(el.props.animationDelay || "0s").timing,
|
|
67
|
-
animationTimingFunction: getTimingFunction(el.props.animationTimingFunction || "ease"),
|
|
68
|
-
animationFillMode: el.props.animationFillMode || "both",
|
|
69
|
-
animationIterationCount: el.props.animationIterationCount || 1,
|
|
70
|
-
animationPlayState: el.props.animationPlayState,
|
|
71
|
-
animationDirection: el.props.animationDirection
|
|
72
|
-
};
|
|
73
|
-
},
|
|
74
|
-
animationName: (val, el) => ({
|
|
75
|
-
animationName: applyAnimationProps(val, el)
|
|
76
|
-
}),
|
|
77
|
-
animationDuration: (val) => ({
|
|
78
|
-
animationDuration: getTimingByKey(val).timing
|
|
79
|
-
}),
|
|
80
|
-
animationDelay: (val) => ({
|
|
81
|
-
animationDelay: getTimingByKey(val).timing
|
|
82
|
-
}),
|
|
83
|
-
animationTimingFunction: (val) => ({
|
|
84
|
-
animationTimingFunction: getTimingFunction(val)
|
|
85
|
-
}),
|
|
86
|
-
animationIterationCount: (val) => ({
|
|
87
|
-
animationIterationCount: val
|
|
88
|
-
}),
|
|
89
|
-
animationFillMode: (val) => ({
|
|
90
|
-
animationFillMode: val
|
|
91
|
-
}),
|
|
92
|
-
animationPlayState: (val) => ({
|
|
93
|
-
animationPlayState: val
|
|
94
|
-
}),
|
|
95
|
-
animationDirection: (val) => ({
|
|
96
|
-
animationDirection: val
|
|
97
|
-
})
|
|
98
|
-
};
|
|
99
|
-
export {
|
|
100
|
-
ANIMATION_PROPS
|
|
101
|
-
};
|
package/dist/esm/props/block.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { isUndefined, isString } from "@domql/utils";
|
|
2
|
-
import {
|
|
3
|
-
getSpacingBasedOnRatio,
|
|
4
|
-
transformSize,
|
|
5
|
-
transformBorderRadius,
|
|
6
|
-
transformSizeRatio,
|
|
7
|
-
transfromGap
|
|
8
|
-
} from "@symbo.ls/scratch";
|
|
9
|
-
const BLOCK_PROPS = {
|
|
10
|
-
show: (val, el, s, ctx) => !!(ctx.utils.exec(val, el, s) === false) && {
|
|
11
|
-
display: "none !important"
|
|
12
|
-
},
|
|
13
|
-
hide: (val, el, s, ctx) => !!ctx.utils.exec(val, el, s) && {
|
|
14
|
-
display: "none !important"
|
|
15
|
-
},
|
|
16
|
-
height: (val, { props }) => transformSizeRatio("height", val, props),
|
|
17
|
-
width: (val, { props }) => transformSizeRatio("width", val, props),
|
|
18
|
-
boxSizing: (val) => !isUndefined(val) ? { boxSizing: val } : { boxSizing: "border-box" },
|
|
19
|
-
boxSize: (val) => {
|
|
20
|
-
if (!isString(val)) return;
|
|
21
|
-
const [height, width] = val.split(" ");
|
|
22
|
-
return {
|
|
23
|
-
...transformSize("height", height),
|
|
24
|
-
...transformSize("width", width || height)
|
|
25
|
-
};
|
|
26
|
-
},
|
|
27
|
-
inlineSize: (val, { props }) => transformSizeRatio("inlineSize", val, props),
|
|
28
|
-
blockSize: (val, { props }) => transformSizeRatio("blockSize", val, props),
|
|
29
|
-
minWidth: (val, { props }) => transformSizeRatio("minWidth", val, props),
|
|
30
|
-
maxWidth: (val, { props }) => transformSizeRatio("maxWidth", val, props),
|
|
31
|
-
widthRange: (val) => {
|
|
32
|
-
if (!isString(val)) return;
|
|
33
|
-
const [minWidth, maxWidth] = val.split(" ");
|
|
34
|
-
return {
|
|
35
|
-
...transformSize("minWidth", minWidth),
|
|
36
|
-
...transformSize("maxWidth", maxWidth || minWidth)
|
|
37
|
-
};
|
|
38
|
-
},
|
|
39
|
-
minHeight: (val, { props }) => transformSizeRatio("minHeight", val, props),
|
|
40
|
-
maxHeight: (val, { props }) => transformSizeRatio("maxHeight", val, props),
|
|
41
|
-
heightRange: (val) => {
|
|
42
|
-
if (!isString(val)) return;
|
|
43
|
-
const [minHeight, maxHeight] = val.split(" ");
|
|
44
|
-
return {
|
|
45
|
-
...transformSize("minHeight", minHeight),
|
|
46
|
-
...transformSize("maxHeight", maxHeight || minHeight)
|
|
47
|
-
};
|
|
48
|
-
},
|
|
49
|
-
size: (val) => {
|
|
50
|
-
if (!isString(val)) return;
|
|
51
|
-
const [inlineSize, blockSize] = val.split(" ");
|
|
52
|
-
return {
|
|
53
|
-
...transformSizeRatio("inlineSize", inlineSize),
|
|
54
|
-
...transformSizeRatio("blockSize", blockSize || inlineSize)
|
|
55
|
-
};
|
|
56
|
-
},
|
|
57
|
-
minBlockSize: (val, { props }) => transformSizeRatio("minBlockSize", val, props),
|
|
58
|
-
minInlineSize: (val, { props }) => transformSizeRatio("minInlineSize", val, props),
|
|
59
|
-
maxBlockSize: (val, { props }) => transformSizeRatio("maxBlockSize", val, props),
|
|
60
|
-
maxInlineSize: (val, { props }) => transformSizeRatio("maxInlineSize", val, props),
|
|
61
|
-
minSize: (val) => {
|
|
62
|
-
if (!isString(val)) return;
|
|
63
|
-
const [minInlineSize, minBlockSize] = val.split(" ");
|
|
64
|
-
return {
|
|
65
|
-
...transformSize("minInlineSize", minInlineSize),
|
|
66
|
-
...transformSize("minBlockSize", minBlockSize || minInlineSize)
|
|
67
|
-
};
|
|
68
|
-
},
|
|
69
|
-
maxSize: (val) => {
|
|
70
|
-
if (!isString(val)) return;
|
|
71
|
-
const [maxInlineSize, maxBlockSize] = val.split(" ");
|
|
72
|
-
return {
|
|
73
|
-
...transformSize("maxInlineSize", maxInlineSize),
|
|
74
|
-
...transformSize("maxBlockSize", maxBlockSize || maxInlineSize)
|
|
75
|
-
};
|
|
76
|
-
},
|
|
77
|
-
borderWidth: (val, { props }) => transformSizeRatio("borderWidth", val, props),
|
|
78
|
-
padding: (val, { props }) => transformSizeRatio("padding", val, props),
|
|
79
|
-
scrollPadding: (val, { props }) => transformSizeRatio("scrollPadding", val, props),
|
|
80
|
-
paddingInline: (val) => {
|
|
81
|
-
if (!isString(val)) return;
|
|
82
|
-
const [paddingInlineStart, paddingInlineEnd] = val.split(" ");
|
|
83
|
-
return {
|
|
84
|
-
...transformSize("paddingInlineStart", paddingInlineStart),
|
|
85
|
-
...transformSize("paddingInlineEnd", paddingInlineEnd || paddingInlineStart)
|
|
86
|
-
};
|
|
87
|
-
},
|
|
88
|
-
paddingBlock: (val) => {
|
|
89
|
-
if (!isString(val)) return;
|
|
90
|
-
const [paddingBlockStart, paddingBlockEnd] = val.split(" ");
|
|
91
|
-
return {
|
|
92
|
-
...transformSize("paddingBlockStart", paddingBlockStart),
|
|
93
|
-
...transformSize("paddingBlockEnd", paddingBlockEnd || paddingBlockStart)
|
|
94
|
-
};
|
|
95
|
-
},
|
|
96
|
-
// Traditional directional padding
|
|
97
|
-
paddingTop: (val, { props }) => transformSizeRatio("paddingBlockStart", val, props),
|
|
98
|
-
paddingBottom: (val, { props }) => transformSizeRatio("paddingBlockEnd", val, props),
|
|
99
|
-
paddingLeft: (val, { props }) => transformSizeRatio("paddingInlineStart", val, props),
|
|
100
|
-
paddingRight: (val, { props }) => transformSizeRatio("paddingInlineEnd", val, props),
|
|
101
|
-
// Logical properties (for reference)
|
|
102
|
-
paddingBlockStart: (val, { props }) => transformSizeRatio("paddingBlockStart", val, props),
|
|
103
|
-
// maps to top
|
|
104
|
-
paddingBlockEnd: (val, { props }) => transformSizeRatio("paddingBlockEnd", val, props),
|
|
105
|
-
// maps to bottom
|
|
106
|
-
paddingInlineStart: (val, { props }) => transformSizeRatio("paddingInlineStart", val, props),
|
|
107
|
-
// maps to left
|
|
108
|
-
paddingInlineEnd: (val, { props }) => transformSizeRatio("paddingInlineEnd", val, props),
|
|
109
|
-
// maps to right
|
|
110
|
-
margin: (val, { props }) => transformSizeRatio("margin", val, props),
|
|
111
|
-
marginInline: (val) => {
|
|
112
|
-
if (!isString(val)) return;
|
|
113
|
-
const [marginInlineStart, marginInlineEnd] = val.split(" ");
|
|
114
|
-
return {
|
|
115
|
-
...transformSize("marginInlineStart", marginInlineStart),
|
|
116
|
-
...transformSize("marginInlineEnd", marginInlineEnd || marginInlineStart)
|
|
117
|
-
};
|
|
118
|
-
},
|
|
119
|
-
marginBlock: (val, { props }) => {
|
|
120
|
-
if (!isString(props.marginBlock)) return;
|
|
121
|
-
const [marginBlockStart, marginBlockEnd] = props.marginBlock.split(" ");
|
|
122
|
-
return {
|
|
123
|
-
...transformSize("marginBlockStart", marginBlockStart),
|
|
124
|
-
...transformSize("marginBlockEnd", marginBlockEnd || marginBlockStart)
|
|
125
|
-
};
|
|
126
|
-
},
|
|
127
|
-
// Traditional directional margin
|
|
128
|
-
marginTop: (val, { props }) => transformSizeRatio("marginBlockStart", val, props),
|
|
129
|
-
marginBottom: (val, { props }) => transformSizeRatio("marginBlockEnd", val, props),
|
|
130
|
-
marginLeft: (val, { props }) => transformSizeRatio("marginInlineStart", val, props),
|
|
131
|
-
marginRight: (val, { props }) => transformSizeRatio("marginInlineEnd", val, props),
|
|
132
|
-
// Logical properties
|
|
133
|
-
marginInlineStart: (val, { props }) => transformSizeRatio("marginInlineStart", val, props),
|
|
134
|
-
marginInlineEnd: (val, { props }) => transformSizeRatio("marginInlineEnd", val, props),
|
|
135
|
-
marginBlockStart: (val, { props }) => transformSizeRatio("marginBlockStart", val, props),
|
|
136
|
-
marginBlockEnd: (val, { props }) => transformSizeRatio("marginBlockEnd", val, props),
|
|
137
|
-
gap: (val) => ({
|
|
138
|
-
gap: transfromGap(val)
|
|
139
|
-
}),
|
|
140
|
-
columnGap: (val, { props }) => getSpacingBasedOnRatio(props, "columnGap", val),
|
|
141
|
-
rowGap: (val, { props }) => getSpacingBasedOnRatio(props, "rowGap", val),
|
|
142
|
-
flexWrap: (val, { props }) => ({
|
|
143
|
-
display: "flex",
|
|
144
|
-
flexFlow: (val || "row").split(" ")[0] + " " + props.flexWrap
|
|
145
|
-
}),
|
|
146
|
-
flexFlow: (val, { props }) => {
|
|
147
|
-
const { reverse } = props;
|
|
148
|
-
if (!isString(val)) return;
|
|
149
|
-
let [direction, wrap] = (val || "row").split(" ");
|
|
150
|
-
if (val.startsWith("x") || val === "row") direction = "row";
|
|
151
|
-
if (val.startsWith("y") || val === "column") direction = "column";
|
|
152
|
-
return {
|
|
153
|
-
display: "flex",
|
|
154
|
-
flexFlow: (direction || "") + (!direction.includes("-reverse") && reverse ? "-reverse" : "") + " " + (wrap || "")
|
|
155
|
-
};
|
|
156
|
-
},
|
|
157
|
-
flexAlign: (val) => {
|
|
158
|
-
if (!isString(val)) return;
|
|
159
|
-
const [alignItems, justifyContent] = val.split(" ");
|
|
160
|
-
return {
|
|
161
|
-
display: "flex",
|
|
162
|
-
alignItems,
|
|
163
|
-
justifyContent
|
|
164
|
-
};
|
|
165
|
-
},
|
|
166
|
-
round: (val, { props }) => transformBorderRadius(val || props.borderRadius, props, "round"),
|
|
167
|
-
borderRadius: (val, { props }) => transformBorderRadius(val || props.round, props, "borderRadius")
|
|
168
|
-
};
|
|
169
|
-
export {
|
|
170
|
-
BLOCK_PROPS
|
|
171
|
-
};
|