@stylexjs/shared 0.1.0-beta.6 → 0.2.0-beta.10
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/README.md +81 -0
- package/lib/convert-to-className.js +13 -6
- package/lib/expand-shorthands.d.ts +5 -0
- package/lib/expand-shorthands.js +241 -101
- package/lib/generate-css-rule.js +10 -38
- package/lib/index.d.ts +14 -2
- package/lib/index.js.flow +5 -0
- package/lib/messages.js +11 -3
- package/lib/namespace-transforms/__tests__/preflatten.test.js +120 -0
- package/lib/namespace-transforms/preflatten.js +89 -0
- package/lib/physical-rtl/generate-ltr.js +32 -32
- package/lib/physical-rtl/generate-rtl.js +30 -30
- package/lib/preprocess-rules/PreRule.js +101 -0
- package/lib/preprocess-rules/application-order.js +259 -0
- package/lib/preprocess-rules/basic-validation.js +92 -0
- package/lib/preprocess-rules/expand-shorthands.js +156 -0
- package/lib/preprocess-rules/flatten-raw-style-obj.js +148 -0
- package/lib/preprocess-rules/index.js +39 -0
- package/lib/preprocess-rules/legacy-expand-shorthands.js +219 -0
- package/lib/preprocess-rules/null-out-longhand.js +310 -0
- package/lib/preprocess-rules/property-specificity.js +135 -0
- package/lib/preprocess-rules/react-native-web.js +142 -0
- package/lib/stylex-create.js +32 -91
- package/lib/stylex-defaultValue.js +397 -0
- package/lib/stylex-keyframes.js +23 -10
- package/lib/utils/Rule.js +71 -0
- package/lib/utils/default-options.js +34 -0
- package/lib/utils/genCSSRule.js +9 -8
- package/lib/utils/normalize-value.js +3 -0
- package/lib/utils/object-utils.js +24 -3
- package/lib/utils/property-priorities.js +116 -0
- package/lib/utils/split-css-value.js +47 -0
- package/lib/validate.js +1 -1
- package/package.json +1 -1
@@ -0,0 +1,135 @@
|
|
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(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
/**
|
10
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
11
|
+
*
|
12
|
+
* This source code is licensed under the MIT license found in the
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
14
|
+
*
|
15
|
+
*
|
16
|
+
*/
|
17
|
+
|
18
|
+
const shorthands = {
|
19
|
+
all: _ => {
|
20
|
+
throw new Error('all is not supported');
|
21
|
+
},
|
22
|
+
animation: _value => {
|
23
|
+
throw new Error('animation is not supported');
|
24
|
+
},
|
25
|
+
background: _value => {
|
26
|
+
throw new Error('background is not supported. Use background-color, border-image etc. instead.');
|
27
|
+
},
|
28
|
+
border: _rawValue => {
|
29
|
+
throw new Error('border is not supported. Use border-width, border-style and border-color instead.');
|
30
|
+
},
|
31
|
+
borderInline: _rawValue => {
|
32
|
+
throw new Error('borderInline is not supported. Use borderInlineWidth, borderInlineStyle and borderInlineColor instead.');
|
33
|
+
},
|
34
|
+
// @Deprecated
|
35
|
+
borderBlock: _rawValue => {
|
36
|
+
throw new Error('borderBlock is not supported. Use borderBlockWidth, borderBlockStyle and borderBlockColor instead.');
|
37
|
+
},
|
38
|
+
// @Deprecated
|
39
|
+
borderTop: _rawValue => {
|
40
|
+
throw new Error('borderTop is not supported. Use borderTopWidth, borderTopStyle and borderTopColor instead.');
|
41
|
+
},
|
42
|
+
// @Deprecated
|
43
|
+
borderInlineEnd: _rawValue => {
|
44
|
+
throw new Error('borderInlineEnd is not supported. Use borderInlineEndWidth, borderInlineEndStyle and borderInlineEndColor instead.');
|
45
|
+
},
|
46
|
+
// @Deprecated
|
47
|
+
borderRight: _rawValue => {
|
48
|
+
throw new Error('borderRight is not supported. Use borderRightWidth, borderRightStyle and borderRightColor instead.');
|
49
|
+
},
|
50
|
+
// @Deprecated
|
51
|
+
borderBottom: _rawValue => {
|
52
|
+
throw new Error('borderBottom is not supported. Use borderBottomWidth, borderBottomStyle and borderBottomColor instead.');
|
53
|
+
},
|
54
|
+
// @Deprecated
|
55
|
+
borderInlineStart: _rawValue => {
|
56
|
+
throw new Error('borderInlineStart is not supported. Use borderInlineStartWidth, borderInlineStartStyle and borderInlineStartColor instead.');
|
57
|
+
},
|
58
|
+
// @Deprecated
|
59
|
+
borderLeft: _rawValue => {
|
60
|
+
throw new Error(['`borderLeft` is not supported.', 'You could use `borderLeftWidth`, `borderLeftStyle` and `borderLeftColor`,', 'but it is preferable to use `borderInlineStartWidth`, `borderInlineStartStyle` and `borderInlineStartColor`.'].join(' '));
|
61
|
+
},
|
62
|
+
margin: value => {
|
63
|
+
const values = (0, _splitCssValue.default)(value);
|
64
|
+
if (values.length === 1) {
|
65
|
+
return [['margin', values[0]]];
|
66
|
+
} else {
|
67
|
+
throw new Error('margin shorthand with multiple values is not supported. Use marginTop, marginInlineEnd, marginBottom and marginInlineStart instead.');
|
68
|
+
}
|
69
|
+
},
|
70
|
+
padding: rawValue => {
|
71
|
+
const values = (0, _splitCssValue.default)(rawValue);
|
72
|
+
if (values.length === 1) {
|
73
|
+
return [['padding', values[0]]];
|
74
|
+
}
|
75
|
+
throw new Error('padding shorthand with multiple values is not supported. Use paddingTop, paddingInlineEnd, paddingBottom and paddingInlineStart instead.');
|
76
|
+
}
|
77
|
+
};
|
78
|
+
const aliases = {
|
79
|
+
// @UNSUPPORTED
|
80
|
+
borderHorizontal: shorthands.borderInline,
|
81
|
+
// @UNSUPPORTED
|
82
|
+
borderVertical: shorthands.borderBlock,
|
83
|
+
// @UNSUPPORTED
|
84
|
+
borderBlockStart: shorthands.borderTop,
|
85
|
+
// @UNSUPPORTED
|
86
|
+
borderEnd: shorthands.borderInlineEnd,
|
87
|
+
// @UNSUPPORTED
|
88
|
+
borderBlockEnd: shorthands.borderBottom,
|
89
|
+
// @UNSUPPORTED
|
90
|
+
borderStart: shorthands.borderInlineStart,
|
91
|
+
borderHorizontalWidth: value => [['borderInlineWidth', value]],
|
92
|
+
borderHorizontalStyle: value => [['borderInlineStyle', value]],
|
93
|
+
borderHorizontalColor: value => [['borderInlineColor', value]],
|
94
|
+
borderVerticalWidth: value => [['borderBlockWidth', value]],
|
95
|
+
borderVerticalStyle: value => [['borderBlockStyle', value]],
|
96
|
+
borderVerticalColor: value => [['borderBlockColor', value]],
|
97
|
+
borderBlockStartColor: value => [['borderTopColor', value]],
|
98
|
+
borderBlockEndColor: value => [['borderBottomColor', value]],
|
99
|
+
borderBlockStartStyle: value => [['borderTopStyle', value]],
|
100
|
+
borderBlockEndStyle: value => [['borderBottomStyle', value]],
|
101
|
+
borderBlockStartWidth: value => [['borderTopWidth', value]],
|
102
|
+
borderBlockEndWidth: value => [['borderBottomWidth', value]],
|
103
|
+
borderStartColor: value => [['borderInlineStartColor', value]],
|
104
|
+
borderEndColor: value => [['borderInlineEndColor', value]],
|
105
|
+
borderStartStyle: value => [['borderInlineStartStyle', value]],
|
106
|
+
borderEndStyle: value => [['borderInlineEndStyle', value]],
|
107
|
+
borderStartWidth: value => [['borderInlineStartWidth', value]],
|
108
|
+
borderEndWidth: value => [['borderInlineEndWidth', value]],
|
109
|
+
borderTopStartRadius: value => [['borderStartStartRadius', value]],
|
110
|
+
borderTopEndRadius: value => [['borderStartEndRadius', value]],
|
111
|
+
borderBottomStartRadius: value => [['borderEndStartRadius', value]],
|
112
|
+
borderBottomEndRadius: value => [['borderEndEndRadius', value]],
|
113
|
+
marginBlockStart: value => [['marginTop', value]],
|
114
|
+
marginBlockEnd: value => [['marginBottom', value]],
|
115
|
+
marginStart: value => [['marginInlineStart', value]],
|
116
|
+
marginEnd: value => [['marginInlineEnd', value]],
|
117
|
+
marginHorizontal: value => [['marginInline', value]],
|
118
|
+
marginVertical: value => [['marginBlock', value]],
|
119
|
+
paddingBlockStart: rawValue => [['paddingTop', rawValue]],
|
120
|
+
paddingBlockEnd: rawValue => [['paddingBottom', rawValue]],
|
121
|
+
paddingStart: value => [['paddingInlineStart', value]],
|
122
|
+
paddingEnd: value => [['paddingInlineEnd', value]],
|
123
|
+
paddingHorizontal: value => [['paddingInline', value]],
|
124
|
+
paddingVertical: value => [['paddingBlock', value]],
|
125
|
+
insetBlockStart: value => [['top', value]],
|
126
|
+
insetBlockEnd: value => [['bottom', value]],
|
127
|
+
start: value => [['insetInlineStart', value]],
|
128
|
+
end: value => [['insetInlineEnd', value]]
|
129
|
+
};
|
130
|
+
const expansions = {
|
131
|
+
...shorthands,
|
132
|
+
...aliases
|
133
|
+
};
|
134
|
+
var _default = expansions;
|
135
|
+
exports.default = _default;
|
@@ -0,0 +1,142 @@
|
|
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(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
9
|
+
/**
|
10
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
11
|
+
*
|
12
|
+
* This source code is licensed under the MIT license found in the
|
13
|
+
* LICENSE file in the root directory of this source tree.
|
14
|
+
*
|
15
|
+
*
|
16
|
+
*/
|
17
|
+
|
18
|
+
/// # Handle CSS shorthands in a React Native compatible way.
|
19
|
+
///
|
20
|
+
/// This means:
|
21
|
+
/// - disallowing certain properties altogether by throwing errors
|
22
|
+
/// - disallowing multiple values within many shorthands
|
23
|
+
/// - Treating certain non-standard properties as aliases for real CSS properties
|
24
|
+
|
25
|
+
const shorthands = {
|
26
|
+
all: _ => {
|
27
|
+
throw new Error('all is not supported');
|
28
|
+
},
|
29
|
+
animation: value => {
|
30
|
+
throw new Error('animation is not supported');
|
31
|
+
},
|
32
|
+
background: value => {
|
33
|
+
throw new Error('background is not supported. Use background-color, border-image etc. instead.');
|
34
|
+
},
|
35
|
+
border: rawValue => {
|
36
|
+
throw new Error('border is not supported. Use border-width, border-style and border-color instead.');
|
37
|
+
},
|
38
|
+
borderInline: rawValue => {
|
39
|
+
throw new Error('borderInline is not supported. Use borderInlineWidth, borderInlineStyle and borderInlineColor instead.');
|
40
|
+
},
|
41
|
+
// @Deprecated
|
42
|
+
borderBlock: rawValue => {
|
43
|
+
throw new Error('borderBlock is not supported. Use borderBlockWidth, borderBlockStyle and borderBlockColor instead.');
|
44
|
+
},
|
45
|
+
// @Deprecated
|
46
|
+
borderTop: rawValue => {
|
47
|
+
throw new Error('borderTop is not supported. Use borderTopWidth, borderTopStyle and borderTopColor instead.');
|
48
|
+
},
|
49
|
+
// @Deprecated
|
50
|
+
borderInlineEnd: rawValue => {
|
51
|
+
throw new Error('borderInlineEnd is not supported. Use borderInlineEndWidth, borderInlineEndStyle and borderInlineEndColor instead.');
|
52
|
+
},
|
53
|
+
// @Deprecated
|
54
|
+
borderRight: rawValue => {
|
55
|
+
throw new Error('borderRight is not supported. Use borderRightWidth, borderRightStyle and borderRightColor instead.');
|
56
|
+
},
|
57
|
+
// @Deprecated
|
58
|
+
borderBottom: rawValue => {
|
59
|
+
throw new Error('borderBottom is not supported. Use borderBottomWidth, borderBottomStyle and borderBottomColor instead.');
|
60
|
+
},
|
61
|
+
// @Deprecated
|
62
|
+
borderInlineStart: rawValue => {
|
63
|
+
throw new Error('borderInlineStart is not supported. Use borderInlineStartWidth, borderInlineStartStyle and borderInlineStartColor instead.');
|
64
|
+
},
|
65
|
+
// @Deprecated
|
66
|
+
borderLeft: rawValue => {
|
67
|
+
throw new Error(['`borderLeft` is not supported.', 'You could use `borderLeftWidth`, `borderLeftStyle` and `borderLeftColor`,', 'but it is preferable to use `borderInlineStartWidth`, `borderInlineStartStyle` and `borderInlineStartColor`.'].join(' '));
|
68
|
+
},
|
69
|
+
margin: value => {
|
70
|
+
const values = typeof value === 'number' ? [value] : (0, _splitCssValue.default)(value);
|
71
|
+
if (values.length === 1) {
|
72
|
+
return [['margin', values[0]]];
|
73
|
+
} else {
|
74
|
+
throw new Error('margin shorthand with multiple values is not supported. Use marginTop, marginInlineEnd, marginBottom and marginInlineStart instead.');
|
75
|
+
}
|
76
|
+
},
|
77
|
+
padding: rawValue => {
|
78
|
+
const values = typeof rawValue === 'number' ? [rawValue] : (0, _splitCssValue.default)(rawValue);
|
79
|
+
if (values.length === 1) {
|
80
|
+
return [['padding', values[0]]];
|
81
|
+
}
|
82
|
+
throw new Error('padding shorthand with multiple values is not supported. Use paddingTop, paddingInlineEnd, paddingBottom and paddingInlineStart instead.');
|
83
|
+
}
|
84
|
+
};
|
85
|
+
const aliases = {
|
86
|
+
// @UNSUPPORTED
|
87
|
+
borderHorizontal: shorthands.borderInline,
|
88
|
+
// @UNSUPPORTED
|
89
|
+
borderVertical: shorthands.borderBlock,
|
90
|
+
// @UNSUPPORTED
|
91
|
+
borderBlockStart: shorthands.borderTop,
|
92
|
+
// @UNSUPPORTED
|
93
|
+
borderEnd: shorthands.borderInlineEnd,
|
94
|
+
// @UNSUPPORTED
|
95
|
+
borderBlockEnd: shorthands.borderBottom,
|
96
|
+
// @UNSUPPORTED
|
97
|
+
borderStart: shorthands.borderInlineStart,
|
98
|
+
borderHorizontalWidth: value => [['borderInlineWidth', value]],
|
99
|
+
borderHorizontalStyle: value => [['borderInlineStyle', value]],
|
100
|
+
borderHorizontalColor: value => [['borderInlineColor', value]],
|
101
|
+
borderVerticalWidth: value => [['borderBlockWidth', value]],
|
102
|
+
borderVerticalStyle: value => [['borderBlockStyle', value]],
|
103
|
+
borderVerticalColor: value => [['borderBlockColor', value]],
|
104
|
+
borderBlockStartColor: value => [['borderTopColor', value]],
|
105
|
+
borderBlockEndColor: value => [['borderBottomColor', value]],
|
106
|
+
borderBlockStartStyle: value => [['borderTopStyle', value]],
|
107
|
+
borderBlockEndStyle: value => [['borderBottomStyle', value]],
|
108
|
+
borderBlockStartWidth: value => [['borderTopWidth', value]],
|
109
|
+
borderBlockEndWidth: value => [['borderBottomWidth', value]],
|
110
|
+
borderStartColor: value => [['borderInlineStartColor', value]],
|
111
|
+
borderEndColor: value => [['borderInlineEndColor', value]],
|
112
|
+
borderStartStyle: value => [['borderInlineStartStyle', value]],
|
113
|
+
borderEndStyle: value => [['borderInlineEndStyle', value]],
|
114
|
+
borderStartWidth: value => [['borderInlineStartWidth', value]],
|
115
|
+
borderEndWidth: value => [['borderInlineEndWidth', value]],
|
116
|
+
borderTopStartRadius: value => [['borderStartStartRadius', value]],
|
117
|
+
borderTopEndRadius: value => [['borderStartEndRadius', value]],
|
118
|
+
borderBottomStartRadius: value => [['borderEndStartRadius', value]],
|
119
|
+
borderBottomEndRadius: value => [['borderEndEndRadius', value]],
|
120
|
+
marginBlockStart: value => [['marginTop', value]],
|
121
|
+
marginBlockEnd: value => [['marginBottom', value]],
|
122
|
+
marginStart: value => [['marginInlineStart', value]],
|
123
|
+
marginEnd: value => [['marginInlineEnd', value]],
|
124
|
+
marginHorizontal: value => [['marginInline', value]],
|
125
|
+
marginVertical: value => [['marginBlock', value]],
|
126
|
+
paddingBlockStart: rawValue => [['paddingTop', rawValue]],
|
127
|
+
paddingBlockEnd: rawValue => [['paddingBottom', rawValue]],
|
128
|
+
paddingStart: value => [['paddingInlineStart', value]],
|
129
|
+
paddingEnd: value => [['paddingInlineEnd', value]],
|
130
|
+
paddingHorizontal: value => [['paddingInline', value]],
|
131
|
+
paddingVertical: value => [['paddingBlock', value]],
|
132
|
+
insetBlockStart: value => [['top', value]],
|
133
|
+
insetBlockEnd: value => [['bottom', value]],
|
134
|
+
start: value => [['insetInlineStart', value]],
|
135
|
+
end: value => [['insetInlineEnd', value]]
|
136
|
+
};
|
137
|
+
const expansions = {
|
138
|
+
...shorthands,
|
139
|
+
...aliases
|
140
|
+
};
|
141
|
+
var _default = expansions;
|
142
|
+
exports.default = _default;
|
package/lib/stylex-create.js
CHANGED
@@ -4,14 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.default = styleXCreateSet;
|
7
|
-
var _convertToClassName = _interopRequireDefault(require("./convert-to-className"));
|
8
|
-
var _expandShorthands = _interopRequireDefault(require("./expand-shorthands"));
|
9
7
|
var _objectUtils = require("./utils/object-utils");
|
10
|
-
var messages = _interopRequireWildcard(require("./messages"));
|
11
8
|
var _stylexInclude = require("./stylex-include");
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
var _defaultOptions = require("./utils/default-options");
|
10
|
+
var _flattenRawStyleObj = require("./preprocess-rules/flatten-raw-style-obj");
|
11
|
+
var _basicValidation = require("./preprocess-rules/basic-validation");
|
15
12
|
/**
|
16
13
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
17
14
|
*
|
@@ -32,97 +29,41 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
32
29
|
//
|
33
30
|
// Before returning, it ensures that there are no duplicate styles being injected.
|
34
31
|
function styleXCreateSet(namespaces) {
|
35
|
-
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] :
|
32
|
+
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : _defaultOptions.defaultOptions;
|
36
33
|
const resolvedNamespaces = {};
|
37
34
|
const injectedStyles = {};
|
38
35
|
for (const namespaceName of Object.keys(namespaces)) {
|
39
36
|
const namespace = namespaces[namespaceName];
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
}
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
// }
|
64
|
-
//
|
65
|
-
// First, it expands shorthand properties. (margin => marginTop, marginBottom, marginStart, marginEnd)
|
66
|
-
// Then, it converts each style value to a className.
|
67
|
-
// Then, it returns the transformed style Object and an object of injected styles.
|
68
|
-
function styleXCreateNamespace(style, options) {
|
69
|
-
const namespaceEntries = (0, _objectUtils.objEntries)(style);
|
70
|
-
|
71
|
-
// First the shorthand properties are expanded.
|
72
|
-
// e.g. `margin` gets expanded to `marginTop`, `marginBottom`, `marginStart`, `marginEnd`.
|
73
|
-
// `entries` is an array of [key, value] pairs.
|
74
|
-
const entries = namespaceEntries.flatMap(_ref => {
|
75
|
-
let [key, value] = _ref;
|
76
|
-
if (value instanceof _stylexInclude.IncludedStyles) {
|
77
|
-
return [[key, value]];
|
78
|
-
}
|
79
|
-
if (value != null && typeof value === 'object' && !Array.isArray(value)) {
|
80
|
-
if (!key.startsWith(':') && !key.startsWith('@')) {
|
81
|
-
throw new Error(messages.INVALID_PSEUDO);
|
82
|
-
}
|
83
|
-
return [[key, (0, _objectUtils.objFromEntries)((0, _objectUtils.objEntries)(value).flatMap(_ref2 => {
|
84
|
-
let [innerKey, innerValue] = _ref2;
|
85
|
-
if (innerValue != null && typeof innerValue === 'object' && !Array.isArray(innerValue)) {
|
86
|
-
throw new Error(messages.ILLEGAL_NESTED_PSEUDO);
|
37
|
+
(0, _basicValidation.validateNamespace)(namespace);
|
38
|
+
const flattenedNamespace = (0, _flattenRawStyleObj.flattenRawStyleObject)(namespace, options);
|
39
|
+
const compiledNamespaceTuples = flattenedNamespace.map(_ref => {
|
40
|
+
let [key, value] = _ref;
|
41
|
+
return [key, value.compiled(options)];
|
42
|
+
});
|
43
|
+
const compiledNamespace = (0, _objectUtils.objFromEntries)(compiledNamespaceTuples);
|
44
|
+
const namespaceObj = {};
|
45
|
+
for (const key of Object.keys(compiledNamespace)) {
|
46
|
+
const value = compiledNamespace[key];
|
47
|
+
if (value instanceof _stylexInclude.IncludedStyles) {
|
48
|
+
namespaceObj[key] = value;
|
49
|
+
} else {
|
50
|
+
const classNameTuples = value.map(v => Array.isArray(v) ? v : null).filter(Boolean);
|
51
|
+
const className = classNameTuples.map(_ref2 => {
|
52
|
+
let [className] = _ref2;
|
53
|
+
return className;
|
54
|
+
}).join(' ') || null;
|
55
|
+
namespaceObj[key] = className;
|
56
|
+
for (const [className, injectable] of classNameTuples) {
|
57
|
+
if (injectedStyles[className] == null) {
|
58
|
+
injectedStyles[className] = injectable;
|
59
|
+
}
|
87
60
|
}
|
88
|
-
return (0, _expandShorthands.default)([innerKey, innerValue]);
|
89
|
-
}))]];
|
90
|
-
} else {
|
91
|
-
if (typeof value !== 'string' && typeof value !== 'number' && !Array.isArray(value)) {
|
92
|
-
throw new Error(messages.ILLEGAL_PROP_VALUE);
|
93
|
-
}
|
94
|
-
if (Array.isArray(value) && value.some(val => typeof val === 'object')) {
|
95
|
-
throw new Error(messages.ILLEGAL_PROP_ARRAY_VALUE);
|
96
|
-
}
|
97
|
-
return (0, _expandShorthands.default)([key, value]);
|
98
|
-
}
|
99
|
-
});
|
100
|
-
|
101
|
-
// Now each [key, value] pair is considered a single atomic style.
|
102
|
-
// This atomic style is converted to a className by hashing
|
103
|
-
//
|
104
|
-
// The [key, className] pair is then added to the output Object: `resolvedNamespace`.
|
105
|
-
// While hashing, the CSS rule that the className is generated from is also added to the output Object: `injectedStyles`.
|
106
|
-
const resolvedNamespace = {};
|
107
|
-
const injectedStyles = {};
|
108
|
-
for (const [key, val] of entries) {
|
109
|
-
if (val instanceof _stylexInclude.IncludedStyles) {
|
110
|
-
resolvedNamespace[key] = val;
|
111
|
-
} else if (val != null && typeof val === 'object' && !Array.isArray(val)) {
|
112
|
-
const pseudo = key;
|
113
|
-
const innerObj = {};
|
114
|
-
for (const [innerKey, innerVal] of (0, _objectUtils.objEntries)(val)) {
|
115
|
-
const [updatedKey, className, cssRule] = (0, _convertToClassName.default)([innerKey, innerVal], pseudo, options);
|
116
|
-
innerObj[updatedKey] = className;
|
117
|
-
injectedStyles[updatedKey + pseudo] = [className, cssRule];
|
118
61
|
}
|
119
|
-
resolvedNamespace[key] = innerObj;
|
120
|
-
} else {
|
121
|
-
const [updatedKey, className, cssRule] = (0, _convertToClassName.default)([key, val], undefined, options);
|
122
|
-
resolvedNamespace[updatedKey] = className;
|
123
|
-
injectedStyles[updatedKey] = [className, cssRule];
|
124
62
|
}
|
63
|
+
resolvedNamespaces[namespaceName] = {
|
64
|
+
...namespaceObj,
|
65
|
+
$$css: true
|
66
|
+
};
|
125
67
|
}
|
126
|
-
|
127
|
-
return [resolvedNamespace, finalInjectedStyles];
|
68
|
+
return [resolvedNamespaces, injectedStyles];
|
128
69
|
}
|