@thanhnguyxn/pixelcraft 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.agents/plugins/marketplace.json +1 -1
- package/.antigravity-plugin/plugin.json +32 -0
- package/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +15 -4
- package/.codex-plugin/plugin.json +45 -0
- package/.cursor-plugin/marketplace.json +17 -0
- package/.cursor-plugin/plugin.json +27 -0
- package/.devin-plugin/plugin.json +21 -0
- package/.github/plugin/marketplace.json +34 -0
- package/CHANGELOG.md +159 -0
- package/GEMINI.md +1 -0
- package/README.md +185 -328
- package/SECURITY.md +28 -0
- package/assets/pixelcraft-logo-128.png +0 -0
- package/assets/pixelcraft-logo-256.png +0 -0
- package/bin/pixelcraft.mjs +431 -23
- package/docs/ARCHITECTURE.md +40 -37
- package/docs/DESIGN-RATIONALE.md +51 -3
- package/docs/INSTALL.md +221 -0
- package/evals/README.md +16 -6
- package/evals/fixtures/3d-web-engineering.json +69 -0
- package/evals/fixtures/acceptance-checklist-rule03-gate.json +43 -0
- package/evals/fixtures/ai-ui-libraries.json +53 -0
- package/evals/fixtures/audio-visual-accessibility.json +69 -0
- package/evals/fixtures/auth-and-checkout-ui.json +53 -0
- package/evals/fixtures/brandkit-identity-governance.json +48 -0
- package/evals/fixtures/build-and-architecture.json +53 -0
- package/evals/fixtures/canvas-and-node-editors.json +53 -0
- package/evals/fixtures/chat-ai-exfiltration-ime-hitl-gate.json +43 -0
- package/evals/fixtures/completion-gate-scan-until-clean.json +44 -0
- package/evals/fixtures/component-systems.json +53 -0
- package/evals/fixtures/component-testing.json +53 -0
- package/evals/fixtures/constrained-voice-and-tv.json +43 -0
- package/evals/fixtures/creative-code-rendering.json +69 -0
- package/evals/fixtures/creative-reference-evidence.json +67 -0
- package/evals/fixtures/data-app-python-marimo.json +49 -0
- package/evals/fixtures/desktop-cpp-juce-audio.json +49 -0
- package/evals/fixtures/desktop-csharp-avalonia.json +49 -0
- package/evals/fixtures/desktop-native-workspace.json +48 -0
- package/evals/fixtures/desktop-python-anti-tkinter.json +49 -0
- package/evals/fixtures/document-prepress-pdfx4-tounicode.json +43 -0
- package/evals/fixtures/document-rust-typst-invoice.json +49 -0
- package/evals/fixtures/document-typst-and-print-css.json +43 -0
- package/evals/fixtures/email-mjml-dark-mode.json +49 -0
- package/evals/fixtures/email-outlook-and-plaintext.json +43 -0
- package/evals/fixtures/enterprise-data-ui.json +53 -0
- package/evals/fixtures/extended-tui-toolkits.json +53 -0
- package/evals/fixtures/extensions-mv3-and-vscode.json +43 -0
- package/evals/fixtures/file-upload-media-ui.json +53 -0
- package/evals/fixtures/forms-validation.json +53 -0
- package/evals/fixtures/game-go-ebitengine.json +49 -0
- package/evals/fixtures/game-godot-gdscript.json +49 -0
- package/evals/fixtures/game-ui-hud-and-engines.json +43 -0
- package/evals/fixtures/i18n-engineering.json +53 -0
- package/evals/fixtures/local-first-sync.json +53 -0
- package/evals/fixtures/lynxjs.json +53 -0
- package/evals/fixtures/maizzle-email.json +53 -0
- package/evals/fixtures/maps-geospatial.json +53 -0
- package/evals/fixtures/media-og-and-video-export.json +43 -0
- package/evals/fixtures/media-players.json +53 -0
- package/evals/fixtures/mobile-compose-16kb-foldable-store-gate.json +44 -0
- package/evals/fixtures/mobile-elixir-liveview-native.json +49 -0
- package/evals/fixtures/mobile-flutter-dynamic-type.json +49 -0
- package/evals/fixtures/mobile-harmonyos-arkui.json +49 -0
- package/evals/fixtures/mobile-jetpack-compose.json +49 -0
- package/evals/fixtures/mobile-swiftui-ios.json +49 -0
- package/evals/fixtures/motion-engineering.json +69 -0
- package/evals/fixtures/pdfjs-and-pptx.json +53 -0
- package/evals/fixtures/plan-discovery-interview.json +31 -0
- package/evals/fixtures/plan-grill-me-brainstorm-gate.json +49 -0
- package/evals/fixtures/reactive-data-apps.json +53 -0
- package/evals/fixtures/review-evidence-audit.json +43 -0
- package/evals/fixtures/rich-text-and-code-editors.json +53 -0
- package/evals/fixtures/scrollytelling-resilience.json +70 -0
- package/evals/fixtures/spatial-xr-comfort-and-platforms.json +43 -0
- package/evals/fixtures/state-architecture.json +53 -0
- package/evals/fixtures/styling-ecosystem.json +53 -0
- package/evals/fixtures/token-tooling.json +53 -0
- package/evals/fixtures/tui-go-bubbletea.json +49 -0
- package/evals/fixtures/tui-rust-ratatui-grapheme-paste-teardown.json +44 -0
- package/evals/fixtures/tui-rust-ratatui.json +49 -0
- package/evals/fixtures/ux-state-matrix-and-i18n.json +43 -0
- package/evals/fixtures/web-3d-engines.json +53 -0
- package/evals/fixtures/web-php-laravel-filament.json +49 -0
- package/evals/fixtures/web-ruby-viewcomponent-phlex.json +49 -0
- package/evals/pixelcraft-accessibility.md +17 -0
- package/evals/pixelcraft-craft.md +16 -0
- package/evals/pixelcraft-dataviz.md +3 -3
- package/evals/pixelcraft-direction.md +17 -0
- package/evals/pixelcraft-game-ui.md +3 -3
- package/evals/pixelcraft-mobile.md +3 -3
- package/evals/pixelcraft-patterns.md +16 -0
- package/evals/pixelcraft-plan.md +65 -3
- package/evals/pixelcraft-review.md +3 -3
- package/evals/pixelcraft-visual-qa.md +11 -5
- package/evals/pixelcraft-web.md +21 -3
- package/evals/pixelcraft.md +4 -4
- package/gemini-extension.json +3 -2
- package/install.ps1 +57 -11
- package/install.sh +82 -7
- package/package.json +32 -4
- package/plugin.json +6 -1
- package/scripts/build-adapters.mjs +11 -13
- package/scripts/run-evals.mjs +397 -0
- package/scripts/sync-docs.mjs +381 -0
- package/scripts/test-build-adapters.mjs +14 -1
- package/scripts/test-cross-platform-qa.mjs +359 -0
- package/scripts/test-distribution.mjs +86 -7
- package/scripts/test-export-tokens.mjs +259 -3
- package/scripts/test-finish-gate.mjs +133 -10
- package/scripts/test-installers.mjs +155 -6
- package/scripts/test-shoot.mjs +23 -1
- package/scripts/test-slop-scan.mjs +390 -3
- package/scripts/test-style-inventory.mjs +23 -0
- package/scripts/test-sync-docs.mjs +140 -0
- package/scripts/test-validate-skills.mjs +82 -4
- package/scripts/validate-skills.mjs +149 -3
- package/skills/pixelcraft/SKILL.md +67 -47
- package/skills/pixelcraft/references/design-brief.md +2 -2
- package/skills/pixelcraft/references/floor.md +36 -19
- package/skills/pixelcraft/references/report-template.md +25 -11
- package/skills/pixelcraft/references/stack-detection.md +138 -67
- package/skills/pixelcraft/references/surface-acceptance.md +33 -21
- package/skills/pixelcraft/references/workflow-checkpoints.md +49 -7
- package/skills/pixelcraft-accessibility/SKILL.md +34 -13
- package/skills/pixelcraft-accessibility/references/apg-patterns.md +13 -0
- package/skills/pixelcraft-accessibility/references/motion-canvas.md +57 -0
- package/skills/pixelcraft-accessibility/references/platforms.md +34 -6
- package/skills/pixelcraft-accessibility/references/verification.md +15 -10
- package/skills/pixelcraft-accessibility/references/wcag22-checks.md +38 -5
- package/skills/pixelcraft-brandkit/SKILL.md +42 -30
- package/skills/pixelcraft-brandkit/references/asset-pipeline.md +90 -50
- package/skills/pixelcraft-brandkit/references/brand-governance.md +29 -27
- package/skills/pixelcraft-brandkit/references/logo-methods.md +33 -34
- package/skills/pixelcraft-brandkit/references/prompt-template.md +53 -51
- package/skills/pixelcraft-brandkit/references/qa-checklist.md +7 -2
- package/skills/pixelcraft-brandkit/references/visual-modes.md +16 -16
- package/skills/pixelcraft-chat-ui/SKILL.md +31 -27
- package/skills/pixelcraft-chat-ui/references/agentic-workspace.md +66 -0
- package/skills/pixelcraft-chat-ui/references/ai-ui-libraries.md +259 -0
- package/skills/pixelcraft-chat-ui/references/conversation-design.md +12 -6
- package/skills/pixelcraft-chat-ui/references/mobile-business-platforms.md +58 -68
- package/skills/pixelcraft-chat-ui/references/slack-discord.md +60 -76
- package/skills/pixelcraft-constrained/SKILL.md +21 -20
- package/skills/pixelcraft-constrained/references/specialized-hardware.md +69 -45
- package/skills/pixelcraft-constrained/references/tv-wearables.md +123 -73
- package/skills/pixelcraft-constrained/references/voice-ui.md +86 -45
- package/skills/pixelcraft-craft/SKILL.md +29 -15
- package/skills/pixelcraft-craft/references/color.md +62 -6
- package/skills/pixelcraft-craft/references/layout.md +32 -0
- package/skills/pixelcraft-craft/references/motion.md +99 -12
- package/skills/pixelcraft-craft/references/typography.md +48 -9
- package/skills/pixelcraft-data-apps/SKILL.md +50 -31
- package/skills/pixelcraft-data-apps/references/ai-and-internal-data-apps.md +147 -0
- package/skills/pixelcraft-data-apps/references/dash.md +87 -31
- package/skills/pixelcraft-data-apps/references/evidence.md +41 -26
- package/skills/pixelcraft-data-apps/references/gradio.md +65 -27
- package/skills/pixelcraft-data-apps/references/julia-genie.md +64 -29
- package/skills/pixelcraft-data-apps/references/jupyter-widgets.md +65 -27
- package/skills/pixelcraft-data-apps/references/nicegui.md +73 -34
- package/skills/pixelcraft-data-apps/references/observable-framework.md +65 -27
- package/skills/pixelcraft-data-apps/references/panel.md +69 -23
- package/skills/pixelcraft-data-apps/references/r-shiny.md +104 -34
- package/skills/pixelcraft-data-apps/references/reactive-data-apps.md +186 -0
- package/skills/pixelcraft-data-apps/references/reflex.md +85 -31
- package/skills/pixelcraft-data-apps/references/shiny.md +84 -27
- package/skills/pixelcraft-data-apps/references/streamlit.md +73 -25
- package/skills/pixelcraft-dataviz/SKILL.md +21 -24
- package/skills/pixelcraft-dataviz/references/color-accessibility.md +2 -2
- package/skills/pixelcraft-dataviz/references/encoding-tables-dashboards.md +35 -25
- package/skills/pixelcraft-dataviz/references/libraries.md +165 -46
- package/skills/pixelcraft-dataviz/references/maps-geospatial.md +159 -0
- package/skills/pixelcraft-dataviz/references/realtime-graphs-maps-scale.md +58 -65
- package/skills/pixelcraft-desktop/SKILL.md +61 -39
- package/skills/pixelcraft-desktop/references/appkit.md +60 -26
- package/skills/pixelcraft-desktop/references/avalonia.md +65 -29
- package/skills/pixelcraft-desktop/references/cpp-gui.md +104 -27
- package/skills/pixelcraft-desktop/references/electron.md +68 -26
- package/skills/pixelcraft-desktop/references/go-gui.md +59 -30
- package/skills/pixelcraft-desktop/references/gtk.md +74 -31
- package/skills/pixelcraft-desktop/references/javafx-swing.md +54 -25
- package/skills/pixelcraft-desktop/references/qt-pyside-qml.md +57 -30
- package/skills/pixelcraft-desktop/references/rust-gui.md +59 -41
- package/skills/pixelcraft-desktop/references/tauri.md +80 -24
- package/skills/pixelcraft-desktop/references/uno-platform.md +42 -23
- package/skills/pixelcraft-desktop/references/winui-wpf.md +66 -26
- package/skills/pixelcraft-desktop/references/working-context.md +82 -3
- package/skills/pixelcraft-direction/SKILL.md +48 -82
- package/skills/pixelcraft-direction/references/creative-brainstorming.md +72 -0
- package/skills/pixelcraft-direction/references/direction-card.md +11 -1
- package/skills/pixelcraft-direction/references/direction-scoring.md +5 -1
- package/skills/pixelcraft-direction/references/motion-identity.md +67 -0
- package/skills/pixelcraft-direction/references/movements.md +3 -0
- package/skills/pixelcraft-direction/references/reference-analysis.md +37 -0
- package/skills/pixelcraft-direction/references/slop-fingerprints.md +32 -7
- package/skills/pixelcraft-document/SKILL.md +27 -23
- package/skills/pixelcraft-document/references/archetypes.md +27 -4
- package/skills/pixelcraft-document/references/pdf-tools.md +241 -81
- package/skills/pixelcraft-document/references/pdfjs-and-pptx.md +114 -0
- package/skills/pixelcraft-document/references/print-css.md +96 -43
- package/skills/pixelcraft-document/references/slides.md +123 -27
- package/skills/pixelcraft-email/SKILL.md +42 -20
- package/skills/pixelcraft-email/references/client-quirks.md +101 -33
- package/skills/pixelcraft-email/references/html-tables.md +83 -22
- package/skills/pixelcraft-email/references/maizzle.md +54 -0
- package/skills/pixelcraft-email/references/mjml.md +13 -11
- package/skills/pixelcraft-email/references/react-email.md +76 -34
- package/skills/pixelcraft-extensions/SKILL.md +32 -27
- package/skills/pixelcraft-extensions/references/browser-extensions.md +91 -17
- package/skills/pixelcraft-extensions/references/figma-office.md +97 -14
- package/skills/pixelcraft-extensions/references/ide-and-saas-plugins.md +125 -0
- package/skills/pixelcraft-extensions/references/raycast.md +90 -11
- package/skills/pixelcraft-extensions/references/vscode-webviews.md +91 -17
- package/skills/pixelcraft-game-ui/SKILL.md +45 -26
- package/skills/pixelcraft-game-ui/references/bevy.md +69 -31
- package/skills/pixelcraft-game-ui/references/godot.md +100 -27
- package/skills/pixelcraft-game-ui/references/hud-principles.md +50 -21
- package/skills/pixelcraft-game-ui/references/love2d.md +53 -27
- package/skills/pixelcraft-game-ui/references/monogame.md +45 -29
- package/skills/pixelcraft-game-ui/references/unity-ugui.md +109 -0
- package/skills/pixelcraft-game-ui/references/unity-ui-toolkit.md +69 -27
- package/skills/pixelcraft-game-ui/references/unreal-umg.md +53 -26
- package/skills/pixelcraft-game-ui/references/web-and-middleware-game-ui.md +122 -0
- package/skills/pixelcraft-handoff/SKILL.md +14 -13
- package/skills/pixelcraft-handoff/references/design-translation.md +40 -10
- package/skills/pixelcraft-handoff/references/motion-handoff.md +54 -0
- package/skills/pixelcraft-media/SKILL.md +20 -23
- package/skills/pixelcraft-media/references/banners-video.md +83 -65
- package/skills/pixelcraft-media/references/og-generation.md +110 -63
- package/skills/pixelcraft-media/references/social-cards.md +57 -58
- package/skills/pixelcraft-mobile/SKILL.md +53 -36
- package/skills/pixelcraft-mobile/references/dotnet-maui.md +62 -34
- package/skills/pixelcraft-mobile/references/flet.md +53 -26
- package/skills/pixelcraft-mobile/references/flutter.md +76 -32
- package/skills/pixelcraft-mobile/references/harmonyos-and-emerging-mobile.md +121 -0
- package/skills/pixelcraft-mobile/references/ionic-capacitor.md +48 -26
- package/skills/pixelcraft-mobile/references/jetpack-compose.md +92 -24
- package/skills/pixelcraft-mobile/references/kivy.md +54 -31
- package/skills/pixelcraft-mobile/references/kotlin-multiplatform.md +53 -27
- package/skills/pixelcraft-mobile/references/lynxjs.md +110 -0
- package/skills/pixelcraft-mobile/references/nativescript-and-skip.md +91 -0
- package/skills/pixelcraft-mobile/references/react-native-expo.md +66 -31
- package/skills/pixelcraft-mobile/references/swiftui.md +158 -28
- package/skills/pixelcraft-mobile/references/tactile-interactions.md +55 -0
- package/skills/pixelcraft-mobile/references/task-state-composition.md +82 -2
- package/skills/pixelcraft-mobile/references/uikit.md +57 -23
- package/skills/pixelcraft-patterns/SKILL.md +30 -13
- package/skills/pixelcraft-patterns/references/accessibility-resilience.md +29 -0
- package/skills/pixelcraft-patterns/references/ai-and-offline-patterns.md +54 -0
- package/skills/pixelcraft-patterns/references/auth-onboarding.md +32 -13
- package/skills/pixelcraft-patterns/references/billing-paywalls.md +40 -0
- package/skills/pixelcraft-patterns/references/command-workspace.md +56 -0
- package/skills/pixelcraft-patterns/references/commerce.md +35 -16
- package/skills/pixelcraft-patterns/references/communication.md +34 -15
- package/skills/pixelcraft-patterns/references/creative-tools.md +30 -17
- package/skills/pixelcraft-patterns/references/creative-web-composition.md +38 -0
- package/skills/pixelcraft-patterns/references/dashboard-admin.md +22 -18
- package/skills/pixelcraft-patterns/references/history-diff-undo.md +50 -0
- package/skills/pixelcraft-patterns/references/marketing.md +31 -19
- package/skills/pixelcraft-patterns/references/multi-tenant-rbac.md +47 -0
- package/skills/pixelcraft-patterns/references/narrative-systems.md +42 -0
- package/skills/pixelcraft-patterns/references/notifications-activity.md +57 -0
- package/skills/pixelcraft-patterns/references/pattern-selection.md +8 -2
- package/skills/pixelcraft-patterns/references/scheduling-kanban.md +47 -0
- package/skills/pixelcraft-patterns/references/scroll-implementation.md +37 -0
- package/skills/pixelcraft-patterns/references/settings.md +40 -12
- package/skills/pixelcraft-plan/SKILL.md +54 -18
- package/skills/pixelcraft-plan/references/discovery-interview.md +110 -0
- package/skills/pixelcraft-plan/references/grill-me-protocol.md +63 -0
- package/skills/pixelcraft-plan/references/plan-template.md +44 -9
- package/skills/pixelcraft-plan/references/repo-discovery.md +16 -9
- package/skills/pixelcraft-plan/references/stack-freshness.md +22 -5
- package/skills/pixelcraft-plan/references/stack-selection.md +65 -9
- package/skills/pixelcraft-review/SKILL.md +41 -19
- package/skills/pixelcraft-review/references/audit-report.md +20 -1
- package/skills/pixelcraft-review/references/heuristics.md +63 -18
- package/skills/pixelcraft-review/references/personas.md +41 -14
- package/skills/pixelcraft-review/references/polish.md +66 -26
- package/skills/pixelcraft-review/scripts/check-acceptance.mjs +619 -0
- package/skills/pixelcraft-review/scripts/fixtures/focus-longhand-removal.css +34 -0
- package/skills/pixelcraft-review/scripts/slop-scan.mjs +679 -32
- package/skills/pixelcraft-spatial/SKILL.md +16 -17
- package/skills/pixelcraft-spatial/references/comfort-accessibility.md +25 -84
- package/skills/pixelcraft-spatial/references/platforms.md +123 -53
- package/skills/pixelcraft-tokens/SKILL.md +18 -14
- package/skills/pixelcraft-tokens/assets/tokens.example.json +1 -1
- package/skills/pixelcraft-tokens/assets/tokens.modes.example.json +1 -1
- package/skills/pixelcraft-tokens/references/format.md +39 -9
- package/skills/pixelcraft-tokens/references/governance.md +1 -1
- package/skills/pixelcraft-tokens/references/theme-presets.md +36 -8
- package/skills/pixelcraft-tokens/references/token-tooling.md +119 -0
- package/skills/pixelcraft-tokens/scripts/export-tokens.mjs +637 -75
- package/skills/pixelcraft-tui/SKILL.md +41 -25
- package/skills/pixelcraft-tui/references/bubbletea-lipgloss.md +49 -30
- package/skills/pixelcraft-tui/references/extended-tui-toolkits.md +127 -0
- package/skills/pixelcraft-tui/references/ink.md +77 -28
- package/skills/pixelcraft-tui/references/ratatui.md +70 -30
- package/skills/pixelcraft-tui/references/rich.md +53 -33
- package/skills/pixelcraft-tui/references/terminal-protocols.md +80 -0
- package/skills/pixelcraft-tui/references/textual.md +75 -34
- package/skills/pixelcraft-ux/SKILL.md +22 -12
- package/skills/pixelcraft-ux/references/feedback-performance.md +39 -19
- package/skills/pixelcraft-ux/references/forms.md +57 -3
- package/skills/pixelcraft-ux/references/i18n.md +50 -12
- package/skills/pixelcraft-ux/references/laws.md +35 -14
- package/skills/pixelcraft-ux/references/state-matrix.md +15 -1
- package/skills/pixelcraft-ux/references/ux-writing.md +1 -0
- package/skills/pixelcraft-visual-qa/SKILL.md +21 -7
- package/skills/pixelcraft-visual-qa/references/capture-desktop-game.md +28 -7
- package/skills/pixelcraft-visual-qa/references/capture-document.md +70 -0
- package/skills/pixelcraft-visual-qa/references/capture-email.md +13 -9
- package/skills/pixelcraft-visual-qa/references/capture-mobile.md +20 -5
- package/skills/pixelcraft-visual-qa/references/capture-terminal.md +6 -2
- package/skills/pixelcraft-visual-qa/references/motion-capture.md +63 -0
- package/skills/pixelcraft-visual-qa/references/performance-budgets.md +25 -12
- package/skills/pixelcraft-visual-qa/references/realtime-graphics.md +55 -0
- package/skills/pixelcraft-visual-qa/scripts/check-contrast.mjs +442 -0
- package/skills/pixelcraft-visual-qa/scripts/check-email.mjs +397 -0
- package/skills/pixelcraft-visual-qa/scripts/check-pdf.mjs +189 -0
- package/skills/pixelcraft-visual-qa/scripts/check-tui.mjs +321 -0
- package/skills/pixelcraft-visual-qa/scripts/finish-gate.mjs +50 -11
- package/skills/pixelcraft-visual-qa/scripts/shoot.mjs +214 -59
- package/skills/pixelcraft-visual-qa/scripts/style-inventory.mjs +121 -49
- package/skills/pixelcraft-web/SKILL.md +105 -49
- package/skills/pixelcraft-web/references/accessibility-performance.md +42 -0
- package/skills/pixelcraft-web/references/adaptive-layout.md +52 -8
- package/skills/pixelcraft-web/references/angular.md +63 -16
- package/skills/pixelcraft-web/references/assets-pipeline.md +67 -0
- package/skills/pixelcraft-web/references/astro.md +64 -13
- package/skills/pixelcraft-web/references/audio-reactive.md +61 -0
- package/skills/pixelcraft-web/references/auth-and-checkout-ui.md +115 -0
- package/skills/pixelcraft-web/references/build-and-architecture.md +215 -0
- package/skills/pixelcraft-web/references/canvas-and-node-editors.md +157 -0
- package/skills/pixelcraft-web/references/clojurescript.md +52 -17
- package/skills/pixelcraft-web/references/component-systems.md +102 -0
- package/skills/pixelcraft-web/references/component-testing.md +170 -0
- package/skills/pixelcraft-web/references/creative-effects.md +59 -0
- package/skills/pixelcraft-web/references/creative-runtime.md +34 -0
- package/skills/pixelcraft-web/references/enterprise-data-ui.md +138 -0
- package/skills/pixelcraft-web/references/file-upload-media-ui.md +82 -0
- package/skills/pixelcraft-web/references/forms-validation.md +123 -0
- package/skills/pixelcraft-web/references/fsharp-fable.md +3 -2
- package/skills/pixelcraft-web/references/gsap.md +102 -0
- package/skills/pixelcraft-web/references/html-css.md +144 -12
- package/skills/pixelcraft-web/references/htmx-alpine.md +68 -18
- package/skills/pixelcraft-web/references/i18n-engineering.md +106 -0
- package/skills/pixelcraft-web/references/interaction-and-search-primitives.md +196 -0
- package/skills/pixelcraft-web/references/java-web.md +27 -18
- package/skills/pixelcraft-web/references/kotlin-web.md +6 -2
- package/skills/pixelcraft-web/references/leptos-yew.md +62 -19
- package/skills/pixelcraft-web/references/lit-web-components.md +4 -2
- package/skills/pixelcraft-web/references/local-first-sync.md +105 -0
- package/skills/pixelcraft-web/references/media-players.md +104 -0
- package/skills/pixelcraft-web/references/motion-react.md +96 -0
- package/skills/pixelcraft-web/references/motion-recipes.md +82 -0
- package/skills/pixelcraft-web/references/preact-fresh-hono.md +111 -0
- package/skills/pixelcraft-web/references/pwa.md +6 -1
- package/skills/pixelcraft-web/references/qwik.md +51 -11
- package/skills/pixelcraft-web/references/r3f-integration.md +69 -0
- package/skills/pixelcraft-web/references/react-next.md +112 -13
- package/skills/pixelcraft-web/references/rendering-choice.md +63 -0
- package/skills/pixelcraft-web/references/rendering-performance.md +80 -0
- package/skills/pixelcraft-web/references/rich-text-and-code-editors.md +220 -0
- package/skills/pixelcraft-web/references/rive-lottie.md +73 -0
- package/skills/pixelcraft-web/references/scene-architecture.md +132 -0
- package/skills/pixelcraft-web/references/server-rendered.md +106 -63
- package/skills/pixelcraft-web/references/shader-workflow.md +77 -0
- package/skills/pixelcraft-web/references/smooth-scroll.md +58 -0
- package/skills/pixelcraft-web/references/solid.md +67 -16
- package/skills/pixelcraft-web/references/state-architecture.md +107 -0
- package/skills/pixelcraft-web/references/styling-ecosystem.md +273 -0
- package/skills/pixelcraft-web/references/svelte.md +61 -11
- package/skills/pixelcraft-web/references/tailwind.md +40 -14
- package/skills/pixelcraft-web/references/video-media.md +69 -0
- package/skills/pixelcraft-web/references/vue-nuxt.md +37 -13
- package/skills/pixelcraft-web/references/web-3d-engines.md +97 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Component development and frontend testing
|
|
2
|
+
|
|
3
|
+
Choose the testing layer by what must be proved: logic contracts in unit tests, real layout/focus/ARIA behavior in browser component tests, end-to-end user journeys in E2E tests, and visual/accessibility regressions in dedicated snapshot and axe checks. Do not claim `rendered` visual or layout verification from `jsdom`/`happy-dom` tests (`jsdom` does not compute real layout, fonts, media queries, or CSS cascade).
|
|
4
|
+
|
|
5
|
+
## Toolchain decision matrix
|
|
6
|
+
|
|
7
|
+
| Layer | Tools | Runs in real browser? | Best fit | Primary trap |
|
|
8
|
+
|---|---|---|---|---|
|
|
9
|
+
| **Component workshop** | **Storybook** (CSF 3 + `play` + Vitest addon + `addon-a11y`), **Histoire** (Vue/Svelte), **Ladle** (lightweight React/Vite) | Yes | Isolated component states, design system docs, interactive stories, visual baselines | Treating stories as static screenshots instead of executable state + interaction specs |
|
|
10
|
+
| **Unit & DOM tests** | **Vitest**, **Jest**, **Testing Library** (`@testing-library/*` + `user-event`) | No (unless Vitest Browser Mode) | Pure logic, reducers, formatters, schema validators, fast hook/DOM contracts | Asserting CSS layout, sticky positioning, or focus traps inside `jsdom` |
|
|
11
|
+
| **Real-browser component tests** | **Vitest Browser Mode** (`@vitest/browser-playwright`), **Storybook + Vitest**, **Playwright story gallery** (`@playwright/test`) | Yes | Component contracts that depend on real CSS, focus order, Shadow DOM, Popover/Dialog, or canvas | Relying on removed `@playwright/experimental-ct-*` packages (removed in Playwright 1.63+) |
|
|
12
|
+
| **E2E tests** | **Playwright**, **Cypress**, **WebdriverIO** | Yes | Critical multi-route flows, auth, network/SSR hydration, cross-browser checks | Sleeping (`waitForTimeout`) instead of auto-retrying web-first assertions |
|
|
13
|
+
| **Visual regression** | **Chromatic** (Storybook cloud), **Percy**, **Loki**, Playwright `toHaveScreenshot()` | Yes | Catching unintended spacing, typography, dark-mode, and responsive regressions | Unmasked dynamic dates/avatars/animations causing flaky diffs |
|
|
14
|
+
| **Accessibility regression** | **`@axe-core/playwright`**, **`@storybook/addon-a11y`**, **`vitest-axe` / `jest-axe`**, **pa11y** | Yes (Playwright/Storybook/pa11y); DOM-only (`jest-axe`) | Continuous WCAG 2.1/2.2 A/AA checks on every PR | Assuming zero axe violations equals full accessibility (axe catches ~30–50% of WCAG issues; keyboard/focus/screen-reader flows still need verification) |
|
|
15
|
+
|
|
16
|
+
## Component workshop & interaction testing (Storybook CSF 3 + `@storybook/addon-vitest`)
|
|
17
|
+
|
|
18
|
+
Write stories for every required state (default, loading, empty, error, disabled, overflow/long text, RTL/dark mode) and attach `play` functions for interactive contracts.
|
|
19
|
+
|
|
20
|
+
- In Storybook 9/10+, import `expect`, `fn`, and `waitFor` from `'storybook/test'` and destructure `{ args, canvas, step, userEvent }` directly in `play`.
|
|
21
|
+
- Wire **`@storybook/addon-vitest`** so every story (and its `play` + `addon-a11y` checks) executes directly in Vitest Browser Mode on CI, or reuse stories in standalone test files via **`composeStories(stories)`** from `@storybook/react` / `@storybook/vue3` / `@storybook/svelte` so decorators and args never drift.
|
|
22
|
+
- Pair Storybook and Vitest with **MSW v2** (`http.get`, `HttpResponse.json`) for deterministic network states rather than mocking `fetch` globally.
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
// Dialog.stories.ts (Storybook CSF 3)
|
|
26
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
27
|
+
import { expect, fn, waitFor } from 'storybook/test';
|
|
28
|
+
import { Dialog } from './Dialog';
|
|
29
|
+
|
|
30
|
+
const meta = {
|
|
31
|
+
component: Dialog,
|
|
32
|
+
args: { onConfirm: fn() },
|
|
33
|
+
} satisfies Meta<typeof Dialog>;
|
|
34
|
+
export default meta;
|
|
35
|
+
|
|
36
|
+
type Story = StoryObj<typeof meta>;
|
|
37
|
+
|
|
38
|
+
export const OpensAndConfirms: Story = {
|
|
39
|
+
play: async ({ args, canvas, step, userEvent }) => {
|
|
40
|
+
await step('Open dialog', async () => {
|
|
41
|
+
await userEvent.click(canvas.getByRole('button', { name: /delete item/i }));
|
|
42
|
+
await expect(canvas.getByRole('dialog')).toBeInTheDocument();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
await step('Confirm action', async () => {
|
|
46
|
+
await userEvent.click(canvas.getByRole('button', { name: /confirm/i }));
|
|
47
|
+
await waitFor(() => expect(args.onConfirm).toHaveBeenCalledTimes(1));
|
|
48
|
+
});
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
// MSW v2 network handler (shared across Storybook, Vitest, and browser tests)
|
|
55
|
+
import { http, HttpResponse } from 'msw';
|
|
56
|
+
|
|
57
|
+
export const handlers = [
|
|
58
|
+
http.get('/api/invoices', ({ request }) => {
|
|
59
|
+
const q = new URL(request.url).searchParams.get('q') ?? '';
|
|
60
|
+
return HttpResponse.json({ items: q ? [] : [{ id: '1', number: 'INV-101' }] });
|
|
61
|
+
}),
|
|
62
|
+
];
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Real-browser component testing (Vitest Browser Mode)
|
|
66
|
+
|
|
67
|
+
Use **Vitest Browser Mode** when a component relies on real layout, CSS custom properties, `@container` queries, Shadow DOM, or native `<dialog>`/Popover behavior.
|
|
68
|
+
|
|
69
|
+
- In Vitest 4+, import `playwright` from `'@vitest/browser-playwright'` and pass `provider: playwright()` (not the legacy string `'playwright'`).
|
|
70
|
+
- Use `page.getByRole()` / `page.getByLabelText()` locators with `await expect.element(locator)` for built-in retryability.
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
// vitest.config.ts (Vitest 4+)
|
|
74
|
+
import { defineConfig } from 'vitest/config';
|
|
75
|
+
import { playwright } from '@vitest/browser-playwright';
|
|
76
|
+
|
|
77
|
+
export default defineConfig({
|
|
78
|
+
test: {
|
|
79
|
+
browser: {
|
|
80
|
+
enabled: true,
|
|
81
|
+
provider: playwright(),
|
|
82
|
+
instances: [{ browser: 'chromium' }],
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
// AlertBanner.browser.test.ts
|
|
90
|
+
import { expect, test } from 'vitest';
|
|
91
|
+
import { page } from 'vitest/browser';
|
|
92
|
+
|
|
93
|
+
test('announces error state accessibly', async () => {
|
|
94
|
+
renderErrorBanner();
|
|
95
|
+
const banner = page.getByRole('alert', { name: /error/i });
|
|
96
|
+
await expect.element(banner).toHaveTextContent('Connection lost');
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Testing Library query & interaction contract
|
|
101
|
+
|
|
102
|
+
Follow Testing Library's accessibility-first query priority so tests validate the accessibility tree simultaneously:
|
|
103
|
+
|
|
104
|
+
1. `getByRole('button', { name: /submit/i })` — top preference; if an interactive control cannot be found by role + accessible name, fix the component's accessibility first.
|
|
105
|
+
2. `getByLabelText(/email/i)` — preferred for form inputs.
|
|
106
|
+
3. `getByPlaceholderText`, `getByText`, `getByDisplayValue` — for non-interactive copy or filled values.
|
|
107
|
+
4. `getByTestId` — last resort only when no user-visible role or text exists.
|
|
108
|
+
|
|
109
|
+
Always initialize `const user = userEvent.setup()` and `await user.click(...)` / `await user.type(...)` instead of low-level `fireEvent`, which bypasses focus, disabled, and visibility checks.
|
|
110
|
+
|
|
111
|
+
## Playwright E2E, Clock, ARIA snapshots, visual regression, and axe-core
|
|
112
|
+
|
|
113
|
+
- **Accessibility fixture**: share a pre-configured `AxeBuilder` fixture via `test.extend()` targeting `['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa']` and assert `expect(results.violations).toEqual([])`.
|
|
114
|
+
- **Playwright Clock (`page.clock`)**: freeze dates and fast-forward debounces, polling intervals, session timeouts, or OTP resend timers deterministically (`await page.clock.install({ time: new Date('2026-03-01T09:00:00Z') })`, `await page.clock.fastForward('00:30')`) instead of sleeping with `waitForTimeout`.
|
|
115
|
+
- **Semantic ARIA snapshots**: use `await expect(locator).toMatchAriaSnapshot(...)` (inline YAML or `.aria.yml` file) to lock down roles, accessible names, heading levels, and checked/expanded states without breaking on benign CSS refactors.
|
|
116
|
+
- **Visual snapshots**: stabilize `toHaveScreenshot()` by disabling/reducing animations (`animations: 'disabled'`), waiting for `document.fonts.ready`, and masking dynamic timestamps or charts (`mask: [page.locator('[data-dynamic]')]`).
|
|
117
|
+
- **Component testing on Playwright 1.63+**: `@playwright/experimental-ct-*` packages were removed in Playwright 1.63; mount component stories through the app's dev server (or Storybook) using standard `@playwright/test` fixtures, or use Vitest Browser Mode.
|
|
118
|
+
|
|
119
|
+
```ts
|
|
120
|
+
// tests/fixtures/axe.ts
|
|
121
|
+
import { test as base, expect } from '@playwright/test';
|
|
122
|
+
import AxeBuilder from '@axe-core/playwright';
|
|
123
|
+
|
|
124
|
+
export const test = base.extend<{ makeAxeBuilder: () => AxeBuilder }>({
|
|
125
|
+
makeAxeBuilder: async ({ page }, use) => {
|
|
126
|
+
await use(() =>
|
|
127
|
+
new AxeBuilder({ page }).withTags(['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa']),
|
|
128
|
+
);
|
|
129
|
+
},
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
export { expect };
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
```ts
|
|
136
|
+
// Playwright Clock + ARIA snapshot example
|
|
137
|
+
test('OTP resend unlocks after 30 seconds and preserves accessible structure', async ({ page }) => {
|
|
138
|
+
await page.clock.install({ time: new Date('2026-03-01T09:00:00Z') });
|
|
139
|
+
await page.goto('/verify');
|
|
140
|
+
await expect(page.getByRole('button', { name: /resend code/i })).toBeDisabled();
|
|
141
|
+
await page.clock.fastForward('00:30');
|
|
142
|
+
await expect(page.getByRole('form', { name: /verify/i })).toMatchAriaSnapshot(`
|
|
143
|
+
- form "Verify email":
|
|
144
|
+
- textbox "Verification code"
|
|
145
|
+
- button "Resend code"
|
|
146
|
+
- button "Continue"
|
|
147
|
+
`);
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Do/don't pairs
|
|
152
|
+
|
|
153
|
+
| Do | Don't |
|
|
154
|
+
|---|---|
|
|
155
|
+
| Query interactive elements with `getByRole` + accessible `name` | Scatter `data-testid` on every button and input while leaving labels broken |
|
|
156
|
+
| Use `const user = userEvent.setup()` for realistic interactions | Use `fireEvent.click` on disabled or hidden controls without noticing they are unreachable |
|
|
157
|
+
| Use MSW v2 (`http.get`, `HttpResponse.json`) and `page.clock` for deterministic async/timer tests | Monkey-patch `global.fetch` or sprinkle `waitForTimeout(5000)` in E2E suites |
|
|
158
|
+
| Run layout, focus-trap, and Shadow DOM tests in Vitest Browser Mode / `@storybook/addon-vitest` / Playwright | Assert visual layout or responsive breakpoints in `jsdom` and mark them `rendered` |
|
|
159
|
+
| Mask timestamps and set `animations: 'disabled'` in visual snapshots; lock structure with `toMatchAriaSnapshot` | Approve brittle full-page screenshots that flake on every CI run |
|
|
160
|
+
| Combine `AxeBuilder` (`wcag22aa`) scans with keyboard/focus-order assertions | Treat a passing `jest-axe` or `AxeBuilder` run as complete WCAG proof |
|
|
161
|
+
| Use `provider: playwright()` from `@vitest/browser-playwright` on Vitest 4+ | Copy legacy `provider: 'playwright'` string config or removed `@playwright/experimental-ct-*` on Playwright 1.63+ |
|
|
162
|
+
|
|
163
|
+
## Verification commands
|
|
164
|
+
|
|
165
|
+
```sh
|
|
166
|
+
npx vitest run
|
|
167
|
+
npx playwright test
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Report `jsdom`/unit runs as `static` (or DOM-unit) evidence and real-browser Playwright / Vitest Browser Mode / Chromatic runs as `rendered` evidence.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Creative effects cookbook
|
|
2
|
+
|
|
3
|
+
| Effect | Useful implementation | Avoid |
|
|
4
|
+
|---|---|---|
|
|
5
|
+
| Particle field | Bounded particle pool, spatial field, seeded initialization, pointer force with capped radius | Unbounded arrays/allocations in each frame |
|
|
6
|
+
| Image displacement | One displacement map and shader pass, responsive texture, static original image | Hiding essential image detail behind an inaccessible effect |
|
|
7
|
+
| Noise field | Deterministic seeded noise, slow evolution, bounded amplitude | Rapid random flicker or high-contrast strobe |
|
|
8
|
+
| Liquid-like transition | Mask/displacement between two meaningful states, short duration, interruptible | Uncontrolled full-screen distortion on every navigation |
|
|
9
|
+
| SDF typography/shape | Distance-field rendering when crisp scalable GPU text/shape is needed | Putting actual UI copy only in a shader |
|
|
10
|
+
| Generative grid | Rule-based cell layout, limited palette, deterministic seed | Decorative patterns without a relationship to content |
|
|
11
|
+
| Audio-reactive field | Map smoothed frequency bands to a few visual parameters | Mapping raw audio noise directly to flashing brightness |
|
|
12
|
+
| Pointer response | Normalized pointer vector, low-pass smoothing, capped strength | Following pointer without a touch/focus equivalent |
|
|
13
|
+
|
|
14
|
+
## Interaction contract
|
|
15
|
+
|
|
16
|
+
Every effect states what pointer/keyboard/touch input changes, how it can be stopped/reset, whether it continues while hidden, and what a static user sees. Prefer subtle reaction over large movement. On touch, use an explicit control rather than pretending hover exists.
|
|
17
|
+
|
|
18
|
+
## Deterministic seed & reduced-motion runtime pattern
|
|
19
|
+
|
|
20
|
+
Avoid `Math.random()` inside particle pools or generative grids—it breaks screenshot baselines and visual regression. Seed a tiny deterministic PRNG (such as Mulberry32), honor optional QA query overrides (`?seed=42&t=0`), and listen to `prefers-reduced-motion` dynamically so toggling the OS preference pauses live evolution immediately:
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
// Deterministic Mulberry32 PRNG + live prefers-reduced-motion gate
|
|
24
|
+
export function createSeededRng(seed: number): () => number {
|
|
25
|
+
let a = seed >>> 0;
|
|
26
|
+
return () => {
|
|
27
|
+
a = (a + 0x6d2b79f5) | 0;
|
|
28
|
+
let t = Math.imul(a ^ (a >>> 15), 1 | a);
|
|
29
|
+
t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;
|
|
30
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function createEffectRuntime(renderStatic: (t: number) => void, startLoop: () => () => void) {
|
|
35
|
+
const params = new URLSearchParams(window.location.search);
|
|
36
|
+
const frozenTime = params.has('t') ? Number(params.get('t')) : null;
|
|
37
|
+
const mql = window.matchMedia('(prefers-reduced-motion: reduce)');
|
|
38
|
+
let stopLoop: (() => void) | null = null;
|
|
39
|
+
|
|
40
|
+
const sync = () => {
|
|
41
|
+
stopLoop?.();
|
|
42
|
+
stopLoop = null;
|
|
43
|
+
if (frozenTime !== null || mql.matches) {
|
|
44
|
+
renderStatic(frozenTime ?? 0);
|
|
45
|
+
} else {
|
|
46
|
+
stopLoop = startLoop();
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
sync();
|
|
51
|
+
mql.addEventListener('change', sync);
|
|
52
|
+
return () => {
|
|
53
|
+
stopLoop?.();
|
|
54
|
+
mql.removeEventListener('change', sync);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Record asset provenance and never bundle third-party example textures/models without license verification.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Creative runtime integration for web
|
|
2
|
+
|
|
3
|
+
Use this when a web project combines DOM UI with animation, canvas, 3D, graphics, or media. Preserve the existing stack and make the creative runtime an isolated enhancement.
|
|
4
|
+
|
|
5
|
+
## SSR & island boundary (React, Vue/Nuxt, SvelteKit, Astro, SolidStart)
|
|
6
|
+
|
|
7
|
+
- Keep SEO, copy, forms, and stateful product UI server-rendered when possible.
|
|
8
|
+
- Isolate Motion, GSAP, Three.js/R3F/Threlte/TresJS, PixiJS, and Web Audio inside narrow client boundaries (`'use client'` + dynamic import in Next.js, `.client.vue` / `<ClientOnly>` in Nuxt, `onMount` in SvelteKit, `client:visible` in Astro, `clientOnly()` in SolidStart).
|
|
9
|
+
- Dynamically import heavyweight renderers and large scenes; render a sized poster/DOM fallback first so CLS stays near zero.
|
|
10
|
+
- Never convert an entire route into a client-only bundle for one interactive canvas or animated CTA.
|
|
11
|
+
- Ensure SSR output never depends on `window`, `Math.random()`, `Date.now()`, or GPU probing; initialize nondeterministic effects after mount or use a fixed seed (`creative-effects.md`).
|
|
12
|
+
|
|
13
|
+
## Ownership matrix
|
|
14
|
+
|
|
15
|
+
| Surface | Primary owner | Keep in DOM |
|
|
16
|
+
|---|---|---|
|
|
17
|
+
| UI state, layout/gesture | CSS or Motion (`motion/react` / vanilla `motion`) | All controls, focus order, and state labels |
|
|
18
|
+
| Choreographed timeline | GSAP (`gsap.md`) | Headings, navigation, form controls |
|
|
19
|
+
| 3D scene | Three.js / R3F / Babylon / Threlte / TresJS / `<model-viewer>` | Product data, options, purchase/navigation |
|
|
20
|
+
| 2D GPU scene | PixiJS v8 / Canvas 2D / WebGL / WebGPU | Headings, CTAs, instructions, accessible summaries |
|
|
21
|
+
| Audio / video | HTML media / Web Audio / Vidstack / Media Chrome / Tone.js | Play/mute/pause, captions, transcript |
|
|
22
|
+
|
|
23
|
+
Avoid duplicate animation ownership on the same properties. Coordinate scroll engines with the single controller selected in the plan.
|
|
24
|
+
|
|
25
|
+
## Loading and failure states
|
|
26
|
+
|
|
27
|
+
- Load scene code/assets on demand and avoid blocking first content.
|
|
28
|
+
- Show a poster/placeholder with stable dimensions.
|
|
29
|
+
- Handle unsupported APIs, missing assets, network failure, WebGL/WebGPU context loss, and media playback rejection.
|
|
30
|
+
- Keep ordinary navigation and content functional if the creative runtime fails.
|
|
31
|
+
|
|
32
|
+
## Cross-skill handoff
|
|
33
|
+
|
|
34
|
+
Pair browser runtime implementation here with `pixelcraft-craft` (motion/color/typography budgets), `pixelcraft-patterns` (narrative/scrollytelling structure), `pixelcraft-accessibility` (reduced-motion and non-visual parity), and `pixelcraft-visual-qa` (timeline capture and device performance budgets). For embodied XR/VR/AR headset UX, route to `pixelcraft-spatial`.
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
# Enterprise data tables, grids, virtualization, spreadsheets, and schedulers
|
|
2
|
+
|
|
3
|
+
Do not render 5,000 DOM table rows or hand-roll Excel-style cell editing, column pinning, and timezone-aware scheduling. Choose between headless tables, enterprise grids, spreadsheet engines, virtualizers, and calendar schedulers by data scale, editing density, and license budget.
|
|
4
|
+
|
|
5
|
+
## Architecture decision matrix
|
|
6
|
+
|
|
7
|
+
| Need | Tools | Rendering / model | Best fit | Primary trade-off |
|
|
8
|
+
|---|---|---|---|---|
|
|
9
|
+
| **Headless data tables** | **TanStack Table (v8)** | Framework-agnostic headless state (React, Vue, Solid, Svelte, Angular) | Custom-styled SaaS tables, full design-system control, server-side sort/filter/page | You own markup, sticky headers, keyboard grid nav, and virtualization wiring |
|
|
10
|
+
| **Enterprise data grids** | **AG Grid (v33+)**, **MUI X Data Grid**, **Glide Data Grid** | Virtualized DOM (AG Grid, MUI X) or Canvas 2D (Glide) | AG Grid/MUI X: 100k+ rows, grouping, inline editing, Excel export; **Glide Data Grid**: millions of cells at 60fps | Commercial licenses for Pro/Enterprise tiers; Canvas grids like Glide require explicit accessibility/DOM overlay discipline |
|
|
11
|
+
| **Spreadsheet UI** | **Handsontable**, **Univer** | Formula engine (HyperFormula / Univer Sheets), cell ranges, clipboard matrix | Financial modeling, bulk tabular editing with Excel copy/paste & formulas (**Univer** is Apache-2.0 open-source core) | Heavier than standard tables; commercial licenses for Handsontable / Univer Pro plugins |
|
|
12
|
+
| **List & table virtualization** | **TanStack Virtual (v3)**, **React Virtuoso**, **react-window** | Windowed DOM recycling | Long feeds, chat logs, 10k+ row headless tables (`TanStack Table + TanStack Virtual`) | Dynamic row heights require `measureElement`; native `Ctrl+F` search cannot see unmounted rows |
|
|
13
|
+
| **Calendars & schedulers** | **FullCalendar (v6/v7)**, **Schedule-X**, **Bryntum**, **DayPilot**, **vis-timeline** | Time-grid / resource-timeline views | **Schedule-X**: modern open-source React/Vue/Angular/Svelte calendar; **FullCalendar**: mature calendar ecosystem; **Bryntum/DayPilot**: heavy Gantt/resource planning; **vis-timeline**: lightweight timeline | Resource timeline/Gantt views are commercial in FullCalendar/Bryntum/DayPilot |
|
|
14
|
+
|
|
15
|
+
## Headless tables + virtualization (TanStack Table v8 + TanStack Virtual v3)
|
|
16
|
+
|
|
17
|
+
- **Stable IDs & references**: always supply `getRowId: (row) => row.id` so row selection, expansion, and inline editing stay bound to record IDs rather than row indices. Memoize `columns` and `data` (never pass `data ?? []` inline every render).
|
|
18
|
+
- **Server-side mode**: set `manualSorting: true`, `manualFiltering: true`, `manualPagination: true`, pass `rowCount` (or `pageCount`), and omit client-only row models (`getSortedRowModel`, `getPaginationRowModel`).
|
|
19
|
+
- **Dynamic-height virtualization**: when using `useVirtualizer` with variable row heights, attach **both** `data-index={virtualRow.index}` and `ref={virtualizer.measureElement}` on every rendered row.
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
// TanStack Table v8 (server-side sorting & pagination)
|
|
23
|
+
const table = useReactTable({
|
|
24
|
+
data,
|
|
25
|
+
columns,
|
|
26
|
+
getRowId: (row) => row.uuid,
|
|
27
|
+
getCoreRowModel: getCoreRowModel(),
|
|
28
|
+
manualSorting: true,
|
|
29
|
+
manualPagination: true,
|
|
30
|
+
rowCount: query.data?.totalCount,
|
|
31
|
+
state: { sorting, pagination },
|
|
32
|
+
onSortingChange: setSorting,
|
|
33
|
+
onPaginationChange: setPagination,
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```tsx
|
|
38
|
+
// TanStack Virtual v3 dynamic measurement
|
|
39
|
+
<div
|
|
40
|
+
key={virtualRow.key}
|
|
41
|
+
data-index={virtualRow.index}
|
|
42
|
+
ref={virtualizer.measureElement}
|
|
43
|
+
style={{ transform: `translateY(${virtualRow.start}px)` }}
|
|
44
|
+
>
|
|
45
|
+
{renderRow(rows[virtualRow.index])}
|
|
46
|
+
</div>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Enterprise data grids (AG Grid v33+, MUI X Data Grid, Glide Data Grid)
|
|
50
|
+
|
|
51
|
+
### AG Grid v33+
|
|
52
|
+
|
|
53
|
+
- **Module registration**: register only needed feature modules via `ModuleRegistry.registerModules([ClientSideRowModelModule, ...])` for tree-shaking—`AllCommunityModule` is convenient for prototyping but disables tree-shaking.
|
|
54
|
+
- **Theming API**: customize themes via `themeQuartz.withParams({ spacing, accentColor })` referencing semantic CSS variables (never hardcoded hex literals) passed to `<AgGridReact theme={myTheme} />` instead of legacy CSS theme imports.
|
|
55
|
+
- **Stable row updates**: pass `getRowId={({ data }) => data.id}` so streaming/realtime transactions update cells in place without resetting focus, scroll, or selection.
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
import { ClientSideRowModelModule, ModuleRegistry, themeQuartz } from 'ag-grid-community';
|
|
59
|
+
import { AgGridReact } from 'ag-grid-react';
|
|
60
|
+
|
|
61
|
+
ModuleRegistry.registerModules([ClientSideRowModelModule]);
|
|
62
|
+
|
|
63
|
+
const gridTheme = themeQuartz.withParams({
|
|
64
|
+
spacing: 8,
|
|
65
|
+
accentColor: 'var(--semantic-color-action)',
|
|
66
|
+
backgroundColor: 'var(--semantic-color-background)',
|
|
67
|
+
foregroundColor: 'var(--semantic-color-foreground)',
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
<AgGridReact
|
|
71
|
+
theme={gridTheme}
|
|
72
|
+
rowData={rows}
|
|
73
|
+
columnDefs={colDefs}
|
|
74
|
+
getRowId={({ data }) => data.id}
|
|
75
|
+
/>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### MUI X Data Grid (`@mui/x-data-grid`)
|
|
79
|
+
|
|
80
|
+
- Bind `getRowId={(row) => row.uuid}` when records do not have an `id` field, and keep `columns` referentially stable (defined outside render or memoized) so cell editors and focus do not reset.
|
|
81
|
+
- For server-backed datasets, set `paginationMode="server"`, `sortingMode="server"`, `filterMode="server"`, and `rowCount={totalRows}` (pass `-1` when unknown), plus `loading={isFetching}` and explicit `slots={{ noRowsOverlay, loadingOverlay }}`.
|
|
82
|
+
- For inline editing, implement `processRowUpdate={async (nextRow, prevRow) => ...}` paired with `onProcessRowUpdateError` so failed server saves roll back cleanly and announce the error.
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import { DataGrid, type GridColDef } from '@mui/x-data-grid';
|
|
86
|
+
|
|
87
|
+
<DataGrid
|
|
88
|
+
rows={rows}
|
|
89
|
+
columns={columns}
|
|
90
|
+
getRowId={(row) => row.uuid}
|
|
91
|
+
rowCount={totalCount}
|
|
92
|
+
paginationMode="server"
|
|
93
|
+
sortingMode="server"
|
|
94
|
+
paginationModel={paginationModel}
|
|
95
|
+
onPaginationModelChange={setPaginationModel}
|
|
96
|
+
loading={isFetching}
|
|
97
|
+
processRowUpdate={saveRowMutation}
|
|
98
|
+
onProcessRowUpdateError={showRowError}
|
|
99
|
+
/>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Glide Data Grid & Univer
|
|
103
|
+
|
|
104
|
+
- **Glide Data Grid**: draws cells to Canvas 2D with DOM portals for active cell editors; ideal for 100k–1M+ cell sheets, but verify keyboard navigation, clipboard copy/paste, and screen-reader export/alternative view because canvas pixels are not automatically exposed to assistive tech.
|
|
105
|
+
- **Univer**: modular open-source spreadsheet/workbook engine (`@univerjs/presets`) when Excel-grade formulas, formatting, and multi-sheet workbooks are required without Handsontable's commercial license.
|
|
106
|
+
|
|
107
|
+
## Calendars, schedulers, and timelines
|
|
108
|
+
|
|
109
|
+
- **FullCalendar v7 vs v6**: verify the installed major—v7 consolidates plugin imports under `@fullcalendar/react/*` (`@fullcalendar/react/daygrid`, `@fullcalendar/react/interaction`), removes `@fullcalendar/core` as a peer dependency, and requires `temporal-polyfill`.
|
|
110
|
+
- **Schedule-X**: lightweight open-source alternative (`@schedule-x/calendar` + framework wrappers) with Temporal-first APIs (`Temporal.ZonedDateTime` / `PlainDate`), clean CSS variable theming, and Day/Week/Month views out of the box.
|
|
111
|
+
- **Timezone safety**: always configure `timeZone` explicitly (e.g., `'UTC'` or an IANA zone like `'America/New_York'`). Because native JS `Date` objects only represent local or UTC time, read `info.dateStr` (ISO string) or `Temporal.ZonedDateTime` rather than `.toString()` when using a named timezone.
|
|
112
|
+
- **Accessible view fallback**: calendars and timelines with dense drag-to-reschedule interactions must provide a list/agenda view (`listPlugin` / list mode) and keyboard/click edit modal (WCAG 2.1.1 & 2.5.7).
|
|
113
|
+
|
|
114
|
+
## Data table & grid accessibility rules
|
|
115
|
+
|
|
116
|
+
- Use native `<table>`, `<thead>`, `<tbody>`, `<th scope="col">`, and `aria-sort="ascending" | "descending" | "none"` for read-only/sortable tables.
|
|
117
|
+
- Reserve `role="grid"` with roving `tabindex` and arrow-key cell navigation for interactive/editable data grids; always set `aria-rowcount` and `aria-rowindex` (and `aria-colcount`/`aria-colindex`) on virtualized tables so screen readers know the true dataset size.
|
|
118
|
+
- Use `font-variant-numeric: tabular-nums` and logical end-alignment for numeric/currency columns.
|
|
119
|
+
|
|
120
|
+
## Do/don't pairs
|
|
121
|
+
|
|
122
|
+
| Do | Don't |
|
|
123
|
+
|---|---|
|
|
124
|
+
| Pass `getRowId` in TanStack Table, AG Grid, and MUI X Data Grid | Key row selection or live updates by row index |
|
|
125
|
+
| Attach both `data-index` and `ref={virtualizer.measureElement}` for variable heights | Hardcode a single fixed row height on multi-line wrapping rows |
|
|
126
|
+
| Register granular AG Grid v33 modules + `themeQuartz.withParams()` using semantic CSS vars | Hardcode hex values in grid themes or bundle `AllCommunityModule` blindly |
|
|
127
|
+
| Pair MUI X `processRowUpdate` with `onProcessRowUpdateError` and server-side modes | Mutate local rows optimistically without rollback or ship 50k rows to client pagination |
|
|
128
|
+
| Set `aria-rowcount` and `aria-rowindex` on virtualized tables | Hide total row count from assistive technologies |
|
|
129
|
+
| Use `info.dateStr` / `Temporal.ZonedDateTime` + explicit IANA `timeZone` + agenda/list view | Assume browser-local `Date.toString()` matches the calendar's configured timezone |
|
|
130
|
+
|
|
131
|
+
## Verification commands
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
npm run build
|
|
135
|
+
npx playwright test
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Verify bundle size of grid/calendar chunks (`static`), and test 10k-row scroll smoothness, column resize, inline edit rollback, keyboard navigation, and timezone DST boundary rendering in a real browser (`rendered`).
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# File upload, drag-and-drop media, and client image pipeline UI
|
|
2
|
+
|
|
3
|
+
File upload is an error-prone, long-running interaction—not a bare `<input type="file">`. Design for **resumable progress, honest validation, keyboard/screen-reader access, clipboard paste, and memory-safe client previews**.
|
|
4
|
+
|
|
5
|
+
## Tooling decision matrix
|
|
6
|
+
|
|
7
|
+
| Tool | Best fit | Built-in resumable (tus) / S3 | Primary trade-off |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| **Direct-to-S3 / Cloudflare R2 presigned PUT** | Most web apps uploading files to object storage without proxying bytes through serverless functions | Single PUT (or S3 multipart for >100 MB) | Requires short-lived signed URL endpoint, strict bucket CORS, and server completion/MIME verification |
|
|
10
|
+
| **UploadThing** | Full-stack TypeScript apps (Next.js, Astro, SvelteKit, Solid, Vue, Hono) wanting typed file routers + webhooks | Managed presigned uploads | Managed service coupling; still verify auth inside `middleware()` on every file router |
|
|
11
|
+
| **Standalone `tus-js-client`** | Large/unreliable-network resumable chunked uploads (`tus` protocol) with custom lightweight UI | Yes (`tus` resumable chunks + fingerprinting) | You own dropzone, file list, and preview UI |
|
|
12
|
+
| **Uppy** (`@uppy/core`, `@uppy/tus`, `@uppy/aws-s3`, `@uppy/dashboard`) | Production multi-file uploads needing pause/resume (`tus`), S3 multipart, webcam/cloud pickers | Yes | Larger bundle if importing full Dashboard + remote plugins; call `uppy.clear()` to reset and `uppy.destroy()` on unmount |
|
|
13
|
+
| **FilePond** | Polished single/multi-image uploads with built-in EXIF rotation, crop, resize, and async previews | Via adapter | Plugin licensing/ecosystem smaller than Uppy for cloud pickers |
|
|
14
|
+
| **react-dropzone** (or native `<input type="file">`) | Lightweight headless drop zones where you own 100% of upload state and styling | No (pair with presigned PUT or `tus-js-client`) | You must implement progress, retry, cancellation, and preview cleanup yourself |
|
|
15
|
+
| **File System Access API** (`showOpenFilePicker`, `showSaveFilePicker`) | Desktop-class local file editors (audio/video/code/design tools) | N/A (local disk) | Chromium-first; always feature-detect and fall back to `<input type="file">` + `<a download>` for Safari/Firefox |
|
|
16
|
+
|
|
17
|
+
## Verified implementation idioms
|
|
18
|
+
|
|
19
|
+
### Direct-to-S3 / R2 presigned PUT & standalone `tus-js-client`
|
|
20
|
+
|
|
21
|
+
- **Presigned PUT flow**: request a short-lived signed PUT URL (scoped to exact `contentType`, `contentLength` bounds, and authenticated user key) from your backend, upload bytes directly from the browser via `XMLHttpRequest` (for reliable upload progress events + `xhr.abort()` cancellation across all browsers), then notify your backend to verify the stored object's magic bytes and attach metadata. Never proxy multi-megabyte uploads through serverless API routes with tiny body limits.
|
|
22
|
+
- **Standalone `tus-js-client`**: use `new tus.Upload(file, { endpoint, retryDelays: [0, 1000, 3000, 5000], onProgress, onError, onSuccess })` and call `upload.abort()` on cancel or unmount.
|
|
23
|
+
|
|
24
|
+
### Uppy restrictions & lifecycle
|
|
25
|
+
|
|
26
|
+
- Configure `restrictions` (`maxFileSize`, `maxTotalFileSize`, `maxNumberOfFiles`, `allowedFileTypes`) upfront so users get immediate feedback before uploading gigabytes.
|
|
27
|
+
- **Security rule**: Uppy's `allowedFileTypes` uses browser `File.type` and filename extensions—treat it as **client UX guidance only**, never authoritative server validation.
|
|
28
|
+
- Call `uppy.clear()` to reset between uploads and `uppy.destroy()` on component unmount (cancels active uploads and removes listeners).
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import Uppy from '@uppy/core';
|
|
32
|
+
import Tus from '@uppy/tus';
|
|
33
|
+
|
|
34
|
+
const uppy = new Uppy({
|
|
35
|
+
restrictions: {
|
|
36
|
+
maxFileSize: 50 * 1024 * 1024,
|
|
37
|
+
maxNumberOfFiles: 5,
|
|
38
|
+
allowedFileTypes: ['image/jpeg', 'image/png', 'image/webp', 'application/pdf'],
|
|
39
|
+
},
|
|
40
|
+
}).use(Tus, { endpoint: '/api/uploads/tus' });
|
|
41
|
+
|
|
42
|
+
// Cleanup on unmount:
|
|
43
|
+
// uppy.destroy();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Previews, clipboard paste, and client-side image compression
|
|
47
|
+
|
|
48
|
+
- **Revoke object URLs**: every `URL.createObjectURL(file)` preview **must** be paired with `URL.revokeObjectURL(url)` on file removal or unmount to prevent multi-hundred-megabyte memory leaks.
|
|
49
|
+
- **Clipboard & drag-drop ergonomics**: support `paste` events (`clipboardData.items`) for screenshots in chat/ticket/editor surfaces, highlight the drop target cleanly on `dragenter`/`dragleave` (using a depth counter or `relatedTarget` check so child elements do not flicker), and always keep a real focusable `<button>` / `<input type="file">` trigger for keyboard and screen-reader users (WCAG 2.1.1 & 2.5.7).
|
|
50
|
+
- **Client-side resize/compress & Safari WebP caveat**: run `createImageBitmap()` + `OffscreenCanvas.convertToBlob(...)` inside a Web Worker so the UI stays responsive. **Safari silently ignores `{ type: 'image/webp' }` on Canvas/`OffscreenCanvas` and returns an uncompressed `image/png` blob instead** (often *larger* than the original photo). Always check `blob.type === 'image/webp'` and fall back to `'image/jpeg'` (or a WASM encoder like `@jsquash/webp`) when WebP encoding is unavailable:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
let blob = await offscreen.convertToBlob({ type: 'image/webp', quality: 0.85 });
|
|
54
|
+
if (blob.type !== 'image/webp') {
|
|
55
|
+
// Safari silent PNG fallback: re-encode as JPEG to avoid bloated PNG uploads
|
|
56
|
+
blob = await offscreen.convertToBlob({ type: 'image/jpeg', quality: 0.85 });
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Required upload states
|
|
61
|
+
|
|
62
|
+
Every upload surface must handle: **idle (limits stated upfront)**, **drag-over highlight**, **invalid type/size rejection (specific reason)**, **uploading (per-file progress + cancel)**, **paused/offline (resumable retry)**, **error (retry without re-picking file)**, and **complete (remove/replace action)**.
|
|
63
|
+
|
|
64
|
+
## Do/don't pairs
|
|
65
|
+
|
|
66
|
+
| Do | Don't |
|
|
67
|
+
|---|---|
|
|
68
|
+
| Upload large binaries directly via S3/R2 presigned PUT, UploadThing, or `tus-js-client` | Proxy 100 MB user uploads through a serverless function with a 4 MB body limit |
|
|
69
|
+
| Check `blob.type === 'image/webp'` after `convertToBlob` and fall back to JPEG on Safari | Assume `convertToBlob({ type: 'image/webp' })` encodes WebP everywhere (Safari silently emits PNG) |
|
|
70
|
+
| State max file size and accepted formats visibly before selection | Reject a 120 MB upload only after a 3-minute transfer completes |
|
|
71
|
+
| Call `URL.revokeObjectURL(url)` when previews unmount or are removed | Leak blob URLs across repeated file selections |
|
|
72
|
+
| Keep a keyboard-focusable file picker trigger alongside drag-and-drop | Build a drag-only dropzone unreachable by keyboard or screen readers |
|
|
73
|
+
| Enforce authoritative MIME/magic-byte checks on the server | Trust client `allowedFileTypes` or `<input accept>` as security |
|
|
74
|
+
|
|
75
|
+
## Verification commands
|
|
76
|
+
|
|
77
|
+
```sh
|
|
78
|
+
npm run build
|
|
79
|
+
npx playwright test
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Verify file-picker keyboard activation, invalid-type rejection copy, progress/cancel/retry states, Safari JPEG fallback (`blob.type`), and `revokeObjectURL` cleanup in a real browser (`rendered`).
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Form frameworks and schema validation
|
|
2
|
+
|
|
3
|
+
Pair this engineering reference with `pixelcraft-ux` (`forms.md`) for UX rules. Choose a form framework by **rendering model (progressive server actions vs client SPA), framework ecosystem, and field-array/async-validation complexity**.
|
|
4
|
+
|
|
5
|
+
## Form framework decision matrix
|
|
6
|
+
|
|
7
|
+
| Library | Frameworks | Validation & schema model | Best fit |
|
|
8
|
+
|---|---|---|---|
|
|
9
|
+
| **TanStack Form (v1)** | React, Vue, Solid, Svelte, Angular, Lit | Native **Standard Schema** (`Zod v3.24+/v4`, `Valibot`, `ArkType`, `Effect/Schema`) with `onBlur`/`onSubmit` + `onChangeAsyncDebounceMs` | Multi-framework or deeply typed TypeScript apps with nested/async validation |
|
|
10
|
+
| **React Hook Form (v7/v8)** | React | `@hookform/resolvers` (v5+ for Zod v4; `zodResolver`, `valibotResolver`, `yupResolver`, `ajvResolver`) | Client-heavy React forms needing minimal re-renders via uncontrolled `register()` |
|
|
11
|
+
| **Conform** | React (Next.js Server Actions, React Router v7) | `@conform-to/zod/v4` (`parseWithZod` / `getZodConstraint`) or `@conform-to/valibot` | Server-first forms requiring progressive enhancement, `FormData`, and auto-wired ARIA (`getFormProps`/`getInputProps`) |
|
|
12
|
+
| **SvelteKit Superforms** | Svelte 5 / SvelteKit 2 | `superValidate(zod4(schema))` / Valibot / ArkType adapters | Progressive SvelteKit `+page.server.ts` forms with full typed client/server sync and tainted-state guards |
|
|
13
|
+
| **Modular Forms** | Solid, Qwik, Preact | Fine-grained signals + Valibot / Zod adapters | Zero-VDOM and resumable frameworks where tiny bundle size and signal-level updates matter |
|
|
14
|
+
| **VeeValidate (v4)** | Vue 3 | `toTypedSchema(zod/valibot/yup)` + Composition API `useForm` / `defineField` | Vue 3 apps needing typed Composition API bindings and repeatable `useFieldArray` |
|
|
15
|
+
| **Formik** | React (legacy) | Yup / custom validate | Maintenance of existing codebases only; prefer TanStack Form, RHF, or Conform for greenfield |
|
|
16
|
+
|
|
17
|
+
## Schema libraries, Standard Schema, and Zod v4 migration
|
|
18
|
+
|
|
19
|
+
Prefer **Standard Schema** (`standard-schema.dev` v1) compatible validators so form and server layers share one schema without custom glue:
|
|
20
|
+
|
|
21
|
+
- **Zod v4 (`zod` / `zod/v4-mini`)**: major perf and bundle improvements. Use top-level string format validators (**`z.email()`**, `z.url()`, `z.uuid()`) instead of deprecated `z.string().email()`, import **`zod/v4-mini`** (`z.string().check(z.minLength(3))`) when minimal client bundle size matters, and align adapters (**`@hookform/resolvers` v5+** for RHF and **`@conform-to/zod/v4`** for Conform—do not mix Zod v3 adapters with Zod v4 schemas).
|
|
22
|
+
- **Valibot**: modular tree-shakeable functions—strong default when client bundle budget is tight.
|
|
23
|
+
- **ArkType**: high-performance TypeScript-syntax runtime validation for dense/complex objects.
|
|
24
|
+
- **Ajv**: JSON Schema (Draft 2020-12) compliance when schemas are language-agnostic or contract-driven.
|
|
25
|
+
- **Yup**: legacy ecosystems already standardized on it.
|
|
26
|
+
|
|
27
|
+
## Verified implementation patterns
|
|
28
|
+
|
|
29
|
+
```tsx
|
|
30
|
+
// TanStack Form: validate onBlur/onSubmit (not premature first-keystroke), wire label + aria-describedby
|
|
31
|
+
import { useId } from 'react';
|
|
32
|
+
import { z } from 'zod';
|
|
33
|
+
|
|
34
|
+
const usernameSchema = z.string().min(3, 'Enter at least 3 characters');
|
|
35
|
+
|
|
36
|
+
<form.Field
|
|
37
|
+
name="username"
|
|
38
|
+
validators={{
|
|
39
|
+
onBlur: usernameSchema,
|
|
40
|
+
onSubmit: usernameSchema,
|
|
41
|
+
onChangeAsyncDebounceMs: 500,
|
|
42
|
+
onChangeAsync: ({ value, fieldApi }) => {
|
|
43
|
+
if (!fieldApi.state.meta.isTouched) return undefined;
|
|
44
|
+
return checkUsernameAvailable(value).then((ok) => (ok ? undefined : 'Username is already taken'));
|
|
45
|
+
},
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
{(field) => {
|
|
49
|
+
const inputId = useId();
|
|
50
|
+
const errorId = `${inputId}-error`;
|
|
51
|
+
const showError =
|
|
52
|
+
(field.state.meta.isTouched || form.state.isSubmitted) && field.state.meta.errors.length > 0;
|
|
53
|
+
const errorText = showError
|
|
54
|
+
? typeof field.state.meta.errors[0] === 'string'
|
|
55
|
+
? field.state.meta.errors[0]
|
|
56
|
+
: field.state.meta.errors[0]?.message
|
|
57
|
+
: undefined;
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<div>
|
|
61
|
+
<label htmlFor={inputId}>Username</label>
|
|
62
|
+
<input
|
|
63
|
+
id={inputId}
|
|
64
|
+
name={field.name}
|
|
65
|
+
value={field.state.value}
|
|
66
|
+
autoComplete="username"
|
|
67
|
+
aria-invalid={showError || undefined}
|
|
68
|
+
aria-describedby={errorText ? errorId : undefined}
|
|
69
|
+
onBlur={field.handleBlur}
|
|
70
|
+
onChange={(e) => field.handleChange(e.target.value)}
|
|
71
|
+
/>
|
|
72
|
+
{errorText && (
|
|
73
|
+
<p id={errorId} role="alert">
|
|
74
|
+
{errorText}
|
|
75
|
+
</p>
|
|
76
|
+
)}
|
|
77
|
+
</div>
|
|
78
|
+
);
|
|
79
|
+
}}
|
|
80
|
+
</form.Field>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
```tsx
|
|
84
|
+
// React Hook Form: preserve record `id` with `keyName` and never use array `index` as key
|
|
85
|
+
const { fields } = useFieldArray({ control, name: 'items', keyName: 'key' });
|
|
86
|
+
// Render with key={field.key} (RHF v8 uses `field.key` by default; v7 defaults to `field.id`)
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
```ts
|
|
90
|
+
// Conform + Zod v4 + Next.js Server Action: single schema validates both client & server
|
|
91
|
+
'use server';
|
|
92
|
+
import { parseWithZod } from '@conform-to/zod/v4';
|
|
93
|
+
import { z } from 'zod';
|
|
94
|
+
|
|
95
|
+
const profileSchema = z.object({ email: z.email('Enter a valid email address') });
|
|
96
|
+
|
|
97
|
+
export async function saveProfile(_prev: unknown, formData: FormData) {
|
|
98
|
+
const submission = parseWithZod(formData, { schema: profileSchema });
|
|
99
|
+
if (submission.status !== 'success') return submission.reply();
|
|
100
|
+
// persist and redirect or return clean status
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Multi-step, validation timing, server errors, and draft recovery
|
|
105
|
+
|
|
106
|
+
- **Inline validation timing ("reward early, punish late")**: do not show red error messages on the first keystroke while a user is still typing a valid value (empirical HCI evidence: Seckler et al., CHI '14). Trigger initial field errors on `onBlur` or submit, only render `role="alert"` after `isTouched` or submission, and clear errors promptly once the field becomes valid.
|
|
107
|
+
- **Multi-step wizards**: keep one typed parent schema (or per-step sub-schemas merged on final submit); validate only the active step on `Next`, allow stepping backward without losing values, and mirror step progress in URL/state.
|
|
108
|
+
- **Server validation errors**: map field-level backend errors back to their exact field (`setError` in RHF, `submission.reply({ fieldErrors })` in Conform, `setError` in Superforms) and focus the first invalid field or error summary while preserving every entered value.
|
|
109
|
+
- **Async validation**: always debounce (`300–500 ms`), cancel stale in-flight checks (`AbortSignal` / request token), and show pending state without blocking unrelated fields.
|
|
110
|
+
- **Synchronous submit lock & idempotent create/pay mutations**: guard `onSubmit` with a synchronous ref lock (`submittingRef.current = true` before the first `await`) plus `aria-busy="true"` and an `Idempotency-Key` header on create/billing mutations ([auth-and-checkout-ui.md](auth-and-checkout-ui.md)) so rapid double-Enter or double-click never creates duplicate records.
|
|
111
|
+
- **Autosave & `401` session-expiry draft preservation**: debounce draft writes to `IndexedDB`/Dexie (or `sessionStorage` for tiny non-sensitive payloads), snapshot dirty form values immediately if a submit fails with `401 Unauthorized` prior to re-authentication, clear the draft on confirmed `2xx` persistence, and offer explicit `Restore draft` / `Discard` recovery on return.
|
|
112
|
+
|
|
113
|
+
## Do/don't pairs
|
|
114
|
+
|
|
115
|
+
| Do | Don't |
|
|
116
|
+
|---|---|
|
|
117
|
+
| Gate `role="alert"` on `isTouched \|\| isSubmitted` and bind `aria-describedby` to the error ID | Fire `onChange` errors on keystroke 1 or leave errors unlinked from the input |
|
|
118
|
+
| Key `useFieldArray` rows by generated `field.key` / `field.id` (`keyName: 'key'` if records have `id`) | Key repeatable form rows by array `index` (corrupts values on delete/reorder) |
|
|
119
|
+
| Match Zod v4 with `z.email()`, `@hookform/resolvers` v5+, and `@conform-to/zod/v4` | Mix Zod v4 schemas into outdated Zod v3 resolver subpaths |
|
|
120
|
+
| Share one Standard Schema between client form validation and server action/endpoint | Duplicate regexes manually in client inputs and backend handlers |
|
|
121
|
+
| Lock submit synchronously before `await`, attach `Idempotency-Key`, and snapshot drafts on `401` | Allow fast double-submits to create duplicate rows or lose long forms on session expiry |
|
|
122
|
+
| Use `defineField` in VeeValidate v4 to bind `aria-invalid` dynamically from field state | Use deprecated `defineComponentBinds` or omit `aria-invalid` / `aria-describedby` |
|
|
123
|
+
| Debounce async validators (`300–500 ms`) and ignore stale responses | Fire an API check on every keystroke without debounce or race protection |
|
|
@@ -45,9 +45,10 @@ Interop impedance mismatch, bundle splitting/startup, typed model divergence fro
|
|
|
45
45
|
|
|
46
46
|
```sh
|
|
47
47
|
dotnet test
|
|
48
|
-
dotnet fable watch src --run
|
|
48
|
+
dotnet fable watch src --run npx vite
|
|
49
|
+
dotnet fable src --run npx vite build
|
|
49
50
|
npm test
|
|
50
51
|
npx playwright test
|
|
51
52
|
```
|
|
52
53
|
|
|
53
|
-
Inspect generated DOM/accessibility tree, browser keyboard/focus behavior, offline/server failure, text scaling/localization, reduced-motion emulation, production bundle behavior.
|
|
54
|
+
Inspect generated DOM/accessibility tree, browser keyboard/focus behavior, offline/server failure, text scaling/localization, reduced-motion emulation, and production bundle behavior (`rendered`).
|