@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
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var index = require('./config/index.cjs');
|
|
6
|
+
var rule = require('./rule.cjs');
|
|
7
|
+
var common = require('./common.cjs');
|
|
8
|
+
var core = require('./core.cjs');
|
|
9
|
+
var layer = require('./layer.cjs');
|
|
10
|
+
var extendConfig = require('./utils/extend-config.cjs');
|
|
11
|
+
var reorderForReadableClasses = require('./utils/reorder-for-readable-classes.cjs');
|
|
12
|
+
var areRuleModesEqual = require('./utils/are-rule-modes-equal.cjs');
|
|
13
|
+
var areRuleAtEqual = require('./utils/are-rule-at-equal.cjs');
|
|
14
|
+
var areRuleSelectorsEqual = require('./utils/are-rule-selectors-equal.cjs');
|
|
15
|
+
var areRuleStatesEqual = require('./utils/are-rule-states-equal.cjs');
|
|
16
|
+
var areRulesDuplicated = require('./utils/are-rules-duplicated.cjs');
|
|
17
|
+
var generateCss = require('./utils/generate-css.cjs');
|
|
18
|
+
var isCoreRule = require('./utils/is-core-rule.cjs');
|
|
19
|
+
var at = require('./config/at.cjs');
|
|
20
|
+
var selectors = require('./config/selectors.cjs');
|
|
21
|
+
var utilities = require('./config/utilities.cjs');
|
|
22
|
+
var functions = require('./config/functions.cjs');
|
|
23
|
+
var animations = require('./config/animations.cjs');
|
|
24
|
+
var variables = require('./config/variables.cjs');
|
|
25
|
+
var modes = require('./config/modes.cjs');
|
|
26
|
+
var rules = require('./config/rules.cjs');
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
exports.config = index.config;
|
|
31
|
+
exports.Rule = rule.Rule;
|
|
32
|
+
exports.ANIMATION_SIGN = common.ANIMATION_SIGN;
|
|
33
|
+
exports.AT_SIGN = common.AT_SIGN;
|
|
34
|
+
exports.BASE_UNIT_REGEX = common.BASE_UNIT_REGEX;
|
|
35
|
+
exports.BORDER_STYLE_VALUES = common.BORDER_STYLE_VALUES;
|
|
36
|
+
exports.CLASS_ATTRIBUTES = common.CLASS_ATTRIBUTES;
|
|
37
|
+
exports.CLASS_DECLARATIONS = common.CLASS_DECLARATIONS;
|
|
38
|
+
exports.CLASS_FUNCTIONS = common.CLASS_FUNCTIONS;
|
|
39
|
+
exports.COLOR_VALUE_REGEX = common.COLOR_VALUE_REGEX;
|
|
40
|
+
exports.DELIMITER_SIGN = common.DELIMITER_SIGN;
|
|
41
|
+
exports.IMAGE_VALUE_REGEX = common.IMAGE_VALUE_REGEX;
|
|
42
|
+
exports.NUMBER_VALUE_REGEX = common.NUMBER_VALUE_REGEX;
|
|
43
|
+
exports.OFFICIAL_URL = common.OFFICIAL_URL;
|
|
44
|
+
exports.QUERY_COMPARISON_OPERATORS = common.QUERY_COMPARISON_OPERATORS;
|
|
45
|
+
exports.QUERY_LOGICAL_OPERATORS = common.QUERY_LOGICAL_OPERATORS;
|
|
46
|
+
exports.SELECTOR_SIGNS = common.SELECTOR_SIGNS;
|
|
47
|
+
exports.SEPARATOR_SIGN = common.SEPARATOR_SIGN;
|
|
48
|
+
exports.SEPARATOR_SIGNS = common.SEPARATOR_SIGNS;
|
|
49
|
+
exports.TRANSITION_SIGN = common.TRANSITION_SIGN;
|
|
50
|
+
exports.UNIT_REGEX = common.UNIT_REGEX;
|
|
51
|
+
exports.VALUE_DELIMITERS = common.VALUE_DELIMITERS;
|
|
52
|
+
exports.VALUE_UNITS = common.VALUE_UNITS;
|
|
53
|
+
exports.MasterCSS = core.default;
|
|
54
|
+
exports.default = core.default;
|
|
55
|
+
exports.masterCSSs = core.masterCSSs;
|
|
56
|
+
exports.Layer = layer;
|
|
57
|
+
exports.extendConfig = extendConfig;
|
|
58
|
+
exports.reorderForReadableClasses = reorderForReadableClasses;
|
|
59
|
+
exports.areRuleModesEqual = areRuleModesEqual;
|
|
60
|
+
exports.areRuleAtEqual = areRuleAtEqual;
|
|
61
|
+
exports.areRuleSelectorsEqual = areRuleSelectorsEqual;
|
|
62
|
+
exports.areRuleStatesEqual = areRuleStatesEqual;
|
|
63
|
+
exports.areRulesDuplicated = areRulesDuplicated;
|
|
64
|
+
exports.generateCSS = generateCss;
|
|
65
|
+
exports.isCoreRule = isCoreRule;
|
|
66
|
+
exports.at = at;
|
|
67
|
+
exports.selectors = selectors;
|
|
68
|
+
exports.utilities = utilities;
|
|
69
|
+
exports.functions = functions;
|
|
70
|
+
exports.animations = animations;
|
|
71
|
+
exports.variables = variables;
|
|
72
|
+
exports.modes = modes;
|
|
73
|
+
exports.rules = rules;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
export
|
|
1
|
+
export * from './config';
|
|
2
|
+
export * from './rule';
|
|
3
|
+
export * from './common';
|
|
4
|
+
export * from './core';
|
|
2
5
|
export { Rule } from './rule';
|
|
6
|
+
export { default as Layer } from './layer';
|
|
7
|
+
export { default as MasterCSS, default } from './core';
|
|
8
|
+
export { default as extendConfig } from './utils/extend-config';
|
|
9
|
+
export { default as reorderForReadableClasses } from './utils/reorder-for-readable-classes';
|
|
10
|
+
export { default as areRuleModesEqual } from './utils/are-rule-modes-equal';
|
|
11
|
+
export { default as areRuleAtEqual } from './utils/are-rule-at-equal';
|
|
12
|
+
export { default as areRuleSelectorsEqual } from './utils/are-rule-selectors-equal';
|
|
13
|
+
export { default as areRuleStatesEqual } from './utils/are-rule-states-equal';
|
|
14
|
+
export { default as areRulesDuplicated } from './utils/are-rules-duplicated';
|
|
15
|
+
export { default as generateCSS } from './utils/generate-css';
|
|
16
|
+
export { default as isCoreRule } from './utils/is-core-rule';
|
|
3
17
|
export type { NativeRule, MediaFeatureComponent, MediaQuery } from './rule';
|
|
4
|
-
export { CONFIG_TEXT } from './constants/config-text';
|
|
5
|
-
export { CONFIG_ESM_TEXT } from './constants/config-esm-text';
|
|
6
|
-
export { CONFIG_TS_TEXT } from './constants/config-ts-text';
|
|
7
|
-
export { Layer } from './layer';
|
|
8
|
-
export { default as extend } from '@techor/extend';
|
|
9
|
-
export { default as reorderForReadableClasses } from './functions/reorder-for-readable-classes';
|
|
10
|
-
export * from './config';
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { config } from './config/index.mjs';
|
|
2
|
+
export { Rule } from './rule.mjs';
|
|
3
|
+
export { ANIMATION_SIGN, AT_SIGN, BASE_UNIT_REGEX, BORDER_STYLE_VALUES, CLASS_ATTRIBUTES, CLASS_DECLARATIONS, CLASS_FUNCTIONS, COLOR_VALUE_REGEX, DELIMITER_SIGN, IMAGE_VALUE_REGEX, NUMBER_VALUE_REGEX, OFFICIAL_URL, QUERY_COMPARISON_OPERATORS, QUERY_LOGICAL_OPERATORS, SELECTOR_SIGNS, SEPARATOR_SIGN, SEPARATOR_SIGNS, TRANSITION_SIGN, UNIT_REGEX, VALUE_DELIMITERS, VALUE_UNITS } from './common.mjs';
|
|
4
|
+
export { default as MasterCSS, default, masterCSSs } from './core.mjs';
|
|
5
|
+
export { default as Layer } from './layer.mjs';
|
|
6
|
+
export { default as extendConfig } from './utils/extend-config.mjs';
|
|
7
|
+
export { default as reorderForReadableClasses } from './utils/reorder-for-readable-classes.mjs';
|
|
8
|
+
export { default as areRuleModesEqual } from './utils/are-rule-modes-equal.mjs';
|
|
9
|
+
export { default as areRuleAtEqual } from './utils/are-rule-at-equal.mjs';
|
|
10
|
+
export { default as areRuleSelectorsEqual } from './utils/are-rule-selectors-equal.mjs';
|
|
11
|
+
export { default as areRuleStatesEqual } from './utils/are-rule-states-equal.mjs';
|
|
12
|
+
export { default as areRulesDuplicated } from './utils/are-rules-duplicated.mjs';
|
|
13
|
+
export { default as generateCSS } from './utils/generate-css.mjs';
|
|
14
|
+
export { default as isCoreRule } from './utils/is-core-rule.mjs';
|
|
15
|
+
export { default as at } from './config/at.mjs';
|
|
16
|
+
export { default as selectors } from './config/selectors.mjs';
|
|
17
|
+
export { default as utilities } from './config/utilities.mjs';
|
|
18
|
+
export { default as functions } from './config/functions.mjs';
|
|
19
|
+
export { default as animations } from './config/animations.mjs';
|
|
20
|
+
export { default as variables } from './config/variables.mjs';
|
|
21
|
+
export { default as modes } from './config/modes.mjs';
|
|
22
|
+
export { default as rules } from './config/rules.mjs';
|
package/dist/layer.cjs
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var Layer;
|
|
4
|
+
(function(Layer) {
|
|
5
|
+
/**
|
|
6
|
+
* utility classes
|
|
7
|
+
* @example block, inline
|
|
8
|
+
*/ Layer[Layer["Utility"] = -4] = "Utility";
|
|
9
|
+
/**
|
|
10
|
+
* native shorthand
|
|
11
|
+
* @example border, padding, margin
|
|
12
|
+
*/ Layer[Layer["NativeShorthand"] = -3] = "NativeShorthand";
|
|
13
|
+
/**
|
|
14
|
+
* shorthand
|
|
15
|
+
* @example px, py, mx, my
|
|
16
|
+
*/ Layer[Layer["Shorthand"] = -2] = "Shorthand";
|
|
17
|
+
/**
|
|
18
|
+
* native properties
|
|
19
|
+
* @example color, background-color, font-size
|
|
20
|
+
*/ Layer[Layer["Native"] = -1] = "Native";
|
|
21
|
+
/**
|
|
22
|
+
* normal
|
|
23
|
+
* @example grid-cols
|
|
24
|
+
*/ Layer[Layer["Normal"] = 0] = "Normal";
|
|
25
|
+
})(Layer || (Layer = {}));
|
|
26
|
+
var Layer$1 = Layer;
|
|
27
|
+
|
|
28
|
+
module.exports = Layer$1;
|
package/dist/layer.d.ts
CHANGED
|
@@ -1,11 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
declare const enum Layer {
|
|
2
|
+
/**
|
|
3
|
+
* utility classes
|
|
4
|
+
* @example block, inline
|
|
5
|
+
*/
|
|
6
|
+
Utility = -4,
|
|
7
|
+
/**
|
|
8
|
+
* native shorthand
|
|
9
|
+
* @example border, padding, margin
|
|
10
|
+
*/
|
|
11
|
+
NativeShorthand = -3,
|
|
12
|
+
/**
|
|
13
|
+
* shorthand
|
|
14
|
+
* @example px, py, mx, my
|
|
15
|
+
*/
|
|
16
|
+
Shorthand = -2,
|
|
17
|
+
/**
|
|
18
|
+
* native properties
|
|
19
|
+
* @example color, background-color, font-size
|
|
20
|
+
*/
|
|
21
|
+
Native = -1,
|
|
22
|
+
/**
|
|
23
|
+
* normal
|
|
24
|
+
* @example grid-cols
|
|
25
|
+
*/
|
|
10
26
|
Normal = 0
|
|
11
27
|
}
|
|
28
|
+
export default Layer;
|
package/dist/layer.mjs
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var Layer;
|
|
2
|
+
(function(Layer) {
|
|
3
|
+
/**
|
|
4
|
+
* utility classes
|
|
5
|
+
* @example block, inline
|
|
6
|
+
*/ Layer[Layer["Utility"] = -4] = "Utility";
|
|
7
|
+
/**
|
|
8
|
+
* native shorthand
|
|
9
|
+
* @example border, padding, margin
|
|
10
|
+
*/ Layer[Layer["NativeShorthand"] = -3] = "NativeShorthand";
|
|
11
|
+
/**
|
|
12
|
+
* shorthand
|
|
13
|
+
* @example px, py, mx, my
|
|
14
|
+
*/ Layer[Layer["Shorthand"] = -2] = "Shorthand";
|
|
15
|
+
/**
|
|
16
|
+
* native properties
|
|
17
|
+
* @example color, background-color, font-size
|
|
18
|
+
*/ Layer[Layer["Native"] = -1] = "Native";
|
|
19
|
+
/**
|
|
20
|
+
* normal
|
|
21
|
+
* @example grid-cols
|
|
22
|
+
*/ Layer[Layer["Normal"] = 0] = "Normal";
|
|
23
|
+
})(Layer || (Layer = {}));
|
|
24
|
+
var Layer$1 = Layer;
|
|
25
|
+
|
|
26
|
+
export { Layer$1 as default };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _commonjsHelpers = require('../_virtual/_commonjsHelpers.cjs');
|
|
4
|
+
|
|
5
|
+
(()=>{
|
|
6
|
+
const root = typeof _commonjsHelpers.commonjsGlobal !== 'undefined' ? _commonjsHelpers.commonjsGlobal : window;
|
|
7
|
+
if (!root.CSS && !root.CSS?.escape) {
|
|
8
|
+
// https://drafts.csswg.org/cssom/#serialize-an-identifier
|
|
9
|
+
const cssEscape = function(value) {
|
|
10
|
+
if (arguments.length == 0) {
|
|
11
|
+
throw new TypeError('`CSS.escape` requires an argument.');
|
|
12
|
+
}
|
|
13
|
+
const string = String(value);
|
|
14
|
+
const length = string.length;
|
|
15
|
+
let index = -1;
|
|
16
|
+
let result = '';
|
|
17
|
+
let codeUnit;
|
|
18
|
+
const firstCodeUnit = string.charCodeAt(0);
|
|
19
|
+
if (// If the character is the first character and is a `-` (U+002D), and
|
|
20
|
+
// there is no second character, […]
|
|
21
|
+
length == 1 && firstCodeUnit == 0x002D) {
|
|
22
|
+
return '\\' + string;
|
|
23
|
+
}
|
|
24
|
+
while(++index < length){
|
|
25
|
+
codeUnit = string.charCodeAt(index);
|
|
26
|
+
// Note: there’s no need to special-case astral symbols, surrogate
|
|
27
|
+
// pairs, or lone surrogates.
|
|
28
|
+
// If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
|
|
29
|
+
// (U+FFFD).
|
|
30
|
+
if (codeUnit == 0x0000) {
|
|
31
|
+
result += '\uFFFD';
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
|
|
35
|
+
// U+007F, […]
|
|
36
|
+
codeUnit >= 0x0001 && codeUnit <= 0x001F || codeUnit == 0x007F || // If the character is the first character and is in the range [0-9]
|
|
37
|
+
// (U+0030 to U+0039), […]
|
|
38
|
+
index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039 || // If the character is the second character and is in the range [0-9]
|
|
39
|
+
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
|
|
40
|
+
index == 1 && codeUnit >= 0x0030 && codeUnit <= 0x0039 && firstCodeUnit == 0x002D) {
|
|
41
|
+
// https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
|
|
42
|
+
result += '\\' + codeUnit.toString(16) + ' ';
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
// If the character is not handled by one of the above rules and is
|
|
46
|
+
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
|
|
47
|
+
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
|
|
48
|
+
// U+005A), or [a-z] (U+0061 to U+007A), […]
|
|
49
|
+
if (codeUnit >= 0x0080 || codeUnit == 0x002D || codeUnit == 0x005F || codeUnit >= 0x0030 && codeUnit <= 0x0039 || codeUnit >= 0x0041 && codeUnit <= 0x005A || codeUnit >= 0x0061 && codeUnit <= 0x007A) {
|
|
50
|
+
// the character itself
|
|
51
|
+
result += string.charAt(index);
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
// Otherwise, the escaped character.
|
|
55
|
+
// https://drafts.csswg.org/cssom/#escape-a-character
|
|
56
|
+
result += '\\' + string.charAt(index);
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
};
|
|
60
|
+
if (!root.CSS) {
|
|
61
|
+
root.CSS = {};
|
|
62
|
+
}
|
|
63
|
+
root.CSS.escape = cssEscape;
|
|
64
|
+
globalThis.CSS.escape = cssEscape;
|
|
65
|
+
}
|
|
66
|
+
})();
|
|
67
|
+
|
|
68
|
+
module.exports = undefined;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { commonjsGlobal } from '../_virtual/_commonjsHelpers.mjs';
|
|
2
|
+
|
|
3
|
+
(()=>{
|
|
4
|
+
const root = typeof commonjsGlobal !== 'undefined' ? commonjsGlobal : window;
|
|
5
|
+
if (!root.CSS && !root.CSS?.escape) {
|
|
6
|
+
// https://drafts.csswg.org/cssom/#serialize-an-identifier
|
|
7
|
+
const cssEscape = function(value) {
|
|
8
|
+
if (arguments.length == 0) {
|
|
9
|
+
throw new TypeError('`CSS.escape` requires an argument.');
|
|
10
|
+
}
|
|
11
|
+
const string = String(value);
|
|
12
|
+
const length = string.length;
|
|
13
|
+
let index = -1;
|
|
14
|
+
let result = '';
|
|
15
|
+
let codeUnit;
|
|
16
|
+
const firstCodeUnit = string.charCodeAt(0);
|
|
17
|
+
if (// If the character is the first character and is a `-` (U+002D), and
|
|
18
|
+
// there is no second character, […]
|
|
19
|
+
length == 1 && firstCodeUnit == 0x002D) {
|
|
20
|
+
return '\\' + string;
|
|
21
|
+
}
|
|
22
|
+
while(++index < length){
|
|
23
|
+
codeUnit = string.charCodeAt(index);
|
|
24
|
+
// Note: there’s no need to special-case astral symbols, surrogate
|
|
25
|
+
// pairs, or lone surrogates.
|
|
26
|
+
// If the character is NULL (U+0000), then the REPLACEMENT CHARACTER
|
|
27
|
+
// (U+FFFD).
|
|
28
|
+
if (codeUnit == 0x0000) {
|
|
29
|
+
result += '\uFFFD';
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (// If the character is in the range [\1-\1F] (U+0001 to U+001F) or is
|
|
33
|
+
// U+007F, […]
|
|
34
|
+
codeUnit >= 0x0001 && codeUnit <= 0x001F || codeUnit == 0x007F || // If the character is the first character and is in the range [0-9]
|
|
35
|
+
// (U+0030 to U+0039), […]
|
|
36
|
+
index == 0 && codeUnit >= 0x0030 && codeUnit <= 0x0039 || // If the character is the second character and is in the range [0-9]
|
|
37
|
+
// (U+0030 to U+0039) and the first character is a `-` (U+002D), […]
|
|
38
|
+
index == 1 && codeUnit >= 0x0030 && codeUnit <= 0x0039 && firstCodeUnit == 0x002D) {
|
|
39
|
+
// https://drafts.csswg.org/cssom/#escape-a-character-as-code-point
|
|
40
|
+
result += '\\' + codeUnit.toString(16) + ' ';
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
// If the character is not handled by one of the above rules and is
|
|
44
|
+
// greater than or equal to U+0080, is `-` (U+002D) or `_` (U+005F), or
|
|
45
|
+
// is in one of the ranges [0-9] (U+0030 to U+0039), [A-Z] (U+0041 to
|
|
46
|
+
// U+005A), or [a-z] (U+0061 to U+007A), […]
|
|
47
|
+
if (codeUnit >= 0x0080 || codeUnit == 0x002D || codeUnit == 0x005F || codeUnit >= 0x0030 && codeUnit <= 0x0039 || codeUnit >= 0x0041 && codeUnit <= 0x005A || codeUnit >= 0x0061 && codeUnit <= 0x007A) {
|
|
48
|
+
// the character itself
|
|
49
|
+
result += string.charAt(index);
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
// Otherwise, the escaped character.
|
|
53
|
+
// https://drafts.csswg.org/cssom/#escape-a-character
|
|
54
|
+
result += '\\' + string.charAt(index);
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
};
|
|
58
|
+
if (!root.CSS) {
|
|
59
|
+
root.CSS = {};
|
|
60
|
+
}
|
|
61
|
+
root.CSS.escape = cssEscape;
|
|
62
|
+
globalThis.CSS.escape = cssEscape;
|
|
63
|
+
}
|
|
64
|
+
})();
|