ripple 0.2.210 → 0.2.212

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,685 @@
1
+ import * as _$_ from 'ripple/internal/server';
2
+
3
+ import { track } from 'ripple/server';
4
+
5
+ export async function IfWithChildren(__output, { children }) {
6
+ return _$_.async(async () => {
7
+ _$_.push_component();
8
+
9
+ let expanded = track(true);
10
+
11
+ __output.push('<div');
12
+ __output.push(' class="container"');
13
+ __output.push('>');
14
+
15
+ {
16
+ __output.push('<div');
17
+ __output.push(' role="button"');
18
+ __output.push(' class="header"');
19
+ __output.push('>');
20
+
21
+ {
22
+ __output.push('Toggle');
23
+ }
24
+
25
+ __output.push('</div>');
26
+ __output.push('<!--[-->');
27
+
28
+ if (_$_.get(expanded)) {
29
+ __output.push('<div');
30
+ __output.push(' class="content"');
31
+ __output.push('>');
32
+
33
+ {
34
+ {
35
+ const comp = children;
36
+ const args = [__output, {}];
37
+
38
+ if (comp?.async) {
39
+ await comp(...args);
40
+ } else if (comp) {
41
+ comp(...args);
42
+ }
43
+ }
44
+ }
45
+
46
+ __output.push('</div>');
47
+ }
48
+
49
+ __output.push('<!--]-->');
50
+ }
51
+
52
+ __output.push('</div>');
53
+ _$_.pop_component();
54
+ });
55
+ }
56
+
57
+ export function ChildItem(__output, { text }) {
58
+ _$_.push_component();
59
+ __output.push('<div');
60
+ __output.push(' class="item"');
61
+ __output.push('>');
62
+
63
+ {
64
+ __output.push(_$_.escape(text));
65
+ }
66
+
67
+ __output.push('</div>');
68
+ _$_.pop_component();
69
+ }
70
+
71
+ export function TestIfWithChildren(__output) {
72
+ _$_.push_component();
73
+
74
+ {
75
+ const comp = IfWithChildren;
76
+
77
+ const args = [
78
+ __output,
79
+
80
+ {
81
+ children: function children(__output) {
82
+ _$_.push_component();
83
+
84
+ {
85
+ const comp = ChildItem;
86
+ const args = [__output, { text: "Item 1" }];
87
+
88
+ comp(...args);
89
+ }
90
+
91
+ {
92
+ const comp = ChildItem;
93
+ const args = [__output, { text: "Item 2" }];
94
+
95
+ comp(...args);
96
+ }
97
+
98
+ _$_.pop_component();
99
+ }
100
+ }
101
+ ];
102
+
103
+ comp(...args);
104
+ }
105
+
106
+ _$_.pop_component();
107
+ }
108
+
109
+ export function IfWithStaticChildren(__output) {
110
+ _$_.push_component();
111
+
112
+ let expanded = track(true);
113
+
114
+ __output.push('<div');
115
+ __output.push(' class="container"');
116
+ __output.push('>');
117
+
118
+ {
119
+ __output.push('<div');
120
+ __output.push(' role="button"');
121
+ __output.push(' class="header"');
122
+ __output.push('>');
123
+
124
+ {
125
+ __output.push('Toggle');
126
+ }
127
+
128
+ __output.push('</div>');
129
+ __output.push('<!--[-->');
130
+
131
+ if (_$_.get(expanded)) {
132
+ __output.push('<div');
133
+ __output.push(' class="content"');
134
+ __output.push('>');
135
+
136
+ {
137
+ __output.push('<span');
138
+ __output.push('>');
139
+
140
+ {
141
+ __output.push('Static child 1');
142
+ }
143
+
144
+ __output.push('</span>');
145
+ __output.push('<span');
146
+ __output.push('>');
147
+
148
+ {
149
+ __output.push('Static child 2');
150
+ }
151
+
152
+ __output.push('</span>');
153
+ }
154
+
155
+ __output.push('</div>');
156
+ }
157
+
158
+ __output.push('<!--]-->');
159
+ }
160
+
161
+ __output.push('</div>');
162
+ _$_.pop_component();
163
+ }
164
+
165
+ export async function IfWithSiblingsAndChildren(__output, { children }) {
166
+ return _$_.async(async () => {
167
+ _$_.push_component();
168
+
169
+ let expanded = track(true);
170
+
171
+ __output.push('<section');
172
+ __output.push(' class="group"');
173
+ __output.push('>');
174
+
175
+ {
176
+ __output.push('<div');
177
+ __output.push(' role="button"');
178
+ __output.push(' class="item"');
179
+ __output.push('>');
180
+
181
+ {
182
+ __output.push('<div');
183
+ __output.push(' class="indicator"');
184
+ __output.push('>');
185
+ __output.push('</div>');
186
+ __output.push('<h2');
187
+ __output.push(' class="text"');
188
+ __output.push('>');
189
+
190
+ {
191
+ __output.push('Title');
192
+ }
193
+
194
+ __output.push('</h2>');
195
+ __output.push('<div');
196
+ __output.push(' class="caret"');
197
+ __output.push('>');
198
+
199
+ {
200
+ __output.push('<svg');
201
+ __output.push(' xmlns="http://www.w3.org/2000/svg"');
202
+ __output.push(' width="18"');
203
+ __output.push(' height="18"');
204
+ __output.push(' viewBox="0 0 24 24"');
205
+ __output.push('>');
206
+
207
+ {
208
+ __output.push('<path');
209
+ __output.push(' d="m9 18 6-6-6-6"');
210
+ __output.push('>');
211
+ __output.push('</path>');
212
+ }
213
+
214
+ __output.push('</svg>');
215
+ }
216
+
217
+ __output.push('</div>');
218
+ }
219
+
220
+ __output.push('</div>');
221
+ __output.push('<!--[-->');
222
+
223
+ if (_$_.get(expanded)) {
224
+ __output.push('<div');
225
+ __output.push(' class="items"');
226
+ __output.push('>');
227
+
228
+ {
229
+ {
230
+ const comp = children;
231
+ const args = [__output, {}];
232
+
233
+ if (comp?.async) {
234
+ await comp(...args);
235
+ } else if (comp) {
236
+ comp(...args);
237
+ }
238
+ }
239
+ }
240
+
241
+ __output.push('</div>');
242
+ }
243
+
244
+ __output.push('<!--]-->');
245
+ }
246
+
247
+ __output.push('</section>');
248
+ _$_.pop_component();
249
+ });
250
+ }
251
+
252
+ export function TestIfWithSiblingsAndChildren(__output) {
253
+ _$_.push_component();
254
+
255
+ {
256
+ const comp = IfWithSiblingsAndChildren;
257
+
258
+ const args = [
259
+ __output,
260
+
261
+ {
262
+ children: function children(__output) {
263
+ _$_.push_component();
264
+
265
+ {
266
+ const comp = ChildItem;
267
+ const args = [__output, { text: "Item A" }];
268
+
269
+ comp(...args);
270
+ }
271
+
272
+ {
273
+ const comp = ChildItem;
274
+ const args = [__output, { text: "Item B" }];
275
+
276
+ comp(...args);
277
+ }
278
+
279
+ _$_.pop_component();
280
+ }
281
+ }
282
+ ];
283
+
284
+ comp(...args);
285
+ }
286
+
287
+ _$_.pop_component();
288
+ }
289
+
290
+ export function ElementWithChildrenThenIf(__output) {
291
+ _$_.push_component();
292
+
293
+ let show = track(true);
294
+
295
+ __output.push('<div');
296
+ __output.push(' class="wrapper"');
297
+ __output.push('>');
298
+
299
+ {
300
+ __output.push('<div');
301
+ __output.push(' class="nested-parent"');
302
+ __output.push('>');
303
+
304
+ {
305
+ __output.push('<div');
306
+ __output.push(' class="nested-child"');
307
+ __output.push('>');
308
+
309
+ {
310
+ __output.push('<span');
311
+ __output.push(' class="deep"');
312
+ __output.push('>');
313
+
314
+ {
315
+ __output.push('Deep content');
316
+ }
317
+
318
+ __output.push('</span>');
319
+ }
320
+
321
+ __output.push('</div>');
322
+ }
323
+
324
+ __output.push('</div>');
325
+ __output.push('<!--[-->');
326
+
327
+ if (_$_.get(show)) {
328
+ __output.push('<div');
329
+ __output.push(' class="conditional"');
330
+ __output.push('>');
331
+
332
+ {
333
+ __output.push('Conditional content');
334
+ }
335
+
336
+ __output.push('</div>');
337
+ }
338
+
339
+ __output.push('<!--]-->');
340
+ }
341
+
342
+ __output.push('</div>');
343
+ __output.push('<button');
344
+ __output.push(' class="toggle"');
345
+ __output.push('>');
346
+
347
+ {
348
+ __output.push('Toggle');
349
+ }
350
+
351
+ __output.push('</button>');
352
+ _$_.pop_component();
353
+ }
354
+
355
+ export function DeepNestingThenIf(__output) {
356
+ _$_.push_component();
357
+
358
+ let visible = track(true);
359
+
360
+ __output.push('<section');
361
+ __output.push(' class="outer"');
362
+ __output.push('>');
363
+
364
+ {
365
+ __output.push('<article');
366
+ __output.push(' class="middle"');
367
+ __output.push('>');
368
+
369
+ {
370
+ __output.push('<div');
371
+ __output.push(' class="inner"');
372
+ __output.push('>');
373
+
374
+ {
375
+ __output.push('<p');
376
+ __output.push(' class="leaf"');
377
+ __output.push('>');
378
+
379
+ {
380
+ __output.push('<strong');
381
+ __output.push('>');
382
+
383
+ {
384
+ __output.push('Bold');
385
+ }
386
+
387
+ __output.push('</strong>');
388
+ __output.push('<em');
389
+ __output.push('>');
390
+
391
+ {
392
+ __output.push('Italic');
393
+ }
394
+
395
+ __output.push('</em>');
396
+ }
397
+
398
+ __output.push('</p>');
399
+ }
400
+
401
+ __output.push('</div>');
402
+ }
403
+
404
+ __output.push('</article>');
405
+ __output.push('<!--[-->');
406
+
407
+ if (_$_.get(visible)) {
408
+ __output.push('<footer');
409
+ __output.push(' class="footer"');
410
+ __output.push('>');
411
+
412
+ {
413
+ __output.push('Footer');
414
+ }
415
+
416
+ __output.push('</footer>');
417
+ }
418
+
419
+ __output.push('<!--]-->');
420
+ }
421
+
422
+ __output.push('</section>');
423
+ __output.push('<button');
424
+ __output.push(' class="btn"');
425
+ __output.push('>');
426
+
427
+ {
428
+ __output.push('Toggle');
429
+ }
430
+
431
+ __output.push('</button>');
432
+ _$_.pop_component();
433
+ }
434
+
435
+ export function DomElementChildrenThenSibling(__output) {
436
+ _$_.push_component();
437
+
438
+ let activeTab = track('code');
439
+
440
+ __output.push('<div');
441
+ __output.push(' class="tabs"');
442
+ __output.push('>');
443
+
444
+ {
445
+ __output.push('<div');
446
+ __output.push(' class="tab-list"');
447
+ __output.push('>');
448
+
449
+ {
450
+ __output.push('<button');
451
+ __output.push(_$_.attr('aria-selected', _$_.get(activeTab) === 'code' ? 'true' : 'false', false));
452
+ __output.push(' class="tab"');
453
+ __output.push('>');
454
+
455
+ {
456
+ __output.push('Code');
457
+ }
458
+
459
+ __output.push('</button>');
460
+ __output.push('<button');
461
+ __output.push(_$_.attr('aria-selected', _$_.get(activeTab) === 'preview' ? 'true' : 'false', false));
462
+ __output.push(' class="tab"');
463
+ __output.push('>');
464
+
465
+ {
466
+ __output.push('Preview');
467
+ }
468
+
469
+ __output.push('</button>');
470
+ }
471
+
472
+ __output.push('</div>');
473
+ __output.push('<div');
474
+ __output.push(' class="panel"');
475
+ __output.push('>');
476
+
477
+ {
478
+ __output.push('<!--[-->');
479
+
480
+ if (_$_.get(activeTab) === 'code') {
481
+ __output.push('<pre');
482
+ __output.push(' class="code"');
483
+ __output.push('>');
484
+
485
+ {
486
+ __output.push('const x = 1;');
487
+ }
488
+
489
+ __output.push('</pre>');
490
+ } else {
491
+ __output.push('<div');
492
+ __output.push(' class="preview"');
493
+ __output.push('>');
494
+
495
+ {
496
+ __output.push('Preview content');
497
+ }
498
+
499
+ __output.push('</div>');
500
+ }
501
+
502
+ __output.push('<!--]-->');
503
+ }
504
+
505
+ __output.push('</div>');
506
+ }
507
+
508
+ __output.push('</div>');
509
+ _$_.pop_component();
510
+ }
511
+
512
+ export function DomChildrenThenStaticSiblings(__output) {
513
+ _$_.push_component();
514
+
515
+ let count = track(0);
516
+
517
+ __output.push('<div');
518
+ __output.push(' class="container"');
519
+ __output.push('>');
520
+
521
+ {
522
+ __output.push('<ul');
523
+ __output.push(' class="list"');
524
+ __output.push('>');
525
+
526
+ {
527
+ __output.push('<li');
528
+ __output.push(' class="item"');
529
+ __output.push('>');
530
+
531
+ {
532
+ __output.push(_$_.escape('Item count: ' + String(_$_.get(count))));
533
+ }
534
+
535
+ __output.push('</li>');
536
+ __output.push('<li');
537
+ __output.push(' class="item"');
538
+ __output.push('>');
539
+
540
+ {
541
+ __output.push('Another item');
542
+ }
543
+
544
+ __output.push('</li>');
545
+ }
546
+
547
+ __output.push('</ul>');
548
+ __output.push('<h2');
549
+ __output.push(' class="heading"');
550
+ __output.push('>');
551
+
552
+ {
553
+ __output.push('Static Heading');
554
+ }
555
+
556
+ __output.push('</h2>');
557
+ __output.push('<p');
558
+ __output.push(' class="para"');
559
+ __output.push('>');
560
+
561
+ {
562
+ __output.push('Static paragraph');
563
+ }
564
+
565
+ __output.push('</p>');
566
+ }
567
+
568
+ __output.push('</div>');
569
+ __output.push('<button');
570
+ __output.push(' class="inc"');
571
+ __output.push('>');
572
+
573
+ {
574
+ __output.push('Increment');
575
+ }
576
+
577
+ __output.push('</button>');
578
+ _$_.pop_component();
579
+ }
580
+
581
+ export function StaticListThenStaticSiblings(__output) {
582
+ _$_.push_component();
583
+ __output.push('<div');
584
+ __output.push(' class="wrapper"');
585
+ __output.push('>');
586
+
587
+ {
588
+ __output.push('<ul');
589
+ __output.push(' class="features"');
590
+ __output.push('>');
591
+
592
+ {
593
+ __output.push('<li');
594
+ __output.push('>');
595
+
596
+ {
597
+ __output.push('<strong');
598
+ __output.push('>');
599
+
600
+ {
601
+ __output.push('Feature One');
602
+ }
603
+
604
+ __output.push('</strong>');
605
+ __output.push(': Description of feature one with ');
606
+ __output.push('<code');
607
+ __output.push('>');
608
+
609
+ {
610
+ __output.push('code');
611
+ }
612
+
613
+ __output.push('</code>');
614
+ __output.push(' reference');
615
+ }
616
+
617
+ __output.push('</li>');
618
+ __output.push('<li');
619
+ __output.push('>');
620
+
621
+ {
622
+ __output.push('<strong');
623
+ __output.push('>');
624
+
625
+ {
626
+ __output.push('Feature Two');
627
+ }
628
+
629
+ __output.push('</strong>');
630
+ __output.push(': Another feature description');
631
+ }
632
+
633
+ __output.push('</li>');
634
+ __output.push('<li');
635
+ __output.push('>');
636
+
637
+ {
638
+ __output.push('<strong');
639
+ __output.push('>');
640
+
641
+ {
642
+ __output.push('Feature Three');
643
+ }
644
+
645
+ __output.push('</strong>');
646
+ __output.push(': Third feature');
647
+ }
648
+
649
+ __output.push('</li>');
650
+ }
651
+
652
+ __output.push('</ul>');
653
+ __output.push('<h2');
654
+ __output.push(' class="section-heading"');
655
+ __output.push('>');
656
+
657
+ {
658
+ __output.push('Section Heading');
659
+ }
660
+
661
+ __output.push('</h2>');
662
+ __output.push('<p');
663
+ __output.push(' class="section-content"');
664
+ __output.push('>');
665
+
666
+ {
667
+ __output.push('Static paragraph with ');
668
+ __output.push('<a');
669
+ __output.push(' href="/link"');
670
+ __output.push('>');
671
+
672
+ {
673
+ __output.push('a link');
674
+ }
675
+
676
+ __output.push('</a>');
677
+ __output.push(' and more text.');
678
+ }
679
+
680
+ __output.push('</p>');
681
+ }
682
+
683
+ __output.push('</div>');
684
+ _$_.pop_component();
685
+ }
@@ -118,3 +118,33 @@ export component WebsiteIndex() {
118
118
  <Actions playgroundVisible={false} />
119
119
  </Layout>
120
120
  }
121
+
122
+ // Test case for component as last element with no following siblings.
123
+ // This exercises hydrate_advance() in append() - at the end of content,
124
+ // there's no next sibling and that should be handled gracefully.
125
+ component LastChild() {
126
+ <footer class="last-child">{'I am the last child'}</footer>
127
+ }
128
+
129
+ export component ComponentAsLastSibling() {
130
+ <div class="wrapper">
131
+ <h1>{'Header'}</h1>
132
+ <p>{'Some content'}</p>
133
+ <LastChild />
134
+ </div>
135
+ }
136
+
137
+ // Nested version - component is last child inside another component
138
+ component InnerContent() {
139
+ <div class="inner">
140
+ <span>{'Inner text'}</span>
141
+ <LastChild />
142
+ </div>
143
+ }
144
+
145
+ export component NestedComponentAsLastSibling() {
146
+ <section class="outer">
147
+ <h2>{'Section title'}</h2>
148
+ <InnerContent />
149
+ </section>
150
+ }