@cloudwick/astral-ui 8.4.0 → 8.5.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 +2 -2
- package/dist/components/adpIcon/adpIcon.d.ts +7 -2
- package/dist/components/button/button.d.ts +7 -7
- package/dist/components/card/card.d.ts +5 -0
- package/dist/components/card/cardVariants.d.ts +3 -0
- package/dist/components/dataTable/dataTable.d.ts +1 -137
- package/dist/components/dataTable/deriveConfiguredColumns.d.ts +7 -0
- package/dist/components/dataTable/index.d.ts +2 -2
- package/dist/components/dataTable/types.d.ts +135 -2
- package/dist/components/emptyState/emptyStateContent.d.ts +6 -0
- package/dist/components/multiSelectTransfer/multiSelectTransferDropdown.d.ts +8 -6
- package/dist/components/multiSelectTransfer/multiSelectTransferModal.d.ts +4 -1
- package/dist/components/multiSelectTransfer/multiSelectTransferOptionRow.d.ts +5 -4
- package/dist/components/multiSelectTransfer/multiSelectTransferVariants.d.ts +18 -0
- package/dist/components/multiSelectTransfer/types.d.ts +16 -0
- package/dist/components/multiSelectTransfer/useMultiSelectTransferDropdownDraft.d.ts +34 -0
- package/dist/components/scrollbar/index.d.ts +2 -1
- package/dist/components/scrollbar/scrollbar.d.ts +1 -51
- package/dist/components/scrollbar/types.d.ts +52 -0
- package/dist/components/scrollbar/utils.d.ts +28 -0
- package/dist/components/select/selectComponents.d.ts +2 -3
- package/dist/components/select/selectKeyboard.d.ts +1 -1
- package/dist/components/select/types.d.ts +48 -9
- package/dist/components/select/useSelectComponents.d.ts +18 -0
- package/dist/components/select/useSelectDraft.d.ts +53 -0
- package/dist/components/select/useSelectOptionPool.d.ts +27 -0
- package/dist/components/select/utils.d.ts +9 -1
- package/dist/components/textField/textField.d.ts +5 -7
- package/dist/components/toggle/toggle.d.ts +1 -1
- package/dist/components/tooltip/tooltip.d.ts +8 -0
- package/dist/components/transferList/transferListItem.d.ts +6 -1
- package/dist/components/transferList/transferListPanel.d.ts +2 -58
- package/dist/components/transferList/types.d.ts +76 -1
- package/dist/components/transferList/useTransferList.d.ts +14 -5
- package/dist/components/transferList/useTransferListLimit.d.ts +24 -0
- package/dist/components/transferList/useTransferListPanelKeys.d.ts +7 -1
- package/dist/css/index.min.css +1 -1
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/useDeprecationWarning.d.ts +4 -0
- package/dist/hooks/useLiveAnnouncement.d.ts +13 -0
- package/dist/hooks/useSelectionLimit.d.ts +37 -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 +8 -2
- package/dist/utils/elementUtils.d.ts +9 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/optionText.d.ts +10 -0
- package/dist/utils/stringUtils/index.d.ts +2 -0
- package/dist/utils/stringUtils/optionToggled.d.ts +12 -0
- package/dist/utils/stringUtils/selectionLimitReached.d.ts +8 -0
- package/package.json +4 -3
|
@@ -1,57 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
type
|
|
3
|
-
/**
|
|
4
|
-
* Props for the Scrollbar component
|
|
5
|
-
*/
|
|
6
|
-
export interface IScrollbarProps extends Omit<React.HTMLAttributes<HTMLElement>, "as"> {
|
|
7
|
-
/**
|
|
8
|
-
* children to render inside the scroll container
|
|
9
|
-
*/
|
|
10
|
-
children: React.ReactNode;
|
|
11
|
-
/**
|
|
12
|
-
* The type of tag to render for the scroll container, the default value is "div".
|
|
13
|
-
* @default div
|
|
14
|
-
*/
|
|
15
|
-
as?: keyof Omit<JSX.IntrinsicElements, TVoidElements>;
|
|
16
|
-
/**
|
|
17
|
-
* Overwrite the children container styles by passing space separated class names.
|
|
18
|
-
* @optional
|
|
19
|
-
*/
|
|
20
|
-
className?: string;
|
|
21
|
-
/**
|
|
22
|
-
* Pass a boolean value to set the visibility of the scroller, by default the scrollbar will be visible on content hover.
|
|
23
|
-
* @optional
|
|
24
|
-
* @default false
|
|
25
|
-
*/
|
|
26
|
-
alwaysVisible?: boolean;
|
|
27
|
-
/**
|
|
28
|
-
* Set it to true if you want to directly scroll to the click position,
|
|
29
|
-
* by default the scroller will move in the direction of the click
|
|
30
|
-
* @default false
|
|
31
|
-
*/
|
|
32
|
-
scrollToClickPosition?: boolean;
|
|
33
|
-
/**
|
|
34
|
-
* Optional ID for the scrollbar container
|
|
35
|
-
*/
|
|
36
|
-
id?: string;
|
|
37
|
-
/**
|
|
38
|
-
* Optional accessible name for the scroll area. When the content overflows the
|
|
39
|
-
* container becomes keyboard-scrollable; providing this label also promotes it
|
|
40
|
-
* to a discoverable `region` landmark. Leave it unset for incidental scroll
|
|
41
|
-
* areas so they don't clutter landmark navigation.
|
|
42
|
-
*/
|
|
43
|
-
"aria-label"?: string;
|
|
44
|
-
/**
|
|
45
|
-
* Whether overflowing content makes the scroll area a Tab stop. Set it to false when an ancestor
|
|
46
|
-
* already scrolls this content from the keyboard - a listbox moving `aria-activedescendant`, for
|
|
47
|
-
* example - so the area does not add a second, inert stop inside that widget.
|
|
48
|
-
* @default true
|
|
49
|
-
*/
|
|
50
|
-
focusable?: boolean;
|
|
51
|
-
}
|
|
2
|
+
import type { IScrollbarProps } from "./types";
|
|
52
3
|
/**
|
|
53
4
|
* Scrollbar component provides a custom scrollbar with support for both vertical and horizontal scrolling.
|
|
54
5
|
* It includes features like custom styling, touch support, RTL support, and keyboard navigation.
|
|
55
6
|
*/
|
|
56
7
|
export declare const Scrollbar: React.ForwardRefExoticComponent<IScrollbarProps & React.RefAttributes<HTMLElement>>;
|
|
57
|
-
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { HTMLAttributes, ReactNode } from "react";
|
|
2
|
+
type TVoidElements = "area" | "base" | "br" | "col" | "embed" | "hr" | "img" | "input" | "link" | "meta" | "param" | "source" | "track" | "wbr" | "audio" | "video" | "canvas" | "iframe" | "embed" | "object" | "param" | "picture" | "portal" | "svg" | "math" | "svg";
|
|
3
|
+
/**
|
|
4
|
+
* Props for the Scrollbar component
|
|
5
|
+
*/
|
|
6
|
+
export interface IScrollbarProps extends Omit<HTMLAttributes<HTMLElement>, "as"> {
|
|
7
|
+
/**
|
|
8
|
+
* children to render inside the scroll container
|
|
9
|
+
*/
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
/**
|
|
12
|
+
* The type of tag to render for the scroll container, the default value is "div".
|
|
13
|
+
* @default div
|
|
14
|
+
*/
|
|
15
|
+
as?: keyof Omit<JSX.IntrinsicElements, TVoidElements>;
|
|
16
|
+
/**
|
|
17
|
+
* Overwrite the children container styles by passing space separated class names.
|
|
18
|
+
* @optional
|
|
19
|
+
*/
|
|
20
|
+
className?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Pass a boolean value to set the visibility of the scroller, by default the scrollbar will be visible on content hover.
|
|
23
|
+
* @optional
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
alwaysVisible?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Set it to true if you want to directly scroll to the click position,
|
|
29
|
+
* by default the scroller will move in the direction of the click
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
scrollToClickPosition?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Optional ID for the scrollbar container
|
|
35
|
+
*/
|
|
36
|
+
id?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Optional accessible name for the scroll area. When the content overflows the
|
|
39
|
+
* container becomes keyboard-scrollable; providing this label also promotes it
|
|
40
|
+
* to a discoverable `region` landmark. Leave it unset for incidental scroll
|
|
41
|
+
* areas so they don't clutter landmark navigation.
|
|
42
|
+
*/
|
|
43
|
+
"aria-label"?: string;
|
|
44
|
+
/**
|
|
45
|
+
* Whether overflowing content makes the scroll area a Tab stop. Set it to false when an ancestor
|
|
46
|
+
* already scrolls this content from the keyboard - a listbox moving `aria-activedescendant`, for
|
|
47
|
+
* example - so the area does not add a second, inert stop inside that widget.
|
|
48
|
+
* @default true
|
|
49
|
+
*/
|
|
50
|
+
focusable?: boolean;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
@@ -14,3 +14,31 @@ export declare const resetCursor: () => void;
|
|
|
14
14
|
* @param scrollProp - The axis to scroll along, either "top" or "left".
|
|
15
15
|
*/
|
|
16
16
|
export declare const handleScrollToHelper: (element: HTMLDivElement, scrollToOffset: number, scrollProp: "top" | "left") => void;
|
|
17
|
+
type TScrollAxis = "X" | "Y";
|
|
18
|
+
interface IPoint {
|
|
19
|
+
clientX: number;
|
|
20
|
+
clientY: number;
|
|
21
|
+
}
|
|
22
|
+
/** Where a thumb drag started: the content's scroll offsets and the pointer position. */
|
|
23
|
+
export interface IThumbDragStart {
|
|
24
|
+
top: number;
|
|
25
|
+
left: number;
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Scrolls the content so the thumb follows a drag from `start` to `point`. The pointer distance is
|
|
31
|
+
* scaled by the content-to-viewport ratio, since the thumb moves along a track the viewport's size.
|
|
32
|
+
*/
|
|
33
|
+
export declare const scrollWithThumbDrag: (content: HTMLDivElement, start: IThumbDragStart, point: IPoint, axis: TScrollAxis) => void;
|
|
34
|
+
interface ITrackClickOptions {
|
|
35
|
+
axis: TScrollAxis;
|
|
36
|
+
isRtl: boolean;
|
|
37
|
+
/** Jump to the clicked position instead of paging half a viewport toward it. */
|
|
38
|
+
toClickPosition: boolean;
|
|
39
|
+
}
|
|
40
|
+
/** Scrolls the content for a click on a scrollbar track: to the clicked position, or half a viewport toward it. */
|
|
41
|
+
export declare const scrollForTrackClick: (content: HTMLDivElement, track: HTMLDivElement, thumb: HTMLDivElement, point: IPoint, { axis, isRtl, toClickPosition }: ITrackClickOptions) => void;
|
|
42
|
+
/** Scrolls the content for an arrow, Page Up/Down, Home or End key. Other keys are ignored. */
|
|
43
|
+
export declare const scrollForKey: (content: HTMLDivElement, key: string) => void;
|
|
44
|
+
export {};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type ReactElement } from "react";
|
|
3
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";
|
|
4
|
+
import { type IOption, type ISelectOptionContext, type ISelectComponentsConfig, type ISelectIcons } from "./types";
|
|
5
|
+
export declare const SelectIconsContext: React.Context<ISelectIcons>;
|
|
5
6
|
export declare const SelectOptionContext: React.Context<ISelectOptionContext>;
|
|
6
7
|
/**
|
|
7
8
|
* A single dropdown option (handles Select All, multi-select checkboxes, and the selected
|
|
@@ -34,8 +35,6 @@ export declare function createSelectComponents<IsMulti extends boolean = false,
|
|
|
34
35
|
*
|
|
35
36
|
* Built apart from the components above, on `maxVisibleValues` alone: react-select unmounts and
|
|
36
37
|
* 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
38
|
*/
|
|
40
39
|
export declare function createSelectInput<IsMulti extends boolean = false, Group extends GroupBase<IOption> = GroupBase<IOption>>(maxVisibleValues: number): (props: InputProps<IOption, IsMulti, Group>) => ReactElement;
|
|
41
40
|
/** react-select renders a separator between the indicators; this component has none. */
|
|
@@ -3,7 +3,7 @@ import { type ISelectMenuContext } from "./types";
|
|
|
3
3
|
/** What the shared handler leaves for its caller to do. */
|
|
4
4
|
export type TSelectKeyOutcome = "handled" | "navigate" | "ignored";
|
|
5
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" | "menuNodeRef" | "searchable" | "searchInputRef" | "isLoading" | "loadError" | "
|
|
6
|
+
export type TSelectKeyContext = Pick<ISelectMenuContext, "closeMenu" | "commitAndClose" | "containerRef" | "menuNodeRef" | "searchable" | "searchInputRef" | "isLoading" | "loadError" | "onLimitBlockedPick">;
|
|
7
7
|
/** The refs that locate the two inputs focus can live in. */
|
|
8
8
|
export type TSelectFocusRefs = Pick<ISelectMenuContext, "searchInputRef" | "containerRef">;
|
|
9
9
|
/**
|
|
@@ -65,9 +65,29 @@ export interface ISelectProps<IsMulti extends boolean = false, Group extends Gro
|
|
|
65
65
|
maxVisibleValuesMsg?: string;
|
|
66
66
|
/** Custom footer in menu */
|
|
67
67
|
menuFooter?: ReactNode;
|
|
68
|
-
/**
|
|
68
|
+
/**
|
|
69
|
+
* Renders the "Select All" row in a multi-select menu. Always hidden while `maxSelected` is set, since
|
|
70
|
+
* selecting everything could not be honoured. Multi-select only.
|
|
71
|
+
* @default true
|
|
72
|
+
*/
|
|
73
|
+
showSelectAll?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* The most options a multi-select draft may hold. Once reached, every unchecked option is disabled
|
|
76
|
+
* (and the Create row withheld) until one is unchecked; a value already over the limit is left as it
|
|
77
|
+
* is. Must be a positive integer — anything else is ignored with a dev warning. Multi-select only.
|
|
78
|
+
*/
|
|
79
|
+
maxSelected?: number;
|
|
80
|
+
/** Screen-reader announcement when `maxSelected` is reached. @default "Selection limit of {maxSelected} reached" */
|
|
81
|
+
maxSelectedMessage?: string;
|
|
82
|
+
/**
|
|
83
|
+
* Prefix icon for the control. Pass an icon from `@cloudwick/icons`; a string icon name (`TIconType`)
|
|
84
|
+
* is deprecated and will be removed in the next major.
|
|
85
|
+
*/
|
|
69
86
|
prefixIcon?: TIconType | ReactNode;
|
|
70
|
-
/**
|
|
87
|
+
/**
|
|
88
|
+
* Suffix icon for the control. Pass an icon from `@cloudwick/icons`; a string icon name (`TIconType`)
|
|
89
|
+
* is deprecated and will be removed in the next major.
|
|
90
|
+
*/
|
|
71
91
|
suffixIcon?: TIconType | ReactNode;
|
|
72
92
|
/**
|
|
73
93
|
* Renders the search input inside the dropdown. With `false` the menu opens straight onto the option
|
|
@@ -187,6 +207,11 @@ export interface ISelectOptionContext {
|
|
|
187
207
|
* even with every visible row ticked.
|
|
188
208
|
*/
|
|
189
209
|
areAllSelected?: boolean;
|
|
210
|
+
/**
|
|
211
|
+
* Whether the option is disabled by `maxSelected` alone (the draft is at the limit and does not hold
|
|
212
|
+
* it), rather than by its own `isDisabled` or the consumer's `isOptionDisabled`.
|
|
213
|
+
*/
|
|
214
|
+
isLimitBlocked?: (option: IOption) => boolean;
|
|
190
215
|
/** Toggle a single option in the multi-select draft. */
|
|
191
216
|
onToggleDraftOption?: (option: IOption) => void;
|
|
192
217
|
/** Toggle Select All / Deselect All on the multi-select draft (shared with the keyboard path). */
|
|
@@ -198,11 +223,12 @@ export interface ISelectOptionContext {
|
|
|
198
223
|
/** tv() class for the hover/focus full-text overlay. */
|
|
199
224
|
optionOverlayClass: string;
|
|
200
225
|
/**
|
|
201
|
-
* Latest input modality, shared across every option. The
|
|
202
|
-
* (local `isHovered`) while the user is using the mouse, and
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
226
|
+
* Latest input modality, shared across every option. The highlighted row (its tint and full-text
|
|
227
|
+
* overlay) follows the pointer (local `isHovered`) while the user is using the mouse, and
|
|
228
|
+
* react-select's `isFocused` while they're using the keyboard, which alone also draws the focus
|
|
229
|
+
* glow. Without this, react-select's `isFocused` - which lingers on the last-focused option after
|
|
230
|
+
* the pointer leaves, and is also set by mouse hover - keeps a row highlighted after the mouse
|
|
231
|
+
* has moved away (and shows two at once mid-transition).
|
|
206
232
|
*
|
|
207
233
|
* State on the Select, not a shared ref: this decides what an option renders, and writing a ref
|
|
208
234
|
* schedules no re-render. Setting the mode it already holds is a no-op React bails out of, so
|
|
@@ -232,10 +258,17 @@ export interface ISelectMenuContext {
|
|
|
232
258
|
searchPlaceholder: string;
|
|
233
259
|
/** Optional custom footer rendered below the option list. */
|
|
234
260
|
menuFooter?: ReactNode;
|
|
261
|
+
/**
|
|
262
|
+
* Polite announcement of the last multi-select draft change (a tick, an untick, "Select All", or the
|
|
263
|
+
* limit refusing a tick). `undefined` for a single-select, which leaves its live region out of the menu.
|
|
264
|
+
*/
|
|
265
|
+
draftAnnouncement?: string;
|
|
235
266
|
/** Close the menu, discarding the multi-select draft. */
|
|
236
267
|
closeMenu: () => void;
|
|
237
268
|
/** Commit the multi-select draft, then close. */
|
|
238
269
|
commitAndClose: () => void;
|
|
270
|
+
/** Announces the limit; called for Enter on a row the limit alone has disabled, which react-select ignores. */
|
|
271
|
+
onLimitBlockedPick?: () => void;
|
|
239
272
|
/** tv() class for the search container. */
|
|
240
273
|
searchContainerClass: string;
|
|
241
274
|
/** tv() class for the search input. */
|
|
@@ -260,7 +293,7 @@ export interface ISelectMenuContext {
|
|
|
260
293
|
isReloading?: boolean;
|
|
261
294
|
/** Reload-button tooltip / aria-label. */
|
|
262
295
|
reloadTooltip?: string;
|
|
263
|
-
/** Records the input modality (see {@link ISelectOptionContext.interactionMode}); set to "keyboard"
|
|
296
|
+
/** Records the input modality (see {@link ISelectOptionContext.interactionMode}); set to "keyboard" by any menu key. */
|
|
264
297
|
onInteractionMode: (mode: TSelectInteractionMode) => void;
|
|
265
298
|
}
|
|
266
299
|
/** What the in-menu search box exposes about the rendered list, read from react-select's DOM. */
|
|
@@ -283,9 +316,15 @@ export interface ITruncatedMultiValueProps {
|
|
|
283
316
|
/** react-select's rendered chip (MultiValueContainer + label + remove). */
|
|
284
317
|
chip: ReactElement;
|
|
285
318
|
}
|
|
286
|
-
|
|
319
|
+
/**
|
|
320
|
+
* The control's prefix/suffix icons, read by ValueContainer through context so a fresh icon element
|
|
321
|
+
* re-renders it in place: react-select remounts a custom component whose reference changed.
|
|
322
|
+
*/
|
|
323
|
+
export interface ISelectIcons {
|
|
287
324
|
prefixIcon?: TIconType | ReactNode;
|
|
288
325
|
suffixIcon?: TIconType | ReactNode;
|
|
326
|
+
}
|
|
327
|
+
export interface ISelectComponentsConfig {
|
|
289
328
|
maxVisibleValues: number;
|
|
290
329
|
maxVisibleValuesMsg?: string;
|
|
291
330
|
disabled: boolean;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { GroupBase } from "react-select";
|
|
2
|
+
import { SelectOption } from "./selectComponents";
|
|
3
|
+
import { SelectMenu } from "./selectMenu";
|
|
4
|
+
import type { IOption, ISelectComponentsConfig } from "./types";
|
|
5
|
+
/**
|
|
6
|
+
* The custom components handed to react-select. Each keeps a stable identity across renders, because
|
|
7
|
+
* react-select remounts a custom component whose identity changed.
|
|
8
|
+
*/
|
|
9
|
+
export declare function useSelectComponents<IsMulti extends boolean, Group extends GroupBase<IOption>>({ maxVisibleValues, maxVisibleValuesMsg, disabled }: ISelectComponentsConfig): {
|
|
10
|
+
IndicatorSeparator: () => null;
|
|
11
|
+
Option: typeof SelectOption;
|
|
12
|
+
Input: (props: import("react-select").InputProps<IOption, IsMulti, Group>) => import("react").ReactElement;
|
|
13
|
+
Menu: typeof SelectMenu;
|
|
14
|
+
DropdownIndicator: (props: import("react-select").DropdownIndicatorProps<IOption, IsMulti, Group>) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
ValueContainer: ({ children, ...props }: import("react-select").ValueContainerProps<IOption, IsMulti, Group>) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
MultiValue: (props: import("react-select").MultiValueProps<IOption>) => import("react/jsx-runtime").JSX.Element | null;
|
|
17
|
+
MultiValueRemove: (props: import("react-select").MultiValueRemoveProps<IOption, IsMulti, Group>) => import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
import type { GroupBase, PropsValue } from "react-select";
|
|
3
|
+
import type { IOption, TSelectOptions } from "./types";
|
|
4
|
+
type TSelectValue = PropsValue<IOption> | undefined;
|
|
5
|
+
type TOnChange = (...args: unknown[]) => void;
|
|
6
|
+
export declare const SELECT_ALL_OPTION: IOption;
|
|
7
|
+
interface IUseSelectDraftArgs<Group extends GroupBase<IOption>> {
|
|
8
|
+
isMulti: boolean;
|
|
9
|
+
/** The consumer's `value`; the Select is controlled while it is defined. */
|
|
10
|
+
value: TSelectValue;
|
|
11
|
+
defaultValue: TSelectValue;
|
|
12
|
+
menuOpen: boolean;
|
|
13
|
+
maxSelected?: number;
|
|
14
|
+
maxSelectedMessage?: string;
|
|
15
|
+
/** The consumer's `showSelectAll`, undefined when not passed. */
|
|
16
|
+
showSelectAll?: boolean;
|
|
17
|
+
onChange?: TOnChange;
|
|
18
|
+
/** Every row the Select offers, before the Select-All row is added. */
|
|
19
|
+
pooledOptions: TSelectOptions<Group>;
|
|
20
|
+
/** The enabled rows on screen, which Select All acts on. */
|
|
21
|
+
visibleSelectable: IOption[];
|
|
22
|
+
/** The consumer's `isOptionDisabled`. */
|
|
23
|
+
isOptionDisabled?: (option: IOption, selectValue: readonly IOption[]) => boolean;
|
|
24
|
+
rememberCreatedOption: (option: IOption) => void;
|
|
25
|
+
/** Speaks a draft change through the menu's polite region. */
|
|
26
|
+
announce: (message: string) => void;
|
|
27
|
+
closeMenu: () => void;
|
|
28
|
+
resetFilter: () => void;
|
|
29
|
+
containerRef: RefObject<HTMLDivElement>;
|
|
30
|
+
/** Puts focus back on the input the menu is driven from. */
|
|
31
|
+
refocusMenuInput: () => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The multi-select draft: while the menu is open, ticks update a draft instead of calling `onChange`,
|
|
35
|
+
* and the draft is committed when the menu closes with the selection intact (an outside click or Tab).
|
|
36
|
+
* Escape discards it. Also owns `maxSelected`, the polite announcement of every tick, and the routing
|
|
37
|
+
* of react-select's `onChange` for both modes.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useSelectDraft<Group extends GroupBase<IOption>>({ isMulti, value, defaultValue, menuOpen, maxSelected, maxSelectedMessage, showSelectAll, onChange: externalOnChange, pooledOptions, visibleSelectable, isOptionDisabled: externalIsOptionDisabled, rememberCreatedOption, announce, closeMenu, resetFilter, containerRef, refocusMenuInput }: IUseSelectDraftArgs<Group>): {
|
|
40
|
+
multiControlValue: PropsValue<IOption> | undefined;
|
|
41
|
+
draftValues: Set<any> | undefined;
|
|
42
|
+
areAllSelected: boolean;
|
|
43
|
+
isCapped: boolean;
|
|
44
|
+
isLimitBlocked: (option: IOption) => boolean;
|
|
45
|
+
selectOptions: TSelectOptions<Group>;
|
|
46
|
+
isOptionDisabled: (option: IOption, selectValue: readonly IOption[]) => boolean;
|
|
47
|
+
announceLimitBlocked: () => void;
|
|
48
|
+
commitDraft: () => void;
|
|
49
|
+
toggleDraftOption: (option: IOption) => void;
|
|
50
|
+
handleSelectAllDraft: () => void;
|
|
51
|
+
handleChange: (newValue: unknown, actionMeta: unknown) => void;
|
|
52
|
+
};
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { FilterOptionOption, GroupBase } from "react-select";
|
|
2
|
+
import type { IOption, ISelectProps, TSelectOptions } from "./types";
|
|
3
|
+
interface IUseSelectOptionPoolArgs<Group extends GroupBase<IOption>> {
|
|
4
|
+
/** The options the source resolved (consumer `options` or the async loader's). */
|
|
5
|
+
options: TSelectOptions<Group>;
|
|
6
|
+
isServerFiltered: boolean;
|
|
7
|
+
/** The debounced query the list is narrowed by. */
|
|
8
|
+
filterQuery: string;
|
|
9
|
+
filterOption: ISelectProps<boolean, Group>["filterOption"];
|
|
10
|
+
getOptionLabel?: (option: IOption) => string;
|
|
11
|
+
getOptionValue?: (option: IOption) => string;
|
|
12
|
+
searchable: boolean;
|
|
13
|
+
filterValue?: string;
|
|
14
|
+
onFilterChange?: (query: string) => void;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* The rows a Select offers and which of them the query leaves visible: the consumer's options plus the
|
|
18
|
+
* ones the user created, the resolved row predicate, and the enabled rows on screen that Select All
|
|
19
|
+
* acts on.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useSelectOptionPool<Group extends GroupBase<IOption>>({ options, isServerFiltered, filterQuery, filterOption: externalFilterOption, getOptionLabel, getOptionValue, searchable, filterValue, onFilterChange }: IUseSelectOptionPoolArgs<Group>): {
|
|
22
|
+
pooledOptions: TSelectOptions<Group>;
|
|
23
|
+
rememberCreatedOption: (option: IOption) => void;
|
|
24
|
+
filterOption: (candidate: FilterOptionOption<IOption>, input: string) => boolean;
|
|
25
|
+
visibleSelectable: IOption[];
|
|
26
|
+
};
|
|
27
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type StylesConfig, type GroupBase } from "react-select";
|
|
1
|
+
import { type AriaOnChangeProps, type StylesConfig, type GroupBase } from "react-select";
|
|
2
2
|
import { type TSelectSize, type IOption } from "./types";
|
|
3
3
|
export declare const SELECT_ALL_VALUE = "select-all";
|
|
4
4
|
export declare const isCreateOption: (option: IOption) => boolean;
|
|
@@ -7,3 +7,11 @@ export declare const getSelectableOptions: (options: readonly (IOption | GroupBa
|
|
|
7
7
|
export declare const getPooledValues: (options: readonly (IOption | GroupBase<IOption>)[]) => Set<IOption["value"]>;
|
|
8
8
|
export declare const areAllSelectableSelected: (selectable: readonly IOption[], draftValues: ReadonlySet<IOption["value"]>) => boolean;
|
|
9
9
|
export declare const reactSelectCustomStyles: <IsMulti extends boolean, Group extends GroupBase<IOption>>(error: boolean, size: TSelectSize, multiSelect: boolean) => StylesConfig<IOption, IsMulti, Group>;
|
|
10
|
+
/**
|
|
11
|
+
* The multi-select's spoken message for a react-select value change. Ticking or unticking an option edits
|
|
12
|
+
* the menu's draft, not the value react-select holds, so react-select's own "selected"/"deselected" would
|
|
13
|
+
* describe the wrong list; those are left silent and Select announces the draft's outcome itself. Every
|
|
14
|
+
* other action keeps react-select's default wording, except Enter on an option disabled by the limit alone
|
|
15
|
+
* (`isLimitBlocked`): Select speaks the limit for that one, so the "disabled" wording is left silent.
|
|
16
|
+
*/
|
|
17
|
+
export declare function multiSelectChangeMessage(props: AriaOnChangeProps<IOption, boolean>, isLimitBlocked?: (option: IOption) => boolean): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
|
-
import { type TIconType } from "../adpIcon";
|
|
3
|
+
import { type TIconType } from "../adpIcon/adpIcon";
|
|
4
4
|
type TSize = "md" | "lg";
|
|
5
5
|
export interface ITextFieldProps extends Omit<React.ComponentPropsWithoutRef<"input">, "css" | "size"> {
|
|
6
6
|
/**
|
|
@@ -27,17 +27,15 @@ export interface ITextFieldProps extends Omit<React.ComponentPropsWithoutRef<"in
|
|
|
27
27
|
/**
|
|
28
28
|
* Icon to be displayed before the input.
|
|
29
29
|
* @description
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* - If a ReactNode is provided, it will be rendered as-is.
|
|
30
|
+
* Pass an icon from `@cloudwick/icons`; the node is rendered as-is. A string icon name
|
|
31
|
+
* (`TIconType`) still renders an ADPIcon but is deprecated and will be removed in the next major.
|
|
33
32
|
*/
|
|
34
33
|
prefixIcon?: TIconType | ReactNode;
|
|
35
34
|
/**
|
|
36
35
|
* Icon to be displayed after the input.
|
|
37
36
|
* @description
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* - If a ReactNode is provided, it will be rendered as-is.
|
|
37
|
+
* Pass an icon from `@cloudwick/icons`; the node is rendered as-is. A string icon name
|
|
38
|
+
* (`TIconType`) still renders an ADPIcon but is deprecated and will be removed in the next major.
|
|
41
39
|
*/
|
|
42
40
|
suffixIcon?: TIconType | ReactNode;
|
|
43
41
|
}
|
|
@@ -53,6 +53,14 @@ export interface ITooltipProps extends React.HTMLAttributes<HTMLDivElement> {
|
|
|
53
53
|
* describe its trigger is also hidden from assistive technology and stays a purely visual hint.
|
|
54
54
|
*/
|
|
55
55
|
describeTrigger?: boolean;
|
|
56
|
+
/**
|
|
57
|
+
* Accessible name for a non-interactive trigger such as a bare icon. When set, the synthesized
|
|
58
|
+
* wrapper becomes a native `<button>` named by this label, and activating it (keyboard, mouse or
|
|
59
|
+
* screen reader) opens the tooltip without toggling it closed. Ignored when the trigger is
|
|
60
|
+
* interactive (it names itself), when `canOpen` is `false`, and on a hover tooltip with
|
|
61
|
+
* `focusable={false}`, whose wrapper is not a tab stop.
|
|
62
|
+
*/
|
|
63
|
+
triggerLabel?: string;
|
|
56
64
|
}
|
|
57
65
|
export declare const Tooltip: React.ForwardRefExoticComponent<ITooltipProps & React.RefAttributes<HTMLDivElement>>;
|
|
58
66
|
export {};
|
|
@@ -13,6 +13,11 @@ interface ITransferListItemProps {
|
|
|
13
13
|
active: boolean;
|
|
14
14
|
reorderable: boolean;
|
|
15
15
|
disabled: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Disabled only for now, by the selection limit: the drag handle keeps its space (hidden) so the row
|
|
18
|
+
* does not shift each time the limit is reached or cleared.
|
|
19
|
+
*/
|
|
20
|
+
isLimitBlocked?: boolean;
|
|
16
21
|
isFirst: boolean;
|
|
17
22
|
isLast: boolean;
|
|
18
23
|
showTopIndicator: boolean;
|
|
@@ -33,7 +38,7 @@ interface ITransferListItemProps {
|
|
|
33
38
|
* A single transfer list row: drag handle + position badge (selected, reorderable
|
|
34
39
|
* only), checkbox, label, and remove / reorder controls.
|
|
35
40
|
*/
|
|
36
|
-
export declare function TransferListItem({ item, panel, index, setSize, id, checked, active, reorderable, disabled, isFirst, isLast, showTopIndicator, showBottomIndicator, isPeekDismissed, onToggle, onRemove, onMoveUp, onMoveDown, onDragStart, onDragEnd, onDragOver, onDrop, onMouseEnter }: ITransferListItemProps): React.ReactElement;
|
|
41
|
+
export declare function TransferListItem({ item, panel, index, setSize, id, checked, active, reorderable, disabled, isLimitBlocked, isFirst, isLast, showTopIndicator, showBottomIndicator, isPeekDismissed, onToggle, onRemove, onMoveUp, onMoveDown, onDragStart, onDragEnd, onDragOver, onDrop, onMouseEnter }: ITransferListItemProps): React.ReactElement;
|
|
37
42
|
export declare namespace TransferListItem {
|
|
38
43
|
var displayName: string;
|
|
39
44
|
}
|
|
@@ -1,66 +1,10 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import type {
|
|
3
|
-
interface ITransferListPanelProps {
|
|
4
|
-
panel: TTransferPanel;
|
|
5
|
-
title: React.ReactNode;
|
|
6
|
-
items: ITransferListItem[];
|
|
7
|
-
reorderable: boolean;
|
|
8
|
-
disabled: boolean;
|
|
9
|
-
emptyText: React.ReactNode;
|
|
10
|
-
searchable: boolean;
|
|
11
|
-
searchValue: string;
|
|
12
|
-
searchPlaceholder: string;
|
|
13
|
-
onSearchChange: (query: string) => void;
|
|
14
|
-
headerSlot?: React.ReactNode;
|
|
15
|
-
reloadTooltip?: string;
|
|
16
|
-
onReload?: () => void;
|
|
17
|
-
isReloading?: boolean;
|
|
18
|
-
hasMore?: boolean;
|
|
19
|
-
onLoadMore?: () => void;
|
|
20
|
-
isLoadingMore?: boolean;
|
|
21
|
-
/** Loader REPLACES the rows (a search/refresh fetch, not a page append). */
|
|
22
|
-
isLoading?: boolean;
|
|
23
|
-
/** The search has a query its rows do not answer yet, so the result count is not announced. */
|
|
24
|
-
isSearchPending?: boolean;
|
|
25
|
-
/** Replaces the rows when set: the panel's source failed to load. */
|
|
26
|
-
loadError?: React.ReactNode;
|
|
27
|
-
/** Shown under the loaded rows when a page append failed; renders a retry button. */
|
|
28
|
-
loadMoreError?: React.ReactNode;
|
|
29
|
-
/** Fired by the retry button under `loadMoreError`. */
|
|
30
|
-
onRetryLoadMore?: () => void;
|
|
31
|
-
/** Label for that retry button. */
|
|
32
|
-
retryLabel?: string;
|
|
33
|
-
/** Server-side total; the header count becomes "(loaded of total)". */
|
|
34
|
-
totalCount?: number;
|
|
35
|
-
selectAllChecked: boolean;
|
|
36
|
-
selectAllIndeterminate: boolean;
|
|
37
|
-
/** Search-visible, non-disabled row count — the scope the select-all checkbox acts on. */
|
|
38
|
-
selectAllCount: number;
|
|
39
|
-
onToggleSelectAll: () => void;
|
|
40
|
-
moveLabel: string;
|
|
41
|
-
moveCount: number;
|
|
42
|
-
moveDisabled: boolean;
|
|
43
|
-
moveIconSide: "left" | "right";
|
|
44
|
-
onMove: () => void;
|
|
45
|
-
isChecked: (value: TTransferListValue) => boolean;
|
|
46
|
-
onToggle: (value: TTransferListValue) => void;
|
|
47
|
-
onRemove?: (value: TTransferListValue) => void;
|
|
48
|
-
onMoveUp?: (index: number) => void;
|
|
49
|
-
onMoveDown?: (index: number) => void;
|
|
50
|
-
dropIndex: number | null;
|
|
51
|
-
showDropOverlay: boolean;
|
|
52
|
-
onItemDragStart: (e: React.DragEvent, value: TTransferListValue) => void;
|
|
53
|
-
onItemDragEnd: () => void;
|
|
54
|
-
onItemDragOver: (e: React.DragEvent, index: number) => void;
|
|
55
|
-
onListDragOver: (e: React.DragEvent) => void;
|
|
56
|
-
onListDrop: (e: React.DragEvent) => void;
|
|
57
|
-
}
|
|
2
|
+
import type { ITransferListPanelProps } from "./types";
|
|
58
3
|
/**
|
|
59
4
|
* One panel of the transfer list: header (title, count, optional reload),
|
|
60
5
|
* optional search + header slot, and a scrollable list of rows or an empty state.
|
|
61
6
|
*/
|
|
62
|
-
export declare function TransferListPanel({ panel, title, items, reorderable, disabled, emptyText, searchable, searchValue, searchPlaceholder, onSearchChange, headerSlot, reloadTooltip, onReload, isReloading, hasMore, onLoadMore, isLoadingMore, isLoading, isSearchPending, 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;
|
|
7
|
+
export declare function TransferListPanel({ panel, title, items, reorderable, disabled, emptyText, searchable, searchValue, searchPlaceholder, onSearchChange, headerSlot, reloadTooltip, onReload, isReloading, hasMore, onLoadMore, isLoadingMore, isLoading, isSearchPending, loadError, loadMoreError, onRetryLoadMore, retryLabel, totalCount, showSelectAll, selectAllChecked, selectAllIndeterminate, selectAllCount, onToggleSelectAll, moveLabel, moveCount, moveDisabled, moveIconSide, onMove, isChecked, onToggle, isItemBlocked, onRemove, onMoveUp, onMoveDown, dropIndex, showDropOverlay, onItemDragStart, onItemDragEnd, onItemDragOver, onListDragOver, onListDrop }: ITransferListPanelProps): React.ReactElement;
|
|
63
8
|
export declare namespace TransferListPanel {
|
|
64
9
|
var displayName: string;
|
|
65
10
|
}
|
|
66
|
-
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReactNode } from "react";
|
|
1
|
+
import type { DragEvent, ReactNode } from "react";
|
|
2
2
|
import type { TLoadOptions, TPrefetch } from "@hooks";
|
|
3
3
|
/**
|
|
4
4
|
* `TPrefetch` minus `"open"`: the panel's list is always visible, so it has no open event to hang a
|
|
@@ -74,6 +74,21 @@ export interface ITransferListProps {
|
|
|
74
74
|
moveToAvailableLabel?: string;
|
|
75
75
|
/** Enable drag handles, position badges and up/down arrows on the selected panel. @default false */
|
|
76
76
|
reorderable?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Renders each panel's "Select all" checkbox. While `maxSelected` is set the Available panel's is
|
|
79
|
+
* always hidden, since checking everything could exceed the limit; the Selected panel's stays.
|
|
80
|
+
* @default true
|
|
81
|
+
*/
|
|
82
|
+
showSelectAll?: boolean;
|
|
83
|
+
/**
|
|
84
|
+
* The most items the Selected panel may hold. Available rows can be checked only while the checked
|
|
85
|
+
* rows still fit, after which every unchecked Available row is disabled; moves and drags into Selected
|
|
86
|
+
* stop at the limit. Removing is never restricted, and a `selectedItems` already over the limit is
|
|
87
|
+
* left as it is. Must be a positive integer — anything else is ignored with a dev warning.
|
|
88
|
+
*/
|
|
89
|
+
maxSelected?: number;
|
|
90
|
+
/** Screen-reader announcement when `maxSelected` is reached. @default "Selection limit of {maxSelected} reached" */
|
|
91
|
+
maxSelectedMessage?: string;
|
|
77
92
|
/** Tooltip for the transfer list reload button. */
|
|
78
93
|
reloadTooltip?: string;
|
|
79
94
|
/** Fired when the reload button is clicked. */
|
|
@@ -150,3 +165,63 @@ export interface ITransferListProps {
|
|
|
150
165
|
selectedEmptyText?: ReactNode;
|
|
151
166
|
className?: string;
|
|
152
167
|
}
|
|
168
|
+
/** Props of one TransferList panel; internal to the component. */
|
|
169
|
+
export interface ITransferListPanelProps {
|
|
170
|
+
panel: TTransferPanel;
|
|
171
|
+
title: ReactNode;
|
|
172
|
+
items: ITransferListItem[];
|
|
173
|
+
reorderable: boolean;
|
|
174
|
+
disabled: boolean;
|
|
175
|
+
emptyText: ReactNode;
|
|
176
|
+
searchable: boolean;
|
|
177
|
+
searchValue: string;
|
|
178
|
+
searchPlaceholder: string;
|
|
179
|
+
onSearchChange: (query: string) => void;
|
|
180
|
+
headerSlot?: ReactNode;
|
|
181
|
+
reloadTooltip?: string;
|
|
182
|
+
onReload?: () => void;
|
|
183
|
+
isReloading?: boolean;
|
|
184
|
+
hasMore?: boolean;
|
|
185
|
+
onLoadMore?: () => void;
|
|
186
|
+
isLoadingMore?: boolean;
|
|
187
|
+
/** Loader REPLACES the rows (a search/refresh fetch, not a page append). */
|
|
188
|
+
isLoading?: boolean;
|
|
189
|
+
/** The search has a query its rows do not answer yet, so the result count is not announced. */
|
|
190
|
+
isSearchPending?: boolean;
|
|
191
|
+
/** Replaces the rows when set: the panel's source failed to load. */
|
|
192
|
+
loadError?: ReactNode;
|
|
193
|
+
/** Shown under the loaded rows when a page append failed; renders a retry button. */
|
|
194
|
+
loadMoreError?: ReactNode;
|
|
195
|
+
/** Fired by the retry button under `loadMoreError`. */
|
|
196
|
+
onRetryLoadMore?: () => void;
|
|
197
|
+
/** Label for that retry button. */
|
|
198
|
+
retryLabel?: string;
|
|
199
|
+
/** Server-side total; the header count becomes "(loaded of total)". */
|
|
200
|
+
totalCount?: number;
|
|
201
|
+
/** Renders the select-all checkbox (still only with two or more rows for it to act on). */
|
|
202
|
+
showSelectAll: boolean;
|
|
203
|
+
selectAllChecked: boolean;
|
|
204
|
+
selectAllIndeterminate: boolean;
|
|
205
|
+
/** Search-visible, non-disabled row count — the scope the select-all checkbox acts on. */
|
|
206
|
+
selectAllCount: number;
|
|
207
|
+
onToggleSelectAll: () => void;
|
|
208
|
+
moveLabel: string;
|
|
209
|
+
moveCount: number;
|
|
210
|
+
moveDisabled: boolean;
|
|
211
|
+
moveIconSide: "left" | "right";
|
|
212
|
+
onMove: () => void;
|
|
213
|
+
isChecked: (value: TTransferListValue) => boolean;
|
|
214
|
+
onToggle: (value: TTransferListValue) => void;
|
|
215
|
+
/** Rows that cannot be checked right now (the selection limit), on top of the item's own `isDisabled`. */
|
|
216
|
+
isItemBlocked?: (item: ITransferListItem) => boolean;
|
|
217
|
+
onRemove?: (value: TTransferListValue) => void;
|
|
218
|
+
onMoveUp?: (index: number) => void;
|
|
219
|
+
onMoveDown?: (index: number) => void;
|
|
220
|
+
dropIndex: number | null;
|
|
221
|
+
showDropOverlay: boolean;
|
|
222
|
+
onItemDragStart: (e: DragEvent, value: TTransferListValue) => void;
|
|
223
|
+
onItemDragEnd: () => void;
|
|
224
|
+
onItemDragOver: (e: DragEvent, index: number) => void;
|
|
225
|
+
onListDragOver: (e: DragEvent) => void;
|
|
226
|
+
onListDrop: (e: DragEvent) => void;
|
|
227
|
+
}
|