@panneau/core 4.0.78 → 4.1.1
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/contexts.d.ts +266 -168
- package/dist/contexts.js +46 -31
- package/dist/hooks.d.ts +78 -40
- package/dist/hooks.js +780 -338
- package/dist/index.d.ts +299 -201
- package/dist/index.js +23 -29
- package/dist/utils.d.ts +192 -15
- package/dist/utils.js +106 -31
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,49 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReactNode, MouseEvent, ElementType, ComponentProps } from 'react';
|
|
2
|
+
import { MessageDescriptor, FormattedMessage } from 'react-intl';
|
|
2
3
|
import EventEmitter from 'wolfy87-eventemitter';
|
|
3
|
-
import { MessageDescriptor } from 'react-intl';
|
|
4
4
|
import { Tracking as Tracking$1 } from '@folklore/tracking';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
merge(manager: ComponentsManager, namespace?: string | null): this;
|
|
12
|
-
addNamespace(namespace: string | null): this;
|
|
13
|
-
getComponent(name: string | ElementType, namespace?: string | null): ElementType | null;
|
|
14
|
-
getComponents(namespace?: string | null): Record<string, ElementType> | null;
|
|
15
|
-
hasComponent(name: string, namespace?: string | null): boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
interface Definition$1 {
|
|
19
|
-
id: string;
|
|
20
|
-
component?: unknown;
|
|
6
|
+
/**
|
|
7
|
+
* User definition
|
|
8
|
+
*/
|
|
9
|
+
interface User {
|
|
10
|
+
id?: number | string;
|
|
21
11
|
[key: string]: unknown;
|
|
22
12
|
}
|
|
23
|
-
declare class DefinitionsManager<T extends Definition$1 = Definition$1> {
|
|
24
|
-
definitions: T[];
|
|
25
|
-
constructor(definitions?: T[]);
|
|
26
|
-
addDefinition(definition: T | T[]): this;
|
|
27
|
-
addDefinitions(definitions: T[]): this;
|
|
28
|
-
merge(manager: DefinitionsManager<T>): this;
|
|
29
|
-
getDefinition(id: string | null): T | null;
|
|
30
|
-
getDefinitions(): T[];
|
|
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
13
|
|
|
48
14
|
/**
|
|
49
15
|
* Core UI Types
|
|
@@ -53,10 +19,22 @@ declare class EventsManager extends EventEmitter {
|
|
|
53
19
|
* Internationalization message definition
|
|
54
20
|
*/
|
|
55
21
|
type Message = MessageDescriptor;
|
|
22
|
+
/**
|
|
23
|
+
* Values that can be interpolated in an internationalization message
|
|
24
|
+
* (the `values` prop of FormattedMessage)
|
|
25
|
+
*/
|
|
26
|
+
type MessageValues = NonNullable<ComponentProps<typeof FormattedMessage>['values']>;
|
|
27
|
+
type MessageValue = MessageValues[string];
|
|
56
28
|
/**
|
|
57
29
|
* Label can be either a message object or any React node
|
|
58
30
|
*/
|
|
59
31
|
type Label = Message | ReactNode;
|
|
32
|
+
/**
|
|
33
|
+
* Map of components, can be nested by namespace (ex: { fields: { text: TextField } })
|
|
34
|
+
*/
|
|
35
|
+
interface ComponentsMap {
|
|
36
|
+
[name: string]: ElementType | ComponentsMap;
|
|
37
|
+
}
|
|
60
38
|
/**
|
|
61
39
|
* HTTP status code (number or string)
|
|
62
40
|
*/
|
|
@@ -68,8 +46,16 @@ interface MenuItem {
|
|
|
68
46
|
id?: number | string;
|
|
69
47
|
label?: Label;
|
|
70
48
|
url?: string;
|
|
49
|
+
href?: string | null;
|
|
71
50
|
external?: boolean;
|
|
72
51
|
active?: boolean;
|
|
52
|
+
type?: string;
|
|
53
|
+
component?: string;
|
|
54
|
+
className?: string | null;
|
|
55
|
+
linkClassName?: string | null;
|
|
56
|
+
onClick?: ((e: MouseEvent) => void) | null;
|
|
57
|
+
items?: MenuItem[] | null;
|
|
58
|
+
dropdown?: MenuItem[] | null;
|
|
73
59
|
}
|
|
74
60
|
/**
|
|
75
61
|
* Button definition
|
|
@@ -77,6 +63,7 @@ interface MenuItem {
|
|
|
77
63
|
type ButtonElement = HTMLButtonElement | HTMLAnchorElement;
|
|
78
64
|
interface Button {
|
|
79
65
|
id?: string;
|
|
66
|
+
name?: string;
|
|
80
67
|
label?: Label;
|
|
81
68
|
onClick?: (e: MouseEvent<ButtonElement>, button?: Button, index?: number) => void;
|
|
82
69
|
href?: string;
|
|
@@ -171,7 +158,7 @@ interface Item {
|
|
|
171
158
|
/**
|
|
172
159
|
* Generic definition
|
|
173
160
|
*/
|
|
174
|
-
interface Definition {
|
|
161
|
+
interface Definition$1 {
|
|
175
162
|
id: string;
|
|
176
163
|
component?: string | ElementType;
|
|
177
164
|
[key: string]: unknown;
|
|
@@ -205,6 +192,20 @@ type SelectOption = string | number | {
|
|
|
205
192
|
value?: unknown;
|
|
206
193
|
label?: Label | string;
|
|
207
194
|
} | Record<string, unknown>;
|
|
195
|
+
/**
|
|
196
|
+
* Settings of a field in a resource (the `settings` key of the field)
|
|
197
|
+
*/
|
|
198
|
+
interface FieldSettings {
|
|
199
|
+
/** Not shown in the resource forms */
|
|
200
|
+
hiddenInForm?: boolean;
|
|
201
|
+
/** Only shown in the create form */
|
|
202
|
+
createOnly?: boolean;
|
|
203
|
+
/** Only shown in the edit form (and show page) */
|
|
204
|
+
updateOnly?: boolean;
|
|
205
|
+
/** Shown as a column of the index when the resource has no `index.columns` */
|
|
206
|
+
showInIndex?: boolean;
|
|
207
|
+
[key: string]: unknown;
|
|
208
|
+
}
|
|
208
209
|
/**
|
|
209
210
|
* Field definition
|
|
210
211
|
*/
|
|
@@ -216,7 +217,7 @@ interface Field$2 {
|
|
|
216
217
|
size?: ControlSize;
|
|
217
218
|
[key: string]: unknown;
|
|
218
219
|
}
|
|
219
|
-
interface FieldDefinition extends Omit<Field$2, 'component'>, Definition {
|
|
220
|
+
interface FieldDefinition extends Omit<Field$2, 'component'>, Definition$1 {
|
|
220
221
|
}
|
|
221
222
|
/**
|
|
222
223
|
* Form definition
|
|
@@ -229,141 +230,7 @@ interface Form {
|
|
|
229
230
|
submitButtonLabel?: Label | null;
|
|
230
231
|
[key: string]: unknown;
|
|
231
232
|
}
|
|
232
|
-
interface FormDefinition extends Form, Definition {
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
declare class FieldsManager extends DefinitionsManager<FieldDefinition> {
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
interface Manager$1 {
|
|
239
|
-
getDefinition: (type: string) => Record<string, unknown> | null;
|
|
240
|
-
}
|
|
241
|
-
interface FontsParserOptions {
|
|
242
|
-
fieldsManager: Manager$1;
|
|
243
|
-
screensManager: Manager$1;
|
|
244
|
-
}
|
|
245
|
-
interface Font {
|
|
246
|
-
name?: string;
|
|
247
|
-
type?: string;
|
|
248
|
-
[key: string]: unknown;
|
|
249
|
-
}
|
|
250
|
-
interface Field$1 {
|
|
251
|
-
id?: string | null;
|
|
252
|
-
name?: string | null;
|
|
253
|
-
type?: string | null;
|
|
254
|
-
fields?: Field$1[];
|
|
255
|
-
itemsField?: Field$1 | null;
|
|
256
|
-
settings?: Field$1[];
|
|
257
|
-
[key: string]: unknown;
|
|
258
|
-
}
|
|
259
|
-
interface Screen$2 {
|
|
260
|
-
type: string;
|
|
261
|
-
[key: string]: unknown;
|
|
262
|
-
}
|
|
263
|
-
interface Story$1 {
|
|
264
|
-
theme?: Story$1 | null;
|
|
265
|
-
components?: Screen$2[];
|
|
266
|
-
fonts?: Font[];
|
|
267
|
-
[key: string]: unknown;
|
|
268
|
-
}
|
|
269
|
-
declare class FontsParser {
|
|
270
|
-
fieldsManager: Manager$1;
|
|
271
|
-
screensManager: Manager$1;
|
|
272
|
-
constructor({ fieldsManager, screensManager }: FontsParserOptions);
|
|
273
|
-
parse(story: Story$1 | null): Story$1 | null;
|
|
274
|
-
getFieldsPattern(fields: Field$1[], namePrefix?: string | null): RegExp[];
|
|
275
|
-
static fieldIsFontFamily({ id }: Field$1): boolean;
|
|
276
|
-
static valueIsFont({ type }: Record<string, unknown>): boolean;
|
|
277
|
-
static extractFontsWithPaths(data: unknown, patterns: RegExp[], keyPrefix?: string | null): Font[];
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
declare class FormsManager extends DefinitionsManager<FormDefinition> {
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
interface Manager {
|
|
284
|
-
getDefinition: (type: string) => Record<string, unknown> | null;
|
|
285
|
-
}
|
|
286
|
-
interface MediasParserOptions {
|
|
287
|
-
fieldsManager: Manager;
|
|
288
|
-
screensManager: Manager;
|
|
289
|
-
}
|
|
290
|
-
interface Media$2 {
|
|
291
|
-
id?: string | null;
|
|
292
|
-
[key: string]: unknown;
|
|
293
|
-
}
|
|
294
|
-
interface Field {
|
|
295
|
-
id?: string | null;
|
|
296
|
-
name?: string | null;
|
|
297
|
-
type?: string | null;
|
|
298
|
-
media?: boolean;
|
|
299
|
-
fields?: Field[];
|
|
300
|
-
itemsField?: Field | null;
|
|
301
|
-
settings?: Field[];
|
|
302
|
-
[key: string]: unknown;
|
|
303
|
-
}
|
|
304
|
-
interface Screen$1 {
|
|
305
|
-
type: string;
|
|
306
|
-
[key: string]: unknown;
|
|
307
|
-
}
|
|
308
|
-
interface Story {
|
|
309
|
-
theme?: Story | null;
|
|
310
|
-
components?: Screen$1[];
|
|
311
|
-
medias?: Record<string, Media$2> | null;
|
|
312
|
-
[key: string]: unknown;
|
|
313
|
-
}
|
|
314
|
-
declare class MediasParser {
|
|
315
|
-
fieldsManager: Manager;
|
|
316
|
-
screensManager: Manager;
|
|
317
|
-
constructor({ fieldsManager, screensManager }: MediasParserOptions);
|
|
318
|
-
toPath(story: Story | null): Story | null;
|
|
319
|
-
fromPath(story: Story | null, defaultMedias?: Record<string, Media$2> | null): Story | null;
|
|
320
|
-
getMediaFieldsPattern(fields: Field[], namePrefix?: string | null): RegExp[];
|
|
321
|
-
static fieldIsMedia({ media }: Field): boolean;
|
|
322
|
-
static fieldIsFontFamily({ id }: Field): boolean;
|
|
323
|
-
static replacePathsWithMedias(data: unknown, medias: Record<string, Media$2>, patterns: RegExp[], keyPrefix?: string | null): unknown;
|
|
324
|
-
static getMediaPath({ id }: Media$2): string | null;
|
|
325
|
-
static replaceMediasWithPaths(data: unknown, patterns: RegExp[], medias?: Record<string, Media$2> | null, keyPrefix?: string | null): {
|
|
326
|
-
data: unknown;
|
|
327
|
-
medias: Record<string, Media$2> | null;
|
|
328
|
-
};
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
interface TrackingOptions {
|
|
332
|
-
variables?: Record<string, unknown> | null;
|
|
333
|
-
[key: string]: unknown;
|
|
334
|
-
}
|
|
335
|
-
interface Screen {
|
|
336
|
-
id?: string | null;
|
|
337
|
-
type?: string | null;
|
|
338
|
-
[key: string]: unknown;
|
|
339
|
-
}
|
|
340
|
-
interface Media$1 {
|
|
341
|
-
id?: string | null;
|
|
342
|
-
name?: string | null;
|
|
343
|
-
duration?: number | null;
|
|
344
|
-
currentTime?: number | null;
|
|
345
|
-
[key: string]: unknown;
|
|
346
|
-
}
|
|
347
|
-
interface TrackingEventOptions {
|
|
348
|
-
value?: number | null;
|
|
349
|
-
[key: string]: unknown;
|
|
350
|
-
}
|
|
351
|
-
declare class Tracking extends Tracking$1 {
|
|
352
|
-
variables: Record<string, unknown> | null;
|
|
353
|
-
constructor(opts?: TrackingOptions);
|
|
354
|
-
setVariables(variables: Record<string, unknown> | null): void;
|
|
355
|
-
getVariables(): Record<string, unknown> | null;
|
|
356
|
-
trackScreenView(screen: Screen | null, screenIndex: number): void;
|
|
357
|
-
trackEvent(category: string, action: string, label: string, { value, ...opts }?: TrackingEventOptions): void;
|
|
358
|
-
trackMedia(type: string, media: Media$1 | null, action: string, { value, ...opts }?: TrackingEventOptions): void;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* User definition
|
|
363
|
-
*/
|
|
364
|
-
interface User {
|
|
365
|
-
id?: number | string;
|
|
366
|
-
[key: string]: unknown;
|
|
233
|
+
interface FormDefinition extends Form, Definition$1 {
|
|
367
234
|
}
|
|
368
235
|
|
|
369
236
|
type MediaType = 'audio' | 'image' | 'video' | 'document' | 'font';
|
|
@@ -374,7 +241,7 @@ interface MediaFile {
|
|
|
374
241
|
/**
|
|
375
242
|
* Media file definition
|
|
376
243
|
*/
|
|
377
|
-
interface Media extends Item {
|
|
244
|
+
interface Media$2 extends Item {
|
|
378
245
|
id: string;
|
|
379
246
|
name: string;
|
|
380
247
|
type: string;
|
|
@@ -382,21 +249,22 @@ interface Media extends Item {
|
|
|
382
249
|
thumbnailUrl?: string;
|
|
383
250
|
url?: string;
|
|
384
251
|
provider?: string;
|
|
252
|
+
deletedAt?: string | null;
|
|
385
253
|
[key: string]: unknown;
|
|
386
254
|
files?: Record<string, MediaFile> | null;
|
|
387
255
|
}
|
|
388
|
-
interface VideoMedia extends Media {
|
|
256
|
+
interface VideoMedia extends Media$2 {
|
|
389
257
|
type: 'video';
|
|
390
258
|
iframeUrl?: string;
|
|
391
259
|
width?: number | null;
|
|
392
260
|
height?: number | null;
|
|
393
261
|
duration?: number | null;
|
|
394
262
|
}
|
|
395
|
-
interface AudioMedia extends Media {
|
|
263
|
+
interface AudioMedia extends Media$2 {
|
|
396
264
|
type: 'audio';
|
|
397
265
|
duration?: number | null;
|
|
398
266
|
}
|
|
399
|
-
interface ImageMedia extends Media {
|
|
267
|
+
interface ImageMedia extends Media$2 {
|
|
400
268
|
type: 'image';
|
|
401
269
|
}
|
|
402
270
|
|
|
@@ -411,6 +279,7 @@ interface ImageMedia extends Media {
|
|
|
411
279
|
type TableColumn = string | Column;
|
|
412
280
|
interface Column extends Record<string, unknown> {
|
|
413
281
|
id?: string | null;
|
|
282
|
+
name?: string | null;
|
|
414
283
|
label?: unknown;
|
|
415
284
|
path?: string;
|
|
416
285
|
valueKey?: string;
|
|
@@ -437,7 +306,7 @@ type ActionValue = Item | Item[] | null;
|
|
|
437
306
|
interface ResourceIntlValues {
|
|
438
307
|
a_singular?: string;
|
|
439
308
|
a_plural?: string;
|
|
440
|
-
[key: string]:
|
|
309
|
+
[key: string]: MessageValue;
|
|
441
310
|
}
|
|
442
311
|
/**
|
|
443
312
|
* Internationalization configuration
|
|
@@ -456,6 +325,11 @@ interface ResourceIndex {
|
|
|
456
325
|
fields?: Field$2[];
|
|
457
326
|
[key: string]: unknown;
|
|
458
327
|
}
|
|
328
|
+
/**
|
|
329
|
+
* Overrides of the built-in resource pages, ex: `{ show: { component: 'my-page' } }`.
|
|
330
|
+
* Used on a resource (`resource.pages`) and on the panneau definition (`definition.pages`),
|
|
331
|
+
* the resource taking precedence.
|
|
332
|
+
*/
|
|
459
333
|
interface ResourcePages {
|
|
460
334
|
index?: PageDefinition;
|
|
461
335
|
show?: PageDefinition;
|
|
@@ -463,15 +337,49 @@ interface ResourcePages {
|
|
|
463
337
|
edit?: PageDefinition;
|
|
464
338
|
delete?: PageDefinition;
|
|
465
339
|
duplicate?: PageDefinition;
|
|
340
|
+
/** @deprecated Legacy resource keys, use `index`, `show`, `create`, etc. */
|
|
341
|
+
resourceIndexPage?: PageDefinition;
|
|
342
|
+
resourceShowPage?: PageDefinition;
|
|
343
|
+
resourceCreatePage?: PageDefinition;
|
|
344
|
+
resourceEditPage?: PageDefinition;
|
|
345
|
+
resourceDeletePage?: PageDefinition;
|
|
346
|
+
resourceDuplicatePage?: PageDefinition;
|
|
347
|
+
/** @deprecated Legacy panneau keys, use `index`, `show`, `create`, etc. */
|
|
348
|
+
indexPage?: PageDefinition;
|
|
349
|
+
showPage?: PageDefinition;
|
|
350
|
+
createPage?: PageDefinition;
|
|
351
|
+
editPage?: PageDefinition;
|
|
352
|
+
deletePage?: PageDefinition;
|
|
353
|
+
duplicatePage?: PageDefinition;
|
|
466
354
|
[key: string]: PageDefinition | undefined;
|
|
467
355
|
}
|
|
356
|
+
/**
|
|
357
|
+
* Form definition of a resource (the id is optional, the form is identified by its key)
|
|
358
|
+
*/
|
|
359
|
+
interface ResourceForm extends Form {
|
|
360
|
+
id?: string;
|
|
361
|
+
component?: string | ElementType;
|
|
362
|
+
}
|
|
468
363
|
interface ResourceForms {
|
|
469
|
-
default
|
|
470
|
-
create
|
|
471
|
-
edit
|
|
472
|
-
delete
|
|
473
|
-
|
|
474
|
-
|
|
364
|
+
default?: ResourceForm | null;
|
|
365
|
+
create?: ResourceForm | null;
|
|
366
|
+
edit?: ResourceForm | null;
|
|
367
|
+
delete?: ResourceForm | null;
|
|
368
|
+
duplicate?: ResourceForm | null;
|
|
369
|
+
modal?: ResourceForm | null;
|
|
370
|
+
[key: string]: ResourceForm | null | undefined;
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Resource type (sub-type of a resource, ex: page types)
|
|
374
|
+
*/
|
|
375
|
+
interface ResourceType {
|
|
376
|
+
id?: string;
|
|
377
|
+
name?: string;
|
|
378
|
+
fields?: Field$2[];
|
|
379
|
+
settings?: {
|
|
380
|
+
canCreate?: boolean;
|
|
381
|
+
[key: string]: unknown;
|
|
382
|
+
};
|
|
475
383
|
}
|
|
476
384
|
interface Resource {
|
|
477
385
|
id: string;
|
|
@@ -483,6 +391,7 @@ interface Resource {
|
|
|
483
391
|
settings?: Record<string, unknown>;
|
|
484
392
|
extraRoutes?: RouteDefinition[];
|
|
485
393
|
pages?: ResourcePages;
|
|
394
|
+
types?: ResourceType[];
|
|
486
395
|
}
|
|
487
396
|
interface ResourceItem extends Item {
|
|
488
397
|
type?: string;
|
|
@@ -532,17 +441,17 @@ interface uppy {
|
|
|
532
441
|
* Panneau route configuration
|
|
533
442
|
*/
|
|
534
443
|
interface Routes {
|
|
535
|
-
'resources.index'
|
|
536
|
-
'resources.create'
|
|
537
|
-
'resources.store'
|
|
538
|
-
'resources.show'
|
|
539
|
-
'resources.edit'
|
|
540
|
-
'resources.update'
|
|
541
|
-
'resources.delete'
|
|
542
|
-
'resources.destroy'
|
|
543
|
-
'resources.duplicate'
|
|
544
|
-
'resources.clone'
|
|
545
|
-
'resources.restore'
|
|
444
|
+
'resources.index'?: RouteDefinition | string;
|
|
445
|
+
'resources.create'?: RouteDefinition | string;
|
|
446
|
+
'resources.store'?: RouteDefinition | string;
|
|
447
|
+
'resources.show'?: RouteDefinition | string;
|
|
448
|
+
'resources.edit'?: RouteDefinition | string;
|
|
449
|
+
'resources.update'?: RouteDefinition | string;
|
|
450
|
+
'resources.delete'?: RouteDefinition | string;
|
|
451
|
+
'resources.destroy'?: RouteDefinition | string;
|
|
452
|
+
'resources.duplicate'?: RouteDefinition | string;
|
|
453
|
+
'resources.clone'?: RouteDefinition | string;
|
|
454
|
+
'resources.restore'?: RouteDefinition | string;
|
|
546
455
|
[key: string]: RouteDefinition | string;
|
|
547
456
|
}
|
|
548
457
|
interface PanneauTheme {
|
|
@@ -562,6 +471,7 @@ interface PanneauIntl {
|
|
|
562
471
|
locale?: string;
|
|
563
472
|
locales?: string[];
|
|
564
473
|
messages?: Record<string, string>;
|
|
474
|
+
/** @deprecated Not used: set the values of each resource in `resources[].intl.values` */
|
|
565
475
|
values?: PanneauIntlValues;
|
|
566
476
|
}
|
|
567
477
|
interface PanneauPages extends ResourcePages {
|
|
@@ -570,6 +480,26 @@ interface PanneauPages extends ResourcePages {
|
|
|
570
480
|
account?: PageDefinition;
|
|
571
481
|
error?: PageDefinition;
|
|
572
482
|
}
|
|
483
|
+
/**
|
|
484
|
+
* Menu item in a Panneau menu: a menu item definition or a special item id
|
|
485
|
+
* (ex: 'resources', 'account', 'separator')
|
|
486
|
+
*/
|
|
487
|
+
type PanneauMenuItem = MenuItem | string;
|
|
488
|
+
interface PanneauMenus {
|
|
489
|
+
main?: PanneauMenuItem[] | null;
|
|
490
|
+
guest?: PanneauMenuItem[] | null;
|
|
491
|
+
[key: string]: PanneauMenuItem[] | null | undefined;
|
|
492
|
+
}
|
|
493
|
+
/**
|
|
494
|
+
* Links shown on the login page: `true` for the default url, or the url of the page
|
|
495
|
+
*/
|
|
496
|
+
interface PanneauAuth {
|
|
497
|
+
/** "Forgot your password?" link (default url: /forgot-password) */
|
|
498
|
+
forgotPassword?: boolean | string;
|
|
499
|
+
/** "Create account" link (default url: /register) */
|
|
500
|
+
register?: boolean | string;
|
|
501
|
+
[key: string]: unknown;
|
|
502
|
+
}
|
|
573
503
|
/**
|
|
574
504
|
* Panneau definition (main configuration)
|
|
575
505
|
*/
|
|
@@ -580,15 +510,183 @@ interface PanneauDefinition {
|
|
|
580
510
|
pages?: PanneauPages;
|
|
581
511
|
intl?: PanneauIntl;
|
|
582
512
|
theme?: PanneauTheme;
|
|
513
|
+
/** @deprecated Not used: give the custom components to the `components` prop of the container */
|
|
583
514
|
components?: PanneauComponents;
|
|
584
515
|
settings?: Record<string, unknown>;
|
|
585
516
|
forms?: FormDefinition[];
|
|
586
517
|
fields?: FieldDefinition[];
|
|
518
|
+
menus?: PanneauMenus;
|
|
519
|
+
auth?: PanneauAuth;
|
|
587
520
|
}
|
|
588
521
|
/**
|
|
589
522
|
* Tracking variables
|
|
590
523
|
*/
|
|
591
524
|
type TrackingVariables = Record<string, unknown>;
|
|
592
525
|
|
|
526
|
+
declare class ComponentsManager {
|
|
527
|
+
components: Record<string, ElementType>;
|
|
528
|
+
constructor(components?: ComponentsMap);
|
|
529
|
+
addComponent(name: string, component: ElementType, namespace?: string | null): this;
|
|
530
|
+
addComponents(components: Record<string, ElementType>, namespace?: string | null): this;
|
|
531
|
+
merge(manager: ComponentsManager, namespace?: string | null): this;
|
|
532
|
+
addNamespace(namespace: string | null): this;
|
|
533
|
+
getComponent(name: string | ElementType, namespace?: string | null): ElementType | null;
|
|
534
|
+
getComponents(namespace?: string | null): Record<string, ElementType> | null;
|
|
535
|
+
hasComponent(name: string, namespace?: string | null): boolean;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
interface Definition {
|
|
539
|
+
id: string;
|
|
540
|
+
component?: unknown;
|
|
541
|
+
[key: string]: unknown;
|
|
542
|
+
}
|
|
543
|
+
declare class DefinitionsManager<T extends Definition = Definition> {
|
|
544
|
+
definitions: T[];
|
|
545
|
+
constructor(definitions?: T[]);
|
|
546
|
+
addDefinition(definition: T | T[]): this;
|
|
547
|
+
addDefinitions(definitions: T[]): this;
|
|
548
|
+
merge(manager: DefinitionsManager<T>): this;
|
|
549
|
+
getDefinition(id: string | null): T | null;
|
|
550
|
+
getDefinitions(): T[];
|
|
551
|
+
hasDefinition(id: string): boolean;
|
|
552
|
+
getComponent(id: string): unknown;
|
|
553
|
+
getComponents(): Record<string, unknown>;
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
type EventCallback = (...args: unknown[]) => void;
|
|
557
|
+
declare class EventsManager extends EventEmitter {
|
|
558
|
+
element: EventTarget;
|
|
559
|
+
events: Record<string, EventCallback[]>;
|
|
560
|
+
listeners: Record<string, EventListener>;
|
|
561
|
+
constructor(element: EventTarget);
|
|
562
|
+
subscribe(event: string, callback: EventCallback): void;
|
|
563
|
+
unsubscribe(event: string, callback: EventCallback): void;
|
|
564
|
+
addEventListener(event: string): void;
|
|
565
|
+
removeEventListener(event: string): void;
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
declare class FieldsManager extends DefinitionsManager<FieldDefinition> {
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
interface Manager$1 {
|
|
572
|
+
getDefinition: (type: string) => Record<string, unknown> | null;
|
|
573
|
+
}
|
|
574
|
+
interface FontsParserOptions {
|
|
575
|
+
fieldsManager: Manager$1;
|
|
576
|
+
screensManager: Manager$1;
|
|
577
|
+
}
|
|
578
|
+
interface Font {
|
|
579
|
+
name?: string;
|
|
580
|
+
type?: string;
|
|
581
|
+
[key: string]: unknown;
|
|
582
|
+
}
|
|
583
|
+
interface Field$1 {
|
|
584
|
+
id?: string | null;
|
|
585
|
+
name?: string | null;
|
|
586
|
+
type?: string | null;
|
|
587
|
+
fields?: Field$1[];
|
|
588
|
+
itemsField?: Field$1 | null;
|
|
589
|
+
settings?: Field$1[];
|
|
590
|
+
[key: string]: unknown;
|
|
591
|
+
}
|
|
592
|
+
interface Screen$2 {
|
|
593
|
+
type: string;
|
|
594
|
+
[key: string]: unknown;
|
|
595
|
+
}
|
|
596
|
+
interface Story$1 {
|
|
597
|
+
theme?: Story$1 | null;
|
|
598
|
+
components?: Screen$2[];
|
|
599
|
+
fonts?: Font[];
|
|
600
|
+
[key: string]: unknown;
|
|
601
|
+
}
|
|
602
|
+
declare class FontsParser {
|
|
603
|
+
fieldsManager: Manager$1;
|
|
604
|
+
screensManager: Manager$1;
|
|
605
|
+
constructor({ fieldsManager, screensManager }: FontsParserOptions);
|
|
606
|
+
parse(story: Story$1 | null): Story$1 | null;
|
|
607
|
+
getFieldsPattern(fields: Field$1[], namePrefix?: string | null): RegExp[];
|
|
608
|
+
static fieldIsFontFamily({ id }: Field$1): boolean;
|
|
609
|
+
static valueIsFont({ type }: {
|
|
610
|
+
type?: unknown;
|
|
611
|
+
}): boolean;
|
|
612
|
+
static extractFontsWithPaths(data: unknown, patterns: RegExp[], keyPrefix?: string | null): Font[];
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
declare class FormsManager extends DefinitionsManager<FormDefinition> {
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
interface Manager {
|
|
619
|
+
getDefinition: (type: string) => Record<string, unknown> | null;
|
|
620
|
+
}
|
|
621
|
+
interface MediasParserOptions {
|
|
622
|
+
fieldsManager: Manager;
|
|
623
|
+
screensManager?: Manager | null;
|
|
624
|
+
}
|
|
625
|
+
interface Media$1 {
|
|
626
|
+
id?: string | null;
|
|
627
|
+
[key: string]: unknown;
|
|
628
|
+
}
|
|
629
|
+
interface Field {
|
|
630
|
+
id?: string | null;
|
|
631
|
+
name?: string | null;
|
|
632
|
+
type?: string | null;
|
|
633
|
+
media?: boolean;
|
|
634
|
+
fields?: Field[];
|
|
635
|
+
itemsField?: Field | null;
|
|
636
|
+
settings?: Field[];
|
|
637
|
+
[key: string]: unknown;
|
|
638
|
+
}
|
|
639
|
+
interface Screen$1 {
|
|
640
|
+
type: string;
|
|
641
|
+
[key: string]: unknown;
|
|
642
|
+
}
|
|
643
|
+
interface Story {
|
|
644
|
+
theme?: Story | null;
|
|
645
|
+
components?: Screen$1[];
|
|
646
|
+
medias?: Record<string, Media$1> | null;
|
|
647
|
+
[key: string]: unknown;
|
|
648
|
+
}
|
|
649
|
+
declare class MediasParser {
|
|
650
|
+
fieldsManager: Manager;
|
|
651
|
+
screensManager: Manager | null;
|
|
652
|
+
constructor({ fieldsManager, screensManager }: MediasParserOptions);
|
|
653
|
+
toPath(story: Story | null): Story | null;
|
|
654
|
+
fromPath(story: Story | null, defaultMedias?: Record<string, Media$1> | null): Story | null;
|
|
655
|
+
getMediaFieldsPattern(fields: Field[], namePrefix?: string | null): RegExp[];
|
|
656
|
+
static fieldIsMedia({ media }: Field): boolean;
|
|
657
|
+
static fieldIsFontFamily({ id }: Field): boolean;
|
|
658
|
+
static replacePathsWithMedias(data: unknown, medias: Record<string, Media$1>, patterns: RegExp[], keyPrefix?: string | null): unknown;
|
|
659
|
+
static getMediaPath({ id }: Media$1): string | null;
|
|
660
|
+
static replaceMediasWithPaths(data: unknown, patterns: RegExp[], medias?: Record<string, Media$1> | null, keyPrefix?: string | null): {
|
|
661
|
+
data: unknown;
|
|
662
|
+
medias: Record<string, Media$1> | null;
|
|
663
|
+
};
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
interface Screen {
|
|
667
|
+
id?: string | null;
|
|
668
|
+
type?: string | null;
|
|
669
|
+
[key: string]: unknown;
|
|
670
|
+
}
|
|
671
|
+
interface Media {
|
|
672
|
+
id?: string | null;
|
|
673
|
+
name?: string | null;
|
|
674
|
+
duration?: number | null;
|
|
675
|
+
currentTime?: number | null;
|
|
676
|
+
[key: string]: unknown;
|
|
677
|
+
}
|
|
678
|
+
interface TrackingEventOptions {
|
|
679
|
+
value?: string | number | null;
|
|
680
|
+
[key: string]: unknown;
|
|
681
|
+
}
|
|
682
|
+
declare class Tracking extends Tracking$1 {
|
|
683
|
+
variables: Record<string, unknown> | null;
|
|
684
|
+
setVariables(variables: Record<string, unknown> | null): void;
|
|
685
|
+
getVariables(): Record<string, unknown> | null;
|
|
686
|
+
trackScreenView(screen: Screen | null, screenIndex: number): void;
|
|
687
|
+
trackEvent(category: string, action: string, label?: string | null, options?: TrackingEventOptions | string | number | null): void;
|
|
688
|
+
trackMedia(type: string, media: Media | null, action: string, { value, ...opts }?: TrackingEventOptions): void;
|
|
689
|
+
}
|
|
690
|
+
|
|
593
691
|
export { ComponentsManager, DefinitionsManager, EventsManager, FieldsManager, FontsParser, FormsManager, MediasParser, Tracking };
|
|
594
|
-
export type { Action, ActionDefinition, ActionValue, AudioMedia, Breadcrumb, BreakpointsSize, Button, ButtonElement, ButtonSize, ButtonTheme, ButtonType, Column, ControlSize, Definition, DialogSize, DropdownAlign, Feedback, Field$2 as Field, FieldDefinition, FieldOption, Filter, Font$1 as Font, Form, FormDefinition, FormError, FormStatus, ImageMedia, Item, Label, Media, MediaFile, MediaType, MenuItem, Message, Modal, PageDefinition, Pagination, PanneauComponents, PanneauDefinition, PanneauIntl, PanneauIntlValues, PanneauPages, PanneauTheme, Preview, Resource, ResourceForms, ResourceIndex, ResourceIntl, ResourceIntlValues, ResourceItem, ResourcePages, RouteDefinition, Routes, SelectOption, StatusCode, TableColumn, Toggle, TrackingVariables, TriggerUpdate, Uppy, User, VideoMedia, uppy };
|
|
692
|
+
export type { Action, ActionDefinition, ActionValue, AudioMedia, Breadcrumb, BreakpointsSize, Button, ButtonElement, ButtonSize, ButtonTheme, ButtonType, Column, ComponentsMap, ControlSize, Definition$1 as Definition, DialogSize, DropdownAlign, Feedback, Field$2 as Field, FieldDefinition, FieldOption, FieldSettings, Filter, Font$1 as Font, Form, FormDefinition, FormError, FormStatus, ImageMedia, Item, Label, Media$2 as Media, MediaFile, MediaType, MenuItem, Message, MessageValue, MessageValues, Modal, PageDefinition, Pagination, PanneauAuth, PanneauComponents, PanneauDefinition, PanneauIntl, PanneauIntlValues, PanneauMenuItem, PanneauMenus, PanneauPages, PanneauTheme, Preview, Resource, ResourceForm, ResourceForms, ResourceIndex, ResourceIntl, ResourceIntlValues, ResourceItem, ResourcePages, ResourceType, RouteDefinition, Routes, SelectOption, StatusCode, TableColumn, Toggle, TrackingVariables, TriggerUpdate, Uppy, User, VideoMedia, uppy };
|