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.
- package/dist/templates/base/FOLDKIT.md +2 -2
- package/dist/templates/examples/api-cache/package.json +2 -2
- package/dist/templates/examples/api-cache/src/main.fixture.ts +4 -4
- package/dist/templates/examples/api-cache/src/main.ts +12 -12
- package/dist/templates/examples/api-cache/src/story.test.ts +6 -6
- package/dist/templates/examples/auth/package.json +2 -2
- package/dist/templates/examples/auth/src/page/loggedOut/page/login.scene.test.ts +2 -2
- package/dist/templates/examples/auth/src/page/loggedOut/page/login.story.test.ts +2 -2
- package/dist/templates/examples/auth/src/page/loggedOut/page/login.ts +5 -5
- package/dist/templates/examples/auth/src/page/loggedOut/update.ts +2 -2
- package/dist/templates/examples/auth/src/scene.test.ts +2 -2
- package/dist/templates/examples/auth/src/update.ts +3 -3
- package/dist/templates/examples/canvas-art/package.json +2 -2
- package/dist/templates/examples/canvas-art/src/main.ts +6 -6
- package/dist/templates/examples/canvas-art/src/scene.test.ts +3 -3
- package/dist/templates/examples/canvas-art/src/story.test.ts +3 -3
- package/dist/templates/examples/charting/package.json +2 -2
- package/dist/templates/examples/charting/src/main.fixture.ts +2 -2
- package/dist/templates/examples/charting/src/scene.test.ts +3 -3
- package/dist/templates/examples/charting/src/story.test.ts +2 -2
- package/dist/templates/examples/charting/src/update.ts +18 -16
- package/dist/templates/examples/counter/package.json +2 -2
- package/dist/templates/examples/counter/src/main.ts +4 -4
- package/dist/templates/examples/counters/package.json +2 -2
- package/dist/templates/examples/counters/src/counter.ts +3 -3
- package/dist/templates/examples/counters/src/main.ts +7 -5
- package/dist/templates/examples/crash-view/package.json +2 -2
- package/dist/templates/examples/embedding/package.json +2 -2
- package/dist/templates/examples/embedding/src/main.ts +5 -3
- package/dist/templates/examples/embedding/src/scene.test.ts +2 -2
- package/dist/templates/examples/embedding/src/story.test.ts +2 -2
- package/dist/templates/examples/form/package.json +2 -2
- package/dist/templates/examples/form/src/main.ts +9 -9
- package/dist/templates/examples/form/src/scene.test.ts +5 -5
- package/dist/templates/examples/form/src/story.test.ts +4 -4
- package/dist/templates/examples/generative-art/package.json +2 -2
- package/dist/templates/examples/generative-art/src/scene.test.ts +2 -2
- package/dist/templates/examples/generative-art/src/story.test.ts +3 -3
- package/dist/templates/examples/generative-art/src/update.ts +11 -11
- package/dist/templates/examples/interrupting-commands/package.json +2 -2
- package/dist/templates/examples/interrupting-commands/src/main.ts +8 -6
- package/dist/templates/examples/job-application/package.json +2 -2
- package/dist/templates/examples/job-application/src/main.fixture.ts +9 -9
- package/dist/templates/examples/job-application/src/scene.test.ts +13 -13
- package/dist/templates/examples/job-application/src/step/attachments/attachments.ts +7 -7
- package/dist/templates/examples/job-application/src/step/coverLetter/coverLetter.ts +2 -2
- package/dist/templates/examples/job-application/src/step/education/education.ts +6 -6
- package/dist/templates/examples/job-application/src/step/education/entry/entry.ts +14 -8
- package/dist/templates/examples/job-application/src/step/personalInfo/personalInfo.ts +20 -15
- package/dist/templates/examples/job-application/src/step/personalInfo/story.test.ts +2 -2
- package/dist/templates/examples/job-application/src/step/skills/entry/entry.ts +7 -5
- package/dist/templates/examples/job-application/src/step/skills/skills.ts +6 -6
- package/dist/templates/examples/job-application/src/step/workHistory/entry/entry.ts +13 -12
- package/dist/templates/examples/job-application/src/step/workHistory/workHistory.ts +6 -6
- package/dist/templates/examples/job-application/src/story.test.ts +10 -10
- package/dist/templates/examples/job-application/src/update.ts +25 -18
- package/dist/templates/examples/kanban/package.json +2 -2
- package/dist/templates/examples/kanban/src/domain/column.ts +9 -6
- package/dist/templates/examples/kanban/src/update.ts +8 -8
- package/dist/templates/examples/managed-resource-layer/package.json +2 -2
- package/dist/templates/examples/managed-resource-layer/src/main.ts +11 -7
- package/dist/templates/examples/managed-resource-layer/src/story.test.ts +3 -3
- package/dist/templates/examples/map/package.json +2 -2
- package/dist/templates/examples/map/src/main.fixture.ts +2 -2
- package/dist/templates/examples/map/src/main.ts +11 -11
- package/dist/templates/examples/map/src/scene.test.ts +4 -4
- package/dist/templates/examples/map/src/story.test.ts +4 -4
- package/dist/templates/examples/pixel-art/package.json +2 -2
- package/dist/templates/examples/pixel-art/src/comparison.bench.test.ts +2 -2
- package/dist/templates/examples/pixel-art/src/main.bench.ts +7 -3
- package/dist/templates/examples/pixel-art/src/scene.test.ts +5 -5
- package/dist/templates/examples/pixel-art/src/story.test.ts +4 -4
- package/dist/templates/examples/pixel-art/src/subscription.ts +2 -2
- package/dist/templates/examples/pixel-art/src/update.ts +49 -33
- package/dist/templates/examples/query-sync/package.json +2 -2
- package/dist/templates/examples/query-sync/src/main.ts +4 -4
- package/dist/templates/examples/query-sync/src/scene.test.ts +4 -4
- package/dist/templates/examples/query-sync/src/story.test.ts +2 -2
- package/dist/templates/examples/route-transitions/package.json +2 -2
- package/dist/templates/examples/route-transitions/src/main.ts +10 -10
- package/dist/templates/examples/route-transitions/src/story.test.ts +10 -6
- package/dist/templates/examples/routing/package.json +2 -2
- package/dist/templates/examples/routing/src/main.ts +13 -17
- package/dist/templates/examples/routing/src/page/people.ts +4 -4
- package/dist/templates/examples/shopping-cart/package.json +2 -2
- package/dist/templates/examples/shopping-cart/src/domain/cart.ts +4 -4
- package/dist/templates/examples/shopping-cart/src/main.ts +12 -12
- package/dist/templates/examples/shopping-cart/src/page/products.ts +2 -2
- package/dist/templates/examples/shopping-cart/src/scene.test.ts +10 -8
- package/dist/templates/examples/shopping-cart/src/story.test.ts +7 -7
- package/dist/templates/examples/slow-warnings/package.json +2 -2
- package/dist/templates/examples/slow-warnings/src/handleSlow.test.ts +2 -2
- package/dist/templates/examples/slow-warnings/src/main.ts +8 -8
- package/dist/templates/examples/slow-warnings/src/scene.test.ts +2 -2
- package/dist/templates/examples/slow-warnings/src/story.test.ts +2 -2
- package/dist/templates/examples/snake/package.json +2 -2
- package/dist/templates/examples/snake/src/main.ts +10 -10
- package/dist/templates/examples/snake/src/scene.test.ts +10 -5
- package/dist/templates/examples/snake/src/story.test.ts +6 -6
- package/dist/templates/examples/ssg/package.json +2 -2
- package/dist/templates/examples/ssg/src/main.ts +3 -3
- package/dist/templates/examples/ssr/package.json +4 -4
- package/dist/templates/examples/ssr/src/main.ts +3 -3
- package/dist/templates/examples/state-machine/package.json +2 -2
- package/dist/templates/examples/state-machine/src/main.ts +14 -10
- package/dist/templates/examples/stopwatch/package.json +2 -2
- package/dist/templates/examples/stopwatch/src/main.ts +5 -5
- package/dist/templates/examples/stopwatch/src/story.test.ts +2 -2
- package/dist/templates/examples/todo/package.json +2 -2
- package/dist/templates/examples/todo/src/main.ts +17 -17
- package/dist/templates/examples/todo/src/scene.test.ts +4 -4
- package/dist/templates/examples/todo/src/story.test.ts +22 -16
- package/dist/templates/examples/ui-showcase/package.json +2 -2
- package/dist/templates/examples/ui-showcase/src/main.ts +8 -5
- package/dist/templates/examples/ui-showcase/src/story.test.ts +3 -3
- package/dist/templates/examples/ui-showcase/src/ui/init.ts +4 -1
- package/dist/templates/examples/ui-showcase/src/ui/subscriptions.ts +10 -0
- package/dist/templates/examples/ui-showcase/src/ui/update.ts +119 -91
- package/dist/templates/examples/ui-showcase/src/ui/view/toast.ts +20 -3
- package/dist/templates/examples/view-transitions/package.json +2 -2
- package/dist/templates/examples/view-transitions/src/main.ts +3 -3
- package/dist/templates/examples/weather/package.json +2 -2
- package/dist/templates/examples/weather/src/main.ts +5 -5
- package/dist/templates/examples/web-components/package.json +2 -2
- package/dist/templates/examples/web-components/src/main.ts +4 -4
- package/dist/templates/examples/websocket-chat/package.json +2 -2
- package/dist/templates/examples/websocket-chat/src/main.ts +8 -8
- package/dist/templates/examples/websocket-chat/src/scene.test.ts +18 -6
- package/dist/templates/examples/websocket-chat/src/story.test.ts +15 -9
- package/dist/templates/release.json +13 -13
- package/dist/templates/rendering/ssg/src/main.ts +3 -3
- package/dist/templates/rendering/ssr/scripts/serve.ts +2 -2
- package/dist/templates/rendering/ssr/src/main.ts +3 -3
- package/package.json +5 -5
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
validate,
|
|
11
11
|
} from 'foldkit/fieldValidation'
|
|
12
12
|
import { defineMessageUnion } from 'foldkit/message'
|
|
13
|
-
import {
|
|
13
|
+
import { modifyFields } from 'foldkit/struct'
|
|
14
14
|
|
|
15
15
|
import { DatePicker } from '@foldkit/ui'
|
|
16
16
|
|
|
@@ -91,13 +91,13 @@ const foldStartDateOutMessage = DatePicker.OutMessage.match<
|
|
|
91
91
|
SelectedDate:
|
|
92
92
|
({ date }) =>
|
|
93
93
|
model => ({
|
|
94
|
-
model:
|
|
94
|
+
model: modifyFields(model, {
|
|
95
95
|
maybeStartDate: () => Option.some(date),
|
|
96
96
|
endDate: DatePicker.reflectMinDate(Option.some(date)),
|
|
97
97
|
}),
|
|
98
98
|
}),
|
|
99
99
|
ClearedDate: () => model => ({
|
|
100
|
-
model:
|
|
100
|
+
model: modifyFields(model, {
|
|
101
101
|
maybeStartDate: () => Option.none(),
|
|
102
102
|
endDate: DatePicker.reflectMinDate(Option.none()),
|
|
103
103
|
}),
|
|
@@ -108,7 +108,7 @@ const foldStartDate = Update.foldChild({
|
|
|
108
108
|
update: DatePicker.update,
|
|
109
109
|
read: (model: Model) => Option.some(model.startDate),
|
|
110
110
|
write: (model, nextStartDate) =>
|
|
111
|
-
|
|
111
|
+
modifyFields(model, { startDate: () => nextStartDate }),
|
|
112
112
|
toParentMessage: message => Message.GotStartDateMessage({ message }),
|
|
113
113
|
foldOutMessage: foldStartDateOutMessage,
|
|
114
114
|
})
|
|
@@ -120,13 +120,13 @@ const foldEndDateOutMessage = DatePicker.OutMessage.match<
|
|
|
120
120
|
SelectedDate:
|
|
121
121
|
({ date }) =>
|
|
122
122
|
model => ({
|
|
123
|
-
model:
|
|
123
|
+
model: modifyFields(model, {
|
|
124
124
|
maybeEndDate: () => Option.some(date),
|
|
125
125
|
startDate: DatePicker.reflectMaxDate(Option.some(date)),
|
|
126
126
|
}),
|
|
127
127
|
}),
|
|
128
128
|
ClearedDate: () => model => ({
|
|
129
|
-
model:
|
|
129
|
+
model: modifyFields(model, {
|
|
130
130
|
maybeEndDate: () => Option.none(),
|
|
131
131
|
startDate: DatePicker.reflectMaxDate(Option.none()),
|
|
132
132
|
}),
|
|
@@ -136,7 +136,8 @@ const foldEndDateOutMessage = DatePicker.OutMessage.match<
|
|
|
136
136
|
const foldEndDate = Update.foldChild({
|
|
137
137
|
update: DatePicker.update,
|
|
138
138
|
read: (model: Model) => Option.some(model.endDate),
|
|
139
|
-
write: (model, nextEndDate) =>
|
|
139
|
+
write: (model, nextEndDate) =>
|
|
140
|
+
modifyFields(model, { endDate: () => nextEndDate }),
|
|
140
141
|
toParentMessage: message => Message.GotEndDateMessage({ message }),
|
|
141
142
|
foldOutMessage: foldEndDateOutMessage,
|
|
142
143
|
})
|
|
@@ -146,11 +147,11 @@ export const update = (model: Model, message: Message) =>
|
|
|
146
147
|
message,
|
|
147
148
|
{
|
|
148
149
|
UpdatedCompany: ({ value }) => ({
|
|
149
|
-
model:
|
|
150
|
+
model: modifyFields(model, { company: () => validateCompany(value) }),
|
|
150
151
|
}),
|
|
151
152
|
|
|
152
153
|
UpdatedTitle: ({ value }) => ({
|
|
153
|
-
model:
|
|
154
|
+
model: modifyFields(model, { title: () => validateTitle(value) }),
|
|
154
155
|
}),
|
|
155
156
|
|
|
156
157
|
GotStartDateMessage: ({ message }) => foldStartDate(model, message),
|
|
@@ -158,11 +159,11 @@ export const update = (model: Model, message: Message) =>
|
|
|
158
159
|
GotEndDateMessage: ({ message }) => foldEndDate(model, message),
|
|
159
160
|
|
|
160
161
|
ToggledCurrentlyEmployed: ({ isChecked }) => ({
|
|
161
|
-
model:
|
|
162
|
+
model: modifyFields(model, { isCurrentlyEmployed: () => isChecked }),
|
|
162
163
|
}),
|
|
163
164
|
|
|
164
165
|
UpdatedDescription: ({ value }) => ({
|
|
165
|
-
model:
|
|
166
|
+
model: modifyFields(model, { description: () => value }),
|
|
166
167
|
}),
|
|
167
168
|
|
|
168
169
|
ClickedRemoveSelf: () => ({ model, outMessage: OutMessage.Removed() }),
|
|
@@ -181,7 +182,7 @@ export const isComplete = (entry: Model): boolean =>
|
|
|
181
182
|
])
|
|
182
183
|
|
|
183
184
|
export const revealErrors = (entry: Model): Model =>
|
|
184
|
-
|
|
185
|
+
modifyFields(entry, {
|
|
185
186
|
company: revealFieldErrors(companyRules),
|
|
186
187
|
title: revealFieldErrors(titleRules),
|
|
187
188
|
})
|
|
@@ -2,7 +2,7 @@ import { Array, Crypto, Effect, Schema } from 'effect'
|
|
|
2
2
|
import { Calendar, Command, Update } from 'foldkit'
|
|
3
3
|
import { type CalendarDate } from 'foldkit/calendar'
|
|
4
4
|
import { defineMessageUnion } from 'foldkit/message'
|
|
5
|
-
import {
|
|
5
|
+
import { modifyFields } from 'foldkit/struct'
|
|
6
6
|
|
|
7
7
|
import { BrowserCrypto } from '@effect/platform-browser'
|
|
8
8
|
|
|
@@ -59,7 +59,7 @@ const foldEntryOutMessage: (
|
|
|
59
59
|
) => (outMessage: Entry.OutMessage) => Update.Step<Model, Message> = entryId =>
|
|
60
60
|
Entry.OutMessage.match<Update.Step<Model, Message>>({
|
|
61
61
|
Removed: () => model => ({
|
|
62
|
-
model:
|
|
62
|
+
model: modifyFields(model, {
|
|
63
63
|
entries: Array.filter(entry => entry.id !== entryId),
|
|
64
64
|
}),
|
|
65
65
|
}),
|
|
@@ -71,7 +71,7 @@ const foldEntry = (entryId: string) =>
|
|
|
71
71
|
read: (model: Model) =>
|
|
72
72
|
Array.findFirst(model.entries, entry => entry.id === entryId),
|
|
73
73
|
write: (model, nextEntry) =>
|
|
74
|
-
|
|
74
|
+
modifyFields(model, {
|
|
75
75
|
entries: Array.map(entry => (entry.id === entryId ? nextEntry : entry)),
|
|
76
76
|
}),
|
|
77
77
|
toParentMessage: message => Message.GotEntryMessage({ entryId, message }),
|
|
@@ -83,7 +83,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
83
83
|
ClickedAddEntry: () => ({ model, commands: [GenerateEntryId()] }),
|
|
84
84
|
|
|
85
85
|
SucceededGenerateEntryId: ({ entryId }) => ({
|
|
86
|
-
model:
|
|
86
|
+
model: modifyFields(model, {
|
|
87
87
|
entries: Array.append(Entry.init(entryId, model.today)),
|
|
88
88
|
}),
|
|
89
89
|
}),
|
|
@@ -91,7 +91,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
91
91
|
FailedGenerateEntryId: () => ({ model }),
|
|
92
92
|
|
|
93
93
|
RemovedEntry: ({ entryId }) => ({
|
|
94
|
-
model:
|
|
94
|
+
model: modifyFields(model, {
|
|
95
95
|
entries: Array.filter(entry => entry.id !== entryId),
|
|
96
96
|
}),
|
|
97
97
|
}),
|
|
@@ -110,4 +110,4 @@ export const isComplete = (model: Model): boolean =>
|
|
|
110
110
|
Array.every(model.entries, Entry.isComplete)
|
|
111
111
|
|
|
112
112
|
export const revealErrors = (model: Model): Model =>
|
|
113
|
-
|
|
113
|
+
modifyFields(model, { entries: Array.map(Entry.revealErrors) })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Array, Option, pipe } from 'effect'
|
|
2
2
|
import { Validating } from 'foldkit/fieldValidation'
|
|
3
3
|
import { Command, given, message, model, story } from 'foldkit/story'
|
|
4
|
-
import {
|
|
4
|
+
import { modifyFields } from 'foldkit/struct'
|
|
5
5
|
import { describe, expect, test } from 'vitest'
|
|
6
6
|
|
|
7
7
|
import { FileDrop, Menu, Tabs } from '@foldkit/ui'
|
|
@@ -49,7 +49,7 @@ describe('update', () => {
|
|
|
49
49
|
test('ClickedPrevious goes back to the previous step', () => {
|
|
50
50
|
story(
|
|
51
51
|
update,
|
|
52
|
-
given(
|
|
52
|
+
given(modifyFields(initialModel, { currentStep: () => 'Education' })),
|
|
53
53
|
message(Message.ClickedPrevious()),
|
|
54
54
|
model(model => {
|
|
55
55
|
expect(model.currentStep).toBe('WorkHistory')
|
|
@@ -71,7 +71,7 @@ describe('update', () => {
|
|
|
71
71
|
test('ClickedNext on the last step stays put', () => {
|
|
72
72
|
story(
|
|
73
73
|
update,
|
|
74
|
-
given(
|
|
74
|
+
given(modifyFields(initialModel, { currentStep: () => 'Review' })),
|
|
75
75
|
message(Message.ClickedNext()),
|
|
76
76
|
model(model => {
|
|
77
77
|
expect(model.currentStep).toBe('Review')
|
|
@@ -250,7 +250,7 @@ describe('update', () => {
|
|
|
250
250
|
test('ClickedSubmit on a complete application transitions to Submitting and fires command', () => {
|
|
251
251
|
story(
|
|
252
252
|
update,
|
|
253
|
-
given(
|
|
253
|
+
given(modifyFields(completeModel, { currentStep: () => 'Review' })),
|
|
254
254
|
message(Message.ClickedSubmit()),
|
|
255
255
|
Command.expectExact(SubmitApplication),
|
|
256
256
|
Command.resolve(
|
|
@@ -267,7 +267,7 @@ describe('update', () => {
|
|
|
267
267
|
test('ClickedSubmit on an incomplete application reveals errors and does not submit', () => {
|
|
268
268
|
story(
|
|
269
269
|
update,
|
|
270
|
-
given(
|
|
270
|
+
given(modifyFields(initialModel, { currentStep: () => 'Review' })),
|
|
271
271
|
message(Message.ClickedSubmit()),
|
|
272
272
|
Command.expectNone(),
|
|
273
273
|
model(model => {
|
|
@@ -308,9 +308,9 @@ describe('update', () => {
|
|
|
308
308
|
story(
|
|
309
309
|
update,
|
|
310
310
|
given(
|
|
311
|
-
|
|
311
|
+
modifyFields(completeModel, {
|
|
312
312
|
currentStep: () => 'Review',
|
|
313
|
-
personalInfo:
|
|
313
|
+
personalInfo: modifyFields({
|
|
314
314
|
email: () => Validating({ value: 'jane@example.com' }),
|
|
315
315
|
}),
|
|
316
316
|
}),
|
|
@@ -328,7 +328,7 @@ describe('update', () => {
|
|
|
328
328
|
test('ClickedSubmit preserves Valid fields rather than re-running validation', () => {
|
|
329
329
|
story(
|
|
330
330
|
update,
|
|
331
|
-
given(
|
|
331
|
+
given(modifyFields(completeModel, { currentStep: () => 'Review' })),
|
|
332
332
|
message(Message.ClickedSubmit()),
|
|
333
333
|
Command.resolve(
|
|
334
334
|
SubmitApplication,
|
|
@@ -345,7 +345,7 @@ describe('update', () => {
|
|
|
345
345
|
story(
|
|
346
346
|
update,
|
|
347
347
|
given(
|
|
348
|
-
|
|
348
|
+
modifyFields(initialModel, {
|
|
349
349
|
currentStep: () => 'Review',
|
|
350
350
|
submission: () => Submission.Submitting(),
|
|
351
351
|
}),
|
|
@@ -361,7 +361,7 @@ describe('update', () => {
|
|
|
361
361
|
story(
|
|
362
362
|
update,
|
|
363
363
|
given(
|
|
364
|
-
|
|
364
|
+
modifyFields(initialModel, {
|
|
365
365
|
currentStep: () => 'Review',
|
|
366
366
|
submission: () => Submission.Submitting(),
|
|
367
367
|
}),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Array, Option, pipe } from 'effect'
|
|
2
2
|
import { Update } from 'foldkit'
|
|
3
|
-
import {
|
|
3
|
+
import { modifyFields } from 'foldkit/struct'
|
|
4
4
|
|
|
5
5
|
import { Menu, Tabs } from '@foldkit/ui'
|
|
6
6
|
|
|
@@ -44,7 +44,7 @@ const foldPersonalInfo = Update.foldChild({
|
|
|
44
44
|
update: PersonalInfo.update,
|
|
45
45
|
read: (model: Model) => Option.some(model.personalInfo),
|
|
46
46
|
write: (model, nextPersonalInfo) =>
|
|
47
|
-
|
|
47
|
+
modifyFields(model, { personalInfo: () => nextPersonalInfo }),
|
|
48
48
|
toParentMessage: message => Message.GotPersonalInfoMessage({ message }),
|
|
49
49
|
})
|
|
50
50
|
|
|
@@ -52,7 +52,7 @@ const foldWorkHistory = Update.foldChild({
|
|
|
52
52
|
update: WorkHistory.update,
|
|
53
53
|
read: (model: Model) => Option.some(model.workHistory),
|
|
54
54
|
write: (model, nextWorkHistory) =>
|
|
55
|
-
|
|
55
|
+
modifyFields(model, { workHistory: () => nextWorkHistory }),
|
|
56
56
|
toParentMessage: message => Message.GotWorkHistoryMessage({ message }),
|
|
57
57
|
})
|
|
58
58
|
|
|
@@ -60,14 +60,15 @@ const foldEducation = Update.foldChild({
|
|
|
60
60
|
update: Education.update,
|
|
61
61
|
read: (model: Model) => Option.some(model.education),
|
|
62
62
|
write: (model, nextEducation) =>
|
|
63
|
-
|
|
63
|
+
modifyFields(model, { education: () => nextEducation }),
|
|
64
64
|
toParentMessage: message => Message.GotEducationMessage({ message }),
|
|
65
65
|
})
|
|
66
66
|
|
|
67
67
|
const foldSkills = Update.foldChild({
|
|
68
68
|
update: Skills.update,
|
|
69
69
|
read: (model: Model) => Option.some(model.skills),
|
|
70
|
-
write: (model, nextSkills) =>
|
|
70
|
+
write: (model, nextSkills) =>
|
|
71
|
+
modifyFields(model, { skills: () => nextSkills }),
|
|
71
72
|
toParentMessage: message => Message.GotSkillsMessage({ message }),
|
|
72
73
|
})
|
|
73
74
|
|
|
@@ -75,7 +76,7 @@ const foldCoverLetter = Update.foldChild({
|
|
|
75
76
|
update: CoverLetter.update,
|
|
76
77
|
read: (model: Model) => Option.some(model.coverLetter),
|
|
77
78
|
write: (model, nextCoverLetter) =>
|
|
78
|
-
|
|
79
|
+
modifyFields(model, { coverLetter: () => nextCoverLetter }),
|
|
79
80
|
toParentMessage: message => Message.GotCoverLetterMessage({ message }),
|
|
80
81
|
})
|
|
81
82
|
|
|
@@ -83,7 +84,7 @@ const foldAttachments = Update.foldChild({
|
|
|
83
84
|
update: Attachments.update,
|
|
84
85
|
read: (model: Model) => Option.some(model.attachments),
|
|
85
86
|
write: (model, nextAttachments) =>
|
|
86
|
-
|
|
87
|
+
modifyFields(model, { attachments: () => nextAttachments }),
|
|
87
88
|
toParentMessage: message => Message.GotAttachmentsMessage({ message }),
|
|
88
89
|
})
|
|
89
90
|
|
|
@@ -93,13 +94,14 @@ const foldStepMenuOutMessage = Menu.OutMessage.match<
|
|
|
93
94
|
>({
|
|
94
95
|
Selected:
|
|
95
96
|
({ value }) =>
|
|
96
|
-
model => ({ model:
|
|
97
|
+
model => ({ model: modifyFields(model, { currentStep: () => value }) }),
|
|
97
98
|
})
|
|
98
99
|
|
|
99
100
|
const foldStepMenu = Update.foldChild({
|
|
100
101
|
update: StepMenu.update,
|
|
101
102
|
read: (model: Model) => Option.some(model.stepMenu),
|
|
102
|
-
write: (model, nextStepMenu) =>
|
|
103
|
+
write: (model, nextStepMenu) =>
|
|
104
|
+
modifyFields(model, { stepMenu: () => nextStepMenu }),
|
|
103
105
|
toParentMessage: message => Message.GotStepMenuMessage({ message }),
|
|
104
106
|
foldOutMessage: foldStepMenuOutMessage,
|
|
105
107
|
})
|
|
@@ -110,13 +112,14 @@ const foldStepTabsOutMessage = Tabs.OutMessage.match<
|
|
|
110
112
|
>({
|
|
111
113
|
Selected:
|
|
112
114
|
({ value }) =>
|
|
113
|
-
model => ({ model:
|
|
115
|
+
model => ({ model: modifyFields(model, { currentStep: () => value }) }),
|
|
114
116
|
})
|
|
115
117
|
|
|
116
118
|
const foldStepTabs = Update.foldChild({
|
|
117
119
|
update: StepTabs.update,
|
|
118
120
|
read: (model: Model) => Option.some(model.stepTabs),
|
|
119
|
-
write: (model, nextStepTabs) =>
|
|
121
|
+
write: (model, nextStepTabs) =>
|
|
122
|
+
modifyFields(model, { stepTabs: () => nextStepTabs }),
|
|
120
123
|
toParentMessage: message => Message.GotStepTabsMessage({ message }),
|
|
121
124
|
foldOutMessage: foldStepTabsOutMessage,
|
|
122
125
|
})
|
|
@@ -139,18 +142,20 @@ export const update = (model: Model, message: Message) =>
|
|
|
139
142
|
|
|
140
143
|
GotStepTabsMessage: ({ message }) => foldStepTabs(model, message),
|
|
141
144
|
|
|
142
|
-
ClickedNext: () => ({
|
|
145
|
+
ClickedNext: () => ({
|
|
146
|
+
model: modifyFields(model, { currentStep: toNextStep }),
|
|
147
|
+
}),
|
|
143
148
|
|
|
144
149
|
ClickedPrevious: () => ({
|
|
145
|
-
model:
|
|
150
|
+
model: modifyFields(model, { currentStep: toPreviousStep }),
|
|
146
151
|
}),
|
|
147
152
|
|
|
148
153
|
ToggledPreview: () => ({
|
|
149
|
-
model:
|
|
154
|
+
model: modifyFields(model, { isPreviewVisible: isVisible => !isVisible }),
|
|
150
155
|
}),
|
|
151
156
|
|
|
152
157
|
ClickedSubmit: () => {
|
|
153
|
-
const revealedModel =
|
|
158
|
+
const revealedModel = modifyFields(model, {
|
|
154
159
|
personalInfo: PersonalInfo.revealErrors,
|
|
155
160
|
workHistory: WorkHistory.revealErrors,
|
|
156
161
|
education: Education.revealErrors,
|
|
@@ -159,7 +164,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
159
164
|
})
|
|
160
165
|
if (isApplicationComplete(revealedModel)) {
|
|
161
166
|
return {
|
|
162
|
-
model:
|
|
167
|
+
model: modifyFields(revealedModel, {
|
|
163
168
|
submission: () => Submission.Submitting(),
|
|
164
169
|
}),
|
|
165
170
|
commands: [SubmitApplication()],
|
|
@@ -169,11 +174,13 @@ export const update = (model: Model, message: Message) =>
|
|
|
169
174
|
},
|
|
170
175
|
|
|
171
176
|
SucceededSubmitApplication: () => ({
|
|
172
|
-
model:
|
|
177
|
+
model: modifyFields(model, {
|
|
178
|
+
submission: () => Submission.SubmitSuccess(),
|
|
179
|
+
}),
|
|
173
180
|
}),
|
|
174
181
|
|
|
175
182
|
FailedSubmitApplication: ({ error }) => ({
|
|
176
|
-
model:
|
|
183
|
+
model: modifyFields(model, {
|
|
177
184
|
submission: () => Submission.SubmitError({ error }),
|
|
178
185
|
}),
|
|
179
186
|
}),
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.0.0-rc.
|
|
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.
|
|
15
|
+
"effect": "4.0.0-rc.116",
|
|
16
16
|
"foldkit": "workspace:*",
|
|
17
17
|
"fractional-indexing": "^4.0.0"
|
|
18
18
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Array, Match, Option, Schema, pipe } from 'effect'
|
|
2
|
-
import {
|
|
2
|
+
import { modifyFields } from 'foldkit/struct'
|
|
3
3
|
import { generateKeyBetween } from 'fractional-indexing'
|
|
4
4
|
|
|
5
5
|
import type { Card } from './card'
|
|
@@ -37,7 +37,7 @@ export const removeCard = (
|
|
|
37
37
|
): { readonly column: Column; readonly maybeCard: Option.Option<Card> } => {
|
|
38
38
|
const maybeCard = Array.findFirst(column.cards, ({ id }) => id === cardId)
|
|
39
39
|
return {
|
|
40
|
-
column:
|
|
40
|
+
column: modifyFields(column, {
|
|
41
41
|
cards: () => Array.filter(column.cards, ({ id }) => id !== cardId),
|
|
42
42
|
}),
|
|
43
43
|
maybeCard,
|
|
@@ -50,8 +50,8 @@ export const insertCard = (
|
|
|
50
50
|
targetIndex: number,
|
|
51
51
|
): Column => {
|
|
52
52
|
const sortKey = generateSortKeyAtIndex(column.cards, targetIndex)
|
|
53
|
-
const updatedCard =
|
|
54
|
-
return
|
|
53
|
+
const updatedCard = modifyFields(card, { sortKey: () => sortKey })
|
|
54
|
+
return modifyFields(column, {
|
|
55
55
|
cards: () =>
|
|
56
56
|
pipe(
|
|
57
57
|
column.cards,
|
|
@@ -63,8 +63,11 @@ export const insertCard = (
|
|
|
63
63
|
|
|
64
64
|
export const appendCard = (column: Column, card: Card): Column => {
|
|
65
65
|
const sortKey = generateSortKeyAtIndex(column.cards, column.cards.length)
|
|
66
|
-
return
|
|
67
|
-
cards: () => [
|
|
66
|
+
return modifyFields(column, {
|
|
67
|
+
cards: () => [
|
|
68
|
+
...column.cards,
|
|
69
|
+
modifyFields(card, { sortKey: () => sortKey }),
|
|
70
|
+
],
|
|
68
71
|
})
|
|
69
72
|
}
|
|
70
73
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Array, Match, Option, String, pipe } from 'effect'
|
|
2
2
|
import { Update } from 'foldkit'
|
|
3
|
-
import {
|
|
3
|
+
import { modifyFields } from 'foldkit/struct'
|
|
4
4
|
|
|
5
5
|
import { DragAndDrop } from '@foldkit/ui'
|
|
6
6
|
|
|
@@ -107,7 +107,7 @@ const foldDragAndDropOutMessage: (
|
|
|
107
107
|
toIndex,
|
|
108
108
|
)
|
|
109
109
|
return {
|
|
110
|
-
model:
|
|
110
|
+
model: modifyFields(model, {
|
|
111
111
|
columns: () => nextColumns,
|
|
112
112
|
announcement: () =>
|
|
113
113
|
screenReaderTextForDrop(previousModel, outMessage),
|
|
@@ -116,7 +116,7 @@ const foldDragAndDropOutMessage: (
|
|
|
116
116
|
}
|
|
117
117
|
},
|
|
118
118
|
Cancelled: () => ({
|
|
119
|
-
model:
|
|
119
|
+
model: modifyFields(model, {
|
|
120
120
|
announcement: () =>
|
|
121
121
|
screenReaderTextForDrop(previousModel, outMessage),
|
|
122
122
|
}),
|
|
@@ -128,7 +128,7 @@ const foldDragAndDrop = (previousModel: Model) =>
|
|
|
128
128
|
update: DragAndDrop.update,
|
|
129
129
|
read: (model: Model) => Option.some(model.dragAndDrop),
|
|
130
130
|
write: (model, nextDragAndDrop) =>
|
|
131
|
-
|
|
131
|
+
modifyFields(model, {
|
|
132
132
|
dragAndDrop: () => nextDragAndDrop,
|
|
133
133
|
announcement: () => announceKeyboardDrag(model, nextDragAndDrop),
|
|
134
134
|
}),
|
|
@@ -142,7 +142,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
142
142
|
foldDragAndDrop(model)(model, message),
|
|
143
143
|
|
|
144
144
|
ClickedAddCard: ({ columnId }) => ({
|
|
145
|
-
model:
|
|
145
|
+
model: modifyFields(model, {
|
|
146
146
|
maybeNewCardColumnId: () => Option.some(columnId),
|
|
147
147
|
newCardTitle: () => '',
|
|
148
148
|
}),
|
|
@@ -150,7 +150,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
150
150
|
}),
|
|
151
151
|
|
|
152
152
|
ChangedNewCardTitle: ({ value }) => ({
|
|
153
|
-
model:
|
|
153
|
+
model: modifyFields(model, { newCardTitle: () => value }),
|
|
154
154
|
}),
|
|
155
155
|
|
|
156
156
|
SubmittedNewCard: () =>
|
|
@@ -183,7 +183,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
183
183
|
})
|
|
184
184
|
|
|
185
185
|
return {
|
|
186
|
-
model:
|
|
186
|
+
model: modifyFields(model, {
|
|
187
187
|
columns: () => nextColumns,
|
|
188
188
|
maybeNewCardColumnId: () => Option.none(),
|
|
189
189
|
newCardTitle: () => '',
|
|
@@ -193,7 +193,7 @@ export const update = (model: Model, message: Message) =>
|
|
|
193
193
|
},
|
|
194
194
|
|
|
195
195
|
CancelledNewCard: () => ({
|
|
196
|
-
model:
|
|
196
|
+
model: modifyFields(model, {
|
|
197
197
|
maybeNewCardColumnId: () => Option.none(),
|
|
198
198
|
newCardTitle: () => '',
|
|
199
199
|
}),
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.0.0-rc.
|
|
12
|
+
"@effect/platform-browser": "4.0.0-rc.116",
|
|
13
13
|
"@foldkit/ui": "workspace:*",
|
|
14
|
-
"effect": "4.0.0-rc.
|
|
14
|
+
"effect": "4.0.0-rc.116",
|
|
15
15
|
"foldkit": "workspace:*"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
@@ -12,7 +12,7 @@ import { Command, ManagedResource, Runtime, type Update } from 'foldkit'
|
|
|
12
12
|
import { Document, Html, HtmlBuilder } from 'foldkit/html'
|
|
13
13
|
import { defineMessageUnion } from 'foldkit/message'
|
|
14
14
|
import { defineTaggedUnion } from 'foldkit/schema'
|
|
15
|
-
import {
|
|
15
|
+
import { modifyFields } from 'foldkit/struct'
|
|
16
16
|
|
|
17
17
|
import { BrowserCrypto } from '@effect/platform-browser'
|
|
18
18
|
import { Button } from '@foldkit/ui'
|
|
@@ -98,15 +98,15 @@ export const Compute = Command.define('Compute', {
|
|
|
98
98
|
export const update = (model: Model, message: Message) =>
|
|
99
99
|
Message.match<Update.Return<Model, Message, EngineService>>(message, {
|
|
100
100
|
ClickedStartEngine: () => ({
|
|
101
|
-
model:
|
|
101
|
+
model: modifyFields(model, { engine: () => EngineState.Booting() }),
|
|
102
102
|
}),
|
|
103
103
|
|
|
104
104
|
ClickedStopEngine: () => ({
|
|
105
|
-
model:
|
|
105
|
+
model: modifyFields(model, { engine: () => EngineState.Off() }),
|
|
106
106
|
}),
|
|
107
107
|
|
|
108
108
|
StartedEngine: ({ engineId }) => ({
|
|
109
|
-
model:
|
|
109
|
+
model: modifyFields(model, {
|
|
110
110
|
engine: () => EngineState.Ready({ engineId }),
|
|
111
111
|
}),
|
|
112
112
|
}),
|
|
@@ -114,19 +114,23 @@ export const update = (model: Model, message: Message) =>
|
|
|
114
114
|
StoppedEngine: () => ({ model }),
|
|
115
115
|
|
|
116
116
|
FailedStartEngine: ({ reason }) => ({
|
|
117
|
-
model:
|
|
117
|
+
model: modifyFields(model, {
|
|
118
|
+
engine: () => EngineState.Failed({ reason }),
|
|
119
|
+
}),
|
|
118
120
|
}),
|
|
119
121
|
|
|
120
122
|
ClickedCompute: () => {
|
|
121
123
|
const nextComputeCount = Number.increment(model.computeCount)
|
|
122
124
|
return {
|
|
123
|
-
model:
|
|
125
|
+
model: modifyFields(model, { computeCount: () => nextComputeCount }),
|
|
124
126
|
commands: [Compute({ value: nextComputeCount })],
|
|
125
127
|
}
|
|
126
128
|
},
|
|
127
129
|
|
|
128
130
|
CompletedCompute: ({ result }) => ({
|
|
129
|
-
model:
|
|
131
|
+
model: modifyFields(model, {
|
|
132
|
+
maybeSquareResult: () => Option.some(result),
|
|
133
|
+
}),
|
|
130
134
|
}),
|
|
131
135
|
|
|
132
136
|
SkippedCompute: () => ({ model }),
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Option } from 'effect'
|
|
2
2
|
import { Command, given, message, model, story } from 'foldkit/story'
|
|
3
|
-
import {
|
|
3
|
+
import { modifyFields } from 'foldkit/struct'
|
|
4
4
|
import { describe, expect, test } from 'vitest'
|
|
5
5
|
|
|
6
6
|
import { Compute, EngineState, Message, type Model, update } from './main'
|
|
@@ -33,7 +33,7 @@ describe('update', () => {
|
|
|
33
33
|
test('StartedEngine marks the engine ready with its id', () => {
|
|
34
34
|
story(
|
|
35
35
|
update,
|
|
36
|
-
given(
|
|
36
|
+
given(modifyFields(offModel, { engine: () => EngineState.Booting() })),
|
|
37
37
|
message(Message.StartedEngine({ engineId: 'engine-7' })),
|
|
38
38
|
model(model => {
|
|
39
39
|
expect(model.engine).toStrictEqual(
|
|
@@ -68,7 +68,7 @@ describe('update', () => {
|
|
|
68
68
|
test('FailedStartEngine records the failure reason', () => {
|
|
69
69
|
story(
|
|
70
70
|
update,
|
|
71
|
-
given(
|
|
71
|
+
given(modifyFields(offModel, { engine: () => EngineState.Booting() })),
|
|
72
72
|
message(Message.FailedStartEngine({ reason: 'boot timeout' })),
|
|
73
73
|
model(model => {
|
|
74
74
|
expect(model.engine).toStrictEqual(
|
|
@@ -9,10 +9,10 @@
|
|
|
9
9
|
"test": "vitest run"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@effect/platform-browser": "4.0.0-rc.
|
|
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.
|
|
15
|
+
"effect": "4.0.0-rc.116",
|
|
16
16
|
"foldkit": "workspace:*",
|
|
17
17
|
"maplibre-gl": "^6.6.0"
|
|
18
18
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Option } from 'effect'
|
|
2
|
-
import {
|
|
2
|
+
import { modifyFields } from 'foldkit/struct'
|
|
3
3
|
|
|
4
4
|
import { Location, featuredLocations } from './locations'
|
|
5
5
|
import { GeolocateState, type Model } from './main'
|
|
@@ -15,7 +15,7 @@ export const initialModel: Model = {
|
|
|
15
15
|
geolocateState: GeolocateState.Idle(),
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export const mountedModel: Model =
|
|
18
|
+
export const mountedModel: Model = modifyFields(initialModel, {
|
|
19
19
|
maybeMapHostId: () => Option.some('map-host-1'),
|
|
20
20
|
})
|
|
21
21
|
|