@adea-ai/ui 0.152.2 → 0.152.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/composites/about-dialog/about-dialog.js.map +1 -1
- package/dist/components/composites/accent-picker/accent-picker.js.map +1 -1
- package/dist/components/composites/accent-picker/custom-color-popover.js.map +1 -1
- package/dist/components/composites/account-menu/account-menu.js.map +1 -1
- package/dist/components/composites/action-button/action-button.js.map +1 -1
- package/dist/components/composites/appearance-editor/accent-swatch-groups.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-choices.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-editor.js.map +1 -1
- package/dist/components/composites/appearance-editor/appearance-rows.js.map +1 -1
- package/dist/components/composites/appearance-editor/font-settings-group.js.map +1 -1
- package/dist/components/composites/appearance-editor/theme-preview.js.map +1 -1
- package/dist/components/composites/catalog-browser/catalog-browser-group.js.map +1 -1
- package/dist/components/composites/catalog-browser/catalog-browser.js.map +1 -1
- package/dist/components/composites/catalog-browser/catalog-detail.js.map +1 -1
- package/dist/components/composites/chain-of-thought/chain-of-thought.js.map +1 -1
- package/dist/components/composites/chat/chat.js.map +1 -1
- package/dist/components/composites/checkpoint/checkpoint.js.map +1 -1
- package/dist/components/composites/confirmation/confirmation.js.map +1 -1
- package/dist/components/composites/context/context.js.map +1 -1
- package/dist/components/composites/file-tree/file-tree.js.map +1 -1
- package/dist/components/composites/help-center/help-center.js.map +1 -1
- package/dist/components/composites/icon-picker/icon-picker.js.map +1 -1
- package/dist/components/composites/inline-citation/inline-citation.js.map +1 -1
- package/dist/components/composites/list-row/list-row-control.js.map +1 -1
- package/dist/components/composites/list-row/list-row.js.map +1 -1
- package/dist/components/composites/message-scroller/message-scroller.js.map +1 -1
- package/dist/components/composites/model-selector/model-selector.js +3 -0
- package/dist/components/composites/model-selector/model-selector.js.map +1 -1
- package/dist/components/composites/plan/plan.js.map +1 -1
- package/dist/components/composites/queue/queue.js.map +1 -1
- package/dist/components/composites/reasoning/reasoning.js.map +1 -1
- package/dist/components/composites/scene-controls/scene-controls.js.map +1 -1
- package/dist/components/composites/settings/settings-layout.js.map +1 -1
- package/dist/components/composites/settings/settings-navigation.js.map +1 -1
- package/dist/components/composites/settings/settings.js.map +1 -1
- package/dist/components/composites/sources/sources.js.map +1 -1
- package/dist/components/composites/stack-trace/stack-trace.js.map +1 -1
- package/dist/components/composites/stat/stat.js.map +1 -1
- package/dist/components/composites/subagent/subagent.js.map +1 -1
- package/dist/components/composites/suggestion/suggestion.js.map +1 -1
- package/dist/components/composites/task/task.js.map +1 -1
- package/dist/components/composites/terminal/terminal.js.map +1 -1
- package/dist/components/composites/test-results/test-results.js.map +1 -1
- package/dist/components/composites/tool/tool.js.map +1 -1
- package/dist/components/composites/tree/tree.js.map +1 -1
- package/dist/components/composites/update-dialog/channel-control.js.map +1 -1
- package/dist/components/composites/update-dialog/update-dialog.js.map +1 -1
- package/dist/components/composites/workspace-mark/workspace-mark.js.map +1 -1
- package/dist/components/composites/workspace-switcher/workspace-reorder-dialog.js.map +1 -1
- package/dist/components/composites/workspace-switcher/workspace-switcher.js.map +1 -1
- package/dist/components/conversation/atomic/chat-composer.js.map +1 -1
- package/dist/components/conversation/busy-send-button.js.map +1 -1
- package/dist/components/conversation/chat-composer.js.map +1 -1
- package/dist/components/conversation/composer-menu.js.map +1 -1
- package/dist/components/conversation/conversation-avatar.js.map +1 -1
- package/dist/components/conversation/conversation-pane.js.map +1 -1
- package/dist/components/conversation/conversation-surface.js.map +1 -1
- package/dist/components/conversation/internal/chat-composer-shell.js.map +1 -1
- package/dist/components/conversation/message-composer.js.map +1 -1
- package/dist/components/conversation/message-row.js.map +1 -1
- package/dist/components/conversation/paste-token-editor.js.map +1 -1
- package/dist/components/conversation/thread-panel.js.map +1 -1
- package/dist/components/conversation/transcript-composition.js.map +1 -1
- package/dist/components/layout/app-shell/app-shell.js.map +1 -1
- package/dist/components/layout/app-shell/skip-link.js.map +1 -1
- package/dist/components/layout/contextual-sidebar/contextual-sidebar.js.map +1 -1
- package/dist/components/layout/contextual-sidebar/mobile-contextual-sidebar.js.map +1 -1
- package/dist/components/layout/floating-preview/floating-preview.js.map +1 -1
- package/dist/components/layout/orbit-layout/orbit-layout.js.map +1 -1
- package/dist/components/layout/page/page.js.map +1 -1
- package/dist/components/layout/panel/panel.js.map +1 -1
- package/dist/components/layout/pixel-pane/pixel-pane.js.map +1 -1
- package/dist/components/layout/pixel-resize-handle/pixel-resize-handle.js.map +1 -1
- package/dist/components/layout/shell-rail/shell-rail.js.map +1 -1
- package/dist/components/layout/shell-top-bar/shell-top-bar.js.map +1 -1
- package/dist/components/layout/side-rail/side-rail.js.map +1 -1
- package/dist/components/layout/sidebar-nav/sidebar-nav-resize-handle.js.map +1 -1
- package/dist/components/layout/sidebar-nav/sidebar-nav.js.map +1 -1
- package/dist/components/layout/split-layout/resize-controller-core-retry.js.map +1 -1
- package/dist/components/layout/split-layout/resize-controller-core.js.map +1 -1
- package/dist/components/layout/split-layout/split-layout.js.map +1 -1
- package/dist/components/layout/status-bar/status-bar.js.map +1 -1
- package/dist/components/layout/top-bar/top-bar.js.map +1 -1
- package/dist/components/layout/virtual-window/virtual-window.js.map +1 -1
- package/dist/components/motion/presence.js.map +1 -1
- package/dist/components/theme/appearance-panel.js.map +1 -1
- package/dist/components/theme/theme-mode-toggle.js.map +1 -1
- package/dist/components/theme/theme-picker.js.map +1 -1
- package/dist/components/theme/theme-provider.js.map +1 -1
- package/dist/components/theme/theme-toggle.js.map +1 -1
- package/dist/components/ui/accordion/accordion.js.map +1 -1
- package/dist/components/ui/alert/alert.js.map +1 -1
- package/dist/components/ui/alert-dialog/alert-dialog.js.map +1 -1
- package/dist/components/ui/annotation-surface/annotation-surface.js.map +1 -1
- package/dist/components/ui/aspect-ratio/aspect-ratio.js.map +1 -1
- package/dist/components/ui/attachment/attachment.js.map +1 -1
- package/dist/components/ui/avatar/avatar.js.map +1 -1
- package/dist/components/ui/badge/badge.js.map +1 -1
- package/dist/components/ui/board/board.js.map +1 -1
- package/dist/components/ui/breadcrumb/breadcrumb.js.map +1 -1
- package/dist/components/ui/bubble/bubble.js.map +1 -1
- package/dist/components/ui/button/button.js.map +1 -1
- package/dist/components/ui/button-group/button-group.js.map +1 -1
- package/dist/components/ui/calendar/calendar.js.map +1 -1
- package/dist/components/ui/callout/callout.js.map +1 -1
- package/dist/components/ui/card/card.js.map +1 -1
- package/dist/components/ui/carousel/carousel.js.map +1 -1
- package/dist/components/ui/chart/chart.js.map +1 -1
- package/dist/components/ui/checkbox/checkbox.js.map +1 -1
- package/dist/components/ui/code-block/code-block.js.map +1 -1
- package/dist/components/ui/collapsible/collapsible.js.map +1 -1
- package/dist/components/ui/combobox/combobox.js.map +1 -1
- package/dist/components/ui/combobox/value-combobox.js.map +1 -1
- package/dist/components/ui/command/command.js.map +1 -1
- package/dist/components/ui/context-menu/context-menu.js.map +1 -1
- package/dist/components/ui/detail-panel/detail-panel.js.map +1 -1
- package/dist/components/ui/dialog/dialog-layer.js.map +1 -1
- package/dist/components/ui/dialog/dialog.js.map +1 -1
- package/dist/components/ui/diff-block/diff-block.js.map +1 -1
- package/dist/components/ui/drawer/drawer.js.map +1 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu.js.map +1 -1
- package/dist/components/ui/dropdown-menu/menu-parts.js.map +1 -1
- package/dist/components/ui/empty/empty-state.js.map +1 -1
- package/dist/components/ui/empty/empty.js.map +1 -1
- package/dist/components/ui/entity-icon/entity-icon.js.map +1 -1
- package/dist/components/ui/field/field.js.map +1 -1
- package/dist/components/ui/field/number-field.js.map +1 -1
- package/dist/components/ui/hover-card/hover-card.js.map +1 -1
- package/dist/components/ui/input/input-control.js.map +1 -1
- package/dist/components/ui/input/input.js.map +1 -1
- package/dist/components/ui/input-group/input-group.js.map +1 -1
- package/dist/components/ui/input-group/secret-input-group.js.map +1 -1
- package/dist/components/ui/input-otp/input-otp.js.map +1 -1
- package/dist/components/ui/item/item.js.map +1 -1
- package/dist/components/ui/kbd/kbd.js.map +1 -1
- package/dist/components/ui/label/label.js.map +1 -1
- package/dist/components/ui/marker/marker.js.map +1 -1
- package/dist/components/ui/menubar/menubar.js.map +1 -1
- package/dist/components/ui/message/message.js.map +1 -1
- package/dist/components/ui/modal-dialog/modal-dialog.js.map +1 -1
- package/dist/components/ui/native-select/native-select.js.map +1 -1
- package/dist/components/ui/navigation-menu/navigation-menu.js.map +1 -1
- package/dist/components/ui/pagination/pagination.js.map +1 -1
- package/dist/components/ui/popover/popover.js.map +1 -1
- package/dist/components/ui/progress/progress.js.map +1 -1
- package/dist/components/ui/questionnaire/questionnaire.js.map +1 -1
- package/dist/components/ui/radio-group/radio-group.js.map +1 -1
- package/dist/components/ui/resizable/resizable.js.map +1 -1
- package/dist/components/ui/scroll-area/scroll-area.js.map +1 -1
- package/dist/components/ui/select/select.js.map +1 -1
- package/dist/components/ui/separator/separator.js.map +1 -1
- package/dist/components/ui/sheet/sheet.js.map +1 -1
- package/dist/components/ui/skeleton/skeleton.js.map +1 -1
- package/dist/components/ui/slider/slider.js.map +1 -1
- package/dist/components/ui/spinner/spinner.js.map +1 -1
- package/dist/components/ui/status-chip/status-chip.js.map +1 -1
- package/dist/components/ui/switch/switch.js.map +1 -1
- package/dist/components/ui/table/table.js.map +1 -1
- package/dist/components/ui/tabs/tabs.js.map +1 -1
- package/dist/components/ui/text-link/text-link.js.map +1 -1
- package/dist/components/ui/textarea/textarea.js.map +1 -1
- package/dist/components/ui/toast/toast.js.map +1 -1
- package/dist/components/ui/toggle/toggle.js.map +1 -1
- package/dist/components/ui/toggle-group/toggle-group.js.map +1 -1
- package/dist/components/ui/tooltip/tooltip.js.map +1 -1
- package/dist/components/ui/trace/trace.js.map +1 -1
- package/dist/components/ui/typography/typography.js.map +1 -1
- package/dist/r/about-dialog.json +1 -1
- package/dist/r/accordion.json +1 -1
- package/dist/r/account-menu.json +1 -1
- package/dist/r/alert.json +1 -1
- package/dist/r/appearance-editor.json +1 -1
- package/dist/r/attachment.json +1 -1
- package/dist/r/breadcrumb.json +1 -1
- package/dist/r/calendar.json +1 -1
- package/dist/r/carousel.json +1 -1
- package/dist/r/catalog-browser.json +1 -1
- package/dist/r/chain-of-thought.json +1 -1
- package/dist/r/chat.json +1 -1
- package/dist/r/checkbox.json +1 -1
- package/dist/r/checkpoint.json +1 -1
- package/dist/r/code-block.json +1 -1
- package/dist/r/combobox.json +1 -1
- package/dist/r/command.json +1 -1
- package/dist/r/confirmation.json +1 -1
- package/dist/r/context.json +1 -1
- package/dist/r/conversation.json +1 -1
- package/dist/r/detail-panel.json +1 -1
- package/dist/r/dialog.json +1 -1
- package/dist/r/dropdown-menu.json +1 -1
- package/dist/r/empty.json +1 -1
- package/dist/r/file-tree.json +1 -1
- package/dist/r/floating-preview.json +1 -1
- package/dist/r/help-center.json +1 -1
- package/dist/r/icon-picker.json +1 -1
- package/dist/r/inline-citation.json +1 -1
- package/dist/r/lib.json +1 -1
- package/dist/r/message-scroller.json +1 -1
- package/dist/r/model-selector.json +1 -1
- package/dist/r/native-select.json +1 -1
- package/dist/r/navigation-menu.json +1 -1
- package/dist/r/pagination.json +1 -1
- package/dist/r/pixel-resize-handle.json +1 -1
- package/dist/r/plan.json +1 -1
- package/dist/r/questionnaire.json +1 -1
- package/dist/r/queue.json +1 -1
- package/dist/r/radio-group.json +1 -1
- package/dist/r/reasoning.json +1 -1
- package/dist/r/registry.json +65 -65
- package/dist/r/resizable.json +1 -1
- package/dist/r/scene-controls.json +1 -1
- package/dist/r/select.json +1 -1
- package/dist/r/settings.json +1 -1
- package/dist/r/sheet.json +1 -1
- package/dist/r/shell-rail.json +1 -1
- package/dist/r/sidebar-nav.json +1 -1
- package/dist/r/sources.json +1 -1
- package/dist/r/spinner.json +1 -1
- package/dist/r/split-layout.json +1 -1
- package/dist/r/src/components/composites/model-selector/model-selector.tsx +4 -1
- package/dist/r/stack-trace.json +1 -1
- package/dist/r/stat.json +1 -1
- package/dist/r/subagent.json +1 -1
- package/dist/r/task.json +1 -1
- package/dist/r/terminal.json +1 -1
- package/dist/r/test-results.json +1 -1
- package/dist/r/theming.json +1 -1
- package/dist/r/toast.json +1 -1
- package/dist/r/tool.json +1 -1
- package/dist/r/top-bar.json +1 -1
- package/dist/r/trace.json +1 -1
- package/dist/r/tree.json +1 -1
- package/dist/r/update-dialog.json +1 -1
- package/dist/r/workspace-switcher.json +1 -1
- package/package.json +11 -11
- package/registry.json +65 -65
- package/src/components/composites/model-selector/model-selector.tsx +4 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"file-tree.js","names":["File","Folder","FolderOpen","createComputed","createMemo","createSignal","For","Show","splitProps","untrack","ComponentProps","keyedRows","cn","Button","Badge","Tree","TreeRow","TreeItemDescriptor","buildFileTree","clampWindow","countChanges","describeChanges","FILE_CHANGE_LABELS","flattenFileTree","indexFileTree","initialExpanded","revealInWindow","RowWindow","FileChangeInput","FileChangeKind","FileTreeExpansion","FileTreeNode","FileTreeRow","FileTreeProps","Omit","files","label","defaultExpanded","compact","selected","onSelect","path","node","maxHeight","maxRows","showSummary","FILE_TREE_MAX_ROWS","CHANGE_VARIANT","Readonly","Record","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","_el$3","firstChild","RowTrailing","_$memo","additions","deletions","_el$4","_tmpl$5","_el$7","_el$5","_tmpl$3","_el$6","_el$8","_tmpl$4","_el$9","_el$0","_tmpl$6","_el$1","fileCount","toLocaleString","variant","size","FileTree","local","rest","build","nodes","roots","counts","setExpanded","ReadonlySet","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","aria-label","visibleItems","onActiveIdChange","onExpand","onActivate","onSelectItem","onRequestReveal","selectionMode","typeaheadLabel","each","entry","item","leading","trailing","_$p","_$setStyleProperty","_el$15","_$className","_$setAttribute","_$createComponent","_$memo","_$mergeProps","_$setStyleProperty"],"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()).toLocaleString()} more rows (\n {rowsAfter().toLocaleString()} not shown)\n </Button>\n </div>\n </Show>\n </Show>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwGA,IAAa8C,qBAAqB;AAElC,IAAMC,iBAEF;CACFG,OAAO;CACPC,UAAU;CACVC,SAAS;CACTC,SAAS;AACX;AAEA,SAASC,WAAWC,KAAsC;CACxD,OAAO;EACLC,IAAID,IAAIb,KAAKc;EACbC,UAAUF,IAAIE;EACdC,OAAOH,IAAIG;EACXC,YAAYJ,IAAIb,KAAKkB,SAAS;EAC9BC,UAAUN,IAAIM;CAChB;AACF;AAEA,SAASC,WAAWC,OAA6B;CAC/C,MAAMrB,aAAaqB,MAAMR,IAAIb;CAC7B,OAAA,QAAA;EAAA,IAAAsB,OAAAC,OAAA;EAAAC,OAAAF,YAQOtB,KAAK,CAAC,CAACyB,IAAI;EAAAC,QAAAC,QAAA;GAAA,IAAAC,MALL1D,GAAG,YAAY,EACpB,sCAAsC8B,KAAK,CAAC,CAAC6B,WAAW,UAC1D,CAAC,GAACC,OACK9B,KAAK,CAAC,CAACc;GAAEc,QAAAD,IAAAI,KAAAC,UAAAV,MAAAK,IAAAI,IAAAH,GAAA;GAAAE,SAAAH,IAAAM,KAAAC,aAAAZ,MAAA,SAAAK,IAAAM,IAAAH,IAAA;GAAA,OAAAH;EAAA,GAAA;GAAAI,GAAAI,KAAAA;GAAAF,GAAAE,KAAAA;EAAA,CAAA;EAAA,OAAAb;CAAA,EAAA,CAAA,GAAAc,gBAIjBvE,MAAI;EAAA,IAACwE,OAAI;GAAA,OA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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()).toLocaleString()} more rows (\n {rowsAfter().toLocaleString()} not shown)\n </Button>\n </div>\n </Show>\n </Show>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwGA,IAAamC,qBAAqB;AAElC,IAAMC,iBAEF;CACFC,OAAO;CACPC,UAAU;CACVC,SAAS;CACTC,SAAS;AACX;AAEA,SAASC,WAAWC,KAAsC;CACxD,OAAO;EACLC,IAAID,IAAIX,KAAKY;EACbC,UAAUF,IAAIE;EACdC,OAAOH,IAAIG;EACXC,YA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;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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help-center.js","names":["For","Show","ExternalLink","createExternalLinkOpener","cn","ActionButton","Alert","AlertDescription","Card","CardContent","CardHeader","Kbd","KbdGroup","Heading","
|
|
1
|
+
{"version":3,"file":"help-center.js","names":["For","Show","ExternalLink","createExternalLinkOpener","cn","ActionButton","Alert","AlertDescription","Card","CardContent","CardHeader","Kbd","KbdGroup","Heading","label","keys","description","url","appName","shortcuts","links","openExternal","showHeader","class","HelpCenter","props","open","failure","_el$","_tmpl$6","_$insert","_$createComponent","when","children","_el$2","_tmpl$","_el$3","firstChild","_el$6","nextSibling","size","_tmpl$2","_el$8","_tmpl$3","each","shortcut","_el$1","_tmpl$7","_el$10","key","_tmpl$4","_el$0","_tmpl$5","link","_el$11","_tmpl$9","as","variant","href","target","rel","tooltip","onClick","_$memo","_el$12","_tmpl$8","error","role","_$effect","_$className"],"sources":["../../../../src/components/composites/help-center/help-center.tsx"],"sourcesContent":["import { For, Show } from 'solid-js'\nimport { ExternalLink } from 'lucide-solid'\nimport { createExternalLinkOpener } from '#lib/external-link'\nimport { cn } from '#lib/utils'\nimport { ActionButton } from '../action-button'\nimport { Alert, AlertDescription } from '../../ui/alert'\nimport { Card, CardContent, CardHeader } from '../../ui/card'\nimport { Kbd, KbdGroup } from '../../ui/kbd'\nimport { Heading } from '../../ui/typography'\n\nexport type HelpShortcut = { label: string; keys: readonly string[] }\nexport type HelpLink = { label: string; description?: string; url: string }\nexport type HelpCenterProps = {\n appName: string\n shortcuts: readonly HelpShortcut[]\n links: readonly HelpLink[]\n openExternal?: (url: string) => Promise<void>\n /** Hides the page heading and introduction when a host dialog supplies them. */\n showHeader?: boolean\n class?: string\n}\n\n/** A shared help page: real keyboard shortcuts and the application's project resources. */\nexport function HelpCenter(props: HelpCenterProps) {\n const links = createExternalLinkOpener({\n open: () => props.openExternal,\n failure: 'Could not open this help resource. Please try again.',\n })\n return (\n <div class={cn('flex min-w-0 flex-col gap-5', props.class)}>\n <Show when={props.showHeader !== false}>\n <div class=\"flex flex-col gap-2\">\n <Heading size=\"page\">Help Center</Heading>\n <p class=\"text-sm text-muted-foreground\">\n Keyboard shortcuts and resources for {props.appName}.\n </p>\n </div>\n </Show>\n <Card>\n <CardHeader>\n <h2 class=\"text-base font-semibold text-foreground\">Keyboard shortcuts</h2>\n </CardHeader>\n <CardContent>\n <ul class=\"flex flex-col gap-3\">\n <For each={props.shortcuts}>\n {(shortcut) => (\n <li class=\"flex flex-wrap items-center justify-between gap-2\">\n <span class=\"text-sm\">{shortcut.label}</span>\n <KbdGroup>\n <For each={shortcut.keys}>{(key) => <Kbd>{key}</Kbd>}</For>\n </KbdGroup>\n </li>\n )}\n </For>\n </ul>\n </CardContent>\n </Card>\n <Card>\n <CardHeader>\n <h2 class=\"text-base font-semibold text-foreground\">Project links</h2>\n </CardHeader>\n <CardContent>\n <ul class=\"flex flex-col gap-4\">\n <For each={props.links}>\n {(link) => (\n <li class=\"flex min-w-0 flex-col items-start gap-1\">\n <ActionButton\n as=\"a\"\n variant=\"link\"\n size=\"sm\"\n class=\"text-foreground decoration-primary\"\n href={link.url}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n tooltip={`Open ${link.label} in your browser.`}\n onClick={links.onClick(link.url)}\n >\n {link.label}\n <ExternalLink aria-hidden=\"true\" />\n </ActionButton>\n <Show when={link.description}>\n <p class=\"text-sm text-muted-foreground\">{link.description}</p>\n </Show>\n </li>\n )}\n </For>\n </ul>\n </CardContent>\n </Card>\n <Show when={links.error()}>\n <Alert variant=\"destructive\" role=\"alert\">\n <AlertDescription>{links.error()}</AlertDescription>\n </Alert>\n </Show>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAuBA,SAAgBwB,WAAWC,OAAwB;CACjD,MAAML,QAAQjB,yBAAyB;EACrCuB,YAAYD,MAAMJ;EAClBM,SAAS;CACX,CAAC;CACD,cAAA;EAAA,IAAAC,OAAAC,QAAA;EAAAC,OAAAF,MAAAG,gBAEK9B,MAAI;GAAA,IAAC+B,OAAI;IAAA,OAAEP,MAAMH,eAAe;GAAK;GAAA,IAAAW,WAAA;IAAA,IAAAC,QAAAC,OAAA,GAAAC,QAAAF,MAAAG,YAAAC,QAAAF,MAAAC,WAAAE;IAAAD,MAAAC;IAAAT,OAAAI,OAAAH,gBAEjClB,SAAO;KAAC2B,MAAI;KAAAP,UAAA;IAAA,CAAA,GAAAG,KAAA;IAAAN,OAAAM,aAE2BX,MAAMP,SAAOoB,KAAA;IAAA,OAAAJ;GAAA;EAAA,CAAA,GAAA,IAAA;EAAAJ,OAAAF,MAAAG,gBAIxDvB,MAAI,EAAA,IAAAyB,WAAA;GAAA,OAAA,CAAAF,gBACFrB,YAAU,EAAA,IAAAuB,WAAA;IAAA,OAAAQ,QAAA;GAAA,EAAA,CAAA,GAAAV,gBAGVtB,aAAW,EAAA,IAAAwB,WAAA;IAAA,IAAAS,QAAAC,QAAA;IAAAb,OAAA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OAAA,CAAA8B,WAE/BV,KAAKvC,KAAK,GAAAiB,gBACV7B,cAAY,EAAA,eAAA,OAAA,CAAA,CAAA;OAAA;MAAA,CAAA,GAAA,IAAA;MAAA4B,OAAAwB,QAAAvB,gBAEd9B,MAAI;OAAA,IAAC+B,OAAI;QAAA,OAAEqB,KAAKrC;OAAW;OAAA,IAAAiB,WAAA;QAAA,IAAA+B,SAAAC,QAAA;QAAAnC,OAAAkC,cACgBX,KAAKrC,WAAW;QAAA,OAAAgD;OAAA;MAAA,CAAA,GAAA,IAAA;MAAA,OAAAV;KAAA,EAAA,CAAA;IAG/D,CAAA,CAAA;IAAA,OAAAH;GAAA,EAAA,CAAA,CAAA;EAAA,EAAA,CAAA,GAAA,IAAA;EAAArB,OAAAF,MAAAG,gBAKR9B,MAAI;GAAA,IAAC+B,OAAI;IAAA,OAAEZ,MAAM8C,MAAM;GAAC;GAAA,IAAAjC,WAAA;IAAA,OAAAF,gBACtBzB,OAAK;KAACmD,SAAO;KAAeU,MAAI;KAAA,IAAAlC,WAAA;MAAA,OAAAF,gBAC9BxB,kBAAgB,EAAA,IAAA0B,WAAA;OAAA,OAAEb,MAAM8C,MAAM;MAAC,EAAA,CAAA;KAAA;IAAA,CAAA;GAAA;EAAA,CAAA,GAAA,IAAA;EAAAE,aAAAC,UAAAzC,MA9D1BxB,GAAG,+BAA+BqB,MAAMF,KAAK,CAAC,CAAA;EAAA,OAAAK;CAAA,EAAA,CAAA;AAmE9D"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"icon-picker.js","names":["RadioGroup","Radio","ChevronDown","ImageUp","Trash2","JSX","For","Show","createSignal","createUniqueId","splitProps","Dynamic","createLatestAction","cn","Button","Popover","PopoverContent","PopoverTrigger","MarkImageError","markImageFromFile","markImageProblemCopy","MARK_IMAGE_MAX_SOURCE_BYTES","resolveShellIcon","shellIconEntries","shellIconLabel","IconPickerProps","label","value","onValueChange","key","defaultKey","image","onImageChange","disabled","class","IconPicker","props","inputId","problem","setProblem","uploads","fileInput","setFileInput","HTMLInputElement","upload","file","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$7","_el$9","_el$8","aria-label","onChange","each","entry","Icon","Item","ItemInput","ItemLabel","title","_el$10","_tmpl$6","_$className","IconPickerDropdownProps","trigger","Element","IconPickerDropdown","open","setOpen","local","picker","Current","onOpenChange","placement","as","_el$11","_tmpl$7","component","_el$12","_tmpl$8","_$mergeProps","_$createComponent","_$setAttribute","_$memo","Radio","_$className","_$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":";;;;;;;;;;;;;;;;;;;AAqDA,SAAgBmC,WAAWC,OAAwB;CACjD,MAAMC,UAAU5B,eAAe;CAC/B,MAAM,CAAC6B,SAASC,cAAc/B,aAAqB;CACnD,MAAMgC,UAAU5B,mBAAmB;CACnC,MAAM,CAAC6B,WAAWC,gBAAgBlC,aAA+B;CAEjE,MAAMoC,SAAS,OAAOC,SAA2B;EAC/C,IAAI,CAACA,QAAQ,CAACT,MAAMJ,eAAe;EACnCO,WAAWQ,KAAAA,CAAS;EACpB,MAAMC,UAAU,MAAMR,QAAQS,UAAU9B,kBAAkB0B,IAAI,CAAC;EAC/D,IAAIG,QAAQE,WAAW,QAAQd,MAAMJ,gBAAgBgB,QAAQrB,KAAK;OAC7D,IAAIqB,QAAQE,WAAW,UAC1BX,WACEnB,qBACE4B,QAAQG,iBAAiBjC,iBAAiB8B,QAAQG,MAAMb,UAAU,aAEtE;CACJ;CAEA,cAAA;EAAA,IAAAc,OAAAC,QAAA;EAAAC,OAAAF,MAAAG,gBAEKhD,MAAI;GAAA,IAACiD,OAAI;IAAA,OAAEpB,MAAMJ;GAAa;GAAA,IAAAyB,WAAA;IAAA,OAAA;YAAA;MAAA,IAAAC,QAAAC,OAAA,GAAAC,QAAAF,MAAAG,YAAAC,QAAAF,MAAAG,aAAAC,QAAAF,MAAAD;MAAAP,OAAAM,OAAAL,gBAMxBhD,MAAI;OAAA,IACHiD,OAAI;QAAA,OAAEpB,MAAML;OAAK;OAAA,IACjBkC,WAAQ;QAAA,OAAAV,gBAAGpD,SAAO;SAAA,SAAA;SAAA,eAAA;QAAA,CAAA;OAAA;OAAAsD,WAEhBS,eAAG;QAAA,IAAAC,QAAAC,QAAA;QAAAC,aAAAC,aAAAH,OAA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","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":";;;;;;;;;;;;;;;;;;;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,SA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C,CAAA,CAAA;IAAA;GAAA,CAAA,CAAA;EAAA;CAAA,CAAA;AAKX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inline-citation.js","names":["ChevronLeft","ChevronRight","createEffect","createSignal","onCleanup","Show","splitProps","cn","ActionButton","Button","MessageCitations","Popover","PopoverContent","PopoverTitle","PopoverTrigger","TextLink","SOURCE_SNIPPET_LIMIT","safeSourceUrl","sourceHost","sourceTitle","Source","boundText","citationLabel","citationName","nextCitationMode","wrapIndex","CitationEvent","CitationMode","InlineCitationProps","sources","index","hoverDelay","class","LEAVE_DELAY","InlineCitation","props","local","mode","setMode","position","setPosition","timer","ReturnType","setTimeout","content","HTMLElement","pressing","restoringFocus","keyboardPeek","setKeyboardPeek","focusInCard","escapeClosedTooltip","onWindowKeyDown","event","KeyboardEvent","key","ownerDocument","querySelector","window","addEventListener","removeEventListener","count","length","active","clear","undefined","clearTimeout","dispatch","current","next","schedule","delay","onPointerEnter","PointerEvent","pointerType","onPointerLeave","onClick","wasPeeking","queueMicrotask","focus","_$createComponent","when","children","_el$","_tmpl$3","_$insert","open","onOpenChange","placement","gutter","as","variant","size","touchTarget","aria-label","onFocus","FocusEvent","currentTarget","matches","onBlur","_el$2","_tmpl$","_el$3","_tmpl$2","_el$4","firstChild","ref","element","inert","onOpenAutoFocus","Event","preventDefault","onFocusIn","onKeyDown","onCloseAutoFocus","returnFocus","source","_el$5","_tmpl$5","_el$6","_tmpl$4","_el$7","_el$8","_el$0","nextSibling","_el$9","_el$1","tooltip","value","CitationDetails","messageCitations","render","numbers","flatMap","number","href","url","host","snippet","withheld","_el$10","_tmpl$6","target","rel","_$memo","_tmpl$9","_tmpl$7","_el$12","_tmpl$8","_$createComponent","_$memo"],"sources":["../../../../src/components/composites/inline-citation/inline-citation.tsx"],"sourcesContent":["import { ChevronLeft, ChevronRight } from 'lucide-solid'\nimport { createEffect, createSignal, onCleanup, Show, splitProps } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { ActionButton } from '../action-button'\nimport { Button } from '../../ui/button'\nimport type { MessageCitations } from '../../ui/message'\nimport { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from '../../ui/popover'\nimport { TextLink } from '../../ui/text-link'\nimport {\n SOURCE_SNIPPET_LIMIT,\n safeSourceUrl,\n sourceHost,\n sourceTitle,\n type Source,\n} from '../sources/source'\nimport { boundText } from '#lib/text'\nimport {\n citationLabel,\n citationName,\n nextCitationMode,\n wrapIndex,\n type CitationEvent,\n type CitationMode,\n} from './citation'\n\n/**\n * InlineCitation.\n *\n * A small badge inside a sentence — \"1\", or a host — that opens the source(s)\n * behind the claim: title, host, address, snippet, and Previous/Next when several\n * sources share one marker. It is an inline element for prose such as\n * `MessageText`: it never breaks across lines, stays on the text baseline, and\n * adds no block of its own. For the list of everything a reply used, reach for\n * `Sources`; the two number sources the same way.\n *\n * ## One popover, two ways to open it\n *\n * A hover card would exclude everyone who is not holding a mouse, so this is a\n * `Popover` that a pointer can also *peek* at:\n *\n * - **Hover or keyboard focus peeks.** The popover opens without taking focus\n * and closes when the pointer or focus leaves. Touch has no hover, so a touch\n * never peeks. A keyboard peek's card is inert, so Tab moves on from the badge\n * to the next control on the page instead of into a card that is closing.\n * - **Click, tap, Enter or Space pins.** Focus moves into the popover so its\n * link and Previous/Next are reachable; it stays until Escape, an outside press,\n * or the badge is pressed again, and focus returns to the badge. Pressing a badge\n * that is only peeking pins it rather than toggling it shut — the transitions\n * are the pure `nextCitationMode`.\n *\n * Kobalte's trigger toggles on every press, so `open` is controlled and its own\n * close request is ignored for the press that we already decided (`pressing`).\n * Without that, hover-then-click, the commonest pointer path, would close the card.\n *\n * ## It makes no claim without sources\n *\n * No sources renders nothing: a marker that points nowhere is not a citation.\n * The address is a link only when `safeSourceUrl` allows it; the host comes from\n * the parsed URL; titles and snippets are clipped, cleaned of direction\n * overrides and rendered as text. The badge's accessible name carries the title\n * and host (the visible label is only a number or a host), so a reader hears\n * what is cited without opening anything.\n */\nexport type InlineCitationProps = {\n /** One source, or several that support the same claim. */\n sources: readonly Source[]\n /**\n * The 1-based number to show, matching the source's position in `Sources`.\n * Omit it to show the host instead; a number is never guessed.\n */\n index?: number\n /** Milliseconds a pointer rests before the peek opens. */\n hoverDelay?: number\n class?: string\n}\n\nconst LEAVE_DELAY = 200\n\nexport function InlineCitation(props: InlineCitationProps) {\n const [local] = splitProps(props, ['sources', 'index', 'hoverDelay', 'class'])\n const [mode, setMode] = createSignal<CitationMode>('closed')\n const [position, setPosition] = createSignal(0)\n let timer: ReturnType<typeof setTimeout> | undefined\n let content: HTMLElement | undefined\n let pressing = false\n // Focus handed back to the badge as the popover closes is not a request to\n // peek again; without this, Escape from a pinned card reopens it as a preview.\n let restoringFocus = false\n // A keyboard peek is a preview of the badge the reader is already on. Its card\n // sits in a portal at the end of the document, so if it stayed tabbable, Tab\n // from the badge would walk into the card, the card would close behind the\n // focus as the badge blurred, and focus would fall to <body> and be pulled\n // back to the badge: a keyboard trap. The card is inert until Enter or Space\n // pins it, and while it closes. A pointer peek stays interactive.\n const [keyboardPeek, setKeyboardPeek] = createSignal(false)\n // Focus goes back to the badge only when it was in the card. A peek never\n // held focus, and its close (finishing after its exit animation) must not\n // pull the reader back from wherever Tab has taken them since.\n let focusInCard = false\n // Escape closes the innermost layer first: an open Previous/Next tooltip, then\n // the card. Kobalte only lets the top-most layer take Escape, and a tooltip\n // that just closed stays the top layer while it animates out, so a second\n // Escape pressed during that exit used to vanish and leave the card open.\n // Whether a tooltip was open is read before any handler runs (window,\n // capture); an Escape that closed nothing else closes the card itself.\n let escapeClosedTooltip = false\n const onWindowKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return\n escapeClosedTooltip =\n content?.ownerDocument.querySelector('[data-slot=\"tooltip-content\"][data-expanded]') != null\n }\n createEffect(() => {\n if (mode() !== 'pinned' || typeof window === 'undefined') return\n window.addEventListener('keydown', onWindowKeyDown, true)\n onCleanup(() => window.removeEventListener('keydown', onWindowKeyDown, true))\n })\n\n const count = () => local.sources.length\n const active = () => local.sources[wrapIndex(position(), count())]\n const clear = () => {\n if (timer !== undefined) clearTimeout(timer)\n timer = undefined\n }\n onCleanup(clear)\n\n const dispatch = (event: CitationEvent) =>\n setMode((current) => {\n const next = nextCitationMode(current, event)\n if (next !== 'peek') setKeyboardPeek(false)\n else if (current === 'closed') setKeyboardPeek(event === 'focus')\n return next\n })\n const schedule = (event: CitationEvent, delay: number) => {\n clear()\n timer = setTimeout(() => dispatch(event), delay)\n }\n\n const onPointerEnter = (event: PointerEvent) => {\n if (event.pointerType === 'touch') return\n schedule('enter', local.hoverDelay ?? 150)\n }\n const onPointerLeave = (event: PointerEvent) => {\n if (event.pointerType === 'touch') return\n schedule('leave', LEAVE_DELAY)\n }\n\n const onClick = () => {\n clear()\n const wasPeeking = mode() === 'peek'\n dispatch('press')\n // Kobalte toggles right after this handler; its request is not a dismissal.\n pressing = true\n queueMicrotask(() => {\n pressing = false\n })\n // The peek never took focus; a deliberate press must hand it over, once\n // Kobalte's own toggle (which runs after this handler) has settled.\n if (wasPeeking) queueMicrotask(() => content?.focus())\n }\n\n // The badge and the popover's portal marker share one wrapper. Without it they\n // are loose siblings in the host's node list, and when the portal marker comes\n // and goes as the card opens and closes, a host that renders its inline nodes\n // as one array (MessageText) reconciles that array and can move the badge,\n // which drops keyboard focus to <body> on the badge the reader just reached.\n return (\n <Show when={count() > 0}>\n <span data-slot=\"inline-citation-root\">\n <Popover\n open={mode() !== 'closed'}\n onOpenChange={(next) => {\n if (!next && !pressing) dispatch('dismiss')\n }}\n placement=\"bottom\"\n gutter={6}\n >\n <PopoverTrigger\n as={Button}\n variant=\"subtle\"\n size=\"2xs\"\n touchTarget=\"comfortable\"\n data-slot=\"inline-citation\"\n aria-label={citationName(local.sources, local.index)}\n class={cn('mx-0.5 align-baseline tabular-nums', local.class)}\n onClick={onClick}\n onPointerEnter={onPointerEnter}\n onPointerLeave={onPointerLeave}\n onFocus={(event: FocusEvent & { currentTarget: HTMLElement }) => {\n // Mouse focus follows the press; only keyboard focus peeks.\n if (restoringFocus) return\n if (event.currentTarget.matches(':focus-visible')) dispatch('focus')\n }}\n onBlur={() => dispatch('blur')}\n >\n <span aria-hidden=\"true\" class=\"max-w-32 truncate\">\n {citationLabel(local.index, local.sources[0])}\n </span>\n <Show when={count() > 1}>\n <span aria-hidden=\"true\">+{count() - 1}</span>\n </Show>\n </PopoverTrigger>\n <PopoverContent\n ref={(element: HTMLElement) => (content = element)}\n inert={keyboardPeek() || mode() === 'closed' || undefined}\n class=\"w-72 max-w-full\"\n onOpenAutoFocus={(event: Event) => {\n if (mode() === 'peek') event.preventDefault()\n }}\n onFocusIn={() => {\n focusInCard = true\n }}\n onKeyDown={(event: KeyboardEvent) => {\n if (event.key !== 'Escape' || escapeClosedTooltip || mode() !== 'pinned') return\n dispatch('dismiss')\n }}\n onCloseAutoFocus={(event: Event) => {\n const returnFocus = focusInCard\n focusInCard = false\n if (!returnFocus) {\n event.preventDefault()\n return\n }\n // The focus move that follows is synchronous; the microtask ends the window.\n restoringFocus = true\n queueMicrotask(() => {\n restoringFocus = false\n })\n }}\n onPointerEnter={(event: PointerEvent) => {\n if (event.pointerType !== 'touch') clear()\n }}\n onPointerLeave={onPointerLeave}\n >\n <Show when={active()}>\n {(source) => (\n <div class=\"flex min-w-0 flex-col gap-1.5 px-2 py-1.5\">\n <Show when={count() > 1}>\n <div class=\"flex items-center justify-between gap-2\">\n <span\n role=\"status\"\n aria-live=\"polite\"\n class=\"text-xs text-muted-foreground tabular-nums\"\n >\n Source {wrapIndex(position(), count()) + 1} of {count()}\n </span>\n <span class=\"flex items-center gap-0.5\">\n <ActionButton\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label=\"Previous source\"\n tooltip=\"Previous source\"\n onClick={() => setPosition((value) => wrapIndex(value - 1, count()))}\n >\n <ChevronLeft />\n </ActionButton>\n <ActionButton\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label=\"Next source\"\n tooltip=\"Next source\"\n onClick={() => setPosition((value) => wrapIndex(value + 1, count()))}\n >\n <ChevronRight />\n </ActionButton>\n </span>\n </div>\n </Show>\n <PopoverTitle class=\"p-0 [overflow-wrap:anywhere]\">\n {sourceTitle(source())}\n </PopoverTitle>\n <CitationDetails source={source()} />\n </div>\n )}\n </Show>\n </PopoverContent>\n </Popover>\n </span>\n </Show>\n )\n}\n\n/**\n * Citation markers for `MessageText`, from the sources a reply really used.\n *\n * `[^2]` in the text becomes the second source's badge; `[^1,3]` one badge for\n * sources 1 and 3. A number beyond the list leaves the marker as written, and an\n * empty list makes every marker literal, so text can never cite a source the host\n * did not supply.\n *\n * <MessageText text={reply} citations={messageCitations(sources)} />\n */\nexport function messageCitations(sources: readonly Source[]): MessageCitations {\n return {\n count: sources.length,\n render: (numbers) => (\n <InlineCitation\n index={numbers[0]}\n sources={numbers.flatMap((number) => {\n const source = sources[number - 1]\n return source ? [source] : []\n })}\n />\n ),\n }\n}\n\nfunction CitationDetails(props: { source: Source }) {\n const href = () => safeSourceUrl(props.source.url)\n const host = () => sourceHost(props.source.url)\n const snippet = () =>\n props.source.snippet ? boundText(props.source.snippet, SOURCE_SNIPPET_LIMIT) : ''\n const withheld = () => props.source.url !== undefined && props.source.url !== '' && !href()\n\n return (\n <>\n <Show when={host()}>\n <p class=\"m-0 text-xs text-muted-foreground [overflow-wrap:anywhere]\">{host()}</p>\n </Show>\n <Show when={href()}>\n {(url) => (\n <TextLink\n href={url()}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n class=\"w-fit max-w-full text-xs [overflow-wrap:anywhere]\"\n >\n {boundText(url(), 96)}\n <span class=\"visually-hidden\"> (opens in a new tab)</span>\n </TextLink>\n )}\n </Show>\n <Show when={withheld()}>\n <p class=\"m-0 text-xs text-muted-foreground\">Address not linked</p>\n </Show>\n <Show when={snippet()}>\n <p class=\"m-0 line-clamp-6 text-xs text-muted-foreground [overflow-wrap:anywhere]\">\n {snippet()}\n </p>\n </Show>\n </>\n )\n}\n"],"m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,MAAI;GAAA,IAAC4E,OAAI;IAAA,OAAE0D,SAAS;GAAC;GAAA,IAAAzD,WAAA;IAAA,OAAAgE,QAAA;GAAA;EAAA,CAAA;EAAAlE,gBAGrB3E,MAAI;GAAA,IAAC4E,OAAI;IAAA,OAAEyD,QAAQ;GAAC;GAAA,IAAAxD,WAAA;IAAA,IAAAiE,SAAAC,QAAA;IAAA/D,OAAA8D,QAEhBT,OAAO;IAAA,OAAAS;GAAA;EAAA,CAAA;CAAA;AAKlB"}
|
|
1
|
+
{"version":3,"file":"inline-citation.js","names":["ChevronLeft","ChevronRight","createEffect","createSignal","onCleanup","Show","splitProps","cn","ActionButton","Button","Popover","PopoverContent","PopoverTitle","PopoverTrigger","TextLink","safeSourceUrl","sourceHost","sourceTitle","boundText","citationLabel","citationName","nextCitationMode","wrapIndex","sources","index","hoverDelay","class","LEAVE_DELAY","InlineCitation","props","local","mode","setMode","position","setPosition","timer","setTimeout","content","pressing","restoringFocus","keyboardPeek","setKeyboardPeek","focusInCard","escapeClosedTooltip","onWindowKeyDown","event","key","ownerDocument","querySelector","window","addEventListener","removeEventListener","count","length","active","clear","undefined","clearTimeout","dispatch","current","next","schedule","delay","onPointerEnter","pointerType","onPointerLeave","onClick","wasPeeking","queueMicrotask","focus","_$createComponent","when","children","_el$","_tmpl$3","_$insert","open","onOpenChange","placement","gutter","as","variant","size","touchTarget","onFocus","currentTarget","matches","onBlur","_el$2","_tmpl$","_el$3","_tmpl$2","firstChild","ref","element","inert","onOpenAutoFocus","preventDefault","onFocusIn","onKeyDown","onCloseAutoFocus","returnFocus","source","_el$5","_tmpl$5","_el$6","_tmpl$4","_el$7","_el$0","nextSibling","_el$1","tooltip","value","CitationDetails","messageCitations","render","numbers","flatMap","number","href","url","host","snippet","withheld","_el$10","_tmpl$6","target","rel","_$memo","_tmpl$9","_tmpl$7","_el$12","_tmpl$8"],"sources":["../../../../src/components/composites/inline-citation/inline-citation.tsx"],"sourcesContent":["import { ChevronLeft, ChevronRight } from 'lucide-solid'\nimport { createEffect, createSignal, onCleanup, Show, splitProps } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { ActionButton } from '../action-button'\nimport { Button } from '../../ui/button'\nimport type { MessageCitations } from '../../ui/message'\nimport { Popover, PopoverContent, PopoverTitle, PopoverTrigger } from '../../ui/popover'\nimport { TextLink } from '../../ui/text-link'\nimport {\n SOURCE_SNIPPET_LIMIT,\n safeSourceUrl,\n sourceHost,\n sourceTitle,\n type Source,\n} from '../sources/source'\nimport { boundText } from '#lib/text'\nimport {\n citationLabel,\n citationName,\n nextCitationMode,\n wrapIndex,\n type CitationEvent,\n type CitationMode,\n} from './citation'\n\n/**\n * InlineCitation.\n *\n * A small badge inside a sentence — \"1\", or a host — that opens the source(s)\n * behind the claim: title, host, address, snippet, and Previous/Next when several\n * sources share one marker. It is an inline element for prose such as\n * `MessageText`: it never breaks across lines, stays on the text baseline, and\n * adds no block of its own. For the list of everything a reply used, reach for\n * `Sources`; the two number sources the same way.\n *\n * ## One popover, two ways to open it\n *\n * A hover card would exclude everyone who is not holding a mouse, so this is a\n * `Popover` that a pointer can also *peek* at:\n *\n * - **Hover or keyboard focus peeks.** The popover opens without taking focus\n * and closes when the pointer or focus leaves. Touch has no hover, so a touch\n * never peeks. A keyboard peek's card is inert, so Tab moves on from the badge\n * to the next control on the page instead of into a card that is closing.\n * - **Click, tap, Enter or Space pins.** Focus moves into the popover so its\n * link and Previous/Next are reachable; it stays until Escape, an outside press,\n * or the badge is pressed again, and focus returns to the badge. Pressing a badge\n * that is only peeking pins it rather than toggling it shut — the transitions\n * are the pure `nextCitationMode`.\n *\n * Kobalte's trigger toggles on every press, so `open` is controlled and its own\n * close request is ignored for the press that we already decided (`pressing`).\n * Without that, hover-then-click, the commonest pointer path, would close the card.\n *\n * ## It makes no claim without sources\n *\n * No sources renders nothing: a marker that points nowhere is not a citation.\n * The address is a link only when `safeSourceUrl` allows it; the host comes from\n * the parsed URL; titles and snippets are clipped, cleaned of direction\n * overrides and rendered as text. The badge's accessible name carries the title\n * and host (the visible label is only a number or a host), so a reader hears\n * what is cited without opening anything.\n */\nexport type InlineCitationProps = {\n /** One source, or several that support the same claim. */\n sources: readonly Source[]\n /**\n * The 1-based number to show, matching the source's position in `Sources`.\n * Omit it to show the host instead; a number is never guessed.\n */\n index?: number\n /** Milliseconds a pointer rests before the peek opens. */\n hoverDelay?: number\n class?: string\n}\n\nconst LEAVE_DELAY = 200\n\nexport function InlineCitation(props: InlineCitationProps) {\n const [local] = splitProps(props, ['sources', 'index', 'hoverDelay', 'class'])\n const [mode, setMode] = createSignal<CitationMode>('closed')\n const [position, setPosition] = createSignal(0)\n let timer: ReturnType<typeof setTimeout> | undefined\n let content: HTMLElement | undefined\n let pressing = false\n // Focus handed back to the badge as the popover closes is not a request to\n // peek again; without this, Escape from a pinned card reopens it as a preview.\n let restoringFocus = false\n // A keyboard peek is a preview of the badge the reader is already on. Its card\n // sits in a portal at the end of the document, so if it stayed tabbable, Tab\n // from the badge would walk into the card, the card would close behind the\n // focus as the badge blurred, and focus would fall to <body> and be pulled\n // back to the badge: a keyboard trap. The card is inert until Enter or Space\n // pins it, and while it closes. A pointer peek stays interactive.\n const [keyboardPeek, setKeyboardPeek] = createSignal(false)\n // Focus goes back to the badge only when it was in the card. A peek never\n // held focus, and its close (finishing after its exit animation) must not\n // pull the reader back from wherever Tab has taken them since.\n let focusInCard = false\n // Escape closes the innermost layer first: an open Previous/Next tooltip, then\n // the card. Kobalte only lets the top-most layer take Escape, and a tooltip\n // that just closed stays the top layer while it animates out, so a second\n // Escape pressed during that exit used to vanish and leave the card open.\n // Whether a tooltip was open is read before any handler runs (window,\n // capture); an Escape that closed nothing else closes the card itself.\n let escapeClosedTooltip = false\n const onWindowKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Escape') return\n escapeClosedTooltip =\n content?.ownerDocument.querySelector('[data-slot=\"tooltip-content\"][data-expanded]') != null\n }\n createEffect(() => {\n if (mode() !== 'pinned' || typeof window === 'undefined') return\n window.addEventListener('keydown', onWindowKeyDown, true)\n onCleanup(() => window.removeEventListener('keydown', onWindowKeyDown, true))\n })\n\n const count = () => local.sources.length\n const active = () => local.sources[wrapIndex(position(), count())]\n const clear = () => {\n if (timer !== undefined) clearTimeout(timer)\n timer = undefined\n }\n onCleanup(clear)\n\n const dispatch = (event: CitationEvent) =>\n setMode((current) => {\n const next = nextCitationMode(current, event)\n if (next !== 'peek') setKeyboardPeek(false)\n else if (current === 'closed') setKeyboardPeek(event === 'focus')\n return next\n })\n const schedule = (event: CitationEvent, delay: number) => {\n clear()\n timer = setTimeout(() => dispatch(event), delay)\n }\n\n const onPointerEnter = (event: PointerEvent) => {\n if (event.pointerType === 'touch') return\n schedule('enter', local.hoverDelay ?? 150)\n }\n const onPointerLeave = (event: PointerEvent) => {\n if (event.pointerType === 'touch') return\n schedule('leave', LEAVE_DELAY)\n }\n\n const onClick = () => {\n clear()\n const wasPeeking = mode() === 'peek'\n dispatch('press')\n // Kobalte toggles right after this handler; its request is not a dismissal.\n pressing = true\n queueMicrotask(() => {\n pressing = false\n })\n // The peek never took focus; a deliberate press must hand it over, once\n // Kobalte's own toggle (which runs after this handler) has settled.\n if (wasPeeking) queueMicrotask(() => content?.focus())\n }\n\n // The badge and the popover's portal marker share one wrapper. Without it they\n // are loose siblings in the host's node list, and when the portal marker comes\n // and goes as the card opens and closes, a host that renders its inline nodes\n // as one array (MessageText) reconciles that array and can move the badge,\n // which drops keyboard focus to <body> on the badge the reader just reached.\n return (\n <Show when={count() > 0}>\n <span data-slot=\"inline-citation-root\">\n <Popover\n open={mode() !== 'closed'}\n onOpenChange={(next) => {\n if (!next && !pressing) dispatch('dismiss')\n }}\n placement=\"bottom\"\n gutter={6}\n >\n <PopoverTrigger\n as={Button}\n variant=\"subtle\"\n size=\"2xs\"\n touchTarget=\"comfortable\"\n data-slot=\"inline-citation\"\n aria-label={citationName(local.sources, local.index)}\n class={cn('mx-0.5 align-baseline tabular-nums', local.class)}\n onClick={onClick}\n onPointerEnter={onPointerEnter}\n onPointerLeave={onPointerLeave}\n onFocus={(event: FocusEvent & { currentTarget: HTMLElement }) => {\n // Mouse focus follows the press; only keyboard focus peeks.\n if (restoringFocus) return\n if (event.currentTarget.matches(':focus-visible')) dispatch('focus')\n }}\n onBlur={() => dispatch('blur')}\n >\n <span aria-hidden=\"true\" class=\"max-w-32 truncate\">\n {citationLabel(local.index, local.sources[0])}\n </span>\n <Show when={count() > 1}>\n <span aria-hidden=\"true\">+{count() - 1}</span>\n </Show>\n </PopoverTrigger>\n <PopoverContent\n ref={(element: HTMLElement) => (content = element)}\n inert={keyboardPeek() || mode() === 'closed' || undefined}\n class=\"w-72 max-w-full\"\n onOpenAutoFocus={(event: Event) => {\n if (mode() === 'peek') event.preventDefault()\n }}\n onFocusIn={() => {\n focusInCard = true\n }}\n onKeyDown={(event: KeyboardEvent) => {\n if (event.key !== 'Escape' || escapeClosedTooltip || mode() !== 'pinned') return\n dispatch('dismiss')\n }}\n onCloseAutoFocus={(event: Event) => {\n const returnFocus = focusInCard\n focusInCard = false\n if (!returnFocus) {\n event.preventDefault()\n return\n }\n // The focus move that follows is synchronous; the microtask ends the window.\n restoringFocus = true\n queueMicrotask(() => {\n restoringFocus = false\n })\n }}\n onPointerEnter={(event: PointerEvent) => {\n if (event.pointerType !== 'touch') clear()\n }}\n onPointerLeave={onPointerLeave}\n >\n <Show when={active()}>\n {(source) => (\n <div class=\"flex min-w-0 flex-col gap-1.5 px-2 py-1.5\">\n <Show when={count() > 1}>\n <div class=\"flex items-center justify-between gap-2\">\n <span\n role=\"status\"\n aria-live=\"polite\"\n class=\"text-xs text-muted-foreground tabular-nums\"\n >\n Source {wrapIndex(position(), count()) + 1} of {count()}\n </span>\n <span class=\"flex items-center gap-0.5\">\n <ActionButton\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label=\"Previous source\"\n tooltip=\"Previous source\"\n onClick={() => setPosition((value) => wrapIndex(value - 1, count()))}\n >\n <ChevronLeft />\n </ActionButton>\n <ActionButton\n variant=\"ghost\"\n size=\"icon-xs\"\n aria-label=\"Next source\"\n tooltip=\"Next source\"\n onClick={() => setPosition((value) => wrapIndex(value + 1, count()))}\n >\n <ChevronRight />\n </ActionButton>\n </span>\n </div>\n </Show>\n <PopoverTitle class=\"p-0 [overflow-wrap:anywhere]\">\n {sourceTitle(source())}\n </PopoverTitle>\n <CitationDetails source={source()} />\n </div>\n )}\n </Show>\n </PopoverContent>\n </Popover>\n </span>\n </Show>\n )\n}\n\n/**\n * Citation markers for `MessageText`, from the sources a reply really used.\n *\n * `[^2]` in the text becomes the second source's badge; `[^1,3]` one badge for\n * sources 1 and 3. A number beyond the list leaves the marker as written, and an\n * empty list makes every marker literal, so text can never cite a source the host\n * did not supply.\n *\n * <MessageText text={reply} citations={messageCitations(sources)} />\n */\nexport function messageCitations(sources: readonly Source[]): MessageCitations {\n return {\n count: sources.length,\n render: (numbers) => (\n <InlineCitation\n index={numbers[0]}\n sources={numbers.flatMap((number) => {\n const source = sources[number - 1]\n return source ? [source] : []\n })}\n />\n ),\n }\n}\n\nfunction CitationDetails(props: { source: Source }) {\n const href = () => safeSourceUrl(props.source.url)\n const host = () => sourceHost(props.source.url)\n const snippet = () =>\n props.source.snippet ? boundText(props.source.snippet, SOURCE_SNIPPET_LIMIT) : ''\n const withheld = () => props.source.url !== undefined && props.source.url !== '' && !href()\n\n return (\n <>\n <Show when={host()}>\n <p class=\"m-0 text-xs text-muted-foreground [overflow-wrap:anywhere]\">{host()}</p>\n </Show>\n <Show when={href()}>\n {(url) => (\n <TextLink\n href={url()}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n class=\"w-fit max-w-full text-xs [overflow-wrap:anywhere]\"\n >\n {boundText(url(), 96)}\n <span class=\"visually-hidden\"> (opens in a new tab)</span>\n </TextLink>\n )}\n </Show>\n <Show when={withheld()}>\n <p class=\"m-0 text-xs text-muted-foreground\">Address not linked</p>\n </Show>\n <Show when={snippet()}>\n <p class=\"m-0 line-clamp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AAE,CAAC,GAAAS,QAAA,CAAA;IAAA;GAAA,CAAA;EAGxB,CAAA;EAAA3D,gBAEFjE,MAAI;GAAA,IAACkE,OAAI;IAAA,OAAEoD,SAAS;GAAC;GAAA,IAAAnD,WAAA;IAAA,OAAA0D,QAAA;GAAA;EAAA,CAAA;EAAA5D,gBAGrBjE,MAAI;GAAA,IAACkE,OAAI;IAAA,OAAEmD,QAAQ;GAAC;GAAA,IAAAlD,WAAA;IAAA,IAAA2D,SAAAC,QAAA;IAAAzD,OAAAwD,QAEhBT,OAAO;IAAA,OAAAS;GAAA;EAAA,CAAA;CAAA;AAKlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-row-control.js","names":["
|
|
1
|
+
{"version":3,"file":"list-row-control.js","names":["Polymorphic","Show","splitProps","cn","class","selected","dense","leading","trailing","description","truncateDescription","stackTrailing","type","as","ListRowControl","props","local","rest","hasClickHandler","Boolean","onClick","rowAs","_$createComponent","_$mergeProps","_$memo","tabIndex","undefined","children","when","_el$","_tmpl$","_$insert","_el$2","_tmpl$4","_el$3","firstChild","_el$4","_el$5","_tmpl$2","_$effect","_$className","truncate","_el$6","_tmpl$3"],"sources":["../../../../src/components/composites/list-row/list-row-control.tsx"],"sourcesContent":["import type { PolymorphicProps } from '@kobalte/core/polymorphic'\nimport { Polymorphic } from '@kobalte/core/polymorphic'\nimport type { ComponentProps, JSX, ValidComponent } from 'solid-js'\nimport { Show, splitProps } from 'solid-js'\nimport { cn } from '#lib/utils'\n\nexport type ListRowControlProps<T extends ValidComponent = 'div'> = PolymorphicProps<\n T,\n {\n class?: string\n /** Marks the row as current. Sets `aria-current` for a link row. */\n selected?: boolean\n /** Draw the row at the compact height. */\n dense?: boolean\n /** Leading slot: an avatar, an icon, a checkbox. */\n leading?: JSX.Element\n /** Trailing slot: a count, a menu trigger, a timestamp. */\n trailing?: JSX.Element\n /** A second line that wraps and grows the row to fit its content. */\n description?: string\n /**\n * Keep the description on one line and end it with an ellipsis instead of\n * wrapping, so a described row stays at its minimum height however long the\n * text is. Use it where rows must be a predictable height (a virtualised\n * queue); leave it off where the whole description should be readable. Pair\n * it with a `tooltip` when the full text matters, and with\n * `stackTrailing={false}` to keep a trailing slot beside the text.\n */\n truncateDescription?: boolean\n /**\n * Whether a described row may drop its trailing slot onto its own line when\n * the row gets narrow (the default). Pass `false` for a short, truncating\n * label whose single action must stay beside it.\n */\n stackTrailing?: boolean\n /** Native button type; defaults to `button` for button rows. */\n type?: ComponentProps<'button'>['type']\n }\n>\n\ntype ListRowControlBaseProps<T extends ValidComponent = 'div'> = ListRowControlProps<T> & {\n as?: T\n}\n\n/** A tree-shakeable ListRow renderer without optional tooltip behavior. */\nexport function ListRowControl<T extends ValidComponent = 'div'>(props: ListRowControlProps<T>) {\n const [local, rest] = splitProps(props as ListRowControlBaseProps, [\n 'as',\n 'class',\n 'selected',\n 'dense',\n 'leading',\n 'trailing',\n 'description',\n 'truncateDescription',\n 'stackTrailing',\n 'type',\n 'tabIndex',\n 'children',\n ])\n const hasClickHandler = () => Boolean(rest.onClick || rest['on:click'])\n const rowAs = () => (local.as ?? (hasClickHandler() ? 'button' : 'div')) as T\n\n return (\n <Polymorphic\n as={rowAs()}\n data-slot=\"list-row\"\n type={rowAs() === 'button' ? (local.type ?? 'button') : local.type}\n tabIndex={local.tabIndex ?? (rowAs() === 'button' || rowAs() === 'a' ? 0 : undefined)}\n aria-current={local.selected ? 'true' : undefined}\n data-selected={local.selected ? '' : undefined}\n data-description={local.description ? '' : undefined}\n data-stack-trailing={local.stackTrailing === false ? 'never' : undefined}\n class={cn(\n 'group/row list-row-description flex min-w-0 items-center gap-2.5 rounded-md px-2 text-sm',\n 'transition-colors ease-out outline-none',\n 'focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-primary-subtle',\n {\n 'h-row-sm': local.dense && !local.description,\n 'h-row-md': !local.dense && !local.description,\n },\n {\n 'bg-primary-subtle text-foreground': local.selected,\n 'hover:bg-surface-hover': !local.selected,\n },\n local.class\n )}\n {...(rest as ComponentProps<'div'>)}\n >\n <Show when={local.leading}>\n <span\n data-slot=\"list-row-leading\"\n class=\"flex shrink-0 items-center justify-center [&_svg]:size-4\"\n >\n {local.leading}\n </span>\n </Show>\n <div data-slot=\"list-row-content\" class=\"flex min-w-0 flex-1 items-center gap-2.5\">\n <span data-slot=\"list-row-label\" class=\"flex min-w-0 flex-1 flex-col\">\n <span class=\"truncate\">{local.children}</span>\n <Show when={local.description}>\n <span\n data-slot=\"list-row-description\"\n class={cn(\n 'text-xs',\n { truncate: local.truncateDescription, 'break-words': !local.truncateDescription },\n local.selected ? 'text-foreground' : 'text-muted-foreground'\n )}\n >\n {local.description}\n </span>\n </Show>\n </span>\n <Show when={local.trailing}>\n <span\n data-slot=\"list-row-trailing\"\n class={cn(\n 'ms-auto flex shrink-0 items-center gap-1',\n local.selected ? 'text-foreground' : 'text-muted-foreground'\n )}\n >\n {local.trailing}\n </span>\n </Show>\n </div>\n </Polymorphic>\n )\n}\n"],"mappings":";;;;;;;;;;AA6CA,SAAgBc,eAAiDC,OAA+B;CAC9F,MAAM,CAACC,OAAOC,QAAQf,WAAWa,OAAkC;EACjE;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAAU,CACX;CACD,MAAMG,wBAAwBC,QAAQF,KAAKG,WAAWH,KAAK,WAAW;CACtE,MAAMI,cAAeL,MAAMH,OAAOK,gBAAgB,IAAI,WAAW;CAEjE,OAAAI,gBACGtB,aAAWuB,WAAA;EAAA,IACVV,KAAE;GAAA,OAAEQ,MAAM;EAAC;EAAA,aAAA;EAAA,IAEXT,OAAI;GAAA,OAAEY,WAAAH,MAAM,MAAM,QAAQ,CAAA,CAAA,IAAIL,MAAMJ,QAAQ,WAAYI,MAAMJ;EAAI;EAAA,IAClEa,WAAQ;GAAA,OAAET,MAAMS,aAAaJ,MAAM,MAAM,YAAYA,MAAM,MAAM,MAAM,IAAIK,KAAAA;EAAU;EAAA,KAAA,kB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MNrB,MAAI;IAAA,IAAC2B,OAAI;KAAA,OAAEZ,MAAMR;IAAQ;IAAA,IAAAmB,WAAA;KAAA,IAAAe,QAAAC,QAAA;KAAAZ,OAAAW,aAQrB1B,MAAMR,QAAQ;KAAA+B,aAAAC,UAAAE,OALRvC,GACL,4CACAa,MAAMX,WAAW,oBAAoB,uBACvC,CAAC,CAAA;KAAA,OAAAqC;IAAA;GAAA,CAAA,GAAA,IAAA;GAAA,OAAAV;EAAA,EAAA,CAAA,CAAA;CAAA,EAAA,CAAA,CAAA;AAQb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list-row.js","names":["
|
|
1
|
+
{"version":3,"file":"list-row.js","names":["createSignal","createUniqueId","Show","splitProps","Tooltip","TooltipContent","TooltipTrigger","Text","cn","ListRowControl","tooltip","type","rowAs","externalDescribedBy","tooltipId","tooltipOpen","ListRowTooltipTarget","props","local","rest","describedBy","ids","undefined","flatMap","value","split","filter","Boolean","Set","join","_$createComponent","_$mergeProps","as","ListRow","setTooltipOpen","hasClickHandler","onClick","rowType","rowProps","when","fallback","children","open","onOpenChange","id","ListGroup","label","action","_el$","_tmpl$3","_el$4","firstChild","_$spread","class","_$insert","_el$2","_tmpl$2","variant","_el$3","_tmpl$"],"sources":["../../../../src/components/composites/list-row/list-row.tsx"],"sourcesContent":["import type { PolymorphicProps } from '@kobalte/core/polymorphic'\nimport type { ComponentProps, ValidComponent } from 'solid-js'\nimport { createSignal, createUniqueId, Show, splitProps } from 'solid-js'\nimport { Tooltip, TooltipContent, TooltipTrigger } from '../../ui/tooltip'\nimport { Text } from '../../ui/typography'\nimport { cn } from '#lib/utils'\nimport { ListRowControl, type ListRowControlProps } from './list-row-control'\n\nexport type ListRowProps<T extends ValidComponent = 'div'> = PolymorphicProps<\n T,\n ListRowControlProps<T> & {\n /** A short explanation shown on pointer hover and keyboard focus. */\n tooltip?: string\n /** Native button type; defaults to `button` for button rows. */\n type?: ComponentProps<'button'>['type']\n /** Additional accessible description preserved on plain and rich rows. */\n 'aria-describedby'?: string\n }\n>\n\ntype ListRowTooltipTargetProps<T extends ValidComponent = 'div'> = Omit<ListRowProps<T>, 'as'> & {\n rowAs?: T\n externalDescribedBy?: string\n tooltipId?: string\n tooltipOpen?: () => boolean\n}\n\n/** Adapts TooltipTrigger's polymorphic target to ListRow's semantic element. */\nfunction ListRowTooltipTarget<T extends ValidComponent = 'div'>(\n props: ListRowTooltipTargetProps<T>\n) {\n const [local, rest] = splitProps(props as ListRowTooltipTargetProps, [\n 'rowAs',\n 'externalDescribedBy',\n 'tooltipId',\n 'tooltipOpen',\n ])\n const describedBy = () => {\n const ids = [\n rest['aria-describedby'],\n local.externalDescribedBy,\n local.tooltipOpen?.() ? local.tooltipId : undefined,\n ]\n .flatMap((value) => value?.split(/\\s+/) ?? [])\n .filter(Boolean)\n return [...new Set(ids)].join(' ') || undefined\n }\n\n return (\n <ListRowControl\n as={local.rowAs}\n {...(rest as unknown as ListRowControlProps<T>)}\n aria-describedby={describedBy()}\n />\n )\n}\n\n/**\n * Rich row composition with optional hover and keyboard tooltip behavior.\n * Import ListRowControl when the tooltip API is not needed and the consumer\n * wants the plain renderer to tree-shake independently.\n */\nexport function ListRow<T extends ValidComponent = 'div'>(props: ListRowProps<T>) {\n const [local, rest] = splitProps(props as ListRowProps<T>, ['as', 'tooltip', 'aria-describedby'])\n const [tooltipOpen, setTooltipOpen] = createSignal(false)\n const tooltipId = `list-row-tooltip-${createUniqueId()}`\n const hasClickHandler = () => Boolean(rest.onClick || rest['on:click'])\n const rowAs = () => (local.as ?? (hasClickHandler() ? 'button' : 'div')) as T\n const rowType = () => (rowAs() === 'button' ? (rest.type ?? 'button') : rest.type)\n const rowProps = () =>\n ({\n ...rest,\n type: rowType(),\n 'aria-describedby': local['aria-describedby'],\n }) as unknown as ListRowControlProps<T>\n\n return (\n <Show when={local.tooltip} fallback={<ListRowControl as={rowAs()} {...rowProps()} />}>\n <Tooltip open={tooltipOpen()} onOpenChange={setTooltipOpen}>\n <TooltipTrigger\n as={ListRowTooltipTarget}\n rowAs={rowAs()}\n type={rowType()}\n externalDescribedBy={local['aria-describedby']}\n tooltipId={tooltipId}\n tooltipOpen={tooltipOpen}\n {...(rest as ListRowTooltipTargetProps<T>)}\n >\n {rest.children}\n </TooltipTrigger>\n <TooltipContent id={tooltipId}>{local.tooltip}</TooltipContent>\n </Tooltip>\n </Show>\n )\n}\n\n/**\n * A group of rows with an optional heading and a scrolling body. The heading is\n * a plain label rather than a control: grouping is for reading, and a disclosure\n * on a list of five rows costs more attention than it saves.\n */\nexport function ListGroup(\n props: ComponentProps<'div'> & { label?: string; action?: import('solid-js').JSX.Element }\n) {\n const [local, rest] = splitProps(props, ['class', 'label', 'action', 'children'])\n return (\n <div data-slot=\"list-group\" class={cn('flex flex-col gap-0.5', local.class)} {...rest}>\n <Show when={local.label}>\n <div class=\"group/list-header flex items-center gap-1 px-2 py-1\">\n <Text variant=\"overline\" class=\"min-w-0 flex-1 truncate\">\n {local.label}\n </Text>\n <Show when={local.action}>\n <span class=\"shrink-0 opacity-0 transition-opacity ease-out group-hover/list-header:opacity-100 focus-within:opacity-100\">\n {local.action}\n </span>\n </Show>\n </div>\n </Show>\n <div class=\"flex flex-col gap-0.5\">{local.children}</div>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;AA4BA,SAASgB,qBACPC,OACA;CACA,MAAM,CAACC,OAAOC,QAAQhB,WAAWc,OAAoC;EACnE;EACA;EACA;EACA;CAAa,CACd;CACD,MAAMG,oBAAoB;EACxB,MAAMC,MAAM;GACVF,KAAK;GACLD,MAAML;GACNK,MAAMH,cAAc,IAAIG,MAAMJ,YAAYQ,KAAAA;EAAS,CACpD,CACEC,SAASC,UAAUA,OAAOC,MAAM,KAAK,KAAK,CAAA,CAAE,CAAC,CAC7CC,OAAOC,OAAO;EACjB,OAAO,CAAC,GAAG,IAAIC,IAAIP,GAAG,CAAC,CAAC,CAACQ,KAAK,GAAG,KAAKP,KAAAA;CACxC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SX","cn","Button","ConversationSurface","ConversationSurfaceProps","anchorIds","captureAnchor","restoreAnchor","ScrollAnchor","MessageScrollerProps","Omit","hasOlder","loadingOlder","onLoadOlder","Promise","olderLabel","loadingOlderLabel","header","Element","empty","announcement","TOP_MARGIN","MessageScroller","props","local","rest","scroller","HTMLDivElement","content","afterHostLoad","resume","undefined","holdFollow","epoch","inFlight","setInFlight","nativeAnchoring","holdNativeAnchoring","style","overflowAnchor","releaseNativeAnchoring","resetKey","stopWatching","settle","anchor","run","heightBefore","restoreFocus","releaseHold","finish","document","activeElement","body","again","querySelector","HTMLElement","focus","preventScroll","scrollTop","scrollHeight","load","afterInsert","requestAnimationFrame","observer","MutationObserver","resizer","ResizeObserver","unfollow","disconnect","fromControl","closest","observe","childList","subtree","follow","addEventListener","passive","watched","removeEventListener","resolve","catch","watchTop","element","IntersectionObserver","io","entries","some","entry","isIntersecting","root","rootMargin","_el$","_tmpl$","_el$2","firstChild","_$insert","_$createComponent","_$mergeProps","role","contentRef","onFollowHold","hold","ref","when","children","_el$3","_tmpl$3","_$use","fallback","type","variant","size","onClick","_$memo","_el$4","_tmpl$2","_$effect","_$className","class","_$createComponent","_$mergeProps","_$memo","_$className"],"sources":["../../../../src/components/composites/message-scroller/message-scroller.tsx"],"sourcesContent":["import { History, LoaderCircle } from 'lucide-solid'\nimport { createEffect, onCleanup, Show, splitProps, createSignal, type JSX } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { Button } from '../../ui/button'\nimport { ConversationSurface, type ConversationSurfaceProps } from '../../conversation'\nimport { anchorIds, captureAnchor, restoreAnchor, type ScrollAnchor } from './scroll-anchor'\n\n/**\n * MessageScroller.\n *\n * The thread. It owns the three scroll behaviours a chat gets wrong when each\n * is bolted on separately, and keeps them from fighting:\n *\n * 1. **Follow the reply only while the reader is at the bottom.** New and\n * streaming content scrolls into view when the reader is already at the end,\n * and never otherwise. Scrolling up parks the view; the \"Jump to latest\"\n * control brings it back. (This is `ConversationSurface`'s follow contract,\n * which this component wraps rather than reimplements.)\n * 2. **Load history without moving what the reader is looking at.** When the\n * reader reaches the top, `onLoadOlder` is asked for earlier turns. Turns\n * inserted *above* the viewport would normally push the visible content down\n * by exactly their height; here the first visible turn (found by\n * `data-anchor-id`, which `Message` sets from `anchorId`) is measured before\n * the load and put back to the same offset after it, on every layout change\n * until the load settles — so images and code blocks that size themselves\n * late do not jolt the view either. A \"Load earlier\" button is always present\n * while there is more, because the scroll trigger alone is unreachable to a\n * keyboard or switch user and fires nothing in a short pane.\n * 3. **Announce without flooding.** The scroller is a polite log, and a turn that\n * is still arriving marks itself `aria-busy`, so a screen reader waits for the\n * settled turn instead of reading every token. `announcement` is a separate\n * status region for the two moments that matter: a response starting and a\n * response finishing.\n *\n * What it does not own: which turns exist, their identity, or what \"older\"\n * means. The host passes children and a loader; a session switch is\n * `resetKey`, which re-arms follow and discards any in-flight anchor.\n */\nexport type MessageScrollerProps = Omit<ConversationSurfaceProps, 'header' | 'empty'> & {\n hasOlder?: boolean\n /** The host is loading earlier turns right now, whether or not this scroller asked. */\n loadingOlder?: boolean\n /**\n * Load earlier turns. The scroller preserves the reader's position across the\n * resulting insert whether the host resolves before or after rendering them. A\n * rejection is the host's to report: the control stays so the reader can retry.\n */\n onLoadOlder?: () => void | Promise<void>\n /** Words for the loader row; override for another language. */\n olderLabel?: string\n loadingOlderLabel?: string\n /** Rendered above the first turn, below the history control. */\n header?: JSX.Element\n empty?: JSX.Element\n /** A short sentence for the live status region (\"Assistant is responding\"). */\n announcement?: string\n}\n\n/** How far from the top counts as \"reached the top\", in px. */\nconst TOP_MARGIN = 160\n\nexport function MessageScroller(props: MessageScrollerProps) {\n const [local, rest] = splitProps(props, [\n 'class',\n 'hasOlder',\n 'loadingOlder',\n 'onLoadOlder',\n 'olderLabel',\n 'loadingOlderLabel',\n 'header',\n 'empty',\n 'announcement',\n 'ref',\n 'resetKey',\n 'children',\n ])\n let scroller: HTMLDivElement | undefined\n let content: HTMLDivElement | undefined\n // A load whose promise resolved while the host still reports `loadingOlder`: its\n // turns land when the host clears it, and the anchor is held until then.\n let afterHostLoad: (() => void) | undefined\n createEffect(() => {\n if (local.loadingOlder || !afterHostLoad) return\n const resume = afterHostLoad\n afterHostLoad = undefined\n resume()\n })\n let holdFollow: (() => () => void) | undefined\n let epoch = 0\n const [inFlight, setInFlight] = createSignal(false)\n\n // While a load holds the reader's place, the browser's own scroll anchoring is\n // switched off: it moves the offset by the same insert, and the two corrections\n // would be added together.\n let nativeAnchoring: string | undefined\n const holdNativeAnchoring = () => {\n if (!scroller || nativeAnchoring !== undefined) return\n nativeAnchoring = scroller.style.overflowAnchor\n scroller.style.overflowAnchor = 'none'\n }\n const releaseNativeAnchoring = () => {\n if (scroller && nativeAnchoring !== undefined) scroller.style.overflowAnchor = nativeAnchoring\n nativeAnchoring = undefined\n }\n\n // A session switch invalidates a load that was started for the previous one.\n createEffect(() => {\n void local.resetKey\n epoch += 1\n afterHostLoad = undefined\n setInFlight(false)\n stopWatching()\n releaseNativeAnchoring()\n })\n\n const settle = (\n anchor: ScrollAnchor | undefined,\n run: number,\n heightBefore: number,\n restoreFocus: boolean,\n releaseHold?: () => void\n ) => {\n const finish = () => {\n if (run !== epoch) return releaseHold?.()\n if (scroller) restoreAnchor(scroller, anchor)\n stopWatching()\n releaseNativeAnchoring()\n setInFlight(false)\n // The control that started the load was replaced by the loading line, which\n // takes focus with it. Put it back on the control (or the thread), so a\n // keyboard user is not dropped onto the page.\n if (restoreFocus && scroller && document.activeElement === document.body) {\n const again = scroller.querySelector<HTMLElement>(\n '[data-slot=\"message-scroller-older\"] button'\n )\n ;(again ?? scroller).focus({ preventScroll: true })\n }\n // Still at the top after a load that added content: keep going, so a\n // pane taller than one page of history fills without a second scroll.\n if (\n scroller &&\n local.hasOlder &&\n scroller.scrollTop < TOP_MARGIN &&\n scroller.scrollHeight > heightBefore\n )\n void load()\n releaseHold?.()\n }\n // Two frames: the first lets the host's insert commit, the second lets\n // late-sizing content (images, highlighted code) report its height.\n const afterInsert = () =>\n requestAnimationFrame(() =>\n requestAnimationFrame(() => {\n if (run !== epoch) return releaseHold?.()\n if (local.loadingOlder) afterHostLoad = afterInsert\n else finish()\n })\n )\n afterInsert()\n }\n\n let observer: MutationObserver | undefined\n let resizer: ResizeObserver | undefined\n let unfollow: (() => void) | undefined\n const stopWatching = () => {\n observer?.disconnect()\n resizer?.disconnect()\n unfollow?.()\n unfollow = undefined\n }\n const load = async (fromControl = false) => {\n if (!scroller || !local.onLoadOlder || !local.hasOlder || local.loadingOlder || inFlight())\n return\n const run = epoch\n const anchor = captureAnchor(scroller, anchorIds(scroller))\n const heightBefore = scroller.scrollHeight\n const restoreFocus =\n fromControl && document.activeElement?.closest('[data-slot=\"message-scroller-older\"]') != null\n setInFlight(true)\n holdNativeAnchoring()\n // Every layout change while the load is open re-pins the anchor *before\n // paint*, which is what makes the insert invisible.\n stopWatching()\n observer = new MutationObserver(() => {\n if (run === epoch && scroller) restoreAnchor(scroller, anchor)\n })\n observer.observe(scroller, { childList: true, subtree: true })\n // Turns that size themselves late (`content-visibility`, images, highlighted code)\n // move the anchor without adding or removing a node, and with the browser's own\n // anchoring held off nothing else would carry the reader through that.\n if (content && typeof ResizeObserver !== 'undefined') {\n resizer = new ResizeObserver(() => {\n if (run === epoch && scroller) restoreAnchor(scroller, anchor)\n })\n resizer.observe(content)\n }\n // The reader may carry on scrolling while the host answers. A restore re-takes the\n // anchor on the turn they have come to, whichever of the observers or this event\n // reaches it first.\n const follow = () => {\n if (run === epoch && scroller) restoreAnchor(scroller, anchor)\n }\n scroller.addEventListener('scroll', follow, { passive: true })\n const watched = scroller\n unfollow = () => watched.removeEventListener('scroll', follow)\n await Promise.resolve(local.onLoadOlder()).catch(() => undefined)\n // A load that outlived its conversation inserts into a thread whose reader it knows\n // nothing about, and the anchor it held is gone. What it does to the layout (rows\n // taking their height, a clamp, the insert itself) is not the reader scrolling, so the\n // follow position is held until the two frames the insert needs have passed.\n settle(anchor, run, heightBefore, restoreFocus, run !== epoch ? holdFollow?.() : undefined)\n }\n\n onCleanup(() => {\n epoch += 1\n stopWatching()\n releaseNativeAnchoring()\n })\n\n const watchTop = (element: HTMLDivElement) => {\n if (typeof IntersectionObserver === 'undefined') return\n const io = new IntersectionObserver(\n (entries) => {\n if (entries.some((entry) => entry.isIntersecting)) void load()\n },\n { root: scroller ?? null, rootMargin: `${TOP_MARGIN}px 0px 0px 0px` }\n )\n io.observe(element)\n onCleanup(() => io.disconnect())\n }\n\n return (\n <div\n class={cn('relative flex min-h-0 flex-1 flex-col', local.class)}\n data-slot=\"message-scroller\"\n >\n <ConversationSurface\n role=\"log\"\n aria-live=\"polite\"\n aria-relevant=\"additions\"\n resetKey={local.resetKey}\n contentRef={(element) => {\n content = element\n }}\n onFollowHold={(hold) => {\n holdFollow = hold\n }}\n {...rest}\n ref={(element) => {\n scroller = element\n if (typeof local.ref === 'function') local.ref(element)\n }}\n class=\"flex-1\"\n header={\n <>\n <Show when={local.hasOlder || local.loadingOlder}>\n <div\n ref={watchTop}\n data-slot=\"message-scroller-older\"\n class=\"flex justify-center py-2\"\n >\n <Show\n when={local.loadingOlder || inFlight()}\n fallback={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n class=\"gap-1.5 text-muted-foreground\"\n onClick={() => void load(true)}\n >\n <History aria-hidden=\"true\" />\n {local.olderLabel ?? 'Load earlier messages'}\n </Button>\n }\n >\n <p\n role=\"status\"\n // The button's own height: swapping one for the other must not move\n // the turns below it by even a pixel while the anchor is being held.\n class=\"flex h-control-sm items-center gap-1.5 text-xs text-muted-foreground\"\n >\n <LoaderCircle aria-hidden=\"true\" class=\"size-3.5 motion-safe:animate-spin\" />\n {local.loadingOlderLabel ?? 'Loading earlier messages…'}\n </p>\n </Show>\n </div>\n </Show>\n {local.header}\n </>\n }\n empty={local.empty}\n >\n {local.children}\n </ConversationSurface>\n <p role=\"status\" class=\"sr-only\">\n {local.announcement}\n </p>\n </div>\n )\n}\n"],"mappings":";;;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QwB,KAAA;MAAAV,OAAAU,OAAAT,gBAIZnG,MAAI;OAAA,IACH0G,OAAI;QAAA,OAAE/E,MAAMZ,gBAAgBsB,SAAS;OAAC;OAAA,IACtC0E,WAAQ;QAAA,OAAAZ,gBACL9F,QAAM;SACL2G,MAAI;SACJC,SAAO;SACPC,MAAI;SAAA,SAAA;SAEJC,eAAe,KAAKpD,KAAK,IAAI;SAAC,IAAA4C,WAAA;UAAA,OAAA,CAAAR,gBAE7BvG,SAAO,EAAA,eAAA,OAAA,CAAA,GAAAwH,WACPzF,MAAMT,cAAc,uBAAuB,CAAA;SAAA;QAAA,CAAA;OAAA;OAAA,IAAAyF,WAAA;QAAA,IAAAU,QAAAC,QAAA;QAAApB,OAAAmB,OAAAlB,gBAU7CtG,cAAY;SAAA,eAAA;SAAA,SAAA;QAAA,CAAA,GAAA,IAAA;QAAAqG,OAAAmB,aACZ1F,MAAMR,qBAAqB,6BAA2B,IAAA;QAAA,OAAAkG;OAAA;MAAA,CAAA,CAAA;MAAA,OAAAT;KAAA;IAAA,CAAA,GAAAQ,WAK9DzF,MAAMP,MAAM,CAAA;GAAA;GAAA,IAGjBE,QAAK;IAAA,OAAEK,MAAML;GAAK;GAAA,IAAAqF,WAAA;IAAA,OAEjBhF,MAAMgF;GAAQ;EAAA,CAAA,CAAA,GAAAX,KAAA;EAAAE,OAAAF,aAGdrE,MAAMJ,YAAY;EAAAgG,aAAAC,UAAA1B,MA/Dd1F,GAAG,yCAAyCuB,MAAM8F,KAAK,CAAC,CAAA;EAAA,OAAA3B;CAAA,EAAA,CAAA;AAmErE"}
|
|
1
|
+
{"version":3,"file":"message-scroller.js","names":["History","LoaderCircle","createEffect","onCleanup","Show","splitProps","createSignal","cn","Button","ConversationSurface","anchorIds","captureAnchor","restoreAnchor","hasOlder","loadingOlder","onLoadOlder","Promise","olderLabel","loadingOlderLabel","header","empty","announcement","TOP_MARGIN","MessageScroller","props","local","rest","scroller","content","afterHostLoad","resume","undefined","holdFollow","epoch","inFlight","setInFlight","nativeAnchoring","holdNativeAnchoring","style","overflowAnchor","releaseNativeAnchoring","resetKey","stopWatching","settle","anchor","run","heightBefore","restoreFocus","releaseHold","finish","document","activeElement","body","again","querySelector","focus","preventScroll","scrollTop","scrollHeight","load","afterInsert","requestAnimationFrame","observer","MutationObserver","resizer","ResizeObserver","unfollow","disconnect","fromControl","closest","observe","childList","subtree","follow","addEventListener","passive","watched","removeEventListener","resolve","catch","watchTop","element","IntersectionObserver","io","entries","some","entry","isIntersecting","root","rootMargin","_el$","_tmpl$","_el$2","firstChild","_$insert","_$createComponent","_$mergeProps","role","contentRef","onFollowHold","hold","ref","when","children","_el$3","_tmpl$3","_$use","fallback","type","variant","size","onClick","_$memo","_el$4","_tmpl$2","_$effect","_$className","class"],"sources":["../../../../src/components/composites/message-scroller/message-scroller.tsx"],"sourcesContent":["import { History, LoaderCircle } from 'lucide-solid'\nimport { createEffect, onCleanup, Show, splitProps, createSignal, type JSX } from 'solid-js'\nimport { cn } from '#lib/utils'\nimport { Button } from '../../ui/button'\nimport { ConversationSurface, type ConversationSurfaceProps } from '../../conversation'\nimport { anchorIds, captureAnchor, restoreAnchor, type ScrollAnchor } from './scroll-anchor'\n\n/**\n * MessageScroller.\n *\n * The thread. It owns the three scroll behaviours a chat gets wrong when each\n * is bolted on separately, and keeps them from fighting:\n *\n * 1. **Follow the reply only while the reader is at the bottom.** New and\n * streaming content scrolls into view when the reader is already at the end,\n * and never otherwise. Scrolling up parks the view; the \"Jump to latest\"\n * control brings it back. (This is `ConversationSurface`'s follow contract,\n * which this component wraps rather than reimplements.)\n * 2. **Load history without moving what the reader is looking at.** When the\n * reader reaches the top, `onLoadOlder` is asked for earlier turns. Turns\n * inserted *above* the viewport would normally push the visible content down\n * by exactly their height; here the first visible turn (found by\n * `data-anchor-id`, which `Message` sets from `anchorId`) is measured before\n * the load and put back to the same offset after it, on every layout change\n * until the load settles — so images and code blocks that size themselves\n * late do not jolt the view either. A \"Load earlier\" button is always present\n * while there is more, because the scroll trigger alone is unreachable to a\n * keyboard or switch user and fires nothing in a short pane.\n * 3. **Announce without flooding.** The scroller is a polite log, and a turn that\n * is still arriving marks itself `aria-busy`, so a screen reader waits for the\n * settled turn instead of reading every token. `announcement` is a separate\n * status region for the two moments that matter: a response starting and a\n * response finishing.\n *\n * What it does not own: which turns exist, their identity, or what \"older\"\n * means. The host passes children and a loader; a session switch is\n * `resetKey`, which re-arms follow and discards any in-flight anchor.\n */\nexport type MessageScrollerProps = Omit<ConversationSurfaceProps, 'header' | 'empty'> & {\n hasOlder?: boolean\n /** The host is loading earlier turns right now, whether or not this scroller asked. */\n loadingOlder?: boolean\n /**\n * Load earlier turns. The scroller preserves the reader's position across the\n * resulting insert whether the host resolves before or after rendering them. A\n * rejection is the host's to report: the control stays so the reader can retry.\n */\n onLoadOlder?: () => void | Promise<void>\n /** Words for the loader row; override for another language. */\n olderLabel?: string\n loadingOlderLabel?: string\n /** Rendered above the first turn, below the history control. */\n header?: JSX.Element\n empty?: JSX.Element\n /** A short sentence for the live status region (\"Assistant is responding\"). */\n announcement?: string\n}\n\n/** How far from the top counts as \"reached the top\", in px. */\nconst TOP_MARGIN = 160\n\nexport function MessageScroller(props: MessageScrollerProps) {\n const [local, rest] = splitProps(props, [\n 'class',\n 'hasOlder',\n 'loadingOlder',\n 'onLoadOlder',\n 'olderLabel',\n 'loadingOlderLabel',\n 'header',\n 'empty',\n 'announcement',\n 'ref',\n 'resetKey',\n 'children',\n ])\n let scroller: HTMLDivElement | undefined\n let content: HTMLDivElement | undefined\n // A load whose promise resolved while the host still reports `loadingOlder`: its\n // turns land when the host clears it, and the anchor is held until then.\n let afterHostLoad: (() => void) | undefined\n createEffect(() => {\n if (local.loadingOlder || !afterHostLoad) return\n const resume = afterHostLoad\n afterHostLoad = undefined\n resume()\n })\n let holdFollow: (() => () => void) | undefined\n let epoch = 0\n const [inFlight, setInFlight] = createSignal(false)\n\n // While a load holds the reader's place, the browser's own scroll anchoring is\n // switched off: it moves the offset by the same insert, and the two corrections\n // would be added together.\n let nativeAnchoring: string | undefined\n const holdNativeAnchoring = () => {\n if (!scroller || nativeAnchoring !== undefined) return\n nativeAnchoring = scroller.style.overflowAnchor\n scroller.style.overflowAnchor = 'none'\n }\n const releaseNativeAnchoring = () => {\n if (scroller && nativeAnchoring !== undefined) scroller.style.overflowAnchor = nativeAnchoring\n nativeAnchoring = undefined\n }\n\n // A session switch invalidates a load that was started for the previous one.\n createEffect(() => {\n void local.resetKey\n epoch += 1\n afterHostLoad = undefined\n setInFlight(false)\n stopWatching()\n releaseNativeAnchoring()\n })\n\n const settle = (\n anchor: ScrollAnchor | undefined,\n run: number,\n heightBefore: number,\n restoreFocus: boolean,\n releaseHold?: () => void\n ) => {\n const finish = () => {\n if (run !== epoch) return releaseHold?.()\n if (scroller) restoreAnchor(scroller, anchor)\n stopWatching()\n releaseNativeAnchoring()\n setInFlight(false)\n // The control that started the load was replaced by the loading line, which\n // takes focus with it. Put it back on the control (or the thread), so a\n // keyboard user is not dropped onto the page.\n if (restoreFocus && scroller && document.activeElement === document.body) {\n const again = scroller.querySelector<HTMLElement>(\n '[data-slot=\"message-scroller-older\"] button'\n )\n ;(again ?? scroller).focus({ preventScroll: true })\n }\n // Still at the top after a load that added content: keep going, so a\n // pane taller than one page of history fills without a second scroll.\n if (\n scroller &&\n local.hasOlder &&\n scroller.scrollTop < TOP_MARGIN &&\n scroller.scrollHeight > heightBefore\n )\n void load()\n releaseHold?.()\n }\n // Two frames: the first lets the host's insert commit, the second lets\n // late-sizing content (images, highlighted code) report its height.\n const afterInsert = () =>\n requestAnimationFrame(() =>\n requestAnimationFrame(() => {\n if (run !== epoch) return releaseHold?.()\n if (local.loadingOlder) afterHostLoad = afterInsert\n else finish()\n })\n )\n afterInsert()\n }\n\n let observer: MutationObserver | undefined\n let resizer: ResizeObserver | undefined\n let unfollow: (() => void) | undefined\n const stopWatching = () => {\n observer?.disconnect()\n resizer?.disconnect()\n unfollow?.()\n unfollow = undefined\n }\n const load = async (fromControl = false) => {\n if (!scroller || !local.onLoadOlder || !local.hasOlder || local.loadingOlder || inFlight())\n return\n const run = epoch\n const anchor = captureAnchor(scroller, anchorIds(scroller))\n const heightBefore = scroller.scrollHeight\n const restoreFocus =\n fromControl && document.activeElement?.closest('[data-slot=\"message-scroller-older\"]') != null\n setInFlight(true)\n holdNativeAnchoring()\n // Every layout change while the load is open re-pins the anchor *before\n // paint*, which is what makes the insert invisible.\n stopWatching()\n observer = new MutationObserver(() => {\n if (run === epoch && scroller) restoreAnchor(scroller, anchor)\n })\n observer.observe(scroller, { childList: true, subtree: true })\n // Turns that size themselves late (`content-visibility`, images, highlighted code)\n // move the anchor without adding or removing a node, and with the browser's own\n // anchoring held off nothing else would carry the reader through that.\n if (content && typeof ResizeObserver !== 'undefined') {\n resizer = new ResizeObserver(() => {\n if (run === epoch && scroller) restoreAnchor(scroller, anchor)\n })\n resizer.observe(content)\n }\n // The reader may carry on scrolling while the host answers. A restore re-takes the\n // anchor on the turn they have come to, whichever of the observers or this event\n // reaches it first.\n const follow = () => {\n if (run === epoch && scroller) restoreAnchor(scroller, anchor)\n }\n scroller.addEventListener('scroll', follow, { passive: true })\n const watched = scroller\n unfollow = () => watched.removeEventListener('scroll', follow)\n await Promise.resolve(local.onLoadOlder()).catch(() => undefined)\n // A load that outlived its conversation inserts into a thread whose reader it knows\n // nothing about, and the anchor it held is gone. What it does to the layout (rows\n // taking their height, a clamp, the insert itself) is not the reader scrolling, so the\n // follow position is held until the two frames the insert needs have passed.\n settle(anchor, run, heightBefore, restoreFocus, run !== epoch ? holdFollow?.() : undefined)\n }\n\n onCleanup(() => {\n epoch += 1\n stopWatching()\n releaseNativeAnchoring()\n })\n\n const watchTop = (element: HTMLDivElement) => {\n if (typeof IntersectionObserver === 'undefined') return\n const io = new IntersectionObserver(\n (entries) => {\n if (entries.some((entry) => entry.isIntersecting)) void load()\n },\n { root: scroller ?? null, rootMargin: `${TOP_MARGIN}px 0px 0px 0px` }\n )\n io.observe(element)\n onCleanup(() => io.disconnect())\n }\n\n return (\n <div\n class={cn('relative flex min-h-0 flex-1 flex-col', local.class)}\n data-slot=\"message-scroller\"\n >\n <ConversationSurface\n role=\"log\"\n aria-live=\"polite\"\n aria-relevant=\"additions\"\n resetKey={local.resetKey}\n contentRef={(element) => {\n content = element\n }}\n onFollowHold={(hold) => {\n holdFollow = hold\n }}\n {...rest}\n ref={(element) => {\n scroller = element\n if (typeof local.ref === 'function') local.ref(element)\n }}\n class=\"flex-1\"\n header={\n <>\n <Show when={local.hasOlder || local.loadingOlder}>\n <div\n ref={watchTop}\n data-slot=\"message-scroller-older\"\n class=\"flex justify-center py-2\"\n >\n <Show\n when={local.loadingOlder || inFlight()}\n fallback={\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n class=\"gap-1.5 text-muted-foreground\"\n onClick={() => void load(true)}\n >\n <History aria-hidden=\"true\" />\n {local.olderLabel ?? 'Load earlier messages'}\n </Button>\n }\n >\n <p\n role=\"status\"\n // The button's own height: swapping one for the other must not move\n // the turns below it by even a pixel while the anchor is being held.\n class=\"flex h-control-sm items-center gap-1.5 text-xs text-muted-foreground\"\n >\n <LoaderCircle aria-hidden=\"true\" class=\"size-3.5 motion-safe:animate-spin\" />\n {local.loadingOlderLabel ?? 'Loading earlier messages…'}\n </p>\n </Show>\n </div>\n </Show>\n {local.header}\n </>\n }\n empty={local.empty}\n >\n {local.children}\n </ConversationSurface>\n <p role=\"status\" class=\"sr-only\">\n {local.announcement}\n </p>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;AA2DA,IAAMsB,aAAa;AAEnB,SAAgBC,gBAAgBC,OAA6B;CAC3D,MAAM,CAACC,OAAOC,QAAQrB,WAAWmB,OAAO;EACtC;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CAAU,CACX;CACD,IAAIG;CACJ,IAAIC;CAGJ,IAAIC;CACJ3B,mBAAmB;EACjB,IAAIuB,MAAMX,gBA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