@dungle-scrubs/admin-ui-soft 0.0.0-stage → 0.1.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/GUIDE.md +110 -0
- package/LICENSE +21 -0
- package/README.md +36 -2
- package/THIRD-PARTY-NOTICES.md +25 -0
- package/UPSTREAM-VENDORED-CHANGES.md +317 -0
- package/VENDORED-CHANGES.md +60 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/ai/compositions/agent-console/agent-console.d.ts +109 -0
- package/dist/ai/compositions/agent-console/agent-console.js +644 -0
- package/dist/ai/compositions/attention-feed/attention-feed.d.ts +127 -0
- package/dist/ai/compositions/attention-feed/attention-feed.js +626 -0
- package/dist/ai/compositions/conversation-browser/conversation-browser.d.ts +126 -0
- package/dist/ai/compositions/conversation-browser/conversation-browser.js +364 -0
- package/dist/ai/compositions/redaction-marker/redaction-marker.d.ts +42 -0
- package/dist/ai/compositions/redaction-marker/redaction-marker.js +202 -0
- package/dist/ai/compositions/run-inspector/json-view.js +164 -0
- package/dist/ai/compositions/run-inspector/run-inspector.d.ts +66 -0
- package/dist/ai/compositions/run-inspector/run-inspector.js +703 -0
- package/dist/ai/compositions/run-inspector/run-model.js +155 -0
- package/dist/ai/compositions/tool-approval/json-args.js +54 -0
- package/dist/ai/compositions/tool-approval/tool-approval.d.ts +57 -0
- package/dist/ai/compositions/tool-approval/tool-approval.js +331 -0
- package/dist/ai/compositions/tool-call-row/tool-call-row.js +74 -0
- package/dist/ai/compositions/transcript-viewer/to-thread-messages.js +65 -0
- package/dist/ai/compositions/transcript-viewer/transcript-viewer.d.ts +63 -0
- package/dist/ai/compositions/transcript-viewer/transcript-viewer.js +471 -0
- package/dist/ai/compositions/usage-meter/usage-format.js +107 -0
- package/dist/ai/compositions/usage-meter/usage-meter.d.ts +32 -0
- package/dist/ai/compositions/usage-meter/usage-meter.js +258 -0
- package/dist/ai/testing/mock-clock.d.ts +31 -0
- package/dist/ai/testing/mock-clock.js +66 -0
- package/dist/ai/testing/mock-reply.d.ts +70 -0
- package/dist/ai/testing/mock-reply.js +100 -0
- package/dist/ai/testing/mock-runtime.d.ts +86 -0
- package/dist/ai/testing/mock-runtime.js +384 -0
- package/dist/ai/types.d.ts +323 -0
- package/dist/ai.css +1088 -0
- package/dist/ai.d.ts +160 -0
- package/dist/ai.js +158 -0
- package/dist/components/assistant-ui/elements/activity-graph.d.ts +14 -0
- package/dist/components/assistant-ui/elements/activity-graph.js +69 -0
- package/dist/components/assistant-ui/elements/agent-card.d.ts +21 -0
- package/dist/components/assistant-ui/elements/agent-card.js +75 -0
- package/dist/components/assistant-ui/elements/agent-handoff.d.ts +13 -0
- package/dist/components/assistant-ui/elements/agent-handoff.js +47 -0
- package/dist/components/assistant-ui/elements/agent-plan.d.ts +16 -0
- package/dist/components/assistant-ui/elements/agent-plan.js +93 -0
- package/dist/components/assistant-ui/elements/agent-status.aui.d.ts +24 -0
- package/dist/components/assistant-ui/elements/agent-status.aui.js +161 -0
- package/dist/components/assistant-ui/elements/agent-status.d.ts +17 -0
- package/dist/components/assistant-ui/elements/agent-status.js +47 -0
- package/dist/components/assistant-ui/elements/approval-card.d.ts +31 -0
- package/dist/components/assistant-ui/elements/approval-card.js +99 -0
- package/dist/components/assistant-ui/elements/artifact-card.d.ts +12 -0
- package/dist/components/assistant-ui/elements/artifact-card.js +47 -0
- package/dist/components/assistant-ui/elements/assistant-modal.aui.d.ts +7 -0
- package/dist/components/assistant-ui/elements/assistant-modal.aui.js +276 -0
- package/dist/components/assistant-ui/elements/assistant-sidebar.aui.d.ts +7 -0
- package/dist/components/assistant-ui/elements/assistant-sidebar.aui.js +18 -0
- package/dist/components/assistant-ui/elements/attachment.aui.d.ts +9 -0
- package/dist/components/assistant-ui/elements/attachment.aui.js +143 -0
- package/dist/components/assistant-ui/elements/background-inbox.d.ts +18 -0
- package/dist/components/assistant-ui/elements/background-inbox.js +65 -0
- package/dist/components/assistant-ui/elements/canvas-split.d.ts +25 -0
- package/dist/components/assistant-ui/elements/canvas-split.js +106 -0
- package/dist/components/assistant-ui/elements/chart.d.ts +19 -0
- package/dist/components/assistant-ui/elements/chart.js +105 -0
- package/dist/components/assistant-ui/elements/chat-panel.d.ts +15 -0
- package/dist/components/assistant-ui/elements/chat-panel.js +82 -0
- package/dist/components/assistant-ui/elements/checkpoint-history.d.ts +17 -0
- package/dist/components/assistant-ui/elements/checkpoint-history.js +60 -0
- package/dist/components/assistant-ui/elements/code-diff.d.ts +18 -0
- package/dist/components/assistant-ui/elements/code-diff.js +89 -0
- package/dist/components/assistant-ui/elements/code-runner.d.ts +15 -0
- package/dist/components/assistant-ui/elements/code-runner.js +108 -0
- package/dist/components/assistant-ui/elements/command-palette.d.ts +20 -0
- package/dist/components/assistant-ui/elements/command-palette.js +129 -0
- package/dist/components/assistant-ui/elements/comparison-card.d.ts +18 -0
- package/dist/components/assistant-ui/elements/comparison-card.js +58 -0
- package/dist/components/assistant-ui/elements/composer-trigger-popover.aui.d.ts +51 -0
- package/dist/components/assistant-ui/elements/composer-trigger-popover.aui.js +104 -0
- package/dist/components/assistant-ui/elements/composer.d.ts +91 -0
- package/dist/components/assistant-ui/elements/composer.js +416 -0
- package/dist/components/assistant-ui/elements/computer-use.d.ts +19 -0
- package/dist/components/assistant-ui/elements/computer-use.js +84 -0
- package/dist/components/assistant-ui/elements/confidence-marker.d.ts +20 -0
- package/dist/components/assistant-ui/elements/confidence-marker.js +58 -0
- package/dist/components/assistant-ui/elements/connection-state.d.ts +13 -0
- package/dist/components/assistant-ui/elements/connection-state.js +59 -0
- package/dist/components/assistant-ui/elements/context-breakdown.d.ts +15 -0
- package/dist/components/assistant-ui/elements/context-breakdown.js +91 -0
- package/dist/components/assistant-ui/elements/context-display.aui.d.ts +25 -0
- package/dist/components/assistant-ui/elements/context-display.aui.js +26 -0
- package/dist/components/assistant-ui/elements/context-display.d.ts +43 -0
- package/dist/components/assistant-ui/elements/context-display.js +300 -0
- package/dist/components/assistant-ui/elements/conversation-map.aui.d.ts +9 -0
- package/dist/components/assistant-ui/elements/conversation-map.aui.js +177 -0
- package/dist/components/assistant-ui/elements/conversation-map.d.ts +19 -0
- package/dist/components/assistant-ui/elements/conversation-map.js +84 -0
- package/dist/components/assistant-ui/elements/conversation-search.d.ts +20 -0
- package/dist/components/assistant-ui/elements/conversation-search.js +75 -0
- package/dist/components/assistant-ui/elements/cost-meter.d.ts +19 -0
- package/dist/components/assistant-ui/elements/cost-meter.js +76 -0
- package/dist/components/assistant-ui/elements/data-table.d.ts +72 -0
- package/dist/components/assistant-ui/elements/data-table.js +368 -0
- package/dist/components/assistant-ui/elements/day-separator.d.ts +16 -0
- package/dist/components/assistant-ui/elements/day-separator.js +44 -0
- package/dist/components/assistant-ui/elements/diagram.d.ts +15 -0
- package/dist/components/assistant-ui/elements/diagram.js +65 -0
- package/dist/components/assistant-ui/elements/directive-text.aui.d.ts +11 -0
- package/dist/components/assistant-ui/elements/directive-text.aui.js +18 -0
- package/dist/components/assistant-ui/elements/directive-text.d.ts +32 -0
- package/dist/components/assistant-ui/elements/directive-text.js +35 -0
- package/dist/components/assistant-ui/elements/document-reference.d.ts +17 -0
- package/dist/components/assistant-ui/elements/document-reference.js +62 -0
- package/dist/components/assistant-ui/elements/draft-restore.d.ts +12 -0
- package/dist/components/assistant-ui/elements/draft-restore.js +43 -0
- package/dist/components/assistant-ui/elements/edit-message.d.ts +15 -0
- package/dist/components/assistant-ui/elements/edit-message.js +63 -0
- package/dist/components/assistant-ui/elements/elicitation-form.d.ts +23 -0
- package/dist/components/assistant-ui/elements/elicitation-form.js +112 -0
- package/dist/components/assistant-ui/elements/empty-state.d.ts +16 -0
- package/dist/components/assistant-ui/elements/empty-state.js +71 -0
- package/dist/components/assistant-ui/elements/error-state.d.ts +13 -0
- package/dist/components/assistant-ui/elements/error-state.js +52 -0
- package/dist/components/assistant-ui/elements/feedback-dialog.d.ts +15 -0
- package/dist/components/assistant-ui/elements/feedback-dialog.js +77 -0
- package/dist/components/assistant-ui/elements/file-tree.d.ts +20 -0
- package/dist/components/assistant-ui/elements/file-tree.js +74 -0
- package/dist/components/assistant-ui/elements/file.d.ts +52 -0
- package/dist/components/assistant-ui/elements/file.js +222 -0
- package/dist/components/assistant-ui/elements/flow-graph.d.ts +23 -0
- package/dist/components/assistant-ui/elements/flow-graph.js +72 -0
- package/dist/components/assistant-ui/elements/follow-up-suggestions.aui.d.ts +7 -0
- package/dist/components/assistant-ui/elements/follow-up-suggestions.aui.js +30 -0
- package/dist/components/assistant-ui/elements/generative-ui.d.ts +8 -0
- package/dist/components/assistant-ui/elements/generative-ui.js +27 -0
- package/dist/components/assistant-ui/elements/geo-map.d.ts +29 -0
- package/dist/components/assistant-ui/elements/geo-map.js +190 -0
- package/dist/components/assistant-ui/elements/guardrail-notice.d.ts +15 -0
- package/dist/components/assistant-ui/elements/guardrail-notice.js +59 -0
- package/dist/components/assistant-ui/elements/heat-graph.d.ts +9 -0
- package/dist/components/assistant-ui/elements/heat-graph.js +90 -0
- package/dist/components/assistant-ui/elements/image-gallery.d.ts +22 -0
- package/dist/components/assistant-ui/elements/image-gallery.js +192 -0
- package/dist/components/assistant-ui/elements/image-generation.d.ts +11 -0
- package/dist/components/assistant-ui/elements/image-generation.js +64 -0
- package/dist/components/assistant-ui/elements/image.d.ts +59 -0
- package/dist/components/assistant-ui/elements/image.js +416 -0
- package/dist/components/assistant-ui/elements/inline-citation.d.ts +23 -0
- package/dist/components/assistant-ui/elements/inline-citation.js +90 -0
- package/dist/components/assistant-ui/elements/job-progress.d.ts +25 -0
- package/dist/components/assistant-ui/elements/job-progress.js +102 -0
- package/dist/components/assistant-ui/elements/launcher-bubble.d.ts +15 -0
- package/dist/components/assistant-ui/elements/launcher-bubble.js +71 -0
- package/dist/components/assistant-ui/elements/link-preview.d.ts +17 -0
- package/dist/components/assistant-ui/elements/link-preview.js +77 -0
- package/dist/components/assistant-ui/elements/loading-state.d.ts +13 -0
- package/dist/components/assistant-ui/elements/loading-state.js +33 -0
- package/dist/components/assistant-ui/elements/logos.d.ts +10 -0
- package/dist/components/assistant-ui/elements/logos.js +63 -0
- package/dist/components/assistant-ui/elements/map-answer.d.ts +19 -0
- package/dist/components/assistant-ui/elements/map-answer.js +120 -0
- package/dist/components/assistant-ui/elements/markdown-text.d.ts +11 -0
- package/dist/components/assistant-ui/elements/markdown-text.js +152 -0
- package/dist/components/assistant-ui/elements/math-block.d.ts +25 -0
- package/dist/components/assistant-ui/elements/math-block.js +60 -0
- package/dist/components/assistant-ui/elements/mcp-config.aui.d.ts +28 -0
- package/dist/components/assistant-ui/elements/mcp-config.aui.js +380 -0
- package/dist/components/assistant-ui/elements/mcp-server-panel.d.ts +20 -0
- package/dist/components/assistant-ui/elements/mcp-server-panel.js +114 -0
- package/dist/components/assistant-ui/elements/media-player.d.ts +21 -0
- package/dist/components/assistant-ui/elements/media-player.js +302 -0
- package/dist/components/assistant-ui/elements/memory-chips.d.ts +16 -0
- package/dist/components/assistant-ui/elements/memory-chips.js +44 -0
- package/dist/components/assistant-ui/elements/mermaid-diagram.aui.d.ts +14 -0
- package/dist/components/assistant-ui/elements/mermaid-diagram.aui.js +43 -0
- package/dist/components/assistant-ui/elements/mermaid-diagram.d.ts +20 -0
- package/dist/components/assistant-ui/elements/mermaid-diagram.js +258 -0
- package/dist/components/assistant-ui/elements/message-actions.d.ts +17 -0
- package/dist/components/assistant-ui/elements/message-actions.js +57 -0
- package/dist/components/assistant-ui/elements/message-attachment.d.ts +18 -0
- package/dist/components/assistant-ui/elements/message-attachment.js +58 -0
- package/dist/components/assistant-ui/elements/message-branches.d.ts +12 -0
- package/dist/components/assistant-ui/elements/message-branches.js +55 -0
- package/dist/components/assistant-ui/elements/message-pair.d.ts +16 -0
- package/dist/components/assistant-ui/elements/message-pair.js +63 -0
- package/dist/components/assistant-ui/elements/message-queue.d.ts +15 -0
- package/dist/components/assistant-ui/elements/message-queue.js +70 -0
- package/dist/components/assistant-ui/elements/message-timing.aui.d.ts +30 -0
- package/dist/components/assistant-ui/elements/message-timing.aui.js +98 -0
- package/dist/components/assistant-ui/elements/message-timing.d.ts +14 -0
- package/dist/components/assistant-ui/elements/message-timing.js +26 -0
- package/dist/components/assistant-ui/elements/mobile-composer.d.ts +18 -0
- package/dist/components/assistant-ui/elements/mobile-composer.js +76 -0
- package/dist/components/assistant-ui/elements/model-picker.d.ts +19 -0
- package/dist/components/assistant-ui/elements/model-picker.js +68 -0
- package/dist/components/assistant-ui/elements/model-selector.aui.d.ts +23 -0
- package/dist/components/assistant-ui/elements/model-selector.aui.js +79 -0
- package/dist/components/assistant-ui/elements/model-selector.d.ts +130 -0
- package/dist/components/assistant-ui/elements/model-selector.js +399 -0
- package/dist/components/assistant-ui/elements/number-ticker.d.ts +10 -0
- package/dist/components/assistant-ui/elements/number-ticker.js +41 -0
- package/dist/components/assistant-ui/elements/onboarding.d.ts +17 -0
- package/dist/components/assistant-ui/elements/onboarding.js +69 -0
- package/dist/components/assistant-ui/elements/option-list.d.ts +39 -0
- package/dist/components/assistant-ui/elements/option-list.js +176 -0
- package/dist/components/assistant-ui/elements/permission-grant.d.ts +14 -0
- package/dist/components/assistant-ui/elements/permission-grant.js +84 -0
- package/dist/components/assistant-ui/elements/prompt-library.d.ts +20 -0
- package/dist/components/assistant-ui/elements/prompt-library.js +121 -0
- package/dist/components/assistant-ui/elements/question-flow.d.ts +24 -0
- package/dist/components/assistant-ui/elements/question-flow.js +180 -0
- package/dist/components/assistant-ui/elements/quota-banner.d.ts +14 -0
- package/dist/components/assistant-ui/elements/quota-banner.js +68 -0
- package/dist/components/assistant-ui/elements/quote-reply.d.ts +20 -0
- package/dist/components/assistant-ui/elements/quote-reply.js +66 -0
- package/dist/components/assistant-ui/elements/quote.aui.d.ts +61 -0
- package/dist/components/assistant-ui/elements/quote.aui.js +170 -0
- package/dist/components/assistant-ui/elements/read-aloud.d.ts +16 -0
- package/dist/components/assistant-ui/elements/read-aloud.js +66 -0
- package/dist/components/assistant-ui/elements/reasoning-effort.d.ts +17 -0
- package/dist/components/assistant-ui/elements/reasoning-effort.js +67 -0
- package/dist/components/assistant-ui/elements/reasoning-panel.d.ts +20 -0
- package/dist/components/assistant-ui/elements/reasoning-panel.js +60 -0
- package/dist/components/assistant-ui/elements/reasoning.aui.d.ts +24 -0
- package/dist/components/assistant-ui/elements/reasoning.aui.js +70 -0
- package/dist/components/assistant-ui/elements/reasoning.d.ts +38 -0
- package/dist/components/assistant-ui/elements/reasoning.js +194 -0
- package/dist/components/assistant-ui/elements/recommendation-card.d.ts +16 -0
- package/dist/components/assistant-ui/elements/recommendation-card.js +65 -0
- package/dist/components/assistant-ui/elements/regenerate-menu.d.ts +18 -0
- package/dist/components/assistant-ui/elements/regenerate-menu.js +46 -0
- package/dist/components/assistant-ui/elements/research-report.d.ts +19 -0
- package/dist/components/assistant-ui/elements/research-report.js +63 -0
- package/dist/components/assistant-ui/elements/retrieval-chunks.d.ts +19 -0
- package/dist/components/assistant-ui/elements/retrieval-chunks.js +86 -0
- package/dist/components/assistant-ui/elements/reviewable-diff.d.ts +21 -0
- package/dist/components/assistant-ui/elements/reviewable-diff.js +104 -0
- package/dist/components/assistant-ui/elements/schedule-card.d.ts +19 -0
- package/dist/components/assistant-ui/elements/schedule-card.js +80 -0
- package/dist/components/assistant-ui/elements/score-breakdown.d.ts +19 -0
- package/dist/components/assistant-ui/elements/score-breakdown.js +107 -0
- package/dist/components/assistant-ui/elements/scroll-anchor.d.ts +15 -0
- package/dist/components/assistant-ui/elements/scroll-anchor.js +104 -0
- package/dist/components/assistant-ui/elements/settings-panel.d.ts +23 -0
- package/dist/components/assistant-ui/elements/settings-panel.js +108 -0
- package/dist/components/assistant-ui/elements/shared-conversation.d.ts +18 -0
- package/dist/components/assistant-ui/elements/shared-conversation.js +56 -0
- package/dist/components/assistant-ui/elements/shiki-highlighter.aui.d.ts +29 -0
- package/dist/components/assistant-ui/elements/shiki-highlighter.aui.js +31 -0
- package/dist/components/assistant-ui/elements/shiki-highlighter.d.ts +26 -0
- package/dist/components/assistant-ui/elements/shiki-highlighter.js +49 -0
- package/dist/components/assistant-ui/elements/sources.aui.d.ts +24 -0
- package/dist/components/assistant-ui/elements/sources.aui.js +121 -0
- package/dist/components/assistant-ui/elements/sources.d.ts +21 -0
- package/dist/components/assistant-ui/elements/sources.js +109 -0
- package/dist/components/assistant-ui/elements/speaker-identity.d.ts +17 -0
- package/dist/components/assistant-ui/elements/speaker-identity.js +45 -0
- package/dist/components/assistant-ui/elements/spec-sheet.d.ts +17 -0
- package/dist/components/assistant-ui/elements/spec-sheet.js +39 -0
- package/dist/components/assistant-ui/elements/stopped-run.d.ts +12 -0
- package/dist/components/assistant-ui/elements/stopped-run.js +44 -0
- package/dist/components/assistant-ui/elements/streaming-text.d.ts +15 -0
- package/dist/components/assistant-ui/elements/streaming-text.js +45 -0
- package/dist/components/assistant-ui/elements/subagent-list.d.ts +17 -0
- package/dist/components/assistant-ui/elements/subagent-list.js +74 -0
- package/dist/components/assistant-ui/elements/suggestions.d.ts +14 -0
- package/dist/components/assistant-ui/elements/suggestions.js +25 -0
- package/dist/components/assistant-ui/elements/surfaces.d.ts +42 -0
- package/dist/components/assistant-ui/elements/surfaces.js +87 -0
- package/dist/components/assistant-ui/elements/syntax-highlighter.d.ts +7 -0
- package/dist/components/assistant-ui/elements/syntax-highlighter.js +41 -0
- package/dist/components/assistant-ui/elements/task-card.aui.d.ts +24 -0
- package/dist/components/assistant-ui/elements/task-card.aui.js +136 -0
- package/dist/components/assistant-ui/elements/task-card.d.ts +22 -0
- package/dist/components/assistant-ui/elements/task-card.js +104 -0
- package/dist/components/assistant-ui/elements/terminal-block.d.ts +27 -0
- package/dist/components/assistant-ui/elements/terminal-block.js +266 -0
- package/dist/components/assistant-ui/elements/thinking-indicator.d.ts +10 -0
- package/dist/components/assistant-ui/elements/thinking-indicator.js +30 -0
- package/dist/components/assistant-ui/elements/thread-list.aui.d.ts +39 -0
- package/dist/components/assistant-ui/elements/thread-list.aui.js +331 -0
- package/dist/components/assistant-ui/elements/thread-list.d.ts +19 -0
- package/dist/components/assistant-ui/elements/thread-list.js +72 -0
- package/dist/components/assistant-ui/elements/thread-search.d.ts +20 -0
- package/dist/components/assistant-ui/elements/thread-search.js +94 -0
- package/dist/components/assistant-ui/elements/thread.aui.d.ts +36 -0
- package/dist/components/assistant-ui/elements/thread.aui.js +625 -0
- package/dist/components/assistant-ui/elements/threadlist-sidebar.aui.d.ts +19 -0
- package/dist/components/assistant-ui/elements/threadlist-sidebar.aui.js +75 -0
- package/dist/components/assistant-ui/elements/timeline.d.ts +18 -0
- package/dist/components/assistant-ui/elements/timeline.js +40 -0
- package/dist/components/assistant-ui/elements/todo-list.d.ts +21 -0
- package/dist/components/assistant-ui/elements/todo-list.js +100 -0
- package/dist/components/assistant-ui/elements/tool-call.d.ts +17 -0
- package/dist/components/assistant-ui/elements/tool-call.js +70 -0
- package/dist/components/assistant-ui/elements/tool-error.d.ts +16 -0
- package/dist/components/assistant-ui/elements/tool-error.js +62 -0
- package/dist/components/assistant-ui/elements/tool-fallback.aui.d.ts +44 -0
- package/dist/components/assistant-ui/elements/tool-fallback.aui.js +542 -0
- package/dist/components/assistant-ui/elements/tool-group.aui.d.ts +37 -0
- package/dist/components/assistant-ui/elements/tool-group.aui.js +104 -0
- package/dist/components/assistant-ui/elements/tool-group.d.ts +20 -0
- package/dist/components/assistant-ui/elements/tool-group.js +71 -0
- package/dist/components/assistant-ui/elements/tool-timeline.d.ts +44 -0
- package/dist/components/assistant-ui/elements/tool-timeline.js +109 -0
- package/dist/components/assistant-ui/elements/tooltip-icon-button.d.ts +12 -0
- package/dist/components/assistant-ui/elements/tooltip-icon-button.js +30 -0
- package/dist/components/assistant-ui/elements/trace-waterfall.d.ts +33 -0
- package/dist/components/assistant-ui/elements/trace-waterfall.js +102 -0
- package/dist/components/assistant-ui/elements/typing-indicator.d.ts +9 -0
- package/dist/components/assistant-ui/elements/typing-indicator.js +45 -0
- package/dist/components/assistant-ui/elements/voice-conversation.aui.d.ts +11 -0
- package/dist/components/assistant-ui/elements/voice-conversation.aui.js +54 -0
- package/dist/components/assistant-ui/elements/voice-conversation.d.ts +21 -0
- package/dist/components/assistant-ui/elements/voice-conversation.js +110 -0
- package/dist/components/assistant-ui/elements/voice.aui.d.ts +22 -0
- package/dist/components/assistant-ui/elements/voice.aui.js +100 -0
- package/dist/components/assistant-ui/elements/voice.d.ts +15 -0
- package/dist/components/assistant-ui/elements/voice.js +400 -0
- package/dist/components/assistant-ui/elements/web-preview.d.ts +18 -0
- package/dist/components/assistant-ui/elements/web-preview.js +61 -0
- package/dist/components/assistant-ui/elements/web-search.d.ts +17 -0
- package/dist/components/assistant-ui/elements/web-search.js +54 -0
- package/dist/components/assistant-ui/utils/href.d.ts +13 -0
- package/dist/components/assistant-ui/utils/href.js +39 -0
- package/dist/components/assistant-ui/utils/range.d.ts +22 -0
- package/dist/components/assistant-ui/utils/range.js +48 -0
- package/dist/components/assistant-ui/utils/task.d.ts +14 -0
- package/dist/components/assistant-ui/utils/task.js +75 -0
- package/dist/components/icons/github.js +13 -0
- package/dist/components/theme-provider.d.ts +16 -0
- package/dist/components/theme-provider.js +116 -0
- package/dist/components/ui/accordion.d.ts +8 -0
- package/dist/components/ui/accordion.js +53 -0
- package/dist/components/ui/alert-dialog.d.ts +20 -0
- package/dist/components/ui/alert-dialog.js +93 -0
- package/dist/components/ui/alert.d.ts +12 -0
- package/dist/components/ui/alert.js +42 -0
- package/dist/components/ui/aspect-ratio.d.ts +6 -0
- package/dist/components/ui/aspect-ratio.js +13 -0
- package/dist/components/ui/attachment.d.ts +25 -0
- package/dist/components/ui/attachment.js +103 -0
- package/dist/components/ui/avatar.d.ts +13 -0
- package/dist/components/ui/avatar.js +50 -0
- package/dist/components/ui/badge.d.ts +14 -0
- package/dist/components/ui/badge.js +30 -0
- package/dist/components/ui/breadcrumb.d.ts +12 -0
- package/dist/components/ui/breadcrumb.js +71 -0
- package/dist/components/ui/bubble.d.ts +18 -0
- package/dist/components/ui/bubble.js +72 -0
- package/dist/components/ui/button-group.d.ts +12 -0
- package/dist/components/ui/button-group.js +41 -0
- package/dist/components/ui/button.d.ts +19 -0
- package/dist/components/ui/button.js +71 -0
- package/dist/components/ui/calendar.d.ts +12 -0
- package/dist/components/ui/calendar.js +108 -0
- package/dist/components/ui/card.d.ts +13 -0
- package/dist/components/ui/card.js +55 -0
- package/dist/components/ui/carousel.d.ts +30 -0
- package/dist/components/ui/carousel.js +131 -0
- package/dist/components/ui/chart.d.ts +46 -0
- package/dist/components/ui/chart.js +148 -0
- package/dist/components/ui/checkbox.d.ts +5 -0
- package/dist/components/ui/checkbox.js +20 -0
- package/dist/components/ui/collapsible.d.ts +7 -0
- package/dist/components/ui/collapsible.js +23 -0
- package/dist/components/ui/combobox.d.ts +26 -0
- package/dist/components/ui/combobox.js +161 -0
- package/dist/components/ui/command.d.ts +21 -0
- package/dist/components/ui/command.js +87 -0
- package/dist/components/ui/context-menu.d.ts +31 -0
- package/dist/components/ui/context-menu.js +132 -0
- package/dist/components/ui/dialog.d.ts +19 -0
- package/dist/components/ui/dialog.js +91 -0
- package/dist/components/ui/diff-viewer.d.ts +100 -0
- package/dist/components/ui/diff-viewer.js +461 -0
- package/dist/components/ui/direction.d.ts +2 -0
- package/dist/components/ui/direction.js +2 -0
- package/dist/components/ui/dot-matrix.d.ts +150 -0
- package/dist/components/ui/dot-matrix.js +248 -0
- package/dist/components/ui/drawer.d.ts +18 -0
- package/dist/components/ui/drawer.js +123 -0
- package/dist/components/ui/dropdown-menu.d.ts +31 -0
- package/dist/components/ui/dropdown-menu.js +136 -0
- package/dist/components/ui/empty.d.ts +13 -0
- package/dist/components/ui/empty.js +59 -0
- package/dist/components/ui/field.d.ts +26 -0
- package/dist/components/ui/field.js +109 -0
- package/dist/components/ui/hover-card.d.ts +7 -0
- package/dist/components/ui/hover-card.js +36 -0
- package/dist/components/ui/input-group.d.ts +20 -0
- package/dist/components/ui/input-group.js +77 -0
- package/dist/components/ui/input-otp.d.ts +13 -0
- package/dist/components/ui/input-otp.js +46 -0
- package/dist/components/ui/input.d.ts +5 -0
- package/dist/components/ui/input.js +14 -0
- package/dist/components/ui/item.d.ts +24 -0
- package/dist/components/ui/item.js +120 -0
- package/dist/components/ui/kbd.d.ts +5 -0
- package/dist/components/ui/kbd.js +19 -0
- package/dist/components/ui/label.d.ts +5 -0
- package/dist/components/ui/label.js +12 -0
- package/dist/components/ui/marker.d.ts +12 -0
- package/dist/components/ui/marker.js +42 -0
- package/dist/components/ui/menubar.d.ts +31 -0
- package/dist/components/ui/menubar.js +135 -0
- package/dist/components/ui/message-scroller.d.ts +12 -0
- package/dist/components/ui/message-scroller.js +59 -0
- package/dist/components/ui/message.d.ts +12 -0
- package/dist/components/ui/message.js +48 -0
- package/dist/components/ui/native-select.d.ts +10 -0
- package/dist/components/ui/native-select.js +37 -0
- package/dist/components/ui/navigation-menu.d.ts +13 -0
- package/dist/components/ui/navigation-menu.js +82 -0
- package/dist/components/ui/number-roll.d.ts +21 -0
- package/dist/components/ui/number-roll.js +269 -0
- package/dist/components/ui/pagination.d.ts +19 -0
- package/dist/components/ui/pagination.js +79 -0
- package/dist/components/ui/popover.d.ts +11 -0
- package/dist/components/ui/popover.js +54 -0
- package/dist/components/ui/progress.d.ts +9 -0
- package/dist/components/ui/progress.js +44 -0
- package/dist/components/ui/questionnaire.d.ts +21 -0
- package/dist/components/ui/questionnaire.js +169 -0
- package/dist/components/ui/radio-group.d.ts +7 -0
- package/dist/components/ui/radio-group.js +26 -0
- package/dist/components/ui/resizable.d.ts +9 -0
- package/dist/components/ui/resizable.js +28 -0
- package/dist/components/ui/scroll-area.d.ts +6 -0
- package/dist/components/ui/scroll-area.js +35 -0
- package/dist/components/ui/select.d.ts +17 -0
- package/dist/components/ui/select.js +96 -0
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/separator.js +14 -0
- package/dist/components/ui/sheet.d.ts +16 -0
- package/dist/components/ui/sheet.js +87 -0
- package/dist/components/ui/sidebar.d.ts +65 -0
- package/dist/components/ui/sidebar.js +386 -0
- package/dist/components/ui/skeleton.d.ts +4 -0
- package/dist/components/ui/skeleton.js +12 -0
- package/dist/components/ui/slider.d.ts +5 -0
- package/dist/components/ui/slider.js +33 -0
- package/dist/components/ui/spinner.d.ts +4 -0
- package/dist/components/ui/spinner.js +15 -0
- package/dist/components/ui/switch.d.ts +7 -0
- package/dist/components/ui/switch.js +19 -0
- package/dist/components/ui/table.d.ts +12 -0
- package/dist/components/ui/table.js +65 -0
- package/dist/components/ui/tabs.d.ts +12 -0
- package/dist/components/ui/tabs.js +45 -0
- package/dist/components/ui/textarea.d.ts +5 -0
- package/dist/components/ui/textarea.js +12 -0
- package/dist/components/ui/toast.d.ts +18 -0
- package/dist/components/ui/toast.js +121 -0
- package/dist/components/ui/toggle-group.d.ts +13 -0
- package/dist/components/ui/toggle-group.js +51 -0
- package/dist/components/ui/toggle.d.ts +10 -0
- package/dist/components/ui/toggle.js +35 -0
- package/dist/components/ui/tooltip.d.ts +8 -0
- package/dist/components/ui/tooltip.js +43 -0
- package/dist/compositions/app-rail/app-rail.d.ts +19 -0
- package/dist/compositions/app-rail/app-rail.js +58 -0
- package/dist/compositions/app-shell/app-shell.d.ts +56 -0
- package/dist/compositions/app-shell/app-shell.js +143 -0
- package/dist/compositions/app-shell/theme-toggle.d.ts +10 -0
- package/dist/compositions/app-shell/theme-toggle.js +65 -0
- package/dist/compositions/confirm-action/confirm-action.d.ts +48 -0
- package/dist/compositions/confirm-action/confirm-action.js +48 -0
- package/dist/compositions/data-table/data-table-state.d.ts +23 -0
- package/dist/compositions/data-table/data-table-state.js +46 -0
- package/dist/compositions/data-table/data-table.d.ts +185 -0
- package/dist/compositions/data-table/data-table.js +615 -0
- package/dist/compositions/date-range-picker/date-range-options.d.ts +28 -0
- package/dist/compositions/date-range-picker/date-range-options.js +61 -0
- package/dist/compositions/date-range-picker/date-range-picker.d.ts +55 -0
- package/dist/compositions/date-range-picker/date-range-picker.js +409 -0
- package/dist/compositions/decision-queue/decision-queue.d.ts +114 -0
- package/dist/compositions/decision-queue/decision-queue.js +478 -0
- package/dist/compositions/event-feed/event-feed.d.ts +59 -0
- package/dist/compositions/event-feed/event-feed.js +105 -0
- package/dist/compositions/feedback.d.ts +20 -0
- package/dist/compositions/feedback.js +49 -0
- package/dist/compositions/fields.d.ts +64 -0
- package/dist/compositions/fields.js +293 -0
- package/dist/compositions/form-kit/form-context.d.ts +10 -0
- package/dist/compositions/form-kit/form-context.js +12 -0
- package/dist/compositions/form-kit/form-fields.d.ts +95 -0
- package/dist/compositions/form-kit/form-fields.js +233 -0
- package/dist/compositions/form-kit/form-kit.d.ts +128 -0
- package/dist/compositions/form-kit/form-kit.js +119 -0
- package/dist/compositions/inspector/inspector.d.ts +53 -0
- package/dist/compositions/inspector/inspector.js +80 -0
- package/dist/compositions/layout.d.ts +36 -0
- package/dist/compositions/layout.js +86 -0
- package/dist/compositions/state-blocks/state-blocks.d.ts +42 -0
- package/dist/compositions/state-blocks/state-blocks.js +81 -0
- package/dist/compositions/status-panel/status-panel.d.ts +94 -0
- package/dist/compositions/status-panel/status-panel.js +189 -0
- package/dist/fonts/InterVariable.woff2 +0 -0
- package/dist/fonts/inter.css +15 -0
- package/dist/hooks/use-attachment-src.js +35 -0
- package/dist/hooks/use-copy-to-clipboard.js +34 -0
- package/dist/hooks/use-mobile.d.ts +3 -0
- package/dist/hooks/use-mobile.js +18 -0
- package/dist/index.d.ts +102 -0
- package/dist/index.js +102 -0
- package/dist/lib/context-level.js +7 -0
- package/dist/lib/elapsed.js +61 -0
- package/dist/lib/iso-date.js +30 -0
- package/dist/lib/motion-loop.js +41 -0
- package/dist/lib/pointer.js +14 -0
- package/dist/lib/status-tone.d.ts +7 -0
- package/dist/lib/status-tone.js +55 -0
- package/dist/lib/triage-keys.js +229 -0
- package/dist/lib/utils.js +2 -0
- package/dist/motion/alert-toast/alert-toast.d.ts +51 -0
- package/dist/motion/alert-toast/alert-toast.js +226 -0
- package/dist/motion/branch-menu/branch-menu.d.ts +47 -0
- package/dist/motion/branch-menu/branch-menu.js +287 -0
- package/dist/motion/check-item/check-item.d.ts +24 -0
- package/dist/motion/check-item/check-item.js +110 -0
- package/dist/motion/dial/dial.d.ts +39 -0
- package/dist/motion/dial/dial.js +290 -0
- package/dist/motion/dictation-button/dictation-button.d.ts +45 -0
- package/dist/motion/dictation-button/dictation-button.js +232 -0
- package/dist/motion/hold-button/hold-button.d.ts +37 -0
- package/dist/motion/hold-button/hold-button.js +192 -0
- package/dist/motion/masonry-grid/masonry-grid.d.ts +42 -0
- package/dist/motion/masonry-grid/masonry-grid.js +145 -0
- package/dist/motion/prompt-composer/prompt-composer.d.ts +90 -0
- package/dist/motion/prompt-composer/prompt-composer.js +374 -0
- package/dist/motion/scrub-select/scrub-select.d.ts +33 -0
- package/dist/motion/scrub-select/scrub-select.js +346 -0
- package/dist/motion/spotlight-grid/spotlight-grid.d.ts +40 -0
- package/dist/motion/spotlight-grid/spotlight-grid.js +171 -0
- package/dist/motion/star-rating/star-rating.d.ts +32 -0
- package/dist/motion/star-rating/star-rating.js +191 -0
- package/dist/motion/status-glyph/status-glyph.d.ts +28 -0
- package/dist/motion/status-glyph/status-glyph.js +171 -0
- package/dist/motion/stepper/stepper.d.ts +56 -0
- package/dist/motion/stepper/stepper.js +211 -0
- package/dist/motion/swipe-row/swipe-row.d.ts +52 -0
- package/dist/motion/swipe-row/swipe-row.js +208 -0
- package/dist/motion/thinking-trace/thinking-trace.d.ts +32 -0
- package/dist/motion/thinking-trace/thinking-trace.js +186 -0
- package/dist/motion/tool-call-chip/tool-call-chip.d.ts +36 -0
- package/dist/motion/tool-call-chip/tool-call-chip.js +135 -0
- package/dist/motion/working-indicator/working-indicator.d.ts +38 -0
- package/dist/motion/working-indicator/working-indicator.js +171 -0
- package/dist/styles.css +828 -0
- package/dist/tokens.css +230 -0
- package/licenses/Inter-OFL.txt +92 -0
- package/licenses/assistant-ui-MIT.txt +21 -0
- package/licenses/shadcn-MIT.md +21 -0
- package/package.json +131 -3
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { Checkbox } from "../../components/ui/checkbox.js";
|
|
2
|
+
import { Input } from "../../components/ui/input.js";
|
|
3
|
+
import { Textarea } from "../../components/ui/textarea.js";
|
|
4
|
+
import { Field, FieldContent, FieldDescription, FieldError, FieldLabel } from "../../components/ui/field.js";
|
|
5
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../components/ui/select.js";
|
|
6
|
+
import { Switch } from "../../components/ui/switch.js";
|
|
7
|
+
import { useFieldContext } from "./form-context.js";
|
|
8
|
+
import { useId } from "react";
|
|
9
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { useStore } from "@tanstack/react-form";
|
|
11
|
+
//#region src/compositions/form-kit/form-fields.tsx
|
|
12
|
+
/**
|
|
13
|
+
* Normalizes TanStack Form's `field.state.meta.errors` into the messages
|
|
14
|
+
* shadcn's `FieldError` renders. Validators return strings (function
|
|
15
|
+
* validators) or Standard Schema issues such as Zod's (`{ message }`);
|
|
16
|
+
* anything without a non-empty message is dropped.
|
|
17
|
+
*/
|
|
18
|
+
function toFieldErrors(errors) {
|
|
19
|
+
const messages = [];
|
|
20
|
+
for (const error of errors) if (Array.isArray(error)) messages.push(...toFieldErrors(error));
|
|
21
|
+
else if (typeof error === "string") {
|
|
22
|
+
if (error) messages.push({ message: error });
|
|
23
|
+
} else if (typeof error === "object" && error !== null && "message" in error && typeof error.message === "string" && error.message) messages.push({ message: error.message });
|
|
24
|
+
return messages;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Binds the field in the surrounding `form.AppField` to shadcn's `field`
|
|
28
|
+
* markup: the control, description and error ids, the invalid state, and the
|
|
29
|
+
* control's ARIA wiring. The kit's field components use it; an app uses it to
|
|
30
|
+
* write a field component of its own with the same error association.
|
|
31
|
+
*
|
|
32
|
+
* A field is invalid once it is touched and has errors, as in shadcn's
|
|
33
|
+
* TanStack Form guide. Submitting touches every field.
|
|
34
|
+
*/
|
|
35
|
+
function useFormField({ hasDescription }) {
|
|
36
|
+
const field = useFieldContext();
|
|
37
|
+
const value = useStore(field.store, (state) => state.value);
|
|
38
|
+
const meta = useStore(field.store, (state) => state.meta);
|
|
39
|
+
const baseId = useId();
|
|
40
|
+
const controlId = `${baseId}-control`;
|
|
41
|
+
const descriptionId = `${baseId}-description`;
|
|
42
|
+
const errorId = `${baseId}-error`;
|
|
43
|
+
const isInvalid = meta.isTouched && !meta.isValid;
|
|
44
|
+
const errors = isInvalid ? toFieldErrors(meta.errors) : [];
|
|
45
|
+
const describedBy = [hasDescription ? descriptionId : null, errors.length > 0 ? errorId : null].filter(Boolean).join(" ");
|
|
46
|
+
return {
|
|
47
|
+
field,
|
|
48
|
+
value,
|
|
49
|
+
isInvalid,
|
|
50
|
+
errors,
|
|
51
|
+
controlId,
|
|
52
|
+
descriptionId,
|
|
53
|
+
errorId,
|
|
54
|
+
controlProps: {
|
|
55
|
+
id: controlId,
|
|
56
|
+
name: field.name,
|
|
57
|
+
"aria-invalid": isInvalid,
|
|
58
|
+
"aria-describedby": describedBy || void 0
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function FieldMessages({ description, descriptionId, errors, errorId }) {
|
|
63
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [description ? /* @__PURE__ */ jsx(FieldDescription, {
|
|
64
|
+
id: descriptionId,
|
|
65
|
+
children: description
|
|
66
|
+
}) : null, /* @__PURE__ */ jsx(FieldError, {
|
|
67
|
+
id: errorId,
|
|
68
|
+
errors
|
|
69
|
+
})] });
|
|
70
|
+
}
|
|
71
|
+
/** A string field rendered as a shadcn `Input`. Use inside `form.AppField`. */
|
|
72
|
+
function TextField({ label, description, className, type = "text", ...inputProps }) {
|
|
73
|
+
const { field, value, isInvalid, errors, descriptionId, errorId, controlProps } = useFormField({ hasDescription: Boolean(description) });
|
|
74
|
+
return /* @__PURE__ */ jsxs(Field, {
|
|
75
|
+
"data-invalid": isInvalid,
|
|
76
|
+
"data-disabled": inputProps.disabled,
|
|
77
|
+
className,
|
|
78
|
+
children: [
|
|
79
|
+
/* @__PURE__ */ jsx(FieldLabel, {
|
|
80
|
+
htmlFor: controlProps.id,
|
|
81
|
+
children: label
|
|
82
|
+
}),
|
|
83
|
+
/* @__PURE__ */ jsx(Input, {
|
|
84
|
+
...inputProps,
|
|
85
|
+
...controlProps,
|
|
86
|
+
type,
|
|
87
|
+
value,
|
|
88
|
+
onBlur: field.handleBlur,
|
|
89
|
+
onChange: (event) => field.handleChange(event.target.value)
|
|
90
|
+
}),
|
|
91
|
+
/* @__PURE__ */ jsx(FieldMessages, {
|
|
92
|
+
description,
|
|
93
|
+
descriptionId,
|
|
94
|
+
errors,
|
|
95
|
+
errorId
|
|
96
|
+
})
|
|
97
|
+
]
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/** A string field rendered as a shadcn `Textarea`. Use inside `form.AppField`. */
|
|
101
|
+
function TextareaField({ label, description, className, ...textareaProps }) {
|
|
102
|
+
const { field, value, isInvalid, errors, descriptionId, errorId, controlProps } = useFormField({ hasDescription: Boolean(description) });
|
|
103
|
+
return /* @__PURE__ */ jsxs(Field, {
|
|
104
|
+
"data-invalid": isInvalid,
|
|
105
|
+
"data-disabled": textareaProps.disabled,
|
|
106
|
+
className,
|
|
107
|
+
children: [
|
|
108
|
+
/* @__PURE__ */ jsx(FieldLabel, {
|
|
109
|
+
htmlFor: controlProps.id,
|
|
110
|
+
children: label
|
|
111
|
+
}),
|
|
112
|
+
/* @__PURE__ */ jsx(Textarea, {
|
|
113
|
+
...textareaProps,
|
|
114
|
+
...controlProps,
|
|
115
|
+
value,
|
|
116
|
+
onBlur: field.handleBlur,
|
|
117
|
+
onChange: (event) => field.handleChange(event.target.value)
|
|
118
|
+
}),
|
|
119
|
+
/* @__PURE__ */ jsx(FieldMessages, {
|
|
120
|
+
description,
|
|
121
|
+
descriptionId,
|
|
122
|
+
errors,
|
|
123
|
+
errorId
|
|
124
|
+
})
|
|
125
|
+
]
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* A string field rendered as a shadcn `Select`. The empty string means "no
|
|
130
|
+
* choice", so a schema rejects it to make the field required. The field
|
|
131
|
+
* counts as blurred when its popup closes. Use inside `form.AppField`.
|
|
132
|
+
*/
|
|
133
|
+
function SelectField({ label, description, className, options, placeholder, disabled }) {
|
|
134
|
+
const { field, value, isInvalid, errors, descriptionId, errorId, controlProps } = useFormField({ hasDescription: Boolean(description) });
|
|
135
|
+
const { name, ...triggerProps } = controlProps;
|
|
136
|
+
return /* @__PURE__ */ jsxs(Field, {
|
|
137
|
+
"data-invalid": isInvalid,
|
|
138
|
+
"data-disabled": disabled,
|
|
139
|
+
className,
|
|
140
|
+
children: [
|
|
141
|
+
/* @__PURE__ */ jsx(FieldLabel, {
|
|
142
|
+
htmlFor: controlProps.id,
|
|
143
|
+
children: label
|
|
144
|
+
}),
|
|
145
|
+
/* @__PURE__ */ jsxs(Select, {
|
|
146
|
+
name,
|
|
147
|
+
items: options,
|
|
148
|
+
value: value === "" ? null : value,
|
|
149
|
+
onValueChange: (next) => field.handleChange(next ?? ""),
|
|
150
|
+
onOpenChange: (open) => {
|
|
151
|
+
if (!open) field.handleBlur();
|
|
152
|
+
},
|
|
153
|
+
disabled,
|
|
154
|
+
children: [/* @__PURE__ */ jsx(SelectTrigger, {
|
|
155
|
+
...triggerProps,
|
|
156
|
+
className: "w-full",
|
|
157
|
+
children: /* @__PURE__ */ jsx(SelectValue, { placeholder })
|
|
158
|
+
}), /* @__PURE__ */ jsx(SelectContent, {
|
|
159
|
+
alignItemWithTrigger: false,
|
|
160
|
+
children: options.map((option) => /* @__PURE__ */ jsx(SelectItem, {
|
|
161
|
+
value: option.value,
|
|
162
|
+
disabled: option.disabled,
|
|
163
|
+
children: option.label
|
|
164
|
+
}, option.value))
|
|
165
|
+
})]
|
|
166
|
+
}),
|
|
167
|
+
/* @__PURE__ */ jsx(FieldMessages, {
|
|
168
|
+
description,
|
|
169
|
+
descriptionId,
|
|
170
|
+
errors,
|
|
171
|
+
errorId
|
|
172
|
+
})
|
|
173
|
+
]
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* A boolean field rendered as a shadcn `Checkbox`, with the label, description
|
|
178
|
+
* and error beside it. Use inside `form.AppField`.
|
|
179
|
+
*/
|
|
180
|
+
function CheckboxField({ label, description, className, disabled }) {
|
|
181
|
+
const { field, value, isInvalid, errors, descriptionId, errorId, controlProps } = useFormField({ hasDescription: Boolean(description) });
|
|
182
|
+
return /* @__PURE__ */ jsxs(Field, {
|
|
183
|
+
orientation: "horizontal",
|
|
184
|
+
"data-invalid": isInvalid,
|
|
185
|
+
"data-disabled": disabled,
|
|
186
|
+
className,
|
|
187
|
+
children: [/* @__PURE__ */ jsx(Checkbox, {
|
|
188
|
+
...controlProps,
|
|
189
|
+
checked: value,
|
|
190
|
+
onCheckedChange: (checked) => field.handleChange(checked),
|
|
191
|
+
onBlur: field.handleBlur,
|
|
192
|
+
disabled
|
|
193
|
+
}), /* @__PURE__ */ jsxs(FieldContent, { children: [/* @__PURE__ */ jsx(FieldLabel, {
|
|
194
|
+
htmlFor: controlProps.id,
|
|
195
|
+
children: label
|
|
196
|
+
}), /* @__PURE__ */ jsx(FieldMessages, {
|
|
197
|
+
description,
|
|
198
|
+
descriptionId,
|
|
199
|
+
errors,
|
|
200
|
+
errorId
|
|
201
|
+
})] })]
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* A boolean field rendered as a shadcn `Switch`, with the label, description
|
|
206
|
+
* and error before it. Use inside `form.AppField`.
|
|
207
|
+
*/
|
|
208
|
+
function SwitchField({ label, description, className, disabled }) {
|
|
209
|
+
const { field, value, isInvalid, errors, descriptionId, errorId, controlProps } = useFormField({ hasDescription: Boolean(description) });
|
|
210
|
+
return /* @__PURE__ */ jsxs(Field, {
|
|
211
|
+
orientation: "horizontal",
|
|
212
|
+
"data-invalid": isInvalid,
|
|
213
|
+
"data-disabled": disabled,
|
|
214
|
+
className,
|
|
215
|
+
children: [/* @__PURE__ */ jsxs(FieldContent, { children: [/* @__PURE__ */ jsx(FieldLabel, {
|
|
216
|
+
htmlFor: controlProps.id,
|
|
217
|
+
children: label
|
|
218
|
+
}), /* @__PURE__ */ jsx(FieldMessages, {
|
|
219
|
+
description,
|
|
220
|
+
descriptionId,
|
|
221
|
+
errors,
|
|
222
|
+
errorId
|
|
223
|
+
})] }), /* @__PURE__ */ jsx(Switch, {
|
|
224
|
+
...controlProps,
|
|
225
|
+
checked: value,
|
|
226
|
+
onCheckedChange: (checked) => field.handleChange(checked),
|
|
227
|
+
onBlur: field.handleBlur,
|
|
228
|
+
disabled
|
|
229
|
+
})]
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
//#endregion
|
|
233
|
+
export { CheckboxField, SelectField, SwitchField, TextField, TextareaField, toFieldErrors, useFormField };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Button } from "../../components/ui/button.js";
|
|
2
|
+
import { Alert } from "../../components/ui/alert.js";
|
|
3
|
+
import { CheckboxField, SelectField, SwitchField, TextField, TextareaField } from "./form-fields.js";
|
|
4
|
+
import * as React from "react";
|
|
5
|
+
//#region src/compositions/form-kit/form-kit.d.ts
|
|
6
|
+
export type FormProps = Omit<React.ComponentProps<"form">, "onSubmit" | "noValidate">;
|
|
7
|
+
/**
|
|
8
|
+
* The `<form>` element of an app form. It runs `form.handleSubmit()` on
|
|
9
|
+
* submit, skips native browser validation (the form's validators own it),
|
|
10
|
+
* and marks itself busy while the submit is pending. A submit started while
|
|
11
|
+
* one is pending is dropped, so a pressed Enter key cannot send twice.
|
|
12
|
+
*
|
|
13
|
+
* If `onSubmit` rejects, the rejection is caught and shown by `SubmitError`
|
|
14
|
+
* until the next submit. Nothing retries on its own.
|
|
15
|
+
*
|
|
16
|
+
* Use as `form.Form` inside `form.AppForm`.
|
|
17
|
+
*/
|
|
18
|
+
export declare function Form({ children, ...props }: FormProps): React.JSX.Element;
|
|
19
|
+
export type SubmitButtonProps = Omit<React.ComponentProps<typeof Button>, "type"> & {
|
|
20
|
+
/** Label shown while the submit is pending. Defaults to the children. */
|
|
21
|
+
pendingLabel?: React.ReactNode;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* The submit button of an app form. While the submit is pending it is
|
|
25
|
+
* disabled (it keeps focus) and shows a spinner. Use as `form.SubmitButton`
|
|
26
|
+
* inside `form.AppForm`.
|
|
27
|
+
*/
|
|
28
|
+
export declare function SubmitButton({ children, pendingLabel, disabled, ...props }: SubmitButtonProps): React.JSX.Element;
|
|
29
|
+
export type SubmitErrorProps = Omit<React.ComponentProps<typeof Alert>, "children" | "variant" | "title"> & {
|
|
30
|
+
/**
|
|
31
|
+
* The app's error from the last submit, for example a mutation's message.
|
|
32
|
+
* When unset, the message of a rejected `onSubmit` is shown instead.
|
|
33
|
+
*/
|
|
34
|
+
error?: React.ReactNode;
|
|
35
|
+
/** The alert title. */
|
|
36
|
+
title?: React.ReactNode;
|
|
37
|
+
/** Shown when `onSubmit` rejected with something that is not an `Error`. */
|
|
38
|
+
fallbackMessage?: React.ReactNode;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The submit failure of an app form, as a destructive alert announced to
|
|
42
|
+
* assistive technology. It renders nothing while there is no failure. Use as
|
|
43
|
+
* `form.SubmitError` inside `form.Form`, usually just above the actions.
|
|
44
|
+
*/
|
|
45
|
+
export declare function SubmitError({ error, title, fallbackMessage, ...props }: SubmitErrorProps): React.JSX.Element | null;
|
|
46
|
+
/**
|
|
47
|
+
* The Form kit: TanStack Form's `createFormHook` bound to shadcn's `field`
|
|
48
|
+
* components, following shadcn's TanStack Form guide. App code writes one
|
|
49
|
+
* line per field:
|
|
50
|
+
*
|
|
51
|
+
* ```tsx
|
|
52
|
+
* const form = useAppForm({ defaultValues, validators: { onSubmit: schema }, onSubmit });
|
|
53
|
+
* <form.AppForm>
|
|
54
|
+
* <form.Form>
|
|
55
|
+
* <form.AppField name="subject">{(field) => <field.TextField label="Subject" />}</form.AppField>
|
|
56
|
+
* <form.SubmitError />
|
|
57
|
+
* <form.SubmitButton>Save</form.SubmitButton>
|
|
58
|
+
* </form.Form>
|
|
59
|
+
* </form.AppForm>
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export declare const useAppForm: <TFormData, TOnMount extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TSubmitMeta>(props: import("@tanstack/react-form").FormOptions<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta>) => import("@tanstack/react-form").AppFieldExtendedReactFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
|
|
63
|
+
readonly TextField: typeof TextField;
|
|
64
|
+
readonly TextareaField: typeof TextareaField;
|
|
65
|
+
readonly SelectField: typeof SelectField;
|
|
66
|
+
readonly CheckboxField: typeof CheckboxField;
|
|
67
|
+
readonly SwitchField: typeof SwitchField;
|
|
68
|
+
}, {
|
|
69
|
+
readonly Form: typeof Form;
|
|
70
|
+
readonly SubmitButton: typeof SubmitButton;
|
|
71
|
+
readonly SubmitError: typeof SubmitError;
|
|
72
|
+
}>, withForm: <TFormData, TOnMount extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TSubmitMeta, TRenderProps extends object = {}>({ render, props }: import("@tanstack/react-form").WithFormProps<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, TSubmitMeta, {
|
|
73
|
+
readonly TextField: typeof TextField;
|
|
74
|
+
readonly TextareaField: typeof TextareaField;
|
|
75
|
+
readonly SelectField: typeof SelectField;
|
|
76
|
+
readonly CheckboxField: typeof CheckboxField;
|
|
77
|
+
readonly SwitchField: typeof SwitchField;
|
|
78
|
+
}, {
|
|
79
|
+
readonly Form: typeof Form;
|
|
80
|
+
readonly SubmitButton: typeof SubmitButton;
|
|
81
|
+
readonly SubmitError: typeof SubmitError;
|
|
82
|
+
}, TRenderProps>) => React.FunctionComponent<React.PropsWithChildren<NoInfer<[unknown] extends [TRenderProps] ? any : TRenderProps> & {
|
|
83
|
+
form: import("@tanstack/react-form").AppFieldExtendedReactFormApi<[unknown] extends [TFormData] ? any : TFormData, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnMount] ? [TOnMount] extends [TOnMount & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnMount : TOnMount, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnChange] ? [TOnChange] extends [TOnChange & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnChange : TOnChange, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnChangeAsync] ? [TOnChangeAsync] extends [TOnChangeAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnChangeAsync : TOnChangeAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnBlur] ? [TOnBlur] extends [TOnBlur & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlur : TOnBlur, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnBlurAsync] ? [TOnBlurAsync] extends [TOnBlurAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnBlurAsync : TOnBlurAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnSubmit] ? [TOnSubmit] extends [TOnSubmit & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmit : TOnSubmit, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnSubmitAsync] ? [TOnSubmitAsync] extends [TOnSubmitAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnSubmitAsync : TOnSubmitAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnDynamic] ? [TOnDynamic] extends [TOnDynamic & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamic : TOnDynamic, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnDynamicAsync] ? [TOnDynamicAsync] extends [TOnDynamicAsync & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnDynamicAsync : TOnDynamicAsync, [import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined] extends [TOnServer] ? [TOnServer] extends [TOnServer & (import("@tanstack/react-form").FormValidateOrFn<TFormData> | undefined)] ? any : TOnServer : TOnServer, [unknown] extends [TSubmitMeta] ? any : TSubmitMeta, {
|
|
84
|
+
readonly TextField: typeof TextField;
|
|
85
|
+
readonly TextareaField: typeof TextareaField;
|
|
86
|
+
readonly SelectField: typeof SelectField;
|
|
87
|
+
readonly CheckboxField: typeof CheckboxField;
|
|
88
|
+
readonly SwitchField: typeof SwitchField;
|
|
89
|
+
}, {
|
|
90
|
+
readonly Form: typeof Form;
|
|
91
|
+
readonly SubmitButton: typeof SubmitButton;
|
|
92
|
+
readonly SubmitError: typeof SubmitError;
|
|
93
|
+
}>;
|
|
94
|
+
}>>, withFieldGroup: <TFieldGroupData, TSubmitMeta, TRenderProps extends object = {}>({ render, props, defaultValues }: import("@tanstack/react-form").WithFieldGroupProps<TFieldGroupData, {
|
|
95
|
+
readonly TextField: typeof TextField;
|
|
96
|
+
readonly TextareaField: typeof TextareaField;
|
|
97
|
+
readonly SelectField: typeof SelectField;
|
|
98
|
+
readonly CheckboxField: typeof CheckboxField;
|
|
99
|
+
readonly SwitchField: typeof SwitchField;
|
|
100
|
+
}, {
|
|
101
|
+
readonly Form: typeof Form;
|
|
102
|
+
readonly SubmitButton: typeof SubmitButton;
|
|
103
|
+
readonly SubmitError: typeof SubmitError;
|
|
104
|
+
}, TSubmitMeta, TRenderProps>) => <TFormData, TFields extends import("@tanstack/react-form").DeepKeysOfType<TFormData, TFieldGroupData | null | undefined> | import("@tanstack/react-form").FieldsMap<TFormData, TFieldGroupData>, TOnMount extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChange extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnChangeAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnBlur extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnBlurAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnSubmit extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnSubmitAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnDynamic extends undefined | import("@tanstack/react-form").FormValidateOrFn<TFormData>, TOnDynamicAsync extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TOnServer extends undefined | import("@tanstack/react-form").FormAsyncValidateOrFn<TFormData>, TFormSubmitMeta>(params: React.PropsWithChildren<NoInfer<TRenderProps> & {
|
|
105
|
+
form: import("@tanstack/react-form").AppFieldExtendedReactFieldGroupApi<unknown, TFormData, string | import("@tanstack/react-form").FieldsMap<unknown, TFormData>, any, any, any, any, any, any, any, any, any, any, unknown extends TSubmitMeta ? TFormSubmitMeta : TSubmitMeta, {
|
|
106
|
+
readonly TextField: typeof TextField;
|
|
107
|
+
readonly TextareaField: typeof TextareaField;
|
|
108
|
+
readonly SelectField: typeof SelectField;
|
|
109
|
+
readonly CheckboxField: typeof CheckboxField;
|
|
110
|
+
readonly SwitchField: typeof SwitchField;
|
|
111
|
+
}, {
|
|
112
|
+
readonly Form: typeof Form;
|
|
113
|
+
readonly SubmitButton: typeof SubmitButton;
|
|
114
|
+
readonly SubmitError: typeof SubmitError;
|
|
115
|
+
}> | import("@tanstack/react-form").AppFieldExtendedReactFormApi<TFormData, TOnMount, TOnChange, TOnChangeAsync, TOnBlur, TOnBlurAsync, TOnSubmit, TOnSubmitAsync, TOnDynamic, TOnDynamicAsync, TOnServer, unknown extends TSubmitMeta ? TFormSubmitMeta : TSubmitMeta, {
|
|
116
|
+
readonly TextField: typeof TextField;
|
|
117
|
+
readonly TextareaField: typeof TextareaField;
|
|
118
|
+
readonly SelectField: typeof SelectField;
|
|
119
|
+
readonly CheckboxField: typeof CheckboxField;
|
|
120
|
+
readonly SwitchField: typeof SwitchField;
|
|
121
|
+
}, {
|
|
122
|
+
readonly Form: typeof Form;
|
|
123
|
+
readonly SubmitButton: typeof SubmitButton;
|
|
124
|
+
readonly SubmitError: typeof SubmitError;
|
|
125
|
+
}>;
|
|
126
|
+
fields: TFields;
|
|
127
|
+
}>) => ReturnType<React.FunctionComponent>;
|
|
128
|
+
//#endregion
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { Alert, AlertDescription, AlertTitle } from "../../components/ui/alert.js";
|
|
2
|
+
import { Spinner } from "../../components/ui/spinner.js";
|
|
3
|
+
import { Button } from "../../components/ui/button.js";
|
|
4
|
+
import { fieldContext, formContext, useFormContext } from "./form-context.js";
|
|
5
|
+
import { CheckboxField, SelectField, SwitchField, TextField, TextareaField } from "./form-fields.js";
|
|
6
|
+
import { createContext, useContext, useState } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
import { CircleAlertIcon } from "lucide-react";
|
|
9
|
+
import { createFormHook, useStore } from "@tanstack/react-form";
|
|
10
|
+
//#region src/compositions/form-kit/form-kit.tsx
|
|
11
|
+
const SubmitFailureContext = createContext(null);
|
|
12
|
+
/**
|
|
13
|
+
* The `<form>` element of an app form. It runs `form.handleSubmit()` on
|
|
14
|
+
* submit, skips native browser validation (the form's validators own it),
|
|
15
|
+
* and marks itself busy while the submit is pending. A submit started while
|
|
16
|
+
* one is pending is dropped, so a pressed Enter key cannot send twice.
|
|
17
|
+
*
|
|
18
|
+
* If `onSubmit` rejects, the rejection is caught and shown by `SubmitError`
|
|
19
|
+
* until the next submit. Nothing retries on its own.
|
|
20
|
+
*
|
|
21
|
+
* Use as `form.Form` inside `form.AppForm`.
|
|
22
|
+
*/
|
|
23
|
+
function Form({ children, ...props }) {
|
|
24
|
+
const form = useFormContext();
|
|
25
|
+
const isSubmitting = useStore(form.store, (state) => state.isSubmitting);
|
|
26
|
+
const [failure, setFailure] = useState(null);
|
|
27
|
+
const handleSubmit = (event) => {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
event.stopPropagation();
|
|
30
|
+
if (form.state.isSubmitting) return;
|
|
31
|
+
setFailure(null);
|
|
32
|
+
form.handleSubmit().catch((error) => setFailure({ error }));
|
|
33
|
+
};
|
|
34
|
+
return /* @__PURE__ */ jsx(SubmitFailureContext, {
|
|
35
|
+
value: failure,
|
|
36
|
+
children: /* @__PURE__ */ jsx("form", {
|
|
37
|
+
...props,
|
|
38
|
+
"data-slot": "form-kit-form",
|
|
39
|
+
noValidate: true,
|
|
40
|
+
"aria-busy": isSubmitting || void 0,
|
|
41
|
+
onSubmit: handleSubmit,
|
|
42
|
+
children
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The submit button of an app form. While the submit is pending it is
|
|
48
|
+
* disabled (it keeps focus) and shows a spinner. Use as `form.SubmitButton`
|
|
49
|
+
* inside `form.AppForm`.
|
|
50
|
+
*/
|
|
51
|
+
function SubmitButton({ children, pendingLabel, disabled, ...props }) {
|
|
52
|
+
const form = useFormContext();
|
|
53
|
+
const isSubmitting = useStore(form.store, (state) => state.isSubmitting);
|
|
54
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
55
|
+
...props,
|
|
56
|
+
type: "submit",
|
|
57
|
+
disabled: disabled || isSubmitting,
|
|
58
|
+
focusableWhenDisabled: true,
|
|
59
|
+
children: [isSubmitting ? /* @__PURE__ */ jsx(Spinner, {
|
|
60
|
+
"data-icon": "inline-start",
|
|
61
|
+
"aria-hidden": "true"
|
|
62
|
+
}) : null, isSubmitting && pendingLabel ? pendingLabel : children]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The submit failure of an app form, as a destructive alert announced to
|
|
67
|
+
* assistive technology. It renders nothing while there is no failure. Use as
|
|
68
|
+
* `form.SubmitError` inside `form.Form`, usually just above the actions.
|
|
69
|
+
*/
|
|
70
|
+
function SubmitError({ error, title = "Could not submit", fallbackMessage = "Something went wrong. Try again.", ...props }) {
|
|
71
|
+
const failure = useContext(SubmitFailureContext);
|
|
72
|
+
const caught = failure ? failure.error instanceof Error && failure.error.message ? failure.error.message : fallbackMessage : null;
|
|
73
|
+
const message = error ?? caught;
|
|
74
|
+
if (!message) return null;
|
|
75
|
+
return /* @__PURE__ */ jsxs(Alert, {
|
|
76
|
+
...props,
|
|
77
|
+
"data-slot": "form-kit-submit-error",
|
|
78
|
+
variant: "destructive",
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ jsx(CircleAlertIcon, { "aria-hidden": "true" }),
|
|
81
|
+
/* @__PURE__ */ jsx(AlertTitle, { children: title }),
|
|
82
|
+
/* @__PURE__ */ jsx(AlertDescription, { children: message })
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* The Form kit: TanStack Form's `createFormHook` bound to shadcn's `field`
|
|
88
|
+
* components, following shadcn's TanStack Form guide. App code writes one
|
|
89
|
+
* line per field:
|
|
90
|
+
*
|
|
91
|
+
* ```tsx
|
|
92
|
+
* const form = useAppForm({ defaultValues, validators: { onSubmit: schema }, onSubmit });
|
|
93
|
+
* <form.AppForm>
|
|
94
|
+
* <form.Form>
|
|
95
|
+
* <form.AppField name="subject">{(field) => <field.TextField label="Subject" />}</form.AppField>
|
|
96
|
+
* <form.SubmitError />
|
|
97
|
+
* <form.SubmitButton>Save</form.SubmitButton>
|
|
98
|
+
* </form.Form>
|
|
99
|
+
* </form.AppForm>
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
const { useAppForm, withForm, withFieldGroup } = createFormHook({
|
|
103
|
+
fieldContext,
|
|
104
|
+
formContext,
|
|
105
|
+
fieldComponents: {
|
|
106
|
+
TextField,
|
|
107
|
+
TextareaField,
|
|
108
|
+
SelectField,
|
|
109
|
+
CheckboxField,
|
|
110
|
+
SwitchField
|
|
111
|
+
},
|
|
112
|
+
formComponents: {
|
|
113
|
+
Form,
|
|
114
|
+
SubmitButton,
|
|
115
|
+
SubmitError
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
//#endregion
|
|
119
|
+
export { Form, SubmitButton, SubmitError, useAppForm, withFieldGroup, withForm };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { SheetContent } from "../../components/ui/sheet.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
//#region src/compositions/inspector/inspector.d.ts
|
|
4
|
+
export interface InspectorSection {
|
|
5
|
+
/** Stable key. Defaults to `label`. */
|
|
6
|
+
id?: string;
|
|
7
|
+
/** The section's heading. */
|
|
8
|
+
label: string;
|
|
9
|
+
content: React.ReactNode;
|
|
10
|
+
}
|
|
11
|
+
export interface InspectorProps {
|
|
12
|
+
/** Whether the sheet is open. The app owns this state. */
|
|
13
|
+
open: boolean;
|
|
14
|
+
/** Called when the sheet asks to close (Escape, the close button, the backdrop). */
|
|
15
|
+
onOpenChange: (open: boolean) => void;
|
|
16
|
+
/** What is being inspected, for example the row's subject. It names the sheet. */
|
|
17
|
+
title: React.ReactNode;
|
|
18
|
+
/** A supporting line under the title. */
|
|
19
|
+
description?: React.ReactNode;
|
|
20
|
+
/** The details, one headed section each, in display order. */
|
|
21
|
+
sections: readonly InspectorSection[];
|
|
22
|
+
/** Actions pinned to the bottom of the sheet, for example buttons. */
|
|
23
|
+
footer?: React.ReactNode;
|
|
24
|
+
/** Which edge the sheet slides in from. */
|
|
25
|
+
side?: "left" | "right";
|
|
26
|
+
/** Show placeholder lines while the details load. */
|
|
27
|
+
isLoading?: boolean;
|
|
28
|
+
/** Plain-text load error, shown in place of the sections. */
|
|
29
|
+
error?: string;
|
|
30
|
+
/** Offer a retry next to `error`. Retrying is the owner's action. */
|
|
31
|
+
onRetry?: () => void;
|
|
32
|
+
/** Text shown when there are no sections. */
|
|
33
|
+
emptyLabel?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Where focus goes when the sheet opens. Defaults to the sheet itself, so a
|
|
36
|
+
* screen reader announces the title and the first Tab reaches the first
|
|
37
|
+
* control, instead of focus landing in a field the owner did not choose.
|
|
38
|
+
*/
|
|
39
|
+
initialFocus?: React.ComponentProps<typeof SheetContent>["initialFocus"];
|
|
40
|
+
/**
|
|
41
|
+
* Where focus goes once the sheet closes. Defaults to the element focused
|
|
42
|
+
* before it opened, such as the row that opened it.
|
|
43
|
+
*/
|
|
44
|
+
finalFocus?: React.ComponentProps<typeof SheetContent>["finalFocus"];
|
|
45
|
+
className?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* A side sheet with the details of one row: a title, headed sections and
|
|
49
|
+
* footer actions. While open it is modal: focus stays inside it, and Escape
|
|
50
|
+
* closes it and returns focus to where it was.
|
|
51
|
+
*/
|
|
52
|
+
export declare function Inspector({ open, onOpenChange, title, description, sections, footer, side, isLoading, error, onRetry, emptyLabel, initialFocus, finalFocus, className }: InspectorProps): React.JSX.Element;
|
|
53
|
+
//#endregion
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Separator } from "../../components/ui/separator.js";
|
|
2
|
+
import { ScrollArea } from "../../components/ui/scroll-area.js";
|
|
3
|
+
import { Sheet, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle } from "../../components/ui/sheet.js";
|
|
4
|
+
import { EmptyState, ErrorState, Loading } from "../state-blocks/state-blocks.js";
|
|
5
|
+
import * as React from "react";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { cn } from "cn";
|
|
8
|
+
//#region src/compositions/inspector/inspector.tsx
|
|
9
|
+
/**
|
|
10
|
+
* A side sheet with the details of one row: a title, headed sections and
|
|
11
|
+
* footer actions. While open it is modal: focus stays inside it, and Escape
|
|
12
|
+
* closes it and returns focus to where it was.
|
|
13
|
+
*/
|
|
14
|
+
function Inspector({ open, onOpenChange, title, description, sections, footer, side = "right", isLoading = false, error, onRetry, emptyLabel = "No details", initialFocus, finalFocus, className }) {
|
|
15
|
+
const baseId = React.useId();
|
|
16
|
+
const popupRef = React.useRef(null);
|
|
17
|
+
const showSections = !isLoading && !error && sections.length > 0;
|
|
18
|
+
return /* @__PURE__ */ jsx(Sheet, {
|
|
19
|
+
open,
|
|
20
|
+
onOpenChange,
|
|
21
|
+
children: /* @__PURE__ */ jsxs(SheetContent, {
|
|
22
|
+
side,
|
|
23
|
+
"data-slot": "inspector",
|
|
24
|
+
"aria-busy": isLoading || void 0,
|
|
25
|
+
ref: popupRef,
|
|
26
|
+
initialFocus: initialFocus ?? popupRef,
|
|
27
|
+
finalFocus,
|
|
28
|
+
className: cn("gap-0 outline-none data-[side=left]:w-full data-[side=right]:w-full data-[side=left]:sm:max-w-md data-[side=right]:sm:max-w-md", className),
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ jsxs(SheetHeader, {
|
|
31
|
+
className: "border-b p-4 pr-12",
|
|
32
|
+
children: [/* @__PURE__ */ jsx(SheetTitle, { children: title }), description ? /* @__PURE__ */ jsx(SheetDescription, { children: description }) : null]
|
|
33
|
+
}),
|
|
34
|
+
/* @__PURE__ */ jsx(ScrollArea, {
|
|
35
|
+
"data-slot": "inspector-body",
|
|
36
|
+
className: "min-h-0 flex-1",
|
|
37
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
38
|
+
className: "flex flex-col gap-4 p-4",
|
|
39
|
+
children: [
|
|
40
|
+
isLoading ? /* @__PURE__ */ jsx(Loading, {
|
|
41
|
+
label: "Loading details",
|
|
42
|
+
variant: "text",
|
|
43
|
+
rows: 6
|
|
44
|
+
}) : null,
|
|
45
|
+
!isLoading && error ? /* @__PURE__ */ jsx(ErrorState, {
|
|
46
|
+
title: error,
|
|
47
|
+
onRetry
|
|
48
|
+
}) : null,
|
|
49
|
+
!isLoading && !error && sections.length === 0 ? /* @__PURE__ */ jsx(EmptyState, { title: emptyLabel }) : null,
|
|
50
|
+
showSections ? sections.map((section, index) => {
|
|
51
|
+
const key = section.id ?? section.label;
|
|
52
|
+
const headingId = `${baseId}-section-${index}`;
|
|
53
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [index > 0 ? /* @__PURE__ */ jsx(Separator, {}) : null, /* @__PURE__ */ jsxs("section", {
|
|
54
|
+
"aria-labelledby": headingId,
|
|
55
|
+
"data-slot": "inspector-section",
|
|
56
|
+
className: "flex flex-col gap-2",
|
|
57
|
+
children: [/* @__PURE__ */ jsx("h3", {
|
|
58
|
+
id: headingId,
|
|
59
|
+
className: "font-heading text-xs font-medium text-muted-foreground",
|
|
60
|
+
children: section.label
|
|
61
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
62
|
+
className: "text-xs/relaxed text-foreground",
|
|
63
|
+
children: section.content
|
|
64
|
+
})]
|
|
65
|
+
})] }, key);
|
|
66
|
+
}) : null
|
|
67
|
+
]
|
|
68
|
+
})
|
|
69
|
+
}),
|
|
70
|
+
footer ? /* @__PURE__ */ jsx(SheetFooter, {
|
|
71
|
+
"data-slot": "inspector-footer",
|
|
72
|
+
className: "mt-0 flex-row flex-wrap justify-end border-t p-4",
|
|
73
|
+
children: footer
|
|
74
|
+
}) : null
|
|
75
|
+
]
|
|
76
|
+
})
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { Inspector };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
2
|
+
//#region src/compositions/layout.d.ts
|
|
3
|
+
export interface PageProps extends Omit<ComponentProps<"main">, "title"> {
|
|
4
|
+
readonly actions?: ReactNode;
|
|
5
|
+
readonly backLink?: {
|
|
6
|
+
readonly href: string;
|
|
7
|
+
readonly label: string;
|
|
8
|
+
readonly onClick?: ComponentProps<"a">["onClick"];
|
|
9
|
+
};
|
|
10
|
+
readonly subtitle?: ReactNode;
|
|
11
|
+
readonly title: ReactNode;
|
|
12
|
+
readonly titleMetadata?: ReactNode;
|
|
13
|
+
}
|
|
14
|
+
export declare function Page({ actions, backLink, children, className, subtitle, title, titleMetadata, ...props }: PageProps): ReactElement;
|
|
15
|
+
export interface SectionProps extends Omit<ComponentProps<"section">, "title"> {
|
|
16
|
+
readonly actions?: ReactNode;
|
|
17
|
+
readonly title?: ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export declare function Section({ actions, children, className, title, ...props }: SectionProps): ReactElement;
|
|
20
|
+
export type LayoutGap = "none" | "small" | "default" | "large";
|
|
21
|
+
export interface StackProps extends ComponentProps<"div"> {
|
|
22
|
+
readonly align?: "start" | "center" | "end" | "stretch";
|
|
23
|
+
readonly direction?: "horizontal" | "vertical";
|
|
24
|
+
readonly gap?: LayoutGap;
|
|
25
|
+
readonly justify?: "start" | "center" | "end" | "between";
|
|
26
|
+
readonly wrap?: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function Stack({ align, className, direction, gap, justify, style, wrap, ...props }: StackProps): ReactElement;
|
|
29
|
+
export interface GridProps extends ComponentProps<"div"> {
|
|
30
|
+
readonly columns?: 1 | 2 | 3 | 4;
|
|
31
|
+
readonly gap?: LayoutGap;
|
|
32
|
+
}
|
|
33
|
+
export declare function Grid({ className, columns, gap, style, ...props }: GridProps): ReactElement;
|
|
34
|
+
export interface LinkProps extends ComponentProps<"a"> {}
|
|
35
|
+
export declare function Link({ className, ...props }: LinkProps): ReactElement;
|
|
36
|
+
//#endregion
|