@firecms/core 3.3.0 → 3.4.0-canary.00f9be5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/app/useApp.d.ts +1 -0
- package/dist/components/EntityCollectionTable/column_utils.d.ts +4 -3
- package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +6 -1
- package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +3 -1
- package/dist/components/EntityCollectionView/EntityCollectionBoardView.d.ts +3 -1
- package/dist/components/EntityCollectionView/EntityCollectionView.d.ts +8 -0
- package/dist/components/EntityCollectionView/EntityCollectionViewActions.d.ts +3 -1
- package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +3 -1
- package/dist/components/EntityCollectionView/FiltersDialog.d.ts +2 -1
- package/dist/components/EntityCollectionView/useBoardDataController.d.ts +3 -1
- package/dist/components/EntityPreview.d.ts +3 -1
- package/dist/components/ErrorBoundary.d.ts +1 -3
- package/dist/components/LicenseBanner.d.ts +23 -0
- package/dist/components/ReferenceTable/ReferenceSelectionTable.d.ts +10 -1
- package/dist/components/SelectableTable/filters/filter_text_input.d.ts +30 -0
- package/dist/components/SelectableTable/filters/filter_text_input.test.d.ts +1 -0
- package/dist/components/common/table_url_params.d.ts +24 -0
- package/dist/components/common/useDataSourceTableController.d.ts +9 -1
- package/dist/components/common/useTableSearchHelper.d.ts +9 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/contexts/LicenseStatusContext.d.ts +16 -0
- package/dist/core/DefaultDrawer.d.ts +10 -3
- package/dist/core/EntityEditView.d.ts +9 -1
- package/dist/core/EntityEditViewFormActions.d.ts +1 -1
- package/dist/core/field_configs.d.ts +1 -1
- package/dist/core/index.d.ts +1 -0
- package/dist/core/plugin_translations.d.ts +38 -0
- package/dist/core/pro_plugins.d.ts +40 -0
- package/dist/de-BF5vcQPY.js +703 -0
- package/dist/de-BF5vcQPY.js.map +1 -0
- package/dist/editor/extensions/Image.d.ts +11 -0
- package/dist/editor/index.d.ts +2 -1
- package/dist/editor/lazy_editor.d.ts +6 -0
- package/dist/editor-BSo_aS1I.js +4563 -0
- package/dist/editor-BSo_aS1I.js.map +1 -0
- package/dist/form/EntityForm.d.ts +8 -1
- package/dist/form/EntityFormActions.d.ts +2 -0
- package/dist/form/field_bindings/GeopointFieldBinding.d.ts +5 -0
- package/dist/form/index.d.ts +1 -0
- package/dist/fr-DH9_wyFI.js +703 -0
- package/dist/fr-DH9_wyFI.js.map +1 -0
- package/dist/hi-BM8dm1Lu.js +703 -0
- package/dist/hi-BM8dm1Lu.js.map +1 -0
- package/dist/hooks/data/delete.d.ts +1 -1
- package/dist/hooks/data/save.d.ts +1 -1
- package/dist/hooks/data/useCollectionFetch.d.ts +7 -1
- package/dist/hooks/data/useEntityFetch.d.ts +9 -1
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/useLicenseStatus.d.ts +16 -0
- package/dist/hooks/useProjectLog.d.ts +11 -6
- package/dist/hooks/useTranslation.d.ts +1 -1
- package/dist/i18n/__tests__/FireCMSi18nProvider.test.d.ts +1 -0
- package/dist/i18n/__tests__/nested_provider_lifecycle.test.d.ts +1 -0
- package/dist/index.es.js +4516 -10668
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +9403 -6774
- package/dist/index.umd.js.map +1 -1
- package/dist/it-D3K1gfe4.js +703 -0
- package/dist/it-D3K1gfe4.js.map +1 -0
- package/dist/locales/pl.d.ts +2 -0
- package/dist/pl-CP1zeLzn.js +705 -0
- package/dist/pl-CP1zeLzn.js.map +1 -0
- package/dist/preview/index.d.ts +1 -0
- package/dist/preview/property_previews/GeopointPropertyPreview.d.ts +4 -0
- package/dist/pt-Cus7eKQR.js +705 -0
- package/dist/pt-Cus7eKQR.js.map +1 -0
- package/dist/types/analytics.d.ts +1 -1
- package/dist/types/collections.d.ts +31 -0
- package/dist/types/datasource.d.ts +67 -4
- package/dist/types/entities.d.ts +21 -1
- package/dist/types/entity_actions.d.ts +6 -0
- package/dist/types/entity_callbacks.d.ts +21 -0
- package/dist/types/firecms.d.ts +18 -1
- package/dist/types/firecms_context.d.ts +8 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/license.d.ts +55 -0
- package/dist/types/navigation.d.ts +34 -5
- package/dist/types/plugins.d.ts +22 -1
- package/dist/types/properties.d.ts +17 -1
- package/dist/types/side_entity_controller.d.ts +7 -0
- package/dist/types/translations.d.ts +43 -2
- package/dist/util/__tests__/collections.test.d.ts +1 -0
- package/dist/util/__tests__/urls.test.d.ts +1 -0
- package/dist/util/collections.d.ts +1 -1
- package/dist/util/date_fns_locales.d.ts +18 -0
- package/dist/util/entities.d.ts +1 -0
- package/dist/util/entity_cache.d.ts +11 -0
- package/dist/util/geopoint.d.ts +22 -0
- package/dist/util/index.d.ts +3 -0
- package/dist/util/lazy_eager.d.ts +3 -3
- package/dist/util/navigation_blocking.d.ts +22 -0
- package/dist/util/navigation_from_path.d.ts +17 -0
- package/dist/util/navigation_utils.d.ts +107 -3
- package/dist/util/parent_references_from_path.d.ts +16 -0
- package/dist/util/paths.d.ts +28 -0
- package/dist/util/permissions.d.ts +10 -4
- package/dist/util/urls.d.ts +22 -0
- package/package.json +17 -11
- package/src/app/Scaffold.tsx +41 -44
- package/src/app/useApp.tsx +1 -0
- package/src/components/DeleteEntityDialog.tsx +2 -0
- package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +2 -2
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +3 -1
- package/src/components/EntityCollectionTable/column_utils.tsx +11 -19
- package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +1 -1
- package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +7 -0
- package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +5 -1
- package/src/components/EntityCollectionView/EntityCollectionBoardView.tsx +12 -0
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +66 -15
- package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +6 -2
- package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +8 -1
- package/src/components/EntityCollectionView/FiltersDialog.tsx +39 -28
- package/src/components/EntityCollectionView/useBoardDataController.tsx +17 -1
- package/src/components/EntityPreview.tsx +45 -41
- package/src/components/ErrorBoundary.tsx +12 -18
- package/src/components/LicenseBanner.tsx +207 -0
- package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +19 -2
- package/src/components/ReferenceWidget.tsx +1 -1
- package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +2 -2
- package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +33 -7
- package/src/components/SelectableTable/filters/filter_text_input.test.ts +184 -0
- package/src/components/SelectableTable/filters/filter_text_input.ts +71 -0
- package/src/components/VirtualTable/VirtualTable.tsx +19 -8
- package/src/components/common/default_entity_actions.tsx +22 -2
- package/src/components/common/table_url_params.ts +172 -0
- package/src/components/common/useDataSourceTableController.tsx +126 -163
- package/src/components/common/useTableSearchHelper.ts +26 -2
- package/src/components/index.tsx +1 -0
- package/src/contexts/LicenseStatusContext.tsx +50 -0
- package/src/contexts/SnackbarProvider.tsx +14 -1
- package/src/core/DefaultAppBar.tsx +28 -16
- package/src/core/DefaultDrawer.tsx +150 -64
- package/src/core/DrawerNavigationGroup.tsx +27 -29
- package/src/core/DrawerNavigationItem.tsx +10 -12
- package/src/core/EntityEditView.tsx +77 -35
- package/src/core/EntityEditViewFormActions.tsx +3 -2
- package/src/core/EntitySidePanel.tsx +8 -4
- package/src/core/FireCMS.tsx +73 -47
- package/src/core/SideDialogs.tsx +44 -1
- package/src/core/field_configs.tsx +15 -0
- package/src/core/index.tsx +1 -0
- package/src/core/plugin_translations.ts +87 -0
- package/src/core/pro_plugins.ts +79 -0
- package/src/editor/components/SlashCommandMenu.tsx +4 -1
- package/src/editor/extensions/Image.ts +17 -1
- package/src/editor/hooks/useProseMirror.ts +5 -0
- package/src/editor/index.ts +11 -1
- package/src/editor/lazy_editor.tsx +33 -0
- package/src/form/EntityForm.tsx +31 -10
- package/src/form/EntityFormActions.tsx +2 -0
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +1 -1
- package/src/form/field_bindings/GeopointFieldBinding.tsx +139 -0
- package/src/form/index.tsx +1 -0
- package/src/hooks/data/delete.ts +8 -0
- package/src/hooks/data/save.ts +6 -1
- package/src/hooks/data/useCollectionFetch.tsx +21 -1
- package/src/hooks/data/useEntityFetch.tsx +35 -4
- package/src/hooks/index.tsx +2 -0
- package/src/hooks/useBuildNavigationController.tsx +70 -15
- package/src/hooks/useFireCMSContext.tsx +7 -3
- package/src/hooks/useLicenseStatus.tsx +32 -0
- package/src/hooks/useProjectLog.tsx +27 -9
- package/src/hooks/useResolvedNavigationFrom.tsx +3 -1
- package/src/hooks/useTranslation.ts +3 -1
- package/src/hooks/useValidateAuthenticator.tsx +4 -0
- package/src/i18n/FireCMSi18nProvider.tsx +199 -23
- package/src/i18n/__tests__/FireCMSi18nProvider.test.tsx +91 -0
- package/src/i18n/__tests__/nested_provider_lifecycle.test.tsx +67 -0
- package/src/internal/useBuildDataSource.ts +37 -15
- package/src/internal/useBuildSideEntityController.tsx +20 -5
- package/src/locales/de.ts +26 -4
- package/src/locales/en.ts +30 -6
- package/src/locales/es.ts +26 -4
- package/src/locales/fr.ts +26 -4
- package/src/locales/hi.ts +26 -4
- package/src/locales/it.ts +26 -4
- package/src/locales/pl.ts +752 -0
- package/src/locales/pt.ts +26 -4
- package/src/preview/PropertyPreview.tsx +12 -0
- package/src/preview/components/DatePreview.tsx +2 -4
- package/src/preview/components/ReferencePreview.tsx +7 -3
- package/src/preview/components/StorageThumbnail.tsx +24 -2
- package/src/preview/index.ts +1 -0
- package/src/preview/property_previews/GeopointPropertyPreview.tsx +23 -0
- package/src/routes/FireCMSRoute.tsx +54 -27
- package/src/types/analytics.ts +3 -0
- package/src/types/collections.ts +34 -0
- package/src/types/datasource.ts +67 -4
- package/src/types/entities.ts +24 -1
- package/src/types/entity_actions.tsx +6 -0
- package/src/types/entity_callbacks.ts +24 -0
- package/src/types/firecms.tsx +19 -1
- package/src/types/firecms_context.tsx +9 -0
- package/src/types/index.ts +1 -0
- package/src/types/license.ts +63 -0
- package/src/types/navigation.ts +35 -5
- package/src/types/plugins.tsx +23 -1
- package/src/types/properties.ts +17 -0
- package/src/types/side_entity_controller.tsx +7 -0
- package/src/types/translations.ts +43 -2
- package/src/util/__tests__/collections.test.ts +32 -0
- package/src/util/__tests__/urls.test.ts +131 -0
- package/src/util/collections.ts +1 -1
- package/src/util/date_fns_locales.ts +168 -0
- package/src/util/entities.ts +16 -1
- package/src/util/entity_cache.ts +18 -0
- package/src/util/geopoint.ts +81 -0
- package/src/util/index.ts +3 -0
- package/src/util/lazy_eager.tsx +30 -8
- package/src/util/navigation_blocking.ts +45 -0
- package/src/util/navigation_from_path.ts +47 -7
- package/src/util/navigation_utils.ts +250 -5
- package/src/util/parent_references_from_path.ts +45 -4
- package/src/util/paths.ts +40 -3
- package/src/util/permissions.ts +22 -10
- package/src/util/previews.ts +8 -1
- package/src/util/resolutions.ts +8 -0
- package/src/util/urls.ts +52 -0
- package/src/util/useStorageUploadController.tsx +6 -1
|
@@ -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
|
-
|
|
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
|
package/dist/types/plugins.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ import { InternalUserManagement } from "./internal_user_management";
|
|
|
13
13
|
* NOTE: This is a work in progress and the API is not stable yet.
|
|
14
14
|
* @group Core
|
|
15
15
|
*/
|
|
16
|
+
/** The strings a plugin contributes for one locale. */
|
|
17
|
+
export type PluginTranslations = Record<string, string>;
|
|
16
18
|
export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollection = EntityCollection, COL_ACTIONS_PROPS = any, COL_ACTIONS_START__PROPS = any> = {
|
|
17
19
|
/**
|
|
18
20
|
* Key of the plugin. This is used to identify the plugin in the CMS.
|
|
@@ -28,8 +30,14 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
|
|
|
28
30
|
* locales, specific for this plugin.
|
|
29
31
|
* Keys can be existing `FireCMSTranslations` keys, or new keys if using
|
|
30
32
|
* module augmentation.
|
|
33
|
+
*
|
|
34
|
+
* A value may be the strings themselves, or a function returning a promise
|
|
35
|
+
* of them. Use the function form for locales you ship in the plugin bundle:
|
|
36
|
+
* only the active language is ever read, so importing all of them statically
|
|
37
|
+
* puts every language into the bundle of every app that mounts the plugin.
|
|
38
|
+
* Both forms are supported; a plain record keeps working unchanged.
|
|
31
39
|
*/
|
|
32
|
-
i18n?: Record<string,
|
|
40
|
+
i18n?: Record<string, PluginTranslations | (() => Promise<PluginTranslations>)>;
|
|
33
41
|
/**
|
|
34
42
|
* You can use this prop to add higher order components to the CMS.
|
|
35
43
|
* The components will be added to the root of the CMS, so any component
|
|
@@ -121,18 +129,24 @@ export type FireCMSPlugin<PROPS = any, FORM_PROPS = any, EC extends EntityCollec
|
|
|
121
129
|
blockSearch?: (props: {
|
|
122
130
|
context: FireCMSContext;
|
|
123
131
|
path: string;
|
|
132
|
+
/** `path` split at its real segment boundaries, when known. */
|
|
133
|
+
pathSegments?: string[];
|
|
124
134
|
collection: EC;
|
|
125
135
|
parentCollectionIds?: string[];
|
|
126
136
|
}) => boolean;
|
|
127
137
|
showTextSearchBar?: (props: {
|
|
128
138
|
context: FireCMSContext;
|
|
129
139
|
path: string;
|
|
140
|
+
/** `path` split at its real segment boundaries, when known. */
|
|
141
|
+
pathSegments?: string[];
|
|
130
142
|
collection: EC;
|
|
131
143
|
parentCollectionIds?: string[];
|
|
132
144
|
}) => boolean;
|
|
133
145
|
onTextSearchClick?: (props: {
|
|
134
146
|
context: FireCMSContext;
|
|
135
147
|
path: string;
|
|
148
|
+
/** `path` split at its real segment boundaries, when known. */
|
|
149
|
+
pathSegments?: string[];
|
|
136
150
|
collection: EC;
|
|
137
151
|
parentCollectionIds?: string[];
|
|
138
152
|
}) => Promise<boolean>;
|
|
@@ -258,6 +272,13 @@ export interface PluginHomePageActionsProps<EP extends object = object, M extend
|
|
|
258
272
|
export interface PluginFormActionProps<USER extends User = User, EC extends EntityCollection = EntityCollection> {
|
|
259
273
|
entityId?: string;
|
|
260
274
|
path: string;
|
|
275
|
+
/**
|
|
276
|
+
* `path` split at its real segment boundaries, e.g. `["nodes", "node/42", "edges"]`.
|
|
277
|
+
*
|
|
278
|
+
* Optional, and never derived by splitting `path` — a parent entity id may itself
|
|
279
|
+
* contain "/". Absent means "not known here", not "no slashes".
|
|
280
|
+
*/
|
|
281
|
+
pathSegments?: string[];
|
|
261
282
|
parentCollectionIds: string[];
|
|
262
283
|
status: EntityStatus;
|
|
263
284
|
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
|
*/
|
|
@@ -56,8 +56,32 @@ export interface FireCMSTranslations {
|
|
|
56
56
|
select_from: string;
|
|
57
57
|
done: string;
|
|
58
58
|
log_out: string;
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
/** License banner during the PRO trial. `{{days}}` is the number of days left; plural form. */
|
|
60
|
+
license_trial_banner: string;
|
|
61
|
+
/** `license_trial_banner` when one day is left (i18next `_one` plural form). */
|
|
62
|
+
license_trial_banner_one: string;
|
|
63
|
+
/** License banner once the trial has ended. `{{date}}` is the day it ended. */
|
|
64
|
+
license_expired_banner: string;
|
|
65
|
+
/** `license_expired_banner` when the end date is not known. */
|
|
66
|
+
license_expired_banner_undated: string;
|
|
67
|
+
/** License banner when the license key is not linked to this project. `{{projectId}}` is the Firebase project id. */
|
|
68
|
+
license_invalid_project_banner: string;
|
|
69
|
+
/** `license_invalid_project_banner` when the project id is not known. */
|
|
70
|
+
license_invalid_project_banner_unnamed: string;
|
|
71
|
+
/** License banner when more projects are linked than the license covers. `{{licensed}}` covered, `{{actual}}` linked; plural form. */
|
|
72
|
+
license_over_quota_banner: string;
|
|
73
|
+
/** `license_over_quota_banner` when the license covers one project (i18next `_one` plural form). */
|
|
74
|
+
license_over_quota_banner_one: string;
|
|
75
|
+
/** Link in the license banner to buy a license. */
|
|
76
|
+
license_get_license: string;
|
|
77
|
+
/** Link in the over-quota banner to the license settings. */
|
|
78
|
+
license_update_license: string;
|
|
79
|
+
/** Link in the invalid-project banner to link this project to the license. */
|
|
80
|
+
license_add_project_to_license: string;
|
|
81
|
+
/** Title of the notice a PRO view shows while PRO features are paused. */
|
|
82
|
+
pro_features_paused: string;
|
|
83
|
+
/** Users and Roles views while PRO features are paused. */
|
|
84
|
+
user_management_paused_description: string;
|
|
61
85
|
column_cannot_be_edited: string;
|
|
62
86
|
close: string;
|
|
63
87
|
unsaved_local_changes: string;
|
|
@@ -368,6 +392,14 @@ export interface FireCMSTranslations {
|
|
|
368
392
|
download: string;
|
|
369
393
|
large_number_of_documents: string;
|
|
370
394
|
include_undefined_values: string;
|
|
395
|
+
/** Toggle in the export dialog, only shown when a filter or sort is active */
|
|
396
|
+
export_apply_filter_sort: string;
|
|
397
|
+
/** Choice in the export dialog, only shown when entities are selected */
|
|
398
|
+
export_all_entities: string;
|
|
399
|
+
/** Same choice; `{{count}}` is the number of selected entities */
|
|
400
|
+
export_selected_entities: string;
|
|
401
|
+
/** Shown in the export dialog when the export fails; `{{message}}` is the error's message */
|
|
402
|
+
export_error: string;
|
|
371
403
|
submit: string;
|
|
372
404
|
no_filterable_properties: string;
|
|
373
405
|
apply_filters: string;
|
|
@@ -413,6 +445,8 @@ export interface FireCMSTranslations {
|
|
|
413
445
|
roles_menu: string;
|
|
414
446
|
project_settings: string;
|
|
415
447
|
firestore_manager: string;
|
|
448
|
+
/** The DataTalk product name, keyed so a locale can transliterate it. */
|
|
449
|
+
datatalk: string;
|
|
416
450
|
manage_your_firestore_data: string;
|
|
417
451
|
build_admin_panel_in_minutes: string;
|
|
418
452
|
go_live_instantly: string;
|
|
@@ -427,6 +461,7 @@ export interface FireCMSTranslations {
|
|
|
427
461
|
not_the_admin_panel: string;
|
|
428
462
|
join_our_newsletter: string;
|
|
429
463
|
by_signing_in_you_agree_to_our: string;
|
|
464
|
+
please_accept_the_terms_to_continue: string;
|
|
430
465
|
terms_and_conditions: string;
|
|
431
466
|
and_our: string;
|
|
432
467
|
privacy_policy: string;
|
|
@@ -465,6 +500,8 @@ export interface FireCMSTranslations {
|
|
|
465
500
|
licensed_projects_lowercase: string;
|
|
466
501
|
manage: string;
|
|
467
502
|
update_payment_method: string;
|
|
503
|
+
/** Snackbar when a Stripe billing portal link can't be created. `{{message}}` is the reason. */
|
|
504
|
+
stripe_portal_error: string;
|
|
468
505
|
your_firecms_cloud_projects: string;
|
|
469
506
|
status_active: string;
|
|
470
507
|
status_trialing: string;
|
|
@@ -547,6 +584,10 @@ export interface FireCMSTranslations {
|
|
|
547
584
|
order_property_not_found: string;
|
|
548
585
|
no_number_properties: string;
|
|
549
586
|
order_property_description: string;
|
|
587
|
+
image_property: string;
|
|
588
|
+
image_property_not_found: string;
|
|
589
|
+
no_image_properties: string;
|
|
590
|
+
image_property_description: string;
|
|
550
591
|
display_settings: string;
|
|
551
592
|
default_row_size: string;
|
|
552
593
|
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";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Locale as DateFnsLocale } from "date-fns";
|
|
2
|
+
import { Locale } from "../types";
|
|
3
|
+
/**
|
|
4
|
+
* Load a date-fns locale, resolving from cache when it is already in memory.
|
|
5
|
+
* Concurrent callers for the same locale share one request.
|
|
6
|
+
*/
|
|
7
|
+
export declare function loadDateFnsLocale(locale: Locale): Promise<DateFnsLocale | undefined>;
|
|
8
|
+
/** The locale if it is already loaded, otherwise undefined. Never suspends. */
|
|
9
|
+
export declare function getLoadedDateFnsLocale(locale?: Locale): DateFnsLocale | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* The date-fns locale for `locale`, loading it in the background on first use.
|
|
12
|
+
*
|
|
13
|
+
* Returns undefined until the chunk arrives, which formats the first paint with
|
|
14
|
+
* date-fns' built-in English and then re-renders. That is a change only for
|
|
15
|
+
* projects that set a locale, and only for the few hundred milliseconds before
|
|
16
|
+
* the chunk lands — in exchange for every project no longer waiting on 625KB.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useDateFnsLocale(locale?: Locale): DateFnsLocale | undefined;
|
package/dist/util/entities.d.ts
CHANGED
|
@@ -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
|
+
};
|
package/dist/util/index.d.ts
CHANGED
|
@@ -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";
|
|
@@ -26,3 +28,4 @@ export * from "./storage";
|
|
|
26
28
|
export * from "./callbacks";
|
|
27
29
|
export * from "./conditions";
|
|
28
30
|
export * from "./lazy_eager";
|
|
31
|
+
export * from "./date_fns_locales";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
/**
|
|
3
|
-
* Returns a React.lazy component that is also preloaded
|
|
4
|
-
*
|
|
5
|
-
* This ensures that chunks are split, but fetched
|
|
3
|
+
* Returns a React.lazy component that is also preloaded in the background, once
|
|
4
|
+
* the page has finished loading.
|
|
5
|
+
* This ensures that chunks are split, but fetched before they are actually needed.
|
|
6
6
|
*/
|
|
7
7
|
export declare function lazyEager<T extends React.ComponentType<any>>(factory: () => Promise<any>, exportName?: string): React.LazyExoticComponent<T>;
|
|
@@ -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[];
|
|
@@ -3,22 +3,124 @@ export declare function removeInitialAndTrailingSlashes(s: string): string;
|
|
|
3
3
|
export declare function removeInitialSlash(s: string): string;
|
|
4
4
|
export declare function removeTrailingSlash(s: string): string;
|
|
5
5
|
export declare function addInitialSlash(s: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Characters that would otherwise be read as structure once an entity id is joined into a
|
|
8
|
+
* path: "/" separates segments, "?" and "#" start the query and hash in a URL, and "%"
|
|
9
|
+
* has to be escaped first so that no escape sequence we introduce can be misread as one
|
|
10
|
+
* that was already part of the id.
|
|
11
|
+
*
|
|
12
|
+
* Entity ids are escaped ONLY inside URL-facing strings — anything handed to
|
|
13
|
+
* `buildUrlCollectionPath` or `navigate`. Every other path string (the `path` field of a
|
|
14
|
+
* navigation entry, datasource paths, `EntityReference.path`) carries raw ids.
|
|
15
|
+
*
|
|
16
|
+
* @group Hooks and utilities
|
|
17
|
+
*/
|
|
18
|
+
export declare function encodeEntityId(entityId: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Inverse of {@link encodeEntityId}. "%25" is undone last, mirroring the encoder, so an id
|
|
21
|
+
* that legitimately contains the text "%2F" survives the round trip.
|
|
22
|
+
*
|
|
23
|
+
* @group Hooks and utilities
|
|
24
|
+
*/
|
|
25
|
+
export declare function decodeEntityId(encodedEntityId: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Segments of a subcollection sitting under the entity `entityId` of `parentPathSegments`.
|
|
28
|
+
*
|
|
29
|
+
* The parent entity id is kept whole however many slashes it contains, while the
|
|
30
|
+
* subcollection's own configured path is spread — a collection path never contains an
|
|
31
|
+
* entity id, so splitting that one is unambiguous.
|
|
32
|
+
*
|
|
33
|
+
* So `["test"] + "test/test" + "accommodation"` yields three segments,
|
|
34
|
+
* `["test", "test/test", "accommodation"]`, where splitting the flattened path
|
|
35
|
+
* `"test/test/test/accommodation"` would wrongly yield four.
|
|
36
|
+
*
|
|
37
|
+
* Returns undefined when the parent segments are unknown: the parent chain cannot be
|
|
38
|
+
* recovered from a flattened path, so there is nothing honest to build on.
|
|
39
|
+
*
|
|
40
|
+
* @group Hooks and utilities
|
|
41
|
+
*/
|
|
42
|
+
export declare function buildSubcollectionPathSegments(parentPathSegments: string[] | undefined, entityId: string | undefined, subcollectionPath: string): string[] | undefined;
|
|
6
43
|
export declare function getLastSegment(path: string): string;
|
|
7
|
-
|
|
44
|
+
/**
|
|
45
|
+
* The outcome of walking a segment chain against a collection tree.
|
|
46
|
+
* @group Hooks and utilities
|
|
47
|
+
*/
|
|
48
|
+
export type PathSegmentsWalkStep = {
|
|
49
|
+
collection: EntityCollection;
|
|
50
|
+
/** Resolved path of this collection, e.g. `"products/pid/locales"`. */
|
|
51
|
+
collectionPath: string;
|
|
52
|
+
/** `collectionPath` split at its real segment boundaries. */
|
|
53
|
+
collectionSegments: string[];
|
|
54
|
+
/** The entity addressed inside it, when the chain continues past the collection. */
|
|
55
|
+
entityId?: string;
|
|
56
|
+
};
|
|
57
|
+
export type PathSegmentsWalk = {
|
|
58
|
+
/** Segments with every collection id replaced by the collection's real `path`. */
|
|
59
|
+
resolved: string[];
|
|
60
|
+
/** The collection the chain ends in, if the whole chain matched. */
|
|
61
|
+
collection?: EntityCollection;
|
|
62
|
+
/** One entry per collection level traversed, outermost first. */
|
|
63
|
+
steps: PathSegmentsWalkStep[];
|
|
64
|
+
/** The first segment that could not be matched, if the walk stopped early. */
|
|
65
|
+
unmatched?: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Walk a segment chain against a collection tree, matching a collection by either its
|
|
69
|
+
* `path` or its `id` and treating exactly one segment as each entity id.
|
|
70
|
+
*
|
|
71
|
+
* This is the primitive the string-based helpers cannot have: working on the flattened
|
|
72
|
+
* path they must *guess* where an entity id ends by reading up to the next "/", which is
|
|
73
|
+
* wrong for any id that contains one. Here the boundaries are given.
|
|
74
|
+
*
|
|
75
|
+
* Stops at the first segment it cannot match and reports it, rather than throwing.
|
|
76
|
+
*
|
|
77
|
+
* @group Hooks and utilities
|
|
78
|
+
*/
|
|
79
|
+
export declare function walkPathSegments(pathSegments: string[], allCollections: EntityCollection[]): PathSegmentsWalk;
|
|
80
|
+
/**
|
|
81
|
+
* Resolve collection aliases in a segment array: every collection id is replaced by the
|
|
82
|
+
* collection's real `path`, and every entity id is carried through untouched.
|
|
83
|
+
*
|
|
84
|
+
* The segment-wise counterpart of {@link resolveCollectionPathIds}, and the reason it
|
|
85
|
+
* exists: that one works on the flattened string, so an entity id containing "/" shifts
|
|
86
|
+
* the rest of the chain by a segment and resolution fails with
|
|
87
|
+
* "Collection definition not found for segment starting with …".
|
|
88
|
+
*
|
|
89
|
+
* Matching accepts either a collection's `path` or its `id`, so already-resolved segments
|
|
90
|
+
* pass through unchanged — the function is idempotent.
|
|
91
|
+
*
|
|
92
|
+
* Mirrors the string version when a chain cannot be matched: it warns and carries the
|
|
93
|
+
* remainder through unresolved, rather than throwing.
|
|
94
|
+
*
|
|
95
|
+
* @group Hooks and utilities
|
|
96
|
+
*/
|
|
97
|
+
export declare function resolveCollectionPathSegments(pathSegments: string[], allCollections: EntityCollection[]): string[];
|
|
98
|
+
/**
|
|
99
|
+
* Find the collection a segment chain addresses, whether it ends on the collection itself
|
|
100
|
+
* or on one of its entities.
|
|
101
|
+
*
|
|
102
|
+
* The segment-wise counterpart of {@link getCollectionByPathOrId}, which asserts an odd
|
|
103
|
+
* number of "/"-separated parts — an assertion a slash-bearing entity id fails, throwing
|
|
104
|
+
* where it should simply have resolved.
|
|
105
|
+
*
|
|
106
|
+
* @group Hooks and utilities
|
|
107
|
+
*/
|
|
108
|
+
export declare function getCollectionByPathSegments(pathSegments: string[], collections: EntityCollection[]): EntityCollection | undefined;
|
|
109
|
+
export declare function resolveCollectionPathIds(path: string, allCollections: EntityCollection[], pathSegments?: string[]): string;
|
|
8
110
|
/**
|
|
9
111
|
* Find the corresponding view at any depth for a given path.
|
|
10
112
|
* Note that path or segments of the paths can be collection aliases.
|
|
11
113
|
* @param pathOrId
|
|
12
114
|
* @param collections
|
|
13
115
|
*/
|
|
14
|
-
export declare function getCollectionByPathOrId(pathOrId: string, collections: EntityCollection[]): EntityCollection | undefined;
|
|
116
|
+
export declare function getCollectionByPathOrId(pathOrId: string, collections: EntityCollection[], pathSegments?: string[]): EntityCollection | undefined;
|
|
15
117
|
/**
|
|
16
118
|
* Get the subcollection combinations from a path:
|
|
17
119
|
* "sites/es/locales" => ["sites/es/locales", "sites"]
|
|
18
120
|
* @param subpaths
|
|
19
121
|
*/
|
|
20
122
|
export declare function getCollectionPathsCombinations(subpaths: string[]): string[];
|
|
21
|
-
export declare function navigateToEntity({ openEntityMode, collection, entityId, copy, path, fullIdPath, selectedTab, sideEntityController, onClose, navigation }: {
|
|
123
|
+
export declare function navigateToEntity({ openEntityMode, collection, entityId, copy, path, fullIdPath, pathSegments, selectedTab, sideEntityController, onClose, navigation }: {
|
|
22
124
|
openEntityMode: "side_panel" | "full_screen";
|
|
23
125
|
collection?: EntityCollection;
|
|
24
126
|
entityId?: string;
|
|
@@ -26,6 +128,8 @@ export declare function navigateToEntity({ openEntityMode, collection, entityId,
|
|
|
26
128
|
copy?: boolean;
|
|
27
129
|
path: string;
|
|
28
130
|
fullIdPath?: string;
|
|
131
|
+
/** `path` split at its real segment boundaries. */
|
|
132
|
+
pathSegments?: string[];
|
|
29
133
|
sideEntityController: SideEntityController;
|
|
30
134
|
onClose?: () => void;
|
|
31
135
|
navigation: NavigationController;
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import { EntityCollection, EntityReference } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* References to every parent entity in a path.
|
|
4
|
+
*
|
|
5
|
+
* NOTE on encoding: `path` is expected ESCAPED, because it comes from the URL — the entity
|
|
6
|
+
* ids in it are decoded on the way out. Pass `pathSegments` instead whenever the path at
|
|
7
|
+
* hand is a raw datasource path (`entity.path`), which is not escaped and whose ids may
|
|
8
|
+
* therefore contain a bare "/": splitting that would silently produce the wrong references.
|
|
9
|
+
*/
|
|
2
10
|
export declare function getParentReferencesFromPath(props: {
|
|
3
11
|
path: string;
|
|
4
12
|
collections: EntityCollection[] | undefined;
|
|
5
13
|
currentFullPath?: string;
|
|
14
|
+
currentPathSegments?: string[];
|
|
15
|
+
/** `path` split at its real segment boundaries, with RAW ids. Takes precedence. */
|
|
16
|
+
pathSegments?: string[];
|
|
6
17
|
}): EntityReference[];
|
|
18
|
+
/**
|
|
19
|
+
* The segment-wise counterpart: the boundaries are given, so an entity id keeps its
|
|
20
|
+
* slashes and nothing has to be decoded.
|
|
21
|
+
*/
|
|
22
|
+
export declare function getParentReferencesFromPathSegments(pathSegments: string[], collections: EntityCollection[]): EntityReference[];
|
package/dist/util/paths.d.ts
CHANGED
|
@@ -9,6 +9,34 @@ export declare function segmentsToStrippedPath(paths: string[]): string;
|
|
|
9
9
|
/**
|
|
10
10
|
* Extract the collection path routes
|
|
11
11
|
* `products/B44RG6APH/locales` => [`products`, `locales`]
|
|
12
|
+
*
|
|
13
|
+
* Finds the entity ids by position, which only works while no id contains "/" — with one,
|
|
14
|
+
* every following segment shifts and the wrong elements are kept. Use
|
|
15
|
+
* {@link collectionSegmentsFrom} when the real boundaries are known.
|
|
16
|
+
*
|
|
12
17
|
* @param path
|
|
13
18
|
*/
|
|
14
19
|
export declare function fullPathToCollectionSegments(path: string): string[];
|
|
20
|
+
/**
|
|
21
|
+
* The collection chain of an already-segmented path:
|
|
22
|
+
* `['products', 'B44RG6APH', 'locales']` => [`products`, `locales`]
|
|
23
|
+
*
|
|
24
|
+
* The counterpart of {@link fullPathToCollectionSegments} for callers that know the real
|
|
25
|
+
* segment boundaries. Kept as a separate function rather than an extra parameter on that
|
|
26
|
+
* one: these helpers are small enough to be passed point-free, and `paths.map(fn)` would
|
|
27
|
+
* then hand the array index in as the new argument.
|
|
28
|
+
*/
|
|
29
|
+
export declare function collectionSegmentsFrom(pathSegments: string[]): string[];
|
|
30
|
+
/**
|
|
31
|
+
* The historical, positional reading of a flattened path:
|
|
32
|
+
* `products/B44RG6APH/locales` => [`products`, `locales`]
|
|
33
|
+
*
|
|
34
|
+
* This produces a **collection chain**, not a datasource `pathSegments` value, and must
|
|
35
|
+
* never be used as one — see `path_segments_no_fabrication.test.ts`. It is only correct
|
|
36
|
+
* while no entity id contains "/", which is why every caller prefers real segments when
|
|
37
|
+
* they are available, and why it is named for what it assumes.
|
|
38
|
+
*
|
|
39
|
+
* It is still the right reading for a path that came from a URL, where entity ids arrive
|
|
40
|
+
* escaped and so cannot contain a bare "/".
|
|
41
|
+
*/
|
|
42
|
+
export declare function positionalCollectionSegments(path: string): string[];
|