@builder.io/mitosis 0.3.14 → 0.3.15
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.
|
@@ -167,29 +167,44 @@ var TWRNC_STYLES_PLUGIN = function () { return ({
|
|
|
167
167
|
post: function (json) {
|
|
168
168
|
(0, legacy_1.default)(json).forEach(function (node) {
|
|
169
169
|
if ((0, is_mitosis_node_1.isMitosisNode)(node)) {
|
|
170
|
-
var
|
|
171
|
-
node.properties.class,
|
|
172
|
-
node.properties.className,
|
|
173
|
-
node.bindings.class,
|
|
174
|
-
node.bindings.className,
|
|
175
|
-
]
|
|
170
|
+
var staticClasses = [node.properties.class, node.properties.className]
|
|
176
171
|
.filter(Boolean)
|
|
177
172
|
.join(' ');
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
173
|
+
var dynamicClasses = [node.bindings.class, node.bindings.className].filter(Boolean);
|
|
174
|
+
if (staticClasses || dynamicClasses.length) {
|
|
175
|
+
var styleCode = '';
|
|
176
|
+
if (staticClasses) {
|
|
177
|
+
styleCode = "tw`".concat(staticClasses, "`");
|
|
178
|
+
}
|
|
179
|
+
if (dynamicClasses.length) {
|
|
180
|
+
var dynamicCode = dynamicClasses
|
|
181
|
+
.map(function (dc) { return (dc && dc.code ? dc.code : null); })
|
|
182
|
+
.filter(Boolean)
|
|
183
|
+
.join(', ');
|
|
184
|
+
if (dynamicCode) {
|
|
185
|
+
if (styleCode) {
|
|
186
|
+
// If we have both static and dynamic classes
|
|
187
|
+
styleCode = "tw.style(".concat(styleCode, ", ").concat(dynamicCode, ")");
|
|
188
|
+
}
|
|
189
|
+
else if (dynamicClasses.length > 1) {
|
|
190
|
+
// If we have multiple dynamic classes
|
|
191
|
+
styleCode = "tw.style([".concat(dynamicCode, "])");
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
// If we have a single dynamic class
|
|
195
|
+
styleCode = "tw.style(".concat(dynamicCode, ")");
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
if (styleCode) {
|
|
200
|
+
node.bindings.style = (0, bindings_1.createSingleBinding)({ code: styleCode });
|
|
201
|
+
}
|
|
192
202
|
}
|
|
203
|
+
// Clean up original class and className properties/bindings
|
|
204
|
+
delete node.properties.class;
|
|
205
|
+
delete node.properties.className;
|
|
206
|
+
delete node.bindings.class;
|
|
207
|
+
delete node.bindings.className;
|
|
193
208
|
}
|
|
194
209
|
});
|
|
195
210
|
},
|