@bixlab/mtone 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1600,6 +1600,14 @@ interface SettingsDialogCategory {
1600
1600
  icon?: React.ReactNode;
1601
1601
  content: React.ReactNode;
1602
1602
  }
1603
+ interface SettingsDialogSearchEntry {
1604
+ /** Value of the category that owns the setting. */
1605
+ category: string;
1606
+ /** DOM id of the target element inside the category content. */
1607
+ id: string;
1608
+ label: string;
1609
+ keywords?: readonly string[];
1610
+ }
1603
1611
  interface SettingsDialogSearchContext {
1604
1612
  selectCategory: (value: string) => void;
1605
1613
  }
@@ -1610,10 +1618,12 @@ interface SettingsDialogProps extends Omit<DialogProps, "children"> {
1610
1618
  defaultValue?: string;
1611
1619
  onValueChange?: (value: string) => void;
1612
1620
  categoriesLabel?: string;
1613
- /** Optional caller-owned search UI. No index or filtering is performed. */
1621
+ /** Opt into built-in search with targets supplied by the application. */
1622
+ searchIndex?: readonly SettingsDialogSearchEntry[];
1623
+ /** Optional caller-owned search UI. Takes precedence over searchIndex. */
1614
1624
  search?: React.ReactNode | ((context: SettingsDialogSearchContext) => React.ReactNode);
1615
1625
  }
1616
- declare function SettingsDialog({ categories, value, defaultValue, onValueChange, categoriesLabel, search, className, onOpenChange, ...dialogProps }: SettingsDialogProps): React.JSX.Element;
1626
+ declare function SettingsDialog({ categories, value, defaultValue, onValueChange, categoriesLabel, search, searchIndex, className, onOpenChange, ...dialogProps }: SettingsDialogProps): React.JSX.Element;
1617
1627
 
1618
1628
  interface SpotlightAction {
1619
1629
  /** Unique within this Spotlight. */
@@ -2824,4 +2834,4 @@ interface HoverMarqueeProps extends React__default.ComponentPropsWithRef<"span">
2824
2834
  /** Reveal clipped text without changing the space allotted by the surrounding layout. */
2825
2835
  declare function HoverMarquee({ children, className, tabIndex, ref, onBlur, onPointerLeave, ...props }: HoverMarqueeProps): React__default.JSX.Element;
2826
2836
 
2827
- export { AdminLayout, type AdminLayoutContentProps, type AdminLayoutHeaderProps, type AdminLayoutProps, type AdminLayoutSiderProps, Affix, type AffixProps, type AiActivityProps, type AiActivityStatus, type AiActivityStep, AiChat, type AiChatProps, AiCheckpoint, type AiCheckpointProps, AiConfirmation, type AiConfirmationProps, AiContext, type AiContextProps, type AiEvidenceAppearance, type AiFileNode, AiFileTree, type AiFileTreeProps, AiInlineCitation, type AiInlineCitationProps, AiMessage, type AiMessageProps, type AiModelOption, AiModelSelector, type AiModelSelectorProps, AiPlan, type AiPlanProps, type AiPromptAttachment, AiPromptInput, type AiPromptInputProps, type AiPromptStatus, type AiPromptSubmission, AiQueue, type AiQueueProps, AiReasoning, type AiReasoningProps, type AiSource, AiSources, type AiSourcesProps, type AiStackFrame, AiStackTrace, type AiStackTraceProps, AiSubagent, type AiSubagentProps, AiSuggestion, type AiSuggestionProps, AiTask, type AiTaskProps, AiTerminal, type AiTerminalProps, type AiTerminalStatus, type AiTestResult, AiTestResults, type AiTestResultsProps, type AiTestStatus, AiTool, type AiToolProps, Alert, AutoComplete, type AutoCompleteGroup, type AutoCompleteOption, type AutoCompleteProps, Avatar, type AvatarBreakpoint, AvatarGroup, type AvatarGroupProps, type AvatarProps, type AvatarSize, Blockquote, type BlockquoteProps, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, type ButtonSize, type ButtonToggleOptions, Calendar, type CalendarCellInfo, type CalendarHeaderInfo, type CalendarMode, type CalendarProps, type CalendarSelectInfo, type CalendarSemanticSlot, Card, type CardGridProps, CardGroup, type CardGroupBreakpoint, type CardGroupItemProps, type CardGroupProps, type CardGroupResponsive, type CardMetaProps, type CardMetaSemantic, type CardProps, type CardSemantic, type CardTabItem, type CardTokens, Cascader, type CascaderKey, type CascaderOption, CascaderPanel, type CascaderPanelProps, type CascaderPath, type CascaderProps, CheckCard, type CheckCardGroupProps, type CheckCardOption, type CheckCardProps, type CheckCardSize, Checkbox, type CheckboxProps, ConfirmDialog, type ConfirmDialogProps, ContextMenu, DataList, type DataListBatchContext, type DataListExpansion, type DataListKey, type DataListLocalPagination, type DataListPagination, type DataListProps, type DataListRemotePagination, type DataListSearch, type DataListSearchProps, type DataListSelection, type DataListSelectionProps, DataTable, type DataTableClassNames, type DataTableColumn, type DataTableColumnTitleProps, type DataTableColumnsType, type DataTableExpandableConfig, type DataTableFilterDropdownProps, type DataTableFilterItem, type DataTableFilterValue, type DataTableFilters, type DataTableLocale, type DataTablePagination, type DataTableProps, type DataTableRef, type DataTableRowSelection, type DataTableSelectionType, type DataTableSortOrder, type DataTableSortResult, type DataTableState, type DataTableStyles, DatePicker, type DatePickerProps, Dialog, type DialogProps, Divider, type DividerProps, DocumentCard, type DocumentItem, DocumentList, Drawer, Empty, Fieldset, type FieldsetProps, FloatingWindow, type FloatingWindowProps, Form, type FormFieldProps, type FormInstance, type FormProps, type FormRule, type FormValidateTrigger, type FormValidationError, type FormValues, GlobalNotice, type GlobalNoticeProps, HoverCard, type HoverCardProps, HoverMarquee, type HoverMarqueeProps, Image, ImageGroup, type ImageGroupProps, type ImageItem, ImagePreview, type ImagePreviewProps, type ImageProps, Input, type InputControlSize, type InputOTPProps, type InputPasswordProps, type InputProps, type InputSearchProps, type InputTextAreaProps, type InputVariant, Link, type LinkProps, List, type ListHandle, ListItem, type ListItemProps, type ListProps, type ListScrollTarget, type ListSortHandleProps, LoadingOverlay, type LoadingOverlayProps, type Locale, type MentionOption, Mentions, type MentionsProps, type MentionsRef, type MentionsSemantic, Menu, type MenuCheckboxItem, type MenuDivider, type MenuEntry, type MenuGroup, type MenuItem, type MenuProps, type MenuRadioGroup, Menubar, type MenubarMenu, type MenubarProps, type MtoneAccent, MtoneProvider, type MtoneProviderProps, MtoneScope, type MtoneScopeProps, type MtoneTheme, NavGroup, type NavGroupProps, NavItem, type NavItemAction, type NavItemButtonProps, type NavItemLinkProps, type NavItemProps, NavSubmenu, type NavSubmenuProps, NumberInput, type NumberInputProps, type OpenProps, type Option, PageLayout, type PageLayoutProps, Pagination, type PaginationProps, Panel, type PanelProps, Paragraph, type ParagraphProps, Popconfirm, type PopconfirmPlacement, type PopconfirmProps, Popover, type PopoverMenuProps, type PopoverProps, Progress, type ProgressColor, type ProgressProps, type ProgressStatus, type ProgressType, PropertyItem, PropertyList, Questionnaire, type QuestionnaireAnswer, type QuestionnaireAnswers, type QuestionnaireChoice, type QuestionnaireItem, type QuestionnaireProps, RadioGroup, type RadioGroupProps, Rate, type RateCharacterInfo, type RateProps, Result, type ResultProps, type ResultSemantic, type ResultStatus, SectionGroup, type SectionGroupProps, type SectionGroupSectionProps, Select, type SelectMultipleProps, type SelectOption, type SelectOptionGroup, type SelectPopupSearchProps, type SelectProps, type SelectSingleProps, type SelectTagsProps, SettingRow, type SettingRowControlProps, type SettingRowGroupProps, type SettingRowProps, SettingsDialog, type SettingsDialogCategory, type SettingsDialogProps, type SettingsDialogSearchContext, type ShortcutOptions, ShortcutScope, type ShortcutScopeProps, ShortcutsProvider, type ShortcutsProviderProps, Sidebar, type SidebarProps, type SidebarResizeOptions, type SidebarTabsOptions, Skeleton, Slider, type SliderProps, Spinner, Splitter, type SplitterPanelProps, type SplitterProps, type SplitterSize, Spotlight, type SpotlightAction, type SpotlightProps, Status, Switch, type TabItem, Table, TableOfContents, type TableOfContentsHandle, type TableOfContentsItem, type TableOfContentsProps, type TableProps, Tabs, type TabsIndicatorColor, type TabsProps, type TabsSize, Tag, type TagProps, TagSelect, type TagSelectOption, type TagSelectProps, Text, type TextProps, Timeline, type TimelineItem, type TimelinePlacement, type TimelineProps, type TimelineSemantic, Title, type TitleProps, type ToastOptions, type ToastPosition, type ToastPromiseOptions, ToastProvider, type ToastProviderProps, type ToastType, type ToastUpdateOptions, type Tokens, type Tone, Toolbar, type ToolbarProps, Tooltip, type TooltipPart, type TooltipProps, TooltipProvider, type TooltipProviderProps, type TooltipTrigger, Transfer, type TransferDirection, type TransferItem, type TransferListContext, type TransferProps, Tree, type TreeAction, type TreeCheckedKeys, type TreeDropInfo, type TreeItem, type TreeKey, type TreeNode, type TreeNodeInfo, type TreeProps, type TreeRef, TreeSelect, type TreeSelectCommonProps, type TreeSelectProps, Typography, type TypographyCodeProps, type TypographyCopyable, type TypographyEditable, type TypographyEllipsis, type TypographyTone, Upload, type UploadAdapter, type UploadContext, type UploadFile, type UploadProps, cn, formatShortcut, getMentions, useMtone, useShortcut, useToast };
2837
+ export { AdminLayout, type AdminLayoutContentProps, type AdminLayoutHeaderProps, type AdminLayoutProps, type AdminLayoutSiderProps, Affix, type AffixProps, type AiActivityProps, type AiActivityStatus, type AiActivityStep, AiChat, type AiChatProps, AiCheckpoint, type AiCheckpointProps, AiConfirmation, type AiConfirmationProps, AiContext, type AiContextProps, type AiEvidenceAppearance, type AiFileNode, AiFileTree, type AiFileTreeProps, AiInlineCitation, type AiInlineCitationProps, AiMessage, type AiMessageProps, type AiModelOption, AiModelSelector, type AiModelSelectorProps, AiPlan, type AiPlanProps, type AiPromptAttachment, AiPromptInput, type AiPromptInputProps, type AiPromptStatus, type AiPromptSubmission, AiQueue, type AiQueueProps, AiReasoning, type AiReasoningProps, type AiSource, AiSources, type AiSourcesProps, type AiStackFrame, AiStackTrace, type AiStackTraceProps, AiSubagent, type AiSubagentProps, AiSuggestion, type AiSuggestionProps, AiTask, type AiTaskProps, AiTerminal, type AiTerminalProps, type AiTerminalStatus, type AiTestResult, AiTestResults, type AiTestResultsProps, type AiTestStatus, AiTool, type AiToolProps, Alert, AutoComplete, type AutoCompleteGroup, type AutoCompleteOption, type AutoCompleteProps, Avatar, type AvatarBreakpoint, AvatarGroup, type AvatarGroupProps, type AvatarProps, type AvatarSize, Blockquote, type BlockquoteProps, Breadcrumb, type BreadcrumbItem, type BreadcrumbProps, Button, ButtonGroup, type ButtonGroupProps, type ButtonProps, type ButtonSize, type ButtonToggleOptions, Calendar, type CalendarCellInfo, type CalendarHeaderInfo, type CalendarMode, type CalendarProps, type CalendarSelectInfo, type CalendarSemanticSlot, Card, type CardGridProps, CardGroup, type CardGroupBreakpoint, type CardGroupItemProps, type CardGroupProps, type CardGroupResponsive, type CardMetaProps, type CardMetaSemantic, type CardProps, type CardSemantic, type CardTabItem, type CardTokens, Cascader, type CascaderKey, type CascaderOption, CascaderPanel, type CascaderPanelProps, type CascaderPath, type CascaderProps, CheckCard, type CheckCardGroupProps, type CheckCardOption, type CheckCardProps, type CheckCardSize, Checkbox, type CheckboxProps, ConfirmDialog, type ConfirmDialogProps, ContextMenu, DataList, type DataListBatchContext, type DataListExpansion, type DataListKey, type DataListLocalPagination, type DataListPagination, type DataListProps, type DataListRemotePagination, type DataListSearch, type DataListSearchProps, type DataListSelection, type DataListSelectionProps, DataTable, type DataTableClassNames, type DataTableColumn, type DataTableColumnTitleProps, type DataTableColumnsType, type DataTableExpandableConfig, type DataTableFilterDropdownProps, type DataTableFilterItem, type DataTableFilterValue, type DataTableFilters, type DataTableLocale, type DataTablePagination, type DataTableProps, type DataTableRef, type DataTableRowSelection, type DataTableSelectionType, type DataTableSortOrder, type DataTableSortResult, type DataTableState, type DataTableStyles, DatePicker, type DatePickerProps, Dialog, type DialogProps, Divider, type DividerProps, DocumentCard, type DocumentItem, DocumentList, Drawer, Empty, Fieldset, type FieldsetProps, FloatingWindow, type FloatingWindowProps, Form, type FormFieldProps, type FormInstance, type FormProps, type FormRule, type FormValidateTrigger, type FormValidationError, type FormValues, GlobalNotice, type GlobalNoticeProps, HoverCard, type HoverCardProps, HoverMarquee, type HoverMarqueeProps, Image, ImageGroup, type ImageGroupProps, type ImageItem, ImagePreview, type ImagePreviewProps, type ImageProps, Input, type InputControlSize, type InputOTPProps, type InputPasswordProps, type InputProps, type InputSearchProps, type InputTextAreaProps, type InputVariant, Link, type LinkProps, List, type ListHandle, ListItem, type ListItemProps, type ListProps, type ListScrollTarget, type ListSortHandleProps, LoadingOverlay, type LoadingOverlayProps, type Locale, type MentionOption, Mentions, type MentionsProps, type MentionsRef, type MentionsSemantic, Menu, type MenuCheckboxItem, type MenuDivider, type MenuEntry, type MenuGroup, type MenuItem, type MenuProps, type MenuRadioGroup, Menubar, type MenubarMenu, type MenubarProps, type MtoneAccent, MtoneProvider, type MtoneProviderProps, MtoneScope, type MtoneScopeProps, type MtoneTheme, NavGroup, type NavGroupProps, NavItem, type NavItemAction, type NavItemButtonProps, type NavItemLinkProps, type NavItemProps, NavSubmenu, type NavSubmenuProps, NumberInput, type NumberInputProps, type OpenProps, type Option, PageLayout, type PageLayoutProps, Pagination, type PaginationProps, Panel, type PanelProps, Paragraph, type ParagraphProps, Popconfirm, type PopconfirmPlacement, type PopconfirmProps, Popover, type PopoverMenuProps, type PopoverProps, Progress, type ProgressColor, type ProgressProps, type ProgressStatus, type ProgressType, PropertyItem, PropertyList, Questionnaire, type QuestionnaireAnswer, type QuestionnaireAnswers, type QuestionnaireChoice, type QuestionnaireItem, type QuestionnaireProps, RadioGroup, type RadioGroupProps, Rate, type RateCharacterInfo, type RateProps, Result, type ResultProps, type ResultSemantic, type ResultStatus, SectionGroup, type SectionGroupProps, type SectionGroupSectionProps, Select, type SelectMultipleProps, type SelectOption, type SelectOptionGroup, type SelectPopupSearchProps, type SelectProps, type SelectSingleProps, type SelectTagsProps, SettingRow, type SettingRowControlProps, type SettingRowGroupProps, type SettingRowProps, SettingsDialog, type SettingsDialogCategory, type SettingsDialogProps, type SettingsDialogSearchContext, type SettingsDialogSearchEntry, type ShortcutOptions, ShortcutScope, type ShortcutScopeProps, ShortcutsProvider, type ShortcutsProviderProps, Sidebar, type SidebarProps, type SidebarResizeOptions, type SidebarTabsOptions, Skeleton, Slider, type SliderProps, Spinner, Splitter, type SplitterPanelProps, type SplitterProps, type SplitterSize, Spotlight, type SpotlightAction, type SpotlightProps, Status, Switch, type TabItem, Table, TableOfContents, type TableOfContentsHandle, type TableOfContentsItem, type TableOfContentsProps, type TableProps, Tabs, type TabsIndicatorColor, type TabsProps, type TabsSize, Tag, type TagProps, TagSelect, type TagSelectOption, type TagSelectProps, Text, type TextProps, Timeline, type TimelineItem, type TimelinePlacement, type TimelineProps, type TimelineSemantic, Title, type TitleProps, type ToastOptions, type ToastPosition, type ToastPromiseOptions, ToastProvider, type ToastProviderProps, type ToastType, type ToastUpdateOptions, type Tokens, type Tone, Toolbar, type ToolbarProps, Tooltip, type TooltipPart, type TooltipProps, TooltipProvider, type TooltipProviderProps, type TooltipTrigger, Transfer, type TransferDirection, type TransferItem, type TransferListContext, type TransferProps, Tree, type TreeAction, type TreeCheckedKeys, type TreeDropInfo, type TreeItem, type TreeKey, type TreeNode, type TreeNodeInfo, type TreeProps, type TreeRef, TreeSelect, type TreeSelectCommonProps, type TreeSelectProps, Typography, type TypographyCodeProps, type TypographyCopyable, type TypographyEditable, type TypographyEllipsis, type TypographyTone, Upload, type UploadAdapter, type UploadContext, type UploadFile, type UploadProps, cn, formatShortcut, getMentions, useMtone, useShortcut, useToast };
package/dist/index.js CHANGED
@@ -4516,11 +4516,11 @@ function Progress({
4516
4516
  0,
4517
4517
  100
4518
4518
  );
4519
- const fill = color ?? (status === "exception" ? "#b6403b" : "#7d9c84");
4519
+ const fill = color ?? (status === "exception" ? "var(--mt-progress-failure-fill, #b6403b)" : "var(--mt-progress-fill, #7d9c84)");
4520
4520
  const gradient = typeof fill !== "string";
4521
4521
  const paint = gradient ? `url(#mt-progress-${id})` : fill;
4522
4522
  const background = gradient ? `linear-gradient(to right, ${fill.from}, ${fill.to})` : fill;
4523
- const successColor = success?.color ?? "#548164";
4523
+ const successColor = success?.color ?? "var(--mt-progress-success-fill, #548164)";
4524
4524
  const info = format ? format(n, completed) : status === "success" ? /* @__PURE__ */ jsx13(Check3, { size: 16, "aria-hidden": "true" }) : status === "exception" ? /* @__PURE__ */ jsx13(X5, { size: 16, "aria-hidden": "true" }) : `${n}%`;
4525
4525
  const infoNode = showInfo && /* @__PURE__ */ jsx13("span", { className: "mt-progress-info", "aria-hidden": "true", children: info });
4526
4526
  const radius = (100 - thickness) / 2;
@@ -8082,6 +8082,17 @@ function subscribeToCompact(onChange) {
8082
8082
  return () => query?.removeEventListener?.("change", onChange);
8083
8083
  }
8084
8084
  var getServerSnapshot = () => false;
8085
+ function scrollInside(container, item, inset2 = 0) {
8086
+ const outer = container.getBoundingClientRect();
8087
+ const inner = item.getBoundingClientRect();
8088
+ const top = outer.top + container.clientTop + inset2;
8089
+ const bottom = outer.top + container.clientTop + container.clientHeight - inset2;
8090
+ if (inner.top < top || inner.height > bottom - top && inner.bottom > bottom) {
8091
+ container.scrollTop += inner.top - top;
8092
+ } else if (inner.bottom > bottom) {
8093
+ container.scrollTop += inner.bottom - bottom;
8094
+ }
8095
+ }
8085
8096
  function SettingsDialog({
8086
8097
  categories,
8087
8098
  value,
@@ -8089,15 +8100,32 @@ function SettingsDialog({
8089
8100
  onValueChange,
8090
8101
  categoriesLabel,
8091
8102
  search,
8103
+ searchIndex,
8092
8104
  className,
8093
8105
  onOpenChange,
8094
8106
  ...dialogProps
8095
8107
  }) {
8096
8108
  const { locale } = useMtone();
8097
- const compact = React31.useSyncExternalStore(subscribeToCompact, getCompactSnapshot, getServerSnapshot);
8109
+ const compact = React31.useSyncExternalStore(
8110
+ subscribeToCompact,
8111
+ getCompactSnapshot,
8112
+ getServerSnapshot
8113
+ );
8098
8114
  const [localValue, setLocalValue] = React31.useState(defaultValue);
8099
8115
  const [detail, setDetail] = React31.useState(false);
8100
- const [visited, setVisited] = React31.useState(() => /* @__PURE__ */ new Set());
8116
+ const [visited, setVisited] = React31.useState(
8117
+ () => /* @__PURE__ */ new Set()
8118
+ );
8119
+ const [query, setQuery] = React31.useState("");
8120
+ const [active, setActive] = React31.useState(-1);
8121
+ const [jump, setJump] = React31.useState(null);
8122
+ const composing = React31.useRef(false);
8123
+ const nav = React31.useRef(null);
8124
+ const pane = React31.useRef(null);
8125
+ const activeContent = React31.useRef(null);
8126
+ const activeOption = React31.useRef(null);
8127
+ const highlightCleanup = React31.useRef(null);
8128
+ const listId = React31.useId();
8101
8129
  const navId = React31.useId();
8102
8130
  const detailId = React31.useId();
8103
8131
  const heading = React31.useRef(null);
@@ -8107,9 +8135,78 @@ function SettingsDialog({
8107
8135
  const current = categories.find((category) => category.value === (value ?? localValue)) ?? categories[0];
8108
8136
  const currentValue = current?.value;
8109
8137
  const showDetail = !compact || detail && current !== void 0;
8138
+ const builtIn = searchIndex !== void 0 && search == null;
8139
+ const queryWords = query.trim().toLocaleLowerCase().split(/\s+/).filter(Boolean);
8140
+ const searching = builtIn && queryWords.length > 0;
8141
+ const categoryLabels = new Map(
8142
+ categories.map(({ value: category, label }) => [
8143
+ category,
8144
+ typeof label === "string" || typeof label === "number" ? String(label) : category
8145
+ ])
8146
+ );
8147
+ const results = searching ? searchIndex.flatMap((entry) => {
8148
+ const categoryLabel = categoryLabels.get(entry.category);
8149
+ if (categoryLabel === void 0) return [];
8150
+ const text = [entry.label, categoryLabel, ...entry.keywords ?? []].join(" ").toLocaleLowerCase();
8151
+ return queryWords.every((word) => text.includes(word)) ? [{ entry, categoryLabel }] : [];
8152
+ }) : [];
8153
+ const activeIndex = active < results.length ? active : -1;
8154
+ function clearSearch() {
8155
+ setQuery("");
8156
+ setActive(-1);
8157
+ setJump(null);
8158
+ composing.current = false;
8159
+ }
8160
+ React31.useLayoutEffect(() => {
8161
+ if (nav.current && activeOption.current)
8162
+ scrollInside(nav.current, activeOption.current);
8163
+ }, [activeIndex, query]);
8164
+ React31.useEffect(() => () => highlightCleanup.current?.(), []);
8165
+ React31.useLayoutEffect(() => {
8166
+ if (!jump) return;
8167
+ if (currentValue !== jump.entry.category) {
8168
+ if (currentValue !== jump.from) setJump(null);
8169
+ return;
8170
+ }
8171
+ if (!showDetail) {
8172
+ setDetail(true);
8173
+ return;
8174
+ }
8175
+ if (!pane.current) return;
8176
+ setJump(null);
8177
+ highlightCleanup.current?.();
8178
+ const target = Array.from(
8179
+ activeContent.current?.querySelectorAll("[id]") ?? []
8180
+ ).find(
8181
+ (element) => element.id === jump.entry.id && !element.closest("[hidden], [inert], [aria-hidden='true']")
8182
+ );
8183
+ pendingFocus.current = null;
8184
+ if (!target) {
8185
+ heading.current?.focus({ preventScroll: true });
8186
+ return;
8187
+ }
8188
+ scrollInside(pane.current, target, 8);
8189
+ const addedTabIndex = target.tabIndex < 0 && !target.hasAttribute("tabindex");
8190
+ if (addedTabIndex) target.setAttribute("tabindex", "-1");
8191
+ target.focus({ preventScroll: true });
8192
+ if (target.ownerDocument.activeElement !== target)
8193
+ heading.current?.focus({ preventScroll: true });
8194
+ target.setAttribute("data-mt-settings-highlight", "");
8195
+ const cleanup = () => {
8196
+ clearTimeout(timeout);
8197
+ target.removeAttribute("data-mt-settings-highlight");
8198
+ if (addedTabIndex && target.getAttribute("tabindex") === "-1")
8199
+ target.removeAttribute("tabindex");
8200
+ highlightCleanup.current = null;
8201
+ };
8202
+ const timeout = setTimeout(cleanup, 1600);
8203
+ highlightCleanup.current = cleanup;
8204
+ }, [currentValue, jump, showDetail]);
8110
8205
  React31.useEffect(() => {
8111
8206
  if (currentValue === void 0) return;
8112
- setVisited((previous) => previous.has(currentValue) ? previous : new Set(previous).add(currentValue));
8207
+ setVisited(
8208
+ (previous) => previous.has(currentValue) ? previous : new Set(previous).add(currentValue)
8209
+ );
8113
8210
  }, [currentValue]);
8114
8211
  function resetCompactView() {
8115
8212
  pendingSelection.current = null;
@@ -8118,6 +8215,10 @@ function SettingsDialog({
8118
8215
  }
8119
8216
  React31.useEffect(() => {
8120
8217
  if (!compact || dialogProps.open === false) resetCompactView();
8218
+ if (dialogProps.open === false) {
8219
+ clearSearch();
8220
+ highlightCleanup.current?.();
8221
+ }
8121
8222
  }, [compact, dialogProps.open]);
8122
8223
  React31.useLayoutEffect(() => {
8123
8224
  if (compact && currentValue !== void 0 && pendingSelection.current === currentValue) {
@@ -8128,7 +8229,7 @@ function SettingsDialog({
8128
8229
  }, [compact, currentValue]);
8129
8230
  React31.useLayoutEffect(() => {
8130
8231
  if (!compact || currentValue === void 0) return;
8131
- if (showDetail && pendingFocus.current === "heading" && heading.current) {
8232
+ if (showDetail && !jump && pendingFocus.current === "heading" && heading.current) {
8132
8233
  pendingFocus.current = null;
8133
8234
  heading.current.focus();
8134
8235
  } else if (!showDetail && pendingFocus.current === "category") {
@@ -8138,12 +8239,14 @@ function SettingsDialog({
8138
8239
  button.focus();
8139
8240
  }
8140
8241
  }
8141
- }, [compact, currentValue, showDetail]);
8142
- function selectCategory(next) {
8242
+ }, [compact, currentValue, showDetail, jump]);
8243
+ function selectCategory(next, viaSearch = false) {
8143
8244
  if (!categories.some((category) => category.value === next)) return;
8144
8245
  pendingSelection.current = null;
8145
8246
  if (compact) {
8146
- if (next === currentValue || value === void 0) {
8247
+ if (viaSearch) {
8248
+ pendingFocus.current = null;
8249
+ } else if (next === currentValue || value === void 0) {
8147
8250
  if (!detail || next !== currentValue) pendingFocus.current = "heading";
8148
8251
  if (detail && next === currentValue) heading.current?.focus();
8149
8252
  setDetail(true);
@@ -8156,6 +8259,14 @@ function SettingsDialog({
8156
8259
  onValueChange?.(next);
8157
8260
  }
8158
8261
  }
8262
+ function activateResult(entry) {
8263
+ setQuery("");
8264
+ setActive(-1);
8265
+ setJump({ entry, from: currentValue });
8266
+ selectCategory(entry.category, true);
8267
+ }
8268
+ const searchName = locale === "zh" ? "\u641C\u7D22\u8BBE\u7F6E" : "Search settings";
8269
+ const resultsName = locale === "zh" ? "\u641C\u7D22\u7ED3\u679C" : "Search results";
8159
8270
  const searchContent = typeof search === "function" ? search({ selectCategory }) : search;
8160
8271
  const categoryName = categoriesLabel ?? (locale === "zh" ? "\u8BBE\u7F6E\u5206\u7C7B" : "Settings categories");
8161
8272
  return /* @__PURE__ */ jsx31(
@@ -8164,51 +8275,184 @@ function SettingsDialog({
8164
8275
  ...dialogProps,
8165
8276
  className: cn("mt-settings-dialog", className),
8166
8277
  onOpenChange: (open) => {
8167
- if (!open && dialogProps.open === void 0) resetCompactView();
8278
+ if (!open && dialogProps.open === void 0) {
8279
+ resetCompactView();
8280
+ clearSearch();
8281
+ highlightCleanup.current?.();
8282
+ }
8168
8283
  onOpenChange?.(open);
8169
8284
  },
8170
- children: /* @__PURE__ */ jsxs25("div", { className: "mt-settings-dialog-layout", "data-compact": compact || void 0, children: [
8171
- searchContent != null && searchContent !== false && /* @__PURE__ */ jsx31("div", { className: "mt-settings-dialog-search", children: searchContent }),
8172
- /* @__PURE__ */ jsxs25("div", { className: "mt-settings-dialog-columns", children: [
8173
- /* @__PURE__ */ jsx31("nav", { id: navId, "aria-label": categoryName, className: "mt-settings-dialog-nav", hidden: compact && showDetail, children: /* @__PURE__ */ jsx31(SidebarContext.Provider, { value: false, children: /* @__PURE__ */ jsx31(NavSubmenuSelectionContext.Provider, { value: null, children: /* @__PURE__ */ jsx31(NavGroup, { children: categories.map(({ value: category, label, icon }) => /* @__PURE__ */ jsx31(
8174
- NavItem,
8175
- {
8176
- ref: (element) => {
8177
- if (element) buttons.current.set(category, element);
8178
- else buttons.current.delete(category);
8179
- },
8180
- icon,
8181
- active: currentValue === category,
8182
- "aria-controls": detailId,
8183
- onClick: () => selectCategory(category),
8184
- children: label
8185
- },
8186
- category
8187
- )) }) }) }) }),
8188
- /* @__PURE__ */ jsxs25("section", { id: detailId, className: "mt-settings-dialog-detail", hidden: !showDetail, children: [
8189
- current && /* @__PURE__ */ jsxs25(Fragment21, { children: [
8190
- compact && /* @__PURE__ */ jsx31(
8191
- "button",
8285
+ children: /* @__PURE__ */ jsxs25(
8286
+ "div",
8287
+ {
8288
+ className: "mt-settings-dialog-layout",
8289
+ "data-compact": compact || void 0,
8290
+ children: [
8291
+ searchContent != null && searchContent !== false && /* @__PURE__ */ jsx31("div", { className: "mt-settings-dialog-search", children: searchContent }),
8292
+ /* @__PURE__ */ jsxs25("div", { className: "mt-settings-dialog-columns", children: [
8293
+ /* @__PURE__ */ jsxs25(
8294
+ "nav",
8192
8295
  {
8193
- type: "button",
8194
- className: "mt-settings-dialog-back",
8195
- "aria-controls": navId,
8196
- onClick: () => {
8197
- pendingSelection.current = null;
8198
- pendingFocus.current = "category";
8199
- setDetail(false);
8200
- },
8201
- children: locale === "zh" ? "\u8FD4\u56DE\u5206\u7C7B" : "Back to categories"
8296
+ ref: nav,
8297
+ id: navId,
8298
+ "aria-label": categoryName,
8299
+ className: "mt-settings-dialog-nav",
8300
+ hidden: compact && showDetail,
8301
+ children: [
8302
+ builtIn && /* @__PURE__ */ jsx31(
8303
+ Input.Search,
8304
+ {
8305
+ wrapperClassName: "mt-settings-dialog-search-input",
8306
+ "aria-label": searchName,
8307
+ placeholder: searchName,
8308
+ role: "combobox",
8309
+ "aria-autocomplete": "list",
8310
+ "aria-expanded": searching,
8311
+ "aria-controls": searching ? listId : void 0,
8312
+ "aria-activedescendant": activeIndex >= 0 && searching ? `${listId}-${activeIndex}` : void 0,
8313
+ value: query,
8314
+ allowClear: true,
8315
+ onClear: clearSearch,
8316
+ onChange: (event) => {
8317
+ setQuery(event.currentTarget.value);
8318
+ setActive(-1);
8319
+ setJump(null);
8320
+ },
8321
+ onCompositionStart: () => {
8322
+ composing.current = true;
8323
+ },
8324
+ onCompositionEnd: () => {
8325
+ composing.current = false;
8326
+ },
8327
+ onKeyDown: (event) => {
8328
+ if (composing.current || event.nativeEvent.isComposing || event.nativeEvent.keyCode === 229)
8329
+ return;
8330
+ if (event.key === "Escape" && query) {
8331
+ event.preventDefault();
8332
+ event.stopPropagation();
8333
+ clearSearch();
8334
+ } else if (searching && results.length > 0) {
8335
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
8336
+ event.preventDefault();
8337
+ const direction = event.key === "ArrowDown" ? 1 : -1;
8338
+ setActive(
8339
+ activeIndex < 0 ? direction > 0 ? 0 : results.length - 1 : (activeIndex + direction + results.length) % results.length
8340
+ );
8341
+ } else if (event.key === "Enter") {
8342
+ event.preventDefault();
8343
+ activateResult(
8344
+ results[activeIndex < 0 ? 0 : activeIndex].entry
8345
+ );
8346
+ }
8347
+ }
8348
+ }
8349
+ }
8350
+ ),
8351
+ searching ? /* @__PURE__ */ jsx31(Fragment21, { children: /* @__PURE__ */ jsx31(
8352
+ "div",
8353
+ {
8354
+ className: "mt-settings-dialog-results",
8355
+ id: listId,
8356
+ role: "listbox",
8357
+ "aria-label": resultsName,
8358
+ children: results.map(({ entry, categoryLabel }, index) => /* @__PURE__ */ jsxs25(
8359
+ "div",
8360
+ {
8361
+ ref: activeIndex === index ? activeOption : void 0,
8362
+ id: `${listId}-${index}`,
8363
+ role: "option",
8364
+ "aria-selected": activeIndex === index,
8365
+ onMouseDown: (event) => event.preventDefault(),
8366
+ onClick: () => activateResult(entry),
8367
+ children: [
8368
+ /* @__PURE__ */ jsx31("span", { children: entry.label }),
8369
+ /* @__PURE__ */ jsx31("small", { children: categoryLabel })
8370
+ ]
8371
+ },
8372
+ JSON.stringify([entry.category, entry.id])
8373
+ ))
8374
+ }
8375
+ ) }) : /* @__PURE__ */ jsx31(SidebarContext.Provider, { value: false, children: /* @__PURE__ */ jsx31(NavSubmenuSelectionContext.Provider, { value: null, children: /* @__PURE__ */ jsx31(NavGroup, { children: categories.map(({ value: category, label, icon }) => /* @__PURE__ */ jsx31(
8376
+ NavItem,
8377
+ {
8378
+ ref: (element) => {
8379
+ if (element) buttons.current.set(category, element);
8380
+ else buttons.current.delete(category);
8381
+ },
8382
+ icon,
8383
+ active: currentValue === category,
8384
+ "aria-controls": detailId,
8385
+ onClick: () => {
8386
+ setJump(null);
8387
+ selectCategory(category);
8388
+ },
8389
+ children: label
8390
+ },
8391
+ category
8392
+ )) }) }) }),
8393
+ builtIn && /* @__PURE__ */ jsx31(
8394
+ "div",
8395
+ {
8396
+ role: "status",
8397
+ className: searching && results.length === 0 ? "mt-settings-dialog-no-results" : "mt-settings-dialog-result-status",
8398
+ children: searching && (results.length > 0 ? locale === "zh" ? `${results.length} \u6761\u641C\u7D22\u7ED3\u679C` : `${results.length} search results` : locale === "zh" ? "\u65E0\u5339\u914D\u7ED3\u679C" : "No results")
8399
+ }
8400
+ )
8401
+ ]
8202
8402
  }
8203
8403
  ),
8204
- /* @__PURE__ */ jsx31("h3", { ref: heading, className: "mt-settings-dialog-category-title", tabIndex: -1, children: current.label })
8205
- ] }),
8206
- categories.map(
8207
- ({ value: category, content: content2 }) => (visited.has(category) || category === currentValue) && /* @__PURE__ */ jsx31("div", { hidden: category !== currentValue, children: content2 }, category)
8208
- )
8209
- ] })
8210
- ] })
8211
- ] })
8404
+ /* @__PURE__ */ jsxs25(
8405
+ "section",
8406
+ {
8407
+ ref: pane,
8408
+ id: detailId,
8409
+ className: "mt-settings-dialog-detail",
8410
+ hidden: !showDetail,
8411
+ children: [
8412
+ current && /* @__PURE__ */ jsxs25(Fragment21, { children: [
8413
+ compact && /* @__PURE__ */ jsx31(
8414
+ "button",
8415
+ {
8416
+ type: "button",
8417
+ className: "mt-settings-dialog-back",
8418
+ "aria-controls": navId,
8419
+ onClick: () => {
8420
+ setJump(null);
8421
+ pendingSelection.current = null;
8422
+ pendingFocus.current = "category";
8423
+ setDetail(false);
8424
+ },
8425
+ children: locale === "zh" ? "\u8FD4\u56DE\u5206\u7C7B" : "Back to categories"
8426
+ }
8427
+ ),
8428
+ /* @__PURE__ */ jsx31(
8429
+ "h3",
8430
+ {
8431
+ ref: heading,
8432
+ className: "mt-settings-dialog-category-title",
8433
+ tabIndex: -1,
8434
+ children: current.label
8435
+ }
8436
+ )
8437
+ ] }),
8438
+ categories.map(
8439
+ ({ value: category, content: content2 }) => (visited.has(category) || category === currentValue) && /* @__PURE__ */ jsx31(
8440
+ "div",
8441
+ {
8442
+ ref: category === currentValue ? activeContent : void 0,
8443
+ hidden: category !== currentValue,
8444
+ children: content2
8445
+ },
8446
+ category
8447
+ )
8448
+ )
8449
+ ]
8450
+ }
8451
+ )
8452
+ ] })
8453
+ ]
8454
+ }
8455
+ )
8212
8456
  }
8213
8457
  );
8214
8458
  }