@master/css 2.0.0-rc.4 → 2.0.0-rc.40
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.
- package/README.md +4 -43
- package/dist/_virtual/_commonjsHelpers.cjs +5 -0
- package/dist/_virtual/_commonjsHelpers.mjs +3 -0
- package/dist/_virtual/css-escape.cjs +5 -0
- package/dist/_virtual/css-escape.mjs +3 -0
- package/dist/bin/index.cjs +11 -0
- package/dist/bin/index.d.ts +0 -1
- package/dist/bin/index.mjs +9 -0
- package/dist/common.cjs +159 -0
- package/dist/common.d.ts +26 -0
- package/dist/common.mjs +137 -0
- package/dist/config/animations.cjs +113 -0
- package/dist/config/animations.mjs +111 -0
- package/dist/config/at.cjs +14 -0
- package/dist/config/at.d.ts +11 -0
- package/dist/config/at.mjs +12 -0
- package/dist/config/functions.cjs +351 -0
- package/dist/config/functions.mjs +349 -0
- package/dist/config/index.cjs +36 -0
- package/dist/config/index.d.ts +17 -14
- package/dist/config/index.mjs +26 -0
- package/dist/config/modes.cjs +8 -0
- package/dist/config/modes.d.ts +3 -0
- package/dist/config/modes.mjs +6 -0
- package/dist/config/rules.cjs +2283 -0
- package/dist/config/rules.d.ts +9 -6
- package/dist/config/rules.mjs +2281 -0
- package/dist/config/selectors.cjs +28 -0
- package/dist/config/selectors.d.ts +0 -1
- package/dist/config/selectors.mjs +26 -0
- package/dist/config/styles.cjs +2 -0
- package/dist/config/styles.mjs +1 -0
- package/dist/config/utilities.cjs +203 -0
- package/dist/config/{semantics.d.ts → utilities.d.ts} +14 -5
- package/dist/config/utilities.mjs +201 -0
- package/dist/config/variables.cjs +127 -0
- package/dist/config/variables.d.ts +132 -177
- package/dist/config/variables.mjs +125 -0
- package/dist/core.cjs +1040 -0
- package/dist/core.d.ts +37 -33
- package/dist/core.mjs +1035 -0
- package/dist/index.cjs +73 -0
- package/dist/index.d.ts +15 -8
- package/dist/index.mjs +22 -0
- package/dist/layer.cjs +28 -0
- package/dist/layer.d.ts +26 -9
- package/dist/layer.mjs +26 -0
- package/dist/polyfills/css-escape.cjs +8 -0
- package/dist/polyfills/css-escape.mjs +2 -0
- package/dist/polyfills/css-escape2.cjs +68 -0
- package/dist/polyfills/css-escape2.mjs +64 -0
- package/dist/rule.cjs +722 -0
- package/dist/rule.d.ts +60 -22
- package/dist/rule.mjs +720 -0
- package/dist/shared/utils/css-escape.cjs +56 -0
- package/dist/shared/utils/css-escape.mjs +54 -0
- package/dist/types/global.cjs +2 -0
- package/dist/types/global.d.ts +3 -3
- package/dist/types/global.mjs +1 -0
- package/dist/utils/are-rule-at-equal.cjs +22 -0
- package/dist/utils/are-rule-at-equal.d.ts +2 -0
- package/dist/utils/are-rule-at-equal.mjs +20 -0
- package/dist/utils/are-rule-modes-equal.cjs +7 -0
- package/dist/utils/are-rule-modes-equal.d.ts +2 -0
- package/dist/utils/are-rule-modes-equal.mjs +5 -0
- package/dist/utils/are-rule-selectors-equal.cjs +29 -0
- package/dist/utils/are-rule-selectors-equal.d.ts +2 -0
- package/dist/utils/are-rule-selectors-equal.mjs +27 -0
- package/dist/utils/are-rule-states-equal.cjs +11 -0
- package/dist/utils/are-rule-states-equal.d.ts +2 -0
- package/dist/utils/are-rule-states-equal.mjs +9 -0
- package/dist/utils/are-rules-duplicated.cjs +17 -0
- package/dist/utils/are-rules-duplicated.d.ts +2 -0
- package/dist/utils/are-rules-duplicated.mjs +15 -0
- package/dist/utils/autofill-solid-style.cjs +31 -0
- package/dist/utils/autofill-solid-style.d.ts +3 -0
- package/dist/utils/autofill-solid-style.mjs +29 -0
- package/dist/utils/extend-config.cjs +73 -0
- package/dist/utils/extend-config.d.ts +1 -1
- package/dist/utils/extend-config.mjs +71 -0
- package/dist/utils/flatten-object.cjs +15 -0
- package/dist/utils/flatten-object.mjs +13 -0
- package/dist/utils/generate-css.cjs +13 -0
- package/dist/utils/generate-css.d.ts +2 -0
- package/dist/utils/generate-css.mjs +11 -0
- package/dist/utils/hex-to-rgb.cjs +30 -0
- package/dist/utils/hex-to-rgb.d.ts +1 -1
- package/dist/utils/hex-to-rgb.mjs +28 -0
- package/dist/utils/is-core-rule.cjs +9 -0
- package/dist/utils/is-core-rule.d.ts +1 -0
- package/dist/utils/is-core-rule.mjs +7 -0
- package/dist/utils/reorder-for-readable-classes.cjs +62 -0
- package/dist/{functions → utils}/reorder-for-readable-classes.d.ts +2 -6
- package/dist/utils/reorder-for-readable-classes.mjs +60 -0
- package/package.json +1 -1
- package/dist/bin/index.bundle.js +0 -36
- package/dist/config/media-queries.d.ts +0 -1
- package/dist/constants/base-unit-regex.d.ts +0 -1
- package/dist/constants/config-esm-text.d.ts +0 -1
- package/dist/constants/config-text.d.ts +0 -1
- package/dist/constants/config-ts-text.d.ts +0 -1
- package/dist/constants/start-symbol.d.ts +0 -6
- package/dist/functions/transform-color-with-opacity.d.ts +0 -1
- package/dist/index.bundle.js +0 -35
- package/dist/index.bundle.mjs +0 -35
- package/dist/tokens/screen-sizes.d.ts +0 -14
- package/dist/utils/concat-arrays.d.ts +0 -1
- package/dist/utils/get-type.d.ts +0 -7
- package/dist/utils/is-plain-object.d.ts +0 -8
- package/dist/utils/is-symbol.d.ts +0 -7
- 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 };
|
package/dist/types/global.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function areRuleAtEqual(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 = areRuleAtEqual;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function areRuleAtEqual(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 { areRuleAtEqual 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,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 areRuleAtEqual = require('./are-rule-at-equal.cjs');
|
|
6
|
+
|
|
7
|
+
function areRuleStatesEqual(aRule, bRule) {
|
|
8
|
+
return areRuleSelectorsEqual(aRule, bRule) && areRuleModesEqual(aRule, bRule) && areRuleAtEqual(aRule, bRule);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
module.exports = areRuleStatesEqual;
|
|
@@ -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(aRule, bRule) {
|
|
6
|
+
return areRuleSelectorsEqual(aRule, bRule) && areRuleModesEqual(aRule, bRule) && areRuleAtEqual(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,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,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,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,73 @@
|
|
|
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.at) {
|
|
24
|
+
formatDeeply(clonedConfig.at);
|
|
25
|
+
}
|
|
26
|
+
if (clonedConfig.variables) {
|
|
27
|
+
formatDeeply(clonedConfig.variables);
|
|
28
|
+
}
|
|
29
|
+
return clonedConfig;
|
|
30
|
+
};
|
|
31
|
+
const formattedConfigs = [];
|
|
32
|
+
for (const eachConfig of configs){
|
|
33
|
+
if (!eachConfig) continue;
|
|
34
|
+
(function getConfigsDeeply(config) {
|
|
35
|
+
if (config.extends?.length) {
|
|
36
|
+
for (const eachExtend of config.extends){
|
|
37
|
+
getConfigsDeeply('config' in eachExtend ? eachExtend.config : eachExtend);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
formattedConfigs.push(formatConfig(config));
|
|
41
|
+
})(eachConfig);
|
|
42
|
+
}
|
|
43
|
+
let extendedConfig = {
|
|
44
|
+
animations: {},
|
|
45
|
+
styles: {},
|
|
46
|
+
at: {},
|
|
47
|
+
variables: {}
|
|
48
|
+
};
|
|
49
|
+
for(let i = 0; i < formattedConfigs.length; i++){
|
|
50
|
+
const currentFormattedConfig = formattedConfigs[i];
|
|
51
|
+
for(const key in currentFormattedConfig){
|
|
52
|
+
switch(key){
|
|
53
|
+
case 'animations':
|
|
54
|
+
if (currentFormattedConfig.animations) {
|
|
55
|
+
Object.assign(extendedConfig.animations, currentFormattedConfig.animations);
|
|
56
|
+
}
|
|
57
|
+
break;
|
|
58
|
+
default:
|
|
59
|
+
if (currentFormattedConfig[key]) {
|
|
60
|
+
extendedConfig = extend(extendedConfig, {
|
|
61
|
+
[key]: currentFormattedConfig[key]
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
// if (Object.prototype.hasOwnProperty.call(currentFormattedConfig.styles, key)) {
|
|
66
|
+
// Object.assign(extendedConfig.styles[key], currentFormattedConfig.styles[key])
|
|
67
|
+
// }
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return extendedConfig;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
module.exports = extendConfig;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Config } from '../config';
|
|
2
|
-
export
|
|
2
|
+
export default function extendConfig(...configs: (Config | undefined)[]): Config;
|
|
@@ -0,0 +1,71 @@
|
|
|
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.at) {
|
|
22
|
+
formatDeeply(clonedConfig.at);
|
|
23
|
+
}
|
|
24
|
+
if (clonedConfig.variables) {
|
|
25
|
+
formatDeeply(clonedConfig.variables);
|
|
26
|
+
}
|
|
27
|
+
return clonedConfig;
|
|
28
|
+
};
|
|
29
|
+
const formattedConfigs = [];
|
|
30
|
+
for (const eachConfig of configs){
|
|
31
|
+
if (!eachConfig) continue;
|
|
32
|
+
(function getConfigsDeeply(config) {
|
|
33
|
+
if (config.extends?.length) {
|
|
34
|
+
for (const eachExtend of config.extends){
|
|
35
|
+
getConfigsDeeply('config' in eachExtend ? eachExtend.config : eachExtend);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
formattedConfigs.push(formatConfig(config));
|
|
39
|
+
})(eachConfig);
|
|
40
|
+
}
|
|
41
|
+
let extendedConfig = {
|
|
42
|
+
animations: {},
|
|
43
|
+
styles: {},
|
|
44
|
+
at: {},
|
|
45
|
+
variables: {}
|
|
46
|
+
};
|
|
47
|
+
for(let i = 0; i < formattedConfigs.length; i++){
|
|
48
|
+
const currentFormattedConfig = formattedConfigs[i];
|
|
49
|
+
for(const key in currentFormattedConfig){
|
|
50
|
+
switch(key){
|
|
51
|
+
case 'animations':
|
|
52
|
+
if (currentFormattedConfig.animations) {
|
|
53
|
+
Object.assign(extendedConfig.animations, currentFormattedConfig.animations);
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
default:
|
|
57
|
+
if (currentFormattedConfig[key]) {
|
|
58
|
+
extendedConfig = extend(extendedConfig, {
|
|
59
|
+
[key]: currentFormattedConfig[key]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
// if (Object.prototype.hasOwnProperty.call(currentFormattedConfig.styles, key)) {
|
|
64
|
+
// Object.assign(extendedConfig.styles[key], currentFormattedConfig.styles[key])
|
|
65
|
+
// }
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return extendedConfig;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
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,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
|
|
1
|
+
export default function hexToRgb(hex: string): (number | undefined)[];
|