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
|
@@ -101,16 +101,13 @@ const sortingFromParam = (() => {
|
|
|
101
101
|
},
|
|
102
102
|
}),
|
|
103
103
|
encode: (sorting): Option.Option<string> =>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
Option.some(`${column}${SORT_PARAM_SEPARATOR}Descending`),
|
|
112
|
-
}),
|
|
113
|
-
),
|
|
104
|
+
Sorting.match<Option.Option<string>>(sorting, {
|
|
105
|
+
Unsorted: () => Option.none(),
|
|
106
|
+
Ascending: ({ column }) =>
|
|
107
|
+
Option.some(`${column}${SORT_PARAM_SEPARATOR}Ascending`),
|
|
108
|
+
Descending: ({ column }) =>
|
|
109
|
+
Option.some(`${column}${SORT_PARAM_SEPARATOR}Descending`),
|
|
110
|
+
}),
|
|
114
111
|
}),
|
|
115
112
|
),
|
|
116
113
|
)
|
|
@@ -268,7 +265,6 @@ const LoadExternal = Command.define('LoadExternal', {
|
|
|
268
265
|
})
|
|
269
266
|
|
|
270
267
|
type UpdateReturn = Update.Return<Model, Message>
|
|
271
|
-
const withUpdateReturn = M.withReturnType<UpdateReturn>()
|
|
272
268
|
|
|
273
269
|
const DietListbox = Listbox.create<string>()
|
|
274
270
|
const PeriodListbox = Listbox.create<string>()
|
|
@@ -342,19 +338,16 @@ export const update = (model: Model, message: Message) =>
|
|
|
342
338
|
CompletedReplaceFilters: () => ({ model }),
|
|
343
339
|
|
|
344
340
|
ClickedLink: ({ request }) =>
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
model,
|
|
350
|
-
commands: [NavigateInternal({ url: urlToString(url) })],
|
|
351
|
-
}),
|
|
352
|
-
External: ({ href }) => ({
|
|
353
|
-
model,
|
|
354
|
-
commands: [LoadExternal({ href })],
|
|
355
|
-
}),
|
|
341
|
+
UrlRequest.match<UpdateReturn>(request, {
|
|
342
|
+
Internal: ({ url }) => ({
|
|
343
|
+
model,
|
|
344
|
+
commands: [NavigateInternal({ url: urlToString(url) })],
|
|
356
345
|
}),
|
|
357
|
-
|
|
346
|
+
External: ({ href }) => ({
|
|
347
|
+
model,
|
|
348
|
+
commands: [LoadExternal({ href })],
|
|
349
|
+
}),
|
|
350
|
+
}),
|
|
358
351
|
|
|
359
352
|
ChangedUrl: ({ url }) => {
|
|
360
353
|
const nextRoute = urlToAppRoute(url)
|
|
@@ -422,14 +415,11 @@ const filterWhenSome =
|
|
|
422
415
|
const sortBySorting =
|
|
423
416
|
<A>(sorting: Sorting, orders: Record<SortColumn, Order.Order<A>>) =>
|
|
424
417
|
(items: ReadonlyArray<A>): ReadonlyArray<A> =>
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
),
|
|
431
|
-
M.exhaustive,
|
|
432
|
-
)
|
|
418
|
+
Sorting.match(sorting, {
|
|
419
|
+
Unsorted: () => items,
|
|
420
|
+
Ascending: ({ column }) => Array.sort(items, orders[column]),
|
|
421
|
+
Descending: ({ column }) => Array.sort(items, Order.flip(orders[column])),
|
|
422
|
+
})
|
|
433
423
|
|
|
434
424
|
const filterAndSort = (fields: BrowseFields): ReadonlyArray<Dinosaur> =>
|
|
435
425
|
pipe(
|
|
@@ -868,12 +858,10 @@ const routeTitle = (route: Model['route']): string =>
|
|
|
868
858
|
)
|
|
869
859
|
|
|
870
860
|
export const view = (model: Model, h: HtmlBuilder<Message>): Document => {
|
|
871
|
-
const routeContent =
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
}),
|
|
876
|
-
)
|
|
861
|
+
const routeContent = AppRoute.match(model.route, {
|
|
862
|
+
Browse: route => browseView(model, route, h),
|
|
863
|
+
NotFound: ({ path }) => notFoundView(path, h),
|
|
864
|
+
})
|
|
877
865
|
|
|
878
866
|
const body = h.div(
|
|
879
867
|
[h.Class('min-h-screen bg-gray-50')],
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@foldkit/devtools": "workspace:*",
|
|
18
18
|
"@foldkit/vite-plugin": "workspace:*",
|
|
19
|
-
"@tailwindcss/vite": "^4.3.
|
|
19
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
20
20
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
21
|
-
"happy-dom": "^20.
|
|
22
|
-
"prettier": "^3.
|
|
23
|
-
"tailwindcss": "^4.3.
|
|
24
|
-
"typescript": "^
|
|
25
|
-
"vite": "^8.
|
|
26
|
-
"vitest": "^4.1.
|
|
21
|
+
"happy-dom": "^20.11.13",
|
|
22
|
+
"prettier": "^3.9.6",
|
|
23
|
+
"tailwindcss": "^4.3.3",
|
|
24
|
+
"typescript": "^7.0.2",
|
|
25
|
+
"vite": "^8.2.2",
|
|
26
|
+
"vitest": "^4.1.11"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -122,7 +122,6 @@ export const SaveDraft = Command.define('SaveDraft', {
|
|
|
122
122
|
|
|
123
123
|
type UpdateReturn = Update.Return<Model, Message>
|
|
124
124
|
type Step = Update.Step<Model, Message>
|
|
125
|
-
const withUpdateReturn = M.withReturnType<UpdateReturn>()
|
|
126
125
|
|
|
127
126
|
export type AppTransition = Transition.Transition<AppRoute>
|
|
128
127
|
|
|
@@ -223,19 +222,16 @@ export const update = (model: Model, message: Message) =>
|
|
|
223
222
|
CompletedLoadExternal: () => ({ model }),
|
|
224
223
|
|
|
225
224
|
ClickedLink: ({ request }) =>
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
model,
|
|
231
|
-
commands: [NavigateInternal({ url: urlToString(url) })],
|
|
232
|
-
}),
|
|
233
|
-
External: ({ href }) => ({
|
|
234
|
-
model,
|
|
235
|
-
commands: [LoadExternal({ href })],
|
|
236
|
-
}),
|
|
225
|
+
UrlRequest.match<UpdateReturn>(request, {
|
|
226
|
+
Internal: ({ url }) => ({
|
|
227
|
+
model,
|
|
228
|
+
commands: [NavigateInternal({ url: urlToString(url) })],
|
|
237
229
|
}),
|
|
238
|
-
|
|
230
|
+
External: ({ href }) => ({
|
|
231
|
+
model,
|
|
232
|
+
commands: [LoadExternal({ href })],
|
|
233
|
+
}),
|
|
234
|
+
}),
|
|
239
235
|
|
|
240
236
|
ChangedUrl: ({ url }) => {
|
|
241
237
|
const nextRoute = urlToAppRoute(url)
|
|
@@ -289,15 +285,13 @@ export const init: Runtime.RoutingApplicationInit<Model, Message> = (
|
|
|
289
285
|
// VIEW
|
|
290
286
|
|
|
291
287
|
const routeLabel = (route: AppRoute): string =>
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
}),
|
|
300
|
-
)
|
|
288
|
+
AppRoute.match(route, {
|
|
289
|
+
Home: () => 'Home',
|
|
290
|
+
Gallery: () => 'Gallery',
|
|
291
|
+
Painting: ({ paintingId }) => `Painting ${paintingId}`,
|
|
292
|
+
Studio: () => 'Studio',
|
|
293
|
+
NotFound: () => 'Not found',
|
|
294
|
+
})
|
|
301
295
|
|
|
302
296
|
const navigationView = (
|
|
303
297
|
currentRoute: AppRoute,
|
|
@@ -760,16 +754,14 @@ const routeTitle = (route: AppRoute): string =>
|
|
|
760
754
|
)
|
|
761
755
|
|
|
762
756
|
export const view = (model: Model, h: HtmlBuilder<Message>): Document => {
|
|
763
|
-
const routeContent =
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
}),
|
|
772
|
-
)
|
|
757
|
+
const routeContent = AppRoute.match(model.route, {
|
|
758
|
+
Home: () => homeView(h),
|
|
759
|
+
Gallery: () => galleryView(model.catalogStatus, h),
|
|
760
|
+
Painting: ({ paintingId }) =>
|
|
761
|
+
paintingView(paintingId, model.paintingStatus, h),
|
|
762
|
+
Studio: () => studioView(model.studioDraft, model.maybeSavedDraft, h),
|
|
763
|
+
NotFound: ({ path }) => notFoundView(path, h),
|
|
764
|
+
})
|
|
773
765
|
|
|
774
766
|
return {
|
|
775
767
|
title: routeTitle(model.route),
|
|
@@ -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
|
}
|
|
@@ -87,7 +87,6 @@ const LoadExternal = Command.define('LoadExternal', {
|
|
|
87
87
|
// UPDATE
|
|
88
88
|
|
|
89
89
|
type UpdateReturn = Update.Return<Model, Message>
|
|
90
|
-
const withUpdateReturn = M.withReturnType<UpdateReturn>()
|
|
91
90
|
|
|
92
91
|
const foldPeopleEntry = <Input>(
|
|
93
92
|
update: (peoplePage: People.Model, input: Input) => People.UpdateReturn,
|
|
@@ -114,19 +113,16 @@ export const update = (model: Model, message: Message) =>
|
|
|
114
113
|
CompletedLoadExternal: () => ({ model }),
|
|
115
114
|
|
|
116
115
|
ClickedLink: ({ request }) =>
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
model,
|
|
122
|
-
commands: [NavigateInternal({ url: urlToString(url) })],
|
|
123
|
-
}),
|
|
124
|
-
External: ({ href }) => ({
|
|
125
|
-
model,
|
|
126
|
-
commands: [LoadExternal({ href })],
|
|
127
|
-
}),
|
|
116
|
+
UrlRequest.match<UpdateReturn>(request, {
|
|
117
|
+
Internal: ({ url }) => ({
|
|
118
|
+
model,
|
|
119
|
+
commands: [NavigateInternal({ url: urlToString(url) })],
|
|
128
120
|
}),
|
|
129
|
-
|
|
121
|
+
External: ({ href }) => ({
|
|
122
|
+
model,
|
|
123
|
+
commands: [LoadExternal({ href })],
|
|
124
|
+
}),
|
|
125
|
+
}),
|
|
130
126
|
|
|
131
127
|
ChangedUrl: ({ url }) => {
|
|
132
128
|
const nextRoute = urlToAppRoute(url)
|
|
@@ -534,23 +530,21 @@ const routeTitle = (route: Model['route']): string =>
|
|
|
534
530
|
)
|
|
535
531
|
|
|
536
532
|
export const view = (model: Model, h: HtmlBuilder<Message>): Document => {
|
|
537
|
-
const routeContent =
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}),
|
|
553
|
-
)
|
|
533
|
+
const routeContent = AppRoute.match(model.route, {
|
|
534
|
+
Home: () => homeView(h),
|
|
535
|
+
Nested: () => nestedView(h),
|
|
536
|
+
People: () =>
|
|
537
|
+
h.submodel({
|
|
538
|
+
slotId: 'people',
|
|
539
|
+
model: model.peoplePage,
|
|
540
|
+
view: People.view,
|
|
541
|
+
toParentMessage: message => Message.GotPeopleMessage({ message }),
|
|
542
|
+
}),
|
|
543
|
+
Person: ({ personId }) => personView(personId, h),
|
|
544
|
+
FilesIndex: () => filesIndexView(h),
|
|
545
|
+
Files: ({ path }) => filesView(path, h),
|
|
546
|
+
NotFound: ({ path }) => notFoundView(path, h),
|
|
547
|
+
})
|
|
554
548
|
|
|
555
549
|
return {
|
|
556
550
|
title: routeTitle(model.route),
|
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
Array,
|
|
3
3
|
Duration,
|
|
4
4
|
Effect,
|
|
5
|
-
Match as M,
|
|
6
5
|
Option,
|
|
7
6
|
Schema as S,
|
|
8
7
|
String,
|
|
@@ -203,10 +202,9 @@ export const informRouteChanged = (model: Model, route: PeopleRoute) =>
|
|
|
203
202
|
// VIEW
|
|
204
203
|
|
|
205
204
|
const statusText = (results: SearchResults): string =>
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
M.tag('Loaded', ({ query, people: found }) => {
|
|
205
|
+
SearchResults.match<string>(results, {
|
|
206
|
+
Loading: () => 'Searching…',
|
|
207
|
+
Loaded: ({ query, people: found }) => {
|
|
210
208
|
if (String.isEmpty(query)) {
|
|
211
209
|
return 'Click on any person to view their details:'
|
|
212
210
|
}
|
|
@@ -214,9 +212,8 @@ const statusText = (results: SearchResults): string =>
|
|
|
214
212
|
const count = Array.length(found)
|
|
215
213
|
const noun = count === 1 ? 'result' : 'results'
|
|
216
214
|
return `${count} ${noun} for “${query}”`
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
)
|
|
215
|
+
},
|
|
216
|
+
})
|
|
220
217
|
|
|
221
218
|
const recentSearchesView = (
|
|
222
219
|
history: ReadonlyArray<string>,
|
|
@@ -259,88 +256,85 @@ const personListItemView = (person: Person, h: HtmlBuilder<Message>): Html =>
|
|
|
259
256
|
],
|
|
260
257
|
)
|
|
261
258
|
|
|
262
|
-
export const view = Submodel.defineView<Model, Message>(
|
|
263
|
-
(
|
|
264
|
-
h.
|
|
265
|
-
|
|
266
|
-
[
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
h.
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
h.
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
h.
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
h.
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
h.Autocomplete('off'),
|
|
293
|
-
h.Class(
|
|
294
|
-
'w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500',
|
|
295
|
-
),
|
|
296
|
-
]),
|
|
297
|
-
h.span([...description]),
|
|
298
|
-
],
|
|
299
|
-
),
|
|
300
|
-
},
|
|
301
|
-
h,
|
|
302
|
-
),
|
|
303
|
-
Button.view(
|
|
304
|
-
{
|
|
305
|
-
type: 'submit',
|
|
306
|
-
toView: ({ button }) =>
|
|
307
|
-
h.button(
|
|
308
|
-
[
|
|
309
|
-
...button,
|
|
259
|
+
export const view = Submodel.defineView<Model, Message>((model, h): Html =>
|
|
260
|
+
h.div(
|
|
261
|
+
[h.Class('max-w-4xl mx-auto px-4')],
|
|
262
|
+
[
|
|
263
|
+
h.h1([h.Class('text-4xl font-bold text-gray-800 mb-6')], ['People']),
|
|
264
|
+
|
|
265
|
+
h.search(
|
|
266
|
+
[h.Class('mb-6')],
|
|
267
|
+
[
|
|
268
|
+
h.form(
|
|
269
|
+
[h.OnSubmit(Message.SubmittedSearch()), h.Class('flex gap-2')],
|
|
270
|
+
[
|
|
271
|
+
Input.view(
|
|
272
|
+
{
|
|
273
|
+
id: 'people-search',
|
|
274
|
+
type: 'search',
|
|
275
|
+
value: model.searchInput,
|
|
276
|
+
placeholder: 'Search by name or role...',
|
|
277
|
+
onInput: value => Message.ChangedSearchInput({ value }),
|
|
278
|
+
toView: ({ input, label, description }) =>
|
|
279
|
+
h.div(
|
|
280
|
+
[h.Class('flex-1')],
|
|
281
|
+
[
|
|
282
|
+
h.label(
|
|
283
|
+
[...label, h.Class('sr-only')],
|
|
284
|
+
['Search people'],
|
|
285
|
+
),
|
|
286
|
+
h.input([
|
|
287
|
+
...input,
|
|
288
|
+
h.Autocomplete('off'),
|
|
310
289
|
h.Class(
|
|
311
|
-
'px-4 py-2
|
|
290
|
+
'w-full px-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500',
|
|
312
291
|
),
|
|
313
|
-
],
|
|
314
|
-
[
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
292
|
+
]),
|
|
293
|
+
h.span([...description]),
|
|
294
|
+
],
|
|
295
|
+
),
|
|
296
|
+
},
|
|
297
|
+
h,
|
|
298
|
+
),
|
|
299
|
+
Button.view(
|
|
300
|
+
{
|
|
301
|
+
type: 'submit',
|
|
302
|
+
toView: ({ button }) =>
|
|
303
|
+
h.button(
|
|
304
|
+
[
|
|
305
|
+
...button,
|
|
306
|
+
h.Class(
|
|
307
|
+
'px-4 py-2 bg-blue-500 text-white rounded-lg hover:bg-blue-600 transition cursor-pointer',
|
|
308
|
+
),
|
|
309
|
+
],
|
|
310
|
+
['Search'],
|
|
311
|
+
),
|
|
312
|
+
},
|
|
313
|
+
h,
|
|
314
|
+
),
|
|
315
|
+
],
|
|
316
|
+
),
|
|
317
|
+
],
|
|
318
|
+
),
|
|
323
319
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
320
|
+
Array.match(model.searchHistory, {
|
|
321
|
+
onEmpty: () => h.empty,
|
|
322
|
+
onNonEmpty: history => recentSearchesView(history, h),
|
|
323
|
+
}),
|
|
328
324
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
325
|
+
h.p(
|
|
326
|
+
[h.Class('text-lg text-gray-600 mb-6'), h.AriaLive('polite')],
|
|
327
|
+
[statusText(model.results)],
|
|
328
|
+
),
|
|
333
329
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
),
|
|
330
|
+
SearchResults.match(model.results, {
|
|
331
|
+
Loading: () => h.empty,
|
|
332
|
+
Loaded: ({ people: results }) =>
|
|
333
|
+
h.ul(
|
|
334
|
+
[h.Class('space-y-3')],
|
|
335
|
+
Array.map(results, person => personListItemView(person, h)),
|
|
341
336
|
),
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
),
|
|
337
|
+
}),
|
|
338
|
+
],
|
|
339
|
+
),
|
|
346
340
|
)
|
|
@@ -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
|
}
|
|
@@ -81,7 +81,6 @@ const LoadExternal = Command.define('LoadExternal', {
|
|
|
81
81
|
// UPDATE
|
|
82
82
|
|
|
83
83
|
type UpdateReturn = Update.Return<Model, Message>
|
|
84
|
-
const withUpdateReturn = M.withReturnType<UpdateReturn>()
|
|
85
84
|
|
|
86
85
|
const foldProductsOutMessage = M.type<Products.OutMessage>().pipe(
|
|
87
86
|
M.withReturnType<Update.Step<Model, Message>>(),
|
|
@@ -117,20 +116,17 @@ export const update = (model: Model, message: Message) =>
|
|
|
117
116
|
CompletedLoadExternal: () => ({ model }),
|
|
118
117
|
|
|
119
118
|
ClickedLink: ({ request }) =>
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
model,
|
|
125
|
-
commands: [NavigateInternal({ url: urlToString(url) })],
|
|
126
|
-
}),
|
|
127
|
-
|
|
128
|
-
External: ({ href }) => ({
|
|
129
|
-
model,
|
|
130
|
-
commands: [LoadExternal({ href })],
|
|
131
|
-
}),
|
|
119
|
+
UrlRequest.match<UpdateReturn>(request, {
|
|
120
|
+
Internal: ({ url }) => ({
|
|
121
|
+
model,
|
|
122
|
+
commands: [NavigateInternal({ url: urlToString(url) })],
|
|
132
123
|
}),
|
|
133
|
-
|
|
124
|
+
|
|
125
|
+
External: ({ href }) => ({
|
|
126
|
+
model,
|
|
127
|
+
commands: [LoadExternal({ href })],
|
|
128
|
+
}),
|
|
129
|
+
}),
|
|
134
130
|
|
|
135
131
|
ChangedUrl: ({ url }) => ({
|
|
136
132
|
model: evo(model, {
|
|
@@ -281,14 +277,12 @@ const routeTitle = (route: Model['route']): string =>
|
|
|
281
277
|
)
|
|
282
278
|
|
|
283
279
|
export const view = (model: Model, h: HtmlBuilder<Message>): Document => {
|
|
284
|
-
const routeContent =
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}),
|
|
291
|
-
)
|
|
280
|
+
const routeContent = AppRoute.match(model.route, {
|
|
281
|
+
Products: () => productsView(model, h),
|
|
282
|
+
Cart: () => cartView(model, h),
|
|
283
|
+
Checkout: () => checkoutView(model, h),
|
|
284
|
+
NotFound: ({ path }) => notFoundView(path, h),
|
|
285
|
+
})
|
|
292
286
|
|
|
293
287
|
return {
|
|
294
288
|
title: routeTitle(model.route),
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@foldkit/devtools": "workspace:*",
|
|
18
18
|
"@foldkit/vite-plugin": "workspace:*",
|
|
19
|
-
"@tailwindcss/vite": "^4.3.
|
|
19
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
20
20
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
21
|
-
"happy-dom": "^20.
|
|
22
|
-
"prettier": "^3.
|
|
23
|
-
"tailwindcss": "^4.3.
|
|
24
|
-
"typescript": "^
|
|
25
|
-
"vite": "^8.
|
|
26
|
-
"vitest": "^4.1.
|
|
21
|
+
"happy-dom": "^20.11.13",
|
|
22
|
+
"prettier": "^3.9.6",
|
|
23
|
+
"tailwindcss": "^4.3.3",
|
|
24
|
+
"typescript": "^7.0.2",
|
|
25
|
+
"vite": "^8.2.2",
|
|
26
|
+
"vitest": "^4.1.11"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@foldkit/devtools": "workspace:*",
|
|
18
18
|
"@foldkit/vite-plugin": "workspace:*",
|
|
19
|
-
"@tailwindcss/vite": "^4.3.
|
|
19
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
20
20
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
21
|
-
"happy-dom": "^20.
|
|
22
|
-
"prettier": "^3.
|
|
23
|
-
"tailwindcss": "^4.3.
|
|
24
|
-
"typescript": "^
|
|
25
|
-
"vite": "^8.
|
|
26
|
-
"vitest": "^4.1.
|
|
21
|
+
"happy-dom": "^20.11.13",
|
|
22
|
+
"prettier": "^3.9.6",
|
|
23
|
+
"tailwindcss": "^4.3.3",
|
|
24
|
+
"typescript": "^7.0.2",
|
|
25
|
+
"vite": "^8.2.2",
|
|
26
|
+
"vitest": "^4.1.11"
|
|
27
27
|
}
|
|
28
28
|
}
|
|
@@ -5,25 +5,23 @@
|
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
8
|
-
"build": "
|
|
8
|
+
"build": "vite build",
|
|
9
9
|
"preview": "vite preview --outDir dist/client",
|
|
10
10
|
"typecheck": "tsc --noEmit"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@effect/platform-browser": "4.0.0-rc.112",
|
|
14
|
-
"@effect/platform-node": "4.0.0-rc.112",
|
|
15
14
|
"effect": "4.0.0-rc.112",
|
|
16
15
|
"foldkit": "workspace:*"
|
|
17
16
|
},
|
|
18
17
|
"devDependencies": {
|
|
19
18
|
"@foldkit/devtools": "workspace:*",
|
|
20
19
|
"@foldkit/vite-plugin": "workspace:*",
|
|
21
|
-
"@tailwindcss/vite": "^4.3.
|
|
20
|
+
"@tailwindcss/vite": "^4.3.3",
|
|
22
21
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
23
|
-
"prettier": "^3.
|
|
24
|
-
"tailwindcss": "^4.3.
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"vite": "^8.0.16"
|
|
22
|
+
"prettier": "^3.9.6",
|
|
23
|
+
"tailwindcss": "^4.3.3",
|
|
24
|
+
"typescript": "^7.0.2",
|
|
25
|
+
"vite": "^8.2.2"
|
|
28
26
|
}
|
|
29
27
|
}
|