@firecms/collection_editor 3.0.0-canary.44 → 3.0.0-canary.46

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/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@firecms/collection_editor",
3
3
  "type": "module",
4
- "version": "3.0.0-canary.44",
4
+ "version": "3.0.0-canary.46",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "source": "src/index.ts",
9
9
  "dependencies": {
10
- "@firecms/data_import_export": "^3.0.0-canary.44",
11
- "@firecms/formex": "^3.0.0-canary.44",
12
- "@firecms/schema_inference": "^3.0.0-canary.44",
13
- "@firecms/ui": "^3.0.0-canary.44",
10
+ "@firecms/data_import_export": "^3.0.0-canary.46",
11
+ "@firecms/formex": "^3.0.0-canary.46",
12
+ "@firecms/schema_inference": "^3.0.0-canary.46",
13
+ "@firecms/ui": "^3.0.0-canary.46",
14
14
  "json5": "^2.2.3",
15
15
  "prism-react-renderer": "^2.3.1"
16
16
  },
@@ -81,5 +81,5 @@
81
81
  "publishConfig": {
82
82
  "access": "public"
83
83
  },
84
- "gitHead": "15e52171f137c2876a3566bbc2752d140b9d0c7a"
84
+ "gitHead": "7af477c065bf21042e06cb957803665ee504a712"
85
85
  }
@@ -109,12 +109,12 @@ export const ConfigControllerProvider = React.memo(
109
109
  deleteCollections: true
110
110
  }), []);
111
111
 
112
- const editCollection = useCallback(({
113
- id,
114
- fullPath,
115
- parentCollectionIds,
116
- parentCollection
117
- }: {
112
+ const editCollection = ({
113
+ id,
114
+ fullPath,
115
+ parentCollectionIds,
116
+ parentCollection
117
+ }: {
118
118
  id?: string,
119
119
  fullPath?: string,
120
120
  parentCollectionIds: string[],
@@ -133,16 +133,16 @@ export const ConfigControllerProvider = React.memo(
133
133
  parentCollection,
134
134
  redirect: false
135
135
  });
136
- }, []);
136
+ };
137
137
 
138
- const editProperty = useCallback(({
139
- propertyKey,
140
- property,
141
- editedCollectionId,
142
- currentPropertiesOrder,
143
- parentCollectionIds,
144
- collection
145
- }: {
138
+ const editProperty = ({
139
+ propertyKey,
140
+ property,
141
+ editedCollectionId,
142
+ currentPropertiesOrder,
143
+ parentCollectionIds,
144
+ collection
145
+ }: {
146
146
  propertyKey?: string,
147
147
  property?: Property,
148
148
  currentPropertiesOrder?: string[],
@@ -171,15 +171,15 @@ export const ConfigControllerProvider = React.memo(
171
171
  parentCollectionIds,
172
172
  collectionEditable: collection?.editable ?? false
173
173
  });
174
- }, []);
174
+ };
175
175
 
176
- const createCollection = React.useCallback(({
177
- parentCollectionIds,
178
- parentCollection,
179
- initialValues,
180
- redirect,
181
- sourceClick
182
- }: {
176
+ const createCollection = ({
177
+ parentCollectionIds,
178
+ parentCollection,
179
+ initialValues,
180
+ redirect,
181
+ sourceClick
182
+ }: {
183
183
  parentCollectionIds: string[],
184
184
  parentCollection?: PersistedCollection
185
185
  initialValues?: {
@@ -211,7 +211,7 @@ export const ConfigControllerProvider = React.memo(
211
211
  initialValues,
212
212
  redirect
213
213
  });
214
- }, []);
214
+ };
215
215
 
216
216
  return (
217
217
  <ConfigControllerContext.Provider value={collectionConfigController}>
@@ -6,7 +6,7 @@ import {
6
6
  } from "@firecms/core";
7
7
  import { DeleteIcon, IconButton, Menu, MenuItem, MoreVertIcon, SettingsIcon, } from "@firecms/ui";
8
8
  import { useCollectionEditorController } from "../useCollectionEditorController";
9
- import { useCallback, useState } from "react";
9
+ import { useState } from "react";
10
10
  import { useCollectionsConfigController } from "../useCollectionsConfigController";
11
11
 
12
12
  export function HomePageEditorCollectionAction({
@@ -24,13 +24,13 @@ export function HomePageEditorCollectionAction({
24
24
  collection
25
25
  });
26
26
 
27
- const onEditCollectionClicked = useCallback(() => {
27
+ const onEditCollectionClicked = () => {
28
28
  collectionEditorController?.editCollection({ id: collection.id, parentCollectionIds: [] });
29
- }, [collectionEditorController, path]);
29
+ };
30
30
 
31
31
  const [deleteRequested, setDeleteRequested] = useState(false);
32
32
 
33
- const deleteCollection = useCallback(() => {
33
+ const deleteCollection = () => {
34
34
  configController?.deleteCollection({ id: collection.id }).then(() => {
35
35
  setDeleteRequested(false);
36
36
  snackbarController.open({
@@ -38,7 +38,7 @@ export function HomePageEditorCollectionAction({
38
38
  type: "success"
39
39
  });
40
40
  });
41
- }, [path, configController]);
41
+ };
42
42
 
43
43
  return <>
44
44
 
@@ -235,6 +235,27 @@ export function CollectionDetailsForm({
235
235
  {showErrors && Boolean(errors.singularName) ? errors.singularName : "Optionally define a singular name for your entities"}
236
236
  </FieldCaption>
237
237
  </div>
238
+ <div className={"col-span-12"}>
239
+ <TextField
240
+ error={showErrors && Boolean(errors.sideDialogWidth)}
241
+ name={"sideDialogWidth"}
242
+ type={"number"}
243
+ aria-describedby={"sideDialogWidth-helper"}
244
+ onChange={(e) => {
245
+ setFieldTouched("sideDialogWidth", true);
246
+ const value = e.target.value;
247
+ if (!value) {
248
+ setFieldValue("sideDialogWidth", undefined);
249
+ } else if (!isNaN(Number(value))) {
250
+ setFieldValue("sideDialogWidth", Number(value));
251
+ }
252
+ }}
253
+ value={values.sideDialogWidth ?? ""}
254
+ label={"Side dialog width"}/>
255
+ <FieldCaption error={showErrors && Boolean(errors.singularName)}>
256
+ {showErrors && Boolean(errors.singularName) ? errors.singularName : "Optionally define the width (in pixels) of entities side dialog. Default is 768px"}
257
+ </FieldCaption>
258
+ </div>
238
259
  <div className={"col-span-12"}>
239
260
  <TextField
240
261
  error={showErrors && Boolean(errors.description)}
@@ -272,7 +293,7 @@ export function CollectionDetailsForm({
272
293
  <div className={"col-span-12"}>
273
294
  <Select
274
295
  name="customId"
275
- label="Data IDs generation"
296
+ label="Document IDs generation"
276
297
  position={"item-aligned"}
277
298
  disabled={customIdValue === "code_defined"}
278
299
  onValueChange={(v) => {
@@ -1,5 +1,5 @@
1
1
  import * as React from "react";
2
- import { useCallback, useEffect, useRef, useState } from "react";
2
+ import { useEffect, useRef, useState } from "react";
3
3
  import {
4
4
  CircularProgressCenter,
5
5
  EntityCollection,
@@ -88,13 +88,13 @@ export function CollectionEditorDialog(props: CollectionEditorDialogProps) {
88
88
  const [formDirty, setFormDirty] = React.useState<boolean>(false);
89
89
  const [unsavedChangesDialogOpen, setUnsavedChangesDialogOpen] = React.useState<boolean>(false);
90
90
 
91
- const handleCancel = useCallback(() => {
91
+ const handleCancel = () => {
92
92
  if (!formDirty) {
93
93
  props.handleClose(undefined);
94
94
  } else {
95
95
  setUnsavedChangesDialogOpen(true);
96
96
  }
97
- }, [formDirty, props.handleClose]);
97
+ };
98
98
 
99
99
  useEffect(() => {
100
100
  if (!open) {
@@ -170,7 +170,7 @@ export function CollectionEditor(props: CollectionEditorDialogProps & {
170
170
  } catch (e) {
171
171
  console.error(e);
172
172
  }
173
- }, [props.editedCollectionId, props.parentCollectionIds, navigation]);
173
+ }, [props.editedCollectionId, props.parentCollectionIds, navigation.initialised, navigation.getCollectionFromPaths]);
174
174
 
175
175
  if (!topLevelNavigation) {
176
176
  throw Error("Internal: Navigation not ready in collection editor");
@@ -294,7 +294,7 @@ function CollectionEditorInternal<M extends Record<string, any>>({
294
294
  });
295
295
  };
296
296
 
297
- const setNextMode = useCallback(() => {
297
+ const setNextMode = () => {
298
298
  if (currentView === "details") {
299
299
  if (importConfig.inUse) {
300
300
  setCurrentView("import_data_saving");
@@ -315,14 +315,14 @@ function CollectionEditorInternal<M extends Record<string, any>>({
315
315
  setCurrentView("details");
316
316
  }
317
317
 
318
- }, [currentView, importConfig.inUse, extraView]);
318
+ };
319
319
 
320
- const doCollectionInference = useCallback((collection: PersistedCollection<any>) => {
320
+ const doCollectionInference = (collection: PersistedCollection<any>) => {
321
321
  if (!collectionInference) return undefined;
322
322
  return collectionInference?.(collection.path, collection.collectionGroup ?? false, parentCollectionIds ?? []);
323
- }, [collectionInference, parentCollectionIds]);
323
+ };
324
324
 
325
- const inferCollectionFromData = useCallback(async (newCollection: PersistedCollection<M>) => {
325
+ const inferCollectionFromData = async (newCollection: PersistedCollection<M>) => {
326
326
 
327
327
  try {
328
328
  if (!doCollectionInference) {
@@ -366,7 +366,7 @@ function CollectionEditorInternal<M extends Record<string, any>>({
366
366
  });
367
367
  return newCollection;
368
368
  }
369
- }, [parentCollectionIds, doCollectionInference]);
369
+ };
370
370
 
371
371
  const onSubmit = (newCollectionState: PersistedCollection<M>, formexController: FormexController<PersistedCollection<M>>) => {
372
372
  console.log("Submitting collection", newCollectionState);
@@ -158,20 +158,20 @@ export function CollectionPropertiesEditorForm({
158
158
  }
159
159
  : undefined;
160
160
 
161
- const getCurrentPropertiesOrder = useCallback((namespace?: string) => {
161
+ const getCurrentPropertiesOrder = (namespace?: string) => {
162
162
  if (!namespace) return currentPropertiesOrderRef.current[""];
163
163
  return currentPropertiesOrderRef.current[namespace] ?? getIn(values, namespaceToPropertiesOrderPath(namespace));
164
- }, [values]);
164
+ };
165
165
 
166
- const updatePropertiesOrder = useCallback((newPropertiesOrder: string[], namespace?: string) => {
166
+ const updatePropertiesOrder = (newPropertiesOrder: string[], namespace?: string) => {
167
167
  const propertiesOrderPath = namespaceToPropertiesOrderPath(namespace);
168
168
 
169
169
  setFieldValue(propertiesOrderPath, newPropertiesOrder, false);
170
170
  currentPropertiesOrderRef.current[namespace ?? ""] = newPropertiesOrder;
171
171
 
172
- }, [setFieldValue]);
172
+ };
173
173
 
174
- const deleteProperty = useCallback((propertyKey?: string, namespace?: string) => {
174
+ const deleteProperty = (propertyKey?: string, namespace?: string) => {
175
175
  const fullId = propertyKey ? getFullId(propertyKey, namespace) : undefined;
176
176
  if (!fullId)
177
177
  throw Error("collection editor miss config");
@@ -187,7 +187,7 @@ export function CollectionPropertiesEditorForm({
187
187
  setSelectedPropertyIndex(undefined);
188
188
  setSelectedPropertyKey(undefined);
189
189
  setSelectedPropertyNamespace(undefined);
190
- }, [getCurrentPropertiesOrder, setFieldValue, updatePropertiesOrder]);
190
+ };
191
191
 
192
192
  const onPropertyMove = (propertiesOrder: string[], namespace?: string) => {
193
193
  setFieldValue(namespaceToPropertiesOrderPath(namespace), propertiesOrder, false);
@@ -273,7 +273,7 @@ export function CollectionPropertiesEditorForm({
273
273
 
274
274
  };
275
275
 
276
- const onPropertyErrorInternal = useCallback((id: string, namespace?: string, error?: Record<string, any>) => {
276
+ const onPropertyErrorInternal = (id: string, namespace?: string, error?: Record<string, any>) => {
277
277
  const propertyPath = id ? getFullId(id, namespace) : undefined;
278
278
  console.debug("onPropertyErrorInternal", {
279
279
  id,
@@ -286,7 +286,7 @@ export function CollectionPropertiesEditorForm({
286
286
  onPropertyError(id, namespace, hasError ? error : undefined);
287
287
  setFieldError(idToPropertiesPath(propertyPath), hasError ? "Property error" : undefined);
288
288
  }
289
- }, [])
289
+ }
290
290
 
291
291
  const closePropertyDialog = () => {
292
292
  setSelectedPropertyIndex(undefined);
@@ -303,7 +303,7 @@ export function CollectionPropertiesEditorForm({
303
303
 
304
304
  const owner = useMemo(() => values.ownerId && getUser ? getUser(values.ownerId) : null, [getUser, values.ownerId]);
305
305
 
306
- const onPropertyClick = useCallback((propertyKey: string, namespace?: string) => {
306
+ const onPropertyClick = (propertyKey: string, namespace?: string) => {
307
307
  console.debug("CollectionEditor: onPropertyClick", {
308
308
  propertyKey,
309
309
  namespace
@@ -311,7 +311,7 @@ export function CollectionPropertiesEditorForm({
311
311
  setSelectedPropertyIndex(usedPropertiesOrder.indexOf(propertyKey));
312
312
  setSelectedPropertyKey(propertyKey);
313
313
  setSelectedPropertyNamespace(namespace);
314
- }, [usedPropertiesOrder]);
314
+ };
315
315
 
316
316
  const body = (
317
317
  <div className={"grid grid-cols-12 gap-2 h-full bg-gray-50 dark:bg-gray-900"}>
@@ -228,6 +228,7 @@ export const PropertyForm = React.memo(
228
228
  a.includeIdAndName === b.includeIdAndName &&
229
229
  a.autoOpenTypeSelect === b.autoOpenTypeSelect &&
230
230
  a.autoUpdateId === b.autoUpdateId &&
231
+ a.existingPropertyKeys === b.existingPropertyKeys &&
231
232
  a.existingProperty === b.existingProperty
232
233
  );
233
234
 
@@ -367,13 +368,13 @@ function PropertyEditFormFields({
367
368
  }
368
369
  }
369
370
  }
370
- }, [deferredValues, includeIdAndTitle, onPropertyChanged, propertyNamespace]);
371
+ }, [deferredValues, includeIdAndTitle, propertyNamespace]);
371
372
 
372
373
  useEffect(() => {
373
374
  if (values?.id && onError) {
374
375
  onError(values?.id, propertyNamespace, errors);
375
376
  }
376
- }, [errors, onError, propertyNamespace, values?.id]);
377
+ }, [errors, propertyNamespace, values?.id]);
377
378
 
378
379
  const onWidgetSelectChanged = (newSelectedWidgetId: PropertyConfigId) => {
379
380
  setSelectedFieldConfigId(newSelectedWidgetId);
@@ -1,4 +1,4 @@
1
- import React, { useCallback } from "react";
1
+ import React from "react";
2
2
  import equal from "react-fast-compare"
3
3
 
4
4
  import {
@@ -48,7 +48,7 @@ export const PropertyTree = React.memo(
48
48
 
49
49
  const propertiesOrder = propertiesOrderProp ?? Object.keys(properties);
50
50
 
51
- const onDragEnd = useCallback((result: any) => {
51
+ const onDragEnd = (result: any) => {
52
52
  // dropped outside the list
53
53
  if (!result.destination) {
54
54
  return;
@@ -61,7 +61,7 @@ export const PropertyTree = React.memo(
61
61
  newPropertiesOrder.splice(endIndex, 0, removed);
62
62
  if (onPropertyMove)
63
63
  onPropertyMove(newPropertiesOrder, namespace);
64
- }, [namespace, onPropertyMove, propertiesOrder])
64
+ }
65
65
 
66
66
  return (
67
67
  <>
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useState } from "react";
1
+ import React, { useState } from "react";
2
2
  import { AddIcon, Button, Paper, Typography } from "@firecms/ui";
3
3
  import { getIn, useFormex } from "@firecms/formex";
4
4
  import { PropertyFormDialog } from "../PropertyEditView";
@@ -49,7 +49,7 @@ export function BlockPropertyField({
49
49
  const selectedPropertyFullId = selectedPropertyKey ? getFullId(selectedPropertyKey, selectedPropertyNamespace) : undefined;
50
50
  const selectedProperty = selectedPropertyFullId ? getIn(values.oneOf?.properties, selectedPropertyFullId.replaceAll(".", ".properties.")) : undefined;
51
51
 
52
- const deleteProperty = useCallback((propertyKey?: string, namespace?: string) => {
52
+ const deleteProperty = (propertyKey?: string, namespace?: string) => {
53
53
  const fullId = propertyKey ? getFullId(propertyKey, namespace) : undefined;
54
54
  if (!fullId)
55
55
  throw Error("collection editor miss config");
@@ -62,7 +62,7 @@ export function BlockPropertyField({
62
62
  setPropertyDialogOpen(false);
63
63
  setSelectedPropertyKey(undefined);
64
64
  setSelectedPropertyNamespace(undefined);
65
- }, [setFieldValue, values]);
65
+ };
66
66
 
67
67
  const addChildButton = <Button
68
68
  autoFocus
@@ -74,9 +74,9 @@ export function BlockPropertyField({
74
74
  Add property to {values.name ?? "this block"}
75
75
  </Button>;
76
76
 
77
- const onPropertyMove = useCallback((propertiesOrder: string[], namespace?: string) => {
77
+ const onPropertyMove = (propertiesOrder: string[], namespace?: string) => {
78
78
  setFieldValue(`oneOf.${namespaceToPropertiesOrderPath(namespace)}`, propertiesOrder, false);
79
- }, []);
79
+ };
80
80
 
81
81
  return (
82
82
  <>
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useState } from "react";
1
+ import React, { useState } from "react";
2
2
  import { FieldCaption, MapProperty, Property, PropertyConfig, } from "@firecms/core";
3
3
  import { AddIcon, BooleanSwitchWithLabel, Button, Paper, Typography } from "@firecms/ui";
4
4
  import { PropertyFormDialog } from "../PropertyEditView";
@@ -42,7 +42,7 @@ export function MapPropertyField({ disabled, getData, allowDataInference, proper
42
42
  setPropertyDialogOpen(false);
43
43
  };
44
44
 
45
- const deleteProperty = useCallback((propertyKey?: string, namespace?: string) => {
45
+ const deleteProperty = (propertyKey?: string, namespace?: string) => {
46
46
  const fullId = propertyKey ? getFullId(propertyKey, namespace) : undefined;
47
47
  if (!fullId)
48
48
  throw Error("collection editor miss config");
@@ -58,16 +58,16 @@ export function MapPropertyField({ disabled, getData, allowDataInference, proper
58
58
  setPropertyDialogOpen(false);
59
59
  setSelectedPropertyKey(undefined);
60
60
  setSelectedPropertyNamespace(undefined);
61
- }, [setFieldValue, values]);
61
+ };
62
62
 
63
63
  const selectedPropertyFullId = selectedPropertyKey ? getFullId(selectedPropertyKey, selectedPropertyNamespace) : undefined;
64
64
  const selectedProperty = selectedPropertyFullId ? getIn(values.properties, selectedPropertyFullId.replaceAll(".", ".properties.")) : undefined;
65
65
 
66
66
  const empty = !propertiesOrder || propertiesOrder.length < 1;
67
67
 
68
- const onPropertyMove = useCallback((propertiesOrder: string[], namespace?: string) => {
68
+ const onPropertyMove = (propertiesOrder: string[], namespace?: string) => {
69
69
  setFieldValue(namespaceToPropertiesOrderPath(namespace), propertiesOrder, false);
70
- }, []);
70
+ };
71
71
 
72
72
  return (
73
73
  <>