babel-plugin-transform-react-jsx-to-rn-stylesheet 3.5.4-alpha.0 → 3.5.4-alpha.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.
@@ -0,0 +1,660 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`jsx style plugin Processing module style assignment When css module enable 1`] = `
4
+ "import { createElement, Component } from 'rax';
5
+ import appScssStyleSheet from \\"./app.scss\\";
6
+ import _styleSheetModuleStyle from './app.module.scss';
7
+
8
+ function _getClassName() {
9
+ var className = [];
10
+ var args = arguments[0];
11
+ var type = Object.prototype.toString.call(args).slice(8, -1).toLowerCase();
12
+
13
+ if (type === 'string') {
14
+ args = args.trim();
15
+ args && className.push(args);
16
+ } else if (type === 'array') {
17
+ args.forEach(function (cls) {
18
+ cls = _getClassName(cls).trim();
19
+ cls && className.push(cls);
20
+ });
21
+ } else if (type === 'object') {
22
+ for (var k in args) {
23
+ k = k.trim();
24
+
25
+ if (k && args.hasOwnProperty(k) && args[k]) {
26
+ className.push(k);
27
+ }
28
+ }
29
+ }
30
+
31
+ return className.join(' ').trim();
32
+ }
33
+
34
+ function _getStyle(classNameExpression) {
35
+ var className = _getClassName(classNameExpression);
36
+
37
+ var classNameArr = className.split(/\\\\s+/);
38
+ var style = {};
39
+ classNameArr.reduce((sty, cls) => Object.assign(sty, _styleSheet[cls.trim()]), style);
40
+ return style;
41
+ }
42
+
43
+ function _getModuleClassName(moduleStyle, styleId) {
44
+ return Object.keys(moduleStyle).reduce((pre, cur) => Object.assign(pre, {
45
+ [cur]: styleId + '-' + cur
46
+ }), {});
47
+ }
48
+
49
+ var styleSheet = _getModuleClassName(_styleSheetModuleStyle, 'styleSheet');
50
+
51
+ function _mergeStyles() {
52
+ var newTarget = {};
53
+
54
+ for (var index = 0; index < arguments.length; index++) {
55
+ var [styleSheet, rawStyleName] = arguments[index];
56
+
57
+ for (var key in styleSheet) {
58
+ const _key = rawStyleName ? rawStyleName + '-' + key : key;
59
+
60
+ newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
61
+ }
62
+ }
63
+
64
+ return newTarget;
65
+ }
66
+
67
+ var _styleSheet = _mergeStyles([appScssStyleSheet, \\"\\"], [_styleSheetModuleStyle, \\"styleSheet\\"]);
68
+
69
+ class App extends Component {
70
+ render() {
71
+ const a = styleSheet.red;
72
+ return <div style={_getStyle(a)} />;
73
+ }
74
+
75
+ }"
76
+ `;
77
+
78
+ exports[`jsx style plugin Processing module style conditional expression When css module enable 1`] = `
79
+ "import { createElement, Component } from 'rax';
80
+ import appScssStyleSheet from \\"./app.scss\\";
81
+ import _styleSheetModuleStyle from './app.module.scss';
82
+
83
+ function _getClassName() {
84
+ var className = [];
85
+ var args = arguments[0];
86
+ var type = Object.prototype.toString.call(args).slice(8, -1).toLowerCase();
87
+
88
+ if (type === 'string') {
89
+ args = args.trim();
90
+ args && className.push(args);
91
+ } else if (type === 'array') {
92
+ args.forEach(function (cls) {
93
+ cls = _getClassName(cls).trim();
94
+ cls && className.push(cls);
95
+ });
96
+ } else if (type === 'object') {
97
+ for (var k in args) {
98
+ k = k.trim();
99
+
100
+ if (k && args.hasOwnProperty(k) && args[k]) {
101
+ className.push(k);
102
+ }
103
+ }
104
+ }
105
+
106
+ return className.join(' ').trim();
107
+ }
108
+
109
+ function _getStyle(classNameExpression) {
110
+ var className = _getClassName(classNameExpression);
111
+
112
+ var classNameArr = className.split(/\\\\s+/);
113
+ var style = {};
114
+ classNameArr.reduce((sty, cls) => Object.assign(sty, _styleSheet[cls.trim()]), style);
115
+ return style;
116
+ }
117
+
118
+ function _getModuleClassName(moduleStyle, styleId) {
119
+ return Object.keys(moduleStyle).reduce((pre, cur) => Object.assign(pre, {
120
+ [cur]: styleId + '-' + cur
121
+ }), {});
122
+ }
123
+
124
+ var styleSheet = _getModuleClassName(_styleSheetModuleStyle, 'styleSheet');
125
+
126
+ function _mergeStyles() {
127
+ var newTarget = {};
128
+
129
+ for (var index = 0; index < arguments.length; index++) {
130
+ var [styleSheet, rawStyleName] = arguments[index];
131
+
132
+ for (var key in styleSheet) {
133
+ const _key = rawStyleName ? rawStyleName + '-' + key : key;
134
+
135
+ newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
136
+ }
137
+ }
138
+
139
+ return newTarget;
140
+ }
141
+
142
+ var _styleSheet = _mergeStyles([appScssStyleSheet, \\"\\"], [_styleSheetModuleStyle, \\"styleSheet\\"]);
143
+
144
+ class App extends Component {
145
+ render() {
146
+ const a = 1 ? styleSheet.red : styleSheet.blue;
147
+ return <div style={_getStyle(a)} />;
148
+ }
149
+
150
+ }"
151
+ `;
152
+
153
+ exports[`jsx style plugin Processing module style spread and assign When css module enable 1`] = `
154
+ "import { createElement, Component } from 'rax';
155
+ import appScssStyleSheet from \\"./app.scss\\";
156
+ import _styleSheetModuleStyle from './app.module.scss';
157
+
158
+ function _getClassName() {
159
+ var className = [];
160
+ var args = arguments[0];
161
+ var type = Object.prototype.toString.call(args).slice(8, -1).toLowerCase();
162
+
163
+ if (type === 'string') {
164
+ args = args.trim();
165
+ args && className.push(args);
166
+ } else if (type === 'array') {
167
+ args.forEach(function (cls) {
168
+ cls = _getClassName(cls).trim();
169
+ cls && className.push(cls);
170
+ });
171
+ } else if (type === 'object') {
172
+ for (var k in args) {
173
+ k = k.trim();
174
+
175
+ if (k && args.hasOwnProperty(k) && args[k]) {
176
+ className.push(k);
177
+ }
178
+ }
179
+ }
180
+
181
+ return className.join(' ').trim();
182
+ }
183
+
184
+ function _getStyle(classNameExpression) {
185
+ var className = _getClassName(classNameExpression);
186
+
187
+ var classNameArr = className.split(/\\\\s+/);
188
+ var style = {};
189
+ classNameArr.reduce((sty, cls) => Object.assign(sty, _styleSheet[cls.trim()]), style);
190
+ return style;
191
+ }
192
+
193
+ function _getModuleClassName(moduleStyle, styleId) {
194
+ return Object.keys(moduleStyle).reduce((pre, cur) => Object.assign(pre, {
195
+ [cur]: styleId + '-' + cur
196
+ }), {});
197
+ }
198
+
199
+ var styleSheet = _getModuleClassName(_styleSheetModuleStyle, 'styleSheet');
200
+
201
+ function _mergeStyles() {
202
+ var newTarget = {};
203
+
204
+ for (var index = 0; index < arguments.length; index++) {
205
+ var [styleSheet, rawStyleName] = arguments[index];
206
+
207
+ for (var key in styleSheet) {
208
+ const _key = rawStyleName ? rawStyleName + '-' + key : key;
209
+
210
+ newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
211
+ }
212
+ }
213
+
214
+ return newTarget;
215
+ }
216
+
217
+ var _styleSheet = _mergeStyles([appScssStyleSheet, \\"\\"], [_styleSheetModuleStyle, \\"styleSheet\\"]);
218
+
219
+ class App extends Component {
220
+ render() {
221
+ const a = { ...styleSheet.red
222
+ };
223
+ const b = a;
224
+ return <div style={_getStyle({ ...b
225
+ })} />;
226
+ }
227
+
228
+ }"
229
+ `;
230
+
231
+ exports[`jsx style plugin Processing module style through call expression When css module enable 1`] = `
232
+ "import { createElement, Component } from 'rax';
233
+ import _styleSheetModuleStyle from './app.module.scss';
234
+
235
+ function _getClassName() {
236
+ var className = [];
237
+ var args = arguments[0];
238
+ var type = Object.prototype.toString.call(args).slice(8, -1).toLowerCase();
239
+
240
+ if (type === 'string') {
241
+ args = args.trim();
242
+ args && className.push(args);
243
+ } else if (type === 'array') {
244
+ args.forEach(function (cls) {
245
+ cls = _getClassName(cls).trim();
246
+ cls && className.push(cls);
247
+ });
248
+ } else if (type === 'object') {
249
+ for (var k in args) {
250
+ k = k.trim();
251
+
252
+ if (k && args.hasOwnProperty(k) && args[k]) {
253
+ className.push(k);
254
+ }
255
+ }
256
+ }
257
+
258
+ return className.join(' ').trim();
259
+ }
260
+
261
+ function _getStyle(classNameExpression) {
262
+ var className = _getClassName(classNameExpression);
263
+
264
+ var classNameArr = className.split(/\\\\s+/);
265
+ var style = {};
266
+ classNameArr.reduce((sty, cls) => Object.assign(sty, _styleSheet[cls.trim()]), style);
267
+ return style;
268
+ }
269
+
270
+ function _getModuleClassName(moduleStyle, styleId) {
271
+ return Object.keys(moduleStyle).reduce((pre, cur) => Object.assign(pre, {
272
+ [cur]: styleId + '-' + cur
273
+ }), {});
274
+ }
275
+
276
+ var styleSheet = _getModuleClassName(_styleSheetModuleStyle, 'styleSheet');
277
+
278
+ function _mergeStyles() {
279
+ var newTarget = {};
280
+
281
+ for (var index = 0; index < arguments.length; index++) {
282
+ var [styleSheet, rawStyleName] = arguments[index];
283
+
284
+ for (var key in styleSheet) {
285
+ const _key = rawStyleName ? rawStyleName + '-' + key : key;
286
+
287
+ newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
288
+ }
289
+ }
290
+
291
+ return newTarget;
292
+ }
293
+
294
+ var _styleSheet = _mergeStyles([_styleSheetModuleStyle, \\"styleSheet\\"]);
295
+
296
+ class App extends Component {
297
+ render() {
298
+ const a = Object.assign({}, styleSheet.red);
299
+ const b = Object.assign({}, a);
300
+ return <div style={_getStyle(a)}><span style={_getStyle(b)} /><span style={_getStyle(Object.assign({}, b))} /></div>;
301
+ }
302
+
303
+ }"
304
+ `;
305
+
306
+ exports[`jsx style plugin Processing multiple module style When css module enable 1`] = `
307
+ "import { createElement, Component } from 'rax';
308
+ import _styleSheetModuleStyle from './app.module.scss';
309
+ import _styleSheet2ModuleStyle from './app2.module.scss';
310
+
311
+ function _getClassName() {
312
+ var className = [];
313
+ var args = arguments[0];
314
+ var type = Object.prototype.toString.call(args).slice(8, -1).toLowerCase();
315
+
316
+ if (type === 'string') {
317
+ args = args.trim();
318
+ args && className.push(args);
319
+ } else if (type === 'array') {
320
+ args.forEach(function (cls) {
321
+ cls = _getClassName(cls).trim();
322
+ cls && className.push(cls);
323
+ });
324
+ } else if (type === 'object') {
325
+ for (var k in args) {
326
+ k = k.trim();
327
+
328
+ if (k && args.hasOwnProperty(k) && args[k]) {
329
+ className.push(k);
330
+ }
331
+ }
332
+ }
333
+
334
+ return className.join(' ').trim();
335
+ }
336
+
337
+ function _getStyle(classNameExpression) {
338
+ var className = _getClassName(classNameExpression);
339
+
340
+ var classNameArr = className.split(/\\\\s+/);
341
+ var style = {};
342
+ classNameArr.reduce((sty, cls) => Object.assign(sty, _styleSheet[cls.trim()]), style);
343
+ return style;
344
+ }
345
+
346
+ function _getModuleClassName(moduleStyle, styleId) {
347
+ return Object.keys(moduleStyle).reduce((pre, cur) => Object.assign(pre, {
348
+ [cur]: styleId + '-' + cur
349
+ }), {});
350
+ }
351
+
352
+ var styleSheet = _getModuleClassName(_styleSheetModuleStyle, 'styleSheet');
353
+
354
+ var styleSheet2 = _getModuleClassName(_styleSheet2ModuleStyle, 'styleSheet2');
355
+
356
+ function _mergeStyles() {
357
+ var newTarget = {};
358
+
359
+ for (var index = 0; index < arguments.length; index++) {
360
+ var [styleSheet, rawStyleName] = arguments[index];
361
+
362
+ for (var key in styleSheet) {
363
+ const _key = rawStyleName ? rawStyleName + '-' + key : key;
364
+
365
+ newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
366
+ }
367
+ }
368
+
369
+ return newTarget;
370
+ }
371
+
372
+ var _styleSheet = _mergeStyles([_styleSheetModuleStyle, \\"styleSheet\\"], [_styleSheet2ModuleStyle, \\"styleSheet2\\"]);
373
+
374
+ class App extends Component {
375
+ render() {
376
+ const a = styleSheet.red;
377
+ return <div style={_getStyle(\`\${a} \${styleSheet2.b}\`)} />;
378
+ }
379
+
380
+ }"
381
+ `;
382
+
383
+ exports[`jsx style plugin Provide a default stylesheet object when css module enable and import css module sheet only 1`] = `
384
+ "import { createElement, Component } from 'rax';
385
+ import _styleSheetModuleStyle from './app.module.scss';
386
+
387
+ function _getClassName() {
388
+ var className = [];
389
+ var args = arguments[0];
390
+ var type = Object.prototype.toString.call(args).slice(8, -1).toLowerCase();
391
+
392
+ if (type === 'string') {
393
+ args = args.trim();
394
+ args && className.push(args);
395
+ } else if (type === 'array') {
396
+ args.forEach(function (cls) {
397
+ cls = _getClassName(cls).trim();
398
+ cls && className.push(cls);
399
+ });
400
+ } else if (type === 'object') {
401
+ for (var k in args) {
402
+ k = k.trim();
403
+
404
+ if (k && args.hasOwnProperty(k) && args[k]) {
405
+ className.push(k);
406
+ }
407
+ }
408
+ }
409
+
410
+ return className.join(' ').trim();
411
+ }
412
+
413
+ function _getStyle(classNameExpression) {
414
+ var className = _getClassName(classNameExpression);
415
+
416
+ var classNameArr = className.split(/\\\\s+/);
417
+ var style = {};
418
+ classNameArr.reduce((sty, cls) => Object.assign(sty, _styleSheet[cls.trim()]), style);
419
+ return style;
420
+ }
421
+
422
+ function _getModuleClassName(moduleStyle, styleId) {
423
+ return Object.keys(moduleStyle).reduce((pre, cur) => Object.assign(pre, {
424
+ [cur]: styleId + '-' + cur
425
+ }), {});
426
+ }
427
+
428
+ var styleSheet = _getModuleClassName(_styleSheetModuleStyle, 'styleSheet');
429
+
430
+ function _mergeStyles() {
431
+ var newTarget = {};
432
+
433
+ for (var index = 0; index < arguments.length; index++) {
434
+ var [styleSheet, rawStyleName] = arguments[index];
435
+
436
+ for (var key in styleSheet) {
437
+ const _key = rawStyleName ? rawStyleName + '-' + key : key;
438
+
439
+ newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
440
+ }
441
+ }
442
+
443
+ return newTarget;
444
+ }
445
+
446
+ var _styleSheet = _mergeStyles([_styleSheetModuleStyle, \\"styleSheet\\"]);
447
+
448
+ class App extends Component {
449
+ render() {
450
+ return <div>
451
+ <div style={_getStyle(styleSheet.header)} />
452
+ <div style={_styleSheet[\\"red\\"]} />
453
+ </div>;
454
+ }
455
+
456
+ }"
457
+ `;
458
+
459
+ exports[`jsx style plugin combine multiple anonymous css file 1`] = `
460
+ "import { createElement, Component } from 'rax';
461
+ import app1CssStyleSheet from \\"./app1.css\\";
462
+ import app2CssStyleSheet from \\"./app2.css\\";
463
+
464
+ function _mergeEleStyles() {
465
+ return [].concat.apply([], arguments).reduce((pre, cur) => Object.assign(pre, cur), {});
466
+ }
467
+
468
+ function _mergeStyles() {
469
+ var newTarget = {};
470
+
471
+ for (var index = 0; index < arguments.length; index++) {
472
+ var [styleSheet, rawStyleName] = arguments[index];
473
+
474
+ for (var key in styleSheet) {
475
+ const _key = rawStyleName ? rawStyleName + '-' + key : key;
476
+
477
+ newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
478
+ }
479
+ }
480
+
481
+ return newTarget;
482
+ }
483
+
484
+ var _styleSheet = _mergeStyles([app1CssStyleSheet, \\"\\"], [app2CssStyleSheet, \\"\\"]);
485
+
486
+ class App extends Component {
487
+ render() {
488
+ return <div style={_mergeEleStyles(_styleSheet[\\"header1\\"], _styleSheet[\\"header2\\"])} />;
489
+ }
490
+
491
+ }"
492
+ `;
493
+
494
+ exports[`jsx style plugin combine multiple different extension style sources 1`] = `
495
+ "import { createElement, render } from 'rax';
496
+ import indexCssStyleSheet from \\"./index.css\\";
497
+ import indexScssStyleSheet from \\"./index.scss\\";
498
+ import indexLessStyleSheet from \\"../index.less\\";
499
+ import styl from \\"./index.styl\\";
500
+
501
+ function _mergeStyles() {
502
+ var newTarget = {};
503
+
504
+ for (var index = 0; index < arguments.length; index++) {
505
+ var [styleSheet, rawStyleName] = arguments[index];
506
+
507
+ for (var key in styleSheet) {
508
+ const _key = rawStyleName ? rawStyleName + '-' + key : key;
509
+
510
+ newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
511
+ }
512
+ }
513
+
514
+ return newTarget;
515
+ }
516
+
517
+ var _styleSheet = _mergeStyles([indexCssStyleSheet, \\"\\"], [indexScssStyleSheet, \\"\\"], [indexLessStyleSheet, \\"\\"], [styl, \\"\\"]);
518
+
519
+ render(<div style={_styleSheet[\\"header\\"]} />);"
520
+ `;
521
+
522
+ exports[`jsx style plugin combine multiple styles and className 1`] = `
523
+ "import { createElement, Component } from 'rax';
524
+ import appCssStyleSheet from \\"./app.css\\";
525
+ import style from \\"./style.css\\";
526
+
527
+ function _mergeEleStyles() {
528
+ return [].concat.apply([], arguments).reduce((pre, cur) => Object.assign(pre, cur), {});
529
+ }
530
+
531
+ function _mergeStyles() {
532
+ var newTarget = {};
533
+
534
+ for (var index = 0; index < arguments.length; index++) {
535
+ var [styleSheet, rawStyleName] = arguments[index];
536
+
537
+ for (var key in styleSheet) {
538
+ const _key = rawStyleName ? rawStyleName + '-' + key : key;
539
+
540
+ newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
541
+ }
542
+ }
543
+
544
+ return newTarget;
545
+ }
546
+
547
+ var _styleSheet = _mergeStyles([appCssStyleSheet, \\"\\"], [style, \\"\\"]);
548
+
549
+ class App extends Component {
550
+ render() {
551
+ return <div style={_mergeEleStyles(_styleSheet[\\"header2\\"], style.header1, style.header3)} />;
552
+ }
553
+
554
+ }"
555
+ `;
556
+
557
+ exports[`jsx style plugin combine one style and className 1`] = `
558
+ "import { createElement, Component } from 'rax';
559
+ import appCssStyleSheet from \\"./app.css\\";
560
+ import style from \\"./style.css\\";
561
+
562
+ function _mergeEleStyles() {
563
+ return [].concat.apply([], arguments).reduce((pre, cur) => Object.assign(pre, cur), {});
564
+ }
565
+
566
+ function _mergeStyles() {
567
+ var newTarget = {};
568
+
569
+ for (var index = 0; index < arguments.length; index++) {
570
+ var [styleSheet, rawStyleName] = arguments[index];
571
+
572
+ for (var key in styleSheet) {
573
+ const _key = rawStyleName ? rawStyleName + '-' + key : key;
574
+
575
+ newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
576
+ }
577
+ }
578
+
579
+ return newTarget;
580
+ }
581
+
582
+ var _styleSheet = _mergeStyles([appCssStyleSheet, \\"\\"], [style, \\"\\"]);
583
+
584
+ class App extends Component {
585
+ render() {
586
+ return <div style={_mergeEleStyles(_styleSheet[\\"header2\\"], style.header1)} />;
587
+ }
588
+
589
+ }"
590
+ `;
591
+
592
+ exports[`jsx style plugin combine the same filename style source 1`] = `
593
+ "import { createElement, Component } from 'rax';
594
+ import appCssStyleSheet from \\"./app.css\\";
595
+ import appCssStyleSheet from \\"../app.css\\";
596
+
597
+ function _mergeEleStyles() {
598
+ return [].concat.apply([], arguments).reduce((pre, cur) => Object.assign(pre, cur), {});
599
+ }
600
+
601
+ function _mergeStyles() {
602
+ var newTarget = {};
603
+
604
+ for (var index = 0; index < arguments.length; index++) {
605
+ var [styleSheet, rawStyleName] = arguments[index];
606
+
607
+ for (var key in styleSheet) {
608
+ const _key = rawStyleName ? rawStyleName + '-' + key : key;
609
+
610
+ newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
611
+ }
612
+ }
613
+
614
+ return newTarget;
615
+ }
616
+
617
+ var _styleSheet = _mergeStyles([appCssStyleSheet, \\"\\"], [appCssStyleSheet, \\"\\"]);
618
+
619
+ class App extends Component {
620
+ render() {
621
+ return <div style={_mergeEleStyles(_styleSheet[\\"header1\\"], _styleSheet[\\"header2\\"])} />;
622
+ }
623
+
624
+ }"
625
+ `;
626
+
627
+ exports[`jsx style plugin merge stylesheet when css module disable 1`] = `
628
+ "import { createElement, Component } from 'rax';
629
+ import appScssStyleSheet from \\"./app.scss\\";
630
+ import styleSheet from \\"./app.module.scss\\";
631
+
632
+ function _mergeEleStyles() {
633
+ return [].concat.apply([], arguments).reduce((pre, cur) => Object.assign(pre, cur), {});
634
+ }
635
+
636
+ function _mergeStyles() {
637
+ var newTarget = {};
638
+
639
+ for (var index = 0; index < arguments.length; index++) {
640
+ var [styleSheet, rawStyleName] = arguments[index];
641
+
642
+ for (var key in styleSheet) {
643
+ const _key = rawStyleName ? rawStyleName + '-' + key : key;
644
+
645
+ newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
646
+ }
647
+ }
648
+
649
+ return newTarget;
650
+ }
651
+
652
+ var _styleSheet = _mergeStyles([appScssStyleSheet, \\"\\"], [styleSheet, \\"\\"]);
653
+
654
+ class App extends Component {
655
+ render() {
656
+ return <div style={_mergeEleStyles(_styleSheet[\\"header\\"], styleSheet.red)} />;
657
+ }
658
+
659
+ }"
660
+ `;