@refactico/pages 0.1.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.
@@ -0,0 +1,376 @@
1
+ import { default as default_2 } from 'react';
2
+ import { RefObject } from 'react';
3
+
4
+ /**
5
+ * Text alignment mapping
6
+ */
7
+ export declare const ALIGNMENT_CLASSES: {
8
+ readonly left: "text-left";
9
+ readonly center: "text-center";
10
+ readonly right: "text-right";
11
+ readonly justify: "text-justify";
12
+ };
13
+
14
+ export declare type BlockType = 'text' | 'heading' | 'image' | 'code' | 'table' | 'divider' | 'quote' | 'list' | 'callout';
15
+
16
+ export declare const CALLOUT_ICONS: {
17
+ readonly info: "ℹ️";
18
+ readonly warning: "⚠️";
19
+ readonly success: "✅";
20
+ readonly error: "❌";
21
+ readonly tip: "💡";
22
+ };
23
+
24
+ export declare const CALLOUT_LABELS: {
25
+ readonly info: "Info";
26
+ readonly warning: "Warning";
27
+ readonly success: "Success";
28
+ readonly error: "Error";
29
+ readonly tip: "Tip";
30
+ };
31
+
32
+ /**
33
+ * Callout variant styles configuration
34
+ */
35
+ export declare const CALLOUT_VARIANT_STYLES: {
36
+ readonly info: {
37
+ readonly light: {
38
+ readonly bg: "bg-blue-50";
39
+ readonly border: "border-blue-200";
40
+ readonly icon: "text-blue-500";
41
+ readonly title: "text-blue-800";
42
+ readonly content: "text-blue-700";
43
+ };
44
+ readonly dark: {
45
+ readonly bg: "bg-blue-950/40";
46
+ readonly border: "border-blue-800";
47
+ readonly icon: "text-blue-500";
48
+ readonly title: "text-blue-300";
49
+ readonly content: "text-blue-200";
50
+ };
51
+ };
52
+ readonly warning: {
53
+ readonly light: {
54
+ readonly bg: "bg-amber-50";
55
+ readonly border: "border-amber-200";
56
+ readonly icon: "text-amber-500";
57
+ readonly title: "text-amber-800";
58
+ readonly content: "text-amber-700";
59
+ };
60
+ readonly dark: {
61
+ readonly bg: "bg-amber-950/40";
62
+ readonly border: "border-amber-800";
63
+ readonly icon: "text-amber-500";
64
+ readonly title: "text-amber-300";
65
+ readonly content: "text-amber-200";
66
+ };
67
+ };
68
+ readonly success: {
69
+ readonly light: {
70
+ readonly bg: "bg-emerald-50";
71
+ readonly border: "border-emerald-200";
72
+ readonly icon: "text-emerald-500";
73
+ readonly title: "text-emerald-800";
74
+ readonly content: "text-emerald-700";
75
+ };
76
+ readonly dark: {
77
+ readonly bg: "bg-emerald-950/40";
78
+ readonly border: "border-emerald-800";
79
+ readonly icon: "text-emerald-500";
80
+ readonly title: "text-emerald-300";
81
+ readonly content: "text-emerald-200";
82
+ };
83
+ };
84
+ readonly error: {
85
+ readonly light: {
86
+ readonly bg: "bg-red-50";
87
+ readonly border: "border-red-200";
88
+ readonly icon: "text-red-500";
89
+ readonly title: "text-red-800";
90
+ readonly content: "text-red-700";
91
+ };
92
+ readonly dark: {
93
+ readonly bg: "bg-red-950/40";
94
+ readonly border: "border-red-800";
95
+ readonly icon: "text-red-500";
96
+ readonly title: "text-red-300";
97
+ readonly content: "text-red-200";
98
+ };
99
+ };
100
+ readonly tip: {
101
+ readonly light: {
102
+ readonly bg: "bg-violet-50";
103
+ readonly border: "border-violet-200";
104
+ readonly icon: "text-violet-500";
105
+ readonly title: "text-violet-800";
106
+ readonly content: "text-violet-700";
107
+ };
108
+ readonly dark: {
109
+ readonly bg: "bg-violet-950/40";
110
+ readonly border: "border-violet-800";
111
+ readonly icon: "text-violet-500";
112
+ readonly title: "text-violet-300";
113
+ readonly content: "text-violet-200";
114
+ };
115
+ };
116
+ };
117
+
118
+ export declare interface CalloutBlock {
119
+ type: 'callout';
120
+ id: string;
121
+ content: string;
122
+ variant: 'info' | 'warning' | 'success' | 'error' | 'tip';
123
+ title?: string;
124
+ }
125
+
126
+ export declare const cloneBlock: (block: EditorBlock) => EditorBlock;
127
+
128
+ export declare interface CodeBlock {
129
+ type: 'code';
130
+ id: string;
131
+ code: string;
132
+ language: string;
133
+ showLineNumbers?: boolean;
134
+ filename?: string;
135
+ }
136
+
137
+ export declare const createCalloutBlock: (variant?: "info" | "warning" | "success" | "error" | "tip") => EditorBlock;
138
+
139
+ export declare const createCodeBlock: (code?: string, language?: string) => EditorBlock;
140
+
141
+ export declare const createDividerBlock: () => EditorBlock;
142
+
143
+ export declare const createEmptyEditorData: () => EditorData;
144
+
145
+ export declare const createHeadingBlock: (level?: 1 | 2 | 3 | 4 | 5 | 6, content?: string) => EditorBlock;
146
+
147
+ export declare const createImageBlock: (src?: string, alt?: string) => EditorBlock;
148
+
149
+ export declare const createListBlock: (listType?: "bullet" | "numbered" | "checklist") => EditorBlock;
150
+
151
+ export declare const createQuoteBlock: (content?: string) => EditorBlock;
152
+
153
+ export declare const createTableBlock: (rows?: number, cols?: number) => EditorBlock;
154
+
155
+ export declare const createTextBlock: (content?: string) => EditorBlock;
156
+
157
+ /**
158
+ * Divider style mapping
159
+ */
160
+ export declare const DIVIDER_STYLE_CLASSES: {
161
+ readonly solid: "border-solid";
162
+ readonly dashed: "border-dashed";
163
+ readonly dotted: "border-dotted";
164
+ };
165
+
166
+ export declare interface DividerBlock {
167
+ type: 'divider';
168
+ id: string;
169
+ style?: 'solid' | 'dashed' | 'dotted';
170
+ }
171
+
172
+ export declare type EditorBlock = TextBlock | HeadingBlock | ImageBlock | CodeBlock | TableBlock | DividerBlock | QuoteBlock | ListBlock | CalloutBlock;
173
+
174
+ export declare interface EditorData {
175
+ version: string;
176
+ createdAt: string;
177
+ updatedAt: string;
178
+ blocks: EditorBlock[];
179
+ }
180
+
181
+ export declare const fileToBase64: (file: File) => Promise<string>;
182
+
183
+ /**
184
+ * Font size mapping for text blocks
185
+ */
186
+ export declare const FONT_SIZE_CLASSES: {
187
+ readonly sm: "text-sm leading-relaxed";
188
+ readonly base: "text-base leading-relaxed";
189
+ readonly lg: "text-lg leading-relaxed";
190
+ readonly xl: "text-xl leading-relaxed";
191
+ };
192
+
193
+ /**
194
+ * Generate a unique ID for blocks.
195
+ * Uses crypto.randomUUID() when available (modern browsers & Node 19+),
196
+ * falls back to a timestamp-based approach for older environments.
197
+ */
198
+ export declare const generateId: () => string;
199
+
200
+ /**
201
+ * Get muted text class
202
+ */
203
+ export declare const getMutedTextClass: (isDark: boolean) => string;
204
+
205
+ /**
206
+ * Get placeholder text class
207
+ */
208
+ export declare const getPlaceholderClass: (isDark: boolean) => string;
209
+
210
+ /**
211
+ * Get primary text class
212
+ */
213
+ export declare const getPrimaryTextClass: (isDark: boolean) => string;
214
+
215
+ /**
216
+ * Get secondary text class
217
+ */
218
+ export declare const getSecondaryTextClass: (isDark: boolean) => string;
219
+
220
+ /**
221
+ * Generate small toolbar button class (used in list items, etc.)
222
+ */
223
+ export declare const getSmallToolbarButtonClass: (isActive: boolean | undefined, isDark: boolean) => string;
224
+
225
+ /**
226
+ * Generate toolbar button class based on active state and theme
227
+ */
228
+ export declare const getToolbarButtonClass: (isActive: boolean | undefined, isDark: boolean) => string;
229
+
230
+ /**
231
+ * Get toolbar container classes
232
+ */
233
+ export declare const getToolbarContainerClass: (isDark: boolean) => string;
234
+
235
+ /**
236
+ * Get toolbar divider class
237
+ */
238
+ export declare const getToolbarDividerClass: (isDark: boolean) => string;
239
+
240
+ export declare interface HeadingBlock {
241
+ type: 'heading';
242
+ id: string;
243
+ content: string;
244
+ level: 1 | 2 | 3 | 4 | 5 | 6;
245
+ alignment?: 'left' | 'center' | 'right';
246
+ }
247
+
248
+ export declare interface ImageBlock {
249
+ type: 'image';
250
+ id: string;
251
+ src: string;
252
+ alt?: string;
253
+ caption?: string;
254
+ width?: number;
255
+ alignment?: 'left' | 'center' | 'right';
256
+ }
257
+
258
+ /**
259
+ * Theme utilities and common styling helpers
260
+ */
261
+ export declare const isDarkTheme: (theme: Theme) => boolean;
262
+
263
+ export declare interface ListBlock {
264
+ type: 'list';
265
+ id: string;
266
+ items: string[];
267
+ listType: 'bullet' | 'numbered' | 'checklist';
268
+ checkedItems?: boolean[];
269
+ }
270
+
271
+ export declare const moveArrayItem: <T>(arr: T[], fromIndex: number, toIndex: number) => T[];
272
+
273
+ export declare const PagesEditor: default_2.FC<PagesEditorProps>;
274
+
275
+ export declare interface PagesEditorProps {
276
+ initialData?: EditorData;
277
+ onChange?: (data: EditorData) => void;
278
+ /** Debounce delay in ms for onChange callback. Default: 300ms */
279
+ debounceDelay?: number;
280
+ readOnly?: boolean;
281
+ placeholder?: string;
282
+ className?: string;
283
+ theme?: Theme;
284
+ }
285
+
286
+ /**
287
+ * Quote style mapping
288
+ */
289
+ export declare const QUOTE_STYLE_CLASSES: {
290
+ readonly default: (isDark: boolean) => string;
291
+ readonly bordered: (isDark: boolean) => string;
292
+ readonly modern: (isDark: boolean) => string;
293
+ };
294
+
295
+ export declare interface QuoteBlock {
296
+ type: 'quote';
297
+ id: string;
298
+ content: string;
299
+ author?: string;
300
+ style?: 'default' | 'bordered' | 'modern';
301
+ }
302
+
303
+ export declare const SUPPORTED_LANGUAGES: readonly ["javascript", "typescript", "python", "java", "csharp", "cpp", "c", "go", "rust", "ruby", "php", "swift", "kotlin", "scala", "html", "css", "scss", "json", "yaml", "xml", "markdown", "sql", "bash", "shell", "powershell", "dockerfile", "plaintext"];
304
+
305
+ export declare type SupportedLanguage = typeof SUPPORTED_LANGUAGES[number];
306
+
307
+ export declare interface TableBlock {
308
+ type: 'table';
309
+ id: string;
310
+ rows: TableCell[][];
311
+ hasHeader?: boolean;
312
+ }
313
+
314
+ export declare interface TableCell {
315
+ content: string;
316
+ header?: boolean;
317
+ alignment?: 'left' | 'center' | 'right';
318
+ }
319
+
320
+ export declare interface TextBlock {
321
+ type: 'text';
322
+ id: string;
323
+ content: string;
324
+ style?: TextStyle;
325
+ alignment?: 'left' | 'center' | 'right' | 'justify';
326
+ fontSize?: 'sm' | 'base' | 'lg' | 'xl';
327
+ }
328
+
329
+ export declare interface TextStyle {
330
+ bold?: boolean;
331
+ italic?: boolean;
332
+ underline?: boolean;
333
+ strikethrough?: boolean;
334
+ code?: boolean;
335
+ color?: string;
336
+ backgroundColor?: string;
337
+ link?: string;
338
+ }
339
+
340
+ export declare type Theme = 'light' | 'dark';
341
+
342
+ /**
343
+ * Custom hook to auto-resize a textarea based on its content.
344
+ * Returns a ref to attach to the textarea element.
345
+ */
346
+ export declare function useAutoResize<T extends HTMLTextAreaElement>(content: string): RefObject<T | null>;
347
+
348
+ /**
349
+ * Custom hook to manage toolbar visibility for block components.
350
+ * Uses focus/blur pattern to show toolbar when block is focused.
351
+ */
352
+ export declare function useBlockToolbar({ readOnly }?: UseBlockToolbarOptions): UseBlockToolbarReturn;
353
+
354
+ declare interface UseBlockToolbarOptions {
355
+ readOnly?: boolean;
356
+ }
357
+
358
+ declare interface UseBlockToolbarReturn {
359
+ showToolbar: boolean;
360
+ handleFocus: () => void;
361
+ handleBlur: (e: React.FocusEvent) => void;
362
+ containerProps: {
363
+ onFocus: () => void;
364
+ onBlur: (e: React.FocusEvent) => void;
365
+ };
366
+ }
367
+
368
+ /**
369
+ * Custom hook to detect clicks outside of a referenced element.
370
+ * Useful for closing menus, modals, dropdowns, etc.
371
+ */
372
+ export declare function useClickOutside<T extends HTMLElement>(ref: RefObject<T | null>, handler: () => void, enabled?: boolean): void;
373
+
374
+ export declare const validateEditorData: (data: unknown) => data is EditorData;
375
+
376
+ export { }