@panneau/core 4.0.11 → 4.0.15

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,502 @@
1
+ import EventEmitter from 'wolfy87-eventemitter';
2
+ import { Tracking as Tracking$1 } from '@folklore/tracking';
3
+ import { ReactNode } from 'react';
4
+ import { MessageDescriptor } from 'react-intl';
5
+
6
+ declare class ComponentsManager {
7
+ components: Record<string, unknown>;
8
+ constructor(components?: Record<string, unknown>);
9
+ addComponent(name: string, component: unknown, namespace?: string | null): this;
10
+ addComponents(components: Record<string, unknown>, namespace?: string | null): this;
11
+ merge(manager: ComponentsManager, namespace?: string | null): this;
12
+ addNamespace(namespace: string | null): this;
13
+ getComponent(name: string, namespace?: string | null): unknown;
14
+ getComponents(namespace?: string | null): Record<string, unknown> | null;
15
+ hasComponent(name: string, namespace?: string | null): boolean;
16
+ }
17
+
18
+ interface Definition$1 {
19
+ id: string;
20
+ component?: unknown;
21
+ [key: string]: unknown;
22
+ }
23
+ declare class DefinitionsManager {
24
+ definitions: Definition$1[];
25
+ constructor(definitions?: Definition$1[]);
26
+ addDefinition(definition: Definition$1 | Definition$1[]): this;
27
+ addDefinitions(definitions: Definition$1[]): this;
28
+ merge(manager: DefinitionsManager): this;
29
+ getDefinition(id: string | null): Definition$1 | null;
30
+ getDefinitions(): Definition$1[];
31
+ hasDefinition(id: string): boolean;
32
+ getComponent(id: string): unknown;
33
+ getComponents(): Record<string, unknown>;
34
+ }
35
+
36
+ type EventCallback = (...args: unknown[]) => void;
37
+ declare class EventsManager extends EventEmitter {
38
+ element: EventTarget;
39
+ events: Record<string, EventCallback[]>;
40
+ listeners: Record<string, EventListener>;
41
+ constructor(element: EventTarget);
42
+ subscribe(event: string, callback: EventCallback): void;
43
+ unsubscribe(event: string, callback: EventCallback): void;
44
+ addEventListener(event: string): void;
45
+ removeEventListener(event: string): void;
46
+ }
47
+
48
+ declare class FieldsManager extends DefinitionsManager {
49
+ }
50
+
51
+ interface Manager$1 {
52
+ getDefinition: (type: string) => Record<string, unknown> | null;
53
+ }
54
+ interface FontsParserOptions {
55
+ fieldsManager: Manager$1;
56
+ screensManager: Manager$1;
57
+ }
58
+ interface Font$1 {
59
+ name?: string;
60
+ type?: string;
61
+ [key: string]: unknown;
62
+ }
63
+ interface Field$2 {
64
+ id?: string | null;
65
+ name?: string | null;
66
+ type?: string | null;
67
+ fields?: Field$2[];
68
+ itemsField?: Field$2 | null;
69
+ settings?: Field$2[];
70
+ [key: string]: unknown;
71
+ }
72
+ interface Screen$2 {
73
+ type: string;
74
+ [key: string]: unknown;
75
+ }
76
+ interface Story$1 {
77
+ theme?: Story$1 | null;
78
+ components?: Screen$2[];
79
+ fonts?: Font$1[];
80
+ [key: string]: unknown;
81
+ }
82
+ declare class FontsParser {
83
+ fieldsManager: Manager$1;
84
+ screensManager: Manager$1;
85
+ constructor({ fieldsManager, screensManager }: FontsParserOptions);
86
+ parse(story: Story$1 | null): Story$1 | null;
87
+ getFieldsPattern(fields: Field$2[], namePrefix?: string | null): RegExp[];
88
+ static fieldIsFontFamily({ id }: Field$2): boolean;
89
+ static valueIsFont({ type }: Record<string, unknown>): boolean;
90
+ static extractFontsWithPaths(data: unknown, patterns: RegExp[], keyPrefix?: string | null): Font$1[];
91
+ }
92
+
93
+ declare class FormsManager extends ComponentsManager {
94
+ }
95
+
96
+ interface Manager {
97
+ getDefinition: (type: string) => Record<string, unknown> | null;
98
+ }
99
+ interface MediasParserOptions {
100
+ fieldsManager: Manager;
101
+ screensManager: Manager;
102
+ }
103
+ interface Media$2 {
104
+ id?: string | null;
105
+ [key: string]: unknown;
106
+ }
107
+ interface Field$1 {
108
+ id?: string | null;
109
+ name?: string | null;
110
+ type?: string | null;
111
+ media?: boolean;
112
+ fields?: Field$1[];
113
+ itemsField?: Field$1 | null;
114
+ settings?: Field$1[];
115
+ [key: string]: unknown;
116
+ }
117
+ interface Screen$1 {
118
+ type: string;
119
+ [key: string]: unknown;
120
+ }
121
+ interface Story {
122
+ theme?: Story | null;
123
+ components?: Screen$1[];
124
+ medias?: Record<string, Media$2> | null;
125
+ [key: string]: unknown;
126
+ }
127
+ declare class MediasParser {
128
+ fieldsManager: Manager;
129
+ screensManager: Manager;
130
+ constructor({ fieldsManager, screensManager }: MediasParserOptions);
131
+ toPath(story: Story | null): Story | null;
132
+ fromPath(story: Story | null, defaultMedias?: Record<string, Media$2> | null): Story | null;
133
+ getMediaFieldsPattern(fields: Field$1[], namePrefix?: string | null): RegExp[];
134
+ static fieldIsMedia({ media }: Field$1): boolean;
135
+ static fieldIsFontFamily({ id }: Field$1): boolean;
136
+ static replacePathsWithMedias(data: unknown, medias: Record<string, Media$2>, patterns: RegExp[], keyPrefix?: string | null): unknown;
137
+ static getMediaPath({ id }: Media$2): string | null;
138
+ static replaceMediasWithPaths(data: unknown, patterns: RegExp[], medias?: Record<string, Media$2> | null, keyPrefix?: string | null): {
139
+ data: unknown;
140
+ medias: Record<string, Media$2> | null;
141
+ };
142
+ }
143
+
144
+ interface TrackingOptions {
145
+ variables?: Record<string, unknown> | null;
146
+ [key: string]: unknown;
147
+ }
148
+ interface Screen {
149
+ id?: string | null;
150
+ type?: string | null;
151
+ [key: string]: unknown;
152
+ }
153
+ interface Media$1 {
154
+ id?: string | null;
155
+ name?: string | null;
156
+ duration?: number | null;
157
+ currentTime?: number | null;
158
+ [key: string]: unknown;
159
+ }
160
+ interface TrackingEventOptions {
161
+ value?: number | null;
162
+ [key: string]: unknown;
163
+ }
164
+ declare class Tracking extends Tracking$1 {
165
+ variables: Record<string, unknown> | null;
166
+ constructor(opts?: TrackingOptions);
167
+ setVariables(variables: Record<string, unknown> | null): void;
168
+ getVariables(): Record<string, unknown> | null;
169
+ trackScreenView(screen: Screen | null, screenIndex: number): void;
170
+ trackEvent(category: string, action: string, label: string, { value, ...opts }?: TrackingEventOptions): void;
171
+ trackMedia(type: string, media: Media$1 | null, action: string, { value, ...opts }?: TrackingEventOptions): void;
172
+ }
173
+
174
+ /**
175
+ * Core UI Types
176
+ */
177
+
178
+ /**
179
+ * Internationalization message definition
180
+ */
181
+ interface Message extends MessageDescriptor {
182
+ id: string;
183
+ defaultMessage?: string;
184
+ }
185
+ /**
186
+ * Label can be either a message object or any React node
187
+ */
188
+ type Label = Message | ReactNode;
189
+ /**
190
+ * HTTP status code (number or string)
191
+ */
192
+ type StatusCode = number | string;
193
+ /**
194
+ * Menu item definition
195
+ */
196
+ interface MenuItem {
197
+ id?: number | string;
198
+ label?: Label;
199
+ url?: string;
200
+ external?: boolean;
201
+ active?: boolean;
202
+ }
203
+ /**
204
+ * Button definition
205
+ */
206
+ interface Button {
207
+ id?: string;
208
+ label?: Label;
209
+ onClick?: () => void;
210
+ href?: string;
211
+ target?: string;
212
+ theme?: ButtonTheme;
213
+ size?: ButtonSize;
214
+ type?: ButtonType;
215
+ disabled?: boolean;
216
+ external?: boolean;
217
+ }
218
+ /**
219
+ * Button theme variants (Bootstrap 5)
220
+ */
221
+ type ButtonTheme = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark' | null;
222
+ /**
223
+ * Button size variants
224
+ */
225
+ type ButtonSize = 'lg' | 'md' | 'sm' | null;
226
+ /**
227
+ * Button type attribute
228
+ */
229
+ type ButtonType = 'button' | 'submit';
230
+ /**
231
+ * Dropdown alignment
232
+ */
233
+ type DropdownAlign = 'start' | 'end';
234
+ /**
235
+ * Form control size
236
+ */
237
+ type ControlSize = 'lg' | 'sm' | null;
238
+ /**
239
+ * Form status states
240
+ */
241
+ type FormStatus = 'loading' | 'success' | 'error' | null;
242
+ /**
243
+ * Form feedback states
244
+ */
245
+ type Feedback = 'valid' | 'invalid' | 'loading' | null;
246
+ /**
247
+ * Form error object
248
+ */
249
+ interface FormError {
250
+ message?: string;
251
+ }
252
+ /**
253
+ * Toggle definition
254
+ */
255
+ interface Toggle {
256
+ key?: string;
257
+ label?: string;
258
+ }
259
+ /**
260
+ * Breadcrumb definition
261
+ */
262
+ interface Breadcrumb {
263
+ url?: string;
264
+ }
265
+ /**
266
+ * Font definition
267
+ */
268
+ interface Font {
269
+ name: string;
270
+ }
271
+ /**
272
+ * Tracking variables
273
+ */
274
+ type TrackingVariables = Record<string, unknown>;
275
+ /**
276
+ * Trigger update identifier
277
+ */
278
+ type TriggerUpdate = string;
279
+
280
+ /**
281
+ * User definition
282
+ */
283
+ interface User {
284
+ id?: number | string;
285
+ [key: string]: unknown;
286
+ }
287
+
288
+ /**
289
+ * Form Types
290
+ * TypeScript interfaces for form-related components
291
+ */
292
+
293
+ /**
294
+ * Field option for select/radio inputs
295
+ */
296
+ interface FieldOption {
297
+ value?: string;
298
+ label?: string;
299
+ }
300
+ /**
301
+ * Select option (more flexible than FieldOption)
302
+ */
303
+ type SelectOption = string | number | {
304
+ value?: unknown;
305
+ label?: Label | string;
306
+ } | Record<string, unknown>;
307
+ /**
308
+ * Field definition
309
+ */
310
+ interface Field {
311
+ name?: string;
312
+ type?: string;
313
+ component?: string;
314
+ label?: ReactNode;
315
+ }
316
+ /**
317
+ * Form definition
318
+ */
319
+ interface Form {
320
+ title: ReactNode;
321
+ fields?: Field[];
322
+ }
323
+ /**
324
+ * Table column definition
325
+ */
326
+ type TableColumn = string | {
327
+ id?: string;
328
+ component?: string;
329
+ path?: string;
330
+ field?: string;
331
+ columnClassName?: string;
332
+ };
333
+
334
+ /**
335
+ * Resource Types
336
+ * TypeScript interfaces for resources, items, users, media, and other entities
337
+ */
338
+
339
+ interface Action {
340
+ id?: string;
341
+ component?: string;
342
+ label?: string | null;
343
+ icon?: string | null;
344
+ href?: string | null;
345
+ external?: boolean;
346
+ theme?: string;
347
+ target?: string;
348
+ onClick?: (() => void) | null;
349
+ endpoint?: string | null;
350
+ withConfirmation?: boolean;
351
+ [key: string]: unknown;
352
+ }
353
+ type ActionDefinition = string | Action;
354
+ type ActionValue = Item | Item[] | null;
355
+ interface ResourceIntlValues {
356
+ a_singular?: string;
357
+ a_plural?: string;
358
+ [key: string]: unknown;
359
+ }
360
+ /**
361
+ * Internationalization configuration
362
+ */
363
+ interface ResourceIntl {
364
+ messages?: Record<string, string>;
365
+ values?: ResourceIntlValues;
366
+ }
367
+ /**
368
+ * Resource definition
369
+ */
370
+ interface Resource {
371
+ id: string;
372
+ name: string;
373
+ intl?: ResourceIntl;
374
+ fields?: Field[];
375
+ forms?: Record<string, unknown>;
376
+ shows_in_navbar?: boolean;
377
+ settings?: Record<string, unknown>;
378
+ }
379
+ /**
380
+ * Generic item (base interface for data items)
381
+ */
382
+ interface Item {
383
+ id: string;
384
+ [key: string]: unknown;
385
+ }
386
+ /**
387
+ * Media file definition
388
+ */
389
+ interface Media {
390
+ id: string;
391
+ name: string;
392
+ type: string;
393
+ thumbnail_url?: string;
394
+ [key: string]: unknown;
395
+ }
396
+ /**
397
+ * Preview definition
398
+ */
399
+ interface Preview {
400
+ id?: string;
401
+ [key: string]: unknown;
402
+ }
403
+ /**
404
+ * Modal definition
405
+ */
406
+ interface Modal {
407
+ name?: string;
408
+ [key: string]: unknown;
409
+ }
410
+ /**
411
+ * Filter definition
412
+ */
413
+ interface Filter {
414
+ id?: string;
415
+ component?: string;
416
+ [key: string]: unknown;
417
+ }
418
+ /**
419
+ * Uppy configuration
420
+ */
421
+ interface Uppy {
422
+ tus?: Record<string, unknown>;
423
+ [key: string]: unknown;
424
+ }
425
+ /**
426
+ * Uppy instance
427
+ */
428
+ interface uppy {
429
+ [key: string]: unknown;
430
+ }
431
+
432
+ /**
433
+ * Panneau Definition Types
434
+ * TypeScript interfaces for main Panneau configuration and definitions
435
+ */
436
+
437
+ /**
438
+ * Panneau route configuration
439
+ */
440
+ interface Routes {
441
+ 'resources.index': string;
442
+ 'resources.create': string;
443
+ 'resources.store': string;
444
+ 'resources.show': string;
445
+ 'resources.edit': string;
446
+ 'resources.update': string;
447
+ 'resources.delete': string;
448
+ 'resources.destroy': string;
449
+ 'resources.duplicate': string;
450
+ 'resources.clone': string;
451
+ 'resources.restore': string;
452
+ [key: string]: string;
453
+ }
454
+ /**
455
+ * Page definition
456
+ */
457
+ interface Page {
458
+ component: string;
459
+ [key: string]: unknown;
460
+ }
461
+ interface PanneauTheme {
462
+ colorScheme?: string | null;
463
+ [key: string]: unknown;
464
+ }
465
+ interface PanneauComponents {
466
+ [key: string]: string | {
467
+ component: string;
468
+ [key: string]: unknown;
469
+ };
470
+ }
471
+ interface PanneauIntlValues {
472
+ [key: string]: string;
473
+ }
474
+ interface PanneauIntl {
475
+ locale?: string;
476
+ locales?: string[];
477
+ messages?: Record<string, string>;
478
+ values?: PanneauIntlValues;
479
+ }
480
+ /**
481
+ * Panneau definition (main configuration)
482
+ */
483
+ interface PanneauDefinition {
484
+ name?: string;
485
+ resources?: Resource[];
486
+ routes?: Routes;
487
+ pages?: Record<string, Page>;
488
+ intl?: PanneauIntl;
489
+ theme?: PanneauTheme;
490
+ components?: PanneauComponents;
491
+ settings?: Record<string, unknown>;
492
+ }
493
+ /**
494
+ * Generic definition
495
+ */
496
+ interface Definition {
497
+ name?: string;
498
+ [key: string]: unknown;
499
+ }
500
+
501
+ export { ComponentsManager, DefinitionsManager, EventsManager, FieldsManager, FontsParser, FormsManager, MediasParser, Tracking };
502
+ export type { Action, ActionDefinition, ActionValue, Breadcrumb, Button, ButtonSize, ButtonTheme, ButtonType, ControlSize, Definition, DropdownAlign, Feedback, Field, FieldOption, Filter, Font, Form, FormError, FormStatus, Item, Label, Media, MenuItem, Message, Modal, Page, PanneauComponents, PanneauDefinition, PanneauIntl, PanneauIntlValues, PanneauTheme, Preview, Resource, ResourceIntl, ResourceIntlValues, Routes, SelectOption, StatusCode, TableColumn, Toggle, TrackingVariables, TriggerUpdate, Uppy, User, uppy };