@firecms/core 3.0.1 → 3.1.0-canary.7d91b7c

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 (185) hide show
  1. package/README.md +1 -1
  2. package/dist/components/AIIcon.d.ts +16 -0
  3. package/dist/components/EntityCollectionTable/EntityCollectionRowActions.d.ts +7 -1
  4. package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +1 -1
  5. package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +14 -0
  6. package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +6 -0
  7. package/dist/components/EntityCollectionTable/internal/CollectionTableToolbar.d.ts +5 -4
  8. package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +6 -0
  9. package/dist/components/EntityCollectionTable/internal/popup_field/useDraggable.d.ts +2 -2
  10. package/dist/components/EntityCollectionView/Board.d.ts +2 -0
  11. package/dist/components/EntityCollectionView/BoardColumn.d.ts +42 -0
  12. package/dist/components/EntityCollectionView/BoardColumnTitle.d.ts +9 -0
  13. package/dist/components/EntityCollectionView/BoardSortableList.d.ts +14 -0
  14. package/dist/components/EntityCollectionView/EntityBoardCard.d.ts +26 -0
  15. package/dist/components/EntityCollectionView/EntityCard.d.ts +19 -0
  16. package/dist/components/EntityCollectionView/EntityCollectionBoardView.d.ts +20 -0
  17. package/dist/components/EntityCollectionView/EntityCollectionCardView.d.ts +31 -0
  18. package/dist/components/EntityCollectionView/EntityCollectionViewActions.d.ts +2 -2
  19. package/dist/components/EntityCollectionView/EntityCollectionViewStartActions.d.ts +7 -3
  20. package/dist/components/EntityCollectionView/FiltersDialog.d.ts +14 -0
  21. package/dist/components/EntityCollectionView/ViewModeToggle.d.ts +44 -0
  22. package/dist/components/EntityCollectionView/board_types.d.ts +105 -0
  23. package/dist/components/EntityCollectionView/useBoardDataController.d.ts +60 -0
  24. package/dist/components/ErrorBoundary.d.ts +1 -1
  25. package/dist/components/SelectableTable/SelectableTable.d.ts +5 -1
  26. package/dist/components/SelectableTable/filters/DateTimeFilterField.d.ts +2 -1
  27. package/dist/components/VirtualTable/VirtualTableCell.d.ts +6 -0
  28. package/dist/components/VirtualTable/VirtualTableHeader.d.ts +3 -1
  29. package/dist/components/VirtualTable/VirtualTableHeaderRow.d.ts +1 -1
  30. package/dist/components/VirtualTable/VirtualTableProps.d.ts +11 -0
  31. package/dist/components/VirtualTable/fields/VirtualTableDateField.d.ts +1 -0
  32. package/dist/components/VirtualTable/types.d.ts +2 -0
  33. package/dist/components/index.d.ts +3 -0
  34. package/dist/contexts/index.d.ts +10 -0
  35. package/dist/core/DrawerNavigationGroup.d.ts +45 -0
  36. package/dist/core/index.d.ts +1 -0
  37. package/dist/form/components/ErrorFocus.d.ts +1 -1
  38. package/dist/form/validation.d.ts +3 -2
  39. package/dist/hooks/useBreadcrumbsController.d.ts +16 -0
  40. package/dist/hooks/useCollapsedGroups.d.ts +4 -1
  41. package/dist/index.es.js +5266 -1578
  42. package/dist/index.es.js.map +1 -1
  43. package/dist/index.umd.js +5260 -1573
  44. package/dist/index.umd.js.map +1 -1
  45. package/dist/internal/useRestoreScroll.d.ts +1 -1
  46. package/dist/preview/PropertyPreviewProps.d.ts +5 -0
  47. package/dist/preview/components/DatePreview.d.ts +13 -3
  48. package/dist/preview/components/ImagePreview.d.ts +5 -1
  49. package/dist/preview/components/StorageThumbnail.d.ts +2 -1
  50. package/dist/preview/components/UrlComponentPreview.d.ts +2 -1
  51. package/dist/preview/property_previews/ArrayOfStorageComponentsPreview.d.ts +1 -1
  52. package/dist/preview/property_previews/ArrayOfStringsPreview.d.ts +1 -1
  53. package/dist/preview/property_previews/SkeletonPropertyComponent.d.ts +1 -1
  54. package/dist/types/analytics.d.ts +1 -1
  55. package/dist/types/collections.d.ts +50 -2
  56. package/dist/types/datasource.d.ts +0 -1
  57. package/dist/types/plugins.d.ts +62 -1
  58. package/dist/types/properties.d.ts +259 -4
  59. package/dist/util/__tests__/conditions.test.d.ts +1 -0
  60. package/dist/util/__tests__/objects.test.d.ts +1 -0
  61. package/dist/util/conditions.d.ts +26 -0
  62. package/dist/util/entities.d.ts +2 -3
  63. package/dist/util/index.d.ts +2 -1
  64. package/dist/util/property_utils.d.ts +2 -1
  65. package/dist/util/resolutions.d.ts +3 -3
  66. package/package.json +14 -11
  67. package/src/app/Scaffold.tsx +14 -15
  68. package/src/components/AIIcon.tsx +39 -0
  69. package/src/components/ArrayContainer.tsx +1 -4
  70. package/src/components/ClearFilterSortButton.tsx +19 -16
  71. package/src/components/ConfirmationDialog.tsx +0 -2
  72. package/src/components/DeleteEntityDialog.tsx +2 -4
  73. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +74 -41
  74. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +130 -79
  75. package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +121 -104
  76. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +132 -103
  77. package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +20 -42
  78. package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +90 -49
  79. package/src/components/EntityCollectionTable/internal/EntityTableCellActions.tsx +1 -1
  80. package/src/components/EntityCollectionTable/internal/popup_field/useDraggable.tsx +11 -11
  81. package/src/components/EntityCollectionView/Board.tsx +324 -0
  82. package/src/components/EntityCollectionView/BoardColumn.tsx +158 -0
  83. package/src/components/EntityCollectionView/BoardColumnTitle.tsx +45 -0
  84. package/src/components/EntityCollectionView/BoardSortableList.tsx +172 -0
  85. package/src/components/EntityCollectionView/EntityBoardCard.tsx +212 -0
  86. package/src/components/EntityCollectionView/EntityCard.tsx +235 -0
  87. package/src/components/EntityCollectionView/EntityCollectionBoardView.tsx +733 -0
  88. package/src/components/EntityCollectionView/EntityCollectionCardView.tsx +244 -0
  89. package/src/components/EntityCollectionView/EntityCollectionView.tsx +519 -203
  90. package/src/components/EntityCollectionView/EntityCollectionViewActions.tsx +31 -19
  91. package/src/components/EntityCollectionView/EntityCollectionViewStartActions.tsx +84 -15
  92. package/src/components/EntityCollectionView/FiltersDialog.tsx +249 -0
  93. package/src/components/EntityCollectionView/ViewModeToggle.tsx +199 -0
  94. package/src/components/EntityCollectionView/board_types.ts +113 -0
  95. package/src/components/EntityCollectionView/useBoardDataController.tsx +490 -0
  96. package/src/components/ErrorTooltip.tsx +2 -1
  97. package/src/components/HomePage/DefaultHomePage.tsx +47 -10
  98. package/src/components/HomePage/HomePageDnD.tsx +56 -41
  99. package/src/components/HomePage/NavigationCard.tsx +20 -18
  100. package/src/components/HomePage/NavigationGroup.tsx +17 -16
  101. package/src/components/HomePage/RenameGroupDialog.tsx +0 -2
  102. package/src/components/HomePage/SmallNavigationCard.tsx +10 -9
  103. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +3 -10
  104. package/src/components/ReferenceWidget.tsx +2 -4
  105. package/src/components/SelectableTable/SelectableTable.tsx +75 -67
  106. package/src/components/SelectableTable/filters/BooleanFilterField.tsx +7 -6
  107. package/src/components/SelectableTable/filters/DateTimeFilterField.tsx +39 -40
  108. package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +38 -38
  109. package/src/components/SelectableTable/filters/StringNumberFilterField.tsx +49 -58
  110. package/src/components/UnsavedChangesDialog.tsx +0 -2
  111. package/src/components/UserDisplay.tsx +4 -4
  112. package/src/components/VirtualTable/VirtualTable.tsx +272 -118
  113. package/src/components/VirtualTable/VirtualTableCell.tsx +18 -2
  114. package/src/components/VirtualTable/VirtualTableHeader.tsx +59 -50
  115. package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +158 -42
  116. package/src/components/VirtualTable/VirtualTableProps.tsx +14 -1
  117. package/src/components/VirtualTable/VirtualTableRow.tsx +1 -1
  118. package/src/components/VirtualTable/fields/VirtualTableDateField.tsx +3 -0
  119. package/src/components/VirtualTable/fields/VirtualTableSelect.tsx +19 -6
  120. package/src/components/VirtualTable/types.tsx +2 -0
  121. package/src/components/common/useColumnsIds.tsx +95 -3
  122. package/src/components/index.tsx +4 -0
  123. package/src/contexts/BreacrumbsContext.tsx +15 -8
  124. package/src/contexts/index.ts +10 -0
  125. package/src/core/DefaultAppBar.tsx +40 -27
  126. package/src/core/DefaultDrawer.tsx +42 -56
  127. package/src/core/DrawerNavigationGroup.tsx +118 -0
  128. package/src/core/DrawerNavigationItem.tsx +4 -3
  129. package/src/core/EntityEditView.tsx +41 -43
  130. package/src/core/EntitySidePanel.tsx +28 -26
  131. package/src/core/SideDialogs.tsx +4 -2
  132. package/src/core/field_configs.tsx +14 -9
  133. package/src/core/index.tsx +1 -0
  134. package/src/form/EntityForm.tsx +69 -60
  135. package/src/form/PropertyFieldBinding.tsx +61 -46
  136. package/src/form/components/ErrorFocus.tsx +3 -3
  137. package/src/form/components/StorageItemPreview.tsx +2 -1
  138. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +0 -1
  139. package/src/form/field_bindings/DateTimeFieldBinding.tsx +17 -16
  140. package/src/form/field_bindings/KeyValueFieldBinding.tsx +0 -1
  141. package/src/form/field_bindings/MapFieldBinding.tsx +69 -67
  142. package/src/form/field_bindings/MarkdownEditorFieldBinding.tsx +22 -18
  143. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +83 -83
  144. package/src/form/field_bindings/TextFieldBinding.tsx +71 -35
  145. package/src/form/validation.ts +245 -160
  146. package/src/hooks/useBreadcrumbsController.tsx +18 -0
  147. package/src/hooks/useBuildNavigationController.tsx +46 -23
  148. package/src/hooks/useCollapsedGroups.ts +12 -4
  149. package/src/hooks/useValidateAuthenticator.tsx +1 -1
  150. package/src/internal/useBuildDataSource.ts +68 -34
  151. package/src/internal/useBuildSideDialogsController.tsx +11 -8
  152. package/src/internal/useBuildSideEntityController.tsx +2 -4
  153. package/src/internal/useRestoreScroll.tsx +26 -14
  154. package/src/preview/PropertyPreview.tsx +41 -32
  155. package/src/preview/PropertyPreviewProps.tsx +6 -0
  156. package/src/preview/components/DatePreview.tsx +72 -4
  157. package/src/preview/components/EmptyValue.tsx +1 -1
  158. package/src/preview/components/ImagePreview.tsx +37 -21
  159. package/src/preview/components/StorageThumbnail.tsx +16 -12
  160. package/src/preview/components/UrlComponentPreview.tsx +28 -25
  161. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +9 -7
  162. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +11 -9
  163. package/src/preview/property_previews/ArrayPropertyPreview.tsx +26 -24
  164. package/src/preview/property_previews/SkeletonPropertyComponent.tsx +61 -56
  165. package/src/routes/CustomCMSRoute.tsx +1 -0
  166. package/src/routes/FireCMSRoute.tsx +26 -13
  167. package/src/types/analytics.ts +10 -0
  168. package/src/types/collections.ts +57 -3
  169. package/src/types/datasource.ts +54 -56
  170. package/src/types/plugins.tsx +69 -1
  171. package/src/types/properties.ts +347 -27
  172. package/src/util/__tests__/conditions.test.ts +506 -0
  173. package/src/util/__tests__/objects.test.ts +196 -0
  174. package/src/util/callbacks.ts +6 -3
  175. package/src/util/collections.ts +51 -6
  176. package/src/util/conditions.ts +339 -0
  177. package/src/util/entities.ts +29 -30
  178. package/src/util/entity_cache.ts +2 -1
  179. package/src/util/index.ts +2 -1
  180. package/src/util/join_collections.ts +10 -8
  181. package/src/util/objects.ts +31 -13
  182. package/src/util/{references.ts → previews.ts} +16 -2
  183. package/src/util/property_utils.tsx +37 -11
  184. package/src/util/resolutions.ts +62 -58
  185. /package/dist/util/{references.d.ts → previews.d.ts} +0 -0
@@ -75,21 +75,21 @@ export const PropertyFieldBinding = React.memo(PropertyFieldBindingInternal, (a:
75
75
  }) as typeof PropertyFieldBindingInternal;
76
76
 
77
77
  function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Record<string, any> = any>
78
- ({
79
- propertyKey,
80
- property,
81
- context,
82
- includeDescription,
83
- underlyingValueHasChanged,
84
- disabled: disabledProp,
85
- partOfArray,
86
- partOfBlock,
87
- minimalistView,
88
- autoFocus,
89
- index,
90
- size,
91
- onPropertyChange,
92
- }: PropertyFieldBindingProps<T, M>): ReactElement<PropertyFieldBindingProps<T, M>> {
78
+ ({
79
+ propertyKey,
80
+ property,
81
+ context,
82
+ includeDescription,
83
+ underlyingValueHasChanged,
84
+ disabled: disabledProp,
85
+ partOfArray,
86
+ partOfBlock,
87
+ minimalistView,
88
+ autoFocus,
89
+ index,
90
+ size,
91
+ onPropertyChange,
92
+ }: PropertyFieldBindingProps<T, M>): ReactElement<PropertyFieldBindingProps<T, M>> {
93
93
 
94
94
  const authController = useAuthController();
95
95
  const customizationController = useCustomizationController();
@@ -137,7 +137,7 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Rec
137
137
  }
138
138
  const configProperty = resolveProperty({
139
139
  propertyKey,
140
- propertyOrBuilder: propertyConfig.property,
140
+ propertyOrBuilder: propertyConfig.property as any,
141
141
  values: fieldProps.form.values,
142
142
  path: context.path,
143
143
  entityId: context.entityId,
@@ -145,7 +145,7 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Rec
145
145
  index,
146
146
  authController
147
147
  });
148
- Component = configProperty.Field as ComponentType<FieldProps<T>>;
148
+ Component = configProperty?.Field as ComponentType<FieldProps<T>> | undefined;
149
149
  }
150
150
  if (!Component) {
151
151
  console.warn(`No field component found for property ${propertyKey}`);
@@ -175,7 +175,7 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Rec
175
175
  return <FieldInternal
176
176
  Component={Component as ComponentType<FieldProps>}
177
177
  componentProps={componentProps}
178
- formexFieldProps={fieldProps}/>;
178
+ formexFieldProps={fieldProps} />;
179
179
  }}
180
180
  </Field>
181
181
  );
@@ -185,39 +185,54 @@ function PropertyFieldBindingInternal<T extends CMSType = CMSType, M extends Rec
185
185
  type ResolvedPropertyFieldBindingProps<T extends CMSType = CMSType, M extends Record<string, any> = any> =
186
186
  Omit<PropertyFieldBindingProps<T, M>, "property">
187
187
  & {
188
- property: ResolvedProperty<T>
189
- };
188
+ property: ResolvedProperty<T>
189
+ };
190
190
 
191
191
  function FieldInternal<T extends CMSType, CustomProps, M extends Record<string, any>>
192
- ({
193
- Component,
194
- componentProps: {
195
- propertyKey,
196
- property,
197
- includeDescription,
198
- underlyingValueHasChanged,
199
- partOfArray,
200
- partOfBlock,
201
- minimalistView,
202
- autoFocus,
203
- context,
204
- disabled,
205
- size,
206
- onPropertyChange
207
- },
208
- formexFieldProps
209
- }:
210
- {
211
- Component: ComponentType<FieldProps<T, any, M>>,
212
- componentProps: ResolvedPropertyFieldBindingProps<T, M>,
213
- formexFieldProps: FormexFieldProps<T, any>
214
- }) {
192
+ ({
193
+ Component,
194
+ componentProps: {
195
+ propertyKey,
196
+ property,
197
+ includeDescription,
198
+ underlyingValueHasChanged,
199
+ partOfArray,
200
+ partOfBlock,
201
+ minimalistView,
202
+ autoFocus,
203
+ context,
204
+ disabled,
205
+ size,
206
+ onPropertyChange
207
+ },
208
+ formexFieldProps
209
+ }:
210
+ {
211
+ Component: ComponentType<FieldProps<T, any, M>>,
212
+ componentProps: ResolvedPropertyFieldBindingProps<T, M>,
213
+ formexFieldProps: FormexFieldProps<T, any>
214
+ }) {
215
215
 
216
216
  const { plugins } = useCustomizationController();
217
217
 
218
218
  const customFieldProps: any = property.customProps;
219
219
  const value = formexFieldProps.field.value;
220
- const error = getIn(formexFieldProps.form.errors, propertyKey);
220
+
221
+ // Get error for this field path, but avoid string indexing issues
222
+ // When an array has a string error like "Tags should have unique values",
223
+ // accessing errors["tags"]["0"] returns "T" (string indexing).
224
+ // We traverse the path manually and stop if we hit a string.
225
+ let error: any = formexFieldProps.form.errors;
226
+ for (const part of propertyKey.split(".")) {
227
+ if (error === undefined || error === null) break;
228
+ if (typeof error === "string") {
229
+ // Parent is a string error, children shouldn't inherit individual characters
230
+ error = undefined;
231
+ break;
232
+ }
233
+ error = error[part];
234
+ }
235
+
221
236
  const touched = getIn(formexFieldProps.form.touched, propertyKey);
222
237
 
223
238
  const showError: boolean = error &&
@@ -272,7 +287,7 @@ function FieldInternal<T extends CMSType, CustomProps, M extends Record<string,
272
287
  return (
273
288
  <ErrorBoundary>
274
289
 
275
- <UsedComponent {...cmsFieldProps}/>
290
+ <UsedComponent {...cmsFieldProps} />
276
291
 
277
292
  {underlyingValueHasChanged && !isSubmitting &&
278
293
  <Typography variant={"caption"} className={"ml-3.5"}>
@@ -287,7 +302,7 @@ const shouldPropertyReRender = (property: PropertyOrBuilder | ResolvedProperty,
287
302
  if (plugins?.some((plugin) => plugin.form?.fieldBuilder)) {
288
303
  return true;
289
304
  }
290
- if (isPropertyBuilder(property)) {
305
+ if (isPropertyBuilder(property as any)) {
291
306
  return true;
292
307
  }
293
308
  const defAProperty = property as Property | ResolvedProperty;
@@ -2,9 +2,9 @@ import React, { useEffect, useRef } from "react";
2
2
  import { useFormex } from "@firecms/formex";
3
3
 
4
4
  export const ErrorFocus = ({ containerRef }:
5
- {
6
- containerRef?: React.RefObject<HTMLDivElement>
7
- }) => {
5
+ {
6
+ containerRef?: React.RefObject<HTMLDivElement | null>
7
+ }) => {
8
8
  const {
9
9
  isValidating,
10
10
  errors,
@@ -29,9 +29,10 @@ export function StorageItemPreview({
29
29
  }: StorageItemPreviewProps) {
30
30
 
31
31
  return (
32
- <div className={cls(paperMixin,
32
+ <div className={cls(
33
33
  "relative border-box flex items-center justify-center",
34
34
  size === "large" ? "min-w-[220px] min-h-[220px] max-w-[220px]" : "min-w-[118px] min-h-[118px] max-w-[118px]",
35
+ paperMixin,
35
36
  className)}>
36
37
 
37
38
  {!placeholder && !disabled &&
@@ -129,7 +129,6 @@ export function ArrayOfReferencesFieldBinding({
129
129
  <Button
130
130
  className="ml-3.5 my-4 justify-center text-left"
131
131
  variant="text"
132
- color="primary"
133
132
  disabled={isSubmitting}
134
133
  onClick={onEntryClick}>
135
134
  <EditIcon size={"small"}/>
@@ -19,17 +19,17 @@ type DateTimeFieldProps = FieldProps<Date>;
19
19
  * @group Form fields
20
20
  */
21
21
  export function DateTimeFieldBinding({
22
- propertyKey,
23
- value,
24
- setValue,
25
- autoFocus,
26
- error,
27
- showError,
28
- disabled,
29
- touched,
30
- property,
31
- includeDescription
32
- }: DateTimeFieldProps) {
22
+ propertyKey,
23
+ value,
24
+ setValue,
25
+ autoFocus,
26
+ error,
27
+ showError,
28
+ disabled,
29
+ touched,
30
+ property,
31
+ includeDescription
32
+ }: DateTimeFieldProps) {
33
33
 
34
34
  const { locale } = useCustomizationController();
35
35
  const internalValue = value || null;
@@ -50,21 +50,22 @@ export function DateTimeFieldBinding({
50
50
  mode={property.mode}
51
51
  clearable={property.clearable}
52
52
  locale={locale}
53
+ timezone={property.timezone}
53
54
  error={showError}
54
55
  disabled={disabled}
55
56
  label={<LabelWithIcon
56
57
  icon={getIconForProperty(property, "small")}
57
58
  required={property.validation?.required}
58
59
  className={showError ? "text-red-500 dark:text-red-500" : "text-text-secondary dark:text-text-secondary-dark"}
59
- title={property.name}/>}
60
+ title={property.name} />}
60
61
  />
61
62
  </PropertyIdCopyTooltip>
62
63
 
63
64
  <FieldHelperText includeDescription={includeDescription}
64
- showError={showError}
65
- error={error}
66
- disabled={disabled}
67
- property={property}/>
65
+ showError={showError}
66
+ error={error}
67
+ disabled={disabled}
68
+ property={property} />
68
69
 
69
70
  </>
70
71
  );
@@ -215,7 +215,6 @@ function MapEditView<T extends Record<string, any>>({
215
215
 
216
216
  <Button variant={"text"}
217
217
  size={"small"}
218
- color="primary"
219
218
  className="w-full"
220
219
  disabled={disabled}
221
220
  startIcon={<AddIcon/>}
@@ -4,6 +4,7 @@ import { FieldProps, MapProperty, Properties, PropertyFieldBindingProps, Resolve
4
4
  import { ErrorBoundary } from "../../components";
5
5
  import { getIconForProperty, isHidden, isReadOnly, pick } from "../../util";
6
6
  import { FieldHelperText, LabelWithIconAndTooltip } from "../components";
7
+ import { FormEntry } from "../components/FormEntry";
7
8
  import { PropertyFieldBinding } from "../PropertyFieldBinding";
8
9
  import { cls, ExpandablePanel, InputLabel, Select, SelectItem } from "@firecms/ui";
9
10
 
@@ -15,19 +16,19 @@ import { cls, ExpandablePanel, InputLabel, Select, SelectItem } from "@firecms/u
15
16
  * @group Form fields
16
17
  */
17
18
  export function MapFieldBinding({
18
- propertyKey,
19
- value,
20
- showError,
21
- error,
22
- disabled,
23
- property,
24
- partOfArray,
25
- minimalistView: minimalistViewProp,
26
- includeDescription,
27
- autoFocus,
28
- context,
29
- onPropertyChange
30
- }: FieldProps<Record<string, any>>) {
19
+ propertyKey,
20
+ value,
21
+ showError,
22
+ error,
23
+ disabled,
24
+ property,
25
+ partOfArray,
26
+ minimalistView: minimalistViewProp,
27
+ includeDescription,
28
+ autoFocus,
29
+ context,
30
+ onPropertyChange
31
+ }: FieldProps<Record<string, any>>) {
31
32
 
32
33
  const pickOnlySomeKeys = property.pickOnlySomeKeys || false;
33
34
  const expanded = property.expanded === undefined ? true : property.expanded;
@@ -52,75 +53,76 @@ export function MapFieldBinding({
52
53
  }
53
54
 
54
55
  const mapFormView = <>
55
- <div
56
- className={cls("py-1 flex flex-col space-y-2", minimalistView && property.widthPercentage !== undefined ? "mt-8" : undefined)}>
57
- {Object.entries(mapProperties)
58
- .filter(([_, property]) => !isHidden(property))
59
- .map(([entryKey, childProperty], index) => {
60
- const thisDisabled = isReadOnly(childProperty) || Boolean(childProperty.disabled);
61
- const fieldBindingProps: PropertyFieldBindingProps<any> = {
62
- propertyKey: `${propertyKey}.${entryKey}`,
63
- disabled: disabled || thisDisabled,
64
- property: childProperty,
65
- includeDescription,
66
- context,
67
- partOfArray: false,
68
- minimalistView: false,
69
- autoFocus: autoFocus && index === 0,
70
- onPropertyChange: function (updatedProperty) {
71
- onPropertyChange?.({
72
- properties: {
73
- [entryKey]: updatedProperty
74
- }
75
- } as Partial<MapProperty>);
56
+ <div
57
+ className={cls("py-1 flex flex-wrap gap-x-4 w-full space-y-2", minimalistView && property.widthPercentage !== undefined ? "mt-8" : undefined)}>
58
+ {Object.entries(mapProperties)
59
+ .filter(([_, property]) => !isHidden(property))
60
+ .map(([entryKey, childProperty], index) => {
61
+ const thisDisabled = isReadOnly(childProperty) || Boolean(childProperty.disabled);
62
+ const fieldBindingProps: PropertyFieldBindingProps<any> = {
63
+ propertyKey: `${propertyKey}.${entryKey}`,
64
+ disabled: disabled || thisDisabled,
65
+ property: childProperty,
66
+ includeDescription,
67
+ context,
68
+ partOfArray: false,
69
+ minimalistView: false,
70
+ autoFocus: autoFocus && index === 0,
71
+ onPropertyChange: function (updatedProperty) {
72
+ onPropertyChange?.({
73
+ properties: {
74
+ [entryKey]: updatedProperty
76
75
  }
77
- };
78
-
79
- return (
80
- <div key={`map-${propertyKey}-${index}`} className={"relative"}>
81
- <ErrorBoundary>
82
- <PropertyFieldBinding
83
- {...fieldBindingProps}/>
84
- </ErrorBoundary>
85
- </div>
86
- ) ;
76
+ } as Partial<MapProperty>);
87
77
  }
88
- )
78
+ };
79
+
80
+ const widthPercentage = childProperty.widthPercentage ?? 100;
81
+ return (
82
+ <FormEntry propertyKey={`${propertyKey}.${entryKey}`}
83
+ widthPercentage={widthPercentage}
84
+ key={`map-${propertyKey}-${index}`}>
85
+ <PropertyFieldBinding
86
+ {...fieldBindingProps} />
87
+ </FormEntry>
88
+ );
89
89
  }
90
- </div>
90
+ )
91
+ }
92
+ </div>
91
93
 
92
- {/*{pickOnlySomeKeys && buildPickKeysSelect(disabled, property.properties, setValue, value)}*/}
94
+ {/*{pickOnlySomeKeys && buildPickKeysSelect(disabled, property.properties, setValue, value)}*/}
93
95
 
94
- </>
95
- ;
96
+ </>
97
+ ;
96
98
 
97
99
  return (
98
100
  <ErrorBoundary>
99
101
 
100
102
  {!minimalistView && <ExpandablePanel initiallyExpanded={expanded}
101
- onExpandedChange={(expanded) => {
102
- onPropertyChange?.({
103
- expanded
104
- });
105
- }}
106
- className={property.widthPercentage !== undefined ? "mt-8" : undefined}
107
- innerClassName={"px-2 md:px-4 pb-2 md:pb-4 pt-1 md:pt-2 bg-white dark:bg-surface-900"}
108
- title={<LabelWithIconAndTooltip
109
- propertyKey={propertyKey}
110
- icon={getIconForProperty(property, "small")}
111
- required={property.validation?.required}
112
- title={property.name}
113
- className={"text-text-secondary dark:text-text-secondary-dark"}/>}>
103
+ onExpandedChange={(expanded) => {
104
+ onPropertyChange?.({
105
+ expanded
106
+ });
107
+ }}
108
+ className={property.widthPercentage !== undefined ? "mt-8" : undefined}
109
+ innerClassName={"px-2 md:px-4 pb-2 md:pb-4 pt-1 md:pt-2 bg-white dark:bg-surface-900"}
110
+ title={<LabelWithIconAndTooltip
111
+ propertyKey={propertyKey}
112
+ icon={getIconForProperty(property, "small")}
113
+ required={property.validation?.required}
114
+ title={property.name}
115
+ className={"text-text-secondary dark:text-text-secondary-dark"} />}>
114
116
  {mapFormView}
115
117
  </ExpandablePanel>}
116
118
 
117
119
  {minimalistView && mapFormView}
118
120
 
119
121
  <FieldHelperText includeDescription={includeDescription}
120
- showError={showError ?? false}
121
- error={error && !partOfArray ? (typeof error === "string" ? error : "A property of this map has an error") : undefined}
122
- disabled={disabled}
123
- property={property}/>
122
+ showError={showError ?? false}
123
+ error={error && !partOfArray ? (typeof error === "string" ? error : "A property of this map has an error") : undefined}
124
+ disabled={disabled}
125
+ property={property} />
124
126
 
125
127
  </ErrorBoundary>
126
128
  );
@@ -150,7 +152,7 @@ const buildPickKeysSelect = (disabled: boolean, properties: Properties, setValue
150
152
  onValueChange={handleAddProperty}
151
153
  renderValue={(key) => (properties as Properties)[key].name || key}>
152
154
  {keys.map((key) => <SelectItem key={key}
153
- value={key}>{(properties as Properties)[key].name || key}</SelectItem>)}
155
+ value={key}>{(properties as Properties)[key].name || key}</SelectItem>)}
154
156
  </Select>
155
157
  </div>;
156
158
  };
@@ -21,19 +21,19 @@ interface MarkdownEditorFieldProps {
21
21
  }
22
22
 
23
23
  export function MarkdownEditorFieldBinding({
24
- property,
25
- propertyKey,
26
- value,
27
- setValue,
28
- includeDescription,
29
- showError,
30
- error,
31
- minimalistView,
32
- disabled: disabledProp,
33
- isSubmitting,
34
- context,
35
- customProps,
36
- }: FieldProps<string, MarkdownEditorFieldProps>) {
24
+ property,
25
+ propertyKey,
26
+ value,
27
+ setValue,
28
+ includeDescription,
29
+ showError,
30
+ error,
31
+ minimalistView,
32
+ disabled: disabledProp,
33
+ isSubmitting,
34
+ context,
35
+ customProps,
36
+ }: FieldProps<string, MarkdownEditorFieldProps>) {
37
37
 
38
38
  const authController = useAuthController();
39
39
  const disabled = disabledProp || isSubmitting;
@@ -65,7 +65,7 @@ export function MarkdownEditorFieldBinding({
65
65
  }, [value]);
66
66
 
67
67
  const resolvedProperty = resolveProperty({
68
- propertyOrBuilder: property as PropertyOrBuilder,
68
+ propertyOrBuilder: property as PropertyOrBuilder<string>,
69
69
  values: entityValues,
70
70
  authController
71
71
  }) as ResolvedStringProperty | ResolvedArrayProperty<string[]>;
@@ -109,12 +109,16 @@ export function MarkdownEditorFieldBinding({
109
109
  }) ?? "/";
110
110
  }, [entityId, entityValues, path, property, propertyKey, storage]);
111
111
 
112
+ // Extract markdown config from property - can be boolean or object
113
+ const markdownConfig = typeof property.markdown === 'object' ? property.markdown : undefined;
114
+
112
115
  const editor = <FireCMSEditor
113
116
  content={value}
114
117
  onMarkdownContentChange={onContentChange}
115
118
  version={context.formex.version + fieldVersion}
116
119
  highlight={highlight}
117
120
  disabled={disabled}
121
+ markdownConfig={markdownConfig}
118
122
  handleImageUpload={async (file: File) => {
119
123
  const storagePath = storagePathBuilder(file);
120
124
  const fileName = await fileNameBuilder(file);
@@ -143,15 +147,15 @@ export function MarkdownEditorFieldBinding({
143
147
  icon={getIconForProperty(property, "small")}
144
148
  required={property.validation?.required}
145
149
  title={property.name}
146
- className={"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5"}/>
150
+ className={"h-8 text-text-secondary dark:text-text-secondary-dark ml-3.5"} />
147
151
  <div
148
152
  className={cls("rounded-md", fieldBackgroundMixin, disabled ? fieldBackgroundDisabledMixin : fieldBackgroundHoverMixin)}>
149
153
  {editor}
150
154
  </div>
151
155
  <FieldHelperText includeDescription={includeDescription}
152
- showError={showError}
153
- error={error}
154
- property={property}/>
156
+ showError={showError}
157
+ error={error}
158
+ property={property} />
155
159
  </>
156
160
 
157
161
  );