@stylexjs/shared 0.7.5 → 0.9.0-beta.1
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/common-types.d.ts +1 -0
- package/lib/common-types.js.flow +1 -0
- package/lib/convert-to-className.d.ts +1 -1
- package/lib/convert-to-className.js +13 -11
- package/lib/convert-to-className.js.flow +1 -1
- package/lib/generate-css-rule.js +1 -1
- package/lib/index.js +2 -2
- package/lib/physical-rtl/generate-ltr.d.ts +3 -1
- package/lib/physical-rtl/generate-ltr.js +8 -12
- package/lib/physical-rtl/generate-ltr.js.flow +2 -2
- package/lib/physical-rtl/generate-rtl.d.ts +2 -2
- package/lib/physical-rtl/generate-rtl.js +57 -64
- package/lib/physical-rtl/generate-rtl.js.flow +2 -2
- package/lib/preprocess-rules/PreRule.d.ts +13 -6
- package/lib/preprocess-rules/PreRule.js +14 -13
- package/lib/preprocess-rules/PreRule.js.flow +14 -6
- package/lib/preprocess-rules/application-order.d.ts +4 -111
- package/lib/preprocess-rules/application-order.js.flow +3 -110
- package/lib/preprocess-rules/basic-validation.js +1 -1
- package/lib/preprocess-rules/flatten-raw-style-obj.d.ts +1 -2
- package/lib/preprocess-rules/flatten-raw-style-obj.js +7 -21
- package/lib/preprocess-rules/flatten-raw-style-obj.js.flow +1 -2
- package/lib/preprocess-rules/index.d.ts +1 -1
- package/lib/preprocess-rules/index.js +1 -1
- package/lib/preprocess-rules/index.js.flow +4 -1
- package/lib/preprocess-rules/legacy-expand-shorthands.d.ts +3 -38
- package/lib/preprocess-rules/legacy-expand-shorthands.js +12 -1
- package/lib/preprocess-rules/legacy-expand-shorthands.js.flow +3 -38
- package/lib/preprocess-rules/property-specificity.d.ts +4 -15
- package/lib/preprocess-rules/property-specificity.js.flow +3 -14
- package/lib/stylex-create-theme.js +2 -2
- package/lib/stylex-create.d.ts +4 -0
- package/lib/stylex-create.js +20 -8
- package/lib/stylex-create.js.flow +9 -1
- package/lib/stylex-define-vars.d.ts +8 -5
- package/lib/stylex-define-vars.js +2 -2
- package/lib/stylex-define-vars.js.flow +5 -1
- package/lib/stylex-include.js +1 -1
- package/lib/stylex-keyframes.js +1 -1
- package/lib/transform-value.js +7 -4
- package/lib/types/index.js.flow +1 -1
- package/lib/utils/default-options.js +1 -0
- package/lib/utils/normalize-value.js +1 -1
- package/lib/utils/normalizers/convert-camel-case-values.js +1 -1
- package/lib/utils/normalizers/detect-unclosed-fns.js +1 -1
- package/lib/utils/normalizers/font-size-px-to-rem.js +1 -1
- package/lib/utils/normalizers/leading-zero.js +1 -1
- package/lib/utils/normalizers/timings.js +1 -1
- package/lib/utils/normalizers/zero-dimensions.js +1 -1
- package/lib/utils/object-utils.d.ts +3 -2
- package/lib/utils/object-utils.js.flow +5 -2
- package/lib/utils/property-priorities.d.ts +3 -56
- package/lib/utils/property-priorities.js.flow +56 -56
- package/lib/utils/rule-utils.d.ts +15 -0
- package/lib/utils/rule-utils.js +41 -0
- package/lib/utils/rule-utils.js.flow +16 -0
- package/lib/utils/split-css-value.js +1 -1
- package/package.json +2 -2
@@ -62,116 +62,9 @@ import type { TStyleValue } from '../common-types';
|
|
62
62
|
|
63
63
|
type TReturn = $ReadOnlyArray<[string, TStyleValue]>;
|
64
64
|
|
65
|
-
declare const shorthands: {
|
66
|
-
|
67
|
-
|
68
|
-
animationRange: (value: TStyleValue) => TReturn,
|
69
|
-
background: (value: TStyleValue) => TReturn,
|
70
|
-
backgroundPosition: (value: TStyleValue) => TReturn,
|
71
|
-
border: (rawValue: TStyleValue) => TReturn,
|
72
|
-
borderInline: (rawValue: TStyleValue) => TReturn,
|
73
|
-
borderBlock: (rawValue: TStyleValue) => TReturn,
|
74
|
-
borderTop: (rawValue: TStyleValue) => TReturn,
|
75
|
-
borderInlineEnd: (rawValue: TStyleValue) => TReturn,
|
76
|
-
borderRight: (rawValue: TStyleValue) => TReturn,
|
77
|
-
borderBottom: (rawValue: TStyleValue) => TReturn,
|
78
|
-
borderInlineStart: (rawValue: TStyleValue) => TReturn,
|
79
|
-
borderLeft: (rawValue: TStyleValue) => TReturn,
|
80
|
-
borderInlineWidth: (rawValue: TStyleValue) => TReturn,
|
81
|
-
borderInlineStyle: (rawValue: TStyleValue) => TReturn,
|
82
|
-
borderInlineColor: (rawValue: TStyleValue) => TReturn,
|
83
|
-
borderBlockWidth: (rawValue: TStyleValue) => TReturn,
|
84
|
-
borderBlockStyle: (rawValue: TStyleValue) => TReturn,
|
85
|
-
borderBlockColor: (rawValue: TStyleValue) => TReturn,
|
86
|
-
borderColor: (value: TStyleValue) => TReturn,
|
87
|
-
borderStyle: (value: TStyleValue) => TReturn,
|
88
|
-
borderWidth: (value: TStyleValue) => TReturn,
|
89
|
-
borderInlineStartColor: (value: TStyleValue) => TReturn,
|
90
|
-
borderInlineEndColor: (value: TStyleValue) => TReturn,
|
91
|
-
borderInlineStartStyle: (value: TStyleValue) => TReturn,
|
92
|
-
borderInlineEndStyle: (value: TStyleValue) => TReturn,
|
93
|
-
borderInlineStartWidth: (value: TStyleValue) => TReturn,
|
94
|
-
borderInlineEndWidth: (value: TStyleValue) => TReturn,
|
95
|
-
borderLeftColor: (value: TStyleValue) => TReturn,
|
96
|
-
borderRightColor: (value: TStyleValue) => TReturn,
|
97
|
-
borderLeftStyle: (value: TStyleValue) => TReturn,
|
98
|
-
borderRightStyle: (value: TStyleValue) => TReturn,
|
99
|
-
borderLeftWidth: (value: TStyleValue) => TReturn,
|
100
|
-
borderRightWidth: (value: TStyleValue) => TReturn,
|
101
|
-
borderRadius: (value: TStyleValue) => TReturn,
|
102
|
-
borderStartStartRadius: (value: TStyleValue) => TReturn,
|
103
|
-
borderStartEndRadius: (value: TStyleValue) => TReturn,
|
104
|
-
borderEndStartRadius: (value: TStyleValue) => TReturn,
|
105
|
-
borderEndEndRadius: (value: TStyleValue) => TReturn,
|
106
|
-
borderTopLeftRadius: (value: TStyleValue) => TReturn,
|
107
|
-
borderTopRightRadius: (value: TStyleValue) => TReturn,
|
108
|
-
borderBottomLeftRadius: (value: TStyleValue) => TReturn,
|
109
|
-
borderBottomRightRadius: (value: TStyleValue) => TReturn,
|
110
|
-
borderImage: (value: TStyleValue) => TReturn,
|
111
|
-
columnRule: (value: TStyleValue) => TReturn,
|
112
|
-
columns: (value: TStyleValue) => TReturn,
|
113
|
-
container: (value: TStyleValue) => TReturn,
|
114
|
-
containIntrinsicSize: (value: TStyleValue) => TReturn,
|
115
|
-
flex: (value: TStyleValue) => TReturn,
|
116
|
-
flexFlow: (value: TStyleValue) => TReturn,
|
117
|
-
font: (value: TStyleValue) => TReturn,
|
118
|
-
fontVariant: (value: TStyleValue) => TReturn,
|
119
|
-
gap: (value: TStyleValue) => TReturn,
|
120
|
-
grid: (value: TStyleValue) => TReturn,
|
121
|
-
gridArea: (value: TStyleValue) => TReturn,
|
122
|
-
gridRow: (value: TStyleValue) => TReturn,
|
123
|
-
gridColumn: (value: TStyleValue) => TReturn,
|
124
|
-
gridTemplate: (value: TStyleValue) => TReturn,
|
125
|
-
inset: (value: TStyleValue) => TReturn,
|
126
|
-
insetInline: (value: TStyleValue) => TReturn,
|
127
|
-
insetBlock: (value: TStyleValue) => TReturn,
|
128
|
-
insetInlineStart: (value: TStyleValue) => TReturn,
|
129
|
-
insetInlineEnd: (value: TStyleValue) => TReturn,
|
130
|
-
left: (value: TStyleValue) => TReturn,
|
131
|
-
right: (value: TStyleValue) => TReturn,
|
132
|
-
listStyle: (value: TStyleValue) => TReturn,
|
133
|
-
margin: (value: TStyleValue) => TReturn,
|
134
|
-
marginInline: (value: TStyleValue) => TReturn,
|
135
|
-
marginBlock: (value: TStyleValue) => TReturn,
|
136
|
-
marginInlineStart: (value: TStyleValue) => TReturn,
|
137
|
-
marginInlineEnd: (value: TStyleValue) => TReturn,
|
138
|
-
marginLeft: (value: TStyleValue) => TReturn,
|
139
|
-
marginRight: (value: TStyleValue) => TReturn,
|
140
|
-
mask: (value: TStyleValue) => TReturn,
|
141
|
-
maskBorder: (value: TStyleValue) => TReturn,
|
142
|
-
offset: (value: TStyleValue) => TReturn,
|
143
|
-
outline: (value: TStyleValue) => TReturn,
|
144
|
-
overflow: (value: TStyleValue) => TReturn,
|
145
|
-
padding: (rawValue: TStyleValue) => TReturn,
|
146
|
-
paddingInline: (rawValue: TStyleValue) => TReturn,
|
147
|
-
paddingBlock: (rawValue: TStyleValue) => TReturn,
|
148
|
-
paddingInlineStart: (value: TStyleValue) => TReturn,
|
149
|
-
paddingInlineEnd: (value: TStyleValue) => TReturn,
|
150
|
-
paddingLeft: (value: TStyleValue) => TReturn,
|
151
|
-
paddingRight: (value: TStyleValue) => TReturn,
|
152
|
-
placeContent: (value: TStyleValue) => TReturn,
|
153
|
-
placeItems: (value: TStyleValue) => TReturn,
|
154
|
-
placeSelf: (value: TStyleValue) => TReturn,
|
155
|
-
scrollMargin: (value: TStyleValue) => TReturn,
|
156
|
-
scrollMarginBlock: (value: TStyleValue) => TReturn,
|
157
|
-
scrollMarginInline: (value: TStyleValue) => TReturn,
|
158
|
-
scrollMarginInlineStart: (value: TStyleValue) => TReturn,
|
159
|
-
scrollMarginInlineEnd: (value: TStyleValue) => TReturn,
|
160
|
-
scrollMarginLeft: (value: TStyleValue) => TReturn,
|
161
|
-
scrollMarginRight: (value: TStyleValue) => TReturn,
|
162
|
-
scrollPadding: (value: TStyleValue) => TReturn,
|
163
|
-
scrollPaddingBlock: (value: TStyleValue) => TReturn,
|
164
|
-
scrollPaddingInline: (value: TStyleValue) => TReturn,
|
165
|
-
scrollPaddingInlineStart: (value: TStyleValue) => TReturn,
|
166
|
-
scrollPaddingInlineEnd: (value: TStyleValue) => TReturn,
|
167
|
-
scrollPaddingLeft: (value: TStyleValue) => TReturn,
|
168
|
-
scrollPaddingRight: (value: TStyleValue) => TReturn,
|
169
|
-
scrollSnapType: (value: TStyleValue) => TReturn,
|
170
|
-
scrollTimeline: (value: TStyleValue) => TReturn,
|
171
|
-
textDecoration: (value: TStyleValue) => TReturn,
|
172
|
-
textEmphasis: (value: TStyleValue) => TReturn,
|
173
|
-
transition: (value: TStyleValue) => TReturn,
|
174
|
-
};
|
65
|
+
declare const shorthands: $ReadOnly<{
|
66
|
+
[key: string]: (TStyleValue) => TReturn,
|
67
|
+
}>;
|
175
68
|
|
176
69
|
declare const aliases: {
|
177
70
|
borderHorizontal: $FlowFixMe,
|
@@ -8,7 +8,7 @@ var _stylexInclude = require("../stylex-include");
|
|
8
8
|
var messages = _interopRequireWildcard(require("../messages"));
|
9
9
|
var _objectUtils = require("../utils/object-utils");
|
10
10
|
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); }
|
11
|
-
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 &&
|
11
|
+
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; }
|
12
12
|
function validateNamespace(namespace) {
|
13
13
|
let conditions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
14
14
|
if (!(0, _objectUtils.isPlainObject)(namespace)) {
|
@@ -19,7 +19,6 @@ export declare function flattenRawStyleObject(
|
|
19
19
|
): ReadonlyArray<Readonly<[string, IPreRule]>>;
|
20
20
|
export declare function _flattenRawStyleObject(
|
21
21
|
style: RawStyles,
|
22
|
-
|
23
|
-
atRules: ReadonlyArray<string>,
|
22
|
+
keyPath: ReadonlyArray<string>,
|
24
23
|
options: StyleXOptions,
|
25
24
|
): Array<Readonly<[string, AnyPreRule | PreIncludedStylesRule]>>;
|
@@ -8,11 +8,11 @@ exports.flattenRawStyleObject = flattenRawStyleObject;
|
|
8
8
|
var _index = _interopRequireDefault(require("./index"));
|
9
9
|
var _PreRule = require("./PreRule");
|
10
10
|
var _stylexInclude = require("../stylex-include");
|
11
|
-
function _interopRequireDefault(
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
12
12
|
function flattenRawStyleObject(style, options) {
|
13
|
-
return _flattenRawStyleObject(style, [],
|
13
|
+
return _flattenRawStyleObject(style, [], options);
|
14
14
|
}
|
15
|
-
function _flattenRawStyleObject(style,
|
15
|
+
function _flattenRawStyleObject(style, keyPath, options) {
|
16
16
|
const flattened = [];
|
17
17
|
for (const _key in style) {
|
18
18
|
const value = style[_key];
|
@@ -27,7 +27,7 @@ function _flattenRawStyleObject(style, pseudos, atRules, options) {
|
|
27
27
|
if (value === null) {
|
28
28
|
flattened.push([property, new _PreRule.NullPreRule()]);
|
29
29
|
} else {
|
30
|
-
flattened.push([property, new _PreRule.PreRule(property, value,
|
30
|
+
flattened.push([property, new _PreRule.PreRule(property, value, keyPath.includes(key) ? keyPath.map(k => k === key ? property : k) : [...keyPath, property])]);
|
31
31
|
}
|
32
32
|
}
|
33
33
|
continue;
|
@@ -61,7 +61,7 @@ function _flattenRawStyleObject(style, pseudos, atRules, options) {
|
|
61
61
|
if (value === null) {
|
62
62
|
flattened.push([property, new _PreRule.NullPreRule()]);
|
63
63
|
} else {
|
64
|
-
flattened.push([property, new _PreRule.PreRule(property, value,
|
64
|
+
flattened.push([property, new _PreRule.PreRule(property, value, keyPath.includes(_key) ? keyPath.map(k => k === _key ? property : k) : [...keyPath, property])]);
|
65
65
|
}
|
66
66
|
});
|
67
67
|
continue;
|
@@ -70,16 +70,9 @@ function _flattenRawStyleObject(style, pseudos, atRules, options) {
|
|
70
70
|
const equivalentPairs = {};
|
71
71
|
for (const condition in value) {
|
72
72
|
const innerValue = value[condition];
|
73
|
-
const pseudosToPassDown = [...pseudos];
|
74
|
-
const atRulesToPassDown = [...atRules];
|
75
|
-
if (condition.startsWith(':')) {
|
76
|
-
pseudosToPassDown.push(condition);
|
77
|
-
} else if (condition.startsWith('@')) {
|
78
|
-
atRulesToPassDown.push(condition);
|
79
|
-
}
|
80
73
|
const pairs = _flattenRawStyleObject({
|
81
74
|
[key]: innerValue
|
82
|
-
},
|
75
|
+
}, keyPath.length > 0 ? [...keyPath, condition] : [key, condition], options);
|
83
76
|
for (const [property, preRule] of pairs) {
|
84
77
|
if (preRule instanceof _PreRule.PreIncludedStylesRule) {
|
85
78
|
throw new Error('stylex.include can only be used at the top-level');
|
@@ -103,14 +96,7 @@ function _flattenRawStyleObject(style, pseudos, atRules, options) {
|
|
103
96
|
}
|
104
97
|
}
|
105
98
|
if (typeof value === 'object' && (key.startsWith(':') || key.startsWith('@'))) {
|
106
|
-
const
|
107
|
-
const atRulesToPassDown = [...atRules];
|
108
|
-
if (key.startsWith(':')) {
|
109
|
-
pseudosToPassDown.push(key);
|
110
|
-
} else if (key.startsWith('@')) {
|
111
|
-
atRulesToPassDown.push(key);
|
112
|
-
}
|
113
|
-
const pairs = _flattenRawStyleObject(value, pseudosToPassDown, atRulesToPassDown, options);
|
99
|
+
const pairs = _flattenRawStyleObject(value, [...keyPath, _key], options);
|
114
100
|
for (const [property, preRule] of pairs) {
|
115
101
|
flattened.push([key + '_' + property, preRule]);
|
116
102
|
}
|
@@ -21,7 +21,6 @@ declare export function flattenRawStyleObject(
|
|
21
21
|
|
22
22
|
declare export function _flattenRawStyleObject(
|
23
23
|
style: RawStyles,
|
24
|
-
|
25
|
-
atRules: $ReadOnlyArray<string>,
|
24
|
+
keyPath: $ReadOnlyArray<string>,
|
26
25
|
options: StyleXOptions,
|
27
26
|
): Array<$ReadOnly<[string, AnyPreRule | PreIncludedStylesRule]>>;
|
@@ -13,6 +13,6 @@ export declare function getExpandedKeys(
|
|
13
13
|
): ReadonlyArray<string>;
|
14
14
|
declare function flatMapExpandedShorthands(
|
15
15
|
objEntry: Readonly<[string, TStyleValue]>,
|
16
|
-
options: StyleXOptions
|
16
|
+
options: Readonly<{ styleResolution: StyleXOptions['styleResolution'] }>,
|
17
17
|
): ReadonlyArray<[string, TStyleValue]>;
|
18
18
|
export default flatMapExpandedShorthands;
|
@@ -8,7 +8,7 @@ exports.getExpandedKeys = getExpandedKeys;
|
|
8
8
|
var _applicationOrder = _interopRequireDefault(require("./application-order"));
|
9
9
|
var _legacyExpandShorthands = _interopRequireDefault(require("./legacy-expand-shorthands"));
|
10
10
|
var _propertySpecificity = _interopRequireDefault(require("./property-specificity"));
|
11
|
-
function _interopRequireDefault(
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
12
12
|
const expansions = {
|
13
13
|
'application-order': _applicationOrder.default,
|
14
14
|
'property-specificity': _propertySpecificity.default,
|
@@ -15,5 +15,8 @@ declare export function getExpandedKeys(
|
|
15
15
|
|
16
16
|
declare export default function flatMapExpandedShorthands(
|
17
17
|
objEntry: $ReadOnly<[string, TStyleValue]>,
|
18
|
-
options:
|
18
|
+
options: $ReadOnly<{
|
19
|
+
styleResolution: StyleXOptions['styleResolution'],
|
20
|
+
...
|
21
|
+
}>,
|
19
22
|
): $ReadOnlyArray<[string, TStyleValue]>;
|
@@ -103,44 +103,9 @@ import type { TStyleValue } from '../common-types';
|
|
103
103
|
*/
|
104
104
|
|
105
105
|
type TReturn = ReadonlyArray<[string, TStyleValue]>;
|
106
|
-
declare const shorthands: {
|
107
|
-
|
108
|
-
|
109
|
-
borderHorizontal: (rawValue: TStyleValue) => TReturn;
|
110
|
-
borderStyle: (rawValue: TStyleValue) => TReturn;
|
111
|
-
borderVertical: (rawValue: TStyleValue) => TReturn;
|
112
|
-
borderWidth: (rawValue: TStyleValue) => TReturn;
|
113
|
-
borderHorizontalColor: (rawValue: TStyleValue) => TReturn;
|
114
|
-
borderHorizontalStyle: (rawValue: TStyleValue) => TReturn;
|
115
|
-
borderHorizontalWidth: (rawValue: TStyleValue) => TReturn;
|
116
|
-
borderVerticalColor: (rawValue: TStyleValue) => TReturn;
|
117
|
-
borderVerticalStyle: (rawValue: TStyleValue) => TReturn;
|
118
|
-
borderVerticalWidth: (rawValue: TStyleValue) => TReturn;
|
119
|
-
borderRadius: (rawValue: TStyleValue) => TReturn;
|
120
|
-
inset: (rawValue: TStyleValue) => TReturn;
|
121
|
-
insetInline: (rawValue: TStyleValue) => TReturn;
|
122
|
-
insetBlock: (rawValue: TStyleValue) => TReturn;
|
123
|
-
start: (rawValue: TStyleValue) => TReturn;
|
124
|
-
end: (rawValue: TStyleValue) => TReturn;
|
125
|
-
left: (rawValue: TStyleValue) => TReturn;
|
126
|
-
right: (rawValue: TStyleValue) => TReturn;
|
127
|
-
gap: (rawValue: TStyleValue) => TReturn;
|
128
|
-
margin: (rawValue: TStyleValue) => TReturn;
|
129
|
-
marginHorizontal: (rawValue: TStyleValue) => TReturn;
|
130
|
-
marginStart: (rawValue: TStyleValue) => TReturn;
|
131
|
-
marginEnd: (rawValue: TStyleValue) => TReturn;
|
132
|
-
marginLeft: (rawValue: TStyleValue) => TReturn;
|
133
|
-
marginRight: (rawValue: TStyleValue) => TReturn;
|
134
|
-
marginVertical: (rawValue: TStyleValue) => TReturn;
|
135
|
-
overflow: (rawValue: TStyleValue) => TReturn;
|
136
|
-
padding: (rawValue: TStyleValue) => TReturn;
|
137
|
-
paddingHorizontal: (val: TStyleValue) => TReturn;
|
138
|
-
paddingStart: (val: TStyleValue) => TReturn;
|
139
|
-
paddingEnd: (val: TStyleValue) => TReturn;
|
140
|
-
paddingLeft: (val: TStyleValue) => TReturn;
|
141
|
-
paddingRight: (val: TStyleValue) => TReturn;
|
142
|
-
paddingVertical: (val: TStyleValue) => TReturn;
|
143
|
-
};
|
106
|
+
declare const shorthands: Readonly<{
|
107
|
+
[key: string]: ($$PARAM_0$$: TStyleValue) => TReturn;
|
108
|
+
}>;
|
144
109
|
declare const aliases: {
|
145
110
|
insetBlockStart: (val: TStyleValue) => TReturn;
|
146
111
|
insetBlockEnd: (val: TStyleValue) => TReturn;
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
7
|
var _splitCssValue = _interopRequireDefault(require("../utils/split-css-value"));
|
8
|
-
function _interopRequireDefault(
|
8
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
9
9
|
const shorthands = {
|
10
10
|
border: rawValue => {
|
11
11
|
return [['borderTop', rawValue], ['borderEnd', rawValue], ['borderBottom', rawValue], ['borderStart', rawValue]];
|
@@ -38,6 +38,17 @@ const shorthands = {
|
|
38
38
|
const [top, right = top, bottom = top, left = right] = (0, _splitCssValue.default)(rawValue);
|
39
39
|
return [['borderTopStartRadius', top], ['borderTopEndRadius', right], ['borderBottomEndRadius', bottom], ['borderBottomStartRadius', left]];
|
40
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
|
+
},
|
41
52
|
inset: rawValue => [['top', rawValue], ['end', rawValue], ['bottom', rawValue], ['start', rawValue]],
|
42
53
|
insetInline: rawValue => [...shorthands.start(rawValue), ...shorthands.end(rawValue)],
|
43
54
|
insetBlock: rawValue => [['top', rawValue], ['bottom', rawValue]],
|
@@ -81,44 +81,9 @@ import type { TStyleValue } from '../common-types';
|
|
81
81
|
|
82
82
|
type TReturn = $ReadOnlyArray<[string, TStyleValue]>;
|
83
83
|
|
84
|
-
declare const shorthands: {
|
85
|
-
|
86
|
-
|
87
|
-
borderHorizontal: (rawValue: TStyleValue) => TReturn,
|
88
|
-
borderStyle: (rawValue: TStyleValue) => TReturn,
|
89
|
-
borderVertical: (rawValue: TStyleValue) => TReturn,
|
90
|
-
borderWidth: (rawValue: TStyleValue) => TReturn,
|
91
|
-
borderHorizontalColor: (rawValue: TStyleValue) => TReturn,
|
92
|
-
borderHorizontalStyle: (rawValue: TStyleValue) => TReturn,
|
93
|
-
borderHorizontalWidth: (rawValue: TStyleValue) => TReturn,
|
94
|
-
borderVerticalColor: (rawValue: TStyleValue) => TReturn,
|
95
|
-
borderVerticalStyle: (rawValue: TStyleValue) => TReturn,
|
96
|
-
borderVerticalWidth: (rawValue: TStyleValue) => TReturn,
|
97
|
-
borderRadius: (rawValue: TStyleValue) => TReturn,
|
98
|
-
inset: (rawValue: TStyleValue) => TReturn,
|
99
|
-
insetInline: (rawValue: TStyleValue) => TReturn,
|
100
|
-
insetBlock: (rawValue: TStyleValue) => TReturn,
|
101
|
-
start: (rawValue: TStyleValue) => TReturn,
|
102
|
-
end: (rawValue: TStyleValue) => TReturn,
|
103
|
-
left: (rawValue: TStyleValue) => TReturn,
|
104
|
-
right: (rawValue: TStyleValue) => TReturn,
|
105
|
-
gap: (rawValue: TStyleValue) => TReturn,
|
106
|
-
margin: (rawValue: TStyleValue) => TReturn,
|
107
|
-
marginHorizontal: (rawValue: TStyleValue) => TReturn,
|
108
|
-
marginStart: (rawValue: TStyleValue) => TReturn,
|
109
|
-
marginEnd: (rawValue: TStyleValue) => TReturn,
|
110
|
-
marginLeft: (rawValue: TStyleValue) => TReturn,
|
111
|
-
marginRight: (rawValue: TStyleValue) => TReturn,
|
112
|
-
marginVertical: (rawValue: TStyleValue) => TReturn,
|
113
|
-
overflow: (rawValue: TStyleValue) => TReturn,
|
114
|
-
padding: (rawValue: TStyleValue) => TReturn,
|
115
|
-
paddingHorizontal: (val: TStyleValue) => TReturn,
|
116
|
-
paddingStart: (val: TStyleValue) => TReturn,
|
117
|
-
paddingEnd: (val: TStyleValue) => TReturn,
|
118
|
-
paddingLeft: (val: TStyleValue) => TReturn,
|
119
|
-
paddingRight: (val: TStyleValue) => TReturn,
|
120
|
-
paddingVertical: (val: TStyleValue) => TReturn,
|
121
|
-
};
|
84
|
+
declare const shorthands: $ReadOnly<{
|
85
|
+
[key: string]: (TStyleValue) => TReturn,
|
86
|
+
}>;
|
122
87
|
|
123
88
|
declare const aliases: {
|
124
89
|
insetBlockStart: (val: TStyleValue) => TReturn,
|
@@ -9,20 +9,9 @@
|
|
9
9
|
|
10
10
|
import type { TStyleValue } from '../common-types';
|
11
11
|
type TReturn = ReadonlyArray<[string, TStyleValue]>;
|
12
|
-
declare const shorthands: {
|
13
|
-
|
14
|
-
|
15
|
-
background: (_value: TStyleValue) => TReturn;
|
16
|
-
border: (_rawValue: TStyleValue) => TReturn;
|
17
|
-
borderInline: (_rawValue: TStyleValue) => TReturn;
|
18
|
-
borderBlock: (_rawValue: TStyleValue) => TReturn;
|
19
|
-
borderTop: (_rawValue: TStyleValue) => TReturn;
|
20
|
-
borderInlineEnd: (_rawValue: TStyleValue) => TReturn;
|
21
|
-
borderRight: (_rawValue: TStyleValue) => TReturn;
|
22
|
-
borderBottom: (_rawValue: TStyleValue) => TReturn;
|
23
|
-
borderInlineStart: (_rawValue: TStyleValue) => TReturn;
|
24
|
-
borderLeft: (_rawValue: TStyleValue) => TReturn;
|
25
|
-
};
|
12
|
+
declare const shorthands: Readonly<{
|
13
|
+
[key: string]: ($$PARAM_0$$: TStyleValue) => TReturn;
|
14
|
+
}>;
|
26
15
|
declare const aliases: {
|
27
16
|
borderHorizontal: any;
|
28
17
|
borderVertical: any;
|
@@ -82,7 +71,7 @@ declare const aliases: {
|
|
82
71
|
end: (val: TStyleValue) => TReturn;
|
83
72
|
};
|
84
73
|
declare const $$EXPORT_DEFAULT_DECLARATION$$: Readonly</**
|
85
|
-
* >
|
74
|
+
* > 85 | ...typeof shorthands,
|
86
75
|
* | ^^^^^^^^^^^^^^^^^^^^ Unsupported feature: Translating "object types with complex spreads" is currently not supported.
|
87
76
|
**/
|
88
77
|
any>;
|
@@ -18,20 +18,9 @@ import type { TStyleValue } from '../common-types';
|
|
18
18
|
|
19
19
|
type TReturn = $ReadOnlyArray<[string, TStyleValue]>;
|
20
20
|
|
21
|
-
declare const shorthands: {
|
22
|
-
|
23
|
-
|
24
|
-
background: (_value: TStyleValue) => TReturn,
|
25
|
-
border: (_rawValue: TStyleValue) => TReturn,
|
26
|
-
borderInline: (_rawValue: TStyleValue) => TReturn,
|
27
|
-
borderBlock: (_rawValue: TStyleValue) => TReturn,
|
28
|
-
borderTop: (_rawValue: TStyleValue) => TReturn,
|
29
|
-
borderInlineEnd: (_rawValue: TStyleValue) => TReturn,
|
30
|
-
borderRight: (_rawValue: TStyleValue) => TReturn,
|
31
|
-
borderBottom: (_rawValue: TStyleValue) => TReturn,
|
32
|
-
borderInlineStart: (_rawValue: TStyleValue) => TReturn,
|
33
|
-
borderLeft: (_rawValue: TStyleValue) => TReturn,
|
34
|
-
};
|
21
|
+
declare const shorthands: $ReadOnly<{
|
22
|
+
[key: string]: (TStyleValue) => TReturn,
|
23
|
+
}>;
|
35
24
|
|
36
25
|
declare const aliases: {
|
37
26
|
borderHorizontal: $FlowFixMe,
|
@@ -8,7 +8,7 @@ var _hash = _interopRequireDefault(require("./hash"));
|
|
8
8
|
var _stylexVarsUtils = require("./stylex-vars-utils");
|
9
9
|
var _types = require("./types");
|
10
10
|
var _defaultOptions = require("./utils/default-options");
|
11
|
-
function _interopRequireDefault(
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
12
12
|
function styleXCreateTheme(themeVars, variables, options) {
|
13
13
|
if (typeof themeVars.__themeName__ !== 'string') {
|
14
14
|
throw new Error('Can only override variables theme created with stylex.defineVars().');
|
@@ -35,7 +35,7 @@ function styleXCreateTheme(themeVars, variables, options) {
|
|
35
35
|
const stylesToInject = {};
|
36
36
|
for (const atRule of sortedAtRules) {
|
37
37
|
const decls = rulesByAtRule[atRule].join('');
|
38
|
-
const rule = `.${overrideClassName}{${decls}}`;
|
38
|
+
const rule = `.${overrideClassName}, .${overrideClassName}:root{${decls}}`;
|
39
39
|
if (atRule === 'default') {
|
40
40
|
stylesToInject[overrideClassName] = {
|
41
41
|
ltr: rule,
|
package/lib/stylex-create.d.ts
CHANGED
@@ -13,11 +13,15 @@ import type {
|
|
13
13
|
StyleXOptions,
|
14
14
|
FlatCompiledStyles,
|
15
15
|
} from './common-types';
|
16
|
+
type ClassPathsInNamespace = {
|
17
|
+
readonly [className: string]: ReadonlyArray<string>;
|
18
|
+
};
|
16
19
|
declare function styleXCreateSet(
|
17
20
|
namespaces: { readonly [$$Key$$: string]: RawStyles },
|
18
21
|
options?: StyleXOptions,
|
19
22
|
): [
|
20
23
|
{ [$$Key$$: string]: FlatCompiledStyles },
|
21
24
|
{ [$$Key$$: string]: InjectableStyle },
|
25
|
+
{ readonly [$$Key$$: string]: ClassPathsInNamespace },
|
22
26
|
];
|
23
27
|
export default styleXCreateSet;
|
package/lib/stylex-create.js
CHANGED
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = styleXCreateSet;
|
7
|
-
var _objectUtils = require("./utils/object-utils");
|
8
7
|
var _stylexInclude = require("./stylex-include");
|
9
8
|
var _defaultOptions = require("./utils/default-options");
|
10
9
|
var _flattenRawStyleObj = require("./preprocess-rules/flatten-raw-style-obj");
|
@@ -13,24 +12,36 @@ function styleXCreateSet(namespaces) {
|
|
13
12
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _defaultOptions.defaultOptions;
|
14
13
|
const resolvedNamespaces = {};
|
15
14
|
const injectedStyles = {};
|
15
|
+
const namespaceToClassPaths = {};
|
16
16
|
for (const namespaceName of Object.keys(namespaces)) {
|
17
17
|
const namespace = namespaces[namespaceName];
|
18
|
+
const classPathsInNamespace = {};
|
18
19
|
(0, _basicValidation.validateNamespace)(namespace);
|
19
|
-
const
|
20
|
+
const seenProperties = new Set();
|
21
|
+
const flattenedNamespace = (0, _flattenRawStyleObj.flattenRawStyleObject)(namespace, options).reduceRight((arr, curr) => {
|
22
|
+
if (seenProperties.has(curr[0])) {
|
23
|
+
return arr;
|
24
|
+
}
|
25
|
+
seenProperties.add(curr[0]);
|
26
|
+
arr.unshift(curr);
|
27
|
+
return arr;
|
28
|
+
}, []);
|
20
29
|
const compiledNamespaceTuples = flattenedNamespace.map(_ref => {
|
21
30
|
let [key, value] = _ref;
|
22
31
|
return [key, value.compiled(options)];
|
23
32
|
});
|
24
|
-
const compiledNamespace = (0, _objectUtils.objFromEntries)(compiledNamespaceTuples);
|
25
33
|
const namespaceObj = {};
|
26
|
-
for (const key of
|
27
|
-
const value = compiledNamespace[key];
|
34
|
+
for (const [key, value] of compiledNamespaceTuples) {
|
28
35
|
if (value instanceof _stylexInclude.IncludedStyles) {
|
29
36
|
namespaceObj[key] = value;
|
30
37
|
} else {
|
31
38
|
const classNameTuples = value.map(v => Array.isArray(v) ? v : null).filter(Boolean);
|
32
|
-
|
33
|
-
let [
|
39
|
+
classNameTuples.forEach(_ref2 => {
|
40
|
+
let [_className, _, classesToOriginalPath] = _ref2;
|
41
|
+
Object.assign(classPathsInNamespace, classesToOriginalPath);
|
42
|
+
});
|
43
|
+
const className = classNameTuples.map(_ref3 => {
|
44
|
+
let [className] = _ref3;
|
34
45
|
return className;
|
35
46
|
}).join(' ') || null;
|
36
47
|
namespaceObj[key] = className;
|
@@ -45,6 +56,7 @@ function styleXCreateSet(namespaces) {
|
|
45
56
|
...namespaceObj,
|
46
57
|
$$css: true
|
47
58
|
};
|
59
|
+
namespaceToClassPaths[namespaceName] = classPathsInNamespace;
|
48
60
|
}
|
49
|
-
return [resolvedNamespaces, injectedStyles];
|
61
|
+
return [resolvedNamespaces, injectedStyles, namespaceToClassPaths];
|
50
62
|
}
|
@@ -14,6 +14,10 @@ import type {
|
|
14
14
|
FlatCompiledStyles,
|
15
15
|
} from './common-types';
|
16
16
|
|
17
|
+
type ClassPathsInNamespace = {
|
18
|
+
+[className: string]: $ReadOnlyArray<string>,
|
19
|
+
};
|
20
|
+
|
17
21
|
// This takes the object of styles passed to `stylex.create` and transforms it.
|
18
22
|
// The transformation replaces style values with classNames.
|
19
23
|
//
|
@@ -27,4 +31,8 @@ import type {
|
|
27
31
|
declare export default function styleXCreateSet(
|
28
32
|
namespaces: { +[string]: RawStyles },
|
29
33
|
options?: StyleXOptions,
|
30
|
-
): [
|
34
|
+
): [
|
35
|
+
{ [string]: FlatCompiledStyles },
|
36
|
+
{ [string]: InjectableStyle },
|
37
|
+
{ +[string]: ClassPathsInNamespace },
|
38
|
+
];
|
@@ -9,11 +9,14 @@
|
|
9
9
|
|
10
10
|
import type { InjectableStyle, StyleXOptions } from './common-types';
|
11
11
|
import type { VarsConfig } from './stylex-vars-utils';
|
12
|
-
type
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
type VarsKeysWithStringValues<Vars extends VarsConfig> = Readonly<{
|
13
|
+
[$$Key$$: keyof Vars]: string;
|
14
|
+
}>;
|
15
|
+
type VarsObject<Vars extends VarsConfig> = Readonly<
|
16
|
+
Omit<VarsKeysWithStringValues<Vars>, keyof ({ __themeName__: string })> & {
|
17
|
+
__themeName__: string;
|
18
|
+
}
|
19
|
+
>;
|
17
20
|
declare function styleXDefineVars<Vars extends VarsConfig>(
|
18
21
|
variables: Vars,
|
19
22
|
options: Readonly<
|
@@ -9,7 +9,7 @@ var _objectUtils = require("./utils/object-utils");
|
|
9
9
|
var _defaultOptions = require("./utils/default-options");
|
10
10
|
var _stylexVarsUtils = require("./stylex-vars-utils");
|
11
11
|
var _types = require("./types");
|
12
|
-
function _interopRequireDefault(
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
13
13
|
function styleXDefineVars(variables, options) {
|
14
14
|
const {
|
15
15
|
classNamePrefix,
|
@@ -35,7 +35,7 @@ function styleXDefineVars(variables, options) {
|
|
35
35
|
}
|
36
36
|
return {
|
37
37
|
nameHash,
|
38
|
-
value
|
38
|
+
value: value
|
39
39
|
};
|
40
40
|
});
|
41
41
|
const themeVariablesObject = (0, _objectUtils.objMap)(variablesMap, _ref => {
|
@@ -10,8 +10,12 @@
|
|
10
10
|
import type { InjectableStyle, StyleXOptions } from './common-types';
|
11
11
|
import type { VarsConfig } from './stylex-vars-utils';
|
12
12
|
|
13
|
+
type VarsKeysWithStringValues<Vars: VarsConfig> = $ReadOnly<{
|
14
|
+
[$Keys<Vars>]: string,
|
15
|
+
}>;
|
16
|
+
|
13
17
|
type VarsObject<Vars: VarsConfig> = $ReadOnly<{
|
14
|
-
|
18
|
+
...VarsKeysWithStringValues<Vars>,
|
15
19
|
__themeName__: string,
|
16
20
|
}>;
|
17
21
|
|
package/lib/stylex-include.js
CHANGED
@@ -7,7 +7,7 @@ exports.IncludedStyles = void 0;
|
|
7
7
|
exports.default = stylexInclude;
|
8
8
|
var messages = _interopRequireWildcard(require("./messages"));
|
9
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 &&
|
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
11
|
let number = 0;
|
12
12
|
function uuid() {
|
13
13
|
return `__included_${++number}__`;
|
package/lib/stylex-keyframes.js
CHANGED
@@ -12,7 +12,7 @@ var _transformValue = _interopRequireDefault(require("./transform-value"));
|
|
12
12
|
var _dashify = _interopRequireDefault(require("./utils/dashify"));
|
13
13
|
var _objectUtils = require("./utils/object-utils");
|
14
14
|
var _defaultOptions = require("./utils/default-options");
|
15
|
-
function _interopRequireDefault(
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
16
16
|
function styleXKeyframes(frames) {
|
17
17
|
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _defaultOptions.defaultOptions;
|
18
18
|
const {
|