@openwarelabs/ui 0.14.1 → 0.16.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 +5 -5
- package/dist/components/ActivityHeatmap/ActivityHeatmap.d.cts +8 -0
- package/dist/components/ActivityHeatmap/ActivityHeatmap.d.ts +8 -0
- package/dist/components/ActivityHeatmap/ActivityHeatmap.types.d.cts +73 -0
- package/dist/components/ActivityHeatmap/ActivityHeatmap.types.d.ts +73 -0
- package/dist/components/DiffViewer/DiffViewer.d.cts +8 -0
- package/dist/components/DiffViewer/DiffViewer.d.ts +8 -0
- package/dist/components/DiffViewer/DiffViewer.types.d.cts +131 -0
- package/dist/components/DiffViewer/DiffViewer.types.d.ts +131 -0
- package/dist/components/DiffViewer/diff.d.cts +10 -0
- package/dist/components/DiffViewer/diff.d.ts +10 -0
- package/dist/components/InlineEdit/InlineEdit.d.cts +8 -0
- package/dist/components/InlineEdit/InlineEdit.d.ts +8 -0
- package/dist/components/InlineEdit/InlineEdit.types.d.cts +74 -0
- package/dist/components/InlineEdit/InlineEdit.types.d.ts +74 -0
- package/dist/components/Markdown/Markdown.d.cts +8 -0
- package/dist/components/Markdown/Markdown.d.ts +8 -0
- package/dist/components/Markdown/Markdown.types.d.cts +59 -0
- package/dist/components/Markdown/Markdown.types.d.ts +59 -0
- package/dist/components/MediaPlayer/MediaPlayer.d.cts +8 -0
- package/dist/components/MediaPlayer/MediaPlayer.d.ts +8 -0
- package/dist/components/MediaPlayer/MediaPlayer.types.d.cts +109 -0
- package/dist/components/MediaPlayer/MediaPlayer.types.d.ts +109 -0
- package/dist/components/MentionInput/MentionInput.d.cts +9 -0
- package/dist/components/MentionInput/MentionInput.d.ts +9 -0
- package/dist/components/MentionInput/MentionInput.types.d.cts +125 -0
- package/dist/components/MentionInput/MentionInput.types.d.ts +125 -0
- package/dist/components/MentionInput/useMentions.d.cts +8 -0
- package/dist/components/MentionInput/useMentions.d.ts +8 -0
- package/dist/components/NavigationMenu/NavigationMenu.d.cts +14 -0
- package/dist/components/NavigationMenu/NavigationMenu.d.ts +14 -0
- package/dist/components/NavigationMenu/NavigationMenu.types.d.cts +84 -0
- package/dist/components/NavigationMenu/NavigationMenu.types.d.ts +84 -0
- package/dist/components/NotificationCenter/NotificationCenter.d.cts +12 -0
- package/dist/components/NotificationCenter/NotificationCenter.d.ts +12 -0
- package/dist/components/NotificationCenter/NotificationCenter.types.d.cts +129 -0
- package/dist/components/NotificationCenter/NotificationCenter.types.d.ts +129 -0
- package/dist/components/QRCode/QRCode.d.cts +18 -0
- package/dist/components/QRCode/QRCode.d.ts +18 -0
- package/dist/components/QRCode/QRCode.types.d.cts +53 -0
- package/dist/components/QRCode/QRCode.types.d.ts +53 -0
- package/dist/components/QRCode/qr.d.cts +8 -0
- package/dist/components/QRCode/qr.d.ts +8 -0
- package/dist/components/SignaturePad/SignaturePad.d.cts +8 -0
- package/dist/components/SignaturePad/SignaturePad.d.ts +8 -0
- package/dist/components/SignaturePad/SignaturePad.types.d.cts +102 -0
- package/dist/components/SignaturePad/SignaturePad.types.d.ts +102 -0
- package/dist/components/SortableList/SortableList.d.cts +7 -0
- package/dist/components/SortableList/SortableList.d.ts +7 -0
- package/dist/components/SortableList/SortableList.types.d.cts +82 -0
- package/dist/components/SortableList/SortableList.types.d.ts +82 -0
- package/dist/components/TransferList/TransferList.d.cts +7 -0
- package/dist/components/TransferList/TransferList.d.ts +7 -0
- package/dist/components/TransferList/TransferList.types.d.cts +75 -0
- package/dist/components/TransferList/TransferList.types.d.ts +75 -0
- package/dist/components/TreeView/TreeView.d.cts +8 -0
- package/dist/components/TreeView/TreeView.d.ts +8 -0
- package/dist/components/TreeView/TreeView.types.d.cts +88 -0
- package/dist/components/TreeView/TreeView.types.d.ts +88 -0
- package/dist/components/UploadList/UploadList.d.cts +9 -0
- package/dist/components/UploadList/UploadList.d.ts +9 -0
- package/dist/components/UploadList/UploadList.types.d.cts +113 -0
- package/dist/components/UploadList/UploadList.types.d.ts +113 -0
- package/dist/components/UploadList/useUploadQueue.d.cts +8 -0
- package/dist/components/UploadList/useUploadQueue.d.ts +8 -0
- package/dist/components/VirtualList/VirtualList.d.cts +9 -0
- package/dist/components/VirtualList/VirtualList.d.ts +9 -0
- package/dist/components/VirtualList/VirtualList.types.d.cts +80 -0
- package/dist/components/VirtualList/VirtualList.types.d.ts +80 -0
- package/dist/components/VirtualList/useVirtualizer.d.cts +60 -0
- package/dist/components/VirtualList/useVirtualizer.d.ts +60 -0
- package/dist/components.css +1840 -113
- package/dist/index.cjs +6770 -2144
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.cts +32 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.js +6790 -2124
- package/dist/index.js.map +4 -4
- package/dist/openware-ui.iife.js +24 -8
- package/dist/styles.css +1840 -113
- package/package.json +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { CSSProperties, Key, ReactNode } from "react";
|
|
2
|
+
import type { ScrollToIndexOptions } from "./useVirtualizer.js";
|
|
3
|
+
export interface VirtualListLabels {
|
|
4
|
+
/** Announced to screen readers while more rows load.
|
|
5
|
+
* @default "Loading more" */
|
|
6
|
+
loading?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface VirtualListProps<T = unknown> {
|
|
9
|
+
/** The rows' data. Leave it out and pass `count` to render rows from their index alone. */
|
|
10
|
+
items?: readonly T[];
|
|
11
|
+
/** How many rows there are.
|
|
12
|
+
* @default items.length */
|
|
13
|
+
count?: number;
|
|
14
|
+
/** Renders one row. With `count` alone, `item` is undefined: use the index. */
|
|
15
|
+
renderItem(item: T, index: number): ReactNode;
|
|
16
|
+
/** A stable key for each row, such as its id. Give one when rows can be added at the top (older messages), so
|
|
17
|
+
* the view stays where it was, and so measured heights follow their row.
|
|
18
|
+
* @default (item, index) => index */
|
|
19
|
+
getKey?(item: T, index: number): Key;
|
|
20
|
+
/** Every row's height in pixels, when they're all the same. The fastest: nothing is measured. */
|
|
21
|
+
itemSize?: number;
|
|
22
|
+
/** A guess at a row's height in pixels when they vary. Each row is measured once it renders, and replaces the
|
|
23
|
+
* guess without the view jumping; the closer the guess, the steadier the scrollbar.
|
|
24
|
+
* @default 48 */
|
|
25
|
+
estimateSize?: number | ((index: number) => number);
|
|
26
|
+
/** How many rows to render beyond each edge of the view, so fast scrolling doesn't show blank space.
|
|
27
|
+
* @default 4 */
|
|
28
|
+
overscan?: number;
|
|
29
|
+
/** Space between rows, in pixels.
|
|
30
|
+
* @default 0 */
|
|
31
|
+
gap?: number;
|
|
32
|
+
/** The list's height. Without `height` or `maxHeight`, it fills its parent, which needs a height. */
|
|
33
|
+
height?: number | string;
|
|
34
|
+
/** Lets the list grow with its rows up to this height, then scroll. */
|
|
35
|
+
maxHeight?: number | string;
|
|
36
|
+
/** Called when the reader scrolls near the end, to load more rows. Called once per number of rows, and not
|
|
37
|
+
* while `loading` or once `hasMore` is false. */
|
|
38
|
+
onEndReached?(): void;
|
|
39
|
+
/** Called when the reader scrolls near the start, to load older rows (a chat's history). Rows added at the top
|
|
40
|
+
* keep the view where it was, as long as `getKey` gives real keys. */
|
|
41
|
+
onStartReached?(): void;
|
|
42
|
+
/** How close to either end, in pixels, calls `onEndReached` or `onStartReached`.
|
|
43
|
+
* @default 200 */
|
|
44
|
+
endReachedThreshold?: number;
|
|
45
|
+
/** Shows a spinner after the last row and tells screen readers more is loading.
|
|
46
|
+
* @default false */
|
|
47
|
+
loading?: boolean;
|
|
48
|
+
/** Whether there are more rows to load at the end; false stops `onEndReached`.
|
|
49
|
+
* @default true */
|
|
50
|
+
hasMore?: boolean;
|
|
51
|
+
/** Opens at the end and keeps the newest row in view as rows are added or grow, while the reader is at the end:
|
|
52
|
+
* for logs and chats. Scrolling up to read stops it; scrolling back down starts it again.
|
|
53
|
+
* @default false */
|
|
54
|
+
followOutput?: boolean;
|
|
55
|
+
/** `list` for a list of rows. `feed` for an endless stream of articles people read one by one (posts, news):
|
|
56
|
+
* each row is a focusable article, and Page Down and Page Up move between them.
|
|
57
|
+
* @default "list" */
|
|
58
|
+
role?: "list" | "feed";
|
|
59
|
+
/** Names the list for screen readers. */
|
|
60
|
+
label?: string;
|
|
61
|
+
/** The id of a visible heading that names the list, in place of `label`. */
|
|
62
|
+
"aria-labelledby"?: string;
|
|
63
|
+
/** Shown in place of the rows when there are none and nothing is loading. */
|
|
64
|
+
empty?: ReactNode;
|
|
65
|
+
/** The words it uses, for other languages. */
|
|
66
|
+
labels?: VirtualListLabels;
|
|
67
|
+
/** A class for each row's wrapper. */
|
|
68
|
+
itemClassName?: string;
|
|
69
|
+
id?: string;
|
|
70
|
+
className?: string;
|
|
71
|
+
style?: CSSProperties;
|
|
72
|
+
}
|
|
73
|
+
export interface VirtualListHandle {
|
|
74
|
+
/** Scrolls a row into view, rendering it first. `behavior: "smooth"` animates, except under reduced motion. */
|
|
75
|
+
scrollToIndex(index: number, options?: ScrollToIndexOptions): void;
|
|
76
|
+
/** Scrolls to the last row, and follows new rows again with `followOutput`. */
|
|
77
|
+
scrollToEnd(options?: Pick<ScrollToIndexOptions, "behavior">): void;
|
|
78
|
+
/** The element that scrolls. */
|
|
79
|
+
readonly element: HTMLDivElement | null;
|
|
80
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type Key } from "react";
|
|
2
|
+
/** One row that's rendered: where it goes and how tall it is. */
|
|
3
|
+
export interface VirtualItem {
|
|
4
|
+
index: number;
|
|
5
|
+
/** The row's key, from `getKey`: use it as the React key. */
|
|
6
|
+
key: Key;
|
|
7
|
+
/** Its top, in pixels from the top of the scrolling content. */
|
|
8
|
+
start: number;
|
|
9
|
+
/** Its height in pixels: `itemSize`, or measured, or the estimate until it's measured. */
|
|
10
|
+
size: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ScrollToIndexOptions {
|
|
13
|
+
/** Where the row ends up: at the `start` (top) of the view, the `center`, the `end`, or `auto`, scrolling only as
|
|
14
|
+
* far as needed to show it.
|
|
15
|
+
* @default "auto" */
|
|
16
|
+
align?: "start" | "center" | "end" | "auto";
|
|
17
|
+
/** `smooth` animates the scroll, except for people who prefer reduced motion.
|
|
18
|
+
* @default "auto" */
|
|
19
|
+
behavior?: ScrollBehavior;
|
|
20
|
+
}
|
|
21
|
+
export interface UseVirtualizerOptions {
|
|
22
|
+
/** How many rows there are. */
|
|
23
|
+
count: number;
|
|
24
|
+
/** Returns the element that scrolls. It must be there once the component has mounted. */
|
|
25
|
+
getScrollElement(): HTMLElement | null;
|
|
26
|
+
/** Every row's height in pixels, when they're all the same: the fastest, as nothing is measured. */
|
|
27
|
+
itemSize?: number;
|
|
28
|
+
/** A guess at a row's height in pixels, before it's measured. Rows are measured as they render, and the view
|
|
29
|
+
* doesn't jump when a row above it turns out taller or shorter than the guess.
|
|
30
|
+
* @default 48 */
|
|
31
|
+
estimateSize?: number | ((index: number) => number);
|
|
32
|
+
/** How many rows to render beyond each edge of the view, so fast scrolling doesn't show gaps.
|
|
33
|
+
* @default 4 */
|
|
34
|
+
overscan?: number;
|
|
35
|
+
/** Space between rows, in pixels.
|
|
36
|
+
* @default 0 */
|
|
37
|
+
gap?: number;
|
|
38
|
+
/** A stable key for each row. With real keys (not the index), measured heights follow their row, and rows
|
|
39
|
+
* added at the top keep the view where it was.
|
|
40
|
+
* @default (index) => index */
|
|
41
|
+
getKey?(index: number): Key;
|
|
42
|
+
/** A row to keep rendered even out of view, such as the one that has focus, so it isn't lost. */
|
|
43
|
+
keepMounted?: number | null;
|
|
44
|
+
}
|
|
45
|
+
export interface Virtualizer {
|
|
46
|
+
/** The rows to render: those in view and the overscan around them. */
|
|
47
|
+
items: VirtualItem[];
|
|
48
|
+
/** The height of all the rows together: give the content inside the scrolling element this height. */
|
|
49
|
+
totalSize: number;
|
|
50
|
+
/** Pass as the `ref` of each rendered row, with `data-index` on it, so its height is measured. */
|
|
51
|
+
measureElement(element: HTMLElement | null): void;
|
|
52
|
+
/** Scrolls a row into view. */
|
|
53
|
+
scrollToIndex(index: number, options?: ScrollToIndexOptions): void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Windowing for long lists: works out which rows of `count` are in view of a scrolling element, where each one goes,
|
|
57
|
+
* and how tall the whole list is, so you render only those rows. Rows have a fixed `itemSize`, or are measured with
|
|
58
|
+
* ResizeObserver as they render. VirtualList is built on it; use it for your own virtualized table or list box.
|
|
59
|
+
*/
|
|
60
|
+
export declare function useVirtualizer({ count, getScrollElement, itemSize, estimateSize, overscan, gap, getKey, keepMounted, }: UseVirtualizerOptions): Virtualizer;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type Key } from "react";
|
|
2
|
+
/** One row that's rendered: where it goes and how tall it is. */
|
|
3
|
+
export interface VirtualItem {
|
|
4
|
+
index: number;
|
|
5
|
+
/** The row's key, from `getKey`: use it as the React key. */
|
|
6
|
+
key: Key;
|
|
7
|
+
/** Its top, in pixels from the top of the scrolling content. */
|
|
8
|
+
start: number;
|
|
9
|
+
/** Its height in pixels: `itemSize`, or measured, or the estimate until it's measured. */
|
|
10
|
+
size: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ScrollToIndexOptions {
|
|
13
|
+
/** Where the row ends up: at the `start` (top) of the view, the `center`, the `end`, or `auto`, scrolling only as
|
|
14
|
+
* far as needed to show it.
|
|
15
|
+
* @default "auto" */
|
|
16
|
+
align?: "start" | "center" | "end" | "auto";
|
|
17
|
+
/** `smooth` animates the scroll, except for people who prefer reduced motion.
|
|
18
|
+
* @default "auto" */
|
|
19
|
+
behavior?: ScrollBehavior;
|
|
20
|
+
}
|
|
21
|
+
export interface UseVirtualizerOptions {
|
|
22
|
+
/** How many rows there are. */
|
|
23
|
+
count: number;
|
|
24
|
+
/** Returns the element that scrolls. It must be there once the component has mounted. */
|
|
25
|
+
getScrollElement(): HTMLElement | null;
|
|
26
|
+
/** Every row's height in pixels, when they're all the same: the fastest, as nothing is measured. */
|
|
27
|
+
itemSize?: number;
|
|
28
|
+
/** A guess at a row's height in pixels, before it's measured. Rows are measured as they render, and the view
|
|
29
|
+
* doesn't jump when a row above it turns out taller or shorter than the guess.
|
|
30
|
+
* @default 48 */
|
|
31
|
+
estimateSize?: number | ((index: number) => number);
|
|
32
|
+
/** How many rows to render beyond each edge of the view, so fast scrolling doesn't show gaps.
|
|
33
|
+
* @default 4 */
|
|
34
|
+
overscan?: number;
|
|
35
|
+
/** Space between rows, in pixels.
|
|
36
|
+
* @default 0 */
|
|
37
|
+
gap?: number;
|
|
38
|
+
/** A stable key for each row. With real keys (not the index), measured heights follow their row, and rows
|
|
39
|
+
* added at the top keep the view where it was.
|
|
40
|
+
* @default (index) => index */
|
|
41
|
+
getKey?(index: number): Key;
|
|
42
|
+
/** A row to keep rendered even out of view, such as the one that has focus, so it isn't lost. */
|
|
43
|
+
keepMounted?: number | null;
|
|
44
|
+
}
|
|
45
|
+
export interface Virtualizer {
|
|
46
|
+
/** The rows to render: those in view and the overscan around them. */
|
|
47
|
+
items: VirtualItem[];
|
|
48
|
+
/** The height of all the rows together: give the content inside the scrolling element this height. */
|
|
49
|
+
totalSize: number;
|
|
50
|
+
/** Pass as the `ref` of each rendered row, with `data-index` on it, so its height is measured. */
|
|
51
|
+
measureElement(element: HTMLElement | null): void;
|
|
52
|
+
/** Scrolls a row into view. */
|
|
53
|
+
scrollToIndex(index: number, options?: ScrollToIndexOptions): void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Windowing for long lists: works out which rows of `count` are in view of a scrolling element, where each one goes,
|
|
57
|
+
* and how tall the whole list is, so you render only those rows. Rows have a fixed `itemSize`, or are measured with
|
|
58
|
+
* ResizeObserver as they render. VirtualList is built on it; use it for your own virtualized table or list box.
|
|
59
|
+
*/
|
|
60
|
+
export declare function useVirtualizer({ count, getScrollElement, itemSize, estimateSize, overscan, gap, getKey, keepMounted, }: UseVirtualizerOptions): Virtualizer;
|