@rebasepro/plugin-data-enhancement 0.0.1-canary.eae7889 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/dist/core/src/components/BootstrapAdminBanner.d.ts +4 -0
  2. package/dist/core/src/components/LoginView/LoginView.d.ts +22 -0
  3. package/dist/core/src/components/common/useDataTableController.d.ts +3 -3
  4. package/dist/core/src/components/index.d.ts +1 -0
  5. package/dist/core/src/hooks/data/useRelationSelector.d.ts +2 -2
  6. package/dist/core/src/hooks/index.d.ts +1 -0
  7. package/dist/core/src/hooks/useCollapsedGroups.d.ts +16 -1
  8. package/dist/core/src/hooks/useResolvedComponent.d.ts +47 -0
  9. package/dist/index.es.js +14 -13
  10. package/dist/index.es.js.map +1 -1
  11. package/dist/index.umd.js +14 -13
  12. package/dist/index.umd.js.map +1 -1
  13. package/dist/types/src/controllers/auth.d.ts +8 -2
  14. package/dist/types/src/controllers/client.d.ts +13 -0
  15. package/dist/types/src/controllers/collection_registry.d.ts +2 -1
  16. package/dist/types/src/controllers/data_driver.d.ts +36 -1
  17. package/dist/types/src/controllers/navigation.d.ts +18 -6
  18. package/dist/types/src/controllers/registry.d.ts +9 -1
  19. package/dist/types/src/controllers/side_entity_controller.d.ts +7 -0
  20. package/dist/types/src/rebase_context.d.ts +17 -0
  21. package/dist/types/src/types/backend_hooks.d.ts +187 -0
  22. package/dist/types/src/types/collections.d.ts +31 -11
  23. package/dist/types/src/types/component_ref.d.ts +47 -0
  24. package/dist/types/src/types/cron.d.ts +1 -1
  25. package/dist/types/src/types/entity_views.d.ts +6 -7
  26. package/dist/types/src/types/formex.d.ts +40 -0
  27. package/dist/types/src/types/index.d.ts +3 -0
  28. package/dist/types/src/types/plugins.d.ts +6 -3
  29. package/dist/types/src/types/properties.d.ts +72 -88
  30. package/dist/types/src/types/slots.d.ts +20 -10
  31. package/dist/types/src/types/translations.d.ts +6 -0
  32. package/dist/ui/src/components/FileUpload.d.ts +1 -1
  33. package/dist/ui/src/components/SearchBar.d.ts +5 -1
  34. package/dist/ui/src/styles.d.ts +2 -2
  35. package/package.json +9 -9
  36. package/src/components/DataEnhancementControllerProvider.tsx +1 -1
  37. package/src/components/FormEnhanceAction.tsx +9 -8
  38. package/src/utils/properties.ts +4 -4
  39. package/src/utils/strings_counter.ts +1 -1
@@ -1,4 +1,4 @@
1
- import React from "react";
1
+ import type { ComponentRef } from "./component_ref";
2
2
  import type { EntityReference, EntityRelation, EntityValues, GeoPoint, Entity } from "./entities";
3
3
  import type { Relation, JoinStep, OnAction } from "./relations";
4
4
  import type { EntityCollection, FilterValues } from "./collections";
@@ -36,6 +36,14 @@ export type Property = StringProperty | NumberProperty | BooleanProperty | DateP
36
36
  export type Properties = {
37
37
  [key: string]: Property;
38
38
  };
39
+ export type PostgresProperty = Exclude<Property, ReferenceProperty>;
40
+ export type PostgresProperties = {
41
+ [key: string]: PostgresProperty;
42
+ };
43
+ export type FirebaseProperty = Exclude<Property, RelationProperty>;
44
+ export type FirebaseProperties = {
45
+ [key: string]: FirebaseProperty;
46
+ };
39
47
  /**
40
48
  * A helper type to infer the underlying data type from a Property definition.
41
49
  * This is the core of the type inference system.
@@ -89,7 +97,18 @@ export type InferEntityType<P extends Properties> = {
89
97
  * Interface including all common properties of a CMS property.
90
98
  * @group Entity properties
91
99
  */
100
+ export interface BaseUIConfig<CustomProps = unknown> {
101
+ columnWidth?: number;
102
+ hideFromCollection?: boolean;
103
+ readOnly?: boolean;
104
+ disabled?: boolean | PropertyDisabledConfig;
105
+ widthPercentage?: number;
106
+ customProps?: CustomProps;
107
+ Field?: ComponentRef<any>;
108
+ Preview?: ComponentRef<any>;
109
+ }
92
110
  export interface BaseProperty<CustomProps = unknown> {
111
+ ui?: BaseUIConfig<CustomProps>;
93
112
  /**
94
113
  * Property name (e.g. Product)
95
114
  */
@@ -106,27 +125,17 @@ export interface BaseProperty<CustomProps = unknown> {
106
125
  */
107
126
  propertyConfig?: string;
108
127
  /**
109
- * Width in pixels of this column in the collection view. If not set
110
- * the width is inferred based on the other configurations
111
- */
112
- columnWidth?: number;
113
- /**
114
- * Do not show this property in the collection view
115
- */
116
- hideFromCollection?: boolean;
117
- /**
118
- * Is this a read only property. When set to true, it gets rendered as a
119
- * preview.
120
- */
121
- readOnly?: boolean;
122
- /**
123
- * Is this field disabled.
124
- * When set to true, it gets rendered as a
125
- * disabled field. You can also specify a configuration for defining the
126
- * behaviour of disabled properties (including custom messages, clear value on
127
- * disabled or hide the field completely)
128
+ * Explicit database column name. When set, this value is used as-is
129
+ * for the SQL column name, bypassing any snake_case conversion of
130
+ * the property key.
131
+ *
132
+ * This is automatically populated by `rebase schema introspect`
133
+ * to guarantee an exact match with the live database schema.
134
+ *
135
+ * For manually-authored collections you can omit this — the framework
136
+ * will derive the column name from the property key via `toSnakeCase()`.
128
137
  */
129
- disabled?: boolean | PropertyDisabledConfig;
138
+ columnName?: string;
130
139
  /**
131
140
  * Rules for validating this property
132
141
  */
@@ -135,16 +144,6 @@ export interface BaseProperty<CustomProps = unknown> {
135
144
  * This value will be set by default for new entities.
136
145
  */
137
146
  defaultValue?: unknown;
138
- /**
139
- * A number between 0 and 100 that indicates the width of the field in the form view.
140
- * It defaults to 100, but you can set it to 50 to have two fields in the same row.
141
- */
142
- widthPercentage?: number;
143
- /**
144
- * Additional props that are passed to the components defined in `field`
145
- * or in `preview`.
146
- */
147
- customProps?: CustomProps;
148
147
  /**
149
148
  * Use this to define dynamic properties that change based on certain conditions
150
149
  * or on the entity's values. For example, you can make a field read-only if
@@ -168,21 +167,19 @@ export interface BaseProperty<CustomProps = unknown> {
168
167
  * Callbacks/Hooks for this property field to transform and sanitize data during its lifecycle.
169
168
  */
170
169
  callbacks?: PropertyCallbacks;
171
- /**
172
- * Custom field component to render this property in forms.
173
- * Used by the CMS layer.
174
- */
175
- Field?: React.ComponentType<any>;
176
- /**
177
- * Custom preview component to render this property in previews/tables.
178
- * Used by the CMS layer.
179
- */
180
- Preview?: React.ComponentType<any>;
181
170
  }
182
171
  /**
183
172
  * @group Entity properties
184
173
  */
174
+ export interface StringUIConfig extends BaseUIConfig {
175
+ multiline?: boolean;
176
+ markdown?: boolean;
177
+ previewAsTag?: boolean;
178
+ clearable?: boolean;
179
+ url?: boolean | PreviewType;
180
+ }
185
181
  export interface StringProperty extends BaseProperty {
182
+ ui?: StringUIConfig;
186
183
  type: "string";
187
184
  /**
188
185
  * Optional database column type. If not set, it defaults to `varchar` or `uuid` depending on `isId` configuration.
@@ -257,10 +254,6 @@ export interface StringProperty extends BaseProperty {
257
254
  * Should this string be rendered as a tag instead of just text.
258
255
  */
259
256
  previewAsTag?: boolean;
260
- /**
261
- * Add an icon to clear the value and set it to `null`. Defaults to `false`
262
- */
263
- clearable?: boolean;
264
257
  /**
265
258
  * You can use this property (a string) to behave as a reference to another
266
259
  * collection. The stored value is the ID of the entity in the
@@ -272,7 +265,11 @@ export interface StringProperty extends BaseProperty {
272
265
  /**
273
266
  * @group Entity properties
274
267
  */
268
+ export interface NumberUIConfig extends BaseUIConfig {
269
+ clearable?: boolean;
270
+ }
275
271
  export interface NumberProperty extends BaseProperty {
272
+ ui?: NumberUIConfig;
276
273
  type: "number";
277
274
  /**
278
275
  * Optional database column type. Allows specifying exact database numeric types.
@@ -300,15 +297,12 @@ export interface NumberProperty extends BaseProperty {
300
297
  * displayed in the dropdown.
301
298
  */
302
299
  enum?: EnumValues;
303
- /**
304
- * Add an icon to clear the value and set it to `null`. Defaults to `false`
305
- */
306
- clearable?: boolean;
307
300
  }
308
301
  /**
309
302
  * @group Entity properties
310
303
  */
311
304
  export interface BooleanProperty extends BaseProperty {
305
+ ui?: BaseUIConfig;
312
306
  type: "boolean";
313
307
  /**
314
308
  * Rules for validating this property
@@ -318,7 +312,11 @@ export interface BooleanProperty extends BaseProperty {
318
312
  /**
319
313
  * @group Entity properties
320
314
  */
315
+ export interface DateUIConfig extends BaseUIConfig {
316
+ clearable?: boolean;
317
+ }
321
318
  export interface DateProperty extends BaseProperty {
319
+ ui?: DateUIConfig;
322
320
  type: "date";
323
321
  /**
324
322
  * Optional database column type. If not set, defaults to `timestamp` with timezone.
@@ -354,6 +352,7 @@ export interface DateProperty extends BaseProperty {
354
352
  * @group Entity properties
355
353
  */
356
354
  export interface GeopointProperty extends BaseProperty {
355
+ ui?: BaseUIConfig;
357
356
  type: "geopoint";
358
357
  /**
359
358
  * Rules for validating this property
@@ -363,7 +362,11 @@ export interface GeopointProperty extends BaseProperty {
363
362
  /**
364
363
  * @group Entity properties
365
364
  */
365
+ export interface ReferenceUIConfig extends BaseUIConfig {
366
+ previewProperties?: string[];
367
+ }
366
368
  export interface ReferenceProperty extends BaseProperty {
369
+ ui?: ReferenceUIConfig;
367
370
  type: "reference";
368
371
  /**
369
372
  * Marks this field as a Primary Key / Unique Identifier.
@@ -384,15 +387,9 @@ export interface ReferenceProperty extends BaseProperty {
384
387
  path?: string;
385
388
  /**
386
389
  * Allow selection of entities that pass the given filter only.
387
- * e.g. `forceFilter: { age: [">=", 18] }`
390
+ * e.g. `fixedFilter: { age: [">=", 18] }`
388
391
  */
389
- forceFilter?: FilterValues<string>;
390
- /**
391
- * Properties that need to be rendered when displaying a preview of this
392
- * reference. If not specified the first 3 are used. Only the first 3
393
- * specified values are considered.
394
- */
395
- previewProperties?: string[];
392
+ fixedFilter?: FilterValues<string>;
396
393
  /**
397
394
  * Should the reference include the ID of the entity. Defaults to `true`
398
395
  */
@@ -405,7 +402,12 @@ export interface ReferenceProperty extends BaseProperty {
405
402
  /**
406
403
  * @group Entity properties
407
404
  */
405
+ export interface RelationUIConfig extends BaseUIConfig {
406
+ previewProperties?: string[];
407
+ widget?: "select" | "dialog";
408
+ }
408
409
  export interface RelationProperty extends BaseProperty {
410
+ ui?: RelationUIConfig;
409
411
  type: "relation";
410
412
  /**
411
413
  * Marks this field as a Primary Key / Unique Identifier.
@@ -492,15 +494,9 @@ export interface RelationProperty extends BaseProperty {
492
494
  relation?: Relation;
493
495
  /**
494
496
  * Allow selection of entities that pass the given filter only.
495
- * e.g. `forceFilter: { age: [">=", 18] }`
497
+ * e.g. `fixedFilter: { age: [">=", 18] }`
496
498
  */
497
- forceFilter?: FilterValues<string>;
498
- /**
499
- * Properties that need to be rendered when displaying a preview of this
500
- * reference. If not specified the first 3 are used. Only the first 3
501
- * specified values are considered.
502
- */
503
- previewProperties?: string[];
499
+ fixedFilter?: FilterValues<string>;
504
500
  /**
505
501
  * Should the reference include the ID of the entity. Defaults to `true`
506
502
  */
@@ -518,7 +514,12 @@ export interface RelationProperty extends BaseProperty {
518
514
  /**
519
515
  * @group Entity properties
520
516
  */
517
+ export interface ArrayUIConfig extends BaseUIConfig {
518
+ expanded?: boolean;
519
+ minimalistView?: boolean;
520
+ }
521
521
  export interface ArrayProperty extends BaseProperty {
522
+ ui?: ArrayUIConfig;
522
523
  type: "array";
523
524
  /**
524
525
  * Optional database column type. Defaults to `jsonb`.
@@ -573,15 +574,6 @@ export interface ArrayProperty extends BaseProperty {
573
574
  * Rules for validating this property
574
575
  */
575
576
  validation?: ArrayPropertyValidationSchema;
576
- /**
577
- * Should the field be initially expanded. Defaults to `true`
578
- */
579
- expanded?: boolean;
580
- /**
581
- * Display the child properties directly, without being wrapped in an
582
- * extendable panel.
583
- */
584
- minimalistView?: boolean;
585
577
  /**
586
578
  * Can the elements in this array be reordered. Defaults to `true`.
587
579
  * This prop has no effect if `disabled` is set to true.
@@ -596,7 +588,13 @@ export interface ArrayProperty extends BaseProperty {
596
588
  /**
597
589
  * @group Entity properties
598
590
  */
591
+ export interface MapUIConfig extends BaseUIConfig {
592
+ expanded?: boolean;
593
+ minimalistView?: boolean;
594
+ spreadChildren?: boolean;
595
+ }
599
596
  export interface MapProperty extends BaseProperty {
597
+ ui?: MapUIConfig;
600
598
  type: "map";
601
599
  /**
602
600
  * Optional database column type. Defaults to `jsonb`.
@@ -630,20 +628,6 @@ export interface MapProperty extends BaseProperty {
630
628
  * needed
631
629
  */
632
630
  pickOnlySomeKeys?: boolean;
633
- /**
634
- * Display the child properties as independent columns in the collection
635
- * view
636
- */
637
- spreadChildren?: boolean;
638
- /**
639
- * Display the child properties directly, without being wrapped in an
640
- * extendable panel. Note that this will also hide the title of this property.
641
- */
642
- minimalistView?: boolean;
643
- /**
644
- * Should the field be initially expanded. Defaults to `true`
645
- */
646
- expanded?: boolean;
647
631
  /**
648
632
  * Render this map as a key-value table that allows to use
649
633
  * arbitrary keys. You don't need to define the properties in this case.
@@ -100,7 +100,8 @@ export interface NavigationSlotProps {
100
100
  export interface CollectionToolbarProps {
101
101
  path: string;
102
102
  collection: EntityCollection;
103
- parentCollectionIds: string[];
103
+ parentCollectionSlugs: string[];
104
+ parentEntityIds: string[];
104
105
  tableController: EntityTableController;
105
106
  selectionController: SelectionController;
106
107
  }
@@ -111,7 +112,8 @@ export interface CollectionToolbarProps {
111
112
  export interface CollectionEmptyStateProps {
112
113
  path: string;
113
114
  collection: EntityCollection;
114
- parentCollectionIds: string[];
115
+ parentCollectionSlugs: string[];
116
+ parentEntityIds: string[];
115
117
  canCreate: boolean;
116
118
  onNewClick?: () => void;
117
119
  }
@@ -123,7 +125,8 @@ export interface CollectionHeaderActionProps {
123
125
  property: Property;
124
126
  propertyKey: string;
125
127
  path: string;
126
- parentCollectionIds: string[];
128
+ parentCollectionSlugs: string[];
129
+ parentEntityIds: string[];
127
130
  onHover: boolean;
128
131
  collection: EntityCollection;
129
132
  tableController: EntityTableController;
@@ -134,7 +137,8 @@ export interface CollectionHeaderActionProps {
134
137
  */
135
138
  export interface CollectionAddColumnProps {
136
139
  path: string;
137
- parentCollectionIds: string[];
140
+ parentCollectionSlugs: string[];
141
+ parentEntityIds: string[];
138
142
  collection: EntityCollection;
139
143
  tableController: EntityTableController;
140
144
  }
@@ -145,7 +149,8 @@ export interface CollectionAddColumnProps {
145
149
  export interface CollectionErrorProps {
146
150
  path: string;
147
151
  collection: EntityCollection;
148
- parentCollectionIds?: string[];
152
+ parentCollectionSlugs?: string[];
153
+ parentEntityIds?: string[];
149
154
  error: Error;
150
155
  }
151
156
  /**
@@ -155,7 +160,8 @@ export interface CollectionErrorProps {
155
160
  export interface KanbanSetupProps {
156
161
  collection: EntityCollection;
157
162
  fullPath: string;
158
- parentCollectionIds: string[];
163
+ parentCollectionSlugs: string[];
164
+ parentEntityIds: string[];
159
165
  }
160
166
  /**
161
167
  * Props for the `kanban.add-column` slot.
@@ -164,7 +170,8 @@ export interface KanbanSetupProps {
164
170
  export interface KanbanAddColumnProps {
165
171
  collection: EntityCollection;
166
172
  fullPath: string;
167
- parentCollectionIds: string[];
173
+ parentCollectionSlugs: string[];
174
+ parentEntityIds: string[];
168
175
  columnProperty: string;
169
176
  }
170
177
  /**
@@ -177,7 +184,8 @@ export interface EntityRowActionsProps {
177
184
  entityId: string;
178
185
  path: string;
179
186
  collection: EntityCollection;
180
- parentCollectionIds: string[];
187
+ parentCollectionSlugs: string[];
188
+ parentEntityIds: string[];
181
189
  selectionController: SelectionController;
182
190
  context: RebaseContext;
183
191
  }
@@ -202,7 +210,8 @@ export interface EntityFieldSlotProps {
202
210
  export interface CollectionFilterPanelProps {
203
211
  path: string;
204
212
  collection: EntityCollection;
205
- parentCollectionIds: string[];
213
+ parentCollectionSlugs: string[];
214
+ parentEntityIds: string[];
206
215
  tableController: EntityTableController;
207
216
  context: RebaseContext;
208
217
  }
@@ -238,7 +247,8 @@ export interface ShellToolbarProps {
238
247
  export interface CollectionInsightsSlotProps {
239
248
  path: string;
240
249
  collection: EntityCollection;
241
- parentCollectionIds: string[];
250
+ parentCollectionSlugs: string[];
251
+ parentEntityIds: string[];
242
252
  }
243
253
  /**
244
254
  * Props for `home.card.insight` slot.
@@ -51,6 +51,8 @@ export interface RebaseTranslations {
51
51
  all_entries_loaded: string;
52
52
  create_your_first_entry: string;
53
53
  no_results_filter_sort: string;
54
+ /** Shown when a text search yields no results. Supports `{{search}}` interpolation. */
55
+ no_results_search?: string;
54
56
  add: string;
55
57
  remove: string;
56
58
  copy_id: string;
@@ -461,6 +463,10 @@ export interface RebaseTranslations {
461
463
  reset_password_success?: string;
462
464
  reset_password_confirmation?: string;
463
465
  error_resetting_password?: string;
466
+ /** Permission-denied empty states */
467
+ no_permission_to_view_users?: string;
468
+ no_permission_to_view_roles?: string;
469
+ no_permission_description?: string;
464
470
  /** Editor table-bubble */
465
471
  add_row_before: string;
466
472
  add_row_after: string;
@@ -9,7 +9,7 @@ export type OnFileUploadRejected = (fileRejections: {
9
9
  }[], event: object) => void;
10
10
  export type OnFilesUploadAdded = (files: File[]) => void;
11
11
  export type FileUploadProps = {
12
- accept: Record<string, string[]>;
12
+ accept?: Record<string, string[]>;
13
13
  onFilesAdded: OnFilesUploadAdded;
14
14
  onFilesRejected?: OnFileUploadRejected;
15
15
  maxSize?: number;
@@ -17,6 +17,10 @@ interface SearchBarProps {
17
17
  disabled?: boolean;
18
18
  loading?: boolean;
19
19
  inputRef?: React.Ref<HTMLInputElement>;
20
+ /**
21
+ * Optional initial value for the search input, e.g. from URL params.
22
+ */
23
+ initialValue?: string;
20
24
  }
21
- export declare function SearchBar({ onClick, onTextSearch, placeholder, expandable, size, innerClassName, className, autoFocus, disabled, loading, inputRef }: SearchBarProps): import("react/jsx-runtime").JSX.Element;
25
+ export declare function SearchBar({ onClick, onTextSearch, placeholder, expandable, size, innerClassName, className, autoFocus, disabled, loading, inputRef, initialValue }: SearchBarProps): import("react/jsx-runtime").JSX.Element;
22
26
  export {};
@@ -7,6 +7,6 @@ export declare const fieldBackgroundDisabledMixin = "dark:bg-surface-900 bg-opac
7
7
  export declare const fieldBackgroundHoverMixin = "hover:bg-opacity-70 dark:hover:bg-surface-700 dark:hover:bg-opacity-40 hover:bg-surface-accent-200/70 hover:dark:bg-surface-700/40";
8
8
  export declare const defaultBorderMixin = "border-surface-200/60 dark:border-surface-700/60 ";
9
9
  export declare const paperMixin = "bg-white rounded-md dark:bg-surface-800 border border-surface-200/60 dark:border-surface-700/60";
10
- export declare const cardMixin = "bg-white dark:bg-surface-800 rounded-md border border-surface-200/60 dark:border-surface-700/60 m-1 -p-1";
11
- export declare const cardClickableMixin = "hover:bg-surface-accent-100 dark:hover:bg-surface-800 hover:ring-2 hover:ring-primary cursor-pointer hover:bg-primary/20 dark:hover:bg-primary/10 ";
10
+ export declare const cardMixin = "bg-white dark:bg-surface-900 rounded-md border border-surface-200/60 dark:border-surface-700/60 m-1 -p-1";
11
+ export declare const cardClickableMixin = "hover:bg-surface-accent-100 dark:hover:bg-surface-800 hover:ring-1 hover:ring-primary/50 hover:shadow-sm cursor-pointer hover:bg-primary/10 dark:hover:bg-primary/10 transition-all duration-150";
12
12
  export declare const cardSelectedMixin = "bg-primary-bg/30 dark:bg-primary-bg/10 ring-1 ring-primary/75";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rebasepro/plugin-data-enhancement",
3
3
  "type": "module",
4
- "version": "0.0.1-canary.eae7889",
4
+ "version": "0.1.0",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",
7
7
  "types": "./dist/index.d.ts",
@@ -17,18 +17,18 @@
17
17
  },
18
18
  "dependencies": {
19
19
  "react-compiler-runtime": "1.0.0",
20
- "@rebasepro/admin": "0.0.1-canary.eae7889",
21
- "@rebasepro/common": "0.0.1-canary.eae7889",
22
- "@rebasepro/types": "0.0.1-canary.eae7889",
23
- "@rebasepro/core": "0.0.1-canary.eae7889",
24
- "@rebasepro/ui": "0.0.1-canary.eae7889",
25
- "@rebasepro/utils": "0.0.1-canary.eae7889"
20
+ "@rebasepro/admin": "0.1.0",
21
+ "@rebasepro/types": "0.1.0",
22
+ "@rebasepro/utils": "0.1.0",
23
+ "@rebasepro/common": "0.1.0",
24
+ "@rebasepro/ui": "0.1.0",
25
+ "@rebasepro/core": "0.1.0"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": ">=19.0.0",
29
29
  "react-dom": ">=19.0.0",
30
- "react-router": "^6.28.0",
31
- "react-router-dom": "^6.28.0"
30
+ "react-router": ">=6.28.0",
31
+ "react-router-dom": ">=6.28.0"
32
32
  },
33
33
  "browserslist": {
34
34
  "production": [
@@ -149,7 +149,7 @@ export function DataEnhancementControllerProvider({
149
149
  const value = getValueInPath(currentValues, propertyKey);
150
150
  const property = getPropertyFromKey(properties, propertyKey);
151
151
 
152
- if (!property || suggestion === null || property.disabled) {
152
+ if (!property || suggestion === null || property?.disabled) {
153
153
  return;
154
154
  }
155
155
 
@@ -31,13 +31,11 @@ export function FormEnhanceAction({
31
31
  const [samplePrompts, setSamplePrompts] = React.useState<SamplePrompt[] | undefined>(undefined);
32
32
  const [instructions, setInstructions] = React.useState<string>("");
33
33
 
34
- const {
35
- suggestions,
36
- getSamplePrompts
37
- } = dataEnhancementController;
34
+ const getSamplePrompts = dataEnhancementController?.getSamplePrompts;
38
35
 
39
36
  const loadingPrompts = useRef(false);
40
37
  const updateSuggestedPrompts = useCallback(async function updateSuggestedPrompts(instructions?: string) {
38
+ if (!getSamplePrompts) return;
41
39
  if (loadingPrompts.current) return;
42
40
  loadingPrompts.current = true;
43
41
  const prompts = status === "new"
@@ -55,18 +53,20 @@ export function FormEnhanceAction({
55
53
  // const enoughData = countStringCharacters(deferredValues, collection.properties) > 20;
56
54
 
57
55
  useEffect(() => {
56
+ if (!dataEnhancementController) return;
58
57
  if (!samplePrompts) {
59
58
  setSamplePrompts(getRecentPromptsFromStorage(storageKey));
60
59
  updateSuggestedPrompts().then();
61
60
  }
62
- }, [samplePrompts, storageKey, updateSuggestedPrompts, instructions, status]);
61
+ }, [dataEnhancementController, samplePrompts, storageKey, updateSuggestedPrompts, instructions, status]);
63
62
 
64
63
  useEffect(() => {
64
+ if (!dataEnhancementController) return;
65
65
  updateSuggestedPrompts().then();
66
- }, [status]);
66
+ }, [dataEnhancementController, status]);
67
67
 
68
68
  const enhance = (prompt?: string) => {
69
- if (!formContext?.values) return;
69
+ if (!dataEnhancementController || !formContext?.values) return;
70
70
  setLoading(true);
71
71
  if (prompt) {
72
72
  addRecentPrompt(storageKey, prompt);
@@ -88,6 +88,7 @@ export function FormEnhanceAction({
88
88
  if (!dataEnhancementController?.enabled)
89
89
  return null;
90
90
 
91
+ const suggestions = dataEnhancementController.suggestions;
91
92
  const hasSuggestions = Object.values(suggestions).filter(Boolean).length > 0;
92
93
 
93
94
  const disabledSuggestionActions = !hasSuggestions;
@@ -222,7 +223,7 @@ function getPromptsForExistingEntities(properties: Properties): SamplePrompt[] {
222
223
  if (isPropertyBuilder(p)) {
223
224
  return false;
224
225
  }
225
- return p.type === "string" && (p.markdown || p.multiline);
226
+ return p.type === "string" && (p.ui?.markdown || p.ui?.multiline);
226
227
  });
227
228
 
228
229
  const multilinePrompt: Property | undefined = multilineProperties.length > 0
@@ -31,7 +31,7 @@ function getSimpleProperty(property: Property): InputProperty {
31
31
  enum: "enum" in property && property.enum
32
32
  ? getSimpleEnumValues(property.enum)
33
33
  : undefined,
34
- disabled: Boolean(property.disabled || property.readOnly)
34
+ disabled: Boolean(property.ui?.disabled || property.ui?.readOnly)
35
35
  };
36
36
  }
37
37
 
@@ -45,7 +45,7 @@ function getSimplifiedProperty(property: Property, path: string, value?: any): R
45
45
  description: property.description,
46
46
  type: property.type,
47
47
  fieldConfigId: "repeat",
48
- disabled: Boolean(property.disabled || property.readOnly),
48
+ disabled: Boolean(property.ui?.disabled || property.ui?.readOnly),
49
49
  of: getSimpleProperty(property.of as Property)
50
50
  };
51
51
 
@@ -77,7 +77,7 @@ function getSimplifiedProperty(property: Property, path: string, value?: any): R
77
77
  description: property.description,
78
78
  type: property.type,
79
79
  fieldConfigId: "block",
80
- disabled: Boolean(property.disabled || property.readOnly),
80
+ disabled: Boolean(property.ui?.disabled || property.ui?.readOnly),
81
81
  oneOf: {
82
82
  typeField: property.oneOf.typeField,
83
83
  valueField: property.oneOf.valueField,
@@ -128,7 +128,7 @@ function getSimplifiedProperty(property: Property, path: string, value?: any): R
128
128
  description: property.description,
129
129
  type: property.type,
130
130
  fieldConfigId: "group",
131
- disabled: Boolean(property.disabled || property.readOnly)
131
+ disabled: Boolean(property.ui?.disabled || property.ui?.readOnly)
132
132
  };
133
133
  return {
134
134
  [path]: mapParentProperty,
@@ -7,7 +7,7 @@ export function countStringCharacters(values: EntityValues<any>, properties: Pro
7
7
  const value = values[key];
8
8
  const property: Property = properties[key];
9
9
 
10
- if (property && !property.disabled) {
10
+ if (property && !property.ui?.disabled) {
11
11
  if (property.type === "string" || property.type === "number") {
12
12
  count += String(value).length;
13
13
  } else if (property.type === "array" && Array.isArray(value) && property.of && !Array.isArray(property.of) && property.of.type === "string") {