@symbo.ls/scratch 2.10.162 → 2.10.164

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 (40) hide show
  1. package/package.json +5 -5
  2. package/dist/esm/defaultConfig/animation.js +0 -4
  3. package/dist/esm/defaultConfig/cases.js +0 -4
  4. package/dist/esm/defaultConfig/color.js +0 -12
  5. package/dist/esm/defaultConfig/document.js +0 -4
  6. package/dist/esm/defaultConfig/font-family.js +0 -19
  7. package/dist/esm/defaultConfig/font.js +0 -13
  8. package/dist/esm/defaultConfig/icons.js +0 -4
  9. package/dist/esm/defaultConfig/index.js +0 -20
  10. package/dist/esm/defaultConfig/media.js +0 -19
  11. package/dist/esm/defaultConfig/responsive.js +0 -28
  12. package/dist/esm/defaultConfig/sequence.js +0 -29
  13. package/dist/esm/defaultConfig/spacing.js +0 -16
  14. package/dist/esm/defaultConfig/svg.js +0 -6
  15. package/dist/esm/defaultConfig/theme.js +0 -16
  16. package/dist/esm/defaultConfig/timing.js +0 -16
  17. package/dist/esm/defaultConfig/typography.js +0 -19
  18. package/dist/esm/defaultConfig/unit.js +0 -6
  19. package/dist/esm/factory.js +0 -39
  20. package/dist/esm/index.js +0 -4
  21. package/dist/esm/set.js +0 -113
  22. package/dist/esm/system/color.js +0 -156
  23. package/dist/esm/system/document.js +0 -15
  24. package/dist/esm/system/font.js +0 -35
  25. package/dist/esm/system/index.js +0 -9
  26. package/dist/esm/system/reset.js +0 -63
  27. package/dist/esm/system/spacing.js +0 -115
  28. package/dist/esm/system/svg.js +0 -61
  29. package/dist/esm/system/theme.js +0 -240
  30. package/dist/esm/system/timing.js +0 -32
  31. package/dist/esm/system/typography.js +0 -80
  32. package/dist/esm/tests/index.js +0 -8
  33. package/dist/esm/utils/color.js +0 -143
  34. package/dist/esm/utils/font.js +0 -50
  35. package/dist/esm/utils/index.js +0 -6
  36. package/dist/esm/utils/object.js +0 -53
  37. package/dist/esm/utils/sequence.js +0 -179
  38. package/dist/esm/utils/sprite.js +0 -43
  39. package/dist/esm/utils/theme.js +0 -12
  40. package/dist/esm/utils/var.js +0 -44
@@ -1,63 +0,0 @@
1
- import { getActiveConfig } from "../factory.js";
2
- import { getMediaTheme } from ".";
3
- import { deepMerge, merge } from "@domql/utils";
4
- const applyReset = (reset = {}) => {
5
- const CONFIG = getActiveConfig();
6
- const { CSS_VARS, RESET, TYPOGRAPHY, DOCUMENT } = CONFIG;
7
- if (RESET) {
8
- if (RESET[":root"]) {
9
- const configReset = RESET;
10
- const configTemplates = TYPOGRAPHY.templates;
11
- configReset.body = {
12
- ...getMediaTheme("document", `@${CONFIG.globalTheme}`),
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
- return deepMerge(merge(RESET, reset), {
24
- html: {
25
- position: "absolute",
26
- overflow: "hidden",
27
- width: "100%",
28
- height: "100%",
29
- top: "0",
30
- left: "0",
31
- margin: "0",
32
- WebkitFontSmoothing: "antialiased",
33
- transform: "translate3d(0, 0, 1px)",
34
- scrollBehavior: "smooth",
35
- fontSize: TYPOGRAPHY.browserDefault + "px",
36
- fontFamily: DOCUMENT.fontFamily,
37
- lineHeight: DOCUMENT.lineHeight
38
- },
39
- body: {
40
- boxSizing: "border-box",
41
- height: "100%",
42
- margin: 0,
43
- fontFamily: DOCUMENT.fontFamily,
44
- fontSize: TYPOGRAPHY.base / TYPOGRAPHY.browserDefault + CONFIG.UNIT.default,
45
- ...CONFIG.useDocumentTheme ? getMediaTheme("document", `@${CONFIG.globalTheme}`) : {},
46
- ...templates,
47
- ...body
48
- },
49
- // form elements
50
- fieldset: {
51
- border: 0,
52
- padding: 0,
53
- margin: 0
54
- },
55
- "select, input": {
56
- fontFamily: DOCUMENT.fontFamily
57
- }
58
- });
59
- }
60
- };
61
- export {
62
- applyReset
63
- };
@@ -1,115 +0,0 @@
1
- import { getActiveConfig } from "../factory.js";
2
- import { isString } from "@domql/utils";
3
- import {
4
- applySequenceVars,
5
- arrayze,
6
- generateSequence,
7
- getSequenceValuePropertyPair,
8
- merge
9
- } from "../utils";
10
- const runThroughMedia = (sequenceProps) => {
11
- for (const prop in sequenceProps) {
12
- const mediaProps = sequenceProps[prop];
13
- if (prop.slice(0, 1) === "@") {
14
- const { type, base, ratio, range, subSequence, h1Matches, unit } = sequenceProps;
15
- merge(mediaProps, {
16
- type,
17
- base,
18
- ratio,
19
- range,
20
- subSequence,
21
- h1Matches,
22
- unit,
23
- sequence: {},
24
- scales: {},
25
- templates: {},
26
- vars: {}
27
- });
28
- generateSequence(mediaProps);
29
- const mediaName = prop.slice(1);
30
- applySequenceVars(mediaProps, mediaName);
31
- }
32
- }
33
- };
34
- const applySpacingSequence = () => {
35
- const CONFIG = getActiveConfig();
36
- const { SPACING } = CONFIG;
37
- generateSequence(SPACING);
38
- applySequenceVars(SPACING);
39
- runThroughMedia(SPACING);
40
- };
41
- const getSequence = (sequenceProps) => {
42
- const CONFIG = getActiveConfig();
43
- const { SPACING } = CONFIG;
44
- if (!sequenceProps)
45
- return SPACING;
46
- const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
47
- return hasGenerated ? sequenceProps : generateSequence(sequenceProps);
48
- };
49
- const getSpacingByKey = (value, propertyName = "padding", sequenceProps) => {
50
- const sequence = getSequence(sequenceProps);
51
- const stack = arrayze(value);
52
- if (!stack)
53
- return;
54
- if (isString(value) && value.includes("calc")) {
55
- return { [propertyName]: value };
56
- }
57
- if (stack.length > 1) {
58
- let suffix = "";
59
- if (propertyName === "borderWidth") {
60
- propertyName = "border";
61
- suffix = "Width";
62
- }
63
- const directions = {
64
- 2: ["Block", "Inline"],
65
- 3: ["BlockStart", "Inline", "BlockEnd"],
66
- 4: ["BlockStart", "InlineEnd", "BlockEnd", "InlineStart"]
67
- };
68
- const wrapSequenceValueByDirection = (direction, i) => getSequenceValuePropertyPair(
69
- stack[i],
70
- propertyName + direction + suffix,
71
- sequence
72
- );
73
- return directions[stack.length].map((dir, key) => wrapSequenceValueByDirection(dir, key));
74
- }
75
- return getSequenceValuePropertyPair(
76
- value,
77
- propertyName,
78
- sequence
79
- );
80
- };
81
- const getSpacingBasedOnRatio = (props, propertyName, val) => {
82
- const CONFIG = getActiveConfig();
83
- const { SPACING } = CONFIG;
84
- const { spacingRatio, unit } = props;
85
- const value = val || props[propertyName];
86
- if (spacingRatio) {
87
- let sequenceProps = SPACING[spacingRatio];
88
- if (!sequenceProps) {
89
- const { type, base, range, subSequence } = SPACING;
90
- sequenceProps = SPACING[spacingRatio] = merge({
91
- ratio: spacingRatio,
92
- type: type + "-" + spacingRatio,
93
- unit,
94
- sequence: {},
95
- scales: {},
96
- templates: {},
97
- vars: {}
98
- }, {
99
- base,
100
- range,
101
- subSequence,
102
- ratio: SPACING.ratio,
103
- unit: SPACING.unit
104
- });
105
- }
106
- applySequenceVars(sequenceProps, null, { useDefault: false });
107
- return getSpacingByKey(value, propertyName, sequenceProps);
108
- }
109
- return getSpacingByKey(value, propertyName);
110
- };
111
- export {
112
- applySpacingSequence,
113
- getSpacingBasedOnRatio,
114
- getSpacingByKey
115
- };
@@ -1,61 +0,0 @@
1
- import { document } from "@domql/globals";
2
- import { generateSprite, convertSvgToSymbol } from "../utils";
3
- import { getActiveConfig } from "../factory.js";
4
- const DEF_OPTIONS = {
5
- document
6
- };
7
- const setSVG = (val, key) => {
8
- if (!val) {
9
- if (CONFIG.verbose)
10
- console.warn("setSVG: val is not defined", key);
11
- return;
12
- }
13
- const CONFIG = getActiveConfig();
14
- if (CONFIG.useSvgSprite) {
15
- return convertSvgToSymbol(key, val);
16
- }
17
- return val;
18
- };
19
- const appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
20
- const CONFIG = getActiveConfig();
21
- const doc = options.document || document;
22
- const lib = Object.keys(LIBRARY).length ? {} : CONFIG.SVG;
23
- for (let key in LIBRARY)
24
- lib[key] = CONFIG.SVG[key];
25
- const SVGsprite = generateSprite(lib);
26
- if (!doc) {
27
- console.warn("To append SVG sprites it should be run in browser environment");
28
- return SVGsprite;
29
- }
30
- const svgSpriteDOM = doc.createElement("template");
31
- svgSpriteDOM.innerHTML = SVGsprite;
32
- doc.body.appendChild(svgSpriteDOM.content);
33
- };
34
- const setIcon = (val, key) => {
35
- const CONFIG = getActiveConfig();
36
- if (CONFIG.useIconSprite) {
37
- return setSVG(val, key);
38
- }
39
- return val;
40
- };
41
- const appendIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
42
- const CONFIG = getActiveConfig();
43
- const doc = options.document || document;
44
- const lib = Object.keys(LIBRARY).length ? {} : CONFIG.ICONS;
45
- for (let key in LIBRARY)
46
- lib[key] = CONFIG.ICONS[key];
47
- const SVGsprite = generateSprite(lib);
48
- if (!doc) {
49
- console.warn("To append SVG Icon sprites it should be run in browser environment");
50
- return SVGsprite;
51
- }
52
- const iconsSpriteDOM = doc.createElement("template");
53
- iconsSpriteDOM.innerHTML = SVGsprite;
54
- doc.body.appendChild(iconsSpriteDOM.content);
55
- };
56
- export {
57
- appendIconsSprite,
58
- appendSVGSprite,
59
- setIcon,
60
- setSVG
61
- };
@@ -1,240 +0,0 @@
1
- import { getColor } from "./color";
2
- import { getActiveConfig } from "../factory.js";
3
- import {
4
- isObject,
5
- isString,
6
- isObjectLike,
7
- isArray
8
- } from "@domql/utils";
9
- const ENV = "development";
10
- const setThemeValue = (theme) => {
11
- const value = {};
12
- const { state, media, helpers, ...rest } = theme;
13
- const keys = Object.keys(rest);
14
- keys.map((key) => {
15
- const conditions = ["color", "Color", "background", "border"];
16
- const isColor = conditions.some((k) => key.includes(k));
17
- return value[key] = isColor ? getColor(theme[key]) : theme[key];
18
- });
19
- return value;
20
- };
21
- const getThemeValue = (theme) => {
22
- if (theme.value)
23
- return theme.value;
24
- theme.value = setThemeValue(theme);
25
- return theme.value;
26
- };
27
- const getTheme = (value, modifier) => {
28
- const CONFIG = getActiveConfig();
29
- if (CONFIG.useVariable)
30
- return getMediaTheme(value, modifier);
31
- const { THEME } = CONFIG;
32
- if (isString(value)) {
33
- const [theme, subtheme] = value.split(" ");
34
- const isOurTheme = THEME[theme];
35
- if (isOurTheme) {
36
- if (!subtheme && !modifier)
37
- return getThemeValue(isOurTheme);
38
- value = [theme, subtheme || modifier];
39
- }
40
- }
41
- if (isObjectLike(value) && value[1]) {
42
- const themeName = value[0];
43
- const subThemeName = value[1];
44
- const { helpers, media, state } = THEME[themeName];
45
- if (media && media[subThemeName])
46
- return getThemeValue(media[subThemeName]);
47
- if (helpers && helpers[subThemeName])
48
- return getThemeValue(helpers[subThemeName]);
49
- if (state && state[subThemeName])
50
- return getThemeValue(state[subThemeName]);
51
- } else if (isObject(value))
52
- return setThemeValue(value);
53
- };
54
- const setInverseTheme = (theme, variant, value) => {
55
- if (isObject(variant)) {
56
- theme.variants.inverse.value = setThemeValue(variant);
57
- } else if (variant === true) {
58
- const { color, background } = value;
59
- theme.variants.inverse = {
60
- value: {
61
- color: background,
62
- background: color
63
- }
64
- };
65
- }
66
- };
67
- const setPseudo = (theme, key, variant, themeValue) => {
68
- const result = getTheme(variant);
69
- themeValue[`&:${key}`] = result;
70
- if (isObject(variant) && !variant.value)
71
- variant.value = result;
72
- };
73
- const setSelectors = (theme, value) => {
74
- const { state } = theme;
75
- if (!state)
76
- return;
77
- const keys = Object.keys(state);
78
- keys.map((key) => {
79
- const variant = state[key];
80
- setPseudo(theme, key, variant, value);
81
- return theme;
82
- });
83
- return theme;
84
- };
85
- const setPrefersScheme = (theme, key, variant, themeValue) => {
86
- const result = getTheme(variant);
87
- themeValue[`@media (prefers-color-scheme: ${key})`] = result;
88
- if (isObject(variant) && !variant.value)
89
- variant.value = result;
90
- };
91
- const setMedia = (theme, value) => {
92
- const { media } = theme;
93
- if (!media)
94
- return;
95
- const keys = Object.keys(media);
96
- keys.map((key) => {
97
- const variant = media[key];
98
- if (key === "dark" || key === "light")
99
- setPrefersScheme(theme, key, variant, value);
100
- if (key === "inverse")
101
- setInverseTheme(theme, variant, value);
102
- return theme;
103
- });
104
- return theme;
105
- };
106
- const setHelpers = (theme, value) => {
107
- const CONFIG = getActiveConfig();
108
- const { helpers } = theme;
109
- if (!helpers)
110
- return;
111
- const keys = Object.keys(helpers);
112
- keys.map((key) => {
113
- const helper = helpers[key];
114
- if (isString(helper))
115
- helpers[key] = CONFIG.THEME[helper];
116
- else
117
- getThemeValue(helpers[key]);
118
- return theme;
119
- });
120
- return theme;
121
- };
122
- const setTheme = (val, key) => {
123
- const CONFIG = getActiveConfig();
124
- if (CONFIG.useVariable)
125
- return setMediaTheme(val, key);
126
- const { state, media, helpers } = val;
127
- const value = setThemeValue(val, key);
128
- const CSSvar = `--theme-${key}`;
129
- setSelectors(val, value);
130
- setMedia(val, value);
131
- setHelpers(val, value);
132
- return { var: CSSvar, value, state, media, helpers };
133
- };
134
- const keySetters = {
135
- // eslint-disable-line
136
- "@": (theme, value) => setMedia(theme, value),
137
- ":": (theme, value) => setSelectors(theme, value),
138
- ".": (theme, value) => setHelpers(theme, value)
139
- };
140
- const setMediaTheme = (val, key, suffix, prefers) => {
141
- const CONFIG = getActiveConfig();
142
- const { CSS_VARS } = CONFIG;
143
- const theme = { value: val };
144
- if (isObjectLike(val)) {
145
- for (const param in val) {
146
- const symb = param.slice(0, 1);
147
- const value = val[param];
148
- if (symb === "@" || symb === ":" || symb === ".") {
149
- const hasPrefers = symb === "@" && param;
150
- theme[param] = setMediaTheme(value, key, param, prefers || hasPrefers);
151
- } else {
152
- const color = getColor(value, prefers);
153
- const metaSuffixes = [...new Set([prefers, suffix].filter((v) => v).map((v) => v.slice(1)))];
154
- const varmetaSuffixName = metaSuffixes.length ? "-" + metaSuffixes.join("-") : "";
155
- const CSSVar = `--theme-${key}${varmetaSuffixName}-${param}`;
156
- if (CONFIG.useVariable) {
157
- CSS_VARS[CSSVar] = color;
158
- theme[param] = `var(${CSSVar})`;
159
- } else {
160
- theme[param] = color;
161
- }
162
- theme[`.${param}`] = { [param]: theme[param] };
163
- }
164
- }
165
- if (theme["background"] || theme["color"] || theme["backgroundColor"]) {
166
- theme[".inversed"] = {
167
- color: theme["background"] || theme["backgroundColor"],
168
- background: theme["color"]
169
- };
170
- }
171
- }
172
- if (isString(val) && val.slice(0, 2) === "--") {
173
- const { THEME } = CONFIG;
174
- const value = THEME[val.slice(2)];
175
- const getReferenced = getMediaTheme(value, prefers);
176
- return getReferenced;
177
- }
178
- return theme;
179
- };
180
- const recursiveTheme = (val) => {
181
- const CONFIG = getActiveConfig();
182
- const obj = {};
183
- for (const param in val) {
184
- const symb = param.slice(0, 1);
185
- if (isObjectLike(val[param])) {
186
- if (symb === "@") {
187
- const query = CONFIG.MEDIA[param.slice(1)];
188
- const media = `@media screen and ${query}`;
189
- obj[media] = recursiveTheme(val[param]);
190
- } else if (symb === ":") {
191
- obj[`&${param}`] = recursiveTheme(val[param]);
192
- }
193
- } else
194
- obj[param] = val[param];
195
- }
196
- return obj;
197
- };
198
- const findModifierFromArray = (val, modifierArray) => {
199
- const currentMod = modifierArray.shift();
200
- if (val[currentMod])
201
- return findModifierFromArray(val[currentMod], modifierArray);
202
- return val;
203
- };
204
- const findModifier = (val, modifier) => {
205
- if (isArray(modifier))
206
- return findModifierFromArray(val, modifier);
207
- else if (isString(modifier) && val[modifier])
208
- return val[modifier];
209
- else
210
- return val;
211
- };
212
- const checkForReference = (val, callback) => {
213
- if (isString(val) && val.slice(0, 2) === "--")
214
- return getMediaTheme(val.slice(2));
215
- return val;
216
- };
217
- const checkThemeReference = (val) => checkForReference(val, checkThemeReference);
218
- const getMediaTheme = (val, mod) => {
219
- const CONFIG = getActiveConfig();
220
- if (isString(val) && val.slice(0, 2) === "--")
221
- val = getMediaTheme(val.slice(2));
222
- if (!val || !isString(val)) {
223
- if (CONFIG.verbose)
224
- console.warn(val, "- theme is not string");
225
- return;
226
- }
227
- const [name, ...modifier] = isArray(val) ? val : val.split(" ");
228
- let value = CONFIG.THEME[name];
229
- if (value && (modifier || mod)) {
230
- value = findModifier(value, modifier.length ? modifier : mod);
231
- }
232
- const r = recursiveTheme(value);
233
- return r;
234
- };
235
- export {
236
- getMediaTheme,
237
- getTheme,
238
- setMediaTheme,
239
- setTheme
240
- };
@@ -1,32 +0,0 @@
1
- import { toCamelCase } from "@symbo.ls/utils";
2
- import { getActiveConfig } from "../factory.js";
3
- import {
4
- applySequenceVars,
5
- generateSequence,
6
- getSequenceValuePropertyPair
7
- } from "../utils";
8
- const applyTimingSequence = () => {
9
- const CONFIG = getActiveConfig();
10
- const { TIMING } = CONFIG;
11
- generateSequence(TIMING);
12
- applySequenceVars(TIMING);
13
- };
14
- const getTimingFunction = (value) => {
15
- const CONFIG = getActiveConfig();
16
- const { TIMING } = CONFIG;
17
- return TIMING[value] || TIMING[toCamelCase(value)] || value;
18
- };
19
- const getTimingByKey = (value, property = "timing") => {
20
- const CONFIG = getActiveConfig();
21
- const { TIMING } = CONFIG;
22
- return getSequenceValuePropertyPair(
23
- value,
24
- property,
25
- TIMING
26
- );
27
- };
28
- export {
29
- applyTimingSequence,
30
- getTimingByKey,
31
- getTimingFunction
32
- };
@@ -1,80 +0,0 @@
1
- import { getActiveConfig } from "../factory.js";
2
- import {
3
- applySequenceVars,
4
- findHeadings,
5
- generateSequence,
6
- getSequenceValuePropertyPair,
7
- merge
8
- } from "../utils";
9
- const runThroughMedia = (props) => {
10
- const CONFIG = getActiveConfig();
11
- const { TYPOGRAPHY, MEDIA } = CONFIG;
12
- for (const prop in props) {
13
- const mediaProps = props[prop];
14
- if (prop.slice(0, 1) === "@") {
15
- const { type, base, ratio, range, subSequence, h1Matches, unit } = props;
16
- merge(mediaProps, {
17
- type,
18
- base,
19
- ratio,
20
- range,
21
- subSequence,
22
- h1Matches,
23
- unit,
24
- sequence: {},
25
- scales: {},
26
- templates: {},
27
- vars: {}
28
- });
29
- generateSequence(mediaProps);
30
- const mediaName = prop.slice(1);
31
- applySequenceVars(mediaProps, mediaName);
32
- const query = MEDIA[mediaName];
33
- TYPOGRAPHY.templates[`@media screen and ${query}`] = {
34
- fontSize: mediaProps.base / TYPOGRAPHY.browserDefault + unit
35
- };
36
- }
37
- }
38
- };
39
- const applyHeadings = (props) => {
40
- const CONFIG = getActiveConfig();
41
- if (props.h1Matches) {
42
- const unit = props.unit;
43
- const HEADINGS = findHeadings(props);
44
- const { templates } = props;
45
- for (const k in HEADINGS) {
46
- const headerName = `h${parseInt(k) + 1}`;
47
- const headerStyle = templates[headerName];
48
- templates[headerName] = {
49
- fontSize: CONFIG.useVariable ? `var(${HEADINGS[k].variable})` : `${HEADINGS[k].scaling}${unit}`,
50
- margin: headerStyle ? headerStyle.margin : 0,
51
- lineHeight: headerStyle ? headerStyle.lineHeight : props.lineHeight,
52
- letterSpacing: headerStyle ? headerStyle.letterSpacing : props.letterSpacing,
53
- fontWeight: headerStyle ? headerStyle.fontWeight : 900 - k * 100
54
- };
55
- }
56
- }
57
- };
58
- const applyTypographySequence = () => {
59
- const CONFIG = getActiveConfig();
60
- const { TYPOGRAPHY } = CONFIG;
61
- generateSequence(TYPOGRAPHY);
62
- applyHeadings(TYPOGRAPHY);
63
- applySequenceVars(TYPOGRAPHY);
64
- runThroughMedia(TYPOGRAPHY);
65
- };
66
- const getFontSizeByKey = (value) => {
67
- const CONFIG = getActiveConfig();
68
- const { TYPOGRAPHY } = CONFIG;
69
- return getSequenceValuePropertyPair(
70
- value,
71
- "fontSize",
72
- TYPOGRAPHY
73
- );
74
- };
75
- export {
76
- applyHeadings,
77
- applyTypographySequence,
78
- getFontSizeByKey,
79
- runThroughMedia
80
- };
@@ -1,8 +0,0 @@
1
- const testWCAGAA = (colorA, colorB) => {
2
- };
3
- const testWCAGAAA = (colorA, colorB) => {
4
- };
5
- export {
6
- testWCAGAA,
7
- testWCAGAAA
8
- };