create-foldkit-app 0.35.1 → 0.35.2

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 (134) hide show
  1. package/dist/templates/base/FOLDKIT.md +2 -2
  2. package/dist/templates/examples/api-cache/package.json +2 -2
  3. package/dist/templates/examples/api-cache/src/main.fixture.ts +4 -4
  4. package/dist/templates/examples/api-cache/src/main.ts +12 -12
  5. package/dist/templates/examples/api-cache/src/story.test.ts +6 -6
  6. package/dist/templates/examples/auth/package.json +2 -2
  7. package/dist/templates/examples/auth/src/page/loggedOut/page/login.scene.test.ts +2 -2
  8. package/dist/templates/examples/auth/src/page/loggedOut/page/login.story.test.ts +2 -2
  9. package/dist/templates/examples/auth/src/page/loggedOut/page/login.ts +5 -5
  10. package/dist/templates/examples/auth/src/page/loggedOut/update.ts +2 -2
  11. package/dist/templates/examples/auth/src/scene.test.ts +2 -2
  12. package/dist/templates/examples/auth/src/update.ts +3 -3
  13. package/dist/templates/examples/canvas-art/package.json +2 -2
  14. package/dist/templates/examples/canvas-art/src/main.ts +6 -6
  15. package/dist/templates/examples/canvas-art/src/scene.test.ts +3 -3
  16. package/dist/templates/examples/canvas-art/src/story.test.ts +3 -3
  17. package/dist/templates/examples/charting/package.json +2 -2
  18. package/dist/templates/examples/charting/src/main.fixture.ts +2 -2
  19. package/dist/templates/examples/charting/src/scene.test.ts +3 -3
  20. package/dist/templates/examples/charting/src/story.test.ts +2 -2
  21. package/dist/templates/examples/charting/src/update.ts +18 -16
  22. package/dist/templates/examples/counter/package.json +2 -2
  23. package/dist/templates/examples/counter/src/main.ts +4 -4
  24. package/dist/templates/examples/counters/package.json +2 -2
  25. package/dist/templates/examples/counters/src/counter.ts +3 -3
  26. package/dist/templates/examples/counters/src/main.ts +7 -5
  27. package/dist/templates/examples/crash-view/package.json +2 -2
  28. package/dist/templates/examples/embedding/package.json +2 -2
  29. package/dist/templates/examples/embedding/src/main.ts +5 -3
  30. package/dist/templates/examples/embedding/src/scene.test.ts +2 -2
  31. package/dist/templates/examples/embedding/src/story.test.ts +2 -2
  32. package/dist/templates/examples/form/package.json +2 -2
  33. package/dist/templates/examples/form/src/main.ts +9 -9
  34. package/dist/templates/examples/form/src/scene.test.ts +5 -5
  35. package/dist/templates/examples/form/src/story.test.ts +4 -4
  36. package/dist/templates/examples/generative-art/package.json +2 -2
  37. package/dist/templates/examples/generative-art/src/scene.test.ts +2 -2
  38. package/dist/templates/examples/generative-art/src/story.test.ts +3 -3
  39. package/dist/templates/examples/generative-art/src/update.ts +11 -11
  40. package/dist/templates/examples/interrupting-commands/package.json +2 -2
  41. package/dist/templates/examples/interrupting-commands/src/main.ts +8 -6
  42. package/dist/templates/examples/job-application/package.json +2 -2
  43. package/dist/templates/examples/job-application/src/main.fixture.ts +9 -9
  44. package/dist/templates/examples/job-application/src/scene.test.ts +13 -13
  45. package/dist/templates/examples/job-application/src/step/attachments/attachments.ts +7 -7
  46. package/dist/templates/examples/job-application/src/step/coverLetter/coverLetter.ts +2 -2
  47. package/dist/templates/examples/job-application/src/step/education/education.ts +6 -6
  48. package/dist/templates/examples/job-application/src/step/education/entry/entry.ts +14 -8
  49. package/dist/templates/examples/job-application/src/step/personalInfo/personalInfo.ts +20 -15
  50. package/dist/templates/examples/job-application/src/step/personalInfo/story.test.ts +2 -2
  51. package/dist/templates/examples/job-application/src/step/skills/entry/entry.ts +7 -5
  52. package/dist/templates/examples/job-application/src/step/skills/skills.ts +6 -6
  53. package/dist/templates/examples/job-application/src/step/workHistory/entry/entry.ts +13 -12
  54. package/dist/templates/examples/job-application/src/step/workHistory/workHistory.ts +6 -6
  55. package/dist/templates/examples/job-application/src/story.test.ts +10 -10
  56. package/dist/templates/examples/job-application/src/update.ts +25 -18
  57. package/dist/templates/examples/kanban/package.json +2 -2
  58. package/dist/templates/examples/kanban/src/domain/column.ts +9 -6
  59. package/dist/templates/examples/kanban/src/update.ts +8 -8
  60. package/dist/templates/examples/managed-resource-layer/package.json +2 -2
  61. package/dist/templates/examples/managed-resource-layer/src/main.ts +11 -7
  62. package/dist/templates/examples/managed-resource-layer/src/story.test.ts +3 -3
  63. package/dist/templates/examples/map/package.json +2 -2
  64. package/dist/templates/examples/map/src/main.fixture.ts +2 -2
  65. package/dist/templates/examples/map/src/main.ts +11 -11
  66. package/dist/templates/examples/map/src/scene.test.ts +4 -4
  67. package/dist/templates/examples/map/src/story.test.ts +4 -4
  68. package/dist/templates/examples/pixel-art/package.json +2 -2
  69. package/dist/templates/examples/pixel-art/src/comparison.bench.test.ts +2 -2
  70. package/dist/templates/examples/pixel-art/src/main.bench.ts +7 -3
  71. package/dist/templates/examples/pixel-art/src/scene.test.ts +5 -5
  72. package/dist/templates/examples/pixel-art/src/story.test.ts +4 -4
  73. package/dist/templates/examples/pixel-art/src/subscription.ts +2 -2
  74. package/dist/templates/examples/pixel-art/src/update.ts +49 -33
  75. package/dist/templates/examples/query-sync/package.json +2 -2
  76. package/dist/templates/examples/query-sync/src/main.ts +4 -4
  77. package/dist/templates/examples/query-sync/src/scene.test.ts +4 -4
  78. package/dist/templates/examples/query-sync/src/story.test.ts +2 -2
  79. package/dist/templates/examples/route-transitions/package.json +2 -2
  80. package/dist/templates/examples/route-transitions/src/main.ts +10 -10
  81. package/dist/templates/examples/route-transitions/src/story.test.ts +10 -6
  82. package/dist/templates/examples/routing/package.json +2 -2
  83. package/dist/templates/examples/routing/src/main.ts +13 -17
  84. package/dist/templates/examples/routing/src/page/people.ts +4 -4
  85. package/dist/templates/examples/shopping-cart/package.json +2 -2
  86. package/dist/templates/examples/shopping-cart/src/domain/cart.ts +4 -4
  87. package/dist/templates/examples/shopping-cart/src/main.ts +12 -12
  88. package/dist/templates/examples/shopping-cart/src/page/products.ts +2 -2
  89. package/dist/templates/examples/shopping-cart/src/scene.test.ts +10 -8
  90. package/dist/templates/examples/shopping-cart/src/story.test.ts +7 -7
  91. package/dist/templates/examples/slow-warnings/package.json +2 -2
  92. package/dist/templates/examples/slow-warnings/src/handleSlow.test.ts +2 -2
  93. package/dist/templates/examples/slow-warnings/src/main.ts +8 -8
  94. package/dist/templates/examples/slow-warnings/src/scene.test.ts +2 -2
  95. package/dist/templates/examples/slow-warnings/src/story.test.ts +2 -2
  96. package/dist/templates/examples/snake/package.json +2 -2
  97. package/dist/templates/examples/snake/src/main.ts +10 -10
  98. package/dist/templates/examples/snake/src/scene.test.ts +10 -5
  99. package/dist/templates/examples/snake/src/story.test.ts +6 -6
  100. package/dist/templates/examples/ssg/package.json +2 -2
  101. package/dist/templates/examples/ssg/src/main.ts +3 -3
  102. package/dist/templates/examples/ssr/package.json +4 -4
  103. package/dist/templates/examples/ssr/src/main.ts +3 -3
  104. package/dist/templates/examples/state-machine/package.json +2 -2
  105. package/dist/templates/examples/state-machine/src/main.ts +14 -10
  106. package/dist/templates/examples/stopwatch/package.json +2 -2
  107. package/dist/templates/examples/stopwatch/src/main.ts +5 -5
  108. package/dist/templates/examples/stopwatch/src/story.test.ts +2 -2
  109. package/dist/templates/examples/todo/package.json +2 -2
  110. package/dist/templates/examples/todo/src/main.ts +17 -17
  111. package/dist/templates/examples/todo/src/scene.test.ts +4 -4
  112. package/dist/templates/examples/todo/src/story.test.ts +22 -16
  113. package/dist/templates/examples/ui-showcase/package.json +2 -2
  114. package/dist/templates/examples/ui-showcase/src/main.ts +8 -5
  115. package/dist/templates/examples/ui-showcase/src/story.test.ts +3 -3
  116. package/dist/templates/examples/ui-showcase/src/ui/init.ts +4 -1
  117. package/dist/templates/examples/ui-showcase/src/ui/subscriptions.ts +10 -0
  118. package/dist/templates/examples/ui-showcase/src/ui/update.ts +119 -91
  119. package/dist/templates/examples/ui-showcase/src/ui/view/toast.ts +20 -3
  120. package/dist/templates/examples/view-transitions/package.json +2 -2
  121. package/dist/templates/examples/view-transitions/src/main.ts +3 -3
  122. package/dist/templates/examples/weather/package.json +2 -2
  123. package/dist/templates/examples/weather/src/main.ts +5 -5
  124. package/dist/templates/examples/web-components/package.json +2 -2
  125. package/dist/templates/examples/web-components/src/main.ts +4 -4
  126. package/dist/templates/examples/websocket-chat/package.json +2 -2
  127. package/dist/templates/examples/websocket-chat/src/main.ts +8 -8
  128. package/dist/templates/examples/websocket-chat/src/scene.test.ts +18 -6
  129. package/dist/templates/examples/websocket-chat/src/story.test.ts +15 -9
  130. package/dist/templates/release.json +13 -13
  131. package/dist/templates/rendering/ssg/src/main.ts +3 -3
  132. package/dist/templates/rendering/ssr/scripts/serve.ts +2 -2
  133. package/dist/templates/rendering/ssr/src/main.ts +3 -3
  134. package/package.json +5 -5
@@ -14,7 +14,7 @@ import { Command, Runtime, type Update } from 'foldkit'
14
14
  import { Document, Html, HtmlBuilder } from 'foldkit/html'
15
15
  import { defineMessageUnion } from 'foldkit/message'
16
16
  import { defineTaggedUnion } from 'foldkit/schema'
17
- import { evo } from 'foldkit/struct'
17
+ import { modifyFields } from 'foldkit/struct'
18
18
 
19
19
  import { BrowserKeyValueStore } from '@effect/platform-browser'
20
20
  import { Button, Checkbox, Input } from '@foldkit/ui'
@@ -104,13 +104,13 @@ type UpdateReturn = Update.Return<Model, Message>
104
104
  export const update = (model: Model, message: Message) =>
105
105
  Message.match<UpdateReturn>(message, {
106
106
  UpdatedNewTodo: ({ text }) => ({
107
- model: evo(model, {
107
+ model: modifyFields(model, {
108
108
  newTodoText: () => text,
109
109
  }),
110
110
  }),
111
111
 
112
112
  UpdatedEditingTodo: ({ text }) => ({
113
- model: evo(model, {
113
+ model: modifyFields(model, {
114
114
  editing: () =>
115
115
  EditingState.match(model.editing, {
116
116
  NotEditing: () => model.editing,
@@ -141,7 +141,7 @@ export const update = (model: Model, message: Message) =>
141
141
  const updatedTodos = [...model.todos, newTodo]
142
142
 
143
143
  return {
144
- model: evo(model, {
144
+ model: modifyFields(model, {
145
145
  todos: () => updatedTodos,
146
146
  newTodoText: () => '',
147
147
  }),
@@ -153,7 +153,7 @@ export const update = (model: Model, message: Message) =>
153
153
  const updatedTodos = Array.filter(model.todos, todo => todo.id !== id)
154
154
 
155
155
  return {
156
- model: evo(model, {
156
+ model: modifyFields(model, {
157
157
  todos: () => updatedTodos,
158
158
  }),
159
159
  commands: [SaveTodos({ todos: updatedTodos })],
@@ -163,12 +163,12 @@ export const update = (model: Model, message: Message) =>
163
163
  ToggledTodo: ({ id }) => {
164
164
  const updatedTodos = Array.map(model.todos, todo =>
165
165
  todo.id === id
166
- ? evo(todo, { completed: completed => !completed })
166
+ ? modifyFields(todo, { completed: completed => !completed })
167
167
  : todo,
168
168
  )
169
169
 
170
170
  return {
171
- model: evo(model, {
171
+ model: modifyFields(model, {
172
172
  todos: () => updatedTodos,
173
173
  }),
174
174
  commands: [SaveTodos({ todos: updatedTodos })],
@@ -178,7 +178,7 @@ export const update = (model: Model, message: Message) =>
178
178
  StartedEditing: ({ id }) => {
179
179
  const maybeTodo = Array.findFirst(model.todos, todo => todo.id === id)
180
180
  return {
181
- model: evo(model, {
181
+ model: modifyFields(model, {
182
182
  editing: () =>
183
183
  EditingState.Editing({
184
184
  id,
@@ -198,7 +198,7 @@ export const update = (model: Model, message: Message) =>
198
198
  Editing: ({ id, text }) => {
199
199
  if (String.isEmpty(String.trim(text))) {
200
200
  return {
201
- model: evo(model, {
201
+ model: modifyFields(model, {
202
202
  editing: () => EditingState.NotEditing(),
203
203
  }),
204
204
  }
@@ -206,12 +206,12 @@ export const update = (model: Model, message: Message) =>
206
206
 
207
207
  const updatedTodos = Array.map(model.todos, todo =>
208
208
  todo.id === id
209
- ? evo(todo, { text: () => String.trim(text) })
209
+ ? modifyFields(todo, { text: () => String.trim(text) })
210
210
  : todo,
211
211
  )
212
212
 
213
213
  return {
214
- model: evo(model, {
214
+ model: modifyFields(model, {
215
215
  todos: () => updatedTodos,
216
216
  editing: () => EditingState.NotEditing(),
217
217
  }),
@@ -221,7 +221,7 @@ export const update = (model: Model, message: Message) =>
221
221
  }),
222
222
 
223
223
  CancelledEdit: () => ({
224
- model: evo(model, {
224
+ model: modifyFields(model, {
225
225
  editing: () => EditingState.NotEditing(),
226
226
  }),
227
227
  }),
@@ -229,13 +229,13 @@ export const update = (model: Model, message: Message) =>
229
229
  ToggledAll: () => {
230
230
  const allCompleted = Array.every(model.todos, todo => todo.completed)
231
231
  const updatedTodos = Array.map(model.todos, todo =>
232
- evo(todo, {
232
+ modifyFields(todo, {
233
233
  completed: () => !allCompleted,
234
234
  }),
235
235
  )
236
236
 
237
237
  return {
238
- model: evo(model, {
238
+ model: modifyFields(model, {
239
239
  todos: () => updatedTodos,
240
240
  }),
241
241
  commands: [SaveTodos({ todos: updatedTodos })],
@@ -246,7 +246,7 @@ export const update = (model: Model, message: Message) =>
246
246
  const updatedTodos = Array.filter(model.todos, todo => !todo.completed)
247
247
 
248
248
  return {
249
- model: evo(model, {
249
+ model: modifyFields(model, {
250
250
  todos: () => updatedTodos,
251
251
  }),
252
252
  commands: [SaveTodos({ todos: updatedTodos })],
@@ -254,13 +254,13 @@ export const update = (model: Model, message: Message) =>
254
254
  },
255
255
 
256
256
  SelectedFilter: ({ filter }) => ({
257
- model: evo(model, {
257
+ model: modifyFields(model, {
258
258
  filter: () => filter,
259
259
  }),
260
260
  }),
261
261
 
262
262
  SucceededSaveTodos: ({ todos }) => ({
263
- model: evo(model, {
263
+ model: modifyFields(model, {
264
264
  todos: () => todos,
265
265
  }),
266
266
  }),
@@ -10,7 +10,7 @@ import {
10
10
  text,
11
11
  type,
12
12
  } from 'foldkit/scene'
13
- import { evo } from 'foldkit/struct'
13
+ import { modifyFields } from 'foldkit/struct'
14
14
  import { describe, test } from 'vitest'
15
15
 
16
16
  import {
@@ -30,7 +30,7 @@ const emptyModel: Model = {
30
30
  editing: EditingState.NotEditing(),
31
31
  }
32
32
 
33
- const modelWithTodos: Model = evo(emptyModel, {
33
+ const modelWithTodos: Model = modifyFields(emptyModel, {
34
34
  todos: () => [
35
35
  { id: 'abc', text: 'Buy milk', completed: false, createdAt: 1000 },
36
36
  { id: 'def', text: 'Walk the dog', completed: false, createdAt: 2000 },
@@ -93,7 +93,7 @@ describe('view', () => {
93
93
 
94
94
  test('toggle a todo by clicking its checkbox', () => {
95
95
  const toggledTodos = modelWithTodos.todos.map(todo =>
96
- todo.id === 'abc' ? evo(todo, { completed: () => true }) : todo,
96
+ todo.id === 'abc' ? modifyFields(todo, { completed: () => true }) : todo,
97
97
  )
98
98
 
99
99
  scene(
@@ -147,7 +147,7 @@ describe('view', () => {
147
147
 
148
148
  test('mark all complete toggles all todos', () => {
149
149
  const allCompletedTodos = modelWithTodos.todos.map(todo =>
150
- evo(todo, { completed: () => true }),
150
+ modifyFields(todo, { completed: () => true }),
151
151
  )
152
152
 
153
153
  scene(
@@ -1,6 +1,6 @@
1
1
  import { Array, Option } from 'effect'
2
2
  import { Command, given, message, model, story } from 'foldkit/story'
3
- import { evo } from 'foldkit/struct'
3
+ import { modifyFields } from 'foldkit/struct'
4
4
  import { describe, expect, test } from 'vitest'
5
5
 
6
6
  import {
@@ -40,7 +40,7 @@ const doneTask = {
40
40
  createdAt: 3000,
41
41
  }
42
42
 
43
- const modelWithTodos: Model = evo(emptyModel, {
43
+ const modelWithTodos: Model = modifyFields(emptyModel, {
44
44
  todos: () => [buyMilk, walkDog, doneTask],
45
45
  })
46
46
 
@@ -49,7 +49,7 @@ describe('update', () => {
49
49
  test('AddedTodo with text produces a GenerateTodo Command', () => {
50
50
  story(
51
51
  update,
52
- given(evo(emptyModel, { newTodoText: () => 'Buy milk' })),
52
+ given(modifyFields(emptyModel, { newTodoText: () => 'Buy milk' })),
53
53
  message(Message.AddedTodo()),
54
54
  Command.expectHas(GenerateTodo),
55
55
  Command.resolve(
@@ -85,7 +85,7 @@ describe('update', () => {
85
85
  test('AddedTodo with empty text is ignored', () => {
86
86
  story(
87
87
  update,
88
- given(evo(emptyModel, { newTodoText: () => '' })),
88
+ given(modifyFields(emptyModel, { newTodoText: () => '' })),
89
89
  message(Message.AddedTodo()),
90
90
  Command.expectNone(),
91
91
  )
@@ -94,7 +94,7 @@ describe('update', () => {
94
94
  test('AddedTodo with whitespace-only text is ignored', () => {
95
95
  story(
96
96
  update,
97
- given(evo(emptyModel, { newTodoText: () => ' ' })),
97
+ given(modifyFields(emptyModel, { newTodoText: () => ' ' })),
98
98
  message(Message.AddedTodo()),
99
99
  Command.expectNone(),
100
100
  )
@@ -115,7 +115,9 @@ describe('update', () => {
115
115
  describe('toggle and delete', () => {
116
116
  test('ToggledTodo flips the completed state', () => {
117
117
  const toggledTodos = modelWithTodos.todos.map(todo =>
118
- todo.id === 'abc' ? evo(todo, { completed: () => true }) : todo,
118
+ todo.id === 'abc'
119
+ ? modifyFields(todo, { completed: () => true })
120
+ : todo,
119
121
  )
120
122
 
121
123
  story(
@@ -137,7 +139,9 @@ describe('update', () => {
137
139
 
138
140
  test('ToggledTodo on completed todo marks it active', () => {
139
141
  const toggledTodos = modelWithTodos.todos.map(todo =>
140
- todo.id === 'ghi' ? evo(todo, { completed: () => false }) : todo,
142
+ todo.id === 'ghi'
143
+ ? modifyFields(todo, { completed: () => false })
144
+ : todo,
141
145
  )
142
146
 
143
147
  story(
@@ -195,7 +199,7 @@ describe('update', () => {
195
199
  })
196
200
 
197
201
  test('UpdatedEditingTodo updates the editing text', () => {
198
- const editingModel: Model = evo(modelWithTodos, {
202
+ const editingModel: Model = modifyFields(modelWithTodos, {
199
203
  editing: () => EditingState.Editing({ id: 'abc', text: 'Buy milk' }),
200
204
  })
201
205
 
@@ -212,13 +216,15 @@ describe('update', () => {
212
216
  })
213
217
 
214
218
  test('SavedEdit updates the todo text and exits editing', () => {
215
- const editingModel: Model = evo(modelWithTodos, {
219
+ const editingModel: Model = modifyFields(modelWithTodos, {
216
220
  editing: () =>
217
221
  EditingState.Editing({ id: 'abc', text: 'Buy oat milk' }),
218
222
  })
219
223
 
220
224
  const editedTodos = modelWithTodos.todos.map(todo =>
221
- todo.id === 'abc' ? evo(todo, { text: () => 'Buy oat milk' }) : todo,
225
+ todo.id === 'abc'
226
+ ? modifyFields(todo, { text: () => 'Buy oat milk' })
227
+ : todo,
222
228
  )
223
229
 
224
230
  story(
@@ -240,7 +246,7 @@ describe('update', () => {
240
246
  })
241
247
 
242
248
  test('SavedEdit with empty text exits editing without saving', () => {
243
- const editingModel: Model = evo(modelWithTodos, {
249
+ const editingModel: Model = modifyFields(modelWithTodos, {
244
250
  editing: () => EditingState.Editing({ id: 'abc', text: ' ' }),
245
251
  })
246
252
 
@@ -260,7 +266,7 @@ describe('update', () => {
260
266
  })
261
267
 
262
268
  test('CancelledEdit exits editing without changes', () => {
263
- const editingModel: Model = evo(modelWithTodos, {
269
+ const editingModel: Model = modifyFields(modelWithTodos, {
264
270
  editing: () =>
265
271
  EditingState.Editing({ id: 'abc', text: 'Changed text' }),
266
272
  })
@@ -283,7 +289,7 @@ describe('update', () => {
283
289
  describe('bulk operations', () => {
284
290
  test('ToggledAll marks all todos completed when some are active', () => {
285
291
  const allCompletedTodos = modelWithTodos.todos.map(todo =>
286
- evo(todo, { completed: () => true }),
292
+ modifyFields(todo, { completed: () => true }),
287
293
  )
288
294
 
289
295
  story(
@@ -303,15 +309,15 @@ describe('update', () => {
303
309
  })
304
310
 
305
311
  test('ToggledAll marks all todos active when all are completed', () => {
306
- const allCompletedModel: Model = evo(emptyModel, {
312
+ const allCompletedModel: Model = modifyFields(emptyModel, {
307
313
  todos: () =>
308
314
  modelWithTodos.todos.map(todo =>
309
- evo(todo, { completed: () => true }),
315
+ modifyFields(todo, { completed: () => true }),
310
316
  ),
311
317
  })
312
318
 
313
319
  const allActiveTodos = allCompletedModel.todos.map(todo =>
314
- evo(todo, { completed: () => false }),
320
+ modifyFields(todo, { completed: () => false }),
315
321
  )
316
322
 
317
323
  story(
@@ -9,10 +9,10 @@
9
9
  "test": "vitest run"
10
10
  },
11
11
  "dependencies": {
12
- "@effect/platform-browser": "4.0.0-rc.115",
12
+ "@effect/platform-browser": "4.0.0-rc.116",
13
13
  "@foldkit/ui": "workspace:*",
14
14
  "clsx": "^2.1.1",
15
- "effect": "4.0.0-rc.115",
15
+ "effect": "4.0.0-rc.116",
16
16
  "foldkit": "workspace:*"
17
17
  },
18
18
  "devDependencies": {
@@ -13,7 +13,7 @@ import { Document, Html, HtmlBuilder } from 'foldkit/html'
13
13
  import { defineMessageUnion } from 'foldkit/message'
14
14
  import { UrlRequest, load, pushUrl } from 'foldkit/navigation'
15
15
  import { defineRouteUnion, literal } from 'foldkit/route'
16
- import { evo } from 'foldkit/struct'
16
+ import { modifyFields } from 'foldkit/struct'
17
17
  import { Url, toString as urlToString } from 'foldkit/url'
18
18
 
19
19
  import { Dialog, Nav } from '@foldkit/ui'
@@ -211,21 +211,24 @@ const toUiMessage = (message: UiMessage): Message =>
211
211
  const foldUi = Update.foldChild({
212
212
  update: uiUpdate,
213
213
  read: (model: Model) => Option.some(model.uiModel),
214
- write: (model, nextUiModel) => evo(model, { uiModel: () => nextUiModel }),
214
+ write: (model, nextUiModel) =>
215
+ modifyFields(model, { uiModel: () => nextUiModel }),
215
216
  toParentMessage: toUiMessage,
216
217
  })
217
218
 
218
219
  const foldUiOpenMobileMenu = Update.foldChildStep({
219
220
  update: openMobileMenu,
220
221
  read: (model: Model) => Option.some(model.uiModel),
221
- write: (model, nextUiModel) => evo(model, { uiModel: () => nextUiModel }),
222
+ write: (model, nextUiModel) =>
223
+ modifyFields(model, { uiModel: () => nextUiModel }),
222
224
  toParentMessage: toUiMessage,
223
225
  })
224
226
 
225
227
  const foldUiCloseMobileMenu = Update.foldChildStep({
226
228
  update: closeMobileMenu,
227
229
  read: (model: Model) => Option.some(model.uiModel),
228
- write: (model, nextUiModel) => evo(model, { uiModel: () => nextUiModel }),
230
+ write: (model, nextUiModel) =>
231
+ modifyFields(model, { uiModel: () => nextUiModel }),
229
232
  toParentMessage: toUiMessage,
230
233
  })
231
234
 
@@ -251,7 +254,7 @@ export const update = (model: Model, message: Message) =>
251
254
  ChangedUrl: ({ url }) =>
252
255
  Update.combine(model, [
253
256
  stepModel => ({
254
- model: evo(stepModel, { route: () => urlToAppRoute(url) }),
257
+ model: modifyFields(stepModel, { route: () => urlToAppRoute(url) }),
255
258
  }),
256
259
  foldUiCloseMobileMenu,
257
260
  ]),
@@ -1,7 +1,7 @@
1
1
  import { Option } from 'effect'
2
2
  import { Calendar } from 'foldkit'
3
3
  import { Command, given, message, model, story } from 'foldkit/story'
4
- import { evo } from 'foldkit/struct'
4
+ import { modifyFields } from 'foldkit/struct'
5
5
  import { fromString } from 'foldkit/url'
6
6
  import { describe, expect, test } from 'vitest'
7
7
 
@@ -98,8 +98,8 @@ describe('update', () => {
98
98
 
99
99
  describe('mobile menu', () => {
100
100
  test('navigating to a new URL closes the mobile menu dialog', () => {
101
- const modelWithOpenMenu: Model = evo(initialModel, {
102
- uiModel: evo({
101
+ const modelWithOpenMenu: Model = modifyFields(initialModel, {
102
+ uiModel: modifyFields({
103
103
  mobileMenuDialog: () =>
104
104
  Dialog.boot({
105
105
  id: 'mobile-menu',
@@ -167,7 +167,10 @@ export const uiInit = (today: Calendar.CalendarDate): InitReturn => ({
167
167
  id: 'vertical-tabs-demo',
168
168
  }),
169
169
  verticalTabsDemoTab: 'Foldkit',
170
- toastDemo: Toast.init({ id: 'toast-demo' }),
170
+ toastDemo: Toast.init({
171
+ id: 'toast-demo',
172
+ swipeToDismiss: {},
173
+ }),
171
174
  tooltipBasicDemo: Tooltip.init({ id: 'tooltip-basic-demo' }),
172
175
  tooltipNoDelayDemo: Tooltip.init({
173
176
  id: 'tooltip-no-delay-demo',
@@ -4,6 +4,7 @@ import { DragAndDrop, Slider, VirtualList } from '@foldkit/ui'
4
4
 
5
5
  import { Message as UiMessage } from './message'
6
6
  import type { UiModel } from './model'
7
+ import { Toast } from './toast'
7
8
 
8
9
  const dragAndDropSubscriptions = Subscription.lift({
9
10
  dragPointer: DragAndDrop.subscriptions.documentPointer,
@@ -46,10 +47,19 @@ const virtualListVariableDemoSubscriptions = Subscription.lift({
46
47
  UiMessage.GotVirtualListVariableDemoMessage({ message }),
47
48
  })
48
49
 
50
+ const toastDemoSubscriptions = Subscription.lift(Toast.subscriptions)<
51
+ UiModel,
52
+ UiMessage
53
+ >({
54
+ toChildModel: model => model.toastDemo,
55
+ toParentMessage: message => UiMessage.GotToastDemoMessage({ message }),
56
+ })
57
+
49
58
  export const subscriptions = Subscription.aggregate(
50
59
  dragAndDropSubscriptions,
51
60
  sliderRatingSubscriptions,
52
61
  sliderVolumeSubscriptions,
53
62
  virtualListDemoSubscriptions,
54
63
  virtualListVariableDemoSubscriptions,
64
+ toastDemoSubscriptions,
55
65
  )