@zyro-sec/ui 1.0.2 → 1.0.3
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/AGENTS.md +29 -29
- package/LICENSE +21 -21
- package/bunfig.toml +2 -2
- package/package.json +2 -2
- package/perf/motion.bench.ts +14 -14
- package/perf/motion.ts +16 -16
- package/script/build-oc2-v2-overrides.ts +38 -38
- package/script/colors.txt +288 -288
- package/script/generate-spinner.ts +121 -121
- package/script/pack.ts +5 -5
- package/script/tailwind.ts +24 -24
- package/src/actions/button/button.css +346 -346
- package/src/actions/button/button.stories.tsx +158 -158
- package/src/actions/button/button.tsx +56 -56
- package/src/actions/icon-button/icon-button.css +128 -128
- package/src/actions/icon-button/icon-button.stories.tsx +122 -122
- package/src/actions/icon-button/icon-button.tsx +46 -46
- package/src/actions/split-button/split-button.css +99 -99
- package/src/actions/split-button/split-button.stories.tsx +59 -59
- package/src/actions/split-button/split-button.tsx +51 -51
- package/src/actions/submit.css +81 -81
- package/src/assets/favicon/favicon-v3.svg +6 -6
- package/src/assets/favicon/favicon.svg +6 -6
- package/src/assets/favicon/site.webmanifest +24 -24
- package/src/assets/icons/app/android-studio.svg +369 -369
- package/src/assets/icons/app/antigravity.svg +97 -97
- package/src/assets/icons/app/cursor.svg +16 -16
- package/src/assets/icons/app/file-explorer.svg +20 -20
- package/src/assets/icons/app/ghostty.svg +13 -13
- package/src/assets/icons/app/iterm2.svg +13 -13
- package/src/assets/icons/app/powershell.svg +14 -14
- package/src/assets/icons/app/sublimetext.svg +17 -17
- package/src/assets/icons/app/vscode.svg +39 -39
- package/src/assets/icons/app/windows-terminal.svg +6 -6
- package/src/assets/icons/app/zed-dark.svg +15 -15
- package/src/assets/icons/app/zed.svg +15 -15
- package/src/assets/icons/file-types/auto_light.svg +12 -12
- package/src/assets/icons/file-types/cursor.svg +1 -1
- package/src/assets/icons/file-types/cursor_light.svg +1 -1
- package/src/assets/icons/file-types/drone_light.svg +4 -4
- package/src/assets/icons/file-types/folder-admin-open.svg +6 -6
- package/src/assets/icons/file-types/folder-admin.svg +6 -6
- package/src/assets/icons/file-types/folder-circleci-open.svg +7 -7
- package/src/assets/icons/file-types/folder-circleci.svg +7 -7
- package/src/assets/icons/file-types/folder-flow-open.svg +6 -6
- package/src/assets/icons/file-types/folder-flow.svg +6 -6
- package/src/assets/icons/file-types/folder-gh-workflows-open.svg +6 -6
- package/src/assets/icons/file-types/folder-gh-workflows.svg +6 -6
- package/src/assets/icons/file-types/folder-github-open.svg +6 -6
- package/src/assets/icons/file-types/folder-github.svg +6 -6
- package/src/assets/icons/file-types/folder-intellij-open.svg +39 -39
- package/src/assets/icons/file-types/folder-intellij.svg +39 -39
- package/src/assets/icons/file-types/folder-macos-open.svg +6 -6
- package/src/assets/icons/file-types/folder-macos.svg +6 -6
- package/src/assets/icons/file-types/folder-next-open.svg +6 -6
- package/src/assets/icons/file-types/folder-next.svg +6 -6
- package/src/assets/icons/file-types/folder-nuxt-open.svg +6 -6
- package/src/assets/icons/file-types/folder-nuxt.svg +6 -6
- package/src/assets/icons/file-types/folder-open.svg +5 -5
- package/src/assets/icons/file-types/folder-scripts-open.svg +6 -6
- package/src/assets/icons/file-types/folder-scripts.svg +6 -6
- package/src/assets/icons/file-types/folder-target-open.svg +10 -10
- package/src/assets/icons/file-types/folder-target.svg +10 -10
- package/src/assets/icons/file-types/folder-turborepo-open.svg +15 -15
- package/src/assets/icons/file-types/folder-turborepo.svg +15 -15
- package/src/assets/icons/file-types/folder-vercel-open.svg +5 -5
- package/src/assets/icons/file-types/folder-vercel.svg +5 -5
- package/src/assets/icons/file-types/folder.svg +5 -5
- package/src/assets/icons/file-types/go_gopher.svg +35 -35
- package/src/assets/icons/file-types/nano-staged_light.svg +4 -4
- package/src/assets/icons/file-types/opa.svg +9 -9
- package/src/assets/icons/file-types/quarto.svg +5 -5
- package/src/assets/icons/file-types/rome.svg +6 -6
- package/src/assets/icons/file-types/stitches_light.svg +10 -10
- package/src/assets/icons/file-types/stylelint_light.svg +13 -13
- package/src/assets/icons/file-types/unocss.svg +5 -5
- package/src/assets/icons/file-types/vlang.svg +6 -6
- package/src/assets/icons/provider/302ai.svg +6 -6
- package/src/assets/icons/provider/abacus.svg +14 -14
- package/src/assets/icons/provider/aihubmix.svg +3 -3
- package/src/assets/icons/provider/alibaba-cn.svg +3 -3
- package/src/assets/icons/provider/alibaba-coding-plan-cn.svg +3 -3
- package/src/assets/icons/provider/alibaba-coding-plan.svg +3 -3
- package/src/assets/icons/provider/alibaba.svg +3 -3
- package/src/assets/icons/provider/amazon-bedrock.svg +3 -3
- package/src/assets/icons/provider/anthropic.svg +2 -2
- package/src/assets/icons/provider/azure-cognitive-services.svg +24 -24
- package/src/assets/icons/provider/azure.svg +3 -3
- package/src/assets/icons/provider/bailing.svg +3 -3
- package/src/assets/icons/provider/baseten.svg +3 -3
- package/src/assets/icons/provider/berget.svg +2 -2
- package/src/assets/icons/provider/cerebras.svg +4 -4
- package/src/assets/icons/provider/chutes.svg +24 -24
- package/src/assets/icons/provider/clarifai.svg +24 -24
- package/src/assets/icons/provider/claude-agent.svg +3 -3
- package/src/assets/icons/provider/cloudferro-sherlock.svg +4 -4
- package/src/assets/icons/provider/cloudflare-ai-gateway.svg +4 -4
- package/src/assets/icons/provider/cloudflare-workers-ai.svg +4 -4
- package/src/assets/icons/provider/cohere.svg +5 -5
- package/src/assets/icons/provider/cortecs.svg +24 -24
- package/src/assets/icons/provider/deepinfra.svg +4 -4
- package/src/assets/icons/provider/deepseek.svg +3 -3
- package/src/assets/icons/provider/digitalocean.svg +6 -6
- package/src/assets/icons/provider/dinference.svg +1 -1
- package/src/assets/icons/provider/drun.svg +8 -8
- package/src/assets/icons/provider/evroc.svg +2 -2
- package/src/assets/icons/provider/fastrouter.svg +3 -3
- package/src/assets/icons/provider/fireworks-ai.svg +3 -3
- package/src/assets/icons/provider/firmware.svg +18 -18
- package/src/assets/icons/provider/friendli.svg +3 -3
- package/src/assets/icons/provider/github-copilot.svg +3 -3
- package/src/assets/icons/provider/github-models.svg +3 -3
- package/src/assets/icons/provider/gitlab.svg +3 -3
- package/src/assets/icons/provider/google-vertex-anthropic.svg +24 -24
- package/src/assets/icons/provider/google-vertex.svg +10 -10
- package/src/assets/icons/provider/google.svg +3 -3
- package/src/assets/icons/provider/groq.svg +3 -3
- package/src/assets/icons/provider/helicone.svg +6 -6
- package/src/assets/icons/provider/huggingface.svg +3 -3
- package/src/assets/icons/provider/iflowcn.svg +3 -3
- package/src/assets/icons/provider/inception.svg +4 -4
- package/src/assets/icons/provider/inference.svg +3 -3
- package/src/assets/icons/provider/io-net.svg +5 -5
- package/src/assets/icons/provider/jiekou.svg +4 -4
- package/src/assets/icons/provider/kilo.svg +4 -4
- package/src/assets/icons/provider/kimi-for-coding.svg +3 -3
- package/src/assets/icons/provider/kuae-cloud-coding-plan.svg +3 -3
- package/src/assets/icons/provider/llama.svg +3 -3
- package/src/assets/icons/provider/lmstudio.svg +24 -24
- package/src/assets/icons/provider/lucidquery.svg +3 -3
- package/src/assets/icons/provider/meganova.svg +3 -3
- package/src/assets/icons/provider/meituan.svg +6 -6
- package/src/assets/icons/provider/meta.svg +3 -3
- package/src/assets/icons/provider/minimax-cn-coding-plan.svg +24 -24
- package/src/assets/icons/provider/minimax-cn.svg +3 -3
- package/src/assets/icons/provider/minimax-coding-plan.svg +24 -24
- package/src/assets/icons/provider/minimax.svg +3 -3
- package/src/assets/icons/provider/mistral.svg +3 -3
- package/src/assets/icons/provider/moark.svg +3 -3
- package/src/assets/icons/provider/modelscope.svg +5 -5
- package/src/assets/icons/provider/moonshotai-cn.svg +3 -3
- package/src/assets/icons/provider/moonshotai.svg +3 -3
- package/src/assets/icons/provider/morph.svg +24 -24
- package/src/assets/icons/provider/nano-gpt.svg +2 -2
- package/src/assets/icons/provider/nebius.svg +4 -4
- package/src/assets/icons/provider/nova.svg +3 -3
- package/src/assets/icons/provider/novita-ai.svg +10 -10
- package/src/assets/icons/provider/nvidia.svg +3 -3
- package/src/assets/icons/provider/ollama-cloud.svg +7 -7
- package/src/assets/icons/provider/openai.svg +3 -3
- package/src/assets/icons/provider/opencode-go.svg +3 -3
- package/src/assets/icons/provider/opencode.svg +3 -3
- package/src/assets/icons/provider/openrouter.svg +3 -3
- package/src/assets/icons/provider/ovhcloud.svg +3 -3
- package/src/assets/icons/provider/perplexity-agent.svg +3 -3
- package/src/assets/icons/provider/perplexity.svg +3 -3
- package/src/assets/icons/provider/poe.svg +7 -7
- package/src/assets/icons/provider/privatemode-ai.svg +4 -4
- package/src/assets/icons/provider/qihang-ai.svg +8 -8
- package/src/assets/icons/provider/qiniu-ai.svg +7 -7
- package/src/assets/icons/provider/reflection.svg +3 -3
- package/src/assets/icons/provider/requesty.svg +24 -24
- package/src/assets/icons/provider/sap-ai-core.svg +24 -24
- package/src/assets/icons/provider/scaleway.svg +5 -5
- package/src/assets/icons/provider/siliconflow-cn.svg +3 -3
- package/src/assets/icons/provider/siliconflow.svg +3 -3
- package/src/assets/icons/provider/stackit.svg +4 -4
- package/src/assets/icons/provider/stepfun.svg +16 -16
- package/src/assets/icons/provider/submodel.svg +3 -3
- package/src/assets/icons/provider/synthetic.svg +24 -24
- package/src/assets/icons/provider/tencent-coding-plan.svg +5 -5
- package/src/assets/icons/provider/tencent.svg +3 -3
- package/src/assets/icons/provider/thinkingmachines.svg +3 -3
- package/src/assets/icons/provider/togetherai.svg +4 -4
- package/src/assets/icons/provider/upstage.svg +24 -24
- package/src/assets/icons/provider/v0.svg +3 -3
- package/src/assets/icons/provider/venice.svg +4 -4
- package/src/assets/icons/provider/vercel.svg +3 -3
- package/src/assets/icons/provider/vivgrid.svg +4 -4
- package/src/assets/icons/provider/vultr.svg +6 -6
- package/src/assets/icons/provider/wandb.svg +24 -24
- package/src/assets/icons/provider/xai.svg +3 -3
- package/src/assets/icons/provider/xiaomi.svg +3 -3
- package/src/assets/icons/provider/zai-coding-plan.svg +3 -3
- package/src/assets/icons/provider/zai.svg +3 -3
- package/src/assets/icons/provider/zenmux.svg +4 -4
- package/src/assets/icons/provider/zhipuai-coding-plan.svg +3 -3
- package/src/assets/icons/provider/zhipuai.svg +3 -3
- package/src/components/animated-number-machine.ts +214 -214
- package/src/components/animated-number.css +110 -110
- package/src/components/animated-number.stories.tsx +35 -35
- package/src/components/animated-number.tsx +202 -202
- package/src/components/app-icon.css +5 -5
- package/src/components/app-icon.stories.tsx +73 -73
- package/src/components/app-icon.tsx +89 -89
- package/src/components/app-icons/sprite.svg +114 -114
- package/src/components/app-icons/types.ts +22 -22
- package/src/components/card.css +94 -94
- package/src/components/card.stories.tsx +101 -101
- package/src/components/card.tsx +145 -145
- package/src/components/collapsible.css +139 -139
- package/src/components/collapsible.stories.tsx +76 -76
- package/src/components/collapsible.tsx +62 -62
- package/src/components/context-menu.css +134 -134
- package/src/components/context-menu.stories.tsx +150 -150
- package/src/components/context-menu.tsx +342 -342
- package/src/components/diagram-preview.css +95 -95
- package/src/components/diagram-preview.stories.tsx +62 -62
- package/src/components/diagram-preview.tsx +332 -332
- package/src/components/dock-surface.css +30 -30
- package/src/components/dock-surface.stories.tsx +26 -26
- package/src/components/dock-surface.tsx +40 -40
- package/src/components/document-surface.css +37 -37
- package/src/components/document-surface.stories.tsx +42 -42
- package/src/components/document-surface.tsx +6 -6
- package/src/components/error-details.css +41 -41
- package/src/components/error-details.stories.tsx +72 -72
- package/src/components/error-details.tsx +13 -13
- package/src/components/favicon.stories.tsx +49 -49
- package/src/components/favicon.tsx +13 -13
- package/src/components/file-icon-machine.ts +78 -78
- package/src/components/file-icon.css +6 -6
- package/src/components/file-icon.stories.tsx +93 -93
- package/src/components/file-icon.tsx +186 -186
- package/src/components/file-icons/choose-icon-name.ts +574 -574
- package/src/components/file-icons/sprite.svg +11707 -11707
- package/src/components/file-icons/types.ts +1095 -1095
- package/src/components/font.stories.tsx +48 -48
- package/src/components/font.tsx +1 -1
- package/src/components/hover-card.css +61 -61
- package/src/components/hover-card.stories.tsx +79 -79
- package/src/components/hover-card.tsx +32 -32
- package/src/components/image-flight-machine.ts +247 -247
- package/src/components/image-flight.ts +161 -161
- package/src/components/image-preview.css +202 -202
- package/src/components/image-preview.stories.tsx +392 -392
- package/src/components/image-preview.tsx +908 -908
- package/src/components/image-zoom-machine.ts +191 -191
- package/src/components/image-zoom.ts +124 -124
- package/src/components/list.css +331 -331
- package/src/components/list.stories.tsx +221 -221
- package/src/components/list.tsx +322 -322
- package/src/components/logo.css +4 -4
- package/src/components/logo.stories.tsx +62 -62
- package/src/components/logo.tsx +62 -62
- package/src/components/menu-scroll.css +70 -70
- package/src/components/menu-scroll.stories.tsx +73 -73
- package/src/components/menu-scroll.tsx +202 -202
- package/src/components/motion-spring.tsx +65 -65
- package/src/components/popover-machine.ts +198 -198
- package/src/components/popover.css +66 -66
- package/src/components/popover.stories.tsx +84 -84
- package/src/components/popover.tsx +234 -234
- package/src/components/preview-controls.css +28 -28
- package/src/components/preview-controls.stories.tsx +40 -40
- package/src/components/preview-controls.tsx +53 -53
- package/src/components/progress.css +63 -63
- package/src/components/progress.stories.tsx +69 -69
- package/src/components/progress.tsx +39 -39
- package/src/components/provider-icon.css +5 -5
- package/src/components/provider-icon.stories.tsx +75 -75
- package/src/components/provider-icon.tsx +31 -31
- package/src/components/provider-icons/sprite.svg +1131 -1131
- package/src/components/provider-icons/types.ts +111 -111
- package/src/components/resize-handle-machine.ts +174 -174
- package/src/components/resize-handle.css +81 -81
- package/src/components/resize-handle.stories.tsx +81 -81
- package/src/components/resize-handle.tsx +164 -164
- package/src/components/rolling-number.css +24 -24
- package/src/components/rolling-number.stories.tsx +23 -23
- package/src/components/rolling-number.tsx +135 -135
- package/src/components/scroll-view-machine.ts +244 -244
- package/src/components/scroll-view.css +99 -99
- package/src/components/scroll-view.stories.tsx +68 -68
- package/src/components/scroll-view.tsx +653 -653
- package/src/components/spinner-frames.css +6 -6
- package/src/components/spinner-radar.ts +150 -150
- package/src/components/spinner.css +38 -38
- package/src/components/spinner.stories.tsx +40 -40
- package/src/components/spinner.tsx +43 -43
- package/src/components/sticky-accordion-header.css +11 -11
- package/src/components/sticky-accordion-header.stories.tsx +64 -64
- package/src/components/sticky-accordion-header.tsx +18 -18
- package/src/components/text-field-machine.ts +102 -102
- package/src/components/text-field.css +134 -134
- package/src/components/text-field.stories.tsx +132 -132
- package/src/components/text-field.tsx +196 -196
- package/src/components/text-reveal-machine.ts +184 -184
- package/src/components/text-reveal.css +150 -150
- package/src/components/text-reveal.stories.tsx +363 -363
- package/src/components/text-reveal.tsx +165 -165
- package/src/components/text-strikethrough.css +27 -27
- package/src/components/text-strikethrough.stories.tsx +296 -296
- package/src/components/text-strikethrough.tsx +92 -92
- package/src/components/thinking-heading.stories.tsx +900 -900
- package/src/components/truncated-text.css +25 -25
- package/src/components/truncated-text.stories.tsx +37 -37
- package/src/components/truncated-text.tsx +30 -30
- package/src/components/typewriter-machine.ts +134 -134
- package/src/components/typewriter.css +14 -14
- package/src/components/typewriter.stories.tsx +51 -51
- package/src/components/typewriter.tsx +70 -70
- package/src/context/dialog-machine.ts +281 -281
- package/src/context/dialog.tsx +376 -376
- package/src/context/file.tsx +11 -11
- package/src/context/focus-rescue.tsx +230 -230
- package/src/context/helper.tsx +43 -43
- package/src/context/highlight-theme.tsx +66 -66
- package/src/context/i18n.tsx +144 -144
- package/src/context/index.ts +7 -7
- package/src/context/marked-base.tsx +67 -67
- package/src/context/marked-parser.tsx +154 -154
- package/src/context/overlay-focus.tsx +90 -90
- package/src/custom-elements.d.ts +17 -17
- package/src/data-display/accordion/accordion.css +130 -130
- package/src/data-display/accordion/accordion.stories.tsx +76 -76
- package/src/data-display/accordion/accordion.tsx +106 -106
- package/src/data-display/avatar/avatar.css +70 -70
- package/src/data-display/avatar/avatar.stories.tsx +48 -48
- package/src/data-display/avatar/avatar.tsx +63 -63
- package/src/data-display/badge/badge.css +63 -63
- package/src/data-display/badge/badge.stories.tsx +75 -75
- package/src/data-display/badge/badge.tsx +26 -26
- package/src/data-display/diff-changes/diff-changes.css +47 -47
- package/src/data-display/diff-changes/diff-changes.stories.tsx +63 -63
- package/src/data-display/diff-changes/diff-changes.tsx +43 -43
- package/src/data-display/keybind/keybind.css +84 -84
- package/src/data-display/keybind/keybind.stories.tsx +77 -77
- package/src/data-display/keybind/keybind.tsx +31 -31
- package/src/data-display/line-comment/line-comment.css +341 -341
- package/src/data-display/line-comment/line-comment.stories.tsx +288 -288
- package/src/data-display/line-comment/line-comment.tsx +554 -554
- package/src/data-display/line-comment/machine.ts +400 -400
- package/src/data-display/line-comment/quote-check.svg +3 -3
- package/src/data-display/project-avatar/animation-machine.ts +182 -182
- package/src/data-display/project-avatar/animation.ts +133 -133
- package/src/data-display/project-avatar/generated.ts +225 -225
- package/src/data-display/project-avatar/procedural-craft.ts +1079 -1079
- package/src/data-display/project-avatar/procedural-kit.ts +244 -244
- package/src/data-display/project-avatar/procedural-machine.ts +924 -924
- package/src/data-display/project-avatar/procedural-world.ts +1542 -1542
- package/src/data-display/project-avatar/procedural.ts +1563 -1563
- package/src/data-display/project-avatar/project-avatar.css +189 -189
- package/src/data-display/project-avatar/project-avatar.stories.tsx +102 -102
- package/src/data-display/project-avatar/project-avatar.tsx +246 -246
- package/src/data-display/project-avatar/project-icon-styles.stories.tsx +772 -772
- package/src/feedback/activity-ring/activity-ring.css +5 -5
- package/src/feedback/activity-ring/activity-ring.stories.tsx +20 -20
- package/src/feedback/activity-ring/activity-ring.tsx +15 -15
- package/src/feedback/loader/loader.css +32 -32
- package/src/feedback/loader/loader.stories.tsx +44 -44
- package/src/feedback/loader/loader.tsx +34 -34
- package/src/feedback/progress-circle/progress-circle.css +28 -28
- package/src/feedback/progress-circle/progress-circle.stories.tsx +56 -56
- package/src/feedback/progress-circle/progress-circle.tsx +64 -64
- package/src/feedback/toast/description.ts +10 -10
- package/src/feedback/toast/machine.ts +115 -115
- package/src/feedback/toast/toast.css +234 -234
- package/src/feedback/toast/toast.stories.tsx +186 -186
- package/src/feedback/toast/toast.tsx +317 -317
- package/src/forms/checkbox/checkbox-compact.css +170 -170
- package/src/forms/checkbox/checkbox.css +125 -125
- package/src/forms/checkbox/checkbox.stories.tsx +104 -104
- package/src/forms/checkbox/checkbox.tsx +119 -119
- package/src/forms/field/field.css +94 -94
- package/src/forms/field/field.stories.tsx +129 -129
- package/src/forms/field/field.tsx +271 -271
- package/src/forms/inline-input/inline-input.css +16 -16
- package/src/forms/inline-input/inline-input.stories.tsx +37 -37
- package/src/forms/inline-input/inline-input.tsx +26 -26
- package/src/forms/radio/radio.css +218 -218
- package/src/forms/radio/radio.stories.tsx +145 -145
- package/src/forms/radio/radio.tsx +95 -95
- package/src/forms/redirect-paste/redirect-paste.stories.tsx +101 -101
- package/src/forms/redirect-paste/redirect-paste.tsx +92 -92
- package/src/forms/search-list/navigation.ts +54 -54
- package/src/forms/search-list/search-list.css +249 -249
- package/src/forms/search-list/search-list.stories.tsx +108 -108
- package/src/forms/search-list/search-list.tsx +463 -463
- package/src/forms/select/machine.ts +81 -81
- package/src/forms/select/select.css +312 -312
- package/src/forms/select/select.stories.tsx +208 -208
- package/src/forms/select/select.tsx +281 -281
- package/src/forms/switch/switch.css +281 -281
- package/src/forms/switch/switch.stories.tsx +97 -97
- package/src/forms/switch/switch.tsx +35 -35
- package/src/forms/text-input/text-input.css +229 -229
- package/src/forms/text-input/text-input.stories.tsx +220 -220
- package/src/forms/text-input/text-input.tsx +115 -115
- package/src/forms/textarea/textarea.css +103 -103
- package/src/forms/textarea/textarea.stories.tsx +137 -137
- package/src/forms/textarea/textarea.tsx +33 -33
- package/src/forms/typeahead/controller.ts +59 -59
- package/src/forms/typeahead/machine.ts +253 -253
- package/src/forms/typeahead/typeahead.stories.tsx +113 -113
- package/src/forms/typeahead/typeahead.tsx +239 -239
- package/src/hooks/auto-scroll-machine.ts +261 -261
- package/src/hooks/create-auto-scroll.tsx +196 -196
- package/src/hooks/index.ts +5 -5
- package/src/hooks/list-machine.ts +359 -359
- package/src/hooks/spin-phase.ts +116 -116
- package/src/hooks/use-filtered-list.tsx +132 -132
- package/src/i18n/am.ts +384 -384
- package/src/i18n/ar.ts +547 -547
- package/src/i18n/az.ts +386 -386
- package/src/i18n/bg.ts +386 -386
- package/src/i18n/bn.ts +393 -393
- package/src/i18n/br.ts +444 -444
- package/src/i18n/bs.ts +445 -445
- package/src/i18n/ca.ts +423 -423
- package/src/i18n/cs.ts +457 -457
- package/src/i18n/da.ts +407 -407
- package/src/i18n/de.ts +414 -414
- package/src/i18n/dv.ts +395 -395
- package/src/i18n/dz.ts +393 -393
- package/src/i18n/el.ts +388 -388
- package/src/i18n/en.ts +433 -433
- package/src/i18n/es.ts +443 -443
- package/src/i18n/et.ts +386 -386
- package/src/i18n/fa.ts +388 -388
- package/src/i18n/fi.ts +388 -388
- package/src/i18n/fo.ts +388 -388
- package/src/i18n/fr.ts +447 -447
- package/src/i18n/he.ts +422 -422
- package/src/i18n/hi.ts +392 -392
- package/src/i18n/hr.ts +422 -422
- package/src/i18n/hu.ts +388 -388
- package/src/i18n/hy.ts +389 -389
- package/src/i18n/id.ts +411 -411
- package/src/i18n/is.ts +388 -388
- package/src/i18n/it.ts +425 -425
- package/src/i18n/ja.ts +406 -406
- package/src/i18n/ka.ts +388 -388
- package/src/i18n/km.ts +389 -389
- package/src/i18n/ko.ts +408 -408
- package/src/i18n/lo.ts +387 -387
- package/src/i18n/lt.ts +457 -457
- package/src/i18n/lv.ts +421 -421
- package/src/i18n/mk.ts +387 -387
- package/src/i18n/mn.ts +386 -386
- package/src/i18n/ms.ts +389 -389
- package/src/i18n/my.ts +389 -389
- package/src/i18n/ne.ts +393 -393
- package/src/i18n/nl.ts +388 -388
- package/src/i18n/no.ts +413 -413
- package/src/i18n/pa.ts +394 -394
- package/src/i18n/pl.ts +476 -476
- package/src/i18n/ro.ts +423 -423
- package/src/i18n/ru.ts +475 -475
- package/src/i18n/si.ts +390 -390
- package/src/i18n/sk.ts +457 -457
- package/src/i18n/sl.ts +457 -457
- package/src/i18n/sq.ts +387 -387
- package/src/i18n/sr.ts +422 -422
- package/src/i18n/sv.ts +388 -388
- package/src/i18n/tg.ts +390 -390
- package/src/i18n/th.ts +407 -407
- package/src/i18n/tk.ts +386 -386
- package/src/i18n/tr.ts +412 -412
- package/src/i18n/uk.ts +480 -480
- package/src/i18n/ur.ts +394 -394
- package/src/i18n/uz.ts +390 -390
- package/src/i18n/vi.ts +387 -387
- package/src/i18n/zh.ts +408 -408
- package/src/i18n/zht.ts +408 -408
- package/src/icons/catalog.ts +638 -638
- package/src/icons/icon/icon.css +3 -3
- package/src/icons/icon/icon.stories.tsx +131 -131
- package/src/icons/icon/icon.tsx +106 -106
- package/src/icons/registry.ts +217 -217
- package/src/layout/divider/divider.css +11 -11
- package/src/layout/divider/divider.stories.tsx +38 -38
- package/src/layout/divider/divider.tsx +21 -21
- package/src/motion/README.md +113 -113
- package/src/motion/index.ts +13 -13
- package/src/motion/loop.ts +139 -139
- package/src/motion/reduced.ts +66 -66
- package/src/motion/slider.ts +45 -45
- package/src/motion/solid.ts +309 -309
- package/src/motion/spring.ts +125 -125
- package/src/motion/velocity.ts +46 -46
- package/src/motion/waapi.ts +89 -89
- package/src/motion-tuning-features.ts +161 -161
- package/src/motion-tuning-fields.ts +42 -42
- package/src/motion-tuning.ts +323 -323
- package/src/navigation/menu/machine.ts +109 -109
- package/src/navigation/menu/menu.css +313 -313
- package/src/navigation/menu/menu.stories.tsx +328 -328
- package/src/navigation/menu/menu.tsx +600 -600
- package/src/navigation/menu/submenu-machine.ts +67 -67
- package/src/navigation/segmented-control/machine.ts +72 -72
- package/src/navigation/segmented-control/segmented-control.css +113 -113
- package/src/navigation/segmented-control/segmented-control.stories.tsx +115 -115
- package/src/navigation/segmented-control/segmented-control.tsx +396 -396
- package/src/navigation/tab-state-indicator.stories.tsx +24 -24
- package/src/navigation/tab-state-indicator.tsx +38 -38
- package/src/navigation/tabs/tabs-current.css +244 -244
- package/src/navigation/tabs/tabs.css +676 -676
- package/src/navigation/tabs/tabs.stories.tsx +193 -193
- package/src/navigation/tabs/tabs.tsx +212 -212
- package/src/overlays/dialog/dialog.css +194 -194
- package/src/overlays/dialog/dialog.stories.tsx +365 -365
- package/src/overlays/dialog/dialog.tsx +192 -192
- package/src/overlays/mcp-sign-in/machine.ts +343 -343
- package/src/overlays/mcp-sign-in/mcp-sign-in.ts +159 -159
- package/src/overlays/tooltip/machine.ts +312 -312
- package/src/overlays/tooltip/tooltip.css +102 -102
- package/src/overlays/tooltip/tooltip.stories.tsx +155 -155
- package/src/overlays/tooltip/tooltip.tsx +290 -290
- package/src/storybook/fixtures.ts +51 -51
- package/src/storybook/scaffold.tsx +65 -65
- package/src/styles/animations.css +13 -13
- package/src/styles/base.css +441 -441
- package/src/styles/blue-tokens.stories.tsx +215 -215
- package/src/styles/colors.css +772 -772
- package/src/styles/file-tree.css +285 -285
- package/src/styles/index.css +42 -42
- package/src/styles/scrollbar.css +79 -79
- package/src/styles/tailwind/colors.css +288 -288
- package/src/styles/tailwind/index.css +113 -113
- package/src/styles/tailwind/utilities.css +17 -17
- package/src/styles/theme.css +640 -640
- package/src/styles/tokens/colors.css +172 -172
- package/src/styles/tokens/index.css +2 -2
- package/src/styles/tokens/theme.css +522 -522
- package/src/styles/utilities.css +93 -93
- package/src/theme/color.ts +290 -290
- package/src/theme/context.tsx +361 -361
- package/src/theme/desktop-theme.schema.json +168 -168
- package/src/theme/index.ts +35 -35
- package/src/theme/machine.ts +508 -508
- package/src/theme/resolve.ts +561 -561
- package/src/theme/themes/amoled.json +49 -49
- package/src/theme/themes/aura.json +51 -51
- package/src/theme/themes/ayu.json +51 -51
- package/src/theme/themes/carbonfox.json +53 -53
- package/src/theme/themes/catppuccin-frappe.json +65 -65
- package/src/theme/themes/catppuccin-macchiato.json +65 -65
- package/src/theme/themes/catppuccin.json +45 -45
- package/src/theme/themes/cobalt2.json +87 -87
- package/src/theme/themes/cursor.json +91 -91
- package/src/theme/themes/dracula.json +49 -49
- package/src/theme/themes/everforest.json +89 -89
- package/src/theme/themes/flexoki.json +86 -86
- package/src/theme/themes/github.json +85 -85
- package/src/theme/themes/gruvbox.json +45 -45
- package/src/theme/themes/kanagawa.json +89 -89
- package/src/theme/themes/lucent-orng.json +87 -87
- package/src/theme/themes/material.json +87 -87
- package/src/theme/themes/matrix.json +113 -113
- package/src/theme/themes/mercury.json +86 -86
- package/src/theme/themes/monokai.json +49 -49
- package/src/theme/themes/nightowl.json +46 -46
- package/src/theme/themes/nord.json +46 -46
- package/src/theme/themes/oc-2.json +509 -509
- package/src/theme/themes/one-dark.json +89 -89
- package/src/theme/themes/onedarkpro.json +45 -45
- package/src/theme/themes/orng.json +87 -87
- package/src/theme/themes/osaka-jade.json +88 -88
- package/src/theme/themes/palenight.json +85 -85
- package/src/theme/themes/rosepine.json +85 -85
- package/src/theme/themes/shadesofpurple.json +51 -51
- package/src/theme/themes/solarized.json +49 -49
- package/src/theme/themes/synthwave84.json +87 -87
- package/src/theme/themes/tokyonight.json +47 -47
- package/src/theme/themes/vercel.json +90 -90
- package/src/theme/themes/vesper.json +51 -51
- package/src/theme/themes/zenburn.json +87 -87
- package/src/theme/types.ts +75 -75
- package/src/theme/v2/avatar.ts +48 -48
- package/src/theme/v2/default-primitives.ts +114 -114
- package/src/theme/v2/foreground.ts +69 -69
- package/src/theme/v2/mapping.ts +180 -180
- package/src/theme/v2/resolve.ts +163 -163
- package/src/typography/slash/slash.css +14 -14
- package/src/typography/slash/slash.stories.tsx +26 -26
- package/src/typography/slash/slash.tsx +16 -16
- package/src/typography/text-shimmer/machine.ts +90 -90
- package/src/typography/text-shimmer/text-shimmer.css +152 -152
- package/src/typography/text-shimmer/text-shimmer.stories.tsx +64 -64
- package/src/typography/text-shimmer/text-shimmer.tsx +81 -81
- package/src/typography/wordmark/wordmark.stories.tsx +19 -19
- package/src/typography/wordmark/wordmark.tsx +73 -73
- package/test/solid-jsx.ts +20 -20
- package/tsconfig.build.json +14 -14
- package/tsconfig.json +23 -23
- package/vite.config.ts +61 -61
- package/src/components/animated-number-machine.test.ts +0 -140
- package/src/components/file-icon-machine.test.ts +0 -52
- package/src/components/image-flight-machine.test.ts +0 -184
- package/src/components/image-flight.test.ts +0 -173
- package/src/components/image-zoom-machine.test.ts +0 -154
- package/src/components/image-zoom.test.ts +0 -96
- package/src/components/popover-machine.test.ts +0 -150
- package/src/components/resize-handle-machine.test.ts +0 -164
- package/src/components/scroll-view-machine.test.ts +0 -141
- package/src/components/scroll-view.test.ts +0 -114
- package/src/components/spinner-radar.test.ts +0 -61
- package/src/components/text-field-machine.test.ts +0 -99
- package/src/components/text-reveal-machine.test.ts +0 -157
- package/src/components/typewriter-machine.test.ts +0 -177
- package/src/context/dialog-machine.test.ts +0 -295
- package/src/context/i18n.test.ts +0 -89
- package/src/context/marked-base.test.ts +0 -75
- package/src/context/marked-parser.test.ts +0 -167
- package/src/context/marked-regression.test.ts +0 -12
- package/src/data-display/line-comment/machine.test.ts +0 -385
- package/src/data-display/project-avatar/animation-machine.test.ts +0 -134
- package/src/data-display/project-avatar/generated.test.ts +0 -50
- package/src/data-display/project-avatar/procedural.test.ts +0 -16
- package/src/data-display/project-avatar/project-avatar.test.ts +0 -21
- package/src/feedback/toast/description.test.ts +0 -20
- package/src/feedback/toast/machine.test.ts +0 -106
- package/src/forms/search-list/navigation.test.ts +0 -40
- package/src/forms/select/machine.test.ts +0 -105
- package/src/forms/typeahead/machine.test.ts +0 -143
- package/src/hooks/auto-scroll-machine.test.ts +0 -212
- package/src/hooks/list-machine.test.ts +0 -263
- package/src/hooks/spin-phase.test.ts +0 -32
- package/src/hooks/use-filtered-list.test.ts +0 -41
- package/src/motion/core.test.ts +0 -328
- package/src/motion-tuning-features.test.ts +0 -129
- package/src/motion-tuning.test.ts +0 -68
- package/src/navigation/menu/machine.test.ts +0 -85
- package/src/navigation/menu/submenu-machine.test.ts +0 -71
- package/src/navigation/segmented-control/segmented-control.test.ts +0 -123
- package/src/overlays/mcp-sign-in/machine.test.ts +0 -215
- package/src/overlays/tooltip/machine.test.ts +0 -214
- package/src/theme/machine.test.ts +0 -498
- package/src/theme/v2/resolve.test.ts +0 -120
- package/src/typography/text-shimmer/machine.test.ts +0 -117
|
@@ -1,184 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import type { FlightFrame } from "./image-flight"
|
|
3
|
-
import {
|
|
4
|
-
INITIAL_PREVIEW_FLIGHT_STATE,
|
|
5
|
-
selectFlightInteractive,
|
|
6
|
-
selectFlightStage,
|
|
7
|
-
selectVideoAtRest,
|
|
8
|
-
transitionPreviewFlight,
|
|
9
|
-
type PreviewFlightEffect,
|
|
10
|
-
type PreviewFlightEvent,
|
|
11
|
-
type PreviewFlightStage,
|
|
12
|
-
type PreviewFlightState,
|
|
13
|
-
} from "./image-flight-machine"
|
|
14
|
-
|
|
15
|
-
const box = { x: 10, y: 20, width: 80, height: 60 }
|
|
16
|
-
|
|
17
|
-
const origin: FlightFrame = { image: box, clip: box, radius: 6, surface: box, surfaceRadius: 6, lift: 0 }
|
|
18
|
-
|
|
19
|
-
type Replay = { state: PreviewFlightState; effects: readonly PreviewFlightEffect[]; stages: PreviewFlightStage[] }
|
|
20
|
-
|
|
21
|
-
function replay(events: PreviewFlightEvent[], from = INITIAL_PREVIEW_FLIGHT_STATE) {
|
|
22
|
-
return events.reduce<Replay>(
|
|
23
|
-
(result, event) => {
|
|
24
|
-
const next = transitionPreviewFlight(result.state, event)
|
|
25
|
-
|
|
26
|
-
return { state: next.state, effects: next.effects, stages: [...result.stages, selectFlightStage(next.state)] }
|
|
27
|
-
},
|
|
28
|
-
{ state: from, effects: [], stages: [] },
|
|
29
|
-
)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const flyingOpen: PreviewFlightEvent[] = [{ type: "image.loaded" }, { type: "decode.ready", attempt: 1, origin }]
|
|
33
|
-
|
|
34
|
-
describe("image preview flight", () => {
|
|
35
|
-
test("opens by flying out of a visible origin and lands at rest", () => {
|
|
36
|
-
const opening = replay(flyingOpen)
|
|
37
|
-
|
|
38
|
-
expect(opening.state).toEqual({ status: "opening", mode: "flight", borrowed: false })
|
|
39
|
-
expect(opening.effects).toEqual([
|
|
40
|
-
{ type: "decode.cancel" },
|
|
41
|
-
{ type: "origin.hide" },
|
|
42
|
-
{ type: "open.flight", from: origin },
|
|
43
|
-
])
|
|
44
|
-
expect(opening.stages).toEqual(["pending", "flying"])
|
|
45
|
-
|
|
46
|
-
const open = transitionPreviewFlight(opening.state, { type: "motion.settled" })
|
|
47
|
-
expect(open.state).toEqual({ status: "open", originHidden: true, borrowed: false })
|
|
48
|
-
expect(selectFlightStage(open.state)).toBe("rest")
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
test("opens by fading without an origin, and when the image fails to load", () => {
|
|
52
|
-
expect(replay([{ type: "image.loaded" }, { type: "decode.ready", attempt: 1, origin: undefined }]).effects).toEqual(
|
|
53
|
-
[{ type: "decode.cancel" }, { type: "open.fade" }],
|
|
54
|
-
)
|
|
55
|
-
const failed = replay([{ type: "image.failed" }])
|
|
56
|
-
expect(failed.state).toEqual({ status: "opening", mode: "fade", borrowed: false })
|
|
57
|
-
expect(failed.effects).toEqual([{ type: "open.fade" }])
|
|
58
|
-
expect(selectFlightStage(failed.state)).toBe("rest")
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
// Bug: closing mid-flight once the origin scrolled away kept the opening flight running, left the origin hidden,
|
|
62
|
-
// and its landing flipped data-stage back to "rest" in the middle of the close.
|
|
63
|
-
test("a close mid-flight with the origin gone fades out, shows the origin and never returns to rest", () => {
|
|
64
|
-
const opening = replay(flyingOpen).state
|
|
65
|
-
const closing = replay([{ type: "close.started", origin: undefined }, { type: "motion.settled" }], opening)
|
|
66
|
-
|
|
67
|
-
expect(transitionPreviewFlight(opening, { type: "close.started", origin: undefined }).effects).toEqual([
|
|
68
|
-
{ type: "body.closing.acquire" },
|
|
69
|
-
{ type: "zoom.settle" },
|
|
70
|
-
{ type: "origin.show" },
|
|
71
|
-
{ type: "close.fade" },
|
|
72
|
-
])
|
|
73
|
-
expect(closing.stages).toEqual(["closing", "closing"])
|
|
74
|
-
expect(closing.state).toEqual({ status: "closed" })
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
// Bug: a fading close left data-stage at "rest", so a borrowed video kept taking clicks and the window keys and
|
|
78
|
-
// wheel stayed captured for the whole exit.
|
|
79
|
-
test("a fading close of a video stops taking input and hands the video back once it fades", () => {
|
|
80
|
-
const open = replay([{ type: "video.ready", origin }, { type: "motion.settled" }]).state
|
|
81
|
-
const closing = transitionPreviewFlight(open, { type: "close.started", origin: undefined })
|
|
82
|
-
|
|
83
|
-
expect(closing.effects).toEqual([
|
|
84
|
-
{ type: "body.closing.acquire" },
|
|
85
|
-
{ type: "zoom.fit" },
|
|
86
|
-
{ type: "origin.show" },
|
|
87
|
-
{ type: "close.fade" },
|
|
88
|
-
])
|
|
89
|
-
expect(selectFlightStage(closing.state)).toBe("closing")
|
|
90
|
-
expect(selectFlightInteractive(closing.state)).toBe(false)
|
|
91
|
-
expect(selectVideoAtRest(closing.state)).toBe(true)
|
|
92
|
-
expect(transitionPreviewFlight(closing.state, { type: "motion.settled" })).toEqual({
|
|
93
|
-
state: { status: "closed" },
|
|
94
|
-
effects: [{ type: "video.return" }],
|
|
95
|
-
})
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
// Bug: reveal awaited decode with no claim, so a decode that settled after the image changed revealed it anyway.
|
|
99
|
-
test("a decode of an image that changed or loaded again is ignored", () => {
|
|
100
|
-
const reloaded = replay([{ type: "image.loaded" }, { type: "src.changed" }, { type: "image.loaded" }])
|
|
101
|
-
|
|
102
|
-
expect(reloaded.state).toEqual({ status: "decoding", attempt: 3 })
|
|
103
|
-
expect(reloaded.effects).toEqual([{ type: "decode.start", attempt: 3 }])
|
|
104
|
-
|
|
105
|
-
const stale = transitionPreviewFlight(reloaded.state, { type: "decode.ready", attempt: 1, origin })
|
|
106
|
-
expect(stale.state).toBe(reloaded.state)
|
|
107
|
-
expect(stale.effects).toEqual([])
|
|
108
|
-
expect(transitionPreviewFlight(reloaded.state, { type: "decode.ready", attempt: 3, origin }).state.status).toBe(
|
|
109
|
-
"opening",
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
const again = transitionPreviewFlight({ status: "decoding", attempt: 1 }, { type: "image.loaded" })
|
|
113
|
-
expect(again.effects).toEqual([{ type: "decode.cancel" }, { type: "decode.start", attempt: 2 }])
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
test("a close before the preview reveals ends it there, and a late decode is ignored", () => {
|
|
117
|
-
const closed = replay([{ type: "image.loaded" }, { type: "close.started", origin }])
|
|
118
|
-
|
|
119
|
-
expect(closed.state).toEqual({ status: "closed" })
|
|
120
|
-
expect(closed.effects).toEqual([{ type: "decode.cancel" }, { type: "body.closing.acquire" }])
|
|
121
|
-
expect(transitionPreviewFlight(closed.state, { type: "decode.ready", attempt: 1, origin }).state).toBe(closed.state)
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
test("a close mid-flight with the origin in sight turns the flight around, then veils the stand-in", () => {
|
|
125
|
-
const opening = replay(flyingOpen).state
|
|
126
|
-
const turned = transitionPreviewFlight(opening, { type: "close.started", origin })
|
|
127
|
-
|
|
128
|
-
expect(turned.effects).toEqual([
|
|
129
|
-
{ type: "body.closing.acquire" },
|
|
130
|
-
{ type: "zoom.settle" },
|
|
131
|
-
{ type: "close.flight", to: origin, turn: true },
|
|
132
|
-
])
|
|
133
|
-
|
|
134
|
-
const landed = transitionPreviewFlight(turned.state, { type: "motion.settled" })
|
|
135
|
-
expect(landed.state).toEqual({ status: "closing", mode: "veil", borrowed: false })
|
|
136
|
-
expect(landed.effects).toEqual([{ type: "origin.show" }, { type: "close.veil" }])
|
|
137
|
-
expect(selectFlightStage(landed.state)).toBe("flying")
|
|
138
|
-
expect(transitionPreviewFlight(landed.state, { type: "motion.settled" }).state).toEqual({ status: "closed" })
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
test("a close from a fade-opened preview hides the origin and flies home from rest", () => {
|
|
142
|
-
const open = replay([{ type: "image.failed" }, { type: "motion.settled" }]).state
|
|
143
|
-
|
|
144
|
-
expect(transitionPreviewFlight(open, { type: "close.started", origin }).effects).toEqual([
|
|
145
|
-
{ type: "body.closing.acquire" },
|
|
146
|
-
{ type: "zoom.settle" },
|
|
147
|
-
{ type: "origin.hide" },
|
|
148
|
-
{ type: "close.flight", to: origin, turn: false },
|
|
149
|
-
])
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
test("a video flying home is handed back as it lands", () => {
|
|
153
|
-
const open = replay([{ type: "video.ready", origin }, { type: "motion.settled" }]).state
|
|
154
|
-
const closing = transitionPreviewFlight(open, { type: "close.started", origin })
|
|
155
|
-
|
|
156
|
-
expect(closing.effects.at(-1)).toEqual({ type: "close.flight", to: origin, turn: false })
|
|
157
|
-
expect(transitionPreviewFlight(closing.state, { type: "motion.settled" })).toEqual({
|
|
158
|
-
state: { status: "closed" },
|
|
159
|
-
effects: [{ type: "origin.show" }, { type: "video.return" }],
|
|
160
|
-
})
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
// A throttled frame loop can let the dialog unmount before the close lands.
|
|
164
|
-
test("disposal tears down what each phase holds, once", () => {
|
|
165
|
-
const flying: PreviewFlightState = { status: "closing", mode: "flight", borrowed: true }
|
|
166
|
-
|
|
167
|
-
expect(transitionPreviewFlight(flying, { type: "disposed" }).effects).toEqual([
|
|
168
|
-
{ type: "loop.stop" },
|
|
169
|
-
{ type: "origin.show" },
|
|
170
|
-
{ type: "video.return" },
|
|
171
|
-
{ type: "body.closing.release" },
|
|
172
|
-
])
|
|
173
|
-
expect(transitionPreviewFlight({ status: "closed" }, { type: "disposed" }).effects).toEqual([
|
|
174
|
-
{ type: "body.closing.release" },
|
|
175
|
-
])
|
|
176
|
-
expect(transitionPreviewFlight({ status: "decoding", attempt: 2 }, { type: "disposed" }).effects).toEqual([
|
|
177
|
-
{ type: "decode.cancel" },
|
|
178
|
-
])
|
|
179
|
-
|
|
180
|
-
const disposed = transitionPreviewFlight(flying, { type: "disposed" }).state
|
|
181
|
-
expect(transitionPreviewFlight(disposed, { type: "motion.settled" }).state).toBe(disposed)
|
|
182
|
-
expect(transitionPreviewFlight(disposed, { type: "disposed" }).effects).toEqual([])
|
|
183
|
-
})
|
|
184
|
-
})
|
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { createFlight, elementFrame, fittedImage, flightStyle, KICK, type FlightFrame } from "./image-flight"
|
|
3
|
-
|
|
4
|
-
// A 1600×900 screenshot.
|
|
5
|
-
const natural = { width: 1600, height: 900 }
|
|
6
|
-
|
|
7
|
-
describe("fittedImage", () => {
|
|
8
|
-
test("covers a box of another shape, overflowing it evenly", () => {
|
|
9
|
-
// A 58×46 thumbnail is taller than 16:9, so the image fills its height and overflows its width.
|
|
10
|
-
expect(fittedImage({ x: 100, y: 200, width: 58, height: 46 }, natural, "cover")).toEqual({
|
|
11
|
-
x: 100 - (46 * (16 / 9) - 58) / 2,
|
|
12
|
-
y: 200,
|
|
13
|
-
width: 46 * (16 / 9),
|
|
14
|
-
height: 46,
|
|
15
|
-
})
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test("contains within a box, letterboxed evenly", () => {
|
|
19
|
-
expect(fittedImage({ x: 0, y: 0, width: 400, height: 400 }, natural, "contain")).toEqual({
|
|
20
|
-
x: 0,
|
|
21
|
-
y: 87.5,
|
|
22
|
-
width: 400,
|
|
23
|
-
height: 225,
|
|
24
|
-
})
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
test("matches the box when the shapes agree", () => {
|
|
28
|
-
const box = { x: 10, y: 20, width: 320, height: 180 }
|
|
29
|
-
|
|
30
|
-
expect(fittedImage(box, natural, "fill")).toEqual(box)
|
|
31
|
-
expect(fittedImage(box, natural, "contain")).toEqual(box)
|
|
32
|
-
})
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
describe("flightStyle", () => {
|
|
36
|
-
const base = { x: 200, y: 100, width: 800, height: 450 }
|
|
37
|
-
|
|
38
|
-
test("is the identity at the base frame", () => {
|
|
39
|
-
expect(flightStyle(base, { image: base, clip: base, radius: 6 })).toEqual({
|
|
40
|
-
transform: "translate(0px, 0px) scale(1)",
|
|
41
|
-
clipPath: "inset(0px 0px 0px 0px round 6px)",
|
|
42
|
-
})
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
test("shrinks uniformly onto an uncropped thumbnail, keeping its on-screen radius", () => {
|
|
46
|
-
const thumbnail = { x: 40, y: 600, width: 320, height: 180 }
|
|
47
|
-
|
|
48
|
-
expect(flightStyle(base, { image: thumbnail, clip: thumbnail, radius: 6 })).toEqual({
|
|
49
|
-
transform: "translate(-160px, 500px) scale(0.4)",
|
|
50
|
-
clipPath: "inset(0px 0px 0px 0px round 15px)",
|
|
51
|
-
})
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
test("crops to a cover thumbnail instead of squashing the image", () => {
|
|
55
|
-
const frame = elementFrame({ x: 100, y: 200, width: 40, height: 45 }, natural, "cover", 6)
|
|
56
|
-
const style = flightStyle(base, frame)
|
|
57
|
-
// The image is 80×45 on screen, half the base, and 20px of it hangs past each side of the box.
|
|
58
|
-
expect(frame.image).toEqual({ x: 80, y: 200, width: 80, height: 45 })
|
|
59
|
-
expect(style).toEqual({
|
|
60
|
-
transform: "translate(-120px, 100px) scale(0.1)",
|
|
61
|
-
clipPath: "inset(0px 200px 0px 200px round 60px)",
|
|
62
|
-
})
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
test("clips a zoomed image to the viewport it is seen through", () => {
|
|
66
|
-
const image = { x: -200, y: -125, width: 1600, height: 900 }
|
|
67
|
-
const clip = { x: 0, y: 0, width: 1200, height: 650 }
|
|
68
|
-
|
|
69
|
-
expect(flightStyle(base, { image, clip, radius: 0 })).toEqual({
|
|
70
|
-
transform: "translate(-400px, -225px) scale(2)",
|
|
71
|
-
clipPath: "inset(62.5px 100px 62.5px 100px round 0px)",
|
|
72
|
-
})
|
|
73
|
-
})
|
|
74
|
-
})
|
|
75
|
-
|
|
76
|
-
describe("elementFrame", () => {
|
|
77
|
-
test("starts from the part the page shows, under a sticky bar, with the panel lying flat on it", () => {
|
|
78
|
-
const box = { x: 100, y: 20, width: 640, height: 360 }
|
|
79
|
-
const frame = elementFrame(box, natural, "fill", 4, { x: 0, y: 48, width: 1280, height: 752 })
|
|
80
|
-
|
|
81
|
-
expect(frame.image).toEqual(box)
|
|
82
|
-
expect(frame.clip).toEqual({ x: 100, y: 48, width: 640, height: 332 })
|
|
83
|
-
expect(frame.surface).toEqual(frame.clip)
|
|
84
|
-
expect(frame.surfaceRadius).toBe(4)
|
|
85
|
-
expect(frame.lift).toBe(0)
|
|
86
|
-
})
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
describe("createFlight", () => {
|
|
90
|
-
const box = (x: number, width: number) => ({ x, y: 100, width, height: width * 0.75 })
|
|
91
|
-
|
|
92
|
-
const frame = (x: number, width: number, radius: number, lift: number): FlightFrame => ({
|
|
93
|
-
image: box(x, width),
|
|
94
|
-
clip: box(x, width),
|
|
95
|
-
radius,
|
|
96
|
-
// On the page the panel is the image itself; open, it is a wider panel around it.
|
|
97
|
-
surface: lift ? { x: x - 120, y: 60, width: width + 240, height: width * 0.75 + 96 } : box(x, width),
|
|
98
|
-
surfaceRadius: lift ? 10 : radius,
|
|
99
|
-
lift,
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
const thumbnail = frame(495, 285, 8, 0)
|
|
103
|
-
|
|
104
|
-
const preview = frame(314, 651, 6, 1)
|
|
105
|
-
|
|
106
|
-
const progress = (flight: ReturnType<typeof createFlight>) =>
|
|
107
|
-
(flight.frame().image.width - thumbnail.image.width) / (preview.image.width - thumbnail.image.width)
|
|
108
|
-
|
|
109
|
-
test("opens fast and settles without overshoot, like Claude's measured preview", () => {
|
|
110
|
-
const flight = createFlight(thumbnail)
|
|
111
|
-
flight.to(preview, KICK.open, { duration: 0.2, bounce: 0 })
|
|
112
|
-
const path = Array.from({ length: 30 }, () => (flight.step(1 / 60), progress(flight)))
|
|
113
|
-
|
|
114
|
-
// Measured at 0.2 s: 25% after one frame, 61% after three, 91% after seven.
|
|
115
|
-
expect(path[0]).toBeCloseTo(0.25, 1)
|
|
116
|
-
expect(path[2]).toBeCloseTo(0.61, 1)
|
|
117
|
-
expect(path[6]).toBeCloseTo(0.91, 1)
|
|
118
|
-
path.forEach((value) => expect(value).toBeLessThanOrEqual(1))
|
|
119
|
-
expect(flight.frame()).toEqual(preview)
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
test("grows the panel out of the image on the same flight, lifting it as it lands", () => {
|
|
123
|
-
const flight = createFlight(thumbnail)
|
|
124
|
-
flight.to(preview, KICK.open)
|
|
125
|
-
const path = Array.from({ length: 30 }, () => (flight.step(1 / 60), flight.frame()))
|
|
126
|
-
|
|
127
|
-
path.slice(1).forEach((frame, index) => {
|
|
128
|
-
expect(frame.lift).toBeGreaterThanOrEqual(path[index].lift)
|
|
129
|
-
expect(frame.surface.width).toBeGreaterThanOrEqual(path[index].surface.width)
|
|
130
|
-
})
|
|
131
|
-
// The lift keeps pace with the image's growth, so the shadow rises as the panel does.
|
|
132
|
-
path.forEach((frame) =>
|
|
133
|
-
expect(frame.lift).toBeCloseTo(
|
|
134
|
-
(frame.image.width - thumbnail.image.width) / (preview.image.width - thumbnail.image.width),
|
|
135
|
-
2,
|
|
136
|
-
),
|
|
137
|
-
)
|
|
138
|
-
expect(flight.frame()).toEqual(preview)
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
test("keeps its launch shape on a slower spring, stretched in time", () => {
|
|
142
|
-
const snappy = createFlight(thumbnail)
|
|
143
|
-
const calm = createFlight(thumbnail)
|
|
144
|
-
snappy.to(preview, KICK.open)
|
|
145
|
-
calm.to(preview, KICK.open, { duration: 0.6, bounce: 0 })
|
|
146
|
-
snappy.step(1 / 60)
|
|
147
|
-
calm.step(2 / 60)
|
|
148
|
-
|
|
149
|
-
expect(progress(calm)).toBeCloseTo(progress(snappy), 5)
|
|
150
|
-
})
|
|
151
|
-
|
|
152
|
-
test("turns around mid-flight from where it is, carrying its velocity", () => {
|
|
153
|
-
const flight = createFlight(thumbnail)
|
|
154
|
-
flight.to(preview, KICK.open)
|
|
155
|
-
Array.from({ length: 4 }, () => flight.step(1 / 60))
|
|
156
|
-
const turn = flight.frame()
|
|
157
|
-
flight.to(thumbnail, KICK.close)
|
|
158
|
-
|
|
159
|
-
expect(flight.frame()).toEqual(turn)
|
|
160
|
-
|
|
161
|
-
// A fresh close launched from the same frame, at rest, moves further on its first frame than the reversed flight,
|
|
162
|
-
// which first has to cancel the outward velocity it still carries.
|
|
163
|
-
const fresh = createFlight(turn)
|
|
164
|
-
fresh.to(thumbnail, KICK.close)
|
|
165
|
-
flight.step(1 / 60)
|
|
166
|
-
fresh.step(1 / 60)
|
|
167
|
-
expect(turn.image.width - flight.frame().image.width).toBeGreaterThan(0)
|
|
168
|
-
expect(turn.image.width - flight.frame().image.width).toBeLessThan(turn.image.width - fresh.frame().image.width)
|
|
169
|
-
|
|
170
|
-
while (flight.step(1 / 60));
|
|
171
|
-
expect(flight.frame()).toEqual(thumbnail)
|
|
172
|
-
})
|
|
173
|
-
})
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import {
|
|
3
|
-
INITIAL_PREVIEW_ZOOM_STATE,
|
|
4
|
-
selectDragging,
|
|
5
|
-
selectPanPointer,
|
|
6
|
-
transitionPreviewZoom,
|
|
7
|
-
type PreviewZoomEffect,
|
|
8
|
-
type PreviewZoomEvent,
|
|
9
|
-
type PreviewZoomState,
|
|
10
|
-
} from "./image-zoom-machine"
|
|
11
|
-
|
|
12
|
-
function replay(events: PreviewZoomEvent[], from = INITIAL_PREVIEW_ZOOM_STATE) {
|
|
13
|
-
return events.reduce<{ state: PreviewZoomState; effects: PreviewZoomEffect[] }>(
|
|
14
|
-
(result, event) => {
|
|
15
|
-
const next = transitionPreviewZoom(result.state, event)
|
|
16
|
-
|
|
17
|
-
return { state: next.state, effects: [...result.effects, ...next.effects] }
|
|
18
|
-
},
|
|
19
|
-
{ state: from, effects: [] },
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function down(target: "viewport" | "video" | "content", options: { zoomed?: boolean; onBackdrop?: boolean } = {}) {
|
|
24
|
-
return {
|
|
25
|
-
type: "pointer.down",
|
|
26
|
-
pointerId: 1,
|
|
27
|
-
button: 0,
|
|
28
|
-
target,
|
|
29
|
-
onBackdrop: options.onBackdrop ?? false,
|
|
30
|
-
zoomed: options.zoomed ?? true,
|
|
31
|
-
} satisfies PreviewZoomEvent
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const moved = { type: "pointer.moved", pointerId: 1 } satisfies PreviewZoomEvent
|
|
35
|
-
|
|
36
|
-
const up = { type: "pointer.up", pointerId: 1 } satisfies PreviewZoomEvent
|
|
37
|
-
|
|
38
|
-
describe("image preview zoom gesture", () => {
|
|
39
|
-
// Bug: nothing ended a pan whose pointer capture was lost without a pointerup, so plain hover with the same mouse
|
|
40
|
-
// pointer kept panning the image under a grabbing cursor. The driver sends `pointer.cancel` on lostpointercapture
|
|
41
|
-
// and on a move with the primary button up.
|
|
42
|
-
test("a pan that loses its pointer ends", () => {
|
|
43
|
-
const panning = replay([down("viewport"), moved])
|
|
44
|
-
|
|
45
|
-
expect(selectDragging(panning.state)).toBe(true)
|
|
46
|
-
expect(panning.effects).toEqual([{ type: "pointer.capture", target: "viewport", pointerId: 1 }])
|
|
47
|
-
|
|
48
|
-
const ended = transitionPreviewZoom(panning.state, { type: "pointer.cancel", pointerId: 1 })
|
|
49
|
-
expect(selectDragging(ended.state)).toBe(false)
|
|
50
|
-
expect(selectPanPointer(ended.state, 1)).toBe(false)
|
|
51
|
-
expect(ended.effects).toEqual([{ type: "pointer.release", target: "viewport", pointerId: 1 }])
|
|
52
|
-
expect(transitionPreviewZoom(ended.state, moved).state).toBe(ended.state)
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
// Bug: Escape or 0 during a press glided back to fit and left the pan, and its grabbing cursor, on a fitted image.
|
|
56
|
-
test("an eased zoom takes over from a pan", () => {
|
|
57
|
-
const glide = replay([down("viewport"), moved, { type: "glide.start" }])
|
|
58
|
-
|
|
59
|
-
expect(glide.state).toEqual({ status: "gliding", gesture: { type: "idle" } })
|
|
60
|
-
expect(glide.effects.slice(1)).toEqual([
|
|
61
|
-
{ type: "pointer.release", target: "viewport", pointerId: 1 },
|
|
62
|
-
{ type: "glide.loop.start" },
|
|
63
|
-
])
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
test("a press does not stop a glide, the hand moving does, and a pan ends once the image is back at fit", () => {
|
|
67
|
-
const pressed = replay([{ type: "glide.start" }, down("viewport")])
|
|
68
|
-
|
|
69
|
-
expect(pressed.state.status).toBe("gliding")
|
|
70
|
-
expect(selectDragging(pressed.state)).toBe(true)
|
|
71
|
-
|
|
72
|
-
const followed = transitionPreviewZoom(pressed.state, { type: "follow", zoomed: true })
|
|
73
|
-
expect(followed.state.status).toBe("still")
|
|
74
|
-
expect(followed.effects).toEqual([{ type: "glide.loop.stop" }])
|
|
75
|
-
|
|
76
|
-
const settled = transitionPreviewZoom(pressed.state, { type: "glide.settled", zoomed: false })
|
|
77
|
-
expect(settled.state).toEqual({ status: "still", gesture: { type: "idle" } })
|
|
78
|
-
expect(settled.effects).toEqual([
|
|
79
|
-
{ type: "glide.loop.stop" },
|
|
80
|
-
{ type: "pointer.release", target: "viewport", pointerId: 1 },
|
|
81
|
-
])
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
// Bug: the "panned" flag outlived its gesture, so a later click on the video's controls was swallowed.
|
|
85
|
-
test("only the release of a moved video pan swallows its click", () => {
|
|
86
|
-
expect(replay([down("video"), moved, up]).effects.at(-1)).toEqual({ type: "video.suppress-click" })
|
|
87
|
-
expect(replay([down("video"), up]).effects).toEqual([{ type: "pointer.capture", target: "video", pointerId: 1 }])
|
|
88
|
-
expect(replay([down("video"), moved, { type: "pointer.cancel", pointerId: 1 }]).effects.at(-1)).toEqual({
|
|
89
|
-
type: "pointer.release",
|
|
90
|
-
target: "video",
|
|
91
|
-
pointerId: 1,
|
|
92
|
-
})
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
test.each([
|
|
96
|
-
["an unzoomed press on the backdrop closes", [down("viewport", { zoomed: false, onBackdrop: true })], true],
|
|
97
|
-
["a press on the band around the body closes", [down("content", { onBackdrop: true })], true],
|
|
98
|
-
["a zoomed press on the backdrop that stays put closes", [down("viewport", { onBackdrop: true }), up], true],
|
|
99
|
-
[
|
|
100
|
-
"a zoomed press on the backdrop that stays put, then loses capture, closes",
|
|
101
|
-
[down("viewport", { onBackdrop: true }), up, { type: "pointer.cancel", pointerId: 1 } satisfies PreviewZoomEvent],
|
|
102
|
-
true,
|
|
103
|
-
],
|
|
104
|
-
["a zoomed press on the image, whose captured click lands on the backdrop, stays", [down("viewport"), up], false],
|
|
105
|
-
["a zoomed press on the backdrop that pans stays", [down("viewport", { onBackdrop: true }), moved, up], false],
|
|
106
|
-
["a press on a control stays", [down("content")], false],
|
|
107
|
-
])("on its click, %s", (_, events, closes) => {
|
|
108
|
-
const pressed = replay(events)
|
|
109
|
-
const clicked = transitionPreviewZoom(pressed.state, { type: "backdrop.click", onBackdrop: true })
|
|
110
|
-
|
|
111
|
-
expect(clicked.effects).toEqual(closes ? [{ type: "dialog.close" }] : [])
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
test("a secondary button or a second pointer leaves the pan alone; the same pointer again starts over", () => {
|
|
115
|
-
const panning = replay([down("viewport"), moved]).state
|
|
116
|
-
|
|
117
|
-
expect(transitionPreviewZoom(panning, { ...down("viewport"), pointerId: 2 }).state).toBe(panning)
|
|
118
|
-
expect(transitionPreviewZoom(panning, { type: "pointer.up", pointerId: 2 }).state).toBe(panning)
|
|
119
|
-
expect(transitionPreviewZoom(INITIAL_PREVIEW_ZOOM_STATE, { ...down("viewport"), button: 2 }).state).toBe(
|
|
120
|
-
INITIAL_PREVIEW_ZOOM_STATE,
|
|
121
|
-
)
|
|
122
|
-
|
|
123
|
-
const again = transitionPreviewZoom(panning, down("viewport"))
|
|
124
|
-
expect(again.state).toEqual({
|
|
125
|
-
status: "still",
|
|
126
|
-
gesture: { type: "panning", pointerId: 1, target: "viewport", onBackdrop: false, moved: false },
|
|
127
|
-
})
|
|
128
|
-
expect(again.effects).toEqual([{ type: "pointer.capture", target: "viewport", pointerId: 1 }])
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
test("moves that change nothing answer with the same transition, so a pan allocates nothing", () => {
|
|
132
|
-
const panning = replay([down("viewport"), moved]).state
|
|
133
|
-
const first = transitionPreviewZoom(panning, moved)
|
|
134
|
-
|
|
135
|
-
expect(first.state).toBe(panning)
|
|
136
|
-
expect(transitionPreviewZoom(panning, moved)).toBe(first)
|
|
137
|
-
expect(transitionPreviewZoom(panning, { type: "follow", zoomed: true })).toBe(first)
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
test("disposal releases the pan and stops the glide, then ignores everything", () => {
|
|
141
|
-
const busy: PreviewZoomState = {
|
|
142
|
-
status: "gliding",
|
|
143
|
-
gesture: { type: "panning", pointerId: 1, target: "video", onBackdrop: false, moved: false },
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const disposed = transitionPreviewZoom(busy, { type: "disposed" })
|
|
147
|
-
|
|
148
|
-
expect(disposed.effects).toEqual([
|
|
149
|
-
{ type: "pointer.release", target: "video", pointerId: 1 },
|
|
150
|
-
{ type: "glide.loop.stop" },
|
|
151
|
-
])
|
|
152
|
-
expect(transitionPreviewZoom(disposed.state, { type: "glide.start" }).effects).toEqual([])
|
|
153
|
-
})
|
|
154
|
-
})
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import { clampView, detailScale, FIT_VIEW, maxScale, panBy, viewBox, wheelZoomFactor, zoomAt } from "./image-zoom"
|
|
3
|
-
|
|
4
|
-
// A 1000×500 image fitted into a 1000×600 viewport at half its natural size.
|
|
5
|
-
const bounds = { width: 1000, height: 500, viewportWidth: 1000, viewportHeight: 600, maxScale: maxScale(0.5) }
|
|
6
|
-
|
|
7
|
-
describe("zoomAt", () => {
|
|
8
|
-
test("keeps the image point under the cursor in place", () => {
|
|
9
|
-
const anchor = { x: 300, y: -100 }
|
|
10
|
-
const view = zoomAt(FIT_VIEW, 2, anchor, bounds)
|
|
11
|
-
// The fitted point under the anchor sits at (anchor - offset) / scale in image space.
|
|
12
|
-
const before = { x: (anchor.x - FIT_VIEW.x) / FIT_VIEW.scale, y: (anchor.y - FIT_VIEW.y) / FIT_VIEW.scale }
|
|
13
|
-
|
|
14
|
-
expect(view).toEqual({ scale: 2, x: -300, y: 100 })
|
|
15
|
-
expect({ x: before.x * view.scale + view.x, y: before.y * view.scale + view.y }).toEqual(anchor)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
test("zooms about the center without moving it", () => {
|
|
19
|
-
expect(zoomAt({ scale: 2, x: 120, y: -40 }, 4, { x: 0, y: 0 }, bounds)).toEqual({ scale: 4, x: 240, y: -80 })
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
test("never shrinks below fit or grows past the limit", () => {
|
|
23
|
-
expect(zoomAt({ scale: 3, x: 400, y: 200 }, 0.2, { x: 100, y: 100 }, bounds)).toEqual(FIT_VIEW)
|
|
24
|
-
expect(zoomAt(FIT_VIEW, 100, { x: 0, y: 0 }, bounds).scale).toBe(16)
|
|
25
|
-
})
|
|
26
|
-
|
|
27
|
-
test("pulls an anchor near the edge back so no empty space shows", () => {
|
|
28
|
-
expect(zoomAt(FIT_VIEW, 2, { x: 500, y: 0 }, bounds)).toEqual({ scale: 2, x: -500, y: 0 })
|
|
29
|
-
expect(zoomAt(FIT_VIEW, 1.1, { x: 500, y: 300 }, bounds)).toEqual({ scale: 1.1, x: -50, y: 0 })
|
|
30
|
-
})
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
describe("panBy", () => {
|
|
34
|
-
test("moves freely inside the overflow", () => {
|
|
35
|
-
expect(panBy({ scale: 2, x: 0, y: 0 }, { x: 120, y: -80 }, bounds)).toEqual({ scale: 2, x: 120, y: -80 })
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
test("stops at each edge of the zoomed image", () => {
|
|
39
|
-
// At 2x the image is 2000×1000, so it can travel 500px horizontally and 200px vertically each way.
|
|
40
|
-
expect(panBy({ scale: 2, x: 450, y: 150 }, { x: 900, y: 900 }, bounds)).toEqual({ scale: 2, x: 500, y: 200 })
|
|
41
|
-
expect(panBy({ scale: 2, x: 0, y: 0 }, { x: -900, y: -900 }, bounds)).toEqual({ scale: 2, x: -500, y: -200 })
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
test("keeps an axis that still fits centered", () => {
|
|
45
|
-
expect(panBy(FIT_VIEW, { x: 40, y: 40 }, bounds)).toEqual(FIT_VIEW)
|
|
46
|
-
expect(panBy({ scale: 1.1, x: 0, y: 0 }, { x: 0, y: 40 }, bounds)).toEqual({ scale: 1.1, x: 0, y: 0 })
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
describe("clampView", () => {
|
|
51
|
-
test("re-centers a pan that a smaller zoom or larger viewport no longer allows", () => {
|
|
52
|
-
expect(clampView({ scale: 2, x: 500, y: 200 }, { ...bounds, viewportWidth: 1600, viewportHeight: 1200 })).toEqual({
|
|
53
|
-
scale: 2,
|
|
54
|
-
x: 200,
|
|
55
|
-
y: 0,
|
|
56
|
-
})
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
describe("detailScale", () => {
|
|
61
|
-
test("opens a downscaled image at 100%", () => {
|
|
62
|
-
expect(detailScale(0.25)).toBe(4)
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
test("doubles an image already shown near its natural size", () => {
|
|
66
|
-
expect(detailScale(1)).toBe(2)
|
|
67
|
-
expect(detailScale(0.8)).toBe(2)
|
|
68
|
-
})
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
describe("wheelZoomFactor", () => {
|
|
72
|
-
test("zooms in for upward deltas and out for downward ones by the same ratio", () => {
|
|
73
|
-
expect(wheelZoomFactor(-10)).toBeGreaterThan(1)
|
|
74
|
-
expect(wheelZoomFactor(-10) * wheelZoomFactor(10)).toBeCloseTo(1)
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
test("bounds a coarse mouse-wheel notch", () => {
|
|
78
|
-
expect(wheelZoomFactor(-400)).toBe(wheelZoomFactor(-100))
|
|
79
|
-
expect(wheelZoomFactor(-400)).toBeLessThan(1.5)
|
|
80
|
-
})
|
|
81
|
-
})
|
|
82
|
-
|
|
83
|
-
describe("viewBox", () => {
|
|
84
|
-
// An 800×450 video fitted at half its natural 1600×900.
|
|
85
|
-
const size = { width: 800, height: 450 }
|
|
86
|
-
const natural = { width: 1600, height: 900 }
|
|
87
|
-
|
|
88
|
-
test("shows the whole frame at fit", () => {
|
|
89
|
-
expect(viewBox(1, 0, 0, size, natural)).toBe("none")
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
test("shows the middle half at 2x, and more of the left once panned right", () => {
|
|
93
|
-
expect(viewBox(2, 0, 0, size, natural)).toBe("inset(225px 400px 225px 400px)")
|
|
94
|
-
expect(viewBox(2, 200, 0, size, natural)).toBe("inset(225px 600px 225px 200px)")
|
|
95
|
-
})
|
|
96
|
-
})
|