@stridge/noctis 1.0.0-beta.4 → 1.0.0-beta.6
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/dist/components/breadcrumb/breadcrumb.d.ts +163 -0
- package/dist/components/breadcrumb/breadcrumb.js +152 -0
- package/dist/components/breadcrumb/breadcrumb.props.d.ts +59 -0
- package/dist/components/breadcrumb/breadcrumb.props.js +68 -0
- package/dist/components/breadcrumb/breadcrumb.slots.d.ts +16 -0
- package/dist/components/breadcrumb/breadcrumb.slots.js +32 -0
- package/dist/components/breadcrumb/breadcrumb.types.d.ts +9 -0
- package/dist/components/breadcrumb/index.d.ts +3 -0
- package/dist/components/command/command-listbox.js +174 -0
- package/dist/components/command/command-rank.d.ts +40 -0
- package/dist/components/command/command-rank.js +61 -0
- package/dist/components/command/command-score.d.ts +25 -0
- package/dist/components/command/command-score.js +85 -0
- package/dist/components/command/command.context.d.ts +17 -0
- package/dist/components/command/command.context.js +13 -0
- package/dist/components/command/command.d.ts +396 -0
- package/dist/components/command/command.js +471 -0
- package/dist/components/command/command.props.d.ts +91 -0
- package/dist/components/command/command.props.js +94 -0
- package/dist/components/command/command.slots.d.ts +23 -0
- package/dist/components/command/command.slots.js +60 -0
- package/dist/components/command/index.d.ts +6 -0
- package/dist/components/command/use-command-ranking.d.ts +37 -0
- package/dist/components/command/use-command-ranking.js +127 -0
- package/dist/components/pagination/index.d.ts +3 -0
- package/dist/components/pagination/pagination.context.js +16 -0
- package/dist/components/pagination/pagination.d.ts +217 -0
- package/dist/components/pagination/pagination.js +333 -0
- package/dist/components/pagination/pagination.props.d.ts +51 -0
- package/dist/components/pagination/pagination.props.js +49 -0
- package/dist/components/pagination/pagination.slots.d.ts +16 -0
- package/dist/components/pagination/pagination.slots.js +32 -0
- package/dist/components/pagination/pagination.types.d.ts +24 -0
- package/dist/components/search-dialog/parts/root.js +1 -1
- package/dist/components/skeleton/index.d.ts +3 -0
- package/dist/components/skeleton/skeleton.context.js +12 -0
- package/dist/components/skeleton/skeleton.d.ts +157 -0
- package/dist/components/skeleton/skeleton.js +130 -0
- package/dist/components/skeleton/skeleton.props.d.ts +47 -0
- package/dist/components/skeleton/skeleton.props.js +57 -0
- package/dist/components/skeleton/skeleton.slots.d.ts +15 -0
- package/dist/components/skeleton/skeleton.slots.js +28 -0
- package/dist/components/skeleton/skeleton.types.d.ts +13 -0
- package/dist/components/surface/surface.d.ts +1 -1
- package/dist/icons/glyphs.js +2 -2
- package/dist/index.d.ts +18 -3
- package/dist/index.js +15 -4
- package/dist/primitives/index.d.ts +1 -1
- package/dist/primitives/index.js +2 -2
- package/dist/props.d.ts +37 -33
- package/dist/props.js +37 -33
- package/dist/styles.css +841 -6
- package/package.json +4 -4
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//#region src/components/command/command.slots.ts
|
|
2
|
+
/**
|
|
3
|
+
* The slot vocabulary every `Command` part stamps as its `data-slot`. The authored source the
|
|
4
|
+
* orchestration file reads from, prefixed `noctis-command-{part}` (the precompiled `command.css` keys
|
|
5
|
+
* every rule off these anchors); SLOTS.md generates from the token-graph declaration.
|
|
6
|
+
*
|
|
7
|
+
* `backdrop`, `header`, `breadcrumb`, `inputAction`, `listSizer`, `listView`, `group`, `itemIcon`,
|
|
8
|
+
* `itemLabel`, `separator`, `loading`, and `footer` are styling-only anchors (the modal scrim, the input
|
|
9
|
+
* row, the drill-in trail, the trailing input affordance, the list's measured content wrapper, the
|
|
10
|
+
* per-page view that re-animates on drill-in, the section wrapper, the row's glyph and label columns,
|
|
11
|
+
* the divider, and the footer region) — they carry no token mints, so they live here but not in the
|
|
12
|
+
* token-graph anatomy.
|
|
13
|
+
*
|
|
14
|
+
* The component is deliberately unopinionated past the leading icon: a row pushes any trailing content
|
|
15
|
+
* (a `Kbd` shortcut, a badge, a count) to its end via the label's `flex`, and the footer is a bare
|
|
16
|
+
* region — neither bakes in a "shortcut"/"hint" concept, so the consumer composes those freely.
|
|
17
|
+
*/
|
|
18
|
+
const COMMAND_SLOTS = {
|
|
19
|
+
panel: "noctis-command",
|
|
20
|
+
backdrop: "noctis-command-backdrop",
|
|
21
|
+
header: "noctis-command-header",
|
|
22
|
+
breadcrumb: "noctis-command-breadcrumb",
|
|
23
|
+
input: "noctis-command-input",
|
|
24
|
+
inputAction: "noctis-command-input-action",
|
|
25
|
+
list: "noctis-command-list",
|
|
26
|
+
listSizer: "noctis-command-list-sizer",
|
|
27
|
+
listView: "noctis-command-list-view",
|
|
28
|
+
group: "noctis-command-group",
|
|
29
|
+
groupLabel: "noctis-command-group-label",
|
|
30
|
+
item: "noctis-command-item",
|
|
31
|
+
itemIcon: "noctis-command-item-icon",
|
|
32
|
+
itemLabel: "noctis-command-item-label",
|
|
33
|
+
separator: "noctis-command-separator",
|
|
34
|
+
empty: "noctis-command-empty",
|
|
35
|
+
loading: "noctis-command-loading",
|
|
36
|
+
footer: "noctis-command-footer"
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The `data-*` hooks `Command` stamps on its parts, for host-side styling and tests. Slot values mark
|
|
40
|
+
* each rendered element; the state attributes are emitted by the palette's own combobox/listbox engine
|
|
41
|
+
* (which drives the keyboard model — see `command-listbox`) and by the composed Dialog — pair a slot with
|
|
42
|
+
* a state to target, say, the highlighted row or the modal panel while it transitions in.
|
|
43
|
+
*/
|
|
44
|
+
let CommandDataAttributes = /* @__PURE__ */ function(CommandDataAttributes) {
|
|
45
|
+
/** Marks each rendered part. */
|
|
46
|
+
CommandDataAttributes["slot"] = "data-slot";
|
|
47
|
+
/** Present on the panel in its modal form (the centred, fixed-height, scale-fading popup). */
|
|
48
|
+
CommandDataAttributes["modal"] = "data-modal";
|
|
49
|
+
/** Present on the command row the pointer or keyboard is currently over (the active descendant). */
|
|
50
|
+
CommandDataAttributes["highlighted"] = "data-highlighted";
|
|
51
|
+
/** Present on a disabled command row. */
|
|
52
|
+
CommandDataAttributes["disabled"] = "data-disabled";
|
|
53
|
+
/** Present on the modal panel/scrim for the first frame after mount — the transition's start state. */
|
|
54
|
+
CommandDataAttributes["startingStyle"] = "data-starting-style";
|
|
55
|
+
/** Present on the modal panel/scrim while it transitions out before unmounting. */
|
|
56
|
+
CommandDataAttributes["endingStyle"] = "data-ending-style";
|
|
57
|
+
return CommandDataAttributes;
|
|
58
|
+
}({});
|
|
59
|
+
//#endregion
|
|
60
|
+
export { COMMAND_SLOTS, CommandDataAttributes };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CommandPage } from "./command.context.js";
|
|
2
|
+
import { Command } from "./command.js";
|
|
3
|
+
import { CommandDataAttributes } from "./command.slots.js";
|
|
4
|
+
import { commandScore } from "./command-score.js";
|
|
5
|
+
import { RankOptions, RankableItem, rankItems } from "./command-rank.js";
|
|
6
|
+
import { UseCommandRankingOptions, createRankingWorker, useCommandRanking } from "./use-command-ranking.js";
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RankOptions, RankableItem } from "./command-rank.js";
|
|
2
|
+
|
|
3
|
+
//#region src/components/command/use-command-ranking.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Options for {@link useCommandRanking} — the {@link RankOptions} plus the Worker-offload controls.
|
|
6
|
+
* A custom `score` function forces the synchronous path (functions can't cross the Worker boundary).
|
|
7
|
+
*/
|
|
8
|
+
interface UseCommandRankingOptions<T extends RankableItem> extends RankOptions<T> {
|
|
9
|
+
/**
|
|
10
|
+
* Offload ranking to a Web Worker once the candidate count reaches `workerThreshold`, keeping a
|
|
11
|
+
* large palette's keystrokes off the main thread. Falls back to synchronous ranking when a Worker
|
|
12
|
+
* can't be constructed (SSR, older bundlers, a custom `score`).
|
|
13
|
+
* @default true
|
|
14
|
+
*/
|
|
15
|
+
worker?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Candidate count at or above which the Worker is used (below it the synchronous path is faster
|
|
18
|
+
* than the round-trip).
|
|
19
|
+
* @default 250
|
|
20
|
+
*/
|
|
21
|
+
workerThreshold?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Build an inline-Blob ranking Worker, or `null` when the environment can't host one. Browser-only:
|
|
25
|
+
* jsdom has no `Worker`, so this is excluded from coverage (the hook's null-fallback path is tested).
|
|
26
|
+
*/
|
|
27
|
+
declare function createRankingWorker(): Worker | null;
|
|
28
|
+
/**
|
|
29
|
+
* Rank `items` against `query`, offloading to a Web Worker for large candidate sets while staying
|
|
30
|
+
* synchronous (and SSR-safe) otherwise. The synchronous result is always returned immediately; a
|
|
31
|
+
* Worker result, when it arrives, supersedes it — so the palette never blocks on the round-trip.
|
|
32
|
+
*
|
|
33
|
+
* Pass `worker: false` (or a custom `score`) to force the synchronous path.
|
|
34
|
+
*/
|
|
35
|
+
declare function useCommandRanking<T extends RankableItem>(items: readonly T[], query: string, options?: UseCommandRankingOptions<T>): T[];
|
|
36
|
+
//#endregion
|
|
37
|
+
export { UseCommandRankingOptions, createRankingWorker, useCommandRanking };
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { commandScore } from "./command-score.js";
|
|
3
|
+
import { rankItems, rankValues } from "./command-rank.js";
|
|
4
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
//#region src/components/command/use-command-ranking.ts
|
|
6
|
+
/**
|
|
7
|
+
* The Worker's message glue: take a ranking request, run the shared `rankValues`, post the ordered
|
|
8
|
+
* values back. This is the *only* worker-specific code — the scoring and ranking it relies on are the
|
|
9
|
+
* real, tested `commandScore` / `rankValues`, serialised verbatim alongside it (see `WORKER_SOURCE`),
|
|
10
|
+
* so the Worker reuses the exact same implementation rather than a copy. Runs only inside a Worker
|
|
11
|
+
* runtime, so it is excluded from coverage.
|
|
12
|
+
*/
|
|
13
|
+
/* v8 ignore start -- executes only inside a Worker (absent in jsdom); its `rankValues`/`commandScore` are covered */
|
|
14
|
+
function workerGlue() {
|
|
15
|
+
const scope = self;
|
|
16
|
+
scope.onmessage = (event) => {
|
|
17
|
+
const { id, items, query, threshold } = event.data;
|
|
18
|
+
scope.postMessage({
|
|
19
|
+
id,
|
|
20
|
+
values: rankValues(items, query, threshold)
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/* v8 ignore stop */
|
|
25
|
+
const WORKER_SOURCE = `${commandScore};\n${rankValues};\n(${workerGlue})();`;
|
|
26
|
+
/**
|
|
27
|
+
* Build an inline-Blob ranking Worker, or `null` when the environment can't host one. Browser-only:
|
|
28
|
+
* jsdom has no `Worker`, so this is excluded from coverage (the hook's null-fallback path is tested).
|
|
29
|
+
*/
|
|
30
|
+
/* v8 ignore start -- browser-only Worker construction (no `Worker` in jsdom) */
|
|
31
|
+
function createRankingWorker() {
|
|
32
|
+
try {
|
|
33
|
+
if (typeof Worker === "undefined" || typeof Blob === "undefined" || typeof URL?.createObjectURL !== "function") return null;
|
|
34
|
+
const url = URL.createObjectURL(new Blob([WORKER_SOURCE], { type: "application/javascript" }));
|
|
35
|
+
const worker = new Worker(url);
|
|
36
|
+
URL.revokeObjectURL(url);
|
|
37
|
+
return worker;
|
|
38
|
+
} catch {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/* v8 ignore stop */
|
|
43
|
+
/**
|
|
44
|
+
* Rank `items` against `query`, offloading to a Web Worker for large candidate sets while staying
|
|
45
|
+
* synchronous (and SSR-safe) otherwise. The synchronous result is always returned immediately; a
|
|
46
|
+
* Worker result, when it arrives, supersedes it — so the palette never blocks on the round-trip.
|
|
47
|
+
*
|
|
48
|
+
* Pass `worker: false` (or a custom `score`) to force the synchronous path.
|
|
49
|
+
*/
|
|
50
|
+
function useCommandRanking(items, query, options = {}) {
|
|
51
|
+
const { worker = true, workerThreshold = 250, threshold = 0, score } = options;
|
|
52
|
+
const useWorker = worker && score === void 0 && items.length >= workerThreshold;
|
|
53
|
+
const sync = useMemo(() => rankItems(items, query, {
|
|
54
|
+
threshold,
|
|
55
|
+
score
|
|
56
|
+
}), [
|
|
57
|
+
items,
|
|
58
|
+
query,
|
|
59
|
+
threshold,
|
|
60
|
+
score
|
|
61
|
+
]);
|
|
62
|
+
const [workerOrder, setWorkerOrder] = useState(null);
|
|
63
|
+
const workerRef = useRef(null);
|
|
64
|
+
const jobRef = useRef(0);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (!useWorker) {
|
|
67
|
+
setWorkerOrder(null);
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
/* v8 ignore start -- the Worker path: jsdom has no Worker, so createRankingWorker is null and
|
|
71
|
+
the message wiring below never runs (the hook's sync fallback is what gets tested) */
|
|
72
|
+
const w = workerRef.current ??= createRankingWorker();
|
|
73
|
+
if (!w) {
|
|
74
|
+
setWorkerOrder(null);
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const id = ++jobRef.current;
|
|
78
|
+
setWorkerOrder(null);
|
|
79
|
+
const onMessage = (event) => {
|
|
80
|
+
const data = event.data;
|
|
81
|
+
if (data.id === id) setWorkerOrder(data.values);
|
|
82
|
+
};
|
|
83
|
+
w.addEventListener("message", onMessage);
|
|
84
|
+
w.postMessage({
|
|
85
|
+
id,
|
|
86
|
+
query,
|
|
87
|
+
threshold,
|
|
88
|
+
items: items.map((item) => ({
|
|
89
|
+
value: item.value,
|
|
90
|
+
label: item.label,
|
|
91
|
+
keywords: item.keywords,
|
|
92
|
+
boost: item.boost
|
|
93
|
+
}))
|
|
94
|
+
});
|
|
95
|
+
return () => w.removeEventListener("message", onMessage);
|
|
96
|
+
/* v8 ignore stop */
|
|
97
|
+
}, [
|
|
98
|
+
useWorker,
|
|
99
|
+
items,
|
|
100
|
+
query,
|
|
101
|
+
threshold
|
|
102
|
+
]);
|
|
103
|
+
useEffect(() => () => {
|
|
104
|
+
/* v8 ignore next -- workerRef is only ever set on the live-Worker path */
|
|
105
|
+
workerRef.current?.terminate();
|
|
106
|
+
}, []);
|
|
107
|
+
return useMemo(() => {
|
|
108
|
+
if (!useWorker) return sync;
|
|
109
|
+
/* v8 ignore start -- reached only when a Worker has replied (never in jsdom) */
|
|
110
|
+
if (workerOrder === null) return sync;
|
|
111
|
+
const byValue = new Map(items.map((item) => [item.value, item]));
|
|
112
|
+
const ordered = [];
|
|
113
|
+
for (const value of workerOrder) {
|
|
114
|
+
const item = byValue.get(value);
|
|
115
|
+
if (item) ordered.push(item);
|
|
116
|
+
}
|
|
117
|
+
return ordered;
|
|
118
|
+
/* v8 ignore stop */
|
|
119
|
+
}, [
|
|
120
|
+
useWorker,
|
|
121
|
+
workerOrder,
|
|
122
|
+
sync,
|
|
123
|
+
items
|
|
124
|
+
]);
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
export { createRankingWorker, useCommandRanking };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, use } from "react";
|
|
3
|
+
//#region src/components/pagination/pagination.context.ts
|
|
4
|
+
const PaginationContext = createContext(null);
|
|
5
|
+
const PaginationProvider = PaginationContext.Provider;
|
|
6
|
+
/**
|
|
7
|
+
* Read the enclosing `Pagination.Root` state. Every compound part is meaningless on its own (it needs
|
|
8
|
+
* the page model and shared labels), so this throws a part-named error when used outside the root.
|
|
9
|
+
*/
|
|
10
|
+
function usePaginationContext(part) {
|
|
11
|
+
const context = use(PaginationContext);
|
|
12
|
+
if (!context) throw new Error(`Pagination.${part} must be rendered inside a <Pagination.Root>.`);
|
|
13
|
+
return context;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { PaginationProvider, usePaginationContext };
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
import { Button } from "../button/button.js";
|
|
2
|
+
import { PaginationLabels, PaginationSize } from "./pagination.types.js";
|
|
3
|
+
import { PaginationPartProps, PaginationRootPropsArgs, controlsProps, infoProps, pageProps, pageSizeLabelProps, pageSizeProps, rootProps, separatorProps } from "./pagination.props.js";
|
|
4
|
+
import { ComponentProps, ReactElement, ReactNode } from "react";
|
|
5
|
+
|
|
6
|
+
//#region src/components/pagination/pagination.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Page navigation: a row of nav controls (a welded `ButtonGroup` of First/Previous/Next/Last buttons),
|
|
9
|
+
* an optional editable page field, a "Showing X–Y of Z" info line, and a page-size picker — composed
|
|
10
|
+
* from the shipped `Button`, `ButtonGroup`, `Input`, and `Select`. `Pagination.Root` is controlled:
|
|
11
|
+
* pass `page` + `onPageChange`, and `total` + `perPage` (so the info line and the last-page bound can
|
|
12
|
+
* be computed) or an explicit `pageCount`. Every part reads the shared model through context, so the
|
|
13
|
+
* bounds-disabling and clamping are handled for you.
|
|
14
|
+
*
|
|
15
|
+
* @see {@link Pagination.Root.Props}
|
|
16
|
+
*/
|
|
17
|
+
declare function PaginationRoot({
|
|
18
|
+
page,
|
|
19
|
+
onPageChange,
|
|
20
|
+
total,
|
|
21
|
+
perPage,
|
|
22
|
+
pageCount: pageCountProp,
|
|
23
|
+
size,
|
|
24
|
+
labels: labelsProp,
|
|
25
|
+
className,
|
|
26
|
+
children,
|
|
27
|
+
...props
|
|
28
|
+
}: Pagination.Root.Props): ReactElement;
|
|
29
|
+
/** The render-prop state `Pagination.Info` exposes for custom info text. */
|
|
30
|
+
interface PaginationInfoState {
|
|
31
|
+
/** Current page, 1-indexed. */
|
|
32
|
+
page: number;
|
|
33
|
+
/** The last reachable page. */
|
|
34
|
+
pageCount: number;
|
|
35
|
+
/** Items per page, when known. */
|
|
36
|
+
perPage?: number;
|
|
37
|
+
/** Total item count, when known. */
|
|
38
|
+
total?: number;
|
|
39
|
+
/** First item index on the current page (1-indexed), or 0 when the set is empty. */
|
|
40
|
+
from: number;
|
|
41
|
+
/** Last item index on the current page. */
|
|
42
|
+
to: number;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The "Showing X–Y of Z" status line, announced politely as the page changes. Renders nothing unless
|
|
46
|
+
* `total` and `perPage` are known on the root — or pass a render function as children for custom text
|
|
47
|
+
* (e.g. "Page X of Y"). Quieter than the controls by design.
|
|
48
|
+
*/
|
|
49
|
+
declare function PaginationInfo({
|
|
50
|
+
children,
|
|
51
|
+
className,
|
|
52
|
+
...props
|
|
53
|
+
}: Pagination.Info.Props): ReactElement | null;
|
|
54
|
+
/**
|
|
55
|
+
* The page-size cluster — a layout wrapper that holds a `Pagination.PageSizeLabel` and a
|
|
56
|
+
* `Pagination.PageSizeSelect` side by side. Compose them inside; the label and select are separate so
|
|
57
|
+
* the consumer can reorder, restyle, translate, or drop either independently.
|
|
58
|
+
*/
|
|
59
|
+
declare function PaginationPageSize({
|
|
60
|
+
className,
|
|
61
|
+
children,
|
|
62
|
+
...props
|
|
63
|
+
}: Pagination.PageSize.Props): ReactElement;
|
|
64
|
+
/**
|
|
65
|
+
* The label beside the page-size select (visible "Per page" micro-copy). Defaults to the localized
|
|
66
|
+
* label; pass children to override the text. Purely visual — the select carries its own accessible name.
|
|
67
|
+
*/
|
|
68
|
+
declare function PaginationPageSizeLabel({
|
|
69
|
+
className,
|
|
70
|
+
children,
|
|
71
|
+
...props
|
|
72
|
+
}: Pagination.PageSizeLabel.Props): ReactElement;
|
|
73
|
+
/**
|
|
74
|
+
* The page-size `Select` of "items per page" choices. Controlled via `value` + `onValueChange`;
|
|
75
|
+
* resetting the page to 1 on change is the consumer's call (do it in the handler).
|
|
76
|
+
*/
|
|
77
|
+
declare function PaginationPageSizeSelect({
|
|
78
|
+
value,
|
|
79
|
+
onValueChange,
|
|
80
|
+
options
|
|
81
|
+
}: Pagination.PageSizeSelect.Props): ReactElement;
|
|
82
|
+
/**
|
|
83
|
+
* The navigation landmark wrapping a welded `ButtonGroup` of nav buttons. Compose `Pagination.First`,
|
|
84
|
+
* `Pagination.Previous`, `Pagination.Next`, `Pagination.Last`, and/or `Pagination.Page` inside — use
|
|
85
|
+
* only Previous/Next for a simple control, or add First/Last/Page for the full set.
|
|
86
|
+
*/
|
|
87
|
+
declare function PaginationControls({
|
|
88
|
+
className,
|
|
89
|
+
children,
|
|
90
|
+
...props
|
|
91
|
+
}: Pagination.Controls.Props): ReactElement;
|
|
92
|
+
/** Jump to the first page. Disabled on page 1. */
|
|
93
|
+
declare function PaginationFirst(props: Pagination.NavButton.Props): ReactElement;
|
|
94
|
+
/** Step to the previous page. Disabled on page 1. */
|
|
95
|
+
declare function PaginationPrevious(props: Pagination.NavButton.Props): ReactElement;
|
|
96
|
+
/** Step to the next page. Disabled on the last page. */
|
|
97
|
+
declare function PaginationNext(props: Pagination.NavButton.Props): ReactElement;
|
|
98
|
+
/** Jump to the last page. Disabled on the last page. */
|
|
99
|
+
declare function PaginationLast(props: Pagination.NavButton.Props): ReactElement;
|
|
100
|
+
/**
|
|
101
|
+
* An editable page-number field (the "full" affordance). Type a page and press Enter or blur to commit;
|
|
102
|
+
* the value is clamped to the valid range and snaps back if cleared. Sits beside the nav buttons.
|
|
103
|
+
*/
|
|
104
|
+
declare function PaginationPage({
|
|
105
|
+
className,
|
|
106
|
+
...props
|
|
107
|
+
}: Pagination.Page.Props): ReactElement;
|
|
108
|
+
/** A vertical hairline between pagination clusters. Purely decorative — a quiet visual rule, hidden
|
|
109
|
+
* from assistive tech (the clusters are already distinct landmarks/labels). */
|
|
110
|
+
declare function PaginationSeparator({
|
|
111
|
+
className,
|
|
112
|
+
...props
|
|
113
|
+
}: Pagination.Separator.Props): ReactElement;
|
|
114
|
+
/**
|
|
115
|
+
* Page navigation controls. `Pagination.Root` owns the controlled page model and shares it with the
|
|
116
|
+
* parts: `Pagination.Controls` (the welded nav `ButtonGroup`) hosting `Pagination.First` / `Previous` /
|
|
117
|
+
* `Next` / `Last` and the editable `Pagination.Page`, plus the `Pagination.Info` status line, the
|
|
118
|
+
* `Pagination.PageSize` picker, and the `Pagination.Separator` divider.
|
|
119
|
+
*
|
|
120
|
+
* The runtime compound is a plain object (kept tree-shakeable); per-part prop types are exposed through
|
|
121
|
+
* the matching `Pagination` namespace — e.g. `Pagination.Root.Props`.
|
|
122
|
+
*/
|
|
123
|
+
declare const Pagination: {
|
|
124
|
+
/** Owns the controlled page model + shared context. `Pagination.Root.props({ size })` → its prop bag. */Root: typeof PaginationRoot & {
|
|
125
|
+
props: typeof rootProps;
|
|
126
|
+
}; /** The "Showing X–Y of Z" status line. `Pagination.Info.props()` → its prop bag. */
|
|
127
|
+
Info: typeof PaginationInfo & {
|
|
128
|
+
props: typeof infoProps;
|
|
129
|
+
}; /** The page-size cluster (compose `PageSizeLabel` + `PageSizeSelect`). `Pagination.PageSize.props()` → its prop bag. */
|
|
130
|
+
PageSize: typeof PaginationPageSize & {
|
|
131
|
+
props: typeof pageSizeProps;
|
|
132
|
+
}; /** The page-size label. `Pagination.PageSizeLabel.props()` → its prop bag. */
|
|
133
|
+
PageSizeLabel: typeof PaginationPageSizeLabel & {
|
|
134
|
+
props: typeof pageSizeLabelProps;
|
|
135
|
+
}; /** The page-size select control. */
|
|
136
|
+
PageSizeSelect: typeof PaginationPageSizeSelect; /** The nav landmark + welded `ButtonGroup`. `Pagination.Controls.props()` → its prop bag. */
|
|
137
|
+
Controls: typeof PaginationControls & {
|
|
138
|
+
props: typeof controlsProps;
|
|
139
|
+
}; /** First-page button. */
|
|
140
|
+
First: typeof PaginationFirst; /** Previous-page button. */
|
|
141
|
+
Previous: typeof PaginationPrevious; /** Next-page button. */
|
|
142
|
+
Next: typeof PaginationNext; /** Last-page button. */
|
|
143
|
+
Last: typeof PaginationLast; /** The editable page-number field. `Pagination.Page.props()` → its prop bag. */
|
|
144
|
+
Page: typeof PaginationPage & {
|
|
145
|
+
props: typeof pageProps;
|
|
146
|
+
}; /** A vertical divider between clusters. `Pagination.Separator.props()` → its prop bag. */
|
|
147
|
+
Separator: typeof PaginationSeparator & {
|
|
148
|
+
props: typeof separatorProps;
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* Per-part prop types. Types-only — it emits no runtime code and merges with the `Pagination` object
|
|
153
|
+
* above, so `Pagination.Root` is the component value while `Pagination.Root.Props` is its prop type.
|
|
154
|
+
*/
|
|
155
|
+
declare namespace Pagination {
|
|
156
|
+
/** Control scale — `sm` | `md`. */
|
|
157
|
+
type Size = PaginationSize;
|
|
158
|
+
/** The accessible-name + micro-copy overrides. */
|
|
159
|
+
type Labels = PaginationLabels;
|
|
160
|
+
/** The spreadable data-attribute prop bag every owned `Pagination.*.props()` returns (D12). */
|
|
161
|
+
type PartProps = PaginationPartProps;
|
|
162
|
+
namespace Root {
|
|
163
|
+
type Props = Omit<ComponentProps<"div">, "onChange"> & {
|
|
164
|
+
/**
|
|
165
|
+
* Current page, 1-indexed.
|
|
166
|
+
* @default 1
|
|
167
|
+
*/
|
|
168
|
+
page?: number; /** Called with the next page (already clamped to `[1, pageCount]`) when the user navigates. */
|
|
169
|
+
onPageChange?: (page: number) => void; /** Total item count across all pages — drives the info range and the last-page bound. */
|
|
170
|
+
total?: number; /** Items shown per page — drives the info range and the last-page bound. */
|
|
171
|
+
perPage?: number; /** The last reachable page, when you'd rather supply it than derive it from `total`/`perPage`. */
|
|
172
|
+
pageCount?: number;
|
|
173
|
+
/**
|
|
174
|
+
* Control scale, fed to the hosted Button/Input/Select.
|
|
175
|
+
* @default "md"
|
|
176
|
+
*/
|
|
177
|
+
size?: PaginationSize; /** Per-instance overrides for the accessible names + micro-copy. */
|
|
178
|
+
labels?: PaginationLabels;
|
|
179
|
+
};
|
|
180
|
+
/** Argument to the `Pagination.Root.props(...)` escape-hatch helper. */
|
|
181
|
+
type PropsArgs = PaginationRootPropsArgs;
|
|
182
|
+
}
|
|
183
|
+
namespace Info {
|
|
184
|
+
type Props = Omit<ComponentProps<"div">, "children"> & {
|
|
185
|
+
/** Render function for custom info text; omit for the default "Showing X–Y of Z". */children?: (state: PaginationInfoState) => ReactNode;
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
namespace PageSize {
|
|
189
|
+
/** The cluster wrapper — compose `Pagination.PageSizeLabel` and `Pagination.PageSizeSelect` inside. */
|
|
190
|
+
type Props = ComponentProps<"div">;
|
|
191
|
+
}
|
|
192
|
+
namespace PageSizeLabel {
|
|
193
|
+
/** The visible "Per page" label; children override the default localized text. */
|
|
194
|
+
type Props = ComponentProps<"span">;
|
|
195
|
+
}
|
|
196
|
+
namespace PageSizeSelect {
|
|
197
|
+
type Props = {
|
|
198
|
+
/** The current page size. */value: number; /** Called with the chosen page size. */
|
|
199
|
+
onValueChange: (size: number) => void; /** The available page-size choices. @default [10, 25, 50, 100] */
|
|
200
|
+
options?: readonly number[];
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
namespace Controls {
|
|
204
|
+
type Props = ComponentProps<"nav">;
|
|
205
|
+
}
|
|
206
|
+
namespace NavButton {
|
|
207
|
+
type Props = Omit<Button.Props, "iconOnly" | "startIcon" | "endIcon" | "onClick" | "children">;
|
|
208
|
+
}
|
|
209
|
+
namespace Page {
|
|
210
|
+
type Props = ComponentProps<"div">;
|
|
211
|
+
}
|
|
212
|
+
namespace Separator {
|
|
213
|
+
type Props = ComponentProps<"div">;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
//#endregion
|
|
217
|
+
export { Pagination };
|