@inkbar/core 0.8.0 → 0.10.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/dist/dom.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { A as DocumentSource, Bn as Point, Ct as AnnotationInput, D as InkStatus, Dt as AnnotationType, E as InkDocument, Hn as Rect, I as FormController, In as PageInfo, K as PluginHistory, Mt as FreeTextAnnotation, O as OpenOptions, R as InkError, Rn as PdfAssets, Sn as FormAction, Vn as Quad, Wt as LineEnding, X as AnnotationStore, Y as AnnotationEdit, Zt as NoteAnnotation, _ as ScopedToolStyle, _t as cssVariableDefaults, a as SignatureOptions, b as StyleProps, bt as Annotation, gt as AnnotationDefaults, h as CurrentStyle, i as SignatureLibrary, j as SearchHit, jn as Readable, mn as TextMarkupAnnotation, nt as RecordChange, o as SignatureStore, rt as RecordStore, s as SignatureTemplate, t as signField, tt as RecordBase, v as StyleGroup, x as ToolStyle, xn as FieldsMode, y as StyleKey, zn as Matrix } from "./sign-47QLNaqQ.mjs";
1
+ import { A as DocumentSource, Bn as Matrix, Cn as FormAction, D as InkStatus, E as InkDocument, Gt as LineEnding, Hn as Quad, L as FormController, Ln as PageInfo, Mn as Readable, Nt as FreeTextAnnotation, O as OpenOptions, Ot as AnnotationType, P as isBlankQuery, Qt as NoteAnnotation, Sn as FieldsMode, Un as Rect, Vn as Point, X as AnnotationEdit, Z as AnnotationStore, _ as ScopedToolStyle, _t as AnnotationDefaults, a as SignatureOptions, b as StyleProps, h as CurrentStyle, hn as TextMarkupAnnotation, i as SignatureLibrary, it as RecordStore, j as SearchHit, nt as RecordBase, o as SignatureStore, q as PluginHistory, rt as RecordChange, s as SignatureTemplate, t as signField, v as StyleGroup, vt as cssVariableDefaults, wt as AnnotationInput, x as ToolStyle, xt as Annotation, y as StyleKey, z as InkError, zn as PdfAssets } from "./sign-BTbtPHbM.mjs";
2
2
  import { IconNode } from "@inkbar/icons";
3
3
  //#region src/dom/transform.d.ts
4
4
  type ViewRotation = 0 | 90 | 180 | 270;
@@ -162,6 +162,27 @@ interface ViewportKeysOptions {
162
162
  */
163
163
  export declare function attachViewportKeys(el: HTMLElement, opts: ViewportKeysOptions): () => void;
164
164
  //#endregion
165
+ //#region src/dom/file-actions.d.ts
166
+ interface DownloadOptions {
167
+ /** The name to save under. Default: the document's `fileName`. */
168
+ filename?: string;
169
+ }
170
+ /** Saves the document's file through the browser's download. */
171
+ export declare function downloadDocument(doc: InkDocument, opts?: DownloadOptions): Promise<void>;
172
+ /**
173
+ * Prints the document's file: it loads into a hidden frame and the browser's own PDF viewer
174
+ * prints it, so text stays sharp. Where a frame cannot print (iOS), the PDF opens in a new tab.
175
+ * Resolves once the print dialog has been asked for.
176
+ */
177
+ export declare function printDocument(doc: InkDocument): Promise<void>;
178
+ /**
179
+ * Ctrl or Cmd+P prints and Ctrl or Cmd+S downloads, for keys pressed anywhere inside `el`,
180
+ * while `doc()` gives a ready document. Then the key is taken from the browser, which would
181
+ * print or save the web page; otherwise it is left alone. Returns a function that removes the
182
+ * listener.
183
+ */
184
+ export declare function attachFileKeys(el: HTMLElement, doc: () => InkDocument | null | undefined): () => void;
185
+ //#endregion
165
186
  //#region src/dom/history-keys.d.ts
166
187
  /** A flag as a plain value, or as a readable such as core's `History.canUndo`. */
167
188
  type Flag = boolean | {
@@ -385,6 +406,8 @@ interface AnnotationLink<T extends RecordBase> {
385
406
  //#endregion
386
407
  //#region src/dom/plugins/api/records.d.ts
387
408
  interface Records<T extends RecordBase> {
409
+ /** The store's key, `<plugin>.<name>`. */
410
+ readonly key: string;
388
411
  /** The open document's records; `[]` while none is open. Emits when the document changes. */
389
412
  readonly list: Readable<readonly T[]>;
390
413
  all(): readonly T[];
@@ -432,6 +455,12 @@ interface CardSpec {
432
455
  swatch?: string;
433
456
  /** Text under the meta line (`.ink-card-body`). */
434
457
  body?: string;
458
+ /** A line of context with the match marked, after `body` (`.ink-card-excerpt`). */
459
+ excerpt?: {
460
+ before: string;
461
+ match: string;
462
+ after: string;
463
+ };
435
464
  /**
436
465
  * One button per key, in order (`.ink-card-actions`). The first takes focus on open and is
437
466
  * styled as the primary action. Each action runs synchronously in one undo step: writes after
@@ -463,9 +492,9 @@ interface MarksOptions<T extends RecordBase & {
463
492
  /** Classes every mark gets. */
464
493
  className?: string;
465
494
  /**
466
- * More attributes (`data-*`, `aria-*`). `data-record`, `data-plugin` and `aria-label` stay
467
- * core's, and so do `aria-haspopup` and `aria-expanded` on a mark with a card; `style`,
468
- * `class` and `type` are skipped (use `style` and `className`).
495
+ * More attributes (`data-*`, `aria-*`). `data-record`, `data-plugin`, `data-selected` and
496
+ * `aria-label` stay core's, and so do `aria-haspopup` and `aria-expanded` on a mark with a
497
+ * card; `style`, `class` and `type` are skipped (use `style` and `className`).
469
498
  */
470
499
  attrs?(record: T): Record<string, string>;
471
500
  /**
@@ -541,6 +570,8 @@ interface ViewerSearch {
541
570
  setMatchCase(on: boolean): void;
542
571
  next(): void;
543
572
  previous(): void;
573
+ /** Makes hit `index` current and scrolls to it as `next()` does. Out of range or non-integer does nothing. */
574
+ select(index: number): void;
544
575
  /** Hides the bar and clears the hits; the query and match case are kept. */
545
576
  close(): void;
546
577
  }
@@ -580,9 +611,10 @@ interface ToolOptions {
580
611
  export declare function createToolOptions(tools?: readonly Tool[]): ToolOptions;
581
612
  //#endregion
582
613
  //#region src/dom/tools/controller.d.ts
583
- type BuiltinToolId = 'select-text' | 'select' | 'highlight' | 'redact-area' | 'note' | 'shape' | 'freetext' | 'draw' | 'sketch' | 'signature';
584
- /** A built-in tool's id, or any id a host registers its own tool under. */
585
- type ToolId = BuiltinToolId | (string & {});
614
+ /** The tools every viewer has. Creation tools are the host's to pass. */
615
+ type CoreToolId = 'select-text' | 'select';
616
+ /** A core tool's id, or any id a host registers a tool under. */
617
+ type ToolId = CoreToolId | (string & {});
586
618
  /**
587
619
  * A one-shot tool switches back to `select-text` once it has made something and the user moves
588
620
  * on; a sticky tool stays on. A tool without a kind is sticky.
@@ -875,6 +907,47 @@ interface PluginLayers {
875
907
  */
876
908
  export declare function createPluginLayers(source: LayerSource): PluginLayers;
877
909
  //#endregion
910
+ //#region src/dom/plugins/registry.d.ts
911
+ /** What one `plugin.marks` call drew its records with. */
912
+ interface MarksRegistration<T extends RecordBase & {
913
+ page: number;
914
+ } = any> {
915
+ /** The id of the plugin that called `marks`. */
916
+ plugin: string;
917
+ /** Whether `record` gets a mark from this call. */
918
+ where(record: T): boolean;
919
+ label(record: T): string;
920
+ rect(record: T): Rect;
921
+ card?(record: T): CardSpec;
922
+ className?: string;
923
+ style?: MarksOptions<T>['style'];
924
+ /** The plugin's `history.batch`: everything `fn` changes is one undo step. */
925
+ batch(fn: () => void): void;
926
+ }
927
+ interface MarksRegistry {
928
+ /** Registers `reg` under `key`; returns a function that removes it. */
929
+ add(key: string, reg: MarksRegistration): () => void;
930
+ /** Registrations for `key`, in call order. */
931
+ of(key: string): readonly MarksRegistration[];
932
+ /** The first registration whose `where` passes, or undefined. */
933
+ resolve<T extends RecordBase & {
934
+ page: number;
935
+ }>(key: string, record: T): MarksRegistration<T> | undefined;
936
+ /** Keys that have registrations. */
937
+ keys(): readonly string[];
938
+ /** Calls `listener` after every add and remove; returns a stop function. */
939
+ watch(listener: () => void): () => void;
940
+ }
941
+ interface RecordSelection {
942
+ /** The selected record's id, or null. */
943
+ readonly selected: Readable<string | null>;
944
+ /**
945
+ * Selects the record with `id`, or clears with null. An id the open document's store lacks,
946
+ * or whose record resolves to no registration, changes nothing.
947
+ */
948
+ select(id: string | null): void;
949
+ }
950
+ //#endregion
878
951
  //#region src/dom/plugins/host.d.ts
879
952
  interface PluginHostOptions {
880
953
  plugins: readonly InkPlugin[];
@@ -891,7 +964,31 @@ interface PluginHostOptions {
891
964
  /** The viewer's search; without one, `ctx.search` is inert. */
892
965
  search?: ViewerSearch;
893
966
  }
967
+ /**
968
+ * A plugin's records as the host app sees them: the plugin's own handle without `annotates`
969
+ * (a plugin links its records to marks in `setup`), plus `batch` to make several writes one
970
+ * undo step. `in(doc)` gives a host handle too.
971
+ */
972
+ type HostRecords<T extends RecordBase> = Omit<Records<T>, 'annotates' | 'in'> & {
973
+ /** The same handle bound to `doc`'s store, as `Records.in` binds it. */
974
+ in(doc: InkDocument): HostRecords<T>;
975
+ /** Makes everything `fn` changes one undo step. */
976
+ batch(fn: () => void): void;
977
+ };
894
978
  interface PluginHost extends LayerSource {
979
+ /**
980
+ * The records a plugin keeps under `key` (`<plugin>.<name>`), following the open document.
981
+ * The same handle on each call. An unknown key gives an empty handle that ignores writes, and
982
+ * logs a warning once.
983
+ */
984
+ records<T extends RecordBase>(key: string): HostRecords<T>;
985
+ /** What each `plugin.marks` call drew, by records key. */
986
+ readonly marks: MarksRegistry;
987
+ /**
988
+ * The selected record under `key`, shared by the marks, every list and the host app. The
989
+ * same object on each call.
990
+ */
991
+ selection(key: string): RecordSelection;
895
992
  readonly commands: ReadonlyMap<string, Command>;
896
993
  command(id: string): Command | undefined;
897
994
  readonly tools: readonly Tool[];
@@ -1010,6 +1107,9 @@ interface PageMount {
1010
1107
  */
1011
1108
  export declare function createPageMount(opts: PageMountOptions): PageMount;
1012
1109
  //#endregion
1110
+ //#region src/dom/tools/draw.d.ts
1111
+ export declare function drawTool(): Tool;
1112
+ //#endregion
1013
1113
  //#region src/dom/tools/freetext.d.ts
1014
1114
  /** Width of a box placed with a click or Enter, user-space points. */
1015
1115
  export declare const DEFAULT_FREETEXT_WIDTH = 144;
@@ -1081,12 +1181,28 @@ export declare function shapeTool(): Tool<ShapeOptions>;
1081
1181
  //#region src/dom/tools/signature.d.ts
1082
1182
  export declare function signatureTool(): Tool<SignatureOptions>;
1083
1183
  //#endregion
1184
+ //#region src/dom/tools/sketch.d.ts
1185
+ export declare function sketchTool(): Tool;
1186
+ //#endregion
1187
+ //#region src/dom/tools/unknown.d.ts
1188
+ /**
1189
+ * The error for a tool id nobody registered, naming the ids that were. The tool controller logs
1190
+ * it rather than throw, so a toolbar naming a missing tool shows the control as it is.
1191
+ */
1192
+ export declare function unknownTool(id: ToolId, registered: readonly ToolId[]): InkError;
1193
+ //#endregion
1084
1194
  //#region src/dom/tools/index.d.ts
1085
- /** Fresh instances of every built-in tool. */
1086
- export declare function builtinTools(): Tool[];
1087
- /** The built-in tools with a host's tools added, a host tool replacing a built-in by id. */
1195
+ /** Fresh instances of every creation tool, in toolbar order. */
1196
+ export declare function allTools(): Tool[];
1197
+ /**
1198
+ * `select-text` and `select` with a host's tools added by id, a later tool replacing an earlier
1199
+ * one with its id.
1200
+ */
1088
1201
  export declare function withHostTools(host?: readonly Tool[]): Tool[];
1089
- /** Listens on `ctx.root` and routes pointer and key events to the active tool. */
1202
+ /**
1203
+ * Listens on `ctx.root` and routes pointer and key events to the active tool. Without `tools`
1204
+ * it has only `select-text` and `select`.
1205
+ */
1090
1206
  export declare function createToolController(opts: Omit<ToolControllerOptions, 'tools'> & {
1091
1207
  tools?: Tool[];
1092
1208
  }): ToolController;
@@ -1097,7 +1213,7 @@ interface ToolStyleTracker {
1097
1213
  }
1098
1214
  /**
1099
1215
  * A `ToolStyle` whose active group is the style group of the active tool among `tools` (the
1100
- * built-ins plus a host's). The engine makes one when it is not handed a style; a binding
1216
+ * select tools plus a host's). The engine makes one when it is not handed a style; a binding
1101
1217
  * makes its own per document, so its style controls work before the viewport mounts.
1102
1218
  */
1103
1219
  export declare function trackToolStyle(opts: {
@@ -1105,15 +1221,15 @@ export declare function trackToolStyle(opts: {
1105
1221
  history: {
1106
1222
  batch(fn: () => void): void;
1107
1223
  };
1108
- /** Host tools, as passed to `mountViewer`. */
1224
+ /** The creation tools, as passed to `mountViewer`. */
1109
1225
  tools?: readonly Tool[] | undefined;
1110
1226
  tool?: ToolId | undefined;
1111
1227
  }): ToolStyleTracker;
1112
1228
  //#endregion
1113
1229
  //#region src/dom/ui.d.ts
1114
1230
  /**
1115
- * Accessible names of the built-in tools, as the toolbar buttons announce them. A host tool has
1116
- * no entry: its button takes the host's `label`, else the tool id.
1231
+ * Accessible names of the two core select tools, as the toolbar buttons announce them. Every
1232
+ * other tool has no entry: its button takes the tool's own `label`, else the tool id.
1117
1233
  */
1118
1234
  export declare const TOOL_LABELS: Readonly<Partial<Record<ToolId, string>>>;
1119
1235
  /**
@@ -1594,8 +1710,9 @@ interface MountViewerOptions {
1594
1710
  buffer?: number;
1595
1711
  tool?: ToolId;
1596
1712
  /**
1597
- * Host tools, added to the built-ins. A host tool with a built-in's id replaces it. The same
1598
- * instances are reused when the engine rebuilds.
1713
+ * The creation tools (`allTools()`, or the ones the host imports); `select-text` and `select`
1714
+ * are always present. A later tool replaces an earlier one with its id, so a host tool can
1715
+ * replace a core one. The same instances are reused when the engine rebuilds.
1599
1716
  */
1600
1717
  tools?: Tool[];
1601
1718
  /**
@@ -1761,8 +1878,21 @@ interface CreateViewerOptions extends Omit<MountViewerOptions, 'container' | 'do
1761
1878
  * Form field values; defaults to uncontrolled, starting from the PDF's. Controlled:
1762
1879
  * `{ mode: 'controlled', initial, onChange }`, where `onChange` hears every commit with the
1763
1880
  * full map and the host pushes back with `viewer.form.get()?.setControlledValue(next)`.
1881
+ * `initial` applies to every document the viewer opens; push your values once the new one is ready.
1764
1882
  */
1765
1883
  fields?: FieldsMode;
1884
+ /**
1885
+ * The annotation list; defaults to uncontrolled. Controlled: `{ mode: 'controlled', initial,
1886
+ * onChange }`, where the host owns the session annotations and `onChange` hears every
1887
+ * proposed list. Nothing shows until the host pushes it back with
1888
+ * `viewer.document.get()?.annotations.setControlledValue(next)`. Embedded annotations stay in
1889
+ * the file and never pass through `onChange`. `initial` applies to every document the viewer
1890
+ * opens, including after `viewer.open()`. A host that keeps its own list pushes it with
1891
+ * `viewer.document.get()?.annotations.setControlledValue(list)` once the new document is
1892
+ * ready (in `onReady`). Undo and redo history is inert in controlled
1893
+ * mode: the host owns the list, so it owns undo too.
1894
+ */
1895
+ annotations?: OpenOptions['annotations'];
1766
1896
  /**
1767
1897
  * Plugins, set up once for the viewer's life. Their tools join the viewer's tools, their
1768
1898
  * decoration and page layers apply to every document, and their commands are placed with
@@ -1816,6 +1946,11 @@ interface Viewer {
1816
1946
  * `open()` runs the search and draws the highlights even when no find bar is mounted.
1817
1947
  */
1818
1948
  readonly search: ViewerSearch;
1949
+ /**
1950
+ * The records a plugin keeps under `key` (`<plugin>.<name>`), following the open document;
1951
+ * the same handle on each call. An unknown key gives an empty handle and logs a warning once.
1952
+ */
1953
+ records<T extends RecordBase>(key: string): HostRecords<T>;
1819
1954
  /**
1820
1955
  * Opens another document in place; the previous one is destroyed. Latest call wins.
1821
1956
  * `password` is used for this load only; without it, the constructor's `password` applies.
@@ -1823,6 +1958,18 @@ interface Viewer {
1823
1958
  open(source: DocumentSource, opts?: {
1824
1959
  password?: string;
1825
1960
  }): void;
1961
+ /**
1962
+ * Saves the open document's file through the browser's download, under its `fileName` or
1963
+ * `opts.filename`. Today that is the file as it was opened, without this session's
1964
+ * annotations. Does nothing while no document is open.
1965
+ */
1966
+ download(opts?: DownloadOptions): Promise<void>;
1967
+ /**
1968
+ * Prints the open document's file with the browser's own PDF viewer; on iOS the PDF opens
1969
+ * in a new tab instead. As with `download`, today that is the file as it was opened. Does
1970
+ * nothing while no document is open.
1971
+ */
1972
+ print(): Promise<void>;
1826
1973
  destroy(): void;
1827
1974
  }
1828
1975
  export declare function createViewer(el: HTMLElement, opts: CreateViewerOptions): Viewer;
@@ -1851,6 +1998,14 @@ export declare function pageSelectionText(root: HTMLElement): string;
1851
1998
  * @internal Shared with the framework bindings.
1852
1999
  */
1853
2000
  export declare function handleFindKey(e: KeyboardEvent, controller: SearchController, selection: () => string): boolean;
2001
+ /**
2002
+ * Enter in a search field other than the find bar's (the search results' own): steps to the
2003
+ * next match, Shift+Enter to the previous, as in the find bar. Returns whether it handled the
2004
+ * key; when it did, the default is prevented.
2005
+ *
2006
+ * @internal Shared with the framework bindings.
2007
+ */
2008
+ export declare function handleResultsFieldKey(e: KeyboardEvent, search: Pick<ViewerSearch, 'next' | 'previous'>): boolean;
1854
2009
  //#endregion
1855
2010
  //#region src/dom/search/find-text.d.ts
1856
2011
  /**
@@ -1871,6 +2026,325 @@ export declare function findCountText(s: SearchState): string;
1871
2026
  */
1872
2027
  export declare function findAnnouncer(): (s: SearchState) => string;
1873
2028
  //#endregion
2029
+ //#region src/dom/records/source.d.ts
2030
+ /** One thing a list shows: an id unique in the list, its 0-based page, and where on it. */
2031
+ interface ListItem {
2032
+ id: string;
2033
+ page: number;
2034
+ /** In user space. */
2035
+ rect?: Rect;
2036
+ }
2037
+ interface RecordListSource<I extends ListItem = ListItem> {
2038
+ /** What is listed, filtered and in order. */
2039
+ readonly items: Readable<readonly I[]>;
2040
+ /** The card `item` shows, or null for none. */
2041
+ card(item: I): CardSpec | null;
2042
+ /** The selected item's id, or null. */
2043
+ readonly selected: Readable<string | null>;
2044
+ select(id: string | null): void;
2045
+ /** Scrolls the viewport to the item; for records, to its mark's rect. */
2046
+ reveal(item: I): void;
2047
+ /** Runs an action as one undo step. */
2048
+ run(item: I, fn: () => void): void;
2049
+ /**
2050
+ * Whether the change to `items` being emitted came from undo or redo, or from another
2051
+ * document opening: a change nobody made from the list, which the list does not announce.
2052
+ */
2053
+ readonly replaying: () => boolean;
2054
+ /**
2055
+ * Polite text to announce, in place of the list's own "N items". A source whose items change
2056
+ * as a scan runs announces once it settles.
2057
+ */
2058
+ readonly announcement?: Readable<string>;
2059
+ }
2060
+ interface RecordsSourceOptions<T> {
2061
+ /** The card each record shows. Default: its mark's card, else its mark's label (or id) and no actions. */
2062
+ card?(record: T): CardSpec;
2063
+ /** Which records to list. Default: those that have a mark, or every record when no `marks` call covers them. */
2064
+ where?(record: T): boolean;
2065
+ /** The order. Default: page, then top to bottom and left to right by the mark's rect. */
2066
+ sort?(a: T, b: T): number;
2067
+ }
2068
+ interface RecordsSourceDeps {
2069
+ pluginHost: PluginHost;
2070
+ /** The viewport `reveal` scrolls; null while none is mounted. */
2071
+ viewport: Readable<Viewport | null>;
2072
+ }
2073
+ /**
2074
+ * The records a plugin keeps under `key` (`<plugin>.<name>`), as its marks show them: each
2075
+ * record takes its card, label and rect from the first `marks` registration whose `where` it
2076
+ * passes, and its actions run in that plugin's undo step. Follows the open document. The
2077
+ * selection is the host's for `key`, shared with the marks and every other list.
2078
+ */
2079
+ export declare function recordsSource<T extends RecordBase & {
2080
+ page: number;
2081
+ }>(deps: RecordsSourceDeps, key: string, opts?: RecordsSourceOptions<T>): RecordListSource<T>;
2082
+ export declare function searchSource(search: ViewerSearch): RecordListSource;
2083
+ //#endregion
2084
+ //#region src/dom/records/list.d.ts
2085
+ interface RecordListRow {
2086
+ item: ListItem;
2087
+ card: CardSpec | null;
2088
+ selected: boolean;
2089
+ }
2090
+ interface RecordListController {
2091
+ /** One per listed item, in order. */
2092
+ readonly rows: Readable<readonly RecordListRow[]>;
2093
+ readonly count: Readable<number>;
2094
+ /** Polite live-region text: "3 items" when a change made from the app adds or removes rows. */
2095
+ readonly announcement: Readable<string>;
2096
+ /**
2097
+ * Binds the element holding the rows: each row is an element with `data-ink-record` set to
2098
+ * its item's id. Handles clicks, arrow keys, Home and End, Enter and Escape inside it, keeps
2099
+ * one row as the Tab stop (it sets the rows' `tabindex`: don't render one), and scrolls the
2100
+ * selected row into view. `el` is where focus goes when the last row goes; it gets
2101
+ * `tabindex="-1"` unless it has one. Attaching another element unbinds the previous one.
2102
+ * Returns the unbind.
2103
+ */
2104
+ attach(el: HTMLElement): () => void;
2105
+ /** Selects the item and scrolls the viewport to it; focus stays where it is. */
2106
+ choose(id: string): void;
2107
+ /** Runs the card action named `action` of item `id` as one undo step. */
2108
+ act(id: string, action: string): void;
2109
+ destroy(): void;
2110
+ }
2111
+ export declare function createRecordListController(source: RecordListSource): RecordListController;
2112
+ /**
2113
+ * The records a plugin keeps under `records` (`<plugin>.<name>`) as a list of cards, the same
2114
+ * cards its marks open, with their actions. Selecting a card selects the record's mark and
2115
+ * scrolls the viewer to it; activating a mark selects its card. Give it a height (it fills its
2116
+ * parent's) and place it anywhere, a sidebar panel for instance. It stops when the viewer is
2117
+ * destroyed.
2118
+ */
2119
+ export declare function createRecordList(viewer: Viewer, opts: {
2120
+ records: string;
2121
+ } & RecordsSourceOptions<any>): HTMLElement;
2122
+ //#endregion
2123
+ //#region src/dom/records/search-results.d.ts
2124
+ interface SearchResultsOptions {
2125
+ /** Show a query field above the results. Default true; turn it off when a find bar is on the page. */
2126
+ field?: boolean;
2127
+ }
2128
+ /**
2129
+ * One card per search hit: its page, its place on that page and the text around it. Choosing
2130
+ * a card makes its hit current, as the find bar's next and previous do, and the find bar's
2131
+ * current hit is the selected card. The count shows the scan's progress and "No results". It stops when the
2132
+ * viewer is destroyed.
2133
+ */
2134
+ export declare function createSearchResults(viewer: Viewer, opts?: SearchResultsOptions): HTMLElement;
2135
+ //#endregion
2136
+ //#region src/dom/sidebar/controller.d.ts
2137
+ type SidebarLayout = 'rail' | 'tabs' | 'stack';
2138
+ type SidebarSide = 'left' | 'right';
2139
+ interface SidebarPanelInfo {
2140
+ id: string;
2141
+ label: string;
2142
+ icon?: IconNode;
2143
+ /** Hidden when empty or 0. */
2144
+ badge?: string | number;
2145
+ }
2146
+ /** rail/tabs: the open id or null; stack: the expanded ids. */
2147
+ type SidebarOpen = string | null | readonly string[];
2148
+ interface SidebarControllerOptions {
2149
+ /** Default `'rail'`. */
2150
+ layout?: SidebarLayout;
2151
+ /** Default `'left'`. */
2152
+ side?: SidebarSide;
2153
+ panels: readonly SidebarPanelInfo[];
2154
+ /** Controlled when given: `toggle` only reports through `onOpenChange`. */
2155
+ open?: SidebarOpen;
2156
+ onOpenChange?(open: SidebarOpen): void;
2157
+ /**
2158
+ * Default true. False hides the whole sidebar (the root gets `hidden`) and keeps its open
2159
+ * panels, their content and scroll, for when it shows again. Your code decides: a results
2160
+ * sidebar shown only while there are results, for instance.
2161
+ */
2162
+ visible?: boolean;
2163
+ /**
2164
+ * True while a binding's panels are still registering, one by one, before it has mounted.
2165
+ * Meanwhile a controlled `open` id not in `panels` yet is kept rather than taken for a
2166
+ * removed panel, and `rootAttrs()` reports the open state expected once they are all in.
2167
+ * Set it back to false (through `update`) once the panels are in: an id still missing then
2168
+ * falls back as a removed one does.
2169
+ */
2170
+ pending?: boolean;
2171
+ /**
2172
+ * Makes the ids `<idPrefix>-trigger-<id>` and `<idPrefix>-panel-<id>`, the same on the server
2173
+ * and the client. Without it they come from a counter.
2174
+ */
2175
+ idPrefix?: string;
2176
+ }
2177
+ interface SidebarState {
2178
+ layout: SidebarLayout;
2179
+ side: SidebarSide;
2180
+ panels: readonly SidebarPanelInfo[];
2181
+ /** The open panels' ids, in panel order: at most one for rail and tabs. */
2182
+ open: readonly string[];
2183
+ visible: boolean;
2184
+ }
2185
+ interface SidebarController {
2186
+ readonly state: Readable<SidebarState>;
2187
+ /**
2188
+ * Takes new options. `open` given makes the sidebar controlled. When the panels no longer
2189
+ * hold an open one, rail and tabs open the first remaining and stack drops it; the new value
2190
+ * goes to `onOpenChange`, controlled or not.
2191
+ */
2192
+ update(opts: Partial<SidebarControllerOptions>): void;
2193
+ /** What activating `id`'s trigger does: rail opens or closes, tabs switch, stack expands or collapses. */
2194
+ toggle(id: string): void;
2195
+ isOpen(id: string): boolean;
2196
+ /**
2197
+ * `data-ink-sidebar`, `data-layout`, `data-side` and `data-state` (`open` while any panel is,
2198
+ * and while pending and uncontrolled, as the first panel will open) for the root, and
2199
+ * `hidden` while it is not `visible`.
2200
+ */
2201
+ rootAttrs(): Record<string, string>;
2202
+ /** ARIA for the element holding the triggers: a tablist for rail and tabs. */
2203
+ tablistAttrs(): Record<string, string>;
2204
+ /** ARIA for the rail button / tab / stack header of `id`. */
2205
+ triggerAttrs(id: string): Record<string, string>;
2206
+ /**
2207
+ * ARIA for `id`'s panel, including `hidden` when closed, and its sidebar's `data-layout`: the
2208
+ * theme shows the panel's title (`.ink-sidebar-panel-title`) in the rail only.
2209
+ */
2210
+ panelAttrs(id: string): Record<string, string>;
2211
+ /**
2212
+ * Roving tabindex, arrow keys, Home and End, and clicks over `[data-ink-sidebar-trigger]`
2213
+ * inside `el`, looked up at event time so re-rendered triggers keep working. Returns the
2214
+ * function that unbinds.
2215
+ */
2216
+ bindTriggers(el: HTMLElement): () => void;
2217
+ destroy(): void;
2218
+ }
2219
+ /** The text a badge shows, or null when it is hidden (empty or 0). */
2220
+ export declare function sidebarBadge(badge: string | number | undefined): string | null;
2221
+ export declare function createSidebarController(opts: SidebarControllerOptions): SidebarController;
2222
+ //#endregion
2223
+ //#region src/dom/sidebar/sidebar.d.ts
2224
+ /**
2225
+ * A sidebar of `opts.panels` in `opts.layout` (`'rail'` by default) on `opts.side`, showing
2226
+ * `opts.content[id]` in each panel. Returns the root element and its controller, which opens
2227
+ * panels from code (`toggle`, `update({ open })`) and takes new panels or a new layout.
2228
+ */
2229
+ export declare function createSidebar(opts: SidebarControllerOptions & {
2230
+ content: Record<string, HTMLElement>;
2231
+ }): {
2232
+ element: HTMLElement;
2233
+ controller: SidebarController;
2234
+ };
2235
+ //#endregion
2236
+ //#region src/dom/thumbnails/thumbnail.d.ts
2237
+ /** Width in CSS pixels when neither `width` nor `height` is given; the theme's `--ink-thumbnail-width`. */
2238
+ export declare const THUMBNAIL_WIDTH = 120;
2239
+ interface ThumbnailDeps {
2240
+ document: Readable<InkDocument | null>;
2241
+ /** Where plugin marks come from. Without it, the thumbnail draws no marks. */
2242
+ pluginHost?: Readable<PluginHost | null>;
2243
+ }
2244
+ interface ThumbnailOptions {
2245
+ /** Zero-based page index. */
2246
+ page: number;
2247
+ /** Width in CSS pixels; the height follows the page's shape. Wins over `height`. */
2248
+ width?: number | undefined;
2249
+ /** Height in CSS pixels, used when `width` is absent; the width follows the page's shape. */
2250
+ height?: number | undefined;
2251
+ /** Draw the page's annotations. Default true. */
2252
+ annotations?: boolean | undefined;
2253
+ /** Draw plugin marks. Default true. */
2254
+ marks?: boolean | undefined;
2255
+ /** The accessible name. Default "Page N", N being `page + 1`. */
2256
+ label?: string | undefined;
2257
+ }
2258
+ interface ThumbnailPainter {
2259
+ /** Applies changed options; the others stay as they were. An option given as `undefined` goes back to its default. */
2260
+ update(opts: Partial<ThumbnailOptions>): void;
2261
+ /** Stops painting and removes everything the painter added to the element. */
2262
+ destroy(): void;
2263
+ }
2264
+ /** CSS size and zoom for `page` fitted to width or height (width wins when both), /Rotate applied. */
2265
+ export declare function thumbnailSize(page: PageInfo, size: {
2266
+ width?: number | undefined;
2267
+ height?: number | undefined;
2268
+ }): {
2269
+ width: number;
2270
+ height: number;
2271
+ zoom: number;
2272
+ };
2273
+ /**
2274
+ * Paints page `opts.page` of the open document into `el`. The element keeps its own children
2275
+ * and classes; the painter appends its layers after them.
2276
+ */
2277
+ export declare function createThumbnailPainter(el: HTMLElement, deps: ThumbnailDeps, initial: ThumbnailOptions): ThumbnailPainter;
2278
+ /**
2279
+ * A thumbnail of page `opts.page` of `viewer`'s open document, with its annotations and plugin
2280
+ * marks. Place it anywhere; it stops when the viewer is destroyed.
2281
+ */
2282
+ export declare function createThumbnail(viewer: Viewer, opts: ThumbnailOptions): HTMLElement;
2283
+ //#endregion
2284
+ //#region src/dom/thumbnails/list.d.ts
2285
+ interface ThumbnailsDeps extends ThumbnailDeps {
2286
+ /** The viewport whose current page the list follows; null while none is mounted. */
2287
+ viewport: Readable<Viewport | null>;
2288
+ }
2289
+ interface ThumbnailsOptions {
2290
+ /** Zero-based pages to list, in this order. Default: every page. Missing pages and repeats are dropped. */
2291
+ pages?: readonly number[] | undefined;
2292
+ /**
2293
+ * Thumbnail width in CSS pixels. Default: the list's width less a 16px gutter on each side,
2294
+ * following the list as it resizes (`THUMBNAIL_WIDTH` until the list is attached and shown).
2295
+ */
2296
+ width?: number | undefined;
2297
+ /** Draw each page's annotations. Default true. */
2298
+ annotations?: boolean | undefined;
2299
+ /** Draw plugin marks. Default true. */
2300
+ marks?: boolean | undefined;
2301
+ }
2302
+ interface ThumbnailsState {
2303
+ /** What is listed: zero-based pages, in list order. */
2304
+ pages: readonly number[];
2305
+ /** The viewport's current page, -1 with no viewport. */
2306
+ current: number;
2307
+ /** Indexes into `pages` to mount, `end` exclusive. Empty until `attach`. */
2308
+ window: {
2309
+ start: number;
2310
+ end: number;
2311
+ };
2312
+ /** Top of each item in CSS px from the top of the list; the last entry is the total height. */
2313
+ offsets: readonly number[];
2314
+ /** The width each thumbnail is drawn at, in CSS px: `width`, else the measured fit. */
2315
+ width: number;
2316
+ }
2317
+ interface ThumbnailsController {
2318
+ readonly state: Readable<ThumbnailsState>;
2319
+ /** Applies changed options; the others stay as they were. */
2320
+ update(opts: Partial<ThumbnailsOptions>): void;
2321
+ /**
2322
+ * Binds the list's scroll element: the element that scrolls, with item `i` positioned at
2323
+ * `offsets[i]` from the top of its content. Follows its scrolling and size to move the
2324
+ * window, and handles clicks, keys and the Tab stop over `[data-ink-thumbnail-item]` buttons
2325
+ * inside it (`data-ink-thumbnail-item` is the page). It sets the items' `tabindex`: don't
2326
+ * render one. Attaching another element unbinds the previous one. Returns the unbind.
2327
+ */
2328
+ attach(scroller: HTMLElement): () => void;
2329
+ /**
2330
+ * The attributes of the list item wrapping item `index` (into `pages`): `role="listitem"`
2331
+ * and, as only the window is mounted, `aria-setsize` and `aria-posinset` for its place in
2332
+ * the whole list.
2333
+ */
2334
+ itemAttrs(index: number): Record<string, string>;
2335
+ /** Scrolls the viewport to `page`. */
2336
+ activate(page: number): void;
2337
+ destroy(): void;
2338
+ }
2339
+ export declare function createThumbnailsController(deps: ThumbnailsDeps, initial?: ThumbnailsOptions): ThumbnailsController;
2340
+ /**
2341
+ * A scrolling list of `viewer`'s pages as thumbnails. Give it a height (it fills its parent's)
2342
+ * and place it anywhere, a sidebar panel for instance. Each item is a button that scrolls the
2343
+ * viewer to its page; the current page is marked and kept in view. It stops when the viewer
2344
+ * is destroyed.
2345
+ */
2346
+ export declare function createThumbnails(viewer: Viewer, opts?: ThumbnailsOptions): HTMLElement;
2347
+ //#endregion
1874
2348
  //#region src/dom/viewer/controls.d.ts
1875
2349
  /**
1876
2350
  * An `<svg>` drawing `icon` from `@inkbar/icons`, hidden from assistive technology: the
@@ -1892,13 +2366,25 @@ export declare function createToolbar(opts?: {
1892
2366
  }): HTMLElement;
1893
2367
  /** A divider between groups of controls in a horizontal toolbar. Not focusable. */
1894
2368
  export declare function createToolbarSeparator(): HTMLDivElement;
2369
+ /**
2370
+ * Saves the document's file (`viewer.download()`); disabled until a document is ready. Today
2371
+ * that is the file as it was opened, without this session's annotations.
2372
+ */
2373
+ export declare function createDownloadButton(viewer: Viewer, opts?: DownloadOptions): HTMLButtonElement;
2374
+ /**
2375
+ * Prints the document's file (`viewer.print()`); disabled until a document is ready. Today
2376
+ * that is the file as it was opened, without this session's annotations.
2377
+ */
2378
+ export declare function createPrintButton(viewer: Viewer): HTMLButtonElement;
1895
2379
  /** Undoes the last change to the document's annotations; disabled when there is none. */
1896
2380
  export declare function createUndo(viewer: Viewer): HTMLButtonElement;
1897
2381
  /** Redoes the last undone change; disabled when there is none. */
1898
2382
  export declare function createRedo(viewer: Viewer): HTMLButtonElement;
1899
2383
  /**
1900
- * Sets the tool; pressed while it is the active one. A host or plugin tool's button takes the
1901
- * tool's own `label` and `icon`; `opts.label` wins, and without either it is named by the tool id.
2384
+ * Sets the tool; pressed while it is the active one. A creation, host or plugin tool's button
2385
+ * takes the tool's own `label` and `icon`; `opts.label` wins, and without either it is named by
2386
+ * the tool id. For an id no tool registered it logs `InkError('UnknownTool')` to the console and
2387
+ * returns the same markup disabled, `aria-hidden` and unnamed.
1902
2388
  */
1903
2389
  export declare function createToolButton(viewer: Viewer, tool: ToolId, opts?: {
1904
2390
  label?: string;
@@ -2167,5 +2653,5 @@ interface FormAlert {
2167
2653
  */
2168
2654
  export declare function createFormAlert(root: HTMLElement): FormAlert;
2169
2655
  //#endregion
2170
- export { type AnnotationDecoration, type AnnotationInputOf, type AnnotationLink, type AnnotationLinkSpec, type AnnotationSlotProps, type AnnotationState, type ArrowheadChoice, type BuiltinToolId, type CardSpec, type ColorMenuModel, type ColorMenuOptions, type ColorMenuSwatch, type ColorProperty, type ColorTrigger, type Command, type CommandOptions, type CommandRun, type CommandSpec, type CreateViewerOptions, type CssLayout, type CssLayoutInput, type CssPageBox, type CssRect, type CurrentStyle, type DecorateAnnotation, type EditorCloseReason, type FocusReturn, type FocusReturnOptions, type FormAlert, type FormLayer, type FreeTextEditor, type FreeTextEditorOptions, type HighlightMenuItem, type HighlightMenuModel, type HighlightOptions, type HistoryKeysTarget, type InkPlugin, type LayerEvent, type LayerSource, type LayerSpec, type LayoutMode, type LineStyleMenuItem, type LineStyleMenuModel, type LineStyleMenuSection, type MarksHandle, type MarksOptions, type MarkupKind, type Menu, type MenuOptions, type MountViewerOptions, type Overlay, type OverlayOptions, type PageHit, type PageLayer, type PageLayers, type PageMount, type PageMountOptions, type PageRenderer, type PageRendererOptions, type PageTransform, type Palette, type PluginApi, type PluginContext, type PluginHost, type PluginHostOptions, type PluginLayer, type PluginLayerHandle, type PluginLayers, type PluginOptions, type PluginStoreOptions, type Popover, type PopoverOptions, type Records, type ScopedToolStyle, type SearchController, type SearchControllerOptions, type SearchState, type SelectionQuads, type ShapeKind, type ShapeMenuItem, type ShapeMenuModel, type ShapeOptions, type SignFieldMenu, type SignFieldMenuOptions, type SignFieldRequest, type SignatureDialog, type SignatureDialogOptions, type SignatureDraft, type SignatureDraftState, type SignatureMenuItem, type SignatureMenuModel, type SignatureOptions, type SignaturePad, type SignatureTab, type StyleGroup, type StyleKey, type StyleProps, type TextAlignChoice, type TextAlignKey, type TextLayerHandle, type TextLayerOptions, type TextStyleMenuModel, type TextStyleToggle, type TextToggleKey, type ThreadPopoverSlotProps, type Tool, type ToolContext, type ToolController, type ToolControllerOptions, type ToolId, type ToolKind, type ToolOptions, type ToolStyle, type ToolStyleTracker, type TypedSignatureOptions, type ViewRotation, type Viewer, type ViewerEngine, type ViewerSearch, type Viewport, type ViewportHit, type ViewportKeysOptions, type ViewportOptions, type ZoomValue, cssVariableDefaults, signField };
2656
+ export { type AnnotationDecoration, type AnnotationInputOf, type AnnotationLink, type AnnotationLinkSpec, type AnnotationSlotProps, type AnnotationState, type ArrowheadChoice, type CardSpec, type ColorMenuModel, type ColorMenuOptions, type ColorMenuSwatch, type ColorProperty, type ColorTrigger, type Command, type CommandOptions, type CommandRun, type CommandSpec, type CoreToolId, type CreateViewerOptions, type CssLayout, type CssLayoutInput, type CssPageBox, type CssRect, type CurrentStyle, type DecorateAnnotation, type DownloadOptions, type EditorCloseReason, type FocusReturn, type FocusReturnOptions, type FormAlert, type FormLayer, type FreeTextEditor, type FreeTextEditorOptions, type HighlightMenuItem, type HighlightMenuModel, type HighlightOptions, type HistoryKeysTarget, type HostRecords, type InkPlugin, type LayerEvent, type LayerSource, type LayerSpec, type LayoutMode, type LineStyleMenuItem, type LineStyleMenuModel, type LineStyleMenuSection, type ListItem, type MarksHandle, type MarksOptions, type MarksRegistration, type MarksRegistry, type MarkupKind, type Menu, type MenuOptions, type MountViewerOptions, type Overlay, type OverlayOptions, type PageHit, type PageLayer, type PageLayers, type PageMount, type PageMountOptions, type PageRenderer, type PageRendererOptions, type PageTransform, type Palette, type PluginApi, type PluginContext, type PluginHost, type PluginHostOptions, type PluginLayer, type PluginLayerHandle, type PluginLayers, type PluginOptions, type PluginStoreOptions, type Popover, type PopoverOptions, type RecordListController, type RecordListRow, type RecordListSource, type RecordSelection, type Records, type RecordsSourceDeps, type RecordsSourceOptions, type ScopedToolStyle, type SearchController, type SearchControllerOptions, type SearchResultsOptions, type SearchState, type SelectionQuads, type ShapeKind, type ShapeMenuItem, type ShapeMenuModel, type ShapeOptions, type SidebarController, type SidebarControllerOptions, type SidebarLayout, type SidebarOpen, type SidebarPanelInfo, type SidebarSide, type SidebarState, type SignFieldMenu, type SignFieldMenuOptions, type SignFieldRequest, type SignatureDialog, type SignatureDialogOptions, type SignatureDraft, type SignatureDraftState, type SignatureMenuItem, type SignatureMenuModel, type SignatureOptions, type SignaturePad, type SignatureTab, type StyleGroup, type StyleKey, type StyleProps, type TextAlignChoice, type TextAlignKey, type TextLayerHandle, type TextLayerOptions, type TextStyleMenuModel, type TextStyleToggle, type TextToggleKey, type ThreadPopoverSlotProps, type ThumbnailDeps, type ThumbnailOptions, type ThumbnailPainter, type ThumbnailsController, type ThumbnailsDeps, type ThumbnailsOptions, type ThumbnailsState, type Tool, type ToolContext, type ToolController, type ToolControllerOptions, type ToolId, type ToolKind, type ToolOptions, type ToolStyle, type ToolStyleTracker, type TypedSignatureOptions, type ViewRotation, type Viewer, type ViewerEngine, type ViewerSearch, type Viewport, type ViewportHit, type ViewportKeysOptions, type ViewportOptions, type ZoomValue, cssVariableDefaults, isBlankQuery, signField };
2171
2657
  //# sourceMappingURL=dom.d.mts.map