@panneau/core 4.0.48 → 4.0.55

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.
@@ -142,10 +142,6 @@ declare function ComponentsProvider({ components, manager, namespace, children,
142
142
  interface Font {
143
143
  name: string;
144
144
  }
145
- /**
146
- * Tracking variables
147
- */
148
- type TrackingVariables = Record<string, unknown>;
149
145
 
150
146
  /**
151
147
  * Form Types
@@ -158,25 +154,28 @@ type TrackingVariables = Record<string, unknown>;
158
154
  interface Field {
159
155
  name?: string;
160
156
  type?: string;
161
- component?: string;
157
+ component?: string | ElementType;
162
158
  label?: ReactNode;
163
159
  }
164
- /**
165
- * Table column definition
166
- */
167
- type TableColumn = string | {
168
- id?: string;
169
- component?: string;
170
- path?: string;
171
- field?: string;
172
- columnClassName?: string;
173
- };
174
160
 
175
161
  /**
176
162
  * Resource Types
177
163
  * TypeScript interfaces for resources, items, users, media, and other entities
178
164
  */
179
165
 
166
+ /**
167
+ * Table column definition
168
+ */
169
+ type TableColumn = string | Column;
170
+ interface Column extends Record<string, unknown> {
171
+ id?: string | null;
172
+ label?: unknown;
173
+ path?: string;
174
+ valueKey?: string;
175
+ component?: string | ElementType | null;
176
+ field?: Field | string | null;
177
+ actions?: ActionDefinition[] | null;
178
+ }
180
179
  interface Action {
181
180
  id?: string;
182
181
  component?: string;
@@ -282,10 +281,16 @@ interface PanneauIntl {
282
281
  values?: PanneauIntlValues;
283
282
  }
284
283
  /**
285
- * Panneau definition (main configuration)
284
+ * Generic definition
286
285
  */
287
- interface PanneauDefinition {
286
+ interface Definition {
288
287
  name?: string;
288
+ [key: string]: unknown;
289
+ }
290
+ /**
291
+ * Panneau definition (main configuration)
292
+ */
293
+ interface PanneauDefinition extends Definition {
289
294
  resources?: Resource[];
290
295
  routes?: Routes;
291
296
  pages?: Record<string, Page>;
@@ -295,12 +300,9 @@ interface PanneauDefinition {
295
300
  settings?: Record<string, unknown>;
296
301
  }
297
302
  /**
298
- * Generic definition
303
+ * Tracking variables
299
304
  */
300
- interface Definition {
301
- name?: string;
302
- [key: string]: unknown;
303
- }
305
+ type TrackingVariables = Record<string, unknown>;
304
306
 
305
307
  declare function useDefinitionContext(): Definition | null;
306
308
  declare function useDefinition(): Definition | null;
package/dist/hooks.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Dayjs } from 'dayjs';
2
- import { ReactNode, SubmitEvent, RefObject } from 'react';
2
+ import { ElementType, ReactNode, SubmitEvent, RefObject } from 'react';
3
3
 
4
4
  interface UseAnimationFrameOptions {
5
5
  disabled?: boolean;
@@ -31,25 +31,28 @@ declare const useDocumentEvent: (event: string, callback: (...args: unknown[]) =
31
31
  interface Field$1 {
32
32
  name?: string;
33
33
  type?: string;
34
- component?: string;
34
+ component?: string | ElementType;
35
35
  label?: ReactNode;
36
36
  }
37
- /**
38
- * Table column definition
39
- */
40
- type TableColumn = string | {
41
- id?: string;
42
- component?: string;
43
- path?: string;
44
- field?: string;
45
- columnClassName?: string;
46
- };
47
37
 
48
38
  /**
49
39
  * Resource Types
50
40
  * TypeScript interfaces for resources, items, users, media, and other entities
51
41
  */
52
42
 
43
+ /**
44
+ * Table column definition
45
+ */
46
+ type TableColumn = string | Column;
47
+ interface Column extends Record<string, unknown> {
48
+ id?: string | null;
49
+ label?: unknown;
50
+ path?: string;
51
+ valueKey?: string;
52
+ component?: string | ElementType | null;
53
+ field?: Field$1 | string | null;
54
+ actions?: ActionDefinition[] | null;
55
+ }
53
56
  interface Action {
54
57
  id?: string;
55
58
  component?: string;
package/dist/index.d.ts CHANGED
@@ -171,6 +171,14 @@ declare class Tracking extends Tracking$1 {
171
171
  trackMedia(type: string, media: Media$1 | null, action: string, { value, ...opts }?: TrackingEventOptions): void;
172
172
  }
173
173
 
174
+ /**
175
+ * User definition
176
+ */
177
+ interface User {
178
+ id?: number | string;
179
+ [key: string]: unknown;
180
+ }
181
+
174
182
  /**
175
183
  * Core UI Types
176
184
  */
@@ -272,10 +280,6 @@ interface Breadcrumb {
272
280
  interface Font {
273
281
  name: string;
274
282
  }
275
- /**
276
- * Tracking variables
277
- */
278
- type TrackingVariables = Record<string, unknown>;
279
283
  /**
280
284
  * Trigger update identifier
281
285
  */
@@ -286,12 +290,11 @@ interface Pagination {
286
290
  total: number;
287
291
  last_page: number;
288
292
  }
289
-
290
293
  /**
291
- * User definition
294
+ * Generic item (base interface for data items)
292
295
  */
293
- interface User {
294
- id?: number | string;
296
+ interface Item {
297
+ id: string;
295
298
  [key: string]: unknown;
296
299
  }
297
300
 
@@ -320,7 +323,7 @@ type SelectOption = string | number | {
320
323
  interface Field {
321
324
  name?: string;
322
325
  type?: string;
323
- component?: string;
326
+ component?: string | ElementType;
324
327
  label?: ReactNode;
325
328
  }
326
329
  /**
@@ -330,22 +333,59 @@ interface Form {
330
333
  title: ReactNode;
331
334
  fields?: Field[];
332
335
  }
336
+
337
+ type MediaType = 'audio' | 'image' | 'video' | 'document' | 'font';
338
+ interface MediaFile {
339
+ url: string;
340
+ type: string;
341
+ }
333
342
  /**
334
- * Table column definition
343
+ * Media file definition
335
344
  */
336
- type TableColumn = string | {
337
- id?: string;
338
- component?: string;
339
- path?: string;
340
- field?: string;
341
- columnClassName?: string;
342
- };
345
+ interface Media extends Item {
346
+ id: string;
347
+ name: string;
348
+ type: string;
349
+ thumbnail_url?: string;
350
+ thumbnailUrl?: string;
351
+ url?: string;
352
+ provider?: string;
353
+ [key: string]: unknown;
354
+ files?: Record<string, MediaFile> | null;
355
+ }
356
+ interface VideoMedia extends Media {
357
+ type: 'video';
358
+ iframeUrl?: string;
359
+ width?: number | null;
360
+ height?: number | null;
361
+ duration?: number | null;
362
+ }
363
+ interface AudioMedia extends Media {
364
+ type: 'audio';
365
+ duration?: number | null;
366
+ }
367
+ interface ImageMedia extends Media {
368
+ type: 'image';
369
+ }
343
370
 
344
371
  /**
345
372
  * Resource Types
346
373
  * TypeScript interfaces for resources, items, users, media, and other entities
347
374
  */
348
375
 
376
+ /**
377
+ * Table column definition
378
+ */
379
+ type TableColumn = string | Column;
380
+ interface Column extends Record<string, unknown> {
381
+ id?: string | null;
382
+ label?: unknown;
383
+ path?: string;
384
+ valueKey?: string;
385
+ component?: string | ElementType | null;
386
+ field?: Field | string | null;
387
+ actions?: ActionDefinition[] | null;
388
+ }
349
389
  interface Action {
350
390
  id?: string;
351
391
  component?: string;
@@ -394,26 +434,9 @@ interface Resource {
394
434
  shows_in_navbar?: boolean;
395
435
  settings?: Record<string, unknown>;
396
436
  }
397
- /**
398
- * Generic item (base interface for data items)
399
- */
400
- interface Item {
401
- id: string;
402
- [key: string]: unknown;
403
- }
404
437
  interface ResourceItem extends Item {
405
438
  type?: string;
406
439
  }
407
- /**
408
- * Media file definition
409
- */
410
- interface Media extends Item {
411
- id: string;
412
- name: string;
413
- type: string;
414
- thumbnail_url?: string;
415
- [key: string]: unknown;
416
- }
417
440
  /**
418
441
  * Preview definition
419
442
  */
@@ -499,10 +522,16 @@ interface PanneauIntl {
499
522
  values?: PanneauIntlValues;
500
523
  }
501
524
  /**
502
- * Panneau definition (main configuration)
525
+ * Generic definition
503
526
  */
504
- interface PanneauDefinition {
527
+ interface Definition {
505
528
  name?: string;
529
+ [key: string]: unknown;
530
+ }
531
+ /**
532
+ * Panneau definition (main configuration)
533
+ */
534
+ interface PanneauDefinition extends Definition {
506
535
  resources?: Resource[];
507
536
  routes?: Routes;
508
537
  pages?: Record<string, Page>;
@@ -512,12 +541,9 @@ interface PanneauDefinition {
512
541
  settings?: Record<string, unknown>;
513
542
  }
514
543
  /**
515
- * Generic definition
544
+ * Tracking variables
516
545
  */
517
- interface Definition {
518
- name?: string;
519
- [key: string]: unknown;
520
- }
546
+ type TrackingVariables = Record<string, unknown>;
521
547
 
522
548
  export { ComponentsManager, DefinitionsManager, EventsManager, FieldsManager, FontsParser, FormsManager, MediasParser, Tracking };
523
- export type { Action, ActionDefinition, ActionValue, Breadcrumb, Button, ButtonElement, ButtonSize, ButtonTheme, ButtonType, ControlSize, Definition, DropdownAlign, Feedback, Field, FieldOption, Filter, Font, Form, FormError, FormStatus, Item, Label, Media, MenuItem, Message, Modal, Page, Pagination, PanneauComponents, PanneauDefinition, PanneauIntl, PanneauIntlValues, PanneauTheme, Preview, Resource, ResourceIndex, ResourceIntl, ResourceIntlValues, ResourceItem, Routes, SelectOption, StatusCode, TableColumn, Toggle, TrackingVariables, TriggerUpdate, Uppy, User, uppy };
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, Page, Pagination, PanneauComponents, PanneauDefinition, PanneauIntl, PanneauIntlValues, PanneauTheme, Preview, Resource, ResourceIndex, ResourceIntl, ResourceIntlValues, ResourceItem, 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, ReactNode, ComponentType, ReactElement } from 'react';
2
+ import { ElementType, ReactNode, ReactElement, ForwardedRef } from 'react';
3
3
  import { MessageDescriptor } from 'react-intl';
4
4
 
5
5
  interface CheckClickableOptions {
@@ -46,6 +46,13 @@ interface Message extends MessageDescriptor {
46
46
  * Label can be either a message object or any React node
47
47
  */
48
48
  type Label = Message | ReactNode;
49
+ /**
50
+ * Generic item (base interface for data items)
51
+ */
52
+ interface Item {
53
+ id: string;
54
+ [key: string]: unknown;
55
+ }
49
56
 
50
57
  /**
51
58
  * Form Types
@@ -65,25 +72,28 @@ type SelectOption = string | number | {
65
72
  interface Field {
66
73
  name?: string;
67
74
  type?: string;
68
- component?: string;
75
+ component?: string | ElementType;
69
76
  label?: ReactNode;
70
77
  }
71
- /**
72
- * Table column definition
73
- */
74
- type TableColumn = string | {
75
- id?: string;
76
- component?: string;
77
- path?: string;
78
- field?: string;
79
- columnClassName?: string;
80
- };
81
78
 
82
79
  /**
83
80
  * Resource Types
84
81
  * TypeScript interfaces for resources, items, users, media, and other entities
85
82
  */
86
83
 
84
+ /**
85
+ * Table column definition
86
+ */
87
+ type TableColumn = string | Column;
88
+ interface Column extends Record<string, unknown> {
89
+ id?: string | null;
90
+ label?: unknown;
91
+ path?: string;
92
+ valueKey?: string;
93
+ component?: string | ElementType | null;
94
+ field?: Field | string | null;
95
+ actions?: ActionDefinition[] | null;
96
+ }
87
97
  interface Action {
88
98
  id?: string;
89
99
  component?: string;
@@ -131,13 +141,6 @@ interface Resource {
131
141
  shows_in_navbar?: boolean;
132
142
  settings?: Record<string, unknown>;
133
143
  }
134
- /**
135
- * Generic item (base interface for data items)
136
- */
137
- interface Item {
138
- id: string;
139
- [key: string]: unknown;
140
- }
141
144
  /**
142
145
  * Filter definition
143
146
  */
@@ -160,22 +163,18 @@ interface Definition {
160
163
  [key: string]: unknown;
161
164
  }
162
165
 
163
- interface Column extends Record<string, unknown> {
164
- id?: string | null;
165
- label?: unknown;
166
- valueKey?: string;
167
- component?: string | null;
168
- field?: Field | string | null;
169
- }
170
166
  declare function getColumnsWithFields(resource: Resource, columns: TableColumn[] | null): Column[];
171
167
 
172
168
  interface ComponentResult {
173
- name: unknown;
169
+ name: string | ElementType | null;
174
170
  props: Record<string, unknown> | null;
175
171
  }
176
- declare function getComponent(component: unknown): ComponentResult;
172
+ declare function getComponent(component: string | {
173
+ component: string | ElementType;
174
+ [key: string]: unknown;
175
+ }): ComponentResult;
177
176
 
178
- declare function getComponentFromName<T = ComponentType<unknown> | 'string'>(name?: string | null, components?: Record<string, T> | null, defaultComponent?: T | null): T | null;
177
+ declare function getComponentFromName(name?: string | ElementType | null, components?: Record<string, ElementType> | null, defaultComponent?: ElementType | null): ElementType | null;
179
178
 
180
179
  declare function getDefinitionFromId<T extends Definition = Definition>(id?: string | null, items?: T[] | null, defaultObject?: T | null): T | null;
181
180
 
@@ -220,6 +219,8 @@ declare function isMessage(message: unknown): message is Message;
220
219
 
221
220
  declare function loadPackage<T = unknown>(name: string, loader: () => Promise<T>): Promise<T>;
222
221
 
222
+ declare function mergeRefs<T>(...refs: Array<ForwardedRef<T> | null | undefined>): (value: T | null) => void;
223
+
223
224
  declare function toggleSelectedItem(items: Item[] | null, item: Item, { multiple: multipleSelection }?: {
224
225
  multiple?: boolean;
225
226
  }): Item[] | null;
@@ -238,4 +239,4 @@ interface FieldWithValidation extends Field {
238
239
  }
239
240
  declare function validateFields(fields: FieldWithValidation[], value: Record<string, unknown> | null): boolean;
240
241
 
241
- export { checkClickable, convertStyleToString, copyToClipboard, createNullableOnChange, createUseEvent, flattenComponents, formatDuration, getColumnsWithFields, getComponent, getComponentFromName, getDefinitionFromId, getDisplayName, getFieldByName, getFieldFromPath, getFileName, getPathValue, getSelectOptions, isMessage, loadPackage, selectItems, setValue as setFieldValue, slug, toggleSelectedItem, unselectItems, validateFields };
242
+ export { checkClickable, convertStyleToString, copyToClipboard, createNullableOnChange, createUseEvent, flattenComponents, formatDuration, getColumnsWithFields, getComponent, getComponentFromName, getDefinitionFromId, getDisplayName, getFieldByName, getFieldFromPath, getFileName, getPathValue, getSelectOptions, isMessage, loadPackage, mergeRefs, selectItems, setValue as setFieldValue, slug, toggleSelectedItem, unselectItems, validateFields };
package/dist/utils.js CHANGED
@@ -6,6 +6,7 @@ import { isValidElementType } from 'react-is';
6
6
  import isString from 'lodash/isString';
7
7
  import { pascalCase, kebabCase, snakeCase as snakeCase$1 } from 'change-case';
8
8
  export { kebabCase as dashCase, pascalCase, snakeCase } from 'change-case';
9
+ import isFunction from 'lodash/isFunction';
9
10
  import isArray from 'lodash/isArray';
10
11
  import get from 'lodash/get';
11
12
  import capitalize from 'lodash/capitalize';
@@ -169,13 +170,13 @@ function formatDuration(timeInSeconds) {
169
170
 
170
171
  function getComponent(component) {
171
172
  const {
172
- component: name,
173
+ component: name = null,
173
174
  ...props
174
- } = isObject(component) ? component : {
175
+ } = isString(component) ? {
175
176
  component
176
- };
177
+ } : component || {};
177
178
  return {
178
- name: component,
179
+ name,
179
180
  props: Object.keys(props).length > 0 ? props : null
180
181
  };
181
182
  }
@@ -184,7 +185,6 @@ function getColumnFromField(field) {
184
185
  if (field === null) {
185
186
  return null;
186
187
  }
187
- // eslint-disable-next-line camelcase
188
188
  const {
189
189
  name,
190
190
  components: {
@@ -231,6 +231,9 @@ function getComponentFromName(name = null, components = {}, defaultComponent = n
231
231
  if (components === null || name === null) {
232
232
  return defaultComponent;
233
233
  }
234
+ if (isObject(name) || isFunction(name)) {
235
+ return name;
236
+ }
234
237
  const pascalName = pascalCase(name);
235
238
  const component = components[pascalName] || components[name] || defaultComponent;
236
239
  if (!component) {
@@ -375,6 +378,18 @@ function loadPackage(name, loader) {
375
378
  });
376
379
  }
377
380
 
381
+ function mergeRefs(...refs) {
382
+ return value => {
383
+ refs.forEach(ref => {
384
+ if (typeof ref === 'function') {
385
+ ref(value);
386
+ } else if (ref !== null) {
387
+ ref.current = value;
388
+ }
389
+ });
390
+ };
391
+ }
392
+
378
393
  function toggleSelectedItem(items, item, {
379
394
  multiple: multipleSelection = false
380
395
  } = {}) {
@@ -463,4 +478,4 @@ function validateFields(fields, value) {
463
478
  }, true);
464
479
  }
465
480
 
466
- export { checkClickable, convertStyleToString, copyToClipboard, createNullableOnChange, createUseEvent, flattenComponents, formatDuration, getColumnsWithFields, getComponent, getComponentFromName, getDefinitionFromId, getDisplayName, getFieldByName, getFieldFromPath, getFileName, getPathValue, getSelectOptions, isMessage, loadPackage, selectItems, setValue as setFieldValue, slug, toggleSelectedItem, unselectItems, validateFields };
481
+ export { checkClickable, convertStyleToString, copyToClipboard, createNullableOnChange, createUseEvent, flattenComponents, formatDuration, getColumnsWithFields, getComponent, getComponentFromName, getDefinitionFromId, getDisplayName, getFieldByName, getFieldFromPath, getFileName, getPathValue, getSelectOptions, isMessage, loadPackage, mergeRefs, 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.0.48",
3
+ "version": "4.0.55",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -96,5 +96,5 @@
96
96
  "publishConfig": {
97
97
  "access": "public"
98
98
  },
99
- "gitHead": "668d90a05a094fe55fcea760df3f9c294c6cbb31"
99
+ "gitHead": "1c9183567fc5bf98ba10fa57c63cf2ed2ae4a054"
100
100
  }