babel-plugin-transform-react-jsx-to-rn-stylesheet 3.7.0-alpha.2 → 3.7.0-alpha.4

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.
@@ -4,12 +4,10 @@ exports[`jsx style plugin Processing module style assignment When css module ena
4
4
  "import { createElement, Component } from 'rax';
5
5
  import _appScssStyleSheet from "./app.scss";
6
6
  import _styleSheetModuleStyle from './app.module.scss';
7
-
8
7
  function _getClassName() {
9
8
  var className = [];
10
9
  var args = arguments[0];
11
10
  var type = Object.prototype.toString.call(args).slice(8, -1).toLowerCase();
12
-
13
11
  if (type === 'string') {
14
12
  args = args.trim();
15
13
  args && className.push(args);
@@ -21,57 +19,43 @@ function _getClassName() {
21
19
  } else if (type === 'object') {
22
20
  for (var k in args) {
23
21
  k = k.trim();
24
-
25
22
  if (k && args.hasOwnProperty(k) && args[k]) {
26
23
  className.push(k);
27
24
  }
28
25
  }
29
26
  }
30
-
31
27
  return className.join(' ').trim();
32
28
  }
33
-
34
29
  function _getStyle(classNameExpression) {
35
30
  var className = _getClassName(classNameExpression);
36
-
37
31
  var classNameArr = className.split(/\\s+/);
38
32
  var style = {};
39
33
  classNameArr.reduce((sty, cls) => Object.assign(sty, _styleSheet[cls.trim()]), style);
40
34
  return style;
41
35
  }
42
-
43
36
  function _getModuleClassName(moduleStyle, styleId) {
44
37
  return Object.keys(moduleStyle).reduce((pre, cur) => Object.assign(pre, {
45
38
  [cur]: styleId + '-' + cur
46
39
  }), {});
47
40
  }
48
-
49
41
  var styleSheet = _getModuleClassName(_styleSheetModuleStyle, 'styleSheet');
50
-
51
42
  function _mergeStyles() {
52
43
  var newTarget = {};
53
-
54
44
  for (var index = 0; index < arguments.length; index++) {
55
45
  var [styleSheet, rawStyleName] = arguments[index];
56
-
57
46
  for (var key in styleSheet) {
58
47
  const _key = rawStyleName ? rawStyleName + '-' + key : key;
59
-
60
48
  newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
61
49
  }
62
50
  }
63
-
64
51
  return newTarget;
65
52
  }
66
-
67
53
  var _styleSheet = _mergeStyles([_appScssStyleSheet, ""], [_styleSheetModuleStyle, "styleSheet"]);
68
-
69
54
  class App extends Component {
70
55
  render() {
71
56
  const a = styleSheet.red;
72
57
  return <div style={_getStyle(a)} />;
73
58
  }
74
-
75
59
  }"
76
60
  `;
77
61
 
@@ -79,12 +63,10 @@ exports[`jsx style plugin Processing module style conditional expression When cs
79
63
  "import { createElement, Component } from 'rax';
80
64
  import _appScssStyleSheet from "./app.scss";
81
65
  import _styleSheetModuleStyle from './app.module.scss';
82
-
83
66
  function _getClassName() {
84
67
  var className = [];
85
68
  var args = arguments[0];
86
69
  var type = Object.prototype.toString.call(args).slice(8, -1).toLowerCase();
87
-
88
70
  if (type === 'string') {
89
71
  args = args.trim();
90
72
  args && className.push(args);
@@ -96,57 +78,43 @@ function _getClassName() {
96
78
  } else if (type === 'object') {
97
79
  for (var k in args) {
98
80
  k = k.trim();
99
-
100
81
  if (k && args.hasOwnProperty(k) && args[k]) {
101
82
  className.push(k);
102
83
  }
103
84
  }
104
85
  }
105
-
106
86
  return className.join(' ').trim();
107
87
  }
108
-
109
88
  function _getStyle(classNameExpression) {
110
89
  var className = _getClassName(classNameExpression);
111
-
112
90
  var classNameArr = className.split(/\\s+/);
113
91
  var style = {};
114
92
  classNameArr.reduce((sty, cls) => Object.assign(sty, _styleSheet[cls.trim()]), style);
115
93
  return style;
116
94
  }
117
-
118
95
  function _getModuleClassName(moduleStyle, styleId) {
119
96
  return Object.keys(moduleStyle).reduce((pre, cur) => Object.assign(pre, {
120
97
  [cur]: styleId + '-' + cur
121
98
  }), {});
122
99
  }
123
-
124
100
  var styleSheet = _getModuleClassName(_styleSheetModuleStyle, 'styleSheet');
125
-
126
101
  function _mergeStyles() {
127
102
  var newTarget = {};
128
-
129
103
  for (var index = 0; index < arguments.length; index++) {
130
104
  var [styleSheet, rawStyleName] = arguments[index];
131
-
132
105
  for (var key in styleSheet) {
133
106
  const _key = rawStyleName ? rawStyleName + '-' + key : key;
134
-
135
107
  newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
136
108
  }
137
109
  }
138
-
139
110
  return newTarget;
140
111
  }
141
-
142
112
  var _styleSheet = _mergeStyles([_appScssStyleSheet, ""], [_styleSheetModuleStyle, "styleSheet"]);
143
-
144
113
  class App extends Component {
145
114
  render() {
146
115
  const a = 1 ? styleSheet.red : styleSheet.blue;
147
116
  return <div style={_getStyle(a)} />;
148
117
  }
149
-
150
118
  }"
151
119
  `;
152
120
 
@@ -154,12 +122,10 @@ exports[`jsx style plugin Processing module style spread and assign When css mod
154
122
  "import { createElement, Component } from 'rax';
155
123
  import _appScssStyleSheet from "./app.scss";
156
124
  import _styleSheetModuleStyle from './app.module.scss';
157
-
158
125
  function _getClassName() {
159
126
  var className = [];
160
127
  var args = arguments[0];
161
128
  var type = Object.prototype.toString.call(args).slice(8, -1).toLowerCase();
162
-
163
129
  if (type === 'string') {
164
130
  args = args.trim();
165
131
  args && className.push(args);
@@ -171,72 +137,58 @@ function _getClassName() {
171
137
  } else if (type === 'object') {
172
138
  for (var k in args) {
173
139
  k = k.trim();
174
-
175
140
  if (k && args.hasOwnProperty(k) && args[k]) {
176
141
  className.push(k);
177
142
  }
178
143
  }
179
144
  }
180
-
181
145
  return className.join(' ').trim();
182
146
  }
183
-
184
147
  function _getStyle(classNameExpression) {
185
148
  var className = _getClassName(classNameExpression);
186
-
187
149
  var classNameArr = className.split(/\\s+/);
188
150
  var style = {};
189
151
  classNameArr.reduce((sty, cls) => Object.assign(sty, _styleSheet[cls.trim()]), style);
190
152
  return style;
191
153
  }
192
-
193
154
  function _getModuleClassName(moduleStyle, styleId) {
194
155
  return Object.keys(moduleStyle).reduce((pre, cur) => Object.assign(pre, {
195
156
  [cur]: styleId + '-' + cur
196
157
  }), {});
197
158
  }
198
-
199
159
  var styleSheet = _getModuleClassName(_styleSheetModuleStyle, 'styleSheet');
200
-
201
160
  function _mergeStyles() {
202
161
  var newTarget = {};
203
-
204
162
  for (var index = 0; index < arguments.length; index++) {
205
163
  var [styleSheet, rawStyleName] = arguments[index];
206
-
207
164
  for (var key in styleSheet) {
208
165
  const _key = rawStyleName ? rawStyleName + '-' + key : key;
209
-
210
166
  newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
211
167
  }
212
168
  }
213
-
214
169
  return newTarget;
215
170
  }
216
-
217
171
  var _styleSheet = _mergeStyles([_appScssStyleSheet, ""], [_styleSheetModuleStyle, "styleSheet"]);
218
-
219
172
  class App extends Component {
220
173
  render() {
221
- const a = { ...styleSheet.red
174
+ const a = {
175
+ ...styleSheet.red
222
176
  };
223
177
  const b = a;
224
- return <div style={_getStyle({ ...b
178
+ return <div style={_getStyle({
179
+ ...b
225
180
  })} />;
226
181
  }
227
-
228
182
  }"
229
183
  `;
230
184
 
231
185
  exports[`jsx style plugin Processing module style through call expression When css module enable 1`] = `
232
186
  "import { createElement, Component } from 'rax';
233
187
  import _styleSheetModuleStyle from './app.module.scss';
234
-
235
188
  function _getClassName() {
236
189
  var className = [];
237
190
  var args = arguments[0];
238
191
  var type = Object.prototype.toString.call(args).slice(8, -1).toLowerCase();
239
-
240
192
  if (type === 'string') {
241
193
  args = args.trim();
242
194
  args && className.push(args);
@@ -248,58 +200,44 @@ function _getClassName() {
248
200
  } else if (type === 'object') {
249
201
  for (var k in args) {
250
202
  k = k.trim();
251
-
252
203
  if (k && args.hasOwnProperty(k) && args[k]) {
253
204
  className.push(k);
254
205
  }
255
206
  }
256
207
  }
257
-
258
208
  return className.join(' ').trim();
259
209
  }
260
-
261
210
  function _getStyle(classNameExpression) {
262
211
  var className = _getClassName(classNameExpression);
263
-
264
212
  var classNameArr = className.split(/\\s+/);
265
213
  var style = {};
266
214
  classNameArr.reduce((sty, cls) => Object.assign(sty, _styleSheet[cls.trim()]), style);
267
215
  return style;
268
216
  }
269
-
270
217
  function _getModuleClassName(moduleStyle, styleId) {
271
218
  return Object.keys(moduleStyle).reduce((pre, cur) => Object.assign(pre, {
272
219
  [cur]: styleId + '-' + cur
273
220
  }), {});
274
221
  }
275
-
276
222
  var styleSheet = _getModuleClassName(_styleSheetModuleStyle, 'styleSheet');
277
-
278
223
  function _mergeStyles() {
279
224
  var newTarget = {};
280
-
281
225
  for (var index = 0; index < arguments.length; index++) {
282
226
  var [styleSheet, rawStyleName] = arguments[index];
283
-
284
227
  for (var key in styleSheet) {
285
228
  const _key = rawStyleName ? rawStyleName + '-' + key : key;
286
-
287
229
  newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
288
230
  }
289
231
  }
290
-
291
232
  return newTarget;
292
233
  }
293
-
294
234
  var _styleSheet = _mergeStyles([_styleSheetModuleStyle, "styleSheet"]);
295
-
296
235
  class App extends Component {
297
236
  render() {
298
237
  const a = Object.assign({}, styleSheet.red);
299
238
  const b = Object.assign({}, a);
300
239
  return <div style={_getStyle(a)}><span style={_getStyle(b)} /><span style={_getStyle(Object.assign({}, b))} /></div>;
301
240
  }
302
-
303
241
  }"
304
242
  `;
305
243
 
@@ -307,12 +245,10 @@ exports[`jsx style plugin Processing multiple module style When css module enabl
307
245
  "import { createElement, Component } from 'rax';
308
246
  import _styleSheetModuleStyle from './app.module.scss';
309
247
  import _styleSheet2ModuleStyle from './app2.module.scss';
310
-
311
248
  function _getClassName() {
312
249
  var className = [];
313
250
  var args = arguments[0];
314
251
  var type = Object.prototype.toString.call(args).slice(8, -1).toLowerCase();
315
-
316
252
  if (type === 'string') {
317
253
  args = args.trim();
318
254
  args && className.push(args);
@@ -324,71 +260,54 @@ function _getClassName() {
324
260
  } else if (type === 'object') {
325
261
  for (var k in args) {
326
262
  k = k.trim();
327
-
328
263
  if (k && args.hasOwnProperty(k) && args[k]) {
329
264
  className.push(k);
330
265
  }
331
266
  }
332
267
  }
333
-
334
268
  return className.join(' ').trim();
335
269
  }
336
-
337
270
  function _getStyle(classNameExpression) {
338
271
  var className = _getClassName(classNameExpression);
339
-
340
272
  var classNameArr = className.split(/\\s+/);
341
273
  var style = {};
342
274
  classNameArr.reduce((sty, cls) => Object.assign(sty, _styleSheet[cls.trim()]), style);
343
275
  return style;
344
276
  }
345
-
346
277
  function _getModuleClassName(moduleStyle, styleId) {
347
278
  return Object.keys(moduleStyle).reduce((pre, cur) => Object.assign(pre, {
348
279
  [cur]: styleId + '-' + cur
349
280
  }), {});
350
281
  }
351
-
352
282
  var styleSheet = _getModuleClassName(_styleSheetModuleStyle, 'styleSheet');
353
-
354
283
  var styleSheet2 = _getModuleClassName(_styleSheet2ModuleStyle, 'styleSheet2');
355
-
356
284
  function _mergeStyles() {
357
285
  var newTarget = {};
358
-
359
286
  for (var index = 0; index < arguments.length; index++) {
360
287
  var [styleSheet, rawStyleName] = arguments[index];
361
-
362
288
  for (var key in styleSheet) {
363
289
  const _key = rawStyleName ? rawStyleName + '-' + key : key;
364
-
365
290
  newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
366
291
  }
367
292
  }
368
-
369
293
  return newTarget;
370
294
  }
371
-
372
295
  var _styleSheet = _mergeStyles([_styleSheetModuleStyle, "styleSheet"], [_styleSheet2ModuleStyle, "styleSheet2"]);
373
-
374
296
  class App extends Component {
375
297
  render() {
376
298
  const a = styleSheet.red;
377
299
  return <div style={_getStyle(\`\${a} \${styleSheet2.b}\`)} />;
378
300
  }
379
-
380
301
  }"
381
302
  `;
382
303
 
383
304
  exports[`jsx style plugin Provide a default stylesheet object when css module enable and import css module sheet only 1`] = `
384
305
  "import { createElement, Component } from 'rax';
385
306
  import _styleSheetModuleStyle from './app.module.scss';
386
-
387
307
  function _getClassName() {
388
308
  var className = [];
389
309
  var args = arguments[0];
390
310
  var type = Object.prototype.toString.call(args).slice(8, -1).toLowerCase();
391
-
392
311
  if (type === 'string') {
393
312
  args = args.trim();
394
313
  args && className.push(args);
@@ -400,51 +319,38 @@ function _getClassName() {
400
319
  } else if (type === 'object') {
401
320
  for (var k in args) {
402
321
  k = k.trim();
403
-
404
322
  if (k && args.hasOwnProperty(k) && args[k]) {
405
323
  className.push(k);
406
324
  }
407
325
  }
408
326
  }
409
-
410
327
  return className.join(' ').trim();
411
328
  }
412
-
413
329
  function _getStyle(classNameExpression) {
414
330
  var className = _getClassName(classNameExpression);
415
-
416
331
  var classNameArr = className.split(/\\s+/);
417
332
  var style = {};
418
333
  classNameArr.reduce((sty, cls) => Object.assign(sty, _styleSheet[cls.trim()]), style);
419
334
  return style;
420
335
  }
421
-
422
336
  function _getModuleClassName(moduleStyle, styleId) {
423
337
  return Object.keys(moduleStyle).reduce((pre, cur) => Object.assign(pre, {
424
338
  [cur]: styleId + '-' + cur
425
339
  }), {});
426
340
  }
427
-
428
341
  var styleSheet = _getModuleClassName(_styleSheetModuleStyle, 'styleSheet');
429
-
430
342
  function _mergeStyles() {
431
343
  var newTarget = {};
432
-
433
344
  for (var index = 0; index < arguments.length; index++) {
434
345
  var [styleSheet, rawStyleName] = arguments[index];
435
-
436
346
  for (var key in styleSheet) {
437
347
  const _key = rawStyleName ? rawStyleName + '-' + key : key;
438
-
439
348
  newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
440
349
  }
441
350
  }
442
-
443
351
  return newTarget;
444
352
  }
445
-
446
353
  var _styleSheet = _mergeStyles([_styleSheetModuleStyle, "styleSheet"]);
447
-
448
354
  class App extends Component {
449
355
  render() {
450
356
  return <div>
@@ -452,27 +358,22 @@ class App extends Component {
452
358
  <div style={_styleSheet["red"]} />
453
359
  </div>;
454
360
  }
455
-
456
361
  }"
457
362
  `;
458
363
 
459
364
  exports[`jsx style plugin combine inline style object and className 1`] = `
460
365
  "import { createElement, Component } from 'rax';
461
366
  import _appCssStyleSheet from "./app.css";
462
-
463
367
  function _mergeEleStyles() {
464
368
  return [].concat.apply([], arguments).reduce((pre, cur) => Object.assign(pre, cur), {});
465
369
  }
466
-
467
370
  var _styleSheet = _appCssStyleSheet;
468
-
469
371
  class App extends Component {
470
372
  render() {
471
373
  return <div style={_mergeEleStyles(_styleSheet["header"], {
472
374
  height: 100
473
375
  })} />;
474
376
  }
475
-
476
377
  }"
477
378
  `;
478
379
 
@@ -480,34 +381,25 @@ exports[`jsx style plugin combine multiple anonymous css file 1`] = `
480
381
  "import { createElement, Component } from 'rax';
481
382
  import _app1CssStyleSheet from "./app1.css";
482
383
  import _app2CssStyleSheet from "./app2.css";
483
-
484
384
  function _mergeEleStyles() {
485
385
  return [].concat.apply([], arguments).reduce((pre, cur) => Object.assign(pre, cur), {});
486
386
  }
487
-
488
387
  function _mergeStyles() {
489
388
  var newTarget = {};
490
-
491
389
  for (var index = 0; index < arguments.length; index++) {
492
390
  var [styleSheet, rawStyleName] = arguments[index];
493
-
494
391
  for (var key in styleSheet) {
495
392
  const _key = rawStyleName ? rawStyleName + '-' + key : key;
496
-
497
393
  newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
498
394
  }
499
395
  }
500
-
501
396
  return newTarget;
502
397
  }
503
-
504
398
  var _styleSheet = _mergeStyles([_app1CssStyleSheet, ""], [_app2CssStyleSheet, ""]);
505
-
506
399
  class App extends Component {
507
400
  render() {
508
401
  return <div style={_mergeEleStyles(_styleSheet["header1"], _styleSheet["header2"])} />;
509
402
  }
510
-
511
403
  }"
512
404
  `;
513
405
 
@@ -517,25 +409,18 @@ import _indexCssStyleSheet from "./index.css";
517
409
  import _indexScssStyleSheet from "./index.scss";
518
410
  import _indexLessStyleSheet from "../index.less";
519
411
  import styl from "./index.styl";
520
-
521
412
  function _mergeStyles() {
522
413
  var newTarget = {};
523
-
524
414
  for (var index = 0; index < arguments.length; index++) {
525
415
  var [styleSheet, rawStyleName] = arguments[index];
526
-
527
416
  for (var key in styleSheet) {
528
417
  const _key = rawStyleName ? rawStyleName + '-' + key : key;
529
-
530
418
  newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
531
419
  }
532
420
  }
533
-
534
421
  return newTarget;
535
422
  }
536
-
537
423
  var _styleSheet = _mergeStyles([_indexCssStyleSheet, ""], [_indexScssStyleSheet, ""], [_indexLessStyleSheet, ""], [styl, ""]);
538
-
539
424
  render(<div style={_styleSheet["header"]} />);"
540
425
  `;
541
426
 
@@ -543,34 +428,25 @@ exports[`jsx style plugin combine multiple styles and className 1`] = `
543
428
  "import { createElement, Component } from 'rax';
544
429
  import _appCssStyleSheet from "./app.css";
545
430
  import style from "./style.css";
546
-
547
431
  function _mergeEleStyles() {
548
432
  return [].concat.apply([], arguments).reduce((pre, cur) => Object.assign(pre, cur), {});
549
433
  }
550
-
551
434
  function _mergeStyles() {
552
435
  var newTarget = {};
553
-
554
436
  for (var index = 0; index < arguments.length; index++) {
555
437
  var [styleSheet, rawStyleName] = arguments[index];
556
-
557
438
  for (var key in styleSheet) {
558
439
  const _key = rawStyleName ? rawStyleName + '-' + key : key;
559
-
560
440
  newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
561
441
  }
562
442
  }
563
-
564
443
  return newTarget;
565
444
  }
566
-
567
445
  var _styleSheet = _mergeStyles([_appCssStyleSheet, ""], [style, ""]);
568
-
569
446
  class App extends Component {
570
447
  render() {
571
448
  return <div style={_mergeEleStyles(_styleSheet["header2"], style.header1, style.header3)} />;
572
449
  }
573
-
574
450
  }"
575
451
  `;
576
452
 
@@ -578,34 +454,25 @@ exports[`jsx style plugin combine one style and className 1`] = `
578
454
  "import { createElement, Component } from 'rax';
579
455
  import _appCssStyleSheet from "./app.css";
580
456
  import style from "./style.css";
581
-
582
457
  function _mergeEleStyles() {
583
458
  return [].concat.apply([], arguments).reduce((pre, cur) => Object.assign(pre, cur), {});
584
459
  }
585
-
586
460
  function _mergeStyles() {
587
461
  var newTarget = {};
588
-
589
462
  for (var index = 0; index < arguments.length; index++) {
590
463
  var [styleSheet, rawStyleName] = arguments[index];
591
-
592
464
  for (var key in styleSheet) {
593
465
  const _key = rawStyleName ? rawStyleName + '-' + key : key;
594
-
595
466
  newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
596
467
  }
597
468
  }
598
-
599
469
  return newTarget;
600
470
  }
601
-
602
471
  var _styleSheet = _mergeStyles([_appCssStyleSheet, ""], [style, ""]);
603
-
604
472
  class App extends Component {
605
473
  render() {
606
474
  return <div style={_mergeEleStyles(_styleSheet["header2"], style.header1)} />;
607
475
  }
608
-
609
476
  }"
610
477
  `;
611
478
 
@@ -614,34 +481,25 @@ exports[`jsx style plugin combine the same filename style source 1`] = `
614
481
  import _appCssStyleSheet from "./app.css";
615
482
  import _appCssStyleSheet2 from "../a/app.css";
616
483
  import _appCssStyleSheet3 from "../b/app.css";
617
-
618
484
  function _mergeEleStyles() {
619
485
  return [].concat.apply([], arguments).reduce((pre, cur) => Object.assign(pre, cur), {});
620
486
  }
621
-
622
487
  function _mergeStyles() {
623
488
  var newTarget = {};
624
-
625
489
  for (var index = 0; index < arguments.length; index++) {
626
490
  var [styleSheet, rawStyleName] = arguments[index];
627
-
628
491
  for (var key in styleSheet) {
629
492
  const _key = rawStyleName ? rawStyleName + '-' + key : key;
630
-
631
493
  newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
632
494
  }
633
495
  }
634
-
635
496
  return newTarget;
636
497
  }
637
-
638
498
  var _styleSheet = _mergeStyles([_appCssStyleSheet, ""], [_appCssStyleSheet2, ""], [_appCssStyleSheet3, ""]);
639
-
640
499
  class App extends Component {
641
500
  render() {
642
501
  return <div style={_mergeEleStyles(_styleSheet["header1"], _styleSheet["header2"])} />;
643
502
  }
644
-
645
503
  }"
646
504
  `;
647
505
 
@@ -649,12 +507,10 @@ exports[`jsx style plugin disableMultipleClassName and transform multiple classN
649
507
  "import { createElement, Component } from 'rax';
650
508
  import _appCssStyleSheet from "./app.css";
651
509
  var _styleSheet = _appCssStyleSheet;
652
-
653
510
  class App extends Component {
654
511
  render() {
655
512
  return <div headerClassName="header" style={_styleSheet["container"]} />;
656
513
  }
657
-
658
514
  }"
659
515
  `;
660
516
 
@@ -662,12 +518,10 @@ exports[`jsx style plugin enableMultipleClassName and transform error css value
662
518
  "import { createElement, Component } from 'rax';
663
519
  import _appCssStyleSheet from "./app.css";
664
520
  var _styleSheet = _appCssStyleSheet;
665
-
666
521
  class App extends Component {
667
522
  render() {
668
523
  return <StatusBar barStyle={"dark-content"} />;
669
524
  }
670
-
671
525
  }"
672
526
  `;
673
527
 
@@ -675,25 +529,20 @@ exports[`jsx style plugin enableMultipleClassName and transform multiple classNa
675
529
  "import { createElement, Component } from 'rax';
676
530
  import _appCssStyleSheet from "./app.css";
677
531
  var _styleSheet = _appCssStyleSheet;
678
-
679
532
  class App extends Component {
680
533
  render() {
681
534
  return <div style={_styleSheet["container"]} headerStyle={_styleSheet["header"]} />;
682
535
  }
683
-
684
536
  }"
685
537
  `;
686
538
 
687
539
  exports[`jsx style plugin enableMultipleClassName and transform multiple className to multiple style as array 1`] = `
688
540
  "import { createElement, Component } from 'rax';
689
541
  import _appCssStyleSheet from "./app.css";
690
-
691
542
  function _mergeEleStyles() {
692
543
  return [].concat.apply([], arguments).reduce((pre, cur) => Object.assign(pre, cur), {});
693
544
  }
694
-
695
545
  var _styleSheet = _appCssStyleSheet;
696
-
697
546
  class App extends Component {
698
547
  render() {
699
548
  return <div style={_mergeEleStyles(_styleSheet["container"], {
@@ -702,7 +551,6 @@ class App extends Component {
702
551
  color: "green"
703
552
  })} />;
704
553
  }
705
-
706
554
  }"
707
555
  `;
708
556
 
@@ -710,46 +558,35 @@ exports[`jsx style plugin merge stylesheet when css module disable 1`] = `
710
558
  "import { createElement, Component } from 'rax';
711
559
  import _appScssStyleSheet from "./app.scss";
712
560
  import styleSheet from "./app.module.scss";
713
-
714
561
  function _mergeEleStyles() {
715
562
  return [].concat.apply([], arguments).reduce((pre, cur) => Object.assign(pre, cur), {});
716
563
  }
717
-
718
564
  function _mergeStyles() {
719
565
  var newTarget = {};
720
-
721
566
  for (var index = 0; index < arguments.length; index++) {
722
567
  var [styleSheet, rawStyleName] = arguments[index];
723
-
724
568
  for (var key in styleSheet) {
725
569
  const _key = rawStyleName ? rawStyleName + '-' + key : key;
726
-
727
570
  newTarget[_key] = Object.assign(newTarget[_key] || {}, styleSheet[key]);
728
571
  }
729
572
  }
730
-
731
573
  return newTarget;
732
574
  }
733
-
734
575
  var _styleSheet = _mergeStyles([_appScssStyleSheet, ""], [styleSheet, ""]);
735
-
736
576
  class App extends Component {
737
577
  render() {
738
578
  return <div style={_mergeEleStyles(_styleSheet["header"], styleSheet.red)} />;
739
579
  }
740
-
741
580
  }"
742
581
  `;
743
582
 
744
583
  exports[`jsx style plugin transform array, object and expressions 1`] = `
745
584
  "import { createElement, Component } from 'rax';
746
585
  import _appCssStyleSheet from "./app.css";
747
-
748
586
  function _getClassName() {
749
587
  var className = [];
750
588
  var args = arguments[0];
751
589
  var type = Object.prototype.toString.call(args).slice(8, -1).toLowerCase();
752
-
753
590
  if (type === 'string') {
754
591
  args = args.trim();
755
592
  args && className.push(args);
@@ -761,27 +598,21 @@ function _getClassName() {
761
598
  } else if (type === 'object') {
762
599
  for (var k in args) {
763
600
  k = k.trim();
764
-
765
601
  if (k && args.hasOwnProperty(k) && args[k]) {
766
602
  className.push(k);
767
603
  }
768
604
  }
769
605
  }
770
-
771
606
  return className.join(' ').trim();
772
607
  }
773
-
774
608
  function _getStyle(classNameExpression) {
775
609
  var className = _getClassName(classNameExpression);
776
-
777
610
  var classNameArr = className.split(/\\s+/);
778
611
  var style = {};
779
612
  classNameArr.reduce((sty, cls) => Object.assign(sty, _styleSheet[cls.trim()]), style);
780
613
  return style;
781
614
  }
782
-
783
615
  var _styleSheet = _appCssStyleSheet;
784
-
785
616
  class App extends Component {
786
617
  render() {
787
618
  return <div style={_styleSheet["header"]}>
@@ -795,7 +626,6 @@ class App extends Component {
795
626
  <div style={_getStyle(getClassName())} />
796
627
  </div>;
797
628
  }
798
-
799
629
  }"
800
630
  `;
801
631
 
@@ -816,18 +646,14 @@ render(<div style={_styleSheet["header"]} />);"
816
646
  exports[`jsx style plugin transform multiple classNames to style as array 1`] = `
817
647
  "import { createElement, Component } from 'rax';
818
648
  import _appCssStyleSheet from "./app.css";
819
-
820
649
  function _mergeEleStyles() {
821
650
  return [].concat.apply([], arguments).reduce((pre, cur) => Object.assign(pre, cur), {});
822
651
  }
823
-
824
652
  var _styleSheet = _appCssStyleSheet;
825
-
826
653
  class App extends Component {
827
654
  render() {
828
655
  return <div style={_mergeEleStyles(_styleSheet["header1"], _styleSheet["header2"])} />;
829
656
  }
830
-
831
657
  }"
832
658
  `;
833
659
 
@@ -835,12 +661,10 @@ exports[`jsx style plugin transform only one className to style as member 1`] =
835
661
  "import { createElement, Component } from 'rax';
836
662
  import _appCssStyleSheet from "./app.css";
837
663
  var _styleSheet = _appCssStyleSheet;
838
-
839
664
  class App extends Component {
840
665
  render() {
841
666
  return <div style={_styleSheet["header"]} />;
842
667
  }
843
-
844
668
  }"
845
669
  `;
846
670
 
@@ -848,12 +672,10 @@ exports[`jsx style plugin transform scss file 1`] = `
848
672
  "import { createElement, Component } from 'rax';
849
673
  import _appScssStyleSheet from "./app.scss";
850
674
  var _styleSheet = _appScssStyleSheet;
851
-
852
675
  class App extends Component {
853
676
  render() {
854
677
  return <div style={_styleSheet["header"]} />;
855
678
  }
856
-
857
679
  }"
858
680
  `;
859
681
 
@@ -861,23 +683,19 @@ exports[`jsx style plugin transform scss file with hyphen(-) in the filename 1`]
861
683
  "import { createElement, Component } from 'rax';
862
684
  import _appStyleScssStyleSheet from "./app-style.scss";
863
685
  var _styleSheet = _appStyleScssStyleSheet;
864
-
865
686
  class App extends Component {
866
687
  render() {
867
688
  return <div style={_styleSheet["header"]} />;
868
689
  }
869
-
870
690
  }"
871
691
  `;
872
692
 
873
693
  exports[`jsx style plugin transform styleAttribute expression 1`] = `
874
694
  "import { createElement, render } from 'rax';
875
695
  import _appLessStyleSheet from "./app.less";
876
-
877
696
  function _mergeEleStyles() {
878
697
  return [].concat.apply([], arguments).reduce((pre, cur) => Object.assign(pre, cur), {});
879
698
  }
880
-
881
699
  var _styleSheet = _appLessStyleSheet;
882
700
  render(<div style={_mergeEleStyles(_styleSheet["header"], {
883
701
  width: 100,
@@ -888,11 +706,9 @@ render(<div style={_mergeEleStyles(_styleSheet["header"], {
888
706
  exports[`jsx style plugin transform styleAttribute inline string and exsit classNameAttribute 1`] = `
889
707
  "import { createElement, render } from 'rax';
890
708
  import _appLessStyleSheet from "./app.less";
891
-
892
709
  function _mergeEleStyles() {
893
710
  return [].concat.apply([], arguments).reduce((pre, cur) => Object.assign(pre, cur), {});
894
711
  }
895
-
896
712
  var _styleSheet = _appLessStyleSheet;
897
713
  render(<div style={_mergeEleStyles(_styleSheet["header"], {
898
714
  "width": 100,
@@ -4,7 +4,7 @@ import syntaxJSX from 'babel-plugin-syntax-jsx'
4
4
  import jSXStylePlugin from '../src/index'
5
5
 
6
6
  describe('jsx style plugin', () => {
7
- function getTransfromCode (source, debug = false, options = {}) {
7
+ function getTransformCode (source, debug = false, options = {}) {
8
8
  const { enableCSSModule, enableMultipleClassName = false } = options
9
9
  const code = transform(source, {
10
10
  plugins: [[jSXStylePlugin, { enableCSSModule, enableMultipleClassName }], syntaxJSX],
@@ -20,7 +20,7 @@ describe('jsx style plugin', () => {
20
20
  }
21
21
 
22
22
  it('no stylesheet import', () => {
23
- expect(getTransfromCode(`
23
+ expect(getTransformCode(`
24
24
  import { createElement, Component } from 'rax';
25
25
 
26
26
  class App extends Component {
@@ -28,17 +28,15 @@ class App extends Component {
28
28
  return <div className="header" />;
29
29
  }
30
30
  }`)).toBe(`import { createElement, Component } from 'rax';
31
-
32
31
  class App extends Component {
33
32
  render() {
34
33
  return <div className="header" />;
35
34
  }
36
-
37
35
  }`)
38
36
  })
39
37
 
40
38
  it('transform only one className to style as member', () => {
41
- expect(getTransfromCode(`
39
+ expect(getTransformCode(`
42
40
  import { createElement, Component } from 'rax';
43
41
  import './app.css';
44
42
 
@@ -50,7 +48,7 @@ class App extends Component {
50
48
  })
51
49
 
52
50
  it('transform multiple classNames to style as array', () => {
53
- expect(getTransfromCode(`
51
+ expect(getTransformCode(`
54
52
  import { createElement, Component } from 'rax';
55
53
  import './app.css';
56
54
 
@@ -62,7 +60,7 @@ class App extends Component {
62
60
  })
63
61
 
64
62
  it('transform array, object and expressions', () => {
65
- expect(getTransfromCode(`
63
+ expect(getTransformCode(`
66
64
  import { createElement, Component } from 'rax';
67
65
  import './app.css';
68
66
 
@@ -79,7 +77,7 @@ class App extends Component {
79
77
  })
80
78
 
81
79
  it('combine multiple anonymous css file', () => {
82
- expect(getTransfromCode(`import { createElement, Component } from 'rax';
80
+ expect(getTransformCode(`import { createElement, Component } from 'rax';
83
81
  import './app1.css';
84
82
  import './app2.css';
85
83
 
@@ -91,7 +89,7 @@ class App extends Component {
91
89
  })
92
90
 
93
91
  it('combine the same filename style source', () => {
94
- expect(getTransfromCode(`import { createElement, Component } from 'rax';
92
+ expect(getTransformCode(`import { createElement, Component } from 'rax';
95
93
  import './app.css';
96
94
  import '../a/app.css';
97
95
  import '../b/app.css';
@@ -104,7 +102,7 @@ class App extends Component {
104
102
  })
105
103
 
106
104
  it('combine one style and className', () => {
107
- expect(getTransfromCode(`import { createElement, Component } from 'rax';
105
+ expect(getTransformCode(`import { createElement, Component } from 'rax';
108
106
  import './app.css';
109
107
  import style from './style.css';
110
108
 
@@ -116,7 +114,7 @@ class App extends Component {
116
114
  })
117
115
 
118
116
  it('combine inline style object and className', () => {
119
- expect(getTransfromCode(`
117
+ expect(getTransformCode(`
120
118
  import { createElement, Component } from 'rax';
121
119
  import "./app.css";
122
120
 
@@ -130,7 +128,7 @@ class App extends Component {
130
128
  })
131
129
 
132
130
  it('combine multiple styles and className', () => {
133
- expect(getTransfromCode(`
131
+ expect(getTransformCode(`
134
132
  import { createElement, Component } from 'rax';
135
133
  import './app.css';
136
134
  import style from './style.css';
@@ -142,20 +140,19 @@ class App extends Component {
142
140
  }`)).toMatchSnapshot()
143
141
  })
144
142
 
145
- it('do not transfrom code when no css file', () => {
143
+ it('do not transform code when no css file', () => {
146
144
  const code = `import { createElement, Component } from 'rax';
147
-
148
145
  class App extends Component {
149
146
  render() {
150
147
  return <div className="header" />;
151
- }\n
148
+ }
152
149
  }`
153
150
 
154
- expect(getTransfromCode(code)).toBe(code)
151
+ expect(getTransformCode(code)).toBe(code)
155
152
  })
156
153
 
157
154
  it('transform scss file', () => {
158
- expect(getTransfromCode(`
155
+ expect(getTransformCode(`
159
156
  import { createElement, Component } from 'rax';
160
157
  import './app.scss';
161
158
 
@@ -167,7 +164,7 @@ class App extends Component {
167
164
  })
168
165
 
169
166
  it('transform scss file with hyphen(-) in the filename', () => {
170
- expect(getTransfromCode(`
167
+ expect(getTransformCode(`
171
168
  import { createElement, Component } from 'rax';
172
169
  import './app-style.scss';
173
170
 
@@ -179,7 +176,7 @@ class App extends Component {
179
176
  })
180
177
 
181
178
  it('transform constant elements in render', () => {
182
- expect(getTransfromCode(`
179
+ expect(getTransformCode(`
183
180
  import { createElement, render } from 'rax';
184
181
  import './app.css';
185
182
 
@@ -188,7 +185,7 @@ render(<div className="header" />);
188
185
  })
189
186
 
190
187
  it('transform stylus in render', () => {
191
- expect(getTransfromCode(`
188
+ expect(getTransformCode(`
192
189
  import { createElement, render } from 'rax';
193
190
  import './app.styl';
194
191
 
@@ -197,7 +194,7 @@ render(<div className="header" />);
197
194
  })
198
195
 
199
196
  it('transform less in render', () => {
200
- expect(getTransfromCode(`
197
+ expect(getTransformCode(`
201
198
  import { createElement, render } from 'rax';
202
199
  import './app.less';
203
200
 
@@ -206,7 +203,7 @@ render(<div className="header" />);
206
203
  })
207
204
 
208
205
  it('combine multiple different extension style sources', () => {
209
- expect(getTransfromCode(`
206
+ expect(getTransformCode(`
210
207
  import { createElement, render } from 'rax';
211
208
  import './index.css'
212
209
  import './index.scss'
@@ -217,7 +214,7 @@ render(<div className="header" />);
217
214
  `)).toMatchSnapshot()
218
215
  })
219
216
  it('transform styleAttribute expression', () => {
220
- expect(getTransfromCode(`
217
+ expect(getTransformCode(`
221
218
  import { createElement, render } from 'rax';
222
219
  import './app.less';
223
220
 
@@ -225,7 +222,7 @@ render(<div className="header" style={{width: 100, height: 100}} />);
225
222
  `)).toMatchSnapshot()
226
223
  })
227
224
  it('transform styleAttribute inline string', () => {
228
- expect(getTransfromCode(`
225
+ expect(getTransformCode(`
229
226
  import { createElement, render } from 'rax';
230
227
 
231
228
  render(<div style="width:100px;height:100px;background-color:rgba(0, 0, 0, 0.5);border: 1px solid;" />);
@@ -241,7 +238,7 @@ render(<div style={{
241
238
  })
242
239
 
243
240
  it('transform styleAttribute inline string and exsit classNameAttribute', () => {
244
- expect(getTransfromCode(`
241
+ expect(getTransformCode(`
245
242
  import { createElement, render } from 'rax';
246
243
  import './app.less';
247
244
  render(<div className="header" style="width:100px;height:100px;background-color:rgba(0, 0, 0, 0.5);border: 1px solid;" />);
@@ -249,7 +246,7 @@ render(<div className="header" style="width:100px;height:100px;background-color:
249
246
  })
250
247
 
251
248
  it('Provide a default stylesheet object when css module enable and import css module sheet only', () => {
252
- expect(getTransfromCode(`
249
+ expect(getTransformCode(`
253
250
  import { createElement, Component } from 'rax';
254
251
  import styleSheet from './app.module.scss';
255
252
 
@@ -264,7 +261,7 @@ class App extends Component {
264
261
  })
265
262
 
266
263
  it('Processing module style assignment When css module enable', () => {
267
- expect(getTransfromCode(`
264
+ expect(getTransformCode(`
268
265
  import { createElement, Component } from 'rax';
269
266
  import './app.scss';
270
267
  import styleSheet from './app.module.scss';
@@ -278,7 +275,7 @@ class App extends Component {
278
275
  })
279
276
 
280
277
  it('Processing multiple module style When css module enable', () => {
281
- expect(getTransfromCode(`
278
+ expect(getTransformCode(`
282
279
  import { createElement, Component } from 'rax';
283
280
  import styleSheet from './app.module.scss';
284
281
  import styleSheet2 from './app2.module.scss';
@@ -292,7 +289,7 @@ class App extends Component {
292
289
  })
293
290
 
294
291
  it('Processing module style spread and assign When css module enable', () => {
295
- expect(getTransfromCode(`
292
+ expect(getTransformCode(`
296
293
  import { createElement, Component } from 'rax';
297
294
  import './app.scss';
298
295
  import styleSheet from './app.module.scss';
@@ -307,7 +304,7 @@ class App extends Component {
307
304
  })
308
305
 
309
306
  it('Processing module style conditional expression When css module enable', () => {
310
- expect(getTransfromCode(`
307
+ expect(getTransformCode(`
311
308
  import { createElement, Component } from 'rax';
312
309
  import './app.scss';
313
310
  import styleSheet from './app.module.scss';
@@ -321,7 +318,7 @@ class App extends Component {
321
318
  })
322
319
 
323
320
  it('Processing module style through call expression When css module enable', () => {
324
- expect(getTransfromCode(`
321
+ expect(getTransformCode(`
325
322
  import { createElement, Component } from 'rax';
326
323
  import styleSheet from './app.module.scss';
327
324
 
@@ -335,7 +332,7 @@ class App extends Component {
335
332
  })
336
333
 
337
334
  it('merge stylesheet when css module disable', () => {
338
- expect(getTransfromCode(`
335
+ expect(getTransformCode(`
339
336
  import { createElement, Component } from 'rax';
340
337
  import './app.scss';
341
338
  import styleSheet from './app.module.scss';
@@ -348,7 +345,7 @@ class App extends Component {
348
345
  })
349
346
 
350
347
  it('disableMultipleClassName and transform multiple className to multiple style', () => {
351
- expect(getTransfromCode(`
348
+ expect(getTransformCode(`
352
349
  import { createElement, Component } from 'rax';
353
350
  import './app.css';
354
351
 
@@ -360,7 +357,7 @@ class App extends Component {
360
357
  })
361
358
 
362
359
  it('enableMultipleClassName and transform multiple className to multiple style', () => {
363
- expect(getTransfromCode(`
360
+ expect(getTransformCode(`
364
361
  import { createElement, Component } from 'rax';
365
362
  import './app.css';
366
363
 
@@ -372,7 +369,7 @@ class App extends Component {
372
369
  })
373
370
 
374
371
  it('enableMultipleClassName and transform multiple className to multiple style as array', () => {
375
- expect(getTransfromCode(`
372
+ expect(getTransformCode(`
376
373
  import { createElement, Component } from 'rax';
377
374
  import './app.css';
378
375
 
@@ -384,7 +381,7 @@ class App extends Component {
384
381
  })
385
382
 
386
383
  it('enableMultipleClassName and transform error css value', () => {
387
- expect(getTransfromCode(`
384
+ expect(getTransformCode(`
388
385
  import { createElement, Component } from 'rax';
389
386
  import './app.css';
390
387
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "babel-plugin-transform-react-jsx-to-rn-stylesheet",
3
- "version": "3.7.0-alpha.2",
3
+ "version": "3.7.0-alpha.4",
4
4
  "description": "Transform stylesheet selector to style in JSX Elements.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "dependencies": {
20
20
  "camelize": "^1.0.0",
21
- "taro-css-to-react-native": "3.7.0-alpha.2"
21
+ "taro-css-to-react-native": "3.7.0-alpha.4"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@babel/core": "^7.14.5",