create-foldkit-app 0.27.3 → 0.28.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/index.js +1 -5
- package/{templates → dist/templates}/base/AGENTS.md +17 -19
- package/dist/templates/examples/api-cache/package.json +29 -0
- package/dist/templates/examples/api-cache/src/data.test.ts +28 -0
- package/dist/templates/examples/api-cache/src/data.ts +126 -0
- package/dist/templates/examples/api-cache/src/entry.ts +17 -0
- package/dist/templates/examples/api-cache/src/main.fixtures.ts +70 -0
- package/dist/templates/examples/api-cache/src/main.ts +744 -0
- package/dist/templates/examples/api-cache/src/scene.test.ts +120 -0
- package/dist/templates/examples/api-cache/src/story.test.ts +288 -0
- package/dist/templates/examples/api-cache/src/styles.css +1 -0
- package/dist/templates/examples/api-cache/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/auth/package.json +30 -0
- package/dist/templates/examples/auth/src/command.ts +49 -0
- package/dist/templates/examples/auth/src/constant.ts +1 -0
- package/dist/templates/examples/auth/src/domain/session.ts +9 -0
- package/dist/templates/examples/auth/src/entry.ts +25 -0
- package/dist/templates/examples/auth/src/main.ts +75 -0
- package/dist/templates/examples/auth/src/message.ts +22 -0
- package/dist/templates/examples/auth/src/model.ts +9 -0
- package/dist/templates/examples/auth/src/notFoundView.ts +25 -0
- package/dist/templates/examples/auth/src/page/index.ts +2 -0
- package/dist/templates/examples/auth/src/page/loggedIn/index.ts +4 -0
- package/dist/templates/examples/auth/src/page/loggedIn/message.ts +17 -0
- package/dist/templates/examples/auth/src/page/loggedIn/model.ts +21 -0
- package/dist/templates/examples/auth/src/page/loggedIn/page/dashboard.ts +40 -0
- package/dist/templates/examples/auth/src/page/loggedIn/page/settings.ts +71 -0
- package/dist/templates/examples/auth/src/page/loggedIn/update.ts +16 -0
- package/dist/templates/examples/auth/src/page/loggedIn/view.ts +87 -0
- package/dist/templates/examples/auth/src/page/loggedOut/index.ts +4 -0
- package/dist/templates/examples/auth/src/page/loggedOut/message.ts +20 -0
- package/dist/templates/examples/auth/src/page/loggedOut/model.ts +21 -0
- package/dist/templates/examples/auth/src/page/loggedOut/page/home.ts +68 -0
- package/dist/templates/examples/auth/src/page/loggedOut/page/login.scene.test.ts +116 -0
- package/dist/templates/examples/auth/src/page/loggedOut/page/login.story.test.ts +112 -0
- package/dist/templates/examples/auth/src/page/loggedOut/page/login.ts +346 -0
- package/dist/templates/examples/auth/src/page/loggedOut/update.ts +32 -0
- package/dist/templates/examples/auth/src/page/loggedOut/view.ts +31 -0
- package/dist/templates/examples/auth/src/route.ts +56 -0
- package/dist/templates/examples/auth/src/scene.test.ts +61 -0
- package/dist/templates/examples/auth/src/styles.css +1 -0
- package/dist/templates/examples/auth/src/update.ts +179 -0
- package/dist/templates/examples/auth/src/view.ts +40 -0
- package/dist/templates/examples/auth/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/canvas-art/package.json +29 -0
- package/dist/templates/examples/canvas-art/src/entry.ts +17 -0
- package/dist/templates/examples/canvas-art/src/main.ts +274 -0
- package/dist/templates/examples/canvas-art/src/scene.test.ts +70 -0
- package/dist/templates/examples/canvas-art/src/story.test.ts +155 -0
- package/dist/templates/examples/canvas-art/src/styles.css +1 -0
- package/dist/templates/examples/canvas-art/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/charting/package.json +31 -0
- package/dist/templates/examples/charting/src/chartHost.ts +20 -0
- package/dist/templates/examples/charting/src/command.ts +62 -0
- package/dist/templates/examples/charting/src/domain.ts +175 -0
- package/dist/templates/examples/charting/src/echarts.ts +408 -0
- package/dist/templates/examples/charting/src/entry.ts +25 -0
- package/dist/templates/examples/charting/src/githubApi.ts +271 -0
- package/dist/templates/examples/charting/src/http.ts +50 -0
- package/dist/templates/examples/charting/src/init.test.ts +14 -0
- package/dist/templates/examples/charting/src/init.ts +29 -0
- package/dist/templates/examples/charting/src/main.fixtures.ts +162 -0
- package/dist/templates/examples/charting/src/message.ts +23 -0
- package/dist/templates/examples/charting/src/model.ts +22 -0
- package/dist/templates/examples/charting/src/npmApi.ts +75 -0
- package/dist/templates/examples/charting/src/radioGroups.ts +11 -0
- package/dist/templates/examples/charting/src/scene.test.ts +103 -0
- package/dist/templates/examples/charting/src/story.test.ts +145 -0
- package/dist/templates/examples/charting/src/styles.css +1 -0
- package/dist/templates/examples/charting/src/subscription.ts +70 -0
- package/dist/templates/examples/charting/src/telemetry.test.ts +64 -0
- package/dist/templates/examples/charting/src/telemetry.ts +432 -0
- package/dist/templates/examples/charting/src/update.ts +217 -0
- package/dist/templates/examples/charting/src/view/chart.ts +129 -0
- package/dist/templates/examples/charting/src/view/format.ts +23 -0
- package/dist/templates/examples/charting/src/view/index.ts +1 -0
- package/dist/templates/examples/charting/src/view/layout.ts +175 -0
- package/dist/templates/examples/charting/src/view/sidebar.ts +309 -0
- package/dist/templates/examples/charting/src/view/view.ts +23 -0
- package/dist/templates/examples/charting/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/charting/src/weeks.ts +105 -0
- package/dist/templates/examples/counter/package.json +29 -0
- package/dist/templates/examples/counter/src/entry.ts +16 -0
- package/dist/templates/examples/counter/src/main.ts +95 -0
- package/dist/templates/examples/counter/src/scene.test.ts +57 -0
- package/dist/templates/examples/counter/src/story.test.ts +71 -0
- package/dist/templates/examples/counter/src/styles.css +1 -0
- package/dist/templates/examples/counter/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/counters/package.json +29 -0
- package/dist/templates/examples/counters/src/counter.ts +70 -0
- package/dist/templates/examples/counters/src/entry.ts +16 -0
- package/dist/templates/examples/counters/src/main.ts +171 -0
- package/dist/templates/examples/counters/src/scene.test.ts +90 -0
- package/dist/templates/examples/counters/src/story.test.ts +127 -0
- package/dist/templates/examples/counters/src/styles.css +1 -0
- package/dist/templates/examples/counters/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/crash-view/package.json +29 -0
- package/dist/templates/examples/crash-view/src/entry.ts +28 -0
- package/dist/templates/examples/crash-view/src/main.ts +104 -0
- package/dist/templates/examples/crash-view/src/scene.test.ts +14 -0
- package/dist/templates/examples/crash-view/src/story.test.ts +11 -0
- package/dist/templates/examples/crash-view/src/styles.css +1 -0
- package/dist/templates/examples/crash-view/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/embedding/package.json +29 -0
- package/dist/templates/examples/embedding/src/entry.ts +3 -0
- package/dist/templates/examples/embedding/src/host.ts +108 -0
- package/dist/templates/examples/embedding/src/main.ts +144 -0
- package/dist/templates/examples/embedding/src/scene.test.ts +28 -0
- package/dist/templates/examples/embedding/src/story.test.ts +64 -0
- package/dist/templates/examples/embedding/src/styles.css +1 -0
- package/dist/templates/examples/embedding/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/form/package.json +30 -0
- package/dist/templates/examples/form/src/entry.ts +16 -0
- package/dist/templates/examples/form/src/main.ts +493 -0
- package/dist/templates/examples/form/src/scene.test.ts +165 -0
- package/dist/templates/examples/form/src/story.test.ts +190 -0
- package/dist/templates/examples/form/src/styles.css +1 -0
- package/dist/templates/examples/form/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/generative-art/package.json +29 -0
- package/dist/templates/examples/generative-art/src/command.ts +109 -0
- package/dist/templates/examples/generative-art/src/constant.ts +68 -0
- package/dist/templates/examples/generative-art/src/entry.ts +22 -0
- package/dist/templates/examples/generative-art/src/main.ts +59 -0
- package/dist/templates/examples/generative-art/src/message.ts +35 -0
- package/dist/templates/examples/generative-art/src/model.ts +33 -0
- package/dist/templates/examples/generative-art/src/noise.ts +93 -0
- package/dist/templates/examples/generative-art/src/scene.test.ts +103 -0
- package/dist/templates/examples/generative-art/src/story.test.ts +203 -0
- package/dist/templates/examples/generative-art/src/styles.css +1 -0
- package/dist/templates/examples/generative-art/src/subscription.ts +35 -0
- package/dist/templates/examples/generative-art/src/update.ts +319 -0
- package/dist/templates/examples/generative-art/src/view.ts +451 -0
- package/dist/templates/examples/generative-art/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/interrupting-commands/package.json +29 -0
- package/dist/templates/examples/interrupting-commands/src/entry.ts +16 -0
- package/dist/templates/examples/interrupting-commands/src/main.ts +354 -0
- package/dist/templates/examples/interrupting-commands/src/scene.test.ts +89 -0
- package/dist/templates/examples/interrupting-commands/src/story.test.ts +224 -0
- package/dist/templates/examples/interrupting-commands/src/styles.css +1 -0
- package/dist/templates/examples/interrupting-commands/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/job-application/package.json +30 -0
- package/dist/templates/examples/job-application/src/command.ts +23 -0
- package/dist/templates/examples/job-application/src/domain/index.ts +3 -0
- package/dist/templates/examples/job-application/src/domain/proficiencyLevel.ts +11 -0
- package/dist/templates/examples/job-application/src/domain/pronounOption.ts +13 -0
- package/dist/templates/examples/job-application/src/domain/step.ts +28 -0
- package/dist/templates/examples/job-application/src/entry.ts +17 -0
- package/dist/templates/examples/job-application/src/main.ts +69 -0
- package/dist/templates/examples/job-application/src/message.ts +44 -0
- package/dist/templates/examples/job-application/src/model.ts +47 -0
- package/dist/templates/examples/job-application/src/scene.test.ts +269 -0
- package/dist/templates/examples/job-application/src/step/attachments.ts +111 -0
- package/dist/templates/examples/job-application/src/step/coverLetter.ts +34 -0
- package/dist/templates/examples/job-application/src/step/education/education.ts +121 -0
- package/dist/templates/examples/job-application/src/step/education/entry.ts +168 -0
- package/dist/templates/examples/job-application/src/step/education/index.ts +2 -0
- package/dist/templates/examples/job-application/src/step/index.ts +6 -0
- package/dist/templates/examples/job-application/src/step/personalInfo.ts +305 -0
- package/dist/templates/examples/job-application/src/step/skills/entry.ts +126 -0
- package/dist/templates/examples/job-application/src/step/skills/index.ts +2 -0
- package/dist/templates/examples/job-application/src/step/skills/skills.ts +118 -0
- package/dist/templates/examples/job-application/src/step/validation.ts +6 -0
- package/dist/templates/examples/job-application/src/step/workHistory/entry.ts +206 -0
- package/dist/templates/examples/job-application/src/step/workHistory/index.ts +2 -0
- package/dist/templates/examples/job-application/src/step/workHistory/workHistory.ts +121 -0
- package/dist/templates/examples/job-application/src/story.test.ts +775 -0
- package/dist/templates/examples/job-application/src/styles.css +1 -0
- package/dist/templates/examples/job-application/src/update.ts +183 -0
- package/dist/templates/examples/job-application/src/view/attachments.ts +215 -0
- package/dist/templates/examples/job-application/src/view/coverLetter.ts +73 -0
- package/dist/templates/examples/job-application/src/view/datePicker.ts +207 -0
- package/dist/templates/examples/job-application/src/view/education.ts +63 -0
- package/dist/templates/examples/job-application/src/view/educationEntry.ts +165 -0
- package/dist/templates/examples/job-application/src/view/field.ts +183 -0
- package/dist/templates/examples/job-application/src/view/format.ts +50 -0
- package/dist/templates/examples/job-application/src/view/icon.ts +21 -0
- package/dist/templates/examples/job-application/src/view/index.ts +352 -0
- package/dist/templates/examples/job-application/src/view/personalInfo.ts +224 -0
- package/dist/templates/examples/job-application/src/view/preview.ts +265 -0
- package/dist/templates/examples/job-application/src/view/review.ts +388 -0
- package/dist/templates/examples/job-application/src/view/skillEntry.ts +102 -0
- package/dist/templates/examples/job-application/src/view/skills.ts +49 -0
- package/dist/templates/examples/job-application/src/view/stepNav.ts +181 -0
- package/dist/templates/examples/job-application/src/view/workEntry.ts +159 -0
- package/dist/templates/examples/job-application/src/view/workHistory.ts +55 -0
- package/dist/templates/examples/job-application/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/kanban/package.json +31 -0
- package/dist/templates/examples/kanban/src/command.ts +46 -0
- package/dist/templates/examples/kanban/src/constant.ts +149 -0
- package/dist/templates/examples/kanban/src/domain/card.ts +10 -0
- package/dist/templates/examples/kanban/src/domain/column.ts +115 -0
- package/dist/templates/examples/kanban/src/domain/index.ts +2 -0
- package/dist/templates/examples/kanban/src/entry.ts +27 -0
- package/dist/templates/examples/kanban/src/main.ts +56 -0
- package/dist/templates/examples/kanban/src/message.ts +21 -0
- package/dist/templates/examples/kanban/src/model.ts +21 -0
- package/dist/templates/examples/kanban/src/scene.test.ts +161 -0
- package/dist/templates/examples/kanban/src/story.test.ts +461 -0
- package/dist/templates/examples/kanban/src/styles.css +1 -0
- package/dist/templates/examples/kanban/src/subscription.ts +16 -0
- package/dist/templates/examples/kanban/src/update.ts +205 -0
- package/dist/templates/examples/kanban/src/view/card.ts +79 -0
- package/dist/templates/examples/kanban/src/view/column.ts +283 -0
- package/dist/templates/examples/kanban/src/view/index.ts +71 -0
- package/dist/templates/examples/kanban/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/managed-resource-layer/package.json +29 -0
- package/dist/templates/examples/managed-resource-layer/src/entry.ts +17 -0
- package/dist/templates/examples/managed-resource-layer/src/main.ts +309 -0
- package/dist/templates/examples/managed-resource-layer/src/scene.test.ts +117 -0
- package/dist/templates/examples/managed-resource-layer/src/story.test.ts +118 -0
- package/dist/templates/examples/managed-resource-layer/src/styles.css +1 -0
- package/dist/templates/examples/managed-resource-layer/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/map/package.json +31 -0
- package/dist/templates/examples/map/src/entry.ts +17 -0
- package/dist/templates/examples/map/src/locations.ts +69 -0
- package/dist/templates/examples/map/src/main.fixtures.ts +28 -0
- package/dist/templates/examples/map/src/main.ts +781 -0
- package/dist/templates/examples/map/src/mapHost.ts +23 -0
- package/dist/templates/examples/map/src/scene.test.ts +136 -0
- package/dist/templates/examples/map/src/story.test.ts +190 -0
- package/dist/templates/examples/map/src/styles.css +2 -0
- package/dist/templates/examples/map/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/pixel-art/package.json +31 -0
- package/dist/templates/examples/pixel-art/src/command.ts +87 -0
- package/dist/templates/examples/pixel-art/src/comparison.bench.test.ts +204 -0
- package/dist/templates/examples/pixel-art/src/constant.ts +21 -0
- package/dist/templates/examples/pixel-art/src/entry.ts +27 -0
- package/dist/templates/examples/pixel-art/src/grid.ts +134 -0
- package/dist/templates/examples/pixel-art/src/main.bench.ts +133 -0
- package/dist/templates/examples/pixel-art/src/main.ts +85 -0
- package/dist/templates/examples/pixel-art/src/message.ts +36 -0
- package/dist/templates/examples/pixel-art/src/model.ts +79 -0
- package/dist/templates/examples/pixel-art/src/palette.ts +134 -0
- package/dist/templates/examples/pixel-art/src/scene.test.ts +250 -0
- package/dist/templates/examples/pixel-art/src/story.test.ts +482 -0
- package/dist/templates/examples/pixel-art/src/styles.css +1 -0
- package/dist/templates/examples/pixel-art/src/subscription.ts +61 -0
- package/dist/templates/examples/pixel-art/src/update.ts +469 -0
- package/dist/templates/examples/pixel-art/src/view/canvas.ts +134 -0
- package/dist/templates/examples/pixel-art/src/view/dialog.ts +152 -0
- package/dist/templates/examples/pixel-art/src/view/history.ts +214 -0
- package/dist/templates/examples/pixel-art/src/view/index.ts +1 -0
- package/dist/templates/examples/pixel-art/src/view/toolbar.ts +452 -0
- package/dist/templates/examples/pixel-art/src/view/view.ts +183 -0
- package/dist/templates/examples/pixel-art/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/query-sync/package.json +30 -0
- package/dist/templates/examples/query-sync/src/data.ts +166 -0
- package/dist/templates/examples/query-sync/src/entry.ts +20 -0
- package/dist/templates/examples/query-sync/src/main.ts +898 -0
- package/dist/templates/examples/query-sync/src/scene.test.ts +89 -0
- package/dist/templates/examples/query-sync/src/story.test.ts +151 -0
- package/dist/templates/examples/query-sync/src/styles.css +1 -0
- package/dist/templates/examples/query-sync/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/route-transitions/package.json +28 -0
- package/dist/templates/examples/route-transitions/src/data.ts +61 -0
- package/dist/templates/examples/route-transitions/src/entry.ts +20 -0
- package/dist/templates/examples/route-transitions/src/main.ts +798 -0
- package/dist/templates/examples/route-transitions/src/route.ts +48 -0
- package/dist/templates/examples/route-transitions/src/story.test.ts +225 -0
- package/dist/templates/examples/route-transitions/src/styles.css +1 -0
- package/dist/templates/examples/route-transitions/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/routing/package.json +29 -0
- package/dist/templates/examples/routing/src/entry.ts +20 -0
- package/dist/templates/examples/routing/src/fileTree.ts +98 -0
- package/dist/templates/examples/routing/src/main.ts +573 -0
- package/dist/templates/examples/routing/src/page/index.ts +1 -0
- package/dist/templates/examples/routing/src/page/people.ts +349 -0
- package/dist/templates/examples/routing/src/route.ts +82 -0
- package/dist/templates/examples/routing/src/scene.test.ts +180 -0
- package/dist/templates/examples/routing/src/story.test.ts +242 -0
- package/dist/templates/examples/routing/src/styles.css +1 -0
- package/dist/templates/examples/routing/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/shopping-cart/package.json +29 -0
- package/dist/templates/examples/shopping-cart/src/data/products.ts +10 -0
- package/dist/templates/examples/shopping-cart/src/domain/cart.ts +77 -0
- package/dist/templates/examples/shopping-cart/src/domain/index.ts +2 -0
- package/dist/templates/examples/shopping-cart/src/domain/item.ts +16 -0
- package/dist/templates/examples/shopping-cart/src/entry.ts +20 -0
- package/dist/templates/examples/shopping-cart/src/main.ts +307 -0
- package/dist/templates/examples/shopping-cart/src/page/cart.ts +203 -0
- package/dist/templates/examples/shopping-cart/src/page/checkout.ts +205 -0
- package/dist/templates/examples/shopping-cart/src/page/index.ts +3 -0
- package/dist/templates/examples/shopping-cart/src/page/products.ts +267 -0
- package/dist/templates/examples/shopping-cart/src/route.ts +43 -0
- package/dist/templates/examples/shopping-cart/src/scene.test.ts +138 -0
- package/dist/templates/examples/shopping-cart/src/story.test.ts +233 -0
- package/dist/templates/examples/shopping-cart/src/styles.css +1 -0
- package/dist/templates/examples/shopping-cart/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/slow-warnings/package.json +28 -0
- package/dist/templates/examples/slow-warnings/src/entry.ts +29 -0
- package/dist/templates/examples/slow-warnings/src/handleSlow.test.ts +43 -0
- package/dist/templates/examples/slow-warnings/src/main.ts +574 -0
- package/dist/templates/examples/slow-warnings/src/scene.test.ts +57 -0
- package/dist/templates/examples/slow-warnings/src/story.test.ts +118 -0
- package/dist/templates/examples/slow-warnings/src/styles.css +1 -0
- package/dist/templates/examples/slow-warnings/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/snake/package.json +28 -0
- package/dist/templates/examples/snake/src/constants.ts +11 -0
- package/dist/templates/examples/snake/src/domain/apple.ts +22 -0
- package/dist/templates/examples/snake/src/domain/direction.ts +17 -0
- package/dist/templates/examples/snake/src/domain/index.ts +4 -0
- package/dist/templates/examples/snake/src/domain/position.ts +32 -0
- package/dist/templates/examples/snake/src/domain/snake.ts +43 -0
- package/dist/templates/examples/snake/src/entry.ts +17 -0
- package/dist/templates/examples/snake/src/main.ts +345 -0
- package/dist/templates/examples/snake/src/scene.test.ts +77 -0
- package/dist/templates/examples/snake/src/story.test.ts +165 -0
- package/dist/templates/examples/snake/src/styles.css +1 -0
- package/dist/templates/examples/snake/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/ssg/package.json +29 -0
- package/dist/templates/examples/ssg/src/entry.server.ts +14 -0
- package/{templates/rendering → dist/templates/examples}/ssg/src/entry.ts +3 -11
- package/dist/templates/examples/ssg/src/main.ts +163 -0
- package/dist/templates/examples/ssg/src/styles.css +1 -0
- package/dist/templates/examples/ssr/package.json +33 -0
- package/dist/templates/examples/ssr/src/cookie.ts +13 -0
- package/dist/templates/examples/ssr/src/entry.server.ts +51 -0
- package/dist/templates/examples/ssr/src/main.ts +170 -0
- package/{templates/rendering → dist/templates/examples}/ssr/src/scene.test.ts +5 -8
- package/dist/templates/examples/ssr/src/styles.css +1 -0
- package/dist/templates/examples/ssr/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/state-machine/package.json +30 -0
- package/dist/templates/examples/state-machine/src/entry.ts +17 -0
- package/dist/templates/examples/state-machine/src/icon.ts +51 -0
- package/dist/templates/examples/state-machine/src/main.ts +420 -0
- package/dist/templates/examples/state-machine/src/scene.test.ts +85 -0
- package/dist/templates/examples/state-machine/src/story.test.ts +199 -0
- package/dist/templates/examples/state-machine/src/styles.css +53 -0
- package/dist/templates/examples/state-machine/src/view.ts +1675 -0
- package/dist/templates/examples/state-machine/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/stopwatch/package.json +29 -0
- package/dist/templates/examples/stopwatch/src/entry.ts +17 -0
- package/dist/templates/examples/stopwatch/src/main.ts +237 -0
- package/dist/templates/examples/stopwatch/src/scene.test.ts +124 -0
- package/dist/templates/examples/stopwatch/src/story.test.ts +126 -0
- package/dist/templates/examples/stopwatch/src/styles.css +1 -0
- package/dist/templates/examples/stopwatch/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/todo/package.json +30 -0
- package/dist/templates/examples/todo/src/entry.ts +17 -0
- package/dist/templates/examples/todo/src/main.ts +682 -0
- package/dist/templates/examples/todo/src/scene.test.ts +177 -0
- package/dist/templates/examples/todo/src/story.test.ts +374 -0
- package/dist/templates/examples/todo/src/styles.css +1 -0
- package/dist/templates/examples/todo/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/ui-showcase/package.json +30 -0
- package/dist/templates/examples/ui-showcase/src/entry.ts +31 -0
- package/dist/templates/examples/ui-showcase/src/icon.ts +64 -0
- package/dist/templates/examples/ui-showcase/src/main.ts +673 -0
- package/dist/templates/examples/ui-showcase/src/scene.test.ts +102 -0
- package/dist/templates/examples/ui-showcase/src/story.test.ts +128 -0
- package/dist/templates/examples/ui-showcase/src/styles.css +21 -0
- package/dist/templates/examples/ui-showcase/src/ui/init.ts +185 -0
- package/dist/templates/examples/ui-showcase/src/ui/message.ts +164 -0
- package/dist/templates/examples/ui-showcase/src/ui/model.ts +138 -0
- package/dist/templates/examples/ui-showcase/src/ui/subscriptions.ts +55 -0
- package/dist/templates/examples/ui-showcase/src/ui/toast.ts +13 -0
- package/dist/templates/examples/ui-showcase/src/ui/update.ts +1234 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/animation.ts +58 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/button.ts +64 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/calendar.ts +202 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/checkbox.ts +185 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/combobox.ts +326 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/datePicker.ts +263 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/dialog.ts +427 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/disclosure.ts +142 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/dragAndDrop.ts +230 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/fieldset.ts +284 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/fileDrop.ts +119 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/index.ts +24 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/input.ts +90 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/listbox.ts +263 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/menu.ts +172 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/popover.ts +262 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/radioGroup.ts +192 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/select.ts +129 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/slider.ts +135 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/switch.ts +82 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/tabs.ts +187 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/textarea.ts +99 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/toast.ts +165 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/tooltip.ts +123 -0
- package/dist/templates/examples/ui-showcase/src/ui/view/virtualList.ts +361 -0
- package/dist/templates/examples/ui-showcase/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/view-transitions/package.json +28 -0
- package/dist/templates/examples/view-transitions/src/artwork.ts +80 -0
- package/dist/templates/examples/view-transitions/src/entry.ts +21 -0
- package/dist/templates/examples/view-transitions/src/main.ts +348 -0
- package/dist/templates/examples/view-transitions/src/route.ts +29 -0
- package/dist/templates/examples/view-transitions/src/scene.test.ts +130 -0
- package/dist/templates/examples/view-transitions/src/styles.css +66 -0
- package/dist/templates/examples/view-transitions/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/weather/package.json +29 -0
- package/dist/templates/examples/weather/src/entry.ts +16 -0
- package/dist/templates/examples/weather/src/main.fixtures.ts +59 -0
- package/dist/templates/examples/weather/src/main.ts +356 -0
- package/dist/templates/examples/weather/src/scene.test.ts +109 -0
- package/dist/templates/examples/weather/src/story.test.ts +125 -0
- package/dist/templates/examples/weather/src/styles.css +1 -0
- package/dist/templates/examples/weather/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/web-components/package.json +32 -0
- package/dist/templates/examples/web-components/src/entry.ts +16 -0
- package/dist/templates/examples/web-components/src/main.ts +327 -0
- package/dist/templates/examples/web-components/src/scene.test.ts +90 -0
- package/dist/templates/examples/web-components/src/story.test.ts +90 -0
- package/dist/templates/examples/web-components/src/styles.css +1 -0
- package/dist/templates/examples/web-components/src/vitest-setup.ts +3 -0
- package/dist/templates/examples/websocket-chat/package.json +29 -0
- package/dist/templates/examples/websocket-chat/src/entry.ts +26 -0
- package/dist/templates/examples/websocket-chat/src/main.ts +626 -0
- package/dist/templates/examples/websocket-chat/src/scene.test.ts +166 -0
- package/dist/templates/examples/websocket-chat/src/story.test.ts +183 -0
- package/dist/templates/examples/websocket-chat/src/styles.css +1 -0
- package/dist/templates/examples/websocket-chat/src/vitest-setup.ts +3 -0
- package/dist/templates/release.json +27 -0
- package/dist/templates/rendering/ssg/src/entry.ts +20 -0
- package/{templates → dist/templates}/rendering/ssg/src/main.ts +36 -43
- package/dist/templates/rendering/ssg/src/route.ts +20 -0
- package/dist/templates/rendering/ssg/src/vite-env.d.ts +19 -0
- package/dist/templates/rendering/ssr/src/entry.ts +17 -0
- package/{templates → dist/templates}/rendering/ssr/src/main.ts +17 -25
- package/dist/templates/rendering/ssr/src/scene.test.ts +40 -0
- package/dist/templates/rendering/ssr/src/vite-env.d.ts +19 -0
- package/dist/utils/files.js +23 -71
- package/dist/utils/packages.js +63 -44
- package/package.json +3 -4
- /package/{templates → dist/templates}/base/.mcp.json +0 -0
- /package/{templates → dist/templates}/base/.oxlintrc.json +0 -0
- /package/{templates → dist/templates}/base/.prettierignore +0 -0
- /package/{templates → dist/templates}/base/.prettierrc +0 -0
- /package/{templates → dist/templates}/base/README.md +0 -0
- /package/{templates → dist/templates}/base/gitignore +0 -0
- /package/{templates → dist/templates}/base/ignore +0 -0
- /package/{templates → dist/templates}/base/index.html +0 -0
- /package/{templates → dist/templates}/base/package.json +0 -0
- /package/{templates → dist/templates}/base/src/styles.css +0 -0
- /package/{templates → dist/templates}/base/src/vitest-setup.ts +0 -0
- /package/{templates → dist/templates}/base/tsconfig.json +0 -0
- /package/{templates → dist/templates}/base/vite.config.ts +0 -0
- /package/{templates → dist/templates}/base/vitest.config.ts +0 -0
- /package/{templates/rendering → dist/templates/examples}/ssg/src/route.ts +0 -0
- /package/{templates/rendering → dist/templates/examples}/ssg/src/vite-env.d.ts +0 -0
- /package/{templates/rendering → dist/templates/examples}/ssr/src/entry.ts +0 -0
- /package/{templates/rendering → dist/templates/examples}/ssr/src/vite-env.d.ts +0 -0
- /package/{templates → dist/templates}/package-managers/pnpm/pnpm-workspace.yaml +0 -0
- /package/{templates → dist/templates}/rendering/ssg/README.md +0 -0
- /package/{templates → dist/templates}/rendering/ssg/package.json +0 -0
- /package/{templates → dist/templates}/rendering/ssg/scripts/build.mjs +0 -0
- /package/{templates → dist/templates}/rendering/ssg/scripts/prerender.ts +0 -0
- /package/{templates → dist/templates}/rendering/ssg/src/entry.server.ts +0 -0
- /package/{templates → dist/templates}/rendering/ssg/src/scene.test.ts +0 -0
- /package/{templates → dist/templates}/rendering/ssg/tsconfig.json +0 -0
- /package/{templates → dist/templates}/rendering/ssg/vite.config.ts +0 -0
- /package/{templates → dist/templates}/rendering/ssr/README.md +0 -0
- /package/{templates → dist/templates}/rendering/ssr/package.json +0 -0
- /package/{templates → dist/templates}/rendering/ssr/scripts/build.mjs +0 -0
- /package/{templates → dist/templates}/rendering/ssr/server/main.ts +0 -0
- /package/{templates → dist/templates}/rendering/ssr/src/cookie.ts +0 -0
- /package/{templates → dist/templates}/rendering/ssr/src/entry.server.ts +0 -0
- /package/{templates → dist/templates}/rendering/ssr/tsconfig.json +0 -0
- /package/{templates → dist/templates}/rendering/ssr/vite.config.ts +0 -0
|
@@ -0,0 +1,673 @@
|
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
import { Array, Effect, Match as M, Option, Schema as S, pipe } from 'effect'
|
|
3
|
+
import {
|
|
4
|
+
Calendar,
|
|
5
|
+
Command,
|
|
6
|
+
Route,
|
|
7
|
+
Runtime,
|
|
8
|
+
Submodel,
|
|
9
|
+
Subscription,
|
|
10
|
+
Update,
|
|
11
|
+
} from 'foldkit'
|
|
12
|
+
import { Document, Html, HtmlBuilder } from 'foldkit/html'
|
|
13
|
+
import { defineMessageUnion } from 'foldkit/message'
|
|
14
|
+
import { UrlRequest, load, pushUrl } from 'foldkit/navigation'
|
|
15
|
+
import { literal, r } from 'foldkit/route'
|
|
16
|
+
import { evo } from 'foldkit/struct'
|
|
17
|
+
import { Url, toString as urlToString } from 'foldkit/url'
|
|
18
|
+
|
|
19
|
+
import { Dialog, Nav } from '@foldkit/ui'
|
|
20
|
+
|
|
21
|
+
import * as Icon from './icon'
|
|
22
|
+
import { uiInit } from './ui/init'
|
|
23
|
+
import { UiMessage } from './ui/message'
|
|
24
|
+
import { UiModel } from './ui/model'
|
|
25
|
+
import * as UiSubscriptions from './ui/subscriptions'
|
|
26
|
+
import { uiUpdate } from './ui/update'
|
|
27
|
+
import * as View from './ui/view'
|
|
28
|
+
|
|
29
|
+
// ROUTE
|
|
30
|
+
|
|
31
|
+
export const HomeRoute = r('Home')
|
|
32
|
+
export const ButtonRoute = r('Button')
|
|
33
|
+
export const CalendarRoute = r('Calendar')
|
|
34
|
+
export const CheckboxRoute = r('Checkbox')
|
|
35
|
+
export const ComboboxRoute = r('Combobox')
|
|
36
|
+
export const DatePickerRoute = r('DatePicker')
|
|
37
|
+
export const DialogRoute = r('Dialog')
|
|
38
|
+
export const DisclosureRoute = r('Disclosure')
|
|
39
|
+
export const DragAndDropRoute = r('DragAndDrop')
|
|
40
|
+
export const FieldsetRoute = r('Fieldset')
|
|
41
|
+
export const FileDropRoute = r('FileDrop')
|
|
42
|
+
export const InputRoute = r('Input')
|
|
43
|
+
export const ListboxRoute = r('Listbox')
|
|
44
|
+
export const MenuRoute = r('Menu')
|
|
45
|
+
export const PopoverRoute = r('Popover')
|
|
46
|
+
export const RadioGroupRoute = r('RadioGroup')
|
|
47
|
+
export const SelectRoute = r('Select')
|
|
48
|
+
export const SliderRoute = r('Slider')
|
|
49
|
+
export const SwitchRoute = r('Switch')
|
|
50
|
+
export const TabsRoute = r('Tabs')
|
|
51
|
+
export const TextareaRoute = r('Textarea')
|
|
52
|
+
export const ToastRoute = r('Toast')
|
|
53
|
+
export const TooltipRoute = r('Tooltip')
|
|
54
|
+
export const AnimationRoute = r('Animation')
|
|
55
|
+
export const VirtualListRoute = r('VirtualList')
|
|
56
|
+
export const NotFoundRoute = r('NotFound', { path: S.String })
|
|
57
|
+
|
|
58
|
+
const AppRoute = S.Union([
|
|
59
|
+
HomeRoute,
|
|
60
|
+
ButtonRoute,
|
|
61
|
+
CalendarRoute,
|
|
62
|
+
CheckboxRoute,
|
|
63
|
+
ComboboxRoute,
|
|
64
|
+
DatePickerRoute,
|
|
65
|
+
DialogRoute,
|
|
66
|
+
DisclosureRoute,
|
|
67
|
+
DragAndDropRoute,
|
|
68
|
+
FieldsetRoute,
|
|
69
|
+
FileDropRoute,
|
|
70
|
+
InputRoute,
|
|
71
|
+
ListboxRoute,
|
|
72
|
+
MenuRoute,
|
|
73
|
+
PopoverRoute,
|
|
74
|
+
RadioGroupRoute,
|
|
75
|
+
SelectRoute,
|
|
76
|
+
SliderRoute,
|
|
77
|
+
SwitchRoute,
|
|
78
|
+
TabsRoute,
|
|
79
|
+
TextareaRoute,
|
|
80
|
+
ToastRoute,
|
|
81
|
+
TooltipRoute,
|
|
82
|
+
AnimationRoute,
|
|
83
|
+
VirtualListRoute,
|
|
84
|
+
NotFoundRoute,
|
|
85
|
+
])
|
|
86
|
+
|
|
87
|
+
type AppRoute = typeof AppRoute.Type
|
|
88
|
+
|
|
89
|
+
const homeRouter = pipe(Route.root, Route.mapTo(HomeRoute))
|
|
90
|
+
const buttonRouter = pipe(literal('button'), Route.mapTo(ButtonRoute))
|
|
91
|
+
const calendarRouter = pipe(literal('calendar'), Route.mapTo(CalendarRoute))
|
|
92
|
+
const checkboxRouter = pipe(literal('checkbox'), Route.mapTo(CheckboxRoute))
|
|
93
|
+
const comboboxRouter = pipe(literal('combobox'), Route.mapTo(ComboboxRoute))
|
|
94
|
+
const datePickerRouter = pipe(
|
|
95
|
+
literal('date-picker'),
|
|
96
|
+
Route.mapTo(DatePickerRoute),
|
|
97
|
+
)
|
|
98
|
+
const dialogRouter = pipe(literal('dialog'), Route.mapTo(DialogRoute))
|
|
99
|
+
const disclosureRouter = pipe(
|
|
100
|
+
literal('disclosure'),
|
|
101
|
+
Route.mapTo(DisclosureRoute),
|
|
102
|
+
)
|
|
103
|
+
const dragAndDropRouter = pipe(
|
|
104
|
+
literal('drag-and-drop'),
|
|
105
|
+
Route.mapTo(DragAndDropRoute),
|
|
106
|
+
)
|
|
107
|
+
const fieldsetRouter = pipe(literal('fieldset'), Route.mapTo(FieldsetRoute))
|
|
108
|
+
const fileDropRouter = pipe(literal('file-drop'), Route.mapTo(FileDropRoute))
|
|
109
|
+
const inputRouter = pipe(literal('input'), Route.mapTo(InputRoute))
|
|
110
|
+
const listboxRouter = pipe(literal('listbox'), Route.mapTo(ListboxRoute))
|
|
111
|
+
const menuRouter = pipe(literal('menu'), Route.mapTo(MenuRoute))
|
|
112
|
+
const popoverRouter = pipe(literal('popover'), Route.mapTo(PopoverRoute))
|
|
113
|
+
const radioGroupRouter = pipe(
|
|
114
|
+
literal('radio-group'),
|
|
115
|
+
Route.mapTo(RadioGroupRoute),
|
|
116
|
+
)
|
|
117
|
+
const selectRouter = pipe(literal('select'), Route.mapTo(SelectRoute))
|
|
118
|
+
const sliderRouter = pipe(literal('slider'), Route.mapTo(SliderRoute))
|
|
119
|
+
const switchRouter = pipe(literal('switch'), Route.mapTo(SwitchRoute))
|
|
120
|
+
const tabsRouter = pipe(literal('tabs'), Route.mapTo(TabsRoute))
|
|
121
|
+
const textareaRouter = pipe(literal('textarea'), Route.mapTo(TextareaRoute))
|
|
122
|
+
const toastRouter = pipe(literal('toast'), Route.mapTo(ToastRoute))
|
|
123
|
+
const tooltipRouter = pipe(literal('tooltip'), Route.mapTo(TooltipRoute))
|
|
124
|
+
const animationRouter = pipe(literal('animation'), Route.mapTo(AnimationRoute))
|
|
125
|
+
const virtualListRouter = pipe(
|
|
126
|
+
literal('virtual-list'),
|
|
127
|
+
Route.mapTo(VirtualListRoute),
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
const routeParser = Route.oneOf(
|
|
131
|
+
buttonRouter,
|
|
132
|
+
calendarRouter,
|
|
133
|
+
checkboxRouter,
|
|
134
|
+
comboboxRouter,
|
|
135
|
+
datePickerRouter,
|
|
136
|
+
dialogRouter,
|
|
137
|
+
disclosureRouter,
|
|
138
|
+
dragAndDropRouter,
|
|
139
|
+
fieldsetRouter,
|
|
140
|
+
fileDropRouter,
|
|
141
|
+
inputRouter,
|
|
142
|
+
listboxRouter,
|
|
143
|
+
menuRouter,
|
|
144
|
+
popoverRouter,
|
|
145
|
+
radioGroupRouter,
|
|
146
|
+
selectRouter,
|
|
147
|
+
sliderRouter,
|
|
148
|
+
switchRouter,
|
|
149
|
+
tabsRouter,
|
|
150
|
+
textareaRouter,
|
|
151
|
+
toastRouter,
|
|
152
|
+
tooltipRouter,
|
|
153
|
+
animationRouter,
|
|
154
|
+
virtualListRouter,
|
|
155
|
+
homeRouter,
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
const urlToAppRoute = Route.parseUrlWithFallback(routeParser, NotFoundRoute)
|
|
159
|
+
|
|
160
|
+
// MODEL
|
|
161
|
+
|
|
162
|
+
export const Model = S.Struct({
|
|
163
|
+
route: AppRoute,
|
|
164
|
+
uiModel: UiModel,
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
export type Model = typeof Model.Type
|
|
168
|
+
|
|
169
|
+
// MESSAGE
|
|
170
|
+
|
|
171
|
+
export const Message = defineMessageUnion({
|
|
172
|
+
CompletedNavigateInternal: {},
|
|
173
|
+
CompletedLoadExternal: {},
|
|
174
|
+
ClickedLink: { request: UrlRequest },
|
|
175
|
+
ChangedUrl: { url: Url },
|
|
176
|
+
GotUiMessage: { message: UiMessage },
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
export type Message = typeof Message.Type
|
|
180
|
+
|
|
181
|
+
// COMMAND
|
|
182
|
+
|
|
183
|
+
const NavigateInternal = Command.define('NavigateInternal', {
|
|
184
|
+
args: { url: S.String },
|
|
185
|
+
messages: [Message.CompletedNavigateInternal],
|
|
186
|
+
execute: ({ url }) =>
|
|
187
|
+
pushUrl(url).pipe(Effect.as(Message.CompletedNavigateInternal())),
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
const LoadExternal = Command.define('LoadExternal', {
|
|
191
|
+
args: { href: S.String },
|
|
192
|
+
messages: [Message.CompletedLoadExternal],
|
|
193
|
+
execute: ({ href }) =>
|
|
194
|
+
load(href).pipe(Effect.as(Message.CompletedLoadExternal())),
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
// INIT
|
|
198
|
+
|
|
199
|
+
export const Flags = S.Struct({
|
|
200
|
+
today: Calendar.CalendarDate,
|
|
201
|
+
})
|
|
202
|
+
|
|
203
|
+
export type Flags = typeof Flags.Type
|
|
204
|
+
|
|
205
|
+
export const flags: Effect.Effect<Flags> = Effect.gen(function* () {
|
|
206
|
+
const today = yield* Calendar.today.local
|
|
207
|
+
return { today }
|
|
208
|
+
})
|
|
209
|
+
|
|
210
|
+
export const init: Runtime.RoutingApplicationInit<Model, Message, Flags> = (
|
|
211
|
+
flags: Flags,
|
|
212
|
+
url: Url,
|
|
213
|
+
) => {
|
|
214
|
+
const [initialUiModel, uiCommands] = uiInit(flags.today)
|
|
215
|
+
|
|
216
|
+
return [
|
|
217
|
+
{
|
|
218
|
+
route: urlToAppRoute(url),
|
|
219
|
+
uiModel: initialUiModel,
|
|
220
|
+
},
|
|
221
|
+
Command.mapMessages(uiCommands, message =>
|
|
222
|
+
Message.GotUiMessage({ message }),
|
|
223
|
+
),
|
|
224
|
+
]
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// UPDATE
|
|
228
|
+
|
|
229
|
+
const toUiMessage = (message: typeof UiMessage.Type): Message =>
|
|
230
|
+
Message.GotUiMessage({ message })
|
|
231
|
+
|
|
232
|
+
const toMobileMenuDialogMessage = (message: Dialog.Message): Message =>
|
|
233
|
+
Message.GotUiMessage({
|
|
234
|
+
message: UiMessage.GotMobileMenuDialogMessage({ message }),
|
|
235
|
+
})
|
|
236
|
+
|
|
237
|
+
const foldUi = Update.foldChild({
|
|
238
|
+
update: uiUpdate,
|
|
239
|
+
read: (model: Model) => Option.some(model.uiModel),
|
|
240
|
+
write: (model, nextUiModel) => evo(model, { uiModel: () => nextUiModel }),
|
|
241
|
+
toParentMessage: toUiMessage,
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
export const update = (model: Model, message: Message) =>
|
|
245
|
+
Message.match<readonly [Model, ReadonlyArray<Command.Command<Message>>]>(
|
|
246
|
+
message,
|
|
247
|
+
{
|
|
248
|
+
CompletedNavigateInternal: () => [model, []],
|
|
249
|
+
CompletedLoadExternal: () => [model, []],
|
|
250
|
+
|
|
251
|
+
ClickedLink: ({ request }) =>
|
|
252
|
+
M.value(request).pipe(
|
|
253
|
+
M.tagsExhaustive({
|
|
254
|
+
Internal: ({
|
|
255
|
+
url,
|
|
256
|
+
}): [
|
|
257
|
+
Model,
|
|
258
|
+
ReadonlyArray<
|
|
259
|
+
Command.Command<typeof Message.CompletedNavigateInternal>
|
|
260
|
+
>,
|
|
261
|
+
] => [model, [NavigateInternal({ url: urlToString(url) })]],
|
|
262
|
+
External: ({
|
|
263
|
+
href,
|
|
264
|
+
}): [
|
|
265
|
+
Model,
|
|
266
|
+
ReadonlyArray<
|
|
267
|
+
Command.Command<typeof Message.CompletedLoadExternal>
|
|
268
|
+
>,
|
|
269
|
+
] => [model, [LoadExternal({ href })]],
|
|
270
|
+
}),
|
|
271
|
+
),
|
|
272
|
+
|
|
273
|
+
ChangedUrl: ({ url }) => {
|
|
274
|
+
const [nextMobileMenuDialog, mobileMenuDialogCommands] = Dialog.close(
|
|
275
|
+
model.uiModel.mobileMenuDialog,
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
return [
|
|
279
|
+
evo(model, {
|
|
280
|
+
route: () => urlToAppRoute(url),
|
|
281
|
+
uiModel: uiModel =>
|
|
282
|
+
evo(uiModel, {
|
|
283
|
+
mobileMenuDialog: () => nextMobileMenuDialog,
|
|
284
|
+
}),
|
|
285
|
+
}),
|
|
286
|
+
Command.mapMessages(
|
|
287
|
+
mobileMenuDialogCommands,
|
|
288
|
+
toMobileMenuDialogMessage,
|
|
289
|
+
),
|
|
290
|
+
]
|
|
291
|
+
},
|
|
292
|
+
|
|
293
|
+
GotUiMessage: ({ message }) => foldUi(model, message),
|
|
294
|
+
},
|
|
295
|
+
)
|
|
296
|
+
|
|
297
|
+
// VIEW
|
|
298
|
+
|
|
299
|
+
type NavItem = Readonly<{
|
|
300
|
+
label: string
|
|
301
|
+
routeTag: string
|
|
302
|
+
href: string
|
|
303
|
+
}>
|
|
304
|
+
|
|
305
|
+
const NAV_ITEMS: ReadonlyArray<NavItem> = [
|
|
306
|
+
{ label: 'Animation', routeTag: 'Animation', href: animationRouter() },
|
|
307
|
+
{ label: 'Button', routeTag: 'Button', href: buttonRouter() },
|
|
308
|
+
{ label: 'Calendar', routeTag: 'Calendar', href: calendarRouter() },
|
|
309
|
+
{ label: 'Checkbox', routeTag: 'Checkbox', href: checkboxRouter() },
|
|
310
|
+
{ label: 'Combobox', routeTag: 'Combobox', href: comboboxRouter() },
|
|
311
|
+
{ label: 'Date Picker', routeTag: 'DatePicker', href: datePickerRouter() },
|
|
312
|
+
{ label: 'Dialog', routeTag: 'Dialog', href: dialogRouter() },
|
|
313
|
+
{ label: 'Disclosure', routeTag: 'Disclosure', href: disclosureRouter() },
|
|
314
|
+
{
|
|
315
|
+
label: 'Drag and Drop',
|
|
316
|
+
routeTag: 'DragAndDrop',
|
|
317
|
+
href: dragAndDropRouter(),
|
|
318
|
+
},
|
|
319
|
+
{ label: 'Fieldset', routeTag: 'Fieldset', href: fieldsetRouter() },
|
|
320
|
+
{ label: 'File Drop', routeTag: 'FileDrop', href: fileDropRouter() },
|
|
321
|
+
{ label: 'Input', routeTag: 'Input', href: inputRouter() },
|
|
322
|
+
{ label: 'Listbox', routeTag: 'Listbox', href: listboxRouter() },
|
|
323
|
+
{ label: 'Menu', routeTag: 'Menu', href: menuRouter() },
|
|
324
|
+
{ label: 'Popover', routeTag: 'Popover', href: popoverRouter() },
|
|
325
|
+
{ label: 'Radio Group', routeTag: 'RadioGroup', href: radioGroupRouter() },
|
|
326
|
+
{ label: 'Select', routeTag: 'Select', href: selectRouter() },
|
|
327
|
+
{ label: 'Slider', routeTag: 'Slider', href: sliderRouter() },
|
|
328
|
+
{ label: 'Switch', routeTag: 'Switch', href: switchRouter() },
|
|
329
|
+
{ label: 'Tabs', routeTag: 'Tabs', href: tabsRouter() },
|
|
330
|
+
{ label: 'Textarea', routeTag: 'Textarea', href: textareaRouter() },
|
|
331
|
+
{ label: 'Toast', routeTag: 'Toast', href: toastRouter() },
|
|
332
|
+
{ label: 'Tooltip', routeTag: 'Tooltip', href: tooltipRouter() },
|
|
333
|
+
{
|
|
334
|
+
label: 'Virtual List',
|
|
335
|
+
routeTag: 'VirtualList',
|
|
336
|
+
href: virtualListRouter(),
|
|
337
|
+
},
|
|
338
|
+
]
|
|
339
|
+
|
|
340
|
+
const NAV_ROUTE_TAGS: ReadonlyArray<string> = Array.map(
|
|
341
|
+
NAV_ITEMS,
|
|
342
|
+
navItem => navItem.routeTag,
|
|
343
|
+
)
|
|
344
|
+
|
|
345
|
+
const navItemHref = (index: number): string =>
|
|
346
|
+
pipe(
|
|
347
|
+
NAV_ITEMS,
|
|
348
|
+
Array.get(index),
|
|
349
|
+
Option.map(navItem => navItem.href),
|
|
350
|
+
Option.getOrElse(() => homeRouter()),
|
|
351
|
+
)
|
|
352
|
+
|
|
353
|
+
const componentNav = (
|
|
354
|
+
currentRoute: AppRoute,
|
|
355
|
+
toView: (render: Nav.RenderInfo) => Html,
|
|
356
|
+
): Html =>
|
|
357
|
+
Nav.view({
|
|
358
|
+
items: NAV_ROUTE_TAGS,
|
|
359
|
+
ariaLabel: 'Components',
|
|
360
|
+
toHref: (_routeTag, index) => navItemHref(index),
|
|
361
|
+
isItemCurrent: routeTag => currentRoute._tag === routeTag,
|
|
362
|
+
toView,
|
|
363
|
+
})
|
|
364
|
+
|
|
365
|
+
const navListView = (
|
|
366
|
+
items: ReadonlyArray<Nav.ItemInfo>,
|
|
367
|
+
linkClassName: (isActive: boolean) => string,
|
|
368
|
+
h: HtmlBuilder<Message>,
|
|
369
|
+
): Html =>
|
|
370
|
+
h.ul(
|
|
371
|
+
[h.Class('flex flex-col gap-0.5')],
|
|
372
|
+
pipe(
|
|
373
|
+
NAV_ITEMS,
|
|
374
|
+
Array.zip(items),
|
|
375
|
+
Array.map(([navItem, item]) =>
|
|
376
|
+
h.li(
|
|
377
|
+
[],
|
|
378
|
+
[
|
|
379
|
+
h.a(
|
|
380
|
+
[...item.link, h.Class(linkClassName(item.isCurrent))],
|
|
381
|
+
[navItem.label],
|
|
382
|
+
),
|
|
383
|
+
],
|
|
384
|
+
),
|
|
385
|
+
),
|
|
386
|
+
),
|
|
387
|
+
)
|
|
388
|
+
|
|
389
|
+
const navLinkClassName = (isActive: boolean): string =>
|
|
390
|
+
clsx(
|
|
391
|
+
'block px-3 py-1.5 rounded-md text-sm transition-colors',
|
|
392
|
+
isActive
|
|
393
|
+
? 'bg-accent-100 text-accent-700'
|
|
394
|
+
: 'text-gray-700 hover:bg-gray-200',
|
|
395
|
+
)
|
|
396
|
+
|
|
397
|
+
const mobileNavLinkClassName = (isActive: boolean): string =>
|
|
398
|
+
clsx(
|
|
399
|
+
'block px-4 py-2.5 rounded-md text-base transition-colors',
|
|
400
|
+
isActive
|
|
401
|
+
? 'bg-accent-100 text-accent-700'
|
|
402
|
+
: 'text-gray-700 hover:bg-gray-200',
|
|
403
|
+
)
|
|
404
|
+
|
|
405
|
+
const sidebarView = (currentRoute: AppRoute, h: HtmlBuilder<Message>): Html =>
|
|
406
|
+
componentNav(currentRoute, ({ nav, items }) =>
|
|
407
|
+
h.nav(
|
|
408
|
+
[
|
|
409
|
+
...nav,
|
|
410
|
+
h.Class(
|
|
411
|
+
'hidden md:flex w-56 shrink-0 border-r border-gray-200 bg-gray-50 p-4 flex-col',
|
|
412
|
+
),
|
|
413
|
+
],
|
|
414
|
+
[
|
|
415
|
+
h.div(
|
|
416
|
+
[h.Class('mb-6')],
|
|
417
|
+
[
|
|
418
|
+
h.a(
|
|
419
|
+
[h.Href(homeRouter()), h.Class('block')],
|
|
420
|
+
[
|
|
421
|
+
h.h1(
|
|
422
|
+
[h.Class('text-lg font-bold text-gray-900')],
|
|
423
|
+
['Foldkit UI'],
|
|
424
|
+
),
|
|
425
|
+
],
|
|
426
|
+
),
|
|
427
|
+
h.span([h.Class('text-xs text-gray-500')], ['Component Showcase']),
|
|
428
|
+
],
|
|
429
|
+
),
|
|
430
|
+
navListView(items, navLinkClassName, h),
|
|
431
|
+
],
|
|
432
|
+
),
|
|
433
|
+
)
|
|
434
|
+
|
|
435
|
+
const mobileMenuContent = (
|
|
436
|
+
currentRoute: AppRoute,
|
|
437
|
+
closeButton: Dialog.RenderInfo['closeButton'],
|
|
438
|
+
h: HtmlBuilder<Message>,
|
|
439
|
+
): Html =>
|
|
440
|
+
h.div(
|
|
441
|
+
[h.Class('flex flex-col h-full')],
|
|
442
|
+
[
|
|
443
|
+
h.div(
|
|
444
|
+
[
|
|
445
|
+
h.Class(
|
|
446
|
+
'flex items-center justify-between border-b border-gray-200 px-4 py-3',
|
|
447
|
+
),
|
|
448
|
+
],
|
|
449
|
+
[
|
|
450
|
+
h.a(
|
|
451
|
+
[h.Href(homeRouter()), h.Class('block')],
|
|
452
|
+
[
|
|
453
|
+
h.div(
|
|
454
|
+
[h.Class('flex flex-col')],
|
|
455
|
+
[
|
|
456
|
+
h.span(
|
|
457
|
+
[h.Class('text-base font-bold text-gray-900')],
|
|
458
|
+
['Foldkit UI'],
|
|
459
|
+
),
|
|
460
|
+
h.span(
|
|
461
|
+
[h.Class('text-xs text-gray-500')],
|
|
462
|
+
['Component Showcase'],
|
|
463
|
+
),
|
|
464
|
+
],
|
|
465
|
+
),
|
|
466
|
+
],
|
|
467
|
+
),
|
|
468
|
+
h.button(
|
|
469
|
+
[
|
|
470
|
+
...closeButton,
|
|
471
|
+
h.Class(
|
|
472
|
+
'p-2 rounded-md hover:bg-gray-200 transition text-gray-700 cursor-pointer',
|
|
473
|
+
),
|
|
474
|
+
h.AriaLabel('Close menu'),
|
|
475
|
+
],
|
|
476
|
+
[Icon.xMark('w-6 h-6')],
|
|
477
|
+
),
|
|
478
|
+
],
|
|
479
|
+
),
|
|
480
|
+
componentNav(currentRoute, ({ nav, items }) =>
|
|
481
|
+
h.nav(
|
|
482
|
+
[
|
|
483
|
+
...nav,
|
|
484
|
+
h.Class('flex-1 overflow-y-auto min-h-0 p-4'),
|
|
485
|
+
h.Tabindex(-1),
|
|
486
|
+
h.Autofocus(true),
|
|
487
|
+
],
|
|
488
|
+
[navListView(items, mobileNavLinkClassName, h)],
|
|
489
|
+
),
|
|
490
|
+
),
|
|
491
|
+
],
|
|
492
|
+
)
|
|
493
|
+
|
|
494
|
+
const mobileHeaderView = (model: Model, h: HtmlBuilder<Message>): Html =>
|
|
495
|
+
h.header(
|
|
496
|
+
[
|
|
497
|
+
h.Class(
|
|
498
|
+
'md:hidden sticky top-0 z-40 flex items-center justify-between border-b border-gray-200 bg-gray-50 px-4 py-3',
|
|
499
|
+
),
|
|
500
|
+
],
|
|
501
|
+
[
|
|
502
|
+
h.a(
|
|
503
|
+
[h.Href(homeRouter()), h.Class('block')],
|
|
504
|
+
[
|
|
505
|
+
h.div(
|
|
506
|
+
[h.Class('flex flex-col')],
|
|
507
|
+
[
|
|
508
|
+
h.span(
|
|
509
|
+
[h.Class('text-base font-bold text-gray-900')],
|
|
510
|
+
['Foldkit UI'],
|
|
511
|
+
),
|
|
512
|
+
h.span(
|
|
513
|
+
[h.Class('text-xs text-gray-500')],
|
|
514
|
+
['Component Showcase'],
|
|
515
|
+
),
|
|
516
|
+
],
|
|
517
|
+
),
|
|
518
|
+
],
|
|
519
|
+
),
|
|
520
|
+
h.button(
|
|
521
|
+
[
|
|
522
|
+
h.Class(
|
|
523
|
+
'p-2 rounded-md hover:bg-gray-200 transition text-gray-700 cursor-pointer',
|
|
524
|
+
),
|
|
525
|
+
h.AriaExpanded(model.uiModel.mobileMenuDialog.isOpen),
|
|
526
|
+
h.AriaLabel('Toggle menu'),
|
|
527
|
+
h.OnClick(toUiMessage(UiMessage.ClickedOpenMobileMenu())),
|
|
528
|
+
],
|
|
529
|
+
[Icon.menu('w-6 h-6')],
|
|
530
|
+
),
|
|
531
|
+
],
|
|
532
|
+
)
|
|
533
|
+
|
|
534
|
+
const mobileMenuView = (model: Model, h: HtmlBuilder<Message>): Html =>
|
|
535
|
+
h.submodel({
|
|
536
|
+
slotId: model.uiModel.mobileMenuDialog.id,
|
|
537
|
+
model: model.uiModel.mobileMenuDialog,
|
|
538
|
+
view: Dialog.view,
|
|
539
|
+
viewInputs: {
|
|
540
|
+
toView: ({ dialog, backdrop, panel, closeButton, isVisible }) =>
|
|
541
|
+
h.dialog(
|
|
542
|
+
[...dialog, h.Class('md:hidden')],
|
|
543
|
+
isVisible
|
|
544
|
+
? [
|
|
545
|
+
h.div([...backdrop, h.Class('fixed inset-0 z-[59]')]),
|
|
546
|
+
h.div(
|
|
547
|
+
[
|
|
548
|
+
...panel,
|
|
549
|
+
h.Class('fixed inset-0 z-[60] bg-white flex flex-col'),
|
|
550
|
+
],
|
|
551
|
+
[mobileMenuContent(model.route, closeButton, h)],
|
|
552
|
+
),
|
|
553
|
+
]
|
|
554
|
+
: [],
|
|
555
|
+
),
|
|
556
|
+
},
|
|
557
|
+
toParentMessage: message => toMobileMenuDialogMessage(message),
|
|
558
|
+
})
|
|
559
|
+
|
|
560
|
+
const homeView = (h: HtmlBuilder<Message>): Html =>
|
|
561
|
+
h.div(
|
|
562
|
+
[h.Class('max-w-2xl')],
|
|
563
|
+
[
|
|
564
|
+
h.h1(
|
|
565
|
+
[h.Class('text-2xl md:text-3xl font-bold text-gray-900 mb-4')],
|
|
566
|
+
['Foldkit UI Showcase'],
|
|
567
|
+
),
|
|
568
|
+
h.p(
|
|
569
|
+
[h.Class('text-gray-600 mb-4')],
|
|
570
|
+
[
|
|
571
|
+
'This is a showcase of every Foldkit UI component. Select a component from the menu to see it in action.',
|
|
572
|
+
],
|
|
573
|
+
),
|
|
574
|
+
h.p(
|
|
575
|
+
[h.Class('text-gray-600')],
|
|
576
|
+
[
|
|
577
|
+
'Each component is headless. You provide the markup and styling via a callback, and Foldkit handles accessibility, keyboard navigation, and state management.',
|
|
578
|
+
],
|
|
579
|
+
),
|
|
580
|
+
],
|
|
581
|
+
)
|
|
582
|
+
|
|
583
|
+
const notFoundView = (path: string, h: HtmlBuilder<Message>): Html =>
|
|
584
|
+
h.div(
|
|
585
|
+
[h.Class('max-w-2xl')],
|
|
586
|
+
[
|
|
587
|
+
h.h1(
|
|
588
|
+
[h.Class('text-2xl md:text-3xl font-bold text-red-600 mb-4')],
|
|
589
|
+
['404 — Page Not Found'],
|
|
590
|
+
),
|
|
591
|
+
h.p(
|
|
592
|
+
[h.Class('text-gray-600 mb-4')],
|
|
593
|
+
[`The path "${path}" was not found.`],
|
|
594
|
+
),
|
|
595
|
+
h.a(
|
|
596
|
+
[h.Href(homeRouter()), h.Class('text-accent-600 hover:underline')],
|
|
597
|
+
['Go Home'],
|
|
598
|
+
),
|
|
599
|
+
],
|
|
600
|
+
)
|
|
601
|
+
|
|
602
|
+
const contentView = (model: Model, h: HtmlBuilder<Message>): Html => {
|
|
603
|
+
const embedUi = (id: string, view: Submodel.View<UiModel, UiMessage>): Html =>
|
|
604
|
+
h.submodel({
|
|
605
|
+
slotId: id,
|
|
606
|
+
model: model.uiModel,
|
|
607
|
+
view,
|
|
608
|
+
toParentMessage: toUiMessage,
|
|
609
|
+
})
|
|
610
|
+
|
|
611
|
+
return M.value(model.route).pipe(
|
|
612
|
+
M.tagsExhaustive({
|
|
613
|
+
Home: () => homeView(h),
|
|
614
|
+
Button: () => embedUi('ui-button', View.button),
|
|
615
|
+
Calendar: () => embedUi('ui-calendar', View.calendar),
|
|
616
|
+
Checkbox: () => embedUi('ui-checkbox', View.checkbox),
|
|
617
|
+
Combobox: () => embedUi('ui-combobox', View.combobox),
|
|
618
|
+
DatePicker: () => embedUi('ui-date-picker', View.datePicker),
|
|
619
|
+
Dialog: () => embedUi('ui-dialog', View.dialog),
|
|
620
|
+
Disclosure: () => embedUi('ui-disclosure', View.disclosure),
|
|
621
|
+
DragAndDrop: () => embedUi('ui-drag-and-drop', View.dragAndDrop),
|
|
622
|
+
Fieldset: () => embedUi('ui-fieldset', View.fieldset),
|
|
623
|
+
FileDrop: () => embedUi('ui-file-drop', View.fileDrop),
|
|
624
|
+
Input: () => embedUi('ui-input', View.input),
|
|
625
|
+
Listbox: () => embedUi('ui-listbox', View.listbox),
|
|
626
|
+
Menu: () => embedUi('ui-menu', View.menu),
|
|
627
|
+
Popover: () => embedUi('ui-popover', View.popover),
|
|
628
|
+
RadioGroup: () => embedUi('ui-radio-group', View.radioGroup),
|
|
629
|
+
Select: () => embedUi('ui-select', View.select),
|
|
630
|
+
Slider: () => embedUi('ui-slider', View.slider),
|
|
631
|
+
Switch: () => embedUi('ui-switch', View.switch_),
|
|
632
|
+
Tabs: () => embedUi('ui-tabs', View.tabs),
|
|
633
|
+
Textarea: () => embedUi('ui-textarea', View.textarea),
|
|
634
|
+
Toast: () => embedUi('ui-toast', View.toast),
|
|
635
|
+
Tooltip: () => embedUi('ui-tooltip', View.tooltip),
|
|
636
|
+
Animation: () => embedUi('ui-animation', View.animation),
|
|
637
|
+
VirtualList: () => embedUi('ui-virtual-list', View.virtualList),
|
|
638
|
+
NotFound: ({ path }) => notFoundView(path, h),
|
|
639
|
+
}),
|
|
640
|
+
)
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
const routeTitle = (route: Model['route']): string =>
|
|
644
|
+
M.value(route).pipe(
|
|
645
|
+
M.tag('Home', () => 'Foldkit UI Showcase'),
|
|
646
|
+
M.orElse(({ _tag }) => `${_tag} | Foldkit UI Showcase`),
|
|
647
|
+
)
|
|
648
|
+
|
|
649
|
+
export const view = (model: Model, h: HtmlBuilder<Message>): Document => ({
|
|
650
|
+
title: routeTitle(model.route),
|
|
651
|
+
body: h.div(
|
|
652
|
+
[h.Class('flex flex-col md:flex-row min-h-screen bg-white')],
|
|
653
|
+
[
|
|
654
|
+
mobileHeaderView(model, h),
|
|
655
|
+
mobileMenuView(model, h),
|
|
656
|
+
sidebarView(model.route, h),
|
|
657
|
+
h.main(
|
|
658
|
+
[h.Class('flex-1 p-4 md:p-8 overflow-auto')],
|
|
659
|
+
[contentView(model, h)],
|
|
660
|
+
),
|
|
661
|
+
],
|
|
662
|
+
),
|
|
663
|
+
})
|
|
664
|
+
|
|
665
|
+
// SUBSCRIPTION
|
|
666
|
+
|
|
667
|
+
export const subscriptions = Subscription.lift(UiSubscriptions.subscriptions)<
|
|
668
|
+
Model,
|
|
669
|
+
Message
|
|
670
|
+
>({
|
|
671
|
+
toChildModel: model => model.uiModel,
|
|
672
|
+
toParentMessage: message => Message.GotUiMessage({ message }),
|
|
673
|
+
})
|