@symbo.ls/scratch 3.8.9 → 3.14.1

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 (119) hide show
  1. package/README.md +2 -2
  2. package/dist/cjs/defaultConfig/animation.js +4 -2
  3. package/dist/cjs/defaultConfig/cases.js +4 -2
  4. package/dist/cjs/defaultConfig/class.js +4 -2
  5. package/dist/cjs/defaultConfig/color.js +6 -9
  6. package/dist/cjs/defaultConfig/document.js +4 -2
  7. package/dist/cjs/defaultConfig/font-family.js +8 -12
  8. package/dist/cjs/defaultConfig/font.js +4 -11
  9. package/dist/cjs/defaultConfig/grid.js +5 -3
  10. package/dist/cjs/defaultConfig/icons.js +6 -4
  11. package/dist/cjs/defaultConfig/index.js +200 -24
  12. package/dist/cjs/defaultConfig/media.js +4 -2
  13. package/dist/cjs/defaultConfig/responsive.js +6 -4
  14. package/dist/cjs/defaultConfig/sequence.js +4 -2
  15. package/dist/cjs/defaultConfig/shadow.js +4 -2
  16. package/dist/cjs/defaultConfig/spacing.js +56 -7
  17. package/dist/cjs/defaultConfig/svg.js +6 -4
  18. package/dist/cjs/defaultConfig/templates.js +4 -2
  19. package/dist/cjs/defaultConfig/theme.js +4 -14
  20. package/dist/cjs/defaultConfig/timing.js +36 -5
  21. package/dist/cjs/defaultConfig/typography.js +36 -5
  22. package/dist/cjs/defaultConfig/unit.js +4 -2
  23. package/dist/cjs/factory.js +341 -40
  24. package/dist/cjs/index.js +6333 -11
  25. package/dist/cjs/package.json +4 -0
  26. package/dist/cjs/set.js +5614 -158
  27. package/dist/cjs/system/color.js +4481 -104
  28. package/dist/cjs/system/document.js +4371 -11
  29. package/dist/cjs/system/font.js +4401 -28
  30. package/dist/cjs/system/index.js +5748 -11
  31. package/dist/cjs/system/reset.js +4445 -21
  32. package/dist/cjs/system/shadow.js +4832 -41
  33. package/dist/cjs/system/spacing.js +4752 -39
  34. package/dist/cjs/system/svg.js +4437 -47
  35. package/dist/cjs/system/theme.js +4526 -335
  36. package/dist/cjs/system/timing.js +4695 -19
  37. package/dist/cjs/system/typography.js +4755 -33
  38. package/dist/cjs/tests/index.js +4 -2
  39. package/dist/cjs/transforms/index.js +5019 -134
  40. package/dist/cjs/utils/color.js +47 -66
  41. package/dist/cjs/utils/font.js +25 -46
  42. package/dist/cjs/utils/index.js +5068 -8
  43. package/dist/cjs/utils/sequence.js +4423 -35
  44. package/dist/cjs/utils/sprite.js +353 -12
  45. package/dist/cjs/utils/theme.js +3 -1
  46. package/dist/cjs/utils/unit.js +4 -2
  47. package/dist/cjs/utils/var.js +4390 -42
  48. package/index.js +1 -0
  49. package/package.json +11 -14
  50. package/src/defaultConfig/class.js +2 -1
  51. package/src/defaultConfig/font-family.js +3 -3
  52. package/src/defaultConfig/icons.js +1 -1
  53. package/src/defaultConfig/svg.js +1 -1
  54. package/src/defaultConfig/timing.js +1 -1
  55. package/src/factory.js +85 -13
  56. package/src/index.js +16 -5
  57. package/src/set.js +156 -63
  58. package/src/system/color.js +113 -12
  59. package/src/system/document.js +3 -3
  60. package/src/system/font.js +5 -5
  61. package/src/system/reset.js +41 -8
  62. package/src/system/shadow.js +4 -3
  63. package/src/system/spacing.js +3 -3
  64. package/src/system/svg.js +42 -5
  65. package/src/system/theme.js +87 -64
  66. package/src/system/timing.js +2 -2
  67. package/src/system/typography.js +12 -3
  68. package/src/transforms/index.js +4 -4
  69. package/src/utils/color.js +2 -1
  70. package/src/utils/font.js +7 -1
  71. package/src/utils/sequence.js +46 -29
  72. package/src/utils/sprite.js +44 -16
  73. package/src/utils/var.js +27 -9
  74. package/dist/esm/defaultConfig/animation.js +0 -4
  75. package/dist/esm/defaultConfig/cases.js +0 -4
  76. package/dist/esm/defaultConfig/class.js +0 -5
  77. package/dist/esm/defaultConfig/color.js +0 -11
  78. package/dist/esm/defaultConfig/document.js +0 -4
  79. package/dist/esm/defaultConfig/font-family.js +0 -18
  80. package/dist/esm/defaultConfig/font.js +0 -13
  81. package/dist/esm/defaultConfig/grid.js +0 -5
  82. package/dist/esm/defaultConfig/icons.js +0 -6
  83. package/dist/esm/defaultConfig/index.js +0 -25
  84. package/dist/esm/defaultConfig/media.js +0 -9
  85. package/dist/esm/defaultConfig/responsive.js +0 -30
  86. package/dist/esm/defaultConfig/sequence.js +0 -29
  87. package/dist/esm/defaultConfig/shadow.js +0 -4
  88. package/dist/esm/defaultConfig/spacing.js +0 -18
  89. package/dist/esm/defaultConfig/svg.js +0 -6
  90. package/dist/esm/defaultConfig/templates.js +0 -4
  91. package/dist/esm/defaultConfig/theme.js +0 -16
  92. package/dist/esm/defaultConfig/timing.js +0 -17
  93. package/dist/esm/defaultConfig/typography.js +0 -21
  94. package/dist/esm/defaultConfig/unit.js +0 -6
  95. package/dist/esm/factory.js +0 -60
  96. package/dist/esm/index.js +0 -12
  97. package/dist/esm/set.js +0 -219
  98. package/dist/esm/system/color.js +0 -193
  99. package/dist/esm/system/document.js +0 -16
  100. package/dist/esm/system/font.js +0 -58
  101. package/dist/esm/system/index.js +0 -10
  102. package/dist/esm/system/reset.js +0 -67
  103. package/dist/esm/system/shadow.js +0 -91
  104. package/dist/esm/system/spacing.js +0 -121
  105. package/dist/esm/system/svg.js +0 -86
  106. package/dist/esm/system/theme.js +0 -480
  107. package/dist/esm/system/timing.js +0 -32
  108. package/dist/esm/system/typography.js +0 -85
  109. package/dist/esm/tests/index.js +0 -8
  110. package/dist/esm/transforms/index.js +0 -216
  111. package/dist/esm/utils/color.js +0 -192
  112. package/dist/esm/utils/font.js +0 -92
  113. package/dist/esm/utils/index.js +0 -7
  114. package/dist/esm/utils/sequence.js +0 -303
  115. package/dist/esm/utils/sprite.js +0 -65
  116. package/dist/esm/utils/theme.js +0 -9
  117. package/dist/esm/utils/unit.js +0 -59
  118. package/dist/esm/utils/var.js +0 -82
  119. package/dist/iife/index.js +0 -3204
@@ -1,67 +0,0 @@
1
- import { deepMerge, merge, overwriteDeep } from "@domql/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
- return deepMerge(merge(RESET, reset), {
26
- html: {
27
- position: "absolute",
28
- // overflow: 'hidden',
29
- width: "100%",
30
- height: "100%",
31
- top: "0",
32
- left: "0",
33
- margin: "0",
34
- WebkitFontSmoothing: "subpixel-antialiased",
35
- scrollBehavior: "smooth",
36
- ...globalTheme,
37
- fontSize: TYPOGRAPHY.browserDefault + "px",
38
- fontFamily: DOCUMENT.fontFamily,
39
- lineHeight: DOCUMENT.lineHeight
40
- },
41
- body: {
42
- boxSizing: "border-box",
43
- height: "100%",
44
- margin: 0,
45
- fontFamily: DOCUMENT.fontFamily,
46
- fontSize: TYPOGRAPHY.base / TYPOGRAPHY.browserDefault + CONFIG.unit.default,
47
- ...templates,
48
- ...body
49
- },
50
- a: {
51
- color: "currentColor"
52
- },
53
- // form elements
54
- fieldset: {
55
- border: 0,
56
- padding: 0,
57
- margin: 0
58
- },
59
- "select, input": {
60
- fontFamily: DOCUMENT.fontFamily
61
- }
62
- });
63
- }
64
- };
65
- export {
66
- applyReset
67
- };
@@ -1,91 +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 "@domql/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 CSSVar = `--shadow-${key}` + (suffix ? `-${suffix}` : "");
47
- if (CONFIG.useVariable) {
48
- CONFIG.CSS_VARS[CSSVar] = value;
49
- }
50
- return {
51
- var: CSSVar,
52
- value
53
- };
54
- };
55
- const getShadow = (value, globalTheme) => {
56
- const CONFIG = getActiveConfig();
57
- if (!globalTheme) globalTheme = CONFIG.globalTheme;
58
- if (!isString(value)) {
59
- if (CONFIG.verbose) console.warn(value, "- type for color is not valid");
60
- return;
61
- }
62
- if (isCSSVar(value)) return `var(${value})`;
63
- const [name] = isArray(value) ? value : value.split(" ");
64
- const SHADOW = CONFIG.shadow;
65
- const val = SHADOW[name];
66
- const isObj = isObject(val);
67
- if (!val) {
68
- if (CONFIG.verbose) console.warn("Can't find color ", name);
69
- return value;
70
- }
71
- if (globalTheme) {
72
- if (val[globalTheme]) return val[globalTheme].value;
73
- else if (CONFIG.verbose) console.warn(value, " - does not have ", globalTheme);
74
- }
75
- if (isObj && val.value) return val.value;
76
- if (isObj) {
77
- const obj = {};
78
- for (const mediaName in val) {
79
- const query = CONFIG.media[mediaName.slice(1)];
80
- const media = "@media " + (query === "print" ? `${query}` : `screen and ${query}`);
81
- obj[media] = val.value;
82
- }
83
- return obj;
84
- }
85
- if (CONFIG.verbose) console.warn("Can't find color", value);
86
- return value;
87
- };
88
- export {
89
- getShadow,
90
- setShadow
91
- };
@@ -1,121 +0,0 @@
1
- import { arrayzeValue } from "@symbo.ls/smbls-utils";
2
- import { isArray, isString, merge } from "@domql/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";
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
- };
@@ -1,86 +0,0 @@
1
- import { document } from "@domql/utils";
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
- const CONFIG = getActiveConfig();
9
- if (!val) {
10
- if (CONFIG.verbose) console.warn("setSVG: val is not defined", key);
11
- return;
12
- }
13
- if (CONFIG.useSvgSprite) {
14
- return convertSvgToSymbol(key, val);
15
- }
16
- return val;
17
- };
18
- const appendSVGSprite = (LIBRARY, options = DEF_OPTIONS) => {
19
- const CONFIG = getActiveConfig();
20
- const lib = Object.keys(LIBRARY).length ? {} : CONFIG.svg;
21
- for (const key in LIBRARY) lib[key] = LIBRARY[key];
22
- appendSVG(lib, options);
23
- };
24
- const setSvgIcon = (val, key) => {
25
- const CONFIG = getActiveConfig();
26
- if (CONFIG.useIconSprite && !CONFIG.semantic_icons?.[key]) {
27
- return setSVG(val, key);
28
- }
29
- return val;
30
- };
31
- const appendSvgIconsSprite = (LIBRARY, options = DEF_OPTIONS) => {
32
- const CONFIG = getActiveConfig();
33
- const lib = Object.keys(LIBRARY).length ? {} : CONFIG.icons;
34
- for (const key in LIBRARY) lib[key] = LIBRARY[key];
35
- appendSVG(lib, options);
36
- };
37
- const createSVGSpriteElement = (doc, options = { isRoot: true }) => {
38
- if (!doc || !doc.createElementNS) return;
39
- const svgElem = doc.createElementNS("http://www.w3.org/2000/svg", "svg");
40
- if (options.isRoot) {
41
- svgElem.setAttribute("aria-hidden", "true");
42
- svgElem.setAttribute("width", "0");
43
- svgElem.setAttribute("height", "0");
44
- svgElem.setAttribute("style", "position:absolute");
45
- svgElem.setAttribute("id", "svgSprite");
46
- }
47
- return svgElem;
48
- };
49
- const appendSVG = (lib, options = DEF_OPTIONS) => {
50
- const CONFIG = getActiveConfig();
51
- const doc = options.document || document;
52
- if (!doc || !doc.documentElement) {
53
- if (CONFIG.verbose) {
54
- console.warn("To append SVG sprites it should be run in browser environment");
55
- }
56
- return generateSprite(lib);
57
- }
58
- const exists = doc.querySelector("#svgSprite");
59
- const SVGsprite = generateSprite(lib);
60
- const spriteHtml = `<svg aria-hidden="true" width="0" height="0" style="position:absolute" id="svgSprite">${SVGsprite}</svg>`;
61
- if (exists) {
62
- if (doc.body.insertAdjacentHTML) {
63
- exists.insertAdjacentHTML("beforeend", SVGsprite);
64
- } else {
65
- const tempSVG = createSVGSpriteElement(doc, { isRoot: false });
66
- tempSVG.innerHTML = SVGsprite;
67
- exists.append(...tempSVG.children);
68
- }
69
- } else {
70
- if (doc.body.insertAdjacentHTML) {
71
- doc.body.insertAdjacentHTML("afterbegin", spriteHtml);
72
- } else {
73
- const svgSpriteDOM = createSVGSpriteElement(doc);
74
- if (svgSpriteDOM && svgSpriteDOM.nodeType) {
75
- svgSpriteDOM.innerHTML = SVGsprite;
76
- doc.body.prepend(svgSpriteDOM);
77
- }
78
- }
79
- }
80
- };
81
- export {
82
- appendSVGSprite,
83
- appendSvgIconsSprite,
84
- setSVG,
85
- setSvgIcon
86
- };