@symbo.ls/scratch 3.4.5 → 3.4.6

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 (85) 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/class.js +25 -0
  4. package/dist/cjs/defaultConfig/color.js +31 -0
  5. package/dist/cjs/defaultConfig/document.js +24 -0
  6. package/dist/cjs/defaultConfig/font-family.js +38 -0
  7. package/dist/cjs/defaultConfig/font.js +33 -0
  8. package/dist/cjs/defaultConfig/grid.js +25 -0
  9. package/dist/cjs/defaultConfig/icons.js +26 -0
  10. package/dist/cjs/defaultConfig/index.js +45 -0
  11. package/dist/cjs/defaultConfig/media.js +29 -0
  12. package/dist/cjs/defaultConfig/responsive.js +50 -0
  13. package/dist/cjs/defaultConfig/sequence.js +49 -0
  14. package/dist/cjs/defaultConfig/shadow.js +29 -0
  15. package/dist/cjs/defaultConfig/spacing.js +38 -0
  16. package/dist/cjs/defaultConfig/svg.js +26 -0
  17. package/dist/cjs/defaultConfig/templates.js +24 -0
  18. package/dist/cjs/defaultConfig/theme.js +36 -0
  19. package/dist/cjs/defaultConfig/timing.js +37 -0
  20. package/dist/cjs/defaultConfig/typography.js +41 -0
  21. package/dist/cjs/defaultConfig/unit.js +26 -0
  22. package/dist/cjs/system/color.js +203 -0
  23. package/dist/cjs/system/document.js +36 -0
  24. package/dist/cjs/system/font.js +64 -0
  25. package/dist/cjs/system/index.js +27 -0
  26. package/dist/cjs/system/reset.js +87 -0
  27. package/dist/cjs/system/shadow.js +107 -0
  28. package/dist/cjs/system/spacing.js +134 -0
  29. package/dist/cjs/system/svg.js +97 -0
  30. package/dist/cjs/system/theme.js +234 -0
  31. package/dist/cjs/system/timing.js +48 -0
  32. package/dist/cjs/system/typography.js +99 -0
  33. package/dist/cjs/tests/index.js +28 -0
  34. package/dist/cjs/transforms/index.js +219 -0
  35. package/dist/cjs/utils/color.js +206 -0
  36. package/dist/cjs/utils/font.js +89 -0
  37. package/dist/cjs/utils/index.js +24 -0
  38. package/dist/cjs/utils/sequence.js +323 -0
  39. package/dist/cjs/utils/sprite.js +85 -0
  40. package/dist/cjs/utils/theme.js +29 -0
  41. package/dist/cjs/utils/unit.js +79 -0
  42. package/dist/cjs/utils/var.js +102 -0
  43. package/dist/esm/defaultConfig/animation.js +4 -0
  44. package/dist/esm/defaultConfig/cases.js +4 -0
  45. package/dist/esm/defaultConfig/class.js +5 -0
  46. package/dist/esm/defaultConfig/color.js +11 -0
  47. package/dist/esm/defaultConfig/document.js +4 -0
  48. package/dist/esm/defaultConfig/font-family.js +18 -0
  49. package/dist/esm/defaultConfig/font.js +13 -0
  50. package/dist/esm/defaultConfig/grid.js +5 -0
  51. package/dist/esm/defaultConfig/icons.js +6 -0
  52. package/dist/esm/defaultConfig/index.js +24 -0
  53. package/dist/esm/defaultConfig/media.js +9 -0
  54. package/dist/esm/defaultConfig/responsive.js +30 -0
  55. package/dist/esm/defaultConfig/sequence.js +29 -0
  56. package/dist/esm/defaultConfig/shadow.js +9 -0
  57. package/dist/esm/defaultConfig/spacing.js +18 -0
  58. package/dist/esm/defaultConfig/svg.js +6 -0
  59. package/dist/esm/defaultConfig/templates.js +4 -0
  60. package/dist/esm/defaultConfig/theme.js +16 -0
  61. package/dist/esm/defaultConfig/timing.js +17 -0
  62. package/dist/esm/defaultConfig/typography.js +21 -0
  63. package/dist/esm/defaultConfig/unit.js +6 -0
  64. package/dist/esm/system/color.js +188 -0
  65. package/dist/esm/system/document.js +16 -0
  66. package/dist/esm/system/font.js +50 -0
  67. package/dist/esm/system/index.js +10 -0
  68. package/dist/esm/system/reset.js +67 -0
  69. package/dist/esm/system/shadow.js +91 -0
  70. package/dist/esm/system/spacing.js +121 -0
  71. package/dist/esm/system/svg.js +77 -0
  72. package/dist/esm/system/theme.js +219 -0
  73. package/dist/esm/system/timing.js +32 -0
  74. package/dist/esm/system/typography.js +85 -0
  75. package/dist/esm/tests/index.js +8 -0
  76. package/dist/esm/transforms/index.js +216 -0
  77. package/dist/esm/utils/color.js +192 -0
  78. package/dist/esm/utils/font.js +69 -0
  79. package/dist/esm/utils/index.js +7 -0
  80. package/dist/esm/utils/sequence.js +303 -0
  81. package/dist/esm/utils/sprite.js +65 -0
  82. package/dist/esm/utils/theme.js +9 -0
  83. package/dist/esm/utils/unit.js +59 -0
  84. package/dist/esm/utils/var.js +82 -0
  85. package/package.json +7 -7
@@ -0,0 +1,134 @@
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 spacing_exports = {};
20
+ __export(spacing_exports, {
21
+ applySpacingSequence: () => applySpacingSequence,
22
+ checkIfBoxSize: () => checkIfBoxSize,
23
+ getSpacingBasedOnRatio: () => getSpacingBasedOnRatio,
24
+ getSpacingByKey: () => getSpacingByKey,
25
+ splitSpacedValue: () => splitSpacedValue
26
+ });
27
+ module.exports = __toCommonJS(spacing_exports);
28
+ var import_smbls_utils = require("@symbo.ls/smbls-utils");
29
+ var import_utils = require("@domql/utils");
30
+ var import_factory = require("../factory.js");
31
+ var import_utils2 = require("../utils");
32
+ const runThroughMedia = (FACTORY) => {
33
+ for (const prop in FACTORY) {
34
+ const mediaProps = FACTORY[prop];
35
+ const isMediaName = prop.slice(0, 1) === "@";
36
+ if (!isMediaName) continue;
37
+ const { type, base, ratio, range, subSequence, h1Matches, unit } = FACTORY;
38
+ (0, import_utils.merge)(mediaProps, {
39
+ type,
40
+ base,
41
+ ratio,
42
+ range,
43
+ subSequence,
44
+ h1Matches,
45
+ unit,
46
+ sequence: {},
47
+ scales: {},
48
+ templates: {},
49
+ vars: {}
50
+ });
51
+ (0, import_utils2.generateSequence)(mediaProps);
52
+ (0, import_utils2.applyMediaSequenceVars)(FACTORY, prop);
53
+ }
54
+ };
55
+ const checkIfBoxSize = (propertyName) => {
56
+ const prop = propertyName.toLowerCase();
57
+ const includesWidth = prop.includes("width") || prop.includes("height");
58
+ const includesBorder = prop.includes("border") || prop.includes("outline");
59
+ return includesWidth && !includesBorder;
60
+ };
61
+ const applySpacingSequence = () => {
62
+ const CONFIG = (0, import_factory.getActiveConfig)();
63
+ const { SPACING } = CONFIG;
64
+ (0, import_utils2.generateSequence)(SPACING);
65
+ (0, import_utils2.applySequenceVars)(SPACING);
66
+ runThroughMedia(SPACING);
67
+ };
68
+ const getSequence = (sequenceProps) => {
69
+ const CONFIG = (0, import_factory.getActiveConfig)();
70
+ const { SPACING } = CONFIG;
71
+ if (!sequenceProps || !sequenceProps.sequence) return SPACING;
72
+ const hasGenerated = Object.keys(sequenceProps.sequence).length > 0;
73
+ return hasGenerated ? sequenceProps : (0, import_utils2.generateSequence)(sequenceProps);
74
+ };
75
+ const getSpacingByKey = (value, propertyName = "padding", sequenceProps, fnPrefix) => {
76
+ const sequence = getSequence(sequenceProps);
77
+ if ((0, import_utils.isString)(value)) {
78
+ if (!fnPrefix && value.includes("(")) {
79
+ const fnArray = (0, import_utils2.getFnPrefixAndValue)(value);
80
+ fnPrefix = fnArray[0];
81
+ value = fnArray[1];
82
+ }
83
+ }
84
+ const stack = fnPrefix ? [value] : (0, import_smbls_utils.arrayzeValue)(value);
85
+ if (!(0, import_utils.isArray)(stack)) return;
86
+ if (stack.length > 1) {
87
+ let suffix = "";
88
+ if (propertyName === "borderWidth") {
89
+ propertyName = "border";
90
+ suffix = "Width";
91
+ }
92
+ const directions = {
93
+ 2: ["Block", "Inline"],
94
+ 3: ["BlockStart", "Inline", "BlockEnd"],
95
+ 4: ["BlockStart", "InlineEnd", "BlockEnd", "InlineStart"]
96
+ };
97
+ const wrapSequenceValueByDirection = (direction, i) => (0, import_utils2.getSequenceValuePropertyPair)(
98
+ stack[i],
99
+ propertyName + direction + suffix,
100
+ sequence,
101
+ fnPrefix
102
+ );
103
+ return directions[stack.length].map(
104
+ (dir, key) => wrapSequenceValueByDirection(dir, key)
105
+ );
106
+ }
107
+ return (0, import_utils2.getSequenceValuePropertyPair)(value, propertyName, sequence, fnPrefix);
108
+ };
109
+ const getSpacingBasedOnRatio = (props, propertyName, val, fnPrefix) => {
110
+ const CONFIG = (0, import_factory.getActiveConfig)();
111
+ const { SPACING } = CONFIG;
112
+ let value = val || props[propertyName];
113
+ if (!fnPrefix && (0, import_utils.isString)(value) && value.includes("(")) {
114
+ const fnArr = (0, import_utils2.getFnPrefixAndValue)(value);
115
+ fnPrefix = fnArr[0];
116
+ value = fnArr[1];
117
+ }
118
+ if (props.spacingRatio) {
119
+ const sequenceProps = applyCustomSequence(props);
120
+ return getSpacingByKey(value, propertyName, sequenceProps, fnPrefix);
121
+ }
122
+ return getSpacingByKey(value, propertyName, SPACING, fnPrefix);
123
+ };
124
+ const splitSpacedValue = (val) => {
125
+ const addDefault = (v) => {
126
+ const isSymbol = ["+", "-", "*", "/"].includes(v);
127
+ const hasUnits = import_utils2.CSS_UNITS.some((unit) => val.includes(unit));
128
+ if (isSymbol || hasUnits) return v;
129
+ const isSingleLetter = v.length < 3 && /[A-Z]/.test(v);
130
+ if (isSingleLetter) return v + "_default";
131
+ return v;
132
+ };
133
+ return val.split(",").map((v) => v.trim()).map(addDefault).join(",").split(" ").map(addDefault).join(" ");
134
+ };
@@ -0,0 +1,97 @@
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
+ appendSVGSprite: () => appendSVGSprite,
22
+ appendSvgIconsSprite: () => appendSvgIconsSprite,
23
+ setSVG: () => setSVG,
24
+ setSvgIcon: () => setSvgIcon
25
+ });
26
+ module.exports = __toCommonJS(svg_exports);
27
+ var import_utils = require("@domql/utils");
28
+ var import_utils2 = require("../utils");
29
+ var import_factory = require("../factory.js");
30
+ const DEF_OPTIONS = {
31
+ document: import_utils.document
32
+ };
33
+ const setSVG = (val, key) => {
34
+ const CONFIG = (0, import_factory.getActiveConfig)();
35
+ if (!val) {
36
+ if (CONFIG.verbose) console.warn("setSVG: val is not defined", key);
37
+ return;
38
+ }
39
+ if (CONFIG.useSvgSprite) {
40
+ return (0, import_utils2.convertSvgToSymbol)(key, val);
41
+ }
42
+ return val;
43
+ };
44
+ const appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
45
+ const CONFIG = (0, import_factory.getActiveConfig)();
46
+ const lib = Object.keys(LIBRARY).length ? {} : CONFIG.SVG;
47
+ for (const key in LIBRARY) lib[key] = CONFIG.SVG[key];
48
+ appendSVG(lib, options);
49
+ };
50
+ const setSvgIcon = (val, key) => {
51
+ const CONFIG = (0, import_factory.getActiveConfig)();
52
+ if (CONFIG.useIconSprite && !CONFIG.SEMANTIC_ICONS?.[key]) {
53
+ return setSVG(val, key);
54
+ }
55
+ return val;
56
+ };
57
+ const appendSvgIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
58
+ const CONFIG = (0, import_factory.getActiveConfig)();
59
+ const lib = Object.keys(LIBRARY).length ? {} : CONFIG.ICONS;
60
+ for (const key in LIBRARY) lib[key] = CONFIG.ICONS[key];
61
+ appendSVG(lib, options);
62
+ };
63
+ const createSVGSpriteElement = (options = { isRoot: true }) => {
64
+ if (!import_utils.document || !import_utils.document.createElementNS) return;
65
+ const svgElem = import_utils.document.createElementNS("http://www.w3.org/2000/svg", "svg");
66
+ if (options.isRoot) {
67
+ svgElem.setAttribute("aria-hidden", "true");
68
+ svgElem.setAttribute("width", "0");
69
+ svgElem.setAttribute("height", "0");
70
+ svgElem.setAttribute("style", "position:absolute");
71
+ svgElem.setAttribute("id", "svgSprite");
72
+ }
73
+ return svgElem;
74
+ };
75
+ const appendSVG = (lib, options = DEF_OPTIONS) => {
76
+ const CONFIG = (0, import_factory.getActiveConfig)();
77
+ const doc = options.document || import_utils.document;
78
+ if (!doc || !doc.documentElement) {
79
+ if (CONFIG.verbose) {
80
+ console.warn("To append SVG sprites it should be run in browser environment");
81
+ }
82
+ return (0, import_utils2.generateSprite)(lib);
83
+ }
84
+ const exists = doc.querySelector("#svgSprite");
85
+ const SVGsprite = (0, import_utils2.generateSprite)(lib);
86
+ if (exists) {
87
+ const tempSVG = createSVGSpriteElement({ isRoot: false });
88
+ tempSVG.innerHTML = SVGsprite;
89
+ exists.append(...tempSVG.children);
90
+ } else {
91
+ const svgSpriteDOM = createSVGSpriteElement();
92
+ if (svgSpriteDOM && svgSpriteDOM.nodeType) {
93
+ svgSpriteDOM.innerHTML = SVGsprite;
94
+ doc.body.prepend(svgSpriteDOM);
95
+ }
96
+ }
97
+ };
@@ -0,0 +1,234 @@
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_color2 = require("../utils/color.js");
30
+ var import_utils = require("@domql/utils");
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) return theme.value;
44
+ theme.value = setThemeValue(theme);
45
+ return theme.value;
46
+ };
47
+ const getTheme = (value, modifier) => {
48
+ const CONFIG = (0, import_factory.getActiveConfig)();
49
+ if (CONFIG.useVariable) return getMediaTheme(value, modifier);
50
+ const { THEME } = CONFIG;
51
+ if ((0, import_utils.isString)(value)) {
52
+ const [theme, subtheme] = value.split(" ");
53
+ const isOurTheme = THEME[theme];
54
+ if (isOurTheme) {
55
+ if (!subtheme && !modifier) return getThemeValue(isOurTheme);
56
+ value = [theme, subtheme || modifier];
57
+ }
58
+ }
59
+ if ((0, import_utils.isObjectLike)(value) && value[1]) {
60
+ const themeName = value[0];
61
+ const subThemeName = value[1];
62
+ const { helpers, media, state } = THEME[themeName];
63
+ if (media && media[subThemeName]) return getThemeValue(media[subThemeName]);
64
+ if (helpers && helpers[subThemeName]) return getThemeValue(helpers[subThemeName]);
65
+ if (state && state[subThemeName]) return getThemeValue(state[subThemeName]);
66
+ } else if ((0, import_utils.isObject)(value)) return setThemeValue(value);
67
+ };
68
+ const setInverseTheme = (theme, variant, value) => {
69
+ if ((0, import_utils.isObject)(variant)) {
70
+ theme.variants.inverse.value = setThemeValue(variant);
71
+ } else if (variant === true) {
72
+ const { color, background } = value;
73
+ theme.variants.inverse = {
74
+ value: {
75
+ color: background,
76
+ background: color
77
+ }
78
+ };
79
+ }
80
+ };
81
+ const setPseudo = (theme, key, variant, themeValue) => {
82
+ const result = getTheme(variant);
83
+ themeValue[`&:${key}`] = result;
84
+ if ((0, import_utils.isObject)(variant) && !variant.value) variant.value = result;
85
+ };
86
+ const setSelectors = (theme, value) => {
87
+ const { state } = theme;
88
+ if (!state) return;
89
+ const keys = Object.keys(state);
90
+ keys.map((key) => {
91
+ const variant = state[key];
92
+ setPseudo(theme, key, variant, value);
93
+ return theme;
94
+ });
95
+ return theme;
96
+ };
97
+ const setPrefersScheme = (theme, key, variant, themeValue) => {
98
+ const result = getTheme(variant);
99
+ themeValue[`@media (prefers-color-scheme: ${key})`] = result;
100
+ if ((0, import_utils.isObject)(variant) && !variant.value) variant.value = result;
101
+ };
102
+ const setMedia = (theme, value) => {
103
+ const { media } = theme;
104
+ if (!media) return;
105
+ const keys = Object.keys(media);
106
+ keys.map((key) => {
107
+ const variant = media[key];
108
+ if (key === "dark" || key === "light") setPrefersScheme(theme, key, variant, value);
109
+ if (key === "inverse") setInverseTheme(theme, variant, value);
110
+ return theme;
111
+ });
112
+ return theme;
113
+ };
114
+ const setHelpers = (theme, value) => {
115
+ const CONFIG = (0, import_factory.getActiveConfig)();
116
+ const { helpers } = theme;
117
+ if (!helpers) return;
118
+ const keys = Object.keys(helpers);
119
+ keys.map((key) => {
120
+ const helper = helpers[key];
121
+ if ((0, import_utils.isString)(helper)) helpers[key] = CONFIG.THEME[helper];
122
+ else getThemeValue(helpers[key]);
123
+ return theme;
124
+ });
125
+ return theme;
126
+ };
127
+ const setTheme = (val, key) => {
128
+ const CONFIG = (0, import_factory.getActiveConfig)();
129
+ if (CONFIG.useVariable) return setMediaTheme(val, key);
130
+ const { state, media, helpers } = val;
131
+ const value = setThemeValue(val, key);
132
+ const CSSvar = `--theme-${key}`;
133
+ setSelectors(val, value);
134
+ setMedia(val, value);
135
+ setHelpers(val, value);
136
+ return { var: CSSvar, value, state, media, helpers };
137
+ };
138
+ const keySetters = {
139
+ // eslint-disable-line
140
+ "@": (theme, value) => setMedia(theme, value),
141
+ ":": (theme, value) => setSelectors(theme, value),
142
+ ".": (theme, value) => setHelpers(theme, value)
143
+ };
144
+ const setMediaTheme = (val, key, suffix, prefers) => {
145
+ const CONFIG = (0, import_factory.getActiveConfig)();
146
+ const { CSS_VARS } = CONFIG;
147
+ const theme = { value: val };
148
+ if ((0, import_utils.isObjectLike)(val)) {
149
+ for (const param in val) {
150
+ const symb = param.slice(0, 1);
151
+ const value = val[param];
152
+ if (symb === "@" || symb === ":" || symb === ".") {
153
+ const hasPrefers = symb === "@" && param;
154
+ theme[param] = setMediaTheme(value, key, param, prefers || hasPrefers);
155
+ } else {
156
+ const color = (0, import_color.getColor)(value, prefers);
157
+ const metaSuffixes = [...new Set([prefers, suffix].filter((v) => v).map((v) => v.slice(1)))];
158
+ const varmetaSuffixName = metaSuffixes.length ? "-" + metaSuffixes.join("-") : "";
159
+ const CSSVar = `--theme-${key}${varmetaSuffixName}-${param}`;
160
+ if (CONFIG.useVariable) {
161
+ CSS_VARS[CSSVar] = color;
162
+ theme[param] = `var(${CSSVar})`;
163
+ } else {
164
+ theme[param] = color;
165
+ }
166
+ theme[`.${param}`] = { [param]: theme[param] };
167
+ }
168
+ }
169
+ if (theme.background || theme.color || theme.backgroundColor) {
170
+ theme[".inversed"] = {
171
+ color: theme.background || theme.backgroundColor,
172
+ background: theme.color
173
+ };
174
+ }
175
+ }
176
+ if ((0, import_utils.isString)(val) && (0, import_color2.isCSSVar)(val)) {
177
+ const { THEME } = CONFIG;
178
+ const value = THEME[val.slice(2)];
179
+ const getReferenced = getMediaTheme(value, prefers);
180
+ return getReferenced;
181
+ }
182
+ return theme;
183
+ };
184
+ const recursiveTheme = (val) => {
185
+ const CONFIG = (0, import_factory.getActiveConfig)();
186
+ const obj = {};
187
+ for (const param in val) {
188
+ const symb = param.slice(0, 1);
189
+ if ((0, import_utils.isObjectLike)(val[param])) {
190
+ if (symb === "@") {
191
+ const query = CONFIG.MEDIA[param.slice(1)];
192
+ const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
193
+ obj[media] = recursiveTheme(val[param]);
194
+ } else if (symb === ":") {
195
+ obj[`&${param}`] = recursiveTheme(val[param]);
196
+ }
197
+ } else obj[param] = val[param];
198
+ }
199
+ return obj;
200
+ };
201
+ const findModifierFromArray = (val, modifierArray) => {
202
+ const currentMod = modifierArray.shift();
203
+ if (val[currentMod]) return findModifierFromArray(val[currentMod], modifierArray);
204
+ return val;
205
+ };
206
+ const findModifier = (val, modifier) => {
207
+ if ((0, import_utils.isArray)(modifier)) return findModifierFromArray(val, modifier);
208
+ else if ((0, import_utils.isString)(modifier) && val[modifier]) return val[modifier];
209
+ else return val;
210
+ };
211
+ const checkForReference = (val, callback) => {
212
+ if ((0, import_utils.isString)(val) && (0, import_color2.isCSSVar)(val)) return getMediaTheme(val.slice(2));
213
+ return val;
214
+ };
215
+ const checkThemeReference = (val) => checkForReference(val, checkThemeReference);
216
+ const getMediaTheme = (value, modifier) => {
217
+ const activeConfig = (0, import_factory.getActiveConfig)();
218
+ if ((0, import_utils.isString)(value) && (0, import_color2.isCSSVar)(value)) {
219
+ value = getMediaTheme(value.slice(2));
220
+ }
221
+ if (!value || !(0, import_utils.isString)(value)) {
222
+ if (activeConfig.verbose) {
223
+ console.warn(`${value} - Theme is not a string`);
224
+ }
225
+ return;
226
+ }
227
+ const [themeName, ...themeModifiers] = (0, import_utils.isArray)(value) ? value : value.split(" ");
228
+ let themeValue = activeConfig.THEME[themeName];
229
+ if (themeValue && (themeModifiers || modifier)) {
230
+ themeValue = findModifier(themeValue, themeModifiers.length ? themeModifiers : modifier);
231
+ }
232
+ const resolvedTheme = recursiveTheme(themeValue);
233
+ return resolvedTheme;
234
+ };
@@ -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_smbls_utils = require("@symbo.ls/smbls-utils");
27
+ var import_factory = require("../factory.js");
28
+ var import_utils = require("../utils");
29
+ const applyTimingSequence = () => {
30
+ const CONFIG = (0, import_factory.getActiveConfig)();
31
+ const { TIMING } = CONFIG;
32
+ (0, import_utils.generateSequence)(TIMING);
33
+ (0, import_utils.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_smbls_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_utils.getSequenceValuePropertyPair)(
44
+ value,
45
+ property,
46
+ TIMING
47
+ );
48
+ };
@@ -0,0 +1,99 @@
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_utils = require("@domql/utils");
28
+ var import_factory = require("../factory.js");
29
+ var import_utils2 = require("../utils");
30
+ const runThroughMedia = (FACTORY) => {
31
+ const CONFIG = (0, import_factory.getActiveConfig)();
32
+ const { TYPOGRAPHY, MEDIA } = CONFIG;
33
+ for (const prop in FACTORY) {
34
+ const isPropMedia = prop.slice(0, 1) === "@";
35
+ const mediaValue = FACTORY[prop];
36
+ if (!isPropMedia) continue;
37
+ const { mediaRegenerate } = FACTORY;
38
+ const mediaName = prop.slice(1);
39
+ const { type, base, ratio, range, subSequence, h1Matches, unit } = FACTORY;
40
+ (0, import_utils.merge)(mediaValue, {
41
+ type,
42
+ base,
43
+ ratio,
44
+ range,
45
+ subSequence,
46
+ h1Matches,
47
+ unit
48
+ });
49
+ const query = MEDIA[mediaName];
50
+ const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
51
+ TYPOGRAPHY.templates[media] = {
52
+ fontSize: mediaValue.base / TYPOGRAPHY.browserDefault + unit
53
+ };
54
+ if (!mediaRegenerate) {
55
+ (0, import_utils2.applyMediaSequenceVars)(FACTORY, prop);
56
+ continue;
57
+ }
58
+ (0, import_utils.merge)(mediaValue, {
59
+ sequence: {},
60
+ scales: {},
61
+ templates: {},
62
+ vars: {}
63
+ });
64
+ (0, import_utils2.generateSequence)(mediaValue);
65
+ (0, import_utils2.applyMediaSequenceVars)(FACTORY, prop);
66
+ }
67
+ };
68
+ const applyHeadings = (props) => {
69
+ const CONFIG = (0, import_factory.getActiveConfig)();
70
+ if (props.h1Matches) {
71
+ const unit = props.unit;
72
+ const HEADINGS = (0, import_utils2.findHeadings)(props);
73
+ const { templates } = props;
74
+ for (const k in HEADINGS) {
75
+ const headerName = `h${parseInt(k) + 1}`;
76
+ const headerStyle = templates[headerName];
77
+ templates[headerName] = {
78
+ fontSize: CONFIG.useVariable ? `var(${HEADINGS[k]?.variable})` : `${HEADINGS[k]?.scaling}${unit}`,
79
+ margin: headerStyle ? headerStyle.margin : 0,
80
+ lineHeight: headerStyle ? headerStyle.lineHeight : props.lineHeight,
81
+ letterSpacing: headerStyle ? headerStyle.letterSpacing : props.letterSpacing,
82
+ fontWeight: headerStyle ? headerStyle.fontWeight : 900 - k * 100
83
+ };
84
+ }
85
+ }
86
+ };
87
+ const applyTypographySequence = () => {
88
+ const CONFIG = (0, import_factory.getActiveConfig)();
89
+ const { TYPOGRAPHY } = CONFIG;
90
+ (0, import_utils2.generateSequence)(TYPOGRAPHY);
91
+ applyHeadings(TYPOGRAPHY);
92
+ (0, import_utils2.applySequenceVars)(TYPOGRAPHY);
93
+ runThroughMedia(TYPOGRAPHY);
94
+ };
95
+ const getFontSizeByKey = (value) => {
96
+ const CONFIG = (0, import_factory.getActiveConfig)();
97
+ const { TYPOGRAPHY } = CONFIG;
98
+ return (0, import_utils2.getSequenceValuePropertyPair)(value, "fontSize", TYPOGRAPHY);
99
+ };
@@ -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
+ };