@talogic/react 0.8.1 → 0.9.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/index.js +903 -741
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/talogic-react.css +1 -1
- package/ui/index.d.ts +1 -0
- package/ui/selectable-list/bulk-action-bar.component.d.ts +26 -0
- package/ui/selectable-list/index.d.ts +8 -0
- package/ui/selectable-list/select-all-checkbox.component.d.ts +28 -0
- package/ui/selectable-list/selectable-list.component.d.ts +32 -0
- package/ui/selectable-list/selection.hook.d.ts +44 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Options of {@link Selection.toggle}. */
|
|
2
|
+
export interface ToggleOptions {
|
|
3
|
+
/** Applies the new state to every item from the last toggled item to this one, as a shift-click does. */
|
|
4
|
+
range?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/** The selection state and commands that {@link useSelection} returns. */
|
|
7
|
+
export interface Selection {
|
|
8
|
+
/** The ids of the list, in display order. */
|
|
9
|
+
ids: readonly string[];
|
|
10
|
+
/** The selected ids that are in the list now. */
|
|
11
|
+
selected: ReadonlySet<string>;
|
|
12
|
+
/** The number of selected ids in the list. */
|
|
13
|
+
count: number;
|
|
14
|
+
/** `true` when all items are selected, `false` when none is, and `indeterminate` for some. */
|
|
15
|
+
allState: boolean | 'indeterminate';
|
|
16
|
+
/** Tells if one item is selected. */
|
|
17
|
+
isSelected: (id: string) => boolean;
|
|
18
|
+
/** Selects or clears one item. With `range`, it sets each item from the last toggled item to the same state. */
|
|
19
|
+
toggle: (id: string, options?: ToggleOptions) => void;
|
|
20
|
+
/** Adds items to the selection. */
|
|
21
|
+
add: (ids: Iterable<string>) => void;
|
|
22
|
+
/** Replaces the selection with these items, for a filter such as "dismissed". */
|
|
23
|
+
set: (ids: Iterable<string>) => void;
|
|
24
|
+
/** Selects every item of the list. */
|
|
25
|
+
selectAll: () => void;
|
|
26
|
+
/** Clears the selection. */
|
|
27
|
+
clear: () => void;
|
|
28
|
+
}
|
|
29
|
+
/** Options of {@link useSelection}. */
|
|
30
|
+
export interface UseSelectionOptions {
|
|
31
|
+
/** The ids that are selected at first. */
|
|
32
|
+
defaultSelected?: Iterable<string>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Keeps a multi-selection of list items by id, with Gmail-style toggle, shift-click range, all and none.
|
|
36
|
+
*
|
|
37
|
+
* The selection is stored by id, so it stays correct when the list sorts, filters or reloads. An id that leaves the
|
|
38
|
+
* list does not count and is not in `selected`. When it comes back, it is selected again.
|
|
39
|
+
*
|
|
40
|
+
* @param ids - The ids of the list, in display order.
|
|
41
|
+
* @param options - The first selection.
|
|
42
|
+
* @returns The selection state and its commands.
|
|
43
|
+
*/
|
|
44
|
+
export declare function useSelection(ids: readonly string[], options?: UseSelectionOptions): Selection;
|