uhuu-components 0.2.77 → 0.2.79
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/index.d.ts +363 -0
- package/package.json +2 -1
- package/uhuu-components.es.js +6215 -5718
- package/uhuu-components.es.js.map +1 -1
- package/uhuu-components.umd.js +14 -24
- package/uhuu-components.umd.js.map +1 -1
package/index.d.ts
ADDED
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
// Public API for `uhuu-components` (mirrors src/index.js). Copied to dist/index.d.ts on build.
|
|
2
|
+
import type {
|
|
3
|
+
ComponentType,
|
|
4
|
+
CSSProperties,
|
|
5
|
+
ImgHTMLAttributes,
|
|
6
|
+
Key,
|
|
7
|
+
ReactElement,
|
|
8
|
+
ReactEventHandler,
|
|
9
|
+
ReactNode,
|
|
10
|
+
} from "react";
|
|
11
|
+
|
|
12
|
+
export interface StaticFlowItemMeta {
|
|
13
|
+
breakBefore?: boolean;
|
|
14
|
+
breakAfter?: boolean;
|
|
15
|
+
keepWithNext?: boolean | number;
|
|
16
|
+
avoidBreakInside?: boolean;
|
|
17
|
+
groupKey?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** A separately measured group whose header may repeat on virtual continuation pages. */
|
|
21
|
+
export interface StaticFlowItemGroup {
|
|
22
|
+
key: string;
|
|
23
|
+
repeatHeader?: boolean;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface StaticFlowFragmentContext<TItem = unknown> {
|
|
27
|
+
flowId: string;
|
|
28
|
+
pageIndex: number;
|
|
29
|
+
pageCount: number;
|
|
30
|
+
itemIndex: number;
|
|
31
|
+
itemKey: Key;
|
|
32
|
+
item: TItem;
|
|
33
|
+
groupKey?: string;
|
|
34
|
+
isFirst: boolean;
|
|
35
|
+
isLast: boolean;
|
|
36
|
+
isFirstInFragment: boolean;
|
|
37
|
+
isLastInFragment: boolean;
|
|
38
|
+
isFirstInGroup: boolean;
|
|
39
|
+
isFirstInGroupOnPage: boolean;
|
|
40
|
+
/** The item is on a continuation page of the Flow. */
|
|
41
|
+
isContinuation: boolean;
|
|
42
|
+
/** The group resumed from the preceding virtual page. */
|
|
43
|
+
isGroupContinuation: boolean;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface StaticFlowUnplaceableItem {
|
|
47
|
+
index: number;
|
|
48
|
+
key: string;
|
|
49
|
+
height: number;
|
|
50
|
+
headerHeight: number;
|
|
51
|
+
requiredHeight: number;
|
|
52
|
+
availableHeight: number;
|
|
53
|
+
groupKey?: string;
|
|
54
|
+
reason: "item-too-tall" | "item-with-header-too-tall";
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface StaticFlowUnplaceableContext {
|
|
58
|
+
flowId: string;
|
|
59
|
+
pageIndex: number;
|
|
60
|
+
pageCount: number;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** A repeatable group-header insertion point in one measured flow chunk. */
|
|
64
|
+
export interface StaticFlowGroupHeaderFragment {
|
|
65
|
+
groupKey: string;
|
|
66
|
+
itemIndex: number;
|
|
67
|
+
isContinuation: boolean;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface StaticFlowChunk {
|
|
71
|
+
indexes: number[];
|
|
72
|
+
keys: string[];
|
|
73
|
+
groupHeaders?: StaticFlowGroupHeaderFragment[];
|
|
74
|
+
unplaceable?: StaticFlowUnplaceableItem;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface StaticFlowMeasurement {
|
|
78
|
+
flowId: string;
|
|
79
|
+
chunks: StaticFlowChunk[];
|
|
80
|
+
signature: string;
|
|
81
|
+
unplaceableItems?: StaticFlowUnplaceableItem[];
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Input for `Static.planFlowChunks`, using heights measured by the consumer. */
|
|
85
|
+
export interface StaticFlowPlanInput {
|
|
86
|
+
heights?: number[];
|
|
87
|
+
keys?: string[];
|
|
88
|
+
metas?: StaticFlowItemMeta[];
|
|
89
|
+
availableHeight?: number;
|
|
90
|
+
headerGroupKeys?: Array<string | null | undefined>;
|
|
91
|
+
headerGroupHeights?: Record<string, number>;
|
|
92
|
+
headerGroupRepeats?: Record<string, boolean>;
|
|
93
|
+
onUnplaceableItem?: (item: StaticFlowUnplaceableItem) => void;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface ImageBlockDialog {
|
|
97
|
+
path: string;
|
|
98
|
+
type: "image" | "satellite";
|
|
99
|
+
[key: string]: unknown;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface ImageBlockAnnotationValue {
|
|
103
|
+
annotationSvg?: string;
|
|
104
|
+
annotations?: unknown[];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface ImageBlockAnnotation {
|
|
108
|
+
path: string;
|
|
109
|
+
value?: ImageBlockAnnotationValue;
|
|
110
|
+
[key: string]: unknown;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface ImageBlockProps {
|
|
114
|
+
src?: string;
|
|
115
|
+
alt?: string;
|
|
116
|
+
onError?: ReactEventHandler<HTMLImageElement>;
|
|
117
|
+
className?: string;
|
|
118
|
+
imageClassName?: string;
|
|
119
|
+
style?: CSSProperties;
|
|
120
|
+
imageStyle?: CSSProperties;
|
|
121
|
+
backgroundColor?: string;
|
|
122
|
+
mode?: "bleed" | "spread" | "auto";
|
|
123
|
+
side?: "start" | "end";
|
|
124
|
+
width?: number;
|
|
125
|
+
height?: number;
|
|
126
|
+
left?: number;
|
|
127
|
+
right?: number;
|
|
128
|
+
top?: number;
|
|
129
|
+
bottom?: number;
|
|
130
|
+
pageWidth?: number;
|
|
131
|
+
pageHeight?: number;
|
|
132
|
+
bleed?: number;
|
|
133
|
+
dialog?: ImageBlockDialog;
|
|
134
|
+
annotation?: ImageBlockAnnotation;
|
|
135
|
+
overlaySvg?: string;
|
|
136
|
+
overlayClassName?: string;
|
|
137
|
+
options?: unknown[];
|
|
138
|
+
dialogProps?: Record<string, unknown>;
|
|
139
|
+
placeholder?: ReactNode;
|
|
140
|
+
children?: ReactNode;
|
|
141
|
+
imageProps?: ImgHTMLAttributes<HTMLImageElement>;
|
|
142
|
+
renderImage?: (props: ImgHTMLAttributes<HTMLImageElement>) => ReactNode;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export const ImageBlock: ComponentType<ImageBlockProps>;
|
|
146
|
+
|
|
147
|
+
export interface EditableProps {
|
|
148
|
+
className?: string;
|
|
149
|
+
dialog?: object;
|
|
150
|
+
children?: ReactNode;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export const Editable: ComponentType<EditableProps>;
|
|
154
|
+
|
|
155
|
+
export interface InteractiveModeContextValue {
|
|
156
|
+
interactive: boolean;
|
|
157
|
+
setInteractive: (interactive: boolean) => void;
|
|
158
|
+
enableDevTools?: boolean;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface BrandKitOption {
|
|
162
|
+
id: string;
|
|
163
|
+
name: string;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export interface PageEditorItem {
|
|
167
|
+
id?: string;
|
|
168
|
+
templateId?: string;
|
|
169
|
+
componentKey?: string;
|
|
170
|
+
pages?: PageEditorItem[];
|
|
171
|
+
[key: string]: unknown;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface PageEditorState {
|
|
175
|
+
items?: PageEditorItem[];
|
|
176
|
+
[key: string]: unknown;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface PageFilterConfig {
|
|
180
|
+
mode?: "all" | "cover" | "text" | "custom" | string;
|
|
181
|
+
coverPageCount?: number;
|
|
182
|
+
ranges?: Array<{ start: number; end: number }>;
|
|
183
|
+
[key: string]: unknown;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface PrintConfig {
|
|
187
|
+
label: string;
|
|
188
|
+
filter: PageFilterConfig | null;
|
|
189
|
+
pageFormat?: { bleed?: number; [key: string]: unknown };
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export type PrintConfigMap = Record<string, PrintConfig>;
|
|
193
|
+
|
|
194
|
+
export interface PageEditorProps {
|
|
195
|
+
templateConfig: Record<string, unknown>;
|
|
196
|
+
payload?: Record<string, unknown>;
|
|
197
|
+
onPayloadChange?: (nextPayload: Record<string, unknown>) => void;
|
|
198
|
+
pageFormat?: { width: number; height: number; preview?: string; bleed?: number; [key: string]: unknown };
|
|
199
|
+
pageOptions?: unknown[];
|
|
200
|
+
pageFilter?: PageFilterConfig;
|
|
201
|
+
printConfigs?: PrintConfigMap;
|
|
202
|
+
onItemsChange?: (items: PageEditorItem[], state: PageEditorState) => void;
|
|
203
|
+
onStateChange?: (state: PageEditorState) => void;
|
|
204
|
+
renderOverlay?: (context: {
|
|
205
|
+
pageNo?: number;
|
|
206
|
+
total?: number;
|
|
207
|
+
pageId?: string;
|
|
208
|
+
parent?: unknown;
|
|
209
|
+
}) => ReactNode;
|
|
210
|
+
reorderTitle?: string;
|
|
211
|
+
reorderDescription?: string;
|
|
212
|
+
stateKey?: string;
|
|
213
|
+
brandKits?: BrandKitOption[];
|
|
214
|
+
activeBrandKitId?: string;
|
|
215
|
+
onSelectBrandKit?: (id: string) => void;
|
|
216
|
+
onAddBrandKit?: (input: string) => void;
|
|
217
|
+
[key: string]: unknown;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
export interface TemplateDataProviderProps {
|
|
221
|
+
payload?: Record<string, unknown>;
|
|
222
|
+
onPayloadChange?: (nextPayload: Record<string, unknown>) => void;
|
|
223
|
+
children: ReactNode;
|
|
224
|
+
stateKey?: string;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export interface IntegrationAdapterConfig {
|
|
228
|
+
dataBinding?: Record<string, unknown>;
|
|
229
|
+
integration?: Record<string, unknown>;
|
|
230
|
+
resolver?: Record<string, unknown> | ((integration: unknown, payload?: unknown) => unknown);
|
|
231
|
+
galleryPath?: string | ((integration: unknown) => string | null);
|
|
232
|
+
defaults?: Record<string, unknown>;
|
|
233
|
+
[key: string]: unknown;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface IntegrationAdapter {
|
|
237
|
+
dialog: (...args: unknown[]) => Record<string, unknown> | null;
|
|
238
|
+
dialogProps: (...args: unknown[]) => Record<string, unknown>;
|
|
239
|
+
[key: string]: unknown;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
export const EditorShell: {
|
|
243
|
+
TemplateDataProvider: ComponentType<TemplateDataProviderProps>;
|
|
244
|
+
PageEditor: ComponentType<PageEditorProps>;
|
|
245
|
+
InteractiveModeProvider: ComponentType<{
|
|
246
|
+
children: ReactNode;
|
|
247
|
+
defaultInteractive?: boolean;
|
|
248
|
+
enableDevTools?: boolean;
|
|
249
|
+
}>;
|
|
250
|
+
useInteractive: () => InteractiveModeContextValue;
|
|
251
|
+
useIntegrationAdapter: (config: IntegrationAdapterConfig) => IntegrationAdapter;
|
|
252
|
+
};
|
|
253
|
+
|
|
254
|
+
export interface StaticSheetProps {
|
|
255
|
+
children: ReactNode;
|
|
256
|
+
className?: string;
|
|
257
|
+
style?: CSSProperties;
|
|
258
|
+
pageNo: number;
|
|
259
|
+
showBleed?: boolean;
|
|
260
|
+
overlay?: (args: { pageNo: number }) => ReactNode;
|
|
261
|
+
"data-page-key"?: string;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export interface StaticPaginationProps {
|
|
265
|
+
children: ReactNode;
|
|
266
|
+
className?: string;
|
|
267
|
+
setup: Record<string, unknown>;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export interface StaticFlowAreaProps {
|
|
271
|
+
children: ReactNode;
|
|
272
|
+
className?: string;
|
|
273
|
+
style?: CSSProperties;
|
|
274
|
+
onFlowMeasurement?: (measurement: StaticFlowMeasurement) => void;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export interface StaticFlowPageProps {
|
|
278
|
+
children: ReactNode;
|
|
279
|
+
header?: ReactNode;
|
|
280
|
+
footer?: ReactNode;
|
|
281
|
+
className?: string;
|
|
282
|
+
style?: CSSProperties;
|
|
283
|
+
flowAreaClassName?: string;
|
|
284
|
+
flowAreaStyle?: CSSProperties;
|
|
285
|
+
onFlowMeasurement?: (measurement: StaticFlowMeasurement) => void;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
export interface StaticFlowProps<TItem = unknown> {
|
|
289
|
+
id: string;
|
|
290
|
+
items: TItem[];
|
|
291
|
+
getKey: (item: TItem, index: number) => Key;
|
|
292
|
+
renderItem: (
|
|
293
|
+
item: TItem,
|
|
294
|
+
index: number,
|
|
295
|
+
fragment: StaticFlowFragmentContext<TItem>
|
|
296
|
+
) => ReactNode;
|
|
297
|
+
getItemMeta?: (item: TItem, index: number) => StaticFlowItemMeta | undefined;
|
|
298
|
+
metaDefaults?: Partial<Record<string, StaticFlowItemMeta>>;
|
|
299
|
+
getItemType?: (item: TItem, index: number) => string | undefined;
|
|
300
|
+
getItemGroup?: (
|
|
301
|
+
item: TItem,
|
|
302
|
+
index: number
|
|
303
|
+
) => StaticFlowItemGroup | string | null | undefined;
|
|
304
|
+
renderGroupHeader?: (
|
|
305
|
+
group: StaticFlowItemGroup,
|
|
306
|
+
fragment: StaticFlowFragmentContext<TItem>
|
|
307
|
+
) => ReactNode;
|
|
308
|
+
className?: string;
|
|
309
|
+
itemClassName?: string | ((item: TItem, index: number) => string | undefined);
|
|
310
|
+
groupHeaderClassName?: string | ((
|
|
311
|
+
group: StaticFlowItemGroup,
|
|
312
|
+
fragment: StaticFlowFragmentContext<TItem>
|
|
313
|
+
) => string | undefined);
|
|
314
|
+
renderUnplaceableItem?: (
|
|
315
|
+
item: StaticFlowUnplaceableItem,
|
|
316
|
+
context: StaticFlowUnplaceableContext
|
|
317
|
+
) => ReactNode;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
export type HtmlFlowItem = {
|
|
321
|
+
id: string;
|
|
322
|
+
type: string;
|
|
323
|
+
html: string;
|
|
324
|
+
breakBefore: boolean;
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
export interface StaticFlowDocumentProps {
|
|
328
|
+
html: string;
|
|
329
|
+
header?: ReactNode;
|
|
330
|
+
footer?: ReactNode;
|
|
331
|
+
className?: string;
|
|
332
|
+
style?: CSSProperties;
|
|
333
|
+
flowAreaClassName?: string;
|
|
334
|
+
flowAreaStyle?: CSSProperties;
|
|
335
|
+
id?: string;
|
|
336
|
+
idPrefix?: string;
|
|
337
|
+
flowClassName?: string;
|
|
338
|
+
itemClassName?: string | ((item: HtmlFlowItem, index: number) => string | undefined);
|
|
339
|
+
metaDefaults?: Partial<Record<string, StaticFlowItemMeta>>;
|
|
340
|
+
getItemMeta?: (item: HtmlFlowItem, index: number) => StaticFlowItemMeta | undefined;
|
|
341
|
+
renderItem?: (item: HtmlFlowItem, index: number) => ReactNode;
|
|
342
|
+
sanitize?: ((html: string) => string) | false;
|
|
343
|
+
editable?: { path: string; type?: string; [key: string]: unknown };
|
|
344
|
+
parseHtml?: (html: string) => unknown[];
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
export const Static: {
|
|
348
|
+
Pagination: ComponentType<StaticPaginationProps>;
|
|
349
|
+
Sheet: ComponentType<StaticSheetProps>;
|
|
350
|
+
FlowArea: ComponentType<StaticFlowAreaProps>;
|
|
351
|
+
FlowPage: ComponentType<StaticFlowPageProps>;
|
|
352
|
+
Flow: <TItem = unknown>(props: StaticFlowProps<TItem>) => ReactElement | null;
|
|
353
|
+
planFlowChunks: (input?: StaticFlowPlanInput) => StaticFlowChunk[];
|
|
354
|
+
FlowDocument: ComponentType<StaticFlowDocumentProps>;
|
|
355
|
+
markdownToFlowItems: (
|
|
356
|
+
markdown?: string,
|
|
357
|
+
options?: Record<string, unknown>
|
|
358
|
+
) => HtmlFlowItem[];
|
|
359
|
+
htmlToFlowItems: (
|
|
360
|
+
html?: string,
|
|
361
|
+
options?: Record<string, unknown>
|
|
362
|
+
) => HtmlFlowItem[];
|
|
363
|
+
};
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.2.
|
|
2
|
+
"version": "0.2.79",
|
|
3
3
|
"name": "uhuu-components",
|
|
4
4
|
"main": "uhuu-components.umd.js",
|
|
5
5
|
"module": "uhuu-components.es.js",
|
|
6
6
|
"browser": "uhuu-components.es.js",
|
|
7
|
+
"types": "index.d.ts",
|
|
7
8
|
"type": "module",
|
|
8
9
|
"license": "https://uhuu.io/license",
|
|
9
10
|
"peerDependencies": {
|