@master/css 2.0.0-rc.6 → 2.0.0-rc.61

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 (144) hide show
  1. package/README.md +4 -43
  2. package/dist/_virtual/_commonjsHelpers.cjs +10 -0
  3. package/dist/_virtual/_commonjsHelpers.mjs +7 -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 +159 -0
  10. package/dist/common.d.ts +26 -0
  11. package/dist/common.mjs +137 -0
  12. package/dist/config/animations.cjs +113 -0
  13. package/dist/config/animations.mjs +111 -0
  14. package/dist/config/at.cjs +16 -0
  15. package/dist/config/at.d.ts +13 -0
  16. package/dist/config/at.mjs +14 -0
  17. package/dist/config/functions.cjs +375 -0
  18. package/dist/config/functions.d.ts +1 -1
  19. package/dist/config/functions.mjs +373 -0
  20. package/dist/config/index.cjs +37 -0
  21. package/dist/config/index.d.ts +5 -62
  22. package/dist/config/index.mjs +27 -0
  23. package/dist/config/modes.cjs +8 -0
  24. package/dist/config/modes.d.ts +3 -0
  25. package/dist/config/modes.mjs +6 -0
  26. package/dist/config/rules.cjs +2300 -0
  27. package/dist/config/rules.d.ts +278 -274
  28. package/dist/config/rules.mjs +2298 -0
  29. package/dist/config/selectors.cjs +28 -0
  30. package/dist/config/selectors.d.ts +0 -1
  31. package/dist/config/selectors.mjs +26 -0
  32. package/dist/config/styles.cjs +2 -0
  33. package/dist/config/styles.d.ts +2 -2
  34. package/dist/config/styles.mjs +1 -0
  35. package/dist/config/utilities.cjs +204 -0
  36. package/dist/config/{semantics.d.ts → utilities.d.ts} +15 -5
  37. package/dist/config/utilities.mjs +202 -0
  38. package/dist/config/variables.cjs +484 -0
  39. package/dist/config/variables.d.ts +208 -312
  40. package/dist/config/variables.mjs +482 -0
  41. package/dist/core.cjs +739 -0
  42. package/dist/core.d.ts +96 -75
  43. package/dist/core.mjs +737 -0
  44. package/dist/factories/with-syntax-layer.cjs +308 -0
  45. package/dist/factories/with-syntax-layer.d.ts +26 -0
  46. package/dist/factories/with-syntax-layer.mjs +306 -0
  47. package/dist/index.cjs +82 -0
  48. package/dist/index.d.ts +21 -9
  49. package/dist/index.mjs +27 -0
  50. package/dist/layer.cjs +50 -0
  51. package/dist/layer.d.ts +14 -10
  52. package/dist/layer.mjs +48 -0
  53. package/dist/non-layer.cjs +64 -0
  54. package/dist/non-layer.d.ts +12 -0
  55. package/dist/non-layer.mjs +62 -0
  56. package/dist/polyfills/css-escape.cjs +9 -0
  57. package/dist/polyfills/css-escape.mjs +7 -0
  58. package/dist/polyfills/css-escape2.cjs +76 -0
  59. package/dist/polyfills/css-escape2.mjs +74 -0
  60. package/dist/register-global.cjs +7 -0
  61. package/dist/register-global.d.ts +5 -0
  62. package/dist/register-global.mjs +5 -0
  63. package/dist/rule-node.cjs +18 -0
  64. package/dist/rule-node.d.ts +14 -0
  65. package/dist/rule-node.mjs +16 -0
  66. package/dist/rule.cjs +18 -0
  67. package/dist/rule.d.ts +9 -111
  68. package/dist/rule.mjs +16 -0
  69. package/dist/shared/utils/css-escape.cjs +56 -0
  70. package/dist/shared/utils/css-escape.mjs +54 -0
  71. package/dist/shared/utils/find-native-css-rule-index.cjs +12 -0
  72. package/dist/shared/utils/find-native-css-rule-index.mjs +10 -0
  73. package/dist/syntax-layer.cjs +8 -0
  74. package/dist/syntax-layer.d.ts +18 -0
  75. package/dist/syntax-layer.mjs +6 -0
  76. package/dist/syntax-rule-type.cjs +27 -0
  77. package/dist/syntax-rule-type.d.ts +28 -0
  78. package/dist/syntax-rule-type.mjs +25 -0
  79. package/dist/syntax-rule.cjs +666 -0
  80. package/dist/syntax-rule.d.ts +51 -0
  81. package/dist/syntax-rule.mjs +664 -0
  82. package/dist/types/common.cjs +2 -0
  83. package/dist/types/common.d.ts +1 -0
  84. package/dist/types/common.mjs +1 -0
  85. package/dist/types/config.cjs +2 -0
  86. package/dist/types/config.d.ts +70 -0
  87. package/dist/types/config.mjs +1 -0
  88. package/dist/types/syntax.cjs +2 -0
  89. package/dist/types/syntax.d.ts +106 -0
  90. package/dist/types/syntax.mjs +1 -0
  91. package/dist/utils/are-rule-at-equal.cjs +12 -0
  92. package/dist/utils/are-rule-at-equal.d.ts +2 -0
  93. package/dist/utils/are-rule-at-equal.mjs +10 -0
  94. package/dist/utils/are-rule-modes-equal.cjs +7 -0
  95. package/dist/utils/are-rule-modes-equal.d.ts +2 -0
  96. package/dist/utils/are-rule-modes-equal.mjs +5 -0
  97. package/dist/utils/are-rule-selectors-equal.cjs +29 -0
  98. package/dist/utils/are-rule-selectors-equal.d.ts +2 -0
  99. package/dist/utils/are-rule-selectors-equal.mjs +27 -0
  100. package/dist/utils/are-rule-states-equal.cjs +11 -0
  101. package/dist/utils/are-rule-states-equal.d.ts +2 -0
  102. package/dist/utils/are-rule-states-equal.mjs +9 -0
  103. package/dist/utils/are-rules-duplicated.cjs +17 -0
  104. package/dist/utils/are-rules-duplicated.d.ts +2 -0
  105. package/dist/utils/are-rules-duplicated.mjs +15 -0
  106. package/dist/utils/autofill-solid-style.cjs +31 -0
  107. package/dist/utils/autofill-solid-style.d.ts +3 -0
  108. package/dist/utils/autofill-solid-style.mjs +29 -0
  109. package/dist/utils/extend-config.cjs +59 -0
  110. package/dist/utils/extend-config.d.ts +2 -2
  111. package/dist/utils/extend-config.mjs +57 -0
  112. package/dist/utils/flatten-object.cjs +15 -0
  113. package/dist/utils/flatten-object.d.ts +1 -1
  114. package/dist/utils/flatten-object.mjs +13 -0
  115. package/dist/utils/generate-css.cjs +13 -0
  116. package/dist/utils/generate-css.d.ts +2 -0
  117. package/dist/utils/generate-css.mjs +11 -0
  118. package/dist/utils/hex-to-rgb.cjs +30 -0
  119. package/dist/utils/hex-to-rgb.d.ts +1 -1
  120. package/dist/utils/hex-to-rgb.mjs +28 -0
  121. package/dist/utils/is-core-rule.cjs +9 -0
  122. package/dist/utils/is-core-rule.d.ts +1 -0
  123. package/dist/utils/is-core-rule.mjs +7 -0
  124. package/dist/utils/reorder-for-readable-classes.cjs +62 -0
  125. package/dist/{functions → utils}/reorder-for-readable-classes.d.ts +2 -6
  126. package/dist/utils/reorder-for-readable-classes.mjs +60 -0
  127. package/package.json +1 -1
  128. package/dist/bin/index.bundle.js +0 -36
  129. package/dist/config/media-queries.d.ts +0 -1
  130. package/dist/constants/base-unit-regex.d.ts +0 -1
  131. package/dist/constants/config-esm-text.d.ts +0 -1
  132. package/dist/constants/config-text.d.ts +0 -1
  133. package/dist/constants/config-ts-text.d.ts +0 -1
  134. package/dist/constants/start-symbol.d.ts +0 -6
  135. package/dist/functions/transform-color-with-opacity.d.ts +0 -1
  136. package/dist/index.bundle.js +0 -35
  137. package/dist/index.bundle.mjs +0 -35
  138. package/dist/tokens/screen-sizes.d.ts +0 -14
  139. package/dist/types/global.d.ts +0 -5
  140. package/dist/utils/concat-arrays.d.ts +0 -1
  141. package/dist/utils/get-type.d.ts +0 -7
  142. package/dist/utils/is-plain-object.d.ts +0 -8
  143. package/dist/utils/is-symbol.d.ts +0 -7
  144. package/dist/utils/rgb-to-hex.d.ts +0 -1
@@ -0,0 +1,70 @@
1
+ import type { PropertiesHyphen } from 'csstype';
2
+ import type SyntaxRuleType from '../syntax-rule-type';
3
+ import type { SyntaxRule } from '../syntax-rule';
4
+ import type { ValueComponent } from './syntax';
5
+ import type { rules, utilities } from '../config';
6
+ export interface SyntaxRuleDefinition {
7
+ type?: SyntaxRuleType;
8
+ matcher?: RegExp;
9
+ sign?: string;
10
+ key?: string;
11
+ subkey?: string;
12
+ ambiguousKeys?: string[];
13
+ ambiguousValues?: (RegExp | string)[];
14
+ variables?: string[];
15
+ separators?: string[];
16
+ unit?: any;
17
+ declarations?: PropertiesHyphen;
18
+ includeAnimations?: boolean;
19
+ analyze?: (this: SyntaxRule, className: string) => [valueToken: string, prefixToken?: string];
20
+ transformValue?(this: SyntaxRule, value: string): string;
21
+ transformValueComponents?(this: SyntaxRule, valueComponents: ValueComponent[]): ValueComponent[];
22
+ declare?(this: SyntaxRule, value: string, valueComponents: ValueComponent[]): PropertiesHyphen;
23
+ delete?(this: SyntaxRule, className: string): void;
24
+ create?(this: SyntaxRule, className: string): void;
25
+ insert?(this: SyntaxRule): void;
26
+ }
27
+ export type VariableValue = number | string | false | (number | string)[];
28
+ export type VariableDefinition = {
29
+ [key in '' | `@${string}` | string]?: VariableValue | VariableDefinition;
30
+ } | VariableValue;
31
+ export type CSSKeyframes = Record<'from' | 'to' | string, PropertiesHyphen>;
32
+ export type AnimationDefinitions = Record<string, CSSKeyframes>;
33
+ export type SelectorDefinitions = Record<string, string | string[]>;
34
+ export interface AtDefinitions {
35
+ [key: string]: number | string | AtDefinitions;
36
+ }
37
+ export interface StyleDefinitions {
38
+ [key: string]: string | StyleDefinitions;
39
+ }
40
+ export type SyntaxRuleDefinitions = Partial<Record<keyof typeof rules | string, SyntaxRuleDefinition>>;
41
+ export type VariableDefinitions = {
42
+ [key in keyof typeof rules]?: VariableDefinition;
43
+ } & Record<string, VariableDefinition>;
44
+ export type UtilityDefinitions = {
45
+ [key in keyof typeof utilities]?: PropertiesHyphen;
46
+ } & Record<string, PropertiesHyphen>;
47
+ export type ModeDefinitions = Record<string, 'class' | 'media' | 'host' | false>;
48
+ export interface FunctionDefinition {
49
+ unit?: string;
50
+ transform?(this: SyntaxRule, value: string, bypassVariableNames: string[]): string | ValueComponent[];
51
+ }
52
+ export type FunctionDefinitions = Record<string, FunctionDefinition>;
53
+ export interface Config {
54
+ extends?: (Config | any)[];
55
+ components?: StyleDefinitions;
56
+ at?: AtDefinitions;
57
+ selectors?: SelectorDefinitions;
58
+ utilities?: UtilityDefinitions;
59
+ variables?: VariableDefinitions;
60
+ rules?: SyntaxRuleDefinitions;
61
+ rootSize?: number;
62
+ baseUnit?: number;
63
+ defaultMode?: 'light' | 'dark' | string | false;
64
+ scope?: string;
65
+ important?: boolean;
66
+ override?: boolean;
67
+ functions?: FunctionDefinitions;
68
+ animations?: AnimationDefinitions;
69
+ modes?: ModeDefinitions;
70
+ }
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
@@ -0,0 +1,106 @@
1
+ import { SyntaxRuleDefinition } from './config';
2
+ export interface AtArbitraryComponent {
3
+ type: 'arbitrary';
4
+ token?: string;
5
+ value: string;
6
+ }
7
+ export interface AtFeatureComponent {
8
+ type: 'feature';
9
+ token?: string;
10
+ name: string;
11
+ valueType: 'number' | 'string';
12
+ value: string | number;
13
+ unit?: string;
14
+ }
15
+ export interface AtOperatorComponent {
16
+ type: 'operator';
17
+ token: '&';
18
+ value: 'and';
19
+ }
20
+ export type AtComponent = AtArbitraryComponent | AtFeatureComponent | AtOperatorComponent;
21
+ export type ValueComponent = StringValueComponent | NumericValueComponent | FunctionValueComponent | VariableValueComponent | SeparatorValueComponent;
22
+ export interface StringValueComponent {
23
+ text?: string;
24
+ token: string;
25
+ type: 'string';
26
+ value: string;
27
+ }
28
+ export interface NumericValueComponent {
29
+ text?: string;
30
+ token: string;
31
+ type: 'number';
32
+ value: number;
33
+ unit?: string;
34
+ }
35
+ export interface FunctionValueComponent {
36
+ text?: string;
37
+ token: string;
38
+ type: 'function';
39
+ name: string;
40
+ symbol: string;
41
+ children: ValueComponent[];
42
+ bypassTransform?: boolean;
43
+ }
44
+ export interface VariableValueComponent {
45
+ text?: string;
46
+ token: string;
47
+ type: 'variable';
48
+ name: string;
49
+ alpha?: string;
50
+ fallback?: string;
51
+ variable?: Variable;
52
+ }
53
+ export interface SeparatorValueComponent {
54
+ text?: string;
55
+ token: string;
56
+ type: 'separator';
57
+ value: string;
58
+ }
59
+ export interface DefinedRule {
60
+ id: string;
61
+ key?: string;
62
+ keys: string[];
63
+ matchers: {
64
+ key?: RegExp;
65
+ variable?: RegExp;
66
+ value?: RegExp;
67
+ arbitrary?: RegExp;
68
+ };
69
+ variables: Record<string, Variable>;
70
+ order: number;
71
+ definition: SyntaxRuleDefinition;
72
+ }
73
+ export type MediaFeatureComponent = {
74
+ type: string;
75
+ tokenType?: string;
76
+ operator?: string;
77
+ value: number;
78
+ unit: string;
79
+ };
80
+ export interface MediaQuery {
81
+ token: string;
82
+ features: Record<string, MediaFeatureComponent>;
83
+ type?: string;
84
+ }
85
+ type VariableCommon = {
86
+ group?: string;
87
+ name: string;
88
+ key: string;
89
+ modes?: Record<string, TypeVariable>;
90
+ };
91
+ export interface StringVariable {
92
+ type: 'string';
93
+ value: string;
94
+ }
95
+ export interface NumberVariable {
96
+ type: 'number';
97
+ value: number;
98
+ }
99
+ export interface ColorVariable {
100
+ type: 'color';
101
+ value: string;
102
+ space: 'rgb' | 'hsl';
103
+ }
104
+ export type TypeVariable = StringVariable | NumberVariable | ColorVariable;
105
+ export type Variable = TypeVariable & VariableCommon;
106
+ export {};
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ function areRuleAtEqual(a, b) {
4
+ const compare = (aList, bList)=>{
5
+ const aResolved = (aList ?? []).map(a.resolveAtComponent);
6
+ const bResolved = (bList ?? []).map(b.resolveAtComponent);
7
+ return aResolved.length === bResolved.length && aResolved.every((val)=>bResolved.includes(val)) && bResolved.every((val)=>aResolved.includes(val));
8
+ };
9
+ return compare(a.mediaAtComponents, b.mediaAtComponents) && compare(a.supportsAtComponents, b.supportsAtComponents) && compare(a.containerAtComponents, b.containerAtComponents) && compare(a.layerAtComponents, b.layerAtComponents);
10
+ }
11
+
12
+ module.exports = areRuleAtEqual;
@@ -0,0 +1,2 @@
1
+ import type { SyntaxRule } from '../syntax-rule';
2
+ export default function areRuleAtEqual(a: SyntaxRule, b: SyntaxRule): boolean;
@@ -0,0 +1,10 @@
1
+ function areRuleAtEqual(a, b) {
2
+ const compare = (aList, bList)=>{
3
+ const aResolved = (aList ?? []).map(a.resolveAtComponent);
4
+ const bResolved = (bList ?? []).map(b.resolveAtComponent);
5
+ return aResolved.length === bResolved.length && aResolved.every((val)=>bResolved.includes(val)) && bResolved.every((val)=>aResolved.includes(val));
6
+ };
7
+ return compare(a.mediaAtComponents, b.mediaAtComponents) && compare(a.supportsAtComponents, b.supportsAtComponents) && compare(a.containerAtComponents, b.containerAtComponents) && compare(a.layerAtComponents, b.layerAtComponents);
8
+ }
9
+
10
+ export { areRuleAtEqual as default };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ function areRuleModesEqual(aSyntaxRule, bSyntaxRule) {
4
+ return aSyntaxRule.mode === bSyntaxRule.mode;
5
+ }
6
+
7
+ module.exports = areRuleModesEqual;
@@ -0,0 +1,2 @@
1
+ import type { SyntaxRule } from '../syntax-rule';
2
+ export default function areRuleModesEqual(aSyntaxRule: SyntaxRule, bSyntaxRule: SyntaxRule): boolean;
@@ -0,0 +1,5 @@
1
+ function areRuleModesEqual(aSyntaxRule, bSyntaxRule) {
2
+ return aSyntaxRule.mode === bSyntaxRule.mode;
3
+ }
4
+
5
+ export { areRuleModesEqual as default };
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ function areRuleSelectorsEqual(aSyntaxRule, bSyntaxRule) {
4
+ // suffix
5
+ const aVendorSuffixSelectorKeys = aSyntaxRule.vendorSuffixSelectors ? Object.keys(aSyntaxRule.vendorSuffixSelectors) : [];
6
+ const bVendorSuffixSelectorKeys = bSyntaxRule.vendorSuffixSelectors ? Object.keys(bSyntaxRule.vendorSuffixSelectors) : [];
7
+ if (aVendorSuffixSelectorKeys.length !== bVendorSuffixSelectorKeys.length) return false;
8
+ const isSameVendorSuffixSelectors = aVendorSuffixSelectorKeys.every((eachAKey)=>{
9
+ if (!Object.prototype.hasOwnProperty.call(bSyntaxRule.vendorSuffixSelectors, eachAKey)) return false;
10
+ const aValues = aSyntaxRule.vendorSuffixSelectors[eachAKey];
11
+ const bValues = bSyntaxRule.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 = aSyntaxRule.vendorPrefixSelectors ? Object.keys(aSyntaxRule.vendorPrefixSelectors) : [];
17
+ const bVendorPrefixSelectorKeys = bSyntaxRule.vendorPrefixSelectors ? Object.keys(bSyntaxRule.vendorPrefixSelectors) : [];
18
+ if (aVendorPrefixSelectorKeys.length !== bVendorPrefixSelectorKeys.length) return false;
19
+ const isSameVendorPrefixSelectors = aVendorPrefixSelectorKeys.every((eachAKey)=>{
20
+ if (!Object.prototype.hasOwnProperty.call(bSyntaxRule.vendorPrefixSelectors, eachAKey)) return false;
21
+ const aValues = aSyntaxRule.vendorPrefixSelectors?.[eachAKey] || [];
22
+ const bValues = bSyntaxRule.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 { SyntaxRule } from '../syntax-rule';
2
+ export default function areRuleSelectorsEqual(aSyntaxRule: SyntaxRule, bSyntaxRule: SyntaxRule): boolean;
@@ -0,0 +1,27 @@
1
+ function areRuleSelectorsEqual(aSyntaxRule, bSyntaxRule) {
2
+ // suffix
3
+ const aVendorSuffixSelectorKeys = aSyntaxRule.vendorSuffixSelectors ? Object.keys(aSyntaxRule.vendorSuffixSelectors) : [];
4
+ const bVendorSuffixSelectorKeys = bSyntaxRule.vendorSuffixSelectors ? Object.keys(bSyntaxRule.vendorSuffixSelectors) : [];
5
+ if (aVendorSuffixSelectorKeys.length !== bVendorSuffixSelectorKeys.length) return false;
6
+ const isSameVendorSuffixSelectors = aVendorSuffixSelectorKeys.every((eachAKey)=>{
7
+ if (!Object.prototype.hasOwnProperty.call(bSyntaxRule.vendorSuffixSelectors, eachAKey)) return false;
8
+ const aValues = aSyntaxRule.vendorSuffixSelectors[eachAKey];
9
+ const bValues = bSyntaxRule.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 = aSyntaxRule.vendorPrefixSelectors ? Object.keys(aSyntaxRule.vendorPrefixSelectors) : [];
15
+ const bVendorPrefixSelectorKeys = bSyntaxRule.vendorPrefixSelectors ? Object.keys(bSyntaxRule.vendorPrefixSelectors) : [];
16
+ if (aVendorPrefixSelectorKeys.length !== bVendorPrefixSelectorKeys.length) return false;
17
+ const isSameVendorPrefixSelectors = aVendorPrefixSelectorKeys.every((eachAKey)=>{
18
+ if (!Object.prototype.hasOwnProperty.call(bSyntaxRule.vendorPrefixSelectors, eachAKey)) return false;
19
+ const aValues = aSyntaxRule.vendorPrefixSelectors?.[eachAKey] || [];
20
+ const bValues = bSyntaxRule.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 areRuleAtEqual = require('./are-rule-at-equal.cjs');
6
+
7
+ function areRuleStatesEqual(aSyntaxRule, bSyntaxRule) {
8
+ return areRuleSelectorsEqual(aSyntaxRule, bSyntaxRule) && areRuleModesEqual(aSyntaxRule, bSyntaxRule) && areRuleAtEqual(aSyntaxRule, bSyntaxRule);
9
+ }
10
+
11
+ module.exports = areRuleStatesEqual;
@@ -0,0 +1,2 @@
1
+ import type { SyntaxRule } from '../syntax-rule';
2
+ export default function areRuleStatesEqual(aSyntaxRule: SyntaxRule, bSyntaxRule: SyntaxRule): 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 areRuleAtEqual from './are-rule-at-equal.mjs';
4
+
5
+ function areRuleStatesEqual(aSyntaxRule, bSyntaxRule) {
6
+ return areRuleSelectorsEqual(aSyntaxRule, bSyntaxRule) && areRuleModesEqual(aSyntaxRule, bSyntaxRule) && areRuleAtEqual(aSyntaxRule, bSyntaxRule);
7
+ }
8
+
9
+ export { areRuleStatesEqual as default };
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ function areRulesDuplicated(aSyntaxRule, bSyntaxRule) {
4
+ const aKeys = Object.keys(aSyntaxRule.declarations || {});
5
+ const bKeys = Object.keys(bSyntaxRule.declarations || {});
6
+ if (aKeys.length !== bKeys.length) {
7
+ return false;
8
+ }
9
+ for (const key of aKeys){
10
+ if (!Object.prototype.hasOwnProperty.call(bSyntaxRule.declarations, key)) {
11
+ return false;
12
+ }
13
+ }
14
+ return true;
15
+ }
16
+
17
+ module.exports = areRulesDuplicated;
@@ -0,0 +1,2 @@
1
+ import { SyntaxRule } from '../syntax-rule';
2
+ export default function areRulesDuplicated(aSyntaxRule: SyntaxRule, bSyntaxRule: SyntaxRule): boolean;
@@ -0,0 +1,15 @@
1
+ function areRulesDuplicated(aSyntaxRule, bSyntaxRule) {
2
+ const aKeys = Object.keys(aSyntaxRule.declarations || {});
3
+ const bKeys = Object.keys(bSyntaxRule.declarations || {});
4
+ if (aKeys.length !== bKeys.length) {
5
+ return false;
6
+ }
7
+ for (const key of aKeys){
8
+ if (!Object.prototype.hasOwnProperty.call(bSyntaxRule.declarations, key)) {
9
+ return false;
10
+ }
11
+ }
12
+ return true;
13
+ }
14
+
15
+ export { areRulesDuplicated as default };
@@ -0,0 +1,31 @@
1
+ 'use strict';
2
+
3
+ var common = require('../common.cjs');
4
+
5
+ const autofillSolidStyle = function(valueComponents) {
6
+ if (valueComponents.length < 2) return valueComponents;
7
+ let styleIncluded = false;
8
+ let varIncluded = false;
9
+ for (const valueComponent of valueComponents){
10
+ if (valueComponent.type === 'string' && common.BORDER_STYLE_VALUES.includes(valueComponent.value) || valueComponent.type === 'variable' && common.BORDER_STYLE_VALUES.includes(String(valueComponent.variable?.value))) {
11
+ styleIncluded = true;
12
+ }
13
+ if (valueComponent.type === 'function' && valueComponent.name === 'var') {
14
+ varIncluded = true;
15
+ }
16
+ }
17
+ if (!styleIncluded && !varIncluded) {
18
+ valueComponents.push({
19
+ type: 'separator',
20
+ value: ' ',
21
+ token: '|'
22
+ }, {
23
+ type: 'string',
24
+ value: 'solid',
25
+ token: 'solid'
26
+ });
27
+ }
28
+ return valueComponents;
29
+ };
30
+
31
+ module.exports = autofillSolidStyle;
@@ -0,0 +1,3 @@
1
+ import { SyntaxRuleDefinition } from '../types/config';
2
+ declare const autofillSolidStyle: SyntaxRuleDefinition['transformValueComponents'];
3
+ export default autofillSolidStyle;
@@ -0,0 +1,29 @@
1
+ import { BORDER_STYLE_VALUES } from '../common.mjs';
2
+
3
+ const autofillSolidStyle = function(valueComponents) {
4
+ if (valueComponents.length < 2) return valueComponents;
5
+ let styleIncluded = false;
6
+ let varIncluded = false;
7
+ for (const valueComponent of valueComponents){
8
+ if (valueComponent.type === 'string' && BORDER_STYLE_VALUES.includes(valueComponent.value) || valueComponent.type === 'variable' && BORDER_STYLE_VALUES.includes(String(valueComponent.variable?.value))) {
9
+ styleIncluded = true;
10
+ }
11
+ if (valueComponent.type === 'function' && valueComponent.name === 'var') {
12
+ varIncluded = true;
13
+ }
14
+ }
15
+ if (!styleIncluded && !varIncluded) {
16
+ valueComponents.push({
17
+ type: 'separator',
18
+ value: ' ',
19
+ token: '|'
20
+ }, {
21
+ type: 'string',
22
+ value: 'solid',
23
+ token: 'solid'
24
+ });
25
+ }
26
+ return valueComponents;
27
+ };
28
+
29
+ export { autofillSolidStyle as default };
@@ -0,0 +1,59 @@
1
+ 'use strict';
2
+
3
+ var extend = require('@techor/extend');
4
+
5
+ // todo: split resolveConfig into a function
6
+ function extendConfig(...configs) {
7
+ const formatConfig = (config)=>{
8
+ const clonedConfig = extend({}, config);
9
+ const formatDeeply = (obj)=>{
10
+ Object.entries(obj).forEach(([key, value])=>{
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
+ [
21
+ 'components',
22
+ 'at',
23
+ 'variables'
24
+ ].forEach((key)=>{
25
+ if (clonedConfig[key]) {
26
+ formatDeeply(clonedConfig[key]);
27
+ }
28
+ });
29
+ return clonedConfig;
30
+ };
31
+ const collectConfigs = (config, result = [])=>{
32
+ if (!config) return result;
33
+ if (config.extends?.length) {
34
+ config.extends.forEach((ext)=>collectConfigs('config' in ext ? ext.config : ext, result));
35
+ }
36
+ result.push(formatConfig(config));
37
+ return result;
38
+ };
39
+ const formattedConfigs = configs.reduce((acc, config)=>collectConfigs(config, acc), []);
40
+ return formattedConfigs.reduce((extendedConfig, currentConfig)=>{
41
+ Object.entries(currentConfig).forEach(([key, value])=>{
42
+ if (key === 'animations' && value) {
43
+ Object.assign(extendedConfig.animations, value);
44
+ } else if (value) {
45
+ extendedConfig = extend(extendedConfig, {
46
+ [key]: value
47
+ });
48
+ }
49
+ });
50
+ return extendedConfig;
51
+ }, {
52
+ animations: {},
53
+ components: {},
54
+ at: {},
55
+ variables: {}
56
+ });
57
+ }
58
+
59
+ module.exports = extendConfig;
@@ -1,2 +1,2 @@
1
- import type { Config } from '../config';
2
- export declare function extendConfig(...configs: Config[]): Config;
1
+ import type { Config } from '../types/config';
2
+ export default function extendConfig(...configs: (Config | undefined)[]): Config;
@@ -0,0 +1,57 @@
1
+ import extend from '@techor/extend';
2
+
3
+ // todo: split resolveConfig into a function
4
+ function extendConfig(...configs) {
5
+ const formatConfig = (config)=>{
6
+ const clonedConfig = extend({}, config);
7
+ const formatDeeply = (obj)=>{
8
+ Object.entries(obj).forEach(([key, value])=>{
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
+ [
19
+ 'components',
20
+ 'at',
21
+ 'variables'
22
+ ].forEach((key)=>{
23
+ if (clonedConfig[key]) {
24
+ formatDeeply(clonedConfig[key]);
25
+ }
26
+ });
27
+ return clonedConfig;
28
+ };
29
+ const collectConfigs = (config, result = [])=>{
30
+ if (!config) return result;
31
+ if (config.extends?.length) {
32
+ config.extends.forEach((ext)=>collectConfigs('config' in ext ? ext.config : ext, result));
33
+ }
34
+ result.push(formatConfig(config));
35
+ return result;
36
+ };
37
+ const formattedConfigs = configs.reduce((acc, config)=>collectConfigs(config, acc), []);
38
+ return formattedConfigs.reduce((extendedConfig, currentConfig)=>{
39
+ Object.entries(currentConfig).forEach(([key, value])=>{
40
+ if (key === 'animations' && value) {
41
+ Object.assign(extendedConfig.animations, value);
42
+ } else if (value) {
43
+ extendedConfig = extend(extendedConfig, {
44
+ [key]: value
45
+ });
46
+ }
47
+ });
48
+ return extendedConfig;
49
+ }, {
50
+ animations: {},
51
+ components: {},
52
+ at: {},
53
+ variables: {}
54
+ });
55
+ }
56
+
57
+ 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;
@@ -1 +1 @@
1
- export declare function flattenObject(obj: Record<string, any>, parentKey?: string): Record<string, any>;
1
+ export declare function flattenObject(obj: Map<string, any> | Record<string, any>, parentKey?: string): Record<string, any>;
@@ -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()) {
6
+ let text = '';
7
+ css.add(...classes);
8
+ text = css.text;
9
+ css.remove(...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.remove(...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)[];