@stylexjs/shared 0.12.0 → 0.17.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/index.d.ts +18 -36
- package/lib/index.js +8 -25
- package/lib/index.js.flow +10 -43
- package/lib/utils/property-priorities.d.ts +7 -0
- package/lib/utils/property-priorities.js +54 -8
- package/lib/utils/property-priorities.js.flow +8 -0
- package/package.json +5 -21
- package/README.md +0 -81
- package/lib/common-types.d.ts +0 -50
- package/lib/common-types.js +0 -1
- package/lib/common-types.js.flow +0 -63
- package/lib/convert-to-className.d.ts +0 -20
- package/lib/convert-to-className.js +0 -66
- package/lib/convert-to-className.js.flow +0 -27
- package/lib/generate-css-rule.d.ts +0 -17
- package/lib/generate-css-rule.js +0 -25
- package/lib/generate-css-rule.js.flow +0 -17
- package/lib/hash.d.ts +0 -12
- package/lib/hash.js +0 -50
- package/lib/hash.js.flow +0 -12
- package/lib/messages.d.ts +0 -42
- package/lib/messages.js +0 -39
- package/lib/messages.js.flow +0 -45
- package/lib/physical-rtl/generate-ltr.d.ts +0 -13
- package/lib/physical-rtl/generate-ltr.js +0 -103
- package/lib/physical-rtl/generate-ltr.js.flow +0 -12
- package/lib/physical-rtl/generate-rtl.d.ts +0 -13
- package/lib/physical-rtl/generate-rtl.js +0 -177
- package/lib/physical-rtl/generate-rtl.js.flow +0 -12
- package/lib/preprocess-rules/PreRule.d.ts +0 -50
- package/lib/preprocess-rules/PreRule.js +0 -76
- package/lib/preprocess-rules/PreRule.js.flow +0 -62
- package/lib/preprocess-rules/application-order.d.ts +0 -183
- package/lib/preprocess-rules/application-order.js +0 -186
- package/lib/preprocess-rules/application-order.js.flow +0 -134
- package/lib/preprocess-rules/basic-validation.d.ts +0 -13
- package/lib/preprocess-rules/basic-validation.js +0 -73
- package/lib/preprocess-rules/basic-validation.js.flow +0 -13
- package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +0 -20
- package/lib/preprocess-rules/flatten-raw-style-obj.js +0 -98
- package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +0 -23
- package/lib/preprocess-rules/index.d.ts +0 -18
- package/lib/preprocess-rules/index.js +0 -33
- package/lib/preprocess-rules/index.js.flow +0 -22
- package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +0 -165
- package/lib/preprocess-rules/legacy-expand-shorthands.js +0 -147
- package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +0 -144
- package/lib/preprocess-rules/property-specificity.d.ts +0 -78
- package/lib/preprocess-rules/property-specificity.js +0 -107
- package/lib/preprocess-rules/property-specificity.js.flow +0 -87
- package/lib/stylex-consts-utils.d.ts +0 -11
- package/lib/stylex-consts-utils.js +0 -1
- package/lib/stylex-consts-utils.js.flow +0 -14
- package/lib/stylex-create-theme.d.ts +0 -26
- package/lib/stylex-create-theme.js +0 -58
- package/lib/stylex-create-theme.js.flow +0 -19
- package/lib/stylex-create.d.ts +0 -27
- package/lib/stylex-create.js +0 -64
- package/lib/stylex-create.js.flow +0 -37
- package/lib/stylex-define-consts.d.ts +0 -23
- package/lib/stylex-define-consts.js +0 -42
- package/lib/stylex-define-consts.js.flow +0 -18
- package/lib/stylex-define-vars.d.ts +0 -28
- package/lib/stylex-define-vars.js +0 -96
- package/lib/stylex-define-vars.js.flow +0 -27
- package/lib/stylex-first-that-works.d.ts +0 -13
- package/lib/stylex-first-that-works.js +0 -26
- package/lib/stylex-first-that-works.js.flow +0 -12
- package/lib/stylex-include.d.ts +0 -18
- package/lib/stylex-include.js +0 -28
- package/lib/stylex-include.js.flow +0 -20
- package/lib/stylex-keyframes.d.ts +0 -17
- package/lib/stylex-keyframes.js +0 -55
- package/lib/stylex-keyframes.js.flow +0 -20
- package/lib/stylex-vars-utils.d.ts +0 -27
- package/lib/stylex-vars-utils.js +0 -69
- package/lib/stylex-vars-utils.js.flow +0 -31
- package/lib/transform-value.d.ts +0 -22
- package/lib/transform-value.js +0 -50
- package/lib/transform-value.js.flow +0 -25
- package/lib/types/index.d.ts +0 -240
- package/lib/types/index.js +0 -147
- package/lib/types/index.js.flow +0 -280
- package/lib/utils/Rule.d.ts +0 -58
- package/lib/utils/Rule.js +0 -50
- package/lib/utils/Rule.js.flow +0 -64
- package/lib/utils/dashify.d.ts +0 -11
- package/lib/utils/dashify.js +0 -9
- package/lib/utils/dashify.js.flow +0 -10
- package/lib/utils/default-options.d.ts +0 -11
- package/lib/utils/default-options.js +0 -17
- package/lib/utils/default-options.js.flow +0 -12
- package/lib/utils/file-based-identifier.d.ts +0 -15
- package/lib/utils/file-based-identifier.js +0 -14
- package/lib/utils/file-based-identifier.js.flow +0 -14
- package/lib/utils/genCSSRule.d.ts +0 -15
- package/lib/utils/genCSSRule.js +0 -15
- package/lib/utils/genCSSRule.js.flow +0 -15
- package/lib/utils/media-query-transform.d.ts +0 -16
- package/lib/utils/media-query-transform.js +0 -53
- package/lib/utils/media-query-transform.js.flow +0 -20
- package/lib/utils/normalize-value.d.ts +0 -16
- package/lib/utils/normalize-value.js +0 -28
- package/lib/utils/normalize-value.js.flow +0 -16
- package/lib/utils/normalizers/convert-camel-case-values.d.ts +0 -14
- package/lib/utils/normalizers/convert-camel-case-values.js +0 -23
- package/lib/utils/normalizers/convert-camel-case-values.js.flow +0 -13
- package/lib/utils/normalizers/detect-unclosed-fns.d.ts +0 -17
- package/lib/utils/normalizers/detect-unclosed-fns.js +0 -17
- package/lib/utils/normalizers/detect-unclosed-fns.js.flow +0 -16
- package/lib/utils/normalizers/font-size-px-to-rem.d.ts +0 -19
- package/lib/utils/normalizers/font-size-px-to-rem.js +0 -24
- package/lib/utils/normalizers/font-size-px-to-rem.js.flow +0 -18
- package/lib/utils/normalizers/leading-zero.d.ts +0 -17
- package/lib/utils/normalizers/leading-zero.js +0 -24
- package/lib/utils/normalizers/leading-zero.js.flow +0 -16
- package/lib/utils/normalizers/quotes.d.ts +0 -18
- package/lib/utils/normalizers/quotes.js +0 -17
- package/lib/utils/normalizers/quotes.js.flow +0 -17
- package/lib/utils/normalizers/timings.d.ts +0 -18
- package/lib/utils/normalizers/timings.js +0 -25
- package/lib/utils/normalizers/timings.js.flow +0 -17
- package/lib/utils/normalizers/whitespace.d.ts +0 -19
- package/lib/utils/normalizers/whitespace.js +0 -54
- package/lib/utils/normalizers/whitespace.js.flow +0 -18
- package/lib/utils/normalizers/zero-dimensions.d.ts +0 -19
- package/lib/utils/normalizers/zero-dimensions.js +0 -42
- package/lib/utils/normalizers/zero-dimensions.js.flow +0 -18
- package/lib/utils/object-utils.d.ts +0 -66
- package/lib/utils/object-utils.js +0 -99
- package/lib/utils/object-utils.js.flow +0 -78
- package/lib/utils/rule-utils.d.ts +0 -15
- package/lib/utils/rule-utils.js +0 -41
- package/lib/utils/rule-utils.js.flow +0 -16
- package/lib/utils/split-css-value.d.ts +0 -14
- package/lib/utils/split-css-value.js +0 -33
- package/lib/utils/split-css-value.js.flow +0 -15
- package/lib/validate.d.ts +0 -12
- package/lib/validate.js +0 -21
- package/lib/validate.js.flow +0 -12
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.validateNamespace = validateNamespace;
|
|
7
|
-
var messages = _interopRequireWildcard(require("../messages"));
|
|
8
|
-
var _objectUtils = require("../utils/object-utils");
|
|
9
|
-
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); }
|
|
10
|
-
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; }
|
|
11
|
-
function validateNamespace(namespace) {
|
|
12
|
-
let conditions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
13
|
-
if (!(0, _objectUtils.isPlainObject)(namespace)) {
|
|
14
|
-
throw new Error(messages.ILLEGAL_NAMESPACE_VALUE);
|
|
15
|
-
}
|
|
16
|
-
const ns = namespace;
|
|
17
|
-
for (const key in ns) {
|
|
18
|
-
const val = ns[key];
|
|
19
|
-
if (val === null || typeof val === 'string' || typeof val === 'number') {
|
|
20
|
-
continue;
|
|
21
|
-
}
|
|
22
|
-
if (Array.isArray(val)) {
|
|
23
|
-
for (const v of val) {
|
|
24
|
-
if (v === null || typeof v === 'string' || typeof v === 'number') {
|
|
25
|
-
continue;
|
|
26
|
-
}
|
|
27
|
-
throw new Error(messages.ILLEGAL_PROP_ARRAY_VALUE);
|
|
28
|
-
}
|
|
29
|
-
continue;
|
|
30
|
-
}
|
|
31
|
-
if ((0, _objectUtils.isPlainObject)(val)) {
|
|
32
|
-
if (key.startsWith('@') || key.startsWith(':')) {
|
|
33
|
-
if (conditions.includes(key)) {
|
|
34
|
-
throw new Error(messages.DUPLICATE_CONDITIONAL);
|
|
35
|
-
}
|
|
36
|
-
validateNamespace(val, [...conditions, key]);
|
|
37
|
-
} else {
|
|
38
|
-
validateConditionalStyles(val);
|
|
39
|
-
}
|
|
40
|
-
continue;
|
|
41
|
-
}
|
|
42
|
-
throw new Error(messages.ILLEGAL_PROP_VALUE);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
function validateConditionalStyles(val) {
|
|
46
|
-
let conditions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
47
|
-
for (const key in val) {
|
|
48
|
-
const v = val[key];
|
|
49
|
-
if (!(key.startsWith('@') || key.startsWith(':') || key === 'default')) {
|
|
50
|
-
throw new Error(messages.INVALID_PSEUDO_OR_AT_RULE);
|
|
51
|
-
}
|
|
52
|
-
if (conditions.includes(key)) {
|
|
53
|
-
throw new Error(messages.DUPLICATE_CONDITIONAL);
|
|
54
|
-
}
|
|
55
|
-
if (v === null || typeof v === 'string' || typeof v === 'number') {
|
|
56
|
-
continue;
|
|
57
|
-
}
|
|
58
|
-
if (Array.isArray(v)) {
|
|
59
|
-
for (const vv of v) {
|
|
60
|
-
if (vv === null || typeof vv === 'string' || typeof vv === 'number') {
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
throw new Error(messages.ILLEGAL_PROP_VALUE);
|
|
64
|
-
}
|
|
65
|
-
continue;
|
|
66
|
-
}
|
|
67
|
-
if ((0, _objectUtils.isPlainObject)(v)) {
|
|
68
|
-
validateConditionalStyles(v, [...conditions, key]);
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
throw new Error(messages.ILLEGAL_PROP_VALUE);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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 function validateNamespace(
|
|
11
|
-
namespace: mixed,
|
|
12
|
-
conditions: $ReadOnlyArray<string>,
|
|
13
|
-
): void;
|
|
@@ -1,20 +0,0 @@
|
|
|
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 { RawStyles, StyleXOptions } from '../common-types';
|
|
11
|
-
import { type AnyPreRule, type IPreRule } from './PreRule';
|
|
12
|
-
export declare function flattenRawStyleObject(
|
|
13
|
-
style: RawStyles,
|
|
14
|
-
options: StyleXOptions,
|
|
15
|
-
): ReadonlyArray<Readonly<[string, IPreRule]>>;
|
|
16
|
-
export declare function _flattenRawStyleObject(
|
|
17
|
-
style: RawStyles,
|
|
18
|
-
keyPath: ReadonlyArray<string>,
|
|
19
|
-
options: StyleXOptions,
|
|
20
|
-
): Array<Readonly<[string, AnyPreRule]>>;
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports._flattenRawStyleObject = _flattenRawStyleObject;
|
|
7
|
-
exports.flattenRawStyleObject = flattenRawStyleObject;
|
|
8
|
-
var _index = _interopRequireDefault(require("./index"));
|
|
9
|
-
var _PreRule = require("./PreRule");
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
-
function flattenRawStyleObject(style, options) {
|
|
12
|
-
return _flattenRawStyleObject(style, [], options);
|
|
13
|
-
}
|
|
14
|
-
function _flattenRawStyleObject(style, keyPath, options) {
|
|
15
|
-
const flattened = [];
|
|
16
|
-
for (const _key in style) {
|
|
17
|
-
const value = style[_key];
|
|
18
|
-
const key = _key.match(/var\(--[a-z0-9]+\)/) ? _key.slice(4, -1) : _key;
|
|
19
|
-
if (value === null || typeof value === 'string' || typeof value === 'number') {
|
|
20
|
-
const pairs = (0, _index.default)([key, value], options);
|
|
21
|
-
for (const [property, value] of pairs) {
|
|
22
|
-
if (value === null) {
|
|
23
|
-
flattened.push([property, new _PreRule.NullPreRule()]);
|
|
24
|
-
} else {
|
|
25
|
-
flattened.push([property, new _PreRule.PreRule(property, value, keyPath.includes(key) ? keyPath.map(k => k === key ? property : k) : [...keyPath, property])]);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
continue;
|
|
29
|
-
}
|
|
30
|
-
if (Array.isArray(value)) {
|
|
31
|
-
const equivalentPairs = {};
|
|
32
|
-
for (const eachVal of value) {
|
|
33
|
-
const pairs = (0, _index.default)([key, eachVal], options);
|
|
34
|
-
for (const [property, val] of pairs) {
|
|
35
|
-
if (Array.isArray(val)) {
|
|
36
|
-
if (equivalentPairs[property] == null) {
|
|
37
|
-
equivalentPairs[property] = [...val];
|
|
38
|
-
} else {
|
|
39
|
-
equivalentPairs[property].push(...val);
|
|
40
|
-
}
|
|
41
|
-
} else if (equivalentPairs[property] == null) {
|
|
42
|
-
equivalentPairs[property] = [val];
|
|
43
|
-
} else {
|
|
44
|
-
equivalentPairs[property].push(val);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
Object.entries(equivalentPairs).map(_ref => {
|
|
49
|
-
let [property, values] = _ref;
|
|
50
|
-
return [property, [...new Set(values.filter(Boolean))]];
|
|
51
|
-
}).map(_ref2 => {
|
|
52
|
-
let [property, values] = _ref2;
|
|
53
|
-
return [property, values.length === 0 ? null : values.length === 1 ? values[0] : values];
|
|
54
|
-
}).forEach(_ref3 => {
|
|
55
|
-
let [property, value] = _ref3;
|
|
56
|
-
if (value === null) {
|
|
57
|
-
flattened.push([property, new _PreRule.NullPreRule()]);
|
|
58
|
-
} else {
|
|
59
|
-
flattened.push([property, new _PreRule.PreRule(property, value, keyPath.includes(_key) ? keyPath.map(k => k === _key ? property : k) : [...keyPath, property])]);
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
continue;
|
|
63
|
-
}
|
|
64
|
-
if (typeof value === 'object' && !key.startsWith(':') && !key.startsWith('@')) {
|
|
65
|
-
const equivalentPairs = {};
|
|
66
|
-
for (const condition in value) {
|
|
67
|
-
const innerValue = value[condition];
|
|
68
|
-
const pairs = _flattenRawStyleObject({
|
|
69
|
-
[key]: innerValue
|
|
70
|
-
}, keyPath.length > 0 ? [...keyPath, condition] : [key, condition], options);
|
|
71
|
-
for (const [property, preRule] of pairs) {
|
|
72
|
-
if (equivalentPairs[property] == null) {
|
|
73
|
-
equivalentPairs[property] = {
|
|
74
|
-
[condition]: preRule
|
|
75
|
-
};
|
|
76
|
-
} else {
|
|
77
|
-
equivalentPairs[property][condition] = preRule;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
for (const [property, obj] of Object.entries(equivalentPairs)) {
|
|
82
|
-
const sortedKeys = Object.keys(obj);
|
|
83
|
-
const rules = [];
|
|
84
|
-
for (const condition of sortedKeys) {
|
|
85
|
-
rules.push(obj[condition]);
|
|
86
|
-
}
|
|
87
|
-
flattened.push([property, _PreRule.PreRuleSet.create(rules)]);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
if (typeof value === 'object' && (key.startsWith(':') || key.startsWith('@'))) {
|
|
91
|
-
const pairs = _flattenRawStyleObject(value, [...keyPath, _key], options);
|
|
92
|
-
for (const [property, preRule] of pairs) {
|
|
93
|
-
flattened.push([key + '_' + property, preRule]);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return flattened;
|
|
98
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
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 { RawStyles, StyleXOptions } from '../common-types';
|
|
11
|
-
|
|
12
|
-
import { type AnyPreRule, type IPreRule } from './PreRule';
|
|
13
|
-
|
|
14
|
-
declare export function flattenRawStyleObject(
|
|
15
|
-
style: RawStyles,
|
|
16
|
-
options: StyleXOptions,
|
|
17
|
-
): $ReadOnlyArray<$ReadOnly<[string, IPreRule]>>;
|
|
18
|
-
|
|
19
|
-
declare export function _flattenRawStyleObject(
|
|
20
|
-
style: RawStyles,
|
|
21
|
-
keyPath: $ReadOnlyArray<string>,
|
|
22
|
-
options: StyleXOptions,
|
|
23
|
-
): Array<$ReadOnly<[string, AnyPreRule]>>;
|
|
@@ -1,18 +0,0 @@
|
|
|
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 { StyleXOptions, TStyleValue } from '../common-types';
|
|
11
|
-
export declare function getExpandedKeys(
|
|
12
|
-
options: StyleXOptions,
|
|
13
|
-
): ReadonlyArray<string>;
|
|
14
|
-
declare function flatMapExpandedShorthands(
|
|
15
|
-
objEntry: Readonly<[string, TStyleValue]>,
|
|
16
|
-
options: Readonly<{ styleResolution: StyleXOptions['styleResolution'] }>,
|
|
17
|
-
): ReadonlyArray<[string, TStyleValue]>;
|
|
18
|
-
export default flatMapExpandedShorthands;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = flatMapExpandedShorthands;
|
|
7
|
-
exports.getExpandedKeys = getExpandedKeys;
|
|
8
|
-
var _applicationOrder = _interopRequireDefault(require("./application-order"));
|
|
9
|
-
var _legacyExpandShorthands = _interopRequireDefault(require("./legacy-expand-shorthands"));
|
|
10
|
-
var _propertySpecificity = _interopRequireDefault(require("./property-specificity"));
|
|
11
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
const expansions = {
|
|
13
|
-
'application-order': _applicationOrder.default,
|
|
14
|
-
'property-specificity': _propertySpecificity.default,
|
|
15
|
-
'legacy-expand-shorthands': _legacyExpandShorthands.default
|
|
16
|
-
};
|
|
17
|
-
function getExpandedKeys(options) {
|
|
18
|
-
return Object.keys(expansions[options.styleResolution ?? 'application-order']);
|
|
19
|
-
}
|
|
20
|
-
function flatMapExpandedShorthands(objEntry, options) {
|
|
21
|
-
let [key, value] = objEntry;
|
|
22
|
-
if (key.startsWith('var(') && key.endsWith(')')) {
|
|
23
|
-
key = key.slice(4, -1);
|
|
24
|
-
}
|
|
25
|
-
const expansion = expansions[options.styleResolution ?? 'application-order'][key];
|
|
26
|
-
if (expansion) {
|
|
27
|
-
if (Array.isArray(value)) {
|
|
28
|
-
throw new Error('Cannot use fallbacks for shorthands. Use the expansion instead.');
|
|
29
|
-
}
|
|
30
|
-
return expansion(value);
|
|
31
|
-
}
|
|
32
|
-
return [[key, value]];
|
|
33
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
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 { StyleXOptions, TStyleValue } from '../common-types';
|
|
11
|
-
|
|
12
|
-
declare export function getExpandedKeys(
|
|
13
|
-
options: StyleXOptions,
|
|
14
|
-
): $ReadOnlyArray<string>;
|
|
15
|
-
|
|
16
|
-
declare export default function flatMapExpandedShorthands(
|
|
17
|
-
objEntry: $ReadOnly<[string, TStyleValue]>,
|
|
18
|
-
options: $ReadOnly<{
|
|
19
|
-
styleResolution: StyleXOptions['styleResolution'],
|
|
20
|
-
...
|
|
21
|
-
}>,
|
|
22
|
-
): $ReadOnlyArray<[string, TStyleValue]>;
|
|
@@ -1,165 +0,0 @@
|
|
|
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
|
-
/**
|
|
12
|
-
* Shorthand properties:
|
|
13
|
-
* - [x] all - Should be banned
|
|
14
|
-
* - [ ] animation
|
|
15
|
-
* - [ ] background
|
|
16
|
-
* - [-] border
|
|
17
|
-
* - [x] border-block-end
|
|
18
|
-
* - [x] border-block-start
|
|
19
|
-
* - [ ] border-bottom
|
|
20
|
-
* - [x] border-color
|
|
21
|
-
* - [x] border-image
|
|
22
|
-
* - [x] border-inline-end
|
|
23
|
-
* - [x] border-inline-start
|
|
24
|
-
* - [ ] border-left
|
|
25
|
-
* - [x] border-radius
|
|
26
|
-
* - [ ] border-right
|
|
27
|
-
* - [x] border-style
|
|
28
|
-
* - [ ] border-top
|
|
29
|
-
* - [x] border-width
|
|
30
|
-
* - [ ] column-rule
|
|
31
|
-
* - [ ] columns
|
|
32
|
-
* - [ ] flex
|
|
33
|
-
* - [ ] flex-flow
|
|
34
|
-
* - [ ] font
|
|
35
|
-
* - [ ] gap
|
|
36
|
-
* - [ ] grid
|
|
37
|
-
* - [ ] grid-area
|
|
38
|
-
* - [ ] grid-column
|
|
39
|
-
* - [ ] grid-row
|
|
40
|
-
* - [ ] grid-template
|
|
41
|
-
* - [ ] list-style
|
|
42
|
-
* - [x] margin
|
|
43
|
-
* - [ ] mask
|
|
44
|
-
* - [ ] offset
|
|
45
|
-
* - [ ] outline
|
|
46
|
-
* - [x] overflow
|
|
47
|
-
* - [x] padding
|
|
48
|
-
* - [ ] place-content
|
|
49
|
-
* - [ ] place-items
|
|
50
|
-
* - [ ] place-self
|
|
51
|
-
* - [ ] scroll-margin
|
|
52
|
-
* - [ ] scroll-padding
|
|
53
|
-
* - [ ] text-decoration
|
|
54
|
-
* - [ ] text-emphasis
|
|
55
|
-
* - [ ] transition
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Shorthand properties:
|
|
60
|
-
* - [x] all - Should be banned
|
|
61
|
-
* - [ ] animation
|
|
62
|
-
* - [ ] background
|
|
63
|
-
* - [-] border
|
|
64
|
-
* - [x] border-block-end
|
|
65
|
-
* - [x] border-block-start
|
|
66
|
-
* - [ ] border-bottom
|
|
67
|
-
* - [x] border-color
|
|
68
|
-
* - [x] border-image
|
|
69
|
-
* - [x] border-inline-end
|
|
70
|
-
* - [x] border-inline-start
|
|
71
|
-
* - [ ] border-left
|
|
72
|
-
* - [x] border-radius
|
|
73
|
-
* - [ ] border-right
|
|
74
|
-
* - [x] border-style
|
|
75
|
-
* - [ ] border-top
|
|
76
|
-
* - [x] border-width
|
|
77
|
-
* - [ ] column-rule
|
|
78
|
-
* - [ ] columns
|
|
79
|
-
* - [ ] flex
|
|
80
|
-
* - [ ] flex-flow
|
|
81
|
-
* - [ ] font
|
|
82
|
-
* - [ ] gap
|
|
83
|
-
* - [ ] grid
|
|
84
|
-
* - [ ] grid-area
|
|
85
|
-
* - [ ] grid-column
|
|
86
|
-
* - [ ] grid-row
|
|
87
|
-
* - [ ] grid-template
|
|
88
|
-
* - [ ] list-style
|
|
89
|
-
* - [x] margin
|
|
90
|
-
* - [ ] mask
|
|
91
|
-
* - [ ] offset
|
|
92
|
-
* - [ ] outline
|
|
93
|
-
* - [x] overflow
|
|
94
|
-
* - [x] padding
|
|
95
|
-
* - [ ] place-content
|
|
96
|
-
* - [ ] place-items
|
|
97
|
-
* - [ ] place-self
|
|
98
|
-
* - [ ] scroll-margin
|
|
99
|
-
* - [ ] scroll-padding
|
|
100
|
-
* - [ ] text-decoration
|
|
101
|
-
* - [ ] text-emphasis
|
|
102
|
-
* - [ ] transition
|
|
103
|
-
*/
|
|
104
|
-
|
|
105
|
-
type TReturn = ReadonlyArray<[string, TStyleValue]>;
|
|
106
|
-
declare const shorthands: Readonly<{
|
|
107
|
-
[key: string]: ($$PARAM_0$$: TStyleValue) => TReturn;
|
|
108
|
-
}>;
|
|
109
|
-
declare const aliases: {
|
|
110
|
-
insetBlockStart: (val: TStyleValue) => TReturn;
|
|
111
|
-
insetBlockEnd: (val: TStyleValue) => TReturn;
|
|
112
|
-
insetInlineStart: any;
|
|
113
|
-
insetInlineEnd: any;
|
|
114
|
-
blockSize: (val: TStyleValue) => TReturn;
|
|
115
|
-
inlineSize: (val: TStyleValue) => TReturn;
|
|
116
|
-
minBlockSize: (val: TStyleValue) => TReturn;
|
|
117
|
-
minInlineSize: (val: TStyleValue) => TReturn;
|
|
118
|
-
maxBlockSize: (val: TStyleValue) => TReturn;
|
|
119
|
-
maxInlineSize: (val: TStyleValue) => TReturn;
|
|
120
|
-
borderBlockWidth: any;
|
|
121
|
-
borderBlockStyle: any;
|
|
122
|
-
borderBlockColor: any;
|
|
123
|
-
borderBlockStartWidth: (val: TStyleValue) => TReturn;
|
|
124
|
-
borderBlockStartStyle: (val: TStyleValue) => TReturn;
|
|
125
|
-
borderBlockStartColor: (val: TStyleValue) => TReturn;
|
|
126
|
-
borderBlockEndWidth: (val: TStyleValue) => TReturn;
|
|
127
|
-
borderBlockEndStyle: (val: TStyleValue) => TReturn;
|
|
128
|
-
borderBlockEndColor: (val: TStyleValue) => TReturn;
|
|
129
|
-
borderInlineWidth: any;
|
|
130
|
-
borderInlineStyle: any;
|
|
131
|
-
borderInlineColor: any;
|
|
132
|
-
borderInlineStartWidth: (val: TStyleValue) => TReturn;
|
|
133
|
-
borderInlineStartStyle: (val: TStyleValue) => TReturn;
|
|
134
|
-
borderInlineStartColor: (val: TStyleValue) => TReturn;
|
|
135
|
-
borderInlineEndWidth: (val: TStyleValue) => TReturn;
|
|
136
|
-
borderInlineEndStyle: (val: TStyleValue) => TReturn;
|
|
137
|
-
borderInlineEndColor: (val: TStyleValue) => TReturn;
|
|
138
|
-
borderStartStartRadius: (val: TStyleValue) => TReturn;
|
|
139
|
-
borderStartEndRadius: (val: TStyleValue) => TReturn;
|
|
140
|
-
borderEndStartRadius: (val: TStyleValue) => TReturn;
|
|
141
|
-
borderEndEndRadius: (val: TStyleValue) => TReturn;
|
|
142
|
-
gridGap: any;
|
|
143
|
-
gridRowGap: (value: TStyleValue) => TReturn;
|
|
144
|
-
gridColumnGap: (value: TStyleValue) => TReturn;
|
|
145
|
-
marginBlock: any;
|
|
146
|
-
marginBlockStart: (val: TStyleValue) => TReturn;
|
|
147
|
-
marginBlockEnd: (val: TStyleValue) => TReturn;
|
|
148
|
-
marginInline: any;
|
|
149
|
-
marginInlineStart: (val: TStyleValue) => TReturn;
|
|
150
|
-
marginInlineEnd: (val: TStyleValue) => TReturn;
|
|
151
|
-
overflowBlock: (value: TStyleValue) => TReturn;
|
|
152
|
-
overflowInline: (value: TStyleValue) => TReturn;
|
|
153
|
-
paddingBlock: any;
|
|
154
|
-
paddingBlockStart: (val: TStyleValue) => TReturn;
|
|
155
|
-
paddingBlockEnd: (val: TStyleValue) => TReturn;
|
|
156
|
-
paddingInline: any;
|
|
157
|
-
paddingInlineStart: (val: TStyleValue) => TReturn;
|
|
158
|
-
paddingInlineEnd: (val: TStyleValue) => TReturn;
|
|
159
|
-
scrollMarginBlockStart: (value: TStyleValue) => TReturn;
|
|
160
|
-
scrollMarginBlockEnd: (value: TStyleValue) => TReturn;
|
|
161
|
-
};
|
|
162
|
-
declare const expansions: Omit<shorthands, keyof (aliases | {})> &
|
|
163
|
-
Omit<aliases, keyof ({})> & {};
|
|
164
|
-
declare const $$EXPORT_DEFAULT_DECLARATION$$: typeof expansions;
|
|
165
|
-
export default $$EXPORT_DEFAULT_DECLARATION$$;
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _splitCssValue = _interopRequireDefault(require("../utils/split-css-value"));
|
|
8
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
const shorthands = {
|
|
10
|
-
border: rawValue => {
|
|
11
|
-
return [['borderTop', rawValue], ['borderEnd', rawValue], ['borderBottom', rawValue], ['borderStart', rawValue]];
|
|
12
|
-
},
|
|
13
|
-
borderColor: rawValue => {
|
|
14
|
-
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
|
|
15
|
-
return [['borderTopColor', top], ['borderEndColor', right], ['borderBottomColor', bottom], ['borderStartColor', left]];
|
|
16
|
-
},
|
|
17
|
-
borderHorizontal: rawValue => {
|
|
18
|
-
return [['borderStart', rawValue], ['borderEnd', rawValue]];
|
|
19
|
-
},
|
|
20
|
-
borderStyle: rawValue => {
|
|
21
|
-
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
|
|
22
|
-
return [['borderTopStyle', top], ['borderEndStyle', right], ['borderBottomStyle', bottom], ['borderStartStyle', left]];
|
|
23
|
-
},
|
|
24
|
-
borderVertical: rawValue => {
|
|
25
|
-
return [['borderTop', rawValue], ['borderBottom', rawValue]];
|
|
26
|
-
},
|
|
27
|
-
borderWidth: rawValue => {
|
|
28
|
-
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
|
|
29
|
-
return [['borderTopWidth', top], ['borderEndWidth', right], ['borderBottomWidth', bottom], ['borderStartWidth', left]];
|
|
30
|
-
},
|
|
31
|
-
borderHorizontalColor: rawValue => [['borderStartColor', rawValue], ['borderEndColor', rawValue]],
|
|
32
|
-
borderHorizontalStyle: rawValue => [['borderStartStyle', rawValue], ['borderEndStyle', rawValue]],
|
|
33
|
-
borderHorizontalWidth: rawValue => [['borderStartWidth', rawValue], ['borderEndWidth', rawValue]],
|
|
34
|
-
borderVerticalColor: rawValue => [['borderTopColor', rawValue], ['borderBottomColor', rawValue]],
|
|
35
|
-
borderVerticalStyle: rawValue => [['borderTopStyle', rawValue], ['borderBottomStyle', rawValue]],
|
|
36
|
-
borderVerticalWidth: rawValue => [['borderTopWidth', rawValue], ['borderBottomWidth', rawValue]],
|
|
37
|
-
borderRadius: rawValue => {
|
|
38
|
-
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
|
|
39
|
-
return [['borderTopStartRadius', top], ['borderTopEndRadius', right], ['borderBottomEndRadius', bottom], ['borderBottomStartRadius', left]];
|
|
40
|
-
},
|
|
41
|
-
containIntrinsicSize: rawValue => {
|
|
42
|
-
const parts = (0, _splitCssValue.default)(rawValue);
|
|
43
|
-
const [width, height = width] = parts.reduce((coll, part) => {
|
|
44
|
-
const lastElement = coll[coll.length - 1];
|
|
45
|
-
if (lastElement === 'auto' && part != null) {
|
|
46
|
-
return [...coll.slice(0, -1), `auto ${part}`];
|
|
47
|
-
}
|
|
48
|
-
return [...coll, part];
|
|
49
|
-
}, []);
|
|
50
|
-
return [['containIntrinsicWidth', width], ['containIntrinsicHeight', height]];
|
|
51
|
-
},
|
|
52
|
-
inset: rawValue => [['top', rawValue], ['end', rawValue], ['bottom', rawValue], ['start', rawValue]],
|
|
53
|
-
insetInline: rawValue => [...shorthands.start(rawValue), ...shorthands.end(rawValue)],
|
|
54
|
-
insetBlock: rawValue => [['top', rawValue], ['bottom', rawValue]],
|
|
55
|
-
start: rawValue => [['start', rawValue], ['left', null], ['right', null]],
|
|
56
|
-
end: rawValue => [['end', rawValue], ['left', null], ['right', null]],
|
|
57
|
-
left: rawValue => [['left', rawValue], ['start', null], ['end', null]],
|
|
58
|
-
right: rawValue => [['right', rawValue], ['start', null], ['end', null]],
|
|
59
|
-
gap: rawValue => {
|
|
60
|
-
const [row, column = row] = (0, _splitCssValue.default)(rawValue);
|
|
61
|
-
return [['rowGap', row], ['columnGap', column]];
|
|
62
|
-
},
|
|
63
|
-
margin: rawValue => {
|
|
64
|
-
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
|
|
65
|
-
return [['marginTop', top], ['marginEnd', right], ['marginBottom', bottom], ['marginStart', left]];
|
|
66
|
-
},
|
|
67
|
-
marginHorizontal: rawValue => [...shorthands.marginStart(rawValue), ...shorthands.marginEnd(rawValue)],
|
|
68
|
-
marginStart: rawValue => [['marginStart', rawValue], ['marginLeft', null], ['marginRight', null]],
|
|
69
|
-
marginEnd: rawValue => [['marginEnd', rawValue], ['marginLeft', null], ['marginRight', null]],
|
|
70
|
-
marginLeft: rawValue => [['marginLeft', rawValue], ['marginStart', null], ['marginEnd', null]],
|
|
71
|
-
marginRight: rawValue => [['marginRight', rawValue], ['marginStart', null], ['marginEnd', null]],
|
|
72
|
-
marginVertical: rawValue => {
|
|
73
|
-
return [['marginTop', rawValue], ['marginBottom', rawValue]];
|
|
74
|
-
},
|
|
75
|
-
overflow: rawValue => {
|
|
76
|
-
const [x, y = x] = (0, _splitCssValue.default)(rawValue);
|
|
77
|
-
return [['overflowX', x], ['overflowY', y]];
|
|
78
|
-
},
|
|
79
|
-
padding: rawValue => {
|
|
80
|
-
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
|
|
81
|
-
return [['paddingTop', top], ['paddingEnd', right], ['paddingBottom', bottom], ['paddingStart', left]];
|
|
82
|
-
},
|
|
83
|
-
paddingHorizontal: val => [...shorthands.paddingStart(val), ...shorthands.paddingEnd(val)],
|
|
84
|
-
paddingStart: val => [['paddingStart', val], ['paddingLeft', null], ['paddingRight', null]],
|
|
85
|
-
paddingEnd: val => [['paddingEnd', val], ['paddingLeft', null], ['paddingRight', null]],
|
|
86
|
-
paddingLeft: val => [['paddingLeft', val], ['paddingStart', null], ['paddingEnd', null]],
|
|
87
|
-
paddingRight: val => [['paddingRight', val], ['paddingStart', null], ['paddingEnd', null]],
|
|
88
|
-
paddingVertical: val => [['paddingTop', val], ['paddingBottom', val]]
|
|
89
|
-
};
|
|
90
|
-
const aliases = {
|
|
91
|
-
insetBlockStart: val => [['top', val]],
|
|
92
|
-
insetBlockEnd: val => [['bottom', val]],
|
|
93
|
-
insetInlineStart: shorthands.start,
|
|
94
|
-
insetInlineEnd: shorthands.end,
|
|
95
|
-
blockSize: val => [['height', val]],
|
|
96
|
-
inlineSize: val => [['width', val]],
|
|
97
|
-
minBlockSize: val => [['minHeight', val]],
|
|
98
|
-
minInlineSize: val => [['minWidth', val]],
|
|
99
|
-
maxBlockSize: val => [['maxHeight', val]],
|
|
100
|
-
maxInlineSize: val => [['maxWidth', val]],
|
|
101
|
-
borderBlockWidth: shorthands.borderVerticalWidth,
|
|
102
|
-
borderBlockStyle: shorthands.borderVerticalStyle,
|
|
103
|
-
borderBlockColor: shorthands.borderVerticalColor,
|
|
104
|
-
borderBlockStartWidth: val => [['borderTopWidth', val]],
|
|
105
|
-
borderBlockStartStyle: val => [['borderTopStyle', val]],
|
|
106
|
-
borderBlockStartColor: val => [['borderTopColor', val]],
|
|
107
|
-
borderBlockEndWidth: val => [['borderBottomWidth', val]],
|
|
108
|
-
borderBlockEndStyle: val => [['borderBottomStyle', val]],
|
|
109
|
-
borderBlockEndColor: val => [['borderBottomColor', val]],
|
|
110
|
-
borderInlineWidth: shorthands.borderHorizontalWidth,
|
|
111
|
-
borderInlineStyle: shorthands.borderHorizontalStyle,
|
|
112
|
-
borderInlineColor: shorthands.borderHorizontalColor,
|
|
113
|
-
borderInlineStartWidth: val => [['borderStartWidth', val]],
|
|
114
|
-
borderInlineStartStyle: val => [['borderStartStyle', val]],
|
|
115
|
-
borderInlineStartColor: val => [['borderStartColor', val]],
|
|
116
|
-
borderInlineEndWidth: val => [['borderEndWidth', val]],
|
|
117
|
-
borderInlineEndStyle: val => [['borderEndStyle', val]],
|
|
118
|
-
borderInlineEndColor: val => [['borderEndColor', val]],
|
|
119
|
-
borderStartStartRadius: val => [['borderTopStartRadius', val]],
|
|
120
|
-
borderStartEndRadius: val => [['borderTopEndRadius', val]],
|
|
121
|
-
borderEndStartRadius: val => [['borderBottomStartRadius', val]],
|
|
122
|
-
borderEndEndRadius: val => [['borderBottomEndRadius', val]],
|
|
123
|
-
gridGap: shorthands.gap,
|
|
124
|
-
gridRowGap: value => [['rowGap', value]],
|
|
125
|
-
gridColumnGap: value => [['columnGap', value]],
|
|
126
|
-
marginBlock: shorthands.marginVertical,
|
|
127
|
-
marginBlockStart: val => [['marginTop', val]],
|
|
128
|
-
marginBlockEnd: val => [['marginBottom', val]],
|
|
129
|
-
marginInline: shorthands.marginHorizontal,
|
|
130
|
-
marginInlineStart: val => [['marginStart', val]],
|
|
131
|
-
marginInlineEnd: val => [['marginEnd', val]],
|
|
132
|
-
overflowBlock: value => [['overflowY', value]],
|
|
133
|
-
overflowInline: value => [['overflowX', value]],
|
|
134
|
-
paddingBlock: shorthands.paddingVertical,
|
|
135
|
-
paddingBlockStart: val => [['paddingTop', val]],
|
|
136
|
-
paddingBlockEnd: val => [['paddingBottom', val]],
|
|
137
|
-
paddingInline: shorthands.paddingHorizontal,
|
|
138
|
-
paddingInlineStart: val => [['paddingStart', val]],
|
|
139
|
-
paddingInlineEnd: val => [['paddingEnd', val]],
|
|
140
|
-
scrollMarginBlockStart: value => [['scrollMarginTop', value]],
|
|
141
|
-
scrollMarginBlockEnd: value => [['scrollMarginBottom', value]]
|
|
142
|
-
};
|
|
143
|
-
const expansions = {
|
|
144
|
-
...shorthands,
|
|
145
|
-
...aliases
|
|
146
|
-
};
|
|
147
|
-
var _default = exports.default = expansions;
|