@stylexjs/shared 0.2.0-beta.20 → 0.2.0-beta.22
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/convert-to-className.js +6 -6
- package/lib/generate-css-rule.js +3 -3
- package/lib/hash.js +10 -11
- package/lib/index.d.ts +4 -4
- package/lib/index.js +12 -21
- package/lib/index.js.flow +4 -4
- package/lib/messages.d.ts +2 -1
- package/lib/messages.js +29 -54
- package/lib/messages.js.flow +2 -1
- package/lib/physical-rtl/generate-ltr.js +39 -39
- package/lib/physical-rtl/generate-rtl.js +57 -57
- package/lib/preprocess-rules/PreRule.js +2 -2
- package/lib/preprocess-rules/application-order.d.ts +36 -8
- package/lib/preprocess-rules/application-order.js +149 -164
- package/lib/preprocess-rules/application-order.js.flow +35 -7
- package/lib/preprocess-rules/basic-validation.js +6 -6
- package/lib/preprocess-rules/flatten-raw-style-obj.js +10 -10
- package/lib/preprocess-rules/index.js +6 -6
- package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +22 -2
- package/lib/preprocess-rules/legacy-expand-shorthands.js +81 -65
- package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +22 -2
- package/lib/preprocess-rules/property-specificity.d.ts +29 -25
- package/lib/preprocess-rules/property-specificity.js +63 -75
- package/lib/preprocess-rules/property-specificity.js.flow +28 -24
- package/lib/properties/CSS Animations.json +445 -0
- package/lib/properties/CSS Backgrounds and Borders.json +1085 -0
- package/lib/properties/CSS Basic User Interface.json +365 -0
- package/lib/properties/CSS Box Alignment.json +245 -0
- package/lib/properties/CSS Box Model.json +501 -0
- package/lib/properties/CSS Color.json +100 -0
- package/lib/properties/CSS Columns.json +185 -0
- package/lib/properties/CSS Containment.json +203 -0
- package/lib/properties/CSS Counter Styles.json +56 -0
- package/lib/properties/CSS Display.json +20 -0
- package/lib/properties/CSS Flexible Box Layout.json +167 -0
- package/lib/properties/CSS Fonts.json +684 -0
- package/lib/properties/CSS Fragmentation.json +110 -0
- package/lib/properties/CSS Generated Content.json +38 -0
- package/lib/properties/CSS Grid Layout.json +500 -0
- package/lib/properties/CSS Images.json +91 -0
- package/lib/properties/CSS Inline.json +38 -0
- package/lib/properties/CSS Lists and Counters.json +86 -0
- package/lib/properties/CSS Logical Properties.json +1086 -0
- package/lib/properties/CSS Masking.json +399 -0
- package/lib/properties/CSS Miscellaneous.json +38 -0
- package/lib/properties/CSS Motion Path.json +132 -0
- package/lib/properties/CSS Overflow.json +216 -0
- package/lib/properties/CSS Pages.json +83 -0
- package/lib/properties/CSS Positioning.json +166 -0
- package/lib/properties/CSS Ruby.json +55 -0
- package/lib/properties/CSS Scroll Anchoring.json +19 -0
- package/lib/properties/CSS Scroll Snap.json +604 -0
- package/lib/properties/CSS Scrollbars.json +38 -0
- package/lib/properties/CSS Shapes.json +56 -0
- package/lib/properties/CSS Speech.json +20 -0
- package/lib/properties/CSS Table.json +115 -0
- package/lib/properties/CSS Text Decoration.json +312 -0
- package/lib/properties/CSS Text.json +415 -0
- package/lib/properties/CSS Transforms.json +188 -0
- package/lib/properties/CSS Transitions.json +122 -0
- package/lib/properties/CSS Variables.json +20 -0
- package/lib/properties/CSS View Transitions.json +20 -0
- package/lib/properties/CSS Will Change.json +20 -0
- package/lib/properties/CSS Writing Modes.json +92 -0
- package/lib/properties/Compositing and Blending.json +62 -0
- package/lib/properties/Filter Effects.json +38 -0
- package/lib/properties/MathML.json +56 -0
- package/lib/properties/Microsoft Extensions.json +885 -0
- package/lib/properties/Mozilla Extensions.json +607 -0
- package/lib/properties/Pointer Events.json +20 -0
- package/lib/properties/WebKit Extensions.json +707 -0
- package/lib/properties.json +10122 -0
- package/lib/{stylex-override-vars.d.ts → stylex-create-theme.d.ts} +2 -2
- package/lib/{stylex-override-vars.js → stylex-create-theme.js} +13 -13
- package/lib/{stylex-override-vars.js.flow → stylex-create-theme.js.flow} +1 -1
- package/lib/stylex-create.js +1 -1
- package/lib/{stylex-create-vars.d.ts → stylex-define-vars.d.ts} +4 -4
- package/lib/{stylex-create-vars.js → stylex-define-vars.js} +9 -9
- package/lib/{stylex-create-vars.js.flow → stylex-define-vars.js.flow} +4 -4
- package/lib/stylex-keyframes.js +6 -6
- package/lib/transform-value.js +13 -15
- package/lib/types/index.d.ts +1 -4
- package/lib/types/index.js +33 -46
- package/lib/types/index.js.flow +2 -2
- package/lib/utils/dashify.js +1 -1
- package/lib/utils/default-options.js +4 -5
- package/lib/utils/file-based-identifier.js +1 -1
- package/lib/utils/genCSSRule.js +6 -6
- package/lib/utils/normalize-value.js +3 -2
- package/lib/utils/normalizers/convert-camel-case-transition-props.d.ts +14 -0
- package/lib/utils/normalizers/convert-camel-case-transition-props.js +23 -0
- package/lib/utils/normalizers/convert-camel-case-transition-props.js.flow +13 -0
- package/lib/utils/normalizers/convert-camel-case-values.d.ts +14 -0
- package/lib/utils/normalizers/convert-camel-case-values.js +23 -0
- package/lib/utils/normalizers/convert-camel-case-values.js.flow +13 -0
- package/lib/utils/normalizers/detect-unclosed-fns.js +2 -2
- package/lib/utils/normalizers/font-size-px-to-rem.js +4 -4
- package/lib/utils/normalizers/leading-zero.js +3 -3
- package/lib/utils/normalizers/quotes.js +4 -4
- package/lib/utils/normalizers/timings.js +4 -4
- package/lib/utils/normalizers/whitespace.js +12 -12
- package/lib/utils/normalizers/zero-dimensions.js +8 -8
- package/lib/utils/object-utils.d.ts +3 -6
- package/lib/utils/object-utils.js +2 -2
- package/lib/utils/property-priorities.js +527 -88
- package/lib/utils/split-css-value.js +8 -8
- package/lib/validate.js +2 -2
- package/package.json +2 -2
@@ -8,7 +8,7 @@
|
|
8
8
|
*/
|
9
9
|
|
10
10
|
import type { InjectableStyle, StyleXOptions } from './common-types';
|
11
|
-
declare function
|
11
|
+
declare function styleXCreateTheme(
|
12
12
|
themeVars: {
|
13
13
|
readonly __themeName__: string;
|
14
14
|
readonly [$$Key$$: string]: string;
|
@@ -23,4 +23,4 @@ declare function styleXOverrideVars(
|
|
23
23
|
{ $$css: true; readonly [$$Key$$: string]: string },
|
24
24
|
{ [$$Key$$: string]: InjectableStyle },
|
25
25
|
];
|
26
|
-
export default
|
26
|
+
export default styleXCreateTheme;
|
@@ -3,13 +3,13 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.default =
|
6
|
+
exports.default = styleXCreateTheme;
|
7
7
|
var _hash = _interopRequireDefault(require("./hash"));
|
8
8
|
var _defaultOptions = require("./utils/default-options");
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
10
|
-
function
|
11
|
-
if (typeof themeVars.__themeName__ !==
|
12
|
-
throw new Error(
|
10
|
+
function styleXCreateTheme(themeVars, variables, options) {
|
11
|
+
if (typeof themeVars.__themeName__ !== 'string') {
|
12
|
+
throw new Error('Can only override variables theme created with stylex.defineVars().');
|
13
13
|
}
|
14
14
|
const {
|
15
15
|
classNamePrefix
|
@@ -22,13 +22,13 @@ function styleXOverrideVars(themeVars, variables, options) {
|
|
22
22
|
const cssVariablesOverrideString = sortedKeys.map(key => {
|
23
23
|
const varNameHash = themeVars[key].slice(4, -1);
|
24
24
|
const value = variables[key];
|
25
|
-
if (varNameHash != null && value !== null && typeof value ===
|
25
|
+
if (varNameHash != null && value !== null && typeof value === 'object') {
|
26
26
|
if (value.default === undefined) {
|
27
|
-
throw new Error(
|
27
|
+
throw new Error('Default value is not defined for ' + key + ' variable.');
|
28
28
|
}
|
29
29
|
const definedVarString = `${varNameHash}:${value.default};`;
|
30
30
|
Object.keys(value).forEach(key => {
|
31
|
-
if (key.startsWith(
|
31
|
+
if (key.startsWith('@')) {
|
32
32
|
const definedVarStringForAtRule = `${varNameHash}:${value[key]};`;
|
33
33
|
if (atRules[key] == null) {
|
34
34
|
atRules[key] = [definedVarStringForAtRule];
|
@@ -39,16 +39,16 @@ function styleXOverrideVars(themeVars, variables, options) {
|
|
39
39
|
});
|
40
40
|
return definedVarString;
|
41
41
|
}
|
42
|
-
return varNameHash != null && typeof value !==
|
43
|
-
}).join(
|
42
|
+
return varNameHash != null && typeof value !== 'object' ? `${varNameHash}:${value};` : '';
|
43
|
+
}).join('');
|
44
44
|
const sortedAtRules = Object.keys(atRules).sort();
|
45
45
|
const atRulesStringForHash = sortedAtRules.map(atRule => {
|
46
|
-
return `${atRule}{${atRules[atRule].sort().join(
|
47
|
-
}).join(
|
46
|
+
return `${atRule}{${atRules[atRule].sort().join('')}}`;
|
47
|
+
}).join('');
|
48
48
|
const overrideClassName = classNamePrefix + (0, _hash.default)(cssVariablesOverrideString + atRulesStringForHash);
|
49
49
|
const atRulesCss = sortedAtRules.map(atRule => {
|
50
|
-
return `${atRule}{.${overrideClassName}{${atRules[atRule].join(
|
51
|
-
}).join(
|
50
|
+
return `${atRule}{.${overrideClassName}{${atRules[atRule].join('')}}}`;
|
51
|
+
}).join('');
|
52
52
|
return [{
|
53
53
|
$$css: true,
|
54
54
|
[themeVars.__themeName__]: overrideClassName
|
@@ -12,7 +12,7 @@ import type { InjectableStyle, StyleXOptions } from './common-types';
|
|
12
12
|
// It takes an object of variables with their values and the original set of variables to override
|
13
13
|
// and returns a hashed className with variables overrides.
|
14
14
|
//
|
15
|
-
declare export default function
|
15
|
+
declare export default function styleXCreateTheme(
|
16
16
|
themeVars: { +__themeName__: string, +[string]: string },
|
17
17
|
variables: { +[string]: string | { default: string, +[string]: string } },
|
18
18
|
options?: StyleXOptions,
|
package/lib/stylex-create.js
CHANGED
@@ -32,7 +32,7 @@ function styleXCreateSet(namespaces) {
|
|
32
32
|
const className = classNameTuples.map(_ref2 => {
|
33
33
|
let [className] = _ref2;
|
34
34
|
return className;
|
35
|
-
}).join(
|
35
|
+
}).join(' ') || null;
|
36
36
|
namespaceObj[key] = className;
|
37
37
|
for (const [className, injectable] of classNameTuples) {
|
38
38
|
if (injectedStyles[className] == null) {
|
@@ -12,18 +12,18 @@ type VarsObject<
|
|
12
12
|
Vars extends {
|
13
13
|
readonly [$$Key$$: string]:
|
14
14
|
| string
|
15
|
-
| { default: string; readonly [$$Key$$: string]: string };
|
15
|
+
| { readonly default: string; readonly [$$Key$$: string]: string };
|
16
16
|
},
|
17
17
|
> = Readonly</**
|
18
18
|
* > 15 | ...$ObjMapConst<Vars, string>,
|
19
19
|
* | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with complex spreads" is currently not supported.
|
20
20
|
**/
|
21
21
|
any>;
|
22
|
-
declare function
|
22
|
+
declare function styleXDefineVars<
|
23
23
|
Vars extends {
|
24
24
|
readonly [$$Key$$: string]:
|
25
25
|
| string
|
26
|
-
| { default: string; readonly [$$Key$$: string]: string };
|
26
|
+
| { readonly default: string; readonly [$$Key$$: string]: string };
|
27
27
|
},
|
28
28
|
>(
|
29
29
|
variables: Vars,
|
@@ -33,4 +33,4 @@ declare function styleXCreateVars<
|
|
33
33
|
}
|
34
34
|
>,
|
35
35
|
): [VarsObject<Vars>, { css: string }];
|
36
|
-
export default
|
36
|
+
export default styleXDefineVars;
|
@@ -3,12 +3,12 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.default =
|
6
|
+
exports.default = styleXDefineVars;
|
7
7
|
var _hash = _interopRequireDefault(require("./hash"));
|
8
8
|
var _objectUtils = require("./utils/object-utils");
|
9
9
|
var _defaultOptions = require("./utils/default-options");
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
-
function
|
11
|
+
function styleXDefineVars(variables, options) {
|
12
12
|
const {
|
13
13
|
classNamePrefix,
|
14
14
|
themeName
|
@@ -45,13 +45,13 @@ function constructCssVariablesString(variables) {
|
|
45
45
|
nameHash,
|
46
46
|
value
|
47
47
|
}] = _ref2;
|
48
|
-
if (value !== null && typeof value ===
|
48
|
+
if (value !== null && typeof value === 'object') {
|
49
49
|
if (value.default === undefined) {
|
50
|
-
throw new Error(
|
50
|
+
throw new Error('Default value is not defined for ' + key + ' variable.');
|
51
51
|
}
|
52
52
|
const definedVarString = `--${nameHash}:${value.default};`;
|
53
53
|
Object.keys(value).forEach(key => {
|
54
|
-
if (key.startsWith(
|
54
|
+
if (key.startsWith('@')) {
|
55
55
|
const definedVarStringForAtRule = `--${nameHash}:${value[key]};`;
|
56
56
|
if (atRules[key] == null) {
|
57
57
|
atRules[key] = [definedVarStringForAtRule];
|
@@ -63,10 +63,10 @@ function constructCssVariablesString(variables) {
|
|
63
63
|
return definedVarString;
|
64
64
|
}
|
65
65
|
return `--${nameHash}:${value};`;
|
66
|
-
}).join(
|
66
|
+
}).join('');
|
67
67
|
const atRulesString = (0, _objectUtils.objEntries)(atRules).map(_ref3 => {
|
68
68
|
let [atRule, varsArr] = _ref3;
|
69
|
-
return `${atRule}{:root{${varsArr.join(
|
70
|
-
}).join(
|
71
|
-
return `:root{${varsString}}${atRulesString ||
|
69
|
+
return `${atRule}{:root{${varsArr.join('')}}}`;
|
70
|
+
}).join('');
|
71
|
+
return `:root{${varsString}}${atRulesString || ''}`;
|
72
72
|
}
|
@@ -10,7 +10,7 @@
|
|
10
10
|
import type { StyleXOptions } from './common-types';
|
11
11
|
|
12
12
|
type VarsObject<
|
13
|
-
Vars: { +[string]: string | { default: string, +[string]: string } },
|
13
|
+
Vars: { +[string]: string | { +default: string, +[string]: string } },
|
14
14
|
> = $ReadOnly<{
|
15
15
|
...$ObjMapConst<Vars, string>,
|
16
16
|
__themeName__: string,
|
@@ -18,9 +18,9 @@ type VarsObject<
|
|
18
18
|
|
19
19
|
// Similar to `stylex.create` it takes an object of variables with their values
|
20
20
|
// and returns a string after hashing it.
|
21
|
-
declare export default function
|
22
|
-
|
23
|
-
+[string]: string | { default: string, +[string]: string },
|
21
|
+
declare export default function styleXDefineVars<
|
22
|
+
Vars: {
|
23
|
+
+[string]: string | { +default: string, +[string]: string },
|
24
24
|
},
|
25
25
|
>(
|
26
26
|
variables: Vars,
|
package/lib/stylex-keyframes.js
CHANGED
@@ -16,15 +16,15 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
16
16
|
function styleXKeyframes(frames) {
|
17
17
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _defaultOptions.defaultOptions;
|
18
18
|
const {
|
19
|
-
stylexSheetName =
|
20
|
-
classNamePrefix =
|
19
|
+
stylexSheetName = '<>',
|
20
|
+
classNamePrefix = 'x'
|
21
21
|
} = options;
|
22
22
|
const expandedObject = (0, _objectUtils.objMap)(frames, frame => _objectUtils.Pipe.create(frame).pipe(frame => expandFrameShorthands(frame, options)).pipe(x => (0, _objectUtils.objMapKeys)(x, _dashify.default)).pipe(x => (0, _objectUtils.objMap)(x, (value, key) => (0, _transformValue.default)(key, value))).done());
|
23
23
|
const ltrStyles = (0, _objectUtils.objMap)(expandedObject, frame => (0, _objectUtils.objMapEntry)(frame, _generateLtr.default));
|
24
24
|
const rtlStyles = (0, _objectUtils.objMap)(expandedObject, frame => (0, _objectUtils.objMapEntry)(frame, entry => (0, _generateRtl.default)(entry) ?? entry));
|
25
25
|
const ltrString = constructKeyframesObj(ltrStyles);
|
26
26
|
const rtlString = constructKeyframesObj(rtlStyles);
|
27
|
-
const animationName = classNamePrefix + (0, _hash.default)(stylexSheetName + ltrString) +
|
27
|
+
const animationName = classNamePrefix + (0, _hash.default)(stylexSheetName + ltrString) + '-B';
|
28
28
|
const ltr = `@keyframes ${animationName}{${ltrString}}`;
|
29
29
|
const rtl = ltrString === rtlString ? null : `@keyframes ${animationName}{${rtlString}}`;
|
30
30
|
return [animationName, {
|
@@ -36,7 +36,7 @@ function styleXKeyframes(frames) {
|
|
36
36
|
function expandFrameShorthands(frame, options) {
|
37
37
|
return (0, _objectUtils.objFromEntries)((0, _objectUtils.objEntries)(frame).flatMap(pair => (0, _index.default)(pair, options).map(_ref => {
|
38
38
|
let [key, value] = _ref;
|
39
|
-
if (typeof value ===
|
39
|
+
if (typeof value === 'string' || typeof value === 'number') {
|
40
40
|
return [key, value];
|
41
41
|
}
|
42
42
|
return null;
|
@@ -51,6 +51,6 @@ function constructKeyframesObj(frames) {
|
|
51
51
|
return `${key}{${(0, _objectUtils.objEntries)(value).map(_ref4 => {
|
52
52
|
let [k, v] = _ref4;
|
53
53
|
return `${k}:${v};`;
|
54
|
-
}).join(
|
55
|
-
}).join(
|
54
|
+
}).join('')}}`;
|
55
|
+
}).join('');
|
56
56
|
}
|
package/lib/transform-value.js
CHANGED
@@ -9,13 +9,13 @@ exports.timeUnits = exports.lengthUnits = void 0;
|
|
9
9
|
var _normalizeValue = _interopRequireDefault(require("./utils/normalize-value"));
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
11
|
function transformValue(key, rawValue) {
|
12
|
-
const value = typeof rawValue ===
|
13
|
-
if (key ===
|
12
|
+
const value = typeof rawValue === 'number' ? String(Math.round(rawValue * 10000) / 10000) + getNumberSuffix(key) : rawValue;
|
13
|
+
if (key === 'content' && typeof value === 'string') {
|
14
14
|
const val = value.trim();
|
15
15
|
if (val.match(/^attr\([a-zA-Z0-9-]+\)$/)) {
|
16
16
|
return val;
|
17
17
|
}
|
18
|
-
if (!(val.startsWith("
|
18
|
+
if (!(val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'"))) {
|
19
19
|
return `"${val}"`;
|
20
20
|
}
|
21
21
|
}
|
@@ -23,24 +23,22 @@ function transformValue(key, rawValue) {
|
|
23
23
|
}
|
24
24
|
function getNumberSuffix(key) {
|
25
25
|
if (unitlessNumberProperties.has(key)) {
|
26
|
-
return
|
26
|
+
return '';
|
27
27
|
}
|
28
28
|
const suffix = numberPropertySuffixes[key];
|
29
29
|
if (suffix == null) {
|
30
|
-
return
|
30
|
+
return 'px';
|
31
31
|
} else {
|
32
32
|
return suffix;
|
33
33
|
}
|
34
34
|
}
|
35
|
-
const unitlessNumberProperties = new Set([
|
35
|
+
const unitlessNumberProperties = new Set(['animationIterationCount', 'aspectRatio', 'borderImageOutset', 'borderImageSlice', 'borderImageWidth', 'columnCount', 'flex', 'flexGrow', 'flexPositive', 'flexShrink', 'flexOrder', 'gridRow', 'gridColumn', 'fontWeight', 'lineClamp', 'lineHeight', 'opacity', 'order', 'orphans', 'tabSize', 'widows', 'zIndex', 'fillOpacity', 'floodOpacity', 'stopOpacity', 'strokeDasharray', 'strokeDashoffset', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth', 'scale']);
|
36
36
|
const numberPropertySuffixes = {
|
37
|
-
animationDelay:
|
38
|
-
animationDuration:
|
39
|
-
transitionDelay:
|
40
|
-
transitionDuration:
|
41
|
-
voiceDuration:
|
37
|
+
animationDelay: 'ms',
|
38
|
+
animationDuration: 'ms',
|
39
|
+
transitionDelay: 'ms',
|
40
|
+
transitionDuration: 'ms',
|
41
|
+
voiceDuration: 'ms'
|
42
42
|
};
|
43
|
-
const timeUnits = new Set(Object.keys(numberPropertySuffixes));
|
44
|
-
exports.
|
45
|
-
const lengthUnits = new Set(["backgroundPositionX", "backgroundPositionY", "blockSize", "borderBlockEndWidth", "borderBlockStartWidth", "borderBlockWidth", "borderVerticalWidth", "borderVerticalWidth", "borderBottomLeftRadius", "borderBottomRightRadius", "borderBottomWidth", "borderEndEndRadius", "borderEndStartRadius", "borderImageWidth", "borderInlineEndWidth", "borderEndWidth", "borderInlineStartWidth", "borderStartWidth", "borderInlineWidth", "borderHorizontalWidth", "borderLeftWidth", "borderRightWidth", "borderSpacing", "borderStartEndRadius", "borderStartStartRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderTopWidth", "bottom", "columnGap", "columnRuleWidth", "columnWidth", "containIntrinsicBlockSize", "containIntrinsicHeight", "containIntrinsicInlineSize", "containIntrinsicWidth", "flexBasis", "fontSize", "fontSmooth", "height", "inlineSize", "insetBlockEnd", "insetBlockStart", "insetInlineEnd", "insetInlineStart", "left", "letterSpacing", "marginBlockEnd", "marginBlockStart", "marginBottom", "marginInlineEnd", "marginEnd", "marginInlineStart", "marginStart", "marginLeft", "marginRight", "marginTop", "maskBorderOutset", "maskBorderWidth", "maxBlockSize", "maxHeight", "maxInlineSize", "maxWidth", "minBlockSize", "minHeight", "minInlineSize", "minWidth", "offsetDistance", "outlineOffset", "outlineWidth", "overflowClipMargin", "paddingBlockEnd", "paddingBlockStart", "paddingBottom", "paddingInlineEnd", "paddingEnd", "paddingInlineStart", "paddingStart", "paddingLeft", "paddingRight", "paddingTop", "perspective", "right", "rowGap", "scrollMarginBlockEnd", "scrollMarginBlockStart", "scrollMarginBottom", "scrollMarginInlineEnd", "scrollMarginInlineStart", "scrollMarginLeft", "scrollMarginRight", "scrollMarginTop", "scrollPaddingBlockEnd", "scrollPaddingBlockStart", "scrollPaddingBottom", "scrollPaddingInlineEnd", "scrollPaddingInlineStart", "scrollPaddingLeft", "scrollPaddingRight", "scrollPaddingTop", "scrollSnapMarginBottom", "scrollSnapMarginLeft", "scrollSnapMarginRight", "scrollSnapMarginTop", "shapeMargin", "tabSize", "textDecorationThickness", "textIndent", "textUnderlineOffset", "top", "transformOrigin", "translate", "verticalAlign", "width", "wordSpacing", "border", "borderBlock", "borderBlockEnd", "borderBlockStart", "borderBottom", "borderLeft", "borderRadius", "borderRight", "borderTop", "borderWidth", "columnRule", "containIntrinsicSize", "gap", "inset", "insetBlock", "insetInline", "margin", "marginBlock", "marginVertical", "marginInline", "marginHorizontal", "offset", "outline", "padding", "paddingBlock", "paddingVertical", "paddingInline", "paddingHorizontal", "scrollMargin", "scrollMarginBlock", "scrollMarginInline", "scrollPadding", "scrollPaddingBlock", "scrollPaddingInline", "scrollSnapMargin"]);
|
46
|
-
exports.lengthUnits = lengthUnits;
|
43
|
+
const timeUnits = exports.timeUnits = new Set(Object.keys(numberPropertySuffixes));
|
44
|
+
const lengthUnits = exports.lengthUnits = new Set(['backgroundPositionX', 'backgroundPositionY', 'blockSize', 'borderBlockEndWidth', 'borderBlockStartWidth', 'borderBlockWidth', 'borderVerticalWidth', 'borderVerticalWidth', 'borderBottomLeftRadius', 'borderBottomRightRadius', 'borderBottomWidth', 'borderEndEndRadius', 'borderEndStartRadius', 'borderImageWidth', 'borderInlineEndWidth', 'borderEndWidth', 'borderInlineStartWidth', 'borderStartWidth', 'borderInlineWidth', 'borderHorizontalWidth', 'borderLeftWidth', 'borderRightWidth', 'borderSpacing', 'borderStartEndRadius', 'borderStartStartRadius', 'borderTopLeftRadius', 'borderTopRightRadius', 'borderTopWidth', 'bottom', 'columnGap', 'columnRuleWidth', 'columnWidth', 'containIntrinsicBlockSize', 'containIntrinsicHeight', 'containIntrinsicInlineSize', 'containIntrinsicWidth', 'flexBasis', 'fontSize', 'fontSmooth', 'height', 'inlineSize', 'insetBlockEnd', 'insetBlockStart', 'insetInlineEnd', 'insetInlineStart', 'left', 'letterSpacing', 'marginBlockEnd', 'marginBlockStart', 'marginBottom', 'marginInlineEnd', 'marginEnd', 'marginInlineStart', 'marginStart', 'marginLeft', 'marginRight', 'marginTop', 'maskBorderOutset', 'maskBorderWidth', 'maxBlockSize', 'maxHeight', 'maxInlineSize', 'maxWidth', 'minBlockSize', 'minHeight', 'minInlineSize', 'minWidth', 'offsetDistance', 'outlineOffset', 'outlineWidth', 'overflowClipMargin', 'paddingBlockEnd', 'paddingBlockStart', 'paddingBottom', 'paddingInlineEnd', 'paddingEnd', 'paddingInlineStart', 'paddingStart', 'paddingLeft', 'paddingRight', 'paddingTop', 'perspective', 'right', 'rowGap', 'scrollMarginBlockEnd', 'scrollMarginBlockStart', 'scrollMarginBottom', 'scrollMarginInlineEnd', 'scrollMarginInlineStart', 'scrollMarginLeft', 'scrollMarginRight', 'scrollMarginTop', 'scrollPaddingBlockEnd', 'scrollPaddingBlockStart', 'scrollPaddingBottom', 'scrollPaddingInlineEnd', 'scrollPaddingInlineStart', 'scrollPaddingLeft', 'scrollPaddingRight', 'scrollPaddingTop', 'scrollSnapMarginBottom', 'scrollSnapMarginLeft', 'scrollSnapMarginRight', 'scrollSnapMarginTop', 'shapeMargin', 'tabSize', 'textDecorationThickness', 'textIndent', 'textUnderlineOffset', 'top', 'transformOrigin', 'translate', 'verticalAlign', 'width', 'wordSpacing', 'border', 'borderBlock', 'borderBlockEnd', 'borderBlockStart', 'borderBottom', 'borderLeft', 'borderRadius', 'borderRight', 'borderTop', 'borderWidth', 'columnRule', 'containIntrinsicSize', 'gap', 'inset', 'insetBlock', 'insetInline', 'margin', 'marginBlock', 'marginVertical', 'marginInline', 'marginHorizontal', 'offset', 'outline', 'padding', 'paddingBlock', 'paddingVertical', 'paddingInline', 'paddingHorizontal', 'scrollMargin', 'scrollMarginBlock', 'scrollMarginInline', 'scrollPadding', 'scrollPaddingBlock', 'scrollPaddingInline', 'scrollSnapMargin']);
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
@@ -7,8 +7,8 @@ exports.url = exports.transformList = exports.transformFunction = exports.time =
|
|
7
7
|
class CSSType {}
|
8
8
|
exports.CSSType = CSSType;
|
9
9
|
class Angle extends CSSType {
|
10
|
-
syntax =
|
11
|
-
static syntax =
|
10
|
+
syntax = '<angle>';
|
11
|
+
static syntax = '<angle>';
|
12
12
|
constructor(value) {
|
13
13
|
super();
|
14
14
|
this.value = value;
|
@@ -18,10 +18,9 @@ class Angle extends CSSType {
|
|
18
18
|
}
|
19
19
|
}
|
20
20
|
exports.Angle = Angle;
|
21
|
-
const angle = Angle.create;
|
22
|
-
exports.angle = angle;
|
21
|
+
const angle = exports.angle = Angle.create;
|
23
22
|
class Color extends CSSType {
|
24
|
-
syntax =
|
23
|
+
syntax = '<color>';
|
25
24
|
constructor(value) {
|
26
25
|
super();
|
27
26
|
this.value = value;
|
@@ -31,10 +30,9 @@ class Color extends CSSType {
|
|
31
30
|
}
|
32
31
|
}
|
33
32
|
exports.Color = Color;
|
34
|
-
const color = Color.create;
|
35
|
-
exports.color = color;
|
33
|
+
const color = exports.color = Color.create;
|
36
34
|
class Url extends CSSType {
|
37
|
-
syntax =
|
35
|
+
syntax = '<url>';
|
38
36
|
constructor(value) {
|
39
37
|
super();
|
40
38
|
this.value = value;
|
@@ -44,10 +42,9 @@ class Url extends CSSType {
|
|
44
42
|
}
|
45
43
|
}
|
46
44
|
exports.Url = Url;
|
47
|
-
const url = Url.create;
|
48
|
-
exports.url = url;
|
45
|
+
const url = exports.url = Url.create;
|
49
46
|
class Image extends Url {
|
50
|
-
syntax =
|
47
|
+
syntax = '<image>';
|
51
48
|
constructor(value) {
|
52
49
|
super(value);
|
53
50
|
this.value = value;
|
@@ -57,10 +54,9 @@ class Image extends Url {
|
|
57
54
|
}
|
58
55
|
}
|
59
56
|
exports.Image = Image;
|
60
|
-
const image = Image.create;
|
61
|
-
exports.image = image;
|
57
|
+
const image = exports.image = Image.create;
|
62
58
|
class Integer extends CSSType {
|
63
|
-
syntax =
|
59
|
+
syntax = '<integer>';
|
64
60
|
constructor(value) {
|
65
61
|
super();
|
66
62
|
this.value = value;
|
@@ -70,10 +66,9 @@ class Integer extends CSSType {
|
|
70
66
|
}
|
71
67
|
}
|
72
68
|
exports.Integer = Integer;
|
73
|
-
const integer = Integer.create;
|
74
|
-
exports.integer = integer;
|
69
|
+
const integer = exports.integer = Integer.create;
|
75
70
|
class LengthPercentage extends CSSType {
|
76
|
-
syntax =
|
71
|
+
syntax = '<length-percentage>';
|
77
72
|
constructor(value) {
|
78
73
|
super();
|
79
74
|
this.value = value;
|
@@ -86,10 +81,9 @@ class LengthPercentage extends CSSType {
|
|
86
81
|
}
|
87
82
|
}
|
88
83
|
exports.LengthPercentage = LengthPercentage;
|
89
|
-
const lengthPercentage = LengthPercentage.createLength;
|
90
|
-
exports.lengthPercentage = lengthPercentage;
|
84
|
+
const lengthPercentage = exports.lengthPercentage = LengthPercentage.createLength;
|
91
85
|
class Length extends LengthPercentage {
|
92
|
-
syntax =
|
86
|
+
syntax = '<length>';
|
93
87
|
constructor(value) {
|
94
88
|
super(convertNumberToLength(value));
|
95
89
|
}
|
@@ -98,10 +92,9 @@ class Length extends LengthPercentage {
|
|
98
92
|
}
|
99
93
|
}
|
100
94
|
exports.Length = Length;
|
101
|
-
const length = Length.create;
|
102
|
-
exports.length = length;
|
95
|
+
const length = exports.length = Length.create;
|
103
96
|
class Percentage extends LengthPercentage {
|
104
|
-
syntax =
|
97
|
+
syntax = '<percentage>';
|
105
98
|
constructor(value) {
|
106
99
|
super(convertNumberToPercentage(value));
|
107
100
|
}
|
@@ -110,10 +103,9 @@ class Percentage extends LengthPercentage {
|
|
110
103
|
}
|
111
104
|
}
|
112
105
|
exports.Percentage = Percentage;
|
113
|
-
const percentage = Percentage.create;
|
114
|
-
exports.percentage = percentage;
|
106
|
+
const percentage = exports.percentage = Percentage.create;
|
115
107
|
class Num extends CSSType {
|
116
|
-
syntax =
|
108
|
+
syntax = '<number>';
|
117
109
|
constructor(value) {
|
118
110
|
super();
|
119
111
|
this.value = value;
|
@@ -123,10 +115,9 @@ class Num extends CSSType {
|
|
123
115
|
}
|
124
116
|
}
|
125
117
|
exports.Num = Num;
|
126
|
-
const number = Num.create;
|
127
|
-
exports.number = number;
|
118
|
+
const number = exports.number = Num.create;
|
128
119
|
class Resolution extends CSSType {
|
129
|
-
syntax =
|
120
|
+
syntax = '<resolution>';
|
130
121
|
constructor(value) {
|
131
122
|
super();
|
132
123
|
this.value = value;
|
@@ -136,10 +127,9 @@ class Resolution extends CSSType {
|
|
136
127
|
}
|
137
128
|
}
|
138
129
|
exports.Resolution = Resolution;
|
139
|
-
const resolution = Resolution.create;
|
140
|
-
exports.resolution = resolution;
|
130
|
+
const resolution = exports.resolution = Resolution.create;
|
141
131
|
class Time extends CSSType {
|
142
|
-
syntax =
|
132
|
+
syntax = '<time>';
|
143
133
|
constructor(value) {
|
144
134
|
super();
|
145
135
|
this.value = value;
|
@@ -149,10 +139,9 @@ class Time extends CSSType {
|
|
149
139
|
}
|
150
140
|
}
|
151
141
|
exports.Time = Time;
|
152
|
-
const time = Time.create;
|
153
|
-
exports.time = time;
|
142
|
+
const time = exports.time = Time.create;
|
154
143
|
class TransformFunction extends CSSType {
|
155
|
-
syntax =
|
144
|
+
syntax = '<transform-function>';
|
156
145
|
constructor(value) {
|
157
146
|
super();
|
158
147
|
this.value = value;
|
@@ -162,10 +151,9 @@ class TransformFunction extends CSSType {
|
|
162
151
|
}
|
163
152
|
}
|
164
153
|
exports.TransformFunction = TransformFunction;
|
165
|
-
const transformFunction = TransformFunction.create;
|
166
|
-
exports.transformFunction = transformFunction;
|
154
|
+
const transformFunction = exports.transformFunction = TransformFunction.create;
|
167
155
|
class TransformList extends CSSType {
|
168
|
-
syntax =
|
156
|
+
syntax = '<transform-list>';
|
169
157
|
constructor(value) {
|
170
158
|
super();
|
171
159
|
this.value = value;
|
@@ -175,23 +163,22 @@ class TransformList extends CSSType {
|
|
175
163
|
}
|
176
164
|
}
|
177
165
|
exports.TransformList = TransformList;
|
178
|
-
const transformList = TransformList.create;
|
179
|
-
exports.transformList = transformList;
|
166
|
+
const transformList = exports.transformList = TransformList.create;
|
180
167
|
const convertNumberToStringUsing = (transformNumber, defaultStr) => value => {
|
181
|
-
if (typeof value ===
|
168
|
+
if (typeof value === 'number') {
|
182
169
|
return transformNumber(value);
|
183
170
|
}
|
184
|
-
if (typeof value ===
|
171
|
+
if (typeof value === 'string') {
|
185
172
|
return value;
|
186
173
|
}
|
187
|
-
if (typeof value ===
|
174
|
+
if (typeof value === 'object') {
|
188
175
|
const {
|
189
176
|
default: defaultValue,
|
190
177
|
...rest
|
191
178
|
} = value;
|
192
179
|
const defaultResult = convertNumberToLength(defaultValue);
|
193
180
|
const result = {
|
194
|
-
default: typeof defaultResult ===
|
181
|
+
default: typeof defaultResult === 'string' ? defaultResult : defaultStr
|
195
182
|
};
|
196
183
|
for (const [key, value] of Object.entries(rest)) {
|
197
184
|
result[key] = convertNumberToLength(value);
|
@@ -200,5 +187,5 @@ const convertNumberToStringUsing = (transformNumber, defaultStr) => value => {
|
|
200
187
|
}
|
201
188
|
return value;
|
202
189
|
};
|
203
|
-
const convertNumberToLength = convertNumberToStringUsing(value => value === 0 ?
|
204
|
-
const convertNumberToPercentage = convertNumberToStringUsing(value => value === 0 ?
|
190
|
+
const convertNumberToLength = convertNumberToStringUsing(value => value === 0 ? '0' : `${value}px`, '0px');
|
191
|
+
const convertNumberToPercentage = convertNumberToStringUsing(value => value === 0 ? '0' : `${value * 100}%`, '0');
|
package/lib/types/index.js.flow
CHANGED
package/lib/utils/dashify.js
CHANGED
@@ -4,10 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.defaultOptions = void 0;
|
7
|
-
const defaultOptions = {
|
7
|
+
const defaultOptions = exports.defaultOptions = {
|
8
8
|
dev: false,
|
9
9
|
test: false,
|
10
|
-
classNamePrefix:
|
11
|
-
styleResolution:
|
12
|
-
};
|
13
|
-
exports.defaultOptions = defaultOptions;
|
10
|
+
classNamePrefix: 'x',
|
11
|
+
styleResolution: 'application-order'
|
12
|
+
};
|
package/lib/utils/genCSSRule.js
CHANGED
@@ -1,15 +1,15 @@
|
|
1
|
-
|
1
|
+
'use strict';
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.genCSSRule = genCSSRule;
|
7
|
-
const THUMB_VARIANTS = [
|
7
|
+
const THUMB_VARIANTS = ['::-webkit-slider-thumb', '::-moz-range-thumb', '::-ms-thumb'];
|
8
8
|
function genCSSRule(className, decls, pseudos, atRules) {
|
9
|
-
const pseudo = pseudos.filter(p => p !==
|
10
|
-
let selectorForAtRules = `.${className}` + atRules.map(() => `.${className}`).join(
|
11
|
-
if (pseudos.includes(
|
12
|
-
selectorForAtRules = THUMB_VARIANTS.map(suffix => selectorForAtRules + suffix).join(
|
9
|
+
const pseudo = pseudos.filter(p => p !== '::thumb').join('');
|
10
|
+
let selectorForAtRules = `.${className}` + atRules.map(() => `.${className}`).join('') + pseudo;
|
11
|
+
if (pseudos.includes('::thumb')) {
|
12
|
+
selectorForAtRules = THUMB_VARIANTS.map(suffix => selectorForAtRules + suffix).join(', ');
|
13
13
|
}
|
14
14
|
return atRules.reduce((acc, atRule) => `${atRule}{${acc}}`, `${selectorForAtRules}{${decls}}`);
|
15
15
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
'use strict';
|
2
2
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
@@ -12,8 +12,9 @@ var _whitespace = _interopRequireDefault(require("./normalizers/whitespace"));
|
|
12
12
|
var _zeroDimensions = _interopRequireDefault(require("./normalizers/zero-dimensions"));
|
13
13
|
var _detectUnclosedFns = _interopRequireDefault(require("./normalizers/detect-unclosed-fns"));
|
14
14
|
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
15
|
+
var _convertCamelCaseValues = _interopRequireDefault(require("./normalizers/convert-camel-case-values"));
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
16
|
-
const normalizers = [_detectUnclosedFns.default, _whitespace.default, _timings.default, _zeroDimensions.default, _leadingZero.default, _quotes.default, _fontSizePxToRem.default];
|
17
|
+
const normalizers = [_detectUnclosedFns.default, _whitespace.default, _timings.default, _zeroDimensions.default, _leadingZero.default, _quotes.default, _fontSizePxToRem.default, _convertCamelCaseValues.default];
|
17
18
|
function normalizeValue(value, key) {
|
18
19
|
if (value == null) {
|
19
20
|
return value;
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/**
|
2
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
3
|
+
*
|
4
|
+
* This source code is licensed under the MIT license found in the
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
6
|
+
*
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
declare function convertCamelCasedTransitionProps(
|
11
|
+
ast: PostCSSValueAST,
|
12
|
+
key: string,
|
13
|
+
): PostCSSValueAST;
|
14
|
+
export default convertCamelCasedTransitionProps;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = convertCamelCasedTransitionProps;
|
7
|
+
var _dashify = _interopRequireDefault(require("../dashify"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
function convertCamelCasedTransitionProps(ast, key) {
|
10
|
+
if (key !== 'transitionProperty') {
|
11
|
+
return ast;
|
12
|
+
}
|
13
|
+
const nodes = ast.nodes;
|
14
|
+
if (!nodes) {
|
15
|
+
return ast;
|
16
|
+
}
|
17
|
+
nodes.forEach(node => {
|
18
|
+
if (node.type === 'word' && !node.value.startsWith('--')) {
|
19
|
+
node.value = (0, _dashify.default)(node.value);
|
20
|
+
}
|
21
|
+
});
|
22
|
+
return ast;
|
23
|
+
}
|