@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,4 +1,10 @@
1
1
  import type { ReactNode } from "react";
2
+ import type { TLoadOptions, TPrefetch } from "@hooks";
3
+ /**
4
+ * `TPrefetch` minus `"open"`: the panel's list is always visible, so it has no open event to hang a
5
+ * fetch on. Narrowed rather than redefined, so the family shares one vocabulary.
6
+ */
7
+ export type TTransferListPrefetch = Exclude<TPrefetch, "open">;
2
8
  /**
3
9
  * Which of the two panels an item or action belongs to.
4
10
  */
@@ -10,9 +16,8 @@ export type TTransferPanel = "available" | "selected";
10
16
  */
11
17
  export type TTransferListValue = string | number;
12
18
  /**
13
- * A single transferable item. MultiSelectTransfer composes TransferList and
14
- * feeds its options straight into these props, so the two shapes are kept
15
- * structurally compatible.
19
+ * A single transferable item. The shape composing components alias rather than redeclare, so an
20
+ * option and a transfer-list item stay structurally identical.
16
21
  */
17
22
  export interface ITransferListItem {
18
23
  value: TTransferListValue;
@@ -21,9 +26,14 @@ export interface ITransferListItem {
21
26
  searchValue?: string;
22
27
  isDisabled?: boolean;
23
28
  }
29
+ /** Async source for the available panel. Paged: `cursor`, `hasMore` and `total` are all honoured. */
30
+ export type TTransferListLoadOptions = TLoadOptions<ITransferListItem>;
24
31
  export interface ITransferListProps {
25
- /** Items in the available (left) panel. Controlled. */
26
- availableItems: ITransferListItem[];
32
+ /**
33
+ * Items in the available (left) panel. Controlled. Optional and **ignored** (with a dev warning)
34
+ * when `loadAvailableOptions` is set — in that mode the component owns the available pool.
35
+ */
36
+ availableItems?: ITransferListItem[];
27
37
  /** Items in the selected (right) panel. Order is preserved when reorderable. Controlled. */
28
38
  selectedItems: ITransferListItem[];
29
39
  /** Fired on every move/reorder with the next available + selected arrays. */
@@ -34,9 +44,19 @@ export interface ITransferListProps {
34
44
  selectedPanelTitle?: ReactNode;
35
45
  /** Show the per-panel search inputs. @default true */
36
46
  searchable?: boolean;
37
- /** Controlled search term for the available panel. */
47
+ /** Controlled search term for the available panel. Overridden when `loadAvailableOptions` is set. */
38
48
  availableSearchTerm?: string;
39
- /** Controlled-search change handler for the available panel. */
49
+ /**
50
+ * Controlled-search change handler for the available panel. Fires on every keystroke (no built-in
51
+ * debounce).
52
+ *
53
+ * Without `loadAvailableOptions`: switches off the panel's local filtering — `availableItems` is
54
+ * treated as already filtered for the query — so the debounce, the fetch, the loading state, the
55
+ * response ordering, and subtracting `selectedItems` from the result are the consumer's
56
+ * responsibility.
57
+ *
58
+ * With `loadAvailableOptions`: notification-only, for analytics.
59
+ */
40
60
  onAvailableSearchChange?: (query: string) => void;
41
61
  /** Controlled search term for the selected panel. */
42
62
  selectedSearchTerm?: string;
@@ -60,12 +80,68 @@ export interface ITransferListProps {
60
80
  onReload?: () => void;
61
81
  /** Spins the reload icon and disables the button. */
62
82
  isReloading?: boolean;
63
- /** More available items can be loaded (drives the infinite-scroll sentinel). */
83
+ /** More available items can be loaded (drives the infinite-scroll sentinel). Ignored when `loadAvailableOptions` is set. */
64
84
  hasMoreAvailable?: boolean;
65
- /** Fired when the available list sentinel scrolls into view. */
85
+ /** Fired when the available list sentinel scrolls into view. Ignored when `loadAvailableOptions` is set. */
66
86
  onLoadMoreAvailable?: () => void;
67
- /** Renders a loader row at the bottom of the available list. */
87
+ /** Renders a loader row at the bottom of the available list. Ignored when `loadAvailableOptions` is set. */
68
88
  isLoadingMoreAvailable?: boolean;
89
+ /**
90
+ * Loader REPLACES the available rows (a search/refresh fetch, not a page append). OR-ed with the
91
+ * loader's own state, so it still applies in async mode. @default false
92
+ */
93
+ isLoadingAvailable?: boolean;
94
+ /** Replaces the available rows when set: the available source failed to load. Ignored in async mode — use `loadErrorMessage`. */
95
+ availableLoadError?: ReactNode;
96
+ /**
97
+ * Shown under the loaded rows when a page append failed; renders a retry button. Ignored in async
98
+ * mode — use `loadMoreErrorMessage`.
99
+ */
100
+ availableLoadMoreError?: ReactNode;
101
+ /** Fired by the retry button under `availableLoadMoreError`. Ignored when `loadAvailableOptions` is set. */
102
+ onRetryLoadMoreAvailable?: () => void;
103
+ /** Label for that retry button. @default "Retry" */
104
+ retryLabel?: string;
105
+ /** Server-side total for the available panel; the header count becomes "(loaded of total)". Takes precedence over the loader's own total. */
106
+ availableTotalCount?: number;
107
+ /**
108
+ * Async source for the available panel. When provided, the component owns that panel's pool, paging,
109
+ * request lifecycle and loading/error state; `availableItems` is ignored (dev warning) and the
110
+ * panel's search becomes server-driven. `selectedItems` stays controlled — the consumer owns the
111
+ * selection — and `onChange` still fires with both arrays.
112
+ */
113
+ loadAvailableOptions?: TTransferListLoadOptions;
114
+ /**
115
+ * Seed rows for a pool you already have — an SSR payload, a route loader, a warm cache. They paint on the
116
+ * first frame, so the panel is never briefly empty, and they stay put while the mount fetch revalidates over
117
+ * them. They go through the same pool-minus-`selectedItems` projection as fetched rows. They do not suppress
118
+ * that fetch: pair with `prefetch="never"` if the seed is the whole pool until the user searches. Seed rows
119
+ * carry no cursor, so nothing pages until a real page lands. A *search* replaces them, since seed rows are
120
+ * not results for a query. Async mode only — ignored (dev warning) without `loadAvailableOptions`, where the
121
+ * rows belong in `availableItems`.
122
+ */
123
+ initialAvailableOptions?: readonly ITransferListItem[];
124
+ /**
125
+ * When to fetch the unfiltered available list. `"mount"` fires at render — the panel has no
126
+ * open/close, so mount is the only trigger it has. `"never"` defers everything until the user
127
+ * searches, for a heavy list that should stay untouched otherwise.
128
+ *
129
+ * Async mode only — ignored (dev warning) without `loadAvailableOptions`, where `availableItems` are
130
+ * already on screen and there is nothing to fetch. @default "mount"
131
+ */
132
+ prefetch?: TTransferListPrefetch;
133
+ /** Clearing the available search revalidates the cached baseline instead of just restoring it. @default false */
134
+ refetchOnClear?: boolean;
135
+ /** Identity of the available option set. A change drops cached pages and repopulates. Does NOT clear the selection. */
136
+ optionsKey?: string | number;
137
+ /** Debounce for the available panel's search when it is server-driven. @default 300 */
138
+ availableFilterDebounceMs?: number;
139
+ /** Shown in place of the available rows when the loader rejects. @default "Couldn't load options." */
140
+ loadErrorMessage?: ReactNode;
141
+ /** Shown under the loaded rows when a page append rejects. @default "Couldn't load more." */
142
+ loadMoreErrorMessage?: ReactNode;
143
+ /** Notified when a load rejects (the component renders the message and swallows it). */
144
+ onLoadError?: (error: unknown) => void;
69
145
  /** Disable all interaction. */
70
146
  disabled?: boolean;
71
147
  /** Empty-state copy for the available panel. @default "No Data Found!" */
@@ -16,7 +16,7 @@ interface IDragState {
16
16
  export declare function useTransferList({ availableItems, selectedItems, onChange }: IUseTransferListArgs): {
17
17
  isChecked: (panel: TTransferPanel, value: TTransferListValue) => boolean;
18
18
  toggleCheck: (panel: TTransferPanel, value: TTransferListValue) => void;
19
- setPanelChecked: (panel: TTransferPanel, values: TTransferListValue[]) => void;
19
+ setPanelChecked: (panel: TTransferPanel, values: TTransferListValue[], checked: boolean) => void;
20
20
  moveRight: (values: TTransferListValue[]) => void;
21
21
  moveLeft: (values: TTransferListValue[]) => void;
22
22
  transferToSelected: (value: TTransferListValue, insertIndex?: number) => void;
@@ -0,0 +1,28 @@
1
+ import type { KeyboardEvent } from "react";
2
+ import type { ITransferListItem, TTransferListValue } from "./types";
3
+ interface IUseTransferListPanelKeysArgs {
4
+ items: ITransferListItem[];
5
+ activeIndex: number;
6
+ setActiveIndex: (index: number) => void;
7
+ moveActive: (direction: 1 | -1) => void;
8
+ firstEnabledIndex: (from: number, direction: 1 | -1) => number;
9
+ reorderable: boolean;
10
+ onToggle: (value: TTransferListValue) => void;
11
+ onRemove?: (value: TTransferListValue) => void;
12
+ onMoveUp?: (index: number) => void;
13
+ onMoveDown?: (index: number) => void;
14
+ setIsFocused: (focused: boolean) => void;
15
+ /**
16
+ * The rows the arrow keys are addressing are about to be replaced (a search fetch is in flight, or
17
+ * an error has taken the list's place), so every key is swallowed. The single place this gate is
18
+ * expressed.
19
+ */
20
+ isBlocked: boolean;
21
+ }
22
+ /**
23
+ * The listbox key handler for one transfer-list panel: arrow/Home/End navigation over
24
+ * `aria-activedescendant`, Enter/Space to toggle, Delete/Backspace to remove, and Alt+Arrow to
25
+ * reorder.
26
+ */
27
+ export declare function useTransferListPanelKeys({ items, activeIndex, setActiveIndex, moveActive, firstEnabledIndex, reorderable, onToggle, onRemove, onMoveUp, onMoveDown, setIsFocused, isBlocked }: IUseTransferListPanelKeysArgs): (e: KeyboardEvent<HTMLDivElement>) => void;
28
+ export {};
@@ -0,0 +1,49 @@
1
+ import { type ReactNode } from "react";
2
+ import type { ITransferListItem, TTransferListLoadOptions, TTransferListPrefetch } from "./types";
3
+ interface IUseTransferListSourceArgs {
4
+ availableItems?: ITransferListItem[];
5
+ /** Controlled by the consumer in every mode — the selection is the whole point of the component. */
6
+ selectedItems: ITransferListItem[];
7
+ loadAvailableOptions?: TTransferListLoadOptions;
8
+ initialAvailableOptions?: readonly ITransferListItem[];
9
+ prefetch?: TTransferListPrefetch;
10
+ refetchOnClear?: boolean;
11
+ optionsKey?: string | number;
12
+ availableFilterDebounceMs?: number;
13
+ loadErrorMessage?: ReactNode;
14
+ loadMoreErrorMessage?: ReactNode;
15
+ onLoadError?: (error: unknown) => void;
16
+ hasMoreAvailable?: boolean;
17
+ onLoadMoreAvailable?: () => void;
18
+ isLoadingMoreAvailable?: boolean;
19
+ isLoadingAvailable?: boolean;
20
+ availableLoadError?: ReactNode;
21
+ availableLoadMoreError?: ReactNode;
22
+ onRetryLoadMoreAvailable?: () => void;
23
+ availableTotalCount?: number;
24
+ availableSearchTerm?: string;
25
+ onAvailableSearchChange?: (query: string) => void;
26
+ }
27
+ interface ITransferListSource {
28
+ /** The available pool: derived from the loaded pages in async mode, the prop otherwise. */
29
+ availableItems: ITransferListItem[];
30
+ hasMoreAvailable: boolean;
31
+ onLoadMoreAvailable?: () => void;
32
+ isLoadingMoreAvailable: boolean;
33
+ isLoadingAvailable: boolean;
34
+ availableLoadError?: ReactNode;
35
+ availableLoadMoreError?: ReactNode;
36
+ onRetryLoadMoreAvailable?: () => void;
37
+ availableTotalCount?: number;
38
+ /** In async mode these make the panel's search controlled and server-driven. */
39
+ availableSearchTerm?: string;
40
+ onAvailableSearchChange?: (query: string) => void;
41
+ }
42
+ /**
43
+ * `TransferList`'s available-panel source. In async mode it owns a `useAsyncOptions` instance, a
44
+ * debounced `useFilterQuery` for the panel's search (which is a raw `onChange` otherwise), the
45
+ * mount/`optionsKey` prefetch, and the pool → available projection. Without a loader every value is
46
+ * the corresponding prop, unchanged.
47
+ */
48
+ export declare function useTransferListSource({ availableItems, selectedItems, loadAvailableOptions, initialAvailableOptions, prefetch, refetchOnClear, optionsKey, availableFilterDebounceMs, loadErrorMessage, loadMoreErrorMessage, onLoadError, hasMoreAvailable, onLoadMoreAvailable, isLoadingMoreAvailable, isLoadingAvailable, availableLoadError, availableLoadMoreError, onRetryLoadMoreAvailable, availableTotalCount, availableSearchTerm, onAvailableSearchChange }: IUseTransferListSourceArgs): ITransferListSource;
49
+ export {};