@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
@@ -2,7 +2,13 @@ import "@alloy-js/core/testing";
2
2
  import { d } from "@alloy-js/core/testing";
3
3
  import { describe, expect, it } from "vitest";
4
4
  import { For } from "../../src/components/For.jsx";
5
- import { onCleanup, printTree, reactive, renderTree } from "../../src/index.js";
5
+ import {
6
+ onCleanup,
7
+ printTree,
8
+ reactive,
9
+ ref,
10
+ renderTree,
11
+ } from "../../src/index.js";
6
12
  import { flushJobs } from "../../src/scheduler.js";
7
13
 
8
14
  it("works", () => {
@@ -154,7 +160,13 @@ it("doesn't rerender mappers with maps", () => {
154
160
  it("doesn't rerender mappers (with splice)", () => {
155
161
  const messages = reactive(["hi", "maybe", "bye"]);
156
162
  let count = 0;
157
- const template = <For each={messages}>{(msg) => <>item {count++}</>}</For>;
163
+ const template = (
164
+ <For each={messages}>
165
+ {(msg) => {
166
+ return <>item {count++}</>;
167
+ }}
168
+ </For>
169
+ );
158
170
  const tree = renderTree(template);
159
171
  expect(count).toBe(3);
160
172
  messages.splice(1, 1);
@@ -239,3 +251,32 @@ it("cleans up things which end up removed (with splice)", () => {
239
251
  Letter c
240
252
  `);
241
253
  });
254
+
255
+ it("doesn't render empty content", () => {
256
+ const items = [1, 2, 3];
257
+ const tree = renderTree(
258
+ <For each={items}>{(item) => (item > 2 ? item : null)}</For>,
259
+ );
260
+ expect(printTree(tree)).toBe(`3`);
261
+ });
262
+
263
+ it("updates joiners appropriately when items get/lose content", () => {
264
+ const items = [
265
+ { content: ref("") },
266
+ { content: ref("") },
267
+ { content: ref("hello") },
268
+ ];
269
+
270
+ const tree = renderTree(
271
+ <For each={items} joiner=", ">
272
+ {(item) => {
273
+ return item.content;
274
+ }}
275
+ </For>,
276
+ );
277
+
278
+ expect(printTree(tree)).toBe(`hello`);
279
+ items[1].content.value = "hi";
280
+ flushJobs();
281
+ expect(printTree(tree)).toBe(`hi, hello`);
282
+ });