@master/css 2.0.0-rc.3 → 2.0.0-rc.31

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 (109) hide show
  1. package/README.md +4 -43
  2. package/dist/_virtual/_commonjsHelpers.cjs +5 -0
  3. package/dist/_virtual/_commonjsHelpers.mjs +3 -0
  4. package/dist/_virtual/css-escape.cjs +5 -0
  5. package/dist/_virtual/css-escape.mjs +3 -0
  6. package/dist/bin/index.cjs +11 -0
  7. package/dist/bin/index.d.ts +0 -1
  8. package/dist/bin/index.mjs +9 -0
  9. package/dist/common.cjs +145 -0
  10. package/dist/common.d.ts +25 -0
  11. package/dist/common.mjs +124 -0
  12. package/dist/config/animations.cjs +113 -0
  13. package/dist/config/animations.mjs +111 -0
  14. package/dist/config/functions.cjs +351 -0
  15. package/dist/config/functions.mjs +349 -0
  16. package/dist/config/index.cjs +36 -0
  17. package/dist/config/index.d.ts +15 -12
  18. package/dist/config/index.mjs +26 -0
  19. package/dist/config/modes.cjs +8 -0
  20. package/dist/config/modes.d.ts +3 -0
  21. package/dist/config/modes.mjs +6 -0
  22. package/dist/config/queries.cjs +17 -0
  23. package/dist/config/queries.d.ts +22 -0
  24. package/dist/config/queries.mjs +15 -0
  25. package/dist/config/rules.cjs +2303 -0
  26. package/dist/config/rules.d.ts +8 -5
  27. package/dist/config/rules.mjs +2298 -0
  28. package/dist/config/selectors.cjs +28 -0
  29. package/dist/config/selectors.d.ts +0 -1
  30. package/dist/config/selectors.mjs +26 -0
  31. package/dist/config/styles.cjs +2 -0
  32. package/dist/config/styles.mjs +1 -0
  33. package/dist/config/utilities.cjs +191 -0
  34. package/dist/config/{semantics.d.ts → utilities.d.ts} +2 -5
  35. package/dist/config/utilities.mjs +189 -0
  36. package/dist/config/variables.cjs +116 -0
  37. package/dist/config/variables.d.ts +132 -177
  38. package/dist/config/variables.mjs +114 -0
  39. package/dist/core.cjs +1046 -0
  40. package/dist/core.d.ts +35 -31
  41. package/dist/core.mjs +1041 -0
  42. package/dist/index.cjs +72 -0
  43. package/dist/index.d.ts +15 -8
  44. package/dist/index.mjs +22 -0
  45. package/dist/layer.cjs +28 -0
  46. package/dist/layer.d.ts +26 -9
  47. package/dist/layer.mjs +26 -0
  48. package/dist/polyfills/css-escape.cjs +8 -0
  49. package/dist/polyfills/css-escape.mjs +2 -0
  50. package/dist/polyfills/css-escape2.cjs +68 -0
  51. package/dist/polyfills/css-escape2.mjs +64 -0
  52. package/dist/rule.cjs +722 -0
  53. package/dist/rule.d.ts +60 -22
  54. package/dist/rule.mjs +720 -0
  55. package/dist/shared/utils/css-escape.cjs +56 -0
  56. package/dist/shared/utils/css-escape.mjs +54 -0
  57. package/dist/tokens/screen-sizes.cjs +17 -0
  58. package/dist/tokens/screen-sizes.mjs +15 -0
  59. package/dist/types/global.cjs +2 -0
  60. package/dist/types/global.d.ts +3 -3
  61. package/dist/types/global.mjs +1 -0
  62. package/dist/utils/are-rule-modes-equal.cjs +7 -0
  63. package/dist/utils/are-rule-modes-equal.d.ts +2 -0
  64. package/dist/utils/are-rule-modes-equal.mjs +5 -0
  65. package/dist/utils/are-rule-queries-equal.cjs +22 -0
  66. package/dist/utils/are-rule-queries-equal.d.ts +2 -0
  67. package/dist/utils/are-rule-queries-equal.mjs +20 -0
  68. package/dist/utils/are-rule-selectors-equal.cjs +29 -0
  69. package/dist/utils/are-rule-selectors-equal.d.ts +2 -0
  70. package/dist/utils/are-rule-selectors-equal.mjs +27 -0
  71. package/dist/utils/are-rule-states-equal.cjs +11 -0
  72. package/dist/utils/are-rule-states-equal.d.ts +2 -0
  73. package/dist/utils/are-rule-states-equal.mjs +9 -0
  74. package/dist/utils/are-rules-duplicated.cjs +17 -0
  75. package/dist/utils/are-rules-duplicated.d.ts +2 -0
  76. package/dist/utils/are-rules-duplicated.mjs +15 -0
  77. package/dist/utils/extend-config.cjs +72 -0
  78. package/dist/utils/extend-config.d.ts +1 -1
  79. package/dist/utils/extend-config.mjs +70 -0
  80. package/dist/utils/flatten-object.cjs +15 -0
  81. package/dist/utils/flatten-object.mjs +13 -0
  82. package/dist/utils/generate-css.cjs +13 -0
  83. package/dist/utils/generate-css.d.ts +2 -0
  84. package/dist/utils/generate-css.mjs +11 -0
  85. package/dist/utils/hex-to-rgb.cjs +30 -0
  86. package/dist/utils/hex-to-rgb.d.ts +1 -1
  87. package/dist/utils/hex-to-rgb.mjs +28 -0
  88. package/dist/utils/is-core-rule.cjs +9 -0
  89. package/dist/utils/is-core-rule.d.ts +1 -0
  90. package/dist/utils/is-core-rule.mjs +7 -0
  91. package/dist/utils/reorder-for-readable-classes.cjs +62 -0
  92. package/dist/{functions → utils}/reorder-for-readable-classes.d.ts +2 -6
  93. package/dist/utils/reorder-for-readable-classes.mjs +60 -0
  94. package/package.json +1 -1
  95. package/dist/bin/index.bundle.js +0 -36
  96. package/dist/config/media-queries.d.ts +0 -1
  97. package/dist/constants/base-unit-regex.d.ts +0 -1
  98. package/dist/constants/config-esm-text.d.ts +0 -1
  99. package/dist/constants/config-text.d.ts +0 -1
  100. package/dist/constants/config-ts-text.d.ts +0 -1
  101. package/dist/constants/start-symbol.d.ts +0 -6
  102. package/dist/functions/transform-color-with-opacity.d.ts +0 -1
  103. package/dist/index.bundle.js +0 -35
  104. package/dist/index.bundle.mjs +0 -35
  105. package/dist/utils/concat-arrays.d.ts +0 -1
  106. package/dist/utils/get-type.d.ts +0 -7
  107. package/dist/utils/is-plain-object.d.ts +0 -8
  108. package/dist/utils/is-symbol.d.ts +0 -7
  109. package/dist/utils/rgb-to-hex.d.ts +0 -1
@@ -0,0 +1,56 @@
1
+ 'use strict';
2
+
3
+ function cssEscape(value) {
4
+ if (typeof CSS !== 'undefined') return CSS.escape(value);
5
+ if (arguments.length == 0) {
6
+ throw new TypeError('`CSS.escape` requires an argument.');
7
+ }
8
+ const string = String(value);
9
+ const length = string.length;
10
+ let index = -1;
11
+ let result = '';
12
+ let codeUnit;
13
+ const firstCodeUnit = string.charCodeAt(0);
14
+ if (// If the character is the first character and is a `-` (U+002D), and
15
+ // there is no second character, […]
16
+ length == 1 && firstCodeUnit == 0x002D) {
17
+ return '\\' + string;
18
+ }
19
+ while(++index < length){
20
+ codeUnit = string.charCodeAt(index);
21
+ // Note: there’s no need to special-case astral symbols, surrogate
22
+ // pairs, or lone surrogates.
23
+ // If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
24
+ // (U+FFFD).
25
+ if (codeUnit == 0x0000) {
26
+ result += '\uFFFD';
27
+ continue;
28
+ }
29
+ if (// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
30
+ // U+007F, […]
31
+ codeUnit >= 0x0001 && codeUnit <= 0x001F || codeUnit == 0x007F || // If the character is the first character and is in the range [0-9]
32
+ // (U+0030 to U+0039), […]
33
+ index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039 || // If the character is the second character and is in the range [0-9]
34
+ // (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
35
+ index == 1 && codeUnit >= 0x0030 && codeUnit <= 0x0039 && firstCodeUnit == 0x002D) {
36
+ // https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
37
+ result += '\\' + codeUnit.toString(16) + ' ';
38
+ continue;
39
+ }
40
+ // If the character is not handled by one of the above rules and is
41
+ // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
42
+ // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
43
+ // U+005A), or [a-z] (U+0061 to U+007A), […]
44
+ if (codeUnit >= 0x0080 || codeUnit == 0x002D || codeUnit == 0x005F || codeUnit >= 0x0030 && codeUnit <= 0x0039 || codeUnit >= 0x0041 && codeUnit <= 0x005A || codeUnit >= 0x0061 && codeUnit <= 0x007A) {
45
+ // the character itself
46
+ result += string.charAt(index);
47
+ continue;
48
+ }
49
+ // Otherwise, the escaped character.
50
+ // https://drafts.csswg.org/cssom/#escape-a-character
51
+ result += '\\' + string.charAt(index);
52
+ }
53
+ return result;
54
+ }
55
+
56
+ module.exports = cssEscape;
@@ -0,0 +1,54 @@
1
+ function cssEscape(value) {
2
+ if (typeof CSS !== 'undefined') return CSS.escape(value);
3
+ if (arguments.length == 0) {
4
+ throw new TypeError('`CSS.escape` requires an argument.');
5
+ }
6
+ const string = String(value);
7
+ const length = string.length;
8
+ let index = -1;
9
+ let result = '';
10
+ let codeUnit;
11
+ const firstCodeUnit = string.charCodeAt(0);
12
+ if (// If the character is the first character and is a `-` (U+002D), and
13
+ // there is no second character, […]
14
+ length == 1 && firstCodeUnit == 0x002D) {
15
+ return '\\' + string;
16
+ }
17
+ while(++index < length){
18
+ codeUnit = string.charCodeAt(index);
19
+ // Note: there’s no need to special-case astral symbols, surrogate
20
+ // pairs, or lone surrogates.
21
+ // If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
22
+ // (U+FFFD).
23
+ if (codeUnit == 0x0000) {
24
+ result += '\uFFFD';
25
+ continue;
26
+ }
27
+ if (// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
28
+ // U+007F, […]
29
+ codeUnit >= 0x0001 && codeUnit <= 0x001F || codeUnit == 0x007F || // If the character is the first character and is in the range [0-9]
30
+ // (U+0030 to U+0039), […]
31
+ index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039 || // If the character is the second character and is in the range [0-9]
32
+ // (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
33
+ index == 1 && codeUnit >= 0x0030 && codeUnit <= 0x0039 && firstCodeUnit == 0x002D) {
34
+ // https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
35
+ result += '\\' + codeUnit.toString(16) + ' ';
36
+ continue;
37
+ }
38
+ // If the character is not handled by one of the above rules and is
39
+ // greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
40
+ // is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
41
+ // U+005A), or [a-z] (U+0061 to U+007A), […]
42
+ if (codeUnit >= 0x0080 || codeUnit == 0x002D || codeUnit == 0x005F || codeUnit >= 0x0030 && codeUnit <= 0x0039 || codeUnit >= 0x0041 && codeUnit <= 0x005A || codeUnit >= 0x0061 && codeUnit <= 0x007A) {
43
+ // the character itself
44
+ result += string.charAt(index);
45
+ continue;
46
+ }
47
+ // Otherwise, the escaped character.
48
+ // https://drafts.csswg.org/cssom/#escape-a-character
49
+ result += '\\' + string.charAt(index);
50
+ }
51
+ return result;
52
+ }
53
+
54
+ export { cssEscape as default };
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ var screenSizes = {
4
+ '4xs': 360,
5
+ '3xs': 480,
6
+ '2xs': 600,
7
+ 'xs': 768,
8
+ 'sm': 834,
9
+ 'md': 1024,
10
+ 'lg': 1280,
11
+ 'xl': 1440,
12
+ '2xl': 1600,
13
+ '3xl': 1920,
14
+ '4xl': 2560
15
+ };
16
+
17
+ module.exports = screenSizes;
@@ -0,0 +1,15 @@
1
+ var screenSizes = {
2
+ '4xs': 360,
3
+ '3xs': 480,
4
+ '2xs': 600,
5
+ 'xs': 768,
6
+ 'sm': 834,
7
+ 'md': 1024,
8
+ 'lg': 1280,
9
+ 'xl': 1440,
10
+ '2xl': 1600,
11
+ '3xl': 1920,
12
+ '4xl': 2560
13
+ };
14
+
15
+ export { screenSizes as default };
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -1,5 +1,5 @@
1
- import type { MasterCSS as _MasterCSS } from '../core';
1
+ import type Core from '../core';
2
2
  declare global {
3
- var MasterCSS: typeof _MasterCSS;
4
- var masterCSSs: _MasterCSS[];
3
+ var masterCSSs: Core[];
4
+ var MasterCSS: typeof Core;
5
5
  }
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ function areRuleModesEqual(aRule, bRule) {
4
+ return aRule.mode === bRule.mode;
5
+ }
6
+
7
+ module.exports = areRuleModesEqual;
@@ -0,0 +1,2 @@
1
+ import type { Rule } from '../rule';
2
+ export default function areRuleModesEqual(aRule: Rule, bRule: Rule): boolean;
@@ -0,0 +1,5 @@
1
+ function areRuleModesEqual(aRule, bRule) {
2
+ return aRule.mode === bRule.mode;
3
+ }
4
+
5
+ export { areRuleModesEqual as default };
@@ -0,0 +1,22 @@
1
+ 'use strict';
2
+
3
+ function areRuleQueriesEqual(aRule, bRule) {
4
+ const aQueryTypes = Object.keys(aRule.at);
5
+ const bQueryTypes = Object.keys(bRule.at);
6
+ if (aQueryTypes.length !== bQueryTypes.length) {
7
+ return false;
8
+ }
9
+ for (const aQueryType of aQueryTypes){
10
+ const aAtComponents = aRule.at[aQueryType];
11
+ const bAtComponents = bRule.at[aQueryType];
12
+ for (const aAtComponent of aAtComponents){
13
+ const aAtComponentToken = aRule.resolveAtComponent(aAtComponent);
14
+ if (!bAtComponents.find((bAtComponent)=>bRule.resolveAtComponent(bAtComponent) === aAtComponentToken)) {
15
+ return false;
16
+ }
17
+ }
18
+ }
19
+ return true;
20
+ }
21
+
22
+ module.exports = areRuleQueriesEqual;
@@ -0,0 +1,2 @@
1
+ import type { Rule } from '../rule';
2
+ export default function areRuleQueriesEqual(aRule: Rule, bRule: Rule): boolean;
@@ -0,0 +1,20 @@
1
+ function areRuleQueriesEqual(aRule, bRule) {
2
+ const aQueryTypes = Object.keys(aRule.at);
3
+ const bQueryTypes = Object.keys(bRule.at);
4
+ if (aQueryTypes.length !== bQueryTypes.length) {
5
+ return false;
6
+ }
7
+ for (const aQueryType of aQueryTypes){
8
+ const aAtComponents = aRule.at[aQueryType];
9
+ const bAtComponents = bRule.at[aQueryType];
10
+ for (const aAtComponent of aAtComponents){
11
+ const aAtComponentToken = aRule.resolveAtComponent(aAtComponent);
12
+ if (!bAtComponents.find((bAtComponent)=>bRule.resolveAtComponent(bAtComponent) === aAtComponentToken)) {
13
+ return false;
14
+ }
15
+ }
16
+ }
17
+ return true;
18
+ }
19
+
20
+ export { areRuleQueriesEqual as default };
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ function areRuleSelectorsEqual(aRule, bRule) {
4
+ // suffix
5
+ const aVendorSuffixSelectorKeys = Object.keys(aRule.vendorSuffixSelectors);
6
+ const bVendorSuffixSelectorKeys = Object.keys(bRule.vendorSuffixSelectors);
7
+ if (aVendorSuffixSelectorKeys.length !== bVendorSuffixSelectorKeys.length) return false;
8
+ const isSameVendorSuffixSelectors = aVendorSuffixSelectorKeys.every((eachAKey)=>{
9
+ if (!Object.prototype.hasOwnProperty.call(bRule.vendorSuffixSelectors, eachAKey)) return false;
10
+ const aValues = aRule.vendorSuffixSelectors[eachAKey];
11
+ const bValues = bRule.vendorSuffixSelectors[eachAKey];
12
+ return aValues.length === bValues.length && aValues.every((eachAValue)=>bValues.includes(eachAValue));
13
+ });
14
+ if (!isSameVendorSuffixSelectors) return false;
15
+ // prefix
16
+ const aVendorPrefixSelectorKeys = Object.keys(aRule.vendorPrefixSelectors);
17
+ const bVendorPrefixSelectorKeys = Object.keys(bRule.vendorPrefixSelectors);
18
+ if (aVendorPrefixSelectorKeys.length !== bVendorPrefixSelectorKeys.length) return false;
19
+ const isSameVendorPrefixSelectors = aVendorPrefixSelectorKeys.every((eachAKey)=>{
20
+ if (!Object.prototype.hasOwnProperty.call(bRule.vendorPrefixSelectors, eachAKey)) return false;
21
+ const aValues = aRule.vendorPrefixSelectors[eachAKey];
22
+ const bValues = bRule.vendorPrefixSelectors[eachAKey];
23
+ return aValues.length === bValues.length && aValues.every((eachAValue)=>bValues.includes(eachAValue));
24
+ });
25
+ if (!isSameVendorPrefixSelectors) return false;
26
+ return true;
27
+ }
28
+
29
+ module.exports = areRuleSelectorsEqual;
@@ -0,0 +1,2 @@
1
+ import type { Rule } from '../rule';
2
+ export default function areRuleSelectorsEqual(aRule: Rule, bRule: Rule): boolean;
@@ -0,0 +1,27 @@
1
+ function areRuleSelectorsEqual(aRule, bRule) {
2
+ // suffix
3
+ const aVendorSuffixSelectorKeys = Object.keys(aRule.vendorSuffixSelectors);
4
+ const bVendorSuffixSelectorKeys = Object.keys(bRule.vendorSuffixSelectors);
5
+ if (aVendorSuffixSelectorKeys.length !== bVendorSuffixSelectorKeys.length) return false;
6
+ const isSameVendorSuffixSelectors = aVendorSuffixSelectorKeys.every((eachAKey)=>{
7
+ if (!Object.prototype.hasOwnProperty.call(bRule.vendorSuffixSelectors, eachAKey)) return false;
8
+ const aValues = aRule.vendorSuffixSelectors[eachAKey];
9
+ const bValues = bRule.vendorSuffixSelectors[eachAKey];
10
+ return aValues.length === bValues.length && aValues.every((eachAValue)=>bValues.includes(eachAValue));
11
+ });
12
+ if (!isSameVendorSuffixSelectors) return false;
13
+ // prefix
14
+ const aVendorPrefixSelectorKeys = Object.keys(aRule.vendorPrefixSelectors);
15
+ const bVendorPrefixSelectorKeys = Object.keys(bRule.vendorPrefixSelectors);
16
+ if (aVendorPrefixSelectorKeys.length !== bVendorPrefixSelectorKeys.length) return false;
17
+ const isSameVendorPrefixSelectors = aVendorPrefixSelectorKeys.every((eachAKey)=>{
18
+ if (!Object.prototype.hasOwnProperty.call(bRule.vendorPrefixSelectors, eachAKey)) return false;
19
+ const aValues = aRule.vendorPrefixSelectors[eachAKey];
20
+ const bValues = bRule.vendorPrefixSelectors[eachAKey];
21
+ return aValues.length === bValues.length && aValues.every((eachAValue)=>bValues.includes(eachAValue));
22
+ });
23
+ if (!isSameVendorPrefixSelectors) return false;
24
+ return true;
25
+ }
26
+
27
+ export { areRuleSelectorsEqual as default };
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ var areRuleSelectorsEqual = require('./are-rule-selectors-equal.cjs');
4
+ var areRuleModesEqual = require('./are-rule-modes-equal.cjs');
5
+ var areRuleQueriesEqual = require('./are-rule-queries-equal.cjs');
6
+
7
+ function areRuleStatesEqual(aRule, bRule) {
8
+ return areRuleSelectorsEqual(aRule, bRule) && areRuleModesEqual(aRule, bRule) && areRuleQueriesEqual(aRule, bRule);
9
+ }
10
+
11
+ module.exports = areRuleStatesEqual;
@@ -0,0 +1,2 @@
1
+ import type { Rule } from '../rule';
2
+ export default function areRuleStatesEqual(aRule: Rule, bRule: Rule): boolean;
@@ -0,0 +1,9 @@
1
+ import areRuleSelectorsEqual from './are-rule-selectors-equal.mjs';
2
+ import areRuleModesEqual from './are-rule-modes-equal.mjs';
3
+ import areRuleQueriesEqual from './are-rule-queries-equal.mjs';
4
+
5
+ function areRuleStatesEqual(aRule, bRule) {
6
+ return areRuleSelectorsEqual(aRule, bRule) && areRuleModesEqual(aRule, bRule) && areRuleQueriesEqual(aRule, bRule);
7
+ }
8
+
9
+ export { areRuleStatesEqual as default };
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ function areRulesDuplicated(aRule, bRule) {
4
+ const aKeys = Object.keys(aRule.declarations || {});
5
+ const bKeys = Object.keys(bRule.declarations || {});
6
+ if (aKeys.length !== bKeys.length) {
7
+ return false;
8
+ }
9
+ for (const key of aKeys){
10
+ if (!Object.prototype.hasOwnProperty.call(bRule.declarations, key)) {
11
+ return false;
12
+ }
13
+ }
14
+ return true;
15
+ }
16
+
17
+ module.exports = areRulesDuplicated;
@@ -0,0 +1,2 @@
1
+ import type { Rule } from '../rule';
2
+ export default function areRulesDuplicated(aRule: Rule, bRule: Rule): boolean;
@@ -0,0 +1,15 @@
1
+ function areRulesDuplicated(aRule, bRule) {
2
+ const aKeys = Object.keys(aRule.declarations || {});
3
+ const bKeys = Object.keys(bRule.declarations || {});
4
+ if (aKeys.length !== bKeys.length) {
5
+ return false;
6
+ }
7
+ for (const key of aKeys){
8
+ if (!Object.prototype.hasOwnProperty.call(bRule.declarations, key)) {
9
+ return false;
10
+ }
11
+ }
12
+ return true;
13
+ }
14
+
15
+ export { areRulesDuplicated as default };
@@ -0,0 +1,72 @@
1
+ 'use strict';
2
+
3
+ var extend = require('@techor/extend');
4
+
5
+ function extendConfig(...configs) {
6
+ const formatConfig = (config)=>{
7
+ const clonedConfig = extend({}, config);
8
+ const formatDeeply = (obj)=>{
9
+ for(const key in obj){
10
+ const value = obj[key];
11
+ if (typeof value === 'object' && !Array.isArray(value)) {
12
+ formatDeeply(value);
13
+ } else if (key && !key.startsWith('@')) {
14
+ obj[key] = {
15
+ '': value
16
+ };
17
+ }
18
+ }
19
+ };
20
+ if (clonedConfig.styles) {
21
+ formatDeeply(clonedConfig.styles);
22
+ }
23
+ if (clonedConfig.queries) {
24
+ formatDeeply(clonedConfig.queries);
25
+ }
26
+ if (clonedConfig.variables) {
27
+ formatDeeply(clonedConfig.variables);
28
+ }
29
+ return clonedConfig;
30
+ };
31
+ const formattedConfigs = [];
32
+ for (const eachConfig of configs){
33
+ (function getConfigsDeeply(config) {
34
+ if (config.extends?.length) {
35
+ for (const eachExtend of config.extends){
36
+ getConfigsDeeply('config' in eachExtend ? eachExtend.config : eachExtend);
37
+ }
38
+ }
39
+ formattedConfigs.push(formatConfig(config));
40
+ })(eachConfig);
41
+ }
42
+ let extendedConfig = {
43
+ animations: {},
44
+ styles: {},
45
+ queries: {},
46
+ variables: {}
47
+ };
48
+ for(let i = 0; i < formattedConfigs.length; i++){
49
+ const currentFormattedConfig = formattedConfigs[i];
50
+ for(const key in currentFormattedConfig){
51
+ switch(key){
52
+ case 'animations':
53
+ if (currentFormattedConfig.animations) {
54
+ Object.assign(extendedConfig.animations, currentFormattedConfig.animations);
55
+ }
56
+ break;
57
+ default:
58
+ if (currentFormattedConfig[key]) {
59
+ extendedConfig = extend(extendedConfig, {
60
+ [key]: currentFormattedConfig[key]
61
+ });
62
+ }
63
+ }
64
+ // if (Object.prototype.hasOwnProperty.call(currentFormattedConfig.styles, key)) {
65
+ // Object.assign(extendedConfig.styles[key], currentFormattedConfig.styles[key])
66
+ // }
67
+ }
68
+ }
69
+ return extendedConfig;
70
+ }
71
+
72
+ module.exports = extendConfig;
@@ -1,2 +1,2 @@
1
1
  import type { Config } from '../config';
2
- export declare function extendConfig(...configs: Config[]): Config;
2
+ export default function extendConfig(...configs: Config[]): Config;
@@ -0,0 +1,70 @@
1
+ import extend from '@techor/extend';
2
+
3
+ function extendConfig(...configs) {
4
+ const formatConfig = (config)=>{
5
+ const clonedConfig = extend({}, config);
6
+ const formatDeeply = (obj)=>{
7
+ for(const key in obj){
8
+ const value = obj[key];
9
+ if (typeof value === 'object' && !Array.isArray(value)) {
10
+ formatDeeply(value);
11
+ } else if (key && !key.startsWith('@')) {
12
+ obj[key] = {
13
+ '': value
14
+ };
15
+ }
16
+ }
17
+ };
18
+ if (clonedConfig.styles) {
19
+ formatDeeply(clonedConfig.styles);
20
+ }
21
+ if (clonedConfig.queries) {
22
+ formatDeeply(clonedConfig.queries);
23
+ }
24
+ if (clonedConfig.variables) {
25
+ formatDeeply(clonedConfig.variables);
26
+ }
27
+ return clonedConfig;
28
+ };
29
+ const formattedConfigs = [];
30
+ for (const eachConfig of configs){
31
+ (function getConfigsDeeply(config) {
32
+ if (config.extends?.length) {
33
+ for (const eachExtend of config.extends){
34
+ getConfigsDeeply('config' in eachExtend ? eachExtend.config : eachExtend);
35
+ }
36
+ }
37
+ formattedConfigs.push(formatConfig(config));
38
+ })(eachConfig);
39
+ }
40
+ let extendedConfig = {
41
+ animations: {},
42
+ styles: {},
43
+ queries: {},
44
+ variables: {}
45
+ };
46
+ for(let i = 0; i < formattedConfigs.length; i++){
47
+ const currentFormattedConfig = formattedConfigs[i];
48
+ for(const key in currentFormattedConfig){
49
+ switch(key){
50
+ case 'animations':
51
+ if (currentFormattedConfig.animations) {
52
+ Object.assign(extendedConfig.animations, currentFormattedConfig.animations);
53
+ }
54
+ break;
55
+ default:
56
+ if (currentFormattedConfig[key]) {
57
+ extendedConfig = extend(extendedConfig, {
58
+ [key]: currentFormattedConfig[key]
59
+ });
60
+ }
61
+ }
62
+ // if (Object.prototype.hasOwnProperty.call(currentFormattedConfig.styles, key)) {
63
+ // Object.assign(extendedConfig.styles[key], currentFormattedConfig.styles[key])
64
+ // }
65
+ }
66
+ }
67
+ return extendedConfig;
68
+ }
69
+
70
+ export { extendConfig as default };
@@ -0,0 +1,15 @@
1
+ 'use strict';
2
+
3
+ function flattenObject(obj, parentKey = '') {
4
+ return Object.entries(obj).reduce((acc, [key, value])=>{
5
+ const currentKey = parentKey ? `${parentKey}${key ? '-' + key : ''}` : key;
6
+ if (typeof value === 'object' && !Array.isArray(value)) {
7
+ Object.assign(acc, flattenObject(value, currentKey));
8
+ } else {
9
+ acc[currentKey] = value;
10
+ }
11
+ return acc;
12
+ }, {});
13
+ }
14
+
15
+ exports.flattenObject = flattenObject;
@@ -0,0 +1,13 @@
1
+ function flattenObject(obj, parentKey = '') {
2
+ return Object.entries(obj).reduce((acc, [key, value])=>{
3
+ const currentKey = parentKey ? `${parentKey}${key ? '-' + key : ''}` : key;
4
+ if (typeof value === 'object' && !Array.isArray(value)) {
5
+ Object.assign(acc, flattenObject(value, currentKey));
6
+ } else {
7
+ acc[currentKey] = value;
8
+ }
9
+ return acc;
10
+ }, {});
11
+ }
12
+
13
+ export { flattenObject };
@@ -0,0 +1,13 @@
1
+ 'use strict';
2
+
3
+ var core = require('../core.cjs');
4
+
5
+ function generateCSS(classes, css = new core.default()) {
6
+ let text = '';
7
+ css.add(...classes);
8
+ text = css.text;
9
+ css.delete(...classes);
10
+ return text;
11
+ }
12
+
13
+ module.exports = generateCSS;
@@ -0,0 +1,2 @@
1
+ import MasterCSS from '../core';
2
+ export default function generateCSS(classes: string[], css?: MasterCSS): string;
@@ -0,0 +1,11 @@
1
+ import MasterCSS from '../core.mjs';
2
+
3
+ function generateCSS(classes, css = new MasterCSS()) {
4
+ let text = '';
5
+ css.add(...classes);
6
+ text = css.text;
7
+ css.delete(...classes);
8
+ return text;
9
+ }
10
+
11
+ export { generateCSS as default };
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ function hexToRgb(hex) {
4
+ if (hex.startsWith('#')) {
5
+ hex = hex.slice(1);
6
+ }
7
+ let r;
8
+ let g;
9
+ let b;
10
+ let a;
11
+ if (hex.length === 3 || hex.length === 4) {
12
+ r = parseInt(hex[0] + hex[0], 16);
13
+ g = parseInt(hex[1] + hex[1], 16);
14
+ b = parseInt(hex[2] + hex[2], 16);
15
+ a = hex.length === 4 ? Math.round(parseInt(hex[3] + hex[3], 16) / 255 * 100) / 100 : 1;
16
+ } else if (hex.length === 6 || hex.length === 8) {
17
+ r = parseInt(hex.slice(0, 2), 16);
18
+ g = parseInt(hex.slice(2, 4), 16);
19
+ b = parseInt(hex.slice(4, 6), 16);
20
+ a = hex.length === 8 ? Math.round(parseInt(hex.slice(6, 8), 16) / 255 * 100) / 100 : 1;
21
+ }
22
+ return [
23
+ r,
24
+ g,
25
+ b,
26
+ a
27
+ ];
28
+ }
29
+
30
+ module.exports = hexToRgb;
@@ -1 +1 @@
1
- export declare function hexToRgb(hex: string): (number | undefined)[];
1
+ export default function hexToRgb(hex: string): (number | undefined)[];
@@ -0,0 +1,28 @@
1
+ function hexToRgb(hex) {
2
+ if (hex.startsWith('#')) {
3
+ hex = hex.slice(1);
4
+ }
5
+ let r;
6
+ let g;
7
+ let b;
8
+ let a;
9
+ if (hex.length === 3 || hex.length === 4) {
10
+ r = parseInt(hex[0] + hex[0], 16);
11
+ g = parseInt(hex[1] + hex[1], 16);
12
+ b = parseInt(hex[2] + hex[2], 16);
13
+ a = hex.length === 4 ? Math.round(parseInt(hex[3] + hex[3], 16) / 255 * 100) / 100 : 1;
14
+ } else if (hex.length === 6 || hex.length === 8) {
15
+ r = parseInt(hex.slice(0, 2), 16);
16
+ g = parseInt(hex.slice(2, 4), 16);
17
+ b = parseInt(hex.slice(4, 6), 16);
18
+ a = hex.length === 8 ? Math.round(parseInt(hex.slice(6, 8), 16) / 255 * 100) / 100 : 1;
19
+ }
20
+ return [
21
+ r,
22
+ g,
23
+ b,
24
+ a
25
+ ];
26
+ }
27
+
28
+ export { hexToRgb as default };
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var rules = require('../config/rules.cjs');
4
+
5
+ function isCoreRule(id) {
6
+ return Object.hasOwnProperty.call(rules.default, id);
7
+ }
8
+
9
+ module.exports = isCoreRule;
@@ -0,0 +1 @@
1
+ export default function isCoreRule(id: string): boolean;
@@ -0,0 +1,7 @@
1
+ import rules from '../config/rules.mjs';
2
+
3
+ function isCoreRule(id) {
4
+ return Object.hasOwnProperty.call(rules, id);
5
+ }
6
+
7
+ export { isCoreRule as default };