@symbo.ls/scratch 2.10.149 → 2.10.156

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 (82) hide show
  1. package/dist/cjs/defaultConfig/animation.js +24 -0
  2. package/dist/cjs/defaultConfig/cases.js +24 -0
  3. package/dist/cjs/defaultConfig/color.js +32 -0
  4. package/dist/cjs/defaultConfig/document.js +24 -0
  5. package/dist/cjs/defaultConfig/font-family.js +39 -0
  6. package/dist/cjs/defaultConfig/font.js +33 -0
  7. package/dist/cjs/defaultConfig/icons.js +24 -0
  8. package/dist/cjs/defaultConfig/index.js +41 -0
  9. package/dist/cjs/defaultConfig/media.js +39 -0
  10. package/dist/cjs/defaultConfig/responsive.js +48 -0
  11. package/dist/cjs/defaultConfig/sequence.js +49 -0
  12. package/dist/cjs/defaultConfig/spacing.js +36 -0
  13. package/dist/cjs/defaultConfig/svg.js +26 -0
  14. package/dist/cjs/defaultConfig/theme.js +36 -0
  15. package/dist/cjs/defaultConfig/timing.js +36 -0
  16. package/dist/cjs/defaultConfig/typography.js +39 -0
  17. package/dist/cjs/defaultConfig/unit.js +26 -0
  18. package/dist/cjs/factory.js +69 -0
  19. package/dist/cjs/index.js +21 -0
  20. package/dist/cjs/package.json +4 -0
  21. package/dist/cjs/set.js +121 -0
  22. package/dist/cjs/system/color.js +169 -0
  23. package/dist/cjs/system/document.js +35 -0
  24. package/dist/cjs/system/font.js +50 -0
  25. package/dist/cjs/system/index.js +26 -0
  26. package/dist/cjs/system/reset.js +83 -0
  27. package/dist/cjs/system/spacing.js +129 -0
  28. package/dist/cjs/system/svg.js +81 -0
  29. package/dist/cjs/system/theme.js +255 -0
  30. package/dist/cjs/system/timing.js +48 -0
  31. package/dist/cjs/system/typography.js +94 -0
  32. package/dist/cjs/tests/index.js +28 -0
  33. package/dist/cjs/utils/color.js +163 -0
  34. package/dist/cjs/utils/font.js +70 -0
  35. package/dist/cjs/utils/index.js +23 -0
  36. package/dist/cjs/utils/object.js +73 -0
  37. package/dist/cjs/utils/sequence.js +199 -0
  38. package/dist/cjs/utils/sprite.js +63 -0
  39. package/dist/cjs/utils/theme.js +32 -0
  40. package/dist/cjs/utils/var.js +64 -0
  41. package/dist/esm/defaultConfig/animation.js +4 -0
  42. package/dist/esm/defaultConfig/cases.js +4 -0
  43. package/dist/esm/defaultConfig/color.js +12 -0
  44. package/dist/esm/defaultConfig/document.js +4 -0
  45. package/dist/esm/defaultConfig/font-family.js +19 -0
  46. package/dist/esm/defaultConfig/font.js +13 -0
  47. package/dist/esm/defaultConfig/icons.js +4 -0
  48. package/dist/esm/defaultConfig/index.js +20 -0
  49. package/dist/esm/defaultConfig/media.js +19 -0
  50. package/dist/esm/defaultConfig/responsive.js +28 -0
  51. package/dist/esm/defaultConfig/sequence.js +29 -0
  52. package/dist/esm/defaultConfig/spacing.js +16 -0
  53. package/dist/esm/defaultConfig/svg.js +6 -0
  54. package/dist/esm/defaultConfig/theme.js +16 -0
  55. package/dist/esm/defaultConfig/timing.js +16 -0
  56. package/dist/esm/defaultConfig/typography.js +19 -0
  57. package/dist/esm/defaultConfig/unit.js +6 -0
  58. package/dist/esm/factory.js +39 -0
  59. package/dist/esm/index.js +4 -0
  60. package/dist/esm/set.js +113 -0
  61. package/dist/esm/system/color.js +156 -0
  62. package/dist/esm/system/document.js +15 -0
  63. package/dist/esm/system/font.js +35 -0
  64. package/dist/esm/system/index.js +9 -0
  65. package/dist/esm/system/reset.js +63 -0
  66. package/dist/esm/system/spacing.js +115 -0
  67. package/dist/esm/system/svg.js +61 -0
  68. package/dist/esm/system/theme.js +240 -0
  69. package/dist/esm/system/timing.js +32 -0
  70. package/dist/esm/system/typography.js +80 -0
  71. package/dist/esm/tests/index.js +8 -0
  72. package/dist/esm/utils/color.js +143 -0
  73. package/dist/esm/utils/font.js +50 -0
  74. package/dist/esm/utils/index.js +6 -0
  75. package/dist/esm/utils/object.js +53 -0
  76. package/dist/esm/utils/sequence.js +179 -0
  77. package/dist/esm/utils/sprite.js +43 -0
  78. package/dist/esm/utils/theme.js +12 -0
  79. package/dist/esm/utils/var.js +44 -0
  80. package/package.json +15 -15
  81. package/dist/index.cjs.js +0 -2389
  82. package/dist/index.cjs.js.map +0 -7
@@ -0,0 +1,81 @@
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 svg_exports = {};
20
+ __export(svg_exports, {
21
+ appendIconsSprite: () => appendIconsSprite,
22
+ appendSVGSprite: () => appendSVGSprite,
23
+ setIcon: () => setIcon,
24
+ setSVG: () => setSVG
25
+ });
26
+ module.exports = __toCommonJS(svg_exports);
27
+ var import_globals = require("@domql/globals");
28
+ var import_utils = require("../utils");
29
+ var import_factory = require("../factory.js");
30
+ const DEF_OPTIONS = {
31
+ document: import_globals.document
32
+ };
33
+ const setSVG = (val, key) => {
34
+ if (!val) {
35
+ if (CONFIG.verbose)
36
+ console.warn("setSVG: val is not defined", key);
37
+ return;
38
+ }
39
+ const CONFIG = (0, import_factory.getActiveConfig)();
40
+ if (CONFIG.useSvgSprite) {
41
+ return (0, import_utils.convertSvgToSymbol)(key, val);
42
+ }
43
+ return val;
44
+ };
45
+ const appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
46
+ const CONFIG = (0, import_factory.getActiveConfig)();
47
+ const doc = options.document || import_globals.document;
48
+ const lib = Object.keys(LIBRARY).length ? {} : CONFIG.SVG;
49
+ for (let key in LIBRARY)
50
+ lib[key] = CONFIG.SVG[key];
51
+ const SVGsprite = (0, import_utils.generateSprite)(lib);
52
+ if (!doc) {
53
+ console.warn("To append SVG sprites it should be run in browser environment");
54
+ return SVGsprite;
55
+ }
56
+ const svgSpriteDOM = doc.createElement("template");
57
+ svgSpriteDOM.innerHTML = SVGsprite;
58
+ doc.body.appendChild(svgSpriteDOM.content);
59
+ };
60
+ const setIcon = (val, key) => {
61
+ const CONFIG = (0, import_factory.getActiveConfig)();
62
+ if (CONFIG.useIconSprite) {
63
+ return setSVG(val, key);
64
+ }
65
+ return val;
66
+ };
67
+ const appendIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
68
+ const CONFIG = (0, import_factory.getActiveConfig)();
69
+ const doc = options.document || import_globals.document;
70
+ const lib = Object.keys(LIBRARY).length ? {} : CONFIG.ICONS;
71
+ for (let key in LIBRARY)
72
+ lib[key] = CONFIG.ICONS[key];
73
+ const SVGsprite = (0, import_utils.generateSprite)(lib);
74
+ if (!doc) {
75
+ console.warn("To append SVG Icon sprites it should be run in browser environment");
76
+ return SVGsprite;
77
+ }
78
+ const iconsSpriteDOM = doc.createElement("template");
79
+ iconsSpriteDOM.innerHTML = SVGsprite;
80
+ doc.body.appendChild(iconsSpriteDOM.content);
81
+ };
@@ -0,0 +1,255 @@
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
+ getMediaTheme: () => getMediaTheme,
22
+ getTheme: () => getTheme,
23
+ setMediaTheme: () => setMediaTheme,
24
+ setTheme: () => setTheme
25
+ });
26
+ module.exports = __toCommonJS(theme_exports);
27
+ var import_color = require("./color");
28
+ var import_factory = require("../factory.js");
29
+ var import_utils = require("@domql/utils");
30
+ const ENV = "development";
31
+ const setThemeValue = (theme) => {
32
+ const value = {};
33
+ const { state, media, helpers, ...rest } = theme;
34
+ const keys = Object.keys(rest);
35
+ keys.map((key) => {
36
+ const conditions = ["color", "Color", "background", "border"];
37
+ const isColor = conditions.some((k) => key.includes(k));
38
+ return value[key] = isColor ? (0, import_color.getColor)(theme[key]) : theme[key];
39
+ });
40
+ return value;
41
+ };
42
+ const getThemeValue = (theme) => {
43
+ if (theme.value)
44
+ return theme.value;
45
+ theme.value = setThemeValue(theme);
46
+ return theme.value;
47
+ };
48
+ const getTheme = (value, modifier) => {
49
+ const CONFIG = (0, import_factory.getActiveConfig)();
50
+ if (CONFIG.useVariable)
51
+ return getMediaTheme(value, modifier);
52
+ const { THEME } = CONFIG;
53
+ if ((0, import_utils.isString)(value)) {
54
+ const [theme, subtheme] = value.split(" ");
55
+ const isOurTheme = THEME[theme];
56
+ if (isOurTheme) {
57
+ if (!subtheme && !modifier)
58
+ return getThemeValue(isOurTheme);
59
+ value = [theme, subtheme || modifier];
60
+ }
61
+ }
62
+ if ((0, import_utils.isObjectLike)(value) && value[1]) {
63
+ const themeName = value[0];
64
+ const subThemeName = value[1];
65
+ const { helpers, media, state } = THEME[themeName];
66
+ if (media && media[subThemeName])
67
+ return getThemeValue(media[subThemeName]);
68
+ if (helpers && helpers[subThemeName])
69
+ return getThemeValue(helpers[subThemeName]);
70
+ if (state && state[subThemeName])
71
+ return getThemeValue(state[subThemeName]);
72
+ } else if ((0, import_utils.isObject)(value))
73
+ return setThemeValue(value);
74
+ };
75
+ const setInverseTheme = (theme, variant, value) => {
76
+ if ((0, import_utils.isObject)(variant)) {
77
+ theme.variants.inverse.value = setThemeValue(variant);
78
+ } else if (variant === true) {
79
+ const { color, background } = value;
80
+ theme.variants.inverse = {
81
+ value: {
82
+ color: background,
83
+ background: color
84
+ }
85
+ };
86
+ }
87
+ };
88
+ const setPseudo = (theme, key, variant, themeValue) => {
89
+ const result = getTheme(variant);
90
+ themeValue[`&:${key}`] = result;
91
+ if ((0, import_utils.isObject)(variant) && !variant.value)
92
+ variant.value = result;
93
+ };
94
+ const setSelectors = (theme, value) => {
95
+ const { state } = theme;
96
+ if (!state)
97
+ return;
98
+ const keys = Object.keys(state);
99
+ keys.map((key) => {
100
+ const variant = state[key];
101
+ setPseudo(theme, key, variant, value);
102
+ return theme;
103
+ });
104
+ return theme;
105
+ };
106
+ const setPrefersScheme = (theme, key, variant, themeValue) => {
107
+ const result = getTheme(variant);
108
+ themeValue[`@media (prefers-color-scheme: ${key})`] = result;
109
+ if ((0, import_utils.isObject)(variant) && !variant.value)
110
+ variant.value = result;
111
+ };
112
+ const setMedia = (theme, value) => {
113
+ const { media } = theme;
114
+ if (!media)
115
+ return;
116
+ const keys = Object.keys(media);
117
+ keys.map((key) => {
118
+ const variant = media[key];
119
+ if (key === "dark" || key === "light")
120
+ setPrefersScheme(theme, key, variant, value);
121
+ if (key === "inverse")
122
+ setInverseTheme(theme, variant, value);
123
+ return theme;
124
+ });
125
+ return theme;
126
+ };
127
+ const setHelpers = (theme, value) => {
128
+ const CONFIG = (0, import_factory.getActiveConfig)();
129
+ const { helpers } = theme;
130
+ if (!helpers)
131
+ return;
132
+ const keys = Object.keys(helpers);
133
+ keys.map((key) => {
134
+ const helper = helpers[key];
135
+ if ((0, import_utils.isString)(helper))
136
+ helpers[key] = CONFIG.THEME[helper];
137
+ else
138
+ getThemeValue(helpers[key]);
139
+ return theme;
140
+ });
141
+ return theme;
142
+ };
143
+ const setTheme = (val, key) => {
144
+ const CONFIG = (0, import_factory.getActiveConfig)();
145
+ if (CONFIG.useVariable)
146
+ return setMediaTheme(val, key);
147
+ const { state, media, helpers } = val;
148
+ const value = setThemeValue(val, key);
149
+ const CSSvar = `--theme-${key}`;
150
+ setSelectors(val, value);
151
+ setMedia(val, value);
152
+ setHelpers(val, value);
153
+ return { var: CSSvar, value, state, media, helpers };
154
+ };
155
+ const keySetters = {
156
+ // eslint-disable-line
157
+ "@": (theme, value) => setMedia(theme, value),
158
+ ":": (theme, value) => setSelectors(theme, value),
159
+ ".": (theme, value) => setHelpers(theme, value)
160
+ };
161
+ const setMediaTheme = (val, key, suffix, prefers) => {
162
+ const CONFIG = (0, import_factory.getActiveConfig)();
163
+ const { CSS_VARS } = CONFIG;
164
+ const theme = { value: val };
165
+ if ((0, import_utils.isObjectLike)(val)) {
166
+ for (const param in val) {
167
+ const symb = param.slice(0, 1);
168
+ const value = val[param];
169
+ if (symb === "@" || symb === ":" || symb === ".") {
170
+ const hasPrefers = symb === "@" && param;
171
+ theme[param] = setMediaTheme(value, key, param, prefers || hasPrefers);
172
+ } else {
173
+ const color = (0, import_color.getColor)(value, prefers);
174
+ const metaSuffixes = [...new Set([prefers, suffix].filter((v) => v).map((v) => v.slice(1)))];
175
+ const varmetaSuffixName = metaSuffixes.length ? "-" + metaSuffixes.join("-") : "";
176
+ const CSSVar = `--theme-${key}${varmetaSuffixName}-${param}`;
177
+ if (CONFIG.useVariable) {
178
+ CSS_VARS[CSSVar] = color;
179
+ theme[param] = `var(${CSSVar})`;
180
+ } else {
181
+ theme[param] = color;
182
+ }
183
+ theme[`.${param}`] = { [param]: theme[param] };
184
+ }
185
+ }
186
+ if (theme["background"] || theme["color"] || theme["backgroundColor"]) {
187
+ theme[".inversed"] = {
188
+ color: theme["background"] || theme["backgroundColor"],
189
+ background: theme["color"]
190
+ };
191
+ }
192
+ }
193
+ if ((0, import_utils.isString)(val) && val.slice(0, 2) === "--") {
194
+ const { THEME } = CONFIG;
195
+ const value = THEME[val.slice(2)];
196
+ const getReferenced = getMediaTheme(value, prefers);
197
+ return getReferenced;
198
+ }
199
+ return theme;
200
+ };
201
+ const recursiveTheme = (val) => {
202
+ const CONFIG = (0, import_factory.getActiveConfig)();
203
+ const obj = {};
204
+ for (const param in val) {
205
+ const symb = param.slice(0, 1);
206
+ if ((0, import_utils.isObjectLike)(val[param])) {
207
+ if (symb === "@") {
208
+ const query = CONFIG.MEDIA[param.slice(1)];
209
+ const media = `@media screen and ${query}`;
210
+ obj[media] = recursiveTheme(val[param]);
211
+ } else if (symb === ":") {
212
+ obj[`&${param}`] = recursiveTheme(val[param]);
213
+ }
214
+ } else
215
+ obj[param] = val[param];
216
+ }
217
+ return obj;
218
+ };
219
+ const findModifierFromArray = (val, modifierArray) => {
220
+ const currentMod = modifierArray.shift();
221
+ if (val[currentMod])
222
+ return findModifierFromArray(val[currentMod], modifierArray);
223
+ return val;
224
+ };
225
+ const findModifier = (val, modifier) => {
226
+ if ((0, import_utils.isArray)(modifier))
227
+ return findModifierFromArray(val, modifier);
228
+ else if ((0, import_utils.isString)(modifier) && val[modifier])
229
+ return val[modifier];
230
+ else
231
+ return val;
232
+ };
233
+ const checkForReference = (val, callback) => {
234
+ if ((0, import_utils.isString)(val) && val.slice(0, 2) === "--")
235
+ return getMediaTheme(val.slice(2));
236
+ return val;
237
+ };
238
+ const checkThemeReference = (val) => checkForReference(val, checkThemeReference);
239
+ const getMediaTheme = (val, mod) => {
240
+ const CONFIG = (0, import_factory.getActiveConfig)();
241
+ if ((0, import_utils.isString)(val) && val.slice(0, 2) === "--")
242
+ val = getMediaTheme(val.slice(2));
243
+ if (!val || !(0, import_utils.isString)(val)) {
244
+ if (CONFIG.verbose)
245
+ console.warn(val, "- theme is not string");
246
+ return;
247
+ }
248
+ const [name, ...modifier] = (0, import_utils.isArray)(val) ? val : val.split(" ");
249
+ let value = CONFIG.THEME[name];
250
+ if (value && (modifier || mod)) {
251
+ value = findModifier(value, modifier.length ? modifier : mod);
252
+ }
253
+ const r = recursiveTheme(value);
254
+ return r;
255
+ };
@@ -0,0 +1,48 @@
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
+ applyTimingSequence: () => applyTimingSequence,
22
+ getTimingByKey: () => getTimingByKey,
23
+ getTimingFunction: () => getTimingFunction
24
+ });
25
+ module.exports = __toCommonJS(timing_exports);
26
+ var import_utils = require("@symbo.ls/utils");
27
+ var import_factory = require("../factory.js");
28
+ var import_utils2 = require("../utils");
29
+ const applyTimingSequence = () => {
30
+ const CONFIG = (0, import_factory.getActiveConfig)();
31
+ const { TIMING } = CONFIG;
32
+ (0, import_utils2.generateSequence)(TIMING);
33
+ (0, import_utils2.applySequenceVars)(TIMING);
34
+ };
35
+ const getTimingFunction = (value) => {
36
+ const CONFIG = (0, import_factory.getActiveConfig)();
37
+ const { TIMING } = CONFIG;
38
+ return TIMING[value] || TIMING[(0, import_utils.toCamelCase)(value)] || value;
39
+ };
40
+ const getTimingByKey = (value, property = "timing") => {
41
+ const CONFIG = (0, import_factory.getActiveConfig)();
42
+ const { TIMING } = CONFIG;
43
+ return (0, import_utils2.getSequenceValuePropertyPair)(
44
+ value,
45
+ property,
46
+ TIMING
47
+ );
48
+ };
@@ -0,0 +1,94 @@
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 typography_exports = {};
20
+ __export(typography_exports, {
21
+ applyHeadings: () => applyHeadings,
22
+ applyTypographySequence: () => applyTypographySequence,
23
+ getFontSizeByKey: () => getFontSizeByKey,
24
+ runThroughMedia: () => runThroughMedia
25
+ });
26
+ module.exports = __toCommonJS(typography_exports);
27
+ var import_factory = require("../factory.js");
28
+ var import_utils = require("../utils");
29
+ const runThroughMedia = (props) => {
30
+ const CONFIG = (0, import_factory.getActiveConfig)();
31
+ const { TYPOGRAPHY, MEDIA } = CONFIG;
32
+ for (const prop in props) {
33
+ const mediaProps = props[prop];
34
+ if (prop.slice(0, 1) === "@") {
35
+ const { type, base, ratio, range, subSequence, h1Matches, unit } = props;
36
+ (0, import_utils.merge)(mediaProps, {
37
+ type,
38
+ base,
39
+ ratio,
40
+ range,
41
+ subSequence,
42
+ h1Matches,
43
+ unit,
44
+ sequence: {},
45
+ scales: {},
46
+ templates: {},
47
+ vars: {}
48
+ });
49
+ (0, import_utils.generateSequence)(mediaProps);
50
+ const mediaName = prop.slice(1);
51
+ (0, import_utils.applySequenceVars)(mediaProps, mediaName);
52
+ const query = MEDIA[mediaName];
53
+ TYPOGRAPHY.templates[`@media screen and ${query}`] = {
54
+ fontSize: mediaProps.base / TYPOGRAPHY.browserDefault + unit
55
+ };
56
+ }
57
+ }
58
+ };
59
+ const applyHeadings = (props) => {
60
+ const CONFIG = (0, import_factory.getActiveConfig)();
61
+ if (props.h1Matches) {
62
+ const unit = props.unit;
63
+ const HEADINGS = (0, import_utils.findHeadings)(props);
64
+ const { templates } = props;
65
+ for (const k in HEADINGS) {
66
+ const headerName = `h${parseInt(k) + 1}`;
67
+ const headerStyle = templates[headerName];
68
+ templates[headerName] = {
69
+ fontSize: CONFIG.useVariable ? `var(${HEADINGS[k].variable})` : `${HEADINGS[k].scaling}${unit}`,
70
+ margin: headerStyle ? headerStyle.margin : 0,
71
+ lineHeight: headerStyle ? headerStyle.lineHeight : props.lineHeight,
72
+ letterSpacing: headerStyle ? headerStyle.letterSpacing : props.letterSpacing,
73
+ fontWeight: headerStyle ? headerStyle.fontWeight : 900 - k * 100
74
+ };
75
+ }
76
+ }
77
+ };
78
+ const applyTypographySequence = () => {
79
+ const CONFIG = (0, import_factory.getActiveConfig)();
80
+ const { TYPOGRAPHY } = CONFIG;
81
+ (0, import_utils.generateSequence)(TYPOGRAPHY);
82
+ applyHeadings(TYPOGRAPHY);
83
+ (0, import_utils.applySequenceVars)(TYPOGRAPHY);
84
+ runThroughMedia(TYPOGRAPHY);
85
+ };
86
+ const getFontSizeByKey = (value) => {
87
+ const CONFIG = (0, import_factory.getActiveConfig)();
88
+ const { TYPOGRAPHY } = CONFIG;
89
+ return (0, import_utils.getSequenceValuePropertyPair)(
90
+ value,
91
+ "fontSize",
92
+ TYPOGRAPHY
93
+ );
94
+ };
@@ -0,0 +1,28 @@
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 tests_exports = {};
20
+ __export(tests_exports, {
21
+ testWCAGAA: () => testWCAGAA,
22
+ testWCAGAAA: () => testWCAGAAA
23
+ });
24
+ module.exports = __toCommonJS(tests_exports);
25
+ const testWCAGAA = (colorA, colorB) => {
26
+ };
27
+ const testWCAGAAA = (colorA, colorB) => {
28
+ };
@@ -0,0 +1,163 @@
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 color_exports = {};
20
+ __export(color_exports, {
21
+ changeLightness: () => changeLightness,
22
+ colorStringToRgbaArray: () => colorStringToRgbaArray,
23
+ getColorShade: () => getColorShade,
24
+ hexToRgb: () => hexToRgb,
25
+ hexToRgbArray: () => hexToRgbArray,
26
+ hexToRgba: () => hexToRgba,
27
+ hslToRgb: () => hslToRgb,
28
+ mixTwoColors: () => mixTwoColors,
29
+ mixTwoRgb: () => mixTwoRgb,
30
+ mixTwoRgba: () => mixTwoRgba,
31
+ opacify: () => opacify,
32
+ rgbArrayToHex: () => rgbArrayToHex,
33
+ rgbToHSL: () => rgbToHSL,
34
+ rgbToHex: () => rgbToHex
35
+ });
36
+ module.exports = __toCommonJS(color_exports);
37
+ var import_globals = require("@domql/globals");
38
+ const ENV = "development";
39
+ const colorStringToRgbaArray = (color) => {
40
+ if (color === "")
41
+ return;
42
+ if (color.toLowerCase() === "transparent")
43
+ return [0, 0, 0, 0];
44
+ if (color[0] === "#") {
45
+ if (color.length < 7) {
46
+ color = "#" + color[1] + color[1] + color[2] + color[2] + color[3] + color[3] + (color.length > 4 ? color[4] + color[4] : "");
47
+ }
48
+ return [
49
+ parseInt(color.substr(1, 2), 16),
50
+ parseInt(color.substr(3, 2), 16),
51
+ parseInt(color.substr(5, 2), 16),
52
+ color.length > 7 ? parseInt(color.substr(7, 2), 16) / 255 : 1
53
+ ];
54
+ }
55
+ if (color.indexOf("rgb") === -1) {
56
+ if (import_globals.document && import_globals.window) {
57
+ const elem = import_globals.document.body.appendChild(import_globals.document.createElement("fictum"));
58
+ const flag = "rgb(1, 2, 3)";
59
+ elem.style.color = flag;
60
+ if (elem.style.color !== flag)
61
+ return;
62
+ elem.style.color = color;
63
+ if (elem.style.color === flag || elem.style.color === "")
64
+ return;
65
+ color = import_globals.window.getComputedStyle(elem).color;
66
+ import_globals.document.body.removeChild(elem);
67
+ } else
68
+ console.warn("Color conversion failed, no document or window object found");
69
+ }
70
+ if (color.indexOf("rgb") === 0) {
71
+ if (color.indexOf("rgba") === -1)
72
+ color = `${color}, 1`;
73
+ return color.match(/[\.\d]+/g).map((a) => +a);
74
+ }
75
+ };
76
+ const mixTwoColors = (colorA, colorB, range = 0.5) => {
77
+ colorA = colorStringToRgbaArray(colorA);
78
+ colorB = colorStringToRgbaArray(colorB);
79
+ return mixTwoRgba(colorA, colorB, range);
80
+ };
81
+ const hexToRgb = (hex, alpha = 1) => {
82
+ const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
83
+ return `rgb(${r},${g},${b})`;
84
+ };
85
+ const hexToRgbArray = (hex, alpha = 1) => {
86
+ const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
87
+ return [r, g, b];
88
+ };
89
+ const rgbToHex = (r, g, b) => {
90
+ return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
91
+ };
92
+ const rgbArrayToHex = ([r, g, b]) => {
93
+ return ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
94
+ };
95
+ const hexToRgba = (hex, alpha = 1) => {
96
+ const [r, g, b] = hex.match(/\w\w/g).map((x) => parseInt(x, 16));
97
+ return `rgba(${r},${g},${b},${alpha})`;
98
+ };
99
+ const mixTwoRgb = (colorA, colorB, range = 0.5) => {
100
+ const arr = [];
101
+ for (let i = 0; i < 3; i++) {
102
+ arr[i] = ~~(colorA[i] + (colorB[i] - colorA[i]) * range);
103
+ }
104
+ return `rgb(${arr})`;
105
+ };
106
+ const changeLightness = (delta, hsl) => {
107
+ const [hue, saturation, lightness] = hsl;
108
+ const newLightness = Math.max(
109
+ 0,
110
+ Math.min(100, lightness + parseFloat(delta))
111
+ );
112
+ return [hue, saturation, newLightness];
113
+ };
114
+ const rgbToHSL = (r, g, b) => {
115
+ const a = Math.max(r, g, b);
116
+ const n = a - Math.min(r, g, b);
117
+ const f = 1 - Math.abs(a + a - n - 1);
118
+ const h = n && (a == r ? (g - b) / n : a == g ? 2 + (b - r) / n : 4 + (r - g) / n);
119
+ return [60 * (h < 0 ? h + 6 : h), f ? n / f : 0, (a + a - n) / 2];
120
+ };
121
+ const hslToRgb = (h, s, l, a = s * Math.min(l, 1 - l), f = (n, k = (n + h / 30) % 12) => l - a * Math.max(
122
+ Math.min(k - 3, 9 - k, 1),
123
+ -1
124
+ )) => [f(0), f(8), f(4)];
125
+ const getColorShade = (col, amt) => {
126
+ const num = parseInt(col, 16);
127
+ let r = (num >> 16) + amt;
128
+ if (r > 255)
129
+ r = 255;
130
+ else if (r < 0)
131
+ r = 0;
132
+ let b = (num >> 8 & 255) + amt;
133
+ if (b > 255)
134
+ b = 255;
135
+ else if (b < 0)
136
+ b = 0;
137
+ let g = (num & 255) + amt;
138
+ if (g > 255)
139
+ g = 255;
140
+ else if (g < 0)
141
+ g = 0;
142
+ return (g | b << 8 | r << 16).toString(16);
143
+ };
144
+ const mixTwoRgba = (colorA, colorB, range = 0.5) => {
145
+ const arr = [];
146
+ for (let i = 0; i < 4; i++) {
147
+ const round = i === 3 ? (x) => x : Math.round;
148
+ arr[i] = round(
149
+ colorA[i] + (colorB[i] - colorA[i]) * range
150
+ );
151
+ }
152
+ return `rgba(${arr})`;
153
+ };
154
+ const opacify = (color, opacity) => {
155
+ const arr = colorStringToRgbaArray(color);
156
+ if (!arr) {
157
+ if (ENV === "test" || ENV === "development")
158
+ console.warn(color + "color is not rgba");
159
+ return;
160
+ }
161
+ arr[3] = opacity;
162
+ return `rgba(${arr})`;
163
+ };