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,461 @@
|
|
|
1
|
+
import { Option } from 'effect'
|
|
2
|
+
import { Command, given, message, model, story } from 'foldkit/story'
|
|
3
|
+
import { generateKeyBetween } from 'fractional-indexing'
|
|
4
|
+
import { describe, expect, test } from 'vitest'
|
|
5
|
+
|
|
6
|
+
import { DragAndDrop } from '@foldkit/ui'
|
|
7
|
+
import { Message as DragAndDropMessage } from '@foldkit/ui/dragAndDrop'
|
|
8
|
+
|
|
9
|
+
import { FocusAddCardInput, GenerateCardId, SaveBoard } from './command'
|
|
10
|
+
import { Column } from './domain'
|
|
11
|
+
import type { Card } from './domain/card'
|
|
12
|
+
import { Message } from './message'
|
|
13
|
+
import type { Model } from './model'
|
|
14
|
+
import { update } from './update'
|
|
15
|
+
|
|
16
|
+
const card = (id: string, title: string, sortKey: string): Card => ({
|
|
17
|
+
id,
|
|
18
|
+
title,
|
|
19
|
+
description: '',
|
|
20
|
+
sortKey,
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
const k1 = generateKeyBetween(null, null)
|
|
24
|
+
const k2 = generateKeyBetween(k1, null)
|
|
25
|
+
const k3 = generateKeyBetween(k2, null)
|
|
26
|
+
const k4 = generateKeyBetween(k3, null)
|
|
27
|
+
|
|
28
|
+
const testColumns: ReadonlyArray<Column.Column> = [
|
|
29
|
+
{
|
|
30
|
+
id: 'todo',
|
|
31
|
+
name: 'To Do',
|
|
32
|
+
cards: [
|
|
33
|
+
card('card-1', 'Write tests', k1),
|
|
34
|
+
card('card-2', 'Fix bug', k2),
|
|
35
|
+
card('card-3', 'Add feature', k3),
|
|
36
|
+
card('card-4', 'Update docs', k4),
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: 'in-progress',
|
|
41
|
+
name: 'In Progress',
|
|
42
|
+
cards: [
|
|
43
|
+
card('card-5', 'Review PR', k1),
|
|
44
|
+
card('card-6', 'Deploy staging', k2),
|
|
45
|
+
],
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 'done',
|
|
49
|
+
name: 'Done',
|
|
50
|
+
cards: [card('card-7', 'Ship v1', k1)],
|
|
51
|
+
},
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
const emptyModel: Model = {
|
|
55
|
+
columns: testColumns,
|
|
56
|
+
dragAndDrop: DragAndDrop.init({ id: 'kanban' }),
|
|
57
|
+
maybeNewCardColumnId: Option.none(),
|
|
58
|
+
newCardTitle: '',
|
|
59
|
+
announcement: '',
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
describe('update', () => {
|
|
63
|
+
describe('add card', () => {
|
|
64
|
+
const acknowledgeFocusInput = Command.resolve(
|
|
65
|
+
FocusAddCardInput,
|
|
66
|
+
Message.CompletedFocusAddCardInput(),
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
test('ClickedAddCard opens the add card form for the column', () => {
|
|
70
|
+
story(
|
|
71
|
+
update,
|
|
72
|
+
given(emptyModel),
|
|
73
|
+
message(Message.ClickedAddCard({ columnId: 'todo' })),
|
|
74
|
+
acknowledgeFocusInput,
|
|
75
|
+
model(model => {
|
|
76
|
+
expect(model.maybeNewCardColumnId).toStrictEqual(Option.some('todo'))
|
|
77
|
+
expect(model.newCardTitle).toBe('')
|
|
78
|
+
}),
|
|
79
|
+
)
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
test('ChangedNewCardTitle updates the title', () => {
|
|
83
|
+
story(
|
|
84
|
+
update,
|
|
85
|
+
given(emptyModel),
|
|
86
|
+
message(Message.ClickedAddCard({ columnId: 'todo' })),
|
|
87
|
+
acknowledgeFocusInput,
|
|
88
|
+
message(Message.ChangedNewCardTitle({ value: 'New task' })),
|
|
89
|
+
model(model => {
|
|
90
|
+
expect(model.newCardTitle).toBe('New task')
|
|
91
|
+
}),
|
|
92
|
+
)
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
test('SubmittedNewCard adds card to the column and saves', () => {
|
|
96
|
+
story(
|
|
97
|
+
update,
|
|
98
|
+
given(emptyModel),
|
|
99
|
+
message(Message.ClickedAddCard({ columnId: 'done' })),
|
|
100
|
+
acknowledgeFocusInput,
|
|
101
|
+
message(Message.ChangedNewCardTitle({ value: 'Ship it' })),
|
|
102
|
+
message(Message.SubmittedNewCard()),
|
|
103
|
+
Command.resolve(
|
|
104
|
+
GenerateCardId,
|
|
105
|
+
Message.CompletedGenerateCardId({
|
|
106
|
+
cardId: 'test-uuid',
|
|
107
|
+
columnId: 'done',
|
|
108
|
+
title: 'Ship it',
|
|
109
|
+
}),
|
|
110
|
+
),
|
|
111
|
+
Command.resolve(SaveBoard, Message.CompletedSaveBoard()),
|
|
112
|
+
model(model => {
|
|
113
|
+
const doneColumn = model.columns.find(column => column.id === 'done')
|
|
114
|
+
const lastCard = doneColumn?.cards[doneColumn.cards.length - 1]
|
|
115
|
+
expect(lastCard?.title).toBe('Ship it')
|
|
116
|
+
expect(lastCard?.id).toBe('test-uuid')
|
|
117
|
+
expect(model.maybeNewCardColumnId).toStrictEqual(Option.none())
|
|
118
|
+
}),
|
|
119
|
+
)
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
test('SubmittedNewCard ignores empty title', () => {
|
|
123
|
+
story(
|
|
124
|
+
update,
|
|
125
|
+
given(emptyModel),
|
|
126
|
+
message(Message.ClickedAddCard({ columnId: 'todo' })),
|
|
127
|
+
acknowledgeFocusInput,
|
|
128
|
+
message(Message.SubmittedNewCard()),
|
|
129
|
+
model(model => {
|
|
130
|
+
expect(model.maybeNewCardColumnId).toStrictEqual(Option.some('todo'))
|
|
131
|
+
}),
|
|
132
|
+
)
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
test('CancelledNewCard closes the form', () => {
|
|
136
|
+
story(
|
|
137
|
+
update,
|
|
138
|
+
given(emptyModel),
|
|
139
|
+
message(Message.ClickedAddCard({ columnId: 'todo' })),
|
|
140
|
+
acknowledgeFocusInput,
|
|
141
|
+
message(Message.ChangedNewCardTitle({ value: 'Draft' })),
|
|
142
|
+
message(Message.CancelledNewCard()),
|
|
143
|
+
model(model => {
|
|
144
|
+
expect(model.maybeNewCardColumnId).toStrictEqual(Option.none())
|
|
145
|
+
expect(model.newCardTitle).toBe('')
|
|
146
|
+
}),
|
|
147
|
+
)
|
|
148
|
+
})
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
describe('drag and drop reorder', () => {
|
|
152
|
+
test('reorders a card within the same column', () => {
|
|
153
|
+
const firstCardId = emptyModel.columns[0]!.cards[0]!.id
|
|
154
|
+
story(
|
|
155
|
+
update,
|
|
156
|
+
given(emptyModel),
|
|
157
|
+
message(
|
|
158
|
+
Message.GotDragAndDropMessage({
|
|
159
|
+
message: DragAndDropMessage.PressedDraggable({
|
|
160
|
+
itemId: firstCardId,
|
|
161
|
+
containerId: 'todo',
|
|
162
|
+
index: 0,
|
|
163
|
+
screenX: 100,
|
|
164
|
+
screenY: 100,
|
|
165
|
+
}),
|
|
166
|
+
}),
|
|
167
|
+
),
|
|
168
|
+
message(
|
|
169
|
+
Message.GotDragAndDropMessage({
|
|
170
|
+
message: DragAndDropMessage.MovedPointer({
|
|
171
|
+
screenX: 100,
|
|
172
|
+
screenY: 200,
|
|
173
|
+
clientX: 100,
|
|
174
|
+
clientY: 200,
|
|
175
|
+
maybeDropTarget: Option.some({ containerId: 'todo', index: 3 }),
|
|
176
|
+
}),
|
|
177
|
+
}),
|
|
178
|
+
),
|
|
179
|
+
message(
|
|
180
|
+
Message.GotDragAndDropMessage({
|
|
181
|
+
message: DragAndDropMessage.ReleasedPointer(),
|
|
182
|
+
}),
|
|
183
|
+
),
|
|
184
|
+
Command.resolve(SaveBoard, Message.CompletedSaveBoard()),
|
|
185
|
+
model(model => {
|
|
186
|
+
const todoColumn = model.columns.find(column => column.id === 'todo')
|
|
187
|
+
const cardIds = todoColumn?.cards.map(card => card.id)
|
|
188
|
+
expect(cardIds?.indexOf(firstCardId)).toBeGreaterThan(0)
|
|
189
|
+
}),
|
|
190
|
+
)
|
|
191
|
+
})
|
|
192
|
+
|
|
193
|
+
test('moves a card to a different column', () => {
|
|
194
|
+
const cardId = emptyModel.columns[0]!.cards[0]!.id
|
|
195
|
+
story(
|
|
196
|
+
update,
|
|
197
|
+
given(emptyModel),
|
|
198
|
+
message(
|
|
199
|
+
Message.GotDragAndDropMessage({
|
|
200
|
+
message: DragAndDropMessage.PressedDraggable({
|
|
201
|
+
itemId: cardId,
|
|
202
|
+
containerId: 'todo',
|
|
203
|
+
index: 0,
|
|
204
|
+
screenX: 100,
|
|
205
|
+
screenY: 100,
|
|
206
|
+
}),
|
|
207
|
+
}),
|
|
208
|
+
),
|
|
209
|
+
message(
|
|
210
|
+
Message.GotDragAndDropMessage({
|
|
211
|
+
message: DragAndDropMessage.MovedPointer({
|
|
212
|
+
screenX: 300,
|
|
213
|
+
screenY: 100,
|
|
214
|
+
clientX: 300,
|
|
215
|
+
clientY: 100,
|
|
216
|
+
maybeDropTarget: Option.some({
|
|
217
|
+
containerId: 'in-progress',
|
|
218
|
+
index: 0,
|
|
219
|
+
}),
|
|
220
|
+
}),
|
|
221
|
+
}),
|
|
222
|
+
),
|
|
223
|
+
message(
|
|
224
|
+
Message.GotDragAndDropMessage({
|
|
225
|
+
message: DragAndDropMessage.ReleasedPointer(),
|
|
226
|
+
}),
|
|
227
|
+
),
|
|
228
|
+
Command.resolve(SaveBoard, Message.CompletedSaveBoard()),
|
|
229
|
+
model(model => {
|
|
230
|
+
const todoCards = model.columns
|
|
231
|
+
.find(column => column.id === 'todo')
|
|
232
|
+
?.cards.map(card => card.id)
|
|
233
|
+
const inProgressCards = model.columns
|
|
234
|
+
.find(column => column.id === 'in-progress')
|
|
235
|
+
?.cards.map(card => card.id)
|
|
236
|
+
expect(todoCards).not.toContain(cardId)
|
|
237
|
+
expect(inProgressCards).toContain(cardId)
|
|
238
|
+
}),
|
|
239
|
+
)
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
test('keyboard drag reorders within the same column', () => {
|
|
243
|
+
const firstCardId = emptyModel.columns[0]!.cards[0]!.id
|
|
244
|
+
story(
|
|
245
|
+
update,
|
|
246
|
+
given(emptyModel),
|
|
247
|
+
message(
|
|
248
|
+
Message.GotDragAndDropMessage({
|
|
249
|
+
message: DragAndDropMessage.ActivatedKeyboardDrag({
|
|
250
|
+
itemId: firstCardId,
|
|
251
|
+
containerId: 'todo',
|
|
252
|
+
index: 0,
|
|
253
|
+
}),
|
|
254
|
+
}),
|
|
255
|
+
),
|
|
256
|
+
message(
|
|
257
|
+
Message.GotDragAndDropMessage({
|
|
258
|
+
message: DragAndDropMessage.CompletedResolveKeyboardMove({
|
|
259
|
+
targetContainerId: 'todo',
|
|
260
|
+
targetIndex: 2,
|
|
261
|
+
}),
|
|
262
|
+
}),
|
|
263
|
+
),
|
|
264
|
+
Command.resolve(
|
|
265
|
+
DragAndDrop.FocusItem({ itemId: firstCardId }),
|
|
266
|
+
DragAndDropMessage.CompletedFocusItem(),
|
|
267
|
+
),
|
|
268
|
+
message(
|
|
269
|
+
Message.GotDragAndDropMessage({
|
|
270
|
+
message: DragAndDropMessage.ConfirmedKeyboardDrop(),
|
|
271
|
+
}),
|
|
272
|
+
),
|
|
273
|
+
Command.resolve(
|
|
274
|
+
DragAndDrop.FocusItem,
|
|
275
|
+
DragAndDropMessage.CompletedFocusItem(),
|
|
276
|
+
),
|
|
277
|
+
Command.resolve(SaveBoard, Message.CompletedSaveBoard()),
|
|
278
|
+
model(model => {
|
|
279
|
+
const todoColumn = model.columns.find(column => column.id === 'todo')
|
|
280
|
+
const cardIds = todoColumn?.cards.map(card => card.id)
|
|
281
|
+
expect(cardIds?.indexOf(firstCardId)).toBe(2)
|
|
282
|
+
}),
|
|
283
|
+
)
|
|
284
|
+
})
|
|
285
|
+
|
|
286
|
+
test('keyboard drag moves a card to a different column', () => {
|
|
287
|
+
const cardId = emptyModel.columns[0]!.cards[0]!.id
|
|
288
|
+
story(
|
|
289
|
+
update,
|
|
290
|
+
given(emptyModel),
|
|
291
|
+
message(
|
|
292
|
+
Message.GotDragAndDropMessage({
|
|
293
|
+
message: DragAndDropMessage.ActivatedKeyboardDrag({
|
|
294
|
+
itemId: cardId,
|
|
295
|
+
containerId: 'todo',
|
|
296
|
+
index: 0,
|
|
297
|
+
}),
|
|
298
|
+
}),
|
|
299
|
+
),
|
|
300
|
+
message(
|
|
301
|
+
Message.GotDragAndDropMessage({
|
|
302
|
+
message: DragAndDropMessage.CompletedResolveKeyboardMove({
|
|
303
|
+
targetContainerId: 'in-progress',
|
|
304
|
+
targetIndex: 0,
|
|
305
|
+
}),
|
|
306
|
+
}),
|
|
307
|
+
),
|
|
308
|
+
Command.resolve(
|
|
309
|
+
DragAndDrop.FocusItem({ itemId: cardId }),
|
|
310
|
+
DragAndDropMessage.CompletedFocusItem(),
|
|
311
|
+
),
|
|
312
|
+
message(
|
|
313
|
+
Message.GotDragAndDropMessage({
|
|
314
|
+
message: DragAndDropMessage.ConfirmedKeyboardDrop(),
|
|
315
|
+
}),
|
|
316
|
+
),
|
|
317
|
+
Command.resolve(
|
|
318
|
+
DragAndDrop.FocusItem,
|
|
319
|
+
DragAndDropMessage.CompletedFocusItem(),
|
|
320
|
+
),
|
|
321
|
+
Command.resolve(SaveBoard, Message.CompletedSaveBoard()),
|
|
322
|
+
model(model => {
|
|
323
|
+
const todoCards = model.columns
|
|
324
|
+
.find(column => column.id === 'todo')
|
|
325
|
+
?.cards.map(card => card.id)
|
|
326
|
+
const inProgressCards = model.columns
|
|
327
|
+
.find(column => column.id === 'in-progress')
|
|
328
|
+
?.cards.map(card => card.id)
|
|
329
|
+
expect(todoCards).not.toContain(cardId)
|
|
330
|
+
expect(inProgressCards).toContain(cardId)
|
|
331
|
+
}),
|
|
332
|
+
)
|
|
333
|
+
})
|
|
334
|
+
|
|
335
|
+
test('cancelled keyboard drag does not change columns', () => {
|
|
336
|
+
story(
|
|
337
|
+
update,
|
|
338
|
+
given(emptyModel),
|
|
339
|
+
message(
|
|
340
|
+
Message.GotDragAndDropMessage({
|
|
341
|
+
message: DragAndDropMessage.ActivatedKeyboardDrag({
|
|
342
|
+
itemId: emptyModel.columns[0]!.cards[0]!.id,
|
|
343
|
+
containerId: 'todo',
|
|
344
|
+
index: 0,
|
|
345
|
+
}),
|
|
346
|
+
}),
|
|
347
|
+
),
|
|
348
|
+
message(
|
|
349
|
+
Message.GotDragAndDropMessage({
|
|
350
|
+
message: DragAndDropMessage.CancelledDrag(),
|
|
351
|
+
}),
|
|
352
|
+
),
|
|
353
|
+
Command.resolve(
|
|
354
|
+
DragAndDrop.FocusItem,
|
|
355
|
+
DragAndDropMessage.CompletedFocusItem(),
|
|
356
|
+
),
|
|
357
|
+
model(model => {
|
|
358
|
+
expect(model.columns).toStrictEqual(emptyModel.columns)
|
|
359
|
+
}),
|
|
360
|
+
)
|
|
361
|
+
})
|
|
362
|
+
|
|
363
|
+
test('cancelled drag does not change columns', () => {
|
|
364
|
+
story(
|
|
365
|
+
update,
|
|
366
|
+
given(emptyModel),
|
|
367
|
+
message(
|
|
368
|
+
Message.GotDragAndDropMessage({
|
|
369
|
+
message: DragAndDropMessage.PressedDraggable({
|
|
370
|
+
itemId: emptyModel.columns[0]!.cards[0]!.id,
|
|
371
|
+
containerId: 'todo',
|
|
372
|
+
index: 0,
|
|
373
|
+
screenX: 100,
|
|
374
|
+
screenY: 100,
|
|
375
|
+
}),
|
|
376
|
+
}),
|
|
377
|
+
),
|
|
378
|
+
message(
|
|
379
|
+
Message.GotDragAndDropMessage({
|
|
380
|
+
message: DragAndDropMessage.MovedPointer({
|
|
381
|
+
screenX: 100,
|
|
382
|
+
screenY: 200,
|
|
383
|
+
clientX: 100,
|
|
384
|
+
clientY: 200,
|
|
385
|
+
maybeDropTarget: Option.none(),
|
|
386
|
+
}),
|
|
387
|
+
}),
|
|
388
|
+
),
|
|
389
|
+
message(
|
|
390
|
+
Message.GotDragAndDropMessage({
|
|
391
|
+
message: DragAndDropMessage.CancelledDrag(),
|
|
392
|
+
}),
|
|
393
|
+
),
|
|
394
|
+
model(model => {
|
|
395
|
+
expect(model.columns).toStrictEqual(emptyModel.columns)
|
|
396
|
+
}),
|
|
397
|
+
)
|
|
398
|
+
})
|
|
399
|
+
})
|
|
400
|
+
})
|
|
401
|
+
|
|
402
|
+
describe('Column.reorder', () => {
|
|
403
|
+
const k1 = generateKeyBetween(null, null)
|
|
404
|
+
const k2 = generateKeyBetween(k1, null)
|
|
405
|
+
const k3 = generateKeyBetween(k2, null)
|
|
406
|
+
|
|
407
|
+
const columns = [
|
|
408
|
+
{
|
|
409
|
+
id: 'a',
|
|
410
|
+
name: 'A',
|
|
411
|
+
cards: [
|
|
412
|
+
{ id: '1', title: '1', description: '', sortKey: k1 },
|
|
413
|
+
{ id: '2', title: '2', description: '', sortKey: k2 },
|
|
414
|
+
{ id: '3', title: '3', description: '', sortKey: k3 },
|
|
415
|
+
],
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
id: 'b',
|
|
419
|
+
name: 'B',
|
|
420
|
+
cards: [{ id: '4', title: '4', description: '', sortKey: k1 }],
|
|
421
|
+
},
|
|
422
|
+
]
|
|
423
|
+
|
|
424
|
+
test('reorders within column', () => {
|
|
425
|
+
const result = Column.reorder(columns, '1', 'a', 'a', 2)
|
|
426
|
+
const cardIds = result
|
|
427
|
+
.find(column => column.id === 'a')
|
|
428
|
+
?.cards.map(card => card.id)
|
|
429
|
+
expect(cardIds).toStrictEqual(['2', '3', '1'])
|
|
430
|
+
})
|
|
431
|
+
|
|
432
|
+
test('moves card to a different column', () => {
|
|
433
|
+
const result = Column.reorder(columns, '1', 'a', 'b', 0)
|
|
434
|
+
const aIds = result
|
|
435
|
+
.find(column => column.id === 'a')
|
|
436
|
+
?.cards.map(card => card.id)
|
|
437
|
+
const bIds = result
|
|
438
|
+
.find(column => column.id === 'b')
|
|
439
|
+
?.cards.map(card => card.id)
|
|
440
|
+
expect(aIds).toStrictEqual(['2', '3'])
|
|
441
|
+
expect(bIds).toStrictEqual(['1', '4'])
|
|
442
|
+
})
|
|
443
|
+
|
|
444
|
+
test('moves card to end of another column', () => {
|
|
445
|
+
const result = Column.reorder(columns, '1', 'a', 'b', 1)
|
|
446
|
+
const bIds = result
|
|
447
|
+
.find(column => column.id === 'b')
|
|
448
|
+
?.cards.map(card => card.id)
|
|
449
|
+
expect(bIds).toStrictEqual(['4', '1'])
|
|
450
|
+
})
|
|
451
|
+
|
|
452
|
+
test('assigns valid sortKeys after reorder', () => {
|
|
453
|
+
const result = Column.reorder(columns, '3', 'a', 'a', 0)
|
|
454
|
+
const cards = result.find(column => column.id === 'a')?.cards
|
|
455
|
+
const sortKeys = cards?.map(card => card.sortKey) ?? []
|
|
456
|
+
const isSorted = sortKeys.every(
|
|
457
|
+
(key, index) => index === 0 || key > sortKeys[index - 1]!,
|
|
458
|
+
)
|
|
459
|
+
expect(isSorted).toBe(true)
|
|
460
|
+
})
|
|
461
|
+
})
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import 'tailwindcss';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Subscription } from 'foldkit'
|
|
2
|
+
|
|
3
|
+
import { DragAndDrop } from '@foldkit/ui'
|
|
4
|
+
|
|
5
|
+
import { Message } from './message'
|
|
6
|
+
import type { Model } from './model'
|
|
7
|
+
|
|
8
|
+
export const subscriptions = Subscription.lift({
|
|
9
|
+
dragPointer: DragAndDrop.subscriptions.documentPointer,
|
|
10
|
+
dragEscape: DragAndDrop.subscriptions.documentEscape,
|
|
11
|
+
dragKeyboard: DragAndDrop.subscriptions.documentKeyboard,
|
|
12
|
+
autoScroll: DragAndDrop.subscriptions.autoScroll,
|
|
13
|
+
})<Model, Message>({
|
|
14
|
+
toChildModel: model => model.dragAndDrop,
|
|
15
|
+
toParentMessage: message => Message.GotDragAndDropMessage({ message }),
|
|
16
|
+
})
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { Array, Match as M, Option, String, pipe } from 'effect'
|
|
2
|
+
import { Command, Update } from 'foldkit'
|
|
3
|
+
import { evo } from 'foldkit/struct'
|
|
4
|
+
|
|
5
|
+
import { DragAndDrop } from '@foldkit/ui'
|
|
6
|
+
|
|
7
|
+
import { FocusAddCardInput, GenerateCardId, SaveBoard } from './command'
|
|
8
|
+
import { Column } from './domain'
|
|
9
|
+
import { Message } from './message'
|
|
10
|
+
import type { Model } from './model'
|
|
11
|
+
|
|
12
|
+
type UpdateReturn = readonly [Model, ReadonlyArray<Command.Command<Message>>]
|
|
13
|
+
|
|
14
|
+
const findCardTitle = (
|
|
15
|
+
columns: ReadonlyArray<Column.Column>,
|
|
16
|
+
cardId: string,
|
|
17
|
+
): string =>
|
|
18
|
+
pipe(
|
|
19
|
+
columns,
|
|
20
|
+
Array.flatMap(({ cards }) => cards),
|
|
21
|
+
Array.findFirst(({ id }) => id === cardId),
|
|
22
|
+
Option.match({
|
|
23
|
+
onNone: () => cardId,
|
|
24
|
+
onSome: ({ title }) => title,
|
|
25
|
+
}),
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
const findColumnName = (
|
|
29
|
+
columns: ReadonlyArray<Column.Column>,
|
|
30
|
+
columnId: string,
|
|
31
|
+
): string =>
|
|
32
|
+
pipe(
|
|
33
|
+
columns,
|
|
34
|
+
Array.findFirst(({ id }) => id === columnId),
|
|
35
|
+
Option.match({
|
|
36
|
+
onNone: () => columnId,
|
|
37
|
+
onSome: ({ name }) => name,
|
|
38
|
+
}),
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
const announceKeyboardDrag = (
|
|
42
|
+
model: Model,
|
|
43
|
+
nextDragAndDrop: DragAndDrop.Model,
|
|
44
|
+
): string =>
|
|
45
|
+
M.value(nextDragAndDrop.dragState).pipe(
|
|
46
|
+
M.withReturnType<string>(),
|
|
47
|
+
M.tag('KeyboardDragging', nextState => {
|
|
48
|
+
const wasIdle = model.dragAndDrop.dragState._tag === 'Idle'
|
|
49
|
+
if (wasIdle) {
|
|
50
|
+
const title = findCardTitle(model.columns, nextState.itemId)
|
|
51
|
+
return `Picked up ${title}. Use arrow keys to move within column, Tab to move between columns, Space to drop, Escape to cancel.`
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (model.dragAndDrop.dragState._tag !== 'KeyboardDragging') {
|
|
55
|
+
return model.announcement
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const prevState = model.dragAndDrop.dragState
|
|
59
|
+
const columnName = findColumnName(
|
|
60
|
+
model.columns,
|
|
61
|
+
nextState.targetContainerId,
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
if (prevState.targetContainerId !== nextState.targetContainerId) {
|
|
65
|
+
return `Moved to ${columnName}, position ${nextState.targetIndex + 1}.`
|
|
66
|
+
}
|
|
67
|
+
if (prevState.targetIndex !== nextState.targetIndex) {
|
|
68
|
+
return `Position ${nextState.targetIndex + 1} in ${columnName}.`
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return model.announcement
|
|
72
|
+
}),
|
|
73
|
+
M.orElse(() => model.announcement),
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
const screenReaderTextForDrop = (
|
|
77
|
+
model: Model,
|
|
78
|
+
outMessage: DragAndDrop.OutMessage,
|
|
79
|
+
): string =>
|
|
80
|
+
DragAndDrop.OutMessage.match<string>(outMessage, {
|
|
81
|
+
Reordered: ({ itemId, toContainerId, toIndex }) => {
|
|
82
|
+
const title = findCardTitle(model.columns, itemId)
|
|
83
|
+
const columnName = findColumnName(model.columns, toContainerId)
|
|
84
|
+
return `Dropped ${title} in position ${toIndex + 1} of ${columnName}.`
|
|
85
|
+
},
|
|
86
|
+
Cancelled: () =>
|
|
87
|
+
Option.match(DragAndDrop.maybeDraggedItemId(model.dragAndDrop), {
|
|
88
|
+
onNone: () => 'Drag cancelled.',
|
|
89
|
+
onSome: id => {
|
|
90
|
+
const title = findCardTitle(model.columns, id)
|
|
91
|
+
return `Drag cancelled, ${title} returned to original position.`
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
const foldDragAndDropOutMessage: (
|
|
97
|
+
previousModel: Model,
|
|
98
|
+
) => (outMessage: DragAndDrop.OutMessage) => Update.Step<Model, Message> =
|
|
99
|
+
previousModel => outMessage => model =>
|
|
100
|
+
DragAndDrop.OutMessage.match<UpdateReturn>(outMessage, {
|
|
101
|
+
Reordered: ({ itemId, fromContainerId, toContainerId, toIndex }) => {
|
|
102
|
+
const nextColumns = Column.reorder(
|
|
103
|
+
model.columns,
|
|
104
|
+
itemId,
|
|
105
|
+
fromContainerId,
|
|
106
|
+
toContainerId,
|
|
107
|
+
toIndex,
|
|
108
|
+
)
|
|
109
|
+
return [
|
|
110
|
+
evo(model, {
|
|
111
|
+
columns: () => nextColumns,
|
|
112
|
+
announcement: () =>
|
|
113
|
+
screenReaderTextForDrop(previousModel, outMessage),
|
|
114
|
+
}),
|
|
115
|
+
[SaveBoard({ columns: nextColumns })],
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
Cancelled: () => [
|
|
119
|
+
evo(model, {
|
|
120
|
+
announcement: () =>
|
|
121
|
+
screenReaderTextForDrop(previousModel, outMessage),
|
|
122
|
+
}),
|
|
123
|
+
[],
|
|
124
|
+
],
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
const foldDragAndDrop = (previousModel: Model) =>
|
|
128
|
+
Update.foldChild({
|
|
129
|
+
update: DragAndDrop.update,
|
|
130
|
+
read: (model: Model) => Option.some(model.dragAndDrop),
|
|
131
|
+
write: (model, nextDragAndDrop) =>
|
|
132
|
+
evo(model, {
|
|
133
|
+
dragAndDrop: () => nextDragAndDrop,
|
|
134
|
+
announcement: () => announceKeyboardDrag(model, nextDragAndDrop),
|
|
135
|
+
}),
|
|
136
|
+
toParentMessage: message => Message.GotDragAndDropMessage({ message }),
|
|
137
|
+
foldOutMessage: foldDragAndDropOutMessage(previousModel),
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
export const update = (model: Model, message: Message) =>
|
|
141
|
+
Message.match<UpdateReturn>(message, {
|
|
142
|
+
GotDragAndDropMessage: ({ message }) =>
|
|
143
|
+
foldDragAndDrop(model)(model, message),
|
|
144
|
+
|
|
145
|
+
ClickedAddCard: ({ columnId }) => [
|
|
146
|
+
evo(model, {
|
|
147
|
+
maybeNewCardColumnId: () => Option.some(columnId),
|
|
148
|
+
newCardTitle: () => '',
|
|
149
|
+
}),
|
|
150
|
+
[FocusAddCardInput()],
|
|
151
|
+
],
|
|
152
|
+
|
|
153
|
+
ChangedNewCardTitle: ({ value }) => [
|
|
154
|
+
evo(model, { newCardTitle: () => value }),
|
|
155
|
+
[],
|
|
156
|
+
],
|
|
157
|
+
|
|
158
|
+
SubmittedNewCard: () =>
|
|
159
|
+
Option.match(model.maybeNewCardColumnId, {
|
|
160
|
+
onNone: () => [model, []],
|
|
161
|
+
onSome: columnId => {
|
|
162
|
+
const title = String.trim(model.newCardTitle)
|
|
163
|
+
if (String.isEmpty(title)) {
|
|
164
|
+
return [model, []]
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
return [model, [GenerateCardId({ columnId: columnId, title: title })]]
|
|
168
|
+
},
|
|
169
|
+
}),
|
|
170
|
+
|
|
171
|
+
CompletedGenerateCardId: ({ cardId, columnId, title }) => {
|
|
172
|
+
const nextColumns = Array.map(model.columns, column => {
|
|
173
|
+
if (column.id !== columnId) {
|
|
174
|
+
return column
|
|
175
|
+
}
|
|
176
|
+
return Column.appendCard(column, {
|
|
177
|
+
id: cardId,
|
|
178
|
+
title,
|
|
179
|
+
description: '',
|
|
180
|
+
sortKey: '',
|
|
181
|
+
})
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
return [
|
|
185
|
+
evo(model, {
|
|
186
|
+
columns: () => nextColumns,
|
|
187
|
+
maybeNewCardColumnId: () => Option.none(),
|
|
188
|
+
newCardTitle: () => '',
|
|
189
|
+
}),
|
|
190
|
+
[SaveBoard({ columns: nextColumns })],
|
|
191
|
+
]
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
CancelledNewCard: () => [
|
|
195
|
+
evo(model, {
|
|
196
|
+
maybeNewCardColumnId: () => Option.none(),
|
|
197
|
+
newCardTitle: () => '',
|
|
198
|
+
}),
|
|
199
|
+
[],
|
|
200
|
+
],
|
|
201
|
+
|
|
202
|
+
CompletedSaveBoard: () => [model, []],
|
|
203
|
+
|
|
204
|
+
CompletedFocusAddCardInput: () => [model, []],
|
|
205
|
+
})
|