@bambamboole/pdf-ua-template-builder 0.2.0 → 0.3.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 +119 -17
- package/dist/index.js +6327 -5201
- package/dist/index.js.map +1 -1
- package/dist/src/builder/Builder.d.ts +7 -0
- package/dist/{builder → src/builder}/TemplateBuilder.d.ts +10 -13
- package/dist/src/builder/blocks/Palette.d.ts +7 -0
- package/dist/src/builder/canvas/BlockDataPreview.d.ts +7 -0
- package/dist/{builder → src/builder}/canvas/BuilderCanvas.d.ts +8 -4
- package/dist/src/builder/canvas/Canvas.d.ts +4 -0
- package/dist/{builder → src/builder}/canvas/ColumnResizer.d.ts +2 -1
- package/dist/{builder → src/builder}/canvas/PageSheet.d.ts +3 -1
- package/dist/{builder → src/builder}/canvas/SortableBlock.d.ts +7 -5
- package/dist/src/builder/canvas/columns.d.ts +13 -0
- package/dist/src/builder/context/BuilderContext.d.ts +66 -0
- package/dist/src/builder/controls/AlignSelect.d.ts +7 -0
- package/dist/src/builder/controls/BuilderField.d.ts +74 -0
- package/dist/src/builder/controls/Field.d.ts +6 -0
- package/dist/src/builder/controls/fieldConverters.d.ts +4 -0
- package/dist/src/builder/controls/index.d.ts +7 -0
- package/dist/src/builder/controls/inputs.d.ts +5 -0
- package/dist/src/builder/hooks/useBuilderDragDrop.d.ts +24 -0
- package/dist/src/builder/inspector/BlockContentControls.d.ts +9 -0
- package/dist/src/builder/inspector/BlockInspector.d.ts +14 -0
- package/dist/src/builder/inspector/BlockLayoutControls.d.ts +7 -0
- package/dist/src/builder/inspector/DocumentSettings.d.ts +18 -0
- package/dist/src/builder/inspector/Inspector.d.ts +1 -0
- package/dist/src/builder/inspector/InspectorShell.d.ts +17 -0
- package/dist/src/builder/inspector/PageSettings.d.ts +4 -0
- package/dist/src/builder/inspector/SpacingControls.d.ts +15 -0
- package/dist/src/builder/inspector/TypographyControls.d.ts +19 -0
- package/dist/src/builder/inspector/alignOptions.d.ts +10 -0
- package/dist/src/builder/inspector/editors/ImageBlockEditor.d.ts +3 -0
- package/dist/src/builder/inspector/editors/KeyValueBlockEditor.d.ts +11 -0
- package/dist/src/builder/inspector/editors/SortableList.d.ts +7 -0
- package/dist/src/builder/inspector/editors/SortableRow.d.ts +10 -0
- package/dist/src/builder/inspector/editors/TableBlockEditor.d.ts +20 -0
- package/dist/src/builder/inspector/editors/blockEditors.d.ts +7 -0
- package/dist/src/builder/lib/records.d.ts +4 -0
- package/dist/src/builder/lib/sensors.d.ts +1 -0
- package/dist/src/builder/primitives/Button.d.ts +10 -0
- package/dist/src/builder/primitives/Chip.d.ts +7 -0
- package/dist/{builder → src/builder}/schema/schemaAdapter.d.ts +2 -5
- package/dist/src/builder/state/configUpdates.d.ts +23 -0
- package/dist/src/builder/state/dragDrop.d.ts +17 -0
- package/dist/{builder → src/builder}/state/editorModel.d.ts +5 -0
- package/dist/src/builder/state/editorReducer.d.ts +71 -0
- package/dist/src/editor/CodeEditor.d.ts +4 -0
- package/dist/src/editor/TemplateEditor.d.ts +23 -0
- package/dist/src/editor/TemplateEditorContext.d.ts +20 -0
- package/dist/src/editor/editorTheme.d.ts +1 -0
- package/dist/src/editor/parseTemplate.d.ts +6 -0
- package/dist/src/editor/templateSchema.d.ts +1 -0
- package/dist/{index.d.ts → src/index.d.ts} +12 -0
- package/dist/src/render/PdfPane.d.ts +14 -0
- package/dist/src/render/Preview.d.ts +4 -0
- package/dist/src/render/RenderContext.d.ts +17 -0
- package/dist/src/render/usePdfUaApi.d.ts +19 -0
- package/dist/{types → src/types}/template.d.ts +5 -1
- package/dist/style.css +3 -1
- package/package.json +22 -9
- package/dist/builder/canvas/columns.d.ts +0 -4
- package/dist/builder/forms/InlineBlockForm.d.ts +0 -9
- package/dist/builder/pdf/PdfPane.d.ts +0 -11
- package/dist/builder/topbar/BuilderTopbar.d.ts +0 -17
- /package/dist/{api → src/api}/pdfUaApi.d.ts +0 -0
- /package/dist/{builder → src/builder}/blocks/BlockPalette.d.ts +0 -0
- /package/dist/{builder → src/builder}/blocks/blockChrome.d.ts +0 -0
- /package/dist/{builder → src/builder}/canvas/BlockCardPreview.d.ts +0 -0
- /package/dist/{builder → src/builder}/lib/displayScale.d.ts +0 -0
- /package/dist/{builder → src/builder}/lib/pageSizes.d.ts +0 -0
- /package/dist/{builder → src/builder}/schema/invoiceExample.d.ts +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TemplateExample } from './context/BuilderContext';
|
|
2
|
+
export interface BuilderProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
/** Loadable examples surfaced in the palette, keyed by display name. */
|
|
5
|
+
examples?: Record<string, TemplateExample>;
|
|
6
|
+
}
|
|
7
|
+
export declare function Builder({ className, examples }?: BuilderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { UniqueIdentifier } from '@dnd-kit/core';
|
|
2
1
|
import { Template } from '../types/generated/template';
|
|
3
2
|
import { TemplateData } from '../types/template';
|
|
4
|
-
import {
|
|
3
|
+
import { TemplateExample } from './context/BuilderContext';
|
|
5
4
|
export interface TemplateBuilderProps {
|
|
6
5
|
/** Base URL of a running pdf-ua-api instance. Defaults to "" (relative URLs / proxy). */
|
|
7
6
|
apiUrl?: string;
|
|
@@ -9,6 +8,8 @@ export interface TemplateBuilderProps {
|
|
|
9
8
|
initialTemplate?: Template;
|
|
10
9
|
/** Runtime data keyed by block id (table rows, dynamic key-value overrides). */
|
|
11
10
|
initialData?: TemplateData;
|
|
11
|
+
/** Loadable examples surfaced in the palette, keyed by display name. */
|
|
12
|
+
examples?: Record<string, TemplateExample>;
|
|
12
13
|
/** Fires whenever the user edits the template or its runtime data. */
|
|
13
14
|
onChange?: (template: Template, data: TemplateData) => void;
|
|
14
15
|
/** Fires after a successful render with the produced PDF blob. */
|
|
@@ -16,14 +17,10 @@ export interface TemplateBuilderProps {
|
|
|
16
17
|
/** Optional className appended to the root element. */
|
|
17
18
|
className?: string;
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
export declare function TemplateBuilder({ apiUrl: initialApiUrlProp, initialTemplate, initialData, onChange, onRendered, className, }?: TemplateBuilderProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
-
export declare function getRowIndex(model: EditorModel, overId: UniqueIdentifier | undefined, overData: DragData): number | null;
|
|
28
|
-
export declare function createNextBlockId(model: EditorModel, blockType: string): string;
|
|
29
|
-
export {};
|
|
20
|
+
/**
|
|
21
|
+
* All-in-one preset: a provider wrapping a Builder and a Preview side by side.
|
|
22
|
+
*
|
|
23
|
+
* For custom layouts (e.g. preview below the builder), compose the parts
|
|
24
|
+
* directly with `TemplateBuilderProvider`, `Builder`, and `Preview`.
|
|
25
|
+
*/
|
|
26
|
+
export declare function TemplateBuilder({ apiUrl, initialTemplate, initialData, examples, onChange, onRendered, className, }?: TemplateBuilderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TemplateExample } from '../context/BuilderContext';
|
|
2
|
+
export interface PaletteProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
/** Loadable examples keyed by display name. The Load control only renders when non-empty. */
|
|
5
|
+
examples?: Record<string, TemplateExample>;
|
|
6
|
+
}
|
|
7
|
+
export declare function Palette({ className, examples }?: PaletteProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Block } from '../../types/generated/template';
|
|
2
|
+
export interface BlockDataPreviewProps {
|
|
3
|
+
block: Block;
|
|
4
|
+
rowData?: unknown;
|
|
5
|
+
onChange?: (block: Block) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function BlockDataPreview({ block, rowData, onChange }: BlockDataPreviewProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,17 +1,21 @@
|
|
|
1
1
|
import { Block, Orientation, PageFormat } from '../../types/generated/template';
|
|
2
|
-
import {
|
|
2
|
+
import { TemplateData } from '../../types/template';
|
|
3
3
|
import { EditorModel, PageNumbersValue } from '../state/editorModel';
|
|
4
4
|
export interface BuilderCanvasProps {
|
|
5
|
-
schema: TemplateSchemaResponse;
|
|
6
5
|
model: EditorModel;
|
|
6
|
+
data: TemplateData;
|
|
7
7
|
format: PageFormat;
|
|
8
8
|
orientation: Orientation;
|
|
9
9
|
footerRepeat: boolean;
|
|
10
10
|
pageNumbers: PageNumbersValue;
|
|
11
|
-
|
|
11
|
+
selectedBlockUid: string | null;
|
|
12
12
|
onRemoveBlock: (blockUid: string) => void;
|
|
13
|
+
onSelectBlock: (blockUid: string) => void;
|
|
14
|
+
onChangeBlock: (blockUid: string, block: Block) => void;
|
|
15
|
+
onDeselect: () => void;
|
|
13
16
|
onSetRowWidths: (rowUid: string, widths: string[]) => void;
|
|
14
17
|
onToggleFooterRepeat: (repeat: boolean) => void;
|
|
15
18
|
onChangePageNumbers: (value: PageNumbersValue) => void;
|
|
19
|
+
className?: string;
|
|
16
20
|
}
|
|
17
|
-
export declare function BuilderCanvas({
|
|
21
|
+
export declare function BuilderCanvas({ model, data, format, orientation, footerRepeat, pageNumbers, selectedBlockUid, onRemoveBlock, onSelectBlock, onChangeBlock, onDeselect, onSetRowWidths, onToggleFooterRepeat, onChangePageNumbers, className, }: BuilderCanvasProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,5 +5,6 @@ export interface ColumnResizerProps {
|
|
|
5
5
|
leftIndex: number;
|
|
6
6
|
containerRef: RefObject<HTMLElement | null>;
|
|
7
7
|
onResize: (widths: string[]) => void;
|
|
8
|
+
label?: string;
|
|
8
9
|
}
|
|
9
|
-
export declare function ColumnResizer({ widths, count, leftIndex, containerRef, onResize, }: ColumnResizerProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function ColumnResizer({ widths, count, leftIndex, containerRef, onResize, label, }: ColumnResizerProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,5 +4,7 @@ export interface PageSheetProps {
|
|
|
4
4
|
format: PageFormat;
|
|
5
5
|
orientation: Orientation;
|
|
6
6
|
children: ReactNode;
|
|
7
|
+
/** Show the "{format} · {orientation} / {width}mm" caption. Off for the footer sheet. */
|
|
8
|
+
showMeta?: boolean;
|
|
7
9
|
}
|
|
8
|
-
export declare function PageSheet({ format, orientation, children }: PageSheetProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function PageSheet({ format, orientation, children, showMeta }: PageSheetProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { CSSProperties } from 'react';
|
|
2
|
-
import { EditorArea, EditorBlock } from '../state/editorModel';
|
|
3
2
|
import { Block } from '../../types/generated/template';
|
|
4
|
-
import {
|
|
3
|
+
import { EditorArea, EditorBlock } from '../state/editorModel';
|
|
4
|
+
import { TemplateData } from '../../types/template';
|
|
5
5
|
export interface SortableBlockProps {
|
|
6
6
|
rowUid: string;
|
|
7
7
|
area: EditorArea;
|
|
8
8
|
editorBlock: EditorBlock;
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
data: TemplateData;
|
|
10
|
+
selected: boolean;
|
|
11
11
|
onRemoveBlock: (blockUid: string) => void;
|
|
12
|
+
onSelect: (blockUid: string) => void;
|
|
13
|
+
onChangeBlock: (blockUid: string, block: Block) => void;
|
|
12
14
|
style?: CSSProperties;
|
|
13
15
|
}
|
|
14
|
-
export declare function SortableBlock({ rowUid, area, editorBlock,
|
|
16
|
+
export declare function SortableBlock({ rowUid, area, editorBlock, data, selected, onRemoveBlock, onSelect, onChangeBlock, style: layoutStyle, }: SortableBlockProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function parseWidths(widths: readonly (number | string)[] | null | undefined, count: number): number[];
|
|
2
|
+
export declare function formatWidths(widths: readonly number[]): string[];
|
|
3
|
+
export declare function gridTemplateForWidths(widths: readonly string[] | null | undefined, count: number): string | null;
|
|
4
|
+
export declare function setBoundary(widths: readonly number[], leftIndex: number, leftPercent: number): number[];
|
|
5
|
+
export declare function labelWidthPercent(width: string | null | undefined, fallback?: number): number;
|
|
6
|
+
export declare const NUMBER_COLUMN_RESERVE = 5;
|
|
7
|
+
export interface TableColumnTracks {
|
|
8
|
+
tracks: number[];
|
|
9
|
+
data: number[];
|
|
10
|
+
}
|
|
11
|
+
export declare function percentWidth(width: string | number | null | undefined): number | null;
|
|
12
|
+
export declare function distribute(count: number, total: number): number[];
|
|
13
|
+
export declare function tableColumnTracks(widths: readonly (string | null | undefined)[], numberRows: boolean): TableColumnTracks;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Block, Orientation, PageFormat, Template } from '../../types/generated/template';
|
|
3
|
+
import { TemplateData, TemplateSchemaResponse } from '../../types/template';
|
|
4
|
+
import { EditorBlock, EditorModel, PageNumbersValue, ResolvedPageSize } from '../state/editorModel';
|
|
5
|
+
import { getBlockTypes } from '../schema/schemaAdapter';
|
|
6
|
+
/** A loadable example: a template plus its optional runtime data. */
|
|
7
|
+
export interface TemplateExample {
|
|
8
|
+
template: Template;
|
|
9
|
+
data?: TemplateData;
|
|
10
|
+
}
|
|
11
|
+
export interface TemplateBuilderProviderProps {
|
|
12
|
+
/** Base URL of a running pdf-ua-api instance. Defaults to "" (relative URLs / proxy). */
|
|
13
|
+
apiUrl?: string;
|
|
14
|
+
/** Template loaded into the editor on first render. */
|
|
15
|
+
initialTemplate?: Template;
|
|
16
|
+
/** Runtime data keyed by block id (table rows, dynamic key-value overrides). */
|
|
17
|
+
initialData?: TemplateData;
|
|
18
|
+
/** Fires whenever the user edits the template or its runtime data. */
|
|
19
|
+
onChange?: (template: Template, data: TemplateData) => void;
|
|
20
|
+
/** Fires after a successful render with the produced PDF blob. */
|
|
21
|
+
onRendered?: (pdf: Blob) => void;
|
|
22
|
+
/** Pane slots to arrange. They share this provider's state and DnD context. */
|
|
23
|
+
children: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
/** Editor state and derived values. Changes as the user edits. */
|
|
26
|
+
export interface BuilderState {
|
|
27
|
+
schema: TemplateSchemaResponse | null;
|
|
28
|
+
schemaLoading: boolean;
|
|
29
|
+
model: EditorModel;
|
|
30
|
+
data: TemplateData;
|
|
31
|
+
serializedTemplate: Template;
|
|
32
|
+
selectedBlockUid: string | null;
|
|
33
|
+
selectedBlock: EditorBlock | null;
|
|
34
|
+
blockTypes: ReturnType<typeof getBlockTypes>;
|
|
35
|
+
pageSize: ResolvedPageSize;
|
|
36
|
+
footerRepeat: boolean;
|
|
37
|
+
pageNumbers: PageNumbersValue;
|
|
38
|
+
pdfUrl: string | null;
|
|
39
|
+
pdfLoading: boolean;
|
|
40
|
+
error: string | null;
|
|
41
|
+
}
|
|
42
|
+
/** Stable editor actions. Identity never changes for the provider's lifetime. */
|
|
43
|
+
export interface BuilderActions {
|
|
44
|
+
renderPdf: () => void;
|
|
45
|
+
loadExample: (example: TemplateExample) => void;
|
|
46
|
+
addBlock: (type: string) => void;
|
|
47
|
+
changeBlock: (blockUid: string, block: Block) => void;
|
|
48
|
+
changeTemplateSettings: (template: Template) => void;
|
|
49
|
+
removeBlock: (blockUid: string) => void;
|
|
50
|
+
selectBlock: (blockUid: string) => void;
|
|
51
|
+
deselect: () => void;
|
|
52
|
+
setRowWidths: (rowUid: string, widths: string[]) => void;
|
|
53
|
+
changeData: (data: TemplateData) => void;
|
|
54
|
+
changeFormat: (format: PageFormat) => void;
|
|
55
|
+
changeOrientation: (orientation: Orientation) => void;
|
|
56
|
+
toggleFooterRepeat: (repeat: boolean) => void;
|
|
57
|
+
changePageNumbers: (value: PageNumbersValue) => void;
|
|
58
|
+
}
|
|
59
|
+
export type BuilderContextValue = BuilderState & BuilderActions;
|
|
60
|
+
/** Subscribe to editor state. Re-renders on edits. */
|
|
61
|
+
export declare function useBuilderState(): BuilderState;
|
|
62
|
+
/** Read the stable editor actions. Does not re-render on edits. */
|
|
63
|
+
export declare function useBuilderActions(): BuilderActions;
|
|
64
|
+
/** Headless escape hatch returning both state and actions. */
|
|
65
|
+
export declare function useTemplateBuilder(): BuilderContextValue;
|
|
66
|
+
export declare function TemplateBuilderProvider({ apiUrl: apiUrlProp, initialTemplate, initialData, onChange, onRendered, children, }: TemplateBuilderProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export type EmptyTextValue = "empty-string" | "undefined";
|
|
3
|
+
export interface BuilderControlProps {
|
|
4
|
+
name: string;
|
|
5
|
+
label: string;
|
|
6
|
+
help?: ReactNode;
|
|
7
|
+
error?: ReactNode;
|
|
8
|
+
id?: string;
|
|
9
|
+
className?: string;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface TextFieldProps extends BuilderControlProps {
|
|
13
|
+
value?: string;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
emptyValue?: EmptyTextValue;
|
|
16
|
+
autoComplete?: string;
|
|
17
|
+
onChange: (value: string | undefined) => void;
|
|
18
|
+
}
|
|
19
|
+
export interface TextAreaFieldProps extends BuilderControlProps {
|
|
20
|
+
value?: string;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
emptyValue?: EmptyTextValue;
|
|
23
|
+
rows?: number;
|
|
24
|
+
onChange: (value: string | undefined) => void;
|
|
25
|
+
}
|
|
26
|
+
export interface NumberFieldProps extends BuilderControlProps {
|
|
27
|
+
value?: number;
|
|
28
|
+
min?: number;
|
|
29
|
+
max?: number;
|
|
30
|
+
step?: number | "any";
|
|
31
|
+
placeholder?: string;
|
|
32
|
+
onChange: (value: number | undefined) => void;
|
|
33
|
+
}
|
|
34
|
+
export interface SelectFieldOption<Value extends string> {
|
|
35
|
+
value: Value;
|
|
36
|
+
label: string;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface SelectFieldProps<Value extends string> extends BuilderControlProps {
|
|
40
|
+
value?: Value;
|
|
41
|
+
options: readonly SelectFieldOption<Value>[];
|
|
42
|
+
optional?: boolean;
|
|
43
|
+
emptyLabel?: string;
|
|
44
|
+
onChange: (value: Value | undefined) => void;
|
|
45
|
+
}
|
|
46
|
+
export interface CheckboxFieldProps extends BuilderControlProps {
|
|
47
|
+
checked: boolean;
|
|
48
|
+
onChange: (checked: boolean) => void;
|
|
49
|
+
}
|
|
50
|
+
export interface ColorFieldProps extends BuilderControlProps {
|
|
51
|
+
value?: string;
|
|
52
|
+
fallbackValue?: string;
|
|
53
|
+
onChange: (value: string | undefined) => void;
|
|
54
|
+
}
|
|
55
|
+
export interface UnitFieldProps extends BuilderControlProps {
|
|
56
|
+
value?: string;
|
|
57
|
+
placeholder?: string;
|
|
58
|
+
emptyValue?: EmptyTextValue;
|
|
59
|
+
readOnly?: boolean;
|
|
60
|
+
onChange?: (value: string | undefined) => void;
|
|
61
|
+
}
|
|
62
|
+
interface FieldLayoutProps extends BuilderControlProps {
|
|
63
|
+
children: ReactNode;
|
|
64
|
+
}
|
|
65
|
+
export declare function TextField({ value, placeholder, emptyValue, autoComplete, onChange, ...fieldProps }: TextFieldProps): ReactNode;
|
|
66
|
+
export declare function TextAreaField({ value, placeholder, emptyValue, rows, onChange, ...fieldProps }: TextAreaFieldProps): ReactNode;
|
|
67
|
+
export declare function NumberField({ value, min, max, step, placeholder, onChange, ...fieldProps }: NumberFieldProps): ReactNode;
|
|
68
|
+
export declare function SelectField<Value extends string>({ value, options, optional, emptyLabel, onChange, ...fieldProps }: SelectFieldProps<Value>): ReactNode;
|
|
69
|
+
export declare function CheckboxField({ checked, onChange, ...fieldProps }: CheckboxFieldProps): ReactNode;
|
|
70
|
+
export declare function ColorField({ value, fallbackValue, onChange, ...fieldProps }: ColorFieldProps): ReactNode;
|
|
71
|
+
export declare function UnitField({ value, placeholder, emptyValue, readOnly, onChange, ...fieldProps }: UnitFieldProps): ReactNode;
|
|
72
|
+
export declare function BuilderField({ name, label, help, error, id, className, children, }: FieldLayoutProps): ReactNode;
|
|
73
|
+
export declare function createFieldId(name: string): string;
|
|
74
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { EmptyTextValue, SelectFieldOption } from './BuilderField';
|
|
2
|
+
export declare function textValue(value: string, emptyValue: EmptyTextValue): string | undefined;
|
|
3
|
+
export declare function numberValue(value: string, valueAsNumber: number): number | undefined;
|
|
4
|
+
export declare function selectValue<Value extends string>(value: string, options: readonly SelectFieldOption<Value>[]): Value | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { BuilderField, CheckboxField, ColorField, createFieldId, NumberField, SelectField, TextAreaField, TextField, UnitField, } from './BuilderField';
|
|
2
|
+
export { AlignSelect } from './AlignSelect';
|
|
3
|
+
export type { AlignSelectProps } from './AlignSelect';
|
|
4
|
+
export { Field } from './Field';
|
|
5
|
+
export type { FieldProps } from './Field';
|
|
6
|
+
export { Checkbox, Input, Select, Textarea } from './inputs';
|
|
7
|
+
export type { BuilderControlProps, CheckboxFieldProps, ColorFieldProps, EmptyTextValue, NumberFieldProps, SelectFieldOption, SelectFieldProps, TextAreaFieldProps, TextFieldProps, UnitFieldProps, } from './BuilderField';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { InputHTMLAttributes, SelectHTMLAttributes, TextareaHTMLAttributes } from 'react';
|
|
2
|
+
export declare function Input({ className, ...rest }: InputHTMLAttributes<HTMLInputElement>): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function Textarea({ className, ...rest }: TextareaHTMLAttributes<HTMLTextAreaElement>): import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
export declare function Select({ className, ...rest }: SelectHTMLAttributes<HTMLSelectElement>): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function Checkbox({ className, ...rest }: InputHTMLAttributes<HTMLInputElement>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useSensors, DragEndEvent, DragStartEvent } from '@dnd-kit/core';
|
|
2
|
+
import { Dispatch, RefObject } from 'react';
|
|
3
|
+
import { Block } from '../../types/generated/template';
|
|
4
|
+
import { JsonSchemaObject } from '../../types/template';
|
|
5
|
+
import { EditorModel } from '../state/editorModel';
|
|
6
|
+
import { EditorAction } from '../state/editorReducer';
|
|
7
|
+
export type ActiveDrag = {
|
|
8
|
+
kind: "palette";
|
|
9
|
+
type: string;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "block";
|
|
12
|
+
block: Block;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "row";
|
|
15
|
+
} | null;
|
|
16
|
+
interface BuilderDragDrop {
|
|
17
|
+
activeDrag: ActiveDrag;
|
|
18
|
+
sensors: ReturnType<typeof useSensors>;
|
|
19
|
+
onDragStart: (event: DragStartEvent) => void;
|
|
20
|
+
onDragEnd: (event: DragEndEvent) => void;
|
|
21
|
+
onDragCancel: () => void;
|
|
22
|
+
}
|
|
23
|
+
export declare function useBuilderDragDrop(schema: JsonSchemaObject | null, dispatch: Dispatch<EditorAction>, modelRef: RefObject<EditorModel>): BuilderDragDrop;
|
|
24
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Block } from '../../types/generated/template';
|
|
3
|
+
export interface BlockContentControlsProps {
|
|
4
|
+
block: Block;
|
|
5
|
+
rowData?: unknown;
|
|
6
|
+
onChangeBlock: (block: Block) => void;
|
|
7
|
+
onChangeRowData?: (data: unknown) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare function BlockContentControls(props: BlockContentControlsProps): ReactNode;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Block } from '../../types/generated/template';
|
|
2
|
+
import { TemplateData, TemplateSchemaResponse } from '../../types/template';
|
|
3
|
+
import { EditorBlock } from '../state/editorModel';
|
|
4
|
+
export interface BlockInspectorProps {
|
|
5
|
+
block: EditorBlock | null;
|
|
6
|
+
schema: TemplateSchemaResponse;
|
|
7
|
+
data: TemplateData;
|
|
8
|
+
onChangeBlock: (blockUid: string, block: Block) => void;
|
|
9
|
+
onChangeData?: (data: TemplateData) => void;
|
|
10
|
+
onRemoveBlock: (blockUid: string) => void;
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function BlockInspector({ block, schema, data, onChangeBlock, onChangeData, onRemoveBlock, onClose, className, }: BlockInspectorProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Block } from '../../types/generated/template';
|
|
3
|
+
export interface BlockLayoutControlsProps {
|
|
4
|
+
block: Block;
|
|
5
|
+
onChangeBlock: (block: Block) => void;
|
|
6
|
+
}
|
|
7
|
+
export declare function BlockLayoutControls({ block, onChangeBlock }: BlockLayoutControlsProps): ReactNode;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Orientation, PageFormat, Template } from '../../types/generated/template';
|
|
3
|
+
import { TemplateSchemaMetadata } from '../../types/template';
|
|
4
|
+
export interface DocumentSettingsProps {
|
|
5
|
+
template: Template;
|
|
6
|
+
metadata?: Pick<TemplateSchemaMetadata, "bundledFonts">;
|
|
7
|
+
format: PageFormat;
|
|
8
|
+
orientation: Orientation;
|
|
9
|
+
onChangeTemplate: (template: Template) => void;
|
|
10
|
+
onChangeFormat: (format: PageFormat) => void;
|
|
11
|
+
onChangeOrientation: (orientation: Orientation) => void;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Document-wide settings, laid out as a horizontal bar above the block palette.
|
|
16
|
+
* Each group wraps to its own column on narrow widths.
|
|
17
|
+
*/
|
|
18
|
+
export declare function DocumentSettings({ template, metadata, format, orientation, onChangeTemplate, onChangeFormat, onChangeOrientation, className, }: DocumentSettingsProps): ReactNode;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function Inspector(): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export declare function InspectorShell({ ariaLabel, className, children, }: {
|
|
3
|
+
ariaLabel: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export interface InspectorHeaderProps {
|
|
8
|
+
title: string;
|
|
9
|
+
chip?: ReactNode;
|
|
10
|
+
subtitle?: string;
|
|
11
|
+
action?: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
export declare function InspectorHeader({ title, chip, subtitle, action }: InspectorHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function InspectorSection({ title, children }: {
|
|
15
|
+
title: string;
|
|
16
|
+
children: ReactNode;
|
|
17
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Block, Template } from '../../types/generated/template';
|
|
3
|
+
interface BlockSpacingControlsProps {
|
|
4
|
+
scope: "block";
|
|
5
|
+
block: Block;
|
|
6
|
+
onChangeBlock: (block: Block) => void;
|
|
7
|
+
}
|
|
8
|
+
interface PageMarginControlsProps {
|
|
9
|
+
scope: "page";
|
|
10
|
+
template: Template;
|
|
11
|
+
onChangeTemplate: (template: Template) => void;
|
|
12
|
+
}
|
|
13
|
+
export type SpacingControlsProps = BlockSpacingControlsProps | PageMarginControlsProps;
|
|
14
|
+
export declare function SpacingControls(props: SpacingControlsProps): ReactNode;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { Block, Template } from '../../types/generated/template';
|
|
3
|
+
import { TemplateSchemaMetadata } from '../../types/template';
|
|
4
|
+
interface TypographyControlsBaseProps {
|
|
5
|
+
metadata?: Pick<TemplateSchemaMetadata, "bundledFonts">;
|
|
6
|
+
}
|
|
7
|
+
export interface BlockTypographyControlsProps extends TypographyControlsBaseProps {
|
|
8
|
+
target: "block";
|
|
9
|
+
block: Block;
|
|
10
|
+
onChangeBlock: (block: Block) => void;
|
|
11
|
+
}
|
|
12
|
+
export interface TemplateTypographyControlsProps extends TypographyControlsBaseProps {
|
|
13
|
+
target: "template";
|
|
14
|
+
template: Template;
|
|
15
|
+
onChangeTemplate: (template: Template) => void;
|
|
16
|
+
}
|
|
17
|
+
export type TypographyControlsProps = BlockTypographyControlsProps | TemplateTypographyControlsProps;
|
|
18
|
+
export declare function TypographyControls(props: TypographyControlsProps): ReactNode;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { KeyValueBlock, KeyValueField } from '../../../types/generated/template';
|
|
3
|
+
import { BlockEditorProps } from './blockEditors';
|
|
4
|
+
export declare function moveField(fields: readonly KeyValueField[], sourceIndex: number, targetIndex: number): KeyValueField[];
|
|
5
|
+
export declare function addField(block: KeyValueBlock): KeyValueBlock;
|
|
6
|
+
export declare function removeField(block: KeyValueBlock, index: number): KeyValueBlock;
|
|
7
|
+
export declare function renameFieldKey(block: KeyValueBlock, index: number, nextKey: string): KeyValueBlock;
|
|
8
|
+
export declare function setFieldLabel(block: KeyValueBlock, index: number, nextLabel: string): KeyValueBlock;
|
|
9
|
+
export declare function setValue(block: KeyValueBlock, key: string, nextValue: string): KeyValueBlock;
|
|
10
|
+
export declare function reorderFields(block: KeyValueBlock, sourceIndex: number, targetIndex: number): KeyValueBlock;
|
|
11
|
+
export declare function KeyValueBlockEditor({ block, onChangeBlock }: BlockEditorProps): ReactNode;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface SortableListProps {
|
|
3
|
+
count: number;
|
|
4
|
+
onReorder: (sourceIndex: number, targetIndex: number) => void;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
}
|
|
7
|
+
export declare function SortableList({ count, onReorder, children }: SortableListProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface SortableRowProps {
|
|
3
|
+
id: string;
|
|
4
|
+
dragLabel: string;
|
|
5
|
+
removeLabel: string;
|
|
6
|
+
removeName?: string;
|
|
7
|
+
onRemove: () => void;
|
|
8
|
+
children: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
export declare function SortableRow({ id, dragLabel, removeLabel, removeName, onRemove, children, }: SortableRowProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { TableBlock, TableColumn } from '../../../types/generated/template';
|
|
3
|
+
import { BlockEditorProps } from './blockEditors';
|
|
4
|
+
type TableRow = Record<string, string>;
|
|
5
|
+
export declare function moveColumn(columns: readonly TableColumn[], sourceIndex: number, targetIndex: number): TableColumn[];
|
|
6
|
+
export declare function moveRow(rows: readonly TableRow[], sourceIndex: number, targetIndex: number): TableRow[];
|
|
7
|
+
export declare function addColumn(block: TableBlock): TableBlock;
|
|
8
|
+
export declare function removeColumn(block: TableBlock, index: number): TableBlock;
|
|
9
|
+
export declare function renameColumnKey(block: TableBlock, index: number, nextKey: string): TableBlock;
|
|
10
|
+
export declare function setColumnLabel(block: TableBlock, index: number, nextLabel: string): TableBlock;
|
|
11
|
+
export declare function setColumnAlign(block: TableBlock, index: number, nextAlign: string): TableBlock;
|
|
12
|
+
export declare function setTableNumberRows(block: TableBlock, value: boolean | undefined): TableBlock;
|
|
13
|
+
export declare function reorderColumns(block: TableBlock, sourceIndex: number, targetIndex: number): TableBlock;
|
|
14
|
+
export declare function addRow(rows: readonly TableRow[], columns: readonly TableColumn[]): TableRow[];
|
|
15
|
+
export declare function removeRow(rows: readonly TableRow[], index: number): TableRow[];
|
|
16
|
+
export declare function setCellValue(rows: readonly TableRow[], index: number, key: string, nextValue: string): TableRow[];
|
|
17
|
+
export declare function removeColumnKeyFromRows(rows: readonly TableRow[], key: string): TableRow[];
|
|
18
|
+
export declare function renameColumnKeyInRows(rows: readonly TableRow[], previousKey: string, nextKey: string): TableRow[];
|
|
19
|
+
export declare function TableBlockEditor({ block, rowData, onChangeBlock, onChangeRowData, }: BlockEditorProps): ReactNode;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export declare function isRecord(value: unknown): value is Record<string, unknown>;
|
|
2
|
+
export declare function omitKey<TValue>(record: Record<string, TValue>, key: string): Record<string, TValue>;
|
|
3
|
+
export declare function renameKey<TValue>(record: Record<string, TValue>, previousKey: string, nextKey: string): Record<string, TValue>;
|
|
4
|
+
export declare function nextKeyIndex(keys: readonly string[], prefix: string): number;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useBuilderSensors(): import('@dnd-kit/core').SensorDescriptor<import('@dnd-kit/core').SensorOptions>[];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type ButtonVariant = "default" | "primary" | "danger" | "ghost";
|
|
3
|
+
export interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
|
4
|
+
variant?: ButtonVariant;
|
|
5
|
+
/** Render as a square icon button (no label padding). */
|
|
6
|
+
icon?: boolean;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
export declare function Button({ variant, icon, type, className, children, ...rest }: ButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function AddButton({ type, className, children, ...rest }: ButtonHTMLAttributes<HTMLButtonElement>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export interface ChipProps {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
/** Grow to fit multi-character labels instead of staying a 22×22 square. */
|
|
5
|
+
wide?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export declare function Chip({ children, wide }: ChipProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { Block } from '../../types/generated/template';
|
|
2
|
-
import { TemplateSchemaMetadata } from '../../types/template';
|
|
3
|
-
export type
|
|
4
|
-
export interface JsonSchemaObject {
|
|
5
|
-
[key: string]: unknown;
|
|
6
|
-
}
|
|
2
|
+
import { JsonSchemaObject, JsonSchemaValue, TemplateSchemaMetadata } from '../../types/template';
|
|
3
|
+
export type { JsonSchemaObject, JsonSchemaValue };
|
|
7
4
|
export declare function getSchemaMetadata(schema: JsonSchemaObject): TemplateSchemaMetadata;
|
|
8
5
|
export declare function resolveRef(schema: JsonSchemaObject, ref: string): JsonSchemaObject;
|
|
9
6
|
export declare function getBlockTypes(schema: JsonSchemaObject): string[];
|