@zyro-sec/ui 1.0.1 → 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 +76 -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,106 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import {
|
|
3
|
-
createToastRegistryState,
|
|
4
|
-
selectToastOptions,
|
|
5
|
-
transitionToastRegistry,
|
|
6
|
-
type ToastRegistryState,
|
|
7
|
-
} from "./machine"
|
|
8
|
-
|
|
9
|
-
type Options = { readonly label: string }
|
|
10
|
-
|
|
11
|
-
const shown = (key: string, liveIds: (number | string)[], label = key) =>
|
|
12
|
-
({
|
|
13
|
-
type: "toast.shown",
|
|
14
|
-
key,
|
|
15
|
-
options: { label },
|
|
16
|
-
liveIds: new Set(liveIds),
|
|
17
|
-
topmostLiveId: liveIds.at(-1),
|
|
18
|
-
}) as const
|
|
19
|
-
|
|
20
|
-
function show(state: ToastRegistryState<Options>, key: string, liveIds: (number | string)[], label = key) {
|
|
21
|
-
return transitionToastRegistry(state, shown(key, liveIds, label))
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
describe("toast registry machine", () => {
|
|
25
|
-
test("a toast closed directly in solid-sonner is pruned and shown again as a new toast", () => {
|
|
26
|
-
const first = show(createToastRegistryState(), "saved", [])
|
|
27
|
-
const other = show(first.state, "failed", [first.id])
|
|
28
|
-
|
|
29
|
-
expect(first.id).toBe(-1)
|
|
30
|
-
expect(other.state.entries.map((entry) => entry.key)).toEqual(["saved", "failed"])
|
|
31
|
-
|
|
32
|
-
// Both were dismissed without callbacks (an unmounted region, a direct `toast.dismiss`), so neither is live.
|
|
33
|
-
const again = show(other.state, "saved", [])
|
|
34
|
-
|
|
35
|
-
expect(again.id).toBe(-3)
|
|
36
|
-
expect(again.state.entries).toEqual([{ id: -3, key: "saved", options: { label: "saved" } }])
|
|
37
|
-
expect(again.effects).toEqual([{ type: "sonner.publish", id: -3, options: { label: "saved" } }])
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
test("a released or dismissed toast has no actions left to run", () => {
|
|
41
|
-
const first = show(createToastRegistryState(), "saved", [])
|
|
42
|
-
|
|
43
|
-
expect(selectToastOptions(first.state, first.id)).toEqual({ label: "saved" })
|
|
44
|
-
|
|
45
|
-
const released = transitionToastRegistry(first.state, { type: "toast.released", id: first.id })
|
|
46
|
-
|
|
47
|
-
expect(selectToastOptions(released.state, first.id)).toBeUndefined()
|
|
48
|
-
expect(released.effects).toEqual([])
|
|
49
|
-
|
|
50
|
-
const dismissed = transitionToastRegistry(first.state, { type: "toast.dismissed", id: first.id })
|
|
51
|
-
|
|
52
|
-
expect(selectToastOptions(dismissed.state, first.id)).toBeUndefined()
|
|
53
|
-
expect(dismissed.effects).toEqual([{ type: "sonner.dismiss", id: first.id }])
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
test("a repeat of the front toast updates it in place and pulses it", () => {
|
|
57
|
-
const first = show(createToastRegistryState(), "saved", [])
|
|
58
|
-
const repeat = show(first.state, "saved", [first.id], "saved again")
|
|
59
|
-
|
|
60
|
-
expect(repeat.id).toBe(first.id)
|
|
61
|
-
expect(repeat.state.nextId).toBe(first.state.nextId)
|
|
62
|
-
expect(selectToastOptions(repeat.state, first.id)).toEqual({ label: "saved again" })
|
|
63
|
-
expect(repeat.effects).toEqual([
|
|
64
|
-
{ type: "sonner.publish", id: first.id, options: { label: "saved again" } },
|
|
65
|
-
{ type: "dom.pulse", id: first.id },
|
|
66
|
-
])
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
test("a repeat of a buried toast replaces it with a new toast in front", () => {
|
|
70
|
-
const first = show(createToastRegistryState(), "saved", [])
|
|
71
|
-
const other = show(first.state, "failed", [first.id])
|
|
72
|
-
const repeat = show(other.state, "saved", [first.id, other.id])
|
|
73
|
-
|
|
74
|
-
expect(repeat.id).toBe(-3)
|
|
75
|
-
expect(repeat.state.entries.map((entry) => [entry.id, entry.key])).toEqual([
|
|
76
|
-
[-2, "failed"],
|
|
77
|
-
[-3, "saved"],
|
|
78
|
-
])
|
|
79
|
-
expect(repeat.effects).toEqual([
|
|
80
|
-
{ type: "sonner.dismiss", id: first.id },
|
|
81
|
-
{ type: "sonner.publish", id: -3, options: { label: "saved" } },
|
|
82
|
-
])
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
test("custom toasts take ids from the same counter, and dismissing all clears every entry", () => {
|
|
86
|
-
const custom = transitionToastRegistry(createToastRegistryState<Options>(), { type: "custom.shown" })
|
|
87
|
-
|
|
88
|
-
expect(custom.state.nextId).toBe(-1)
|
|
89
|
-
expect(custom.effects).toEqual([])
|
|
90
|
-
|
|
91
|
-
const first = show(custom.state, "saved", [custom.state.nextId])
|
|
92
|
-
|
|
93
|
-
expect(first.id).toBe(-2)
|
|
94
|
-
|
|
95
|
-
const all = transitionToastRegistry(first.state, { type: "toast.dismissed" })
|
|
96
|
-
|
|
97
|
-
expect(all.state).toEqual({ nextId: -2, entries: [] })
|
|
98
|
-
expect(all.effects).toEqual([{ type: "sonner.dismiss", id: undefined }])
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
test("releasing an unknown toast keeps the state", () => {
|
|
102
|
-
const first = show(createToastRegistryState(), "saved", [])
|
|
103
|
-
|
|
104
|
-
expect(transitionToastRegistry(first.state, { type: "toast.released", id: -9 }).state).toBe(first.state)
|
|
105
|
-
})
|
|
106
|
-
})
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test"
|
|
2
|
-
import { searchListMove, searchListTarget, type SearchListMove } from "./navigation"
|
|
3
|
-
|
|
4
|
-
const key = (key: string, modifiers: { metaKey?: boolean; altKey?: boolean; shiftKey?: boolean } = {}) => ({
|
|
5
|
-
key,
|
|
6
|
-
ctrlKey: false,
|
|
7
|
-
metaKey: false,
|
|
8
|
-
altKey: false,
|
|
9
|
-
shiftKey: false,
|
|
10
|
-
...modifiers,
|
|
11
|
-
})
|
|
12
|
-
|
|
13
|
-
test("⌘ and ⌥ arrows jump sections, Home and End reach the ends, and Shift stays with the input", () => {
|
|
14
|
-
expect(searchListMove(key("ArrowDown"))).toBe("next")
|
|
15
|
-
expect(searchListMove(key("ArrowDown", { metaKey: true }))).toBe("nextSection")
|
|
16
|
-
expect(searchListMove(key("ArrowUp", { altKey: true }))).toBe("previousSection")
|
|
17
|
-
expect(searchListMove(key("Home"))).toBe("first")
|
|
18
|
-
expect(searchListMove(key("End", { shiftKey: true }))).toBeUndefined()
|
|
19
|
-
expect(searchListMove(key("Home", { metaKey: true }))).toBeUndefined()
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
// Sections a a | b | c c c, so rows 0–1, 2 and 3–5.
|
|
23
|
-
const sections = ["a", "a", "b", "c", "c", "c"]
|
|
24
|
-
|
|
25
|
-
test.each<[number, SearchListMove, number]>([
|
|
26
|
-
[0, "nextSection", 2],
|
|
27
|
-
[1, "nextSection", 2],
|
|
28
|
-
[2, "nextSection", 3],
|
|
29
|
-
[4, "nextSection", 0],
|
|
30
|
-
[4, "previousSection", 3],
|
|
31
|
-
[3, "previousSection", 2],
|
|
32
|
-
[2, "previousSection", 0],
|
|
33
|
-
[0, "previousSection", 3],
|
|
34
|
-
[5, "next", 0],
|
|
35
|
-
[0, "previous", 5],
|
|
36
|
-
[3, "first", 0],
|
|
37
|
-
[1, "last", 5],
|
|
38
|
-
])("from row %i, %s lands on row %i", (from, move, to) => {
|
|
39
|
-
expect(searchListTarget(sections, from, move)).toBe(to)
|
|
40
|
-
})
|
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import {
|
|
3
|
-
createSelectHighlightState,
|
|
4
|
-
transitionSelectHighlight,
|
|
5
|
-
type SelectHighlightEvent,
|
|
6
|
-
type SelectHighlightState,
|
|
7
|
-
type SelectHighlightTransition,
|
|
8
|
-
} from "./machine"
|
|
9
|
-
|
|
10
|
-
const OPEN: SelectHighlightEvent = { type: "open.changed", open: true }
|
|
11
|
-
|
|
12
|
-
const CLOSE: SelectHighlightEvent = { type: "open.changed", open: false }
|
|
13
|
-
|
|
14
|
-
const highlight = (key: string): SelectHighlightEvent => ({ type: "highlight.changed", key, previewable: true })
|
|
15
|
-
|
|
16
|
-
const select = (key: string | undefined, closing = true): SelectHighlightEvent => ({
|
|
17
|
-
type: "option.selected",
|
|
18
|
-
key,
|
|
19
|
-
closing,
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
function run(state: SelectHighlightState, ...events: SelectHighlightEvent[]) {
|
|
23
|
-
const steps: SelectHighlightTransition[] = []
|
|
24
|
-
|
|
25
|
-
events.forEach((event) => steps.push(transitionSelectHighlight(steps.at(-1)?.state ?? state, event)))
|
|
26
|
-
|
|
27
|
-
return steps
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const effects = (steps: SelectHighlightTransition[]) => steps.map((step) => step.effects.map((effect) => effect.type))
|
|
31
|
-
|
|
32
|
-
describe("select highlight preview", () => {
|
|
33
|
-
test("choosing the previewed option keeps its preview through the close", () => {
|
|
34
|
-
// Before: onChange ran the highlighted option's undo after onSelect had committed it.
|
|
35
|
-
const steps = run(createSelectHighlightState(false), OPEN, highlight("b"), select("b"), CLOSE)
|
|
36
|
-
|
|
37
|
-
expect(steps[1]!.effects).toEqual([{ type: "preview.apply", key: "b" }])
|
|
38
|
-
expect(effects(steps).slice(2)).toEqual([[], []])
|
|
39
|
-
expect(steps.at(-1)!.state).toEqual({ status: "closed" })
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
test("choosing another option, or clearing, reverts the preview before the caller commits", () => {
|
|
43
|
-
for (const key of ["b", undefined]) {
|
|
44
|
-
const steps = run(createSelectHighlightState(false), OPEN, highlight("a"), select(key), CLOSE)
|
|
45
|
-
|
|
46
|
-
expect(effects(steps).slice(2)).toEqual([["preview.revert"], []])
|
|
47
|
-
expect(steps.at(-1)!.state).toEqual({ status: "closed" })
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
test("items that highlight while the menu is closing or closed preview nothing, and a reopen previews again", () => {
|
|
52
|
-
// Before: a focus or pointer event during the exit animation applied a preview nothing ever reverted.
|
|
53
|
-
const committed = run(createSelectHighlightState(false), OPEN, highlight("a"), select("a")).at(-1)!.state
|
|
54
|
-
const late = transitionSelectHighlight(committed, highlight("c"))
|
|
55
|
-
|
|
56
|
-
expect(late.state).toBe(committed)
|
|
57
|
-
expect(late.effects).toEqual([])
|
|
58
|
-
const closed = transitionSelectHighlight(committed, CLOSE).state
|
|
59
|
-
expect(transitionSelectHighlight(closed, highlight("c")).state).toBe(closed)
|
|
60
|
-
|
|
61
|
-
const steps = run(closed, OPEN, highlight("c"), CLOSE)
|
|
62
|
-
expect(steps[1]!.effects).toEqual([{ type: "preview.apply", key: "c" }])
|
|
63
|
-
expect(effects(steps)[2]).toEqual(["preview.revert"])
|
|
64
|
-
})
|
|
65
|
-
|
|
66
|
-
test("a controlled close reverts the preview", () => {
|
|
67
|
-
// Before: a parent setting open={false} fired no onOpenChange, so the preview stayed applied while closed.
|
|
68
|
-
const steps = run(createSelectHighlightState(true), highlight("a"), CLOSE)
|
|
69
|
-
|
|
70
|
-
expect(effects(steps)).toEqual([["preview.apply"], ["preview.revert"]])
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
test("moving between options reverts the previous preview first, and the same option does nothing", () => {
|
|
74
|
-
const steps = run(createSelectHighlightState(true), highlight("a"), highlight("a"), highlight("b"))
|
|
75
|
-
|
|
76
|
-
expect(steps[1]!.state).toBe(steps[0]!.state)
|
|
77
|
-
expect(steps[2]!.effects).toEqual([{ type: "preview.revert" }, { type: "preview.apply", key: "b" }])
|
|
78
|
-
})
|
|
79
|
-
|
|
80
|
-
test("a select without onHighlight previews nothing and drops a preview it had", () => {
|
|
81
|
-
const off: SelectHighlightEvent = { type: "highlight.changed", key: "a", previewable: false }
|
|
82
|
-
const idle = createSelectHighlightState(true)
|
|
83
|
-
|
|
84
|
-
expect(transitionSelectHighlight(idle, off).state).toBe(idle)
|
|
85
|
-
expect(effects(run(idle, highlight("b"), off))[1]).toEqual(["preview.revert"])
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
test("a choice that keeps the menu open keeps previewing", () => {
|
|
89
|
-
const steps = run(createSelectHighlightState(true), highlight("a"), select("a", false), highlight("b"))
|
|
90
|
-
|
|
91
|
-
expect(steps[1]!.state).toEqual({ status: "idle" })
|
|
92
|
-
expect(steps[1]!.effects).toEqual([])
|
|
93
|
-
expect(steps[2]!.effects).toEqual([{ type: "preview.apply", key: "b" }])
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
test("disposal reverts an active preview and ignores everything after", () => {
|
|
97
|
-
const steps = run(createSelectHighlightState(true), highlight("a"), { type: "disposed" })
|
|
98
|
-
|
|
99
|
-
expect(effects(steps)[1]).toEqual(["preview.revert"])
|
|
100
|
-
const disposed = steps[1]!.state
|
|
101
|
-
expect(transitionSelectHighlight(disposed, OPEN).state).toBe(disposed)
|
|
102
|
-
expect(transitionSelectHighlight(disposed, highlight("b")).effects).toEqual([])
|
|
103
|
-
expect(transitionSelectHighlight(createSelectHighlightState(false), { type: "disposed" }).effects).toEqual([])
|
|
104
|
-
})
|
|
105
|
-
})
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { describe, expect, test } from "bun:test"
|
|
2
|
-
import {
|
|
3
|
-
createTypeaheadState,
|
|
4
|
-
selectTypeaheadFailed,
|
|
5
|
-
selectTypeaheadItems,
|
|
6
|
-
selectTypeaheadPending,
|
|
7
|
-
selectTypeaheadStale,
|
|
8
|
-
transitionTypeahead,
|
|
9
|
-
type TypeaheadEvent,
|
|
10
|
-
type TypeaheadInitial,
|
|
11
|
-
type TypeaheadState,
|
|
12
|
-
type TypeaheadTransition,
|
|
13
|
-
} from "./machine"
|
|
14
|
-
|
|
15
|
-
const match = (item: string, query: string) => item.includes(query)
|
|
16
|
-
|
|
17
|
-
const type = (input: string, delayMs = 100): TypeaheadEvent<string> => ({
|
|
18
|
-
type: "input.changed",
|
|
19
|
-
input,
|
|
20
|
-
delayMs,
|
|
21
|
-
match,
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
function run(start: TypeaheadTransition<string> | TypeaheadState<string>, ...events: TypeaheadEvent<string>[]) {
|
|
25
|
-
const initial = "state" in start ? start : { state: start, effects: [] }
|
|
26
|
-
|
|
27
|
-
return events.reduce<TypeaheadTransition<string>>(
|
|
28
|
-
(result, event) => transitionTypeahead(result.state, event),
|
|
29
|
-
initial,
|
|
30
|
-
)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const mount = (initial?: TypeaheadInitial<string>) => createTypeaheadState(initial)
|
|
34
|
-
|
|
35
|
-
describe("typeahead machine", () => {
|
|
36
|
-
test("clearing the query back to the opening list shows it without a request", () => {
|
|
37
|
-
const cleared = run(mount({ items: ["dev", "main"] }), type("rel"), type(""))
|
|
38
|
-
|
|
39
|
-
expect(selectTypeaheadItems(cleared.state)).toEqual(["dev", "main"])
|
|
40
|
-
expect(selectTypeaheadPending(cleared.state)).toBe(false)
|
|
41
|
-
// Only the pending debounce is cancelled; nothing asks the source for the empty query.
|
|
42
|
-
expect(cleared.effects).toEqual([{ type: "cancel" }])
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
test("retrying a failed opening list shows the rows it returns", () => {
|
|
46
|
-
const opened = mount({ items: [], failed: true })
|
|
47
|
-
|
|
48
|
-
expect(selectTypeaheadFailed(opened.state)).toBe(true)
|
|
49
|
-
|
|
50
|
-
const retried = run(opened, { type: "retry.requested" })
|
|
51
|
-
|
|
52
|
-
expect(retried.effects).toEqual([{ type: "request", attempt: 1, query: "" }])
|
|
53
|
-
|
|
54
|
-
const answered = run(retried, { type: "request.succeeded", attempt: 1, items: ["dev"] })
|
|
55
|
-
|
|
56
|
-
expect(selectTypeaheadFailed(answered.state)).toBe(false)
|
|
57
|
-
expect(selectTypeaheadItems(answered.state)).toEqual(["dev"])
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
test("typing during a request cancels it and stops loading until the new query is sent", () => {
|
|
61
|
-
const loading = run(mount({ items: ["dev"] }), type("a"), { type: "debounce.elapsed", attempt: 1 })
|
|
62
|
-
|
|
63
|
-
expect(loading.state.status).toBe("loading")
|
|
64
|
-
|
|
65
|
-
const retyped = run(loading, type("ab"))
|
|
66
|
-
|
|
67
|
-
expect(retyped.state).toMatchObject({ status: "debouncing", attempt: 2 })
|
|
68
|
-
expect(retyped.effects).toEqual([{ type: "debounce", attempt: 2, delayMs: 100 }])
|
|
69
|
-
// The superseded request's late answer is ignored.
|
|
70
|
-
expect(run(retyped, { type: "request.succeeded", attempt: 1, items: ["a"] }).state).toBe(retyped.state)
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
test("a failed query does not offer retry for the next query", () => {
|
|
74
|
-
const failed = run(
|
|
75
|
-
mount({ items: ["dev"] }),
|
|
76
|
-
type("foo"),
|
|
77
|
-
{ type: "debounce.elapsed", attempt: 1 },
|
|
78
|
-
{ type: "request.failed", attempt: 1 },
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
expect(selectTypeaheadFailed(failed.state)).toBe(true)
|
|
82
|
-
expect(selectTypeaheadFailed(run(failed, type("foobar")).state)).toBe(false)
|
|
83
|
-
})
|
|
84
|
-
|
|
85
|
-
test("a request that never answers fails after the timeout and cancels the request", () => {
|
|
86
|
-
const timedOut = run(mount({ items: [] }), type("x", 0), { type: "request.timed-out", attempt: 1 })
|
|
87
|
-
|
|
88
|
-
expect(selectTypeaheadFailed(timedOut.state)).toBe(true)
|
|
89
|
-
expect(timedOut.effects).toEqual([{ type: "cancel" }])
|
|
90
|
-
})
|
|
91
|
-
|
|
92
|
-
test("pending queries narrow the rows on screen, and keep them dimmed when nothing matches", () => {
|
|
93
|
-
const narrowed = run(mount({ items: ["dev", "release/base"] }), type("rel"))
|
|
94
|
-
|
|
95
|
-
expect(selectTypeaheadItems(narrowed.state)).toEqual(["release/base"])
|
|
96
|
-
expect(selectTypeaheadStale(narrowed.state)).toBe(false)
|
|
97
|
-
|
|
98
|
-
const unmatched = run(narrowed, type("zzz"))
|
|
99
|
-
|
|
100
|
-
expect(selectTypeaheadItems(unmatched.state)).toEqual(["release/base"])
|
|
101
|
-
expect(selectTypeaheadStale(unmatched.state)).toBe(true)
|
|
102
|
-
})
|
|
103
|
-
|
|
104
|
-
test("a cached query answers at once", () => {
|
|
105
|
-
const cached = run(
|
|
106
|
-
mount({ items: ["dev"] }),
|
|
107
|
-
type("rel"),
|
|
108
|
-
{ type: "debounce.elapsed", attempt: 1 },
|
|
109
|
-
{ type: "request.succeeded", attempt: 1, items: ["release"] },
|
|
110
|
-
type("main"),
|
|
111
|
-
type("rel"),
|
|
112
|
-
)
|
|
113
|
-
|
|
114
|
-
expect(cached.state.status).toBe("ready")
|
|
115
|
-
expect(selectTypeaheadItems(cached.state)).toEqual(["release"])
|
|
116
|
-
expect(cached.effects).toEqual([{ type: "cancel" }])
|
|
117
|
-
})
|
|
118
|
-
|
|
119
|
-
test("without an opening list the empty query is requested on mount", () => {
|
|
120
|
-
const opened = mount()
|
|
121
|
-
|
|
122
|
-
expect(opened.effects).toEqual([{ type: "request", attempt: 1, query: "" }])
|
|
123
|
-
expect(selectTypeaheadPending(opened.state)).toBe(true)
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
test("a refreshed opening list replaces the shown rows for the empty query", () => {
|
|
127
|
-
const refreshed = run(
|
|
128
|
-
mount({ items: [], failed: true }),
|
|
129
|
-
{ type: "retry.requested" },
|
|
130
|
-
{ type: "request.succeeded", attempt: 1, items: ["dev"] },
|
|
131
|
-
{ type: "initial.synced", initial: { items: ["dev", "main"] } },
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
expect(selectTypeaheadItems(refreshed.state)).toEqual(["dev", "main"])
|
|
135
|
-
})
|
|
136
|
-
|
|
137
|
-
test("disposing cancels pending work and ignores later results", () => {
|
|
138
|
-
const disposed = run(mount(), { type: "disposed" })
|
|
139
|
-
|
|
140
|
-
expect(disposed.effects).toEqual([{ type: "cancel" }])
|
|
141
|
-
expect(run(disposed, { type: "request.succeeded", attempt: 1, items: ["dev"] }).state).toBe(disposed.state)
|
|
142
|
-
})
|
|
143
|
-
})
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "bun:test"
|
|
2
|
-
import {
|
|
3
|
-
DISPOSED,
|
|
4
|
-
FOLLOWING,
|
|
5
|
-
IDLE,
|
|
6
|
-
PAUSED_IDLE,
|
|
7
|
-
PAUSED_WORKING,
|
|
8
|
-
createAutoScrollState,
|
|
9
|
-
selectOverflowAnchor,
|
|
10
|
-
selectPausesOnSelection,
|
|
11
|
-
selectUserScrolled,
|
|
12
|
-
transitionAutoScroll,
|
|
13
|
-
type AutoScrollEffect,
|
|
14
|
-
type AutoScrollEvent,
|
|
15
|
-
type AutoScrollState,
|
|
16
|
-
} from "./auto-scroll-machine"
|
|
17
|
-
|
|
18
|
-
function run(state: AutoScrollState, ...events: AutoScrollEvent[]) {
|
|
19
|
-
return events.reduce<{ state: AutoScrollState; effects: readonly AutoScrollEffect[] }>(
|
|
20
|
-
(result, event) => transitionAutoScroll(result.state, event),
|
|
21
|
-
{ state, effects: [] },
|
|
22
|
-
)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const types = (effects: readonly AutoScrollEffect[]) => effects.map((effect) => effect.type)
|
|
26
|
-
|
|
27
|
-
// Built the way `handleScroll` builds it from the viewport.
|
|
28
|
-
const scroll = (scrollTop: number, maxScroll: number, threshold = 10): AutoScrollEvent => ({
|
|
29
|
-
type: "scroll",
|
|
30
|
-
overflow: maxScroll > 1,
|
|
31
|
-
scrollTop,
|
|
32
|
-
maxScroll,
|
|
33
|
-
threshold,
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
const flight = (top: number): AutoScrollEvent => ({ type: "flight.started", top })
|
|
37
|
-
|
|
38
|
-
test("a user scroll that lands on the last programmatic target pauses", () => {
|
|
39
|
-
const consumed = run(FOLLOWING, flight(400), scroll(400, 400))
|
|
40
|
-
expect(consumed.state).toBe(FOLLOWING)
|
|
41
|
-
|
|
42
|
-
const later = transitionAutoScroll(consumed.state, scroll(400, 450))
|
|
43
|
-
expect(later.state).toBe(PAUSED_WORKING)
|
|
44
|
-
expect(types(later.effects)).toEqual(["notify.interacted"])
|
|
45
|
-
|
|
46
|
-
const nudged = run(FOLLOWING, flight(400), scroll(398.8, 450))
|
|
47
|
-
expect(nudged.state).toBe(PAUSED_WORKING)
|
|
48
|
-
expect(types(nudged.effects)).toEqual(["notify.interacted"])
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
test("taking over drops the pending programmatic target", () => {
|
|
52
|
-
const takeover = run(FOLLOWING, flight(400), { type: "pause", overflow: true })
|
|
53
|
-
expect(takeover.state).toBe(PAUSED_WORKING)
|
|
54
|
-
expect(takeover.state).not.toHaveProperty("flight")
|
|
55
|
-
|
|
56
|
-
const resumed = run(takeover.state, scroll(445, 450), scroll(400, 450))
|
|
57
|
-
expect(resumed.state).toBe(PAUSED_WORKING)
|
|
58
|
-
expect(types(resumed.effects)).toEqual(["notify.interacted"])
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
test("content growth during a programmatic scroll catches up", () => {
|
|
62
|
-
const result = run(FOLLOWING, flight(400), scroll(400, 460))
|
|
63
|
-
expect(result.state).toBe(FOLLOWING)
|
|
64
|
-
expect(types(result.effects)).toEqual(["pin.bottom"])
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
test("content that grows after the settling tail still follows", () => {
|
|
68
|
-
const settling = transitionAutoScroll(FOLLOWING, { type: "working.changed", working: false, attempt: 1 })
|
|
69
|
-
expect(settling.state).toEqual({ status: "settling", attempt: 1, detached: false, flight: undefined })
|
|
70
|
-
expect(settling.effects).toEqual([{ type: "settle.start", attempt: 1 }])
|
|
71
|
-
|
|
72
|
-
const idle = transitionAutoScroll(settling.state, { type: "settle.elapsed", attempt: 1 })
|
|
73
|
-
expect(idle.state).toBe(IDLE)
|
|
74
|
-
|
|
75
|
-
const grown = transitionAutoScroll(idle.state, { type: "resize", overflow: true })
|
|
76
|
-
expect(grown.state).toBe(IDLE)
|
|
77
|
-
expect(types(grown.effects)).toEqual(["pin.bottom"])
|
|
78
|
-
expect(types(transitionAutoScroll(IDLE, { type: "scroll.bottom", force: false }).effects)).toEqual(["pin.bottom"])
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
test("pause ends as soon as the viewport stops overflowing", () => {
|
|
82
|
-
expect(transitionAutoScroll(PAUSED_WORKING, { type: "resize", overflow: false }).state).toBe(FOLLOWING)
|
|
83
|
-
expect(transitionAutoScroll(PAUSED_IDLE, { type: "resize", overflow: false }).state).toBe(IDLE)
|
|
84
|
-
expect(transitionAutoScroll(PAUSED_WORKING, { type: "pause", overflow: false }).state).toBe(FOLLOWING)
|
|
85
|
-
expect(transitionAutoScroll(FOLLOWING, { type: "pause", overflow: false }).state).toBe(FOLLOWING)
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
test("a viewport ref change keeps the pause until the new viewport measures", () => {
|
|
89
|
-
const detached = transitionAutoScroll(PAUSED_IDLE, { type: "scroller.detached" }).state
|
|
90
|
-
|
|
91
|
-
const remounted = run(
|
|
92
|
-
detached,
|
|
93
|
-
{ type: "scroller.changed", overflow: false },
|
|
94
|
-
{ type: "scroller.changed", overflow: false },
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
expect(remounted.state).toBe(PAUSED_IDLE)
|
|
98
|
-
expect(remounted.effects).toEqual([])
|
|
99
|
-
|
|
100
|
-
expect(transitionAutoScroll(remounted.state, { type: "resize", overflow: false }).state).toBe(IDLE)
|
|
101
|
-
})
|
|
102
|
-
|
|
103
|
-
test("text selection pauses only while content still moves", () => {
|
|
104
|
-
const settling = run(FOLLOWING, { type: "working.changed", working: false, attempt: 1 }).state
|
|
105
|
-
|
|
106
|
-
expect(selectPausesOnSelection(FOLLOWING)).toBe(true)
|
|
107
|
-
expect(selectPausesOnSelection(settling)).toBe(true)
|
|
108
|
-
expect(selectPausesOnSelection(IDLE)).toBe(false)
|
|
109
|
-
expect(selectPausesOnSelection(PAUSED_WORKING)).toBe(false)
|
|
110
|
-
|
|
111
|
-
const paused = transitionAutoScroll(settling, { type: "pause", overflow: true })
|
|
112
|
-
expect(paused.state).toBe(PAUSED_IDLE)
|
|
113
|
-
expect(types(paused.effects)).toEqual(["settle.stop", "notify.interacted"])
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
test("a detached viewport keeps its pause and pins again on reattach", () => {
|
|
117
|
-
const detached = transitionAutoScroll(PAUSED_WORKING, { type: "scroller.detached" }).state
|
|
118
|
-
const measured = run(detached, { type: "resize", overflow: false }, scroll(0, 0))
|
|
119
|
-
expect(measured.state).toBe(detached)
|
|
120
|
-
|
|
121
|
-
const reattached = transitionAutoScroll(detached, { type: "scroller.reattached", overflow: true })
|
|
122
|
-
expect(reattached.state).toBe(PAUSED_WORKING)
|
|
123
|
-
expect(reattached.effects).toEqual([])
|
|
124
|
-
|
|
125
|
-
const idle = run(IDLE, { type: "scroller.detached" }, { type: "scroller.reattached", overflow: true })
|
|
126
|
-
expect(idle.state).toBe(IDLE)
|
|
127
|
-
expect(types(idle.effects)).toEqual(["pin.bottom"])
|
|
128
|
-
|
|
129
|
-
expect(transitionAutoScroll(IDLE, { type: "scroller.reattached", overflow: true }).effects).toEqual([])
|
|
130
|
-
})
|
|
131
|
-
|
|
132
|
-
test("detaching drops a programmatic target whose scroll event will not come", () => {
|
|
133
|
-
const result = run(
|
|
134
|
-
FOLLOWING,
|
|
135
|
-
flight(400),
|
|
136
|
-
{ type: "scroller.detached" },
|
|
137
|
-
{ type: "scroller.reattached", overflow: true },
|
|
138
|
-
)
|
|
139
|
-
|
|
140
|
-
expect(result.state).toBe(FOLLOWING)
|
|
141
|
-
|
|
142
|
-
expect(transitionAutoScroll(result.state, scroll(400, 450)).state).toBe(PAUSED_WORKING)
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
test("working resumes following from the settling tail and ignores stale settle timers", () => {
|
|
146
|
-
const stopped = { type: "working.changed", working: false } as const
|
|
147
|
-
const first = run(FOLLOWING, { ...stopped, attempt: 1 })
|
|
148
|
-
const resumed = transitionAutoScroll(first.state, { type: "working.changed", working: true, attempt: 1 })
|
|
149
|
-
expect(resumed.state).toBe(FOLLOWING)
|
|
150
|
-
expect(types(resumed.effects)).toEqual(["settle.stop", "pin.bottom"])
|
|
151
|
-
|
|
152
|
-
const second = transitionAutoScroll(resumed.state, { ...stopped, attempt: 2 }).state
|
|
153
|
-
expect(transitionAutoScroll(second, { type: "settle.elapsed", attempt: 1 }).state).toBe(second)
|
|
154
|
-
expect(transitionAutoScroll(second, { type: "settle.elapsed", attempt: 2 }).state).toBe(IDLE)
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
test("paused tracks work and a forced scroll resumes where work stands", () => {
|
|
158
|
-
const idle = transitionAutoScroll(PAUSED_WORKING, { type: "working.changed", working: false, attempt: 1 })
|
|
159
|
-
expect(idle.state).toBe(PAUSED_IDLE)
|
|
160
|
-
expect(idle.effects).toEqual([])
|
|
161
|
-
|
|
162
|
-
expect(transitionAutoScroll(PAUSED_IDLE, { type: "scroll.bottom", force: false }).state).toBe(PAUSED_IDLE)
|
|
163
|
-
const forced = transitionAutoScroll(PAUSED_IDLE, { type: "scroll.bottom", force: true })
|
|
164
|
-
expect(forced.state).toBe(IDLE)
|
|
165
|
-
expect(types(forced.effects)).toEqual(["pin.bottom"])
|
|
166
|
-
expect(transitionAutoScroll(PAUSED_WORKING, scroll(445, 450)).state).toBe(FOLLOWING)
|
|
167
|
-
})
|
|
168
|
-
|
|
169
|
-
test("steady scroll and resize return the same transition", () => {
|
|
170
|
-
const steady: [AutoScrollState, AutoScrollEvent][] = [
|
|
171
|
-
[IDLE, scroll(400, 400)],
|
|
172
|
-
[FOLLOWING, scroll(400, 400)],
|
|
173
|
-
[PAUSED_IDLE, scroll(100, 400)],
|
|
174
|
-
[PAUSED_WORKING, scroll(100, 400)],
|
|
175
|
-
[PAUSED_WORKING, { type: "resize", overflow: true }],
|
|
176
|
-
[IDLE, { type: "resize", overflow: true }],
|
|
177
|
-
[FOLLOWING, { type: "resize", overflow: true }],
|
|
178
|
-
]
|
|
179
|
-
|
|
180
|
-
steady.forEach(([state, event]) => {
|
|
181
|
-
const result = transitionAutoScroll(state, event)
|
|
182
|
-
expect(result.state).toBe(state)
|
|
183
|
-
expect(transitionAutoScroll(state, event)).toBe(result)
|
|
184
|
-
})
|
|
185
|
-
})
|
|
186
|
-
|
|
187
|
-
test("disposal stops the settle timer and ignores later events", () => {
|
|
188
|
-
const settling = run(FOLLOWING, { type: "working.changed", working: false, attempt: 1 }, flight(400)).state
|
|
189
|
-
const disposed = transitionAutoScroll(settling, { type: "disposed" })
|
|
190
|
-
expect(disposed.state).toBe(DISPOSED)
|
|
191
|
-
expect(types(disposed.effects)).toEqual(["settle.stop"])
|
|
192
|
-
|
|
193
|
-
const later = run(
|
|
194
|
-
DISPOSED,
|
|
195
|
-
{ type: "working.changed", working: true, attempt: 2 },
|
|
196
|
-
{ type: "resize", overflow: true },
|
|
197
|
-
)
|
|
198
|
-
|
|
199
|
-
expect(later.state).toBe(DISPOSED)
|
|
200
|
-
expect(later.effects).toEqual([])
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
test("selectors derive the public view", () => {
|
|
204
|
-
expect(createAutoScrollState(true)).toBe(FOLLOWING)
|
|
205
|
-
expect(createAutoScrollState(false)).toBe(IDLE)
|
|
206
|
-
expect(selectUserScrolled(PAUSED_IDLE)).toBe(true)
|
|
207
|
-
expect(selectUserScrolled(FOLLOWING)).toBe(false)
|
|
208
|
-
expect(selectOverflowAnchor(PAUSED_IDLE)).toBe("auto")
|
|
209
|
-
expect(selectOverflowAnchor(FOLLOWING)).toBe("none")
|
|
210
|
-
expect(selectOverflowAnchor(PAUSED_IDLE, "none")).toBe("none")
|
|
211
|
-
expect(selectOverflowAnchor(FOLLOWING, "auto")).toBe("auto")
|
|
212
|
-
})
|