@stylexjs/shared 0.2.0-beta.8 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +81 -0
- package/lib/common-types.d.ts +50 -0
- package/lib/common-types.js.flow +65 -0
- package/lib/convert-to-className.d.ts +16 -0
- package/lib/convert-to-className.js +17 -26
- package/lib/convert-to-className.js.flow +23 -0
- package/lib/generate-css-rule.d.ts +17 -0
- package/lib/generate-css-rule.js +8 -47
- package/lib/generate-css-rule.js.flow +17 -0
- package/lib/hash.d.ts +11 -0
- package/lib/hash.js +3 -27
- package/lib/hash.js.flow +10 -0
- package/lib/index.d.ts +42 -85
- package/lib/index.js +19 -27
- package/lib/index.js.flow +59 -0
- package/lib/messages.d.ts +36 -0
- package/lib/messages.js +28 -55
- package/lib/messages.js.flow +39 -0
- package/lib/physical-rtl/generate-ltr.d.ts +11 -0
- package/lib/physical-rtl/generate-ltr.js +18 -46
- package/lib/physical-rtl/generate-ltr.js.flow +12 -0
- package/lib/physical-rtl/generate-rtl.d.ts +13 -0
- package/lib/physical-rtl/generate-rtl.js +18 -50
- package/lib/physical-rtl/generate-rtl.js.flow +12 -0
- package/lib/preprocess-rules/PreRule.d.ts +52 -0
- package/lib/preprocess-rules/PreRule.js +87 -0
- package/lib/preprocess-rules/PreRule.js.flow +64 -0
- package/lib/preprocess-rules/application-order.d.ts +290 -0
- package/lib/preprocess-rules/application-order.js +193 -0
- package/lib/preprocess-rules/application-order.js.flow +241 -0
- package/lib/preprocess-rules/basic-validation.d.ts +13 -0
- package/lib/preprocess-rules/basic-validation.js +83 -0
- package/lib/preprocess-rules/basic-validation.js.flow +13 -0
- package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +25 -0
- package/lib/preprocess-rules/flatten-raw-style-obj.js +120 -0
- package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +27 -0
- package/lib/preprocess-rules/index.d.ts +18 -0
- package/lib/preprocess-rules/index.js +30 -0
- package/lib/preprocess-rules/index.js.flow +19 -0
- package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +200 -0
- package/lib/preprocess-rules/legacy-expand-shorthands.js +136 -0
- package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +179 -0
- package/lib/preprocess-rules/property-specificity.d.ts +89 -0
- package/lib/preprocess-rules/property-specificity.js +107 -0
- package/lib/preprocess-rules/property-specificity.js.flow +98 -0
- 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-create-theme.d.ts +26 -0
- package/lib/stylex-create-theme.js +62 -0
- package/lib/stylex-create-theme.js.flow +19 -0
- package/lib/stylex-create.d.ts +23 -0
- package/lib/stylex-create.js +30 -142
- package/lib/stylex-create.js.flow +30 -0
- package/lib/stylex-define-vars.d.ts +36 -0
- package/lib/stylex-define-vars.js +72 -0
- package/lib/stylex-define-vars.js.flow +28 -0
- package/lib/stylex-first-that-works.d.ts +13 -0
- package/lib/stylex-first-that-works.js +0 -10
- package/lib/stylex-first-that-works.js.flow +12 -0
- package/lib/stylex-include.d.ts +18 -0
- package/lib/stylex-include.js +0 -10
- package/lib/stylex-include.js.flow +20 -0
- package/lib/stylex-keyframes.d.ts +17 -0
- package/lib/stylex-keyframes.js +22 -30
- package/lib/stylex-keyframes.js.flow +20 -0
- package/lib/transform-value.d.ts +22 -0
- package/lib/transform-value.js +9 -23
- package/lib/transform-value.js.flow +25 -0
- package/lib/types/index.d.ts +205 -0
- package/lib/types/index.js +191 -0
- package/lib/types/index.js.flow +241 -0
- package/lib/utils/Rule.d.ts +58 -0
- package/lib/utils/Rule.js +50 -0
- package/lib/utils/Rule.js.flow +64 -0
- package/lib/utils/dashify.d.ts +11 -0
- package/lib/utils/dashify.js +0 -8
- package/lib/utils/dashify.js.flow +10 -0
- package/lib/utils/default-options.d.ts +11 -0
- package/lib/utils/default-options.js +14 -0
- package/lib/utils/default-options.js.flow +25 -0
- package/lib/utils/file-based-identifier.d.ts +15 -0
- package/lib/utils/file-based-identifier.js +14 -0
- package/lib/utils/file-based-identifier.js.flow +14 -0
- package/lib/utils/genCSSRule.d.ts +15 -0
- package/lib/utils/genCSSRule.js +9 -18
- package/lib/utils/genCSSRule.js.flow +15 -0
- package/lib/utils/normalize-value.d.ts +16 -0
- package/lib/utils/normalize-value.js +11 -15
- package/lib/utils/normalize-value.js.flow +16 -0
- 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.d.ts +17 -0
- package/lib/utils/normalizers/detect-unclosed-fns.js +0 -12
- package/lib/utils/normalizers/detect-unclosed-fns.js.flow +16 -0
- package/lib/utils/normalizers/font-size-px-to-rem.d.ts +19 -0
- package/lib/utils/normalizers/font-size-px-to-rem.js +9 -19
- package/lib/utils/normalizers/font-size-px-to-rem.js.flow +18 -0
- package/lib/utils/normalizers/leading-zero.d.ts +17 -0
- package/lib/utils/normalizers/leading-zero.js +0 -12
- package/lib/utils/normalizers/leading-zero.js.flow +16 -0
- package/lib/utils/normalizers/quotes.d.ts +18 -0
- package/lib/utils/normalizers/quotes.js +0 -13
- package/lib/utils/normalizers/quotes.js.flow +17 -0
- package/lib/utils/normalizers/timings.d.ts +18 -0
- package/lib/utils/normalizers/timings.js +0 -14
- package/lib/utils/normalizers/timings.js.flow +17 -0
- package/lib/utils/normalizers/whitespace.d.ts +19 -0
- package/lib/utils/normalizers/whitespace.js +0 -15
- package/lib/utils/normalizers/whitespace.js.flow +18 -0
- package/lib/utils/normalizers/zero-dimensions.d.ts +19 -0
- package/lib/utils/normalizers/zero-dimensions.js +0 -15
- package/lib/utils/normalizers/zero-dimensions.js.flow +18 -0
- package/lib/utils/object-utils.d.ts +66 -0
- package/lib/utils/object-utils.js +21 -13
- package/lib/utils/object-utils.js.flow +77 -0
- package/lib/utils/property-priorities.d.ts +11 -0
- package/lib/utils/property-priorities.js +531 -0
- package/lib/utils/property-priorities.js.flow +10 -0
- package/lib/utils/split-css-value.d.ts +14 -0
- package/lib/utils/split-css-value.js +33 -0
- package/lib/utils/split-css-value.js.flow +15 -0
- package/lib/validate.d.ts +12 -0
- package/lib/validate.js +1 -10
- package/lib/validate.js.flow +12 -0
- package/package.json +4 -5
- package/lib/expand-shorthands.d.ts +0 -5
- package/lib/expand-shorthands.js +0 -387
- package/lib/stylex-defaultValue.js +0 -397
@@ -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
|
+
import type { TStyleValue } from '../common-types';
|
11
|
+
declare function splitValue(
|
12
|
+
str: TStyleValue,
|
13
|
+
): ReadonlyArray<number | string | null>;
|
14
|
+
export default splitValue;
|
@@ -0,0 +1,33 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = splitValue;
|
7
|
+
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
8
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
function printNode(node) {
|
10
|
+
switch (node.type) {
|
11
|
+
case 'word':
|
12
|
+
case 'string':
|
13
|
+
return `${node.value}`;
|
14
|
+
case 'function':
|
15
|
+
return `${node.value}(${node.nodes.map(printNode).join('')})`;
|
16
|
+
default:
|
17
|
+
return node.value;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
function splitValue(str) {
|
21
|
+
if (str == null || typeof str === 'number') {
|
22
|
+
return [str];
|
23
|
+
}
|
24
|
+
if (Array.isArray(str)) {
|
25
|
+
return str;
|
26
|
+
}
|
27
|
+
const parsed = (0, _postcssValueParser.default)(str.trim());
|
28
|
+
const nodes = parsed.nodes.filter(node => node.type !== 'space' && node.type !== 'div').map(printNode);
|
29
|
+
if (nodes.length > 1 && nodes[nodes.length - 1].toLowerCase() === '!important') {
|
30
|
+
return nodes.slice(0, nodes.length - 1).map(node => node + ' !important');
|
31
|
+
}
|
32
|
+
return nodes;
|
33
|
+
}
|
@@ -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
|
+
* @flow strict
|
8
|
+
*/
|
9
|
+
|
10
|
+
import type { TStyleValue } from '../common-types';
|
11
|
+
|
12
|
+
// Using split(' ') Isn't enough bcause of values like calc.
|
13
|
+
declare export default function splitValue(
|
14
|
+
str: TStyleValue,
|
15
|
+
): $ReadOnlyArray<number | string | null>;
|
@@ -0,0 +1,12 @@
|
|
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
|
+
import type { TRawValue } from './common-types';
|
11
|
+
declare function validateEntry($$PARAM_0$$: [string, TRawValue]): void;
|
12
|
+
export default validateEntry;
|
package/lib/validate.js
CHANGED
@@ -4,15 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = validateEntry;
|
7
|
-
/**
|
8
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
9
|
-
*
|
10
|
-
* This source code is licensed under the MIT license found in the
|
11
|
-
* LICENSE file in the root directory of this source tree.
|
12
|
-
*
|
13
|
-
*
|
14
|
-
*/
|
15
|
-
|
16
7
|
function validateEntry(_ref) {
|
17
8
|
let [key, value] = _ref;
|
18
9
|
if (Array.isArray(value)) {
|
@@ -22,7 +13,7 @@ function validateEntry(_ref) {
|
|
22
13
|
}
|
23
14
|
}
|
24
15
|
function validateSimplyEntry(_ref2) {
|
25
|
-
let [key,
|
16
|
+
let [key, _value] = _ref2;
|
26
17
|
if (BANNED_KEYS.has(key)) {
|
27
18
|
throw new Error('Banned key: ' + key);
|
28
19
|
}
|
@@ -0,0 +1,12 @@
|
|
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
|
+
import type { TRawValue } from './common-types';
|
11
|
+
|
12
|
+
declare export default function validateEntry([string, TRawValue]): void;
|
package/package.json
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
{
|
2
2
|
"name": "@stylexjs/shared",
|
3
|
-
"version": "0.
|
4
|
-
"description": "Shared Code for Stylex compile and runtime.",
|
3
|
+
"version": "0.3.0",
|
5
4
|
"main": "lib/index.js",
|
6
|
-
"repository": "https://www.github.com/
|
7
|
-
"author": "Naman Goel <nmn@fb.com>",
|
5
|
+
"repository": "https://www.github.com/facebook/stylex",
|
8
6
|
"license": "MIT",
|
9
7
|
"scripts": {
|
8
|
+
"prebuild": "gen-types -i src/ -o lib/",
|
10
9
|
"build": "babel src/ --out-dir lib/ --copy-files",
|
11
10
|
"test": "jest"
|
12
11
|
},
|
@@ -14,7 +13,7 @@
|
|
14
13
|
"postcss-value-parser": "^4.1.0"
|
15
14
|
},
|
16
15
|
"devDependencies": {
|
17
|
-
"
|
16
|
+
"@stylexjs/scripts": "0.3.0"
|
18
17
|
},
|
19
18
|
"jest": {
|
20
19
|
"snapshotFormat": {
|
package/lib/expand-shorthands.js
DELETED
@@ -1,387 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
4
|
-
value: true
|
5
|
-
});
|
6
|
-
exports.BANNED_PROPERTIES = void 0;
|
7
|
-
exports.default = flatMapExpandedShorthands;
|
8
|
-
exports.expandedKeys = void 0;
|
9
|
-
var _postcssValueParser = _interopRequireDefault(require("postcss-value-parser"));
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
11
|
-
/**
|
12
|
-
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
13
|
-
*
|
14
|
-
* This source code is licensed under the MIT license found in the
|
15
|
-
* LICENSE file in the root directory of this source tree.
|
16
|
-
*
|
17
|
-
*
|
18
|
-
*/
|
19
|
-
|
20
|
-
function printNode(node) {
|
21
|
-
switch (node.type) {
|
22
|
-
case 'word':
|
23
|
-
case 'string':
|
24
|
-
return `${node.value}`;
|
25
|
-
case 'function':
|
26
|
-
return `${node.value}(${node.nodes.map(printNode).join('')})`;
|
27
|
-
default:
|
28
|
-
return node.value;
|
29
|
-
}
|
30
|
-
}
|
31
|
-
|
32
|
-
// Using split(' ') Isn't enough bcause of values like calc.
|
33
|
-
function splitValue(str) {
|
34
|
-
if (Array.isArray(str)) {
|
35
|
-
return str;
|
36
|
-
}
|
37
|
-
const parsed = (0, _postcssValueParser.default)(str.trim());
|
38
|
-
const nodes = parsed.nodes.filter(node => node.type !== 'space' && node.type !== 'div').map(printNode);
|
39
|
-
if (nodes.length > 1 && nodes[nodes.length - 1].toLowerCase() === '!important') {
|
40
|
-
return nodes.slice(0, nodes.length - 1).map(node => node + ' !important');
|
41
|
-
}
|
42
|
-
return nodes;
|
43
|
-
}
|
44
|
-
|
45
|
-
// TODO: to be added later.
|
46
|
-
// const aliases = {
|
47
|
-
// marginInlineStart: (rawValue) => [['marginStart', rawValue]],
|
48
|
-
// marginInlineEnd: (rawValue) => [['marginEnd', rawValue]],
|
49
|
-
// marginInline: (rawValue) => [
|
50
|
-
// ['marginStart', rawValue],
|
51
|
-
// ['marginEnd', rawValue],
|
52
|
-
// ],
|
53
|
-
// paddingInlineStart: (rawValue) => [['paddingStart', rawValue]],
|
54
|
-
// paddingInlineEnd: (rawValue) => [['paddingEnd', rawValue]],
|
55
|
-
// paddingInline: (rawValue) => [
|
56
|
-
// ['paddingStart', rawValue],
|
57
|
-
// ['paddingEnd', rawValue],
|
58
|
-
// ],
|
59
|
-
// // 'borderInlineStart': (rawValue) => [['borderStart', rawValue]],
|
60
|
-
// // 'borderInlineEnd': (rawValue) => [['borderEnd', rawValue]],
|
61
|
-
// // // This will need to change.
|
62
|
-
// // 'borderInline': (rawValue) => [
|
63
|
-
// // ['borderStart', rawValue],
|
64
|
-
// // ['borderEnd', rawValue],
|
65
|
-
// // ],
|
66
|
-
// };
|
67
|
-
|
68
|
-
/**
|
69
|
-
* Shorthand properties:
|
70
|
-
* - [!] all - BANNED
|
71
|
-
* - [!] animation - BANNED
|
72
|
-
* - [!] background - BANNED
|
73
|
-
* - [x] border - Expanded to border-{direction}. Not to border-*-(width|style|color).
|
74
|
-
* This is to limit the number of atoms to 4 instead of 12.
|
75
|
-
* - [o] border-top - Only the shorthand is allowed.
|
76
|
-
* - [o] border-end - Only the shorthand is allowed.
|
77
|
-
* - [o] border-bottom - Only the shorthand is allowed.
|
78
|
-
* - [o] border-start - Only the shorthand is allowed.
|
79
|
-
* - [!] border-left - BANNED
|
80
|
-
* - [!] border-right
|
81
|
-
* - [!] border-*-width - BANNED
|
82
|
-
* - [!] border-*-style - BANNED
|
83
|
-
* - [!] border-*-color - BANNED
|
84
|
-
* - [ ] border-block-end
|
85
|
-
* - [ ] border-block-start
|
86
|
-
* - [ ] border-inline-start
|
87
|
-
* - [ ] border-inline-end
|
88
|
-
* - [!] border-image - BANNED
|
89
|
-
* - [x] border-radius
|
90
|
-
* - [o] column-rule - Only the shorthand is allowed.
|
91
|
-
* - [!] columns - BANNED
|
92
|
-
* - [!] flex - BANNED
|
93
|
-
* - [!] flex-flow - BANNED
|
94
|
-
* - [!] font - BANNED
|
95
|
-
* - [x] gap
|
96
|
-
* - [!] grid - BANNED
|
97
|
-
* - [!] grid-area - BANNED
|
98
|
-
* - [!] grid-column - BANNED
|
99
|
-
* - [!] grid-row - BANNED
|
100
|
-
* - [!] grid-template - BANNED
|
101
|
-
* - [!] grid-template-areas - BANNED
|
102
|
-
*
|
103
|
-
* - [o] list-style - Only the shorthand is allowed.
|
104
|
-
* - [x] margin
|
105
|
-
* - [o] mask - Only the shorthand is allowed.
|
106
|
-
* - [o] offset - Only the shorthand is allowed.
|
107
|
-
* - [o] outline - Only the shorthand is allowed.
|
108
|
-
* - [x] overflow
|
109
|
-
* - [x] padding
|
110
|
-
* - [x] place-content
|
111
|
-
* - [x] place-items
|
112
|
-
* - [x] place-self
|
113
|
-
* - [X] scroll-margin
|
114
|
-
* - [x] scroll-padding
|
115
|
-
* - [o] text-decoration - Only the shorthand is allowed.
|
116
|
-
* - [o] text-emphasis - Only the shorthand is allowed.
|
117
|
-
* - [!] transition - BANNED
|
118
|
-
*/
|
119
|
-
|
120
|
-
const BANNED_PROPERTIES = {
|
121
|
-
all: '`all` is not supported. Use individual properties instead.',
|
122
|
-
animation: '`animation` is not supported. Use individual properties like `animationName`, `animationDuration`, etc. instead.',
|
123
|
-
background: '`background` is not supported. Use individual properties like `backgroundImage`, `backgroundPosition`, etc. instead.',
|
124
|
-
borderColor: '`borderColor` is not supported. Use `border`, `borderTop`, `borderEnd`, `borderBottom` or `borderStart` instead.',
|
125
|
-
borderStyle: '`borderStyle` is not supported. Use `border`, `borderTop`, `borderEnd`, `borderBottom` or `borderStart` instead.',
|
126
|
-
borderWidth: '`borderWidth` is not supported. Use `border`, `borderTop`, `borderEnd`, `borderBottom` or `borderStart` instead.',
|
127
|
-
borderTopColor: '`borderTopColor` is not supported. Use `borderTop` instead.',
|
128
|
-
borderTopStyle: '`borderTopStyle` is not supported. Use `borderTop` instead.',
|
129
|
-
borderTopWidth: '`borderTopWidth` is not supported. Use `borderTop` instead.',
|
130
|
-
borderEndColor: '`borderEndColor` is not supported. Use `borderEnd` instead.',
|
131
|
-
borderEndStyle: '`borderEndStyle` is not supported. Use `borderEnd` instead.',
|
132
|
-
borderEndWidth: '`borderEndWidth` is not supported. Use `borderEnd` instead.',
|
133
|
-
borderBottomColor: '`borderBottomColor` is not supported. Use `borderBottom` instead.',
|
134
|
-
borderBottomStyle: '`borderBottomStyle` is not supported. Use `borderBottom` instead.',
|
135
|
-
borderBottomWidth: '`borderBottomWidth` is not supported. Use `borderBottom` instead.',
|
136
|
-
borderStartColor: '`borderStartColor` is not supported. Use `borderStart` instead.',
|
137
|
-
borderStartStyle: '`borderStartStyle` is not supported. Use `borderStart` instead.',
|
138
|
-
borderStartWidth: '`borderStartWidth` is not supported. Use `borderStart` instead.',
|
139
|
-
borderBlockStartColor: '`borderBlockStartColor` is not supported. Use `borderTop` instead.',
|
140
|
-
borderBlockStartStyle: '`borderBlockStartStyle` is not supported. Use `borderTop` instead.',
|
141
|
-
borderBlockStartWidth: '`borderBlockStartWidth` is not supported. Use `borderTop` instead.',
|
142
|
-
borderBlockEndColor: '`borderBlockEndColor` is not supported. Use `borderBottom` instead.',
|
143
|
-
borderBlockEndStyle: '`borderBlockEndStyle` is not supported. Use `borderBottom` instead.',
|
144
|
-
borderBlockEndWidth: '`borderBlockEndWidth` is not supported. Use `borderBottom` instead.',
|
145
|
-
borderInlineStartColor: '`borderInlineStartColor` is not supported. Use `borderStart` instead.',
|
146
|
-
borderInlineStartStyle: '`borderInlineStartStyle` is not supported. Use `borderStart` instead.',
|
147
|
-
borderInlineStartWidth: '`borderInlineStartWidth` is not supported. Use `borderStart` instead.',
|
148
|
-
borderInlineEndColor: '`borderInlineEndColor` is not supported. Use `borderEnd` instead.',
|
149
|
-
borderInlineEndStyle: '`borderInlineEndStyle` is not supported. Use `borderEnd` instead.',
|
150
|
-
borderInlineEndWidth: '`borderInlineEndWidth` is not supported. Use `borderEnd` instead.',
|
151
|
-
borderLeft: '`borderLeft` is not supported. Use `borderStart` instead.',
|
152
|
-
borderLeftColor: '`borderLeftColor` is not supported. Use `borderStart` instead.',
|
153
|
-
borderLeftStyle: '`borderLeftStyle` is not supported. Use `borderStart` instead.',
|
154
|
-
borderLeftWidth: '`borderLeftWidth` is not supported. Use `borderStart` instead.',
|
155
|
-
borderRight: '`borderRight` is not supported. Use `borderEnd` instead.',
|
156
|
-
borderRightColor: '`borderRightColor` is not supported. Use `borderEnd` instead.',
|
157
|
-
borderRightStyle: '`borderRightStyle` is not supported. Use `borderEnd` instead.',
|
158
|
-
borderRightWidth: '`borderRightWidth` is not supported. Use `borderEnd` instead.',
|
159
|
-
borderTopLeftRadius: '`borderTopLeftRadius` is not supported. Use `borderTopStartRadius` instead.',
|
160
|
-
borderTopRightRadius: '`borderTopRightRadius` is not supported. Use `borderTopEndRadius` instead.',
|
161
|
-
borderBottomLeftRadius: '`borderBottomLeftRadius` is not supported. Use `borderBottomStartRadius` instead.',
|
162
|
-
borderBottomRightRadius: '`borderBottomRightRadius` is not supported. Use `borderBottomEndRadius` instead.',
|
163
|
-
borderImageSource: '`borderImageSource` is not supported. Use `borderImage` instead.',
|
164
|
-
borderImageSlice: '`borderImageSlice` is not supported. Use `borderImage` instead.',
|
165
|
-
borderImageWidth: '`borderImageWidth` is not supported. Use `borderImage` instead.',
|
166
|
-
borderImageOutset: '`borderImageOutset` is not supported. Use `borderImage` instead.',
|
167
|
-
borderImageRepeat: '`borderImageRepeat` is not supported. Use `borderImage` instead.',
|
168
|
-
marginLeft: '`marginLeft` is not supported. Use `marginStart` instead.',
|
169
|
-
marginRight: '`marginRight` is not supported. Use `marginEnd` instead.',
|
170
|
-
paddingLeft: '`paddingLeft` is not supported. Use `paddingStart` instead.',
|
171
|
-
paddingRight: '`paddingRight` is not supported. Use `paddingEnd` instead.',
|
172
|
-
columnRuleWidth: '`columnRuleWidth` is not supported. Use `columnRule` instead.',
|
173
|
-
columnRuleStyle: '`columnRuleStyle` is not supported. Use `columnRule` instead.',
|
174
|
-
columnRuleColor: '`columnRuleColor` is not supported. Use `columnRule` instead.',
|
175
|
-
columns: '`columns` is not supported. Use `columnCount` and `columnWidth` instead.',
|
176
|
-
flex: '`flex` is not supported. Use `flexGrow`, `flexShrink`, and `flexBasis` instead.',
|
177
|
-
flexFlow: '`flexFlow` is not supported. Use `flexDirection` and `flexWrap` instead.',
|
178
|
-
font: '`font` is not supported. Use individual properties like `fontFamily`, `fontSize`, etc. instead.',
|
179
|
-
grid: '`grid` is not supported. Use individual properties like `gridTemplateColumns`, `gridTemplateRows`, etc. instead.',
|
180
|
-
gridColumn: '`gridColumn` is not supported. Use `gridColumnStart` and `gridColumnEnd` instead.',
|
181
|
-
gridRow: '`gridRow` is not supported. Use `gridRowStart` and `gridRowEnd` instead.',
|
182
|
-
gridArea: '`gridArea` is not supported. Use `gridRowStart`, `gridColumnStart`, `gridRowEnd`, and `gridColumnEnd` instead.',
|
183
|
-
gridTemplate: '`gridTemplate` is not supported. Use individual properties like `gridTemplateColumns`, `gridTemplateRows`, etc. instead.',
|
184
|
-
gridTemplateAreas: '`gridTemplateAreas` is not supported. Use `gridTemplateRows` and `gridTemplateColumns` instead.',
|
185
|
-
listStyleImage: '`listStyleImage` is not supported. Use `listStyle` instead.',
|
186
|
-
listStylePosition: '`listStylePosition` is not supported. Use `listStyle` instead.',
|
187
|
-
listStyleType: '`listStyleType` is not supported. Use `listStyle` instead.',
|
188
|
-
maskClip: '`maskClip` is not supported. Use `mask` instead.',
|
189
|
-
maskComposite: '`maskComposite` is not supported. Use `mask` instead.',
|
190
|
-
maskImage: '`maskImage` is not supported. Use `mask` instead.',
|
191
|
-
maskMode: '`maskMode` is not supported. Use `mask` instead.',
|
192
|
-
maskOrigin: '`maskOrigin` is not supported. Use `mask` instead.',
|
193
|
-
maskPosition: '`maskPosition` is not supported. Use `mask` instead.',
|
194
|
-
maskRepeat: '`maskRepeat` is not supported. Use `mask` instead.',
|
195
|
-
maskSize: '`maskSize` is not supported. Use `mask` instead.',
|
196
|
-
offsetAnchor: '`offsetAnchor` is not supported. Use `offset` instead.',
|
197
|
-
offsetDistance: '`offsetDistance` is not supported. Use `offset` instead.',
|
198
|
-
offsetPath: '`offsetPath` is not supported. Use `offset` instead.',
|
199
|
-
offsetPosition: '`offsetPosition` is not supported. Use `offset` instead.',
|
200
|
-
offsetRotate: '`offsetRotate` is not supported. Use `offset` instead.',
|
201
|
-
outlineColor: '`outlineColor` is not supported. Use `outline` instead.',
|
202
|
-
outlineStyle: '`outlineStyle` is not supported. Use `outline` instead.',
|
203
|
-
outlineWidth: '`outlineWidth` is not supported. Use `outline` instead.',
|
204
|
-
textDecorationColor: '`textDecorationColor` is not supported. Use `textDecoration` instead.',
|
205
|
-
textDecorationLine: '`textDecorationLine` is not supported. Use `textDecoration` instead.',
|
206
|
-
textDecorationStyle: '`textDecorationStyle` is not supported. Use `textDecoration` instead.',
|
207
|
-
textDecorationThickness: '`textDecorationThickness` is not supported. Use `textDecoration` instead.',
|
208
|
-
textEmphasisColor: '`textEmphasisColor` is not supported. Use `textEmphasis` instead.',
|
209
|
-
textEmphasisStyle: '`textEmphasisStyle` is not supported. Use `textEmphasis` instead.',
|
210
|
-
transition: '`transition` is not supported. Use individual properties like `transitionProperty`, `transitionDuration`, etc. instead.'
|
211
|
-
};
|
212
|
-
exports.BANNED_PROPERTIES = BANNED_PROPERTIES;
|
213
|
-
const expansions = {
|
214
|
-
border: rawValue => {
|
215
|
-
return [['borderTop', rawValue], ['borderEnd', rawValue], ['borderBottom', rawValue], ['borderStart', rawValue]];
|
216
|
-
},
|
217
|
-
// border: (rawValue: string) => {
|
218
|
-
// if (typeof rawValue === 'number') {
|
219
|
-
// return expansions.borderWidth(rawValue);
|
220
|
-
// }
|
221
|
-
// const [width, style, color, more] = splitValue(rawValue);
|
222
|
-
// if (more != null) {
|
223
|
-
// throw new Error(messages.MULTIPLE_DIRECTIONS_IN_SHORTHAND);
|
224
|
-
// }
|
225
|
-
// if (style == null || color == null) {
|
226
|
-
// throw new Error(
|
227
|
-
// 'Border shorthand requires at least 2 values - width, style and color.'
|
228
|
-
// );
|
229
|
-
// }
|
230
|
-
// return [
|
231
|
-
// ...expansions.borderWidth(width),
|
232
|
-
// ...expansions.borderStyle(style),
|
233
|
-
// ...expansions.borderColor(color),
|
234
|
-
// ];
|
235
|
-
// },
|
236
|
-
// borderTop: (rawValue: string) => {
|
237
|
-
// if (typeof rawValue === 'number') {
|
238
|
-
// return [['borderTopWidth', rawValue + 'px']];
|
239
|
-
// }
|
240
|
-
// const [width, style, color] = splitValue(rawValue);
|
241
|
-
// if (style == null || color == null) {
|
242
|
-
// throw new Error(
|
243
|
-
// 'BorderTop shorthand requires at least 2 values - width, style and color.'
|
244
|
-
// );
|
245
|
-
// }
|
246
|
-
// return [
|
247
|
-
// ['borderTopWidth', width],
|
248
|
-
// ['borderTopStyle', style],
|
249
|
-
// ['borderTopColor', color],
|
250
|
-
// ];
|
251
|
-
// },
|
252
|
-
// borderEnd: (rawValue: string) => {
|
253
|
-
// if (typeof rawValue === 'number') {
|
254
|
-
// return [['borderEndWidth', rawValue + 'px']];
|
255
|
-
// }
|
256
|
-
// const [width, style, color] = splitValue(rawValue);
|
257
|
-
// if (style == null || color == null) {
|
258
|
-
// throw new Error(
|
259
|
-
// 'BorderEnd shorthand requires at least 2 values - width, style and color.'
|
260
|
-
// );
|
261
|
-
// }
|
262
|
-
// return [
|
263
|
-
// ['borderEndWidth', width],
|
264
|
-
// ['borderEndStyle', style],
|
265
|
-
// ['borderEndColor', color],
|
266
|
-
// ];
|
267
|
-
// },
|
268
|
-
// borderBottom: (rawValue: string) => {
|
269
|
-
// if (typeof rawValue === 'number') {
|
270
|
-
// return [['borderBottomWidth', rawValue + 'px']];
|
271
|
-
// }
|
272
|
-
// const [width, style, color] = splitValue(rawValue);
|
273
|
-
// if (style == null || color == null) {
|
274
|
-
// throw new Error(
|
275
|
-
// 'BorderBottom shorthand requires at least 2 values - width, style and color.'
|
276
|
-
// );
|
277
|
-
// }
|
278
|
-
// return [
|
279
|
-
// ['borderBottomWidth', width],
|
280
|
-
// ['borderBottomStyle', style],
|
281
|
-
// ['borderBottomColor', color],
|
282
|
-
// ];
|
283
|
-
// },
|
284
|
-
// borderStart: (rawValue: string) => {
|
285
|
-
// if (typeof rawValue === 'number') {
|
286
|
-
// return [['borderStartWidth', rawValue + 'px']];
|
287
|
-
// }
|
288
|
-
// const [width, style, color] = splitValue(rawValue);
|
289
|
-
// if (style == null || color == null) {
|
290
|
-
// throw new Error(
|
291
|
-
// 'BorderStart shorthand requires at least 2 values - width, style and color.'
|
292
|
-
// );
|
293
|
-
// }
|
294
|
-
// return [
|
295
|
-
// ['borderStartWidth', width],
|
296
|
-
// ['borderStartStyle', style],
|
297
|
-
// ['borderStartColor', color],
|
298
|
-
// ];
|
299
|
-
// },
|
300
|
-
borderColor: rawValue => {
|
301
|
-
const [top, right = top, bottom = top, left = right] = splitValue(rawValue);
|
302
|
-
return [['borderTopColor', top], ['borderEndColor', right], ['borderBottomColor', bottom], ['borderStartColor', left]];
|
303
|
-
},
|
304
|
-
borderHorizontal: rawValue => {
|
305
|
-
return [['borderStart', rawValue], ['borderEnd', rawValue]];
|
306
|
-
},
|
307
|
-
borderStyle: rawValue => {
|
308
|
-
const [top, right = top, bottom = top, left = right] = splitValue(rawValue);
|
309
|
-
return [['borderTopStyle', top], ['borderEndStyle', right], ['borderBottomStyle', bottom], ['borderStartStyle', left]];
|
310
|
-
},
|
311
|
-
borderVertical: rawValue => {
|
312
|
-
return [['borderTop', rawValue], ['borderBottom', rawValue]];
|
313
|
-
},
|
314
|
-
borderWidth: rawValue => {
|
315
|
-
const [top, right = top, bottom = top, left = right] = typeof rawValue === 'number' ? [rawValue] : splitValue(rawValue);
|
316
|
-
return [['borderTopWidth', top], ['borderEndWidth', right], ['borderBottomWidth', bottom], ['borderStartWidth', left]];
|
317
|
-
},
|
318
|
-
borderRadius: rawValue => {
|
319
|
-
const [top, right = top, bottom = top, left = right] = typeof rawValue === 'string' ? splitValue(rawValue) : typeof rawValue === 'number' ? [rawValue] : rawValue; // remove
|
320
|
-
|
321
|
-
return [['borderTopStartRadius', top], ['borderTopEndRadius', right], ['borderBottomEndRadius', bottom], ['borderBottomStartRadius', left]];
|
322
|
-
},
|
323
|
-
margin: rawValue => {
|
324
|
-
const [top, right = top, bottom = top, left = right] = typeof rawValue === 'number' ? [rawValue] : splitValue(rawValue);
|
325
|
-
return [['marginTop', top], ['marginEnd', right], ['marginBottom', bottom], ['marginStart', left]];
|
326
|
-
},
|
327
|
-
marginHorizontal: rawValue => {
|
328
|
-
return [['marginStart', rawValue], ['marginEnd', rawValue]];
|
329
|
-
},
|
330
|
-
marginVertical: rawValue => {
|
331
|
-
return [['marginTop', rawValue], ['marginBottom', rawValue]];
|
332
|
-
},
|
333
|
-
overflow: rawValue => {
|
334
|
-
const [x, y = x] = splitValue(rawValue);
|
335
|
-
return [['overflowX', x], ['overflowY', y]];
|
336
|
-
},
|
337
|
-
padding: rawValue => {
|
338
|
-
const [top, right = top, bottom = top, left = right] = typeof rawValue === 'number' ? [rawValue] : splitValue(rawValue);
|
339
|
-
return [['paddingTop', top], ['paddingEnd', right], ['paddingBottom', bottom], ['paddingStart', left]];
|
340
|
-
},
|
341
|
-
paddingHorizontal: rawValue => {
|
342
|
-
return [['paddingStart', rawValue], ['paddingEnd', rawValue]];
|
343
|
-
},
|
344
|
-
paddingVertical: rawValue => {
|
345
|
-
return [['paddingTop', rawValue], ['paddingBottom', rawValue]];
|
346
|
-
},
|
347
|
-
gap: rawValue => {
|
348
|
-
if (typeof rawValue === 'number') {
|
349
|
-
return [['rowGap', rawValue], ['columnGap', rawValue]];
|
350
|
-
}
|
351
|
-
const [row, column = row] = splitValue(rawValue);
|
352
|
-
return [['rowGap', row], ['columnGap', column]];
|
353
|
-
},
|
354
|
-
placeContent: rawValue => {
|
355
|
-
const [align, justify = align] = splitValue(rawValue);
|
356
|
-
return [['alignContent', align], ['justifyContent', justify]];
|
357
|
-
},
|
358
|
-
placeItems: rawValue => {
|
359
|
-
const [align, justify = align] = splitValue(rawValue);
|
360
|
-
return [['alignItems', align], ['justifyItems', justify]];
|
361
|
-
},
|
362
|
-
placeSelf: rawValue => {
|
363
|
-
const [align, justify = align] = splitValue(rawValue);
|
364
|
-
return [['alignSelf', align], ['justifySelf', justify]];
|
365
|
-
},
|
366
|
-
scrollMargin: rawValue => {
|
367
|
-
const [top, right = top, bottom = top, left = right] = typeof rawValue === 'number' ? [rawValue] : splitValue(rawValue);
|
368
|
-
return [['scrollMarginTop', top], ['scrollMarginEnd', right], ['scrollMarginBottom', bottom], ['scrollMarginStart', left]];
|
369
|
-
},
|
370
|
-
scrollPadding: rawValue => {
|
371
|
-
const [top, right = top, bottom = top, left = right] = typeof rawValue === 'number' ? [rawValue] : splitValue(rawValue);
|
372
|
-
return [['scrollPaddingTop', top], ['scrollPaddingEnd', right], ['scrollPaddingBottom', bottom], ['scrollPaddingStart', left]];
|
373
|
-
}
|
374
|
-
};
|
375
|
-
const expandedKeys = [...Object.keys(expansions), ...Object.keys(BANNED_PROPERTIES)];
|
376
|
-
exports.expandedKeys = expandedKeys;
|
377
|
-
function flatMapExpandedShorthands(objEntry) {
|
378
|
-
const [key, value] = objEntry;
|
379
|
-
const expansion = expansions[key];
|
380
|
-
if (expansion) {
|
381
|
-
if (Array.isArray(value)) {
|
382
|
-
throw new Error('Cannot use fallbacks for shorthands. Use the expansion instead.');
|
383
|
-
}
|
384
|
-
return expansion(value);
|
385
|
-
}
|
386
|
-
return [objEntry];
|
387
|
-
}
|