@firecms/core 3.3.0 → 3.4.0-canary.2575a08

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 (155) hide show
  1. package/dist/app/useApp.d.ts +1 -0
  2. package/dist/components/EntityCollectionTable/column_utils.d.ts +4 -3
  3. package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +6 -1
  4. package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +3 -1
  5. package/dist/components/EntityCollectionView/EntityCollectionBoardView.d.ts +3 -1
  6. package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +8 -0
  7. package/dist/components/EntityCollectionView/EntityCollectionViewActions.d.ts +3 -1
  8. package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +3 -1
  9. package/dist/components/EntityCollectionView/FiltersDialog.d.ts +2 -1
  10. package/dist/components/EntityCollectionView/useBoardDataController.d.ts +3 -1
  11. package/dist/components/EntityPreview.d.ts +3 -1
  12. package/dist/components/ReferenceTable/ReferenceSelectionTable.d.ts +10 -1
  13. package/dist/components/SelectableTable/filters/filter_text_input.d.ts +30 -0
  14. package/dist/components/SelectableTable/filters/filter_text_input.test.d.ts +1 -0
  15. package/dist/components/common/table_url_params.d.ts +24 -0
  16. package/dist/components/common/useDataSourceTableController.d.ts +9 -1
  17. package/dist/components/common/useTableSearchHelper.d.ts +9 -1
  18. package/dist/core/DefaultDrawer.d.ts +10 -3
  19. package/dist/core/EntityEditView.d.ts +9 -1
  20. package/dist/core/EntityEditViewFormActions.d.ts +1 -1
  21. package/dist/core/field_configs.d.ts +1 -1
  22. package/dist/form/EntityForm.d.ts +8 -1
  23. package/dist/form/EntityFormActions.d.ts +2 -0
  24. package/dist/form/field_bindings/GeopointFieldBinding.d.ts +5 -0
  25. package/dist/form/index.d.ts +1 -0
  26. package/dist/hooks/data/delete.d.ts +1 -1
  27. package/dist/hooks/data/save.d.ts +1 -1
  28. package/dist/hooks/data/useCollectionFetch.d.ts +7 -1
  29. package/dist/hooks/data/useEntityFetch.d.ts +9 -1
  30. package/dist/i18n/__tests__/FireCMSi18nProvider.test.d.ts +1 -0
  31. package/dist/i18n/__tests__/nested_provider_lifecycle.test.d.ts +1 -0
  32. package/dist/index.es.js +3658 -1820
  33. package/dist/index.es.js.map +1 -1
  34. package/dist/index.umd.js +3655 -1817
  35. package/dist/index.umd.js.map +1 -1
  36. package/dist/locales/pl.d.ts +2 -0
  37. package/dist/preview/index.d.ts +1 -0
  38. package/dist/preview/property_previews/GeopointPropertyPreview.d.ts +4 -0
  39. package/dist/types/collections.d.ts +31 -0
  40. package/dist/types/datasource.d.ts +67 -4
  41. package/dist/types/entities.d.ts +21 -1
  42. package/dist/types/entity_actions.d.ts +6 -0
  43. package/dist/types/entity_callbacks.d.ts +21 -0
  44. package/dist/types/navigation.d.ts +34 -5
  45. package/dist/types/plugins.d.ts +13 -0
  46. package/dist/types/properties.d.ts +17 -1
  47. package/dist/types/side_entity_controller.d.ts +7 -0
  48. package/dist/types/translations.d.ts +6 -0
  49. package/dist/util/__tests__/collections.test.d.ts +1 -0
  50. package/dist/util/__tests__/urls.test.d.ts +1 -0
  51. package/dist/util/collections.d.ts +1 -1
  52. package/dist/util/entities.d.ts +1 -0
  53. package/dist/util/entity_cache.d.ts +11 -0
  54. package/dist/util/geopoint.d.ts +22 -0
  55. package/dist/util/index.d.ts +2 -0
  56. package/dist/util/navigation_blocking.d.ts +22 -0
  57. package/dist/util/navigation_from_path.d.ts +17 -0
  58. package/dist/util/navigation_utils.d.ts +107 -3
  59. package/dist/util/parent_references_from_path.d.ts +16 -0
  60. package/dist/util/paths.d.ts +28 -0
  61. package/dist/util/permissions.d.ts +10 -4
  62. package/dist/util/urls.d.ts +22 -0
  63. package/package.json +17 -10
  64. package/src/app/Scaffold.tsx +34 -44
  65. package/src/app/useApp.tsx +1 -0
  66. package/src/components/DeleteEntityDialog.tsx +2 -0
  67. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +2 -2
  68. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +3 -1
  69. package/src/components/EntityCollectionTable/column_utils.tsx +11 -19
  70. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +1 -1
  71. package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +7 -0
  72. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +5 -1
  73. package/src/components/EntityCollectionView/EntityCollectionBoardView.tsx +12 -0
  74. package/src/components/EntityCollectionView/EntityCollectionView.tsx +66 -15
  75. package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +6 -2
  76. package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +8 -1
  77. package/src/components/EntityCollectionView/FiltersDialog.tsx +39 -28
  78. package/src/components/EntityCollectionView/useBoardDataController.tsx +17 -1
  79. package/src/components/EntityPreview.tsx +45 -41
  80. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +19 -2
  81. package/src/components/ReferenceWidget.tsx +1 -1
  82. package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +2 -2
  83. package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +33 -7
  84. package/src/components/SelectableTable/filters/filter_text_input.test.ts +184 -0
  85. package/src/components/SelectableTable/filters/filter_text_input.ts +71 -0
  86. package/src/components/VirtualTable/VirtualTable.tsx +19 -8
  87. package/src/components/common/default_entity_actions.tsx +22 -2
  88. package/src/components/common/table_url_params.ts +172 -0
  89. package/src/components/common/useDataSourceTableController.tsx +126 -163
  90. package/src/components/common/useTableSearchHelper.ts +26 -2
  91. package/src/contexts/SnackbarProvider.tsx +14 -1
  92. package/src/core/DefaultDrawer.tsx +150 -64
  93. package/src/core/DrawerNavigationGroup.tsx +27 -29
  94. package/src/core/DrawerNavigationItem.tsx +10 -12
  95. package/src/core/EntityEditView.tsx +77 -35
  96. package/src/core/EntityEditViewFormActions.tsx +3 -2
  97. package/src/core/EntitySidePanel.tsx +8 -4
  98. package/src/core/field_configs.tsx +15 -0
  99. package/src/form/EntityForm.tsx +31 -10
  100. package/src/form/EntityFormActions.tsx +2 -0
  101. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +1 -1
  102. package/src/form/field_bindings/GeopointFieldBinding.tsx +139 -0
  103. package/src/form/index.tsx +1 -0
  104. package/src/hooks/data/delete.ts +8 -0
  105. package/src/hooks/data/save.ts +6 -1
  106. package/src/hooks/data/useCollectionFetch.tsx +21 -1
  107. package/src/hooks/data/useEntityFetch.tsx +35 -4
  108. package/src/hooks/useBuildNavigationController.tsx +23 -8
  109. package/src/hooks/useResolvedNavigationFrom.tsx +3 -1
  110. package/src/hooks/useValidateAuthenticator.tsx +4 -0
  111. package/src/i18n/FireCMSi18nProvider.tsx +50 -4
  112. package/src/i18n/__tests__/FireCMSi18nProvider.test.tsx +91 -0
  113. package/src/i18n/__tests__/nested_provider_lifecycle.test.tsx +67 -0
  114. package/src/internal/useBuildDataSource.ts +37 -15
  115. package/src/internal/useBuildSideEntityController.tsx +20 -5
  116. package/src/locales/de.ts +7 -2
  117. package/src/locales/en.ts +7 -2
  118. package/src/locales/es.ts +7 -2
  119. package/src/locales/fr.ts +7 -2
  120. package/src/locales/hi.ts +7 -2
  121. package/src/locales/it.ts +7 -2
  122. package/src/locales/pl.ts +735 -0
  123. package/src/locales/pt.ts +7 -2
  124. package/src/preview/PropertyPreview.tsx +12 -0
  125. package/src/preview/components/ReferencePreview.tsx +7 -3
  126. package/src/preview/components/StorageThumbnail.tsx +24 -2
  127. package/src/preview/index.ts +1 -0
  128. package/src/preview/property_previews/GeopointPropertyPreview.tsx +23 -0
  129. package/src/routes/FireCMSRoute.tsx +54 -27
  130. package/src/types/collections.ts +34 -0
  131. package/src/types/datasource.ts +67 -4
  132. package/src/types/entities.ts +24 -1
  133. package/src/types/entity_actions.tsx +6 -0
  134. package/src/types/entity_callbacks.ts +24 -0
  135. package/src/types/navigation.ts +35 -5
  136. package/src/types/plugins.tsx +13 -0
  137. package/src/types/properties.ts +17 -0
  138. package/src/types/side_entity_controller.tsx +7 -0
  139. package/src/types/translations.ts +6 -0
  140. package/src/util/__tests__/collections.test.ts +32 -0
  141. package/src/util/__tests__/urls.test.ts +131 -0
  142. package/src/util/collections.ts +1 -1
  143. package/src/util/entities.ts +16 -1
  144. package/src/util/entity_cache.ts +18 -0
  145. package/src/util/geopoint.ts +81 -0
  146. package/src/util/index.ts +2 -0
  147. package/src/util/navigation_blocking.ts +45 -0
  148. package/src/util/navigation_from_path.ts +47 -7
  149. package/src/util/navigation_utils.ts +244 -4
  150. package/src/util/parent_references_from_path.ts +45 -4
  151. package/src/util/paths.ts +40 -3
  152. package/src/util/permissions.ts +22 -10
  153. package/src/util/previews.ts +8 -1
  154. package/src/util/resolutions.ts +8 -0
  155. package/src/util/urls.ts +52 -0
@@ -0,0 +1,2 @@
1
+ import { FireCMSTranslations } from "../types/translations";
2
+ export declare const pl: FireCMSTranslations;
@@ -4,6 +4,7 @@ export * from "./property_previews/ArrayOfStringsPreview";
4
4
  export * from "./property_previews/ArrayPropertyEnumPreview";
5
5
  export * from "./property_previews/ArrayOfMapsPreview";
6
6
  export * from "./property_previews/NumberPropertyPreview";
7
+ export * from "./property_previews/GeopointPropertyPreview";
7
8
  export * from "./property_previews/StringPropertyPreview";
8
9
  export * from "./property_previews/ArrayOfStorageComponentsPreview";
9
10
  export * from "./property_previews/ArrayOfReferencesPreview";
@@ -0,0 +1,4 @@
1
+ import React from "react";
2
+ import { GeoPoint } from "../../types";
3
+ import { PropertyPreviewProps } from "../PropertyPreviewProps";
4
+ export declare function GeopointPropertyPreview({ value, size }: PropertyPreviewProps<GeoPoint>): React.ReactElement;
@@ -87,6 +87,13 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
87
87
  * If not specified, the first property simple text property will be used.
88
88
  */
89
89
  titleProperty?: keyof M;
90
+ /**
91
+ * Property used as the image thumbnail in Cards and Kanban view modes.
92
+ * Must reference a storage/image property (or an array of them), or a
93
+ * string property with `url: "image"`.
94
+ * If not specified, the first matching image property will be used.
95
+ */
96
+ imageProperty?: keyof M;
90
97
  /**
91
98
  * When editing an entity, you can choose to open the entity in a side dialog
92
99
  * or in a full screen dialog. Defaults to `full_screen`.
@@ -232,6 +239,21 @@ export interface EntityCollection<M extends Record<string, any> = any, USER exte
232
239
  * e.g. `initialFilter: { related_user: ["==", new EntityReference("sdc43dsw2", "users")] }`
233
240
  */
234
241
  initialFilter?: FilterValues<Extract<keyof M, string>>;
242
+ /**
243
+ * Array of property keys that are allowed for filtering. Allowed filters will be displayed in the collection view, table row headers
244
+ * and will be used to filter data.
245
+ *
246
+ * If not specified, all properties that are filterable will be allowed.
247
+ *
248
+ * If you specify this prop, the filters will be displayed in the collection view if they are filterable.
249
+ *
250
+ * If you set it as an empty array, no filters will be displayed.
251
+ *
252
+ * e.g. `allowedFilters: ["name", "category"]`
253
+ *
254
+ * e.g. `allowedFilters: []`
255
+ */
256
+ allowedFilters?: (keyof M)[];
235
257
  /**
236
258
  * Default sort applied to this collection.
237
259
  * When setting this prop, entities will have a default order
@@ -417,6 +439,13 @@ export interface CollectionActionsProps<M extends Record<string, any> = any, USE
417
439
  * `users/1234/addresses`
418
440
  */
419
441
  path: string;
442
+ /**
443
+ * `path` split at its real segment boundaries, e.g. `["nodes", "node/42", "edges"]`.
444
+ *
445
+ * Optional, and never derived by splitting `path` — a parent entity id may itself
446
+ * contain "/". Absent means "not known here", not "no slashes".
447
+ */
448
+ pathSegments?: string[];
420
449
  /**
421
450
  * Path of the last collection, like `addresses`
422
451
  */
@@ -621,6 +650,8 @@ export type EntityTableController<M extends Record<string, any> = any> = {
621
650
  dataLoadingError?: Error;
622
651
  filterValues?: FilterValues<Extract<keyof M, string>>;
623
652
  setFilterValues?: (filterValues: FilterValues<Extract<keyof M, string>>) => void;
653
+ allowedFilters?: (keyof M)[];
654
+ forcedFilters?: (keyof M)[];
624
655
  sortBy?: [Extract<keyof M, string>, "asc" | "desc"];
625
656
  setSortBy?: (sortBy?: [Extract<keyof M, string>, "asc" | "desc"]) => void;
626
657
  searchString?: string;
@@ -7,6 +7,20 @@ import { FireCMSContext } from "./firecms_context";
7
7
  */
8
8
  export interface FetchEntityProps<M extends Record<string, any> = any> {
9
9
  path: string;
10
+ /**
11
+ * The path split at its real segment boundaries, e.g.
12
+ * `["nodes", "node/42", "edges"]`.
13
+ *
14
+ * `path` is a single flattened string, so a parent entity id containing "/" cannot be
15
+ * recovered from it — `"nodes/node/42/edges"` is indistinguishable from a three-level
16
+ * nesting. This is the unambiguous form: one array element per segment, entity ids
17
+ * kept whole however many slashes they contain.
18
+ *
19
+ * For any backend whose ids cannot contain "/" this is exactly `path.split("/")`, so
20
+ * delegates that do not care can keep using `path`. Delegates that do should prefer
21
+ * `pathSegments ?? path.split("/")`.
22
+ */
23
+ pathSegments?: string[];
10
24
  entityId: string;
11
25
  databaseId?: string;
12
26
  collection?: EntityCollection<M, any>;
@@ -23,6 +37,20 @@ export type ListenEntityProps<M extends Record<string, any> = any> = FetchEntity
23
37
  */
24
38
  export interface FetchCollectionProps<M extends Record<string, any> = any> {
25
39
  path: string;
40
+ /**
41
+ * The path split at its real segment boundaries, e.g.
42
+ * `["nodes", "node/42", "edges"]`.
43
+ *
44
+ * `path` is a single flattened string, so a parent entity id containing "/" cannot be
45
+ * recovered from it — `"nodes/node/42/edges"` is indistinguishable from a three-level
46
+ * nesting. This is the unambiguous form: one array element per segment, entity ids
47
+ * kept whole however many slashes they contain.
48
+ *
49
+ * For any backend whose ids cannot contain "/" this is exactly `path.split("/")`, so
50
+ * delegates that do not care can keep using `path`. Delegates that do should prefer
51
+ * `pathSegments ?? path.split("/")`.
52
+ */
53
+ pathSegments?: string[];
26
54
  collection?: EntityCollection<M> | ResolvedEntityCollection<M>;
27
55
  filter?: FilterValues<Extract<keyof M, string>>;
28
56
  limit?: number;
@@ -43,6 +71,20 @@ export type ListenCollectionProps<M extends Record<string, any> = any> = FetchCo
43
71
  */
44
72
  export interface SaveEntityProps<M extends Record<string, any> = any> {
45
73
  path: string;
74
+ /**
75
+ * The path split at its real segment boundaries, e.g.
76
+ * `["nodes", "node/42", "edges"]`.
77
+ *
78
+ * `path` is a single flattened string, so a parent entity id containing "/" cannot be
79
+ * recovered from it — `"nodes/node/42/edges"` is indistinguishable from a three-level
80
+ * nesting. This is the unambiguous form: one array element per segment, entity ids
81
+ * kept whole however many slashes they contain.
82
+ *
83
+ * For any backend whose ids cannot contain "/" this is exactly `path.split("/")`, so
84
+ * delegates that do not care can keep using `path`. Delegates that do should prefer
85
+ * `pathSegments ?? path.split("/")`.
86
+ */
87
+ pathSegments?: string[];
46
88
  values: Partial<EntityValues<M>>;
47
89
  entityId?: string;
48
90
  previousValues?: Partial<EntityValues<M>>;
@@ -54,6 +96,11 @@ export interface SaveEntityProps<M extends Record<string, any> = any> {
54
96
  */
55
97
  export interface DeleteEntityProps<M extends Record<string, any> = any> {
56
98
  entity: Entity<M>;
99
+ /**
100
+ * `entity.path` split at its real segment boundaries, when the caller knows them.
101
+ * Never derived from `entity.path` — see `pathSegments` on FetchCollectionProps.
102
+ */
103
+ pathSegments?: string[];
57
104
  collection?: EntityCollection<M> | ResolvedEntityCollection<M>;
58
105
  }
59
106
  /**
@@ -133,11 +180,17 @@ export interface DataSource {
133
180
  * @param entityId
134
181
  * @return `true` if there are no other fields besides the given entity
135
182
  */
136
- checkUniqueField(path: string, name: string, value: any, entityId?: string, collection?: EntityCollection): Promise<boolean>;
183
+ checkUniqueField(path: string, name: string, value: any, entityId?: string, collection?: EntityCollection,
184
+ /**
185
+ * Appended last, and optional, so existing implementations and callers keep
186
+ * working unchanged — a function declaring fewer parameters stays assignable.
187
+ * See `pathSegments` on FetchCollectionProps.
188
+ */
189
+ pathSegments?: string[]): Promise<boolean>;
137
190
  /**
138
191
  * Generate an id for a new entity
139
192
  */
140
- generateEntityId(path: string, collection: EntityCollection): string;
193
+ generateEntityId(path: string, collection: EntityCollection, pathSegments?: string[]): string;
141
194
  /**
142
195
  * Count the number of entities in a collection
143
196
  */
@@ -155,11 +208,17 @@ export interface DataSource {
155
208
  initTextSearch?: (props: {
156
209
  context: FireCMSContext;
157
210
  path: string;
211
+ /**
212
+ * `path` split at its real segment boundaries, when known. Never derived from `path`.
213
+ */
214
+ pathSegments?: string[];
158
215
  collection: EntityCollection;
159
216
  parentCollectionIds?: string[];
160
217
  }) => Promise<boolean>;
161
218
  }
162
219
  export type FilterCombinationValidProps = {
220
+ /** `path` split at its real segment boundaries — see `pathSegments` on FetchCollectionProps. */
221
+ pathSegments?: string[];
163
222
  path: string;
164
223
  collection: EntityCollection<any>;
165
224
  filterValues: FilterValues<any>;
@@ -245,11 +304,11 @@ export interface DataSourceDelegate {
245
304
  * @param collection
246
305
  * @return `true` if there are no other fields besides the given entity
247
306
  */
248
- checkUniqueField(path: string, name: string, value: any, entityId?: string, collection?: EntityCollection): Promise<boolean>;
307
+ checkUniqueField(path: string, name: string, value: any, entityId?: string, collection?: EntityCollection, pathSegments?: string[]): Promise<boolean>;
249
308
  /**
250
309
  * Generate an id for a new entity
251
310
  */
252
- generateEntityId(path: string, collection?: EntityCollection): string;
311
+ generateEntityId(path: string, collection?: EntityCollection, pathSegments?: string[]): string;
253
312
  /**
254
313
  * Count the number of entities in a collection
255
314
  */
@@ -270,6 +329,10 @@ export interface DataSourceDelegate {
270
329
  initTextSearch?: (props: {
271
330
  context: FireCMSContext;
272
331
  path: string;
332
+ /**
333
+ * `path` split at its real segment boundaries, when known. Never derived from `path`.
334
+ */
335
+ pathSegments?: string[];
273
336
  databaseId?: string;
274
337
  collection: EntityCollection;
275
338
  parentCollectionIds?: string[];
@@ -17,6 +17,16 @@ export interface Entity<M extends object = any> {
17
17
  * to the root of the database).
18
18
  */
19
19
  path: string;
20
+ /**
21
+ * `path` split at its real segment boundaries, e.g. `["nodes", "node/42", "edges"]`.
22
+ *
23
+ * `path` is a single flattened string, so a parent entity id containing "/" cannot be
24
+ * recovered from it. This keeps each segment whole.
25
+ *
26
+ * Optional, and never derived by splitting `path` — a guess would be wrong in exactly
27
+ * the case the field exists for. Absent means "not known here", not "no slashes".
28
+ */
29
+ pathSegments?: string[];
20
30
  /**
21
31
  * Current values
22
32
  */
@@ -46,7 +56,17 @@ export declare class EntityReference {
46
56
  * Optional database ID where the entity is stored (if multiple databases are used)
47
57
  */
48
58
  readonly databaseId?: string;
49
- constructor(id: string, path: string, databaseId?: string);
59
+ /**
60
+ * `path` split at its real segment boundaries, e.g. `["nodes", "node/42", "edges"]`.
61
+ *
62
+ * `path` is a single flattened string, so a parent entity id containing "/" cannot be
63
+ * recovered from it. This keeps each segment whole.
64
+ *
65
+ * Optional, and never derived by splitting `path` — a guess would be wrong in exactly
66
+ * the case the field exists for. Absent means "not known here", not "no slashes".
67
+ */
68
+ readonly pathSegments?: string[];
69
+ constructor(id: string, path: string, databaseId?: string, pathSegments?: string[]);
50
70
  get pathWithId(): string;
51
71
  get pathWithIdAndDatabase(): string;
52
72
  isEntityReference(): boolean;
@@ -55,6 +55,12 @@ export type EntityActionClickProps<M extends object, USER extends User = User> =
55
55
  entity?: Entity<M>;
56
56
  context: FireCMSContext<USER>;
57
57
  fullPath?: string;
58
+ /**
59
+ * `fullPath` split at its real segment boundaries, e.g. `["nodes", "node/42", "edges"]`,
60
+ * when the caller knows them. Absent means "not known here" — never derived from
61
+ * `fullPath`, since a parent id may itself contain "/".
62
+ */
63
+ pathSegments?: string[];
58
64
  fullIdPath?: string;
59
65
  collection?: EntityCollection<M>;
60
66
  /**
@@ -69,6 +69,13 @@ export interface EntityOnFetchProps<M extends Record<string, any> = any, USER ex
69
69
  * Might contain unresolved aliases.
70
70
  */
71
71
  path: string;
72
+ /**
73
+ * `path` split at its real segment boundaries, e.g. `["nodes", "node/42", "edges"]`.
74
+ *
75
+ * Optional, and never derived by splitting `path` — a parent entity id may itself
76
+ * contain "/". Absent means "not known here", not "no slashes".
77
+ */
78
+ pathSegments?: string[];
72
79
  /**
73
80
  * Fetched entity
74
81
  */
@@ -106,6 +113,13 @@ export interface EntityOnSaveProps<M extends Record<string, any> = any, USER ext
106
113
  * Might contain unresolved aliases.
107
114
  */
108
115
  path: string;
116
+ /**
117
+ * `path` split at its real segment boundaries, e.g. `["nodes", "node/42", "edges"]`.
118
+ *
119
+ * Optional, and never derived by splitting `path` — a parent entity id may itself
120
+ * contain "/". Absent means "not known here", not "no slashes".
121
+ */
122
+ pathSegments?: string[];
109
123
  /**
110
124
  * Full path where this entity is being saved, with alias resolved
111
125
  */
@@ -144,6 +158,13 @@ export interface EntityOnDeleteProps<M extends Record<string, any> = any, USER e
144
158
  * Path of the parent collection
145
159
  */
146
160
  path: string;
161
+ /**
162
+ * `path` split at its real segment boundaries, e.g. `["nodes", "node/42", "edges"]`.
163
+ *
164
+ * Optional, and never derived by splitting `path` — a parent entity id may itself
165
+ * contain "/". Absent means "not known here", not "no slashes".
166
+ */
167
+ pathSegments?: string[];
147
168
  /**
148
169
  * Deleted entity id
149
170
  */
@@ -48,8 +48,12 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
48
48
  /**
49
49
  * Get the collection configuration for a given path.
50
50
  * The collection is resolved from the given path or alias.
51
+ *
52
+ * Pass `pathSegments` when you have them: without them the path is split on "/" and
53
+ * asserted to have an odd number of parts, which a chain containing a slash-bearing
54
+ * entity id fails — it throws instead of resolving.
51
55
  */
52
- getCollection: (pathOrId: string, includeUserOverride?: boolean) => EC | undefined;
56
+ getCollection: (pathOrId: string, includeUserOverride?: boolean, pathSegments?: string[]) => EC | undefined;
53
57
  /**
54
58
  * Get the top level collection configuration for a given id
55
59
  */
@@ -99,23 +103,48 @@ export type NavigationController<EC extends EntityCollection = EntityCollection<
99
103
  /**
100
104
  * Turn a path with collection ids into a resolved path.
101
105
  * The ids (typically used in urls) will be replaced with relative paths (typically used in database paths)
106
+ *
107
+ * Pass `pathSegments` whenever you have them. Without them this has to find the entity
108
+ * ids inside the flattened string by reading up to the next "/", which is wrong for any
109
+ * id that contains one — the chain then shifts by a segment and resolution fails.
110
+ *
102
111
  * @param pathWithAliases
112
+ * @param pathSegments `pathWithAliases` split at its real segment boundaries, if known
113
+ */
114
+ resolveIdsFrom: (pathWithAliases: string, pathSegments?: string[]) => string;
115
+ /**
116
+ * The segment-wise counterpart of {@link resolveIdsFrom}: replaces collection ids with
117
+ * their real paths while carrying every entity id through whole, slashes included.
118
+ *
119
+ * Idempotent — segments that are already resolved pass through unchanged.
120
+ *
121
+ * Optional so that a `navigationController` built against an earlier version keeps
122
+ * working: callers fall back to using the segments as given, which is what happened
123
+ * before this method existed. Controllers built by `useBuildNavigationController`
124
+ * always provide it.
125
+ *
126
+ * @param pathSegments
103
127
  */
104
- resolveIdsFrom: (pathWithAliases: string) => string;
128
+ resolveSegmentsFrom?: (pathSegments: string[]) => string[];
105
129
  /**
106
130
  * Call this method to recalculate the navigation
107
131
  */
108
132
  refreshNavigation: () => void;
109
133
  /**
110
- * Retrieve all the related parent references for a given path
134
+ * Retrieve all the related parent references for a given path.
135
+ *
136
+ * `path` is expected escaped, as it comes from the URL. Pass `pathSegments` when the
137
+ * path at hand is a raw datasource path, whose ids may contain a bare "/".
138
+ *
111
139
  * @param path
140
+ * @param pathSegments `path` split at its real segment boundaries, with raw ids
112
141
  */
113
- getParentReferencesFromPath: (path: string) => EntityReference[];
142
+ getParentReferencesFromPath: (path: string, pathSegments?: string[]) => EntityReference[];
114
143
  /**
115
144
  * Retrieve all the related parent collection ids for a given path
116
145
  * @param path
117
146
  */
118
- getParentCollectionIds: (path: string) => string[];
147
+ getParentCollectionIds: (path: string, pathSegments?: string[]) => string[];
119
148
  /**
120
149
  * Resolve paths from a list of ids
121
150
  * @param ids
@@ -121,18 +121,24 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
121
121
  blockSearch?: (props: {
122
122
  context: FireCMSContext;
123
123
  path: string;
124
+ /** `path` split at its real segment boundaries, when known. */
125
+ pathSegments?: string[];
124
126
  collection: EC;
125
127
  parentCollectionIds?: string[];
126
128
  }) => boolean;
127
129
  showTextSearchBar?: (props: {
128
130
  context: FireCMSContext;
129
131
  path: string;
132
+ /** `path` split at its real segment boundaries, when known. */
133
+ pathSegments?: string[];
130
134
  collection: EC;
131
135
  parentCollectionIds?: string[];
132
136
  }) => boolean;
133
137
  onTextSearchClick?: (props: {
134
138
  context: FireCMSContext;
135
139
  path: string;
140
+ /** `path` split at its real segment boundaries, when known. */
141
+ pathSegments?: string[];
136
142
  collection: EC;
137
143
  parentCollectionIds?: string[];
138
144
  }) => Promise<boolean>;
@@ -258,6 +264,13 @@ export interface PluginHomePageActionsProps<EP extends object = object, M extend
258
264
  export interface PluginFormActionProps<USER extends User = User, EC extends EntityCollection = EntityCollection> {
259
265
  entityId?: string;
260
266
  path: string;
267
+ /**
268
+ * `path` split at its real segment boundaries, e.g. `["nodes", "node/42", "edges"]`.
269
+ *
270
+ * Optional, and never derived by splitting `path` — a parent entity id may itself
271
+ * contain "/". Absent means "not known here", not "no slashes".
272
+ */
273
+ pathSegments?: string[];
261
274
  parentCollectionIds: string[];
262
275
  status: EntityStatus;
263
276
  collection: EC;
@@ -433,6 +433,22 @@ export type PropertyBuilderProps<M extends Record<string, any> = any> = {
433
433
  * Current value of this property
434
434
  */
435
435
  propertyValue?: any;
436
+ /**
437
+ * Path of this property within the entity, in dot notation, e.g.
438
+ * `my_map.my_field` or `my_array.0.my_field`.
439
+ * Useful to look up sibling values in `values` with `getValueInPath`.
440
+ *
441
+ * When a property builder is used as the `of` prop of an array property,
442
+ * it is resolved twice: once per existing element, with an index
443
+ * qualified key (`my_array.0`), and once as the template for the element
444
+ * shape, with the array's own key (`my_array`). In the latter case
445
+ * `propertyValue` is the whole array, since the template is not bound to
446
+ * any element.
447
+ *
448
+ * It may be undefined if the property is resolved outside the context of
449
+ * an entity.
450
+ */
451
+ propertyKey?: string;
436
452
  /**
437
453
  * Index of this property (only for arrays)
438
454
  */
@@ -456,7 +472,7 @@ export type PropertyBuilderProps<M extends Record<string, any> = any> = {
456
472
  * current value of the property, as well as the path and entity ID.
457
473
  * @group Entity properties
458
474
  */
459
- export type PropertyBuilder<T extends CMSType = any, M extends Record<string, any> = any> = ({ values, previousValues, propertyValue, index, path, entityId, authController }: PropertyBuilderProps<M>) => Property<T> | null;
475
+ export type PropertyBuilder<T extends CMSType = any, M extends Record<string, any> = any> = ({ values, previousValues, propertyValue, propertyKey, index, path, entityId, authController }: PropertyBuilderProps<M>) => Property<T> | null;
460
476
  /**
461
477
  * @group Entity properties
462
478
  */
@@ -15,6 +15,13 @@ export interface EntitySidePanelProps<M extends Record<string, any> = any> {
15
15
  * Full CMS path of the entity, including the collection and sub-collections.
16
16
  */
17
17
  fullIdPath?: string;
18
+ /**
19
+ * `path` split at its real segment boundaries, e.g. `["nodes", "node/42", "edges"]`.
20
+ *
21
+ * Optional, and never derived by splitting `path` — a guess would be wrong in exactly
22
+ * the case the field exists for. Absent means "not known here", not "no slashes".
23
+ */
24
+ pathSegments?: string[];
18
25
  /**
19
26
  * ID of the entity, if not set, it means we are creating a new entity
20
27
  */
@@ -368,6 +368,8 @@ export interface FireCMSTranslations {
368
368
  download: string;
369
369
  large_number_of_documents: string;
370
370
  include_undefined_values: string;
371
+ /** Toggle in the export dialog, only shown when a filter or sort is active */
372
+ export_apply_filter_sort: string;
371
373
  submit: string;
372
374
  no_filterable_properties: string;
373
375
  apply_filters: string;
@@ -547,6 +549,10 @@ export interface FireCMSTranslations {
547
549
  order_property_not_found: string;
548
550
  no_number_properties: string;
549
551
  order_property_description: string;
552
+ image_property: string;
553
+ image_property_not_found: string;
554
+ no_image_properties: string;
555
+ image_property_description: string;
550
556
  display_settings: string;
551
557
  default_row_size: string;
552
558
  side_dialog_width: string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -9,4 +9,4 @@ export declare function resolveDefaultSelectedView(defaultSelectedView: string |
9
9
  * @param permissionsBuilder
10
10
  */
11
11
  export declare const applyPermissionsFunctionIfEmpty: (collections: EntityCollection[], permissionsBuilder?: PermissionsBuilder<any, any>) => EntityCollection[];
12
- export declare function getLocalChangesBackup(collection: EntityCollection): "manual_apply" | "auto_apply";
12
+ export declare function getLocalChangesBackup(collection: EntityCollection): false | "manual_apply" | "auto_apply";
@@ -25,3 +25,4 @@ export declare function sanitizeData<M extends Record<string, any>>(values: Enti
25
25
  export declare function getReferenceFrom<M extends Record<string, any>>(entity: Entity<M>): EntityReference;
26
26
  export declare function traverseValuesProperties<M extends Record<string, any>>(inputValues: Partial<EntityValues<M>>, properties: ResolvedProperties<M>, operation: (value: any, property: Property) => any): EntityValues<M> | undefined;
27
27
  export declare function traverseValueProperty(inputValue: any, property: Property, operation: (value: any, property: Property) => any): any;
28
+ export declare function isDataTypeFilterable(dataType: DataType, isPartOfArray?: boolean): boolean;
@@ -1,3 +1,14 @@
1
+ /**
2
+ * Key identifying one entity in a cache.
3
+ *
4
+ * The id is escaped so that a `(path, entityId)` pair maps to exactly one key. Without it
5
+ * `("a", "b/c")` and `("a/b", "c")` both flatten to `"a/b/c"`, and one entity's cached
6
+ * values are served for the other.
7
+ *
8
+ * `encodeEntityId` is the identity for any id without "/", "?", "#" or "%", so this changes
9
+ * no key in an app whose ids cannot contain them.
10
+ */
11
+ export declare function entityCacheKey(path: string | undefined, entityId: string | undefined): string;
1
12
  /**
2
13
  * Saves data to the in-memory cache and persists it individually in `localStorage`.
3
14
  * @param path - The unique path/key for the data.
@@ -0,0 +1,22 @@
1
+ import { GeoPoint } from "../types";
2
+ export type GeoPointLike = GeoPoint | {
3
+ latitude?: number;
4
+ longitude?: number;
5
+ lat?: number;
6
+ lng?: number;
7
+ _lat?: number;
8
+ _long?: number;
9
+ } | null | undefined;
10
+ export interface GeoPointCoordinates {
11
+ latitude: number;
12
+ longitude: number;
13
+ }
14
+ export declare function getGeoPointCoordinates(value: GeoPointLike): GeoPointCoordinates | undefined;
15
+ export declare function normalizeGeoPoint(value: GeoPointLike): GeoPoint | undefined;
16
+ export declare function formatGeoPoint(value: GeoPointLike, options?: {
17
+ maximumFractionDigits?: number;
18
+ }): string;
19
+ export declare function parseGeoPoint(input: string): {
20
+ point: GeoPoint | null;
21
+ error?: string;
22
+ };
@@ -6,12 +6,14 @@ export * from "./enums";
6
6
  export * from "./objects";
7
7
  export * from "./paths";
8
8
  export * from "./regexp";
9
+ export * from "./urls";
9
10
  export * from "./navigation_utils";
10
11
  export * from "./entity_actions";
11
12
  export * from "./useDebouncedCallback";
12
13
  export * from "./property_utils";
13
14
  export * from "./resolutions";
14
15
  export * from "./permissions";
16
+ export * from "./geopoint";
15
17
  export * from "./icon_list";
16
18
  export * from "./icon_synonyms";
17
19
  export * from "./icons";
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Pure predicate deciding whether an in-progress navigation away from an open
3
+ * entity form should be blocked (to warn about unsaved changes).
4
+ *
5
+ * Extracted from FireCMSRoute so the branching can be unit-tested without
6
+ * mounting the router. This is an internal helper — it is intentionally not
7
+ * re-exported from the package index.
8
+ */
9
+ export interface NavigationBlockLocation {
10
+ pathname: string;
11
+ hash: string;
12
+ }
13
+ export declare function shouldBlockEntityNavigation(params: {
14
+ currentLocation: NavigationBlockLocation;
15
+ nextLocation: NavigationBlockLocation;
16
+ /** Path of the currently open entity (basePath + "/" + entityId). */
17
+ entityPath: string;
18
+ /** Collection path the entity form lives under. */
19
+ basePath: string;
20
+ /** Whether the form currently has unsaved modifications. */
21
+ blocked: boolean;
22
+ }): boolean;
@@ -6,6 +6,8 @@ export interface NavigationViewEntityInternal<M extends Record<string, any>> {
6
6
  path: string;
7
7
  fullIdPath: string;
8
8
  fullPath: string;
9
+ /** `path` split at its real boundaries — see `pathSegments` on the datasource props. */
10
+ pathSegments: string[];
9
11
  parentCollection: EntityCollection<M>;
10
12
  }
11
13
  export interface NavigationViewCollectionInternal<M extends Record<string, any>> {
@@ -14,6 +16,8 @@ export interface NavigationViewCollectionInternal<M extends Record<string, any>>
14
16
  path: string;
15
17
  fullIdPath: string;
16
18
  fullPath: string;
19
+ /** `path` split at its real boundaries — see `pathSegments` on the datasource props. */
20
+ pathSegments: string[];
17
21
  collection: EntityCollection<M>;
18
22
  }
19
23
  export interface NavigationViewEntityCustomInternal<M extends Record<string, any>> {
@@ -21,13 +25,26 @@ export interface NavigationViewEntityCustomInternal<M extends Record<string, any
21
25
  path: string;
22
26
  fullIdPath: string;
23
27
  fullPath: string;
28
+ /** `path` split at its real boundaries — see `pathSegments` on the datasource props. */
29
+ pathSegments: string[];
24
30
  entityId: string;
25
31
  view: EntityCustomView<M>;
26
32
  }
33
+ /**
34
+ * Note on encoding: `path` arrives from the URL, so any entity id in it is escaped (see
35
+ * `encodeEntityId`). Two chains are threaded through the recursion:
36
+ *
37
+ * - `currentFullPath` carries RAW ids and feeds the `path` / `fullPath` used to address
38
+ * the datasource.
39
+ * - `currentFullUrlPath` carries ESCAPED ids and feeds `fullPath`, which is handed back
40
+ * to `buildUrlCollectionPath` for breadcrumbs and links.
41
+ */
27
42
  export declare function getNavigationEntriesFromPath(props: {
28
43
  path: string;
29
44
  collections: EntityCollection[] | undefined;
30
45
  currentFullPath?: string;
31
46
  currentFullIdPath?: string;
47
+ currentFullUrlPath?: string;
48
+ currentPathSegments?: string[];
32
49
  contextEntityViews?: EntityCustomView<any>[];
33
50
  }): NavigationViewInternal[];