css-in-props 3.14.0 → 3.14.3
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/CHANGELOG.md +25 -0
- package/README.md +1 -1
- package/dist/cjs/index.js +1 -21
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/src/index.js +1 -0
- package/dist/cjs/src/props/animation.js +1 -0
- package/dist/cjs/src/props/block.js +1 -0
- package/dist/cjs/src/props/defaults.js +1 -0
- package/dist/cjs/src/props/flex.js +1 -0
- package/dist/cjs/src/props/font.js +1 -0
- package/dist/cjs/src/props/grid.js +1 -0
- package/dist/cjs/src/props/index.js +1 -0
- package/dist/cjs/src/props/misc.js +1 -0
- package/dist/cjs/src/props/position.js +1 -0
- package/dist/cjs/src/props/theme.js +1 -0
- package/dist/cjs/src/props/timing.js +1 -0
- package/dist/cjs/src/set.js +1 -0
- package/dist/cjs/src/transform/executors.js +1 -0
- package/dist/cjs/src/transform/index.js +1 -0
- package/dist/cjs/src/transform/transformers.js +1 -0
- package/dist/esm/index.js +1 -4
- package/dist/esm/src/index.js +1 -0
- package/dist/esm/src/props/animation.js +1 -0
- package/dist/esm/src/props/block.js +1 -0
- package/dist/esm/src/props/defaults.js +1 -0
- package/dist/esm/src/props/flex.js +1 -0
- package/dist/esm/src/props/font.js +1 -0
- package/dist/esm/src/props/grid.js +1 -0
- package/dist/esm/src/props/index.js +1 -0
- package/dist/esm/src/props/misc.js +1 -0
- package/dist/esm/src/props/position.js +1 -0
- package/dist/esm/src/props/theme.js +1 -0
- package/dist/esm/src/props/timing.js +1 -0
- package/dist/esm/src/set.js +1 -0
- package/dist/esm/src/transform/executors.js +1 -0
- package/dist/esm/src/transform/index.js +1 -0
- package/dist/esm/src/transform/transformers.js +1 -0
- package/package.json +19 -20
- package/dist/cjs/props/animation.js +0 -126
- package/dist/cjs/props/block.js +0 -173
- package/dist/cjs/props/defaults.js +0 -340
- package/dist/cjs/props/flex.js +0 -44
- package/dist/cjs/props/font.js +0 -36
- package/dist/cjs/props/grid.js +0 -39
- package/dist/cjs/props/index.js +0 -55
- package/dist/cjs/props/misc.js +0 -42
- package/dist/cjs/props/position.js +0 -51
- package/dist/cjs/props/theme.js +0 -147
- package/dist/cjs/props/timing.js +0 -42
- package/dist/cjs/set.js +0 -36
- package/dist/cjs/transform/executors.js +0 -131
- package/dist/cjs/transform/index.js +0 -19
- package/dist/cjs/transform/transformers.js +0 -156
- package/dist/esm/props/animation.js +0 -106
- package/dist/esm/props/block.js +0 -159
- package/dist/esm/props/defaults.js +0 -321
- package/dist/esm/props/flex.js +0 -24
- package/dist/esm/props/font.js +0 -16
- package/dist/esm/props/grid.js +0 -19
- package/dist/esm/props/index.js +0 -34
- package/dist/esm/props/misc.js +0 -22
- package/dist/esm/props/position.js +0 -31
- package/dist/esm/props/theme.js +0 -137
- package/dist/esm/props/timing.js +0 -26
- package/dist/esm/set.js +0 -16
- package/dist/esm/transform/executors.js +0 -111
- package/dist/esm/transform/index.js +0 -2
- package/dist/esm/transform/transformers.js +0 -136
- package/dist/iife/index.js +0 -1147
- package/index.js +0 -1
- package/src/index.js +0 -6
- package/src/props/animation.js +0 -119
- package/src/props/block.js +0 -183
- package/src/props/defaults.js +0 -318
- package/src/props/flex.js +0 -30
- package/src/props/font.js +0 -16
- package/src/props/grid.js +0 -21
- package/src/props/index.js +0 -35
- package/src/props/misc.js +0 -23
- package/src/props/position.js +0 -34
- package/src/props/theme.js +0 -155
- package/src/props/timing.js +0 -26
- package/src/set.js +0 -16
- package/src/transform/executors.js +0 -123
- package/src/transform/index.js +0 -4
- package/src/transform/transformers.js +0 -178
package/dist/cjs/props/misc.js
DELETED
|
@@ -1,42 +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 misc_exports = {};
|
|
20
|
-
__export(misc_exports, {
|
|
21
|
-
MISC_PROPS: () => MISC_PROPS
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(misc_exports);
|
|
24
|
-
const MISC_PROPS = {
|
|
25
|
-
overflow: (value) => ({
|
|
26
|
-
overflow: value,
|
|
27
|
-
scrollBehavior: "smooth"
|
|
28
|
-
}),
|
|
29
|
-
cursor: (value, el, s, ctx) => {
|
|
30
|
-
if (!value) return;
|
|
31
|
-
const asset = ctx.assets && ctx.assets[value];
|
|
32
|
-
if (asset && asset.content) value = `url(${asset.content.src})`;
|
|
33
|
-
else {
|
|
34
|
-
const file = ctx.files && ctx.files[value];
|
|
35
|
-
if (file && file.content) value = `url(${file.content.src})`;
|
|
36
|
-
}
|
|
37
|
-
return { cursor: value };
|
|
38
|
-
},
|
|
39
|
-
opacity: (value) => value != null ? { opacity: String(value) } : void 0,
|
|
40
|
-
visibility: (value) => value != null ? { visibility: value } : void 0,
|
|
41
|
-
pointerEvents: (value) => value != null ? { pointerEvents: value } : void 0
|
|
42
|
-
};
|
|
@@ -1,51 +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 position_exports = {};
|
|
20
|
-
__export(position_exports, {
|
|
21
|
-
POSITION_PROPS: () => POSITION_PROPS
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(position_exports);
|
|
24
|
-
var import_scratch = require("@symbo.ls/scratch");
|
|
25
|
-
const POSITION_PROPS = {
|
|
26
|
-
inset: (val, el) => {
|
|
27
|
-
if (el.call("isNumber", val)) return { inset: val };
|
|
28
|
-
if (!el.call("isString", val)) return;
|
|
29
|
-
return { inset: val.split(" ").map((v) => (0, import_scratch.getSpacingByKey)(v, "k").k).join(" ") };
|
|
30
|
-
},
|
|
31
|
-
left: (val) => (0, import_scratch.getSpacingByKey)(val, "left"),
|
|
32
|
-
top: (val) => (0, import_scratch.getSpacingByKey)(val, "top"),
|
|
33
|
-
right: (val) => (0, import_scratch.getSpacingByKey)(val, "right"),
|
|
34
|
-
bottom: (val) => (0, import_scratch.getSpacingByKey)(val, "bottom"),
|
|
35
|
-
verticalInset: (val) => {
|
|
36
|
-
if (typeof val !== "string") return;
|
|
37
|
-
const vi = val.split(" ").map((v) => (0, import_scratch.getSpacingByKey)(v, "k").k);
|
|
38
|
-
return {
|
|
39
|
-
top: vi[0],
|
|
40
|
-
bottom: vi[1] || vi[0]
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
horizontalInset: (val) => {
|
|
44
|
-
if (typeof val !== "string") return;
|
|
45
|
-
const vi = val.split(" ").map((v) => (0, import_scratch.getSpacingByKey)(v, "k").k);
|
|
46
|
-
return {
|
|
47
|
-
left: vi[0],
|
|
48
|
-
right: vi[1] || vi[0]
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
};
|
package/dist/cjs/props/theme.js
DELETED
|
@@ -1,147 +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 theme_exports = {};
|
|
20
|
-
__export(theme_exports, {
|
|
21
|
-
THEME_PROPS: () => THEME_PROPS,
|
|
22
|
-
getSystemGlobalTheme: () => getSystemGlobalTheme
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(theme_exports);
|
|
25
|
-
var import_scratch = require("@symbo.ls/scratch");
|
|
26
|
-
var import_utils = require("@symbo.ls/utils");
|
|
27
|
-
const getSystemGlobalTheme = ({ context, state }) => {
|
|
28
|
-
const theme = state?.root?.globalTheme || context.designSystem?.globalTheme;
|
|
29
|
-
return theme === "auto" ? null : theme;
|
|
30
|
-
};
|
|
31
|
-
const THEME_PROPS = {
|
|
32
|
-
theme: (val, element) => {
|
|
33
|
-
if (!val) return;
|
|
34
|
-
if (element.themeModifier) {
|
|
35
|
-
return (0, import_scratch.getMediaTheme)(val, `@${element.themeModifier}`);
|
|
36
|
-
}
|
|
37
|
-
return (0, import_scratch.getMediaTheme)(val);
|
|
38
|
-
},
|
|
39
|
-
color: (val, element) => {
|
|
40
|
-
const globalTheme = getSystemGlobalTheme(element);
|
|
41
|
-
if (!val) return;
|
|
42
|
-
return {
|
|
43
|
-
color: (0, import_scratch.getMediaColor)(val, globalTheme)
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
background: (val, element) => {
|
|
47
|
-
const globalTheme = getSystemGlobalTheme(element);
|
|
48
|
-
if (!val) return;
|
|
49
|
-
if ((0, import_utils.isString)(val) && val.includes("gradient")) {
|
|
50
|
-
return { background: (0, import_scratch.resolveColorsInGradient)(val, globalTheme) };
|
|
51
|
-
}
|
|
52
|
-
return {
|
|
53
|
-
background: (0, import_scratch.getMediaColor)(val, globalTheme)
|
|
54
|
-
};
|
|
55
|
-
},
|
|
56
|
-
backgroundColor: (val, element) => {
|
|
57
|
-
const globalTheme = getSystemGlobalTheme(element);
|
|
58
|
-
if (!val) return;
|
|
59
|
-
return {
|
|
60
|
-
backgroundColor: (0, import_scratch.getMediaColor)(val, globalTheme)
|
|
61
|
-
};
|
|
62
|
-
},
|
|
63
|
-
backgroundImage: (val, element, s, ctx) => {
|
|
64
|
-
const globalTheme = getSystemGlobalTheme(element);
|
|
65
|
-
if (!val) return;
|
|
66
|
-
const asset = ctx.assets && ctx.assets[val];
|
|
67
|
-
if (asset && asset.content) val = asset.content.src;
|
|
68
|
-
else {
|
|
69
|
-
const file = ctx.files && ctx.files[val];
|
|
70
|
-
if (file && file.content) val = file.content.src;
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
backgroundImage: (0, import_scratch.transformBackgroundImage)(val, globalTheme)
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
textStroke: (val) => ({
|
|
77
|
-
WebkitTextStroke: (0, import_scratch.transformTextStroke)(val)
|
|
78
|
-
}),
|
|
79
|
-
outline: (val) => ({
|
|
80
|
-
outline: (0, import_scratch.transformBorder)(val)
|
|
81
|
-
}),
|
|
82
|
-
outlineOffset: (val, el) => (0, import_scratch.transformSizeRatio)("outlineOffset", val, el),
|
|
83
|
-
border: (val) => ({
|
|
84
|
-
border: (0, import_scratch.transformBorder)(val)
|
|
85
|
-
}),
|
|
86
|
-
borderColor: (val, element) => {
|
|
87
|
-
const globalTheme = getSystemGlobalTheme(element);
|
|
88
|
-
if (!val) return;
|
|
89
|
-
return {
|
|
90
|
-
borderColor: (0, import_scratch.getMediaColor)(val, globalTheme)
|
|
91
|
-
};
|
|
92
|
-
},
|
|
93
|
-
borderTopColor: (val, element) => {
|
|
94
|
-
const globalTheme = getSystemGlobalTheme(element);
|
|
95
|
-
if (!val) return;
|
|
96
|
-
return { borderTopColor: (0, import_scratch.getMediaColor)(val, globalTheme) };
|
|
97
|
-
},
|
|
98
|
-
borderBottomColor: (val, element) => {
|
|
99
|
-
const globalTheme = getSystemGlobalTheme(element);
|
|
100
|
-
if (!val) return;
|
|
101
|
-
return { borderBottomColor: (0, import_scratch.getMediaColor)(val, globalTheme) };
|
|
102
|
-
},
|
|
103
|
-
borderLeftColor: (val, element) => {
|
|
104
|
-
const globalTheme = getSystemGlobalTheme(element);
|
|
105
|
-
if (!val) return;
|
|
106
|
-
return { borderLeftColor: (0, import_scratch.getMediaColor)(val, globalTheme) };
|
|
107
|
-
},
|
|
108
|
-
borderRightColor: (val, element) => {
|
|
109
|
-
const globalTheme = getSystemGlobalTheme(element);
|
|
110
|
-
if (!val) return;
|
|
111
|
-
return { borderRightColor: (0, import_scratch.getMediaColor)(val, globalTheme) };
|
|
112
|
-
},
|
|
113
|
-
borderLeft: (val) => ({
|
|
114
|
-
borderLeft: (0, import_scratch.transformBorder)(val)
|
|
115
|
-
}),
|
|
116
|
-
borderTop: (val) => ({
|
|
117
|
-
borderTop: (0, import_scratch.transformBorder)(val)
|
|
118
|
-
}),
|
|
119
|
-
borderRight: (val) => ({
|
|
120
|
-
borderRight: (0, import_scratch.transformBorder)(val)
|
|
121
|
-
}),
|
|
122
|
-
borderBottom: (val) => ({
|
|
123
|
-
borderBottom: (0, import_scratch.transformBorder)(val)
|
|
124
|
-
}),
|
|
125
|
-
shadow: (val, element) => {
|
|
126
|
-
const globalTheme = getSystemGlobalTheme(element);
|
|
127
|
-
if (!val) return;
|
|
128
|
-
return {
|
|
129
|
-
boxShadow: (0, import_scratch.transformShadow)(val, globalTheme)
|
|
130
|
-
};
|
|
131
|
-
},
|
|
132
|
-
boxShadow: (val, element) => {
|
|
133
|
-
if (!(0, import_utils.isString)(val)) return;
|
|
134
|
-
const [value, hasImportant] = val.split("!importan");
|
|
135
|
-
const globalTheme = getSystemGlobalTheme(element);
|
|
136
|
-
const important = hasImportant ? " !important" : "";
|
|
137
|
-
return {
|
|
138
|
-
boxShadow: (0, import_scratch.transformBoxShadow)(value.trim(), globalTheme) + important
|
|
139
|
-
};
|
|
140
|
-
},
|
|
141
|
-
textShadow: (val, { context }) => ({
|
|
142
|
-
textShadow: (0, import_scratch.transformBoxShadow)(val, context.designSystem.globalTheme)
|
|
143
|
-
}),
|
|
144
|
-
columnRule: (val) => ({
|
|
145
|
-
columnRule: (0, import_scratch.transformBorder)(val)
|
|
146
|
-
})
|
|
147
|
-
};
|
package/dist/cjs/props/timing.js
DELETED
|
@@ -1,42 +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 timing_exports = {};
|
|
20
|
-
__export(timing_exports, {
|
|
21
|
-
TIMING_PROPS: () => TIMING_PROPS
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(timing_exports);
|
|
24
|
-
var import_scratch = require("@symbo.ls/scratch");
|
|
25
|
-
const TIMING_PROPS = {
|
|
26
|
-
transition: (val) => ({
|
|
27
|
-
transition: (0, import_scratch.splitTransition)(val)
|
|
28
|
-
}),
|
|
29
|
-
transitionDuration: (val) => ({
|
|
30
|
-
transitionDuration: (0, import_scratch.transformDuration)(val)
|
|
31
|
-
}),
|
|
32
|
-
transitionDelay: (val) => ({
|
|
33
|
-
transitionDelay: (0, import_scratch.transformDuration)(val)
|
|
34
|
-
}),
|
|
35
|
-
transitionTimingFunction: (val) => ({
|
|
36
|
-
transitionTimingFunction: (0, import_scratch.getTimingFunction)(val)
|
|
37
|
-
}),
|
|
38
|
-
transitionProperty: (val) => ({
|
|
39
|
-
transitionProperty: val,
|
|
40
|
-
willChange: val
|
|
41
|
-
})
|
|
42
|
-
};
|
package/dist/cjs/set.js
DELETED
|
@@ -1,36 +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 set_exports = {};
|
|
20
|
-
__export(set_exports, {
|
|
21
|
-
setClassname: () => setClassname,
|
|
22
|
-
transformClassname: () => transformClassname
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(set_exports);
|
|
25
|
-
var import_utils = require("@symbo.ls/utils");
|
|
26
|
-
var import_transform = require("./transform/index.js");
|
|
27
|
-
var import_css = require("@symbo.ls/css");
|
|
28
|
-
const transformClassname = (element) => {
|
|
29
|
-
if (!(0, import_utils.isObject)(element)) return;
|
|
30
|
-
return (0, import_transform.useCssInProps)(element, element);
|
|
31
|
-
};
|
|
32
|
-
const setClassname = (props, cssEngine) => {
|
|
33
|
-
const transform = transformClassname(props);
|
|
34
|
-
if (typeof cssEngine === "function") return cssEngine(transform);
|
|
35
|
-
return (0, import_css.css)(transform);
|
|
36
|
-
};
|
|
@@ -1,131 +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("@symbo.ls/utils");
|
|
28
|
-
var import_scratch = require("@symbo.ls/scratch");
|
|
29
|
-
var import_props = require("../props/index.js");
|
|
30
|
-
var import_defaults = require("../props/defaults.js");
|
|
31
|
-
var import_transformers = require("./transformers.js");
|
|
32
|
-
const isProd = (0, import_utils.isProduction)();
|
|
33
|
-
const usePropsAsCSS = (sourceObj, element, opts) => {
|
|
34
|
-
const ds = element?.context?.designSystem;
|
|
35
|
-
if (ds) (0, import_scratch.pushConfig)(ds);
|
|
36
|
-
try {
|
|
37
|
-
let obj = {};
|
|
38
|
-
const rest = {};
|
|
39
|
-
const setToObj = (key, val) => {
|
|
40
|
-
if (opts.unpack) {
|
|
41
|
-
obj = { ...obj, ...val };
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
obj[key] = val;
|
|
45
|
-
};
|
|
46
|
-
for (const key in sourceObj) {
|
|
47
|
-
const value = sourceObj[key];
|
|
48
|
-
if (key === "class" && element.call("isString", sourceObj.class)) {
|
|
49
|
-
const val = value.split(" ");
|
|
50
|
-
if (val.length) {
|
|
51
|
-
const CLASS = element.context.designSystem.class;
|
|
52
|
-
const result = val.reduce((acc, curr) => (0, import_utils.merge)(acc, CLASS[curr]), {});
|
|
53
|
-
obj.designSystemClass = result;
|
|
54
|
-
}
|
|
55
|
-
} else if (key === "true") {
|
|
56
|
-
const val = (0, import_utils.exec)(value, element);
|
|
57
|
-
(0, import_utils.merge)(obj, (0, import_transformers.applyTrueProps)(val, element));
|
|
58
|
-
} else if (element.classlist[key]) {
|
|
59
|
-
const originalFromClass = element.classlist[key];
|
|
60
|
-
const result = (0, import_utils.isFunction)(originalFromClass) ? originalFromClass(element, element.state, element.context) : originalFromClass;
|
|
61
|
-
if (result) setToObj(key, result);
|
|
62
|
-
if (!isProd && (0, import_utils.isObject)(obj[key])) obj[key].label = key;
|
|
63
|
-
} else if (import_props.CSS_PROPS_REGISTRY[key]) {
|
|
64
|
-
let val = (0, import_utils.exec)(value, element);
|
|
65
|
-
if ((0, import_utils.isArray)(val)) {
|
|
66
|
-
val = val.reduce((a, c) => (0, import_utils.merge)(a, c), {});
|
|
67
|
-
}
|
|
68
|
-
let result = import_props.CSS_PROPS_REGISTRY[key](val, element, element.state, element.context);
|
|
69
|
-
if ((0, import_utils.isArray)(result)) result = result.reduce((a, c) => (0, import_utils.merge)(a, c), {});
|
|
70
|
-
if (result) setToObj(key, result);
|
|
71
|
-
if (!isProd && (0, import_utils.isObject)(obj[key])) obj[key].label = key;
|
|
72
|
-
} else if (import_defaults.DEFAULT_CSS_PROPERTIES_LIST.has(key)) {
|
|
73
|
-
let result = (0, import_utils.exec)(value, element);
|
|
74
|
-
if (typeof result === "string" && result.charCodeAt(0) === 45 && result.charCodeAt(1) === 45) {
|
|
75
|
-
result = `var(${result})`;
|
|
76
|
-
}
|
|
77
|
-
setToObj(key, { [key]: result });
|
|
78
|
-
if (!isProd && (0, import_utils.isObject)(obj[key])) obj[key].label = key;
|
|
79
|
-
} else {
|
|
80
|
-
rest[key] = value;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return [obj, rest];
|
|
84
|
-
} finally {
|
|
85
|
-
if (ds) (0, import_scratch.popConfig)();
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
const useSelectorsAsCSS = (sourceObj, element) => {
|
|
89
|
-
const obj = {};
|
|
90
|
-
for (const key in sourceObj) {
|
|
91
|
-
const selectroSetter = import_transformers.transformersByPrefix[key.slice(0, 1)];
|
|
92
|
-
if (selectroSetter) {
|
|
93
|
-
const result = selectroSetter(key, sourceObj[key], element);
|
|
94
|
-
if (result) {
|
|
95
|
-
for (const k in result) {
|
|
96
|
-
if (Object.prototype.hasOwnProperty.call(result, k)) {
|
|
97
|
-
if (obj[k] && typeof obj[k] === "object" && typeof result[k] === "object") {
|
|
98
|
-
(0, import_utils.overwriteDeep)(obj[k], result[k]);
|
|
99
|
-
} else {
|
|
100
|
-
obj[k] = result[k];
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return obj;
|
|
108
|
-
};
|
|
109
|
-
const useCssInProps = (selectorProps, element, opts = { unpack: true }) => {
|
|
110
|
-
const [cssObj, restProps] = usePropsAsCSS(selectorProps, element, opts);
|
|
111
|
-
const selectorsObj = useSelectorsAsCSS(restProps, element);
|
|
112
|
-
let hasSelectors = false;
|
|
113
|
-
for (const _k in selectorsObj) {
|
|
114
|
-
hasSelectors = true;
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
if (hasSelectors) {
|
|
118
|
-
if (opts.unpack) return (0, import_utils.overwrite)(cssObj, selectorsObj);
|
|
119
|
-
cssObj._selectors = selectorsObj;
|
|
120
|
-
}
|
|
121
|
-
return cssObj;
|
|
122
|
-
};
|
|
123
|
-
const exetuteClassPerComponent = (component, element) => {
|
|
124
|
-
const classObj = {};
|
|
125
|
-
if (component.class) {
|
|
126
|
-
for (const classProp in component.class) {
|
|
127
|
-
classObj[classProp] = component.class[classProp](element);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return classObj;
|
|
131
|
-
};
|
|
@@ -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.js"), module.exports);
|
|
19
|
-
__reExport(transform_exports, require("./transformers.js"), module.exports);
|
|
@@ -1,156 +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("@symbo.ls/utils");
|
|
26
|
-
var import_executors = require("./executors.js");
|
|
27
|
-
const DATA_THEME_RE = /^\[data-theme=(?:"([^"]+)"|'([^']+)')\]$/;
|
|
28
|
-
const applyMediaProps = (key, selectorProps, element) => {
|
|
29
|
-
const { context } = element;
|
|
30
|
-
if (!context.designSystem?.media) return;
|
|
31
|
-
const schemeKey = key.slice(1);
|
|
32
|
-
const mediaValue = context.designSystem.media[schemeKey];
|
|
33
|
-
const generatedClass = (0, import_executors.useCssInProps)(selectorProps, element);
|
|
34
|
-
if (!mediaValue) {
|
|
35
|
-
return { [key]: generatedClass };
|
|
36
|
-
}
|
|
37
|
-
if (mediaValue === "print") {
|
|
38
|
-
return { "@media print": generatedClass };
|
|
39
|
-
}
|
|
40
|
-
if (mediaValue[0] === "(") {
|
|
41
|
-
return { [`@media screen and ${mediaValue}`]: generatedClass };
|
|
42
|
-
}
|
|
43
|
-
const match = mediaValue.match(DATA_THEME_RE);
|
|
44
|
-
const scheme = match ? match[1] || match[2] : schemeKey;
|
|
45
|
-
const result = { [`${mediaValue} &`]: generatedClass };
|
|
46
|
-
if (scheme === "dark" || scheme === "light") {
|
|
47
|
-
const scopeSelector = context.designSystem?.scopeSelector || ":root";
|
|
48
|
-
const guard = scopeSelector === ":root" ? ":root:not([data-theme])" : `${scopeSelector}:not([data-theme])`;
|
|
49
|
-
result[`@media (prefers-color-scheme: ${scheme})`] = {
|
|
50
|
-
[`${guard} &`]: generatedClass
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
return result;
|
|
54
|
-
};
|
|
55
|
-
const applyAndProps = (key, selectorProps, element) => {
|
|
56
|
-
return { [key]: (0, import_executors.useCssInProps)(selectorProps, element) };
|
|
57
|
-
};
|
|
58
|
-
const applySelectorProps = (key, selectorProps, element) => {
|
|
59
|
-
const selectorKey = `&${key}`;
|
|
60
|
-
const resolved = (0, import_executors.useCssInProps)(selectorProps, element);
|
|
61
|
-
if (key.includes(",") && resolved) {
|
|
62
|
-
const flat = {};
|
|
63
|
-
const nested = {};
|
|
64
|
-
for (const k in resolved) {
|
|
65
|
-
if (typeof resolved[k] === "object" && resolved[k] !== null) {
|
|
66
|
-
nested[k] = resolved[k];
|
|
67
|
-
} else {
|
|
68
|
-
flat[k] = resolved[k];
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
if (Object.keys(nested).length) {
|
|
72
|
-
const parts = selectorKey.split(",").map((p) => p.trim());
|
|
73
|
-
const result = {};
|
|
74
|
-
if (Object.keys(flat).length) {
|
|
75
|
-
result[selectorKey] = flat;
|
|
76
|
-
}
|
|
77
|
-
for (const nestedKey in nested) {
|
|
78
|
-
const distributed = parts.map((p) => `${p} ${nestedKey}`).join(", ");
|
|
79
|
-
result[distributed] = nested[nestedKey];
|
|
80
|
-
}
|
|
81
|
-
return result;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return { [selectorKey]: resolved };
|
|
85
|
-
};
|
|
86
|
-
const resolveCase = (caseKey, element) => {
|
|
87
|
-
const caseFn = element.context?.cases?.[caseKey];
|
|
88
|
-
if (caseFn === void 0) return void 0;
|
|
89
|
-
if ((0, import_utils.isFunction)(caseFn)) return caseFn.call(element, element);
|
|
90
|
-
return !!caseFn;
|
|
91
|
-
};
|
|
92
|
-
const applyCaseProps = (key, selectorProps, element) => {
|
|
93
|
-
const caseKey = key.slice(1);
|
|
94
|
-
let isCaseTrue = resolveCase(caseKey, element);
|
|
95
|
-
if (isCaseTrue === void 0) {
|
|
96
|
-
isCaseTrue = !!element[caseKey];
|
|
97
|
-
}
|
|
98
|
-
if (!isCaseTrue) return;
|
|
99
|
-
return (0, import_executors.useCssInProps)(selectorProps, element);
|
|
100
|
-
};
|
|
101
|
-
const applyVariableProps = (key, selectorVal, element) => {
|
|
102
|
-
return { [key]: selectorVal };
|
|
103
|
-
};
|
|
104
|
-
const applyConditionalCaseProps = (key, selectorProps, element) => {
|
|
105
|
-
const caseKey = key.slice(1);
|
|
106
|
-
let isCaseTrue = element[caseKey] === true || element.state?.[caseKey];
|
|
107
|
-
if (!isCaseTrue) {
|
|
108
|
-
if (typeof element[caseKey] === "function") {
|
|
109
|
-
try {
|
|
110
|
-
isCaseTrue = element[caseKey](element, element.state, element.context);
|
|
111
|
-
} catch (e) {
|
|
112
|
-
}
|
|
113
|
-
} else {
|
|
114
|
-
const caseResult = resolveCase(caseKey, element);
|
|
115
|
-
if (caseResult !== void 0) isCaseTrue = caseResult;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
if (!isCaseTrue) return;
|
|
119
|
-
return (0, import_executors.useCssInProps)(selectorProps, element);
|
|
120
|
-
};
|
|
121
|
-
const applyConditionalFalsyProps = (key, selectorProps, element) => {
|
|
122
|
-
const caseKey = key.slice(1);
|
|
123
|
-
let isCaseTrue = element[caseKey] === true || element.state?.[caseKey];
|
|
124
|
-
if (!isCaseTrue) {
|
|
125
|
-
if (typeof element[caseKey] === "function") {
|
|
126
|
-
try {
|
|
127
|
-
isCaseTrue = element[caseKey](element, element.state, element.context);
|
|
128
|
-
} catch (e) {
|
|
129
|
-
}
|
|
130
|
-
} else {
|
|
131
|
-
const caseResult = resolveCase(caseKey, element);
|
|
132
|
-
if (caseResult !== void 0) isCaseTrue = caseResult;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
if (isCaseTrue) return;
|
|
136
|
-
return (0, import_executors.useCssInProps)(selectorProps, element);
|
|
137
|
-
};
|
|
138
|
-
const applyTrueProps = (selectorProps, element) => {
|
|
139
|
-
return (0, import_executors.useCssInProps)(selectorProps, element);
|
|
140
|
-
};
|
|
141
|
-
const transformersByPrefix = {
|
|
142
|
-
"@": applyMediaProps,
|
|
143
|
-
// Selector handlers
|
|
144
|
-
":": applySelectorProps,
|
|
145
|
-
"[": applySelectorProps,
|
|
146
|
-
"*": applySelectorProps,
|
|
147
|
-
"+": applySelectorProps,
|
|
148
|
-
"~": applySelectorProps,
|
|
149
|
-
"&": applyAndProps,
|
|
150
|
-
">": applyAndProps,
|
|
151
|
-
// Conditional and variable handlers
|
|
152
|
-
$: applyCaseProps,
|
|
153
|
-
"-": applyVariableProps,
|
|
154
|
-
".": applyConditionalCaseProps,
|
|
155
|
-
"!": applyConditionalFalsyProps
|
|
156
|
-
};
|