@panneau/core 4.1.0 → 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.
@@ -162,6 +162,11 @@ interface ResourceIndex {
162
162
  fields?: Field[];
163
163
  [key: string]: unknown;
164
164
  }
165
+ /**
166
+ * Overrides of the built-in resource pages, ex: `{ show: { component: 'my-page' } }`.
167
+ * Used on a resource (`resource.pages`) and on the panneau definition (`definition.pages`),
168
+ * the resource taking precedence.
169
+ */
165
170
  interface ResourcePages {
166
171
  index?: PageDefinition;
167
172
  show?: PageDefinition;
@@ -169,6 +174,20 @@ interface ResourcePages {
169
174
  edit?: PageDefinition;
170
175
  delete?: PageDefinition;
171
176
  duplicate?: PageDefinition;
177
+ /** @deprecated Legacy resource keys, use `index`, `show`, `create`, etc. */
178
+ resourceIndexPage?: PageDefinition;
179
+ resourceShowPage?: PageDefinition;
180
+ resourceCreatePage?: PageDefinition;
181
+ resourceEditPage?: PageDefinition;
182
+ resourceDeletePage?: PageDefinition;
183
+ resourceDuplicatePage?: PageDefinition;
184
+ /** @deprecated Legacy panneau keys, use `index`, `show`, `create`, etc. */
185
+ indexPage?: PageDefinition;
186
+ showPage?: PageDefinition;
187
+ createPage?: PageDefinition;
188
+ editPage?: PageDefinition;
189
+ deletePage?: PageDefinition;
190
+ duplicatePage?: PageDefinition;
172
191
  [key: string]: PageDefinition | undefined;
173
192
  }
174
193
  /**
@@ -183,6 +202,7 @@ interface ResourceForms {
183
202
  create?: ResourceForm | null;
184
203
  edit?: ResourceForm | null;
185
204
  delete?: ResourceForm | null;
205
+ duplicate?: ResourceForm | null;
186
206
  modal?: ResourceForm | null;
187
207
  [key: string]: ResourceForm | null | undefined;
188
208
  }
@@ -258,6 +278,7 @@ interface PanneauIntl {
258
278
  locale?: string;
259
279
  locales?: string[];
260
280
  messages?: Record<string, string>;
281
+ /** @deprecated Not used: set the values of each resource in `resources[].intl.values` */
261
282
  values?: PanneauIntlValues;
262
283
  }
263
284
  interface PanneauPages extends ResourcePages {
@@ -276,9 +297,14 @@ interface PanneauMenus {
276
297
  guest?: PanneauMenuItem[] | null;
277
298
  [key: string]: PanneauMenuItem[] | null | undefined;
278
299
  }
300
+ /**
301
+ * Links shown on the login page: `true` for the default url, or the url of the page
302
+ */
279
303
  interface PanneauAuth {
280
- forgotPassword?: boolean;
281
- register?: boolean;
304
+ /** "Forgot your password?" link (default url: /forgot-password) */
305
+ forgotPassword?: boolean | string;
306
+ /** "Create account" link (default url: /register) */
307
+ register?: boolean | string;
282
308
  [key: string]: unknown;
283
309
  }
284
310
  /**
@@ -291,6 +317,7 @@ interface PanneauDefinition {
291
317
  pages?: PanneauPages;
292
318
  intl?: PanneauIntl;
293
319
  theme?: PanneauTheme;
320
+ /** @deprecated Not used: give the custom components to the `components` prop of the container */
294
321
  components?: PanneauComponents;
295
322
  settings?: Record<string, unknown>;
296
323
  forms?: FormDefinition[];
@@ -604,7 +631,9 @@ declare function usePanneauColorScheme(): {
604
631
  text: 'light' | 'dark' | null;
605
632
  sidebarPosition?: string | null;
606
633
  };
634
+ /** @deprecated The `components` key of the definition is not supported */
607
635
  declare function usePanneauComponents(): Record<string, unknown>;
636
+ /** @deprecated The `components` key of the definition is not supported */
608
637
  declare function usePanneauComponent(namespace: string | null, name: string): string | null;
609
638
  declare function usePanneauAuth(): PanneauAuth;
610
639
  declare function usePanneauSettings(): Record<string, unknown>;
package/dist/contexts.js CHANGED
@@ -1557,6 +1557,8 @@ function usePanneauColorScheme() {
1557
1557
  return t3;
1558
1558
  }
1559
1559
  const DEFAULT_COMPONENTS = {};
1560
+
1561
+ /** @deprecated The `components` key of the definition is not supported */
1560
1562
  function usePanneauComponents() {
1561
1563
  const {
1562
1564
  components: t0
@@ -1564,6 +1566,8 @@ function usePanneauComponents() {
1564
1566
  const components = t0 === undefined ? DEFAULT_COMPONENTS : t0;
1565
1567
  return components;
1566
1568
  }
1569
+
1570
+ /** @deprecated The `components` key of the definition is not supported */
1567
1571
  function usePanneauComponent(namespace, name) {
1568
1572
  const $ = c(2);
1569
1573
  const {
@@ -1621,24 +1625,38 @@ function usePanneauSettings() {
1621
1625
  return settings;
1622
1626
  }
1623
1627
  function PanneauProvider(t0) {
1624
- const $ = c(3);
1628
+ const $ = c(6);
1625
1629
  const {
1626
1630
  definition,
1627
1631
  children
1628
1632
  } = t0;
1629
1633
  let t1;
1630
- if ($[0] !== children || $[1] !== definition) {
1631
- t1 = /*#__PURE__*/jsx(PanneauContext, {
1634
+ let t2;
1635
+ if ($[0] !== definition) {
1636
+ t1 = () => {
1637
+ };
1638
+ t2 = [definition];
1639
+ $[0] = definition;
1640
+ $[1] = t1;
1641
+ $[2] = t2;
1642
+ } else {
1643
+ t1 = $[1];
1644
+ t2 = $[2];
1645
+ }
1646
+ useEffect(t1, t2);
1647
+ let t3;
1648
+ if ($[3] !== children || $[4] !== definition) {
1649
+ t3 = /*#__PURE__*/jsx(PanneauContext, {
1632
1650
  value: definition,
1633
1651
  children: children
1634
1652
  });
1635
- $[0] = children;
1636
- $[1] = definition;
1637
- $[2] = t1;
1653
+ $[3] = children;
1654
+ $[4] = definition;
1655
+ $[5] = t3;
1638
1656
  } else {
1639
- t1 = $[2];
1657
+ t3 = $[5];
1640
1658
  }
1641
- return t1;
1659
+ return t3;
1642
1660
  }
1643
1661
 
1644
1662
  const ResourceContext = /*#__PURE__*/createContext(null);
package/dist/hooks.d.ts CHANGED
@@ -137,6 +137,11 @@ interface ResourceIndex {
137
137
  fields?: Field$1[];
138
138
  [key: string]: unknown;
139
139
  }
140
+ /**
141
+ * Overrides of the built-in resource pages, ex: `{ show: { component: 'my-page' } }`.
142
+ * Used on a resource (`resource.pages`) and on the panneau definition (`definition.pages`),
143
+ * the resource taking precedence.
144
+ */
140
145
  interface ResourcePages {
141
146
  index?: PageDefinition;
142
147
  show?: PageDefinition;
@@ -144,6 +149,20 @@ interface ResourcePages {
144
149
  edit?: PageDefinition;
145
150
  delete?: PageDefinition;
146
151
  duplicate?: PageDefinition;
152
+ /** @deprecated Legacy resource keys, use `index`, `show`, `create`, etc. */
153
+ resourceIndexPage?: PageDefinition;
154
+ resourceShowPage?: PageDefinition;
155
+ resourceCreatePage?: PageDefinition;
156
+ resourceEditPage?: PageDefinition;
157
+ resourceDeletePage?: PageDefinition;
158
+ resourceDuplicatePage?: PageDefinition;
159
+ /** @deprecated Legacy panneau keys, use `index`, `show`, `create`, etc. */
160
+ indexPage?: PageDefinition;
161
+ showPage?: PageDefinition;
162
+ createPage?: PageDefinition;
163
+ editPage?: PageDefinition;
164
+ deletePage?: PageDefinition;
165
+ duplicatePage?: PageDefinition;
147
166
  [key: string]: PageDefinition | undefined;
148
167
  }
149
168
  /**
@@ -158,6 +177,7 @@ interface ResourceForms {
158
177
  create?: ResourceForm | null;
159
178
  edit?: ResourceForm | null;
160
179
  delete?: ResourceForm | null;
180
+ duplicate?: ResourceForm | null;
161
181
  modal?: ResourceForm | null;
162
182
  [key: string]: ResourceForm | null | undefined;
163
183
  }
package/dist/index.d.ts CHANGED
@@ -192,6 +192,20 @@ type SelectOption = string | number | {
192
192
  value?: unknown;
193
193
  label?: Label | string;
194
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
+ }
195
209
  /**
196
210
  * Field definition
197
211
  */
@@ -311,6 +325,11 @@ interface ResourceIndex {
311
325
  fields?: Field$2[];
312
326
  [key: string]: unknown;
313
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
+ */
314
333
  interface ResourcePages {
315
334
  index?: PageDefinition;
316
335
  show?: PageDefinition;
@@ -318,6 +337,20 @@ interface ResourcePages {
318
337
  edit?: PageDefinition;
319
338
  delete?: PageDefinition;
320
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;
321
354
  [key: string]: PageDefinition | undefined;
322
355
  }
323
356
  /**
@@ -332,6 +365,7 @@ interface ResourceForms {
332
365
  create?: ResourceForm | null;
333
366
  edit?: ResourceForm | null;
334
367
  delete?: ResourceForm | null;
368
+ duplicate?: ResourceForm | null;
335
369
  modal?: ResourceForm | null;
336
370
  [key: string]: ResourceForm | null | undefined;
337
371
  }
@@ -437,6 +471,7 @@ interface PanneauIntl {
437
471
  locale?: string;
438
472
  locales?: string[];
439
473
  messages?: Record<string, string>;
474
+ /** @deprecated Not used: set the values of each resource in `resources[].intl.values` */
440
475
  values?: PanneauIntlValues;
441
476
  }
442
477
  interface PanneauPages extends ResourcePages {
@@ -455,9 +490,14 @@ interface PanneauMenus {
455
490
  guest?: PanneauMenuItem[] | null;
456
491
  [key: string]: PanneauMenuItem[] | null | undefined;
457
492
  }
493
+ /**
494
+ * Links shown on the login page: `true` for the default url, or the url of the page
495
+ */
458
496
  interface PanneauAuth {
459
- forgotPassword?: boolean;
460
- register?: boolean;
497
+ /** "Forgot your password?" link (default url: /forgot-password) */
498
+ forgotPassword?: boolean | string;
499
+ /** "Create account" link (default url: /register) */
500
+ register?: boolean | string;
461
501
  [key: string]: unknown;
462
502
  }
463
503
  /**
@@ -470,6 +510,7 @@ interface PanneauDefinition {
470
510
  pages?: PanneauPages;
471
511
  intl?: PanneauIntl;
472
512
  theme?: PanneauTheme;
513
+ /** @deprecated Not used: give the custom components to the `components` prop of the container */
473
514
  components?: PanneauComponents;
474
515
  settings?: Record<string, unknown>;
475
516
  forms?: FormDefinition[];
@@ -648,4 +689,4 @@ declare class Tracking extends Tracking$1 {
648
689
  }
649
690
 
650
691
  export { ComponentsManager, DefinitionsManager, EventsManager, FieldsManager, FontsParser, FormsManager, MediasParser, Tracking };
651
- 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, 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 };
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 };
package/dist/utils.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { kebabCase as dashCase, pascalCase, snakeCase } from 'change-case';
2
- import { ElementType, ComponentProps, ReactNode, ReactElement, ForwardedRef } from 'react';
2
+ import { ElementType, ComponentProps, ReactNode, MouseEvent, ReactElement, ForwardedRef } from 'react';
3
3
  import { FormattedMessage, MessageDescriptor } from 'react-intl';
4
4
 
5
5
  interface CheckClickableOptions {
@@ -50,6 +50,24 @@ type Label = Message | ReactNode;
50
50
  interface ComponentsMap {
51
51
  [name: string]: ElementType | ComponentsMap;
52
52
  }
53
+ /**
54
+ * Menu item definition
55
+ */
56
+ interface MenuItem {
57
+ id?: number | string;
58
+ label?: Label;
59
+ url?: string;
60
+ href?: string | null;
61
+ external?: boolean;
62
+ active?: boolean;
63
+ type?: string;
64
+ component?: string;
65
+ className?: string | null;
66
+ linkClassName?: string | null;
67
+ onClick?: ((e: MouseEvent) => void) | null;
68
+ items?: MenuItem[] | null;
69
+ dropdown?: MenuItem[] | null;
70
+ }
53
71
  /**
54
72
  * Form control size
55
73
  */
@@ -102,6 +120,8 @@ interface Field {
102
120
  size?: ControlSize;
103
121
  [key: string]: unknown;
104
122
  }
123
+ interface FieldDefinition$1 extends Omit<Field, 'component'>, Definition {
124
+ }
105
125
  /**
106
126
  * Form definition
107
127
  */
@@ -113,6 +133,8 @@ interface Form {
113
133
  submitButtonLabel?: Label | null;
114
134
  [key: string]: unknown;
115
135
  }
136
+ interface FormDefinition extends Form, Definition {
137
+ }
116
138
 
117
139
  /**
118
140
  * Resource Types
@@ -170,6 +192,11 @@ interface ResourceIndex {
170
192
  fields?: Field[];
171
193
  [key: string]: unknown;
172
194
  }
195
+ /**
196
+ * Overrides of the built-in resource pages, ex: `{ show: { component: 'my-page' } }`.
197
+ * Used on a resource (`resource.pages`) and on the panneau definition (`definition.pages`),
198
+ * the resource taking precedence.
199
+ */
173
200
  interface ResourcePages {
174
201
  index?: PageDefinition;
175
202
  show?: PageDefinition;
@@ -177,6 +204,20 @@ interface ResourcePages {
177
204
  edit?: PageDefinition;
178
205
  delete?: PageDefinition;
179
206
  duplicate?: PageDefinition;
207
+ /** @deprecated Legacy resource keys, use `index`, `show`, `create`, etc. */
208
+ resourceIndexPage?: PageDefinition;
209
+ resourceShowPage?: PageDefinition;
210
+ resourceCreatePage?: PageDefinition;
211
+ resourceEditPage?: PageDefinition;
212
+ resourceDeletePage?: PageDefinition;
213
+ resourceDuplicatePage?: PageDefinition;
214
+ /** @deprecated Legacy panneau keys, use `index`, `show`, `create`, etc. */
215
+ indexPage?: PageDefinition;
216
+ showPage?: PageDefinition;
217
+ createPage?: PageDefinition;
218
+ editPage?: PageDefinition;
219
+ deletePage?: PageDefinition;
220
+ duplicatePage?: PageDefinition;
180
221
  [key: string]: PageDefinition | undefined;
181
222
  }
182
223
  /**
@@ -191,6 +232,7 @@ interface ResourceForms {
191
232
  create?: ResourceForm | null;
192
233
  edit?: ResourceForm | null;
193
234
  delete?: ResourceForm | null;
235
+ duplicate?: ResourceForm | null;
194
236
  modal?: ResourceForm | null;
195
237
  [key: string]: ResourceForm | null | undefined;
196
238
  }
@@ -227,6 +269,93 @@ interface Filter {
227
269
  [key: string]: unknown;
228
270
  }
229
271
 
272
+ /**
273
+ * Panneau Definition Types
274
+ * TypeScript interfaces for main Panneau configuration and definitions
275
+ */
276
+
277
+ /**
278
+ * Panneau route configuration
279
+ */
280
+ interface Routes {
281
+ 'resources.index'?: RouteDefinition | string;
282
+ 'resources.create'?: RouteDefinition | string;
283
+ 'resources.store'?: RouteDefinition | string;
284
+ 'resources.show'?: RouteDefinition | string;
285
+ 'resources.edit'?: RouteDefinition | string;
286
+ 'resources.update'?: RouteDefinition | string;
287
+ 'resources.delete'?: RouteDefinition | string;
288
+ 'resources.destroy'?: RouteDefinition | string;
289
+ 'resources.duplicate'?: RouteDefinition | string;
290
+ 'resources.clone'?: RouteDefinition | string;
291
+ 'resources.restore'?: RouteDefinition | string;
292
+ [key: string]: RouteDefinition | string;
293
+ }
294
+ interface PanneauTheme {
295
+ colorScheme?: string | null;
296
+ [key: string]: unknown;
297
+ }
298
+ interface PanneauComponents {
299
+ [key: string]: string | {
300
+ component: string;
301
+ [key: string]: unknown;
302
+ };
303
+ }
304
+ interface PanneauIntlValues {
305
+ [key: string]: string;
306
+ }
307
+ interface PanneauIntl {
308
+ locale?: string;
309
+ locales?: string[];
310
+ messages?: Record<string, string>;
311
+ /** @deprecated Not used: set the values of each resource in `resources[].intl.values` */
312
+ values?: PanneauIntlValues;
313
+ }
314
+ interface PanneauPages extends ResourcePages {
315
+ home?: PageDefinition;
316
+ login?: PageDefinition;
317
+ account?: PageDefinition;
318
+ error?: PageDefinition;
319
+ }
320
+ /**
321
+ * Menu item in a Panneau menu: a menu item definition or a special item id
322
+ * (ex: 'resources', 'account', 'separator')
323
+ */
324
+ type PanneauMenuItem = MenuItem | string;
325
+ interface PanneauMenus {
326
+ main?: PanneauMenuItem[] | null;
327
+ guest?: PanneauMenuItem[] | null;
328
+ [key: string]: PanneauMenuItem[] | null | undefined;
329
+ }
330
+ /**
331
+ * Links shown on the login page: `true` for the default url, or the url of the page
332
+ */
333
+ interface PanneauAuth {
334
+ /** "Forgot your password?" link (default url: /forgot-password) */
335
+ forgotPassword?: boolean | string;
336
+ /** "Create account" link (default url: /register) */
337
+ register?: boolean | string;
338
+ [key: string]: unknown;
339
+ }
340
+ /**
341
+ * Panneau definition (main configuration)
342
+ */
343
+ interface PanneauDefinition {
344
+ name?: string;
345
+ resources?: Resource[];
346
+ routes?: Routes;
347
+ pages?: PanneauPages;
348
+ intl?: PanneauIntl;
349
+ theme?: PanneauTheme;
350
+ /** @deprecated Not used: give the custom components to the `components` prop of the container */
351
+ components?: PanneauComponents;
352
+ settings?: Record<string, unknown>;
353
+ forms?: FormDefinition[];
354
+ fields?: FieldDefinition$1[];
355
+ menus?: PanneauMenus;
356
+ auth?: PanneauAuth;
357
+ }
358
+
230
359
  declare function flattenComponents(components: ComponentsMap | null, prefix?: string | null): Record<string, ElementType> | null;
231
360
 
232
361
  declare function formatDuration(timeInSeconds: number | string): string;
@@ -246,6 +375,12 @@ declare function getComponentFromName(name?: string | ElementType | null, compon
246
375
 
247
376
  declare function getDefinitionFromId<T extends Definition = Definition>(id?: string | null, items?: T[] | null, defaultObject?: T | null): T | null;
248
377
 
378
+ /**
379
+ * Returns a message for each key of the definition that is not supported anymore,
380
+ * with the key to use instead. Without it, these keys would be silently ignored.
381
+ */
382
+ declare function getDefinitionWarnings(definition: PanneauDefinition | null): string[];
383
+
249
384
  interface ComponentWithName {
250
385
  displayName?: string | null;
251
386
  name?: string | null;
@@ -319,4 +454,4 @@ interface FieldWithValidation extends Field {
319
454
  }
320
455
  declare function validateFields(fields: FieldWithValidation[], value: Record<string, unknown> | null): boolean;
321
456
 
322
- export { checkClickable, convertStyleToString, copyToClipboard, createNullableOnChange, createUseEvent, flattenComponents, formatDuration, getColumnsWithFields, getComponent, getComponentFromName, getDefinitionFromId, getDisplayName, getFieldByName, getFieldFromPath, getFileName, getPathValue, getSelectOptions, isMessage, loadPackage, mergeRefs, parseDateOnly, selectItems, setValue as setFieldValue, slug, toggleSelectedItem, unselectItems, validateFields };
457
+ export { checkClickable, convertStyleToString, copyToClipboard, createNullableOnChange, createUseEvent, flattenComponents, formatDuration, getColumnsWithFields, getComponent, getComponentFromName, getDefinitionFromId, getDefinitionWarnings, getDisplayName, getFieldByName, getFieldFromPath, getFileName, getPathValue, getSelectOptions, isMessage, loadPackage, mergeRefs, parseDateOnly, selectItems, setValue as setFieldValue, slug, toggleSelectedItem, unselectItems, validateFields };
package/dist/utils.js CHANGED
@@ -262,6 +262,33 @@ function getDefinitionFromId(id = null, items = [], defaultObject = null) {
262
262
  return items.find(i => i.id === pascalId) || items.find(i => i.id === id) || defaultObject;
263
263
  }
264
264
 
265
+ /**
266
+ * Returns a message for each key of the definition that is not supported anymore,
267
+ * with the key to use instead. Without it, these keys would be silently ignored.
268
+ */
269
+ function getDefinitionWarnings(definition) {
270
+ if (!isObject(definition)) {
271
+ return [];
272
+ }
273
+ const {
274
+ components = null,
275
+ intl = null,
276
+ theme = null,
277
+ resources = []
278
+ } = definition;
279
+ const {
280
+ values = null
281
+ } = intl || {};
282
+ return [...(components !== null ? ['`components` is not supported: give the custom components to the `components` prop of the container.'] : []), ...(values !== null ? ['`intl.values` is not supported: set the values of each resource in `resources[].intl.values`.'] : []), ...Object.keys(theme || {}).filter(key => key !== 'colorScheme').map(key => `\`theme.${key}\` is not supported: only \`theme.colorScheme\` is.`), ...(resources || []).reduce((warnings, resource) => {
283
+ const {
284
+ id,
285
+ components: resourceComponents = null,
286
+ columns = null
287
+ } = resource;
288
+ return [...warnings, ...(resourceComponents !== null ? [`\`resources[${id}].components\` is not supported: use \`index.component\`, \`forms.default.component\` and \`pages\`.`] : []), ...(columns !== null ? [`\`resources[${id}].columns\` is not supported: use \`index.columns\`.`] : [])];
289
+ }, [])];
290
+ }
291
+
265
292
  function getDisplayName({
266
293
  displayName = null,
267
294
  name = null
@@ -527,4 +554,4 @@ function validateFields(fields, value) {
527
554
  }, true);
528
555
  }
529
556
 
530
- export { checkClickable, convertStyleToString, copyToClipboard, createNullableOnChange, createUseEvent, flattenComponents, formatDuration, getColumnsWithFields, getComponent, getComponentFromName, getDefinitionFromId, getDisplayName, getFieldByName, getFieldFromPath, getFileName, getPathValue, getSelectOptions, isMessage, loadPackage, mergeRefs, parseDateOnly, selectItems, setValue as setFieldValue, slug, toggleSelectedItem, unselectItems, validateFields };
557
+ export { checkClickable, convertStyleToString, copyToClipboard, createNullableOnChange, createUseEvent, flattenComponents, formatDuration, getColumnsWithFields, getComponent, getComponentFromName, getDefinitionFromId, getDefinitionWarnings, getDisplayName, getFieldByName, getFieldFromPath, getFileName, getPathValue, getSelectOptions, isMessage, loadPackage, mergeRefs, parseDateOnly, selectItems, setValue as setFieldValue, slug, toggleSelectedItem, unselectItems, validateFields };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/core",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -96,5 +96,5 @@
96
96
  "publishConfig": {
97
97
  "access": "public"
98
98
  },
99
- "gitHead": "8a6accc1aab59368bf546c83b9433dfe94ccf767"
99
+ "gitHead": "28b394278cffa0c927989873dd4b3f184635ceff"
100
100
  }