import { ThemeIcon } from "../../../../base/common/themables.js"; import { CancellationToken } from "../../../../base/common/cancellation.js"; import { IDisposable } from "../../../../base/common/lifecycle.js"; import { Event } from "../../../../base/common/event.js"; /** Returns whether the target belongs to a mobile picker sheet mounted at the workbench root. */ export declare function isMobilePickerSheetTarget(target: HTMLElement): boolean; /** * One row in the {@link showMobilePickerSheet} bottom sheet. * * Shape mirrors the data the desktop action-widget pickers already produce * (icon + label + optional description + optional checked) so callers can * map their existing items list directly. */ export interface IMobilePickerSheetItem { readonly id: string; readonly label: string; /** Optional badge displayed beside the label and included in its accessible name. */ readonly badge?: string; readonly description?: string; readonly icon?: ThemeIcon; readonly checked?: boolean; readonly disabled?: boolean; /** * When true, the row is rendered with a trailing chevron to signal * that tapping it navigates deeper (drill-down) rather than selecting * a final value. Navigational rows never show the radio checkmark and * are excluded from the in-section radio toggle. */ readonly navigates?: boolean; /** * Optional section title shown above this row. When set, a divider is * inserted above the row (for sections after the first) and the title * text is rendered as a small uppercase label. Pass an empty string * (`''`) to insert a divider with no title — useful for translating * action-list `Separator` items. */ readonly sectionTitle?: string; } export interface IMobilePickerSheetOptions { /** Dismisses the sheet when its owner or picker data becomes unavailable. */ readonly cancellationToken?: CancellationToken; /** * Optional caption shown beneath the title (single-line, muted). Useful * for explaining what the picker controls (e.g. "Agents are pre-configured * templates"). */ readonly caption?: string; /** * Optional set of icon buttons rendered in the sheet's title row to * the left of the Done button. Use these for sheet-level actions * (e.g. "browse for a folder") that aren't a single picker row. * * Each button resolves the sheet with `headerAction:` so the * caller can route header taps the same way it routes row taps. */ readonly headerActions?: readonly IMobilePickerSheetHeaderAction[]; /** * Optional inline-search section. When set, a search input is * rendered below the title row and the result list is appended below * the static items list, refreshed (with cancellation) as the user * types. Tapping a result row resolves the sheet with that row's id, * exactly like a static row. */ readonly search?: IMobilePickerSheetSearchSource; /** * When true, row taps call {@link onDidSelect} instead of resolving * the sheet. The sheet stays open until the user taps Done, the * backdrop, or presses Escape (all resolve with `undefined`). Use * this for multi-property sheets (e.g. Worktree + Branch) where the * user adjusts several values before dismissing, or for drill-down * navigation where a tap replaces the row list rather than picking * a final value. * * When false (default), a row tap resolves the sheet with that * row's id and closes immediately (the original behavior). */ readonly stayOpenOnSelect?: boolean; /** * Called when a row is tapped and {@link stayOpenOnSelect} is true. * Callers should write-through the selection (e.g. * `provider.setSessionConfigValue`). * * If the callback returns a string, that string is injected into * the search input and a new query is triggered — use this for * drill-down navigation where tapping a folder replaces the query * with `folderName/` to list its children. * * If the callback returns {@link MOBILE_PICKER_SHEET_CONFIRM}, the * tapped row is treated as confirmed: the sheet resolves with that * row's id and closes immediately. * * Ignored when `stayOpenOnSelect` is false. */ readonly onDidSelect?: (id: string) => string | typeof MOBILE_PICKER_SHEET_CONFIRM | void; /** * Optional override for the dismiss button label (defaults to "Done"). * Use "Cancel" for sheets where rows self-confirm on tap and the * header button is purely a dismiss affordance. */ readonly doneLabel?: string; } /** * A pinned, single primary action rendered above the scrollable list. * Tapping it runs {@link run} and then closes the sheet. Produced by * {@link IMobilePickerSheetSearchSource.getPrimaryAction} for the current * query. */ export interface IMobilePickerSheetPrimaryAction { readonly label: string; readonly icon?: ThemeIcon; readonly run: () => void; } export interface IMobilePickerSheetHeaderAction { readonly id: string; readonly label: string; readonly icon: ThemeIcon; } /** * Backs the inline search section in {@link IMobilePickerSheetOptions.search}. * The sheet calls {@link loadItems} with the current input value (debounced) * and a cancellation token that fires when the user types again or the * sheet closes; implementations should honor it before yielding stale * results. */ export interface IMobilePickerSheetSearchSource { /** Placeholder text for the search input. */ readonly placeholder: string; /** Section title shown above the result list. */ readonly resultsSectionTitle?: string; /** Aria label for the search input (defaults to {@link placeholder}). */ readonly ariaLabel?: string; /** Message rendered inside the result list when zero results are returned. */ readonly emptyMessage?: string; /** Notifies the sheet that the current query's results have changed. */ readonly onDidChangeItems?: Event; /** Loads the result rows for the given query. */ loadItems(query: string, token: CancellationToken): Promise; /** * Optional pinned primary action for the given query, rendered above * the result list. Return `undefined` to hide it. Called on every * query change, so the action can track the browse state (e.g. an * "Open this folder" button that follows the folder being browsed). */ getPrimaryAction?(query: string): IMobilePickerSheetPrimaryAction | undefined; } /** * Renderer API passed into the {@link showMobileContentSheet} body * callback. The renderer fills {@link bodyContainer} with arbitrary DOM * and may call {@link close} to dismiss the sheet (e.g. after a confirm * button is tapped, or after a sub-view navigation completes). */ export interface IMobileContentSheetApi { /** * The same element passed as the first argument to the body * renderer; exposed here for convenience so callbacks can capture * the API object without also closing over the body element. */ readonly bodyContainer: HTMLElement; readonly sheet: HTMLElement; readonly overlay: HTMLElement; /** Update the body's tab stops when opting into focus containment. */ setBodyFocusTargets(targets: readonly HTMLElement[]): void; /** Dismiss the sheet (plays the close animation). Idempotent. */ close(): void; } /** * Options for {@link showMobileContentSheet}. */ export interface IMobileContentSheetOptions { /** * Optional caption shown beneath the title (single-line, muted). * Mirrors {@link IMobilePickerSheetOptions.caption}. */ readonly caption?: string; /** * Optional set of icon buttons rendered in the sheet's title row * to the left of the Done button. By default, tapping one dismisses * the sheet; provide onHeaderAction to keep it open instead. */ readonly headerActions?: readonly IMobilePickerSheetHeaderAction[]; /** Optional override for the Done button label (defaults to "Done"). */ readonly doneLabel?: string; /** * When true, the Done button is hidden. Use this for sheets where * the body itself provides primary dismissal (e.g. a confirm widget * with explicit Approve / Reject buttons that call `api.close()`). * The user can still dismiss via the backdrop or Escape. */ readonly hideDoneButton?: boolean; /** Use a compact title row with an icon-only close control. */ readonly iconClose?: boolean; /** Run header actions without dismissing; the invoked action is disabled until completion. */ readonly onHeaderAction?: (actionId: string) => void | Promise; readonly onHeaderActionError?: (error: unknown) => void; /** Contain Tab navigation using header controls and registered body focus targets. */ readonly trapFocus?: boolean; } /** * Prefix used on the resolved id when a header action is invoked from a * mobile picker sheet, so callers can disambiguate header taps from * regular row selections. */ export declare const MOBILE_PICKER_SHEET_HEADER_ACTION_PREFIX = "headerAction:"; /** * Return from `onDidSelect` to confirm the tapped row and close the sheet while `stayOpenOnSelect` is enabled. */ export declare const MOBILE_PICKER_SHEET_CONFIRM: unique symbol; /** * Show a phone-friendly bottom sheet for picker-style choices. * * Renders as a fixed-position overlay docked at the bottom of the * viewport with a translucent backdrop, drag handle, header (title + * Done button), and a scrollable list of rows. Tapping a row resolves * with that row's id; tapping the backdrop, the Done button, or * pressing Escape resolves with `undefined`. * * The sheet is intended as the mobile replacement for the desktop * action-widget popups used by the workspace picker, session type * picker, and similar dropdowns. Build it as a reusable widget so other * picker callers can share it. */ export declare function showMobilePickerSheet(workbenchContainer: HTMLElement, title: string, items: readonly IMobilePickerSheetItem[], options?: IMobilePickerSheetOptions): Promise; /** * Show a phone-friendly bottom sheet that hosts arbitrary body content. * * Reuses the same shell as {@link showMobilePickerSheet} — translucent * backdrop, slide-up animation, drag handle, title row with Done button, * optional caption, optional icon header actions, iOS visual-viewport * keyboard avoidance, and `Escape` / backdrop dismissal — but leaves the * scrollable body to the caller. Use this for overlays that don't fit * the picker's row-list shape: tool-confirmation carousels, plan * reviews, anchor previews, code-block expand views, and so on. * * The {@link renderBody} callback is invoked once after the sheet shell * mounts. The caller fills the supplied `bodyElement` with whatever DOM * they like and may return an {@link IDisposable} whose `dispose()` runs * when the sheet closes (alongside the shell's own listeners). * * The body container has `overflow-y: auto`, * `-webkit-overflow-scrolling: touch`, and `touch-action: pan-y` applied * via the `.mobile-content-sheet-body` class so vertical scrolling works * correctly under iOS. * * The returned promise resolves with `void` when the sheet closes for * any reason: Done button, backdrop tap, Escape, a header action tap, * or an explicit `api.close()` from inside `renderBody`. * * @example * ```ts * await showMobileContentSheet( * this._layoutService.mainContainer, * localize('confirm.title', "Confirm Tool Use"), * (body, api) => { * const store = new DisposableStore(); * const summary = DOM.append(body, DOM.$('div.tool-confirm-summary')); * summary.textContent = toolDescription; * * const approve = DOM.append(body, DOM.$('button.tool-confirm-approve')); * approve.textContent = localize('confirm.approve', "Approve"); * store.add(DOM.addDisposableListener(approve, 'click', () => { * writeApproval(); * api.close(); * })); * * return store; * }, * { caption: localize('confirm.caption', "This will modify your workspace.") }, * ); * ``` */ export declare function showMobileContentSheet(workbenchContainer: HTMLElement, title: string, renderBody: (bodyElement: HTMLElement, api: IMobileContentSheetApi) => IDisposable | void, options?: IMobileContentSheetOptions): Promise;