create-foldkit-app 0.31.1 → 0.32.0
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 +1 -1
- package/dist/templates/examples/api-cache/package.json +7 -7
- package/dist/templates/examples/auth/package.json +7 -7
- package/dist/templates/examples/auth/src/page/loggedOut/page/login.ts +28 -35
- package/dist/templates/examples/auth/src/update.ts +10 -13
- package/dist/templates/examples/canvas-art/package.json +7 -7
- package/dist/templates/examples/charting/package.json +7 -7
- package/dist/templates/examples/charting/src/view/chart.ts +43 -45
- package/dist/templates/examples/counter/package.json +7 -7
- package/dist/templates/examples/counters/package.json +7 -7
- package/dist/templates/examples/crash-view/package.json +7 -7
- package/dist/templates/examples/embedding/package.json +7 -7
- package/dist/templates/examples/form/package.json +7 -7
- package/dist/templates/examples/form/src/main.ts +59 -74
- package/dist/templates/examples/generative-art/package.json +7 -7
- package/dist/templates/examples/interrupting-commands/package.json +7 -7
- package/dist/templates/examples/interrupting-commands/src/main.ts +6 -9
- package/dist/templates/examples/job-application/package.json +7 -7
- package/dist/templates/examples/job-application/src/view/education.ts +31 -32
- package/dist/templates/examples/job-application/src/view/field.ts +7 -8
- package/dist/templates/examples/job-application/src/view/workHistory.ts +40 -41
- package/dist/templates/examples/kanban/package.json +8 -8
- package/dist/templates/examples/managed-resource-layer/package.json +7 -7
- package/dist/templates/examples/managed-resource-layer/src/main.ts +10 -11
- package/dist/templates/examples/map/package.json +8 -8
- package/dist/templates/examples/map/src/main.ts +59 -63
- package/dist/templates/examples/map/src/vite-env.d.ts +1 -0
- package/dist/templates/examples/pixel-art/package.json +7 -7
- package/dist/templates/examples/pixel-art/src/scene.test.ts +3 -3
- package/dist/templates/examples/pixel-art/src/story.test.ts +3 -3
- package/dist/templates/examples/query-sync/package.json +7 -7
- package/dist/templates/examples/query-sync/src/main.ts +25 -37
- package/dist/templates/examples/route-transitions/package.json +7 -7
- package/dist/templates/examples/route-transitions/src/main.ts +24 -32
- package/dist/templates/examples/routing/package.json +7 -7
- package/dist/templates/examples/routing/src/main.ts +24 -30
- package/dist/templates/examples/routing/src/page/people.ts +80 -86
- package/dist/templates/examples/shopping-cart/package.json +7 -7
- package/dist/templates/examples/shopping-cart/src/main.ts +16 -22
- package/dist/templates/examples/slow-warnings/package.json +7 -7
- package/dist/templates/examples/snake/package.json +7 -7
- package/dist/templates/examples/ssg/package.json +6 -8
- package/dist/templates/examples/ssg/src/main.ts +65 -75
- package/dist/templates/examples/ssr/package.json +8 -9
- package/dist/templates/examples/state-machine/package.json +7 -7
- package/dist/templates/examples/state-machine/src/view.ts +50 -59
- package/dist/templates/examples/stopwatch/package.json +7 -7
- package/dist/templates/examples/todo/package.json +7 -7
- package/dist/templates/examples/todo/src/main.ts +29 -37
- package/dist/templates/examples/ui-showcase/package.json +7 -7
- package/dist/templates/examples/ui-showcase/src/main.ts +49 -42
- package/dist/templates/examples/ui-showcase/src/scene.test.ts +11 -0
- package/dist/templates/examples/ui-showcase/src/ui/init.ts +2 -0
- package/dist/templates/examples/ui-showcase/src/ui/message.ts +2 -0
- package/dist/templates/examples/ui-showcase/src/ui/model.ts +2 -0
- package/dist/templates/examples/ui-showcase/src/ui/update.ts +21 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/hoverIntent.ts +89 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/index.ts +1 -0
- package/dist/templates/examples/view-transitions/package.json +7 -7
- package/dist/templates/examples/view-transitions/src/main.ts +29 -40
- package/dist/templates/examples/weather/package.json +7 -7
- package/dist/templates/examples/web-components/package.json +7 -7
- package/dist/templates/examples/websocket-chat/package.json +7 -7
- package/dist/templates/examples/websocket-chat/src/main.ts +22 -32
- package/dist/templates/release.json +18 -18
- package/dist/templates/rendering/ssg/README.md +8 -7
- package/dist/templates/rendering/ssg/package.json +2 -2
- package/dist/templates/rendering/ssg/src/main.ts +61 -70
- package/dist/templates/rendering/ssg/tsconfig.json +1 -1
- package/dist/templates/rendering/ssg/vite.config.ts +22 -1
- package/dist/templates/rendering/ssr/README.md +10 -7
- package/dist/templates/rendering/ssr/package.json +2 -2
- package/dist/templates/rendering/ssr/vite.config.ts +22 -1
- package/package.json +5 -5
- package/dist/templates/rendering/ssg/scripts/build.mjs +0 -27
- package/dist/templates/rendering/ssg/scripts/prerender.ts +0 -120
- package/dist/templates/rendering/ssr/scripts/build.mjs +0 -23
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect,
|
|
1
|
+
import { Effect, Schema as S } from 'effect'
|
|
2
2
|
import { Command, Runtime, type Update } from 'foldkit'
|
|
3
3
|
import { type Document, type Html, type HtmlBuilder } from 'foldkit/html'
|
|
4
4
|
import { defineMessageUnion } from 'foldkit/message'
|
|
@@ -53,7 +53,6 @@ const LoadExternal = Command.define('LoadExternal', {
|
|
|
53
53
|
// UPDATE
|
|
54
54
|
|
|
55
55
|
type UpdateReturn = Update.Return<Model, Message>
|
|
56
|
-
const withUpdateReturn = M.withReturnType<UpdateReturn>()
|
|
57
56
|
|
|
58
57
|
export const update = (model: Model, message: Message) =>
|
|
59
58
|
Message.match<UpdateReturn>(message, {
|
|
@@ -61,19 +60,16 @@ export const update = (model: Model, message: Message) =>
|
|
|
61
60
|
model: evo(model, { count: count => count + 1 }),
|
|
62
61
|
}),
|
|
63
62
|
ClickedLink: ({ request }) =>
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
model,
|
|
69
|
-
commands: [NavigateInternal({ url: urlToString(url) })],
|
|
70
|
-
}),
|
|
71
|
-
External: ({ href }) => ({
|
|
72
|
-
model,
|
|
73
|
-
commands: [LoadExternal({ href })],
|
|
74
|
-
}),
|
|
63
|
+
UrlRequest.match<UpdateReturn>(request, {
|
|
64
|
+
Internal: ({ url }) => ({
|
|
65
|
+
model,
|
|
66
|
+
commands: [NavigateInternal({ url: urlToString(url) })],
|
|
75
67
|
}),
|
|
76
|
-
|
|
68
|
+
External: ({ href }) => ({
|
|
69
|
+
model,
|
|
70
|
+
commands: [LoadExternal({ href })],
|
|
71
|
+
}),
|
|
72
|
+
}),
|
|
77
73
|
ChangedUrl: ({ url }) => ({
|
|
78
74
|
model: evo(model, { route: () => urlToAppRoute(url) }),
|
|
79
75
|
}),
|
|
@@ -84,13 +80,11 @@ export const update = (model: Model, message: Message) =>
|
|
|
84
80
|
// VIEW
|
|
85
81
|
|
|
86
82
|
const routeTitle = (route: AppRoute): string =>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}),
|
|
93
|
-
)
|
|
83
|
+
AppRoute.match(route, {
|
|
84
|
+
Home: () => 'Home | Static Generation | Foldkit',
|
|
85
|
+
About: () => 'About | Static Generation | Foldkit',
|
|
86
|
+
NotFound: () => 'Not Found | Static Generation | Foldkit',
|
|
87
|
+
})
|
|
94
88
|
|
|
95
89
|
const navigationView = (h: HtmlBuilder<Message>): Html =>
|
|
96
90
|
h.nav(
|
|
@@ -102,60 +96,56 @@ const navigationView = (h: HtmlBuilder<Message>): Html =>
|
|
|
102
96
|
)
|
|
103
97
|
|
|
104
98
|
const pageView = (model: Model, h: HtmlBuilder<Message>): Html =>
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
h.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
h.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
),
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
),
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
],
|
|
156
|
-
),
|
|
157
|
-
}),
|
|
158
|
-
)
|
|
99
|
+
AppRoute.match(model.route, {
|
|
100
|
+
Home: () =>
|
|
101
|
+
h.section(
|
|
102
|
+
[h.Class('grid gap-4')],
|
|
103
|
+
[
|
|
104
|
+
h.h1(
|
|
105
|
+
[h.Id('page-title'), h.Class('text-4xl font-bold')],
|
|
106
|
+
['Statically generated home'],
|
|
107
|
+
),
|
|
108
|
+
h.p(
|
|
109
|
+
[],
|
|
110
|
+
['This route was rendered during the build and hydrated in place.'],
|
|
111
|
+
),
|
|
112
|
+
h.button(
|
|
113
|
+
[
|
|
114
|
+
h.OnClick(Message.ClickedIncrement()),
|
|
115
|
+
h.Class('w-fit bg-black px-4 py-2 text-white'),
|
|
116
|
+
],
|
|
117
|
+
[`Count: ${model.count}`],
|
|
118
|
+
),
|
|
119
|
+
],
|
|
120
|
+
),
|
|
121
|
+
About: () =>
|
|
122
|
+
h.section(
|
|
123
|
+
[h.Class('grid gap-4')],
|
|
124
|
+
[
|
|
125
|
+
h.h1(
|
|
126
|
+
[h.Id('page-title'), h.Class('text-4xl font-bold')],
|
|
127
|
+
['Statically generated about page'],
|
|
128
|
+
),
|
|
129
|
+
h.p(
|
|
130
|
+
[],
|
|
131
|
+
[
|
|
132
|
+
'The same renderPage function produced this route in the same build.',
|
|
133
|
+
],
|
|
134
|
+
),
|
|
135
|
+
],
|
|
136
|
+
),
|
|
137
|
+
NotFound: ({ path }) =>
|
|
138
|
+
h.section(
|
|
139
|
+
[h.Class('grid gap-4')],
|
|
140
|
+
[
|
|
141
|
+
h.h1(
|
|
142
|
+
[h.Id('page-title'), h.Class('text-4xl font-bold')],
|
|
143
|
+
['Not found'],
|
|
144
|
+
),
|
|
145
|
+
h.p([], [`No statically generated page exists for ${path}.`]),
|
|
146
|
+
],
|
|
147
|
+
),
|
|
148
|
+
})
|
|
159
149
|
|
|
160
150
|
export const view = (model: Model, h: HtmlBuilder<Message>): Document => ({
|
|
161
151
|
title: routeTitle(model.route),
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
8
|
-
"build": "
|
|
8
|
+
"build": "vite build",
|
|
9
9
|
"start": "node dist/server/main.js",
|
|
10
10
|
"typecheck": "tsc --noEmit",
|
|
11
11
|
"test": "vitest run"
|
|
@@ -20,14 +20,13 @@
|
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"@foldkit/devtools": "workspace:*",
|
|
22
22
|
"@foldkit/vite-plugin": "workspace:*",
|
|
23
|
-
"@tailwindcss/vite": "^4.3.
|
|
23
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
24
24
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
25
|
-
"happy-dom": "^20.
|
|
26
|
-
"prettier": "^3.
|
|
27
|
-
"tailwindcss": "^4.3.
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"vitest": "^4.1.9"
|
|
25
|
+
"happy-dom": "^20.11.13",
|
|
26
|
+
"prettier": "^3.9.6",
|
|
27
|
+
"tailwindcss": "^4.3.3",
|
|
28
|
+
"typescript": "^7.0.2",
|
|
29
|
+
"vite": "^8.2.2",
|
|
30
|
+
"vitest": "^4.1.11"
|
|
32
31
|
}
|
|
33
32
|
}
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@foldkit/devtools": "workspace:*",
|
|
20
20
|
"@foldkit/vite-plugin": "workspace:*",
|
|
21
|
-
"@tailwindcss/vite": "^4.3.
|
|
21
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
22
22
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
23
|
-
"happy-dom": "^20.
|
|
24
|
-
"prettier": "^3.
|
|
25
|
-
"tailwindcss": "^4.3.
|
|
26
|
-
"typescript": "^
|
|
27
|
-
"vite": "^8.
|
|
28
|
-
"vitest": "^4.1.
|
|
23
|
+
"happy-dom": "^20.11.13",
|
|
24
|
+
"prettier": "^3.9.6",
|
|
25
|
+
"tailwindcss": "^4.3.3",
|
|
26
|
+
"typescript": "^7.0.2",
|
|
27
|
+
"vite": "^8.2.2",
|
|
28
|
+
"vitest": "^4.1.11"
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
EditionRadioGroup,
|
|
13
13
|
Message,
|
|
14
14
|
type Model,
|
|
15
|
+
Promo,
|
|
15
16
|
checkoutMachine,
|
|
16
17
|
editionName,
|
|
17
18
|
isReviewReady,
|
|
@@ -37,43 +38,37 @@ const cancelButtonClassName =
|
|
|
37
38
|
'cursor-pointer text-sm font-medium text-stone-600 underline decoration-stone-400 underline-offset-4 transition-colors hover:text-orange-800 focus-visible:outline-2 focus-visible:outline-offset-4 focus-visible:outline-stone-900'
|
|
38
39
|
|
|
39
40
|
const stateEyebrow = (state: typeof CheckoutState.Type): string =>
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}),
|
|
50
|
-
)
|
|
41
|
+
CheckoutState.match(state, {
|
|
42
|
+
Cart: () => 'Bag',
|
|
43
|
+
Shipping: () => 'Delivery',
|
|
44
|
+
Payment: () => 'Payment',
|
|
45
|
+
Review: () => 'Review',
|
|
46
|
+
Placing: () => 'Order',
|
|
47
|
+
Confirmed: () => 'Order',
|
|
48
|
+
Cancelled: () => 'Checkout',
|
|
49
|
+
})
|
|
51
50
|
|
|
52
51
|
const stateTitle = (state: typeof CheckoutState.Type): string =>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}),
|
|
63
|
-
)
|
|
52
|
+
CheckoutState.match(state, {
|
|
53
|
+
Cart: () => 'Your order',
|
|
54
|
+
Shipping: () => 'Delivery details',
|
|
55
|
+
Payment: () => 'Payment',
|
|
56
|
+
Review: () => 'Review and place order',
|
|
57
|
+
Placing: () => 'Processing your order',
|
|
58
|
+
Confirmed: () => 'Thank you',
|
|
59
|
+
Cancelled: () => 'Checkout cancelled',
|
|
60
|
+
})
|
|
64
61
|
|
|
65
62
|
const stateDescription = (state: typeof CheckoutState.Type): string =>
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}),
|
|
76
|
-
)
|
|
63
|
+
CheckoutState.match(state, {
|
|
64
|
+
Cart: () => 'Choose your edition before continuing to checkout.',
|
|
65
|
+
Shipping: () => 'Confirm where we should send your hardcover.',
|
|
66
|
+
Payment: () => 'Select a saved payment method for this order.',
|
|
67
|
+
Review: () => 'Check the details below before placing your order.',
|
|
68
|
+
Placing: () => 'Please keep this page open for a moment.',
|
|
69
|
+
Confirmed: () => 'Your order is confirmed and a receipt is on its way.',
|
|
70
|
+
Cancelled: () => 'Nothing was charged. Your selection has been saved.',
|
|
71
|
+
})
|
|
77
72
|
|
|
78
73
|
const progressSteps: ReadonlyArray<string> = [
|
|
79
74
|
'Bag',
|
|
@@ -1039,21 +1034,19 @@ const reviewView = (
|
|
|
1039
1034
|
),
|
|
1040
1035
|
],
|
|
1041
1036
|
),
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
h.
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
h.
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
}),
|
|
1056
|
-
),
|
|
1037
|
+
Promo.match(state.promo, {
|
|
1038
|
+
NoPromo: () => h.p([h.Class(promoFeedbackClassName)], ['']),
|
|
1039
|
+
AppliedPromo: ({ discount }) =>
|
|
1040
|
+
h.p(
|
|
1041
|
+
[h.Class(clsx(promoFeedbackClassName, 'text-orange-800'))],
|
|
1042
|
+
[`${discount.code} applied · ${discount.percentOff}% off`],
|
|
1043
|
+
),
|
|
1044
|
+
RejectedPromo: () =>
|
|
1045
|
+
h.p(
|
|
1046
|
+
[h.Class(clsx(promoFeedbackClassName, 'text-red-700'))],
|
|
1047
|
+
["That code isn't recognized."],
|
|
1048
|
+
),
|
|
1049
|
+
}),
|
|
1057
1050
|
],
|
|
1058
1051
|
),
|
|
1059
1052
|
Checkbox.view(
|
|
@@ -1288,17 +1281,15 @@ const checkoutContentView = (
|
|
|
1288
1281
|
editionRadioGroup: RadioGroup.Model,
|
|
1289
1282
|
h: HtmlBuilder<Message>,
|
|
1290
1283
|
): Html =>
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
}),
|
|
1301
|
-
)
|
|
1284
|
+
CheckoutState.match(state, {
|
|
1285
|
+
Cart: cartState => cartView(cartState, editionRadioGroup, h),
|
|
1286
|
+
Shipping: () => shippingView(h),
|
|
1287
|
+
Payment: paymentState => paymentView(paymentState, h),
|
|
1288
|
+
Review: reviewState => reviewView(reviewState, h),
|
|
1289
|
+
Placing: () => placingView(h),
|
|
1290
|
+
Confirmed: confirmedState => confirmedView(confirmedState, h),
|
|
1291
|
+
Cancelled: () => cancelledView(h),
|
|
1292
|
+
})
|
|
1302
1293
|
|
|
1303
1294
|
const checkoutPanelView = (
|
|
1304
1295
|
state: typeof CheckoutState.Type,
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@foldkit/devtools": "workspace:*",
|
|
19
19
|
"@foldkit/vite-plugin": "workspace:*",
|
|
20
|
-
"@tailwindcss/vite": "^4.3.
|
|
20
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
21
21
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
22
|
-
"happy-dom": "^20.
|
|
23
|
-
"prettier": "^3.
|
|
24
|
-
"tailwindcss": "^4.3.
|
|
25
|
-
"typescript": "^
|
|
26
|
-
"vite": "^8.
|
|
27
|
-
"vitest": "^4.1.
|
|
22
|
+
"happy-dom": "^20.11.13",
|
|
23
|
+
"prettier": "^3.9.6",
|
|
24
|
+
"tailwindcss": "^4.3.3",
|
|
25
|
+
"typescript": "^7.0.2",
|
|
26
|
+
"vite": "^8.2.2",
|
|
27
|
+
"vitest": "^4.1.11"
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@foldkit/devtools": "workspace:*",
|
|
20
20
|
"@foldkit/vite-plugin": "workspace:*",
|
|
21
|
-
"@tailwindcss/vite": "^4.3.
|
|
21
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
22
22
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
23
|
-
"happy-dom": "^20.
|
|
24
|
-
"prettier": "^3.
|
|
25
|
-
"tailwindcss": "^4.3.
|
|
26
|
-
"typescript": "^
|
|
27
|
-
"vite": "^8.
|
|
28
|
-
"vitest": "^4.1.
|
|
23
|
+
"happy-dom": "^20.11.13",
|
|
24
|
+
"prettier": "^3.9.6",
|
|
25
|
+
"tailwindcss": "^4.3.3",
|
|
26
|
+
"typescript": "^7.0.2",
|
|
27
|
+
"vite": "^8.2.2",
|
|
28
|
+
"vitest": "^4.1.11"
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -108,12 +108,10 @@ export const update = (model: Model, message: Message) =>
|
|
|
108
108
|
UpdatedEditingTodo: ({ text }) => ({
|
|
109
109
|
model: evo(model, {
|
|
110
110
|
editing: () =>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}),
|
|
116
|
-
),
|
|
111
|
+
EditingState.match(model.editing, {
|
|
112
|
+
NotEditing: () => model.editing,
|
|
113
|
+
Editing: ({ id }) => EditingState.Editing({ id, text }),
|
|
114
|
+
}),
|
|
117
115
|
}),
|
|
118
116
|
}),
|
|
119
117
|
|
|
@@ -190,36 +188,33 @@ export const update = (model: Model, message: Message) =>
|
|
|
190
188
|
},
|
|
191
189
|
|
|
192
190
|
SavedEdit: () =>
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
M.tagsExhaustive({
|
|
196
|
-
NotEditing: () => ({ model }),
|
|
197
|
-
|
|
198
|
-
Editing: ({ id, text }) => {
|
|
199
|
-
if (String.isEmpty(String.trim(text))) {
|
|
200
|
-
return {
|
|
201
|
-
model: evo(model, {
|
|
202
|
-
editing: () => EditingState.NotEditing(),
|
|
203
|
-
}),
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
const updatedTodos = Array.map(model.todos, todo =>
|
|
208
|
-
todo.id === id
|
|
209
|
-
? evo(todo, { text: () => String.trim(text) })
|
|
210
|
-
: todo,
|
|
211
|
-
)
|
|
191
|
+
EditingState.match<UpdateReturn>(model.editing, {
|
|
192
|
+
NotEditing: () => ({ model }),
|
|
212
193
|
|
|
194
|
+
Editing: ({ id, text }) => {
|
|
195
|
+
if (String.isEmpty(String.trim(text))) {
|
|
213
196
|
return {
|
|
214
197
|
model: evo(model, {
|
|
215
|
-
todos: () => updatedTodos,
|
|
216
198
|
editing: () => EditingState.NotEditing(),
|
|
217
199
|
}),
|
|
218
|
-
commands: [SaveTodos({ todos: updatedTodos })],
|
|
219
200
|
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const updatedTodos = Array.map(model.todos, todo =>
|
|
204
|
+
todo.id === id
|
|
205
|
+
? evo(todo, { text: () => String.trim(text) })
|
|
206
|
+
: todo,
|
|
207
|
+
)
|
|
208
|
+
|
|
209
|
+
return {
|
|
210
|
+
model: evo(model, {
|
|
211
|
+
todos: () => updatedTodos,
|
|
212
|
+
editing: () => EditingState.NotEditing(),
|
|
213
|
+
}),
|
|
214
|
+
commands: [SaveTodos({ todos: updatedTodos })],
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
}),
|
|
223
218
|
|
|
224
219
|
CancelledEdit: () => ({
|
|
225
220
|
model: evo(model, {
|
|
@@ -304,13 +299,10 @@ const editingTextFor = (
|
|
|
304
299
|
editing: EditingState,
|
|
305
300
|
todoId: string,
|
|
306
301
|
): Option.Option<string> =>
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
Option.liftPredicate(text, () => id === todoId),
|
|
312
|
-
}),
|
|
313
|
-
)
|
|
302
|
+
EditingState.match(editing, {
|
|
303
|
+
NotEditing: () => Option.none(),
|
|
304
|
+
Editing: ({ id, text }) => Option.liftPredicate(text, () => id === todoId),
|
|
305
|
+
})
|
|
314
306
|
|
|
315
307
|
const todoItemView = (
|
|
316
308
|
todo: Todo,
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@foldkit/devtools": "workspace:*",
|
|
20
20
|
"@foldkit/vite-plugin": "workspace:*",
|
|
21
|
-
"@tailwindcss/vite": "^4.3.
|
|
21
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
22
22
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
23
|
-
"happy-dom": "^20.
|
|
24
|
-
"prettier": "^3.
|
|
25
|
-
"tailwindcss": "^4.3.
|
|
26
|
-
"typescript": "^
|
|
27
|
-
"vite": "^8.
|
|
28
|
-
"vitest": "^4.1.
|
|
23
|
+
"happy-dom": "^20.11.13",
|
|
24
|
+
"prettier": "^3.9.6",
|
|
25
|
+
"tailwindcss": "^4.3.3",
|
|
26
|
+
"typescript": "^7.0.2",
|
|
27
|
+
"vite": "^8.2.2",
|
|
28
|
+
"vitest": "^4.1.11"
|
|
29
29
|
}
|
|
30
30
|
}
|