@cloudwick/astral-ui 8.0.0 → 8.1.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/README.md +1 -1
- package/dist/components/button/reloadButton.d.ts +20 -0
- package/dist/components/emptyState/emptyStateVariants.d.ts +3 -3
- package/dist/components/multiSelectTransfer/index.d.ts +1 -1
- package/dist/components/multiSelectTransfer/multiSelectTransfer.d.ts +5 -4
- package/dist/components/multiSelectTransfer/multiSelectTransferDropdown.d.ts +21 -3
- package/dist/components/multiSelectTransfer/multiSelectTransferModal.d.ts +16 -4
- package/dist/components/multiSelectTransfer/multiSelectTransferTrigger.d.ts +26 -0
- package/dist/components/multiSelectTransfer/multiSelectTransferVariants.d.ts +18 -0
- package/dist/components/multiSelectTransfer/types.d.ts +84 -2
- package/dist/components/multiSelectTransfer/useMultiSelectTransferDraft.d.ts +24 -0
- package/dist/components/multiSelectTransfer/useMultiSelectTransferOptionSource.d.ts +56 -0
- package/dist/components/select/index.d.ts +1 -1
- package/dist/components/select/select.d.ts +5 -6
- package/dist/components/select/selectComponents.d.ts +2 -18
- package/dist/components/select/selectMenu.d.ts +12 -0
- package/dist/components/select/selectVariants.d.ts +6 -0
- package/dist/components/select/types.d.ts +129 -15
- package/dist/components/select/useSelectOptionSource.d.ts +39 -0
- package/dist/components/select/useSelectOutsideClose.d.ts +16 -0
- package/dist/components/select/utils.d.ts +2 -1
- package/dist/components/transferList/index.d.ts +1 -1
- package/dist/components/transferList/transferList.d.ts +2 -5
- package/dist/components/transferList/transferListPanel.d.ts +14 -1
- package/dist/components/transferList/transferListPanelHeader.d.ts +29 -0
- package/dist/components/transferList/transferListVariants.d.ts +9 -0
- package/dist/components/transferList/types.d.ts +86 -10
- package/dist/components/transferList/useTransferList.d.ts +1 -1
- package/dist/components/transferList/useTransferListPanelKeys.d.ts +28 -0
- package/dist/components/transferList/useTransferListSource.d.ts +49 -0
- package/dist/css/index.min.css +1 -1
- package/dist/hooks/index.d.ts +7 -1
- package/dist/hooks/useAsyncOptions.d.ts +85 -0
- package/dist/hooks/useAsyncOptionsReducer.d.ts +75 -0
- package/dist/hooks/useAvailableProjection.d.ts +20 -0
- package/dist/hooks/useFilterQuery.d.ts +28 -0
- package/dist/hooks/useIgnoredPropWarning.d.ts +5 -0
- package/dist/hooks/useInfiniteScroll.d.ts +11 -2
- package/dist/hooks/useOnValueChange.d.ts +6 -0
- package/dist/hooks/usePrefetchBaseline.d.ts +22 -0
- package/dist/index.cjs.js +5 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.esm.js +5 -5
- package/dist/utils/devWarn.d.ts +5 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/mergeUnique.d.ts +6 -0
- package/dist/utils/resolveLoadErrors.d.ts +20 -0
- package/dist/utils/resolveReloadControls.d.ts +23 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
export interface IReloadButtonProps {
|
|
3
|
+
/** Absent means the surface has no reload affordance, and nothing renders. */
|
|
4
|
+
onReload?: () => void;
|
|
5
|
+
/** Spins the icon and blocks a second click while the refetch is in flight. */
|
|
6
|
+
isReloading?: boolean;
|
|
7
|
+
/** OR-ed with `isReloading` — a disabled surface has nothing to reload. */
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
/** Doubles as the accessible name; the button is icon-only. */
|
|
10
|
+
tooltip?: string;
|
|
11
|
+
className?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The icon-only refetch affordance for any surface backed by an async option source. One component
|
|
15
|
+
* so the icon, the in-flight disable and the tooltip/aria-label pairing cannot drift between them.
|
|
16
|
+
*/
|
|
17
|
+
export declare function ReloadButton({ onReload, isReloading, disabled, tooltip, className }: IReloadButtonProps): React.ReactElement | null;
|
|
18
|
+
export declare namespace ReloadButton {
|
|
19
|
+
var displayName: string;
|
|
20
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export declare const emptyStateVariants: import("tailwind-variants").TVReturnType<{
|
|
2
2
|
[key: string]: {
|
|
3
3
|
[key: string]: import("tailwind-merge").ClassNameValue | {
|
|
4
|
+
base?: import("tailwind-merge").ClassNameValue;
|
|
4
5
|
title?: import("tailwind-merge").ClassNameValue;
|
|
5
6
|
content?: import("tailwind-merge").ClassNameValue;
|
|
6
|
-
base?: import("tailwind-merge").ClassNameValue;
|
|
7
7
|
cta?: import("tailwind-merge").ClassNameValue;
|
|
8
8
|
contentWrapper?: import("tailwind-merge").ClassNameValue;
|
|
9
9
|
};
|
|
@@ -11,9 +11,9 @@ export declare const emptyStateVariants: import("tailwind-variants").TVReturnTyp
|
|
|
11
11
|
} | {
|
|
12
12
|
[x: string]: {
|
|
13
13
|
[x: string]: import("tailwind-merge").ClassNameValue | {
|
|
14
|
+
base?: import("tailwind-merge").ClassNameValue;
|
|
14
15
|
title?: import("tailwind-merge").ClassNameValue;
|
|
15
16
|
content?: import("tailwind-merge").ClassNameValue;
|
|
16
|
-
base?: import("tailwind-merge").ClassNameValue;
|
|
17
17
|
cta?: import("tailwind-merge").ClassNameValue;
|
|
18
18
|
contentWrapper?: import("tailwind-merge").ClassNameValue;
|
|
19
19
|
};
|
|
@@ -27,9 +27,9 @@ export declare const emptyStateVariants: import("tailwind-variants").TVReturnTyp
|
|
|
27
27
|
}, undefined, {
|
|
28
28
|
[key: string]: {
|
|
29
29
|
[key: string]: import("tailwind-merge").ClassNameValue | {
|
|
30
|
+
base?: import("tailwind-merge").ClassNameValue;
|
|
30
31
|
title?: import("tailwind-merge").ClassNameValue;
|
|
31
32
|
content?: import("tailwind-merge").ClassNameValue;
|
|
32
|
-
base?: import("tailwind-merge").ClassNameValue;
|
|
33
33
|
cta?: import("tailwind-merge").ClassNameValue;
|
|
34
34
|
contentWrapper?: import("tailwind-merge").ClassNameValue;
|
|
35
35
|
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { MultiSelectTransfer } from "./multiSelectTransfer";
|
|
2
2
|
export { multiSelectTransferVariants } from "./multiSelectTransferVariants";
|
|
3
|
-
export type { IMultiSelectTransferProps, TMultiSelectTransferOption, TMultiSelectTransferSize } from "./types";
|
|
3
|
+
export type { IMultiSelectTransferProps, TMultiSelectTransferOption, TMultiSelectTransferSize, TMultiSelectTransferLoadOptions } from "./types";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type IMultiSelectTransferProps } from "./types";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
/**
|
|
4
|
+
* A pill trigger over a dropdown option list, with a two-panel transfer-list modal as its second
|
|
5
|
+
* surface. The forwarded ref lands on the wrapper `<div>`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MultiSelectTransfer: React.ForwardRefExoticComponent<IMultiSelectTransferProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import { type TSentinelRef } from "@hooks";
|
|
2
3
|
import type { TTransferListValue } from "../transferList/types";
|
|
3
4
|
import type { TMultiSelectTransferOption, TMultiSelectTransferSize } from "./types";
|
|
4
5
|
interface IMultiSelectTransferDropdownProps {
|
|
@@ -8,15 +9,32 @@ interface IMultiSelectTransferDropdownProps {
|
|
|
8
9
|
filterQuery: string;
|
|
9
10
|
onFilterInput: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
|
10
11
|
onFilterKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
12
|
+
onFilterKeyUp: (e: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
13
|
+
onFilterBlur: (e: React.FocusEvent<HTMLInputElement>) => void;
|
|
11
14
|
searchPlaceholder: string;
|
|
12
|
-
|
|
15
|
+
/** Readonly so the option source's pool can be passed through without a defensive copy. */
|
|
16
|
+
options: readonly TMultiSelectTransferOption[];
|
|
13
17
|
selectedValues: Set<TTransferListValue>;
|
|
14
18
|
onOptionToggle: (option: TMultiSelectTransferOption) => void;
|
|
15
19
|
hasSelectAll: boolean;
|
|
16
20
|
areAllSelected: boolean;
|
|
17
21
|
onSelectAll: () => void;
|
|
22
|
+
/** Any load in flight; renders the loader row below the list. */
|
|
18
23
|
isLoading?: boolean;
|
|
19
|
-
|
|
24
|
+
/**
|
|
25
|
+
* Loader (or error) takes the rows' place rather than appending below them. Required, and supplied
|
|
26
|
+
* by the option source rather than re-derived here, so the hook is the single source of this
|
|
27
|
+
* predicate — two components deriving it differently is how they drifted.
|
|
28
|
+
*/
|
|
29
|
+
isSearchFetch: boolean;
|
|
30
|
+
sentinelRef: TSentinelRef;
|
|
31
|
+
/** Replaces the rows when set: the whole list failed to load. */
|
|
32
|
+
loadError?: React.ReactNode;
|
|
33
|
+
/** Shown below the loaded rows when a page append failed. */
|
|
34
|
+
loadMoreError?: React.ReactNode;
|
|
35
|
+
/** Fired by the retry button beside `loadMoreError`. */
|
|
36
|
+
onRetryLoadMore?: () => void;
|
|
37
|
+
retryLabel?: string;
|
|
20
38
|
reloadTooltip?: string;
|
|
21
39
|
onReload?: () => void;
|
|
22
40
|
isReloading?: boolean;
|
|
@@ -25,7 +43,7 @@ interface IMultiSelectTransferDropdownProps {
|
|
|
25
43
|
* The open-state dropdown for MultiSelectTransfer: a search input, an optional "Select All"
|
|
26
44
|
* row, the (draft-checked) option list, and the infinite-scroll sentinel.
|
|
27
45
|
*/
|
|
28
|
-
export declare function MultiSelectTransferDropdown({ error, size, disabled, filterQuery, onFilterInput, onFilterKeyDown, searchPlaceholder, options, selectedValues, onOptionToggle, hasSelectAll, areAllSelected, onSelectAll, isLoading, sentinelRef, reloadTooltip, onReload, isReloading }: IMultiSelectTransferDropdownProps): React.ReactElement;
|
|
46
|
+
export declare function MultiSelectTransferDropdown({ error, size, disabled, filterQuery, onFilterInput, onFilterKeyDown, onFilterKeyUp, onFilterBlur, searchPlaceholder, options, selectedValues, onOptionToggle, hasSelectAll, areAllSelected, onSelectAll, isLoading, isSearchFetch, sentinelRef, loadError, loadMoreError, onRetryLoadMore, retryLabel, reloadTooltip, onReload, isReloading }: IMultiSelectTransferDropdownProps): React.ReactElement;
|
|
29
47
|
export declare namespace MultiSelectTransferDropdown {
|
|
30
48
|
var displayName: string;
|
|
31
49
|
}
|
|
@@ -17,9 +17,21 @@ interface IMultiSelectTransferModalProps {
|
|
|
17
17
|
searchPlaceholder?: string;
|
|
18
18
|
availablePanelHeaderSlot?: React.ReactNode;
|
|
19
19
|
selectedPanelHeaderSlot?: React.ReactNode;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
hasMoreAvailable?: boolean;
|
|
21
|
+
onLoadMoreAvailable?: () => void;
|
|
22
|
+
/** Loader (or error) REPLACES the available rows rather than appending below them. */
|
|
23
|
+
isLoadingAvailable?: boolean;
|
|
24
|
+
/** Loader appends below the available rows (a page fetch). */
|
|
25
|
+
isLoadingMoreAvailable: boolean;
|
|
26
|
+
availableLoadError?: React.ReactNode;
|
|
27
|
+
availableLoadMoreError?: React.ReactNode;
|
|
28
|
+
onRetryLoadMoreAvailable?: () => void;
|
|
29
|
+
retryLabel?: string;
|
|
30
|
+
/** Server-side total for the available panel. */
|
|
31
|
+
availableTotalCount?: number;
|
|
32
|
+
/** Set (async mode only) to drive the available panel's search server-side. */
|
|
33
|
+
availableSearchTerm?: string;
|
|
34
|
+
onAvailableSearchChange?: (query: string) => void;
|
|
23
35
|
cancelLabel: React.ReactNode;
|
|
24
36
|
doneLabel: React.ReactNode;
|
|
25
37
|
}
|
|
@@ -27,7 +39,7 @@ interface IMultiSelectTransferModalProps {
|
|
|
27
39
|
* The transfer-list modal surface for MultiSelectTransfer: full-screen on mobile, a widened
|
|
28
40
|
* centered dialog from sm up. Hosts the two-panel TransferList plus a pinned footer bar.
|
|
29
41
|
*/
|
|
30
|
-
export declare function MultiSelectTransferModal({ showModal, availableItems, selectedItems, onChange, onCancel, onDone, header, title, subtitle, reorderable, reloadTooltip, onReload, isReloading, searchPlaceholder, availablePanelHeaderSlot, selectedPanelHeaderSlot,
|
|
42
|
+
export declare function MultiSelectTransferModal({ showModal, availableItems, selectedItems, onChange, onCancel, onDone, header, title, subtitle, reorderable, reloadTooltip, onReload, isReloading, searchPlaceholder, availablePanelHeaderSlot, selectedPanelHeaderSlot, hasMoreAvailable, onLoadMoreAvailable, isLoadingAvailable, isLoadingMoreAvailable, availableLoadError, availableLoadMoreError, onRetryLoadMoreAvailable, retryLabel, availableTotalCount, availableSearchTerm, onAvailableSearchChange, cancelLabel, doneLabel }: IMultiSelectTransferModalProps): React.ReactElement;
|
|
31
43
|
export declare namespace MultiSelectTransferModal {
|
|
32
44
|
var displayName: string;
|
|
33
45
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import type { TMultiSelectTransferOption, TMultiSelectTransferSize } from "./types";
|
|
3
|
+
interface IMultiSelectTransferTriggerProps {
|
|
4
|
+
id: string;
|
|
5
|
+
error?: boolean;
|
|
6
|
+
size: TMultiSelectTransferSize;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
isOpen: boolean;
|
|
9
|
+
/** The committed selection — the trigger shows pills for this, never for the in-progress draft. */
|
|
10
|
+
value: TMultiSelectTransferOption[];
|
|
11
|
+
placeholder: string;
|
|
12
|
+
maxVisiblePills: number;
|
|
13
|
+
onClick: () => void;
|
|
14
|
+
onKeyDown: (e: React.KeyboardEvent<HTMLDivElement>) => void;
|
|
15
|
+
onRemovePill: (option: TMultiSelectTransferOption, e: React.MouseEvent) => void;
|
|
16
|
+
onOpenTransferList: (e: React.MouseEvent) => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The read-only control for MultiSelectTransfer: committed pills (capped by `maxVisiblePills` with a
|
|
20
|
+
* "+N More" overflow), the transfer-list CTA and the open/close chevron. It owns no state.
|
|
21
|
+
*
|
|
22
|
+
* The trigger comes back through `forwardRef`, not a `triggerRef` prop: a ref taken as an ordinary
|
|
23
|
+
* prop cannot be merged with a caller's own, and is invisible to anything composing over `ref`.
|
|
24
|
+
*/
|
|
25
|
+
export declare const MultiSelectTransferTrigger: React.ForwardRefExoticComponent<IMultiSelectTransferTriggerProps & React.RefAttributes<HTMLDivElement>>;
|
|
26
|
+
export {};
|
|
@@ -17,6 +17,7 @@ export declare const multiSelectTransferVariants: import("tailwind-variants").TV
|
|
|
17
17
|
pillMore: string;
|
|
18
18
|
placeholder: string;
|
|
19
19
|
optionLabel: string;
|
|
20
|
+
noOptionsMessage: string;
|
|
20
21
|
};
|
|
21
22
|
lg: {
|
|
22
23
|
trigger: string;
|
|
@@ -25,6 +26,7 @@ export declare const multiSelectTransferVariants: import("tailwind-variants").TV
|
|
|
25
26
|
pillMore: string;
|
|
26
27
|
placeholder: string;
|
|
27
28
|
optionLabel: string;
|
|
29
|
+
noOptionsMessage: string;
|
|
28
30
|
};
|
|
29
31
|
};
|
|
30
32
|
disabled: {
|
|
@@ -48,6 +50,10 @@ export declare const multiSelectTransferVariants: import("tailwind-variants").TV
|
|
|
48
50
|
dropdownHeader: string;
|
|
49
51
|
filterInput: string;
|
|
50
52
|
optionsList: string;
|
|
53
|
+
noOptionsMessage: string;
|
|
54
|
+
loaderRow: string;
|
|
55
|
+
errorMessage: string;
|
|
56
|
+
loadMoreErrorRow: string;
|
|
51
57
|
optionItem: string;
|
|
52
58
|
optionLabelWrap: string;
|
|
53
59
|
optionLabel: string;
|
|
@@ -78,6 +84,7 @@ export declare const multiSelectTransferVariants: import("tailwind-variants").TV
|
|
|
78
84
|
pillMore: string;
|
|
79
85
|
placeholder: string;
|
|
80
86
|
optionLabel: string;
|
|
87
|
+
noOptionsMessage: string;
|
|
81
88
|
};
|
|
82
89
|
lg: {
|
|
83
90
|
trigger: string;
|
|
@@ -86,6 +93,7 @@ export declare const multiSelectTransferVariants: import("tailwind-variants").TV
|
|
|
86
93
|
pillMore: string;
|
|
87
94
|
placeholder: string;
|
|
88
95
|
optionLabel: string;
|
|
96
|
+
noOptionsMessage: string;
|
|
89
97
|
};
|
|
90
98
|
};
|
|
91
99
|
disabled: {
|
|
@@ -109,6 +117,10 @@ export declare const multiSelectTransferVariants: import("tailwind-variants").TV
|
|
|
109
117
|
dropdownHeader: string;
|
|
110
118
|
filterInput: string;
|
|
111
119
|
optionsList: string;
|
|
120
|
+
noOptionsMessage: string;
|
|
121
|
+
loaderRow: string;
|
|
122
|
+
errorMessage: string;
|
|
123
|
+
loadMoreErrorRow: string;
|
|
112
124
|
optionItem: string;
|
|
113
125
|
optionLabelWrap: string;
|
|
114
126
|
optionLabel: string;
|
|
@@ -139,6 +151,7 @@ export declare const multiSelectTransferVariants: import("tailwind-variants").TV
|
|
|
139
151
|
pillMore: string;
|
|
140
152
|
placeholder: string;
|
|
141
153
|
optionLabel: string;
|
|
154
|
+
noOptionsMessage: string;
|
|
142
155
|
};
|
|
143
156
|
lg: {
|
|
144
157
|
trigger: string;
|
|
@@ -147,6 +160,7 @@ export declare const multiSelectTransferVariants: import("tailwind-variants").TV
|
|
|
147
160
|
pillMore: string;
|
|
148
161
|
placeholder: string;
|
|
149
162
|
optionLabel: string;
|
|
163
|
+
noOptionsMessage: string;
|
|
150
164
|
};
|
|
151
165
|
};
|
|
152
166
|
disabled: {
|
|
@@ -170,6 +184,10 @@ export declare const multiSelectTransferVariants: import("tailwind-variants").TV
|
|
|
170
184
|
dropdownHeader: string;
|
|
171
185
|
filterInput: string;
|
|
172
186
|
optionsList: string;
|
|
187
|
+
noOptionsMessage: string;
|
|
188
|
+
loaderRow: string;
|
|
189
|
+
errorMessage: string;
|
|
190
|
+
loadMoreErrorRow: string;
|
|
173
191
|
optionItem: string;
|
|
174
192
|
optionLabelWrap: string;
|
|
175
193
|
optionLabel: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import type { TLoadOptions, TPrefetch } from "@hooks";
|
|
2
3
|
import type { ITransferListItem } from "../transferList/types";
|
|
3
4
|
export declare enum EMultiSelectTransferSizes {
|
|
4
5
|
MD = "md",
|
|
@@ -6,26 +7,58 @@ export declare enum EMultiSelectTransferSizes {
|
|
|
6
7
|
}
|
|
7
8
|
export type TMultiSelectTransferSize = `${EMultiSelectTransferSizes}`;
|
|
8
9
|
export type TMultiSelectTransferOption = ITransferListItem;
|
|
10
|
+
/**
|
|
11
|
+
* Async option source. Paged: `cursor`, `hasMore` and `total` on the resolved page are all honoured.
|
|
12
|
+
*/
|
|
13
|
+
export type TMultiSelectTransferLoadOptions = TLoadOptions<TMultiSelectTransferOption>;
|
|
9
14
|
export interface IMultiSelectTransferProps {
|
|
15
|
+
/** Unique id for the trigger. A generated id is used when omitted. */
|
|
10
16
|
id?: string;
|
|
17
|
+
/** Custom className for the wrapper. */
|
|
11
18
|
className?: string;
|
|
19
|
+
/** Label displayed above the trigger. */
|
|
12
20
|
label?: ReactNode;
|
|
21
|
+
/** Text shown in the trigger while nothing is selected. @default "Select..." */
|
|
13
22
|
placeholder?: string;
|
|
23
|
+
/** Helper text displayed below the trigger. */
|
|
14
24
|
helperText?: ReactNode;
|
|
25
|
+
/** Display error styling. @default false */
|
|
15
26
|
error?: boolean;
|
|
27
|
+
/** Disable all interaction. @default false */
|
|
16
28
|
disabled?: boolean;
|
|
29
|
+
/** Trigger size variant. @default "md" */
|
|
17
30
|
size?: TMultiSelectTransferSize;
|
|
18
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Options to choose from; treated as the result for the current query in server mode. Ignored (with
|
|
33
|
+
* a dev warning) when `loadOptions` is set — pass `initialOptions` to seed the list instead.
|
|
34
|
+
*/
|
|
35
|
+
options?: TMultiSelectTransferOption[];
|
|
36
|
+
/** Selected options. Passing this makes the component controlled. */
|
|
19
37
|
value?: TMultiSelectTransferOption[];
|
|
38
|
+
/** Fired with the next selection when the dropdown or modal commits. */
|
|
20
39
|
onChange?: (selected: TMultiSelectTransferOption[]) => void;
|
|
40
|
+
/** Seeds/re-syncs dropdown search; semi-controlled — pair with onFilterChange. */
|
|
21
41
|
filterValue?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Debounced search-query callback; also called with "" when the component clears search (dropdown
|
|
44
|
+
* commit/cancel, or opening the transfer list modal).
|
|
45
|
+
*
|
|
46
|
+
* Without `loadOptions`: switches off local filtering — `options` is treated as already filtered
|
|
47
|
+
* for the query — and the fetch, loading state, paging, and response ordering are the consumer's
|
|
48
|
+
* responsibility.
|
|
49
|
+
*
|
|
50
|
+
* With `loadOptions`: notification-only, for analytics or `filterValue` syncing.
|
|
51
|
+
*/
|
|
22
52
|
onFilterChange?: (query: string) => void;
|
|
23
53
|
/** Placeholder for the dropdown filter input and the transfer list modal's panel search inputs. @default "Search..." */
|
|
24
54
|
searchPlaceholder?: string;
|
|
25
|
-
/** Debounce
|
|
55
|
+
/** Debounce for the search query, in both sync and `loadOptions` mode. Set to 0 to disable. @default 300 */
|
|
26
56
|
filterDebounceMs?: number;
|
|
57
|
+
/** Whether more options can be loaded; arms the dropdown's infinite-scroll sentinel. Ignored when `loadOptions` is set. @default false */
|
|
27
58
|
hasMore?: boolean;
|
|
59
|
+
/** Fired when the infinite-scroll sentinel at the bottom of the option list scrolls into view. Ignored when `loadOptions` is set. */
|
|
28
60
|
onLoadMore?: () => void;
|
|
61
|
+
/** Loader replaces rows on search fetch, appends on load-more. OR-ed with the loader's own state, so it still applies in async mode. @default false */
|
|
29
62
|
isLoading?: boolean;
|
|
30
63
|
/** Max pills shown in the trigger before showing "+N More". @default 3 */
|
|
31
64
|
maxVisiblePills?: number;
|
|
@@ -53,4 +86,53 @@ export interface IMultiSelectTransferProps {
|
|
|
53
86
|
cancelLabel?: ReactNode;
|
|
54
87
|
/** Label for the modal commit button. @default "Done" */
|
|
55
88
|
doneLabel?: ReactNode;
|
|
89
|
+
/**
|
|
90
|
+
* Server-side option source. When provided, the component owns the option list, paging, the request
|
|
91
|
+
* lifecycle and the loading state; `options` / `hasMore` / `onLoadMore` / `isLoading` are ignored and
|
|
92
|
+
* `onFilterChange` becomes notification-only. Responsible for mapping the payload to
|
|
93
|
+
* `TMultiSelectTransferOption` — envelopes and domain filtering are the consumer's business. Options
|
|
94
|
+
* are stored exactly as returned, so extra fields survive. A fresh inline arrow is fine: the loader
|
|
95
|
+
* is read through a ref.
|
|
96
|
+
*/
|
|
97
|
+
loadOptions?: TMultiSelectTransferLoadOptions;
|
|
98
|
+
/**
|
|
99
|
+
* Seed rows for a list you already have — an SSR payload, a route loader, a warm cache. They paint on the
|
|
100
|
+
* first frame of both surfaces instead of a loader, and stay put while the baseline fetch revalidates over
|
|
101
|
+
* them (the dropdown's spinner appends below the rows, as it does for any load in flight). They do not
|
|
102
|
+
* suppress that fetch: pair with `prefetch="never"` if the seed is the whole list until the user types.
|
|
103
|
+
* Seed rows carry no cursor, so nothing pages until a real page lands.
|
|
104
|
+
* A *search* replaces them, since seed rows are not results for a query; clearing it brings them back until
|
|
105
|
+
* a fetched baseline does. Async mode only — ignored (dev warning) without `loadOptions`, where the rows
|
|
106
|
+
* belong in `options`.
|
|
107
|
+
*/
|
|
108
|
+
initialOptions?: readonly TMultiSelectTransferOption[];
|
|
109
|
+
/**
|
|
110
|
+
* When to fetch the unfiltered first page.
|
|
111
|
+
* - `"open"` — when the dropdown or the transfer-list modal first opens, whichever comes first.
|
|
112
|
+
* - `"mount"` — at render, so the first open shows rows instead of a loader. The trigger renders its
|
|
113
|
+
* committed chips either way, so this buys latency rather than fixing an empty-looking control.
|
|
114
|
+
* - `"never"` — no baseline at all; fetch only once the user types. For heavy lists.
|
|
115
|
+
*
|
|
116
|
+
* Async mode only — ignored (dev warning) without `loadOptions`, where `options` are already on screen
|
|
117
|
+
* and there is nothing to fetch.
|
|
118
|
+
* @default "open"
|
|
119
|
+
*/
|
|
120
|
+
prefetch?: TPrefetch;
|
|
121
|
+
/** Clearing the search revalidates the cached baseline instead of just restoring it. @default false */
|
|
122
|
+
refetchOnClear?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Identity of the option set, for dependent pickers. When it changes, cached pages are dropped and the
|
|
125
|
+
* list is repopulated. Compose several parents into one scalar. Does NOT clear the selection.
|
|
126
|
+
*/
|
|
127
|
+
optionsKey?: string | number;
|
|
128
|
+
/** Shown in place of the rows when `loadOptions` rejects. @default "Couldn't load options." */
|
|
129
|
+
loadErrorMessage?: ReactNode;
|
|
130
|
+
/** Shown under the loaded rows when a page append rejects; a failed page never blanks the list. @default "Couldn't load more." */
|
|
131
|
+
loadMoreErrorMessage?: ReactNode;
|
|
132
|
+
/** Label for the retry button beside `loadMoreErrorMessage`. @default "Retry" */
|
|
133
|
+
retryLabel?: string;
|
|
134
|
+
/** Shows the reload button in async mode, wired to re-run the current query from page one. @default false */
|
|
135
|
+
showReloadButton?: boolean;
|
|
136
|
+
/** Notified when a load rejects (the component renders the message and swallows it). */
|
|
137
|
+
onLoadError?: (error: unknown) => void;
|
|
56
138
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { TMultiSelectTransferOption } from "./types";
|
|
2
|
+
interface IMultiSelectTransferDraft {
|
|
3
|
+
/** Derived: the loaded pool plus the opening snapshot, minus whatever is in the draft selection. */
|
|
4
|
+
draftAvailable: TMultiSelectTransferOption[];
|
|
5
|
+
/** Owned: the ordered draft selection. Order matters when `reorderable`. */
|
|
6
|
+
draftSelected: TMultiSelectTransferOption[];
|
|
7
|
+
/** Wire to `TransferList`'s onChange; only its second argument is needed. */
|
|
8
|
+
onDraftChange: (nextAvailable: TMultiSelectTransferOption[], nextSelected: TMultiSelectTransferOption[]) => void;
|
|
9
|
+
/** Seed the draft from the committed selection. Call when opening the modal. */
|
|
10
|
+
seedDraft: (committed: TMultiSelectTransferOption[]) => void;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The transfer-list modal's draft, as a **projection** of the loaded option pool rather than a second
|
|
14
|
+
* array kept in sync with it. A paged-in option appears in Available automatically; an option the
|
|
15
|
+
* user moved right is never re-offered; and an `optionsKey` change re-seeds by construction. An
|
|
16
|
+
* option that left Selected but is not in the pool is covered by the opening snapshot, since the
|
|
17
|
+
* only way into the draft is the pool or the committed value.
|
|
18
|
+
*
|
|
19
|
+
* `searchQuery` is the panel's active server query (empty when the search is client-side, where
|
|
20
|
+
* TransferList filters for us); it keeps the snapshot from surfacing an option the server's answer
|
|
21
|
+
* for that query would not have returned.
|
|
22
|
+
*/
|
|
23
|
+
export declare function useMultiSelectTransferDraft(pool: readonly TMultiSelectTransferOption[], isOpen: boolean, searchQuery?: string): IMultiSelectTransferDraft;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type TPrefetch } from "@hooks";
|
|
3
|
+
import type { TMultiSelectTransferLoadOptions, TMultiSelectTransferOption } from "./types";
|
|
4
|
+
interface IUseMultiSelectTransferOptionSourceArgs {
|
|
5
|
+
options?: TMultiSelectTransferOption[];
|
|
6
|
+
loadOptions?: TMultiSelectTransferLoadOptions;
|
|
7
|
+
initialOptions?: readonly TMultiSelectTransferOption[];
|
|
8
|
+
prefetch?: TPrefetch;
|
|
9
|
+
refetchOnClear?: boolean;
|
|
10
|
+
optionsKey?: string | number;
|
|
11
|
+
loadErrorMessage?: ReactNode;
|
|
12
|
+
loadMoreErrorMessage?: ReactNode;
|
|
13
|
+
showReloadButton?: boolean;
|
|
14
|
+
onLoadError?: (error: unknown) => void;
|
|
15
|
+
/** Legacy (consumer-driven) paging and loading. Ignored in async mode. */
|
|
16
|
+
hasMore?: boolean;
|
|
17
|
+
onLoadMore?: () => void;
|
|
18
|
+
isLoading?: boolean;
|
|
19
|
+
onReload?: () => void;
|
|
20
|
+
isReloading?: boolean;
|
|
21
|
+
onFilterChange?: (query: string) => void;
|
|
22
|
+
}
|
|
23
|
+
interface IMultiSelectTransferOptionSource {
|
|
24
|
+
options: readonly TMultiSelectTransferOption[];
|
|
25
|
+
/** The mode decision, made once here — the component must never re-test `loadOptions` itself. */
|
|
26
|
+
isAsync: boolean;
|
|
27
|
+
isServerFiltered: boolean;
|
|
28
|
+
/** Any load in flight — feeds aria-busy on the option list. */
|
|
29
|
+
isLoading: boolean;
|
|
30
|
+
/** Loader INSTEAD of rows: a search/reload fetch, not a page append. */
|
|
31
|
+
isSearchFetch: boolean;
|
|
32
|
+
/** Loader BELOW the rows, and the infinite-scroll observer's in-flight gate. */
|
|
33
|
+
isLoadingMore: boolean;
|
|
34
|
+
hasMore: boolean;
|
|
35
|
+
total: number | undefined;
|
|
36
|
+
onLoadMore?: () => void;
|
|
37
|
+
onRetryLoadMore?: () => void;
|
|
38
|
+
isReloading?: boolean;
|
|
39
|
+
onReload?: () => void;
|
|
40
|
+
onFilterQueryChange: (query: string) => void;
|
|
41
|
+
ensureDefaults: () => void;
|
|
42
|
+
/** Set when the whole list failed. Mutually exclusive with `loadMoreError`. */
|
|
43
|
+
loadError?: ReactNode;
|
|
44
|
+
/** Set when a page append failed. The rows the user was reading stay on screen. */
|
|
45
|
+
loadMoreError?: ReactNode;
|
|
46
|
+
/** Ends legacy load-more mode: typing or clearing means the next fetch replaces rows, not appends. */
|
|
47
|
+
clearLoadMoreMode: () => void;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* MultiSelectTransfer's option-source policy: async vs legacy `options` / `isLoading` / `hasMore` /
|
|
51
|
+
* `onLoadMore`, the replace-vs-append loader question, and the paging trio. In async mode the hook
|
|
52
|
+
* knows the request *kind* directly; the legacy path still needs a ref latch, since `isLoading` is a
|
|
53
|
+
* bare boolean there and the kind has to be inferred from its edges.
|
|
54
|
+
*/
|
|
55
|
+
export declare function useMultiSelectTransferOptionSource({ options, loadOptions, initialOptions, prefetch, refetchOnClear, optionsKey, loadErrorMessage, loadMoreErrorMessage, showReloadButton, onLoadError, hasMore, onLoadMore, isLoading, onReload, isReloading, onFilterChange }: IUseMultiSelectTransferOptionSourceArgs): IMultiSelectTransferOptionSource;
|
|
56
|
+
export {};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { type ReactElement } from "react";
|
|
1
|
+
import { type ReactElement, type RefAttributes } from "react";
|
|
2
2
|
import { type GroupBase } from "react-select";
|
|
3
3
|
import { type IOption, type ISelectProps } from "./types";
|
|
4
4
|
/**
|
|
5
|
-
* Select component for single or multi selection
|
|
5
|
+
* Select component for single or multi selection. The forwarded ref lands on the wrapper `<div>`; the
|
|
6
|
+
* cast is what stops `forwardRef` — whose own signature is not generic — from collapsing `IsMulti` /
|
|
7
|
+
* `Group` to their defaults.
|
|
6
8
|
*/
|
|
7
|
-
export declare
|
|
8
|
-
export declare namespace Select {
|
|
9
|
-
var displayName: string;
|
|
10
|
-
}
|
|
9
|
+
export declare const Select: <IsMulti extends boolean = false, Group extends GroupBase<IOption> = GroupBase<IOption>>(props: ISelectProps<IsMulti, Group> & RefAttributes<HTMLDivElement>) => ReactElement;
|
|
@@ -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
|
|
4
|
-
import { type IOption, type ISelectOptionContext, type
|
|
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;
|
|
@@ -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
|
+
}
|
|
@@ -13,6 +13,8 @@ export declare const selectVariants: import("tailwind-variants").TVReturnType<{
|
|
|
13
13
|
helperText: string;
|
|
14
14
|
menuSearchContainer: string;
|
|
15
15
|
menuSearchInput: string;
|
|
16
|
+
menuLoader: string;
|
|
17
|
+
menuError: string;
|
|
16
18
|
optionLabelWrap: string;
|
|
17
19
|
optionLabel: string;
|
|
18
20
|
optionOverlay: string;
|
|
@@ -31,6 +33,8 @@ export declare const selectVariants: import("tailwind-variants").TVReturnType<{
|
|
|
31
33
|
helperText: string;
|
|
32
34
|
menuSearchContainer: string;
|
|
33
35
|
menuSearchInput: string;
|
|
36
|
+
menuLoader: string;
|
|
37
|
+
menuError: string;
|
|
34
38
|
optionLabelWrap: string;
|
|
35
39
|
optionLabel: string;
|
|
36
40
|
optionOverlay: string;
|
|
@@ -49,6 +53,8 @@ export declare const selectVariants: import("tailwind-variants").TVReturnType<{
|
|
|
49
53
|
helperText: string;
|
|
50
54
|
menuSearchContainer: string;
|
|
51
55
|
menuSearchInput: string;
|
|
56
|
+
menuLoader: string;
|
|
57
|
+
menuError: string;
|
|
52
58
|
optionLabelWrap: string;
|
|
53
59
|
optionLabel: string;
|
|
54
60
|
optionOverlay: string;
|