@stylexjs/shared 0.2.0-beta.16 → 0.2.0-beta.17
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/convert-to-className.d.ts +1 -1
- package/lib/convert-to-className.js +6 -22
- package/lib/convert-to-className.js.flow +1 -1
- package/lib/generate-css-rule.d.ts +1 -1
- package/lib/generate-css-rule.js +3 -14
- package/lib/generate-css-rule.js.flow +1 -1
- package/lib/hash.d.ts +2 -2
- package/lib/hash.js +9 -33
- package/lib/hash.js.flow +1 -3
- package/lib/index.d.ts +9 -9
- package/lib/index.js +0 -14
- package/lib/index.js.flow +9 -9
- package/lib/messages.d.ts +26 -26
- package/lib/messages.js +26 -36
- package/lib/messages.js.flow +26 -26
- package/lib/physical-rtl/generate-ltr.js +39 -67
- package/lib/physical-rtl/generate-ltr.js.flow +1 -1
- package/lib/physical-rtl/generate-rtl.d.ts +1 -2
- package/lib/physical-rtl/generate-rtl.js +57 -89
- package/lib/physical-rtl/generate-rtl.js.flow +1 -2
- package/lib/preprocess-rules/PreRule.d.ts +3 -3
- package/lib/preprocess-rules/PreRule.js +3 -17
- package/lib/preprocess-rules/PreRule.js.flow +3 -3
- package/lib/preprocess-rules/application-order.d.ts +8 -5
- package/lib/preprocess-rules/application-order.js +121 -160
- package/lib/preprocess-rules/application-order.js.flow +6 -5
- package/lib/preprocess-rules/basic-validation.d.ts +1 -1
- package/lib/preprocess-rules/basic-validation.js +6 -15
- package/lib/preprocess-rules/basic-validation.js.flow +1 -1
- package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +2 -2
- package/lib/preprocess-rules/flatten-raw-style-obj.js +14 -43
- package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +2 -2
- package/lib/preprocess-rules/index.d.ts +2 -2
- package/lib/preprocess-rules/index.js +6 -15
- package/lib/preprocess-rules/index.js.flow +2 -2
- package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +3 -2
- package/lib/preprocess-rules/legacy-expand-shorthands.js +14 -33
- package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +2 -2
- package/lib/preprocess-rules/property-specificity.d.ts +8 -5
- package/lib/preprocess-rules/property-specificity.js +54 -76
- package/lib/preprocess-rules/property-specificity.js.flow +6 -5
- package/lib/stylex-create-vars.d.ts +17 -8
- package/lib/stylex-create-vars.js +30 -17
- package/lib/stylex-create-vars.js.flow +10 -4
- package/lib/stylex-create.d.ts +2 -2
- package/lib/stylex-create.js +1 -20
- package/lib/stylex-create.js.flow +1 -1
- package/lib/stylex-first-that-works.js +0 -10
- package/lib/stylex-include.js +0 -10
- package/lib/stylex-keyframes.d.ts +1 -1
- package/lib/stylex-keyframes.js +7 -27
- package/lib/stylex-keyframes.js.flow +1 -1
- package/lib/stylex-override-vars.d.ts +11 -4
- package/lib/stylex-override-vars.js +32 -18
- package/lib/stylex-override-vars.js.flow +3 -3
- package/lib/transform-value.js +11 -29
- package/lib/transform-value.js.flow +1 -1
- package/lib/utils/Rule.d.ts +2 -2
- package/lib/utils/Rule.js +0 -21
- package/lib/utils/Rule.js.flow +2 -2
- package/lib/utils/dashify.js +1 -9
- package/lib/utils/default-options.d.ts +1 -1
- package/lib/utils/default-options.js +2 -23
- package/lib/utils/default-options.js.flow +1 -1
- package/lib/utils/file-based-identifier.js +1 -9
- package/lib/utils/genCSSRule.d.ts +1 -1
- package/lib/utils/genCSSRule.js +6 -16
- package/lib/utils/genCSSRule.js.flow +1 -1
- package/lib/utils/normalize-value.js +1 -13
- package/lib/utils/normalize-value.js.flow +1 -1
- package/lib/utils/normalizers/detect-unclosed-fns.d.ts +1 -1
- package/lib/utils/normalizers/detect-unclosed-fns.js +2 -14
- package/lib/utils/normalizers/detect-unclosed-fns.js.flow +1 -1
- package/lib/utils/normalizers/font-size-px-to-rem.d.ts +1 -1
- package/lib/utils/normalizers/font-size-px-to-rem.js +4 -19
- package/lib/utils/normalizers/font-size-px-to-rem.js.flow +1 -1
- package/lib/utils/normalizers/leading-zero.d.ts +1 -1
- package/lib/utils/normalizers/leading-zero.js +3 -15
- package/lib/utils/normalizers/leading-zero.js.flow +1 -1
- package/lib/utils/normalizers/quotes.d.ts +1 -1
- package/lib/utils/normalizers/quotes.js +4 -17
- package/lib/utils/normalizers/quotes.js.flow +1 -1
- package/lib/utils/normalizers/timings.d.ts +1 -1
- package/lib/utils/normalizers/timings.js +4 -18
- package/lib/utils/normalizers/timings.js.flow +1 -1
- package/lib/utils/normalizers/whitespace.d.ts +1 -1
- package/lib/utils/normalizers/whitespace.js +12 -27
- package/lib/utils/normalizers/whitespace.js.flow +1 -1
- package/lib/utils/normalizers/zero-dimensions.d.ts +1 -1
- package/lib/utils/normalizers/zero-dimensions.js +8 -23
- package/lib/utils/normalizers/zero-dimensions.js.flow +1 -1
- package/lib/utils/object-utils.d.ts +28 -20
- package/lib/utils/object-utils.js +2 -15
- package/lib/utils/object-utils.js.flow +23 -27
- package/lib/utils/property-priorities.js +68 -83
- package/lib/utils/split-css-value.d.ts +1 -1
- package/lib/utils/split-css-value.js +8 -22
- package/lib/utils/split-css-value.js.flow +1 -1
- package/lib/validate.js +2 -11
- package/package.json +2 -3
|
@@ -9,15 +9,6 @@ var _index = _interopRequireDefault(require("./index"));
|
|
|
9
9
|
var _PreRule = require("./PreRule");
|
|
10
10
|
var _stylexInclude = require("../stylex-include");
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
/**
|
|
13
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
12
|
function flattenRawStyleObject(style, options) {
|
|
22
13
|
return _flattenRawStyleObject(style, [], [], options);
|
|
23
14
|
}
|
|
@@ -25,15 +16,11 @@ function _flattenRawStyleObject(style, pseudos, atRules, options) {
|
|
|
25
16
|
const flattened = [];
|
|
26
17
|
for (const key in style) {
|
|
27
18
|
const value = style[key];
|
|
28
|
-
|
|
29
|
-
// Included Styles
|
|
30
|
-
if (typeof value === 'object' && value instanceof _stylexInclude.IncludedStyles) {
|
|
19
|
+
if (typeof value === "object" && value instanceof _stylexInclude.IncludedStyles) {
|
|
31
20
|
flattened.push([key, new _PreRule.PreIncludedStylesRule(value)]);
|
|
32
21
|
continue;
|
|
33
22
|
}
|
|
34
|
-
|
|
35
|
-
// Default styles
|
|
36
|
-
if (value === null || typeof value === 'string' || typeof value === 'number') {
|
|
23
|
+
if (value === null || typeof value === "string" || typeof value === "number") {
|
|
37
24
|
const pairs = (0, _index.default)([key, value], options);
|
|
38
25
|
for (const [property, value] of pairs) {
|
|
39
26
|
if (value === null) {
|
|
@@ -44,8 +31,6 @@ function _flattenRawStyleObject(style, pseudos, atRules, options) {
|
|
|
44
31
|
}
|
|
45
32
|
continue;
|
|
46
33
|
}
|
|
47
|
-
|
|
48
|
-
// Fallback Styles
|
|
49
34
|
if (Array.isArray(value)) {
|
|
50
35
|
const equivalentPairs = {};
|
|
51
36
|
for (const eachVal of value) {
|
|
@@ -64,20 +49,13 @@ function _flattenRawStyleObject(style, pseudos, atRules, options) {
|
|
|
64
49
|
}
|
|
65
50
|
}
|
|
66
51
|
}
|
|
67
|
-
|
|
68
|
-
Object.entries(equivalentPairs)
|
|
69
|
-
// Remove Nulls
|
|
70
|
-
.map(_ref => {
|
|
52
|
+
Object.entries(equivalentPairs).map(_ref => {
|
|
71
53
|
let [property, values] = _ref;
|
|
72
54
|
return [property, [...new Set(values.filter(Boolean))]];
|
|
73
|
-
})
|
|
74
|
-
// Deduplicate and default to null when no values are found
|
|
75
|
-
.map(_ref2 => {
|
|
55
|
+
}).map(_ref2 => {
|
|
76
56
|
let [property, values] = _ref2;
|
|
77
57
|
return [property, values.length === 0 ? null : values.length === 1 ? values[0] : values];
|
|
78
|
-
})
|
|
79
|
-
// Push to flattened
|
|
80
|
-
.forEach(_ref3 => {
|
|
58
|
+
}).forEach(_ref3 => {
|
|
81
59
|
let [property, value] = _ref3;
|
|
82
60
|
if (value === null) {
|
|
83
61
|
flattened.push([property, new _PreRule.NullPreRule()]);
|
|
@@ -87,17 +65,15 @@ function _flattenRawStyleObject(style, pseudos, atRules, options) {
|
|
|
87
65
|
});
|
|
88
66
|
continue;
|
|
89
67
|
}
|
|
90
|
-
|
|
91
|
-
// Object Values for propetiies. e.g. { color: { hover: 'red', default: 'blue' } }
|
|
92
|
-
if (typeof value === 'object' && !key.startsWith(':') && !key.startsWith('@')) {
|
|
68
|
+
if (typeof value === "object" && !key.startsWith(":") && !key.startsWith("@")) {
|
|
93
69
|
const equivalentPairs = {};
|
|
94
70
|
for (const condition in value) {
|
|
95
71
|
const innerValue = value[condition];
|
|
96
72
|
const pseudosToPassDown = [...pseudos];
|
|
97
73
|
const atRulesToPassDown = [...atRules];
|
|
98
|
-
if (condition.startsWith(
|
|
74
|
+
if (condition.startsWith(":")) {
|
|
99
75
|
pseudosToPassDown.push(condition);
|
|
100
|
-
} else if (condition.startsWith(
|
|
76
|
+
} else if (condition.startsWith("@")) {
|
|
101
77
|
atRulesToPassDown.push(condition);
|
|
102
78
|
}
|
|
103
79
|
const pairs = _flattenRawStyleObject({
|
|
@@ -105,8 +81,7 @@ function _flattenRawStyleObject(style, pseudos, atRules, options) {
|
|
|
105
81
|
}, pseudosToPassDown, atRulesToPassDown, options);
|
|
106
82
|
for (const [property, preRule] of pairs) {
|
|
107
83
|
if (preRule instanceof _PreRule.PreIncludedStylesRule) {
|
|
108
|
-
|
|
109
|
-
throw new Error('stylex.include can only be used at the top-level');
|
|
84
|
+
throw new Error("stylex.include can only be used at the top-level");
|
|
110
85
|
}
|
|
111
86
|
if (equivalentPairs[property] == null) {
|
|
112
87
|
equivalentPairs[property] = {
|
|
@@ -118,29 +93,25 @@ function _flattenRawStyleObject(style, pseudos, atRules, options) {
|
|
|
118
93
|
}
|
|
119
94
|
}
|
|
120
95
|
for (const [property, obj] of Object.entries(equivalentPairs)) {
|
|
121
|
-
const sortedKeys = Object.keys(obj);
|
|
96
|
+
const sortedKeys = Object.keys(obj);
|
|
122
97
|
const rules = [];
|
|
123
98
|
for (const condition of sortedKeys) {
|
|
124
99
|
rules.push(obj[condition]);
|
|
125
100
|
}
|
|
126
|
-
// If there are many conditions with `null` values, we will collapse them into a single `null` value.
|
|
127
|
-
// `PreRuleSet.create` takes care of that for us.
|
|
128
101
|
flattened.push([property, _PreRule.PreRuleSet.create(rules)]);
|
|
129
102
|
}
|
|
130
103
|
}
|
|
131
|
-
|
|
132
|
-
// Object Values for pseudos and at-rules. e.g. { ':hover': { color: 'red' } }
|
|
133
|
-
if (typeof value === 'object' && (key.startsWith(':') || key.startsWith('@'))) {
|
|
104
|
+
if (typeof value === "object" && (key.startsWith(":") || key.startsWith("@"))) {
|
|
134
105
|
const pseudosToPassDown = [...pseudos];
|
|
135
106
|
const atRulesToPassDown = [...atRules];
|
|
136
|
-
if (key.startsWith(
|
|
107
|
+
if (key.startsWith(":")) {
|
|
137
108
|
pseudosToPassDown.push(key);
|
|
138
|
-
} else if (key.startsWith(
|
|
109
|
+
} else if (key.startsWith("@")) {
|
|
139
110
|
atRulesToPassDown.push(key);
|
|
140
111
|
}
|
|
141
112
|
const pairs = _flattenRawStyleObject(value, pseudosToPassDown, atRulesToPassDown, options);
|
|
142
113
|
for (const [property, preRule] of pairs) {
|
|
143
|
-
flattened.push([key +
|
|
114
|
+
flattened.push([key + "_" + property, preRule]);
|
|
144
115
|
}
|
|
145
116
|
}
|
|
146
117
|
}
|
|
@@ -16,12 +16,12 @@ import {
|
|
|
16
16
|
} from './PreRule';
|
|
17
17
|
declare export function flattenRawStyleObject(
|
|
18
18
|
style: RawStyles,
|
|
19
|
-
options: StyleXOptions
|
|
19
|
+
options: StyleXOptions,
|
|
20
20
|
): $ReadOnlyArray<$ReadOnly<[string, IPreRule]>>;
|
|
21
21
|
|
|
22
22
|
declare export function _flattenRawStyleObject(
|
|
23
23
|
style: RawStyles,
|
|
24
24
|
pseudos: $ReadOnlyArray<string>,
|
|
25
25
|
atRules: $ReadOnlyArray<string>,
|
|
26
|
-
options: StyleXOptions
|
|
26
|
+
options: StyleXOptions,
|
|
27
27
|
): Array<$ReadOnly<[string, AnyPreRule | PreIncludedStylesRule]>>;
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
|
|
10
10
|
import type { StyleXOptions, TStyleValue } from '../common-types';
|
|
11
11
|
export declare function getExpandedKeys(
|
|
12
|
-
options: StyleXOptions
|
|
12
|
+
options: StyleXOptions,
|
|
13
13
|
): ReadonlyArray<string>;
|
|
14
14
|
declare function flatMapExpandedShorthands(
|
|
15
15
|
objEntry: Readonly<[string, TStyleValue]>,
|
|
16
|
-
options: StyleXOptions
|
|
16
|
+
options: StyleXOptions,
|
|
17
17
|
): ReadonlyArray<[string, TStyleValue]>;
|
|
18
18
|
export default flatMapExpandedShorthands;
|
|
@@ -9,29 +9,20 @@ var _applicationOrder = _interopRequireDefault(require("./application-order"));
|
|
|
9
9
|
var _legacyExpandShorthands = _interopRequireDefault(require("./legacy-expand-shorthands"));
|
|
10
10
|
var _propertySpecificity = _interopRequireDefault(require("./property-specificity"));
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
/**
|
|
13
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
12
|
const expansions = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
"application-order": _applicationOrder.default,
|
|
14
|
+
"property-specificity": _propertySpecificity.default,
|
|
15
|
+
"legacy-expand-shorthands": _legacyExpandShorthands.default
|
|
25
16
|
};
|
|
26
17
|
function getExpandedKeys(options) {
|
|
27
|
-
return Object.keys(expansions[options.styleResolution ??
|
|
18
|
+
return Object.keys(expansions[options.styleResolution ?? "application-order"]);
|
|
28
19
|
}
|
|
29
20
|
function flatMapExpandedShorthands(objEntry, options) {
|
|
30
21
|
const [key, value] = objEntry;
|
|
31
|
-
const expansion = expansions[options.styleResolution ??
|
|
22
|
+
const expansion = expansions[options.styleResolution ?? "application-order"][key];
|
|
32
23
|
if (expansion) {
|
|
33
24
|
if (Array.isArray(value)) {
|
|
34
|
-
throw new Error(
|
|
25
|
+
throw new Error("Cannot use fallbacks for shorthands. Use the expansion instead.");
|
|
35
26
|
}
|
|
36
27
|
return expansion(value);
|
|
37
28
|
}
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
import type { StyleXOptions, TStyleValue } from '../common-types';
|
|
11
11
|
|
|
12
12
|
declare export function getExpandedKeys(
|
|
13
|
-
options: StyleXOptions
|
|
13
|
+
options: StyleXOptions,
|
|
14
14
|
): $ReadOnlyArray<string>;
|
|
15
15
|
|
|
16
16
|
declare export default function flatMapExpandedShorthands(
|
|
17
17
|
objEntry: $ReadOnly<[string, TStyleValue]>,
|
|
18
|
-
options: StyleXOptions
|
|
18
|
+
options: StyleXOptions,
|
|
19
19
|
): $ReadOnlyArray<[string, TStyleValue]>;
|
|
@@ -103,7 +103,7 @@ import type { TStyleValue } from '../common-types';
|
|
|
103
103
|
*/
|
|
104
104
|
|
|
105
105
|
type TReturn = ReadonlyArray<[string, TStyleValue]>;
|
|
106
|
-
declare
|
|
106
|
+
declare const expansions: {
|
|
107
107
|
border: (rawValue: TStyleValue) => TReturn;
|
|
108
108
|
borderColor: (rawValue: TStyleValue) => TReturn;
|
|
109
109
|
borderHorizontal: (rawValue: TStyleValue) => TReturn;
|
|
@@ -119,4 +119,5 @@ declare var expansions: {
|
|
|
119
119
|
paddingHorizontal: (rawValue: TStyleValue) => TReturn;
|
|
120
120
|
paddingVertical: (rawValue: TStyleValue) => TReturn;
|
|
121
121
|
};
|
|
122
|
-
|
|
122
|
+
declare const $$EXPORT_DEFAULT_DECLARATION$$: typeof expansions;
|
|
123
|
+
export default $$EXPORT_DEFAULT_DECLARATION$$;
|
|
@@ -6,74 +6,55 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _splitCssValue = _interopRequireDefault(require("../utils/split-css-value"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
/**
|
|
10
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
11
|
-
*
|
|
12
|
-
* This source code is licensed under the MIT license found in the
|
|
13
|
-
* LICENSE file in the root directory of this source tree.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
9
|
const expansions = {
|
|
19
10
|
border: rawValue => {
|
|
20
|
-
return [[
|
|
11
|
+
return [["borderTop", rawValue], ["borderEnd", rawValue], ["borderBottom", rawValue], ["borderStart", rawValue]];
|
|
21
12
|
},
|
|
22
13
|
borderColor: rawValue => {
|
|
23
14
|
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
|
|
24
|
-
return [[
|
|
15
|
+
return [["borderTopColor", top], ["borderEndColor", right], ["borderBottomColor", bottom], ["borderStartColor", left]];
|
|
25
16
|
},
|
|
26
17
|
borderHorizontal: rawValue => {
|
|
27
|
-
return [[
|
|
28
|
-
// return [
|
|
29
|
-
// ...expansions.borderStart(rawValue),
|
|
30
|
-
// ...expansions.borderEnd(rawValue),
|
|
31
|
-
// ];
|
|
18
|
+
return [["borderStart", rawValue], ["borderEnd", rawValue]];
|
|
32
19
|
},
|
|
33
|
-
|
|
34
20
|
borderStyle: rawValue => {
|
|
35
21
|
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
|
|
36
|
-
return [[
|
|
22
|
+
return [["borderTopStyle", top], ["borderEndStyle", right], ["borderBottomStyle", bottom], ["borderStartStyle", left]];
|
|
37
23
|
},
|
|
38
24
|
borderVertical: rawValue => {
|
|
39
|
-
return [[
|
|
40
|
-
// return [
|
|
41
|
-
// ...expansions.borderTop(rawValue),
|
|
42
|
-
// ...expansions.borderBottom(rawValue),
|
|
43
|
-
// ];
|
|
25
|
+
return [["borderTop", rawValue], ["borderBottom", rawValue]];
|
|
44
26
|
},
|
|
45
|
-
|
|
46
27
|
borderWidth: rawValue => {
|
|
47
28
|
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
|
|
48
|
-
return [[
|
|
29
|
+
return [["borderTopWidth", top], ["borderEndWidth", right], ["borderBottomWidth", bottom], ["borderStartWidth", left]];
|
|
49
30
|
},
|
|
50
31
|
borderRadius: rawValue => {
|
|
51
32
|
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
|
|
52
|
-
return [[
|
|
33
|
+
return [["borderTopStartRadius", top], ["borderTopEndRadius", right], ["borderBottomEndRadius", bottom], ["borderBottomStartRadius", left]];
|
|
53
34
|
},
|
|
54
35
|
margin: rawValue => {
|
|
55
36
|
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
|
|
56
|
-
return [[
|
|
37
|
+
return [["marginTop", top], ["marginEnd", right], ["marginBottom", bottom], ["marginStart", left]];
|
|
57
38
|
},
|
|
58
39
|
marginHorizontal: rawValue => {
|
|
59
|
-
return [[
|
|
40
|
+
return [["marginStart", rawValue], ["marginEnd", rawValue]];
|
|
60
41
|
},
|
|
61
42
|
marginVertical: rawValue => {
|
|
62
|
-
return [[
|
|
43
|
+
return [["marginTop", rawValue], ["marginBottom", rawValue]];
|
|
63
44
|
},
|
|
64
45
|
overflow: rawValue => {
|
|
65
46
|
const [x, y = x] = (0, _splitCssValue.default)(rawValue);
|
|
66
|
-
return [[
|
|
47
|
+
return [["overflowX", x], ["overflowY", y]];
|
|
67
48
|
},
|
|
68
49
|
padding: rawValue => {
|
|
69
50
|
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
|
|
70
|
-
return [[
|
|
51
|
+
return [["paddingTop", top], ["paddingEnd", right], ["paddingBottom", bottom], ["paddingStart", left]];
|
|
71
52
|
},
|
|
72
53
|
paddingHorizontal: rawValue => {
|
|
73
|
-
return [[
|
|
54
|
+
return [["paddingStart", rawValue], ["paddingEnd", rawValue]];
|
|
74
55
|
},
|
|
75
56
|
paddingVertical: rawValue => {
|
|
76
|
-
return [[
|
|
57
|
+
return [["paddingTop", rawValue], ["paddingBottom", rawValue]];
|
|
77
58
|
}
|
|
78
59
|
};
|
|
79
60
|
var _default = expansions;
|
|
@@ -81,7 +81,7 @@ import type { TStyleValue } from '../common-types';
|
|
|
81
81
|
|
|
82
82
|
type TReturn = $ReadOnlyArray<[string, TStyleValue]>;
|
|
83
83
|
|
|
84
|
-
declare
|
|
84
|
+
declare const expansions: {
|
|
85
85
|
border: (rawValue: TStyleValue) => TReturn,
|
|
86
86
|
borderColor: (rawValue: TStyleValue) => TReturn,
|
|
87
87
|
borderHorizontal: (rawValue: TStyleValue) => TReturn,
|
|
@@ -98,4 +98,4 @@ declare var expansions: {
|
|
|
98
98
|
paddingVertical: (rawValue: TStyleValue) => TReturn,
|
|
99
99
|
};
|
|
100
100
|
|
|
101
|
-
declare export default expansions;
|
|
101
|
+
declare export default typeof expansions;
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import type { TStyleValue } from '../common-types';
|
|
11
11
|
type TReturn = ReadonlyArray<[string, TStyleValue]>;
|
|
12
|
-
declare
|
|
12
|
+
declare const shorthands: {
|
|
13
13
|
all: (_: TStyleValue) => TReturn;
|
|
14
14
|
animation: (_value: TStyleValue) => TReturn;
|
|
15
15
|
background: (_value: TStyleValue) => TReturn;
|
|
@@ -25,7 +25,7 @@ declare var shorthands: {
|
|
|
25
25
|
margin: (value: TStyleValue) => TReturn;
|
|
26
26
|
padding: (rawValue: TStyleValue) => TReturn;
|
|
27
27
|
};
|
|
28
|
-
declare
|
|
28
|
+
declare const aliases: {
|
|
29
29
|
borderHorizontal: any;
|
|
30
30
|
borderVertical: any;
|
|
31
31
|
borderBlockStart: any;
|
|
@@ -71,6 +71,9 @@ declare var aliases: {
|
|
|
71
71
|
start: (value: TStyleValue) => TReturn;
|
|
72
72
|
end: (value: TStyleValue) => TReturn;
|
|
73
73
|
};
|
|
74
|
-
declare
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
declare const $$EXPORT_DEFAULT_DECLARATION$$: Readonly</**
|
|
75
|
+
* > 86 | ...typeof shorthands,
|
|
76
|
+
* | ^^^^^^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with complex spreads" is currently not supported.
|
|
77
|
+
**/
|
|
78
|
+
any>;
|
|
79
|
+
export default $$EXPORT_DEFAULT_DECLARATION$$;
|
|
@@ -6,126 +6,104 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _splitCssValue = _interopRequireDefault(require("../utils/split-css-value"));
|
|
8
8
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
/**
|
|
10
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
11
|
-
*
|
|
12
|
-
* This source code is licensed under the MIT license found in the
|
|
13
|
-
* LICENSE file in the root directory of this source tree.
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
9
|
const shorthands = {
|
|
19
10
|
all: _ => {
|
|
20
|
-
throw new Error(
|
|
11
|
+
throw new Error("all is not supported");
|
|
21
12
|
},
|
|
22
13
|
animation: _value => {
|
|
23
|
-
throw new Error(
|
|
14
|
+
throw new Error("animation is not supported");
|
|
24
15
|
},
|
|
25
16
|
background: _value => {
|
|
26
|
-
throw new Error(
|
|
17
|
+
throw new Error("background is not supported. Use background-color, border-image etc. instead.");
|
|
27
18
|
},
|
|
28
19
|
border: _rawValue => {
|
|
29
|
-
throw new Error(
|
|
20
|
+
throw new Error("border is not supported. Use border-width, border-style and border-color instead.");
|
|
30
21
|
},
|
|
31
22
|
borderInline: _rawValue => {
|
|
32
|
-
throw new Error(
|
|
23
|
+
throw new Error("borderInline is not supported. Use borderInlineWidth, borderInlineStyle and borderInlineColor instead.");
|
|
33
24
|
},
|
|
34
|
-
// @Deprecated
|
|
35
25
|
borderBlock: _rawValue => {
|
|
36
|
-
throw new Error(
|
|
26
|
+
throw new Error("borderBlock is not supported. Use borderBlockWidth, borderBlockStyle and borderBlockColor instead.");
|
|
37
27
|
},
|
|
38
|
-
// @Deprecated
|
|
39
28
|
borderTop: _rawValue => {
|
|
40
|
-
throw new Error(
|
|
29
|
+
throw new Error("borderTop is not supported. Use borderTopWidth, borderTopStyle and borderTopColor instead.");
|
|
41
30
|
},
|
|
42
|
-
// @Deprecated
|
|
43
31
|
borderInlineEnd: _rawValue => {
|
|
44
|
-
throw new Error(
|
|
32
|
+
throw new Error("borderInlineEnd is not supported. Use borderInlineEndWidth, borderInlineEndStyle and borderInlineEndColor instead.");
|
|
45
33
|
},
|
|
46
|
-
// @Deprecated
|
|
47
34
|
borderRight: _rawValue => {
|
|
48
|
-
throw new Error(
|
|
35
|
+
throw new Error("borderRight is not supported. Use borderRightWidth, borderRightStyle and borderRightColor instead.");
|
|
49
36
|
},
|
|
50
|
-
// @Deprecated
|
|
51
37
|
borderBottom: _rawValue => {
|
|
52
|
-
throw new Error(
|
|
38
|
+
throw new Error("borderBottom is not supported. Use borderBottomWidth, borderBottomStyle and borderBottomColor instead.");
|
|
53
39
|
},
|
|
54
|
-
// @Deprecated
|
|
55
40
|
borderInlineStart: _rawValue => {
|
|
56
|
-
throw new Error(
|
|
41
|
+
throw new Error("borderInlineStart is not supported. Use borderInlineStartWidth, borderInlineStartStyle and borderInlineStartColor instead.");
|
|
57
42
|
},
|
|
58
|
-
// @Deprecated
|
|
59
43
|
borderLeft: _rawValue => {
|
|
60
|
-
throw new Error([
|
|
44
|
+
throw new Error(["`borderLeft` is not supported.", "You could use `borderLeftWidth`, `borderLeftStyle` and `borderLeftColor`,", "but it is preferable to use `borderInlineStartWidth`, `borderInlineStartStyle` and `borderInlineStartColor`."].join(" "));
|
|
61
45
|
},
|
|
62
46
|
margin: value => {
|
|
63
47
|
const values = (0, _splitCssValue.default)(value);
|
|
64
48
|
if (values.length === 1) {
|
|
65
|
-
return [[
|
|
49
|
+
return [["margin", values[0]]];
|
|
66
50
|
} else {
|
|
67
|
-
throw new Error(
|
|
51
|
+
throw new Error("margin shorthand with multiple values is not supported. Use marginTop, marginInlineEnd, marginBottom and marginInlineStart instead.");
|
|
68
52
|
}
|
|
69
53
|
},
|
|
70
54
|
padding: rawValue => {
|
|
71
55
|
const values = (0, _splitCssValue.default)(rawValue);
|
|
72
56
|
if (values.length === 1) {
|
|
73
|
-
return [[
|
|
57
|
+
return [["padding", values[0]]];
|
|
74
58
|
}
|
|
75
|
-
throw new Error(
|
|
59
|
+
throw new Error("padding shorthand with multiple values is not supported. Use paddingTop, paddingInlineEnd, paddingBottom and paddingInlineStart instead.");
|
|
76
60
|
}
|
|
77
61
|
};
|
|
78
62
|
const aliases = {
|
|
79
|
-
// @UNSUPPORTED
|
|
80
63
|
borderHorizontal: shorthands.borderInline,
|
|
81
|
-
// @UNSUPPORTED
|
|
82
64
|
borderVertical: shorthands.borderBlock,
|
|
83
|
-
// @UNSUPPORTED
|
|
84
65
|
borderBlockStart: shorthands.borderTop,
|
|
85
|
-
// @UNSUPPORTED
|
|
86
66
|
borderEnd: shorthands.borderInlineEnd,
|
|
87
|
-
// @UNSUPPORTED
|
|
88
67
|
borderBlockEnd: shorthands.borderBottom,
|
|
89
|
-
// @UNSUPPORTED
|
|
90
68
|
borderStart: shorthands.borderInlineStart,
|
|
91
|
-
borderHorizontalWidth: value => [[
|
|
92
|
-
borderHorizontalStyle: value => [[
|
|
93
|
-
borderHorizontalColor: value => [[
|
|
94
|
-
borderVerticalWidth: value => [[
|
|
95
|
-
borderVerticalStyle: value => [[
|
|
96
|
-
borderVerticalColor: value => [[
|
|
97
|
-
borderBlockStartColor: value => [[
|
|
98
|
-
borderBlockEndColor: value => [[
|
|
99
|
-
borderBlockStartStyle: value => [[
|
|
100
|
-
borderBlockEndStyle: value => [[
|
|
101
|
-
borderBlockStartWidth: value => [[
|
|
102
|
-
borderBlockEndWidth: value => [[
|
|
103
|
-
borderStartColor: value => [[
|
|
104
|
-
borderEndColor: value => [[
|
|
105
|
-
borderStartStyle: value => [[
|
|
106
|
-
borderEndStyle: value => [[
|
|
107
|
-
borderStartWidth: value => [[
|
|
108
|
-
borderEndWidth: value => [[
|
|
109
|
-
borderTopStartRadius: value => [[
|
|
110
|
-
borderTopEndRadius: value => [[
|
|
111
|
-
borderBottomStartRadius: value => [[
|
|
112
|
-
borderBottomEndRadius: value => [[
|
|
113
|
-
marginBlockStart: value => [[
|
|
114
|
-
marginBlockEnd: value => [[
|
|
115
|
-
marginStart: value => [[
|
|
116
|
-
marginEnd: value => [[
|
|
117
|
-
marginHorizontal: value => [[
|
|
118
|
-
marginVertical: value => [[
|
|
119
|
-
paddingBlockStart: rawValue => [[
|
|
120
|
-
paddingBlockEnd: rawValue => [[
|
|
121
|
-
paddingStart: value => [[
|
|
122
|
-
paddingEnd: value => [[
|
|
123
|
-
paddingHorizontal: value => [[
|
|
124
|
-
paddingVertical: value => [[
|
|
125
|
-
insetBlockStart: value => [[
|
|
126
|
-
insetBlockEnd: value => [[
|
|
127
|
-
start: value => [[
|
|
128
|
-
end: value => [[
|
|
69
|
+
borderHorizontalWidth: value => [["borderInlineWidth", value]],
|
|
70
|
+
borderHorizontalStyle: value => [["borderInlineStyle", value]],
|
|
71
|
+
borderHorizontalColor: value => [["borderInlineColor", value]],
|
|
72
|
+
borderVerticalWidth: value => [["borderBlockWidth", value]],
|
|
73
|
+
borderVerticalStyle: value => [["borderBlockStyle", value]],
|
|
74
|
+
borderVerticalColor: value => [["borderBlockColor", value]],
|
|
75
|
+
borderBlockStartColor: value => [["borderTopColor", value]],
|
|
76
|
+
borderBlockEndColor: value => [["borderBottomColor", value]],
|
|
77
|
+
borderBlockStartStyle: value => [["borderTopStyle", value]],
|
|
78
|
+
borderBlockEndStyle: value => [["borderBottomStyle", value]],
|
|
79
|
+
borderBlockStartWidth: value => [["borderTopWidth", value]],
|
|
80
|
+
borderBlockEndWidth: value => [["borderBottomWidth", value]],
|
|
81
|
+
borderStartColor: value => [["borderInlineStartColor", value]],
|
|
82
|
+
borderEndColor: value => [["borderInlineEndColor", value]],
|
|
83
|
+
borderStartStyle: value => [["borderInlineStartStyle", value]],
|
|
84
|
+
borderEndStyle: value => [["borderInlineEndStyle", value]],
|
|
85
|
+
borderStartWidth: value => [["borderInlineStartWidth", value]],
|
|
86
|
+
borderEndWidth: value => [["borderInlineEndWidth", value]],
|
|
87
|
+
borderTopStartRadius: value => [["borderStartStartRadius", value]],
|
|
88
|
+
borderTopEndRadius: value => [["borderStartEndRadius", value]],
|
|
89
|
+
borderBottomStartRadius: value => [["borderEndStartRadius", value]],
|
|
90
|
+
borderBottomEndRadius: value => [["borderEndEndRadius", value]],
|
|
91
|
+
marginBlockStart: value => [["marginTop", value]],
|
|
92
|
+
marginBlockEnd: value => [["marginBottom", value]],
|
|
93
|
+
marginStart: value => [["marginInlineStart", value]],
|
|
94
|
+
marginEnd: value => [["marginInlineEnd", value]],
|
|
95
|
+
marginHorizontal: value => [["marginInline", value]],
|
|
96
|
+
marginVertical: value => [["marginBlock", value]],
|
|
97
|
+
paddingBlockStart: rawValue => [["paddingTop", rawValue]],
|
|
98
|
+
paddingBlockEnd: rawValue => [["paddingBottom", rawValue]],
|
|
99
|
+
paddingStart: value => [["paddingInlineStart", value]],
|
|
100
|
+
paddingEnd: value => [["paddingInlineEnd", value]],
|
|
101
|
+
paddingHorizontal: value => [["paddingInline", value]],
|
|
102
|
+
paddingVertical: value => [["paddingBlock", value]],
|
|
103
|
+
insetBlockStart: value => [["top", value]],
|
|
104
|
+
insetBlockEnd: value => [["bottom", value]],
|
|
105
|
+
start: value => [["insetInlineStart", value]],
|
|
106
|
+
end: value => [["insetInlineEnd", value]]
|
|
129
107
|
};
|
|
130
108
|
const expansions = {
|
|
131
109
|
...shorthands,
|
|
@@ -18,7 +18,7 @@ import type { TStyleValue } from '../common-types';
|
|
|
18
18
|
|
|
19
19
|
type TReturn = $ReadOnlyArray<[string, TStyleValue]>;
|
|
20
20
|
|
|
21
|
-
declare
|
|
21
|
+
declare const shorthands: {
|
|
22
22
|
all: (_: TStyleValue) => TReturn,
|
|
23
23
|
animation: (_value: TStyleValue) => TReturn,
|
|
24
24
|
background: (_value: TStyleValue) => TReturn,
|
|
@@ -35,7 +35,7 @@ declare var shorthands: {
|
|
|
35
35
|
padding: (rawValue: TStyleValue) => TReturn,
|
|
36
36
|
};
|
|
37
37
|
|
|
38
|
-
declare
|
|
38
|
+
declare const aliases: {
|
|
39
39
|
borderHorizontal: $FlowFixMe,
|
|
40
40
|
borderVertical: $FlowFixMe,
|
|
41
41
|
borderBlockStart: $FlowFixMe,
|
|
@@ -82,6 +82,7 @@ declare var aliases: {
|
|
|
82
82
|
end: (value: TStyleValue) => TReturn,
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
declare
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
declare export default $ReadOnly<{
|
|
86
|
+
...typeof shorthands,
|
|
87
|
+
...typeof aliases,
|
|
88
|
+
}>;
|
|
@@ -8,20 +8,29 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { StyleXOptions } from './common-types';
|
|
11
|
-
type VarsObject<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
type VarsObject<
|
|
12
|
+
Vars extends {
|
|
13
|
+
readonly [$$Key$$: string]:
|
|
14
|
+
| string
|
|
15
|
+
| { default: string; readonly [$$Key$$: string]: string };
|
|
16
|
+
},
|
|
17
|
+
> = Readonly</**
|
|
18
|
+
* > 15 | ...$ObjMapConst<Vars, string>,
|
|
19
|
+
* | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with complex spreads" is currently not supported.
|
|
20
|
+
**/
|
|
21
|
+
any>;
|
|
17
22
|
declare function styleXCreateVars<
|
|
18
|
-
Vars extends {
|
|
23
|
+
Vars extends {
|
|
24
|
+
readonly [$$Key$$: string]:
|
|
25
|
+
| string
|
|
26
|
+
| { default: string; readonly [$$Key$$: string]: string };
|
|
27
|
+
},
|
|
19
28
|
>(
|
|
20
29
|
variables: Vars,
|
|
21
30
|
options: Readonly<
|
|
22
31
|
Omit<Partial<StyleXOptions>, keyof ({ themeName: string })> & {
|
|
23
32
|
themeName: string;
|
|
24
33
|
}
|
|
25
|
-
|
|
34
|
+
>,
|
|
26
35
|
): [VarsObject<Vars>, { css: string }];
|
|
27
36
|
export default styleXCreateVars;
|