@bizapps/design-system-testing 1.8.0 → 1.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/dist/editor.d.cts DELETED
@@ -1,428 +0,0 @@
1
- import * as react from 'react';
2
- import { ReactNode } from 'react';
3
- import { Editor, JSONContent, EditorOptions } from '@tiptap/react';
4
- import * as _tiptap_core from '@tiptap/core';
5
- import { ImageOptions } from '@tiptap/extension-image';
6
-
7
- /**
8
- * A toolbar entry is data, never a mark.
9
- *
10
- * An editor's marks are ProseMirror extensions — code with serialization and
11
- * parsing rules — so they belong to whoever owns the document contract, not to
12
- * this package. A consumer declares what its buttons do here and keeps its own
13
- * custom marks; the toolbar only asks the editor whether something is active
14
- * and runs the callback it was handed.
15
- */
16
- type ToolbarItem = {
17
- kind: 'separator';
18
- } | {
19
- kind: 'button';
20
- id: string;
21
- /**
22
- * A node, not an icon name: keeps this package off any icon library
23
- * and lets a button pass bare text (a font's own name, say) instead.
24
- */
25
- icon: ReactNode;
26
- /** Already translated. Names the button for both `title` and `aria-label`. */
27
- label: string;
28
- /**
29
- * What to ask the editor for the pressed state. Omit for actions that
30
- * only open a dialog and are never "on" — announcing those as a
31
- * permanently-off toggle misleads a screen reader.
32
- */
33
- active?: {
34
- name: string;
35
- attrs?: Record<string, unknown>;
36
- };
37
- run: (editor: Editor) => void;
38
- }
39
- /** Escape hatch for entries that own state or render their own popover. */
40
- | {
41
- kind: 'custom';
42
- id: string;
43
- render: (editor: Editor | null) => ReactNode;
44
- };
45
- interface RichTextToolbarProps {
46
- /** Null while the editor mounts; every button disables itself until then. */
47
- editor: Editor | null;
48
- items: ToolbarItem[];
49
- }
50
- /** Renders a declarative toolbar for a Tiptap editor. */
51
- declare function RichTextToolbar({ editor, items }: RichTextToolbarProps): react.JSX.Element;
52
-
53
- /**
54
- * Base content styles for the editable area, exported so a consumer can pass
55
- * them to `useEditor({ editorProps: { attributes: { class } } })` — ProseMirror
56
- * needs that class at construction time, before this component renders.
57
- *
58
- * Compose rather than replace: `cn(EDITOR_CONTENT_STYLE, 'my-overrides')`.
59
- */
60
- declare const EDITOR_CONTENT_STYLE: string;
61
- interface RichTextEditorProps {
62
- /** Null while the editor mounts. Build it with Tiptap's `useEditor`. */
63
- editor: Editor | null;
64
- items: ToolbarItem[];
65
- /**
66
- * Already translated. Omit to render no visible label.
67
- *
68
- * Note that a visible label does NOT name the editable area on its own:
69
- * ProseMirror renders that as role='textbox', and EditorContent's props land
70
- * on a wrapper div rather than on the editable node. Give the editor its own
71
- * name where you construct it:
72
- *
73
- * ```ts
74
- * useEditor({
75
- * editorProps: { attributes: { class: EDITOR_CONTENT_STYLE, 'aria-label': t('body') } },
76
- * })
77
- * ```
78
- */
79
- label?: string;
80
- /** Already translated message. Drives the destructive border and the hint. */
81
- error?: string;
82
- /**
83
- * Slot under the editor for product-specific actions, so the editor itself
84
- * stays free of any one product's features.
85
- */
86
- footer?: ReactNode;
87
- className?: string;
88
- }
89
- /** Chrome for a Tiptap editor: a declarative toolbar, the editable area, and an error slot. */
90
- declare function RichTextEditor({ editor, items, label, error, footer, className }: RichTextEditorProps): react.JSX.Element;
91
-
92
- interface TableMenuLabels {
93
- trigger: string;
94
- insert: string;
95
- /**
96
- * A function, not a string: this is the only label with variables, and
97
- * formatting it here would mean reimplementing message interpolation. The
98
- * consumer keeps that in whatever i18n layer it already has.
99
- */
100
- dimensions: (rows: number, columns: number) => string;
101
- rowBefore: string;
102
- rowAfter: string;
103
- deleteRow: string;
104
- columnBefore: string;
105
- columnAfter: string;
106
- deleteColumn: string;
107
- toggleHeader: string;
108
- deleteTable: string;
109
- }
110
- interface TableMenuProps {
111
- editor: Editor | null;
112
- labels: TableMenuLabels;
113
- icon: ReactNode;
114
- /**
115
- * The picker grid's extent. These bound the visual picker only — a
116
- * consumer whose document contract caps table size should also enforce
117
- * that ceiling where it validates the document.
118
- */
119
- maxRows?: number;
120
- maxColumns?: number;
121
- }
122
- /** Word-style table controls: a grid picker to insert, then row/column actions. */
123
- declare function TableMenu({ editor, labels, icon, maxRows, maxColumns, }: TableMenuProps): react.JSX.Element;
124
-
125
- interface InsertImageDialogLabels {
126
- title: string;
127
- urlLabel: string;
128
- urlPlaceholder: string;
129
- altLabel: string;
130
- hint: string;
131
- cancel: string;
132
- apply: string;
133
- remove: string;
134
- }
135
- interface InsertImageDialogProps {
136
- open: boolean;
137
- onOpenChange: (open: boolean) => void;
138
- labels: InsertImageDialogLabels;
139
- url: string;
140
- onUrlChange: (url: string) => void;
141
- alt: string;
142
- onAltChange: (alt: string) => void;
143
- file: File | null;
144
- onFileChange: (file: File | null) => void;
145
- /** True while the consumer is transferring the picked file. Locks the form. */
146
- uploading: boolean;
147
- onApply: () => void;
148
- onCancel?: () => void;
149
- /**
150
- * True when editing an image already in the document — reveals the
151
- * destructive remove action beside the apply button.
152
- */
153
- removable?: boolean;
154
- onRemove?: () => void;
155
- /** Upload limits belong to whoever receives the file, not to this dialog. */
156
- maxSizeBytes?: number;
157
- accept?: Record<string, string[]>;
158
- }
159
- /**
160
- * A controlled form for inserting an image. It deliberately does NOT upload:
161
- * the consumer owns the transfer (its own API, its own storage) and drives
162
- * `uploading` / `onApply` from there, so this dialog stays reusable across
163
- * products with different backends.
164
- */
165
- declare function InsertImageDialog({ open, onOpenChange, labels, url, onUrlChange, alt, onAltChange, file, onFileChange, uploading, onApply, onCancel, removable, onRemove, maxSizeBytes, accept, }: InsertImageDialogProps): react.JSX.Element;
166
-
167
- interface LinkBubbleMenuLabels {
168
- open: string;
169
- edit: string;
170
- remove: string;
171
- }
172
- interface LinkBubbleMenuProps {
173
- editor: Editor | null;
174
- labels: LinkBubbleMenuLabels;
175
- /** Opens the consumer's link dialog, pre-filled with the current href. */
176
- onEdit: () => void;
177
- /**
178
- * Follows the link. Left to the consumer for the cases this package cannot
179
- * judge — routing instead of navigating, or confirming first.
180
- *
181
- * Defaults to opening a new tab, which is also what Ctrl/Cmd-click does, so
182
- * the author never loses unsaved work just by checking a URL.
183
- */
184
- onOpen?: (href: string) => void;
185
- }
186
- /**
187
- * A floating bar that appears when the caret sits inside a link, offering to
188
- * open, edit or unlink it.
189
- *
190
- * It exists because an editor cannot let a plain click navigate: clicking is how
191
- * you place the caret to fix a typo, so `openOnClick` stays false and this gives
192
- * the author a deliberate way out to the URL. Ctrl/Cmd-click is wired separately,
193
- * on the editor itself, for people who expect the shortcut.
194
- */
195
- declare function LinkBubbleMenu({ editor, labels, onEdit, onOpen }: LinkBubbleMenuProps): react.JSX.Element | null;
196
-
197
- /**
198
- * Whatever `useEditor` accepts in its `extensions` array.
199
- *
200
- * Derived from Tiptap's own option rather than imported as AnyExtension: the
201
- * name resolves to a structurally different declaration depending on which copy
202
- * of @tiptap/core is in scope, and the two do not assign to each other.
203
- */
204
- type EditorExtension = EditorOptions['extensions'][number];
205
- /** Every string the built-in toolbar and menus need. All already translated. */
206
- interface RichTextEditorLabels {
207
- /** Names the editable area for assistive tech. Required — it has no visible label. */
208
- editor: string;
209
- bold: string;
210
- italic: string;
211
- heading: string;
212
- underline: string;
213
- strikethrough: string;
214
- quote: string;
215
- insertLink: string;
216
- insertImage: string;
217
- resizeImage: string;
218
- lists: {
219
- trigger: string;
220
- bullet: string;
221
- ordered: string;
222
- };
223
- /** The floating bar shown while the caret sits inside a link. */
224
- link: LinkBubbleMenuLabels;
225
- table: TableMenuLabels;
226
- highlight: string;
227
- }
228
- interface UseRichTextEditorOptions {
229
- labels: RichTextEditorLabels;
230
- /** Fires on every document change, with the current ProseMirror JSON. */
231
- onUpdate?: (doc: JSONContent) => void;
232
- /** Initial document. */
233
- content?: JSONContent | string;
234
- /** Opens the consumer's link dialog. Wire the toolbar's link button to it. */
235
- onInsertLink?: () => void;
236
- /** Opens the consumer's image dialog. */
237
- onInsertImage?: () => void;
238
- /**
239
- * Marks and nodes this product's document contract requires — a brand font,
240
- * a colour palette, anything a server-side whitelist validates. They are
241
- * appended to the built-in set rather than replacing it.
242
- */
243
- extraExtensions?: EditorExtension[];
244
- /**
245
- * Extra toolbar entries, and where they go. `after` names a built-in id
246
- * (`heading`, `highlight`, `strike`, `image`…); omit it to append at the end.
247
- */
248
- extraToolbar?: {
249
- after?: string;
250
- items: ToolbarItem[];
251
- }[];
252
- /**
253
- * Replaces a built-in entry, keyed by its id.
254
- *
255
- * For when a product needs a richer version of something the preset already
256
- * provides — swapping the single highlight button for a palette of shades,
257
- * say. Replacing rather than adding keeps the toolbar from carrying both.
258
- */
259
- replaceToolbar?: Record<string, ToolbarItem>;
260
- /** Merged on top of the built-in content styles. */
261
- contentClassName?: string;
262
- /** Allows data: URIs in images. Off by default: uploads belong in storage. */
263
- allowBase64Images?: boolean;
264
- /**
265
- * Merged into the editor's `editorProps`. For behaviour only a product can
266
- * define — clamping pasted tables to a contract's row limit, say.
267
- *
268
- * `attributes` and `handleClick` are set by the hook and are not overridable:
269
- * they carry the accessible name and the link shortcut, which are the
270
- * defaults consumers were getting wrong by hand.
271
- */
272
- editorProps?: Omit<NonNullable<EditorOptions['editorProps']>, 'attributes' | 'handleClick'>;
273
- }
274
- interface UseRichTextEditorResult {
275
- editor: Editor | null;
276
- /**
277
- * The floating link bar, ready to render beside `<RichTextEditor />`.
278
- *
279
- * Returned as an element rather than left to the consumer because it is easy
280
- * to forget, and an editor without it gives the author no way to reach or
281
- * remove a link they have already inserted.
282
- */
283
- linkMenu: ReactNode;
284
- /** Ready for `<RichTextEditor items={...} />`. */
285
- toolbar: ToolbarItem[];
286
- /** True when the caret has no selection, so a new link needs its own text. */
287
- linkNeedsText: boolean;
288
- /** Reads the caret's current href — pre-fill the dialog with it. */
289
- currentLinkHref: () => string;
290
- /** Applies a link, inserting `text` when there is no selection to wrap. */
291
- applyLink: (href: string, text?: string) => void;
292
- }
293
- /**
294
- * Builds a configured Tiptap editor and its toolbar.
295
- *
296
- * Everything a rich text editor needs to behave correctly is set up here —
297
- * Ctrl/Cmd-click on links, the accessible name for the editable area, the
298
- * repaint-on-transaction the toolbar's pressed state depends on, the content
299
- * styles — so a consumer cannot end up with a subtly different editor by
300
- * forgetting one of them.
301
- *
302
- * What stays with the consumer is what only it can know: the marks its document
303
- * contract allows, and the copy. Both arrive as options.
304
- */
305
- declare function useRichTextEditor({ labels, onUpdate, content, onInsertLink, onInsertImage, extraExtensions, extraToolbar, replaceToolbar, contentClassName, allowBase64Images, editorProps, }: UseRichTextEditorOptions): UseRichTextEditorResult;
306
-
307
- /**
308
- * One entry in the palette.
309
- *
310
- * `mark` is a mark name, not a colour value: a consumer's document contract
311
- * decides which marks exist, and a palette of named marks costs nothing to
312
- * validate server-side — unlike a mark carrying an arbitrary colour, which would
313
- * change the shape of every stored span.
314
- */
315
- interface ColorSwatch {
316
- /** The Tiptap mark this swatch toggles, e.g. `colorPrimary`. */
317
- mark: string;
318
- /** Already translated name, used as the swatch's accessible label. */
319
- label: string;
320
- /** CSS colour for the swatch preview only. */
321
- preview: string;
322
- }
323
- interface ColorMenuLabels {
324
- trigger: string;
325
- /** Heading above the swatches. */
326
- heading: string;
327
- /** Clears whichever colour mark is applied. */
328
- clear: string;
329
- }
330
- interface ColorMenuProps {
331
- editor: Editor | null;
332
- labels: ColorMenuLabels;
333
- icon: ReactNode;
334
- swatches: ColorSwatch[];
335
- }
336
- /**
337
- * A palette dropdown that toggles one mark at a time.
338
- *
339
- * Deliberately not the design system's `ColorPicker`: a free picker offers
340
- * millions of values, and an editor whose authors can pick any colour produces
341
- * articles that no longer look like one publication. A short list of brand
342
- * shades is the constraint that keeps them consistent.
343
- */
344
- declare function ColorMenu({ editor, labels, icon, swatches }: ColorMenuProps): react.JSX.Element;
345
-
346
- /** One list style the consumer offers. */
347
- interface ListOption {
348
- /** The Tiptap node this entry toggles, e.g. `bulletList`. */
349
- node: string;
350
- /** Already translated name. */
351
- label: string;
352
- icon: ReactNode;
353
- run: (editor: Editor) => void;
354
- }
355
- interface ListMenuProps {
356
- editor: Editor | null;
357
- /** Already translated. Names the trigger for assistive tech. */
358
- triggerLabel: string;
359
- /** Shown on the trigger when no list style is active. */
360
- icon: ReactNode;
361
- options: ListOption[];
362
- }
363
- /**
364
- * Groups the list styles behind one trigger.
365
- *
366
- * A row of separate buttons costs three toolbar slots for choices that are
367
- * mutually exclusive; one trigger showing the active style reads faster and
368
- * leaves room for the rest of the toolbar. The trigger swaps to the active
369
- * style's icon so the current state is visible without opening the menu.
370
- */
371
- declare function ListMenu({ editor, triggerLabel, icon, options }: ListMenuProps): react.JSX.Element;
372
-
373
- interface InsertLinkDialogLabels {
374
- title: string;
375
- urlLabel: string;
376
- urlPlaceholder: string;
377
- /** Explains that clearing the field removes an existing link. */
378
- hint: string;
379
- /** Field for the visible text, shown only when there is no selection to wrap. */
380
- textLabel: string;
381
- textPlaceholder: string;
382
- cancel: string;
383
- apply: string;
384
- }
385
- interface InsertLinkDialogProps {
386
- open: boolean;
387
- onOpenChange: (open: boolean) => void;
388
- labels: InsertLinkDialogLabels;
389
- url: string;
390
- onUrlChange: (url: string) => void;
391
- /**
392
- * The visible text for a brand-new link. Pass these three together with
393
- * `needsText` when the editor has no selection to turn into a link — without
394
- * them the dialog can only re-point an existing one.
395
- */
396
- text?: string;
397
- onTextChange?: (text: string) => void;
398
- /**
399
- * True when there is nothing selected, so the link needs its own text.
400
- * Reveals the text field and requires it before applying.
401
- */
402
- needsText?: boolean;
403
- onApply: () => void;
404
- onCancel?: () => void;
405
- }
406
- /**
407
- * A controlled form for inserting or editing a link.
408
- *
409
- * Clearing the URL and applying is how a link is removed — the consumer decides
410
- * what that means for its document, so this dialog only reports the values.
411
- */
412
- declare function InsertLinkDialog({ open, onOpenChange, labels, url, onUrlChange, text, onTextChange, needsText, onApply, onCancel, }: InsertLinkDialogProps): react.JSX.Element;
413
-
414
- interface ResizableImageOptions {
415
- /** Already translated: names the resize handle for assistive tech. */
416
- resizeLabel: string;
417
- minWidth?: number;
418
- }
419
- /**
420
- * Builds an Image extension whose node view carries a resize handle.
421
- *
422
- * A factory rather than a component because ProseMirror — not React —
423
- * instantiates the node view, so there is no place to hand it props. Options
424
- * ride on the extension instead, and the view reads them off `extension.options`.
425
- */
426
- declare function createResizableImage(options: ResizableImageOptions): _tiptap_core.Node<ImageOptions & ResizableImageOptions, any>;
427
-
428
- export { ColorMenu, type ColorMenuLabels, type ColorMenuProps, type ColorSwatch, EDITOR_CONTENT_STYLE, InsertImageDialog, type InsertImageDialogLabels, type InsertImageDialogProps, InsertLinkDialog, type InsertLinkDialogLabels, type InsertLinkDialogProps, LinkBubbleMenu, type LinkBubbleMenuLabels, type LinkBubbleMenuProps, ListMenu, type ListMenuProps, type ListOption, type ResizableImageOptions, RichTextEditor, type RichTextEditorLabels, type RichTextEditorProps, RichTextToolbar, type RichTextToolbarProps, TableMenu, type TableMenuLabels, type TableMenuProps, type ToolbarItem, type UseRichTextEditorOptions, type UseRichTextEditorResult, createResizableImage, useRichTextEditor };