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,177 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Command,
|
|
3
|
+
click,
|
|
4
|
+
expect,
|
|
5
|
+
given,
|
|
6
|
+
label,
|
|
7
|
+
role,
|
|
8
|
+
scene,
|
|
9
|
+
submit,
|
|
10
|
+
text,
|
|
11
|
+
type,
|
|
12
|
+
} from 'foldkit/scene'
|
|
13
|
+
import { describe, test } from 'vitest'
|
|
14
|
+
|
|
15
|
+
import {
|
|
16
|
+
GenerateTodo,
|
|
17
|
+
Message,
|
|
18
|
+
type Model,
|
|
19
|
+
NotEditing,
|
|
20
|
+
SaveTodos,
|
|
21
|
+
update,
|
|
22
|
+
view,
|
|
23
|
+
} from './main'
|
|
24
|
+
|
|
25
|
+
const emptyModel: Model = {
|
|
26
|
+
todos: [],
|
|
27
|
+
newTodoText: '',
|
|
28
|
+
filter: 'All',
|
|
29
|
+
editing: NotEditing(),
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const modelWithTodos: Model = {
|
|
33
|
+
...emptyModel,
|
|
34
|
+
todos: [
|
|
35
|
+
{ id: 'abc', text: 'Buy milk', completed: false, createdAt: 1000 },
|
|
36
|
+
{ id: 'def', text: 'Walk the dog', completed: false, createdAt: 2000 },
|
|
37
|
+
{ id: 'ghi', text: 'Done task', completed: true, createdAt: 3000 },
|
|
38
|
+
],
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
describe('view', () => {
|
|
42
|
+
test('empty state shows heading and placeholder message', () => {
|
|
43
|
+
scene(
|
|
44
|
+
{ update, view },
|
|
45
|
+
given(emptyModel),
|
|
46
|
+
expect(role('heading', { name: 'Todo App' })).toExist(),
|
|
47
|
+
expect(text('No todos yet. Add one above!')).toExist(),
|
|
48
|
+
)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
test('renders existing todos', () => {
|
|
52
|
+
scene(
|
|
53
|
+
{ update, view },
|
|
54
|
+
given(modelWithTodos),
|
|
55
|
+
expect(text('Buy milk')).toExist(),
|
|
56
|
+
expect(text('Walk the dog')).toExist(),
|
|
57
|
+
expect(text('Done task')).toExist(),
|
|
58
|
+
expect(role('status')).toContainText('2 active, 1 completed'),
|
|
59
|
+
)
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
test('add a todo through the form', () => {
|
|
63
|
+
const addedTodo = {
|
|
64
|
+
id: 'new-1',
|
|
65
|
+
text: 'Write tests',
|
|
66
|
+
completed: false,
|
|
67
|
+
createdAt: 5000,
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
scene(
|
|
71
|
+
{ update, view },
|
|
72
|
+
given(emptyModel),
|
|
73
|
+
type(label('New todo'), 'Write tests'),
|
|
74
|
+
submit(role('form')),
|
|
75
|
+
Command.expectExact(GenerateTodo),
|
|
76
|
+
Command.resolve(
|
|
77
|
+
GenerateTodo,
|
|
78
|
+
Message.CompletedGenerateTodo({
|
|
79
|
+
id: 'new-1',
|
|
80
|
+
timestamp: 5000,
|
|
81
|
+
text: 'Write tests',
|
|
82
|
+
}),
|
|
83
|
+
),
|
|
84
|
+
Command.expectExact(SaveTodos),
|
|
85
|
+
Command.resolve(
|
|
86
|
+
SaveTodos,
|
|
87
|
+
Message.SucceededSaveTodos({ todos: [addedTodo] }),
|
|
88
|
+
),
|
|
89
|
+
expect(text('Write tests')).toExist(),
|
|
90
|
+
expect(label('New todo')).toHaveValue(''),
|
|
91
|
+
)
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
test('toggle a todo by clicking its checkbox', () => {
|
|
95
|
+
const toggledTodos = modelWithTodos.todos.map(todo =>
|
|
96
|
+
todo.id === 'abc' ? { ...todo, completed: true } : todo,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
scene(
|
|
100
|
+
{ update, view },
|
|
101
|
+
given(modelWithTodos),
|
|
102
|
+
click(label('Buy milk')),
|
|
103
|
+
Command.expectExact(SaveTodos),
|
|
104
|
+
Command.resolve(
|
|
105
|
+
SaveTodos,
|
|
106
|
+
Message.SucceededSaveTodos({ todos: toggledTodos }),
|
|
107
|
+
),
|
|
108
|
+
expect(role('status')).toContainText('1 active, 2 completed'),
|
|
109
|
+
)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
test('delete a todo', () => {
|
|
113
|
+
const remainingTodos = modelWithTodos.todos.filter(({ id }) => id !== 'abc')
|
|
114
|
+
|
|
115
|
+
scene(
|
|
116
|
+
{ update, view },
|
|
117
|
+
given(modelWithTodos),
|
|
118
|
+
click(role('button', { name: 'Delete Buy milk' })),
|
|
119
|
+
Command.expectExact(SaveTodos),
|
|
120
|
+
Command.resolve(
|
|
121
|
+
SaveTodos,
|
|
122
|
+
Message.SucceededSaveTodos({ todos: remainingTodos }),
|
|
123
|
+
),
|
|
124
|
+
expect(text('Buy milk')).toBeAbsent(),
|
|
125
|
+
expect(text('Walk the dog')).toExist(),
|
|
126
|
+
)
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
test('clear completed removes done todos', () => {
|
|
130
|
+
const activeTodos = modelWithTodos.todos.filter(
|
|
131
|
+
({ completed }) => !completed,
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
scene(
|
|
135
|
+
{ update, view },
|
|
136
|
+
given(modelWithTodos),
|
|
137
|
+
click(role('button', { name: 'Clear 1 completed' })),
|
|
138
|
+
Command.expectExact(SaveTodos),
|
|
139
|
+
Command.resolve(
|
|
140
|
+
SaveTodos,
|
|
141
|
+
Message.SucceededSaveTodos({ todos: activeTodos }),
|
|
142
|
+
),
|
|
143
|
+
expect(text('Done task')).toBeAbsent(),
|
|
144
|
+
expect(role('status')).toContainText('2 active, 0 completed'),
|
|
145
|
+
)
|
|
146
|
+
})
|
|
147
|
+
|
|
148
|
+
test('mark all complete toggles all todos', () => {
|
|
149
|
+
const allCompletedTodos = modelWithTodos.todos.map(todo => ({
|
|
150
|
+
...todo,
|
|
151
|
+
completed: true,
|
|
152
|
+
}))
|
|
153
|
+
|
|
154
|
+
scene(
|
|
155
|
+
{ update, view },
|
|
156
|
+
given(modelWithTodos),
|
|
157
|
+
click(role('button', { name: 'Mark all complete' })),
|
|
158
|
+
Command.expectExact(SaveTodos),
|
|
159
|
+
Command.resolve(
|
|
160
|
+
SaveTodos,
|
|
161
|
+
Message.SucceededSaveTodos({ todos: allCompletedTodos }),
|
|
162
|
+
),
|
|
163
|
+
expect(role('status')).toContainText('0 active, 3 completed'),
|
|
164
|
+
)
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
test('keeps in-memory changes when saving fails', () => {
|
|
168
|
+
scene(
|
|
169
|
+
{ update, view },
|
|
170
|
+
given(modelWithTodos),
|
|
171
|
+
click(label('Buy milk')),
|
|
172
|
+
Command.expectExact(SaveTodos),
|
|
173
|
+
Command.resolve(SaveTodos, Message.FailedSaveTodos()),
|
|
174
|
+
expect(role('status')).toContainText('1 active, 2 completed'),
|
|
175
|
+
)
|
|
176
|
+
})
|
|
177
|
+
})
|
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { Array, Option } from 'effect'
|
|
2
|
+
import { Command, given, message, model, story } from 'foldkit/story'
|
|
3
|
+
import { describe, expect, test } from 'vitest'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
Editing,
|
|
7
|
+
GenerateTodo,
|
|
8
|
+
Message,
|
|
9
|
+
type Model,
|
|
10
|
+
NotEditing,
|
|
11
|
+
SaveTodos,
|
|
12
|
+
update,
|
|
13
|
+
} from './main'
|
|
14
|
+
|
|
15
|
+
const emptyModel: Model = {
|
|
16
|
+
todos: [],
|
|
17
|
+
newTodoText: '',
|
|
18
|
+
filter: 'All',
|
|
19
|
+
editing: NotEditing(),
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const buyMilk = {
|
|
23
|
+
id: 'abc',
|
|
24
|
+
text: 'Buy milk',
|
|
25
|
+
completed: false,
|
|
26
|
+
createdAt: 1000,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const walkDog = {
|
|
30
|
+
id: 'def',
|
|
31
|
+
text: 'Walk the dog',
|
|
32
|
+
completed: false,
|
|
33
|
+
createdAt: 2000,
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const doneTask = {
|
|
37
|
+
id: 'ghi',
|
|
38
|
+
text: 'Done task',
|
|
39
|
+
completed: true,
|
|
40
|
+
createdAt: 3000,
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const modelWithTodos: Model = {
|
|
44
|
+
...emptyModel,
|
|
45
|
+
todos: [buyMilk, walkDog, doneTask],
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
describe('update', () => {
|
|
49
|
+
describe('add todo', () => {
|
|
50
|
+
test('AddedTodo with text produces a GenerateTodo Command', () => {
|
|
51
|
+
story(
|
|
52
|
+
update,
|
|
53
|
+
given({ ...emptyModel, newTodoText: 'Buy milk' }),
|
|
54
|
+
message(Message.AddedTodo()),
|
|
55
|
+
Command.expectHas(GenerateTodo),
|
|
56
|
+
Command.resolve(
|
|
57
|
+
GenerateTodo,
|
|
58
|
+
Message.CompletedGenerateTodo({
|
|
59
|
+
id: 'abc',
|
|
60
|
+
timestamp: 1000,
|
|
61
|
+
text: 'Buy milk',
|
|
62
|
+
}),
|
|
63
|
+
),
|
|
64
|
+
Command.resolve(
|
|
65
|
+
SaveTodos,
|
|
66
|
+
Message.SucceededSaveTodos({
|
|
67
|
+
todos: [
|
|
68
|
+
{
|
|
69
|
+
id: 'abc',
|
|
70
|
+
text: 'Buy milk',
|
|
71
|
+
completed: false,
|
|
72
|
+
createdAt: 1000,
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
}),
|
|
76
|
+
),
|
|
77
|
+
model(model => {
|
|
78
|
+
expect(model.todos).toHaveLength(1)
|
|
79
|
+
expect(model.todos[0]?.text).toBe('Buy milk')
|
|
80
|
+
expect(model.todos[0]?.completed).toBe(false)
|
|
81
|
+
expect(model.newTodoText).toBe('')
|
|
82
|
+
}),
|
|
83
|
+
)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
test('AddedTodo with empty text is ignored', () => {
|
|
87
|
+
story(
|
|
88
|
+
update,
|
|
89
|
+
given({ ...emptyModel, newTodoText: '' }),
|
|
90
|
+
message(Message.AddedTodo()),
|
|
91
|
+
Command.expectNone(),
|
|
92
|
+
)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
test('AddedTodo with whitespace-only text is ignored', () => {
|
|
96
|
+
story(
|
|
97
|
+
update,
|
|
98
|
+
given({ ...emptyModel, newTodoText: ' ' }),
|
|
99
|
+
message(Message.AddedTodo()),
|
|
100
|
+
Command.expectNone(),
|
|
101
|
+
)
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
test('UpdatedNewTodo updates the input text', () => {
|
|
105
|
+
story(
|
|
106
|
+
update,
|
|
107
|
+
given(emptyModel),
|
|
108
|
+
message(Message.UpdatedNewTodo({ text: 'Walk' })),
|
|
109
|
+
model(model => {
|
|
110
|
+
expect(model.newTodoText).toBe('Walk')
|
|
111
|
+
}),
|
|
112
|
+
)
|
|
113
|
+
})
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
describe('toggle and delete', () => {
|
|
117
|
+
test('ToggledTodo flips the completed state', () => {
|
|
118
|
+
const toggledTodos = modelWithTodos.todos.map(todo =>
|
|
119
|
+
todo.id === 'abc' ? { ...todo, completed: true } : todo,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
story(
|
|
123
|
+
update,
|
|
124
|
+
given(modelWithTodos),
|
|
125
|
+
message(Message.ToggledTodo({ id: 'abc' })),
|
|
126
|
+
Command.resolve(
|
|
127
|
+
SaveTodos,
|
|
128
|
+
Message.SucceededSaveTodos({ todos: toggledTodos }),
|
|
129
|
+
),
|
|
130
|
+
model(model => {
|
|
131
|
+
const todo = Array.findFirst(model.todos, ({ id }) => id === 'abc')
|
|
132
|
+
expect(Option.map(todo, ({ completed }) => completed)).toStrictEqual(
|
|
133
|
+
Option.some(true),
|
|
134
|
+
)
|
|
135
|
+
}),
|
|
136
|
+
)
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
test('ToggledTodo on completed todo marks it active', () => {
|
|
140
|
+
const toggledTodos = modelWithTodos.todos.map(todo =>
|
|
141
|
+
todo.id === 'ghi' ? { ...todo, completed: false } : todo,
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
story(
|
|
145
|
+
update,
|
|
146
|
+
given(modelWithTodos),
|
|
147
|
+
message(Message.ToggledTodo({ id: 'ghi' })),
|
|
148
|
+
Command.resolve(
|
|
149
|
+
SaveTodos,
|
|
150
|
+
Message.SucceededSaveTodos({ todos: toggledTodos }),
|
|
151
|
+
),
|
|
152
|
+
model(model => {
|
|
153
|
+
const todo = Array.findFirst(model.todos, ({ id }) => id === 'ghi')
|
|
154
|
+
expect(Option.map(todo, ({ completed }) => completed)).toStrictEqual(
|
|
155
|
+
Option.some(false),
|
|
156
|
+
)
|
|
157
|
+
}),
|
|
158
|
+
)
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
test('DeletedTodo removes the todo and saves', () => {
|
|
162
|
+
const remainingTodos = modelWithTodos.todos.filter(
|
|
163
|
+
({ id }) => id !== 'abc',
|
|
164
|
+
)
|
|
165
|
+
|
|
166
|
+
story(
|
|
167
|
+
update,
|
|
168
|
+
given(modelWithTodos),
|
|
169
|
+
message(Message.DeletedTodo({ id: 'abc' })),
|
|
170
|
+
Command.resolve(
|
|
171
|
+
SaveTodos,
|
|
172
|
+
Message.SucceededSaveTodos({ todos: remainingTodos }),
|
|
173
|
+
),
|
|
174
|
+
model(model => {
|
|
175
|
+
expect(model.todos).toHaveLength(2)
|
|
176
|
+
expect(
|
|
177
|
+
Array.findFirst(model.todos, ({ id }) => id === 'abc'),
|
|
178
|
+
).toStrictEqual(Option.none())
|
|
179
|
+
}),
|
|
180
|
+
)
|
|
181
|
+
})
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
describe('editing', () => {
|
|
185
|
+
test('StartedEditing enters editing state with the todo text', () => {
|
|
186
|
+
story(
|
|
187
|
+
update,
|
|
188
|
+
given(modelWithTodos),
|
|
189
|
+
message(Message.StartedEditing({ id: 'abc' })),
|
|
190
|
+
model(model => {
|
|
191
|
+
expect(model.editing).toStrictEqual(
|
|
192
|
+
Editing({ id: 'abc', text: 'Buy milk' }),
|
|
193
|
+
)
|
|
194
|
+
}),
|
|
195
|
+
)
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
test('UpdatedEditingTodo updates the editing text', () => {
|
|
199
|
+
const editingModel: Model = {
|
|
200
|
+
...modelWithTodos,
|
|
201
|
+
editing: Editing({ id: 'abc', text: 'Buy milk' }),
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
story(
|
|
205
|
+
update,
|
|
206
|
+
given(editingModel),
|
|
207
|
+
message(Message.UpdatedEditingTodo({ text: 'Buy oat milk' })),
|
|
208
|
+
model(model => {
|
|
209
|
+
expect(model.editing).toStrictEqual(
|
|
210
|
+
Editing({ id: 'abc', text: 'Buy oat milk' }),
|
|
211
|
+
)
|
|
212
|
+
}),
|
|
213
|
+
)
|
|
214
|
+
})
|
|
215
|
+
|
|
216
|
+
test('SavedEdit updates the todo text and exits editing', () => {
|
|
217
|
+
const editingModel: Model = {
|
|
218
|
+
...modelWithTodos,
|
|
219
|
+
editing: Editing({ id: 'abc', text: 'Buy oat milk' }),
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const editedTodos = modelWithTodos.todos.map(todo =>
|
|
223
|
+
todo.id === 'abc' ? { ...todo, text: 'Buy oat milk' } : todo,
|
|
224
|
+
)
|
|
225
|
+
|
|
226
|
+
story(
|
|
227
|
+
update,
|
|
228
|
+
given(editingModel),
|
|
229
|
+
message(Message.SavedEdit()),
|
|
230
|
+
Command.resolve(
|
|
231
|
+
SaveTodos,
|
|
232
|
+
Message.SucceededSaveTodos({ todos: editedTodos }),
|
|
233
|
+
),
|
|
234
|
+
model(model => {
|
|
235
|
+
const todo = Array.findFirst(model.todos, ({ id }) => id === 'abc')
|
|
236
|
+
expect(Option.map(todo, ({ text }) => text)).toStrictEqual(
|
|
237
|
+
Option.some('Buy oat milk'),
|
|
238
|
+
)
|
|
239
|
+
expect(model.editing).toStrictEqual(NotEditing())
|
|
240
|
+
}),
|
|
241
|
+
)
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
test('SavedEdit with empty text exits editing without saving', () => {
|
|
245
|
+
const editingModel: Model = {
|
|
246
|
+
...modelWithTodos,
|
|
247
|
+
editing: Editing({ id: 'abc', text: ' ' }),
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
story(
|
|
251
|
+
update,
|
|
252
|
+
given(editingModel),
|
|
253
|
+
message(Message.SavedEdit()),
|
|
254
|
+
model(model => {
|
|
255
|
+
const todo = Array.findFirst(model.todos, ({ id }) => id === 'abc')
|
|
256
|
+
expect(Option.map(todo, ({ text }) => text)).toStrictEqual(
|
|
257
|
+
Option.some('Buy milk'),
|
|
258
|
+
)
|
|
259
|
+
expect(model.editing).toStrictEqual(NotEditing())
|
|
260
|
+
}),
|
|
261
|
+
Command.expectNone(),
|
|
262
|
+
)
|
|
263
|
+
})
|
|
264
|
+
|
|
265
|
+
test('CancelledEdit exits editing without changes', () => {
|
|
266
|
+
const editingModel: Model = {
|
|
267
|
+
...modelWithTodos,
|
|
268
|
+
editing: Editing({ id: 'abc', text: 'Changed text' }),
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
story(
|
|
272
|
+
update,
|
|
273
|
+
given(editingModel),
|
|
274
|
+
message(Message.CancelledEdit()),
|
|
275
|
+
model(model => {
|
|
276
|
+
const todo = Array.findFirst(model.todos, ({ id }) => id === 'abc')
|
|
277
|
+
expect(Option.map(todo, ({ text }) => text)).toStrictEqual(
|
|
278
|
+
Option.some('Buy milk'),
|
|
279
|
+
)
|
|
280
|
+
expect(model.editing).toStrictEqual(NotEditing())
|
|
281
|
+
}),
|
|
282
|
+
)
|
|
283
|
+
})
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
describe('bulk operations', () => {
|
|
287
|
+
test('ToggledAll marks all todos completed when some are active', () => {
|
|
288
|
+
const allCompletedTodos = modelWithTodos.todos.map(todo => ({
|
|
289
|
+
...todo,
|
|
290
|
+
completed: true,
|
|
291
|
+
}))
|
|
292
|
+
|
|
293
|
+
story(
|
|
294
|
+
update,
|
|
295
|
+
given(modelWithTodos),
|
|
296
|
+
message(Message.ToggledAll()),
|
|
297
|
+
Command.resolve(
|
|
298
|
+
SaveTodos,
|
|
299
|
+
Message.SucceededSaveTodos({ todos: allCompletedTodos }),
|
|
300
|
+
),
|
|
301
|
+
model(model => {
|
|
302
|
+
expect(Array.every(model.todos, ({ completed }) => completed)).toBe(
|
|
303
|
+
true,
|
|
304
|
+
)
|
|
305
|
+
}),
|
|
306
|
+
)
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
test('ToggledAll marks all todos active when all are completed', () => {
|
|
310
|
+
const allCompletedModel: Model = {
|
|
311
|
+
...emptyModel,
|
|
312
|
+
todos: modelWithTodos.todos.map(todo => ({
|
|
313
|
+
...todo,
|
|
314
|
+
completed: true,
|
|
315
|
+
})),
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
const allActiveTodos = allCompletedModel.todos.map(todo => ({
|
|
319
|
+
...todo,
|
|
320
|
+
completed: false,
|
|
321
|
+
}))
|
|
322
|
+
|
|
323
|
+
story(
|
|
324
|
+
update,
|
|
325
|
+
given(allCompletedModel),
|
|
326
|
+
message(Message.ToggledAll()),
|
|
327
|
+
Command.resolve(
|
|
328
|
+
SaveTodos,
|
|
329
|
+
Message.SucceededSaveTodos({ todos: allActiveTodos }),
|
|
330
|
+
),
|
|
331
|
+
model(model => {
|
|
332
|
+
expect(Array.every(model.todos, ({ completed }) => !completed)).toBe(
|
|
333
|
+
true,
|
|
334
|
+
)
|
|
335
|
+
}),
|
|
336
|
+
)
|
|
337
|
+
})
|
|
338
|
+
|
|
339
|
+
test('ClearedCompleted removes only completed todos', () => {
|
|
340
|
+
const activeTodos = modelWithTodos.todos.filter(
|
|
341
|
+
({ completed }) => !completed,
|
|
342
|
+
)
|
|
343
|
+
|
|
344
|
+
story(
|
|
345
|
+
update,
|
|
346
|
+
given(modelWithTodos),
|
|
347
|
+
message(Message.ClearedCompleted()),
|
|
348
|
+
Command.resolve(
|
|
349
|
+
SaveTodos,
|
|
350
|
+
Message.SucceededSaveTodos({ todos: activeTodos }),
|
|
351
|
+
),
|
|
352
|
+
model(model => {
|
|
353
|
+
expect(model.todos).toHaveLength(2)
|
|
354
|
+
expect(Array.every(model.todos, ({ completed }) => !completed)).toBe(
|
|
355
|
+
true,
|
|
356
|
+
)
|
|
357
|
+
}),
|
|
358
|
+
)
|
|
359
|
+
})
|
|
360
|
+
})
|
|
361
|
+
|
|
362
|
+
describe('filter', () => {
|
|
363
|
+
test('SelectedFilter changes the active filter', () => {
|
|
364
|
+
story(
|
|
365
|
+
update,
|
|
366
|
+
given(modelWithTodos),
|
|
367
|
+
message(Message.SelectedFilter({ filter: 'Active' })),
|
|
368
|
+
model(model => {
|
|
369
|
+
expect(model.filter).toBe('Active')
|
|
370
|
+
}),
|
|
371
|
+
)
|
|
372
|
+
})
|
|
373
|
+
})
|
|
374
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import 'tailwindcss';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "ui-showcase",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"typecheck": "tsc --noEmit",
|
|
9
|
+
"test": "vitest run"
|
|
10
|
+
},
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@effect/platform-browser": "4.0.0-rc.109",
|
|
13
|
+
"@foldkit/ui": "workspace:*",
|
|
14
|
+
"@tailwindcss/vite": "^4.3.1",
|
|
15
|
+
"clsx": "^2.1.1",
|
|
16
|
+
"effect": "4.0.0-rc.109",
|
|
17
|
+
"foldkit": "workspace:*",
|
|
18
|
+
"tailwindcss": "^4.3.1"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@foldkit/devtools": "workspace:*",
|
|
22
|
+
"@foldkit/vite-plugin": "workspace:*",
|
|
23
|
+
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
24
|
+
"happy-dom": "^20.10.4",
|
|
25
|
+
"prettier": "^3.8.4",
|
|
26
|
+
"typescript": "^6.0.3",
|
|
27
|
+
"vite": "^8.0.16",
|
|
28
|
+
"vitest": "^4.1.9"
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Runtime } from 'foldkit'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Flags,
|
|
5
|
+
Message,
|
|
6
|
+
Model,
|
|
7
|
+
flags,
|
|
8
|
+
init,
|
|
9
|
+
subscriptions,
|
|
10
|
+
update,
|
|
11
|
+
view,
|
|
12
|
+
} from './main'
|
|
13
|
+
|
|
14
|
+
const application = Runtime.makeApplication({
|
|
15
|
+
Model,
|
|
16
|
+
Flags,
|
|
17
|
+
init,
|
|
18
|
+
update,
|
|
19
|
+
view,
|
|
20
|
+
subscriptions,
|
|
21
|
+
container: document.getElementById('root'),
|
|
22
|
+
routing: {
|
|
23
|
+
onUrlRequest: request => Message.ClickedLink({ request }),
|
|
24
|
+
onUrlChange: url => Message.ChangedUrl({ url }),
|
|
25
|
+
},
|
|
26
|
+
devTools: {
|
|
27
|
+
Message,
|
|
28
|
+
},
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
Runtime.run(application, { flags })
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Html, inertHtml as ih } from 'foldkit/html'
|
|
2
|
+
|
|
3
|
+
const heroIcon = (className: string, strokeWidth: string, d: string): Html =>
|
|
4
|
+
ih.svg(
|
|
5
|
+
[
|
|
6
|
+
ih.AriaHidden(true),
|
|
7
|
+
ih.Class(className),
|
|
8
|
+
ih.Xmlns('http://www.w3.org/2000/svg'),
|
|
9
|
+
ih.Fill('none'),
|
|
10
|
+
ih.ViewBox('0 0 24 24'),
|
|
11
|
+
ih.StrokeWidth(strokeWidth),
|
|
12
|
+
ih.Stroke('currentColor'),
|
|
13
|
+
],
|
|
14
|
+
[ih.path([ih.StrokeLinecap('round'), ih.StrokeLinejoin('round'), ih.D(d)])],
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
export const chevronDown = (className: string = 'w-6 h-6'): Html =>
|
|
18
|
+
heroIcon(className, '1.5', 'M19.5 8.25l-7.5 7.5-7.5-7.5')
|
|
19
|
+
|
|
20
|
+
export const chevronLeft = (className: string = 'w-6 h-6'): Html =>
|
|
21
|
+
heroIcon(className, '1.5', 'M15.75 19.5L8.25 12l7.5-7.5')
|
|
22
|
+
|
|
23
|
+
export const chevronRight = (className: string = 'w-6 h-6'): Html =>
|
|
24
|
+
heroIcon(className, '1.5', 'm8.25 4.5 7.5 7.5-7.5 7.5')
|
|
25
|
+
|
|
26
|
+
export const check = (className: string = 'w-6 h-6'): Html =>
|
|
27
|
+
heroIcon(className, '2', 'M4.5 12.75l6 6 9-13.5')
|
|
28
|
+
|
|
29
|
+
export const pencil = (className: string = 'w-5 h-5'): Html =>
|
|
30
|
+
heroIcon(
|
|
31
|
+
className,
|
|
32
|
+
'1.5',
|
|
33
|
+
'm16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L6.832 19.82a4.5 4.5 0 0 1-1.897 1.13l-2.685.8.8-2.685a4.5 4.5 0 0 1 1.13-1.897L16.863 4.487Zm0 0L19.5 7.125',
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
export const documentDuplicate = (className: string = 'w-5 h-5'): Html =>
|
|
37
|
+
heroIcon(
|
|
38
|
+
className,
|
|
39
|
+
'1.5',
|
|
40
|
+
'M15.75 17.25v3.375c0 .621-.504 1.125-1.125 1.125h-9.75a1.125 1.125 0 0 1-1.125-1.125V7.875c0-.621.504-1.125 1.125-1.125H6.75a9.06 9.06 0 0 1 1.5.124m7.5 10.376h3.375c.621 0 1.125-.504 1.125-1.125V11.25c0-4.46-3.243-8.161-7.5-8.876a9.06 9.06 0 0 0-1.5-.124H9.375c-.621 0-1.125.504-1.125 1.125v3.5m7.5 10.375H9.375a1.125 1.125 0 0 1-1.125-1.125v-9.25m12 6.625v-1.875a3.375 3.375 0 0 0-3.375-3.375h-1.5a1.125 1.125 0 0 1-1.125-1.125v-1.5a3.375 3.375 0 0 0-3.375-3.375H9.75',
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
export const archiveBox = (className: string = 'w-5 h-5'): Html =>
|
|
44
|
+
heroIcon(
|
|
45
|
+
className,
|
|
46
|
+
'1.5',
|
|
47
|
+
'm20.25 7.5-.625 10.632a2.25 2.25 0 0 1-2.247 2.118H6.622a2.25 2.25 0 0 1-2.247-2.118L3.75 7.5M10 11.25h4M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H2.25c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125Z',
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
export const arrowRight = (className: string = 'w-5 h-5'): Html =>
|
|
51
|
+
heroIcon(className, '1.5', 'M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3')
|
|
52
|
+
|
|
53
|
+
export const trash = (className: string = 'w-5 h-5'): Html =>
|
|
54
|
+
heroIcon(
|
|
55
|
+
className,
|
|
56
|
+
'1.5',
|
|
57
|
+
'm14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0',
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
export const menu = (className: string = 'w-6 h-6'): Html =>
|
|
61
|
+
heroIcon(className, '1.5', 'M3.75 6.75h16.5M3.75 12h16.5m-16.5 5.25h16.5')
|
|
62
|
+
|
|
63
|
+
export const xMark = (className: string = 'w-6 h-6'): Html =>
|
|
64
|
+
heroIcon(className, '1.5', 'M6 18 18 6M6 6l12 12')
|