@alloy-js/core 0.22.0-dev.1 → 0.22.0-dev.3

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.
Files changed (65) hide show
  1. package/dist/src/components/Block.d.ts.map +1 -1
  2. package/dist/src/components/Block.js +24 -7
  3. package/dist/src/components/Block.js.map +1 -1
  4. package/dist/src/components/Indent.d.ts.map +1 -1
  5. package/dist/src/components/Indent.js +2 -1
  6. package/dist/src/components/Indent.js.map +1 -1
  7. package/dist/src/components/Prose.d.ts.map +1 -1
  8. package/dist/src/components/Prose.js +2 -1
  9. package/dist/src/components/Prose.js.map +1 -1
  10. package/dist/src/content-slot.d.ts +51 -0
  11. package/dist/src/content-slot.d.ts.map +1 -0
  12. package/dist/src/content-slot.js +69 -0
  13. package/dist/src/content-slot.js.map +1 -0
  14. package/dist/src/content-slot.test.d.ts +2 -0
  15. package/dist/src/content-slot.test.d.ts.map +1 -0
  16. package/dist/src/content-slot.test.js +57 -0
  17. package/dist/src/content-slot.test.js.map +1 -0
  18. package/dist/src/index.d.ts +1 -0
  19. package/dist/src/index.d.ts.map +1 -1
  20. package/dist/src/index.js +1 -0
  21. package/dist/src/index.js.map +1 -1
  22. package/dist/src/reactivity.d.ts +15 -1
  23. package/dist/src/reactivity.d.ts.map +1 -1
  24. package/dist/src/reactivity.js +20 -8
  25. package/dist/src/reactivity.js.map +1 -1
  26. package/dist/src/render.d.ts +1 -0
  27. package/dist/src/render.d.ts.map +1 -1
  28. package/dist/src/render.js +66 -2
  29. package/dist/src/render.js.map +1 -1
  30. package/dist/src/symbols/decl.d.ts +8 -0
  31. package/dist/src/symbols/decl.d.ts.map +1 -0
  32. package/dist/src/symbols/decl.js +22 -0
  33. package/dist/src/symbols/decl.js.map +1 -0
  34. package/dist/src/symbols/index.d.ts +1 -0
  35. package/dist/src/symbols/index.d.ts.map +1 -1
  36. package/dist/src/symbols/index.js +1 -0
  37. package/dist/src/symbols/index.js.map +1 -1
  38. package/dist/src/utils.d.ts.map +1 -1
  39. package/dist/src/utils.js +212 -15
  40. package/dist/src/utils.js.map +1 -1
  41. package/dist/test/components/block.test.d.ts.map +1 -1
  42. package/dist/test/components/block.test.js +18 -1
  43. package/dist/test/components/block.test.js.map +1 -1
  44. package/dist/test/components/list.test.d.ts.map +1 -1
  45. package/dist/test/components/list.test.js +80 -1
  46. package/dist/test/components/list.test.js.map +1 -1
  47. package/dist/test/control-flow/for.test.js +32 -2
  48. package/dist/test/control-flow/for.test.js.map +1 -1
  49. package/dist/tsconfig.tsbuildinfo +1 -1
  50. package/package.json +1 -1
  51. package/src/components/Block.tsx +18 -6
  52. package/src/components/Indent.tsx +4 -2
  53. package/src/components/Prose.tsx +2 -1
  54. package/src/content-slot.test.tsx +65 -0
  55. package/src/content-slot.tsx +91 -0
  56. package/src/index.ts +1 -0
  57. package/src/reactivity.ts +38 -5
  58. package/src/render.ts +80 -3
  59. package/src/symbols/decl.ts +25 -0
  60. package/src/symbols/index.ts +1 -0
  61. package/src/utils.tsx +240 -16
  62. package/temp/api.json +469 -0
  63. package/test/components/block.test.tsx +21 -1
  64. package/test/components/list.test.tsx +76 -1
  65. package/test/control-flow/for.test.tsx +43 -2
package/temp/api.json CHANGED
@@ -3261,6 +3261,227 @@
3261
3261
  }
3262
3262
  ]
3263
3263
  },
3264
+ {
3265
+ "kind": "Interface",
3266
+ "canonicalReference": "@alloy-js/core!ContentSlot:interface",
3267
+ "docComment": "",
3268
+ "excerptTokens": [
3269
+ {
3270
+ "kind": "Content",
3271
+ "text": "export interface ContentSlot "
3272
+ }
3273
+ ],
3274
+ "fileUrlPath": "src/content-slot.tsx",
3275
+ "releaseTag": "Public",
3276
+ "name": "ContentSlot",
3277
+ "preserveMemberOrder": false,
3278
+ "members": [
3279
+ {
3280
+ "kind": "CallSignature",
3281
+ "canonicalReference": "@alloy-js/core!ContentSlot:call(1)",
3282
+ "docComment": "",
3283
+ "excerptTokens": [
3284
+ {
3285
+ "kind": "Content",
3286
+ "text": "(props: "
3287
+ },
3288
+ {
3289
+ "kind": "Content",
3290
+ "text": "{\n children: "
3291
+ },
3292
+ {
3293
+ "kind": "Reference",
3294
+ "text": "Children",
3295
+ "canonicalReference": "@alloy-js/core!Children:type"
3296
+ },
3297
+ {
3298
+ "kind": "Content",
3299
+ "text": ";\n }"
3300
+ },
3301
+ {
3302
+ "kind": "Content",
3303
+ "text": "): "
3304
+ },
3305
+ {
3306
+ "kind": "Reference",
3307
+ "text": "Children",
3308
+ "canonicalReference": "@alloy-js/core!Children:type"
3309
+ },
3310
+ {
3311
+ "kind": "Content",
3312
+ "text": ";"
3313
+ }
3314
+ ],
3315
+ "returnTypeTokenRange": {
3316
+ "startIndex": 5,
3317
+ "endIndex": 6
3318
+ },
3319
+ "releaseTag": "Public",
3320
+ "overloadIndex": 1,
3321
+ "parameters": [
3322
+ {
3323
+ "parameterName": "props",
3324
+ "parameterTypeTokenRange": {
3325
+ "startIndex": 1,
3326
+ "endIndex": 4
3327
+ },
3328
+ "isOptional": false
3329
+ }
3330
+ ]
3331
+ },
3332
+ {
3333
+ "kind": "PropertySignature",
3334
+ "canonicalReference": "@alloy-js/core!ContentSlot#hasContent:member",
3335
+ "docComment": "/**\n * Whether the slot has any content.\n */\n",
3336
+ "excerptTokens": [
3337
+ {
3338
+ "kind": "Content",
3339
+ "text": "hasContent: "
3340
+ },
3341
+ {
3342
+ "kind": "Content",
3343
+ "text": "boolean"
3344
+ },
3345
+ {
3346
+ "kind": "Content",
3347
+ "text": ";"
3348
+ }
3349
+ ],
3350
+ "isReadonly": false,
3351
+ "isOptional": false,
3352
+ "releaseTag": "Public",
3353
+ "name": "hasContent",
3354
+ "propertyTypeTokenRange": {
3355
+ "startIndex": 1,
3356
+ "endIndex": 2
3357
+ }
3358
+ },
3359
+ {
3360
+ "kind": "PropertySignature",
3361
+ "canonicalReference": "@alloy-js/core!ContentSlot#isEmpty:member",
3362
+ "docComment": "/**\n * Whether the slot is currently empty.\n */\n",
3363
+ "excerptTokens": [
3364
+ {
3365
+ "kind": "Content",
3366
+ "text": "isEmpty: "
3367
+ },
3368
+ {
3369
+ "kind": "Content",
3370
+ "text": "boolean"
3371
+ },
3372
+ {
3373
+ "kind": "Content",
3374
+ "text": ";"
3375
+ }
3376
+ ],
3377
+ "isReadonly": false,
3378
+ "isOptional": false,
3379
+ "releaseTag": "Public",
3380
+ "name": "isEmpty",
3381
+ "propertyTypeTokenRange": {
3382
+ "startIndex": 1,
3383
+ "endIndex": 2
3384
+ }
3385
+ },
3386
+ {
3387
+ "kind": "PropertySignature",
3388
+ "canonicalReference": "@alloy-js/core!ContentSlot#ref:member",
3389
+ "docComment": "/**\n * A ref indicating whether the slot is currently empty.\n */\n",
3390
+ "excerptTokens": [
3391
+ {
3392
+ "kind": "Content",
3393
+ "text": "ref: "
3394
+ },
3395
+ {
3396
+ "kind": "Reference",
3397
+ "text": "Ref",
3398
+ "canonicalReference": "@vue/reactivity!Ref:interface"
3399
+ },
3400
+ {
3401
+ "kind": "Content",
3402
+ "text": "<boolean>"
3403
+ },
3404
+ {
3405
+ "kind": "Content",
3406
+ "text": ";"
3407
+ }
3408
+ ],
3409
+ "isReadonly": false,
3410
+ "isOptional": false,
3411
+ "releaseTag": "Public",
3412
+ "name": "ref",
3413
+ "propertyTypeTokenRange": {
3414
+ "startIndex": 1,
3415
+ "endIndex": 3
3416
+ }
3417
+ },
3418
+ {
3419
+ "kind": "PropertySignature",
3420
+ "canonicalReference": "@alloy-js/core!ContentSlot#WhenEmpty:member",
3421
+ "docComment": "/**\n * A component that will render its contents when the content slot is empty.\n */\n",
3422
+ "excerptTokens": [
3423
+ {
3424
+ "kind": "Content",
3425
+ "text": "WhenEmpty: "
3426
+ },
3427
+ {
3428
+ "kind": "Reference",
3429
+ "text": "Component",
3430
+ "canonicalReference": "@alloy-js/core!Component:interface"
3431
+ },
3432
+ {
3433
+ "kind": "Content",
3434
+ "text": "<{}>"
3435
+ },
3436
+ {
3437
+ "kind": "Content",
3438
+ "text": ";"
3439
+ }
3440
+ ],
3441
+ "isReadonly": false,
3442
+ "isOptional": false,
3443
+ "releaseTag": "Public",
3444
+ "name": "WhenEmpty",
3445
+ "propertyTypeTokenRange": {
3446
+ "startIndex": 1,
3447
+ "endIndex": 3
3448
+ }
3449
+ },
3450
+ {
3451
+ "kind": "PropertySignature",
3452
+ "canonicalReference": "@alloy-js/core!ContentSlot#WhenHasContent:member",
3453
+ "docComment": "/**\n * A component that will render its contents when the content slot has content.\n */\n",
3454
+ "excerptTokens": [
3455
+ {
3456
+ "kind": "Content",
3457
+ "text": "WhenHasContent: "
3458
+ },
3459
+ {
3460
+ "kind": "Reference",
3461
+ "text": "Component",
3462
+ "canonicalReference": "@alloy-js/core!Component:interface"
3463
+ },
3464
+ {
3465
+ "kind": "Content",
3466
+ "text": "<{}>"
3467
+ },
3468
+ {
3469
+ "kind": "Content",
3470
+ "text": ";"
3471
+ }
3472
+ ],
3473
+ "isReadonly": false,
3474
+ "isOptional": false,
3475
+ "releaseTag": "Public",
3476
+ "name": "WhenHasContent",
3477
+ "propertyTypeTokenRange": {
3478
+ "startIndex": 1,
3479
+ "endIndex": 3
3480
+ }
3481
+ }
3482
+ ],
3483
+ "extendsTokenRanges": []
3484
+ },
3264
3485
  {
3265
3486
  "kind": "Interface",
3266
3487
  "canonicalReference": "@alloy-js/core!Context:interface",
@@ -3276,6 +3497,33 @@
3276
3497
  "name": "Context",
3277
3498
  "preserveMemberOrder": false,
3278
3499
  "members": [
3500
+ {
3501
+ "kind": "PropertySignature",
3502
+ "canonicalReference": "@alloy-js/core!Context#childrenWithContent:member",
3503
+ "docComment": "/**\n * The number of child nodes that have content. When zero, this component is\n * semantically empty.\n */\n",
3504
+ "excerptTokens": [
3505
+ {
3506
+ "kind": "Content",
3507
+ "text": "childrenWithContent: "
3508
+ },
3509
+ {
3510
+ "kind": "Content",
3511
+ "text": "number"
3512
+ },
3513
+ {
3514
+ "kind": "Content",
3515
+ "text": ";"
3516
+ }
3517
+ ],
3518
+ "isReadonly": false,
3519
+ "isOptional": false,
3520
+ "releaseTag": "Public",
3521
+ "name": "childrenWithContent",
3522
+ "propertyTypeTokenRange": {
3523
+ "startIndex": 1,
3524
+ "endIndex": 2
3525
+ }
3526
+ },
3279
3527
  {
3280
3528
  "kind": "PropertySignature",
3281
3529
  "canonicalReference": "@alloy-js/core!Context#componentOwner:member",
@@ -3400,6 +3648,65 @@
3400
3648
  "endIndex": 2
3401
3649
  }
3402
3650
  },
3651
+ {
3652
+ "kind": "PropertySignature",
3653
+ "canonicalReference": "@alloy-js/core!Context#isEmpty:member",
3654
+ "docComment": "/**\n * A ref that indicates whether the component is empty.\n */\n",
3655
+ "excerptTokens": [
3656
+ {
3657
+ "kind": "Content",
3658
+ "text": "isEmpty?: "
3659
+ },
3660
+ {
3661
+ "kind": "Reference",
3662
+ "text": "Ref",
3663
+ "canonicalReference": "@vue/reactivity!Ref:interface"
3664
+ },
3665
+ {
3666
+ "kind": "Content",
3667
+ "text": "<boolean>"
3668
+ },
3669
+ {
3670
+ "kind": "Content",
3671
+ "text": ";"
3672
+ }
3673
+ ],
3674
+ "isReadonly": false,
3675
+ "isOptional": true,
3676
+ "releaseTag": "Public",
3677
+ "name": "isEmpty",
3678
+ "propertyTypeTokenRange": {
3679
+ "startIndex": 1,
3680
+ "endIndex": 3
3681
+ }
3682
+ },
3683
+ {
3684
+ "kind": "PropertySignature",
3685
+ "canonicalReference": "@alloy-js/core!Context#isRoot:member",
3686
+ "docComment": "/**\n * Whether this context is a root context\n */\n",
3687
+ "excerptTokens": [
3688
+ {
3689
+ "kind": "Content",
3690
+ "text": "isRoot: "
3691
+ },
3692
+ {
3693
+ "kind": "Content",
3694
+ "text": "boolean"
3695
+ },
3696
+ {
3697
+ "kind": "Content",
3698
+ "text": ";"
3699
+ }
3700
+ ],
3701
+ "isReadonly": false,
3702
+ "isOptional": false,
3703
+ "releaseTag": "Public",
3704
+ "name": "isRoot",
3705
+ "propertyTypeTokenRange": {
3706
+ "startIndex": 1,
3707
+ "endIndex": 2
3708
+ }
3709
+ },
3403
3710
  {
3404
3711
  "kind": "PropertySignature",
3405
3712
  "canonicalReference": "@alloy-js/core!Context#meta:member",
@@ -4073,6 +4380,35 @@
4073
4380
  ],
4074
4381
  "name": "createComponent"
4075
4382
  },
4383
+ {
4384
+ "kind": "Function",
4385
+ "canonicalReference": "@alloy-js/core!createContentSlot:function(1)",
4386
+ "docComment": "/**\n * Create a component which tracks whether any content is placed inside of it.\n * The component exposes a ref `isEmpty` which indicates whether the slot is\n * empty, as well as convenience accessors `isEmpty` and `hasContent`.\n * Additionally, it provides two sub-components, `WhenEmpty` and\n * `WhenHasContent`, which render their contents conditionally based on whether\n * the slot is empty.\n *\n * @example\n *\n *\n *\n * ```tsx\n * const ContentSlot = createContentSlot();\n *\n * <>\n * <ContentSlot.WhenEmpty>The slot is empty!</ContentSlot.WhenEmpty>\n * <ContentSlot.WhenHasContent>The slot has content!</ContentSlot.WhenHasContent>\n * <ContentSlot>\n * {someCondition && \"Here is some content!\"}\n * </ContentSlot>\n * </>\n * ```\n *\n */\n",
4387
+ "excerptTokens": [
4388
+ {
4389
+ "kind": "Content",
4390
+ "text": "export declare function createContentSlot(): "
4391
+ },
4392
+ {
4393
+ "kind": "Reference",
4394
+ "text": "ContentSlot",
4395
+ "canonicalReference": "@alloy-js/core!ContentSlot:interface"
4396
+ },
4397
+ {
4398
+ "kind": "Content",
4399
+ "text": ";"
4400
+ }
4401
+ ],
4402
+ "fileUrlPath": "src/content-slot.tsx",
4403
+ "returnTypeTokenRange": {
4404
+ "startIndex": 1,
4405
+ "endIndex": 2
4406
+ },
4407
+ "releaseTag": "Public",
4408
+ "overloadIndex": 1,
4409
+ "parameters": [],
4410
+ "name": "createContentSlot"
4411
+ },
4076
4412
  {
4077
4413
  "kind": "Function",
4078
4414
  "canonicalReference": "@alloy-js/core!createContext:function(1)",
@@ -5504,6 +5840,61 @@
5504
5840
  "endIndex": 4
5505
5841
  }
5506
5842
  },
5843
+ {
5844
+ "kind": "Function",
5845
+ "canonicalReference": "@alloy-js/core!decl:function(1)",
5846
+ "docComment": "/**\n * Create a declaration in the current scope with the given namekey. Only works\n * with basic scopes. Import `decl` from a specific language library for\n * declaring language-specific symbols.\n */\n",
5847
+ "excerptTokens": [
5848
+ {
5849
+ "kind": "Content",
5850
+ "text": "export declare function decl(namekey: "
5851
+ },
5852
+ {
5853
+ "kind": "Reference",
5854
+ "text": "Namekey",
5855
+ "canonicalReference": "@alloy-js/core!Namekey:interface"
5856
+ },
5857
+ {
5858
+ "kind": "Content",
5859
+ "text": "): "
5860
+ },
5861
+ {
5862
+ "kind": "Content",
5863
+ "text": "import(\"../runtime/component.js\")."
5864
+ },
5865
+ {
5866
+ "kind": "Reference",
5867
+ "text": "ComponentCreator",
5868
+ "canonicalReference": "@alloy-js/core!ComponentCreator:interface"
5869
+ },
5870
+ {
5871
+ "kind": "Content",
5872
+ "text": "<{}>"
5873
+ },
5874
+ {
5875
+ "kind": "Content",
5876
+ "text": ";"
5877
+ }
5878
+ ],
5879
+ "fileUrlPath": "src/symbols/decl.ts",
5880
+ "returnTypeTokenRange": {
5881
+ "startIndex": 3,
5882
+ "endIndex": 6
5883
+ },
5884
+ "releaseTag": "Public",
5885
+ "overloadIndex": 1,
5886
+ "parameters": [
5887
+ {
5888
+ "parameterName": "namekey",
5889
+ "parameterTypeTokenRange": {
5890
+ "startIndex": 1,
5891
+ "endIndex": 2
5892
+ },
5893
+ "isOptional": false
5894
+ }
5895
+ ],
5896
+ "name": "decl"
5897
+ },
5507
5898
  {
5508
5899
  "kind": "Function",
5509
5900
  "canonicalReference": "@alloy-js/core!Declaration:function(1)",
@@ -13107,6 +13498,34 @@
13107
13498
  ],
13108
13499
  "extendsTokenRanges": []
13109
13500
  },
13501
+ {
13502
+ "kind": "Function",
13503
+ "canonicalReference": "@alloy-js/core!notifyContentState:function(1)",
13504
+ "docComment": "",
13505
+ "excerptTokens": [
13506
+ {
13507
+ "kind": "Content",
13508
+ "text": "export declare function notifyContentState(): "
13509
+ },
13510
+ {
13511
+ "kind": "Content",
13512
+ "text": "void"
13513
+ },
13514
+ {
13515
+ "kind": "Content",
13516
+ "text": ";"
13517
+ }
13518
+ ],
13519
+ "fileUrlPath": "src/render.ts",
13520
+ "returnTypeTokenRange": {
13521
+ "startIndex": 1,
13522
+ "endIndex": 2
13523
+ },
13524
+ "releaseTag": "Public",
13525
+ "overloadIndex": 1,
13526
+ "parameters": [],
13527
+ "name": "notifyContentState"
13528
+ },
13110
13529
  {
13111
13530
  "kind": "Function",
13112
13531
  "canonicalReference": "@alloy-js/core!onCleanup:function(1)",
@@ -18467,6 +18886,56 @@
18467
18886
  ],
18468
18887
  "extendsTokenRanges": []
18469
18888
  },
18889
+ {
18890
+ "kind": "Function",
18891
+ "canonicalReference": "@alloy-js/core!refId:function(1)",
18892
+ "docComment": "",
18893
+ "excerptTokens": [
18894
+ {
18895
+ "kind": "Content",
18896
+ "text": "export declare function refId(ref: "
18897
+ },
18898
+ {
18899
+ "kind": "Reference",
18900
+ "text": "Ref",
18901
+ "canonicalReference": "@vue/reactivity!Ref:interface"
18902
+ },
18903
+ {
18904
+ "kind": "Content",
18905
+ "text": "<unknown>"
18906
+ },
18907
+ {
18908
+ "kind": "Content",
18909
+ "text": "): "
18910
+ },
18911
+ {
18912
+ "kind": "Content",
18913
+ "text": "number"
18914
+ },
18915
+ {
18916
+ "kind": "Content",
18917
+ "text": ";"
18918
+ }
18919
+ ],
18920
+ "fileUrlPath": "src/reactivity.ts",
18921
+ "returnTypeTokenRange": {
18922
+ "startIndex": 4,
18923
+ "endIndex": 5
18924
+ },
18925
+ "releaseTag": "Public",
18926
+ "overloadIndex": 1,
18927
+ "parameters": [
18928
+ {
18929
+ "parameterName": "ref",
18930
+ "parameterTypeTokenRange": {
18931
+ "startIndex": 1,
18932
+ "endIndex": 3
18933
+ },
18934
+ "isOptional": false
18935
+ }
18936
+ ],
18937
+ "name": "refId"
18938
+ },
18470
18939
  {
18471
18940
  "kind": "Function",
18472
18941
  "canonicalReference": "@alloy-js/core!refkey:function(1)",
@@ -1,5 +1,7 @@
1
+ import { ref } from "@vue/reactivity";
1
2
  import { expect, it } from "vitest";
2
3
  import { Block } from "../../src/components/Block.jsx";
4
+ import { printTree, renderTree } from "../../src/render.js";
3
5
  import "../../testing/extend-expect.js";
4
6
  it("renders properly with no children", () => {
5
7
  const template = (
@@ -33,7 +35,7 @@ it("renders properly with newline and no children", () => {
33
35
  `);
34
36
  });
35
37
 
36
- it("renders properly with newline and no children", () => {
38
+ it("renders properly with newline and children", () => {
37
39
  const template = (
38
40
  <>
39
41
  class<Block newline>contents!!</Block>
@@ -46,3 +48,21 @@ it("renders properly with newline and no children", () => {
46
48
  }
47
49
  `);
48
50
  });
51
+
52
+ it("renders properly when content is added reactively", () => {
53
+ const contents = ref("");
54
+ const tree = renderTree(
55
+ <>
56
+ class Foo <Block>{contents}</Block>
57
+ </>,
58
+ );
59
+ expect(printTree(tree)).toRenderTo(`
60
+ class Foo {}
61
+ `);
62
+ contents.value = "x = 12;";
63
+ expect(printTree(tree)).toRenderTo(`
64
+ class Foo {
65
+ x = 12;
66
+ }
67
+ `);
68
+ });
@@ -1,5 +1,12 @@
1
1
  import { expect, it } from "vitest";
2
- import { List, printTree, ref, renderTree } from "../../src/index.js";
2
+ import {
3
+ createContentSlot,
4
+ List,
5
+ printTree,
6
+ ref,
7
+ renderTree,
8
+ Show,
9
+ } from "../../src/index.js";
3
10
  import "../../testing/extend-expect.js";
4
11
  import { d } from "../../testing/render.js";
5
12
 
@@ -88,3 +95,71 @@ it("is useful for statements", () => {
88
95
 
89
96
  `);
90
97
  });
98
+
99
+ it("doesn't add joiners when items are empty", () => {
100
+ expect(
101
+ <group>
102
+ <List comma line>
103
+ <></>
104
+ <></>
105
+ <></>
106
+ </List>
107
+ </group>,
108
+ ).toRenderTo(``);
109
+ });
110
+
111
+ it("It add joiners when items are become non-empty", () => {
112
+ const item1 = ref("");
113
+ const item2 = ref("");
114
+ const item3 = ref("");
115
+
116
+ const tree = renderTree(
117
+ <group>
118
+ <List comma line ender=";">
119
+ <>{item1}</>
120
+ <>{item2}</>
121
+ <>{item3}</>
122
+ </List>
123
+ </group>,
124
+ );
125
+
126
+ expect(printTree(tree)).toBe(``);
127
+ item1.value = "hi";
128
+ expect(printTree(tree)).toBe(`hi;`);
129
+ item2.value = "there";
130
+ expect(printTree(tree)).toBe(`hi, there;`);
131
+ item3.value = "friend";
132
+ expect(printTree(tree)).toBe(`hi, there, friend;`);
133
+
134
+ item1.value = "";
135
+ expect(printTree(tree)).toBe(`there, friend;`);
136
+ item3.value = "";
137
+ expect(printTree(tree)).toBe(`there;`);
138
+ item2.value = "";
139
+ expect(printTree(tree)).toBe(``);
140
+ });
141
+
142
+ it("works with show", () => {
143
+ const ContentSlot = createContentSlot();
144
+ const showFirst = ref(false);
145
+ const showSecond = ref(false);
146
+ const tree = renderTree(
147
+ <>
148
+ <ContentSlot.WhenEmpty>Empty list!</ContentSlot.WhenEmpty>
149
+ <ContentSlot>
150
+ <List comma space>
151
+ <Show when={showFirst.value}>One</Show>
152
+ <Show when={showSecond.value}>Two</Show>
153
+ </List>
154
+ </ContentSlot>
155
+ </>,
156
+ );
157
+ expect(printTree(tree)).toBe(`Empty list!`);
158
+ showFirst.value = true;
159
+ expect(printTree(tree)).toBe(`One`);
160
+ showSecond.value = true;
161
+ expect(printTree(tree)).toBe(`One, Two`);
162
+ showFirst.value = false;
163
+ showSecond.value = false;
164
+ expect(printTree(tree)).toBe(`Empty list!`);
165
+ });