@adea-ai/ui 0.152.4 → 0.154.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/README.md +469 -580
- package/dist/NOTICE +10 -1
- package/dist/components/composites/account-menu/account-menu.d.ts +5 -0
- package/dist/components/composites/account-menu/account-menu.d.ts.map +1 -1
- package/dist/components/composites/account-menu/account-menu.js +37 -13
- package/dist/components/composites/account-menu/account-menu.js.map +1 -1
- package/dist/components/composites/action-button/action-button.d.ts +2 -1
- package/dist/components/composites/action-button/action-button.d.ts.map +1 -1
- package/dist/components/composites/action-button/action-button.js +92 -66
- package/dist/components/composites/action-button/action-button.js.map +1 -1
- package/dist/components/composites/appearance-editor/accent-swatch-groups.d.ts +3 -3
- package/dist/components/composites/appearance-editor/accent-swatch-groups.js +1 -1
- package/dist/components/composites/appearance-editor/accent-swatch-groups.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-choices.d.ts +1 -1
- package/dist/components/composites/appearance-editor/appearance-choices.js +1 -1
- package/dist/components/composites/appearance-editor/appearance-choices.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-editor.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-editor.js +57 -57
- package/dist/components/composites/appearance-editor/appearance-editor.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-rows.d.ts.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-rows.js +9 -9
- package/dist/components/composites/appearance-editor/appearance-rows.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-types.d.ts +7 -7
- package/dist/components/composites/appearance-editor/theme-preview.d.ts +1 -1
- package/dist/components/composites/appearance-editor/theme-preview.js +1 -1
- package/dist/components/composites/appearance-editor/theme-preview.js.map +1 -1
- package/dist/components/composites/catalog-browser/catalog-browser.d.ts.map +1 -1
- package/dist/components/composites/catalog-browser/catalog-browser.js +6 -10
- package/dist/components/composites/catalog-browser/catalog-browser.js.map +1 -1
- package/dist/components/composites/catalog-browser/catalog-detail.d.ts.map +1 -1
- package/dist/components/composites/catalog-browser/catalog-detail.js +36 -36
- package/dist/components/composites/catalog-browser/catalog-detail.js.map +1 -1
- package/dist/components/composites/chain-of-thought/chain-of-thought.d.ts +4 -4
- package/dist/components/composites/chain-of-thought/chain-of-thought.js.map +1 -1
- package/dist/components/composites/chat/chat.d.ts.map +1 -1
- package/dist/components/composites/chat/chat.js +33 -37
- package/dist/components/composites/chat/chat.js.map +1 -1
- package/dist/components/composites/checkpoint/checkpoint-model.d.ts +3 -3
- package/dist/components/composites/checkpoint/checkpoint-model.js +2 -2
- package/dist/components/composites/checkpoint/checkpoint-model.js.map +1 -1
- package/dist/components/composites/checkpoint/checkpoint.d.ts +2 -2
- package/dist/components/composites/checkpoint/checkpoint.js.map +1 -1
- package/dist/components/composites/confirmation/confirmation.d.ts.map +1 -1
- package/dist/components/composites/confirmation/confirmation.js +1 -1
- package/dist/components/composites/confirmation/confirmation.js.map +1 -1
- package/dist/components/composites/context/context.d.ts +2 -2
- package/dist/components/composites/context/context.js.map +1 -1
- package/dist/components/composites/file-tree/build-file-tree.d.ts +1 -1
- package/dist/components/composites/file-tree/build-file-tree.js +1 -1
- package/dist/components/composites/file-tree/build-file-tree.js.map +1 -1
- package/dist/components/composites/file-tree/file-tree.d.ts.map +1 -1
- package/dist/components/composites/file-tree/file-tree.js +7 -3
- package/dist/components/composites/file-tree/file-tree.js.map +1 -1
- package/dist/components/composites/icon-picker/icon-picker.js +1 -3
- package/dist/components/composites/icon-picker/icon-picker.js.map +1 -1
- package/dist/components/composites/inline-citation/citation.d.ts +1 -1
- package/dist/components/composites/inline-citation/citation.js +1 -1
- package/dist/components/composites/inline-citation/citation.js.map +1 -1
- package/dist/components/composites/inline-citation/inline-citation.d.ts +2 -2
- package/dist/components/composites/inline-citation/inline-citation.js.map +1 -1
- package/dist/components/composites/list-row/list-row-control.d.ts.map +1 -1
- package/dist/components/composites/list-row/list-row-control.js +22 -22
- package/dist/components/composites/list-row/list-row-control.js.map +1 -1
- package/dist/components/composites/list-row/list-row.d.ts +5 -0
- package/dist/components/composites/list-row/list-row.d.ts.map +1 -1
- package/dist/components/composites/list-row/list-row.js +75 -83
- package/dist/components/composites/list-row/list-row.js.map +1 -1
- package/dist/components/composites/message-scroller/message-scroller.d.ts +1 -1
- package/dist/components/composites/message-scroller/message-scroller.js.map +1 -1
- package/dist/components/composites/model-selector/model-selector.d.ts +19 -5
- package/dist/components/composites/model-selector/model-selector.d.ts.map +1 -1
- package/dist/components/composites/model-selector/model-selector.js +263 -29
- package/dist/components/composites/model-selector/model-selector.js.map +1 -1
- package/dist/components/composites/model-selector/models.d.ts +2 -2
- package/dist/components/composites/model-selector/models.js +1 -1
- package/dist/components/composites/model-selector/models.js.map +1 -1
- package/dist/components/composites/plan/plan.d.ts.map +1 -1
- package/dist/components/composites/plan/plan.js +17 -15
- package/dist/components/composites/plan/plan.js.map +1 -1
- package/dist/components/composites/queue/queue.d.ts.map +1 -1
- package/dist/components/composites/queue/queue.js +5 -7
- package/dist/components/composites/queue/queue.js.map +1 -1
- package/dist/components/composites/reasoning/reasoning.d.ts +4 -4
- package/dist/components/composites/reasoning/reasoning.js +4 -4
- package/dist/components/composites/reasoning/reasoning.js.map +1 -1
- package/dist/components/composites/settings/settings-navigation.d.ts.map +1 -1
- package/dist/components/composites/settings/settings-navigation.js +63 -14
- package/dist/components/composites/settings/settings-navigation.js.map +1 -1
- package/dist/components/composites/settings/settings.d.ts.map +1 -1
- package/dist/components/composites/settings/settings.js +32 -32
- package/dist/components/composites/settings/settings.js.map +1 -1
- package/dist/components/composites/sources/source.d.ts +1 -1
- package/dist/components/composites/sources/source.js.map +1 -1
- package/dist/components/composites/sources/sources.d.ts +2 -2
- package/dist/components/composites/sources/sources.js.map +1 -1
- package/dist/components/composites/stack-trace/parse-stack-trace.d.ts +3 -3
- package/dist/components/composites/stack-trace/parse-stack-trace.js +4 -4
- package/dist/components/composites/stack-trace/parse-stack-trace.js.map +1 -1
- package/dist/components/composites/stack-trace/stack-trace.d.ts +3 -3
- package/dist/components/composites/stack-trace/stack-trace.js.map +1 -1
- package/dist/components/composites/stat/stat.d.ts.map +1 -1
- package/dist/components/composites/stat/stat.js +14 -16
- package/dist/components/composites/stat/stat.js.map +1 -1
- package/dist/components/composites/subagent/subagent.d.ts.map +1 -1
- package/dist/components/composites/subagent/subagent.js +6 -4
- package/dist/components/composites/subagent/subagent.js.map +1 -1
- package/dist/components/composites/task/task.d.ts +1 -1
- package/dist/components/composites/task/task.js.map +1 -1
- package/dist/components/composites/terminal/ansi.d.ts +3 -3
- package/dist/components/composites/terminal/ansi.js.map +1 -1
- package/dist/components/composites/terminal/terminal-model.d.ts +3 -3
- package/dist/components/composites/terminal/terminal-model.d.ts.map +1 -1
- package/dist/components/composites/terminal/terminal-model.js +1 -1
- package/dist/components/composites/terminal/terminal-model.js.map +1 -1
- package/dist/components/composites/terminal/terminal.d.ts.map +1 -1
- package/dist/components/composites/terminal/terminal.js +24 -11
- package/dist/components/composites/terminal/terminal.js.map +1 -1
- package/dist/components/composites/test-results/test-results-model.d.ts +4 -4
- package/dist/components/composites/test-results/test-results-model.js +2 -2
- package/dist/components/composites/test-results/test-results-model.js.map +1 -1
- package/dist/components/composites/test-results/test-results.d.ts +1 -1
- package/dist/components/composites/test-results/test-results.js.map +1 -1
- package/dist/components/composites/tool/tool.d.ts +4 -4
- package/dist/components/composites/tool/tool.js.map +1 -1
- package/dist/components/composites/tree/tree.d.ts +1 -1
- package/dist/components/composites/tree/tree.d.ts.map +1 -1
- package/dist/components/composites/tree/tree.js +25 -18
- package/dist/components/composites/tree/tree.js.map +1 -1
- package/dist/components/composites/update-dialog/channel-control.d.ts +10 -4
- package/dist/components/composites/update-dialog/channel-control.d.ts.map +1 -1
- package/dist/components/composites/update-dialog/channel-control.js +14 -19
- package/dist/components/composites/update-dialog/channel-control.js.map +1 -1
- package/dist/components/composites/update-dialog/index.d.ts +1 -1
- package/dist/components/composites/update-dialog/index.d.ts.map +1 -1
- package/dist/components/composites/update-dialog/update-dialog.js +4 -5
- package/dist/components/composites/update-dialog/update-dialog.js.map +1 -1
- package/dist/components/composites/workspace-mark/workspace-mark.d.ts.map +1 -1
- package/dist/components/composites/workspace-mark/workspace-mark.js +19 -20
- package/dist/components/composites/workspace-mark/workspace-mark.js.map +1 -1
- package/dist/components/conversation/busy-send-button.d.ts.map +1 -1
- package/dist/components/conversation/busy-send-button.js +18 -20
- package/dist/components/conversation/busy-send-button.js.map +1 -1
- package/dist/components/conversation/composer-menu.d.ts +3 -3
- package/dist/components/conversation/composer-menu.js +3 -3
- package/dist/components/conversation/composer-menu.js.map +1 -1
- package/dist/components/conversation/conversation-avatar.js +2 -4
- package/dist/components/conversation/conversation-avatar.js.map +1 -1
- package/dist/components/conversation/conversation-pane.d.ts.map +1 -1
- package/dist/components/conversation/conversation-pane.js +6 -5
- package/dist/components/conversation/conversation-pane.js.map +1 -1
- package/dist/components/conversation/conversation-surface.js +3 -7
- package/dist/components/conversation/conversation-surface.js.map +1 -1
- package/dist/components/conversation/internal/chat-composer-shell.d.ts.map +1 -1
- package/dist/components/conversation/internal/chat-composer-shell.js +76 -76
- package/dist/components/conversation/internal/chat-composer-shell.js.map +1 -1
- package/dist/components/conversation/message-composer.d.ts.map +1 -1
- package/dist/components/conversation/message-composer.js +32 -38
- package/dist/components/conversation/message-composer.js.map +1 -1
- package/dist/components/conversation/message-row.d.ts.map +1 -1
- package/dist/components/conversation/message-row.js +79 -73
- package/dist/components/conversation/message-row.js.map +1 -1
- package/dist/components/conversation/scroll-follow-core.d.ts +7 -7
- package/dist/components/conversation/scroll-follow-core.js +4 -4
- package/dist/components/conversation/scroll-follow-core.js.map +1 -1
- package/dist/components/conversation/scroll-follow.d.ts.map +1 -1
- package/dist/components/conversation/scroll-follow.js +19 -4
- package/dist/components/conversation/scroll-follow.js.map +1 -1
- package/dist/components/conversation/thread-panel.d.ts.map +1 -1
- package/dist/components/conversation/thread-panel.js +23 -23
- package/dist/components/conversation/thread-panel.js.map +1 -1
- package/dist/components/conversation/transcript-composition.d.ts.map +1 -1
- package/dist/components/conversation/transcript-composition.js +2 -2
- package/dist/components/conversation/transcript-composition.js.map +1 -1
- package/dist/components/layout/app-shell/app-shell.d.ts +1 -1
- package/dist/components/layout/app-shell/app-shell.js +1 -1
- package/dist/components/layout/app-shell/app-shell.js.map +1 -1
- package/dist/components/layout/app-shell/skip-link.d.ts.map +1 -1
- package/dist/components/layout/app-shell/skip-link.js +4 -6
- package/dist/components/layout/app-shell/skip-link.js.map +1 -1
- package/dist/components/layout/page/page.d.ts.map +1 -1
- package/dist/components/layout/page/page.js +17 -17
- package/dist/components/layout/page/page.js.map +1 -1
- package/dist/components/layout/panel/panel.js +2 -4
- package/dist/components/layout/panel/panel.js.map +1 -1
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.d.ts.map +1 -1
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.js +16 -1
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.js.map +1 -1
- package/dist/components/layout/side-rail/side-rail-context.d.ts +1 -1
- package/dist/components/layout/side-rail/side-rail-context.js.map +1 -1
- package/dist/components/layout/side-rail/side-rail.d.ts.map +1 -1
- package/dist/components/layout/side-rail/side-rail.js +62 -57
- package/dist/components/layout/side-rail/side-rail.js.map +1 -1
- package/dist/components/layout/sidebar-nav/sidebar-nav.d.ts.map +1 -1
- package/dist/components/layout/sidebar-nav/sidebar-nav.js +23 -23
- package/dist/components/layout/sidebar-nav/sidebar-nav.js.map +1 -1
- package/dist/components/layout/split-layout/resize-controller-core-retry.d.ts.map +1 -1
- package/dist/components/layout/split-layout/resize-controller-core-retry.js +25 -7
- package/dist/components/layout/split-layout/resize-controller-core-retry.js.map +1 -1
- package/dist/components/layout/split-layout/resize-controller-core.d.ts.map +1 -1
- package/dist/components/layout/split-layout/resize-controller-core.js +25 -7
- package/dist/components/layout/split-layout/resize-controller-core.js.map +1 -1
- package/dist/components/layout/split-layout/split-layout.d.ts.map +1 -1
- package/dist/components/layout/split-layout/split-layout.js +2 -2
- package/dist/components/layout/split-layout/split-layout.js.map +1 -1
- package/dist/components/layout/status-bar/status-bar.d.ts +1 -1
- package/dist/components/layout/status-bar/status-bar.js +1 -1
- package/dist/components/layout/status-bar/status-bar.js.map +1 -1
- package/dist/components/layout/top-bar/top-bar.d.ts.map +1 -1
- package/dist/components/layout/top-bar/top-bar.js +15 -14
- package/dist/components/layout/top-bar/top-bar.js.map +1 -1
- package/dist/components/motion/presence.d.ts +2 -2
- package/dist/components/motion/presence.js.map +1 -1
- package/dist/components/theme/appearance-panel.d.ts +5 -5
- package/dist/components/theme/appearance-panel.js.map +1 -1
- package/dist/components/theme/lazy.d.ts +1 -1
- package/dist/components/theme/lazy.js.map +1 -1
- package/dist/components/theme/theme-catalogue-source.d.ts +2 -2
- package/dist/components/theme/theme-catalogue-source.js +2 -2
- package/dist/components/theme/theme-catalogue-source.js.map +1 -1
- package/dist/components/theme/theme-context.d.ts +2 -2
- package/dist/components/theme/theme-context.js +3 -3
- package/dist/components/theme/theme-context.js.map +1 -1
- package/dist/components/theme/theme-document.d.ts.map +1 -1
- package/dist/components/theme/theme-document.js +14 -9
- package/dist/components/theme/theme-document.js.map +1 -1
- package/dist/components/theme/theme-picker.d.ts +5 -5
- package/dist/components/theme/theme-picker.js.map +1 -1
- package/dist/components/theme/theme-provider-value.d.ts +0 -6
- package/dist/components/theme/theme-provider-value.d.ts.map +1 -1
- package/dist/components/theme/theme-provider-value.js +9 -3
- package/dist/components/theme/theme-provider-value.js.map +1 -1
- package/dist/components/theme/theme-script.d.ts +14 -0
- package/dist/components/theme/theme-script.d.ts.map +1 -1
- package/dist/components/theme/theme-script.js +1 -0
- package/dist/components/theme/theme-script.js.map +1 -1
- package/dist/components/theme/theme-state.d.ts +7 -7
- package/dist/components/theme/theme-state.js.map +1 -1
- package/dist/components/theme/theme-toggle.d.ts +1 -1
- package/dist/components/theme/theme-toggle.js.map +1 -1
- package/dist/components/ui/alert/alert.d.ts.map +1 -1
- package/dist/components/ui/alert/alert.js +4 -3
- package/dist/components/ui/alert/alert.js.map +1 -1
- package/dist/components/ui/alert-dialog/alert-dialog.d.ts +1 -1
- package/dist/components/ui/alert-dialog/alert-dialog.js +3 -3
- package/dist/components/ui/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/ui/badge/badge.d.ts +1 -1
- package/dist/components/ui/badge/badge.js +2 -2
- package/dist/components/ui/badge/badge.js.map +1 -1
- package/dist/components/ui/board/board.d.ts.map +1 -1
- package/dist/components/ui/board/board.js +10 -6
- package/dist/components/ui/board/board.js.map +1 -1
- package/dist/components/ui/bubble/bubble.d.ts.map +1 -1
- package/dist/components/ui/bubble/bubble.js +6 -4
- package/dist/components/ui/bubble/bubble.js.map +1 -1
- package/dist/components/ui/button/button.js +2 -2
- package/dist/components/ui/button/button.js.map +1 -1
- package/dist/components/ui/button-group/button-group.d.ts +1 -1
- package/dist/components/ui/button-group/button-group.js +1 -1
- package/dist/components/ui/button-group/button-group.js.map +1 -1
- package/dist/components/ui/calendar/calendar.js +6 -6
- package/dist/components/ui/calendar/calendar.js.map +1 -1
- package/dist/components/ui/callout/callout.d.ts +4 -4
- package/dist/components/ui/callout/callout.js +4 -4
- package/dist/components/ui/callout/callout.js.map +1 -1
- package/dist/components/ui/card/card.d.ts +2 -2
- package/dist/components/ui/card/card.js +2 -2
- package/dist/components/ui/card/card.js.map +1 -1
- package/dist/components/ui/carousel/carousel.d.ts +4 -4
- package/dist/components/ui/carousel/carousel.d.ts.map +1 -1
- package/dist/components/ui/carousel/carousel.js.map +1 -1
- package/dist/components/ui/chart/chart-options.d.ts +7 -7
- package/dist/components/ui/chart/chart-options.js +9 -9
- package/dist/components/ui/chart/chart-options.js.map +1 -1
- package/dist/components/ui/chart/chart.d.ts.map +1 -1
- package/dist/components/ui/chart/chart.js +16 -7
- package/dist/components/ui/chart/chart.js.map +1 -1
- package/dist/components/ui/checkbox/checkbox.d.ts.map +1 -1
- package/dist/components/ui/checkbox/checkbox.js +8 -6
- package/dist/components/ui/checkbox/checkbox.js.map +1 -1
- package/dist/components/ui/code-block/code-block.d.ts.map +1 -1
- package/dist/components/ui/code-block/code-block.js +8 -6
- package/dist/components/ui/code-block/code-block.js.map +1 -1
- package/dist/components/ui/command/command.d.ts +4 -4
- package/dist/components/ui/command/command.js +4 -4
- package/dist/components/ui/command/command.js.map +1 -1
- package/dist/components/ui/context-menu/context-menu.d.ts +1 -1
- package/dist/components/ui/context-menu/context-menu.js.map +1 -1
- package/dist/components/ui/detail-panel/detail-panel.d.ts.map +1 -1
- package/dist/components/ui/detail-panel/detail-panel.js +13 -13
- package/dist/components/ui/detail-panel/detail-panel.js.map +1 -1
- package/dist/components/ui/dialog/dialog-layer.d.ts +0 -4
- package/dist/components/ui/dialog/dialog-layer.d.ts.map +1 -1
- package/dist/components/ui/dialog/dialog-layer.js +17 -1
- package/dist/components/ui/dialog/dialog-layer.js.map +1 -1
- package/dist/components/ui/dialog/dialog.d.ts.map +1 -1
- package/dist/components/ui/dialog/dialog.js +4 -3
- package/dist/components/ui/dialog/dialog.js.map +1 -1
- package/dist/components/ui/diff-block/diff-block.d.ts +6 -6
- package/dist/components/ui/diff-block/diff-block.js +3 -3
- package/dist/components/ui/diff-block/diff-block.js.map +1 -1
- package/dist/components/ui/drawer/drawer.d.ts +3 -3
- package/dist/components/ui/drawer/drawer.js +2 -2
- package/dist/components/ui/drawer/drawer.js.map +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu.d.ts +5 -5
- package/dist/components/ui/dropdown-menu/dropdown-menu.js +3 -3
- package/dist/components/ui/dropdown-menu/dropdown-menu.js.map +1 -1
- package/dist/components/ui/dropdown-menu/menu-parts.d.ts +3 -3
- package/dist/components/ui/dropdown-menu/menu-parts.js +1 -1
- package/dist/components/ui/dropdown-menu/menu-parts.js.map +1 -1
- package/dist/components/ui/empty/empty-state.d.ts.map +1 -1
- package/dist/components/ui/empty/empty-state.js +33 -36
- package/dist/components/ui/empty/empty-state.js.map +1 -1
- package/dist/components/ui/empty/empty.d.ts +1 -1
- package/dist/components/ui/empty/empty.js +1 -1
- package/dist/components/ui/empty/empty.js.map +1 -1
- package/dist/components/ui/entity-icon/entity-icon.d.ts.map +1 -1
- package/dist/components/ui/entity-icon/entity-icon.js +7 -7
- package/dist/components/ui/entity-icon/entity-icon.js.map +1 -1
- package/dist/components/ui/field/field.d.ts.map +1 -1
- package/dist/components/ui/field/field.js +15 -15
- package/dist/components/ui/field/field.js.map +1 -1
- package/dist/components/ui/field/number-field.d.ts +1 -1
- package/dist/components/ui/field/number-field.js +1 -1
- package/dist/components/ui/field/number-field.js.map +1 -1
- package/dist/components/ui/hover-card/hover-card.d.ts +1 -1
- package/dist/components/ui/hover-card/hover-card.js.map +1 -1
- package/dist/components/ui/input-group/input-group.d.ts +1 -1
- package/dist/components/ui/input-group/input-group.js.map +1 -1
- package/dist/components/ui/input-otp/input-otp.d.ts +1 -1
- package/dist/components/ui/input-otp/input-otp.js.map +1 -1
- package/dist/components/ui/item/item.d.ts.map +1 -1
- package/dist/components/ui/item/item.js +26 -26
- package/dist/components/ui/item/item.js.map +1 -1
- package/dist/components/ui/kbd/kbd.d.ts +25 -12
- package/dist/components/ui/kbd/kbd.d.ts.map +1 -1
- package/dist/components/ui/kbd/kbd.js +44 -13
- package/dist/components/ui/kbd/kbd.js.map +1 -1
- package/dist/components/ui/kbd/platform-modifier.d.ts +3 -3
- package/dist/components/ui/kbd/platform-modifier.js +3 -3
- package/dist/components/ui/kbd/platform-modifier.js.map +1 -1
- package/dist/components/ui/label/label.d.ts +1 -1
- package/dist/components/ui/label/label.js +1 -1
- package/dist/components/ui/label/label.js.map +1 -1
- package/dist/components/ui/marker/marker.d.ts.map +1 -1
- package/dist/components/ui/marker/marker.js +17 -19
- package/dist/components/ui/marker/marker.js.map +1 -1
- package/dist/components/ui/menubar/menubar.d.ts +2 -2
- package/dist/components/ui/menubar/menubar.js +1 -1
- package/dist/components/ui/menubar/menubar.js.map +1 -1
- package/dist/components/ui/message/message.d.ts.map +1 -1
- package/dist/components/ui/message/message.js +16 -18
- package/dist/components/ui/message/message.js.map +1 -1
- package/dist/components/ui/modal-dialog/modal-dialog.d.ts.map +1 -1
- package/dist/components/ui/modal-dialog/modal-dialog.js +7 -11
- package/dist/components/ui/modal-dialog/modal-dialog.js.map +1 -1
- package/dist/components/ui/native-select/native-select.d.ts +1 -1
- package/dist/components/ui/native-select/native-select.js.map +1 -1
- package/dist/components/ui/navigation-menu/navigation-menu.d.ts.map +1 -1
- package/dist/components/ui/navigation-menu/navigation-menu.js +5 -4
- package/dist/components/ui/navigation-menu/navigation-menu.js.map +1 -1
- package/dist/components/ui/pagination/pagination.js +2 -4
- package/dist/components/ui/pagination/pagination.js.map +1 -1
- package/dist/components/ui/popover/popover.d.ts.map +1 -1
- package/dist/components/ui/popover/popover.js +11 -4
- package/dist/components/ui/popover/popover.js.map +1 -1
- package/dist/components/ui/progress/progress.d.ts.map +1 -1
- package/dist/components/ui/progress/progress.js +6 -8
- package/dist/components/ui/progress/progress.js.map +1 -1
- package/dist/components/ui/questionnaire/questionnaire.d.ts.map +1 -1
- package/dist/components/ui/questionnaire/questionnaire.js +73 -73
- package/dist/components/ui/questionnaire/questionnaire.js.map +1 -1
- package/dist/components/ui/radio-group/radio-group.d.ts.map +1 -1
- package/dist/components/ui/radio-group/radio-group.js +12 -6
- package/dist/components/ui/radio-group/radio-group.js.map +1 -1
- package/dist/components/ui/resizable/resizable.d.ts +2 -2
- package/dist/components/ui/resizable/resizable.js +3 -3
- package/dist/components/ui/resizable/resizable.js.map +1 -1
- package/dist/components/ui/select/select.d.ts +3 -3
- package/dist/components/ui/select/select.js +1 -1
- package/dist/components/ui/select/select.js.map +1 -1
- package/dist/components/ui/sheet/sheet.d.ts.map +1 -1
- package/dist/components/ui/sheet/sheet.js +4 -3
- package/dist/components/ui/sheet/sheet.js.map +1 -1
- package/dist/components/ui/skeleton/skeleton.d.ts +1 -1
- package/dist/components/ui/skeleton/skeleton.js +1 -1
- package/dist/components/ui/skeleton/skeleton.js.map +1 -1
- package/dist/components/ui/slider/slider.d.ts +1 -1
- package/dist/components/ui/slider/slider.js.map +1 -1
- package/dist/components/ui/spinner/spinner.d.ts +1 -1
- package/dist/components/ui/spinner/spinner.js +1 -1
- package/dist/components/ui/spinner/spinner.js.map +1 -1
- package/dist/components/ui/status-chip/status-chip.d.ts +13 -13
- package/dist/components/ui/status-chip/status-chip.d.ts.map +1 -1
- package/dist/components/ui/status-chip/status-chip.js +11 -11
- package/dist/components/ui/status-chip/status-chip.js.map +1 -1
- package/dist/components/ui/switch/switch.d.ts.map +1 -1
- package/dist/components/ui/switch/switch.js +8 -6
- package/dist/components/ui/switch/switch.js.map +1 -1
- package/dist/components/ui/tabs/tabs.d.ts +4 -4
- package/dist/components/ui/tabs/tabs.js +4 -4
- package/dist/components/ui/tabs/tabs.js.map +1 -1
- package/dist/components/ui/textarea/textarea.d.ts +1 -1
- package/dist/components/ui/textarea/textarea.js +1 -1
- package/dist/components/ui/textarea/textarea.js.map +1 -1
- package/dist/components/ui/toast/toast.d.ts.map +1 -1
- package/dist/components/ui/toast/toast.js +13 -15
- package/dist/components/ui/toast/toast.js.map +1 -1
- package/dist/components/ui/toggle/toggle.d.ts +1 -1
- package/dist/components/ui/toggle/toggle.js +1 -1
- package/dist/components/ui/toggle/toggle.js.map +1 -1
- package/dist/components/ui/tooltip/deferred-tooltip.d.ts +51 -0
- package/dist/components/ui/tooltip/deferred-tooltip.d.ts.map +1 -0
- package/dist/components/ui/tooltip/deferred-tooltip.js +103 -0
- package/dist/components/ui/tooltip/deferred-tooltip.js.map +1 -0
- package/dist/components/ui/tooltip/index.d.ts +1 -0
- package/dist/components/ui/tooltip/index.d.ts.map +1 -1
- package/dist/components/ui/tooltip/index.js +3 -1
- package/dist/components/ui/tooltip/tooltip.d.ts.map +1 -1
- package/dist/components/ui/tooltip/tooltip.js +6 -5
- package/dist/components/ui/tooltip/tooltip.js.map +1 -1
- package/dist/components/ui/trace/trace.d.ts.map +1 -1
- package/dist/components/ui/trace/trace.js +17 -17
- package/dist/components/ui/trace/trace.js.map +1 -1
- package/dist/components/ui/typography/typography.d.ts +3 -3
- package/dist/components/ui/typography/typography.js +5 -5
- package/dist/components/ui/typography/typography.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/lib/accent-presets.d.ts +1 -1
- package/dist/lib/accent-presets.js.map +1 -1
- package/dist/lib/accent-roles.d.ts +2 -2
- package/dist/lib/accent-roles.js +2 -2
- package/dist/lib/accent-roles.js.map +1 -1
- package/dist/lib/appearance-font-settings.d.ts.map +1 -1
- package/dist/lib/appearance-font-settings.js +15 -7
- package/dist/lib/appearance-font-settings.js.map +1 -1
- package/dist/lib/create-poll.d.ts +39 -0
- package/dist/lib/create-poll.d.ts.map +1 -0
- package/dist/lib/create-poll.js +116 -0
- package/dist/lib/create-poll.js.map +1 -0
- package/dist/lib/font-zoom.d.ts +1 -1
- package/dist/lib/font-zoom.js +1 -1
- package/dist/lib/font-zoom.js.map +1 -1
- package/dist/lib/keyed-rows.d.ts +2 -1
- package/dist/lib/keyed-rows.d.ts.map +1 -1
- package/dist/lib/keyed-rows.js +3 -2
- package/dist/lib/keyed-rows.js.map +1 -1
- package/dist/lib/overlay.d.ts +6 -6
- package/dist/lib/overlay.d.ts.map +1 -1
- package/dist/lib/overlay.js +6 -6
- package/dist/lib/overlay.js.map +1 -1
- package/dist/lib/preference-store.d.ts +2 -2
- package/dist/lib/preference-store.js +2 -2
- package/dist/lib/preference-store.js.map +1 -1
- package/dist/lib/safe-script.d.ts +2 -2
- package/dist/lib/safe-script.js +2 -2
- package/dist/lib/safe-script.js.map +1 -1
- package/dist/lib/scroll-geometry.d.ts +1 -1
- package/dist/lib/scroll-geometry.js +1 -1
- package/dist/lib/scroll-geometry.js.map +1 -1
- package/dist/lib/text.d.ts +1 -1
- package/dist/lib/text.js +1 -1
- package/dist/lib/text.js.map +1 -1
- package/dist/lib/theme-accents.js +3 -3
- package/dist/lib/theme-accents.js.map +1 -1
- package/dist/lib/theme-css.js.map +1 -1
- package/dist/lib/theme-defaults.d.ts +4 -4
- package/dist/lib/theme-defaults.js +4 -4
- package/dist/lib/theme-defaults.js.map +1 -1
- package/dist/lib/theme-engine-light.js.map +1 -1
- package/dist/lib/theme-engine.d.ts +2 -2
- package/dist/lib/theme-engine.js +2 -2
- package/dist/lib/theme-engine.js.map +1 -1
- package/dist/lib/theme-projection.d.ts +1 -1
- package/dist/lib/theme-projection.js +2 -2
- package/dist/lib/theme-projection.js.map +1 -1
- package/dist/lib/theme-records.d.ts +2 -2
- package/dist/lib/theme-records.js +2 -2
- package/dist/lib/theme-records.js.map +1 -1
- package/dist/lib/theme-types.d.ts +1 -1
- package/dist/lib/theme-types.js.map +1 -1
- package/dist/lib/themes.d.ts +13 -13
- package/dist/lib/themes.js +13 -13
- package/dist/lib/themes.js.map +1 -1
- package/dist/lib/tokens.d.ts +2 -2
- package/dist/lib/tokens.js +1 -1
- package/dist/lib/tokens.js.map +1 -1
- package/dist/lib/tooltip-focus-gate.d.ts +2 -2
- package/dist/lib/tooltip-focus-gate.js +2 -2
- package/dist/lib/tooltip-focus-gate.js.map +1 -1
- package/dist/lib/utils.d.ts +1 -1
- package/dist/lib/utils.js +1 -1
- package/dist/lib/utils.js.map +1 -1
- package/dist/lib/variants.d.ts +4 -4
- package/dist/lib/variants.js +1 -1
- package/dist/lib/variants.js.map +1 -1
- package/dist/lib/version-notes.d.ts +4 -4
- package/dist/lib/version-notes.js +4 -4
- package/dist/lib/version-notes.js.map +1 -1
- package/dist/lint.js.map +1 -1
- package/dist/r/account-menu.json +1 -0
- package/dist/r/lib.json +5 -0
- package/dist/r/model-selector.json +1 -0
- package/dist/r/registry.json +14 -0
- package/dist/r/side-rail.json +1 -0
- package/dist/r/src/components/composites/account-menu/account-menu.tsx +22 -2
- package/dist/r/src/components/composites/action-button/action-button.tsx +124 -78
- package/dist/r/src/components/composites/appearance-editor/accent-swatch-groups.tsx +3 -3
- package/dist/r/src/components/composites/appearance-editor/appearance-choices.tsx +3 -3
- package/dist/r/src/components/composites/appearance-editor/appearance-editor.tsx +15 -9
- package/dist/r/src/components/composites/appearance-editor/appearance-rows.tsx +3 -1
- package/dist/r/src/components/composites/appearance-editor/appearance-types.ts +7 -7
- package/dist/r/src/components/composites/appearance-editor/theme-preview.tsx +1 -1
- package/dist/r/src/components/composites/catalog-browser/catalog-browser.tsx +6 -2
- package/dist/r/src/components/composites/catalog-browser/catalog-detail.tsx +15 -6
- package/dist/r/src/components/composites/chain-of-thought/chain-of-thought.tsx +4 -4
- package/dist/r/src/components/composites/chat/chat.tsx +15 -9
- package/dist/r/src/components/composites/checkpoint/checkpoint-model.ts +3 -3
- package/dist/r/src/components/composites/checkpoint/checkpoint.tsx +2 -2
- package/dist/r/src/components/composites/confirmation/confirmation.tsx +8 -4
- package/dist/r/src/components/composites/context/context.tsx +2 -2
- package/dist/r/src/components/composites/file-tree/build-file-tree.ts +1 -1
- package/dist/r/src/components/composites/file-tree/file-tree.tsx +16 -2
- package/dist/r/src/components/composites/icon-picker/icon-picker.tsx +1 -1
- package/dist/r/src/components/composites/inline-citation/citation.ts +1 -1
- package/dist/r/src/components/composites/inline-citation/inline-citation.tsx +2 -2
- package/dist/r/src/components/composites/list-row/list-row-control.tsx +31 -22
- package/dist/r/src/components/composites/list-row/list-row.tsx +69 -73
- package/dist/r/src/components/composites/message-scroller/message-scroller.tsx +1 -1
- package/dist/r/src/components/composites/model-selector/model-selector.tsx +190 -14
- package/dist/r/src/components/composites/model-selector/models.ts +2 -2
- package/dist/r/src/components/composites/plan/plan.tsx +19 -11
- package/dist/r/src/components/composites/queue/queue.tsx +5 -3
- package/dist/r/src/components/composites/reasoning/reasoning.tsx +4 -4
- package/dist/r/src/components/composites/settings/settings-navigation.tsx +57 -17
- package/dist/r/src/components/composites/settings/settings.tsx +14 -6
- package/dist/r/src/components/composites/sources/source.ts +1 -1
- package/dist/r/src/components/composites/sources/sources.tsx +2 -2
- package/dist/r/src/components/composites/stack-trace/parse-stack-trace.ts +7 -7
- package/dist/r/src/components/composites/stack-trace/stack-trace.tsx +3 -3
- package/dist/r/src/components/composites/stat/stat.tsx +20 -16
- package/dist/r/src/components/composites/subagent/subagent.tsx +6 -4
- package/dist/r/src/components/composites/task/task.tsx +1 -1
- package/dist/r/src/components/composites/terminal/ansi.ts +3 -3
- package/dist/r/src/components/composites/terminal/terminal-model.ts +3 -3
- package/dist/r/src/components/composites/terminal/terminal.tsx +24 -12
- package/dist/r/src/components/composites/test-results/test-results-model.ts +4 -4
- package/dist/r/src/components/composites/test-results/test-results.tsx +1 -1
- package/dist/r/src/components/composites/tool/tool.tsx +4 -4
- package/dist/r/src/components/composites/tree/tree.tsx +31 -15
- package/dist/r/src/components/composites/update-dialog/channel-control.tsx +17 -8
- package/dist/r/src/components/composites/update-dialog/index.ts +1 -0
- package/dist/r/src/components/composites/update-dialog/update-dialog.tsx +7 -7
- package/dist/r/src/components/composites/workspace-mark/workspace-mark.tsx +15 -12
- package/dist/r/src/components/conversation/busy-send-button.tsx +6 -2
- package/dist/r/src/components/conversation/composer-menu.tsx +3 -3
- package/dist/r/src/components/conversation/conversation-avatar.tsx +1 -1
- package/dist/r/src/components/conversation/conversation-pane.tsx +8 -5
- package/dist/r/src/components/conversation/conversation-surface.tsx +2 -2
- package/dist/r/src/components/conversation/internal/chat-composer-shell.tsx +18 -12
- package/dist/r/src/components/conversation/message-composer.tsx +4 -6
- package/dist/r/src/components/conversation/message-row.tsx +34 -26
- package/dist/r/src/components/conversation/scroll-follow-core.ts +8 -8
- package/dist/r/src/components/conversation/scroll-follow.ts +24 -8
- package/dist/r/src/components/conversation/thread-panel.tsx +7 -3
- package/dist/r/src/components/conversation/transcript-composition.tsx +4 -2
- package/dist/r/src/components/layout/app-shell/app-shell.tsx +1 -1
- package/dist/r/src/components/layout/app-shell/skip-link.tsx +3 -2
- package/dist/r/src/components/layout/page/page.tsx +15 -11
- package/dist/r/src/components/layout/panel/panel.tsx +1 -1
- package/dist/r/src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx +21 -1
- package/dist/r/src/components/layout/side-rail/side-rail-context.ts +1 -1
- package/dist/r/src/components/layout/side-rail/side-rail.tsx +41 -28
- package/dist/r/src/components/layout/sidebar-nav/sidebar-nav.tsx +22 -16
- package/dist/r/src/components/layout/split-layout/resize-controller-core-retry.tsx +25 -7
- package/dist/r/src/components/layout/split-layout/resize-controller-core.tsx +25 -7
- package/dist/r/src/components/layout/split-layout/split-layout.tsx +6 -2
- package/dist/r/src/components/layout/status-bar/status-bar.tsx +1 -1
- package/dist/r/src/components/layout/top-bar/top-bar.tsx +4 -6
- package/dist/r/src/components/motion/presence.tsx +2 -2
- package/dist/r/src/components/theme/appearance-panel.tsx +5 -5
- package/dist/r/src/components/theme/lazy.ts +1 -1
- package/dist/r/src/components/theme/theme-catalogue-source.ts +2 -2
- package/dist/r/src/components/theme/theme-context.ts +3 -3
- package/dist/r/src/components/theme/theme-document.ts +22 -11
- package/dist/r/src/components/theme/theme-picker.tsx +5 -5
- package/dist/r/src/components/theme/theme-provider-value.ts +15 -3
- package/dist/r/src/components/theme/theme-script.ts +20 -0
- package/dist/r/src/components/theme/theme-state.ts +7 -7
- package/dist/r/src/components/theme/theme-toggle.tsx +1 -1
- package/dist/r/src/components/ui/alert/alert.tsx +4 -3
- package/dist/r/src/components/ui/alert-dialog/alert-dialog.tsx +4 -4
- package/dist/r/src/components/ui/badge/badge.tsx +2 -2
- package/dist/r/src/components/ui/board/board.tsx +17 -5
- package/dist/r/src/components/ui/bubble/bubble.tsx +6 -4
- package/dist/r/src/components/ui/button/button.tsx +2 -2
- package/dist/r/src/components/ui/button-group/button-group.tsx +1 -1
- package/dist/r/src/components/ui/calendar/calendar.tsx +2 -2
- package/dist/r/src/components/ui/callout/callout.tsx +4 -4
- package/dist/r/src/components/ui/card/card.tsx +2 -2
- package/dist/r/src/components/ui/carousel/carousel.tsx +6 -6
- package/dist/r/src/components/ui/chart/chart-options.ts +9 -9
- package/dist/r/src/components/ui/chart/chart.tsx +14 -1
- package/dist/r/src/components/ui/checkbox/checkbox.tsx +9 -6
- package/dist/r/src/components/ui/code-block/code-block.tsx +14 -7
- package/dist/r/src/components/ui/command/command.tsx +7 -7
- package/dist/r/src/components/ui/context-menu/context-menu.tsx +1 -1
- package/dist/r/src/components/ui/detail-panel/detail-panel.tsx +5 -3
- package/dist/r/src/components/ui/dialog/dialog-layer.tsx +25 -1
- package/dist/r/src/components/ui/dialog/dialog.tsx +4 -3
- package/dist/r/src/components/ui/diff-block/diff-block.tsx +6 -6
- package/dist/r/src/components/ui/drawer/drawer.tsx +3 -3
- package/dist/r/src/components/ui/dropdown-menu/dropdown-menu.tsx +6 -6
- package/dist/r/src/components/ui/dropdown-menu/menu-parts.tsx +5 -5
- package/dist/r/src/components/ui/empty/empty-state.tsx +23 -18
- package/dist/r/src/components/ui/empty/empty.tsx +1 -1
- package/dist/r/src/components/ui/entity-icon/entity-icon.tsx +5 -1
- package/dist/r/src/components/ui/field/field.tsx +15 -7
- package/dist/r/src/components/ui/field/number-field.tsx +1 -1
- package/dist/r/src/components/ui/hover-card/hover-card.tsx +1 -1
- package/dist/r/src/components/ui/input-group/input-group.tsx +1 -1
- package/dist/r/src/components/ui/input-otp/input-otp.tsx +1 -1
- package/dist/r/src/components/ui/item/item.tsx +24 -18
- package/dist/r/src/components/ui/kbd/kbd.tsx +55 -14
- package/dist/r/src/components/ui/kbd/platform-modifier.ts +3 -3
- package/dist/r/src/components/ui/label/label.tsx +1 -1
- package/dist/r/src/components/ui/marker/marker.tsx +9 -5
- package/dist/r/src/components/ui/menubar/menubar.tsx +2 -2
- package/dist/r/src/components/ui/message/message.tsx +14 -13
- package/dist/r/src/components/ui/modal-dialog/modal-dialog.tsx +9 -5
- package/dist/r/src/components/ui/native-select/native-select.tsx +1 -1
- package/dist/r/src/components/ui/navigation-menu/navigation-menu.tsx +5 -4
- package/dist/r/src/components/ui/pagination/pagination.tsx +1 -1
- package/dist/r/src/components/ui/popover/popover.tsx +4 -2
- package/dist/r/src/components/ui/progress/progress.tsx +5 -3
- package/dist/r/src/components/ui/questionnaire/questionnaire.tsx +10 -5
- package/dist/r/src/components/ui/radio-group/radio-group.tsx +9 -6
- package/dist/r/src/components/ui/resizable/resizable.tsx +5 -5
- package/dist/r/src/components/ui/select/select.tsx +4 -4
- package/dist/r/src/components/ui/sheet/sheet.tsx +4 -3
- package/dist/r/src/components/ui/skeleton/skeleton.tsx +1 -1
- package/dist/r/src/components/ui/slider/slider.tsx +1 -1
- package/dist/r/src/components/ui/spinner/spinner.tsx +1 -1
- package/dist/r/src/components/ui/status-chip/status-chip.tsx +13 -13
- package/dist/r/src/components/ui/switch/switch.tsx +9 -6
- package/dist/r/src/components/ui/tabs/tabs.tsx +4 -4
- package/dist/r/src/components/ui/textarea/textarea.tsx +1 -1
- package/dist/r/src/components/ui/toast/toast.tsx +6 -4
- package/dist/r/src/components/ui/toggle/toggle.tsx +1 -1
- package/dist/r/src/components/ui/tooltip/deferred-tooltip.tsx +131 -0
- package/dist/r/src/components/ui/tooltip/index.ts +1 -0
- package/dist/r/src/components/ui/tooltip/tooltip.tsx +6 -4
- package/dist/r/src/components/ui/trace/trace.tsx +13 -9
- package/dist/r/src/components/ui/typography/typography.tsx +5 -5
- package/dist/r/src/lib/accent-presets.ts +1 -1
- package/dist/r/src/lib/accent-roles.ts +2 -2
- package/dist/r/src/lib/appearance-font-settings.ts +18 -7
- package/dist/r/src/lib/create-poll.ts +150 -0
- package/dist/r/src/lib/font-zoom.ts +3 -3
- package/dist/r/src/lib/keyed-rows.ts +3 -2
- package/dist/r/src/lib/overlay.ts +6 -6
- package/dist/r/src/lib/preference-store.ts +2 -2
- package/dist/r/src/lib/safe-script.ts +2 -2
- package/dist/r/src/lib/scroll-geometry.ts +1 -1
- package/dist/r/src/lib/text.ts +1 -1
- package/dist/r/src/lib/theme-accents.ts +3 -3
- package/dist/r/src/lib/theme-css.ts +2 -2
- package/dist/r/src/lib/theme-defaults.ts +4 -4
- package/dist/r/src/lib/theme-engine-light.ts +2 -2
- package/dist/r/src/lib/theme-engine.ts +2 -2
- package/dist/r/src/lib/theme-projection.ts +2 -2
- package/dist/r/src/lib/theme-records.ts +2 -2
- package/dist/r/src/lib/theme-types.ts +1 -1
- package/dist/r/src/lib/themes.ts +14 -14
- package/dist/r/src/lib/tokens.ts +2 -2
- package/dist/r/src/lib/tooltip-focus-gate.ts +11 -11
- package/dist/r/src/lib/utils.ts +1 -1
- package/dist/r/src/lib/variants.ts +4 -4
- package/dist/r/src/lib/version-notes.ts +4 -4
- package/dist/r/src/styles/base.css +12 -43
- package/dist/r/src/styles/fonts.css +1 -1
- package/dist/r/src/styles/theme.css +35 -35
- package/dist/r/tooltip.json +5 -0
- package/dist/r/top-bar.json +1 -0
- package/package.json +2 -1
- package/registry.json +14 -0
- package/src/components/composites/account-menu/account-menu.tsx +22 -2
- package/src/components/composites/action-button/action-button.tsx +124 -78
- package/src/components/composites/appearance-editor/accent-swatch-groups.tsx +3 -3
- package/src/components/composites/appearance-editor/appearance-choices.tsx +3 -3
- package/src/components/composites/appearance-editor/appearance-editor.tsx +15 -9
- package/src/components/composites/appearance-editor/appearance-rows.tsx +3 -1
- package/src/components/composites/appearance-editor/appearance-types.ts +7 -7
- package/src/components/composites/appearance-editor/theme-preview.tsx +1 -1
- package/src/components/composites/catalog-browser/catalog-browser.tsx +6 -2
- package/src/components/composites/catalog-browser/catalog-detail.tsx +15 -6
- package/src/components/composites/chain-of-thought/chain-of-thought.tsx +4 -4
- package/src/components/composites/chat/chat.tsx +15 -9
- package/src/components/composites/checkpoint/checkpoint-model.ts +3 -3
- package/src/components/composites/checkpoint/checkpoint.tsx +2 -2
- package/src/components/composites/confirmation/confirmation.tsx +8 -4
- package/src/components/composites/context/context.tsx +2 -2
- package/src/components/composites/file-tree/build-file-tree.ts +1 -1
- package/src/components/composites/file-tree/file-tree.tsx +16 -2
- package/src/components/composites/icon-picker/icon-picker.tsx +1 -1
- package/src/components/composites/inline-citation/citation.ts +1 -1
- package/src/components/composites/inline-citation/inline-citation.tsx +2 -2
- package/src/components/composites/list-row/list-row-control.tsx +31 -22
- package/src/components/composites/list-row/list-row.tsx +69 -73
- package/src/components/composites/message-scroller/message-scroller.tsx +1 -1
- package/src/components/composites/model-selector/model-selector.tsx +190 -14
- package/src/components/composites/model-selector/models.ts +2 -2
- package/src/components/composites/plan/plan.tsx +19 -11
- package/src/components/composites/queue/queue.tsx +5 -3
- package/src/components/composites/reasoning/reasoning.tsx +4 -4
- package/src/components/composites/settings/settings-navigation.tsx +57 -17
- package/src/components/composites/settings/settings.tsx +14 -6
- package/src/components/composites/sources/source.ts +1 -1
- package/src/components/composites/sources/sources.tsx +2 -2
- package/src/components/composites/stack-trace/parse-stack-trace.ts +7 -7
- package/src/components/composites/stack-trace/stack-trace.tsx +3 -3
- package/src/components/composites/stat/stat.tsx +20 -16
- package/src/components/composites/subagent/subagent.tsx +6 -4
- package/src/components/composites/task/task.tsx +1 -1
- package/src/components/composites/terminal/ansi.ts +3 -3
- package/src/components/composites/terminal/terminal-model.ts +3 -3
- package/src/components/composites/terminal/terminal.tsx +24 -12
- package/src/components/composites/test-results/test-results-model.ts +4 -4
- package/src/components/composites/test-results/test-results.tsx +1 -1
- package/src/components/composites/tool/tool.tsx +4 -4
- package/src/components/composites/tree/tree.tsx +31 -15
- package/src/components/composites/update-dialog/channel-control.tsx +17 -8
- package/src/components/composites/update-dialog/index.ts +1 -0
- package/src/components/composites/update-dialog/update-dialog.tsx +7 -7
- package/src/components/composites/workspace-mark/workspace-mark.tsx +15 -12
- package/src/components/conversation/busy-send-button.tsx +6 -2
- package/src/components/conversation/composer-menu.tsx +3 -3
- package/src/components/conversation/conversation-avatar.tsx +1 -1
- package/src/components/conversation/conversation-pane.tsx +8 -5
- package/src/components/conversation/conversation-surface.tsx +2 -2
- package/src/components/conversation/internal/chat-composer-shell.tsx +18 -12
- package/src/components/conversation/message-composer.tsx +4 -6
- package/src/components/conversation/message-row.tsx +34 -26
- package/src/components/conversation/scroll-follow-core.ts +8 -8
- package/src/components/conversation/scroll-follow.ts +24 -8
- package/src/components/conversation/thread-panel.tsx +7 -3
- package/src/components/conversation/transcript-composition.tsx +4 -2
- package/src/components/layout/app-shell/app-shell.tsx +1 -1
- package/src/components/layout/app-shell/skip-link.tsx +3 -2
- package/src/components/layout/page/page.tsx +15 -11
- package/src/components/layout/panel/panel.tsx +1 -1
- package/src/components/layout/pixel-resize-handle/pixel-resize-handle.tsx +21 -1
- package/src/components/layout/side-rail/side-rail-context.ts +1 -1
- package/src/components/layout/side-rail/side-rail.tsx +41 -28
- package/src/components/layout/sidebar-nav/sidebar-nav.tsx +22 -16
- package/src/components/layout/split-layout/resize-controller-core-retry.tsx +25 -7
- package/src/components/layout/split-layout/resize-controller-core.tsx +25 -7
- package/src/components/layout/split-layout/split-layout.tsx +6 -2
- package/src/components/layout/status-bar/status-bar.tsx +1 -1
- package/src/components/layout/top-bar/top-bar.tsx +4 -6
- package/src/components/motion/presence.tsx +2 -2
- package/src/components/theme/appearance-panel.tsx +5 -5
- package/src/components/theme/lazy.ts +1 -1
- package/src/components/theme/theme-catalogue-source.ts +2 -2
- package/src/components/theme/theme-context.ts +3 -3
- package/src/components/theme/theme-document.ts +22 -11
- package/src/components/theme/theme-picker.tsx +5 -5
- package/src/components/theme/theme-provider-value.ts +15 -3
- package/src/components/theme/theme-script.ts +20 -0
- package/src/components/theme/theme-state.ts +7 -7
- package/src/components/theme/theme-toggle.tsx +1 -1
- package/src/components/ui/alert/alert.tsx +4 -3
- package/src/components/ui/alert-dialog/alert-dialog.tsx +4 -4
- package/src/components/ui/badge/badge.tsx +2 -2
- package/src/components/ui/board/board.tsx +17 -5
- package/src/components/ui/bubble/bubble.tsx +6 -4
- package/src/components/ui/button/button.tsx +2 -2
- package/src/components/ui/button-group/button-group.tsx +1 -1
- package/src/components/ui/calendar/calendar.tsx +2 -2
- package/src/components/ui/callout/callout.tsx +4 -4
- package/src/components/ui/card/card.tsx +2 -2
- package/src/components/ui/carousel/carousel.tsx +6 -6
- package/src/components/ui/chart/chart-options.ts +9 -9
- package/src/components/ui/chart/chart.tsx +14 -1
- package/src/components/ui/checkbox/checkbox.tsx +9 -6
- package/src/components/ui/code-block/code-block.tsx +14 -7
- package/src/components/ui/command/command.tsx +7 -7
- package/src/components/ui/context-menu/context-menu.tsx +1 -1
- package/src/components/ui/detail-panel/detail-panel.tsx +5 -3
- package/src/components/ui/dialog/dialog-layer.tsx +25 -1
- package/src/components/ui/dialog/dialog.tsx +4 -3
- package/src/components/ui/diff-block/diff-block.tsx +6 -6
- package/src/components/ui/drawer/drawer.tsx +3 -3
- package/src/components/ui/dropdown-menu/dropdown-menu.tsx +6 -6
- package/src/components/ui/dropdown-menu/menu-parts.tsx +5 -5
- package/src/components/ui/empty/empty-state.tsx +23 -18
- package/src/components/ui/empty/empty.tsx +1 -1
- package/src/components/ui/entity-icon/entity-icon.tsx +5 -1
- package/src/components/ui/field/field.tsx +15 -7
- package/src/components/ui/field/number-field.tsx +1 -1
- package/src/components/ui/hover-card/hover-card.tsx +1 -1
- package/src/components/ui/input-group/input-group.tsx +1 -1
- package/src/components/ui/input-otp/input-otp.tsx +1 -1
- package/src/components/ui/item/item.tsx +24 -18
- package/src/components/ui/kbd/kbd.tsx +55 -14
- package/src/components/ui/kbd/platform-modifier.ts +3 -3
- package/src/components/ui/label/label.tsx +1 -1
- package/src/components/ui/marker/marker.tsx +9 -5
- package/src/components/ui/menubar/menubar.tsx +2 -2
- package/src/components/ui/message/message.tsx +14 -13
- package/src/components/ui/modal-dialog/modal-dialog.tsx +9 -5
- package/src/components/ui/native-select/native-select.tsx +1 -1
- package/src/components/ui/navigation-menu/navigation-menu.tsx +5 -4
- package/src/components/ui/pagination/pagination.tsx +1 -1
- package/src/components/ui/popover/popover.tsx +4 -2
- package/src/components/ui/progress/progress.tsx +5 -3
- package/src/components/ui/questionnaire/questionnaire.tsx +10 -5
- package/src/components/ui/radio-group/radio-group.tsx +9 -6
- package/src/components/ui/resizable/resizable.tsx +5 -5
- package/src/components/ui/select/select.tsx +4 -4
- package/src/components/ui/sheet/sheet.tsx +4 -3
- package/src/components/ui/skeleton/skeleton.tsx +1 -1
- package/src/components/ui/slider/slider.tsx +1 -1
- package/src/components/ui/spinner/spinner.tsx +1 -1
- package/src/components/ui/status-chip/status-chip.tsx +13 -13
- package/src/components/ui/switch/switch.tsx +9 -6
- package/src/components/ui/tabs/tabs.tsx +4 -4
- package/src/components/ui/textarea/textarea.tsx +1 -1
- package/src/components/ui/toast/toast.tsx +6 -4
- package/src/components/ui/toggle/toggle.tsx +1 -1
- package/src/components/ui/tooltip/deferred-tooltip.tsx +131 -0
- package/src/components/ui/tooltip/index.ts +1 -0
- package/src/components/ui/tooltip/tooltip.tsx +6 -4
- package/src/components/ui/trace/trace.tsx +13 -9
- package/src/components/ui/typography/typography.tsx +5 -5
- package/src/index.ts +1 -0
- package/src/lib/accent-presets.ts +1 -1
- package/src/lib/accent-roles.ts +2 -2
- package/src/lib/appearance-font-settings.ts +18 -7
- package/src/lib/create-poll.ts +150 -0
- package/src/lib/font-zoom.ts +3 -3
- package/src/lib/keyed-rows.ts +3 -2
- package/src/lib/overlay.ts +6 -6
- package/src/lib/preference-store.ts +2 -2
- package/src/lib/safe-script.ts +2 -2
- package/src/lib/scroll-geometry.ts +1 -1
- package/src/lib/text.ts +1 -1
- package/src/lib/theme-accents.ts +3 -3
- package/src/lib/theme-css.ts +2 -2
- package/src/lib/theme-defaults.ts +4 -4
- package/src/lib/theme-engine-light.ts +2 -2
- package/src/lib/theme-engine.ts +2 -2
- package/src/lib/theme-projection.ts +2 -2
- package/src/lib/theme-records.ts +2 -2
- package/src/lib/theme-types.ts +1 -1
- package/src/lib/themes.ts +14 -14
- package/src/lib/tokens.ts +2 -2
- package/src/lib/tooltip-focus-gate.ts +11 -11
- package/src/lib/utils.ts +1 -1
- package/src/lib/variants.ts +4 -4
- package/src/lib/version-notes.ts +4 -4
- package/src/lint/index.ts +1 -1
- package/src/styles/base.css +12 -43
- package/src/styles/fonts.css +1 -1
- package/src/styles/theme.css +35 -35
- package/src/styles/themes/aardvark-blue.css +98 -0
- package/src/styles/themes/aardvark-ink.css +98 -0
- package/src/styles/themes/adea-dark-colorblind.css +98 -0
- package/src/styles/themes/adea-dark-high-contrast.css +98 -0
- package/src/styles/themes/adea-dark.css +47 -0
- package/src/styles/themes/adea-light-colorblind.css +141 -0
- package/src/styles/themes/adea-light-high-contrast.css +141 -0
- package/src/styles/themes/adea-light.css +47 -0
- package/src/styles/themes/ayu-light.css +141 -0
- package/src/styles/themes/ayu-mirage.css +98 -0
- package/src/styles/themes/ayu.css +98 -0
- package/src/styles/themes/catppuccin-frappe.css +98 -0
- package/src/styles/themes/catppuccin-latte.css +141 -0
- package/src/styles/themes/catppuccin-macchiato.css +98 -0
- package/src/styles/themes/catppuccin-mocha.css +98 -0
- package/src/styles/themes/dracula.css +98 -0
- package/src/styles/themes/everforest-dark.css +98 -0
- package/src/styles/themes/everforest-light.css +141 -0
- package/src/styles/themes/gruvbox-dark.css +98 -0
- package/src/styles/themes/gruvbox-light.css +141 -0
- package/src/styles/themes/kanagawa.css +98 -0
- package/src/styles/themes/monokai.css +98 -0
- package/src/styles/themes/nord-light.css +141 -0
- package/src/styles/themes/nord.css +98 -0
- package/src/styles/themes/one-dark.css +98 -0
- package/src/styles/themes/rosepine-dawn.css +141 -0
- package/src/styles/themes/rosepine-moon.css +98 -0
- package/src/styles/themes/rosepine.css +98 -0
- package/src/styles/themes/solarized-dark.css +98 -0
- package/src/styles/themes/solarized-light.css +141 -0
- package/src/styles/themes/tokyonight-day.css +141 -0
- package/src/styles/themes/tokyonight-night.css +98 -0
- package/src/styles/themes/tokyonight-storm.css +98 -0
- package/src/styles/themes/vesper.css +98 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","names":["OctagonAlert","TriangleAlert","For","Show","splitProps","cn","Button","Popover","PopoverContent","PopoverTitle","PopoverTrigger","Progress","breakdownRows","contextLabel","contextLevel","contextLevelWord","contextPercent","contextShort","formatCost","formatExact","hasContextFigures","isFigure","locale","placement","class","RING_RADIUS","RING_CIRCUMFERENCE","Math","PI","Context","props","local","figures","percent","used","total","level","levelWord","rows","breakdown","remaining","undefined","cost","amount","_$createComponent","when","children","gutter","as","variant","size","fallback","Ring","_el$","_tmpl$","_$insert","_$effect","_$className","_el$2","_tmpl$2","_el$3","_tmpl$4","_el$6","firstChild","value","min","minValue","maxValue","label","getValueLabel","_el$4","_tmpl$3","_el$5","Row","each","row","filled","max","_el$7","_tmpl$5","_el$9","nextSibling","_$setAttribute","_el$0","_tmpl$6","_el$1","_el$10"],"sources":["../../../../src/components/composites/context/context.tsx"],"sourcesContent":["import { OctagonAlert, TriangleAlert } from 'lucide-solid'\nimport { For, Show, splitProps, type ComponentProps } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { Button } from '../../ui/button'\nimport { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from '../../ui/popover'\nimport { Progress } from '../../ui/progress'\nimport {\n breakdownRows,\n contextLabel,\n contextLevel,\n contextLevelWord,\n contextPercent,\n contextShort,\n formatCost,\n formatExact,\n hasContextFigures,\n isFigure,\n type ContextFigures,\n type ContextLevel,\n} from './context-model'\n\n/**\n * Context.\n *\n * How much of the model's context window is in use, as a compact trigger that\n * opens the figures behind it. It sits next to the composer, where the reader\n * decides whether to keep going or start fresh, so the trigger is small and the\n * detail is a press away rather than permanent chrome.\n *\n * ## Every figure is a claim, so every figure is optional\n *\n * A host passes whatever it knows: `used`, `total`, a `breakdown` (input, output,\n * cache read and write, reasoning), a `cost`. A missing value is omitted — never\n * drawn as 0, which would say \"empty\" about a window nobody measured — and when\n * *nothing* is known the trigger is not rendered at all (`hasContextFigures`).\n * Nothing is estimated here; the one derived row, \"Remaining\", appears only when\n * both `used` and `total` are known and `used` does not exceed `total`.\n *\n * ## Never colour alone\n *\n * The ring shows the fraction; past 75% the ring gives way to a warning glyph\n * (triangle, then octagon at 90% and above), the popover says \"Getting full\",\n * \"Nearly full\" or \"Full\" in words, and the trigger's accessible name speaks the\n * same. An overrun is reported as it is (\"112%\"); only the ring saturates.\n *\n * It is a `Popover`, not a hover card: the figures must be reachable by keyboard\n * and by touch, and Escape closes it and returns focus to the trigger.\n */\nexport type ContextProps = ContextFigures & {\n /** BCP 47 tag for number formatting. Defaults to `en-US`, so output is stable. */\n locale?: string\n placement?: ComponentProps<typeof Popover>['placement']\n class?: string\n}\n\n// A circle of radius 6 in a 16-unit box; the dash array is the fraction of this.\nconst RING_RADIUS = 6\nconst RING_CIRCUMFERENCE = 2 * Math.PI * RING_RADIUS\n\nexport function Context(props: ContextProps) {\n const [local, figures] = splitProps(props, ['locale', 'placement', 'class'])\n const locale = () => local.locale ?? 'en-US'\n const percent = () => contextPercent(figures.used, figures.total)\n const level = (): ContextLevel => contextLevel(percent())\n const levelWord = () => contextLevelWord(level())\n const rows = () => breakdownRows(figures.breakdown)\n const remaining = () =>\n isFigure(figures.used) && isFigure(figures.total) && figures.used <= figures.total\n ? figures.total - figures.used\n : undefined\n const cost = () => (figures.cost && isFigure(figures.cost.amount) ? figures.cost : undefined)\n\n return (\n <Show when={hasContextFigures(figures)}>\n <Popover placement={local.placement ?? 'top'} gutter={6}>\n <PopoverTrigger\n as={Button}\n variant=\"ghost\"\n size=\"xs\"\n data-slot=\"context\"\n data-level={level()}\n aria-label={contextLabel(figures, locale())}\n class={local.class}\n >\n <Show\n when={level() !== 'normal'}\n fallback={\n <Show when={percent() !== undefined}>\n <Ring percent={percent() ?? 0} />\n </Show>\n }\n >\n <span\n aria-hidden=\"true\"\n class={cn({\n 'text-warning': level() === 'high',\n 'text-destructive': level() === 'critical' || level() === 'full',\n })}\n >\n <Show when={level() === 'high'} fallback={<OctagonAlert />}>\n <TriangleAlert />\n </Show>\n </span>\n </Show>\n <span aria-hidden=\"true\" class=\"tabular-nums\">\n {contextShort(figures, locale())}\n </span>\n </PopoverTrigger>\n <PopoverContent class=\"w-72 max-w-full\">\n <PopoverTitle>Context window</PopoverTitle>\n <div class=\"flex flex-col gap-2 px-2 pb-2\">\n <Show when={percent() !== undefined}>\n <Progress\n value={Math.min(percent() ?? 0, 100)}\n minValue={0}\n maxValue={100}\n label=\"Context used\"\n getValueLabel={() => `${percent()}% used`}\n />\n </Show>\n <Show when={levelWord()}>\n <p\n class={cn('m-0 flex items-center gap-1.5 text-sm font-medium', {\n 'text-warning': level() === 'high',\n 'text-destructive': level() === 'critical' || level() === 'full',\n })}\n >\n <Show when={level() === 'high'} fallback={<OctagonAlert class=\"size-4\" />}>\n <TriangleAlert class=\"size-4\" />\n </Show>\n <span class=\"text-foreground\">{levelWord()}</span>\n </p>\n </Show>\n <dl class=\"m-0 flex flex-col gap-1 text-sm\">\n <Show when={isFigure(figures.used)}>\n <Row label=\"Used\" value={`${formatExact(figures.used ?? 0, locale())} tokens`} />\n </Show>\n <Show when={isFigure(figures.total)}>\n <Row label=\"Window\" value={`${formatExact(figures.total ?? 0, locale())} tokens`} />\n </Show>\n <Show when={remaining() !== undefined}>\n <Row\n label=\"Remaining\"\n value={`${formatExact(remaining() ?? 0, locale())} tokens`}\n />\n </Show>\n <For each={rows()}>\n {(row) => <Row label={row.label} value={formatExact(row.value, locale())} />}\n </For>\n <Show when={cost()}>\n {(value) => <Row label=\"Cost\" value={formatCost(value(), locale())} />}\n </Show>\n </dl>\n </div>\n </PopoverContent>\n </Popover>\n </Show>\n )\n}\n\nfunction Ring(props: { percent: number }) {\n const filled = () => (RING_CIRCUMFERENCE * Math.min(Math.max(props.percent, 0), 100)) / 100\n return (\n <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" class=\"size-4\">\n <circle cx=\"8\" cy=\"8\" r={RING_RADIUS} stroke-width=\"2\" class=\"stroke-border\" />\n <circle\n cx=\"8\"\n cy=\"8\"\n r={RING_RADIUS}\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-dasharray={`${filled()} ${RING_CIRCUMFERENCE}`}\n transform=\"rotate(-90 8 8)\"\n class=\"stroke-primary\"\n />\n </svg>\n )\n}\n\nfunction Row(props: { label: string; value: string }) {\n return (\n <div class=\"flex items-baseline justify-between gap-4\">\n <dt class=\"text-muted-foreground\">{props.label}</dt>\n <dd class=\"m-0 text-end tabular-nums\">{props.value}</dd>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;AAyDA,IAAM0B,qBAAqB,IAAIC,KAAKC,KAAKH;AAEzC,SAAgBI,QAAQC,OAAqB;CAC3C,MAAM,CAACC,OAAOC,WAAW5B,WAAW0B,OAAO;EAAC;EAAU;EAAa;CAAO,CAAC;CAC3E,MAAMR,eAAeS,MAAMT,UAAU;CACrC,MAAMW,gBAAgBjB,eAAegB,QAAQE,MAAMF,QAAQG,KAAK;CAChE,MAAMC,cAA4BtB,aAAamB,QAAQ,CAAC;CACxD,MAAMI,kBAAkBtB,iBAAiBqB,MAAM,CAAC;CAChD,MAAME,aAAa1B,cAAcoB,QAAQO,SAAS;CAClD,MAAMC,kBACJnB,SAASW,QAAQE,IAAI,KAAKb,SAASW,QAAQG,KAAK,KAAKH,QAAQE,QAAQF,QAAQG,QACzEH,QAAQG,QAAQH,QAAQE,OACxBO,KAAAA;CACN,MAAMC,aAAcV,QAAQU,QAAQrB,SAASW,QAAQU,KAAKC,MAAM,IAAIX,QAAQU,OAAOD,KAAAA;CAEnF,OAAAG,gBACGzC,MAAI;EAAA,IAAC0C,OAAI;GAAA,OAAEzB,kBAAkBY,OAAO;EAAC;EAAA,IAAAc,WAAA;GAAA,OAAAF,gBACnCrC,SAAO;IAAA,IAACgB,YAAS;KAAA,OAAEQ,MAAMR,aAAa;IAAK;IAAEwB,QAAQ;IAAC,IAAAD,WAAA;KAAA,OAAA,CAAAF,gBACpDlC,gBAAc;MACbsC,IAAI1C;MACJ2C,SAAO;MACPC,MAAI;M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AI,CAAA,GAAA,IAAA;QAAA,OAAAsC;OAAA,EAAA,CAAA,CAAA;MAAA;KAAA,CAAA,CAAA;IAAA;GAAA,CAAA;EAAA;CAAA,CAAA;AAQtF;AAEA,SAASR,KAAKtB,OAA4B;CACxC,MAAM8C,eAAgBlD,qBAAqBC,KAAKsC,IAAItC,KAAKkD,IAAI/C,MAAMG,SAAS,CAAC,GAAG,GAAG,IAAK;CACxF,cAAA;EAAA,IAAA6C,QAAAC,QAAA,GAAAC,QAAAF,MAAAf,WAAAkB;EAAAzB,aAAA0B,aAAAF,OAAA,oBASwB,GAAGJ,OAAO,EAAC,GAAIlD,oBAAoB,CAAA;EAAA,OAAAoD;CAAA,EAAA,CAAA;AAM7D;AAEA,SAASL,IAAI3C,OAAyC;CACpD,cAAA;EAAA,IAAAqD,QAAAC,QAAA,GAAAC,QAAAF,MAAApB,YAAAuB,SAAAD,MAAAJ;EAAA1B,OAAA8B,aAEuCvD,MAAMsC,KAAK;EAAAb,OAAA+B,cACPxD,MAAMkC,KAAK;EAAA,OAAAmB;CAAA,EAAA,CAAA;AAGxD"}
|
|
1
|
+
{"version":3,"file":"context.js","names":["OctagonAlert","TriangleAlert","For","Show","splitProps","cn","Button","Popover","PopoverContent","PopoverTitle","PopoverTrigger","Progress","breakdownRows","contextLabel","contextLevel","contextLevelWord","contextPercent","contextShort","formatCost","formatExact","hasContextFigures","isFigure","locale","placement","class","RING_RADIUS","RING_CIRCUMFERENCE","Math","PI","Context","props","local","figures","percent","used","total","level","levelWord","rows","breakdown","remaining","undefined","cost","amount","_$createComponent","when","children","gutter","as","variant","size","fallback","Ring","_el$","_tmpl$","_$insert","_$effect","_$className","_el$2","_tmpl$2","_el$3","_tmpl$4","_el$6","firstChild","value","min","minValue","maxValue","label","getValueLabel","_el$4","_tmpl$3","_el$5","Row","each","row","filled","max","_el$7","_tmpl$5","_el$9","nextSibling","_$setAttribute","_el$0","_tmpl$6","_el$1","_el$10"],"sources":["../../../../src/components/composites/context/context.tsx"],"sourcesContent":["import { OctagonAlert, TriangleAlert } from 'lucide-solid'\nimport { For, Show, splitProps, type ComponentProps } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { Button } from '../../ui/button'\nimport { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from '../../ui/popover'\nimport { Progress } from '../../ui/progress'\nimport {\n breakdownRows,\n contextLabel,\n contextLevel,\n contextLevelWord,\n contextPercent,\n contextShort,\n formatCost,\n formatExact,\n hasContextFigures,\n isFigure,\n type ContextFigures,\n type ContextLevel,\n} from './context-model'\n\n/**\n * Context.\n *\n * How much of the model's context window is in use, as a compact trigger that\n * opens the figures behind it. It sits next to the composer, where the reader\n * decides whether to keep going or start fresh, so the trigger is small and the\n * detail is a press away rather than permanent chrome.\n *\n * ## Every figure is a claim, so every figure is optional\n *\n * A host passes whatever it knows: `used`, `total`, a `breakdown` (input, output,\n * cache read and write, reasoning), a `cost`. A missing value is omitted, never\n * drawn as 0, which would say \"empty\" about a window nobody measured, and when\n * *nothing* is known the trigger is not rendered at all (`hasContextFigures`).\n * Nothing is estimated here; the one derived row, \"Remaining\", appears only when\n * both `used` and `total` are known and `used` does not exceed `total`.\n *\n * ## Never colour alone\n *\n * The ring shows the fraction; past 75% the ring gives way to a warning glyph\n * (triangle, then octagon at 90% and above), the popover says \"Getting full\",\n * \"Nearly full\" or \"Full\" in words, and the trigger's accessible name speaks the\n * same. An overrun is reported as it is (\"112%\"); only the ring saturates.\n *\n * It is a `Popover`, not a hover card: the figures must be reachable by keyboard\n * and by touch, and Escape closes it and returns focus to the trigger.\n */\nexport type ContextProps = ContextFigures & {\n /** BCP 47 tag for number formatting. Defaults to `en-US`, so output is stable. */\n locale?: string\n placement?: ComponentProps<typeof Popover>['placement']\n class?: string\n}\n\n// A circle of radius 6 in a 16-unit box; the dash array is the fraction of this.\nconst RING_RADIUS = 6\nconst RING_CIRCUMFERENCE = 2 * Math.PI * RING_RADIUS\n\nexport function Context(props: ContextProps) {\n const [local, figures] = splitProps(props, ['locale', 'placement', 'class'])\n const locale = () => local.locale ?? 'en-US'\n const percent = () => contextPercent(figures.used, figures.total)\n const level = (): ContextLevel => contextLevel(percent())\n const levelWord = () => contextLevelWord(level())\n const rows = () => breakdownRows(figures.breakdown)\n const remaining = () =>\n isFigure(figures.used) && isFigure(figures.total) && figures.used <= figures.total\n ? figures.total - figures.used\n : undefined\n const cost = () => (figures.cost && isFigure(figures.cost.amount) ? figures.cost : undefined)\n\n return (\n <Show when={hasContextFigures(figures)}>\n <Popover placement={local.placement ?? 'top'} gutter={6}>\n <PopoverTrigger\n as={Button}\n variant=\"ghost\"\n size=\"xs\"\n data-slot=\"context\"\n data-level={level()}\n aria-label={contextLabel(figures, locale())}\n class={local.class}\n >\n <Show\n when={level() !== 'normal'}\n fallback={\n <Show when={percent() !== undefined}>\n <Ring percent={percent() ?? 0} />\n </Show>\n }\n >\n <span\n aria-hidden=\"true\"\n class={cn({\n 'text-warning': level() === 'high',\n 'text-destructive': level() === 'critical' || level() === 'full',\n })}\n >\n <Show when={level() === 'high'} fallback={<OctagonAlert />}>\n <TriangleAlert />\n </Show>\n </span>\n </Show>\n <span aria-hidden=\"true\" class=\"tabular-nums\">\n {contextShort(figures, locale())}\n </span>\n </PopoverTrigger>\n <PopoverContent class=\"w-72 max-w-full\">\n <PopoverTitle>Context window</PopoverTitle>\n <div class=\"flex flex-col gap-2 px-2 pb-2\">\n <Show when={percent() !== undefined}>\n <Progress\n value={Math.min(percent() ?? 0, 100)}\n minValue={0}\n maxValue={100}\n label=\"Context used\"\n getValueLabel={() => `${percent()}% used`}\n />\n </Show>\n <Show when={levelWord()}>\n <p\n class={cn('m-0 flex items-center gap-1.5 text-sm font-medium', {\n 'text-warning': level() === 'high',\n 'text-destructive': level() === 'critical' || level() === 'full',\n })}\n >\n <Show when={level() === 'high'} fallback={<OctagonAlert class=\"size-4\" />}>\n <TriangleAlert class=\"size-4\" />\n </Show>\n <span class=\"text-foreground\">{levelWord()}</span>\n </p>\n </Show>\n <dl class=\"m-0 flex flex-col gap-1 text-sm\">\n <Show when={isFigure(figures.used)}>\n <Row label=\"Used\" value={`${formatExact(figures.used ?? 0, locale())} tokens`} />\n </Show>\n <Show when={isFigure(figures.total)}>\n <Row label=\"Window\" value={`${formatExact(figures.total ?? 0, locale())} tokens`} />\n </Show>\n <Show when={remaining() !== undefined}>\n <Row\n label=\"Remaining\"\n value={`${formatExact(remaining() ?? 0, locale())} tokens`}\n />\n </Show>\n <For each={rows()}>\n {(row) => <Row label={row.label} value={formatExact(row.value, locale())} />}\n </For>\n <Show when={cost()}>\n {(value) => <Row label=\"Cost\" value={formatCost(value(), locale())} />}\n </Show>\n </dl>\n </div>\n </PopoverContent>\n </Popover>\n </Show>\n )\n}\n\nfunction Ring(props: { percent: number }) {\n const filled = () => (RING_CIRCUMFERENCE * Math.min(Math.max(props.percent, 0), 100)) / 100\n return (\n <svg aria-hidden=\"true\" viewBox=\"0 0 16 16\" fill=\"none\" class=\"size-4\">\n <circle cx=\"8\" cy=\"8\" r={RING_RADIUS} stroke-width=\"2\" class=\"stroke-border\" />\n <circle\n cx=\"8\"\n cy=\"8\"\n r={RING_RADIUS}\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-dasharray={`${filled()} ${RING_CIRCUMFERENCE}`}\n transform=\"rotate(-90 8 8)\"\n class=\"stroke-primary\"\n />\n </svg>\n )\n}\n\nfunction Row(props: { label: string; value: string }) {\n return (\n <div class=\"flex items-baseline justify-between gap-4\">\n <dt class=\"text-muted-foreground\">{props.label}</dt>\n <dd class=\"m-0 text-end tabular-nums\">{props.value}</dd>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;AAyDA,IAAM0B,qBAAqB,IAAIC,KAAKC,KAAKH;AAEzC,SAAgBI,QAAQC,OAAqB;CAC3C,MAAM,CAACC,OAAOC,WAAW5B,WAAW0B,OAAO;EAAC;EAAU;EAAa;CAAO,CAAC;CAC3E,MAAMR,eAAeS,MAAMT,UAAU;CACrC,MAAM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C,QAAAF,MAAApB,YAAAuB,SAAAD,MAAAJ;EAAA1B,OAAA8B,aAEuCvD,MAAMsC,KAAK;EAAAb,OAAA+B,cACPxD,MAAMkC,KAAK;EAAA,OAAAmB;CAAA,EAAA,CAAA;AAGxD"}
|
|
@@ -106,7 +106,7 @@ export type RowWindow = Readonly<{
|
|
|
106
106
|
export declare function clampWindow(window: RowWindow, total: number, page: number): RowWindow;
|
|
107
107
|
/**
|
|
108
108
|
* The window after the keyboard (or typeahead) asks for a row. A row inside the
|
|
109
|
-
* window changes nothing. A row just outside it
|
|
109
|
+
* window changes nothing. A row just outside it, an arrow key at the edge, grows
|
|
110
110
|
* the window by one page, so walking the tree costs a page at a time. Anything
|
|
111
111
|
* further is a jump (End, Home, a typed letter): the window moves to the page that
|
|
112
112
|
* holds the row instead of mounting every row between, which is what keeps End on
|
|
@@ -251,7 +251,7 @@ function clampWindow(window, total, page) {
|
|
|
251
251
|
}
|
|
252
252
|
/**
|
|
253
253
|
* The window after the keyboard (or typeahead) asks for a row. A row inside the
|
|
254
|
-
* window changes nothing. A row just outside it
|
|
254
|
+
* window changes nothing. A row just outside it, an arrow key at the edge, grows
|
|
255
255
|
* the window by one page, so walking the tree costs a page at a time. Anything
|
|
256
256
|
* further is a jump (End, Home, a typed letter): the window moves to the page that
|
|
257
257
|
* holds the row instead of mounting every row between, which is what keeps End on
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-file-tree.js","names":[],"sources":["../../../../src/components/composites/file-tree/build-file-tree.ts"],"sourcesContent":["/**\n * The model behind the changed-files tree: paths in, a folder tree out, and the\n * small pure rules the view needs (what is visible, what to say about the\n * changes, what a typed letter jumps to).\n *\n * Paths come from an agent, which means from a model, which means they are\n * untrusted text. They are used here as labels and as ids, never as places to\n * read or write, and the builder is strict about what counts as a path at all:\n * a `..` segment, a control character or a bidirectional override rejects the\n * path rather than being cleaned up, because a cleaned-up path is a different\n * path and the tree would be making a claim the input did not. Rejected paths\n * are returned, not dropped silently, so the view can say how many it ignored.\n *\n * Everything is iterative. A path with ten thousand segments, or a tree five\n * thousand files wide, must not be able to overflow the stack or stall the page.\n */\n\n/** Every change kind, in the order a summary names them. */\nconst FILE_CHANGE_KINDS = ['added', 'modified', 'deleted', 'renamed'] as const\n\nexport type FileChangeKind = (typeof FILE_CHANGE_KINDS)[number]\n\nexport type FileChangeInput = Readonly<{\n path: string\n /** Absent means the host did not say; the tree makes no statement about the file. */\n change?: FileChangeKind\n /** For a rename, where the file was. Shown as text only. */\n renamedFrom?: string\n additions?: number\n deletions?: number\n}>\n\nexport type FileTreeNode = Readonly<{\n /** The normalised path, `/`-separated. Unique within a tree. */\n id: string\n /** The label. For a compacted folder chain this is `a/b/c`. */\n name: string\n kind: 'file' | 'directory'\n change?: FileChangeKind\n renamedFrom?: string\n additions?: number\n deletions?: number\n children: readonly FileTreeNode[]\n /** Files at or below this node. A file counts itself. */\n fileCount: number\n}>\n\nexport type FileTreeBuild = Readonly<{\n roots: readonly FileTreeNode[]\n /** Inputs that were not accepted as paths, exactly as given. */\n rejected: readonly string[]\n /** Inputs that named a path already present. The first one wins. */\n duplicates: number\n fileCount: number\n}>\n\nexport type BuildFileTreeOptions = {\n /** Merge a folder with a single folder child into one row (`src/lib`). Default true. */\n compact?: boolean\n}\n\n/** Deeper paths are rejected: no real repository nests this far, and a row's indent would be unusable. */\nexport const FILE_TREE_MAX_DEPTH = 256\nconst MAX_SEGMENT_LENGTH = 1024\n\nfunction hasForbiddenCharacter(value: string): boolean {\n for (let i = 0; i < value.length; i += 1) {\n const code = value.charCodeAt(i)\n if (\n code < 0x20 ||\n (code >= 0x7f && code <= 0x9f) ||\n (code >= 0x202a && code <= 0x202e) ||\n (code >= 0x2066 && code <= 0x2069) ||\n code === 0x2028 ||\n code === 0x2029\n ) {\n return true\n }\n }\n return false\n}\n\n/**\n * A path as its segments, or `null` when it is not acceptable. Both separators\n * are accepted, empty and `.` segments are dropped (`a//b`, `./a`, trailing `/`),\n * and a leading separator is dropped, so an absolute path becomes relative to\n * the tree's root rather than escaping it.\n */\nexport function normalizePath(path: unknown): string[] | null {\n if (typeof path !== 'string' || hasForbiddenCharacter(path)) return null\n const segments: string[] = []\n let start = 0\n for (let i = 0; i <= path.length; i += 1) {\n if (i !== path.length && path[i] !== '/' && path[i] !== '\\\\') continue\n const segment = path.slice(start, i)\n start = i + 1\n if (segment === '' || segment === '.') continue\n if (segment === '..' || segment.length > MAX_SEGMENT_LENGTH) return null\n segments.push(segment)\n if (segments.length > FILE_TREE_MAX_DEPTH) return null\n }\n return segments.length === 0 ? null : segments\n}\n\ntype Draft = {\n id: string\n name: string\n children: Map<string, Draft>\n change?: FileChangeKind\n renamedFrom?: string\n additions?: number\n deletions?: number\n explicit: boolean\n}\n\nfunction newDraft(id: string, name: string): Draft {\n return { id, name, children: new Map(), explicit: false }\n}\n\nfunction compareNodes(a: FileTreeNode, b: FileTreeNode): number {\n if (a.kind !== b.kind) return a.kind === 'directory' ? -1 : 1\n const left = a.name.toLowerCase()\n const right = b.name.toLowerCase()\n if (left !== right) return left < right ? -1 : 1\n return a.name < b.name ? -1 : a.name > b.name ? 1 : 0\n}\n\nfunction safeCount(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isFinite(value) && value >= 0\n ? Math.floor(value)\n : undefined\n}\n\nconst CHANGE_KINDS: ReadonlySet<string> = new Set(FILE_CHANGE_KINDS)\n\n/**\n * Build the tree. Folders sort before files, then by name without regard to\n * case. A path that is both a file and the parent of another path is a folder\n * that keeps the file entry's change (a file replaced by a directory is a real\n * thing to report).\n */\nexport function buildFileTree(\n paths: readonly (string | FileChangeInput)[],\n options: BuildFileTreeOptions = {}\n): FileTreeBuild {\n const root = newDraft('', '')\n const rejected: string[] = []\n let duplicates = 0\n\n for (const input of paths) {\n const entry: FileChangeInput | undefined =\n typeof input === 'string'\n ? { path: input }\n : input && typeof input === 'object'\n ? input\n : undefined\n const segments = normalizePath(entry?.path)\n if (!entry || !segments) {\n rejected.push(\n typeof input === 'string' ? input : String((input as { path?: unknown })?.path ?? '')\n )\n continue\n }\n\n let node = root\n let id = ''\n for (const segment of segments) {\n id = id === '' ? segment : `${id}/${segment}`\n let child = node.children.get(segment)\n if (!child) {\n child = newDraft(id, segment)\n node.children.set(segment, child)\n }\n node = child\n }\n if (node.explicit) {\n duplicates += 1\n continue\n }\n node.explicit = true\n if (entry.change && CHANGE_KINDS.has(entry.change)) node.change = entry.change\n if (typeof entry.renamedFrom === 'string' && !hasForbiddenCharacter(entry.renamedFrom)) {\n node.renamedFrom = entry.renamedFrom\n }\n node.additions = safeCount(entry.additions)\n node.deletions = safeCount(entry.deletions)\n }\n\n // Pre-order flatten, then fold back in reverse: a child always has a larger\n // index than its parent, so one backwards pass builds every node after its\n // children without recursion.\n const order: Draft[] = []\n const parentOf: number[] = []\n const stack: [Draft, number][] = [...root.children.values()].map((draft) => [draft, -1])\n while (stack.length > 0) {\n const [draft, parent] = stack.pop()!\n const index = order.length\n order.push(draft)\n parentOf.push(parent)\n for (const child of draft.children.values()) stack.push([child, index])\n }\n\n const built: FileTreeNode[][] = order.map(() => [])\n const roots: FileTreeNode[] = []\n const compact = options.compact !== false\n let fileCount = 0\n\n for (let index = order.length - 1; index >= 0; index -= 1) {\n const draft = order[index]!\n const children = built[index]!.toSorted(compareNodes)\n let node: FileTreeNode\n const only = children.length === 1 ? children[0]! : undefined\n if (compact && only?.kind === 'directory' && draft.change === undefined) {\n // A folder holding only another folder reads as one row: `src/lib`, not two.\n node = { ...only, name: `${draft.name}/${only.name}` }\n } else if (children.length > 0) {\n node = {\n id: draft.id,\n name: draft.name,\n kind: 'directory',\n ...(draft.change && { change: draft.change }),\n ...(draft.renamedFrom !== undefined && { renamedFrom: draft.renamedFrom }),\n children,\n fileCount: children.reduce((sum, child) => sum + child.fileCount, 0),\n }\n } else {\n fileCount += 1\n node = {\n id: draft.id,\n name: draft.name,\n kind: 'file',\n ...(draft.change && { change: draft.change }),\n ...(draft.renamedFrom !== undefined && { renamedFrom: draft.renamedFrom }),\n ...(draft.additions !== undefined && { additions: draft.additions }),\n ...(draft.deletions !== undefined && { deletions: draft.deletions }),\n children: [],\n fileCount: 1,\n }\n }\n const parent = parentOf[index]!\n if (parent === -1) roots.push(node)\n else built[parent]!.push(node)\n }\n\n roots.sort(compareNodes)\n return { roots, rejected, duplicates, fileCount }\n}\n\n// ---------------------------------------------------------------------------\n// Projection\n// ---------------------------------------------------------------------------\n\nexport type FileTreeRow = Readonly<{\n node: FileTreeNode\n /** One-based depth. */\n level: number\n parentId: string | null\n expanded: boolean\n}>\n\n/**\n * The rows that are on screen, in reading order. A collapsed folder's subtree\n * is never visited, so toggling a folder in a 5 000-file tree costs the size of\n * what is visible, not of what exists.\n */\nexport function flattenFileTree(\n roots: readonly FileTreeNode[],\n expanded: ReadonlySet<string>\n): FileTreeRow[] {\n const rows: FileTreeRow[] = []\n const stack: [FileTreeNode, number, string | null][] = []\n for (let i = roots.length - 1; i >= 0; i -= 1) stack.push([roots[i]!, 1, null])\n while (stack.length > 0) {\n const [node, level, parentId] = stack.pop()!\n const open = node.kind === 'directory' && expanded.has(node.id)\n rows.push({ node, level, parentId, expanded: open })\n if (open) {\n for (let i = node.children.length - 1; i >= 0; i -= 1) {\n stack.push([node.children[i]!, level + 1, node.id])\n }\n }\n }\n return rows\n}\n\n/** Every node by id, for turning a row id back into its node. */\nexport function indexFileTree(roots: readonly FileTreeNode[]): Map<string, FileTreeNode> {\n const index = new Map<string, FileTreeNode>()\n const stack = [...roots]\n while (stack.length > 0) {\n const node = stack.pop()!\n index.set(node.id, node)\n for (const child of node.children) stack.push(child)\n }\n return index\n}\n\nexport type FileTreeExpansion = boolean | number | readonly string[] | undefined\n\n/** Tree this small opens fully by default; a larger one opens only its top level. */\nexport const FILE_TREE_AUTO_EXPAND_LIMIT = 100\n\n/**\n * Which folders start open. `true` opens every folder, a number opens folders up\n * to that depth (1 is the top level), a list opens exactly those ids, `false`\n * none. Unset is \"auto\": everything for a small tree, the top level for a large\n * one, because a tree that opens 5 000 rows is the freeze this exists to avoid.\n */\nexport function initialExpanded(\n roots: readonly FileTreeNode[],\n spec: FileTreeExpansion,\n fileCount: number\n): Set<string> {\n const open = new Set<string>()\n if (Array.isArray(spec)) {\n for (const id of spec) open.add(id)\n return open\n }\n const depth =\n spec === true\n ? Infinity\n : spec === false\n ? 0\n : typeof spec === 'number'\n ? Math.max(0, Math.floor(spec))\n : fileCount <= FILE_TREE_AUTO_EXPAND_LIMIT\n ? Infinity\n : 1\n const stack: [FileTreeNode, number][] = roots.map((node) => [node, 1])\n while (stack.length > 0) {\n const [node, level] = stack.pop()!\n if (node.kind !== 'directory' || level > depth) continue\n open.add(node.id)\n for (const child of node.children) stack.push([child, level + 1])\n }\n return open\n}\n\n// ---------------------------------------------------------------------------\n// Mounted window\n// ---------------------------------------------------------------------------\n\n/** The slice of visible rows that is mounted: `start` inclusive, `end` exclusive. */\nexport type RowWindow = Readonly<{ start: number; end: number }>\n\n/**\n * A window clamped to what exists, and never narrower than one page when that\n * many rows are there. Rows collapse and files are removed while a window is\n * held, so every read goes through this.\n */\nexport function clampWindow(window: RowWindow, total: number, page: number): RowWindow {\n if (total <= 0) return { start: 0, end: 0 }\n const start = Math.min(Math.max(0, window.start), total - 1)\n return { start, end: Math.min(total, Math.max(window.end, start + Math.max(1, page))) }\n}\n\n/**\n * The window after the keyboard (or typeahead) asks for a row. A row inside the\n * window changes nothing. A row just outside it — an arrow key at the edge — grows\n * the window by one page, so walking the tree costs a page at a time. Anything\n * further is a jump (End, Home, a typed letter): the window moves to the page that\n * holds the row instead of mounting every row between, which is what keeps End on\n * a 5 000-row tree from being a multi-second freeze.\n */\nexport function revealInWindow(\n window: RowWindow,\n index: number,\n total: number,\n page: number\n): RowWindow {\n const current = clampWindow(window, total, page)\n if (index < 0 || index >= total) return current\n if (index >= current.start && index < current.end) return current\n if (index === current.start - 1) {\n return { start: Math.max(0, current.start - page), end: current.end }\n }\n if (index === current.end)\n return { start: current.start, end: Math.min(total, current.end + page) }\n const start = Math.floor(index / page) * page\n return { start, end: Math.min(total, start + page) }\n}\n\n// ---------------------------------------------------------------------------\n// Words\n// ---------------------------------------------------------------------------\n\nexport type ChangeCounts = Readonly<\n Record<FileChangeKind, number> & {\n total: number\n /** Files with no change kind supplied. */\n unspecified: number\n }\n>\n\nexport function countChanges(roots: readonly FileTreeNode[]): ChangeCounts {\n const counts: { -readonly [K in keyof ChangeCounts]: number } = {\n total: 0,\n added: 0,\n modified: 0,\n deleted: 0,\n renamed: 0,\n unspecified: 0,\n }\n const stack = [...roots]\n while (stack.length > 0) {\n const node = stack.pop()!\n for (const child of node.children) stack.push(child)\n if (node.kind !== 'file') continue\n counts.total += 1\n if (node.change) counts[node.change] += 1\n else counts.unspecified += 1\n }\n return counts\n}\n\n/**\n * The summary in words: \"12 files changed: 3 added, 8 modified, 1 deleted\". Only\n * kinds that occur are named, and files with no kind are not folded into any of\n * them. Empty is empty, not \"0 files changed\".\n */\nexport function describeChanges(counts: ChangeCounts): string {\n if (counts.total === 0) return 'No changed files'\n const parts: string[] = []\n for (const kind of FILE_CHANGE_KINDS) {\n if (counts[kind] > 0) parts.push(`${counts[kind].toLocaleString()} ${kind}`)\n }\n const noun = counts.total === 1 ? 'file' : 'files'\n const head = `${counts.total.toLocaleString()} ${noun} changed`\n return parts.length > 0 ? `${head}: ${parts.join(', ')}` : head\n}\n\n/** The words for a change, which are drawn on the row and so also spoken. */\nexport const FILE_CHANGE_LABELS: Readonly<Record<FileChangeKind, string>> = {\n added: 'Added',\n modified: 'Modified',\n deleted: 'Deleted',\n renamed: 'Renamed',\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,IAAM,oBAAoB;CAAC;CAAS;CAAY;CAAW;AAAS;;AA4CpE,IAAa,sBAAsB;AACnC,IAAM,qBAAqB;AAE3B,SAAS,sBAAsB,OAAwB;CACrD,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAAK,GAAG;EACxC,MAAM,OAAO,MAA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,IAAI,IAAI;CACzC,OAAO;EAAE;EAAO,KAAK,KAAK,IAAI,OAAO,QAAQ,IAAI;CAAE;AACrD;AAcA,SAAgB,aAAa,OAA8C;CACzE,MAAM,SAA0D;EAC9D,OAAO;EACP,OAAO;EACP,UAAU;EACV,SAAS;EACT,SAAS;EACT,aAAa;CACf;CACA,MAAM,QAAQ,CAAC,GAAG,KAAK;CACvB,OAAO,MAAM,SAAS,GAAG;EACvB,MAAM,OAAO,MAAM,IAAI;EACvB,KAAK,MAAM,SAAS,KAAK,UAAU,MAAM,KAAK,KAAK;EACnD,IAAI,KAAK,SAAS,QAAQ;EAC1B,OAAO,SAAS;EAChB,IAAI,KAAK,QAAQ,OAAO,KAAK,WAAW;OACnC,OAAO,eAAe;CAC7B;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,gBAAgB,QAA8B;CAC5D,IAAI,OAAO,UAAU,GAAG,OAAO;CAC/B,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,QAAQ,mBACjB,IAAI,OAAO,QAAQ,GAAG,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,eAAe,EAAE,GAAG,MAAM;CAE7E,MAAM,OAAO,OAAO,UAAU,IAAI,SAAS;CAC3C,MAAM,OAAO,GAAG,OAAO,MAAM,eAAe,EAAE,GAAG,KAAK;CACtD,OAAO,MAAM,SAAS,IAAI,GAAG,KAAK,IAAI,MAAM,KAAK,IAAI,MAAM;AAC7D;;AAGA,IAAa,qBAA+D;CAC1E,OAAO;CACP,UAAU;CACV,SAAS;CACT,SAAS;AACX"}
|
|
1
|
+
{"version":3,"file":"build-file-tree.js","names":[],"sources":["../../../../src/components/composites/file-tree/build-file-tree.ts"],"sourcesContent":["/**\n * The model behind the changed-files tree: paths in, a folder tree out, and the\n * small pure rules the view needs (what is visible, what to say about the\n * changes, what a typed letter jumps to).\n *\n * Paths come from an agent, which means from a model, which means they are\n * untrusted text. They are used here as labels and as ids, never as places to\n * read or write, and the builder is strict about what counts as a path at all:\n * a `..` segment, a control character or a bidirectional override rejects the\n * path rather than being cleaned up, because a cleaned-up path is a different\n * path and the tree would be making a claim the input did not. Rejected paths\n * are returned, not dropped silently, so the view can say how many it ignored.\n *\n * Everything is iterative. A path with ten thousand segments, or a tree five\n * thousand files wide, must not be able to overflow the stack or stall the page.\n */\n\n/** Every change kind, in the order a summary names them. */\nconst FILE_CHANGE_KINDS = ['added', 'modified', 'deleted', 'renamed'] as const\n\nexport type FileChangeKind = (typeof FILE_CHANGE_KINDS)[number]\n\nexport type FileChangeInput = Readonly<{\n path: string\n /** Absent means the host did not say; the tree makes no statement about the file. */\n change?: FileChangeKind\n /** For a rename, where the file was. Shown as text only. */\n renamedFrom?: string\n additions?: number\n deletions?: number\n}>\n\nexport type FileTreeNode = Readonly<{\n /** The normalised path, `/`-separated. Unique within a tree. */\n id: string\n /** The label. For a compacted folder chain this is `a/b/c`. */\n name: string\n kind: 'file' | 'directory'\n change?: FileChangeKind\n renamedFrom?: string\n additions?: number\n deletions?: number\n children: readonly FileTreeNode[]\n /** Files at or below this node. A file counts itself. */\n fileCount: number\n}>\n\nexport type FileTreeBuild = Readonly<{\n roots: readonly FileTreeNode[]\n /** Inputs that were not accepted as paths, exactly as given. */\n rejected: readonly string[]\n /** Inputs that named a path already present. The first one wins. */\n duplicates: number\n fileCount: number\n}>\n\nexport type BuildFileTreeOptions = {\n /** Merge a folder with a single folder child into one row (`src/lib`). Default true. */\n compact?: boolean\n}\n\n/** Deeper paths are rejected: no real repository nests this far, and a row's indent would be unusable. */\nexport const FILE_TREE_MAX_DEPTH = 256\nconst MAX_SEGMENT_LENGTH = 1024\n\nfunction hasForbiddenCharacter(value: string): boolean {\n for (let i = 0; i < value.length; i += 1) {\n const code = value.charCodeAt(i)\n if (\n code < 0x20 ||\n (code >= 0x7f && code <= 0x9f) ||\n (code >= 0x202a && code <= 0x202e) ||\n (code >= 0x2066 && code <= 0x2069) ||\n code === 0x2028 ||\n code === 0x2029\n ) {\n return true\n }\n }\n return false\n}\n\n/**\n * A path as its segments, or `null` when it is not acceptable. Both separators\n * are accepted, empty and `.` segments are dropped (`a//b`, `./a`, trailing `/`),\n * and a leading separator is dropped, so an absolute path becomes relative to\n * the tree's root rather than escaping it.\n */\nexport function normalizePath(path: unknown): string[] | null {\n if (typeof path !== 'string' || hasForbiddenCharacter(path)) return null\n const segments: string[] = []\n let start = 0\n for (let i = 0; i <= path.length; i += 1) {\n if (i !== path.length && path[i] !== '/' && path[i] !== '\\\\') continue\n const segment = path.slice(start, i)\n start = i + 1\n if (segment === '' || segment === '.') continue\n if (segment === '..' || segment.length > MAX_SEGMENT_LENGTH) return null\n segments.push(segment)\n if (segments.length > FILE_TREE_MAX_DEPTH) return null\n }\n return segments.length === 0 ? null : segments\n}\n\ntype Draft = {\n id: string\n name: string\n children: Map<string, Draft>\n change?: FileChangeKind\n renamedFrom?: string\n additions?: number\n deletions?: number\n explicit: boolean\n}\n\nfunction newDraft(id: string, name: string): Draft {\n return { id, name, children: new Map(), explicit: false }\n}\n\nfunction compareNodes(a: FileTreeNode, b: FileTreeNode): number {\n if (a.kind !== b.kind) return a.kind === 'directory' ? -1 : 1\n const left = a.name.toLowerCase()\n const right = b.name.toLowerCase()\n if (left !== right) return left < right ? -1 : 1\n return a.name < b.name ? -1 : a.name > b.name ? 1 : 0\n}\n\nfunction safeCount(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isFinite(value) && value >= 0\n ? Math.floor(value)\n : undefined\n}\n\nconst CHANGE_KINDS: ReadonlySet<string> = new Set(FILE_CHANGE_KINDS)\n\n/**\n * Build the tree. Folders sort before files, then by name without regard to\n * case. A path that is both a file and the parent of another path is a folder\n * that keeps the file entry's change (a file replaced by a directory is a real\n * thing to report).\n */\nexport function buildFileTree(\n paths: readonly (string | FileChangeInput)[],\n options: BuildFileTreeOptions = {}\n): FileTreeBuild {\n const root = newDraft('', '')\n const rejected: string[] = []\n let duplicates = 0\n\n for (const input of paths) {\n const entry: FileChangeInput | undefined =\n typeof input === 'string'\n ? { path: input }\n : input && typeof input === 'object'\n ? input\n : undefined\n const segments = normalizePath(entry?.path)\n if (!entry || !segments) {\n rejected.push(\n typeof input === 'string' ? input : String((input as { path?: unknown })?.path ?? '')\n )\n continue\n }\n\n let node = root\n let id = ''\n for (const segment of segments) {\n id = id === '' ? segment : `${id}/${segment}`\n let child = node.children.get(segment)\n if (!child) {\n child = newDraft(id, segment)\n node.children.set(segment, child)\n }\n node = child\n }\n if (node.explicit) {\n duplicates += 1\n continue\n }\n node.explicit = true\n if (entry.change && CHANGE_KINDS.has(entry.change)) node.change = entry.change\n if (typeof entry.renamedFrom === 'string' && !hasForbiddenCharacter(entry.renamedFrom)) {\n node.renamedFrom = entry.renamedFrom\n }\n node.additions = safeCount(entry.additions)\n node.deletions = safeCount(entry.deletions)\n }\n\n // Pre-order flatten, then fold back in reverse: a child always has a larger\n // index than its parent, so one backwards pass builds every node after its\n // children without recursion.\n const order: Draft[] = []\n const parentOf: number[] = []\n const stack: [Draft, number][] = [...root.children.values()].map((draft) => [draft, -1])\n while (stack.length > 0) {\n const [draft, parent] = stack.pop()!\n const index = order.length\n order.push(draft)\n parentOf.push(parent)\n for (const child of draft.children.values()) stack.push([child, index])\n }\n\n const built: FileTreeNode[][] = order.map(() => [])\n const roots: FileTreeNode[] = []\n const compact = options.compact !== false\n let fileCount = 0\n\n for (let index = order.length - 1; index >= 0; index -= 1) {\n const draft = order[index]!\n const children = built[index]!.toSorted(compareNodes)\n let node: FileTreeNode\n const only = children.length === 1 ? children[0]! : undefined\n if (compact && only?.kind === 'directory' && draft.change === undefined) {\n // A folder holding only another folder reads as one row: `src/lib`, not two.\n node = { ...only, name: `${draft.name}/${only.name}` }\n } else if (children.length > 0) {\n node = {\n id: draft.id,\n name: draft.name,\n kind: 'directory',\n ...(draft.change && { change: draft.change }),\n ...(draft.renamedFrom !== undefined && { renamedFrom: draft.renamedFrom }),\n children,\n fileCount: children.reduce((sum, child) => sum + child.fileCount, 0),\n }\n } else {\n fileCount += 1\n node = {\n id: draft.id,\n name: draft.name,\n kind: 'file',\n ...(draft.change && { change: draft.change }),\n ...(draft.renamedFrom !== undefined && { renamedFrom: draft.renamedFrom }),\n ...(draft.additions !== undefined && { additions: draft.additions }),\n ...(draft.deletions !== undefined && { deletions: draft.deletions }),\n children: [],\n fileCount: 1,\n }\n }\n const parent = parentOf[index]!\n if (parent === -1) roots.push(node)\n else built[parent]!.push(node)\n }\n\n roots.sort(compareNodes)\n return { roots, rejected, duplicates, fileCount }\n}\n\n// ---------------------------------------------------------------------------\n// Projection\n// ---------------------------------------------------------------------------\n\nexport type FileTreeRow = Readonly<{\n node: FileTreeNode\n /** One-based depth. */\n level: number\n parentId: string | null\n expanded: boolean\n}>\n\n/**\n * The rows that are on screen, in reading order. A collapsed folder's subtree\n * is never visited, so toggling a folder in a 5 000-file tree costs the size of\n * what is visible, not of what exists.\n */\nexport function flattenFileTree(\n roots: readonly FileTreeNode[],\n expanded: ReadonlySet<string>\n): FileTreeRow[] {\n const rows: FileTreeRow[] = []\n const stack: [FileTreeNode, number, string | null][] = []\n for (let i = roots.length - 1; i >= 0; i -= 1) stack.push([roots[i]!, 1, null])\n while (stack.length > 0) {\n const [node, level, parentId] = stack.pop()!\n const open = node.kind === 'directory' && expanded.has(node.id)\n rows.push({ node, level, parentId, expanded: open })\n if (open) {\n for (let i = node.children.length - 1; i >= 0; i -= 1) {\n stack.push([node.children[i]!, level + 1, node.id])\n }\n }\n }\n return rows\n}\n\n/** Every node by id, for turning a row id back into its node. */\nexport function indexFileTree(roots: readonly FileTreeNode[]): Map<string, FileTreeNode> {\n const index = new Map<string, FileTreeNode>()\n const stack = [...roots]\n while (stack.length > 0) {\n const node = stack.pop()!\n index.set(node.id, node)\n for (const child of node.children) stack.push(child)\n }\n return index\n}\n\nexport type FileTreeExpansion = boolean | number | readonly string[] | undefined\n\n/** Tree this small opens fully by default; a larger one opens only its top level. */\nexport const FILE_TREE_AUTO_EXPAND_LIMIT = 100\n\n/**\n * Which folders start open. `true` opens every folder, a number opens folders up\n * to that depth (1 is the top level), a list opens exactly those ids, `false`\n * none. Unset is \"auto\": everything for a small tree, the top level for a large\n * one, because a tree that opens 5 000 rows is the freeze this exists to avoid.\n */\nexport function initialExpanded(\n roots: readonly FileTreeNode[],\n spec: FileTreeExpansion,\n fileCount: number\n): Set<string> {\n const open = new Set<string>()\n if (Array.isArray(spec)) {\n for (const id of spec) open.add(id)\n return open\n }\n const depth =\n spec === true\n ? Infinity\n : spec === false\n ? 0\n : typeof spec === 'number'\n ? Math.max(0, Math.floor(spec))\n : fileCount <= FILE_TREE_AUTO_EXPAND_LIMIT\n ? Infinity\n : 1\n const stack: [FileTreeNode, number][] = roots.map((node) => [node, 1])\n while (stack.length > 0) {\n const [node, level] = stack.pop()!\n if (node.kind !== 'directory' || level > depth) continue\n open.add(node.id)\n for (const child of node.children) stack.push([child, level + 1])\n }\n return open\n}\n\n// ---------------------------------------------------------------------------\n// Mounted window\n// ---------------------------------------------------------------------------\n\n/** The slice of visible rows that is mounted: `start` inclusive, `end` exclusive. */\nexport type RowWindow = Readonly<{ start: number; end: number }>\n\n/**\n * A window clamped to what exists, and never narrower than one page when that\n * many rows are there. Rows collapse and files are removed while a window is\n * held, so every read goes through this.\n */\nexport function clampWindow(window: RowWindow, total: number, page: number): RowWindow {\n if (total <= 0) return { start: 0, end: 0 }\n const start = Math.min(Math.max(0, window.start), total - 1)\n return { start, end: Math.min(total, Math.max(window.end, start + Math.max(1, page))) }\n}\n\n/**\n * The window after the keyboard (or typeahead) asks for a row. A row inside the\n * window changes nothing. A row just outside it, an arrow key at the edge, grows\n * the window by one page, so walking the tree costs a page at a time. Anything\n * further is a jump (End, Home, a typed letter): the window moves to the page that\n * holds the row instead of mounting every row between, which is what keeps End on\n * a 5 000-row tree from being a multi-second freeze.\n */\nexport function revealInWindow(\n window: RowWindow,\n index: number,\n total: number,\n page: number\n): RowWindow {\n const current = clampWindow(window, total, page)\n if (index < 0 || index >= total) return current\n if (index >= current.start && index < current.end) return current\n if (index === current.start - 1) {\n return { start: Math.max(0, current.start - page), end: current.end }\n }\n if (index === current.end)\n return { start: current.start, end: Math.min(total, current.end + page) }\n const start = Math.floor(index / page) * page\n return { start, end: Math.min(total, start + page) }\n}\n\n// ---------------------------------------------------------------------------\n// Words\n// ---------------------------------------------------------------------------\n\nexport type ChangeCounts = Readonly<\n Record<FileChangeKind, number> & {\n total: number\n /** Files with no change kind supplied. */\n unspecified: number\n }\n>\n\nexport function countChanges(roots: readonly FileTreeNode[]): ChangeCounts {\n const counts: { -readonly [K in keyof ChangeCounts]: number } = {\n total: 0,\n added: 0,\n modified: 0,\n deleted: 0,\n renamed: 0,\n unspecified: 0,\n }\n const stack = [...roots]\n while (stack.length > 0) {\n const node = stack.pop()!\n for (const child of node.children) stack.push(child)\n if (node.kind !== 'file') continue\n counts.total += 1\n if (node.change) counts[node.change] += 1\n else counts.unspecified += 1\n }\n return counts\n}\n\n/**\n * The summary in words: \"12 files changed: 3 added, 8 modified, 1 deleted\". Only\n * kinds that occur are named, and files with no kind are not folded into any of\n * them. Empty is empty, not \"0 files changed\".\n */\nexport function describeChanges(counts: ChangeCounts): string {\n if (counts.total === 0) return 'No changed files'\n const parts: string[] = []\n for (const kind of FILE_CHANGE_KINDS) {\n if (counts[kind] > 0) parts.push(`${counts[kind].toLocaleString()} ${kind}`)\n }\n const noun = counts.total === 1 ? 'file' : 'files'\n const head = `${counts.total.toLocaleString()} ${noun} changed`\n return parts.length > 0 ? `${head}: ${parts.join(', ')}` : head\n}\n\n/** The words for a change, which are drawn on the row and so also spoken. */\nexport const FILE_CHANGE_LABELS: Readonly<Record<FileChangeKind, string>> = {\n added: 'Added',\n modified: 'Modified',\n deleted: 'Deleted',\n renamed: 'Renamed',\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,IAAM,oBAAoB;CAAC;CAAS;CAAY;CAAW;AAAS;;AA4CpE,IAAa,sBAAsB;AACnC,IAAM,qBAAqB;AAE3B,SAAS,s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Q;EAAO,KAAK,KAAK,IAAI,OAAO,QAAQ,MAAM,IAAI;CAAE;CAC1E,MAAM,QAAQ,KAAK,MAAM,QAAQ,IAAI,IAAI;CACzC,OAAO;EAAE;EAAO,KAAK,KAAK,IAAI,OAAO,QAAQ,IAAI;CAAE;AACrD;AAcA,SAAgB,aAAa,OAA8C;CACzE,MAAM,SAA0D;EAC9D,OAAO;EACP,OAAO;EACP,UAAU;EACV,SAAS;EACT,SAAS;EACT,aAAa;CACf;CACA,MAAM,QAAQ,CAAC,GAAG,KAAK;CACvB,OAAO,MAAM,SAAS,GAAG;EACvB,MAAM,OAAO,MAAM,IAAI;EACvB,KAAK,MAAM,SAAS,KAAK,UAAU,MAAM,KAAK,KAAK;EACnD,IAAI,KAAK,SAAS,QAAQ;EAC1B,OAAO,SAAS;EAChB,IAAI,KAAK,QAAQ,OAAO,KAAK,WAAW;OACnC,OAAO,eAAe;CAC7B;CACA,OAAO;AACT;;;;;;AAOA,SAAgB,gBAAgB,QAA8B;CAC5D,IAAI,OAAO,UAAU,GAAG,OAAO;CAC/B,MAAM,QAAkB,CAAC;CACzB,KAAK,MAAM,QAAQ,mBACjB,IAAI,OAAO,QAAQ,GAAG,MAAM,KAAK,GAAG,OAAO,KAAK,CAAC,eAAe,EAAE,GAAG,MAAM;CAE7E,MAAM,OAAO,OAAO,UAAU,IAAI,SAAS;CAC3C,MAAM,OAAO,GAAG,OAAO,MAAM,eAAe,EAAE,GAAG,KAAK;CACtD,OAAO,MAAM,SAAS,IAAI,GAAG,KAAK,IAAI,MAAM,KAAK,IAAI,MAAM;AAC7D;;AAGA,IAAa,qBAA+D;CAC1E,OAAO;CACP,UAAU;CACV,SAAS;CACT,SAAS;AACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-tree.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/file-tree/file-tree.tsx"],"names":[],"mappings":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"file-tree.d.ts","sourceRoot":"","sources":["../../../../src/components/composites/file-tree/file-tree.tsx"],"names":[],"mappings":"AACA,OAAO,EASL,KAAK,cAAc,EACpB,MAAM,UAAU,CAAA;AAMjB,OAAO,EAWL,KAAK,eAAe,EAEpB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAElB,MAAM,mBAAmB,CAAA;AAE1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,GAAG,UAAU,CAAC,GAAG;IACjF,8EAA8E;IAC9E,KAAK,EAAE,SAAS,CAAC,MAAM,GAAG,eAAe,CAAC,EAAE,CAAA;IAC5C,2DAA2D;IAC3D,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,eAAe,CAAC,EAAE,iBAAiB,CAAA;IACnC,4EAA4E;IAC5E,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,+DAA+D;IAC/D,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,4DAA4D;IAC5D,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,KAAK,IAAI,CAAA;IACrD,0FAA0F;IAC1F,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IAC3B,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,eAAO,MAAM,kBAAkB,MAAM,CAAA;AAgFrC,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,kCAoL5C"}
|
|
@@ -6,7 +6,7 @@ import { Tree, TreeRow } from "../tree/tree.js";
|
|
|
6
6
|
import { FILE_CHANGE_LABELS, buildFileTree, clampWindow, countChanges, describeChanges, flattenFileTree, indexFileTree, initialExpanded, revealInWindow } from "./build-file-tree.js";
|
|
7
7
|
import { className, createComponent, effect, insert, memo, mergeProps, setAttribute, setStyleProperty, spread, template } from "solid-js/web";
|
|
8
8
|
import { File, Folder, FolderOpen } from "lucide-solid";
|
|
9
|
-
import { For, Show, createComputed, createMemo, createSignal, splitProps, untrack } from "solid-js";
|
|
9
|
+
import { For, Show, createComputed, createMemo, createSelector, createSignal, splitProps, untrack } from "solid-js";
|
|
10
10
|
// src/components/composites/file-tree/file-tree.tsx
|
|
11
11
|
var _tmpl$ = /*#__PURE__*/ template(`<span>`);
|
|
12
12
|
var _tmpl$2 = /*#__PURE__*/ template(`<span class=sr-only>, renamed from `);
|
|
@@ -26,6 +26,9 @@ var CHANGE_VARIANT = {
|
|
|
26
26
|
deleted: "destructive",
|
|
27
27
|
renamed: "info"
|
|
28
28
|
};
|
|
29
|
+
function sameRow(previous, next) {
|
|
30
|
+
return previous.node === next.node && previous.expanded === next.expanded && previous.level === next.level && previous.parentId === next.parentId;
|
|
31
|
+
}
|
|
29
32
|
function descriptor(row) {
|
|
30
33
|
return {
|
|
31
34
|
id: row.node.id,
|
|
@@ -164,11 +167,12 @@ function FileTree(props) {
|
|
|
164
167
|
end: pageSize()
|
|
165
168
|
} : requested(), rows().length, pageSize()));
|
|
166
169
|
const items = createMemo(() => rows().map(descriptor));
|
|
167
|
-
const mounted = keyedRows(() => rows().slice(mountedWindow().start, mountedWindow().end), (row) => row.node.id);
|
|
170
|
+
const mounted = keyedRows(() => rows().slice(mountedWindow().start, mountedWindow().end), (row) => row.node.id, sameRow);
|
|
168
171
|
const rowsBefore = () => mountedWindow().start;
|
|
169
172
|
const rowsAfter = () => Math.max(0, rows().length - mountedWindow().end);
|
|
170
173
|
const [activeId, setActiveId] = createSignal(null);
|
|
171
174
|
const selectable = () => local.onSelect !== void 0;
|
|
175
|
+
const isSelected = createSelector(() => local.selected);
|
|
172
176
|
const toggle = (id, open) => {
|
|
173
177
|
setExpanded((current) => {
|
|
174
178
|
const next = new Set(current);
|
|
@@ -294,7 +298,7 @@ function FileTree(props) {
|
|
|
294
298
|
return descriptor(entry.item());
|
|
295
299
|
},
|
|
296
300
|
get selected() {
|
|
297
|
-
return memo(() => !!selectable())() ?
|
|
301
|
+
return memo(() => !!selectable())() ? isSelected(entry.item().node.id) : void 0;
|
|
298
302
|
},
|
|
299
303
|
get leading() {
|
|
300
304
|
return memo(() => entry.item().node.kind === "directory")() ? memo(() => !!entry.item().expanded)() ? createComponent(FolderOpen, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-tree.js","names":["File","Folder","FolderOpen","createComputed","createMemo","createSignal","For","Show","splitProps","untrack","keyedRows","cn","Button","Badge","Tree","TreeRow","buildFileTree","clampWindow","countChanges","describeChanges","FILE_CHANGE_LABELS","flattenFileTree","indexFileTree","initialExpanded","revealInWindow","files","label","defaultExpanded","compact","selected","onSelect","node","maxHeight","maxRows","showSummary","FILE_TREE_MAX_ROWS","CHANGE_VARIANT","added","modified","deleted","renamed","descriptor","row","id","parentId","level","expandable","kind","expanded","RowContent","props","_el$","_tmpl$","_$insert","name","_$effect","_p$","_v$","change","_v$2","e","_$className","t","_$setAttribute","undefined","_$createComponent","when","renamedFrom","children","_el$2","_tmpl$2","firstChild","RowTrailing","_$memo","additions","deletions","_el$4","_tmpl$5","_el$7","_el$5","_tmpl$3","_el$8","_tmpl$4","_el$0","_tmpl$6","_el$1","fileCount","toLocaleString","variant","size","FileTree","local","rest","build","nodes","roots","counts","setExpanded","Set","seen","wanted","folders","add","next","filter","has","rows","pageSize","Math","max","floor","requested","setRequested","start","end","mountedWindow","length","items","map","mounted","slice","rowsBefore","rowsAfter","activeId","setActiveId","selectable","toggle","open","current","delete","reveal","index","findIndex","select","get","activate","_el$10","_tmpl$1","_$spread","_$mergeProps","class","_el$11","_tmpl$7","rejected","_tmpl$8","_el$13","_tmpl$9","onClick","min","_el$14","_tmpl$0","visibleItems","onActiveIdChange","onExpand","onActivate","onSelectItem","onRequestReveal","selectionMode","typeaheadLabel","each","entry","item","leading","trailing","_$p","_$setStyleProperty","_el$15"],"sources":["../../../../src/components/composites/file-tree/file-tree.tsx"],"sourcesContent":["import { File, Folder, FolderOpen } from 'lucide-solid'\nimport {\n createComputed,\n createMemo,\n createSignal,\n For,\n Show,\n splitProps,\n untrack,\n type ComponentProps,\n} from 'solid-js'\nimport { keyedRows } from '#lib/keyed-rows'\nimport { cn } from '#lib/utils'\nimport { Button } from '../../ui/button'\nimport { Badge } from '../../ui/badge'\nimport { Tree, TreeRow, type TreeItemDescriptor } from '../tree'\nimport {\n buildFileTree,\n clampWindow,\n countChanges,\n describeChanges,\n FILE_CHANGE_LABELS,\n flattenFileTree,\n indexFileTree,\n initialExpanded,\n revealInWindow,\n type RowWindow,\n type FileChangeInput,\n type FileChangeKind,\n type FileTreeExpansion,\n type FileTreeNode,\n type FileTreeRow,\n} from './build-file-tree'\n\n/**\n * FileTree.\n *\n * The files an agent changed, as a folder tree. It is for a change set — dozens\n * to thousands of paths with an optional change kind each — and not for browsing\n * a workspace: it has no rename, drag, or filesystem action, and it never opens\n * anything. Reach for `Trace` lines when the agent touched two or three files, and\n * for the shared `Tree` directly when the host owns a real file explorer.\n *\n * ## Built on `Tree`, and why that fits\n *\n * `Tree` supplies the treeitem semantics and the WAI-ARIA keyboard model (arrows,\n * Home/End, roving tab stop) and leaves the projection to the host. A changed-file\n * tree is small enough that the whole projection can live in memory, and the\n * `Tree` contract for a mounted window — a complete `visibleItems` list with only\n * some rows rendered, `onRequestReveal` to mount a row the keyboard moved to — is\n * exactly the seam a bounded render needs, so this adds no navigation code of\n * its own. Typeahead is `Tree`'s too, searching row names: a typed prefix jumps\n * to the next row whose name starts with it.\n *\n * ## Large trees\n *\n * A collapsed folder's subtree is never visited or rendered, so a 5 000-file tree\n * costs what is visible. A tree of more than 100 files starts with only its top\n * level open (`defaultExpanded` overrides). Past `maxRows` visible rows only a\n * window of them is mounted, with a control above and below to move it a page at\n * a time. The full list is what keyboard navigation walks: an arrow key at the\n * window's edge grows it by a page, and a jump (End, Home, a typed letter) moves\n * it to the page holding the target instead of mounting every row between, so End\n * on a tree of thousands of open rows stays one page of work.\n *\n * ## Changes are claims\n *\n * A change kind is drawn — as a word on the row, so it is also spoken — only for a\n * file the host gave one. A file without one is listed and nothing more is said.\n * The summary counts what was supplied, and is silent about files with no kind.\n * Paths that are not acceptable (`..` segments, control characters) are not drawn;\n * their number is stated, so the list is never quietly shorter than the input.\n *\n * ## Selection is the host's\n *\n * Rows select only when `onSelect` is supplied; without it no row is selectable\n * and `aria-selected` is not set. Enter or a click on a folder expands it; on a\n * file it selects. Space selects either. The tree never opens a file itself — the\n * path is untrusted text, and what it means on this machine is the host's call.\n */\nexport type FileTreeProps = Omit<ComponentProps<'div'>, 'children' | 'onSelect'> & {\n /** Paths, or paths with a change kind. Both `/` and `\\` separate segments. */\n files: readonly (string | FileChangeInput)[]\n /** The tree's accessible name. Default \"Changed files\". */\n label?: string\n /**\n * Which folders start open: `true` all, `false` none, a number to that depth,\n * or a list of ids. Unset opens a small tree fully and a large one at its top level.\n */\n defaultExpanded?: FileTreeExpansion\n /** Merge a folder with a single folder child into one row. Default true. */\n compact?: boolean\n /** The selected node's id. Meaningful only with `onSelect`. */\n selected?: string\n /** Make rows selectable. Omit and nothing is selectable. */\n onSelect?: (path: string, node: FileTreeNode) => void\n /** Height of the tree box, which scrolls past it. A number is pixels. Default `20rem`. */\n maxHeight?: number | string\n /** Visible rows mounted at once; more are added a page at a time. Default 500. */\n maxRows?: number\n /** Show the count of changes above the tree. Default true. */\n showSummary?: boolean\n}\n\nexport const FILE_TREE_MAX_ROWS = 500\n\nconst CHANGE_VARIANT: Readonly<\n Record<FileChangeKind, 'success' | 'warning' | 'destructive' | 'info'>\n> = {\n added: 'success',\n modified: 'warning',\n deleted: 'destructive',\n renamed: 'info',\n}\n\nfunction descriptor(row: FileTreeRow): TreeItemDescriptor {\n return {\n id: row.node.id,\n parentId: row.parentId,\n level: row.level,\n expandable: row.node.kind === 'directory',\n expanded: row.expanded,\n }\n}\n\nfunction RowContent(props: { row: FileTreeRow }) {\n const node = () => props.row.node\n return (\n <>\n <span\n class={cn('truncate', {\n 'text-muted-foreground line-through': node().change === 'deleted',\n })}\n title={node().id}\n >\n {node().name}\n </span>\n <Show when={node().renamedFrom}>\n <span class=\"sr-only\">, renamed from {node().renamedFrom}</span>\n </Show>\n </>\n )\n}\n\nfunction RowTrailing(props: { row: FileTreeRow }) {\n const node = () => props.row.node\n return (\n <>\n <Show when={node().kind === 'file' && (node().additions || node().deletions)}>\n <span class=\"font-code text-2xs tabular-nums\">\n <Show when={node().additions !== undefined}>\n <span class=\"text-foreground\">+{node().additions}</span>\n </Show>{' '}\n <Show when={node().deletions !== undefined}>\n <span class=\"text-foreground\">−{node().deletions}</span>\n </Show>\n </span>\n </Show>\n <Show when={node().kind === 'directory' && !props.row.expanded}>\n <span class=\"text-2xs tabular-nums\">\n {node().fileCount.toLocaleString()} {node().fileCount === 1 ? 'file' : 'files'}\n </span>\n </Show>\n {/* The word is the signal; the tint only helps a sighted reader find it. */}\n <Show when={node().change}>\n {(change) => (\n <Badge variant={CHANGE_VARIANT[change()]} size=\"sm\">\n {FILE_CHANGE_LABELS[change()]}\n </Badge>\n )}\n </Show>\n </>\n )\n}\n\nexport function FileTree(props: FileTreeProps) {\n const [local, rest] = splitProps(props, [\n 'files',\n 'label',\n 'defaultExpanded',\n 'compact',\n 'selected',\n 'onSelect',\n 'maxHeight',\n 'maxRows',\n 'showSummary',\n 'class',\n ])\n\n const build = createMemo(() => buildFileTree(local.files, { compact: local.compact }))\n const nodes = createMemo(() => indexFileTree(build().roots))\n const counts = createMemo(() => countChanges(build().roots))\n\n // Folders the tree has already decided about. A change set that grows while\n // the agent works opens its new folders by the same rule as the first render,\n // and never reopens one the reader closed.\n const [expanded, setExpanded] = createSignal<ReadonlySet<string>>(new Set())\n let seen = new Set<string>()\n createComputed(() => {\n const { roots, fileCount } = build()\n const wanted = initialExpanded(roots, local.defaultExpanded, fileCount)\n const folders = new Set<string>()\n for (const [id, node] of nodes()) if (node.kind === 'directory') folders.add(id)\n untrack(() => {\n const next = new Set([...expanded()].filter((id) => folders.has(id)))\n for (const id of wanted) if (!seen.has(id)) next.add(id)\n seen = folders\n setExpanded(next)\n })\n })\n\n const rows = createMemo(() => flattenFileTree(build().roots, expanded()))\n const pageSize = () => Math.max(1, Math.floor(local.maxRows ?? FILE_TREE_MAX_ROWS))\n const [requested, setRequested] = createSignal<RowWindow>({ start: 0, end: 0 })\n const mountedWindow = createMemo(() =>\n clampWindow(\n requested().end === 0 ? { start: 0, end: pageSize() } : requested(),\n rows().length,\n pageSize()\n )\n )\n const items = createMemo(() => rows().map(descriptor))\n const mounted = keyedRows(\n () => rows().slice(mountedWindow().start, mountedWindow().end),\n (row) => row.node.id\n )\n const rowsBefore = () => mountedWindow().start\n const rowsAfter = () => Math.max(0, rows().length - mountedWindow().end)\n\n const [activeId, setActiveId] = createSignal<string | null>(null)\n const selectable = () => local.onSelect !== undefined\n\n const toggle = (id: string, open: boolean) => {\n setExpanded((current) => {\n const next = new Set(current)\n if (open) next.add(id)\n else next.delete(id)\n return next\n })\n }\n\n /** Mount the rows around one the keyboard is moving to, so focus can land on it. */\n const reveal = (id: string) => {\n const index = rows().findIndex((row) => row.node.id === id)\n setRequested(revealInWindow(mountedWindow(), index, rows().length, pageSize()))\n }\n\n const select = (id: string) => {\n const node = nodes().get(id)\n if (node) local.onSelect?.(id, node)\n }\n const activate = (id: string) => {\n const node = nodes().get(id)\n if (!node) return\n if (node.kind === 'directory') toggle(id, !expanded().has(id))\n else select(id)\n }\n\n const maxHeight = () =>\n typeof local.maxHeight === 'number' ? `${local.maxHeight}px` : (local.maxHeight ?? '20rem')\n\n return (\n <div data-slot=\"file-tree\" class={cn('flex min-w-0 flex-col gap-1', local.class)} {...rest}>\n <Show when={local.showSummary !== false}>\n <p data-slot=\"file-tree-summary\" class=\"m-0 text-xs text-muted-foreground\">\n {describeChanges(counts())}\n <Show when={build().rejected.length > 0}>\n {' '}\n · {build().rejected.length.toLocaleString()}{' '}\n {build().rejected.length === 1 ? 'path' : 'paths'} ignored as not valid\n </Show>\n </p>\n </Show>\n <Show when={rows().length === 0 && local.showSummary === false}>\n <p class=\"m-0 text-xs text-muted-foreground\">No changed files</p>\n </Show>\n <Show when={rows().length > 0}>\n <Show when={rowsBefore() > 0}>\n <div>\n <Button\n variant=\"ghost\"\n size=\"2xs\"\n onClick={() =>\n setRequested({\n start: Math.max(0, mountedWindow().start - pageSize()),\n end: mountedWindow().end,\n })\n }\n >\n Show {Math.min(rowsBefore(), pageSize()).toLocaleString()} earlier rows (\n {rowsBefore().toLocaleString()} not shown)\n </Button>\n </div>\n </Show>\n <div class=\"scroll-fade overflow-auto rounded-md\" style={{ 'max-height': maxHeight() }}>\n <Tree\n aria-label={local.label ?? 'Changed files'}\n visibleItems={items()}\n activeId={activeId()}\n onActiveIdChange={setActiveId}\n onExpand={toggle}\n onActivate={(id) => activate(id)}\n onSelectItem={(id) => select(id)}\n onRequestReveal={reveal}\n selectionMode={selectable() ? 'single' : undefined}\n typeaheadLabel={(id) => nodes().get(id)?.name ?? ''}\n >\n <For each={mounted()}>\n {(entry) => (\n <TreeRow\n item={descriptor(entry.item())}\n selected={selectable() ? local.selected === entry.item().node.id : undefined}\n leading={\n entry.item().node.kind === 'directory' ? (\n entry.item().expanded ? (\n <FolderOpen aria-hidden=\"true\" class=\"text-muted-foreground\" />\n ) : (\n <Folder aria-hidden=\"true\" class=\"text-muted-foreground\" />\n )\n ) : (\n <File aria-hidden=\"true\" class=\"text-muted-foreground\" />\n )\n }\n trailing={<RowTrailing row={entry.item()} />}\n >\n <RowContent row={entry.item()} />\n </TreeRow>\n )}\n </For>\n </Tree>\n </div>\n <Show when={rowsAfter() > 0}>\n <div>\n <Button\n variant=\"ghost\"\n size=\"2xs\"\n onClick={() =>\n setRequested({\n start: mountedWindow().start,\n end: Math.min(rows().length, mountedWindow().end + pageSize()),\n })\n }\n >\n Show {Math.min(rowsAfter(), pageSize()).toLoca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AAA;UAAA;UAAA,IAAA7F,WAAA;WAAA,OAAAH,gBAEvChB,YAAU,EAAA,IAACP,MAAG;YAAA,OAAEsH,MAAMC,KAAK;WAAC,EAAA,CAAA;UAAA;SAAA,CAAA;QAEhC,CAAA;OAAA;MAAA,CAAA,CAAA;MAAA1G,QAAA6G,QAAAC,iBAAAhB,QAAA,cAjCkErH,UAAU,CAAC,CAAA;MAAA,OAAAqH;KAAA,EAAA,CAAA;KAAApF,gBAqCnF1D,MAAI;MAAA,IAAC2D,OAAI;OAAA,OAAEwD,UAAU,IAAI;MAAC;MAAA,IAAAtD,WAAA;OAAA,IAAAkG,SAAApB,QAAA;OAAA7F,OAAAiH,QAAArG,gBAEtBrD,QAAM;QACL4E,SAAO;QACPC,MAAI;QACJ0D,eACEnC,aAAa;SACXC,OAAOE,cAAc,CAAC,CAACF;SACvBC,KAAKN,KAAKwC,IAAI1C,KAAK,CAAC,CAACU,QAAQD,cAAc,CAAC,CAACD,MAAMP,SAAS,CAAC;QAC/D,CAAC;QAAC,IAAAvC,WAAA;SAAA,OAAA;UAAA;UAAAK,WAGEmC,KAAKwC,IAAI1B,UAAU,GAAGf,SAAS,CAAC,CAAC,CAACpB,eAAe,CAAC;UAAA;UAAAd,WACvDiD,UAAU,CAAC,CAACnC,eAAe,CAAC;UAAA;SAAA;QAAA;OAAA,CAAA,CAAA;OAAA,OAAA+E;MAAA;KAAA,CAAA;IAAA;GAAA;EAAA,CAAA,GAAA,IAAA;EAAA,OAAA9B;CAAA,EAAA,CAAA;AAO3C"}
|
|
1
|
+
{"version":3,"file":"file-tree.js","names":["File","Folder","FolderOpen","createComputed","createMemo","createSelector","createSignal","For","Show","splitProps","untrack","keyedRows","cn","Button","Badge","Tree","TreeRow","buildFileTree","clampWindow","countChanges","describeChanges","FILE_CHANGE_LABELS","flattenFileTree","indexFileTree","initialExpanded","revealInWindow","files","label","defaultExpanded","compact","selected","onSelect","node","maxHeight","maxRows","showSummary","FILE_TREE_MAX_ROWS","CHANGE_VARIANT","added","modified","deleted","renamed","sameRow","previous","next","expanded","level","parentId","descriptor","row","id","expandable","kind","RowContent","props","_el$","_tmpl$","_$insert","name","_$effect","_p$","_v$","change","_v$2","e","_$className","t","_$setAttribute","undefined","_$createComponent","when","renamedFrom","children","_el$2","_tmpl$2","firstChild","RowTrailing","_$memo","additions","deletions","_el$4","_tmpl$5","_el$7","_el$5","_tmpl$3","_el$8","_tmpl$4","_el$0","_tmpl$6","_el$1","fileCount","toLocaleString","variant","size","FileTree","local","rest","build","nodes","roots","counts","setExpanded","Set","seen","wanted","folders","add","filter","has","rows","pageSize","Math","max","floor","requested","setRequested","start","end","mountedWindow","length","items","map","mounted","slice","rowsBefore","rowsAfter","activeId","setActiveId","selectable","isSelected","toggle","open","current","delete","reveal","index","findIndex","select","get","activate","_el$10","_tmpl$1","_$spread","_$mergeProps","class","_el$11","_tmpl$7","rejected","_tmpl$8","_el$13","_tmpl$9","onClick","min","_el$14","_tmpl$0","visibleItems","onActiveIdChange","onExpand","onActivate","onSelectItem","onRequestReveal","selectionMode","typeaheadLabel","each","entry","item","leading","trailing","_$p","_$setStyleProperty","_el$15"],"sources":["../../../../src/components/composites/file-tree/file-tree.tsx"],"sourcesContent":["import { File, Folder, FolderOpen } from 'lucide-solid'\nimport {\n createComputed,\n createMemo,\n createSelector,\n createSignal,\n For,\n Show,\n splitProps,\n untrack,\n type ComponentProps,\n} from 'solid-js'\nimport { keyedRows } from '#lib/keyed-rows'\nimport { cn } from '#lib/utils'\nimport { Button } from '../../ui/button'\nimport { Badge } from '../../ui/badge'\nimport { Tree, TreeRow, type TreeItemDescriptor } from '../tree'\nimport {\n buildFileTree,\n clampWindow,\n countChanges,\n describeChanges,\n FILE_CHANGE_LABELS,\n flattenFileTree,\n indexFileTree,\n initialExpanded,\n revealInWindow,\n type RowWindow,\n type FileChangeInput,\n type FileChangeKind,\n type FileTreeExpansion,\n type FileTreeNode,\n type FileTreeRow,\n} from './build-file-tree'\n\n/**\n * FileTree.\n *\n * The files an agent changed, as a folder tree. It is for a change set — dozens\n * to thousands of paths with an optional change kind each — and not for browsing\n * a workspace: it has no rename, drag, or filesystem action, and it never opens\n * anything. Reach for `Trace` lines when the agent touched two or three files, and\n * for the shared `Tree` directly when the host owns a real file explorer.\n *\n * ## Built on `Tree`, and why that fits\n *\n * `Tree` supplies the treeitem semantics and the WAI-ARIA keyboard model (arrows,\n * Home/End, roving tab stop) and leaves the projection to the host. A changed-file\n * tree is small enough that the whole projection can live in memory, and the\n * `Tree` contract for a mounted window — a complete `visibleItems` list with only\n * some rows rendered, `onRequestReveal` to mount a row the keyboard moved to — is\n * exactly the seam a bounded render needs, so this adds no navigation code of\n * its own. Typeahead is `Tree`'s too, searching row names: a typed prefix jumps\n * to the next row whose name starts with it.\n *\n * ## Large trees\n *\n * A collapsed folder's subtree is never visited or rendered, so a 5 000-file tree\n * costs what is visible. A tree of more than 100 files starts with only its top\n * level open (`defaultExpanded` overrides). Past `maxRows` visible rows only a\n * window of them is mounted, with a control above and below to move it a page at\n * a time. The full list is what keyboard navigation walks: an arrow key at the\n * window's edge grows it by a page, and a jump (End, Home, a typed letter) moves\n * it to the page holding the target instead of mounting every row between, so End\n * on a tree of thousands of open rows stays one page of work.\n *\n * ## Changes are claims\n *\n * A change kind is drawn — as a word on the row, so it is also spoken — only for a\n * file the host gave one. A file without one is listed and nothing more is said.\n * The summary counts what was supplied, and is silent about files with no kind.\n * Paths that are not acceptable (`..` segments, control characters) are not drawn;\n * their number is stated, so the list is never quietly shorter than the input.\n *\n * ## Selection is the host's\n *\n * Rows select only when `onSelect` is supplied; without it no row is selectable\n * and `aria-selected` is not set. Enter or a click on a folder expands it; on a\n * file it selects. Space selects either. The tree never opens a file itself — the\n * path is untrusted text, and what it means on this machine is the host's call.\n */\nexport type FileTreeProps = Omit<ComponentProps<'div'>, 'children' | 'onSelect'> & {\n /** Paths, or paths with a change kind. Both `/` and `\\` separate segments. */\n files: readonly (string | FileChangeInput)[]\n /** The tree's accessible name. Default \"Changed files\". */\n label?: string\n /**\n * Which folders start open: `true` all, `false` none, a number to that depth,\n * or a list of ids. Unset opens a small tree fully and a large one at its top level.\n */\n defaultExpanded?: FileTreeExpansion\n /** Merge a folder with a single folder child into one row. Default true. */\n compact?: boolean\n /** The selected node's id. Meaningful only with `onSelect`. */\n selected?: string\n /** Make rows selectable. Omit and nothing is selectable. */\n onSelect?: (path: string, node: FileTreeNode) => void\n /** Height of the tree box, which scrolls past it. A number is pixels. Default `20rem`. */\n maxHeight?: number | string\n /** Visible rows mounted at once; more are added a page at a time. Default 500. */\n maxRows?: number\n /** Show the count of changes above the tree. Default true. */\n showSummary?: boolean\n}\n\nexport const FILE_TREE_MAX_ROWS = 500\n\nconst CHANGE_VARIANT: Readonly<\n Record<FileChangeKind, 'success' | 'warning' | 'destructive' | 'info'>\n> = {\n added: 'success',\n modified: 'warning',\n deleted: 'destructive',\n renamed: 'info',\n}\n\nfunction sameRow(previous: FileTreeRow, next: FileTreeRow) {\n return (\n previous.node === next.node &&\n previous.expanded === next.expanded &&\n previous.level === next.level &&\n previous.parentId === next.parentId\n )\n}\n\nfunction descriptor(row: FileTreeRow): TreeItemDescriptor {\n return {\n id: row.node.id,\n parentId: row.parentId,\n level: row.level,\n expandable: row.node.kind === 'directory',\n expanded: row.expanded,\n }\n}\n\nfunction RowContent(props: { row: FileTreeRow }) {\n const node = () => props.row.node\n return (\n <>\n <span\n class={cn('truncate', {\n 'text-muted-foreground line-through': node().change === 'deleted',\n })}\n title={node().id}\n >\n {node().name}\n </span>\n <Show when={node().renamedFrom}>\n <span class=\"sr-only\">, renamed from {node().renamedFrom}</span>\n </Show>\n </>\n )\n}\n\nfunction RowTrailing(props: { row: FileTreeRow }) {\n const node = () => props.row.node\n return (\n <>\n <Show when={node().kind === 'file' && (node().additions || node().deletions)}>\n <span class=\"font-code text-2xs tabular-nums\">\n <Show when={node().additions !== undefined}>\n <span class=\"text-foreground\">+{node().additions}</span>\n </Show>{' '}\n <Show when={node().deletions !== undefined}>\n <span class=\"text-foreground\">−{node().deletions}</span>\n </Show>\n </span>\n </Show>\n <Show when={node().kind === 'directory' && !props.row.expanded}>\n <span class=\"text-2xs tabular-nums\">\n {node().fileCount.toLocaleString()} {node().fileCount === 1 ? 'file' : 'files'}\n </span>\n </Show>\n {/* The word is the signal; the tint only helps a sighted reader find it. */}\n <Show when={node().change}>\n {(change) => (\n <Badge variant={CHANGE_VARIANT[change()]} size=\"sm\">\n {FILE_CHANGE_LABELS[change()]}\n </Badge>\n )}\n </Show>\n </>\n )\n}\n\nexport function FileTree(props: FileTreeProps) {\n const [local, rest] = splitProps(props, [\n 'files',\n 'label',\n 'defaultExpanded',\n 'compact',\n 'selected',\n 'onSelect',\n 'maxHeight',\n 'maxRows',\n 'showSummary',\n 'class',\n ])\n\n const build = createMemo(() => buildFileTree(local.files, { compact: local.compact }))\n const nodes = createMemo(() => indexFileTree(build().roots))\n const counts = createMemo(() => countChanges(build().roots))\n\n // Folders the tree has already decided about. A change set that grows while\n // the agent works opens its new folders by the same rule as the first render,\n // and never reopens one the reader closed.\n const [expanded, setExpanded] = createSignal<ReadonlySet<string>>(new Set())\n let seen = new Set<string>()\n createComputed(() => {\n const { roots, fileCount } = build()\n const wanted = initialExpanded(roots, local.defaultExpanded, fileCount)\n const folders = new Set<string>()\n for (const [id, node] of nodes()) if (node.kind === 'directory') folders.add(id)\n untrack(() => {\n const next = new Set([...expanded()].filter((id) => folders.has(id)))\n for (const id of wanted) if (!seen.has(id)) next.add(id)\n seen = folders\n setExpanded(next)\n })\n })\n\n const rows = createMemo(() => flattenFileTree(build().roots, expanded()))\n const pageSize = () => Math.max(1, Math.floor(local.maxRows ?? FILE_TREE_MAX_ROWS))\n const [requested, setRequested] = createSignal<RowWindow>({ start: 0, end: 0 })\n const mountedWindow = createMemo(() =>\n clampWindow(\n requested().end === 0 ? { start: 0, end: pageSize() } : requested(),\n rows().length,\n pageSize()\n )\n )\n const items = createMemo(() => rows().map(descriptor))\n // Flattening returns a fresh row object for every row on each expand or collapse;\n // only a row whose own fields changed should update, not all of them.\n const mounted = keyedRows(\n () => rows().slice(mountedWindow().start, mountedWindow().end),\n (row) => row.node.id,\n sameRow\n )\n const rowsBefore = () => mountedWindow().start\n const rowsAfter = () => Math.max(0, rows().length - mountedWindow().end)\n\n const [activeId, setActiveId] = createSignal<string | null>(null)\n const selectable = () => local.onSelect !== undefined\n const isSelected = createSelector(() => local.selected)\n\n const toggle = (id: string, open: boolean) => {\n setExpanded((current) => {\n const next = new Set(current)\n if (open) next.add(id)\n else next.delete(id)\n return next\n })\n }\n\n /** Mount the rows around one the keyboard is moving to, so focus can land on it. */\n const reveal = (id: string) => {\n const index = rows().findIndex((row) => row.node.id === id)\n setRequested(revealInWindow(mountedWindow(), index, rows().length, pageSize()))\n }\n\n const select = (id: string) => {\n const node = nodes().get(id)\n if (node) local.onSelect?.(id, node)\n }\n const activate = (id: string) => {\n const node = nodes().get(id)\n if (!node) return\n if (node.kind === 'directory') toggle(id, !expanded().has(id))\n else select(id)\n }\n\n const maxHeight = () =>\n typeof local.maxHeight === 'number' ? `${local.maxHeight}px` : (local.maxHeight ?? '20rem')\n\n return (\n <div data-slot=\"file-tree\" class={cn('flex min-w-0 flex-col gap-1', local.class)} {...rest}>\n <Show when={local.showSummary !== false}>\n <p data-slot=\"file-tree-summary\" class=\"m-0 text-xs text-muted-foreground\">\n {describeChanges(counts())}\n <Show when={build().rejected.length > 0}>\n {' '}\n · {build().rejected.length.toLocaleString()}{' '}\n {build().rejected.length === 1 ? 'path' : 'paths'} ignored as not valid\n </Show>\n </p>\n </Show>\n <Show when={rows().length === 0 && local.showSummary === false}>\n <p class=\"m-0 text-xs text-muted-foreground\">No changed files</p>\n </Show>\n <Show when={rows().length > 0}>\n <Show when={rowsBefore() > 0}>\n <div>\n <Button\n variant=\"ghost\"\n size=\"2xs\"\n onClick={() =>\n setRequested({\n start: Math.max(0, mountedWindow().start - pageSize()),\n end: mountedWindow().end,\n })\n }\n >\n Show {Math.min(rowsBefore(), pageSize()).toLocaleString()} earlier rows (\n {rowsBefore().toLocaleString()} not shown)\n </Button>\n </div>\n </Show>\n <div class=\"scroll-fade overflow-auto rounded-md\" style={{ 'max-height': maxHeight() }}>\n <Tree\n aria-label={local.label ?? 'Changed files'}\n visibleItems={items()}\n activeId={activeId()}\n onActiveIdChange={setActiveId}\n onExpand={toggle}\n onActivate={(id) => activate(id)}\n onSelectItem={(id) => select(id)}\n onRequestReveal={reveal}\n selectionMode={selectable() ? 'single' : undefined}\n typeaheadLabel={(id) => nodes().get(id)?.name ?? ''}\n >\n <For each={mounted()}>\n {(entry) => (\n <TreeRow\n item={descriptor(entry.item())}\n selected={selectable() ? isSelected(entry.item().node.id) : undefined}\n leading={\n entry.item().node.kind === 'directory' ? (\n entry.item().expanded ? (\n <FolderOpen aria-hidden=\"true\" class=\"text-muted-foreground\" />\n ) : (\n <Folder aria-hidden=\"true\" class=\"text-muted-foreground\" />\n )\n ) : (\n <File aria-hidden=\"true\" class=\"text-muted-foreground\" />\n )\n }\n trailing={<RowTrailing row={entry.item()} />}\n >\n <RowContent row={entry.item()} />\n </TreeRow>\n )}\n </For>\n </Tree>\n </div>\n <Show when={rowsAfter() > 0}>\n <div>\n <Button\n variant=\"ghost\"\n size=\"2xs\"\n onClick={() =>\n setRequested({\n start: mountedWindow().start,\n end: Math.min(rows().length, mountedWindow().end + pageSize()),\n })\n }\n >\n Show {Math.min(rowsAfter(), pageSize()).toLocaleString()} more rows (\n {rowsAfter().toLocaleString()} not shown)\n </Button>\n </div>\n </Show>\n </Show>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAyGA,IAAaoC,qBAAqB;AAElC,IAAMC,iBAEF;CACFC,OAAO;CACPC,UAAU;CACVC,SAAS;CACTC,SAAS;AACX;AAEA,SAASC,QAAQC,UAAuBC,MAAmB;CACzD,OACED,SAASX,SAASY,KAAKZ,QACvBW,SAASE,aAAaD,KAAKC,YAC3BF,SAASG,UAAU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EmH,MAAMC,KAAK;WAAC,EAAA,CAAA;UAAA;SAAA,CAAA;QAEhC,CAAA;OAAA;MAAA,CAAA,CAAA;MAAA1G,QAAA6G,QAAAC,iBAAAhB,QAAA,cAjCkExH,UAAU,CAAC,CAAA;MAAA,OAAAwH;KAAA,EAAA,CAAA;KAAApF,gBAqCnF7D,MAAI;MAAA,IAAC8D,OAAI;OAAA,OAAEuD,UAAU,IAAI;MAAC;MAAA,IAAArD,WAAA;OAAA,IAAAkG,SAAApB,QAAA;OAAA7F,OAAAiH,QAAArG,gBAEtBxD,QAAM;QACL+E,SAAO;QACPC,MAAI;QACJ0D,eACEpC,aAAa;SACXC,OAAOE,cAAc,CAAC,CAACF;SACvBC,KAAKN,KAAKyC,IAAI3C,KAAK,CAAC,CAACU,QAAQD,cAAc,CAAC,CAACD,MAAMP,SAAS,CAAC;QAC/D,CAAC;QAAC,IAAAtC,WAAA;SAAA,OAAA;UAAA;UAAAK,WAGEkC,KAAKyC,IAAI3B,UAAU,GAAGf,SAAS,CAAC,CAAC,CAACnB,eAAe,CAAC;UAAA;UAAAd,WACvDgD,UAAU,CAAC,CAAClC,eAAe,CAAC;UAAA;SAAA;QAAA;OAAA,CAAA,CAAA;OAAA,OAAA+E;MAAA;KAAA,CAAA;IAAA;GAAA;EAAA,CAAA,GAAA,IAAA;EAAA,OAAA9B;CAAA,EAAA,CAAA;AAO3C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-picker.js","names":["Radio","ChevronDown","ImageUp","Trash2","For","Show","createSignal","createUniqueId","splitProps","Dynamic","createLatestAction","cn","Button","Popover","PopoverContent","PopoverTrigger","MarkImageError","markImageFromFile","markImageProblemCopy","MARK_IMAGE_MAX_SOURCE_BYTES","resolveShellIcon","shellIconEntries","shellIconLabel","label","value","onValueChange","key","defaultKey","image","onImageChange","disabled","class","IconPicker","props","inputId","problem","setProblem","uploads","fileInput","setFileInput","upload","file","undefined","outcome","run","status","error","_el$","_tmpl$3","_$insert","_$createComponent","when","children","_el$2","_tmpl$","_el$3","firstChild","_el$4","nextSibling","_el$5","fallback","src","_el$0","_tmpl$4","_$effect","_$setAttribute","addEventListener","event","input","currentTarget","files","_$use","type","variant","size","pending","onClick","click","_$memo","_p$","_v$","_v$2","e","t","message","_el$1","_tmpl$5","_el$6","_tmpl$2","_el$9","onChange","each","entry","Icon","Item","ItemInput","ItemLabel","title","_el$10","_tmpl$6","_$className","trigger","IconPickerDropdown","open","setOpen","local","picker","Current","onOpenChange","placement","as","_el$11","_tmpl$7","component","_el$12","_tmpl$8","_$mergeProps"],"sources":["../../../../src/components/composites/icon-picker/icon-picker.tsx"],"sourcesContent":["import { RadioGroup as Radio } from '@kobalte/core/radio-group'\nimport { ChevronDown, ImageUp, Trash2 } from 'lucide-solid'\nimport type { JSX } from 'solid-js'\nimport { For, Show, createSignal, createUniqueId, splitProps } from 'solid-js'\nimport { Dynamic } from 'solid-js/web'\nimport { createLatestAction } from '#lib/async-action'\nimport { cn } from '#lib/utils'\nimport { Button } from '../../ui/button'\nimport { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover'\nimport {\n MarkImageError,\n markImageFromFile,\n markImageProblemCopy,\n MARK_IMAGE_MAX_SOURCE_BYTES,\n} from './image-data-url'\nimport { resolveShellIcon, shellIconEntries, shellIconLabel } from './shell-icons'\n\n/**\n * IconPicker.\n *\n * The control behind \"choose an icon\" for a workspace or a project: a grid of\n * curated glyphs, and optionally an uploaded picture in their place.\n *\n * It is a single-choice group. The glyph grid is a Kobalte radio group, so\n * arrow keys move the choice and Tab enters and leaves the grid as one stop,\n * which is the contract a 56-cell grid needs to stay usable from a keyboard. An\n * uploaded image is a separate state, not a 57th cell: while `image` is set no\n * glyph is checked, and choosing a glyph asks the caller to drop the image, so\n * the stored mark is never both.\n *\n * The picker does not persist anything. The caller owns `value` and `image`\n * and saves them with the rest of its form; the image arrives already resized\n * to the stored square (see `markImageFromFile`).\n */\nexport type IconPickerProps = {\n /** The group's accessible name, e.g. \"Workspace icon\". */\n label: string\n /** The checked icon key; ignored while `image` is set. */\n value: string | undefined\n onValueChange(key: string): void\n /** The key the surface treats as unset, labelled \"default\" in the grid. */\n defaultKey?: string\n /** An uploaded mark (a data URL) currently chosen in place of a glyph. */\n image?: string\n /**\n * Called with the resized upload, or `undefined` for Remove. Omit it for a\n * surface that offers glyphs only; the upload row then does not render.\n */\n onImageChange?(image: string | undefined): void\n disabled?: boolean\n class?: string\n}\n\nexport function IconPicker(props: IconPickerProps) {\n const inputId = createUniqueId()\n const [problem, setProblem] = createSignal<string>()\n const uploads = createLatestAction()\n const [fileInput, setFileInput] = createSignal<HTMLInputElement>()\n\n const upload = async (file: File | undefined) => {\n if (!file || !props.onImageChange) return\n setProblem(undefined)\n const outcome = await uploads.run(() => markImageFromFile(file))\n if (outcome.status === 'done') props.onImageChange?.(outcome.value)\n else if (outcome.status === 'failed')\n setProblem(\n markImageProblemCopy[\n outcome.error instanceof MarkImageError ? outcome.error.problem : 'unreadable'\n ]\n )\n }\n\n return (\n <div data-slot=\"icon-picker\" class={cn('flex flex-col gap-3', props.class)}>\n <Show when={props.onImageChange}>\n <div class=\"flex items-center gap-3\" data-slot=\"icon-picker-upload\">\n <span\n aria-hidden=\"true\"\n class=\"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-muted\"\n >\n <Show\n when={props.image}\n fallback={<ImageUp class=\"size-5 text-muted-foreground\" aria-hidden=\"true\" />}\n >\n {(src) => <img src={src()} alt=\"\" class=\"size-full object-cover\" />}\n </Show>\n </span>\n <div class=\"flex flex-wrap items-center gap-2\">\n <input\n ref={setFileInput}\n id={inputId}\n type=\"file\"\n class=\"sr-only\"\n tabIndex={-1}\n // The visible button drives this input; hide the duplicate from assistive\n // technology but keep a name so the form-label rule is satisfied.\n aria-hidden=\"true\"\n aria-label={props.image ? 'Replace image' : 'Upload image'}\n accept=\"image/png,image/jpeg,image/webp,image/gif\"\n disabled={props.disabled}\n onChange={(event) => {\n const input = event.currentTarget\n void upload(input.files?.[0])\n // Clearing the value lets the same file be chosen again after Remove.\n input.value = ''\n }}\n />\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n disabled={props.disabled || uploads.pending()}\n onClick={() => fileInput()?.click()}\n >\n <ImageUp aria-hidden=\"true\" />\n {props.image ? 'Replace image' : 'Upload image'}\n </Button>\n <Show when={props.image}>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n disabled={props.disabled || uploads.pending()}\n onClick={() => {\n setProblem(undefined)\n props.onImageChange?.(undefined)\n }}\n >\n <Trash2 aria-hidden=\"true\" />\n Remove image\n </Button>\n </Show>\n </div>\n </div>\n <Show when={problem()}>\n {(message) => (\n <p role=\"alert\" class=\"text-sm text-destructive\">\n {message()}\n </p>\n )}\n </Show>\n <p class=\"text-xs text-muted-foreground\">\n PNG, JPEG, WebP or GIF up to {MARK_IMAGE_MAX_SOURCE_BYTES / 1024 / 1024} MB. It is cropped\n to a square.\n </p>\n </Show>\n <Radio\n aria-label={props.label}\n value={props.image ? '' : (props.value ?? '')}\n disabled={props.disabled}\n onChange={(key) => {\n if (key) props.onValueChange(key)\n }}\n class=\"grid grid-cols-[repeat(auto-fill,minmax(2.5rem,1fr))] gap-1.5\"\n >\n <For each={shellIconEntries}>\n {(entry) => {\n const Icon = resolveShellIcon(entry.key)\n return (\n <Radio.Item value={entry.key} class=\"contents\">\n <Radio.ItemInput class=\"peer\" />\n <Radio.ItemLabel\n title={entry.key === props.defaultKey ? `${entry.label} (default)` : entry.label}\n class={cn(\n 'flex size-10 cursor-pointer items-center justify-center rounded-lg border border-border bg-card text-muted-foreground',\n 'transition-colors ease-out',\n 'hover:bg-surface-hover hover:text-foreground',\n 'peer-focus-visible:border-ring peer-focus-visible:ring-3 peer-focus-visible:ring-primary-subtle',\n 'data-[checked]:border-primary data-[checked]:bg-primary-subtle data-[checked]:text-primary',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50'\n )}\n >\n <Icon class=\"size-5\" aria-hidden=\"true\" />\n <span class=\"sr-only\">\n {entry.label}\n {entry.key === props.defaultKey ? ' (default)' : ''}\n </span>\n </Radio.ItemLabel>\n </Radio.Item>\n )\n }}\n </For>\n </Radio>\n </div>\n )\n}\n\n/**\n * IconPickerDropdown.\n *\n * The compact form of the picker for a settings row: one button showing the\n * current mark, opening the full grid (and the upload row, when the host offers\n * it) in a popover. Choosing a glyph applies it and closes the popover; an\n * upload or Remove leaves it open so the result is visible. The host owns the\n * value exactly as it does for `IconPicker`.\n */\nexport type IconPickerDropdownProps = IconPickerProps & {\n /** The mark shown on the trigger; defaults to the checked glyph or the uploaded image. */\n trigger?: JSX.Element\n}\n\nexport function IconPickerDropdown(props: IconPickerDropdownProps) {\n const [open, setOpen] = createSignal(false)\n const [local, picker] = splitProps(props, ['trigger', 'class'])\n const Current = () => resolveShellIcon(props.value ?? props.defaultKey ?? '')\n return (\n <Popover open={open()} onOpenChange={setOpen} placement=\"bottom-start\">\n <PopoverTrigger\n as={Button}\n type=\"button\"\n variant=\"outline\"\n data-slot=\"icon-picker-trigger\"\n aria-label={`${props.label}: ${props.image ? 'uploaded image' : shellIconLabel(props.value ?? props.defaultKey ?? '')}`}\n disabled={props.disabled}\n class={cn('gap-2', local.class)}\n >\n <span aria-hidden=\"true\" class=\"flex size-5 items-center justify-center overflow-hidden\">\n <Show\n when={local.trigger}\n fallback={\n <Show\n when={props.image}\n fallback={<Dynamic component={Current()} class=\"size-4\" aria-hidden=\"true\" />}\n >\n {(src) => <img src={src()} alt=\"\" class=\"size-full rounded-sm object-cover\" />}\n </Show>\n }\n >\n {local.trigger}\n </Show>\n </span>\n <ChevronDown class=\"size-4 text-muted-foreground\" aria-hidden=\"true\" />\n </PopoverTrigger>\n <PopoverContent class=\"w-88 max-w-(--kb-popper-content-available-width)\">\n <IconPicker\n {...picker}\n onValueChange={(key) => {\n picker.onValueChange(key)\n setOpen(false)\n }}\n />\n </PopoverContent>\n </Popover>\n )\n}\n"],"mappings":";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AAS8F,MAAM1E,KAAK;IAAC;IAAA,IAAAqB,WAAA;KAAA,OAAA,QAAA;MAAA,IAAA2D,SAAAC,QAAA;MAAA/D,OAAA8D,QAAA7D,gBAG5B7C,MAAI;OAAA,IACH8C,OAAI;QAAA,OAAEsD,MAAMJ;OAAO;OAAA,IACnBzC,WAAQ;QAAA,OAAAV,gBACL7C,MAAI;SAAA,IACH8C,OAAI;UAAA,OAAElB,MAAML;SAAK;SAAA,IACjBgC,WAAQ;UAAA,OAAAV,gBAAGzC,SAAO;WAAA,IAACwG,YAAS;YAAA,OAAEN,QAAQ;WAAC;WAAA,SAAA;WAAA,eAAA;UAAA,CAAA;SAAA;SAAAvD,WAErCS,eAAG;UAAA,IAAAqD,SAAAC,QAAA;UAAAnD,aAAAC,aAAAiD,QAAA,OAAerD,IAAI,CAAC,CAAA;UAAA,OAAAqD;SAAA,EAAA,CAAA;QAAqD,CAAA;OAAA;OAAA,IAAA9D,WAAA;QAAA,OAIjFqD,MAAMJ;OAAO;MAAA,CAAA,CAAA;MAAA,OAAAU;KAAA,EAAA,CAAA,GAAA7D,gBAGjBjD,aAAW;MAAA,SAAA;MAAA,eAAA;KAAA,CAAA,CAAA;IAAA;GAAA,CAAA,GAAAiD,gBAEbpC,gBAAc;IAAA,SAAA;IAAA,IAAAsC,WAAA;KAAA,OAAAF,gBACZlB,YAAUoF,WACLV,QAAM,EACVjF,gBAAgBC,QAAQ;MACtBgF,OAAOjF,cAAcC,GAAG;MACxB8E,QAAQ,KAAK;KACf,EAAC,CAAA,CAAA;IAAA;GAAA,CAAA,CAAA;EAAA;CAAA,CAAA;AAKX"}
|
|
1
|
+
{"version":3,"file":"icon-picker.js","names":["Radio","ChevronDown","ImageUp","Trash2","For","Show","createSignal","createUniqueId","splitProps","Dynamic","createLatestAction","cn","Button","Popover","PopoverContent","PopoverTrigger","MarkImageError","markImageFromFile","markImageProblemCopy","MARK_IMAGE_MAX_SOURCE_BYTES","resolveShellIcon","shellIconEntries","shellIconLabel","label","value","onValueChange","key","defaultKey","image","onImageChange","disabled","class","IconPicker","props","inputId","problem","setProblem","uploads","fileInput","setFileInput","upload","file","undefined","outcome","run","status","error","_el$","_tmpl$3","_$insert","_$createComponent","when","children","_el$2","_tmpl$","_el$3","firstChild","_el$4","nextSibling","_el$5","fallback","src","_el$0","_tmpl$4","_$effect","_$setAttribute","addEventListener","event","input","currentTarget","files","_$use","type","variant","size","pending","onClick","click","_$memo","_p$","_v$","_v$2","e","t","message","_el$1","_tmpl$5","_el$6","_tmpl$2","_el$9","onChange","each","entry","Icon","Item","ItemInput","ItemLabel","title","_el$10","_tmpl$6","_$className","trigger","IconPickerDropdown","open","setOpen","local","picker","Current","onOpenChange","placement","as","_el$11","_tmpl$7","component","_el$12","_tmpl$8","triggerSlot","_$mergeProps"],"sources":["../../../../src/components/composites/icon-picker/icon-picker.tsx"],"sourcesContent":["import { RadioGroup as Radio } from '@kobalte/core/radio-group'\nimport { ChevronDown, ImageUp, Trash2 } from 'lucide-solid'\nimport type { JSX } from 'solid-js'\nimport { For, Show, createSignal, createUniqueId, splitProps } from 'solid-js'\nimport { Dynamic } from 'solid-js/web'\nimport { createLatestAction } from '#lib/async-action'\nimport { cn } from '#lib/utils'\nimport { Button } from '../../ui/button'\nimport { Popover, PopoverContent, PopoverTrigger } from '../../ui/popover'\nimport {\n MarkImageError,\n markImageFromFile,\n markImageProblemCopy,\n MARK_IMAGE_MAX_SOURCE_BYTES,\n} from './image-data-url'\nimport { resolveShellIcon, shellIconEntries, shellIconLabel } from './shell-icons'\n\n/**\n * IconPicker.\n *\n * The control behind \"choose an icon\" for a workspace or a project: a grid of\n * curated glyphs, and optionally an uploaded picture in their place.\n *\n * It is a single-choice group. The glyph grid is a Kobalte radio group, so\n * arrow keys move the choice and Tab enters and leaves the grid as one stop,\n * which is the contract a 56-cell grid needs to stay usable from a keyboard. An\n * uploaded image is a separate state, not a 57th cell: while `image` is set no\n * glyph is checked, and choosing a glyph asks the caller to drop the image, so\n * the stored mark is never both.\n *\n * The picker does not persist anything. The caller owns `value` and `image`\n * and saves them with the rest of its form; the image arrives already resized\n * to the stored square (see `markImageFromFile`).\n */\nexport type IconPickerProps = {\n /** The group's accessible name, e.g. \"Workspace icon\". */\n label: string\n /** The checked icon key; ignored while `image` is set. */\n value: string | undefined\n onValueChange(key: string): void\n /** The key the surface treats as unset, labelled \"default\" in the grid. */\n defaultKey?: string\n /** An uploaded mark (a data URL) currently chosen in place of a glyph. */\n image?: string\n /**\n * Called with the resized upload, or `undefined` for Remove. Omit it for a\n * surface that offers glyphs only; the upload row then does not render.\n */\n onImageChange?(image: string | undefined): void\n disabled?: boolean\n class?: string\n}\n\nexport function IconPicker(props: IconPickerProps) {\n const inputId = createUniqueId()\n const [problem, setProblem] = createSignal<string>()\n const uploads = createLatestAction()\n const [fileInput, setFileInput] = createSignal<HTMLInputElement>()\n\n const upload = async (file: File | undefined) => {\n if (!file || !props.onImageChange) return\n setProblem(undefined)\n const outcome = await uploads.run(() => markImageFromFile(file))\n if (outcome.status === 'done') props.onImageChange?.(outcome.value)\n else if (outcome.status === 'failed')\n setProblem(\n markImageProblemCopy[\n outcome.error instanceof MarkImageError ? outcome.error.problem : 'unreadable'\n ]\n )\n }\n\n return (\n <div data-slot=\"icon-picker\" class={cn('flex flex-col gap-3', props.class)}>\n <Show when={props.onImageChange}>\n <div class=\"flex items-center gap-3\" data-slot=\"icon-picker-upload\">\n <span\n aria-hidden=\"true\"\n class=\"flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-lg border border-border bg-muted\"\n >\n <Show\n when={props.image}\n fallback={<ImageUp class=\"size-5 text-muted-foreground\" aria-hidden=\"true\" />}\n >\n {(src) => <img src={src()} alt=\"\" class=\"size-full object-cover\" />}\n </Show>\n </span>\n <div class=\"flex flex-wrap items-center gap-2\">\n <input\n ref={setFileInput}\n id={inputId}\n type=\"file\"\n class=\"sr-only\"\n tabIndex={-1}\n // The visible button drives this input; hide the duplicate from assistive\n // technology but keep a name so the form-label rule is satisfied.\n aria-hidden=\"true\"\n aria-label={props.image ? 'Replace image' : 'Upload image'}\n accept=\"image/png,image/jpeg,image/webp,image/gif\"\n disabled={props.disabled}\n onChange={(event) => {\n const input = event.currentTarget\n void upload(input.files?.[0])\n // Clearing the value lets the same file be chosen again after Remove.\n input.value = ''\n }}\n />\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n disabled={props.disabled || uploads.pending()}\n onClick={() => fileInput()?.click()}\n >\n <ImageUp aria-hidden=\"true\" />\n {props.image ? 'Replace image' : 'Upload image'}\n </Button>\n <Show when={props.image}>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n disabled={props.disabled || uploads.pending()}\n onClick={() => {\n setProblem(undefined)\n props.onImageChange?.(undefined)\n }}\n >\n <Trash2 aria-hidden=\"true\" />\n Remove image\n </Button>\n </Show>\n </div>\n </div>\n <Show when={problem()}>\n {(message) => (\n <p role=\"alert\" class=\"text-sm text-destructive\">\n {message()}\n </p>\n )}\n </Show>\n <p class=\"text-xs text-muted-foreground\">\n PNG, JPEG, WebP or GIF up to {MARK_IMAGE_MAX_SOURCE_BYTES / 1024 / 1024} MB. It is cropped\n to a square.\n </p>\n </Show>\n <Radio\n aria-label={props.label}\n value={props.image ? '' : (props.value ?? '')}\n disabled={props.disabled}\n onChange={(key) => {\n if (key) props.onValueChange(key)\n }}\n class=\"grid grid-cols-[repeat(auto-fill,minmax(2.5rem,1fr))] gap-1.5\"\n >\n <For each={shellIconEntries}>\n {(entry) => {\n const Icon = resolveShellIcon(entry.key)\n return (\n <Radio.Item value={entry.key} class=\"contents\">\n <Radio.ItemInput class=\"peer\" />\n <Radio.ItemLabel\n title={entry.key === props.defaultKey ? `${entry.label} (default)` : entry.label}\n class={cn(\n 'flex size-10 cursor-pointer items-center justify-center rounded-lg border border-border bg-card text-muted-foreground',\n 'transition-colors ease-out',\n 'hover:bg-surface-hover hover:text-foreground',\n 'peer-focus-visible:border-ring peer-focus-visible:ring-3 peer-focus-visible:ring-primary-subtle',\n 'data-[checked]:border-primary data-[checked]:bg-primary-subtle data-[checked]:text-primary',\n 'data-[disabled]:pointer-events-none data-[disabled]:opacity-50'\n )}\n >\n <Icon class=\"size-5\" aria-hidden=\"true\" />\n <span class=\"sr-only\">\n {entry.label}\n {entry.key === props.defaultKey ? ' (default)' : ''}\n </span>\n </Radio.ItemLabel>\n </Radio.Item>\n )\n }}\n </For>\n </Radio>\n </div>\n )\n}\n\n/**\n * IconPickerDropdown.\n *\n * The compact form of the picker for a settings row: one button showing the\n * current mark, opening the full grid (and the upload row, when the host offers\n * it) in a popover. Choosing a glyph applies it and closes the popover; an\n * upload or Remove leaves it open so the result is visible. The host owns the\n * value exactly as it does for `IconPicker`.\n */\nexport type IconPickerDropdownProps = IconPickerProps & {\n /** The mark shown on the trigger; defaults to the checked glyph or the uploaded image. */\n trigger?: JSX.Element\n}\n\nexport function IconPickerDropdown(props: IconPickerDropdownProps) {\n const [open, setOpen] = createSignal(false)\n const [local, picker] = splitProps(props, ['trigger', 'class'])\n const Current = () => resolveShellIcon(props.value ?? props.defaultKey ?? '')\n return (\n <Popover open={open()} onOpenChange={setOpen} placement=\"bottom-start\">\n <PopoverTrigger\n as={Button}\n type=\"button\"\n variant=\"outline\"\n data-slot=\"icon-picker-trigger\"\n aria-label={`${props.label}: ${props.image ? 'uploaded image' : shellIconLabel(props.value ?? props.defaultKey ?? '')}`}\n disabled={props.disabled}\n class={cn('gap-2', local.class)}\n >\n <span aria-hidden=\"true\" class=\"flex size-5 items-center justify-center overflow-hidden\">\n <Show\n when={local.trigger}\n fallback={\n <Show\n when={props.image}\n fallback={<Dynamic component={Current()} class=\"size-4\" aria-hidden=\"true\" />}\n >\n {(src) => <img src={src()} alt=\"\" class=\"size-full rounded-sm object-cover\" />}\n </Show>\n }\n >\n {(triggerSlot) => <>{triggerSlot()}</>}\n </Show>\n </span>\n <ChevronDown class=\"size-4 text-muted-foreground\" aria-hidden=\"true\" />\n </PopoverTrigger>\n <PopoverContent class=\"w-88 max-w-(--kb-popper-content-available-width)\">\n <IconPicker\n {...picker}\n onValueChange={(key) => {\n picker.onValueChange(key)\n setOpen(false)\n }}\n />\n </PopoverContent>\n </Popover>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqDA,SAAgBgC,WAAWC,OAAwB;CACjD,MAAMC,UAAU3B,eAAe;CAC/B,MAAM,CAAC4B,SAASC,cAAc9B,aAAqB;CACnD,MAAM+B,UAAU3B,mBAAmB;CACnC,MAAM,CAAC4B,WAAWC,gBAAgBjC,aAA+B;CAEjE,MAAMkC,SAAS,OAAOC,SAA2B;EAC/C,IAAI,CAACA,QAAQ,CAACR,MAAMJ,eAAe;EACnCO,WAAWM,KAAAA,CAAS;EACpB,MAAMC,UAAU,MAAMN,QAAQO,UAAU3B,kBAAkBwB,IAAI,CAAC;EAC/D,IAAIE,QAAQE,WAAW,QAAQZ,MAAMJ,gBAAgBc,QAAQnB,KAAK;OAC7D,IAAImB,QAAQE,WAAW,UAC1BT,WACElB,qBACEyB,QAAQG,iBAAiB9B,iBAAiB2B,QAAQG,MAAMX,UAAU,aAEtE;CACJ;CAEA,cAAA;EAAA,IAAAY,OAAAC,QAAA;EAAAC,OAAAF,MAAAG,gBAEK7C,MAAI;GAAA,IAAC8C,OAAI;IAAA,OAAElB,MAAMJ;GAAa;GAAA,IAAAuB,WAAA;IAAA,OAAA;YAAA;MAAA,IAAAC,QAAAC,OAAA,GAAAC,QAAAF,MAAAG,YAAAC,QAAAF,MAAAG,aAAAC,QAAAF,MAAAD;MAAAP,OAAAM,OAAAL,gBAMxB7C,MAAI;OAAA,IACH8C,OAAI;QAAA,OAAElB,MAAML;OAAK;OAAA,IACjBgC,WAAQ;QAAA,OAAAV,gBAAGhD,SAAO;SAAA,SAAA;SAAA,eAAA;QAAA,CAAA;OAAA;OAAAkD,WAEhBS,eAAG;QAAA,IAAAC,QAAAC,QAAA;QAAAC,aAAAC,aAAAH,OAAA,OAAeD,IAAI,CAA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own markers
|
|
6
6
|
* and the Sources list use. Without one the badge shows the source's host (read
|
|
7
7
|
* from the parsed URL, so it cannot be spoofed by a title), then a clipped title,
|
|
8
|
-
* and only then a neutral word
|
|
8
|
+
* and only then a neutral word, never an invented number.
|
|
9
9
|
*/
|
|
10
10
|
export declare function citationLabel(index: number | undefined, source: Source | undefined): string;
|
|
11
11
|
/**
|
|
@@ -9,7 +9,7 @@ var LABEL_LIMIT = 24;
|
|
|
9
9
|
* A 1-based `index` wins, because a number is what the sentence's own markers
|
|
10
10
|
* and the Sources list use. Without one the badge shows the source's host (read
|
|
11
11
|
* from the parsed URL, so it cannot be spoofed by a title), then a clipped title,
|
|
12
|
-
* and only then a neutral word
|
|
12
|
+
* and only then a neutral word, never an invented number.
|
|
13
13
|
*/
|
|
14
14
|
function citationLabel(index, source) {
|
|
15
15
|
if (index !== void 0 && Number.isInteger(index) && index >= 1 && index <= 9999) return String(index);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"citation.js","names":[],"sources":["../../../../src/components/composites/inline-citation/citation.ts"],"sourcesContent":["import { boundText } from '#lib/text'\nimport { sourceHost, sourceTitle, type Source } from '../sources/source'\n\n/** Characters of a host or title that fit in a badge before it is clipped. */\nconst LABEL_LIMIT = 24\n\n/**\n * The text on a citation badge.\n *\n * A 1-based `index` wins, because a number is what the sentence's own markers\n * and the Sources list use. Without one the badge shows the source's host (read\n * from the parsed URL, so it cannot be spoofed by a title), then a clipped title,\n * and only then a neutral word
|
|
1
|
+
{"version":3,"file":"citation.js","names":[],"sources":["../../../../src/components/composites/inline-citation/citation.ts"],"sourcesContent":["import { boundText } from '#lib/text'\nimport { sourceHost, sourceTitle, type Source } from '../sources/source'\n\n/** Characters of a host or title that fit in a badge before it is clipped. */\nconst LABEL_LIMIT = 24\n\n/**\n * The text on a citation badge.\n *\n * A 1-based `index` wins, because a number is what the sentence's own markers\n * and the Sources list use. Without one the badge shows the source's host (read\n * from the parsed URL, so it cannot be spoofed by a title), then a clipped title,\n * and only then a neutral word, never an invented number.\n */\nexport function citationLabel(index: number | undefined, source: Source | undefined): string {\n if (index !== undefined && Number.isInteger(index) && index >= 1 && index <= 9999) {\n return String(index)\n }\n if (source === undefined) return 'source'\n const host = sourceHost(source.url)\n if (host !== undefined) return boundText(host, LABEL_LIMIT)\n return boundText(source.title, LABEL_LIMIT) || 'source'\n}\n\n/**\n * The badge's accessible name. The visible label is a number or a host, which\n * says nothing on its own, so the name carries the title and host: a screen-reader\n * or voice-control user learns what is cited without opening the popover.\n */\nexport function citationName(sources: readonly Source[], index: number | undefined): string {\n const first = sources[0]\n if (first === undefined) return 'Citation'\n const label = citationLabel(index, first)\n if (sources.length > 1) {\n // Keep the visible badge text in the accessible name for label-content-name-mismatch checks.\n return `${label}+${sources.length - 1} — Sources ${label} and ${sources.length - 1} more`\n }\n const host = sourceHost(first.url)\n const title = sourceTitle(first)\n return host !== undefined && host !== title\n ? `Source ${label}: ${title}, ${host}`\n : `Source ${label}: ${title}`\n}\n\n/** Wrap a position into 0..count-1, so Previous on the first source goes to the last. */\nexport function wrapIndex(position: number, count: number): number {\n if (count <= 0) return 0\n return ((position % count) + count) % count\n}\n\n/**\n * How a citation's popover is open.\n *\n * - `peek` is a hover or keyboard-focus preview: it does not take focus, and it\n * goes away when the pointer or focus does.\n * - `pinned` is a deliberate open (click, tap, Enter, Space): focus moves into\n * the popover so its link and Previous/Next are reachable, and it stays until\n * Escape, an outside press, or the badge is pressed again.\n *\n * A popover that only opened on hover would exclude keyboard and touch readers;\n * one that only opened on press would make pointer users click to glance at a\n * source. This is the smallest model that serves both, and it is a pure function\n * so the awkward transitions (hover then click must pin, not toggle shut) are\n * tested rather than argued about.\n */\nexport type CitationMode = 'closed' | 'peek' | 'pinned'\nexport type CitationEvent = 'enter' | 'leave' | 'focus' | 'blur' | 'press' | 'dismiss'\n\nexport function nextCitationMode(mode: CitationMode, event: CitationEvent): CitationMode {\n switch (event) {\n case 'press':\n return mode === 'pinned' ? 'closed' : 'pinned'\n case 'dismiss':\n return 'closed'\n case 'enter':\n case 'focus':\n return mode === 'closed' ? 'peek' : mode\n case 'leave':\n case 'blur':\n return mode === 'peek' ? 'closed' : mode\n }\n}\n"],"mappings":";;;;AAIA,IAAM,cAAc;;;;;;;;;AAUpB,SAAgB,cAAc,OAA2B,QAAoC;CAC3F,IAAI,UAAU,KAAA,KAAa,OAAO,UAAU,KAAK,KAAK,SAAS,KAAK,SAAS,MAC3E,OAAO,OAAO,KAAK;CAErB,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,MAAM,OAAO,WAAW,OAAO,GAAG;CAClC,IAAI,SAAS,KAAA,GAAW,OAAO,UAAU,MAAM,WAAW;CAC1D,OAAO,UAAU,OAAO,OAAO,WAAW,KAAK;AACjD;;;;;;AAOA,SAAgB,aAAa,SAA4B,OAAmC;CAC1F,MAAM,QAAQ,QAAQ;CACtB,IAAI,UAAU,KAAA,GAAW,OAAO;CAChC,MAAM,QAAQ,cAAc,OAAO,KAAK;CACxC,IAAI,QAAQ,SAAS,GAEnB,OAAO,GAAG,MAAM,GAAG,QAAQ,SAAS,EAAE,aAAa,MAAM,OAAO,QAAQ,SAAS,EAAE;CAErF,MAAM,OAAO,WAAW,MAAM,GAAG;CACjC,MAAM,QAAQ,YAAY,KAAK;CAC/B,OAAO,SAAS,KAAA,KAAa,SAAS,QAClC,UAAU,MAAM,IAAI,MAAM,IAAI,SAC9B,UAAU,MAAM,IAAI;AAC1B;;AAGA,SAAgB,UAAU,UAAkB,OAAuB;CACjE,IAAI,SAAS,GAAG,OAAO;CACvB,QAAS,WAAW,QAAS,SAAS;AACxC;AAoBA,SAAgB,iBAAiB,MAAoB,OAAoC;CACvF,QAAQ,OAAR;EACE,KAAK,SACH,OAAO,SAAS,WAAW,WAAW;EACxC,KAAK,WACH,OAAO;EACT,KAAK;EACL,KAAK,SACH,OAAO,SAAS,WAAW,SAAS;EACtC,KAAK;EACL,KAAK,QACH,OAAO,SAAS,SAAS,WAAW;CACxC;AACF"}
|
|
@@ -3,7 +3,7 @@ import { type Source } from '../sources/source';
|
|
|
3
3
|
/**
|
|
4
4
|
* InlineCitation.
|
|
5
5
|
*
|
|
6
|
-
* A small badge inside a sentence
|
|
6
|
+
* A small badge inside a sentence, "1", or a host, that opens the source(s)
|
|
7
7
|
* behind the claim: title, host, address, snippet, and Previous/Next when several
|
|
8
8
|
* sources share one marker. It is an inline element for prose such as
|
|
9
9
|
* `MessageText`: it never breaks across lines, stays on the text baseline, and
|
|
@@ -22,7 +22,7 @@ import { type Source } from '../sources/source';
|
|
|
22
22
|
* - **Click, tap, Enter or Space pins.** Focus moves into the popover so its
|
|
23
23
|
* link and Previous/Next are reachable; it stays until Escape, an outside press,
|
|
24
24
|
* or the badge is pressed again, and focus returns to the badge. Pressing a badge
|
|
25
|
-
* that is only peeking pins it rather than toggling it shut
|
|
25
|
+
* that is only peeking pins it rather than toggling it shut, the transitions
|
|
26
26
|
* are the pure `nextCitationMode`.
|
|
27
27
|
*
|
|
28
28
|
* Kobalte's trigger toggles on every press, so `open` is controlled and its own
|