Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(crm): board scrollbar UX, snapping layout, trimmed default stages (#4822)
Evan Hutnikfffc17d6de76
diff --git a/apps/web/src/features/companies/crm/deal-stages.ts b/apps/web/src/features/companies/crm/deal-stages.tsindex b54e6ce857..5ae7d0f878 100644--- a/apps/web/src/features/companies/crm/deal-stages.ts+++ b/apps/web/src/features/companies/crm/deal-stages.ts@@ -18,6 +18,7 @@import { soupPropertyToProperty } from '@entity/extractors-property';import { getCompanyStageOptionId } from '@entity/utils/company-properties';import {+ ALL_COMPANY_STAGE_OPTIONS,COMPANY_STAGE_OPTIONS,getPropertyOptionLabel,} from '@entity/utils/task-properties';@@ -45,6 +46,12 @@ export type DealStage = {export type DealStages = {/** Active stages, in display order (team set when customized). */stages: Accessor<DealStage[]>;+ /**+ * Stages offered by stage *filters*: the active set plus, on the system+ * default set, the retired legacy stages — companies may still carry+ * those values and should stay reachable.+ */+ filterStages: Accessor<DealStage[]>;/** True when the team has its own stage set. */isCustomized: Accessor<boolean>;/** Definition id stage values are read from / written to. */@@ -79,6 +86,15 @@ const DEFAULT_STAGES: DealStage[] = COMPANY_STAGE_OPTIONS.map((option) => ({label: option.label,}));+// The filterable set on the system default: every system stage, in+// canonical pipeline order (legacy stages included).+const ALL_SYSTEM_STAGES: DealStage[] = ALL_COMPANY_STAGE_OPTIONS.map(+ (option) => ({+ id: option.value as string,+ label: option.label,+ })+);+function optionLabel(option: PropertyOption): string {const value = option.value;if (@@ -219,6 +235,10 @@ export function useDealStages(): DealStages {return customStages.length > 0 ? customStages : DEFAULT_STAGES;});+ const filterStages = createMemo((): DealStage[] =>+ isCustomized() ? stages() : ALL_SYSTEM_STAGES+ );+const stageDefinitionId = createMemo(() => {const definition = teamStageDefinition();return definition && stagesFromDefinition(definition).length > 0@@ -265,6 +285,7 @@ export function useDealStages(): DealStages {return {stages,+ filterStages,isCustomized,stageDefinitionId,stageProperty,diff --git a/apps/web/src/features/entity/utils/task-properties.ts b/apps/web/src/features/entity/utils/task-properties.tsindex 5da4aedde3..d31f41b0c7 100644--- a/apps/web/src/features/entity/utils/task-properties.ts+++ b/apps/web/src/features/entity/utils/task-properties.ts@@ -16,7 +16,19 @@ const TASK_PRIORITY_OPTIONS = [{ value: PROPERTY_OPTION_IDS.PRIORITY.LOW, label: 'Low' },] as const;-export const COMPANY_STAGE_OPTIONS = [+// Retired from the default stage set, but companies may still carry these+// values — labels stay resolvable and stage filters still offer them.+const LEGACY_STAGE_IDS: ReadonlySet<string> = new Set([+ PROPERTY_OPTION_IDS.STAGE.QUALIFIED,+ PROPERTY_OPTION_IDS.STAGE.TRIAL,+ PROPERTY_OPTION_IDS.STAGE.NEGOTIATION,+]);++/**+ * Every system stage option in canonical pipeline order — fixes the+ * display order of stage filters/columns when legacy stages are shown.+ */+export const ALL_COMPANY_STAGE_OPTIONS = [{ value: PROPERTY_OPTION_IDS.STAGE.LEAD, label: 'Lead' },{ value: PROPERTY_OPTION_IDS.STAGE.QUALIFIED, label: 'Qualified' },{ value: PROPERTY_OPTION_IDS.STAGE.DEMO, label: 'Demo' },@@ -26,10 +38,17 @@ export const COMPANY_STAGE_OPTIONS = [{ value: PROPERTY_OPTION_IDS.STAGE.CHURNED, label: 'Churned' },] as const;+/** The default (non-legacy) stage set, in canonical order. */+export const COMPANY_STAGE_OPTIONS = ALL_COMPANY_STAGE_OPTIONS.filter(+ (option) => !LEGACY_STAGE_IDS.has(option.value)+);+const PROPERTY_OPTION_LABELS: Record<string, string> = {...Object.fromEntries(TASK_STATUS_OPTIONS.map((o) => [o.value, o.label])),...Object.fromEntries(TASK_PRIORITY_OPTIONS.map((o) => [o.value, o.label])),- ...Object.fromEntries(COMPANY_STAGE_OPTIONS.map((o) => [o.value, o.label])),+ ...Object.fromEntries(+ ALL_COMPANY_STAGE_OPTIONS.map((o) => [o.value, o.label])+ ),};export const getPropertyOptionLabel = (diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/consolidated-filter-chip.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/consolidated-filter-chip.tsxindex 8c0fee4985..3da59768ff 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/consolidated-filter-chip.tsx+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/consolidated-filter-chip.tsx@@ -53,6 +53,8 @@ export type ConsolidatedFilter = {searchPlaceholder?: string;isPopupOpen?: Accessor<boolean>;setPopupOpen?: (v: boolean) => void;+ /** Keep options in their given order instead of pinning selected first. */+ preserveOptionOrder?: boolean;};interface ConsolidatedFilterChipProps {@@ -257,6 +259,7 @@ const SearchableValueSegment = (props: {placement="bottom-start"open={props.filter.isPopupOpen}onOpenChange={(v) => props.filter.setPopupOpen?.(v)}+ preserveOrder={props.filter.preserveOptionOrder}><Combobox.Triggerclass={cn(diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/searchable-multi-select.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/searchable-multi-select.tsxindex 2b7d60d8ea..beb5ec07b4 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/searchable-multi-select.tsx+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/searchable-multi-select.tsx@@ -317,6 +317,8 @@ type SearchableMultiSelectInlineProps = {inputRef?: (el: HTMLInputElement) => void;onRequestClose?: () => void;listboxClass?: string;+ /** Keep `options` in their given order instead of pinning selected first. */+ preserveOrder?: boolean;};/**@@ -335,12 +337,14 @@ export const SearchableMultiSelectInline = (// Inline variant is freshly mounted each time the parent submenu opens,// so we don't need an explicit "menu opened" trigger — the memo's first// run captures the current selection ordering.- const sortedOptions = useSelectedFirst({+ const selectedFirstOptions = useSelectedFirst({items: props.options,selectedIds: props.activeIds,searchQuery,getId: getOptionId,});+ const sortedOptions = () =>+ props.preserveOrder ? props.options() : selectedFirstOptions();const handleChange = (selected: SearchableOption[]) => {props.onChange(selected.map((o) => o.id));diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsxindex 79c49e3ad6..d443f437cc 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx@@ -397,6 +397,8 @@ const SearchableFilterSubmenu = (props: {placeholder?: string;open?: Accessor<boolean>;onOpenChange?: (v: boolean) => void;+ /** Keep `options` in their given order instead of pinning selected first. */+ preserveOrder?: boolean;}) => {const [internalOpen, setInternalOpen] = createSignal(false);const isOpen = () => props.open?.() ?? internalOpen();@@ -468,6 +470,7 @@ const SearchableFilterSubmenu = (props: {onChange={props.onChange}options={props.options}inputRef={setInputRef}+ preserveOrder={props.preserveOrder}/></Dropdown.Group></Dropdown.SubContent>@@ -765,9 +768,10 @@ export const UnifiedFilterDropdown = (};// Stage options for the Customers view: the team's active deal-stage set- // plus a trailing "No stage" row.+ // (plus retired legacy stages on the default set) and a trailing+ // "No stage" row.const stageOptions = createMemo((): SearchableOption[] => [- ...dealStages.stages().map((stage, index) => ({+ ...dealStages.filterStages().map((stage, index) => ({id: stage.id,label: stage.label,icon: () => (@@ -781,20 +785,26 @@ export const UnifiedFilterDropdown = (},]);- // The stage submenu reflects what's on screen: an empty filter shows- // every stage, so everything reads as checked.+ // The stage set shown when no filter is active: the active deal stages+ // plus "No stage" — retired legacy stages only display when filtered in.+ const defaultStageIds = createMemo(+ () => new Set([...dealStages.stages().map((stage) => stage.id), NO_STAGE])+ );++ // The stage submenu reflects what's on screen: an empty filter shows the+ // default columns, so exactly those read as checked (legacy stages don't).const effectiveStageFilter = () =>- stageFilter().length > 0- ? stageFilter()- : stageOptions().map((option) => option.id);+ stageFilter().length > 0 ? stageFilter() : [...defaultStageIds()];// Stage filtering is a client-side predicate, mirroring the owner filter.const handleStageChange = (ids: string[]) => {- // Checking every stage is the same as no filter — store it as empty so- // the predicate deactivates.- const next = stageOptions().every((option) => ids.includes(option.id))- ? []- : ids;+ // Checking exactly the default set is the same as no filter — store it+ // as empty so the predicate deactivates.+ const next =+ ids.length === defaultStageIds().size &&+ ids.every((id) => defaultStageIds().has(id))+ ? []+ : ids;batch(() => {setStageFilter(next);const shouldBeActive = next.length > 0;@@ -961,6 +971,7 @@ export const UnifiedFilterDropdown = (activeIds={effectiveStageFilter}onChange={handleStageChange}placeholder="Filter stages..."+ preserveOrder/><SearchableFilterSubmenulabel="Owner"diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/use-filter-refinements.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/use-filter-refinements.tsxindex 8c7c743e14..22033737a2 100644--- a/apps/web/src/features/next-soup/soup-view/filters-bar/use-filter-refinements.tsx+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/use-filter-refinements.tsx@@ -300,10 +300,11 @@ export function useFilterRefinements() {/*** Stage options for the Customers view's stage sub-filter: the team's- * active deal-stage set plus a trailing "No stage" row.+ * active deal-stage set (plus retired legacy stages on the default set)+ * and a trailing "No stage" row.*/const stageSearchableOptions = createMemo((): SearchableOption[] => [- ...dealStages.stages().map((stage, index) => ({+ ...dealStages.filterStages().map((stage, index) => ({id: stage.id,label: stage.label,icon: () => (@@ -815,6 +816,9 @@ export function useFilterRefinements() {activeSearchableIds: stageFilter,onSearchableChange: handleStageChange,searchPlaceholder: 'Filter stages...',+ // Stages read as a pipeline — keep canonical order, don't pin+ // checked ones to the top.+ preserveOptionOrder: true,isPopupOpen,setPopupOpen,onRemoveAll: () => handleStageChange([]),diff --git a/apps/web/src/features/next-soup/soup-view/soup-view.tsx b/apps/web/src/features/next-soup/soup-view/soup-view.tsxindex 0fc9069a9b..9d6079e9f7 100644--- a/apps/web/src/features/next-soup/soup-view/soup-view.tsx+++ b/apps/web/src/features/next-soup/soup-view/soup-view.tsx@@ -44,10 +44,7 @@ import {import { CompanyKanban } from '@app/features/next-soup/soup-view/views/companies/CompanyKanban';import { CompanyListEntity } from '@app/features/next-soup/soup-view/views/companies/CompanyListEntity';import { ResponsiveCompanyListHeader } from '@app/features/next-soup/soup-view/views/companies/CompanyListHeader';-import {- CompanyDisplayMenu,- CompanyViewsMenu,-} from '@app/features/next-soup/soup-view/views/companies/CompanyViewsMenu';+import { CompanyDisplayMenu } from '@app/features/next-soup/soup-view/views/companies/CompanyViewsMenu';import { DateGroupHeader } from '@app/features/next-soup/soup-view/views/inbox/date-group-header';import { InboxListEntity } from '@app/features/next-soup/soup-view/views/inbox/InboxListEntity';import { TaskListEntity } from '@app/features/next-soup/soup-view/views/tasks/TaskListEntity';@@ -667,7 +664,6 @@ export const SoupView = (props: SoupViewProps) => {!narrowSearchExpanded() && isComponentListView('companies')}>- <CompanyViewsMenu /><CompanyDisplayMenu /></Show><Show@@ -752,9 +748,14 @@ export const SoupView = (props: SoupViewProps) => {</div></div><Suspense>+ {/* The board hides the AI bar: it floats over the bottom edge, where+ it would cover the board's horizontal scrollbar. */}<Showwhen={- ENABLE_UNIFIED_LIST_AI_INPUT && !isMobile() && !isNewInboxEnabled()+ ENABLE_UNIFIED_LIST_AI_INPUT &&+ !isMobile() &&+ !isNewInboxEnabled() &&+ !isBoardMode()}><SoupChatInput />diff --git a/apps/web/src/features/next-soup/soup-view/views/companies/CompanyKanban.tsx b/apps/web/src/features/next-soup/soup-view/views/companies/CompanyKanban.tsxindex 9716bebefc..d7b147a7cb 100644--- a/apps/web/src/features/next-soup/soup-view/views/companies/CompanyKanban.tsx+++ b/apps/web/src/features/next-soup/soup-view/views/companies/CompanyKanban.tsx@@ -26,12 +26,20 @@ import {import CircleDashed from '@phosphor/circle-dashed.svg';import { useBulkSaveEntityPropertiesMutation } from '@queries/properties/entity';import { EntityType } from '@service-properties/generated/schemas/entityType';+import { createElementSize } from '@solid-primitives/resize-observer';import { cn, EmptyStatePanel, Layer } from '@ui';import { createMemo, createSignal, For, Show } from 'solid-js';/** Column key for companies without a Stage value. */const NO_STAGE_KEY = '';+/** Minimum column width the snapping layout will shrink to. */+const MIN_COLUMN_WIDTH = 224;+/** gap-3 between columns. */+const COLUMN_GAP = 12;+/** p-3 on each side of the column row. */+const BOARD_PADDING_X = 24;+type StageColumn = {key: string;label: string;@@ -55,20 +63,29 @@ export function CompanyKanban() {const saveMutation = useBulkSaveEntityPropertiesMutation();const orchestrator = useGlobalBlockOrchestrator();- const { stages, stageProperty, resolveStage } = useDealStages();+ const { stages, filterStages, stageProperty, resolveStage } = useDealStages();const { canEditCrm, canMoveClosedDeals } = useCrmPermissions();const closedStageIds = useClosedStageIds(stages);const stageColumns = createMemo((): StageColumn[] => {- const all: StageColumn[] = [- ...stages().map((stage) => ({ key: stage.id, label: stage.label })),+ // Candidates in canonical pipeline order: the filterable set (active+ // stages plus retired legacy stages on the system default), then+ // "No stage" — checked columns always render in this fixed order.+ const candidates: StageColumn[] = [+ ...filterStages().map((stage) => ({ key: stage.id, label: stage.label })),{ key: NO_STAGE_KEY, label: 'No stage' },];// An active stage filter removes the filtered-out columns entirely,- // not just their (already predicate-filtered) cards.+ // not just their (already predicate-filtered) cards. With no filter,+ // only the active stage set shows (legacy stages are opt-in).const filter = stageFilter();- if (filter.length === 0) return all;- return all.filter((column) =>+ if (filter.length === 0) {+ const active = new Set(stages().map((stage) => stage.id));+ return candidates.filter(+ (column) => column.key === NO_STAGE_KEY || active.has(column.key)+ );+ }+ return candidates.filter((column) =>filter.includes(column.key === NO_STAGE_KEY ? NO_STAGE : column.key));});@@ -103,6 +120,27 @@ export function CompanyKanban() {const [dropTarget, setDropTarget] = createSignal<string>();const [scrollRef, setScrollRef] = createSignal<HTMLDivElement>();+ // Columns snap to a whole-column layout: as many columns as fit at the+ // minimum width, each widened to exactly fill the viewport. Growing the+ // board snaps in the next column once there's room; the rest scroll.+ const boardSize = createElementSize(scrollRef);+ const columnWidth = createMemo(() => {+ const width = boardSize.width;+ const count = stageColumns().length;+ if (!width || count === 0) return undefined;+ const usable = width - BOARD_PADDING_X;+ const fit = Math.max(+ 1,+ Math.min(+ count,+ Math.floor((usable + COLUMN_GAP) / (MIN_COLUMN_WIDTH + COLUMN_GAP))+ )+ );+ // Floored so rounding can't overflow the viewport by a pixel and+ // phantom-trigger the horizontal scrollbar.+ return Math.floor((usable - (fit - 1) * COLUMN_GAP) / fit);+ });+const moveToStage = (entityId: string, stageKey: string) => {const entity = companies().find((company) => company.id === entityId);if (!entity) return;@@ -161,13 +199,18 @@ export function CompanyKanban() {{(column, columnIndex) => (<divclass={cn(- // Columns split the available width evenly, but never- // shrink below w-64 — past that the board scrolls.- 'flex h-full min-w-64 flex-1 flex-col rounded-lg border border-edge-muted bg-surface',+ // Fallback sizing until the board is measured; after+ // that the snapping columnWidth() takes over.+ 'flex h-full min-w-56 flex-1 flex-col rounded-lg border border-edge-muted bg-surface',dropTarget() === column.key &&draggedId() &&'border-accent/50 bg-accent/5')}+ style={+ columnWidth() !== undefined+ ? { width: `${columnWidth()}px`, flex: 'none' }+ : undefined+ }onDragOver={(e) => {if (!draggedId()) return;e.preventDefault();@@ -205,9 +248,6 @@ export function CompanyKanban() {/></Show><span class="truncate">{column.label}</span>- <span class="ml-auto shrink-0 tabular-nums px-1.5 py-px rounded-full bg-ink/10 text-ink-extra-muted font-medium">- {column.entities.length}- </span></div><div class="min-h-0 flex-1 overflow-y-auto scrollbar-hidden flex flex-col gap-2 px-2 pb-2"><For each={column.entities}>@@ -247,7 +287,15 @@ export function CompanyKanban() {</For></div></div>- <CustomScrollbar scrollContainer={scrollRef} horizontal />+ {/* watchContent: columns mount after the initial measurement, so+ overflow must be re-detected as they load in. */}+ <CustomScrollbar+ scrollContainer={scrollRef}+ horizontal+ revealZone={48}+ gutterSize={20}+ watchContent+ /></div></Resize.Panel><Show when={paneVisible()}>diff --git a/apps/web/src/features/next-soup/soup-view/views/companies/CompanyViewsMenu.tsx b/apps/web/src/features/next-soup/soup-view/views/companies/CompanyViewsMenu.tsxindex c20dde81a4..7d108b84de 100644--- a/apps/web/src/features/next-soup/soup-view/views/companies/CompanyViewsMenu.tsx+++ b/apps/web/src/features/next-soup/soup-view/views/companies/CompanyViewsMenu.tsx@@ -313,56 +313,71 @@ export function CompanyViewsMenu() {*/export function CompanyDisplayMenu() {const { options, toggleListColumn } = useCrmDisplayOptions();- const { activeTab } = useSoupView();+ const { activeTab, viewMode } = useSoupView();const { applyTabPreset } = useApplyPreset();const isTeamAdmin = useIsTeamAdmin();const showingHidden = () => activeTab() === 'hidden';+ // On the board, the menu holds only the admin-gated hidden toggle — hide+ // the trigger entirely when there'd be nothing to show.+ const hasContent = () => viewMode() === 'list' || isTeamAdmin();+return (- <Dropdown>- <Tooltip label="Display options">- <Dropdown.Trigger depth={2} class="bg-surface" label="Display options">- <SlidersIcon />- </Dropdown.Trigger>- </Tooltip>+ <Show when={hasContent()}>+ <Dropdown>+ <Tooltip label="Display options">+ <Dropdown.Trigger+ depth={2}+ class="bg-surface"+ label="Display options"+ >+ <SlidersIcon />+ </Dropdown.Trigger>+ </Tooltip>- <Dropdown.Content class="w-56 shadow-menu">- <Dropdown.Group>- <Dropdown.GroupLabel>List columns</Dropdown.GroupLabel>- <For each={Object.keys(CRM_LIST_COLUMN_LABELS) as CrmListColumnId[]}>- {(column) => (+ <Dropdown.Content class="w-56 shadow-menu">+ {/* Column visibility only applies to the list. */}+ <Show when={viewMode() === 'list'}>+ <Dropdown.Group>+ <Dropdown.GroupLabel>List columns</Dropdown.GroupLabel>+ <For+ each={Object.keys(CRM_LIST_COLUMN_LABELS) as CrmListColumnId[]}+ >+ {(column) => (+ <Dropdown.CheckboxItem+ checked={options().listColumns[column]}+ onChange={() => toggleListColumn(column)}+ closeOnSelect={false}+ >+ <span class="flex-1 truncate">+ {CRM_LIST_COLUMN_LABELS[column]}+ </span>+ </Dropdown.CheckboxItem>+ )}+ </For>+ </Dropdown.Group>+ </Show>+ {/* Admin/owner only — the BE rejects hidden-set requests from+ non-admins, matching the old Hidden tab's gating. */}+ <Show when={isTeamAdmin()}>+ <Dropdown.Group><Dropdown.CheckboxItem- checked={options().listColumns[column]}- onChange={() => toggleListColumn(column)}+ checked={showingHidden()}+ onChange={() =>+ applyTabPreset(+ 'companies',+ showingHidden() ? 'active' : 'hidden'+ )+ }closeOnSelect={false}>- <span class="flex-1 truncate">- {CRM_LIST_COLUMN_LABELS[column]}- </span>+ <span class="flex-1 truncate">Show hidden companies</span></Dropdown.CheckboxItem>- )}- </For>- </Dropdown.Group>- {/* Admin/owner only — the BE rejects hidden-set requests from- non-admins, matching the old Hidden tab's gating. */}- <Show when={isTeamAdmin()}>- <Dropdown.Group>- <Dropdown.CheckboxItem- checked={showingHidden()}- onChange={() =>- applyTabPreset(- 'companies',- showingHidden() ? 'active' : 'hidden'- )- }- closeOnSelect={false}- >- <span class="flex-1 truncate">Show hidden companies</span>- </Dropdown.CheckboxItem>- </Dropdown.Group>- </Show>- </Dropdown.Content>- </Dropdown>+ </Dropdown.Group>+ </Show>+ </Dropdown.Content>+ </Dropdown>+ </Show>);}diff --git a/apps/web/src/lib/core/component/CustomScrollbar.tsx b/apps/web/src/lib/core/component/CustomScrollbar.tsxindex 77b84ae24f..1ce51d428e 100644--- a/apps/web/src/lib/core/component/CustomScrollbar.tsx+++ b/apps/web/src/lib/core/component/CustomScrollbar.tsx@@ -12,6 +12,22 @@ interface CustomScrollbarProps {enabled?: boolean;reverse?: boolean;horizontal?: boolean;+ /**+ * Reveal the bar when the pointer moves within this many px of the+ * scrollbar edge, instead of only when hovering the gutter itself.+ */+ revealZone?: number;+ /**+ * Re-measure when content mounts/unmounts inside the container. Needed+ * when content loads in after mount without resizing the container.+ */+ watchContent?: boolean;+ /**+ * Thickness (px) of the interactive gutter for clicking/dragging the bar.+ * Defaults to 8. The thumb stays anchored to the scrollbar edge, and wheel+ * events over an enlarged gutter are forwarded to the container.+ */+ gutterSize?: number;}const MIN_THUMB_SIZE = 24;@@ -111,15 +127,47 @@ function InnerCustomScrollbar(props: CustomScrollbarProps) {};container.addEventListener('scroll', handleScroll, { passive: true });++ // Proximity reveal: pointer movement near the scrollbar edge shows the+ // bar without the gutter needing a click-stealing enlarged hit area.+ const handleProximity = (e: PointerEvent) => {+ const zone = props.revealZone;+ if (zone === undefined) return;+ const rect = container.getBoundingClientRect();+ const dist = horiz() ? rect.bottom - e.clientY : rect.right - e.clientX;+ setIsHovered(dist >= 0 && dist <= zone);+ };+ const handleProximityLeave = () => {+ if (props.revealZone !== undefined) setIsHovered(false);+ };+ container.addEventListener('pointermove', handleProximity, {+ passive: true,+ });+ container.addEventListener('pointerleave', handleProximityLeave);+const resizeObserver = new ResizeObserver(updateScrollMetrics);resizeObserver.observe(container);+ let mutationObserver: MutationObserver | undefined;+ if (props.watchContent) {+ mutationObserver = new MutationObserver(updateScrollMetrics);+ mutationObserver.observe(container, { childList: true, subtree: true });+ }+onCleanup(() => {container.removeEventListener('scroll', handleScroll);+ container.removeEventListener('pointermove', handleProximity);+ container.removeEventListener('pointerleave', handleProximityLeave);resizeObserver.disconnect();+ mutationObserver?.disconnect();});});+ // Where the pointer grabbed the thumb, relative to the thumb's start.+ // Keeps the grab point under the pointer while dragging instead of+ // snapping the thumb's center to it.+ let dragOffset = 0;+const scrollToPointer = (clientPos: number, gutterRect: DOMRect) => {const container = props.scrollContainer();if (!container) return;@@ -128,7 +176,7 @@ function InnerCustomScrollbar(props: CustomScrollbarProps) {const mt = maxTop();if (mt <= 0) return;const start = horiz() ? gutterRect.left : gutterRect.top;- const localPos = clientPos - start - thumbSize() / 2;+ const localPos = clientPos - start - dragOffset;const clamped = Math.max(0, Math.min(mt, localPos - THUMB_INSET));let newPos = (clamped / mt) * max;if (props.reverse && !horiz()) newPos = newPos - max;@@ -148,7 +196,14 @@ function InnerCustomScrollbar(props: CustomScrollbarProps) {setIsDragging(true);setIsScrolling(true);const rect = gutter.getBoundingClientRect();- scrollToPointer(horiz() ? e.clientX : e.clientY, rect);+ const clientPos = horiz() ? e.clientX : e.clientY;+ const local = clientPos - (horiz() ? rect.left : rect.top);+ const onThumb =+ local >= thumbOffset() && local <= thumbOffset() + thumbSize();+ // Grabbing the thumb holds it in place until dragged; clicking the+ // track jumps there (centering the thumb on the pointer).+ dragOffset = onThumb ? local - thumbOffset() : thumbSize() / 2;+ if (!onThumb) scrollToPointer(clientPos, rect);};const handlePointerMove = (e: PointerEvent) => {@@ -178,8 +233,31 @@ function InnerCustomScrollbar(props: CustomScrollbarProps) {)}style={horiz()- ? { height: `${GUTTER_SIZE}px`, 'touch-action': 'none' }- : { width: `${GUTTER_SIZE}px`, 'touch-action': 'none' }+ ? {+ height: `${props.gutterSize ?? GUTTER_SIZE}px`,+ 'touch-action': 'none',+ }+ : {+ width: `${props.gutterSize ?? GUTTER_SIZE}px`,+ 'touch-action': 'none',+ }+ }+ onWheel={+ props.gutterSize === undefined+ ? undefined+ : (e) => {+ const container = props.scrollContainer();+ if (!container) return;+ // Consume the event so ancestors don't also scroll, and+ // drive only the axis this bar owns.+ e.preventDefault();+ if (horiz()) {+ container.scrollLeft +=+ e.deltaX || (e.shiftKey ? e.deltaY : 0);+ } else {+ container.scrollTop += e.deltaY;+ }+ }}onPointerDown={handlePointerDown}onPointerMove={handlePointerMove}