@symbo.ls/scratch 3.14.0 → 3.14.2

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.
Files changed (94) hide show
  1. package/README.md +1 -1
  2. package/package.json +2 -2
  3. package/src/utils/sprite.js +29 -12
  4. package/dist/cjs/defaultConfig/animation.js +0 -24
  5. package/dist/cjs/defaultConfig/cases.js +0 -24
  6. package/dist/cjs/defaultConfig/class.js +0 -24
  7. package/dist/cjs/defaultConfig/color.js +0 -31
  8. package/dist/cjs/defaultConfig/document.js +0 -24
  9. package/dist/cjs/defaultConfig/font-family.js +0 -38
  10. package/dist/cjs/defaultConfig/font.js +0 -33
  11. package/dist/cjs/defaultConfig/grid.js +0 -25
  12. package/dist/cjs/defaultConfig/icons.js +0 -26
  13. package/dist/cjs/defaultConfig/index.js +0 -46
  14. package/dist/cjs/defaultConfig/media.js +0 -29
  15. package/dist/cjs/defaultConfig/responsive.js +0 -50
  16. package/dist/cjs/defaultConfig/sequence.js +0 -49
  17. package/dist/cjs/defaultConfig/shadow.js +0 -24
  18. package/dist/cjs/defaultConfig/spacing.js +0 -38
  19. package/dist/cjs/defaultConfig/svg.js +0 -26
  20. package/dist/cjs/defaultConfig/templates.js +0 -24
  21. package/dist/cjs/defaultConfig/theme.js +0 -36
  22. package/dist/cjs/defaultConfig/timing.js +0 -37
  23. package/dist/cjs/defaultConfig/typography.js +0 -41
  24. package/dist/cjs/defaultConfig/unit.js +0 -26
  25. package/dist/cjs/factory.js +0 -145
  26. package/dist/cjs/index.js +0 -45
  27. package/dist/cjs/set.js +0 -286
  28. package/dist/cjs/system/color.js +0 -268
  29. package/dist/cjs/system/document.js +0 -36
  30. package/dist/cjs/system/font.js +0 -71
  31. package/dist/cjs/system/index.js +0 -27
  32. package/dist/cjs/system/reset.js +0 -114
  33. package/dist/cjs/system/shadow.js +0 -108
  34. package/dist/cjs/system/spacing.js +0 -134
  35. package/dist/cjs/system/svg.js +0 -133
  36. package/dist/cjs/system/theme.js +0 -496
  37. package/dist/cjs/system/timing.js +0 -48
  38. package/dist/cjs/system/typography.js +0 -108
  39. package/dist/cjs/tests/index.js +0 -28
  40. package/dist/cjs/transforms/index.js +0 -219
  41. package/dist/cjs/utils/color.js +0 -206
  42. package/dist/cjs/utils/font.js +0 -114
  43. package/dist/cjs/utils/index.js +0 -24
  44. package/dist/cjs/utils/sequence.js +0 -342
  45. package/dist/cjs/utils/sprite.js +0 -92
  46. package/dist/cjs/utils/theme.js +0 -29
  47. package/dist/cjs/utils/unit.js +0 -79
  48. package/dist/cjs/utils/var.js +0 -116
  49. package/dist/esm/defaultConfig/animation.js +0 -4
  50. package/dist/esm/defaultConfig/cases.js +0 -4
  51. package/dist/esm/defaultConfig/class.js +0 -4
  52. package/dist/esm/defaultConfig/color.js +0 -11
  53. package/dist/esm/defaultConfig/document.js +0 -4
  54. package/dist/esm/defaultConfig/font-family.js +0 -18
  55. package/dist/esm/defaultConfig/font.js +0 -13
  56. package/dist/esm/defaultConfig/grid.js +0 -5
  57. package/dist/esm/defaultConfig/icons.js +0 -6
  58. package/dist/esm/defaultConfig/index.js +0 -25
  59. package/dist/esm/defaultConfig/media.js +0 -9
  60. package/dist/esm/defaultConfig/responsive.js +0 -30
  61. package/dist/esm/defaultConfig/sequence.js +0 -29
  62. package/dist/esm/defaultConfig/shadow.js +0 -4
  63. package/dist/esm/defaultConfig/spacing.js +0 -18
  64. package/dist/esm/defaultConfig/svg.js +0 -6
  65. package/dist/esm/defaultConfig/templates.js +0 -4
  66. package/dist/esm/defaultConfig/theme.js +0 -16
  67. package/dist/esm/defaultConfig/timing.js +0 -17
  68. package/dist/esm/defaultConfig/typography.js +0 -21
  69. package/dist/esm/defaultConfig/unit.js +0 -6
  70. package/dist/esm/factory.js +0 -120
  71. package/dist/esm/index.js +0 -14
  72. package/dist/esm/set.js +0 -280
  73. package/dist/esm/system/color.js +0 -253
  74. package/dist/esm/system/document.js +0 -16
  75. package/dist/esm/system/font.js +0 -58
  76. package/dist/esm/system/index.js +0 -10
  77. package/dist/esm/system/reset.js +0 -94
  78. package/dist/esm/system/shadow.js +0 -92
  79. package/dist/esm/system/spacing.js +0 -121
  80. package/dist/esm/system/svg.js +0 -113
  81. package/dist/esm/system/theme.js +0 -481
  82. package/dist/esm/system/timing.js +0 -32
  83. package/dist/esm/system/typography.js +0 -94
  84. package/dist/esm/tests/index.js +0 -8
  85. package/dist/esm/transforms/index.js +0 -216
  86. package/dist/esm/utils/color.js +0 -192
  87. package/dist/esm/utils/font.js +0 -94
  88. package/dist/esm/utils/index.js +0 -7
  89. package/dist/esm/utils/sequence.js +0 -322
  90. package/dist/esm/utils/sprite.js +0 -72
  91. package/dist/esm/utils/theme.js +0 -9
  92. package/dist/esm/utils/unit.js +0 -59
  93. package/dist/esm/utils/var.js +0 -96
  94. package/dist/iife/index.js +0 -3630
@@ -1,253 +0,0 @@
1
- import { isObject, isArray, isString } from "@symbo.ls/utils";
2
- import { getActiveConfig } from "../factory.js";
3
- import {
4
- colorStringToRgbaArray,
5
- getRgbTone,
6
- isCSSVar,
7
- parseColorToken
8
- } from "../utils/index.js";
9
- const getColor = (value, key, config) => {
10
- const CONFIG = config || getActiveConfig();
11
- if (!isString(value)) {
12
- if (CONFIG.verbose) console.warn(value, "- type for color is not valid");
13
- return;
14
- }
15
- if (isCSSVar(value)) return `var(${value})`;
16
- if (key && value[key]) value = value[key];
17
- let name, alpha, tone;
18
- if (isArray(value)) {
19
- [name, alpha, tone] = value;
20
- } else {
21
- const parsed = parseColorToken(value);
22
- if (!parsed) {
23
- const { color: COLOR2, gradient: GRADIENT2 } = CONFIG;
24
- const directVal = GRADIENT2[value] || COLOR2[value];
25
- if (directVal) return CONFIG.useVariable ? `var(${directVal.var})` : directVal.value;
26
- return value;
27
- }
28
- if (parsed.passthrough) return parsed.passthrough;
29
- if (parsed.cssVar) return `var(${parsed.cssVar})`;
30
- name = parsed.name;
31
- alpha = parsed.alpha;
32
- tone = parsed.tone;
33
- }
34
- const { color: COLOR, gradient: GRADIENT } = CONFIG;
35
- let val = COLOR[name] || GRADIENT[name];
36
- if (!val) {
37
- if (CONFIG.verbose) console.warn("Can't find color ", name);
38
- return value;
39
- }
40
- if (key) {
41
- if (val[key]) val = val[key];
42
- else if (CONFIG.verbose) console.warn(value, " - does not have ", key);
43
- }
44
- let rgb = val.rgb;
45
- if (!rgb) {
46
- return CONFIG.useVariable ? `var(${val.var})` : val.value;
47
- }
48
- if (tone && !val[tone]) {
49
- rgb = getRgbTone(rgb, tone);
50
- val[tone] = { rgb, var: `${val.var}-${tone}` };
51
- }
52
- if (val[tone]) rgb = val[tone].rgb;
53
- if (alpha) return `rgba(${rgb}, ${alpha})`;
54
- if (tone) return `rgba(${rgb}, 1)`;
55
- return CONFIG.useVariable ? `var(${val.var})` : `rgb(${rgb})`;
56
- };
57
- const getMediaColor = (value, globalTheme, config) => {
58
- const CONFIG = config || getActiveConfig();
59
- if (!globalTheme) globalTheme = CONFIG.globalTheme === "auto" ? null : CONFIG.globalTheme;
60
- if (!isString(value)) {
61
- if (CONFIG.verbose) console.warn(value, "- type for color is not valid");
62
- return;
63
- }
64
- if (isCSSVar(value)) return `var(${value})`;
65
- let name;
66
- if (isArray(value)) {
67
- name = value[0];
68
- } else {
69
- const parsed = parseColorToken(value);
70
- if (!parsed) return value;
71
- if (parsed.passthrough) return parsed.passthrough;
72
- if (parsed.cssVar) return `var(${parsed.cssVar})`;
73
- name = parsed.name;
74
- }
75
- const { color: COLOR, gradient: GRADIENT } = CONFIG;
76
- const val = COLOR[name] || GRADIENT[name];
77
- const isObj = isObject(val);
78
- if (isObj && val.value) return getColor(value, `@${globalTheme}`, config);
79
- else if (isObj) {
80
- if (CONFIG.useVariable && val.var) return `var(${val.var})`;
81
- if (globalTheme) return getColor(value, `@${globalTheme}`, config);
82
- else {
83
- const obj = {};
84
- for (const mediaName in val) {
85
- if (mediaName.charCodeAt(0) !== 64) continue;
86
- const query = CONFIG.media[mediaName.slice(1)];
87
- if (!query) continue;
88
- const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
89
- obj[media] = getColor(value, mediaName, config);
90
- }
91
- return obj;
92
- }
93
- } else {
94
- if (CONFIG.verbose) console.warn("Can't find color", value);
95
- return value;
96
- }
97
- };
98
- const setColor = (val, key, suffix) => {
99
- const CONFIG = getActiveConfig();
100
- if (isString(val) && isCSSVar(val)) {
101
- const rawRef = val.slice(2);
102
- val = getColor(rawRef);
103
- if (!(val.includes("rgb") || val.includes("var") || val.includes("#"))) {
104
- const parts = rawRef.split(" ");
105
- let refColor = CONFIG.color[parts[0]];
106
- if (refColor && !refColor.value && !refColor.rgb && (isString(refColor) || isArray(refColor) || isObject(refColor))) {
107
- CONFIG.color[parts[0]] = setColor(refColor, parts[0]);
108
- refColor = CONFIG.color[parts[0]];
109
- }
110
- if (refColor && refColor.value) {
111
- let rgb2 = refColor.rgb;
112
- const alpha2 = parts[1] !== void 0 ? parts[1] : "1";
113
- const tone = parts[2];
114
- if (tone) {
115
- rgb2 = getRgbTone(rgb2, tone);
116
- }
117
- val = `rgba(${rgb2}, ${alpha2})`;
118
- } else {
119
- const tone = parts[2];
120
- const alpha2 = parts[1] !== void 0 ? parts[1] : "1";
121
- if (tone) {
122
- try {
123
- const rgb2 = colorStringToRgbaArray(parts[0]);
124
- if (rgb2 && rgb2.length >= 3) {
125
- const tonedRgb = getRgbTone(rgb2.slice(0, 3).join(", "), tone);
126
- val = `rgba(${tonedRgb}, ${alpha2})`;
127
- } else {
128
- val = parts[0];
129
- }
130
- } catch (e) {
131
- val = parts[0];
132
- }
133
- } else {
134
- val = parts[0];
135
- }
136
- }
137
- }
138
- }
139
- if (isArray(val)) {
140
- val = { "@light": val[0], "@dark": val[1] };
141
- }
142
- if (isObject(val)) {
143
- const obj = {};
144
- for (const variant in val) {
145
- obj[variant] = setColor(
146
- val[variant],
147
- key,
148
- variant.slice(0, 1) === "@" ? variant.slice(1) : variant
149
- );
150
- }
151
- if (CONFIG.useVariable) {
152
- const vp2 = CONFIG.varPrefix ? CONFIG.varPrefix + "-" : "";
153
- const adaptiveVar = `--${vp2}color-${key}`;
154
- let fallbackValue;
155
- const schemeValues = {};
156
- for (const variant in obj) {
157
- if (variant.charCodeAt(0) !== 64) continue;
158
- const scheme = variant.slice(1);
159
- const entry = obj[variant];
160
- const value2 = entry && (entry.value || entry);
161
- if (!value2 || typeof value2 !== "string") continue;
162
- schemeValues[scheme] = value2;
163
- if (scheme === "light" || fallbackValue === void 0) fallbackValue = value2;
164
- }
165
- if (fallbackValue !== void 0) {
166
- CONFIG.cssVars[adaptiveVar] = fallbackValue;
167
- if (!CONFIG.cssMediaVars) CONFIG.cssMediaVars = {};
168
- for (const scheme in schemeValues) {
169
- const sel = `[data-theme="${scheme}"]`;
170
- if (!CONFIG.cssMediaVars[sel]) CONFIG.cssMediaVars[sel] = {};
171
- CONFIG.cssMediaVars[sel][adaptiveVar] = schemeValues[scheme];
172
- if (scheme === "light" || scheme === "dark") {
173
- const mq = `@media (prefers-color-scheme: ${scheme})`;
174
- if (!CONFIG.cssMediaVars[mq]) CONFIG.cssMediaVars[mq] = {};
175
- CONFIG.cssMediaVars[mq][adaptiveVar] = schemeValues[scheme];
176
- }
177
- }
178
- obj.var = adaptiveVar;
179
- }
180
- }
181
- return obj;
182
- }
183
- const vp = CONFIG.varPrefix ? CONFIG.varPrefix + "-" : "";
184
- const CSSVar = `--${vp}color-${key}` + (suffix ? `-${suffix}` : "");
185
- let resolvedVal = val.value || val;
186
- if (isString(resolvedVal) && resolvedVal.includes(".") && !resolvedVal.includes("(")) {
187
- const [colorRef, alphaStr] = resolvedVal.split(".");
188
- const refColor = CONFIG.color[colorRef];
189
- if (refColor && refColor.rgb) {
190
- resolvedVal = `rgba(${refColor.rgb}, ${parseFloat("0." + alphaStr) || 1})`;
191
- }
192
- }
193
- if (isString(resolvedVal) && !resolvedVal.includes("(") && !resolvedVal.startsWith("#")) {
194
- const parsed = parseColorToken(resolvedVal);
195
- if (parsed && parsed.name && !parsed.passthrough && !parsed.cssVar) {
196
- const refColor = CONFIG.color[parsed.name];
197
- if (refColor && !refColor.value && !refColor.rgb && (isString(refColor) || isArray(refColor) || isObject(refColor))) {
198
- CONFIG.color[parsed.name] = setColor(refColor, parsed.name);
199
- }
200
- const baseColor = CONFIG.color[parsed.name];
201
- if (baseColor && baseColor.rgb) {
202
- let rgb2 = baseColor.rgb;
203
- if (parsed.tone) rgb2 = getRgbTone(rgb2, parsed.tone);
204
- const alphaVal = parsed.alpha ? parseFloat(parsed.alpha) : 1;
205
- resolvedVal = `rgba(${rgb2}, ${alphaVal})`;
206
- }
207
- }
208
- }
209
- const colorArr = colorStringToRgbaArray(resolvedVal);
210
- const [r, g, b, a = 1] = colorArr;
211
- const alpha = parseFloat(a.toFixed(2));
212
- const rgb = `${r}, ${g}, ${b}`;
213
- const value = `rgba(${rgb}, ${alpha})`;
214
- if (CONFIG.useVariable) {
215
- CONFIG.cssVars[CSSVar] = value;
216
- }
217
- return {
218
- var: CSSVar,
219
- rgb,
220
- alpha,
221
- value
222
- };
223
- };
224
- const setGradient = (val, key, suffix) => {
225
- const CONFIG = getActiveConfig();
226
- if (isString(val) && isCSSVar(val)) val = getColor(val.slice(2));
227
- if (isArray(val)) {
228
- return {
229
- "@light": setGradient(val[0], key, "light"),
230
- "@dark": setGradient(val[0], key, "dark")
231
- };
232
- }
233
- if (isObject(val)) {
234
- const obj = {};
235
- for (const variant in val) obj[variant] = setGradient(val[variant], key, variant.slice(0, 1) === "@" ? variant.slice(1) : variant);
236
- return obj;
237
- }
238
- const vp = CONFIG.varPrefix ? CONFIG.varPrefix + "-" : "";
239
- const CSSVar = `--${vp}gradient-${key}` + (suffix ? `-${suffix}` : "");
240
- if (CONFIG.useVariable) {
241
- CONFIG.cssVars[CSSVar] = val.value || val;
242
- }
243
- return {
244
- var: CSSVar,
245
- value: val.value || val
246
- };
247
- };
248
- export {
249
- getColor,
250
- getMediaColor,
251
- setColor,
252
- setGradient
253
- };
@@ -1,16 +0,0 @@
1
- import { merge } from "@symbo.ls/utils";
2
- import { getActiveConfig } from "../factory.js";
3
- import { getDefaultOrFirstKey } from "../utils/index.js";
4
- const applyDocument = () => {
5
- const CONFIG = getActiveConfig();
6
- const { document: DOCUMENT, fontFamily: FONT_FAMILY, theme: THEME, typography: TYPOGRAPHY } = CONFIG;
7
- return merge(DOCUMENT, {
8
- theme: THEME.document,
9
- fontFamily: getDefaultOrFirstKey(FONT_FAMILY),
10
- fontSize: TYPOGRAPHY.base,
11
- lineHeight: TYPOGRAPHY.lineHeight
12
- });
13
- };
14
- export {
15
- applyDocument
16
- };
@@ -1,58 +0,0 @@
1
- import { isObject, isArray } from "@symbo.ls/utils";
2
- import { arrayzeValue } from "@symbo.ls/utils";
3
- import { getActiveConfig } from "../factory.js";
4
- import {
5
- getDefaultOrFirstKey,
6
- getFontFaceEach,
7
- isGoogleFontsUrl,
8
- setCustomFontMedia,
9
- setFontImport,
10
- resolveFileUrl
11
- } from "../utils/index.js";
12
- const setFont = (val, key) => {
13
- const CONFIG = getActiveConfig();
14
- const CSSvar = `--font-${key}`;
15
- if (!val || isArray(val) && !val[0]) return;
16
- let fontFace;
17
- if (val.isVariable) {
18
- const url = resolveFileUrl(val.url, CONFIG.files) || val.url;
19
- if (isGoogleFontsUrl(url)) {
20
- fontFace = setFontImport(url);
21
- } else {
22
- fontFace = setCustomFontMedia(key, url, val.fontWeight, {
23
- fontStretch: val.fontStretch,
24
- fontDisplay: val.fontDisplay || "swap"
25
- });
26
- }
27
- } else if (val[0]) {
28
- fontFace = getFontFaceEach(key, val, CONFIG.files);
29
- } else {
30
- const url = Array.isArray(val.url) ? val.url.map((u) => resolveFileUrl(u, CONFIG.files) || u) : resolveFileUrl(val.url, CONFIG.files) || val.url;
31
- fontFace = setCustomFontMedia(key, url, val.fontWeight, {
32
- fontStyle: val.fontStyle,
33
- fontDisplay: val.fontDisplay,
34
- fontStretch: val.fontStretch
35
- });
36
- }
37
- return { var: CSSvar, value: val, fontFace };
38
- };
39
- const getFontFamily = (key, factory) => {
40
- const CONFIG = getActiveConfig();
41
- const { fontFamily: FONT_FAMILY } = CONFIG;
42
- return getDefaultOrFirstKey(factory || FONT_FAMILY, key);
43
- };
44
- const setFontFamily = (val, key) => {
45
- const CONFIG = getActiveConfig();
46
- const { fontFamily: FONT_FAMILY, fontFamilyTypes: FONT_FAMILY_TYPES } = CONFIG;
47
- let { value, type } = val;
48
- if (val.isDefault) FONT_FAMILY.default = key;
49
- if (isObject(value)) value = arrayzeValue(value);
50
- const CSSvar = `--font-family-${key}`;
51
- const str = `${value.join(", ")}, ${FONT_FAMILY_TYPES[type]}`;
52
- return { var: CSSvar, value: str, arr: value, type };
53
- };
54
- export {
55
- getFontFamily,
56
- setFont,
57
- setFontFamily
58
- };
@@ -1,10 +0,0 @@
1
- export * from "./color.js";
2
- export * from "./theme.js";
3
- export * from "./font.js";
4
- export * from "./typography.js";
5
- export * from "./spacing.js";
6
- export * from "./shadow.js";
7
- export * from "./timing.js";
8
- export * from "./document.js";
9
- export * from "./svg.js";
10
- export * from "./reset.js";
@@ -1,94 +0,0 @@
1
- import { deepMerge, merge, overwriteDeep } from "@symbo.ls/utils";
2
- import { getActiveConfig } from "../factory.js";
3
- import { getMediaTheme } from "./theme.js";
4
- const applyReset = (reset = {}) => {
5
- const CONFIG = getActiveConfig();
6
- const { reset: RESET, typography: TYPOGRAPHY, document: DOCUMENT } = CONFIG;
7
- if (RESET) {
8
- if (RESET[":root"]) {
9
- const configReset = RESET;
10
- const configTemplates = TYPOGRAPHY.templates;
11
- configReset.body = {
12
- ...CONFIG.useDocumentTheme ? getMediaTheme("document") : {},
13
- ...configTemplates.body
14
- };
15
- configReset.h1 = configTemplates.h1;
16
- configReset.h2 = configTemplates.h2;
17
- configReset.h3 = configTemplates.h3;
18
- configReset.h4 = configTemplates.h4;
19
- configReset.h5 = configTemplates.h5;
20
- configReset.h6 = configTemplates.h6;
21
- }
22
- const { body, ...templates } = TYPOGRAPHY.templates;
23
- const globalTheme = CONFIG.useDocumentTheme ? getMediaTheme("document") : {};
24
- if (RESET.html) overwriteDeep(RESET.html, globalTheme);
25
- if (TYPOGRAPHY.unit) {
26
- const { media: MEDIA } = CONFIG;
27
- for (const key in TYPOGRAPHY) {
28
- if (key.charAt(0) !== "@") continue;
29
- const mediaTypo = TYPOGRAPHY[key];
30
- if (!mediaTypo) continue;
31
- if (mediaTypo.unit === TYPOGRAPHY.unit || !mediaTypo.unit) continue;
32
- const mediaUnit = mediaTypo.unit;
33
- const mediaBase = mediaTypo.base || TYPOGRAPHY.base;
34
- const mediaBrowserDefault = mediaTypo.browserDefault || TYPOGRAPHY.browserDefault;
35
- const mediaName = key.slice(1);
36
- const query = MEDIA[mediaName];
37
- if (!query) continue;
38
- const mediaKey = "@media " + (query === "print" ? query : "screen and " + query);
39
- if (!RESET[mediaKey]) RESET[mediaKey] = {};
40
- if (!RESET[mediaKey].html) RESET[mediaKey].html = {};
41
- RESET[mediaKey].html.fontSize = mediaBase / mediaBrowserDefault + mediaUnit;
42
- }
43
- }
44
- return deepMerge(merge(RESET, reset), {
45
- html: {
46
- position: "absolute",
47
- width: "100%",
48
- height: "100%",
49
- top: "0",
50
- left: "0",
51
- margin: "0",
52
- WebkitFontSmoothing: "subpixel-antialiased",
53
- scrollBehavior: "smooth",
54
- ...globalTheme,
55
- fontSize: TYPOGRAPHY.unit ? TYPOGRAPHY.base / TYPOGRAPHY.browserDefault + TYPOGRAPHY.unit : TYPOGRAPHY.browserDefault + "px",
56
- fontFamily: DOCUMENT.fontFamily,
57
- lineHeight: DOCUMENT.lineHeight
58
- },
59
- body: {
60
- boxSizing: "border-box",
61
- height: "100%",
62
- margin: 0,
63
- fontFamily: DOCUMENT.fontFamily,
64
- fontSize: TYPOGRAPHY.base / TYPOGRAPHY.browserDefault + CONFIG.unit.default,
65
- ...templates,
66
- ...body
67
- },
68
- a: {
69
- color: "currentColor"
70
- },
71
- button: {
72
- color: "inherit",
73
- font: "inherit",
74
- background: "transparent",
75
- border: "none",
76
- cursor: "pointer",
77
- appearance: "none",
78
- WebkitAppearance: "none"
79
- },
80
- "input, select, textarea": {
81
- color: "inherit",
82
- font: "inherit"
83
- },
84
- fieldset: {
85
- border: 0,
86
- padding: 0,
87
- margin: 0
88
- }
89
- });
90
- }
91
- };
92
- export {
93
- applyReset
94
- };
@@ -1,92 +0,0 @@
1
- import { getActiveConfig } from "../factory.js";
2
- import { getColor } from "./color.js";
3
- import { getSpacingByKey } from "./spacing.js";
4
- import { isResolvedColor, isCSSVar, splitTopLevelCommas, CSS_NATIVE_COLOR_REGEX } from "../utils/color.js";
5
- import {
6
- isObject,
7
- isString,
8
- isArray
9
- } from "@symbo.ls/utils";
10
- const setShadow = (value, key, suffix, prefers) => {
11
- const CONFIG = getActiveConfig();
12
- if (isArray(value)) {
13
- return {
14
- "@light": setShadow(value[0], key, "light"),
15
- "@dark": setShadow(value[1], key, "dark")
16
- };
17
- }
18
- if (isObject(value)) {
19
- const obj = {};
20
- for (const variant in value) {
21
- obj[variant] = setShadow(
22
- value[variant],
23
- key,
24
- variant.startsWith("@") ? variant.slice(1) : variant
25
- );
26
- }
27
- return obj;
28
- }
29
- if (isString(value) && !CSS_NATIVE_COLOR_REGEX.test(value)) {
30
- value = splitTopLevelCommas(value).map((shadow) => {
31
- shadow = shadow.trim();
32
- return shadow.split(/\s+/).map((v) => {
33
- v = v.trim();
34
- if (!v) return "";
35
- if (v.startsWith("--")) return `var(${v})`;
36
- const color = getColor(v);
37
- if (isResolvedColor(color)) return color;
38
- if (/^\d/.test(v) || v === "0" || v.includes("px") || v.slice(-2) === "em") return v;
39
- if (v === "inset" || v === "none") return v;
40
- const spacing = getSpacingByKey(v, "shadow");
41
- if (spacing && spacing.shadow) return spacing.shadow;
42
- return v;
43
- }).join(" ");
44
- }).join(", ");
45
- }
46
- const vp = CONFIG.varPrefix ? CONFIG.varPrefix + "-" : "";
47
- const CSSVar = `--${vp}shadow-${key}` + (suffix ? `-${suffix}` : "");
48
- if (CONFIG.useVariable) {
49
- CONFIG.cssVars[CSSVar] = value;
50
- }
51
- return {
52
- var: CSSVar,
53
- value
54
- };
55
- };
56
- const getShadow = (value, globalTheme) => {
57
- const CONFIG = getActiveConfig();
58
- if (!globalTheme) globalTheme = CONFIG.globalTheme;
59
- if (!isString(value)) {
60
- if (CONFIG.verbose) console.warn(value, "- type for color is not valid");
61
- return;
62
- }
63
- if (isCSSVar(value)) return `var(${value})`;
64
- const [name] = isArray(value) ? value : value.split(" ");
65
- const SHADOW = CONFIG.shadow;
66
- const val = SHADOW[name];
67
- const isObj = isObject(val);
68
- if (!val) {
69
- if (CONFIG.verbose) console.warn("Can't find color ", name);
70
- return value;
71
- }
72
- if (globalTheme) {
73
- if (val[globalTheme]) return val[globalTheme].value;
74
- else if (CONFIG.verbose) console.warn(value, " - does not have ", globalTheme);
75
- }
76
- if (isObj && val.value) return val.value;
77
- if (isObj) {
78
- const obj = {};
79
- for (const mediaName in val) {
80
- const query = CONFIG.media[mediaName.slice(1)];
81
- const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
82
- obj[media] = val.value;
83
- }
84
- return obj;
85
- }
86
- if (CONFIG.verbose) console.warn("Can't find color", value);
87
- return value;
88
- };
89
- export {
90
- getShadow,
91
- setShadow
92
- };
@@ -1,121 +0,0 @@
1
- import { arrayzeValue } from "@symbo.ls/utils";
2
- import { isArray, isString, merge } from "@symbo.ls/utils";
3
- import { getActiveConfig } from "../factory.js";
4
- import {
5
- CSS_UNITS,
6
- applyMediaSequenceVars,
7
- applySequenceVars,
8
- generateSequence,
9
- getFnPrefixAndValue,
10
- getSequenceValuePropertyPair
11
- } from "../utils/index.js";
12
- const runThroughMedia = (FACTORY) => {
13
- for (const prop in FACTORY) {
14
- const mediaProps = FACTORY[prop];
15
- const isMediaName = prop.slice(0, 1) === "@";
16
- if (!isMediaName) continue;
17
- const { type, base, ratio, range, subSequence, h1Matches, unit } = FACTORY;
18
- merge(mediaProps, {
19
- type,
20
- base,
21
- ratio,
22
- range,
23
- subSequence,
24
- h1Matches,
25
- unit,
26
- sequence: {},
27
- scales: {},
28
- templates: {},
29
- vars: {}
30
- });
31
- generateSequence(mediaProps);
32
- applyMediaSequenceVars(FACTORY, prop);
33
- }
34
- };
35
- const checkIfBoxSize = (propertyName) => {
36
- const prop = propertyName.toLowerCase();
37
- const includesWidth = prop.includes("width") || prop.includes("height");
38
- const includesBorder = prop.includes("border") || prop.includes("outline");
39
- return includesWidth && !includesBorder;
40
- };
41
- const applySpacingSequence = () => {
42
- const CONFIG = getActiveConfig();
43
- const { spacing: SPACING } = CONFIG;
44
- generateSequence(SPACING);
45
- applySequenceVars(SPACING);
46
- runThroughMedia(SPACING);
47
- };
48
- const getSequence = (sequenceProps) => {
49
- const CONFIG = getActiveConfig();
50
- const { spacing: SPACING } = CONFIG;
51
- if (!sequenceProps || !sequenceProps.sequence) return SPACING;
52
- const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
53
- return hasGenerated ? sequenceProps : generateSequence(sequenceProps);
54
- };
55
- const getSpacingByKey = (value, propertyName = "padding", sequenceProps, fnPrefix) => {
56
- const sequence = getSequence(sequenceProps);
57
- if (isString(value)) {
58
- if (!fnPrefix && value.includes("(")) {
59
- const fnArray = getFnPrefixAndValue(value);
60
- fnPrefix = fnArray[0];
61
- value = fnArray[1];
62
- }
63
- }
64
- const stack = fnPrefix ? [value] : arrayzeValue(value);
65
- if (!isArray(stack)) return;
66
- if (stack.length > 1) {
67
- let suffix = "";
68
- if (propertyName === "borderWidth") {
69
- propertyName = "border";
70
- suffix = "Width";
71
- }
72
- const directions = {
73
- 2: ["Block", "Inline"],
74
- 3: ["BlockStart", "Inline", "BlockEnd"],
75
- 4: ["BlockStart", "InlineEnd", "BlockEnd", "InlineStart"]
76
- };
77
- const wrapSequenceValueByDirection = (direction, i) => getSequenceValuePropertyPair(
78
- stack[i],
79
- propertyName + direction + suffix,
80
- sequence,
81
- fnPrefix
82
- );
83
- return directions[stack.length].map(
84
- (dir, key) => wrapSequenceValueByDirection(dir, key)
85
- );
86
- }
87
- return getSequenceValuePropertyPair(value, propertyName, sequence, fnPrefix);
88
- };
89
- const getSpacingBasedOnRatio = (props, propertyName, val, fnPrefix) => {
90
- const CONFIG = getActiveConfig();
91
- const { spacing: SPACING } = CONFIG;
92
- let value = val || props[propertyName];
93
- if (!fnPrefix && isString(value) && value.includes("(")) {
94
- const fnArr = getFnPrefixAndValue(value);
95
- fnPrefix = fnArr[0];
96
- value = fnArr[1];
97
- }
98
- if (props.spacingRatio) {
99
- const sequenceProps = applyCustomSequence(props);
100
- return getSpacingByKey(value, propertyName, sequenceProps, fnPrefix);
101
- }
102
- return getSpacingByKey(value, propertyName, SPACING, fnPrefix);
103
- };
104
- const splitSpacedValue = (val) => {
105
- const addDefault = (v) => {
106
- const isSymbol = ["+", "-", "*", "/"].includes(v);
107
- const hasUnits = CSS_UNITS.some((unit) => val.includes(unit));
108
- if (isSymbol || hasUnits) return v;
109
- const isSingleLetter = v.length < 3 && /[A-Z]/.test(v);
110
- if (isSingleLetter) return v + "_default";
111
- return v;
112
- };
113
- return val.split(",").map((v) => v.trim()).map(addDefault).join(",").split(" ").map(addDefault).join(" ");
114
- };
115
- export {
116
- applySpacingSequence,
117
- checkIfBoxSize,
118
- getSpacingBasedOnRatio,
119
- getSpacingByKey,
120
- splitSpacedValue
121
- };