@stylexjs/shared 0.7.5 → 0.9.0-beta.1
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/lib/common-types.d.ts +1 -0
- package/lib/common-types.js.flow +1 -0
- package/lib/convert-to-className.d.ts +1 -1
- package/lib/convert-to-className.js +13 -11
- package/lib/convert-to-className.js.flow +1 -1
- package/lib/generate-css-rule.js +1 -1
- package/lib/index.js +2 -2
- package/lib/physical-rtl/generate-ltr.d.ts +3 -1
- package/lib/physical-rtl/generate-ltr.js +8 -12
- package/lib/physical-rtl/generate-ltr.js.flow +2 -2
- package/lib/physical-rtl/generate-rtl.d.ts +2 -2
- package/lib/physical-rtl/generate-rtl.js +57 -64
- package/lib/physical-rtl/generate-rtl.js.flow +2 -2
- package/lib/preprocess-rules/PreRule.d.ts +13 -6
- package/lib/preprocess-rules/PreRule.js +14 -13
- package/lib/preprocess-rules/PreRule.js.flow +14 -6
- package/lib/preprocess-rules/application-order.d.ts +4 -111
- package/lib/preprocess-rules/application-order.js.flow +3 -110
- package/lib/preprocess-rules/basic-validation.js +1 -1
- package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +1 -2
- package/lib/preprocess-rules/flatten-raw-style-obj.js +7 -21
- package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +1 -2
- package/lib/preprocess-rules/index.d.ts +1 -1
- package/lib/preprocess-rules/index.js +1 -1
- package/lib/preprocess-rules/index.js.flow +4 -1
- package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +3 -38
- package/lib/preprocess-rules/legacy-expand-shorthands.js +12 -1
- package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +3 -38
- package/lib/preprocess-rules/property-specificity.d.ts +4 -15
- package/lib/preprocess-rules/property-specificity.js.flow +3 -14
- package/lib/stylex-create-theme.js +2 -2
- package/lib/stylex-create.d.ts +4 -0
- package/lib/stylex-create.js +20 -8
- package/lib/stylex-create.js.flow +9 -1
- package/lib/stylex-define-vars.d.ts +8 -5
- package/lib/stylex-define-vars.js +2 -2
- package/lib/stylex-define-vars.js.flow +5 -1
- package/lib/stylex-include.js +1 -1
- package/lib/stylex-keyframes.js +1 -1
- package/lib/transform-value.js +7 -4
- package/lib/types/index.js.flow +1 -1
- package/lib/utils/default-options.js +1 -0
- package/lib/utils/normalize-value.js +1 -1
- package/lib/utils/normalizers/convert-camel-case-values.js +1 -1
- package/lib/utils/normalizers/detect-unclosed-fns.js +1 -1
- package/lib/utils/normalizers/font-size-px-to-rem.js +1 -1
- package/lib/utils/normalizers/leading-zero.js +1 -1
- package/lib/utils/normalizers/timings.js +1 -1
- package/lib/utils/normalizers/zero-dimensions.js +1 -1
- package/lib/utils/object-utils.d.ts +3 -2
- package/lib/utils/object-utils.js.flow +5 -2
- package/lib/utils/property-priorities.d.ts +3 -56
- package/lib/utils/property-priorities.js.flow +56 -56
- package/lib/utils/rule-utils.d.ts +15 -0
- package/lib/utils/rule-utils.js +41 -0
- package/lib/utils/rule-utils.js.flow +16 -0
- package/lib/utils/split-css-value.js +1 -1
- package/package.json +2 -2
package/lib/transform-value.js
CHANGED
@@ -7,7 +7,7 @@ exports.default = transformValue;
|
|
7
7
|
exports.getNumberSuffix = getNumberSuffix;
|
8
8
|
exports.timeUnits = exports.lengthUnits = void 0;
|
9
9
|
var _normalizeValue = _interopRequireDefault(require("./utils/normalize-value"));
|
10
|
-
function _interopRequireDefault(
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
11
11
|
function transformValue(key, rawValue, options) {
|
12
12
|
const value = typeof rawValue === 'number' ? String(Math.round(rawValue * 10000) / 10000) + getNumberSuffix(key) : rawValue;
|
13
13
|
if ((key === 'content' || key === 'hyphenateCharacter' || key === 'hyphenate-character') && typeof value === 'string') {
|
@@ -22,9 +22,12 @@ function transformValue(key, rawValue, options) {
|
|
22
22
|
return (0, _normalizeValue.default)(value, key, options);
|
23
23
|
}
|
24
24
|
function getNumberSuffix(key) {
|
25
|
-
if (unitlessNumberProperties.has(key)) {
|
25
|
+
if (unitlessNumberProperties.has(key) || key.startsWith('--')) {
|
26
26
|
return '';
|
27
27
|
}
|
28
|
+
if (!(key in numberPropertySuffixes)) {
|
29
|
+
return 'px';
|
30
|
+
}
|
28
31
|
const suffix = numberPropertySuffixes[key];
|
29
32
|
if (suffix == null) {
|
30
33
|
return 'px';
|
@@ -32,7 +35,7 @@ function getNumberSuffix(key) {
|
|
32
35
|
return suffix;
|
33
36
|
}
|
34
37
|
}
|
35
|
-
const unitlessNumberProperties = new Set(['WebkitLineClamp', 'animationIterationCount', 'aspectRatio', 'borderImageOutset', 'borderImageSlice', 'borderImageWidth', 'counterSet', '
|
38
|
+
const unitlessNumberProperties = new Set(['WebkitLineClamp', 'animationIterationCount', 'aspectRatio', 'borderImageOutset', 'borderImageSlice', 'borderImageWidth', 'counterSet', 'counterReset', 'columnCount', 'flex', 'flexGrow', 'flexShrink', 'flexOrder', 'gridRow', 'gridRowStart', 'gridRowEnd', 'gridColumn', 'gridColumnStart', 'gridColumnEnd', 'gridArea', 'fontWeight', 'hyphenateLimitChars', 'lineClamp', 'lineHeight', 'maskBorderOutset', 'maskBorderSlice', 'maskBorderWidth', 'opacity', 'order', 'orphans', 'tabSize', 'widows', 'zIndex', 'fillOpacity', 'floodOpacity', 'rotate', 'scale', 'shapeImageThreshold', 'stopOpacity', 'strokeDasharray', 'strokeDashoffset', 'strokeMiterlimit', 'strokeOpacity', 'strokeWidth', 'scale', 'mathDepth']);
|
36
39
|
const numberPropertySuffixes = {
|
37
40
|
animationDelay: 'ms',
|
38
41
|
animationDuration: 'ms',
|
@@ -41,4 +44,4 @@ const numberPropertySuffixes = {
|
|
41
44
|
voiceDuration: 'ms'
|
42
45
|
};
|
43
46
|
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', '
|
47
|
+
const lengthUnits = exports.lengthUnits = new Set(['backgroundPositionX', 'backgroundPositionY', 'blockSize', 'borderBlockEndWidth', 'borderBlockStartWidth', 'borderBlockWidth', 'borderVerticalWidth', 'borderVerticalWidth', 'borderBottomLeftRadius', 'borderBottomRightRadius', 'borderBottomWidth', 'borderEndEndRadius', 'borderEndStartRadius', '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', '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.js.flow
CHANGED
@@ -65,7 +65,7 @@ export interface CSSType<+_T: string | number = string | number> {
|
|
65
65
|
|
66
66
|
declare export const isCSSType: (
|
67
67
|
value: mixed,
|
68
|
-
) => value is CSSType<string | number>;
|
68
|
+
) => implies value is CSSType<string | number>;
|
69
69
|
|
70
70
|
type AngleValue = string;
|
71
71
|
declare export class Angle<+T: AngleValue>
|
@@ -13,7 +13,7 @@ var _zeroDimensions = _interopRequireDefault(require("./normalizers/zero-dimensi
|
|
13
13
|
var _detectUnclosedFns = _interopRequireDefault(require("./normalizers/detect-unclosed-fns"));
|
14
14
|
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
15
15
|
var _convertCamelCaseValues = _interopRequireDefault(require("./normalizers/convert-camel-case-values"));
|
16
|
-
function _interopRequireDefault(
|
16
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
17
17
|
const normalizers = [_detectUnclosedFns.default, _whitespace.default, _timings.default, _zeroDimensions.default, _leadingZero.default, _quotes.default, _convertCamelCaseValues.default];
|
18
18
|
function normalizeValue(value, key, _ref) {
|
19
19
|
let {
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = convertCamelCasedValues;
|
7
7
|
var _dashify = _interopRequireDefault(require("../dashify"));
|
8
|
-
function _interopRequireDefault(
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
9
9
|
function convertCamelCasedValues(ast, key) {
|
10
10
|
if (key !== 'transitionProperty' && key !== 'willChange') {
|
11
11
|
return ast;
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
exports.default = detectUnclosedFns;
|
7
7
|
var messages = _interopRequireWildcard(require("../../messages"));
|
8
8
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
9
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u &&
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
10
10
|
function detectUnclosedFns(ast, _) {
|
11
11
|
ast.walk(node => {
|
12
12
|
if (node.type === 'function' && node.unclosed) {
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = convertFontSizeToRem;
|
7
7
|
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
8
|
-
function _interopRequireDefault(
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
9
9
|
const ROOT_FONT_SIZE = 16;
|
10
10
|
function convertFontSizeToRem(ast, key) {
|
11
11
|
if (key !== 'fontSize') {
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = normalizeLeadingZero;
|
7
7
|
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
8
|
-
function _interopRequireDefault(
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
9
9
|
function normalizeLeadingZero(ast, _) {
|
10
10
|
ast.walk(node => {
|
11
11
|
if (node.type !== 'word') {
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = normalizeTimings;
|
7
7
|
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
8
|
-
function _interopRequireDefault(
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
9
9
|
function normalizeTimings(ast, _) {
|
10
10
|
ast.walk(node => {
|
11
11
|
if (node.type !== 'word') {
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = normalizeZeroDimensions;
|
7
7
|
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
8
|
-
function _interopRequireDefault(
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
9
9
|
const angles = ['deg', 'grad', 'turn', 'rad'];
|
10
10
|
const timings = ['ms', 's'];
|
11
11
|
const fraction = 'fr';
|
@@ -9,7 +9,8 @@
|
|
9
9
|
|
10
10
|
import type { CompiledStyles } from '../common-types';
|
11
11
|
import { IncludedStyles } from '../stylex-include';
|
12
|
-
|
12
|
+
type AnyObject = { readonly [$$Key$$: string]: unknown };
|
13
|
+
export declare function isPlainObject(obj: unknown): obj is AnyObject;
|
13
14
|
export declare function flattenObject(obj: CompiledStyles): {
|
14
15
|
readonly [$$Key$$: string]: null | string | IncludedStyles;
|
15
16
|
};
|
@@ -42,7 +43,7 @@ export declare function objMapEntry<
|
|
42
43
|
K2 extends string = string,
|
43
44
|
>(
|
44
45
|
obj: { readonly [$$Key$$: K1]: V },
|
45
|
-
mapper: ($$PARAM_0$$: [K1, V]) => [K2, V2]
|
46
|
+
mapper: ($$PARAM_0$$: Readonly<[K1, V]>) => Readonly<[K2, V2]>,
|
46
47
|
): { readonly [$$Key$$: K2]: V2 };
|
47
48
|
export declare function objMap<V, V2, K extends string = string>(
|
48
49
|
obj: { readonly [$$Key$$: K]: V },
|
@@ -13,7 +13,10 @@ import type { CompiledStyles } from '../common-types';
|
|
13
13
|
|
14
14
|
import { IncludedStyles } from '../stylex-include';
|
15
15
|
|
16
|
-
|
16
|
+
// eslint-disable-next-line no-unused-vars
|
17
|
+
type AnyObject = { +[string]: mixed };
|
18
|
+
|
19
|
+
declare export function isPlainObject(obj: mixed): implies obj is AnyObject;
|
17
20
|
|
18
21
|
declare export function flattenObject(obj: CompiledStyles): {
|
19
22
|
+[string]: null | string | IncludedStyles,
|
@@ -48,7 +51,7 @@ declare export function objMapEntry<
|
|
48
51
|
K2: string = string,
|
49
52
|
>(
|
50
53
|
obj: { +[K1]: V },
|
51
|
-
mapper: ([K1, V]) => [K2, V2]
|
54
|
+
mapper: ($ReadOnly<[K1, V]>) => $ReadOnly<[K2, V2]>,
|
52
55
|
): { +[K2]: V2 };
|
53
56
|
|
54
57
|
declare export function objMap<V, V2, K: string = string>(
|
@@ -7,62 +7,9 @@
|
|
7
7
|
*
|
8
8
|
*/
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
':not': 40;
|
14
|
-
':has': 45;
|
15
|
-
':dir': 50;
|
16
|
-
':lang': 51;
|
17
|
-
':first-child': 52;
|
18
|
-
':first-of-type': 53;
|
19
|
-
':last-child': 54;
|
20
|
-
':last-of-type': 55;
|
21
|
-
':only-child': 56;
|
22
|
-
':only-of-type': 57;
|
23
|
-
':nth-child': 60;
|
24
|
-
':nth-last-child': 61;
|
25
|
-
':nth-of-type': 62;
|
26
|
-
':nth-last-of-type': 63;
|
27
|
-
':empty': 70;
|
28
|
-
':link': 80;
|
29
|
-
':any-link': 81;
|
30
|
-
':local-link': 82;
|
31
|
-
':target-within': 83;
|
32
|
-
':target': 84;
|
33
|
-
':visited': 85;
|
34
|
-
':enabled': 91;
|
35
|
-
':disabled': 92;
|
36
|
-
':required': 93;
|
37
|
-
':optional': 94;
|
38
|
-
':read-only': 95;
|
39
|
-
':read-write': 96;
|
40
|
-
':placeholder-shown': 97;
|
41
|
-
':in-range': 98;
|
42
|
-
':out-of-range': 99;
|
43
|
-
':default': 100;
|
44
|
-
':checked': 101;
|
45
|
-
':indeterminate': 101;
|
46
|
-
':blank': 102;
|
47
|
-
':valid': 103;
|
48
|
-
':invalid': 104;
|
49
|
-
':user-invalid': 105;
|
50
|
-
':autofill': 110;
|
51
|
-
':picture-in-picture': 120;
|
52
|
-
':modal': 121;
|
53
|
-
':fullscreen': 122;
|
54
|
-
':paused': 123;
|
55
|
-
':playing': 124;
|
56
|
-
':current': 125;
|
57
|
-
':past': 126;
|
58
|
-
':future': 127;
|
59
|
-
':hover': 130;
|
60
|
-
':focusWithin': 140;
|
61
|
-
':focus': 150;
|
62
|
-
':focusVisible': 160;
|
63
|
-
':active': 170;
|
64
|
-
};
|
65
|
-
export declare const PSEUDO_CLASS_PRIORITIES: Readonly<PseudoClassPriorities>;
|
10
|
+
export declare const PSEUDO_CLASS_PRIORITIES: Readonly<{
|
11
|
+
[$$Key$$: string]: number;
|
12
|
+
}>;
|
66
13
|
type AtRulePriorities = { '@supports': 30; '@media': 200; '@container': 300 };
|
67
14
|
export declare const AT_RULE_PRIORITIES: Readonly<AtRulePriorities>;
|
68
15
|
export declare const PSEUDO_ELEMENT_PRIORITY: number;
|
@@ -7,63 +7,63 @@
|
|
7
7
|
* @flow strict
|
8
8
|
*/
|
9
9
|
|
10
|
-
type PseudoClassPriorities = {
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
};
|
10
|
+
// type PseudoClassPriorities = {
|
11
|
+
// ':is': 40,
|
12
|
+
// ':where': 40,
|
13
|
+
// ':not': 40,
|
14
|
+
// ':has': 45,
|
15
|
+
// ':dir': 50,
|
16
|
+
// ':lang': 51,
|
17
|
+
// ':first-child': 52,
|
18
|
+
// ':first-of-type': 53,
|
19
|
+
// ':last-child': 54,
|
20
|
+
// ':last-of-type': 55,
|
21
|
+
// ':only-child': 56,
|
22
|
+
// ':only-of-type': 57,
|
23
|
+
// ':nth-child': 60,
|
24
|
+
// ':nth-last-child': 61,
|
25
|
+
// ':nth-of-type': 62,
|
26
|
+
// ':nth-last-of-type': 63, // 'nth-last-of-type' is the same priority as 'nth-of-type
|
27
|
+
// ':empty': 70,
|
28
|
+
// ':link': 80,
|
29
|
+
// ':any-link': 81,
|
30
|
+
// ':local-link': 82,
|
31
|
+
// ':target-within': 83,
|
32
|
+
// ':target': 84,
|
33
|
+
// ':visited': 85,
|
34
|
+
// ':enabled': 91,
|
35
|
+
// ':disabled': 92,
|
36
|
+
// ':required': 93,
|
37
|
+
// ':optional': 94,
|
38
|
+
// ':read-only': 95,
|
39
|
+
// ':read-write': 96,
|
40
|
+
// ':placeholder-shown': 97,
|
41
|
+
// ':in-range': 98,
|
42
|
+
// ':out-of-range': 99,
|
43
|
+
// ':default': 100,
|
44
|
+
// ':checked': 101,
|
45
|
+
// ':indeterminate': 101,
|
46
|
+
// ':blank': 102,
|
47
|
+
// ':valid': 103,
|
48
|
+
// ':invalid': 104,
|
49
|
+
// ':user-invalid': 105,
|
50
|
+
// ':autofill': 110,
|
51
|
+
// ':picture-in-picture': 120,
|
52
|
+
// ':modal': 121,
|
53
|
+
// ':fullscreen': 122,
|
54
|
+
// ':paused': 123,
|
55
|
+
// ':playing': 124,
|
56
|
+
// ':current': 125,
|
57
|
+
// ':past': 126,
|
58
|
+
// ':future': 127,
|
59
|
+
// ':hover': 130,
|
60
|
+
// ':focusWithin': 140,
|
61
|
+
// ':focus': 150,
|
62
|
+
// ':focusVisible': 160,
|
63
|
+
// ':active': 170,
|
64
|
+
// };
|
65
65
|
|
66
|
-
declare export const PSEUDO_CLASS_PRIORITIES: $ReadOnly<
|
66
|
+
declare export const PSEUDO_CLASS_PRIORITIES: $ReadOnly<{ [string]: number }>;
|
67
67
|
|
68
68
|
type AtRulePriorities = {
|
69
69
|
'@supports': 30,
|
@@ -0,0 +1,15 @@
|
|
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
|
+
export declare const sortPseudos: (
|
11
|
+
pseudos: ReadonlyArray<string>,
|
12
|
+
) => ReadonlyArray<string>;
|
13
|
+
export declare const sortAtRules: (
|
14
|
+
atRules: ReadonlyArray<string>,
|
15
|
+
) => ReadonlyArray<string>;
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.sortPseudos = exports.sortAtRules = void 0;
|
7
|
+
var _objectUtils = require("./object-utils");
|
8
|
+
const sortPseudos = pseudos => {
|
9
|
+
if (pseudos.length < 2) {
|
10
|
+
return pseudos;
|
11
|
+
}
|
12
|
+
return pseudos.reduce((acc, pseudo) => {
|
13
|
+
if (pseudo.startsWith('::')) {
|
14
|
+
return [...acc, pseudo];
|
15
|
+
}
|
16
|
+
const lastElement = acc[acc.length - 1];
|
17
|
+
const allButLast = acc.slice(0, acc.length - 1);
|
18
|
+
if (Array.isArray(lastElement)) {
|
19
|
+
return [...allButLast, [...lastElement, pseudo]];
|
20
|
+
} else {
|
21
|
+
return [...allButLast, lastElement, [pseudo]].filter(Boolean);
|
22
|
+
}
|
23
|
+
}, []).flatMap(pseudo => {
|
24
|
+
if (Array.isArray(pseudo)) {
|
25
|
+
return (0, _objectUtils.arraySort)(pseudo, stringComparator);
|
26
|
+
}
|
27
|
+
return [pseudo];
|
28
|
+
});
|
29
|
+
};
|
30
|
+
exports.sortPseudos = sortPseudos;
|
31
|
+
const sortAtRules = atRules => (0, _objectUtils.arraySort)(atRules);
|
32
|
+
exports.sortAtRules = sortAtRules;
|
33
|
+
const stringComparator = (a, b) => {
|
34
|
+
if (a === 'default') {
|
35
|
+
return -1;
|
36
|
+
}
|
37
|
+
if (b === 'default') {
|
38
|
+
return 1;
|
39
|
+
}
|
40
|
+
return a.localeCompare(b);
|
41
|
+
};
|
@@ -0,0 +1,16 @@
|
|
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
|
+
* @flow strict
|
8
|
+
*/
|
9
|
+
|
10
|
+
declare export const sortPseudos: (
|
11
|
+
pseudos: $ReadOnlyArray<string>,
|
12
|
+
) => $ReadOnlyArray<string>;
|
13
|
+
|
14
|
+
declare export const sortAtRules: (
|
15
|
+
atRules: $ReadOnlyArray<string>,
|
16
|
+
) => $ReadOnlyArray<string>;
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = splitValue;
|
7
7
|
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
8
|
-
function _interopRequireDefault(
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
9
9
|
function printNode(node) {
|
10
10
|
switch (node.type) {
|
11
11
|
case 'word':
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@stylexjs/shared",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.9.0-beta.1",
|
4
4
|
"main": "lib/index.js",
|
5
5
|
"repository": "https://www.github.com/facebook/stylex",
|
6
6
|
"license": "MIT",
|
@@ -13,7 +13,7 @@
|
|
13
13
|
"postcss-value-parser": "^4.1.0"
|
14
14
|
},
|
15
15
|
"devDependencies": {
|
16
|
-
"@stylexjs/scripts": "0.
|
16
|
+
"@stylexjs/scripts": "0.9.0-beta.1"
|
17
17
|
},
|
18
18
|
"jest": {
|
19
19
|
"snapshotFormat": {
|