@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,263 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test"
|
|
2
|
-
import {
|
|
3
|
-
createListState,
|
|
4
|
-
listActive,
|
|
5
|
-
listScrollTarget,
|
|
6
|
-
selectListEmptyState,
|
|
7
|
-
transitionList,
|
|
8
|
-
type ListEffect,
|
|
9
|
-
type ListEvent,
|
|
10
|
-
type ListKeyDown,
|
|
11
|
-
type ListState,
|
|
12
|
-
} from "./list-machine"
|
|
13
|
-
|
|
14
|
-
const items = ["Alpha", "Beta", "Gamma"]
|
|
15
|
-
|
|
16
|
-
const config = { key: (item: string) => item }
|
|
17
|
-
|
|
18
|
-
function run(state: ListState<string>, ...events: ListEvent<string>[]) {
|
|
19
|
-
return events.reduce<{ state: ListState<string>; effects: ListEffect<string>[]; handled: boolean }>(
|
|
20
|
-
(result, event) => transitionList(result.state, event, config),
|
|
21
|
-
{ state, effects: [], handled: false },
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Answers the load a transition asked for, as the driver does for a synchronous `items` list.
|
|
26
|
-
function settle(result: { state: ListState<string>; effects: ListEffect<string>[] }) {
|
|
27
|
-
const load = result.effects.find((effect) => effect.type === "load")
|
|
28
|
-
|
|
29
|
-
if (!load) return result.state
|
|
30
|
-
const matches = items.filter((item) => item.toLowerCase().includes(load.query.toLowerCase()))
|
|
31
|
-
|
|
32
|
-
return transitionList(result.state, { type: "load.resolved", attempt: load.attempt, items: matches }, config).state
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function loaded(filter?: string) {
|
|
36
|
-
return settle(run(createListState<string>(filter), { type: "items.reload" }))
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function key(key: string, input: Partial<Omit<ListKeyDown, "type" | "key">> = {}): ListKeyDown {
|
|
40
|
-
return {
|
|
41
|
-
type: "key.down",
|
|
42
|
-
key,
|
|
43
|
-
ctrl: false,
|
|
44
|
-
alt: false,
|
|
45
|
-
meta: false,
|
|
46
|
-
shift: false,
|
|
47
|
-
composing: false,
|
|
48
|
-
search: false,
|
|
49
|
-
claimed: false,
|
|
50
|
-
...input,
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
test("the clear button shows every row again and tells the parent", () => {
|
|
55
|
-
const typed = settle(run(loaded(), { type: "query.change", value: "al" }))
|
|
56
|
-
expect(typed.rows).toEqual(["Alpha"])
|
|
57
|
-
|
|
58
|
-
const cleared = run(typed, { type: "query.change", value: "" })
|
|
59
|
-
expect(cleared.effects).toEqual([
|
|
60
|
-
{ type: "notify.filter", value: "" },
|
|
61
|
-
{ type: "load", attempt: 3, query: "" },
|
|
62
|
-
])
|
|
63
|
-
|
|
64
|
-
const state = settle(cleared)
|
|
65
|
-
expect(state.filter).toEqual({ type: "uncontrolled", query: "" })
|
|
66
|
-
expect(state.rows).toEqual(items)
|
|
67
|
-
expect(state.highlight.activeKey).toBe("Alpha")
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
test("a controlled list clears when the parent accepts and keeps rows and query together when it does not", () => {
|
|
71
|
-
const start = loaded("al")
|
|
72
|
-
expect(start.rows).toEqual(["Alpha"])
|
|
73
|
-
|
|
74
|
-
const cleared = run(start, { type: "query.change", value: "" })
|
|
75
|
-
expect(cleared.effects).toEqual([{ type: "notify.filter", value: "" }])
|
|
76
|
-
expect(cleared.state).toBe(start)
|
|
77
|
-
|
|
78
|
-
const accepted = run(cleared.state, { type: "filter.controlled", value: "" })
|
|
79
|
-
expect(accepted.effects).toEqual([{ type: "load", attempt: 2, query: "" }])
|
|
80
|
-
expect(settle(accepted).rows).toEqual(items)
|
|
81
|
-
expect(settle(accepted).filter).toEqual({ type: "controlled", query: "" })
|
|
82
|
-
})
|
|
83
|
-
|
|
84
|
-
test("a forced change reloads an unchanged query once", () => {
|
|
85
|
-
const start = loaded()
|
|
86
|
-
|
|
87
|
-
expect(run(start, { type: "query.change", value: "" }).effects).toEqual([])
|
|
88
|
-
expect(run(start, { type: "query.change", value: "", force: true }).effects).toEqual([
|
|
89
|
-
{ type: "notify.filter", value: "" },
|
|
90
|
-
{ type: "load", attempt: 2, query: "" },
|
|
91
|
-
])
|
|
92
|
-
expect(run(loaded("al"), { type: "query.change", value: "al", force: true }).effects).toEqual([
|
|
93
|
-
{ type: "notify.filter", value: "al" },
|
|
94
|
-
{ type: "load", attempt: 2, query: "al" },
|
|
95
|
-
])
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
test("switching between controlled and uncontrolled keeps the query and reloads only on a new one", () => {
|
|
99
|
-
const start = loaded()
|
|
100
|
-
const adopted = run(start, { type: "filter.controlled", value: "" })
|
|
101
|
-
expect(adopted.effects).toEqual([])
|
|
102
|
-
expect(adopted.state.filter).toEqual({ type: "controlled", query: "" })
|
|
103
|
-
|
|
104
|
-
expect(run(adopted.state, { type: "filter.uncontrolled" }).state.filter).toEqual({ type: "uncontrolled", query: "" })
|
|
105
|
-
expect(run(start, { type: "filter.controlled", value: "be" }).effects).toEqual([
|
|
106
|
-
{ type: "load", attempt: 2, query: "be" },
|
|
107
|
-
])
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
test("a superseded or late load result is ignored", () => {
|
|
111
|
-
const first = run(loaded(), { type: "query.change", value: "a" })
|
|
112
|
-
const second = run(first.state, { type: "query.change", value: "al" })
|
|
113
|
-
const stale = transitionList(second.state, { type: "load.resolved", attempt: 2, items }, config)
|
|
114
|
-
expect(stale.state).toBe(second.state)
|
|
115
|
-
|
|
116
|
-
const ready = transitionList(second.state, { type: "load.resolved", attempt: 3, items }, config).state
|
|
117
|
-
expect(ready).toMatchObject({ status: "ready", epoch: 3, rows: ["Alpha"] })
|
|
118
|
-
expect(transitionList(ready, { type: "load.failed", attempt: 3 }, config).state).toBe(ready)
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
test("a rejected load reports a failure, not an empty result, and a reload or new query recovers", () => {
|
|
122
|
-
// `load.failed` used to settle as `ready` with no rows, so the list said "No results" for a server error.
|
|
123
|
-
const loading = run(loaded(), { type: "items.reload" })
|
|
124
|
-
const failed = transitionList(loading.state, { type: "load.failed", attempt: 2 }, config)
|
|
125
|
-
expect(failed.state).toMatchObject({ status: "failed", epoch: 2, rows: [], highlight: { activeKey: null } })
|
|
126
|
-
expect(failed.effects).toEqual([{ type: "cancel.load" }])
|
|
127
|
-
expect(selectListEmptyState(failed.state)).toEqual({ type: "failed" })
|
|
128
|
-
|
|
129
|
-
const empty = transitionList(loading.state, { type: "load.resolved", attempt: 2, items: [] }, config).state
|
|
130
|
-
expect(selectListEmptyState(empty)).toEqual({ type: "empty", query: "" })
|
|
131
|
-
|
|
132
|
-
expect(run(failed.state, { type: "items.reload" }).effects).toEqual([{ type: "load", attempt: 3, query: "" }])
|
|
133
|
-
expect(settle(run(failed.state, { type: "items.reload" }))).toMatchObject({ status: "ready", rows: items })
|
|
134
|
-
expect(settle(run(failed.state, { type: "query.change", value: "be" }))).toMatchObject({
|
|
135
|
-
status: "ready",
|
|
136
|
-
rows: ["Beta"],
|
|
137
|
-
})
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
test("a load that never settles times out into a failure", () => {
|
|
141
|
-
const typed = run(loaded(), { type: "query.change", value: "al" })
|
|
142
|
-
expect(selectListEmptyState(typed.state)).toEqual({ type: "loading" })
|
|
143
|
-
|
|
144
|
-
const timedOut = transitionList(typed.state, { type: "load.timed-out", attempt: 2 }, config)
|
|
145
|
-
expect(timedOut.state).toMatchObject({ status: "failed", epoch: 2, rows: [] })
|
|
146
|
-
expect(timedOut.effects).toEqual([{ type: "cancel.load" }])
|
|
147
|
-
|
|
148
|
-
// A superseded attempt's timeout does not fail the attempt that replaced it.
|
|
149
|
-
const retyped = run(typed.state, { type: "query.change", value: "alp" }).state
|
|
150
|
-
expect(transitionList(retyped, { type: "load.timed-out", attempt: 2 }, config).state).toBe(retyped)
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
test("a slow search that timed out still shows its results, unless a newer attempt started", () => {
|
|
154
|
-
const timedOut = transitionList(
|
|
155
|
-
run(loaded(), { type: "query.change", value: "al" }).state,
|
|
156
|
-
{ type: "load.timed-out", attempt: 2 },
|
|
157
|
-
config,
|
|
158
|
-
).state
|
|
159
|
-
|
|
160
|
-
const late = transitionList(timedOut, { type: "load.resolved", attempt: 2, items }, config)
|
|
161
|
-
expect(late.state).toMatchObject({ status: "ready", epoch: 2, rows: ["Alpha"], highlight: { activeKey: "Alpha" } })
|
|
162
|
-
expect(late.effects).toEqual([])
|
|
163
|
-
expect(transitionList(timedOut, { type: "load.failed", attempt: 2 }, config).state).toBe(timedOut)
|
|
164
|
-
expect(transitionList(timedOut, { type: "load.resolved", attempt: 1, items }, config).state).toBe(timedOut)
|
|
165
|
-
|
|
166
|
-
const reloading = run(timedOut, { type: "items.reload" }).state
|
|
167
|
-
expect(transitionList(reloading, { type: "load.resolved", attempt: 2, items }, config).state).toBe(reloading)
|
|
168
|
-
|
|
169
|
-
const reloaded = settle(run(timedOut, { type: "items.reload" }))
|
|
170
|
-
expect(transitionList(reloaded, { type: "load.resolved", attempt: 2, items }, config).state).toBe(reloaded)
|
|
171
|
-
})
|
|
172
|
-
|
|
173
|
-
test("disposing stops an in-flight load and ignores every later event", () => {
|
|
174
|
-
const loading = run(loaded(), { type: "items.reload" }).state
|
|
175
|
-
const disposed = transitionList(loading, { type: "disposed" }, config)
|
|
176
|
-
expect(disposed.state.status).toBe("disposed")
|
|
177
|
-
expect(disposed.effects).toEqual([{ type: "cancel.load" }])
|
|
178
|
-
expect(transitionList(loaded(), { type: "disposed" }, config).effects).toEqual([])
|
|
179
|
-
|
|
180
|
-
for (const event of [
|
|
181
|
-
{ type: "load.resolved", attempt: 2, items },
|
|
182
|
-
{ type: "load.failed", attempt: 2 },
|
|
183
|
-
{ type: "query.change", value: "be" },
|
|
184
|
-
{ type: "items.reload" },
|
|
185
|
-
key("ArrowDown"),
|
|
186
|
-
] satisfies ListEvent<string>[])
|
|
187
|
-
expect(transitionList(disposed.state, event, config)).toMatchObject({ state: disposed.state, effects: [] })
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
test("the pointer takes the highlight without scrolling and any key gives it back", () => {
|
|
191
|
-
const start = loaded()
|
|
192
|
-
expect(run(start, { type: "pointer.move", key: "Beta", moved: false }).state).toBe(start)
|
|
193
|
-
|
|
194
|
-
const hovered = run(start, { type: "pointer.move", key: "Beta", moved: true }).state
|
|
195
|
-
expect(hovered.highlight).toEqual({ mode: "mouse", activeKey: "Beta" })
|
|
196
|
-
expect(listScrollTarget(hovered)).toEqual({ type: "none" })
|
|
197
|
-
|
|
198
|
-
const left = run(hovered, { type: "pointer.leave" }).state
|
|
199
|
-
expect(left.highlight).toEqual({ mode: "mouse", activeKey: null })
|
|
200
|
-
expect(run(start, { type: "pointer.leave" }).state).toBe(start)
|
|
201
|
-
|
|
202
|
-
const typed = run(hovered, key("Escape", { claimed: true }))
|
|
203
|
-
expect(typed.handled).toBe(false)
|
|
204
|
-
expect(typed.state.highlight).toEqual({ mode: "keyboard", activeKey: "Beta" })
|
|
205
|
-
expect(listScrollTarget(typed.state)).toEqual({ type: "item", key: "Beta" })
|
|
206
|
-
})
|
|
207
|
-
|
|
208
|
-
test.each<{ name: string; events: ListKeyDown[]; active: string | null; handled: boolean }>([
|
|
209
|
-
{ name: "ArrowDown moves to the next row", events: [key("ArrowDown")], active: "Beta", handled: true },
|
|
210
|
-
{ name: "ArrowUp wraps to the last row", events: [key("ArrowUp")], active: "Gamma", handled: true },
|
|
211
|
-
{
|
|
212
|
-
name: "Ctrl+N and Ctrl+P move like arrows",
|
|
213
|
-
events: [key("n", { ctrl: true }), key("n", { ctrl: true }), key("p", { ctrl: true })],
|
|
214
|
-
active: "Beta",
|
|
215
|
-
handled: true,
|
|
216
|
-
},
|
|
217
|
-
{ name: "ArrowDown wraps to the first row", events: [key("End"), key("ArrowDown")], active: "Alpha", handled: true },
|
|
218
|
-
{
|
|
219
|
-
name: "Option+Arrow is left to text editing",
|
|
220
|
-
events: [key("ArrowDown", { alt: true })],
|
|
221
|
-
active: "Alpha",
|
|
222
|
-
handled: false,
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
name: "Cmd+Arrow is left to text editing",
|
|
226
|
-
events: [key("ArrowDown", { meta: true })],
|
|
227
|
-
active: "Alpha",
|
|
228
|
-
handled: false,
|
|
229
|
-
},
|
|
230
|
-
{ name: "End jumps to the last row", events: [key("End")], active: "Gamma", handled: true },
|
|
231
|
-
{ name: "a search input keeps End", events: [key("End", { search: true })], active: "Alpha", handled: false },
|
|
232
|
-
{ name: "Tab moves to the next row", events: [key("Tab")], active: "Beta", handled: true },
|
|
233
|
-
{
|
|
234
|
-
name: "Shift+Tab on the first row leaves focus to the browser",
|
|
235
|
-
events: [key("Tab", { shift: true })],
|
|
236
|
-
active: "Alpha",
|
|
237
|
-
handled: false,
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
name: "a claimed key does not move",
|
|
241
|
-
events: [key("ArrowDown", { claimed: true })],
|
|
242
|
-
active: "Alpha",
|
|
243
|
-
handled: false,
|
|
244
|
-
},
|
|
245
|
-
])("$name", (input) => {
|
|
246
|
-
const result = run(loaded(), ...input.events)
|
|
247
|
-
expect(result.state.highlight.activeKey).toBe(input.active)
|
|
248
|
-
expect(result.handled).toBe(input.handled)
|
|
249
|
-
})
|
|
250
|
-
|
|
251
|
-
test("Enter selects the highlighted row and is handled even with none", () => {
|
|
252
|
-
const start = run(loaded(), key("ArrowDown")).state
|
|
253
|
-
expect(listActive(start)).toEqual({ item: "Beta", index: 1 })
|
|
254
|
-
expect(run(start, key("Enter"))).toMatchObject({
|
|
255
|
-
handled: true,
|
|
256
|
-
effects: [{ type: "select", item: "Beta", index: 1 }],
|
|
257
|
-
})
|
|
258
|
-
expect(run(start, key("Enter", { composing: true })).handled).toBe(false)
|
|
259
|
-
|
|
260
|
-
const empty = run(start, { type: "active.set", key: "" })
|
|
261
|
-
expect(empty.state.highlight.activeKey).toBeNull()
|
|
262
|
-
expect(run(empty.state, key("Enter"))).toMatchObject({ handled: true, effects: [] })
|
|
263
|
-
})
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test"
|
|
2
|
-
import { pinSpinPhase } from "./spin-phase"
|
|
3
|
-
|
|
4
|
-
test("pins only running infinite loops to the timeline origin without touching already-pinned or paused ones", () => {
|
|
5
|
-
let timingCalls = 0
|
|
6
|
-
|
|
7
|
-
const animation = (iterations: number, startTime: number, playState?: AnimationPlayState) => ({
|
|
8
|
-
startTime,
|
|
9
|
-
playState,
|
|
10
|
-
effect: {
|
|
11
|
-
getTiming: () => {
|
|
12
|
-
timingCalls++
|
|
13
|
-
|
|
14
|
-
return { iterations }
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
const loops = [animation(Infinity, 1234, "running"), animation(Infinity, 87, "running")]
|
|
20
|
-
const alreadyPinned = animation(Infinity, 0, "running")
|
|
21
|
-
const paused = animation(Infinity, 500, "paused")
|
|
22
|
-
const fade = animation(1, 1234, "running")
|
|
23
|
-
|
|
24
|
-
pinSpinPhase({ getAnimations: () => [...loops, alreadyPinned, paused, fade] })
|
|
25
|
-
|
|
26
|
-
expect(loops.map((loop) => loop.startTime)).toEqual([0, 0])
|
|
27
|
-
expect(alreadyPinned.startTime).toBe(0)
|
|
28
|
-
expect(paused.startTime).toBe(500)
|
|
29
|
-
expect(fade.startTime).toBe(1234)
|
|
30
|
-
// Already-pinned and paused animations short-circuit before calling getTiming().
|
|
31
|
-
expect(timingCalls).toBe(3)
|
|
32
|
-
})
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test"
|
|
2
|
-
import { groupItems } from "./use-filtered-list"
|
|
3
|
-
|
|
4
|
-
test("groups under one empty category without a groupBy", () => {
|
|
5
|
-
expect(groupItems(["b", "a"], {})).toEqual([{ category: "", items: ["b", "a"] }])
|
|
6
|
-
})
|
|
7
|
-
|
|
8
|
-
test("keeps item order within a group and first-seen order between groups", () => {
|
|
9
|
-
const items = [
|
|
10
|
-
{ name: "x1", group: "x" },
|
|
11
|
-
{ name: "y1", group: "y" },
|
|
12
|
-
{ name: "x2", group: "x" },
|
|
13
|
-
]
|
|
14
|
-
|
|
15
|
-
expect(groupItems(items, { groupBy: (item) => item.group }).map((g) => [g.category, g.items.map((i) => i.name)])).toEqual([
|
|
16
|
-
["x", ["x1", "x2"]],
|
|
17
|
-
["y", ["y1"]],
|
|
18
|
-
])
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
test("lists numeric-looking categories first, as object keys do", () => {
|
|
22
|
-
expect(groupItems(["b", "10", "a", "2"], { groupBy: (item) => item }).map((g) => g.category)).toEqual([
|
|
23
|
-
"2",
|
|
24
|
-
"10",
|
|
25
|
-
"b",
|
|
26
|
-
"a",
|
|
27
|
-
])
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
test("sorts items within groups and then the groups", () => {
|
|
31
|
-
const groups = groupItems([3, 1, 4, 2], {
|
|
32
|
-
groupBy: (n) => (n % 2 ? "odd" : "even"),
|
|
33
|
-
sortBy: (a, b) => a - b,
|
|
34
|
-
sortGroupsBy: (a, b) => a.category.localeCompare(b.category),
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
expect(groups).toEqual([
|
|
38
|
-
{ category: "even", items: [2, 4] },
|
|
39
|
-
{ category: "odd", items: [1, 3] },
|
|
40
|
-
])
|
|
41
|
-
})
|
package/src/motion/core.test.ts
DELETED
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, mock, spyOn } from "bun:test"
|
|
2
|
-
import { Spring } from "./spring"
|
|
3
|
-
import { createFrameLoop } from "./loop"
|
|
4
|
-
import { VelocityTracker } from "./velocity"
|
|
5
|
-
import { sliderFraction, sliderStep, sliderStops, sliderValue } from "./slider"
|
|
6
|
-
|
|
7
|
-
describe("Spring", () => {
|
|
8
|
-
it("settles to the exact target, retaining velocity on interruption", () => {
|
|
9
|
-
const spring = new Spring(0).set(200)
|
|
10
|
-
spring.step(0.1)
|
|
11
|
-
const velocity = spring.velocity
|
|
12
|
-
spring.set(-40)
|
|
13
|
-
expect(spring.velocity).toBe(velocity)
|
|
14
|
-
|
|
15
|
-
for (let i = 0; i < 240; i++) spring.step(1 / 60)
|
|
16
|
-
expect(spring.value).toBe(-40)
|
|
17
|
-
expect(spring.velocity).toBe(0)
|
|
18
|
-
expect(spring.resting).toBe(true)
|
|
19
|
-
})
|
|
20
|
-
it("does not overshoot at bounce zero", () => {
|
|
21
|
-
const spring = Spring.fromDuration(0, { duration: 0.42, bounce: 0 }).set(1)
|
|
22
|
-
|
|
23
|
-
for (let i = 0; i < 240; i++) {
|
|
24
|
-
expect(spring.step(1 / 120)).toBeLessThanOrEqual(1)
|
|
25
|
-
expect(spring.value).toBeGreaterThanOrEqual(0)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
expect(spring.value).toBe(1)
|
|
29
|
-
})
|
|
30
|
-
it("bounce .3 produces the harmonic oscillator overshoot (~4.6%)", () => {
|
|
31
|
-
const spring = Spring.fromDuration(0, { duration: 0.42, bounce: 0.3 }).set(1)
|
|
32
|
-
let peak = 0
|
|
33
|
-
|
|
34
|
-
for (let i = 0; i < 480; i++) peak = Math.max(peak, spring.step(1 / 480))
|
|
35
|
-
const expected = Math.exp((-Math.PI * 0.7) / Math.sqrt(1 - 0.7 ** 2))
|
|
36
|
-
expect(peak - 1).toBeCloseTo(expected, 2)
|
|
37
|
-
})
|
|
38
|
-
it.each([0.2, 0.42, 0.8])("has perceptual 2%% settle time near duration %s (not a hard timeout)", (duration) => {
|
|
39
|
-
const spring = Spring.fromDuration(0, { duration, bounce: 0 }).set(1)
|
|
40
|
-
let t = 0
|
|
41
|
-
|
|
42
|
-
while (spring.value < 0.98) {
|
|
43
|
-
spring.step(1 / 480)
|
|
44
|
-
t += 1 / 480
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
expect(t / duration).toBeGreaterThan(0.9)
|
|
48
|
-
expect(t / duration).toBeLessThan(1.1)
|
|
49
|
-
})
|
|
50
|
-
it("matches 60 and 120 Hz frame partitioning", () => {
|
|
51
|
-
const a = new Spring(0).set(100)
|
|
52
|
-
const b = new Spring(0).set(100)
|
|
53
|
-
|
|
54
|
-
for (let i = 0; i < 12; i++) {
|
|
55
|
-
a.step(1 / 60)
|
|
56
|
-
b.step(1 / 120)
|
|
57
|
-
b.step(1 / 120)
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
expect(a.value).toBeCloseTo(b.value, 10)
|
|
61
|
-
expect(a.velocity).toBeCloseTo(b.velocity, 10)
|
|
62
|
-
})
|
|
63
|
-
it("clamps suspension dt and rejects invalid parameters", () => {
|
|
64
|
-
const a = new Spring(0).set(100)
|
|
65
|
-
const b = new Spring(0).set(100)
|
|
66
|
-
expect(a.step(30)).toBe(b.step(0.1))
|
|
67
|
-
expect(a.step(-1)).toBe(a.value)
|
|
68
|
-
expect(() => a.set(NaN)).toThrow(RangeError)
|
|
69
|
-
expect(() => new Spring(0, { omega: 0 })).toThrow(RangeError)
|
|
70
|
-
expect(() => Spring.fromDuration(0, { duration: 0, bounce: 0 })).toThrow(RangeError)
|
|
71
|
-
expect(() => Spring.fromDuration(0, { duration: 0.42, bounce: 1 })).toThrow(RangeError)
|
|
72
|
-
expect(() => Spring.fromDuration(0, { duration: 0.42, bounce: -0.3 })).toThrow(RangeError)
|
|
73
|
-
expect(() => new Spring(0, { omega: 240, zeta: 2 })).toThrow(RangeError)
|
|
74
|
-
})
|
|
75
|
-
it("matches native SwiftUI stiffness and damping", () => {
|
|
76
|
-
const spring = Spring.fromDuration(0, { duration: 0.42, bounce: 0.18 })
|
|
77
|
-
expect(spring.omega ** 2).toBeCloseTo(223.80055331268386, 10)
|
|
78
|
-
expect(2 * spring.zeta * spring.omega).toBeCloseTo(24.534342628034576, 10)
|
|
79
|
-
})
|
|
80
|
-
it("tracks the 480 Hz reference integrator across underdamped, critical, and overdamped regimes", () => {
|
|
81
|
-
const regimes = [
|
|
82
|
-
{ omega: 26, zeta: 0.7 },
|
|
83
|
-
{ omega: 26, zeta: 1 },
|
|
84
|
-
{ omega: 26, zeta: 1 + 1e-9 },
|
|
85
|
-
{ omega: 20, zeta: 1.4 },
|
|
86
|
-
]
|
|
87
|
-
|
|
88
|
-
for (const cfg of regimes) {
|
|
89
|
-
const spring = new Spring(0, cfg).set(100)
|
|
90
|
-
let refValue = 0
|
|
91
|
-
let refVelocity = 0
|
|
92
|
-
const stiffness = cfg.omega * cfg.omega
|
|
93
|
-
const damping = 2 * cfg.zeta * cfg.omega
|
|
94
|
-
let maxDiff = 0
|
|
95
|
-
|
|
96
|
-
for (let frame = 0; frame < 180; frame++) {
|
|
97
|
-
if (frame === 15) {
|
|
98
|
-
spring.set(-50)
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
const target = frame < 15 ? 100 : -50
|
|
102
|
-
|
|
103
|
-
for (let i = 0; i < 8; i++) {
|
|
104
|
-
const h = 1 / 480
|
|
105
|
-
refVelocity += (-stiffness * (refValue - target) - damping * refVelocity) * h
|
|
106
|
-
refValue += refVelocity * h
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
spring.step(1 / 60)
|
|
110
|
-
maxDiff = Math.max(maxDiff, Math.abs(spring.value - refValue))
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// First-order 480 Hz Euler lag over a 150-unit sweep is within ~2% of travel, and both settle to target.
|
|
114
|
-
expect(maxDiff).toBeLessThan(3.5)
|
|
115
|
-
expect(spring.value).toBe(-50)
|
|
116
|
-
expect(spring.velocity).toBe(0)
|
|
117
|
-
expect(spring.resting).toBe(true)
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
})
|
|
121
|
-
|
|
122
|
-
function scheduler() {
|
|
123
|
-
let id = 0
|
|
124
|
-
const pending = new Map<number, (time: number) => void>()
|
|
125
|
-
|
|
126
|
-
return {
|
|
127
|
-
pending,
|
|
128
|
-
request: (fn: (time: number) => void) => {
|
|
129
|
-
pending.set(++id, fn)
|
|
130
|
-
|
|
131
|
-
return id
|
|
132
|
-
},
|
|
133
|
-
cancel: (key: number) => {
|
|
134
|
-
pending.delete(key)
|
|
135
|
-
},
|
|
136
|
-
frame: (time: number) => {
|
|
137
|
-
const callbacks = [...pending.values()]
|
|
138
|
-
pending.clear()
|
|
139
|
-
|
|
140
|
-
for (const callback of callbacks) callback(time)
|
|
141
|
-
},
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
describe("frame loop", () => {
|
|
146
|
-
it("sleeps, wakes once, and clamps suspension time", () => {
|
|
147
|
-
const clock = scheduler()
|
|
148
|
-
const loop = createFrameLoop(clock)
|
|
149
|
-
const values: number[] = []
|
|
150
|
-
|
|
151
|
-
const remove = loop.add((dt) => {
|
|
152
|
-
values.push(dt)
|
|
153
|
-
|
|
154
|
-
return true
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
loop.add(() => false)
|
|
158
|
-
expect(clock.pending.size).toBe(1)
|
|
159
|
-
clock.frame(1000)
|
|
160
|
-
clock.frame(4000)
|
|
161
|
-
expect(values).toEqual([1 / 60, 0.1])
|
|
162
|
-
remove()
|
|
163
|
-
expect(clock.pending.size).toBe(0)
|
|
164
|
-
loop.add((dt) => {
|
|
165
|
-
expect(dt).toBe(1 / 60)
|
|
166
|
-
|
|
167
|
-
return false
|
|
168
|
-
})
|
|
169
|
-
clock.frame(9000)
|
|
170
|
-
expect(clock.pending.size).toBe(0)
|
|
171
|
-
})
|
|
172
|
-
it("can remove the next job, add a job, and remove itself mid-frame", () => {
|
|
173
|
-
const clock = scheduler()
|
|
174
|
-
const loop = createFrameLoop(clock)
|
|
175
|
-
const calls: string[] = []
|
|
176
|
-
|
|
177
|
-
const first = loop.add(() => {
|
|
178
|
-
calls.push("a")
|
|
179
|
-
second()
|
|
180
|
-
first()
|
|
181
|
-
loop.add(() => {
|
|
182
|
-
calls.push("c")
|
|
183
|
-
|
|
184
|
-
return false
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
return true
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
const second = loop.add(() => {
|
|
191
|
-
calls.push("b")
|
|
192
|
-
|
|
193
|
-
return false
|
|
194
|
-
})
|
|
195
|
-
|
|
196
|
-
clock.frame(0)
|
|
197
|
-
expect(calls).toEqual(["a"])
|
|
198
|
-
clock.frame(16)
|
|
199
|
-
expect(calls).toEqual(["a", "c"])
|
|
200
|
-
expect(clock.pending.size).toBe(0)
|
|
201
|
-
})
|
|
202
|
-
it("batches every read before every write, and skips removed writes", () => {
|
|
203
|
-
const clock = scheduler()
|
|
204
|
-
const loop = createFrameLoop(clock)
|
|
205
|
-
const calls: string[] = []
|
|
206
|
-
loop.addMeasured(
|
|
207
|
-
() => {
|
|
208
|
-
calls.push("read a")
|
|
209
|
-
},
|
|
210
|
-
() => {
|
|
211
|
-
calls.push("write a")
|
|
212
|
-
|
|
213
|
-
return false
|
|
214
|
-
},
|
|
215
|
-
)
|
|
216
|
-
loop.addMeasured(
|
|
217
|
-
() => {
|
|
218
|
-
calls.push("read b")
|
|
219
|
-
},
|
|
220
|
-
() => {
|
|
221
|
-
calls.push("write b")
|
|
222
|
-
|
|
223
|
-
return false
|
|
224
|
-
},
|
|
225
|
-
)
|
|
226
|
-
clock.frame(0)
|
|
227
|
-
expect(calls).toEqual(["read a", "read b", "write a", "write b"])
|
|
228
|
-
})
|
|
229
|
-
it("removes jobs during the read phase without breaking traversal", () => {
|
|
230
|
-
const clock = scheduler(),
|
|
231
|
-
loop = createFrameLoop(clock),
|
|
232
|
-
calls: string[] = []
|
|
233
|
-
|
|
234
|
-
loop.addMeasured(
|
|
235
|
-
() => {
|
|
236
|
-
remove()
|
|
237
|
-
},
|
|
238
|
-
() => {
|
|
239
|
-
calls.push("a")
|
|
240
|
-
|
|
241
|
-
return false
|
|
242
|
-
},
|
|
243
|
-
)
|
|
244
|
-
|
|
245
|
-
const remove = loop.addMeasured(
|
|
246
|
-
() => {
|
|
247
|
-
calls.push("read b")
|
|
248
|
-
},
|
|
249
|
-
() => {
|
|
250
|
-
calls.push("b")
|
|
251
|
-
|
|
252
|
-
return false
|
|
253
|
-
},
|
|
254
|
-
)
|
|
255
|
-
|
|
256
|
-
loop.add(() => {
|
|
257
|
-
calls.push("c")
|
|
258
|
-
|
|
259
|
-
return false
|
|
260
|
-
})
|
|
261
|
-
clock.frame(0)
|
|
262
|
-
expect(calls).toEqual(["a", "c"])
|
|
263
|
-
expect(clock.pending.size).toBe(0)
|
|
264
|
-
})
|
|
265
|
-
it("removes a throwing job and lets other jobs complete next frame", () => {
|
|
266
|
-
const clock = scheduler(),
|
|
267
|
-
loop = createFrameLoop(clock),
|
|
268
|
-
done = mock(() => false)
|
|
269
|
-
|
|
270
|
-
loop.add(() => {
|
|
271
|
-
throw new Error("broken job")
|
|
272
|
-
})
|
|
273
|
-
loop.add(done)
|
|
274
|
-
expect(() => clock.frame(0)).toThrow("broken job")
|
|
275
|
-
clock.frame(16)
|
|
276
|
-
expect(done).toHaveBeenCalledTimes(1)
|
|
277
|
-
expect(clock.pending.size).toBe(0)
|
|
278
|
-
})
|
|
279
|
-
})
|
|
280
|
-
|
|
281
|
-
describe("velocity tracker", () => {
|
|
282
|
-
it("uses recent samples in px/s and becomes stale after a pause", () => {
|
|
283
|
-
const tracker = new VelocityTracker()
|
|
284
|
-
const clock = spyOn(performance, "now").mockReturnValue(180)
|
|
285
|
-
tracker.push(0, 0, 0)
|
|
286
|
-
tracker.push(90, 45, 90)
|
|
287
|
-
tracker.push(180, 90, 180)
|
|
288
|
-
expect(tracker.velocity()).toEqual({ x: 1000, y: 500 })
|
|
289
|
-
clock.mockReturnValue(300)
|
|
290
|
-
expect(tracker.velocity()).toEqual({ x: 0, y: 0 })
|
|
291
|
-
tracker.reset()
|
|
292
|
-
expect(tracker.velocity()).toEqual({ x: 0, y: 0 })
|
|
293
|
-
clock.mockRestore()
|
|
294
|
-
})
|
|
295
|
-
it("handles duplicate timestamps, reversed clocks, and the ring wrapping", () => {
|
|
296
|
-
const tracker = new VelocityTracker()
|
|
297
|
-
const clock = spyOn(performance, "now").mockReturnValue(50)
|
|
298
|
-
tracker.push(10, 0, 20)
|
|
299
|
-
tracker.push(15, 0, 20)
|
|
300
|
-
expect(tracker.velocity().x).toBe(0)
|
|
301
|
-
tracker.push(0, 0, 0)
|
|
302
|
-
expect(tracker.velocity().x).toBe(0)
|
|
303
|
-
|
|
304
|
-
for (let i = 0; i <= 200; i++) tracker.push(i / 4, 0, i / 4)
|
|
305
|
-
expect(tracker.velocity().x).toBe(1000)
|
|
306
|
-
clock.mockRestore()
|
|
307
|
-
})
|
|
308
|
-
})
|
|
309
|
-
|
|
310
|
-
describe("slider math", () => {
|
|
311
|
-
it("counts actual stops, rounds relative to min and clamps", () => {
|
|
312
|
-
const spec = { min: 1, max: 5, step: 1 }
|
|
313
|
-
expect(sliderStops(spec)).toBe(5)
|
|
314
|
-
expect(sliderValue(spec, 2.6)).toBe(3)
|
|
315
|
-
expect(sliderValue(spec, 20)).toBe(5)
|
|
316
|
-
expect(sliderFraction(spec, 3)).toBe(0.5)
|
|
317
|
-
expect(sliderStops({ min: 0, max: 0.9, step: 0.1 })).toBe(10)
|
|
318
|
-
})
|
|
319
|
-
it("supports decimals, singleton ranges and final partial steps", () => {
|
|
320
|
-
expect(sliderValue({ min: 0.1, max: 1, step: 0.1 }, 0.31)).toBe(0.3)
|
|
321
|
-
expect(sliderStops({ min: 0, max: 1, step: 0.3 })).toBe(5)
|
|
322
|
-
expect(sliderValue({ min: 0, max: 1, step: 0.3 }, 0.98)).toBe(1)
|
|
323
|
-
expect(sliderStep({ min: 0, max: 1, step: 0.3 }, 1, -1)).toBe(0.9)
|
|
324
|
-
expect(sliderStep({ min: 0, max: 1, step: 0.3 }, 0.9, 1)).toBe(1)
|
|
325
|
-
expect(sliderFraction({ min: 2, max: 2, step: 1 }, 2)).toBe(0)
|
|
326
|
-
expect(() => sliderStops({ min: 1, max: 2, step: 0 })).toThrow(RangeError)
|
|
327
|
-
})
|
|
328
|
-
})
|