Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions packages/components/src/Autocomplete/Autocomplete.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,3 +668,12 @@ export function defineMenu<
>(menu: MenuItem<T, S, A>[]): MenuItem<T, S, A>[] {
return menu;
}

export type RenderItem<
T extends OptionLike,
S extends object = Record<string, unknown>,
A extends object = Record<string, unknown>,
> =
| { kind: "option"; value: T }
| { kind: "action"; action: MenuAction<A>; origin?: ActionOrigin }
| { kind: "section"; section: MenuSection<T, S, A> };
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import type {
MenuAction,
MenuSection,
OptionLike,
RenderItem,
} from "../Autocomplete.types";
import styles from "../AutocompleteRebuilt.module.css";
import type { RenderItem } from "../useAutocomplete";
import { preventDefaultPointerDown } from "../utils/interactionUtils";
import { Heading } from "../../Heading";
import { Text } from "../../Text";
Expand Down
12 changes: 1 addition & 11 deletions packages/components/src/Autocomplete/useAutocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { useCallbackRef, useDebounce } from "@jobber/hooks";
import type {
ActionConfig,
ActionOrigin,
AutocompleteRebuiltProps,
AutocompleteValue,
MenuAction,
MenuSection,
OptionLike,
RenderItem,
} from "./Autocomplete.types";
import {
buildRenderableList,
Expand All @@ -19,15 +18,6 @@ import {
import { useAutocompleteListNav } from "./hooks/useAutocompleteListNav";
import { createInteractionPointerDownHandler } from "./utils/interactionUtils";

export type RenderItem<
T extends OptionLike,
S extends object = Record<string, unknown>,
A extends object = Record<string, unknown>,
> =
| { kind: "option"; value: T }
| { kind: "action"; action: MenuAction<A>; origin?: ActionOrigin }
| { kind: "section"; section: MenuSection<T, S, A> };

// Keeping this hook cohesive improves readability by centralizing related
// interactions and state transitions.
// eslint-disable-next-line max-statements
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/Autocomplete/utils/menuModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import type {
MenuOptions,
MenuSection,
OptionLike,
RenderItem,
} from "../Autocomplete.types";
import type { RenderItem } from "../useAutocomplete";

export function flattenMenu<
Value extends OptionLike,
Expand Down
Loading