@panneau/core 4.0.74 → 4.0.75
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 +143 -76
- package/dist/contexts.js +113 -10
- package/dist/hooks.d.ts +67 -6
- package/dist/index.d.ts +232 -187
- package/dist/index.js +12 -8
- package/dist/utils.d.ts +54 -23
- package/dist/utils.js +3 -2
- package/package.json +2 -2
package/dist/contexts.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ElementType, ReactNode, ComponentType } from 'react';
|
|
3
|
+
import { MessageDescriptor } from 'react-intl';
|
|
3
4
|
export { RoutesContext, RoutesProvider, useRoutes, useUrlGenerator } from '@folklore/routes';
|
|
4
5
|
export { TrackingContext } from '@folklore/tracking';
|
|
5
6
|
|
|
@@ -10,7 +11,7 @@ declare class ComponentsManager {
|
|
|
10
11
|
addComponents(components: Record<string, ElementType>, namespace?: string | null): this;
|
|
11
12
|
merge(manager: ComponentsManager, namespace?: string | null): this;
|
|
12
13
|
addNamespace(namespace: string | null): this;
|
|
13
|
-
getComponent(name: string, namespace?: string | null): ElementType | null;
|
|
14
|
+
getComponent(name: string | ElementType, namespace?: string | null): ElementType | null;
|
|
14
15
|
getComponents(namespace?: string | null): Record<string, ElementType> | null;
|
|
15
16
|
hasComponent(name: string, namespace?: string | null): boolean;
|
|
16
17
|
}
|
|
@@ -20,20 +21,95 @@ interface Definition$1 {
|
|
|
20
21
|
component?: unknown;
|
|
21
22
|
[key: string]: unknown;
|
|
22
23
|
}
|
|
23
|
-
declare class DefinitionsManager {
|
|
24
|
-
definitions:
|
|
25
|
-
constructor(definitions?:
|
|
26
|
-
addDefinition(definition:
|
|
27
|
-
addDefinitions(definitions:
|
|
28
|
-
merge(manager: DefinitionsManager): this;
|
|
29
|
-
getDefinition(id: string | null):
|
|
30
|
-
getDefinitions():
|
|
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[];
|
|
31
32
|
hasDefinition(id: string): boolean;
|
|
32
33
|
getComponent(id: string): unknown;
|
|
33
34
|
getComponents(): Record<string, unknown>;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Core UI Types
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Internationalization message definition
|
|
43
|
+
*/
|
|
44
|
+
type Message = MessageDescriptor;
|
|
45
|
+
/**
|
|
46
|
+
* Label can be either a message object or any React node
|
|
47
|
+
*/
|
|
48
|
+
type Label = Message | ReactNode;
|
|
49
|
+
/**
|
|
50
|
+
* Form control size
|
|
51
|
+
*/
|
|
52
|
+
type ControlSize = 'lg' | 'sm' | null;
|
|
53
|
+
/**
|
|
54
|
+
* Font definition
|
|
55
|
+
*/
|
|
56
|
+
interface Font {
|
|
57
|
+
name: string;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Generic definition
|
|
61
|
+
*/
|
|
62
|
+
interface Definition {
|
|
63
|
+
id: string;
|
|
64
|
+
component?: string | ElementType;
|
|
65
|
+
[key: string]: unknown;
|
|
66
|
+
}
|
|
67
|
+
interface RouteDefinition {
|
|
68
|
+
path?: string;
|
|
69
|
+
route?: string;
|
|
70
|
+
component: string | ElementType;
|
|
71
|
+
[key: string]: unknown;
|
|
72
|
+
}
|
|
73
|
+
interface PageDefinition {
|
|
74
|
+
component: string | ElementType;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Form Types
|
|
79
|
+
* TypeScript interfaces for form-related components
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Field definition
|
|
84
|
+
*/
|
|
85
|
+
interface Field {
|
|
86
|
+
name?: string;
|
|
87
|
+
type?: string;
|
|
88
|
+
label?: Label;
|
|
89
|
+
component?: string;
|
|
90
|
+
size?: ControlSize;
|
|
91
|
+
[key: string]: unknown;
|
|
92
|
+
}
|
|
93
|
+
interface FieldDefinition extends Omit<Field, 'component'>, Definition {
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Form definition
|
|
97
|
+
*/
|
|
98
|
+
interface Form {
|
|
99
|
+
title?: ReactNode;
|
|
100
|
+
fields?: Field[];
|
|
101
|
+
method?: string | null;
|
|
102
|
+
action?: string | null;
|
|
103
|
+
submitButtonLabel?: Label | null;
|
|
104
|
+
[key: string]: unknown;
|
|
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> {
|
|
37
113
|
}
|
|
38
114
|
|
|
39
115
|
declare const MODALS_NAMESPACE = "modals";
|
|
@@ -131,39 +207,6 @@ interface ComponentsProviderProps {
|
|
|
131
207
|
}
|
|
132
208
|
declare function ComponentsProvider({ components, manager, namespace, children, }: ComponentsProviderProps): react.JSX.Element;
|
|
133
209
|
|
|
134
|
-
/**
|
|
135
|
-
* Core UI Types
|
|
136
|
-
*/
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Font definition
|
|
140
|
-
*/
|
|
141
|
-
interface Font {
|
|
142
|
-
name: string;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Form Types
|
|
147
|
-
* TypeScript interfaces for form-related components
|
|
148
|
-
*/
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* Field definition
|
|
152
|
-
*/
|
|
153
|
-
interface Field {
|
|
154
|
-
name?: string;
|
|
155
|
-
type?: string;
|
|
156
|
-
component?: string | ElementType;
|
|
157
|
-
label?: ReactNode;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Form definition
|
|
161
|
-
*/
|
|
162
|
-
interface Form {
|
|
163
|
-
title: ReactNode;
|
|
164
|
-
fields?: Field[];
|
|
165
|
-
}
|
|
166
|
-
|
|
167
210
|
/**
|
|
168
211
|
* Resource Types
|
|
169
212
|
* TypeScript interfaces for resources, items, users, media, and other entities
|
|
@@ -219,15 +262,33 @@ interface ResourceIndex {
|
|
|
219
262
|
fields?: Field[];
|
|
220
263
|
[key: string]: unknown;
|
|
221
264
|
}
|
|
265
|
+
interface ResourcePages {
|
|
266
|
+
index?: PageDefinition;
|
|
267
|
+
show?: PageDefinition;
|
|
268
|
+
create?: PageDefinition;
|
|
269
|
+
edit?: PageDefinition;
|
|
270
|
+
delete?: PageDefinition;
|
|
271
|
+
duplicate?: PageDefinition;
|
|
272
|
+
[key: string]: PageDefinition | undefined;
|
|
273
|
+
}
|
|
274
|
+
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;
|
|
281
|
+
}
|
|
222
282
|
interface Resource {
|
|
223
283
|
id: string;
|
|
224
284
|
name: string;
|
|
225
285
|
intl?: ResourceIntl;
|
|
226
286
|
fields?: Field[];
|
|
227
287
|
index?: ResourceIndex;
|
|
228
|
-
forms?:
|
|
229
|
-
shows_in_navbar?: boolean;
|
|
288
|
+
forms?: ResourceForms;
|
|
230
289
|
settings?: Record<string, unknown>;
|
|
290
|
+
extraRoutes?: RouteDefinition[];
|
|
291
|
+
pages?: ResourcePages;
|
|
231
292
|
}
|
|
232
293
|
/**
|
|
233
294
|
* Filter definition
|
|
@@ -247,25 +308,18 @@ interface Filter {
|
|
|
247
308
|
* Panneau route configuration
|
|
248
309
|
*/
|
|
249
310
|
interface Routes {
|
|
250
|
-
'resources.index': string;
|
|
251
|
-
'resources.create': string;
|
|
252
|
-
'resources.store': string;
|
|
253
|
-
'resources.show': string;
|
|
254
|
-
'resources.edit': string;
|
|
255
|
-
'resources.update': string;
|
|
256
|
-
'resources.delete': string;
|
|
257
|
-
'resources.destroy': string;
|
|
258
|
-
'resources.duplicate': string;
|
|
259
|
-
'resources.clone': string;
|
|
260
|
-
'resources.restore': string;
|
|
261
|
-
[key: string]: string;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Page definition
|
|
265
|
-
*/
|
|
266
|
-
interface Page {
|
|
267
|
-
component: string;
|
|
268
|
-
[key: string]: unknown;
|
|
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;
|
|
322
|
+
[key: string]: RouteDefinition | string;
|
|
269
323
|
}
|
|
270
324
|
interface PanneauTheme {
|
|
271
325
|
colorScheme?: string | null;
|
|
@@ -286,24 +340,26 @@ interface PanneauIntl {
|
|
|
286
340
|
messages?: Record<string, string>;
|
|
287
341
|
values?: PanneauIntlValues;
|
|
288
342
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
[key: string]: unknown;
|
|
343
|
+
interface PanneauPages extends ResourcePages {
|
|
344
|
+
home?: PageDefinition;
|
|
345
|
+
login?: PageDefinition;
|
|
346
|
+
account?: PageDefinition;
|
|
347
|
+
error?: PageDefinition;
|
|
295
348
|
}
|
|
296
349
|
/**
|
|
297
350
|
* Panneau definition (main configuration)
|
|
298
351
|
*/
|
|
299
|
-
interface PanneauDefinition
|
|
352
|
+
interface PanneauDefinition {
|
|
353
|
+
name?: string;
|
|
300
354
|
resources?: Resource[];
|
|
301
355
|
routes?: Routes;
|
|
302
|
-
pages?:
|
|
356
|
+
pages?: PanneauPages;
|
|
303
357
|
intl?: PanneauIntl;
|
|
304
358
|
theme?: PanneauTheme;
|
|
305
359
|
components?: PanneauComponents;
|
|
306
360
|
settings?: Record<string, unknown>;
|
|
361
|
+
forms?: FormDefinition[];
|
|
362
|
+
fields?: FieldDefinition[];
|
|
307
363
|
}
|
|
308
364
|
/**
|
|
309
365
|
* Tracking variables
|
|
@@ -320,10 +376,10 @@ declare function DefinitionProvider({ definition, children }: DefinitionProvider
|
|
|
320
376
|
|
|
321
377
|
declare const FieldsContext: react.Context<FieldsManager>;
|
|
322
378
|
declare function useFieldsManager(): FieldsManager | null;
|
|
323
|
-
declare function
|
|
324
|
-
declare function
|
|
379
|
+
declare function useFieldDefinition(id: string): FieldDefinition | null;
|
|
380
|
+
declare function useFieldDefinitions(): FieldDefinition[];
|
|
325
381
|
interface FieldsProviderProps {
|
|
326
|
-
fields?:
|
|
382
|
+
fields?: FieldDefinition[] | null;
|
|
327
383
|
manager?: FieldsManager | null;
|
|
328
384
|
children: ReactNode;
|
|
329
385
|
}
|
|
@@ -364,6 +420,17 @@ interface FormProviderProps {
|
|
|
364
420
|
}
|
|
365
421
|
declare function FormProvider({ value, setValue, children }: FormProviderProps): react.JSX.Element;
|
|
366
422
|
|
|
423
|
+
declare const FormsContext: react.Context<FormsManager>;
|
|
424
|
+
declare function useFormsManager(): FormsManager | null;
|
|
425
|
+
declare function useFormDefinition(id: string): FormDefinition | null;
|
|
426
|
+
declare function useFormDefinitions(): FormDefinition[];
|
|
427
|
+
interface FormsProviderProps {
|
|
428
|
+
forms?: FormDefinition[] | null;
|
|
429
|
+
manager?: FormsManager | null;
|
|
430
|
+
children: ReactNode;
|
|
431
|
+
}
|
|
432
|
+
declare function FormsProvider({ forms, manager, children }: FormsProviderProps): react.JSX.Element;
|
|
433
|
+
|
|
367
434
|
declare const GoogleApiClientContext: react.Context<any>;
|
|
368
435
|
declare function useGoogleApiClient(): any | null;
|
|
369
436
|
declare function withGoogleApiClient(WrappedComponent: ComponentType<any>): {
|
|
@@ -498,5 +565,5 @@ interface TrackingProviderProps {
|
|
|
498
565
|
}
|
|
499
566
|
declare function TrackingProvider({ variables, children }: TrackingProviderProps): react.JSX.Element;
|
|
500
567
|
|
|
501
|
-
export { ACTIONS_NAMESPACE, APP_NAMESPACE, BUTTONS_NAMESPACE, ComponentsContext, ComponentsProvider, DISPLAYS_NAMESPACE, DefinitionProvider, FIELDS_NAMESPACE, FILTERS_NAMESPACE, FORMS_NAMESPACE, FieldsContext, FieldsProvider, FontsContext, FontsProvider, FormProvider, 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,
|
|
568
|
+
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 };
|
|
502
569
|
export type { ModalContextValue, ModalData };
|
package/dist/contexts.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { c } from 'react/compiler-runtime';
|
|
2
2
|
import isString from 'lodash-es/isString';
|
|
3
|
-
import { createContext, useContext,
|
|
4
|
-
import { ComponentsManager, FieldsManager, Tracking } from '@panneau/core';
|
|
3
|
+
import { createContext, useContext, use, useState, useEffect, useRef } from 'react';
|
|
4
|
+
import { ComponentsManager, FieldsManager, FormsManager, Tracking } from '@panneau/core';
|
|
5
5
|
import { jsx } from 'react/jsx-runtime';
|
|
6
6
|
import uniqBy from 'lodash-es/uniqBy';
|
|
7
7
|
import { getJSON } from '@folklore/fetch';
|
|
@@ -441,9 +441,9 @@ function DefinitionProvider(t0) {
|
|
|
441
441
|
|
|
442
442
|
const FieldsContext = /*#__PURE__*/createContext(null);
|
|
443
443
|
function useFieldsManager() {
|
|
444
|
-
return
|
|
444
|
+
return use(FieldsContext);
|
|
445
445
|
}
|
|
446
|
-
function
|
|
446
|
+
function useFieldDefinition(id) {
|
|
447
447
|
const $ = c(3);
|
|
448
448
|
const manager = useFieldsManager();
|
|
449
449
|
let t0;
|
|
@@ -457,7 +457,7 @@ function useField(id) {
|
|
|
457
457
|
}
|
|
458
458
|
return t0;
|
|
459
459
|
}
|
|
460
|
-
function
|
|
460
|
+
function useFieldDefinitions() {
|
|
461
461
|
const $ = c(2);
|
|
462
462
|
const manager = useFieldsManager();
|
|
463
463
|
let t0;
|
|
@@ -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$
|
|
485
|
+
const newFields = uniqBy([...(fields || []), ...(manager !== null ? manager.getDefinitions() : []), ...(previousManager !== null ? previousManager.getDefinitions() : [])], _temp$2).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$
|
|
538
|
+
function _temp$2(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);
|
|
625
|
+
const newFonts = items.map(_temp$1);
|
|
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(it) {
|
|
651
|
+
function _temp$1(it) {
|
|
652
652
|
return {
|
|
653
653
|
type: "google",
|
|
654
654
|
name: it.family,
|
|
@@ -847,6 +847,109 @@ function FormProvider(t0) {
|
|
|
847
847
|
return t2;
|
|
848
848
|
}
|
|
849
849
|
|
|
850
|
+
const FormsContext = /*#__PURE__*/createContext(null);
|
|
851
|
+
function useFormsManager() {
|
|
852
|
+
return use(FormsContext);
|
|
853
|
+
}
|
|
854
|
+
function useFormDefinition(id) {
|
|
855
|
+
const $ = c(3);
|
|
856
|
+
const manager = useFormsManager();
|
|
857
|
+
let t0;
|
|
858
|
+
if ($[0] !== id || $[1] !== manager) {
|
|
859
|
+
t0 = manager.getDefinition(id);
|
|
860
|
+
$[0] = id;
|
|
861
|
+
$[1] = manager;
|
|
862
|
+
$[2] = t0;
|
|
863
|
+
} else {
|
|
864
|
+
t0 = $[2];
|
|
865
|
+
}
|
|
866
|
+
return t0;
|
|
867
|
+
}
|
|
868
|
+
function useFormDefinitions() {
|
|
869
|
+
const $ = c(2);
|
|
870
|
+
const manager = useFormsManager();
|
|
871
|
+
let t0;
|
|
872
|
+
if ($[0] !== manager) {
|
|
873
|
+
t0 = manager.getDefinitions();
|
|
874
|
+
$[0] = manager;
|
|
875
|
+
$[1] = t0;
|
|
876
|
+
} else {
|
|
877
|
+
t0 = $[1];
|
|
878
|
+
}
|
|
879
|
+
return t0;
|
|
880
|
+
}
|
|
881
|
+
function FormsProvider(t0) {
|
|
882
|
+
const $ = c(12);
|
|
883
|
+
const {
|
|
884
|
+
forms: t1,
|
|
885
|
+
manager: t2,
|
|
886
|
+
children
|
|
887
|
+
} = t0;
|
|
888
|
+
const forms = t1 === undefined ? null : t1;
|
|
889
|
+
const manager = t2 === undefined ? null : t2;
|
|
890
|
+
const previousManager = useFormsManager() || null;
|
|
891
|
+
let t3;
|
|
892
|
+
if ($[0] !== forms || $[1] !== manager || $[2] !== previousManager) {
|
|
893
|
+
const newForms = uniqBy([...(forms || []), ...(manager !== null ? manager.getDefinitions() : []), ...(previousManager !== null ? previousManager.getDefinitions() : [])], _temp).reverse();
|
|
894
|
+
t3 = new FormsManager(newForms);
|
|
895
|
+
$[0] = forms;
|
|
896
|
+
$[1] = manager;
|
|
897
|
+
$[2] = previousManager;
|
|
898
|
+
$[3] = t3;
|
|
899
|
+
} else {
|
|
900
|
+
t3 = $[3];
|
|
901
|
+
}
|
|
902
|
+
const finalManager = t3;
|
|
903
|
+
let t4;
|
|
904
|
+
if ($[4] !== finalManager) {
|
|
905
|
+
const newComponents = finalManager.getComponents();
|
|
906
|
+
t4 = Object.keys(newComponents).reduce((map, id_0) => {
|
|
907
|
+
const component = newComponents[id_0];
|
|
908
|
+
return isString(component) ? map : {
|
|
909
|
+
...map,
|
|
910
|
+
[id_0]: component
|
|
911
|
+
};
|
|
912
|
+
}, {});
|
|
913
|
+
$[4] = finalManager;
|
|
914
|
+
$[5] = t4;
|
|
915
|
+
} else {
|
|
916
|
+
t4 = $[5];
|
|
917
|
+
}
|
|
918
|
+
const components = t4;
|
|
919
|
+
let t5;
|
|
920
|
+
if ($[6] !== children || $[7] !== components) {
|
|
921
|
+
t5 = /*#__PURE__*/jsx(ComponentsProvider, {
|
|
922
|
+
namespace: FORMS_NAMESPACE,
|
|
923
|
+
components: components,
|
|
924
|
+
children: children
|
|
925
|
+
});
|
|
926
|
+
$[6] = children;
|
|
927
|
+
$[7] = components;
|
|
928
|
+
$[8] = t5;
|
|
929
|
+
} else {
|
|
930
|
+
t5 = $[8];
|
|
931
|
+
}
|
|
932
|
+
let t6;
|
|
933
|
+
if ($[9] !== finalManager || $[10] !== t5) {
|
|
934
|
+
t6 = /*#__PURE__*/jsx(FormsContext, {
|
|
935
|
+
value: finalManager,
|
|
936
|
+
children: t5
|
|
937
|
+
});
|
|
938
|
+
$[9] = finalManager;
|
|
939
|
+
$[10] = t5;
|
|
940
|
+
$[11] = t6;
|
|
941
|
+
} else {
|
|
942
|
+
t6 = $[11];
|
|
943
|
+
}
|
|
944
|
+
return t6;
|
|
945
|
+
}
|
|
946
|
+
function _temp(t0) {
|
|
947
|
+
const {
|
|
948
|
+
id
|
|
949
|
+
} = t0;
|
|
950
|
+
return id;
|
|
951
|
+
}
|
|
952
|
+
|
|
850
953
|
const GoogleApiClientContext = /*#__PURE__*/createContext(null);
|
|
851
954
|
function useGoogleApiClient() {
|
|
852
955
|
return useContext(GoogleApiClientContext);
|
|
@@ -1651,4 +1754,4 @@ function TrackingProvider(t0) {
|
|
|
1651
1754
|
return t3;
|
|
1652
1755
|
}
|
|
1653
1756
|
|
|
1654
|
-
export { ACTIONS_NAMESPACE, APP_NAMESPACE, BUTTONS_NAMESPACE, ComponentsContext, ComponentsProvider, DISPLAYS_NAMESPACE, DefinitionProvider, FIELDS_NAMESPACE, FILTERS_NAMESPACE, FORMS_NAMESPACE, FieldsContext, FieldsProvider, FontsContext, FontsProvider, FormProvider, 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,
|
|
1757
|
+
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 };
|
package/dist/hooks.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Dayjs } from 'dayjs';
|
|
2
|
-
import {
|
|
2
|
+
import { ReactNode, ElementType, SubmitEvent, RefObject } from 'react';
|
|
3
|
+
import { MessageDescriptor } from 'react-intl';
|
|
3
4
|
|
|
4
5
|
interface UseAnimationFrameOptions {
|
|
5
6
|
disabled?: boolean;
|
|
@@ -20,6 +21,40 @@ declare function useFormattedTime({ format, showNow, timeGap, }?: UseFormattedTi
|
|
|
20
21
|
|
|
21
22
|
declare const useDocumentEvent: (event: string, callback: (...args: unknown[]) => void, enabled?: boolean) => void;
|
|
22
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Core UI Types
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Internationalization message definition
|
|
30
|
+
*/
|
|
31
|
+
type Message = MessageDescriptor;
|
|
32
|
+
/**
|
|
33
|
+
* Label can be either a message object or any React node
|
|
34
|
+
*/
|
|
35
|
+
type Label = Message | ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* Form control size
|
|
38
|
+
*/
|
|
39
|
+
type ControlSize = 'lg' | 'sm' | null;
|
|
40
|
+
/**
|
|
41
|
+
* Generic definition
|
|
42
|
+
*/
|
|
43
|
+
interface Definition {
|
|
44
|
+
id: string;
|
|
45
|
+
component?: string | ElementType;
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
interface RouteDefinition {
|
|
49
|
+
path?: string;
|
|
50
|
+
route?: string;
|
|
51
|
+
component: string | ElementType;
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
}
|
|
54
|
+
interface PageDefinition {
|
|
55
|
+
component: string | ElementType;
|
|
56
|
+
}
|
|
57
|
+
|
|
23
58
|
/**
|
|
24
59
|
* Form Types
|
|
25
60
|
* TypeScript interfaces for form-related components
|
|
@@ -31,15 +66,23 @@ declare const useDocumentEvent: (event: string, callback: (...args: unknown[]) =
|
|
|
31
66
|
interface Field$1 {
|
|
32
67
|
name?: string;
|
|
33
68
|
type?: string;
|
|
34
|
-
|
|
35
|
-
|
|
69
|
+
label?: Label;
|
|
70
|
+
component?: string;
|
|
71
|
+
size?: ControlSize;
|
|
72
|
+
[key: string]: unknown;
|
|
36
73
|
}
|
|
37
74
|
/**
|
|
38
75
|
* Form definition
|
|
39
76
|
*/
|
|
40
77
|
interface Form {
|
|
41
|
-
title
|
|
78
|
+
title?: ReactNode;
|
|
42
79
|
fields?: Field$1[];
|
|
80
|
+
method?: string | null;
|
|
81
|
+
action?: string | null;
|
|
82
|
+
submitButtonLabel?: Label | null;
|
|
83
|
+
[key: string]: unknown;
|
|
84
|
+
}
|
|
85
|
+
interface FormDefinition extends Form, Definition {
|
|
43
86
|
}
|
|
44
87
|
|
|
45
88
|
/**
|
|
@@ -97,15 +140,33 @@ interface ResourceIndex {
|
|
|
97
140
|
fields?: Field$1[];
|
|
98
141
|
[key: string]: unknown;
|
|
99
142
|
}
|
|
143
|
+
interface ResourcePages {
|
|
144
|
+
index?: PageDefinition;
|
|
145
|
+
show?: PageDefinition;
|
|
146
|
+
create?: PageDefinition;
|
|
147
|
+
edit?: PageDefinition;
|
|
148
|
+
delete?: PageDefinition;
|
|
149
|
+
duplicate?: PageDefinition;
|
|
150
|
+
[key: string]: PageDefinition | undefined;
|
|
151
|
+
}
|
|
152
|
+
interface ResourceForms {
|
|
153
|
+
default: FormDefinition | null;
|
|
154
|
+
create: FormDefinition | null;
|
|
155
|
+
edit: FormDefinition | null;
|
|
156
|
+
delete: FormDefinition | null;
|
|
157
|
+
modal: FormDefinition | null;
|
|
158
|
+
[key: string]: FormDefinition | null;
|
|
159
|
+
}
|
|
100
160
|
interface Resource {
|
|
101
161
|
id: string;
|
|
102
162
|
name: string;
|
|
103
163
|
intl?: ResourceIntl;
|
|
104
164
|
fields?: Field$1[];
|
|
105
165
|
index?: ResourceIndex;
|
|
106
|
-
forms?:
|
|
107
|
-
shows_in_navbar?: boolean;
|
|
166
|
+
forms?: ResourceForms;
|
|
108
167
|
settings?: Record<string, unknown>;
|
|
168
|
+
extraRoutes?: RouteDefinition[];
|
|
169
|
+
pages?: ResourcePages;
|
|
109
170
|
}
|
|
110
171
|
/**
|
|
111
172
|
* Filter definition
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ElementType, ReactNode, MouseEvent } from 'react';
|
|
2
2
|
import EventEmitter from 'wolfy87-eventemitter';
|
|
3
|
-
import { Tracking as Tracking$1 } from '@folklore/tracking';
|
|
4
3
|
import { MessageDescriptor } from 'react-intl';
|
|
4
|
+
import { Tracking as Tracking$1 } from '@folklore/tracking';
|
|
5
5
|
|
|
6
6
|
declare class ComponentsManager {
|
|
7
7
|
components: Record<string, ElementType>;
|
|
@@ -10,7 +10,7 @@ declare class ComponentsManager {
|
|
|
10
10
|
addComponents(components: Record<string, ElementType>, namespace?: string | null): this;
|
|
11
11
|
merge(manager: ComponentsManager, namespace?: string | null): this;
|
|
12
12
|
addNamespace(namespace: string | null): this;
|
|
13
|
-
getComponent(name: string, namespace?: string | null): ElementType | null;
|
|
13
|
+
getComponent(name: string | ElementType, namespace?: string | null): ElementType | null;
|
|
14
14
|
getComponents(namespace?: string | null): Record<string, ElementType> | null;
|
|
15
15
|
hasComponent(name: string, namespace?: string | null): boolean;
|
|
16
16
|
}
|
|
@@ -20,14 +20,14 @@ interface Definition$1 {
|
|
|
20
20
|
component?: unknown;
|
|
21
21
|
[key: string]: unknown;
|
|
22
22
|
}
|
|
23
|
-
declare class DefinitionsManager {
|
|
24
|
-
definitions:
|
|
25
|
-
constructor(definitions?:
|
|
26
|
-
addDefinition(definition:
|
|
27
|
-
addDefinitions(definitions:
|
|
28
|
-
merge(manager: DefinitionsManager): this;
|
|
29
|
-
getDefinition(id: string | null):
|
|
30
|
-
getDefinitions():
|
|
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
31
|
hasDefinition(id: string): boolean;
|
|
32
32
|
getComponent(id: string): unknown;
|
|
33
33
|
getComponents(): Record<string, unknown>;
|
|
@@ -45,140 +45,6 @@ declare class EventsManager extends EventEmitter {
|
|
|
45
45
|
removeEventListener(event: string): void;
|
|
46
46
|
}
|
|
47
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
|
-
* User definition
|
|
176
|
-
*/
|
|
177
|
-
interface User {
|
|
178
|
-
id?: number | string;
|
|
179
|
-
[key: string]: unknown;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
48
|
/**
|
|
183
49
|
* Core UI Types
|
|
184
50
|
*/
|
|
@@ -186,10 +52,7 @@ interface User {
|
|
|
186
52
|
/**
|
|
187
53
|
* Internationalization message definition
|
|
188
54
|
*/
|
|
189
|
-
|
|
190
|
-
id: string;
|
|
191
|
-
defaultMessage?: string;
|
|
192
|
-
}
|
|
55
|
+
type Message = MessageDescriptor;
|
|
193
56
|
/**
|
|
194
57
|
* Label can be either a message object or any React node
|
|
195
58
|
*/
|
|
@@ -231,10 +94,14 @@ interface Button {
|
|
|
231
94
|
* Button theme variants (Bootstrap 5)
|
|
232
95
|
*/
|
|
233
96
|
type ButtonTheme = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'light' | 'dark' | null;
|
|
97
|
+
/**
|
|
98
|
+
* Breakpoints size variants
|
|
99
|
+
*/
|
|
100
|
+
type BreakpointsSize = 'xxl' | 'xl' | 'lg' | 'md' | 'sm' | null;
|
|
234
101
|
/**
|
|
235
102
|
* Button size variants
|
|
236
103
|
*/
|
|
237
|
-
type ButtonSize = 'lg' | '
|
|
104
|
+
type ButtonSize = 'lg' | 'sm' | null;
|
|
238
105
|
/**
|
|
239
106
|
* Button type attribute
|
|
240
107
|
*/
|
|
@@ -247,6 +114,10 @@ type DropdownAlign = 'start' | 'end';
|
|
|
247
114
|
* Form control size
|
|
248
115
|
*/
|
|
249
116
|
type ControlSize = 'lg' | 'sm' | null;
|
|
117
|
+
/**
|
|
118
|
+
* Dialog size
|
|
119
|
+
*/
|
|
120
|
+
type DialogSize = 'xl' | 'lg' | 'sm' | null;
|
|
250
121
|
/**
|
|
251
122
|
* Form status states
|
|
252
123
|
*/
|
|
@@ -277,7 +148,7 @@ interface Breadcrumb {
|
|
|
277
148
|
/**
|
|
278
149
|
* Font definition
|
|
279
150
|
*/
|
|
280
|
-
interface Font {
|
|
151
|
+
interface Font$1 {
|
|
281
152
|
name: string;
|
|
282
153
|
}
|
|
283
154
|
/**
|
|
@@ -297,6 +168,23 @@ interface Item {
|
|
|
297
168
|
id: string;
|
|
298
169
|
[key: string]: unknown;
|
|
299
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Generic definition
|
|
173
|
+
*/
|
|
174
|
+
interface Definition {
|
|
175
|
+
id: string;
|
|
176
|
+
component?: string | ElementType;
|
|
177
|
+
[key: string]: unknown;
|
|
178
|
+
}
|
|
179
|
+
interface RouteDefinition {
|
|
180
|
+
path?: string;
|
|
181
|
+
route?: string;
|
|
182
|
+
component: string | ElementType;
|
|
183
|
+
[key: string]: unknown;
|
|
184
|
+
}
|
|
185
|
+
interface PageDefinition {
|
|
186
|
+
component: string | ElementType;
|
|
187
|
+
}
|
|
300
188
|
|
|
301
189
|
/**
|
|
302
190
|
* Form Types
|
|
@@ -320,18 +208,162 @@ type SelectOption = string | number | {
|
|
|
320
208
|
/**
|
|
321
209
|
* Field definition
|
|
322
210
|
*/
|
|
323
|
-
interface Field {
|
|
211
|
+
interface Field$2 {
|
|
324
212
|
name?: string;
|
|
325
213
|
type?: string;
|
|
326
|
-
|
|
327
|
-
|
|
214
|
+
label?: Label;
|
|
215
|
+
component?: string;
|
|
216
|
+
size?: ControlSize;
|
|
217
|
+
[key: string]: unknown;
|
|
218
|
+
}
|
|
219
|
+
interface FieldDefinition extends Omit<Field$2, 'component'>, Definition {
|
|
328
220
|
}
|
|
329
221
|
/**
|
|
330
222
|
* Form definition
|
|
331
223
|
*/
|
|
332
224
|
interface Form {
|
|
333
|
-
title
|
|
225
|
+
title?: ReactNode;
|
|
226
|
+
fields?: Field$2[];
|
|
227
|
+
method?: string | null;
|
|
228
|
+
action?: string | null;
|
|
229
|
+
submitButtonLabel?: Label | null;
|
|
230
|
+
[key: string]: unknown;
|
|
231
|
+
}
|
|
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;
|
|
334
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;
|
|
335
367
|
}
|
|
336
368
|
|
|
337
369
|
type MediaType = 'audio' | 'image' | 'video' | 'document' | 'font';
|
|
@@ -383,7 +415,7 @@ interface Column extends Record<string, unknown> {
|
|
|
383
415
|
path?: string;
|
|
384
416
|
valueKey?: string;
|
|
385
417
|
component?: string | ElementType | null;
|
|
386
|
-
field?: Field | string | null;
|
|
418
|
+
field?: Field$2 | string | null;
|
|
387
419
|
actions?: ActionDefinition[] | null;
|
|
388
420
|
}
|
|
389
421
|
interface Action {
|
|
@@ -421,18 +453,36 @@ interface ResourceIndex {
|
|
|
421
453
|
filters?: Filter[];
|
|
422
454
|
columns?: TableColumn[];
|
|
423
455
|
actions?: ActionDefinition[];
|
|
424
|
-
fields?: Field[];
|
|
456
|
+
fields?: Field$2[];
|
|
425
457
|
[key: string]: unknown;
|
|
426
458
|
}
|
|
459
|
+
interface ResourcePages {
|
|
460
|
+
index?: PageDefinition;
|
|
461
|
+
show?: PageDefinition;
|
|
462
|
+
create?: PageDefinition;
|
|
463
|
+
edit?: PageDefinition;
|
|
464
|
+
delete?: PageDefinition;
|
|
465
|
+
duplicate?: PageDefinition;
|
|
466
|
+
[key: string]: PageDefinition | undefined;
|
|
467
|
+
}
|
|
468
|
+
interface ResourceForms {
|
|
469
|
+
default: FormDefinition | null;
|
|
470
|
+
create: FormDefinition | null;
|
|
471
|
+
edit: FormDefinition | null;
|
|
472
|
+
delete: FormDefinition | null;
|
|
473
|
+
modal: FormDefinition | null;
|
|
474
|
+
[key: string]: FormDefinition | null;
|
|
475
|
+
}
|
|
427
476
|
interface Resource {
|
|
428
477
|
id: string;
|
|
429
478
|
name: string;
|
|
430
479
|
intl?: ResourceIntl;
|
|
431
|
-
fields?: Field[];
|
|
480
|
+
fields?: Field$2[];
|
|
432
481
|
index?: ResourceIndex;
|
|
433
|
-
forms?:
|
|
434
|
-
shows_in_navbar?: boolean;
|
|
482
|
+
forms?: ResourceForms;
|
|
435
483
|
settings?: Record<string, unknown>;
|
|
484
|
+
extraRoutes?: RouteDefinition[];
|
|
485
|
+
pages?: ResourcePages;
|
|
436
486
|
}
|
|
437
487
|
interface ResourceItem extends Item {
|
|
438
488
|
type?: string;
|
|
@@ -482,25 +532,18 @@ interface uppy {
|
|
|
482
532
|
* Panneau route configuration
|
|
483
533
|
*/
|
|
484
534
|
interface Routes {
|
|
485
|
-
'resources.index': string;
|
|
486
|
-
'resources.create': string;
|
|
487
|
-
'resources.store': string;
|
|
488
|
-
'resources.show': string;
|
|
489
|
-
'resources.edit': string;
|
|
490
|
-
'resources.update': string;
|
|
491
|
-
'resources.delete': string;
|
|
492
|
-
'resources.destroy': string;
|
|
493
|
-
'resources.duplicate': string;
|
|
494
|
-
'resources.clone': string;
|
|
495
|
-
'resources.restore': string;
|
|
496
|
-
[key: string]: string;
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Page definition
|
|
500
|
-
*/
|
|
501
|
-
interface Page {
|
|
502
|
-
component: string;
|
|
503
|
-
[key: string]: unknown;
|
|
535
|
+
'resources.index': RouteDefinition | string;
|
|
536
|
+
'resources.create': RouteDefinition | string;
|
|
537
|
+
'resources.store': RouteDefinition | string;
|
|
538
|
+
'resources.show': RouteDefinition | string;
|
|
539
|
+
'resources.edit': RouteDefinition | string;
|
|
540
|
+
'resources.update': RouteDefinition | string;
|
|
541
|
+
'resources.delete': RouteDefinition | string;
|
|
542
|
+
'resources.destroy': RouteDefinition | string;
|
|
543
|
+
'resources.duplicate': RouteDefinition | string;
|
|
544
|
+
'resources.clone': RouteDefinition | string;
|
|
545
|
+
'resources.restore': RouteDefinition | string;
|
|
546
|
+
[key: string]: RouteDefinition | string;
|
|
504
547
|
}
|
|
505
548
|
interface PanneauTheme {
|
|
506
549
|
colorScheme?: string | null;
|
|
@@ -521,24 +564,26 @@ interface PanneauIntl {
|
|
|
521
564
|
messages?: Record<string, string>;
|
|
522
565
|
values?: PanneauIntlValues;
|
|
523
566
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
[key: string]: unknown;
|
|
567
|
+
interface PanneauPages extends ResourcePages {
|
|
568
|
+
home?: PageDefinition;
|
|
569
|
+
login?: PageDefinition;
|
|
570
|
+
account?: PageDefinition;
|
|
571
|
+
error?: PageDefinition;
|
|
530
572
|
}
|
|
531
573
|
/**
|
|
532
574
|
* Panneau definition (main configuration)
|
|
533
575
|
*/
|
|
534
|
-
interface PanneauDefinition
|
|
576
|
+
interface PanneauDefinition {
|
|
577
|
+
name?: string;
|
|
535
578
|
resources?: Resource[];
|
|
536
579
|
routes?: Routes;
|
|
537
|
-
pages?:
|
|
580
|
+
pages?: PanneauPages;
|
|
538
581
|
intl?: PanneauIntl;
|
|
539
582
|
theme?: PanneauTheme;
|
|
540
583
|
components?: PanneauComponents;
|
|
541
584
|
settings?: Record<string, unknown>;
|
|
585
|
+
forms?: FormDefinition[];
|
|
586
|
+
fields?: FieldDefinition[];
|
|
542
587
|
}
|
|
543
588
|
/**
|
|
544
589
|
* Tracking variables
|
|
@@ -546,4 +591,4 @@ interface PanneauDefinition extends Definition {
|
|
|
546
591
|
type TrackingVariables = Record<string, unknown>;
|
|
547
592
|
|
|
548
593
|
export { ComponentsManager, DefinitionsManager, EventsManager, FieldsManager, FontsParser, FormsManager, MediasParser, Tracking };
|
|
549
|
-
export type { Action, ActionDefinition, ActionValue, AudioMedia, Breadcrumb, Button, ButtonElement, ButtonSize, ButtonTheme, ButtonType, Column, ControlSize, Definition, DropdownAlign, Feedback, Field, FieldOption, Filter, Font, Form, FormError, FormStatus, ImageMedia, Item, Label, Media, MediaFile, MediaType, MenuItem, Message, Modal,
|
|
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 };
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { flattenComponents, getComponentFromName } from '@panneau/core/utils';
|
|
2
|
+
import { isObject } from 'lodash';
|
|
2
3
|
import isArray from 'lodash-es/isArray';
|
|
3
4
|
import uniqBy from 'lodash-es/uniqBy';
|
|
4
5
|
import EventEmitter from 'wolfy87-eventemitter';
|
|
5
|
-
import isObject from 'lodash-es/isObject';
|
|
6
|
+
import isObject$1 from 'lodash-es/isObject';
|
|
6
7
|
import uniq from 'lodash-es/uniq';
|
|
7
8
|
import { Tracking as Tracking$1 } from '@folklore/tracking';
|
|
8
9
|
|
|
@@ -40,6 +41,9 @@ class ComponentsManager {
|
|
|
40
41
|
return this;
|
|
41
42
|
}
|
|
42
43
|
getComponent(name, namespace = null) {
|
|
44
|
+
if (isObject(name)) {
|
|
45
|
+
return name;
|
|
46
|
+
}
|
|
43
47
|
const components = this.getComponents(namespace);
|
|
44
48
|
return getComponentFromName(name, components);
|
|
45
49
|
}
|
|
@@ -240,9 +244,9 @@ class FontsParser {
|
|
|
240
244
|
const value = data[key];
|
|
241
245
|
let font = null;
|
|
242
246
|
let subFonts = null;
|
|
243
|
-
if (patternMatch && isObject(value) && FontsParser.valueIsFont(value)) {
|
|
247
|
+
if (patternMatch && isObject$1(value) && FontsParser.valueIsFont(value)) {
|
|
244
248
|
font = value;
|
|
245
|
-
} else if (isObject(value) || isArray(value)) {
|
|
249
|
+
} else if (isObject$1(value) || isArray(value)) {
|
|
246
250
|
subFonts = FontsParser.extractFontsWithPaths(value, patterns, path);
|
|
247
251
|
}
|
|
248
252
|
return subFonts !== null || font !== null ? [...currentFonts, ...(subFonts || []), ...(font !== null ? [font] : [])] : currentFonts;
|
|
@@ -250,7 +254,7 @@ class FontsParser {
|
|
|
250
254
|
}
|
|
251
255
|
}
|
|
252
256
|
|
|
253
|
-
class FormsManager extends
|
|
257
|
+
class FormsManager extends DefinitionsManager {}
|
|
254
258
|
|
|
255
259
|
class MediasParser {
|
|
256
260
|
constructor({
|
|
@@ -401,9 +405,9 @@ class MediasParser {
|
|
|
401
405
|
const value = data[key];
|
|
402
406
|
let newValue;
|
|
403
407
|
if (patternMatch) {
|
|
404
|
-
newValue = isObject(value) ? value : medias[value] || null;
|
|
408
|
+
newValue = isObject$1(value) ? value : medias[value] || null;
|
|
405
409
|
} else {
|
|
406
|
-
newValue = isObject(value) || isArray(value) ? MediasParser.replacePathsWithMedias(value, medias, patterns, path) : value;
|
|
410
|
+
newValue = isObject$1(value) || isArray(value) ? MediasParser.replacePathsWithMedias(value, medias, patterns, path) : value;
|
|
407
411
|
}
|
|
408
412
|
return dataIsArray ? [...newData, newValue] : {
|
|
409
413
|
...newData,
|
|
@@ -429,11 +433,11 @@ class MediasParser {
|
|
|
429
433
|
let newValue;
|
|
430
434
|
let media = null;
|
|
431
435
|
let subMedias = null;
|
|
432
|
-
if (patternMatch && isObject(value)) {
|
|
436
|
+
if (patternMatch && isObject$1(value)) {
|
|
433
437
|
const mediaPath = MediasParser.getMediaPath(value);
|
|
434
438
|
newValue = mediaPath !== null ? mediaPath : value;
|
|
435
439
|
media = mediaPath !== null ? value : null;
|
|
436
|
-
} else if (isObject(value) || isArray(value)) {
|
|
440
|
+
} else if (isObject$1(value) || isArray(value)) {
|
|
437
441
|
const subReturn = MediasParser.replaceMediasWithPaths(value, patterns, medias, path);
|
|
438
442
|
newValue = subReturn.data;
|
|
439
443
|
subMedias = subReturn.medias;
|
package/dist/utils.d.ts
CHANGED
|
@@ -38,14 +38,15 @@ declare function formatDuration(timeInSeconds: number | string): string;
|
|
|
38
38
|
/**
|
|
39
39
|
* Internationalization message definition
|
|
40
40
|
*/
|
|
41
|
-
|
|
42
|
-
id: string;
|
|
43
|
-
defaultMessage?: string;
|
|
44
|
-
}
|
|
41
|
+
type Message = MessageDescriptor;
|
|
45
42
|
/**
|
|
46
43
|
* Label can be either a message object or any React node
|
|
47
44
|
*/
|
|
48
45
|
type Label = Message | ReactNode;
|
|
46
|
+
/**
|
|
47
|
+
* Form control size
|
|
48
|
+
*/
|
|
49
|
+
type ControlSize = 'lg' | 'sm' | null;
|
|
49
50
|
/**
|
|
50
51
|
* Generic item (base interface for data items)
|
|
51
52
|
*/
|
|
@@ -53,6 +54,23 @@ interface Item {
|
|
|
53
54
|
id: string;
|
|
54
55
|
[key: string]: unknown;
|
|
55
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Generic definition
|
|
59
|
+
*/
|
|
60
|
+
interface Definition {
|
|
61
|
+
id: string;
|
|
62
|
+
component?: string | ElementType;
|
|
63
|
+
[key: string]: unknown;
|
|
64
|
+
}
|
|
65
|
+
interface RouteDefinition {
|
|
66
|
+
path?: string;
|
|
67
|
+
route?: string;
|
|
68
|
+
component: string | ElementType;
|
|
69
|
+
[key: string]: unknown;
|
|
70
|
+
}
|
|
71
|
+
interface PageDefinition {
|
|
72
|
+
component: string | ElementType;
|
|
73
|
+
}
|
|
56
74
|
|
|
57
75
|
/**
|
|
58
76
|
* Form Types
|
|
@@ -72,15 +90,23 @@ type SelectOption = string | number | {
|
|
|
72
90
|
interface Field {
|
|
73
91
|
name?: string;
|
|
74
92
|
type?: string;
|
|
75
|
-
|
|
76
|
-
|
|
93
|
+
label?: Label;
|
|
94
|
+
component?: string;
|
|
95
|
+
size?: ControlSize;
|
|
96
|
+
[key: string]: unknown;
|
|
77
97
|
}
|
|
78
98
|
/**
|
|
79
99
|
* Form definition
|
|
80
100
|
*/
|
|
81
101
|
interface Form {
|
|
82
|
-
title
|
|
102
|
+
title?: ReactNode;
|
|
83
103
|
fields?: Field[];
|
|
104
|
+
method?: string | null;
|
|
105
|
+
action?: string | null;
|
|
106
|
+
submitButtonLabel?: Label | null;
|
|
107
|
+
[key: string]: unknown;
|
|
108
|
+
}
|
|
109
|
+
interface FormDefinition extends Form, Definition {
|
|
84
110
|
}
|
|
85
111
|
|
|
86
112
|
/**
|
|
@@ -138,15 +164,33 @@ interface ResourceIndex {
|
|
|
138
164
|
fields?: Field[];
|
|
139
165
|
[key: string]: unknown;
|
|
140
166
|
}
|
|
167
|
+
interface ResourcePages {
|
|
168
|
+
index?: PageDefinition;
|
|
169
|
+
show?: PageDefinition;
|
|
170
|
+
create?: PageDefinition;
|
|
171
|
+
edit?: PageDefinition;
|
|
172
|
+
delete?: PageDefinition;
|
|
173
|
+
duplicate?: PageDefinition;
|
|
174
|
+
[key: string]: PageDefinition | undefined;
|
|
175
|
+
}
|
|
176
|
+
interface ResourceForms {
|
|
177
|
+
default: FormDefinition | null;
|
|
178
|
+
create: FormDefinition | null;
|
|
179
|
+
edit: FormDefinition | null;
|
|
180
|
+
delete: FormDefinition | null;
|
|
181
|
+
modal: FormDefinition | null;
|
|
182
|
+
[key: string]: FormDefinition | null;
|
|
183
|
+
}
|
|
141
184
|
interface Resource {
|
|
142
185
|
id: string;
|
|
143
186
|
name: string;
|
|
144
187
|
intl?: ResourceIntl;
|
|
145
188
|
fields?: Field[];
|
|
146
189
|
index?: ResourceIndex;
|
|
147
|
-
forms?:
|
|
148
|
-
shows_in_navbar?: boolean;
|
|
190
|
+
forms?: ResourceForms;
|
|
149
191
|
settings?: Record<string, unknown>;
|
|
192
|
+
extraRoutes?: RouteDefinition[];
|
|
193
|
+
pages?: ResourcePages;
|
|
150
194
|
}
|
|
151
195
|
/**
|
|
152
196
|
* Filter definition
|
|
@@ -157,19 +201,6 @@ interface Filter {
|
|
|
157
201
|
[key: string]: unknown;
|
|
158
202
|
}
|
|
159
203
|
|
|
160
|
-
/**
|
|
161
|
-
* Panneau Definition Types
|
|
162
|
-
* TypeScript interfaces for main Panneau configuration and definitions
|
|
163
|
-
*/
|
|
164
|
-
|
|
165
|
-
/**
|
|
166
|
-
* Generic definition
|
|
167
|
-
*/
|
|
168
|
-
interface Definition {
|
|
169
|
-
name?: string;
|
|
170
|
-
[key: string]: unknown;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
204
|
declare function getColumnsWithFields(resource: Resource, columns: TableColumn[] | null): Column[];
|
|
174
205
|
|
|
175
206
|
interface ComponentResult {
|
|
@@ -181,7 +212,7 @@ declare function getComponent(component: string | {
|
|
|
181
212
|
[key: string]: unknown;
|
|
182
213
|
}): ComponentResult;
|
|
183
214
|
|
|
184
|
-
declare function getComponentFromName(name?: string | ElementType | null, components?: Record<string, ElementType> | null, defaultComponent?: ElementType | null): ElementType | null;
|
|
215
|
+
declare function getComponentFromName(name?: string | ElementType | null, components?: Record<string, ElementType> | null, defaultComponent?: ElementType | string | null): ElementType | null;
|
|
185
216
|
|
|
186
217
|
declare function getDefinitionFromId<T extends Definition = Definition>(id?: string | null, items?: T[] | null, defaultObject?: T | null): T | null;
|
|
187
218
|
|
package/dist/utils.js
CHANGED
|
@@ -229,13 +229,14 @@ function getColumnsWithFields(resource, columns) {
|
|
|
229
229
|
|
|
230
230
|
function getComponentFromName(name = null, components = {}, defaultComponent = null) {
|
|
231
231
|
if (components === null || name === null) {
|
|
232
|
-
return defaultComponent;
|
|
232
|
+
return !isString(defaultComponent) ? defaultComponent : null;
|
|
233
233
|
}
|
|
234
234
|
if (isObject(name) || isFunction(name)) {
|
|
235
235
|
return name;
|
|
236
236
|
}
|
|
237
237
|
const pascalName = pascalCase(name);
|
|
238
|
-
const
|
|
238
|
+
const pascalDefaultName = isString(defaultComponent) ? pascalCase(defaultComponent) : null;
|
|
239
|
+
const component = components[pascalName] || components[name] || (isString(pascalDefaultName) ? components[pascalDefaultName] : null) || (isString(defaultComponent) ? components[defaultComponent] : null) || defaultComponent;
|
|
239
240
|
if (!component) {
|
|
240
241
|
console.warn('Could not find component from name', name, pascalName, components);
|
|
241
242
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@panneau/core",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.75",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"publishConfig": {
|
|
97
97
|
"access": "public"
|
|
98
98
|
},
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "2eb608f88ad5041b3fa9c472e97a68680e281766"
|
|
100
100
|
}
|