@panneau/core 4.0.78 → 4.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.
@@ -1,39 +1,9 @@
1
1
  import * as react from 'react';
2
- import { ElementType, ReactNode, ComponentType } from 'react';
3
- import { MessageDescriptor } from 'react-intl';
2
+ import { ElementType, ReactNode, ComponentProps, MouseEvent, ComponentType } from 'react';
3
+ import { MessageDescriptor, FormattedMessage } from 'react-intl';
4
4
  export { RoutesContext, RoutesProvider, useRoutes, useUrlGenerator } from '@folklore/routes';
5
5
  export { TrackingContext } from '@folklore/tracking';
6
6
 
7
- declare class ComponentsManager {
8
- components: Record<string, ElementType>;
9
- constructor(components?: Record<string, ElementType>);
10
- addComponent(name: string, component: ElementType, namespace?: string | null): this;
11
- addComponents(components: Record<string, ElementType>, namespace?: string | null): this;
12
- merge(manager: ComponentsManager, namespace?: string | null): this;
13
- addNamespace(namespace: string | null): this;
14
- getComponent(name: string | ElementType, namespace?: string | null): ElementType | null;
15
- getComponents(namespace?: string | null): Record<string, ElementType> | null;
16
- hasComponent(name: string, namespace?: string | null): boolean;
17
- }
18
-
19
- interface Definition$1 {
20
- id: string;
21
- component?: unknown;
22
- [key: string]: unknown;
23
- }
24
- declare class DefinitionsManager<T extends Definition$1 = Definition$1> {
25
- definitions: T[];
26
- constructor(definitions?: T[]);
27
- addDefinition(definition: T | T[]): this;
28
- addDefinitions(definitions: T[]): this;
29
- merge(manager: DefinitionsManager<T>): this;
30
- getDefinition(id: string | null): T | null;
31
- getDefinitions(): T[];
32
- hasDefinition(id: string): boolean;
33
- getComponent(id: string): unknown;
34
- getComponents(): Record<string, unknown>;
35
- }
36
-
37
7
  /**
38
8
  * Core UI Types
39
9
  */
@@ -42,10 +12,40 @@ declare class DefinitionsManager<T extends Definition$1 = Definition$1> {
42
12
  * Internationalization message definition
43
13
  */
44
14
  type Message = MessageDescriptor;
15
+ /**
16
+ * Values that can be interpolated in an internationalization message
17
+ * (the `values` prop of FormattedMessage)
18
+ */
19
+ type MessageValues = NonNullable<ComponentProps<typeof FormattedMessage>['values']>;
20
+ type MessageValue = MessageValues[string];
45
21
  /**
46
22
  * Label can be either a message object or any React node
47
23
  */
48
24
  type Label = Message | ReactNode;
25
+ /**
26
+ * Map of components, can be nested by namespace (ex: { fields: { text: TextField } })
27
+ */
28
+ interface ComponentsMap {
29
+ [name: string]: ElementType | ComponentsMap;
30
+ }
31
+ /**
32
+ * Menu item definition
33
+ */
34
+ interface MenuItem {
35
+ id?: number | string;
36
+ label?: Label;
37
+ url?: string;
38
+ href?: string | null;
39
+ external?: boolean;
40
+ active?: boolean;
41
+ type?: string;
42
+ component?: string;
43
+ className?: string | null;
44
+ linkClassName?: string | null;
45
+ onClick?: ((e: MouseEvent) => void) | null;
46
+ items?: MenuItem[] | null;
47
+ dropdown?: MenuItem[] | null;
48
+ }
49
49
  /**
50
50
  * Form control size
51
51
  */
@@ -59,7 +59,7 @@ interface Font {
59
59
  /**
60
60
  * Generic definition
61
61
  */
62
- interface Definition {
62
+ interface Definition$1 {
63
63
  id: string;
64
64
  component?: string | ElementType;
65
65
  [key: string]: unknown;
@@ -90,7 +90,7 @@ interface Field {
90
90
  size?: ControlSize;
91
91
  [key: string]: unknown;
92
92
  }
93
- interface FieldDefinition extends Omit<Field, 'component'>, Definition {
93
+ interface FieldDefinition extends Omit<Field, 'component'>, Definition$1 {
94
94
  }
95
95
  /**
96
96
  * Form definition
@@ -103,109 +103,8 @@ interface Form {
103
103
  submitButtonLabel?: Label | null;
104
104
  [key: string]: unknown;
105
105
  }
106
- interface FormDefinition extends Form, Definition {
107
- }
108
-
109
- declare class FieldsManager extends DefinitionsManager<FieldDefinition> {
110
- }
111
-
112
- declare class FormsManager extends DefinitionsManager<FormDefinition> {
113
- }
114
-
115
- declare const MODALS_NAMESPACE = "modals";
116
- declare const FIELDS_NAMESPACE = "fields";
117
- declare const FORMS_NAMESPACE = "forms";
118
- declare const FILTERS_NAMESPACE = "filters";
119
- declare const LISTS_NAMESPACE = "lists";
120
- declare const DISPLAYS_NAMESPACE = "displays";
121
- declare const ACTIONS_NAMESPACE = "actions";
122
- declare const BUTTONS_NAMESPACE = "buttons";
123
- declare const PAGES_NAMESPACE = "pages";
124
- declare const PREVIEWS_NAMESPACE = "previews";
125
- declare const APP_NAMESPACE = "app";
126
- declare const ComponentsContext: react.Context<ComponentsManager>;
127
- /**
128
- * Hooks
129
- */
130
- declare function useComponentsManager(namespace?: string | null): ComponentsManager;
131
- declare function useComponents(namespace?: string | null, defaultComponents?: Record<string, ElementType>): Record<string, ElementType>;
132
- declare function useComponent(name: string | ElementType | null, defaultComponent?: ElementType | null, namespace?: string | null): ElementType | null;
133
- /**
134
- * Fields hooks
135
- */
136
- declare function useFieldsComponentsManager(): ComponentsManager;
137
- declare function useFieldsComponents(defaultComponents?: {}): Record<string, ElementType>;
138
- declare function useFieldComponent(name: any, defaultComponent?: any): ElementType;
139
- /**
140
- * Forms hooks
141
- */
142
- declare function useFormsComponentsManager(): ComponentsManager;
143
- declare function useFormsComponents(defaultComponents?: {}): Record<string, ElementType>;
144
- declare function useFormComponent(name: any, defaultComponent?: any): ElementType;
145
- /**
146
- * Modals hooks
147
- */
148
- declare function useModalsComponentsManager(): ComponentsManager;
149
- declare function useModalsComponents(defaultComponents?: {}): Record<string, ElementType>;
150
- declare function useModalComponent(name: any, defaultComponent?: any): ElementType;
151
- /**
152
- * Filters hooks
153
- */
154
- declare function useFiltersComponentsManager(): ComponentsManager;
155
- declare function useFiltersComponents(defaultComponents?: {}): Record<string, ElementType>;
156
- declare function useFilterComponent(name: any, defaultComponent?: any): ElementType;
157
- /**
158
- * Lists hooks
159
- */
160
- declare function useListsComponentsManager(): ComponentsManager;
161
- declare function useListsComponents(defaultComponents?: {}): Record<string, ElementType>;
162
- declare function useListComponent(name: any, defaultComponent?: any): ElementType;
163
- /**
164
- * Displays hooks
165
- */
166
- declare function useDisplaysComponentsManager(): ComponentsManager;
167
- declare function useDisplaysComponents(defaultComponents?: {}): Record<string, ElementType>;
168
- declare function useDisplayComponent(name: any, defaultComponent?: any): ElementType;
169
- /**
170
- * Actions hooks
171
- */
172
- declare function useActionsComponentsManager(): ComponentsManager;
173
- declare function useActionsComponents(defaultComponents?: {}): Record<string, ElementType>;
174
- declare function useActionComponent(name: any, defaultComponent?: any): ElementType;
175
- /**
176
- * Buttons hooks
177
- */
178
- declare function useButtonsComponentsManager(): ComponentsManager;
179
- declare function useButtonsComponents(defaultComponents?: {}): Record<string, ElementType>;
180
- declare function useButtonComponent(name: any, defaultComponent?: any): ElementType;
181
- /**
182
- * Pages hooks
183
- */
184
- declare function usePagesComponentsManager(): ComponentsManager;
185
- declare function usePagesComponents(defaultComponents?: {}): Record<string, ElementType>;
186
- declare function usePageComponent(name: any, defaultComponent?: any): ElementType;
187
- /**
188
- * Previews hooks
189
- */
190
- declare function usePreviewsComponentsManager(): ComponentsManager;
191
- declare function usePreviewsComponents(defaultComponents?: {}): Record<string, ElementType>;
192
- declare function usePreviewComponent(name: any, defaultComponent?: any): ElementType;
193
- /**
194
- * App hooks
195
- */
196
- declare function useAppComponentsManager(): ComponentsManager;
197
- declare function useAppComponents(defaultComponents?: {}): Record<string, ElementType>;
198
- declare function useAppComponent(name: any, defaultComponent?: any): ElementType;
199
- /**
200
- * Provider
201
- */
202
- interface ComponentsProviderProps {
203
- children: ReactNode;
204
- namespace?: string | null;
205
- manager?: ComponentsManager | null;
206
- components?: Record<string, ElementType>;
106
+ interface FormDefinition extends Form, Definition$1 {
207
107
  }
208
- declare function ComponentsProvider({ components, manager, namespace, children, }: ComponentsProviderProps): react.JSX.Element;
209
108
 
210
109
  /**
211
110
  * Resource Types
@@ -218,6 +117,7 @@ declare function ComponentsProvider({ components, manager, namespace, children,
218
117
  type TableColumn = string | Column;
219
118
  interface Column extends Record<string, unknown> {
220
119
  id?: string | null;
120
+ name?: string | null;
221
121
  label?: unknown;
222
122
  path?: string;
223
123
  valueKey?: string;
@@ -243,7 +143,7 @@ type ActionDefinition = string | Action;
243
143
  interface ResourceIntlValues {
244
144
  a_singular?: string;
245
145
  a_plural?: string;
246
- [key: string]: unknown;
146
+ [key: string]: MessageValue;
247
147
  }
248
148
  /**
249
149
  * Internationalization configuration
@@ -271,13 +171,32 @@ interface ResourcePages {
271
171
  duplicate?: PageDefinition;
272
172
  [key: string]: PageDefinition | undefined;
273
173
  }
174
+ /**
175
+ * Form definition of a resource (the id is optional, the form is identified by its key)
176
+ */
177
+ interface ResourceForm extends Form {
178
+ id?: string;
179
+ component?: string | ElementType;
180
+ }
274
181
  interface ResourceForms {
275
- default: FormDefinition | null;
276
- create: FormDefinition | null;
277
- edit: FormDefinition | null;
278
- delete: FormDefinition | null;
279
- modal: FormDefinition | null;
280
- [key: string]: FormDefinition | null;
182
+ default?: ResourceForm | null;
183
+ create?: ResourceForm | null;
184
+ edit?: ResourceForm | null;
185
+ delete?: ResourceForm | null;
186
+ modal?: ResourceForm | null;
187
+ [key: string]: ResourceForm | null | undefined;
188
+ }
189
+ /**
190
+ * Resource type (sub-type of a resource, ex: page types)
191
+ */
192
+ interface ResourceType {
193
+ id?: string;
194
+ name?: string;
195
+ fields?: Field[];
196
+ settings?: {
197
+ canCreate?: boolean;
198
+ [key: string]: unknown;
199
+ };
281
200
  }
282
201
  interface Resource {
283
202
  id: string;
@@ -289,6 +208,7 @@ interface Resource {
289
208
  settings?: Record<string, unknown>;
290
209
  extraRoutes?: RouteDefinition[];
291
210
  pages?: ResourcePages;
211
+ types?: ResourceType[];
292
212
  }
293
213
  /**
294
214
  * Filter definition
@@ -308,17 +228,17 @@ interface Filter {
308
228
  * Panneau route configuration
309
229
  */
310
230
  interface Routes {
311
- 'resources.index': RouteDefinition | string;
312
- 'resources.create': RouteDefinition | string;
313
- 'resources.store': RouteDefinition | string;
314
- 'resources.show': RouteDefinition | string;
315
- 'resources.edit': RouteDefinition | string;
316
- 'resources.update': RouteDefinition | string;
317
- 'resources.delete': RouteDefinition | string;
318
- 'resources.destroy': RouteDefinition | string;
319
- 'resources.duplicate': RouteDefinition | string;
320
- 'resources.clone': RouteDefinition | string;
321
- 'resources.restore': RouteDefinition | string;
231
+ 'resources.index'?: RouteDefinition | string;
232
+ 'resources.create'?: RouteDefinition | string;
233
+ 'resources.store'?: RouteDefinition | string;
234
+ 'resources.show'?: RouteDefinition | string;
235
+ 'resources.edit'?: RouteDefinition | string;
236
+ 'resources.update'?: RouteDefinition | string;
237
+ 'resources.delete'?: RouteDefinition | string;
238
+ 'resources.destroy'?: RouteDefinition | string;
239
+ 'resources.duplicate'?: RouteDefinition | string;
240
+ 'resources.clone'?: RouteDefinition | string;
241
+ 'resources.restore'?: RouteDefinition | string;
322
242
  [key: string]: RouteDefinition | string;
323
243
  }
324
244
  interface PanneauTheme {
@@ -346,6 +266,21 @@ interface PanneauPages extends ResourcePages {
346
266
  account?: PageDefinition;
347
267
  error?: PageDefinition;
348
268
  }
269
+ /**
270
+ * Menu item in a Panneau menu: a menu item definition or a special item id
271
+ * (ex: 'resources', 'account', 'separator')
272
+ */
273
+ type PanneauMenuItem = MenuItem | string;
274
+ interface PanneauMenus {
275
+ main?: PanneauMenuItem[] | null;
276
+ guest?: PanneauMenuItem[] | null;
277
+ [key: string]: PanneauMenuItem[] | null | undefined;
278
+ }
279
+ interface PanneauAuth {
280
+ forgotPassword?: boolean;
281
+ register?: boolean;
282
+ [key: string]: unknown;
283
+ }
349
284
  /**
350
285
  * Panneau definition (main configuration)
351
286
  */
@@ -360,16 +295,149 @@ interface PanneauDefinition {
360
295
  settings?: Record<string, unknown>;
361
296
  forms?: FormDefinition[];
362
297
  fields?: FieldDefinition[];
298
+ menus?: PanneauMenus;
299
+ auth?: PanneauAuth;
363
300
  }
364
301
  /**
365
302
  * Tracking variables
366
303
  */
367
304
  type TrackingVariables = Record<string, unknown>;
368
305
 
369
- declare function useDefinitionContext(): Definition | null;
370
- declare function useDefinition(): Definition | null;
306
+ declare class ComponentsManager {
307
+ components: Record<string, ElementType>;
308
+ constructor(components?: ComponentsMap);
309
+ addComponent(name: string, component: ElementType, namespace?: string | null): this;
310
+ addComponents(components: Record<string, ElementType>, namespace?: string | null): this;
311
+ merge(manager: ComponentsManager, namespace?: string | null): this;
312
+ addNamespace(namespace: string | null): this;
313
+ getComponent(name: string | ElementType, namespace?: string | null): ElementType | null;
314
+ getComponents(namespace?: string | null): Record<string, ElementType> | null;
315
+ hasComponent(name: string, namespace?: string | null): boolean;
316
+ }
317
+
318
+ interface Definition {
319
+ id: string;
320
+ component?: unknown;
321
+ [key: string]: unknown;
322
+ }
323
+ declare class DefinitionsManager<T extends Definition = Definition> {
324
+ definitions: T[];
325
+ constructor(definitions?: T[]);
326
+ addDefinition(definition: T | T[]): this;
327
+ addDefinitions(definitions: T[]): this;
328
+ merge(manager: DefinitionsManager<T>): this;
329
+ getDefinition(id: string | null): T | null;
330
+ getDefinitions(): T[];
331
+ hasDefinition(id: string): boolean;
332
+ getComponent(id: string): unknown;
333
+ getComponents(): Record<string, unknown>;
334
+ }
335
+
336
+ declare class FieldsManager extends DefinitionsManager<FieldDefinition> {
337
+ }
338
+
339
+ declare class FormsManager extends DefinitionsManager<FormDefinition> {
340
+ }
341
+
342
+ declare const MODALS_NAMESPACE = "modals";
343
+ declare const FIELDS_NAMESPACE = "fields";
344
+ declare const FORMS_NAMESPACE = "forms";
345
+ declare const FILTERS_NAMESPACE = "filters";
346
+ declare const LISTS_NAMESPACE = "lists";
347
+ declare const DISPLAYS_NAMESPACE = "displays";
348
+ declare const ACTIONS_NAMESPACE = "actions";
349
+ declare const BUTTONS_NAMESPACE = "buttons";
350
+ declare const PAGES_NAMESPACE = "pages";
351
+ declare const PREVIEWS_NAMESPACE = "previews";
352
+ declare const APP_NAMESPACE = "app";
353
+ declare const ComponentsContext: react.Context<ComponentsManager>;
354
+ /**
355
+ * Hooks
356
+ */
357
+ declare function useComponentsManager(namespace?: string | null): ComponentsManager;
358
+ declare function useComponents(namespace?: string | null, defaultComponents?: Record<string, ElementType>): Record<string, ElementType>;
359
+ declare function useComponent(name: string | ElementType | null, defaultComponent?: ElementType | null, namespace?: string | null): ElementType | null;
360
+ /**
361
+ * Fields hooks
362
+ */
363
+ declare function useFieldsComponentsManager(): ComponentsManager;
364
+ declare function useFieldsComponents(defaultComponents?: {}): Record<string, ElementType>;
365
+ declare function useFieldComponent(name: any, defaultComponent?: any): ElementType;
366
+ /**
367
+ * Forms hooks
368
+ */
369
+ declare function useFormsComponentsManager(): ComponentsManager;
370
+ declare function useFormsComponents(defaultComponents?: {}): Record<string, ElementType>;
371
+ declare function useFormComponent(name: any, defaultComponent?: any): ElementType;
372
+ /**
373
+ * Modals hooks
374
+ */
375
+ declare function useModalsComponentsManager(): ComponentsManager;
376
+ declare function useModalsComponents(defaultComponents?: {}): Record<string, ElementType>;
377
+ declare function useModalComponent(name: any, defaultComponent?: any): ElementType;
378
+ /**
379
+ * Filters hooks
380
+ */
381
+ declare function useFiltersComponentsManager(): ComponentsManager;
382
+ declare function useFiltersComponents(defaultComponents?: {}): Record<string, ElementType>;
383
+ declare function useFilterComponent(name: any, defaultComponent?: any): ElementType;
384
+ /**
385
+ * Lists hooks
386
+ */
387
+ declare function useListsComponentsManager(): ComponentsManager;
388
+ declare function useListsComponents(defaultComponents?: {}): Record<string, ElementType>;
389
+ declare function useListComponent(name: any, defaultComponent?: any): ElementType;
390
+ /**
391
+ * Displays hooks
392
+ */
393
+ declare function useDisplaysComponentsManager(): ComponentsManager;
394
+ declare function useDisplaysComponents(defaultComponents?: {}): Record<string, ElementType>;
395
+ declare function useDisplayComponent(name: any, defaultComponent?: any): ElementType;
396
+ /**
397
+ * Actions hooks
398
+ */
399
+ declare function useActionsComponentsManager(): ComponentsManager;
400
+ declare function useActionsComponents(defaultComponents?: {}): Record<string, ElementType>;
401
+ declare function useActionComponent(name: any, defaultComponent?: any): ElementType;
402
+ /**
403
+ * Buttons hooks
404
+ */
405
+ declare function useButtonsComponentsManager(): ComponentsManager;
406
+ declare function useButtonsComponents(defaultComponents?: {}): Record<string, ElementType>;
407
+ declare function useButtonComponent(name: any, defaultComponent?: any): ElementType;
408
+ /**
409
+ * Pages hooks
410
+ */
411
+ declare function usePagesComponentsManager(): ComponentsManager;
412
+ declare function usePagesComponents(defaultComponents?: {}): Record<string, ElementType>;
413
+ declare function usePageComponent(name: any, defaultComponent?: any): ElementType;
414
+ /**
415
+ * Previews hooks
416
+ */
417
+ declare function usePreviewsComponentsManager(): ComponentsManager;
418
+ declare function usePreviewsComponents(defaultComponents?: {}): Record<string, ElementType>;
419
+ declare function usePreviewComponent(name: any, defaultComponent?: any): ElementType;
420
+ /**
421
+ * App hooks
422
+ */
423
+ declare function useAppComponentsManager(): ComponentsManager;
424
+ declare function useAppComponents(defaultComponents?: {}): Record<string, ElementType>;
425
+ declare function useAppComponent(name: any, defaultComponent?: any): ElementType;
426
+ /**
427
+ * Provider
428
+ */
429
+ interface ComponentsProviderProps {
430
+ children: ReactNode;
431
+ namespace?: string | null;
432
+ manager?: ComponentsManager | null;
433
+ components?: ComponentsMap;
434
+ }
435
+ declare function ComponentsProvider({ components, manager, namespace, children, }: ComponentsProviderProps): react.JSX.Element;
436
+
437
+ declare function useDefinitionContext(): Definition$1 | null;
438
+ declare function useDefinition(): Definition$1 | null;
371
439
  interface DefinitionProviderProps {
372
- definition: Definition;
440
+ definition: Definition$1;
373
441
  children: ReactNode;
374
442
  }
375
443
  declare function DefinitionProvider({ definition, children }: DefinitionProviderProps): react.JSX.Element;
@@ -386,9 +454,9 @@ interface FieldsProviderProps {
386
454
  declare function FieldsProvider({ fields, manager, children }: FieldsProviderProps): react.JSX.Element;
387
455
 
388
456
  interface FontsContextValue {
389
- systemFonts: Font[] | null;
390
- googleFonts: Font[] | null;
391
- customFonts: Font[] | null;
457
+ systemFonts: (Font | string)[] | null;
458
+ googleFonts: (Font | string)[] | null;
459
+ customFonts: (Font | string)[] | null;
392
460
  setGoogleFonts?: ((fonts: Font[]) => void) | null;
393
461
  }
394
462
  declare const FontsContext: react.Context<FontsContextValue>;
@@ -485,10 +553,11 @@ interface ModalData {
485
553
  withoutBackdrop?: boolean;
486
554
  [key: string]: unknown;
487
555
  }
556
+ type ModalContainer = Element | DocumentFragment;
488
557
  interface ModalContextValue {
489
558
  modals: ModalData[];
490
- container: unknown | null;
491
- setContainer: (container: unknown) => void;
559
+ container: ModalContainer | null;
560
+ setContainer: (container: ModalContainer | null) => void;
492
561
  register: (id: string, data?: Record<string, unknown> | null) => void;
493
562
  unregister: (id?: string | null) => void;
494
563
  closeModal: (id: string) => void;
@@ -499,7 +568,7 @@ declare const ModalContext: react.Context<ModalContextValue>;
499
568
  declare function useModal(): ModalContextValue;
500
569
  interface ModalProviderProps {
501
570
  children: ReactNode;
502
- container?: unknown | null;
571
+ container?: ModalContainer | null;
503
572
  }
504
573
  declare function ModalProvider({ children, container: initialContainer }: ModalProviderProps): react.JSX.Element;
505
574
 
@@ -531,13 +600,13 @@ declare function usePanneauResources(): Resource[];
531
600
  declare function usePanneauResource(id: Resource | string | null): Resource | null;
532
601
  declare function usePanneauColorScheme(): {
533
602
  theme: string;
534
- background: string | null;
535
- text: string | null;
603
+ background: 'light' | 'dark' | null;
604
+ text: 'light' | 'dark' | null;
536
605
  sidebarPosition?: string | null;
537
606
  };
538
607
  declare function usePanneauComponents(): Record<string, unknown>;
539
608
  declare function usePanneauComponent(namespace: string | null, name: string): string | null;
540
- declare function usePanneauAuth(): Record<string, unknown>;
609
+ declare function usePanneauAuth(): PanneauAuth;
541
610
  declare function usePanneauSettings(): Record<string, unknown>;
542
611
  interface PanneauProviderProps {
543
612
  definition: PanneauDefinition;
@@ -555,7 +624,7 @@ declare function ResourceProvider({ resource, children }: ResourceProviderProps)
555
624
  declare function useRoutePush(): (route: string | {
556
625
  pathname?: string | null;
557
626
  search?: string | null;
558
- }, data?: unknown, ...args: unknown[]) => void;
627
+ }, data?: Record<string, unknown> | null, ...args: unknown[]) => void;
559
628
  declare function useRouteBack(): () => void;
560
629
 
561
630
  declare function useTracking(): any;
@@ -566,4 +635,4 @@ interface TrackingProviderProps {
566
635
  declare function TrackingProvider({ variables, children }: TrackingProviderProps): react.JSX.Element;
567
636
 
568
637
  export { ACTIONS_NAMESPACE, APP_NAMESPACE, BUTTONS_NAMESPACE, ComponentsContext, ComponentsProvider, DISPLAYS_NAMESPACE, DefinitionProvider, FIELDS_NAMESPACE, FILTERS_NAMESPACE, FORMS_NAMESPACE, FieldsContext, FieldsProvider, FontsContext, FontsProvider, FormProvider, FormsContext, FormsProvider, GoogleApiClientContext, GoogleApiClientProvider, GoogleKeysContext, GoogleKeysProvider, GoogleMapsClientContext, GoogleMapsClientProvider, LISTS_NAMESPACE, LocalesContext, LocalesProvider, MODALS_NAMESPACE, ModalContext, ModalProvider, PAGES_NAMESPACE, PREVIEWS_NAMESPACE, PanelsContext, PanelsProvider, PanneauProvider, ResourceProvider, TrackingProvider, useActionComponent, useActionsComponents, useActionsComponentsManager, useAppComponent, useAppComponents, useAppComponentsManager, useButtonComponent, useButtonsComponents, useButtonsComponentsManager, useComponent, useComponents, useComponentsManager, useDefinition, useDefinitionContext, useDisplayComponent, useDisplaysComponents, useDisplaysComponentsManager, useFieldComponent, useFieldDefinition, useFieldDefinitions, useFieldsComponents, useFieldsComponentsManager, useFieldsManager, useFilterComponent, useFiltersComponents, useFiltersComponentsManager, useFonts, useFormComponent, useFormContext, useFormDefinition, useFormDefinitions, useFormSetValue, useFormValue, useFormsComponents, useFormsComponentsManager, useFormsManager, useGoogleApiClient, useGoogleFonts, useGoogleKeys, useGoogleMapsClient, useListComponent, useListsComponents, useListsComponentsManager, useLocales, useLocalesContext, useModal, useModalComponent, useModalsComponents, useModalsComponentsManager, useOtherLocales, usePageComponent, usePagesComponents, usePagesComponentsManager, usePanels, usePanneau, usePanneauAuth, usePanneauColorScheme, usePanneauComponent, usePanneauComponents, usePanneauResource, usePanneauResources, usePanneauSettings, usePreviewComponent, usePreviewsComponents, usePreviewsComponentsManager, useResource, useRouteBack, useRoutePush, useTracking, withGoogleApiClient, withGoogleMapsClient, withPanels };
569
- export type { ModalContextValue, ModalData };
638
+ export type { ModalContainer, ModalContextValue, ModalData };
package/dist/contexts.js CHANGED
@@ -37,7 +37,7 @@ function useComponentsManager(t0) {
37
37
  const manager = useContext(ComponentsContext);
38
38
  let t1;
39
39
  if ($[0] !== manager || $[1] !== namespace) {
40
- t1 = namespace !== null ? new ComponentsManager(manager.getComponents(namespace)) : manager;
40
+ t1 = namespace !== null ? new ComponentsManager(manager?.getComponents(namespace) ?? {}) : manager;
41
41
  $[0] = manager;
42
42
  $[1] = namespace;
43
43
  $[2] = t1;
@@ -62,7 +62,7 @@ function useComponents(t0, t1) {
62
62
  const manager = useComponentsManager();
63
63
  let t3;
64
64
  if ($[2] !== defaultComponents || $[3] !== manager || $[4] !== namespace) {
65
- t3 = manager.getComponents(namespace) || defaultComponents;
65
+ t3 = manager?.getComponents(namespace) || defaultComponents;
66
66
  $[2] = defaultComponents;
67
67
  $[3] = manager;
68
68
  $[4] = namespace;
@@ -85,7 +85,7 @@ function useComponent(name, t0, t1) {
85
85
  }
86
86
  let t3;
87
87
  if ($[0] !== defaultComponent || $[1] !== manager || $[2] !== name) {
88
- t3 = manager.getComponent(name) || defaultComponent;
88
+ t3 = manager?.getComponent(name) || defaultComponent;
89
89
  $[0] = defaultComponent;
90
90
  $[1] = manager;
91
91
  $[2] = name;
@@ -482,7 +482,7 @@ function FieldsProvider(t0) {
482
482
  const previousManager = useFieldsManager() || null;
483
483
  let t3;
484
484
  if ($[0] !== fields || $[1] !== manager || $[2] !== previousManager) {
485
- const newFields = uniqBy([...(fields || []), ...(manager !== null ? manager.getDefinitions() : []), ...(previousManager !== null ? previousManager.getDefinitions() : [])], _temp$2).reverse();
485
+ const newFields = uniqBy([...(fields || []), ...(manager !== null ? manager.getDefinitions() : []), ...(previousManager !== null ? previousManager.getDefinitions() : [])], _temp$3).reverse();
486
486
  t3 = new FieldsManager(newFields);
487
487
  $[0] = fields;
488
488
  $[1] = manager;
@@ -535,7 +535,7 @@ function FieldsProvider(t0) {
535
535
  }
536
536
  return t6;
537
537
  }
538
- function _temp$2(t0) {
538
+ function _temp$3(t0) {
539
539
  const {
540
540
  id
541
541
  } = t0;
@@ -622,7 +622,7 @@ function useGoogleFonts(t0) {
622
622
  } = t6;
623
623
  const items = t7 === undefined ? [] : t7;
624
624
  if (!canceled) {
625
- const newFonts = items.map(_temp$1);
625
+ const newFonts = items.map(_temp$2);
626
626
  if (setFonts !== null) {
627
627
  setFonts(newFonts);
628
628
  } else {
@@ -648,7 +648,7 @@ function useGoogleFonts(t0) {
648
648
  useEffect(t4, t5);
649
649
  return googleFonts;
650
650
  }
651
- function _temp$1(it) {
651
+ function _temp$2(it) {
652
652
  return {
653
653
  type: "google",
654
654
  name: it.family,
@@ -890,7 +890,7 @@ function FormsProvider(t0) {
890
890
  const previousManager = useFormsManager() || null;
891
891
  let t3;
892
892
  if ($[0] !== forms || $[1] !== manager || $[2] !== previousManager) {
893
- const newForms = uniqBy([...(forms || []), ...(manager !== null ? manager.getDefinitions() : []), ...(previousManager !== null ? previousManager.getDefinitions() : [])], _temp).reverse();
893
+ const newForms = uniqBy([...(forms || []), ...(manager !== null ? manager.getDefinitions() : []), ...(previousManager !== null ? previousManager.getDefinitions() : [])], _temp$1).reverse();
894
894
  t3 = new FormsManager(newForms);
895
895
  $[0] = forms;
896
896
  $[1] = manager;
@@ -943,7 +943,7 @@ function FormsProvider(t0) {
943
943
  }
944
944
  return t6;
945
945
  }
946
- function _temp(t0) {
946
+ function _temp$1(t0) {
947
947
  const {
948
948
  id
949
949
  } = t0;
@@ -981,6 +981,9 @@ function withGoogleApiClient(WrappedComponent) {
981
981
  WithGoogleApiClientComponent.displayName = `WithGoogleApiClient(${getDisplayName(WrappedComponent)})`;
982
982
  return WithGoogleApiClientComponent;
983
983
  }
984
+
985
+ // Minimal shape of the Google API (gapi) object used here, @folklore/services types it as unknown
986
+
984
987
  function GoogleApiClientProvider(t0) {
985
988
  const $ = c(6);
986
989
  const {
@@ -1039,7 +1042,7 @@ function withGoogleMapsClient(WrappedComponent) {
1039
1042
  if ($[0] !== props) {
1040
1043
  t0 = /*#__PURE__*/jsx(GoogleMapsClientContext.Consumer, {
1041
1044
  children: client => /*#__PURE__*/jsx(WrappedComponent, {
1042
- googleApiClient: client,
1045
+ googleMapsClient: client,
1043
1046
  ...props
1044
1047
  })
1045
1048
  });
@@ -1342,7 +1345,7 @@ const PanelsContext = /*#__PURE__*/createContext({
1342
1345
  unregister: () => {}
1343
1346
  });
1344
1347
  function usePanels() {
1345
- return useContext(PanelsContext) || {};
1348
+ return useContext(PanelsContext);
1346
1349
  }
1347
1350
  function withPanels(WrappedComponent) {
1348
1351
  function WithPanelsComponent(props) {
@@ -1693,20 +1696,14 @@ function useRoutePush() {
1693
1696
  return push;
1694
1697
  }
1695
1698
  function useRouteBack() {
1696
- const $ = c(2);
1697
- useUrlGenerator();
1698
- const [, navigate] = useLocation();
1699
- let t0;
1700
- if ($[0] !== navigate) {
1701
- t0 = () => navigate(-1);
1702
- $[0] = navigate;
1703
- $[1] = t0;
1704
- } else {
1705
- t0 = $[1];
1706
- }
1707
- const back = t0;
1699
+ const back = _temp;
1708
1700
  return back;
1709
1701
  }
1702
+ function _temp() {
1703
+ if (typeof window !== "undefined") {
1704
+ window.history.back();
1705
+ }
1706
+ }
1710
1707
 
1711
1708
  function useTracking() {
1712
1709
  return useContext(TrackingContext);