@cloudwick/astral-ui 8.0.0 → 8.2.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.
Files changed (52) hide show
  1. package/README.md +1 -1
  2. package/dist/components/button/reloadButton.d.ts +20 -0
  3. package/dist/components/emptyState/emptyStateVariants.d.ts +3 -3
  4. package/dist/components/multiSelectTransfer/index.d.ts +1 -1
  5. package/dist/components/multiSelectTransfer/multiSelectTransfer.d.ts +5 -4
  6. package/dist/components/multiSelectTransfer/multiSelectTransferDropdown.d.ts +25 -5
  7. package/dist/components/multiSelectTransfer/multiSelectTransferDropdownHeader.d.ts +31 -0
  8. package/dist/components/multiSelectTransfer/multiSelectTransferModal.d.ts +18 -4
  9. package/dist/components/multiSelectTransfer/multiSelectTransferOptionRow.d.ts +27 -0
  10. package/dist/components/multiSelectTransfer/multiSelectTransferTrigger.d.ts +26 -0
  11. package/dist/components/multiSelectTransfer/multiSelectTransferVariants.d.ts +36 -0
  12. package/dist/components/multiSelectTransfer/types.d.ts +93 -2
  13. package/dist/components/multiSelectTransfer/useMultiSelectTransferDraft.d.ts +24 -0
  14. package/dist/components/multiSelectTransfer/useMultiSelectTransferOptionSource.d.ts +56 -0
  15. package/dist/components/select/index.d.ts +1 -1
  16. package/dist/components/select/select.d.ts +5 -6
  17. package/dist/components/select/selectComponents.d.ts +16 -19
  18. package/dist/components/select/selectKeyboard.d.ts +22 -0
  19. package/dist/components/select/selectMenu.d.ts +12 -0
  20. package/dist/components/select/selectVariants.d.ts +21 -0
  21. package/dist/components/select/types.d.ts +142 -16
  22. package/dist/components/select/useSelectOptionSource.d.ts +39 -0
  23. package/dist/components/select/useSelectOutsideClose.d.ts +16 -0
  24. package/dist/components/select/utils.d.ts +5 -1
  25. package/dist/components/transferList/index.d.ts +1 -1
  26. package/dist/components/transferList/transferList.d.ts +2 -5
  27. package/dist/components/transferList/transferListPanel.d.ts +14 -1
  28. package/dist/components/transferList/transferListPanelHeader.d.ts +29 -0
  29. package/dist/components/transferList/transferListVariants.d.ts +9 -0
  30. package/dist/components/transferList/types.d.ts +86 -10
  31. package/dist/components/transferList/useTransferList.d.ts +1 -1
  32. package/dist/components/transferList/useTransferListPanelKeys.d.ts +28 -0
  33. package/dist/components/transferList/useTransferListSource.d.ts +49 -0
  34. package/dist/css/index.min.css +1 -1
  35. package/dist/hooks/index.d.ts +7 -1
  36. package/dist/hooks/useAsyncOptions.d.ts +85 -0
  37. package/dist/hooks/useAsyncOptionsReducer.d.ts +75 -0
  38. package/dist/hooks/useAvailableProjection.d.ts +20 -0
  39. package/dist/hooks/useFilterQuery.d.ts +28 -0
  40. package/dist/hooks/useIgnoredPropWarning.d.ts +5 -0
  41. package/dist/hooks/useInfiniteScroll.d.ts +11 -2
  42. package/dist/hooks/useOnValueChange.d.ts +6 -0
  43. package/dist/hooks/usePrefetchBaseline.d.ts +22 -0
  44. package/dist/index.cjs.js +5 -5
  45. package/dist/index.d.ts +1 -0
  46. package/dist/index.esm.js +5 -5
  47. package/dist/utils/devWarn.d.ts +5 -0
  48. package/dist/utils/index.d.ts +4 -0
  49. package/dist/utils/mergeUnique.d.ts +6 -0
  50. package/dist/utils/resolveLoadErrors.d.ts +20 -0
  51. package/dist/utils/resolveReloadControls.d.ts +23 -0
  52. package/package.json +2 -2
@@ -1,24 +1,8 @@
1
1
  import * as React from "react";
2
2
  import { type ReactElement } from "react";
3
- import { type GroupBase, type OptionProps, type MultiValueProps, type MultiValueRemoveProps, type DropdownIndicatorProps, type ValueContainerProps, type InputProps, type MenuProps } from "react-select";
4
- import { type IOption, type ISelectOptionContext, type ISelectMenuContext, type ISelectComponentsConfig } from "./types";
3
+ import { type GroupBase, type OptionProps, type MultiValueProps, type MultiValueRemoveProps, type DropdownIndicatorProps, type ValueContainerProps, type InputProps } from "react-select";
4
+ import { type IOption, type ISelectOptionContext, type ISelectComponentsConfig } from "./types";
5
5
  export declare const SelectOptionContext: React.Context<ISelectOptionContext>;
6
- export declare const SelectMenuContext: React.Context<ISelectMenuContext | null>;
7
- /**
8
- * react-select's Menu with an in-dropdown search input (plus optional reload button and footer)
9
- * above the option list. Defined at module level with a stable identity so react-select never
10
- * remounts it - which is what keeps the search input's focus, caret, and the MenuList scroll
11
- * position alive across keystrokes. All live values arrive via {@link SelectMenuContext}.
12
- *
13
- * The search input sits inside the Menu but OUTSIDE the MenuList on purpose: react-select's
14
- * onInputBlur refocuses its own control input if the active element is inside the MenuList, so
15
- * keeping the search field outside stops that focus war; the caller's controlled menuIsOpen keeps
16
- * the menu open.
17
- */
18
- export declare function SelectMenu<IsMulti extends boolean = boolean, Group extends GroupBase<IOption> = GroupBase<IOption>>(props: MenuProps<IOption, IsMulti, Group>): ReactElement;
19
- export declare namespace SelectMenu {
20
- var displayName: string;
21
- }
22
6
  /**
23
7
  * A single dropdown option (handles Select All, multi-select checkboxes, and the selected
24
8
  * checkmark). Defined at module level with a stable identity so react-select never remounts it;
@@ -41,5 +25,18 @@ export declare function createSelectComponents<IsMulti extends boolean = false,
41
25
  ValueContainer: ({ children, ...props }: ValueContainerProps<IOption, IsMulti, Group>) => import("react/jsx-runtime").JSX.Element;
42
26
  MultiValue: (props: MultiValueProps<IOption>) => import("react/jsx-runtime").JSX.Element | null;
43
27
  MultiValueRemove: (props: MultiValueRemoveProps<IOption, IsMulti, Group>) => import("react/jsx-runtime").JSX.Element;
44
- Input: (props: InputProps<IOption, IsMulti, Group>) => import("react/jsx-runtime").JSX.Element;
45
28
  };
29
+ /**
30
+ * The control input, which must remain present and focusable so react-select's click-to-open flow
31
+ * works (onControlMouseDown → focusInput → onInputFocus → openMenu). It is read-only and visually
32
+ * hidden, so all actual typing happens in the dropdown search input — and with no search input on
33
+ * screen it is where focus lives for as long as the menu is open.
34
+ *
35
+ * Built apart from the components above, on `maxVisibleValues` alone: react-select unmounts and
36
+ * remounts a custom component whose identity changed, and remounting this one destroys that focus.
37
+ * Sharing the icon props' identity would put the focus at the mercy of a consumer passing a fresh
38
+ * `prefixIcon` element on every render.
39
+ */
40
+ export declare function createSelectInput<IsMulti extends boolean = false, Group extends GroupBase<IOption> = GroupBase<IOption>>(maxVisibleValues: number): (props: InputProps<IOption, IsMulti, Group>) => ReactElement;
41
+ /** react-select renders a separator between the indicators; this component has none. */
42
+ export declare const NoIndicatorSeparator: () => null;
@@ -0,0 +1,22 @@
1
+ import { type KeyboardEvent, type RefObject } from "react";
2
+ import { type ISelectMenuContext } from "./types";
3
+ /** What the shared handler leaves for its caller to do. */
4
+ export type TSelectKeyOutcome = "handled" | "navigate" | "ignored";
5
+ /** The slice of the menu context the shared handler reads, so callers can pass the context whole. */
6
+ export type TSelectKeyContext = Pick<ISelectMenuContext, "closeMenu" | "commitAndClose" | "containerRef" | "searchable" | "searchInputRef" | "isLoading" | "loadError" | "onInteractionMode">;
7
+ /** The refs that locate the two inputs focus can live in. */
8
+ export type TSelectFocusRefs = Pick<ISelectMenuContext, "searchInputRef" | "containerRef">;
9
+ /**
10
+ * react-select's hidden control input — the focus holder whenever the search box is absent. Queried
11
+ * fresh every time: react-select rebuilds this node whenever the custom Input's identity changes.
12
+ */
13
+ export declare function getControlInput(containerRef: RefObject<HTMLDivElement>): HTMLInputElement | null;
14
+ /** Focus follows the search box while it exists, and the control input otherwise. */
15
+ export declare function focusMenuInput({ searchInputRef, containerRef }: TSelectFocusRefs): void;
16
+ /**
17
+ * The open menu's keyboard model, shared by the search box and by the control. Escape discards the
18
+ * draft and closes, Tab commits it and closes, and navigation keys are refused while the loader or
19
+ * the error notice stands in for the list. "navigate" means react-select's own option navigation
20
+ * still has to see the key.
21
+ */
22
+ export declare function handleMenuKey(e: KeyboardEvent<Element>, ctx: TSelectKeyContext): TSelectKeyOutcome;
@@ -0,0 +1,12 @@
1
+ import { type ReactElement } from "react";
2
+ import { type GroupBase, type MenuProps } from "react-select";
3
+ import { type IOption, type ISelectMenuContext } from "./types";
4
+ export declare const SelectMenuContext: import("react").Context<ISelectMenuContext | null>;
5
+ /**
6
+ * Menu with in-dropdown search. Stable module identity (keeps focus/caret/scroll); search sits
7
+ * outside MenuList to avoid react-select's focus war. Live values via {@link SelectMenuContext}.
8
+ */
9
+ export declare function SelectMenu<IsMulti extends boolean = boolean, Group extends GroupBase<IOption> = GroupBase<IOption>>(props: MenuProps<IOption, IsMulti, Group>): ReactElement;
10
+ export declare namespace SelectMenu {
11
+ var displayName: string;
12
+ }
@@ -7,12 +7,19 @@ export declare const selectVariants: import("tailwind-variants").TVReturnType<{
7
7
  helperText: string;
8
8
  };
9
9
  };
10
+ searchable: {
11
+ false: {
12
+ menuSearchContainer: string;
13
+ };
14
+ };
10
15
  }, {
11
16
  base: string;
12
17
  label: string;
13
18
  helperText: string;
14
19
  menuSearchContainer: string;
15
20
  menuSearchInput: string;
21
+ menuLoader: string;
22
+ menuError: string;
16
23
  optionLabelWrap: string;
17
24
  optionLabel: string;
18
25
  optionOverlay: string;
@@ -25,12 +32,19 @@ export declare const selectVariants: import("tailwind-variants").TVReturnType<{
25
32
  helperText: string;
26
33
  };
27
34
  };
35
+ searchable: {
36
+ false: {
37
+ menuSearchContainer: string;
38
+ };
39
+ };
28
40
  }, {
29
41
  base: string;
30
42
  label: string;
31
43
  helperText: string;
32
44
  menuSearchContainer: string;
33
45
  menuSearchInput: string;
46
+ menuLoader: string;
47
+ menuError: string;
34
48
  optionLabelWrap: string;
35
49
  optionLabel: string;
36
50
  optionOverlay: string;
@@ -43,12 +57,19 @@ export declare const selectVariants: import("tailwind-variants").TVReturnType<{
43
57
  helperText: string;
44
58
  };
45
59
  };
60
+ searchable: {
61
+ false: {
62
+ menuSearchContainer: string;
63
+ };
64
+ };
46
65
  }, {
47
66
  base: string;
48
67
  label: string;
49
68
  helperText: string;
50
69
  menuSearchContainer: string;
51
70
  menuSearchInput: string;
71
+ menuLoader: string;
72
+ menuError: string;
52
73
  optionLabelWrap: string;
53
74
  optionLabel: string;
54
75
  optionOverlay: string;
@@ -1,5 +1,6 @@
1
- import type { ReactNode, ReactElement, MutableRefObject, RefObject } from "react";
1
+ import type { ChangeEvent, FocusEvent, KeyboardEvent, ReactNode, ReactElement, MutableRefObject, RefObject } from "react";
2
2
  import type { Props as ReactSelectProps, GroupBase } from "react-select";
3
+ import type { TLoadOptions, TPrefetch } from "@hooks";
3
4
  import { type TIconType } from "../adpIcon";
4
5
  /**
5
6
  * Available sizes for the Select component
@@ -23,10 +24,19 @@ export interface IOption {
23
24
  isFixed?: boolean;
24
25
  isDisabled?: boolean;
25
26
  }
27
+ /**
28
+ * Async option source. Page one only: a resolved page that reports `hasMore` is dev-warned, and no
29
+ * further page is ever requested.
30
+ */
31
+ export type TSelectLoadOptions = TLoadOptions<IOption>;
32
+ /** Latest input modality. Drives which signal shows an option's full-text overlay. */
33
+ export type TSelectInteractionMode = "pointer" | "keyboard";
34
+ /** Options as react-select accepts them — sync mode may carry groups; async mode never does. */
35
+ export type TSelectOptions<Group extends GroupBase<IOption> = GroupBase<IOption>> = readonly (IOption | Group)[];
26
36
  /**
27
37
  * Props for the Select component
28
38
  */
29
- export interface ISelectProps<IsMulti extends boolean = false, Group extends GroupBase<IOption> = GroupBase<IOption>> extends Omit<ReactSelectProps<IOption, IsMulti, Group>, "options" | "value" | "className" | "inputValue" | "onInputChange" | "isSearchable"> {
39
+ export interface ISelectProps<IsMulti extends boolean = false, Group extends GroupBase<IOption> = GroupBase<IOption>> extends Omit<ReactSelectProps<IOption, IsMulti, Group>, "options" | "value" | "className" | "inputValue" | "onInputChange" | "isSearchable" | "isLoading" | "filterOption" | "tabSelectsValue"> {
30
40
  /** Unique id for the select input */
31
41
  id?: string;
32
42
  /** Custom className for wrapper */
@@ -35,7 +45,7 @@ export interface ISelectProps<IsMulti extends boolean = false, Group extends Gro
35
45
  label?: ReactNode;
36
46
  /** Select size variant */
37
47
  size?: TSelectSize;
38
- /** Options or groups to render */
48
+ /** Options or groups to render. Ignored (dev warning) when `loadOptions` is set — seed with `initialOptions` instead. */
39
49
  options?: ReactSelectProps<IOption, IsMulti, Group>["options"];
40
50
  /** Current value of the select */
41
51
  value?: ReactSelectProps<IOption, IsMulti, Group>["value"];
@@ -59,7 +69,17 @@ export interface ISelectProps<IsMulti extends boolean = false, Group extends Gro
59
69
  prefixIcon?: TIconType | ReactNode;
60
70
  /** Suffix icon for the control */
61
71
  suffixIcon?: TIconType | ReactNode;
62
- /** Placeholder text for the search input inside the dropdown */
72
+ /**
73
+ * Renders the search input inside the dropdown. With `false` the menu opens straight onto the option
74
+ * list and the control keeps the whole keyboard model: arrows and PageUp/PageDown move the focused
75
+ * option, Home/End jump to its ends, Enter or Space selects, Escape closes and discards the
76
+ * multi-select draft, Tab commits it. Space and Home/End work only in this mode — with a search input
77
+ * on screen they belong to the text field. The reload button is independent of this and still renders
78
+ * when `onReload` / `showReloadButton` is set.
79
+ * @default true
80
+ */
81
+ searchable?: boolean;
82
+ /** Placeholder text for the search input inside the dropdown. Ignored when `searchable={false}`. */
63
83
  searchPlaceholder?: string;
64
84
  /** Tooltip for the select reload button. */
65
85
  reloadTooltip?: string;
@@ -67,6 +87,83 @@ export interface ISelectProps<IsMulti extends boolean = false, Group extends Gro
67
87
  onReload?: () => void;
68
88
  /** Spins the select reload button. */
69
89
  isReloading?: boolean;
90
+ /** Seeds/re-syncs dropdown search; semi-controlled — pair with onFilterChange. Applies in both modes. */
91
+ filterValue?: string;
92
+ /**
93
+ * Debounced search-query callback; also called with "" when the component clears search.
94
+ *
95
+ * Without `loadOptions`: switches off local filtering — `options` is treated as already filtered
96
+ * for the query — and the fetch, loading state, and response ordering are the consumer's
97
+ * responsibility.
98
+ *
99
+ * With `loadOptions`: notification-only, for analytics or `filterValue` syncing.
100
+ */
101
+ onFilterChange?: (query: string) => void;
102
+ /** Debounce for the search query, in both sync and `loadOptions` mode. Set to 0 to disable. @default 300 */
103
+ filterDebounceMs?: number;
104
+ /** Replaces option list with loader. OR-ed with the loader's own state, so it still applies in async mode. @default false */
105
+ isLoading?: boolean;
106
+ /**
107
+ * Custom client-side match, replacing the shared `matchesQuery` default.
108
+ *
109
+ * @deprecated Use `onFilterChange` instead, which does the same job without a second filtering axis:
110
+ * it hands you the query and treats `options` as already filtered, so your predicate lives in your own
111
+ * `useMemo` rather than in a react-select callback. Pair with `filterDebounceMs={0}` to keep filtering
112
+ * synchronous. Ignored entirely when filtering is already delegated (`onFilterChange`/`loadOptions`),
113
+ * and scheduled for removal in the next major.
114
+ *
115
+ * ```tsx
116
+ * const visible = useMemo(() => all.filter(( o ) => myMatch( o, query )), [ all, query ]);
117
+ * <Select options={visible} onFilterChange={setQuery} filterDebounceMs={0} />
118
+ * ```
119
+ */
120
+ filterOption?: ReactSelectProps<IOption, IsMulti, Group>["filterOption"];
121
+ /**
122
+ * Server-side option source. When provided, `Select` owns the option list, the request lifecycle and
123
+ * the loading state; `options` is ignored (dev warning) and `onFilterChange` becomes
124
+ * notification-only. Responsible for mapping the payload to `IOption` — envelopes and domain
125
+ * filtering are the consumer's business. Options are stored exactly as returned, so extra fields
126
+ * survive. A fresh inline arrow is fine: the loader is read through a ref.
127
+ *
128
+ * Page one only: `cursor` / `hasMore` / `total` in the result are ignored.
129
+ */
130
+ loadOptions?: TSelectLoadOptions;
131
+ /**
132
+ * Seed rows for a list you already have — an SSR payload, a route loader, a warm cache. They paint on the
133
+ * first frame, so there is no loader to sit through, and they stay put while the baseline fetch revalidates
134
+ * over them. They do not suppress that fetch: pair with `prefetch="never"` if the seed is the whole list
135
+ * until the user types. A *search* replaces them, since seed rows are not results for a query; clearing it
136
+ * brings them back until a fetched baseline lands. Async mode only — ignored (dev warning) without
137
+ * `loadOptions`, where the rows belong in `options`.
138
+ */
139
+ initialOptions?: readonly IOption[];
140
+ /**
141
+ * When to fetch the unfiltered baseline.
142
+ * - `"open"` — on first menu open. Right for forms with several server-filtered Selects, where paying
143
+ * for menus the user may never open is the worse trade.
144
+ * - `"mount"` — at render, before any interaction. Use when the list is near-certain to be needed and
145
+ * a visible-but-empty Select would read as broken.
146
+ * - `"never"` — no baseline at all; fetch only once the user types. For heavy lists.
147
+ *
148
+ * Async mode only — ignored (dev warning) without `loadOptions`, where `options` are already on screen
149
+ * and there is nothing to fetch.
150
+ * @default "open"
151
+ */
152
+ prefetch?: TPrefetch;
153
+ /** Clearing the search revalidates the cached baseline instead of just restoring it. Costs one request per menu close. @default false */
154
+ refetchOnClear?: boolean;
155
+ /**
156
+ * Identity of the option set, for dependent selects. When it changes, cached results are dropped and
157
+ * the list is repopulated — immediately if the menu is open, otherwise on next open. Compose several
158
+ * parents into one scalar: ``optionsKey={`${domainId}|${accessType}`}``. Does NOT clear the selection.
159
+ */
160
+ optionsKey?: string | number;
161
+ /** Shown in the menu when `loadOptions` rejects. @default "Couldn't load options." */
162
+ loadErrorMessage?: ReactNode;
163
+ /** Shows the menu's reload button in async mode, wired to re-run the current query. @default false */
164
+ showReloadButton?: boolean;
165
+ /** Notified when a load rejects (the component renders `loadErrorMessage` and swallows it). */
166
+ onLoadError?: (error: unknown) => void;
70
167
  }
71
168
  /**
72
169
  * Per-render option config for the SelectOption component. react-select keys custom components by
@@ -77,8 +174,19 @@ export interface ISelectProps<IsMulti extends boolean = false, Group extends Gro
77
174
  * `useIsTruncated` measurement (and the hover-expand affordance) from flickering.
78
175
  */
79
176
  export interface ISelectOptionContext {
80
- /** In-progress multi-select draft. Drives checkboxes / Select All while the committed value drives the control. */
81
- draftValues?: IOption[];
177
+ /**
178
+ * In-progress multi-select draft, as a value Set. Drives checkboxes / Select All while the
179
+ * committed value drives the control. A Set rather than the array: every option row tests its own
180
+ * membership, so an array would make one menu render O(options x draft).
181
+ */
182
+ draftValues?: ReadonlySet<IOption["value"]>;
183
+ /**
184
+ * Checked state of the Select All row: every option the query currently leaves VISIBLE is in the
185
+ * draft. Resolved on the Select, which is the only place that knows the visible set — react-select
186
+ * hands each option its unfiltered `options` array, so deriving it here would report unchecked
187
+ * even with every visible row ticked.
188
+ */
189
+ areAllSelected?: boolean;
82
190
  /** Toggle a single option in the multi-select draft. */
83
191
  onToggleDraftOption?: (option: IOption) => void;
84
192
  /** Toggle Select All / Deselect All on the multi-select draft (shared with the keyboard path). */
@@ -95,21 +203,31 @@ export interface ISelectOptionContext {
95
203
  * they're navigating by keyboard. Without this, react-select's `isFocused` - which lingers on the
96
204
  * last-focused option after the pointer leaves, and is also set by mouse hover - keeps an
97
205
  * overlay visible after the mouse has moved away (and shows two at once mid-transition).
206
+ *
207
+ * State on the Select, not a shared ref: this decides what an option renders, and writing a ref
208
+ * schedules no re-render. Setting the mode it already holds is a no-op React bails out of, so
209
+ * hovering along a list costs a render only at a genuine modality switch.
98
210
  */
99
- interactionModeRef: MutableRefObject<"pointer" | "keyboard">;
211
+ interactionMode: TSelectInteractionMode;
212
+ /** Records the modality the user just used. See {@link ISelectOptionContext.interactionMode}. */
213
+ onInteractionMode: (mode: TSelectInteractionMode) => void;
100
214
  }
101
215
  /**
102
- * Live, per-instance config for the stable SelectMenu component. Mirrors {@link ISelectOptionContext}:
103
- * routing these through context lets SelectMenu keep a module-level identity - so react-select never
104
- * remounts it and the search input keeps its focus, caret, and scroll position across keystrokes -
105
- * while still re-rendering with current values whenever they change. (A component closing over these
106
- * directly would freeze them at first render, since its identity must never change.)
216
+ * Per-instance menu config via context (keeps SelectMenu's stable identity).
107
217
  */
108
218
  export interface ISelectMenuContext {
109
219
  /** Current search text (controls react-select's inputValue). */
110
220
  filterQuery: string;
111
- /** Called with the search input's new value. */
112
- onFilterChange: (value: string) => void;
221
+ /** Updates the query and (debounced) notifies `onFilterChange`. */
222
+ onFilterInput: (e: ChangeEvent<HTMLInputElement>) => void;
223
+ /** Marks Backspace/Delete held; defer debounce until keyup. */
224
+ onFilterKeyDown: (e: KeyboardEvent<HTMLInputElement>) => void;
225
+ /** On Backspace/Delete release, starts the deferred debounce. */
226
+ onFilterKeyUp: (e: KeyboardEvent<HTMLInputElement>) => void;
227
+ /** On blur during hold, flush deferred debounce. */
228
+ onFilterBlur: (e: FocusEvent<HTMLInputElement>) => void;
229
+ /** Renders the in-dropdown search input; the reload button is independent of it. */
230
+ searchable: boolean;
113
231
  /** Placeholder for the search input. */
114
232
  searchPlaceholder: string;
115
233
  /** Optional custom footer rendered below the option list. */
@@ -122,6 +240,14 @@ export interface ISelectMenuContext {
122
240
  searchContainerClass: string;
123
241
  /** tv() class for the search input. */
124
242
  searchInputClass: string;
243
+ /** tv() class for the loader shown in place of the option list. */
244
+ loaderClass: string;
245
+ /** Replaces the option list with the loader. */
246
+ isLoading?: boolean;
247
+ /** Replaces the option list when set (async load failure). */
248
+ loadError?: ReactNode;
249
+ /** tv() class for the error container. */
250
+ errorClass: string;
125
251
  /** Ref to the search input; focused when the menu opens. */
126
252
  searchInputRef: RefObject<HTMLInputElement>;
127
253
  /** Captures the menu's (possibly portaled) DOM node for the outside-click check. */
@@ -134,8 +260,8 @@ export interface ISelectMenuContext {
134
260
  isReloading?: boolean;
135
261
  /** Reload-button tooltip / aria-label. */
136
262
  reloadTooltip?: string;
137
- /** Shared input-modality flag (see {@link ISelectOptionContext}); flipped to "keyboard" here. */
138
- interactionModeRef: MutableRefObject<"pointer" | "keyboard">;
263
+ /** Records the input modality (see {@link ISelectOptionContext.interactionMode}); set to "keyboard" here. */
264
+ onInteractionMode: (mode: TSelectInteractionMode) => void;
139
265
  }
140
266
  export interface IOptionLabelOverlayProps {
141
267
  anchorRef: RefObject<HTMLElement>;
@@ -0,0 +1,39 @@
1
+ import { type ReactNode } from "react";
2
+ import type { GroupBase } from "react-select";
3
+ import { type TPrefetch } from "@hooks";
4
+ import type { IOption, TSelectLoadOptions, TSelectOptions } from "./types";
5
+ interface IUseSelectOptionSourceArgs<Group extends GroupBase<IOption>> {
6
+ options?: TSelectOptions<Group>;
7
+ loadOptions?: TSelectLoadOptions;
8
+ initialOptions?: readonly IOption[];
9
+ prefetch?: TPrefetch;
10
+ refetchOnClear?: boolean;
11
+ optionsKey?: string | number;
12
+ loadErrorMessage?: ReactNode;
13
+ showReloadButton?: boolean;
14
+ onLoadError?: (error: unknown) => void;
15
+ /** Consumer-owned loading flag; OR-ed with the async loader rather than replaced by it. */
16
+ isLoading?: boolean;
17
+ onReload?: () => void;
18
+ isReloading?: boolean;
19
+ onFilterChange?: (query: string) => void;
20
+ }
21
+ interface ISelectOptionSource<Group extends GroupBase<IOption>> {
22
+ options: TSelectOptions<Group>;
23
+ isServerFiltered: boolean;
24
+ /** Loader instead of rows (SelectMenu's `isLoading`). */
25
+ isLoading: boolean;
26
+ isReloading?: boolean;
27
+ onReload?: () => void;
28
+ /** Hand to `useFilterQuery`; notifies the consumer AND drives the async source. */
29
+ onFilterQueryChange: (query: string) => void;
30
+ ensureDefaults: () => void;
31
+ loadError?: ReactNode;
32
+ }
33
+ /**
34
+ * All of `Select`'s option-source policy: async vs sync mode detection, value precedence between the
35
+ * consumer's own flags and the loader's derived ones, default messages, and the dev warnings for the
36
+ * two footguns a type-level XOR cannot express against react-select's generics.
37
+ */
38
+ export declare function useSelectOptionSource<Group extends GroupBase<IOption>>({ options, loadOptions, initialOptions, prefetch, refetchOnClear, optionsKey, loadErrorMessage, showReloadButton, onLoadError, isLoading, onReload, isReloading, onFilterChange }: IUseSelectOptionSourceArgs<Group>): ISelectOptionSource<Group>;
39
+ export {};
@@ -0,0 +1,16 @@
1
+ import { type MutableRefObject } from "react";
2
+ interface IUseSelectOutsideCloseArgs {
3
+ /** Only while the menu is open is a listener attached. */
4
+ menuOpen: boolean;
5
+ /** The menu's (possibly portaled) DOM node, so clicks inside it are not "outside". */
6
+ menuNodeRef: MutableRefObject<HTMLDivElement | null>;
7
+ /** Commits the multi-select draft, then closes. */
8
+ commitAndClose: () => void;
9
+ }
10
+ /**
11
+ * Closes the dropdown on interaction outside the component. react-select's own outside-click
12
+ * handling relies on its input being focused (it is not — focus lives in the dropdown search input),
13
+ * so Select handles it here instead.
14
+ */
15
+ export declare function useSelectOutsideClose({ menuOpen, menuNodeRef, commitAndClose }: IUseSelectOutsideCloseArgs): void;
16
+ export {};
@@ -1,5 +1,9 @@
1
1
  import { type StylesConfig, type GroupBase } from "react-select";
2
2
  import { type TSelectSize, type IOption } from "./types";
3
+ export declare const SELECT_ALL_VALUE = "select-all";
4
+ export declare const isCreateOption: (option: IOption) => boolean;
5
+ export declare const toPoolOption: (option: IOption) => IOption;
3
6
  export declare const getSelectableOptions: (options: readonly (IOption | GroupBase<IOption>)[]) => IOption[];
4
- export declare const areAllSelectableSelected: (options: readonly (IOption | GroupBase<IOption>)[], draft: IOption[]) => boolean;
7
+ export declare const getPooledValues: (options: readonly (IOption | GroupBase<IOption>)[]) => Set<IOption["value"]>;
8
+ export declare const areAllSelectableSelected: (selectable: readonly IOption[], draftValues: ReadonlySet<IOption["value"]>) => boolean;
5
9
  export declare const reactSelectCustomStyles: <IsMulti extends boolean, Group extends GroupBase<IOption>>(error: boolean, size: TSelectSize, multiSelect: boolean) => StylesConfig<IOption, IsMulti, Group>;
@@ -1,3 +1,3 @@
1
1
  export { TransferList } from "./transferList";
2
2
  export { transferListVariants } from "./transferListVariants";
3
- export type { ITransferListProps, ITransferListItem, TTransferListValue, TTransferPanel } from "./types";
3
+ export type { ITransferListProps, ITransferListItem, TTransferListValue, TTransferPanel, TTransferListLoadOptions, TTransferListPrefetch } from "./types";
@@ -4,9 +4,6 @@ import type { ITransferListProps } from "./types";
4
4
  * A fully-controlled two-panel transfer list. Move items between the Available
5
5
  * and Selected panels via checkboxes + arrow controls or native drag-and-drop.
6
6
  * Rendering and ownership of any surrounding chrome (modal, footer) is left to
7
- * the consumer.
7
+ * the consumer. The forwarded ref lands on the wrapper `<div>`.
8
8
  */
9
- export declare function TransferList({ availableItems, selectedItems, onChange, availablePanelTitle, selectedPanelTitle, searchable, availableSearchTerm, onAvailableSearchChange, selectedSearchTerm, onSelectedSearchChange, searchPlaceholder, availablePanelHeaderSlot, selectedPanelHeaderSlot, moveToSelectedLabel, moveToAvailableLabel, reorderable, reloadTooltip, onReload, isReloading, hasMoreAvailable, onLoadMoreAvailable, isLoadingMoreAvailable, disabled, availableEmptyText, selectedEmptyText, className }: ITransferListProps): React.ReactElement;
10
- export declare namespace TransferList {
11
- var displayName: string;
12
- }
9
+ export declare const TransferList: React.ForwardRefExoticComponent<ITransferListProps & React.RefAttributes<HTMLDivElement>>;
@@ -18,8 +18,21 @@ interface ITransferListPanelProps {
18
18
  hasMore?: boolean;
19
19
  onLoadMore?: () => void;
20
20
  isLoadingMore?: boolean;
21
+ /** Loader REPLACES the rows (a search/refresh fetch, not a page append). */
22
+ isLoading?: boolean;
23
+ /** Replaces the rows when set: the panel's source failed to load. */
24
+ loadError?: React.ReactNode;
25
+ /** Shown under the loaded rows when a page append failed; renders a retry button. */
26
+ loadMoreError?: React.ReactNode;
27
+ /** Fired by the retry button under `loadMoreError`. */
28
+ onRetryLoadMore?: () => void;
29
+ /** Label for that retry button. */
30
+ retryLabel?: string;
31
+ /** Server-side total; the header count becomes "(loaded of total)". */
32
+ totalCount?: number;
21
33
  selectAllChecked: boolean;
22
34
  selectAllIndeterminate: boolean;
35
+ /** Search-visible, non-disabled row count — the scope the select-all checkbox acts on. */
23
36
  selectAllCount: number;
24
37
  onToggleSelectAll: () => void;
25
38
  moveLabel: string;
@@ -44,7 +57,7 @@ interface ITransferListPanelProps {
44
57
  * One panel of the transfer list: header (title, count, optional reload),
45
58
  * optional search + header slot, and a scrollable list of rows or an empty state.
46
59
  */
47
- export declare function TransferListPanel({ panel, title, items, reorderable, disabled, emptyText, searchable, searchValue, searchPlaceholder, onSearchChange, headerSlot, reloadTooltip, onReload, isReloading, hasMore, onLoadMore, isLoadingMore, selectAllChecked, selectAllIndeterminate, selectAllCount, onToggleSelectAll, moveLabel, moveCount, moveDisabled, moveIconSide, onMove, isChecked, onToggle, onRemove, onMoveUp, onMoveDown, dropIndex, showDropOverlay, onItemDragStart, onItemDragEnd, onItemDragOver, onListDragOver, onListDrop }: ITransferListPanelProps): React.ReactElement;
60
+ export declare function TransferListPanel({ panel, title, items, reorderable, disabled, emptyText, searchable, searchValue, searchPlaceholder, onSearchChange, headerSlot, reloadTooltip, onReload, isReloading, hasMore, onLoadMore, isLoadingMore, isLoading, loadError, loadMoreError, onRetryLoadMore, retryLabel, totalCount, selectAllChecked, selectAllIndeterminate, selectAllCount, onToggleSelectAll, moveLabel, moveCount, moveDisabled, moveIconSide, onMove, isChecked, onToggle, onRemove, onMoveUp, onMoveDown, dropIndex, showDropOverlay, onItemDragStart, onItemDragEnd, onItemDragOver, onListDragOver, onListDrop }: ITransferListPanelProps): React.ReactElement;
48
61
  export declare namespace TransferListPanel {
49
62
  var displayName: string;
50
63
  }
@@ -0,0 +1,29 @@
1
+ import * as React from "react";
2
+ import type { TTransferPanel } from "./types";
3
+ interface ITransferListPanelHeaderProps {
4
+ panel: TTransferPanel;
5
+ title: React.ReactNode;
6
+ /** Rows currently loaded in this panel. */
7
+ count: number;
8
+ /** Server-side total; the count becomes "(loaded of total)" when it exceeds `count`. */
9
+ totalCount?: number;
10
+ disabled: boolean;
11
+ searchable: boolean;
12
+ searchValue: string;
13
+ searchPlaceholder: string;
14
+ onSearchChange: (query: string) => void;
15
+ headerSlot?: React.ReactNode;
16
+ reloadTooltip?: string;
17
+ onReload?: () => void;
18
+ isReloading?: boolean;
19
+ }
20
+ /**
21
+ * The non-interactive chrome above a transfer-list panel's listbox: title + count, the optional
22
+ * reload button, the search input, and the consumer's header slot. It shares no state with the
23
+ * listbox below it.
24
+ */
25
+ export declare function TransferListPanelHeader({ panel, title, count, totalCount, disabled, searchable, searchValue, searchPlaceholder, onSearchChange, headerSlot, reloadTooltip, onReload, isReloading }: ITransferListPanelHeaderProps): React.ReactElement;
26
+ export declare namespace TransferListPanelHeader {
27
+ var displayName: string;
28
+ }
29
+ export {};
@@ -54,6 +54,9 @@ export declare const transferListVariants: import("tailwind-variants").TVReturnT
54
54
  emptyWrap: string;
55
55
  emptyText: string;
56
56
  loaderRow: string;
57
+ replaceLoader: string;
58
+ panelError: string;
59
+ loadMoreErrorRow: string;
57
60
  row: string;
58
61
  dragHandle: string;
59
62
  badge: string;
@@ -121,6 +124,9 @@ export declare const transferListVariants: import("tailwind-variants").TVReturnT
121
124
  emptyWrap: string;
122
125
  emptyText: string;
123
126
  loaderRow: string;
127
+ replaceLoader: string;
128
+ panelError: string;
129
+ loadMoreErrorRow: string;
124
130
  row: string;
125
131
  dragHandle: string;
126
132
  badge: string;
@@ -188,6 +194,9 @@ export declare const transferListVariants: import("tailwind-variants").TVReturnT
188
194
  emptyWrap: string;
189
195
  emptyText: string;
190
196
  loaderRow: string;
197
+ replaceLoader: string;
198
+ panelError: string;
199
+ loadMoreErrorRow: string;
191
200
  row: string;
192
201
  dragHandle: string;
193
202
  badge: string;