@firecms/collection_editor 3.0.0-beta.10 → 3.0.0-beta.11

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 (35) hide show
  1. package/dist/index.es.js +8975 -5244
  2. package/dist/index.es.js.map +1 -1
  3. package/dist/index.umd.js +8967 -5237
  4. package/dist/index.umd.js.map +1 -1
  5. package/dist/types/config_permissions.d.ts +2 -2
  6. package/dist/types/persisted_collection.d.ts +1 -1
  7. package/dist/useCollectionEditorPlugin.d.ts +4 -4
  8. package/package.json +18 -16
  9. package/src/types/config_permissions.ts +1 -1
  10. package/src/types/persisted_collection.ts +2 -3
  11. package/src/ui/CollectionViewHeaderAction.tsx +1 -1
  12. package/src/ui/NewCollectionButton.tsx +1 -1
  13. package/src/ui/PropertyAddColumnComponent.tsx +2 -2
  14. package/src/ui/collection_editor/CollectionDetailsForm.tsx +8 -4
  15. package/src/ui/collection_editor/CollectionEditorDialog.tsx +9 -5
  16. package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +2 -2
  17. package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +5 -9
  18. package/src/ui/collection_editor/EntityCustomViewsSelectDialog.tsx +6 -5
  19. package/src/ui/collection_editor/EnumForm.tsx +10 -6
  20. package/src/ui/collection_editor/GetCodeDialog.tsx +41 -23
  21. package/src/ui/collection_editor/PropertyEditView.tsx +7 -4
  22. package/src/ui/collection_editor/PropertyFieldPreview.tsx +4 -4
  23. package/src/ui/collection_editor/PropertyTree.tsx +2 -2
  24. package/src/ui/collection_editor/UnsavedChangesDialog.tsx +3 -5
  25. package/src/ui/collection_editor/import/CollectionEditorImportMapping.tsx +2 -0
  26. package/src/ui/collection_editor/properties/BlockPropertyField.tsx +18 -12
  27. package/src/ui/collection_editor/properties/DateTimePropertyField.tsx +4 -0
  28. package/src/ui/collection_editor/properties/EnumPropertyField.tsx +2 -0
  29. package/src/ui/collection_editor/properties/MapPropertyField.tsx +2 -1
  30. package/src/ui/collection_editor/properties/MarkdownPropertyField.tsx +3 -3
  31. package/src/ui/collection_editor/properties/ReferencePropertyField.tsx +2 -0
  32. package/src/ui/collection_editor/properties/StoragePropertyField.tsx +3 -3
  33. package/src/ui/collection_editor/properties/UrlPropertyField.tsx +1 -0
  34. package/src/ui/collection_editor/properties/validation/ValidationPanel.tsx +1 -1
  35. package/src/useCollectionEditorPlugin.tsx +6 -6
@@ -1,5 +1,5 @@
1
1
  import React from "react";
2
- import { Button, Dialog, DialogActions, DialogContent, Typography } from "@firecms/ui";
2
+ import { Button, Dialog, DialogActions, DialogContent, DialogTitle, Typography } from "@firecms/ui";
3
3
 
4
4
  export interface UnsavedChangesDialogProps {
5
5
  open: boolean;
@@ -24,11 +24,9 @@ export function UnsavedChangesDialog({
24
24
  aria-labelledby="alert-dialog-title"
25
25
  aria-describedby="alert-dialog-description"
26
26
  >
27
- <DialogContent>
28
- <Typography variant={"h6"}>
29
- {title ?? "Unsaved changes"}
30
- </Typography>
31
27
 
28
+ <DialogTitle>{title ?? "Unsaved changes"}</DialogTitle>
29
+ <DialogContent>
32
30
  {body && <Typography>
33
31
  {body}
34
32
  </Typography>}
@@ -235,9 +235,11 @@ function PropertySelect({
235
235
  open={selectOpen}
236
236
  onOpenChange={setSelectOpen}
237
237
  invisible={true}
238
+ size={"large"}
238
239
  className={"w-full"}
239
240
  disabled={disabled}
240
241
  error={!widget}
242
+ fullWidth={true}
241
243
  value={fieldId ?? ""}
242
244
  placeholder={"Select a property widget"}
243
245
  position={"item-aligned"}
@@ -1,10 +1,16 @@
1
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
- import { PropertyFormDialog } from "../PropertyEditView";
5
- import { getFullId, idToPropertiesPath, namespaceToPropertiesOrderPath, namespaceToPropertiesPath } from "../util";
4
+ import { OnPropertyChangedParams, PropertyFormDialog } from "../PropertyEditView";
5
+ import {
6
+ getFullId,
7
+ getFullIdPath,
8
+ idToPropertiesPath,
9
+ namespaceToPropertiesOrderPath,
10
+ namespaceToPropertiesPath
11
+ } from "../util";
6
12
  import { PropertyTree } from "../PropertyTree";
7
- import { ArrayProperty, Property, PropertyConfig } from "@firecms/core";
13
+ import { ArrayProperty, PropertyConfig } from "@firecms/core";
8
14
 
9
15
  export function BlockPropertyField({
10
16
  disabled,
@@ -31,18 +37,17 @@ export function BlockPropertyField({
31
37
 
32
38
  const onPropertyChanged = ({
33
39
  id,
40
+ namespace,
34
41
  property
35
- }: { id?: string, property: Property }) => {
42
+ }: OnPropertyChangedParams) => {
36
43
  if (!id)
37
44
  throw Error();
38
45
 
39
- setFieldValue("oneOf.properties", {
40
- ...(values.oneOf?.properties ?? {}),
41
- [id]: property
42
- }, false);
46
+ setFieldValue("oneOf." + getFullIdPath(id, namespace), property, false);
47
+
43
48
  const currentPropertiesOrder = values.oneOf?.propertiesOrder ?? Object.keys(values.oneOf?.properties ?? {});
44
49
  const newPropertiesOrder = currentPropertiesOrder.includes(id) ? currentPropertiesOrder : [...currentPropertiesOrder, id];
45
- setFieldValue("oneOf.propertiesOrder", newPropertiesOrder, false);
50
+ setFieldValue("oneOf." + namespaceToPropertiesOrderPath(namespace), newPropertiesOrder, false);
46
51
  setPropertyDialogOpen(false);
47
52
  };
48
53
 
@@ -82,8 +87,9 @@ export function BlockPropertyField({
82
87
  <>
83
88
  <div className={"col-span-12"}>
84
89
  <div className={"flex justify-between items-end mt-8 mb-4"}>
85
- <Typography variant={"subtitle2"}>Properties in this
86
- block</Typography>
90
+ <Typography variant={"subtitle2"}>
91
+ Properties in this block
92
+ </Typography>
87
93
  {addChildButton}
88
94
  </div>
89
95
  <Paper className="p-2 pl-8">
@@ -104,7 +110,7 @@ export function BlockPropertyField({
104
110
  ? undefined
105
111
  : onPropertyMove}/>
106
112
 
107
- {!disabled && !values.oneOf?.propertiesOrder?.length &&
113
+ {!disabled && (values.oneOf?.propertiesOrder?.length === 0)&&
108
114
  <div className="h-full flex items-center justify-center p-4">
109
115
  Add the first property to this block
110
116
  </div>}
@@ -31,8 +31,10 @@ export function DateTimePropertyField({ disabled }: {
31
31
  <Select name={modePath}
32
32
  value={modeValue ?? "date"}
33
33
  error={Boolean(modeError)}
34
+ size={"large"}
34
35
  onValueChange={(v) => setFieldValue(modePath, v)}
35
36
  label={"Mode"}
37
+ fullWidth={true}
36
38
  renderValue={(v) => {
37
39
  switch (v) {
38
40
  case "date_time":
@@ -54,6 +56,8 @@ export function DateTimePropertyField({ disabled }: {
54
56
  <div>
55
57
  <Select name={autoValuePath}
56
58
  disabled={disabled}
59
+ size={"large"}
60
+ fullWidth={true}
57
61
  value={autoValueValue ?? ""}
58
62
  onValueChange={(v) => setFieldValue(autoValuePath, v === "none" ? null : v)}
59
63
  renderValue={(v) => {
@@ -93,9 +93,11 @@ export function EnumPropertyField({
93
93
  <Select
94
94
  disabled={disabled}
95
95
  position={"item-aligned"}
96
+ fullWidth={true}
96
97
  onValueChange={(value: string) => {
97
98
  setFieldValue("defaultValue", value);
98
99
  }}
100
+ size={"large"}
99
101
  label={"Default value"}
100
102
  value={defaultValue ?? ""}>
101
103
  {enumValues
@@ -113,7 +113,8 @@ export function MapPropertyField({ disabled, getData, allowDataInference, proper
113
113
  value={values.spreadChildren ?? false}
114
114
  />
115
115
  <FieldCaption>
116
- Set this flag to true if you want to display the children of this group as individual columns.
116
+ Set this flag to true if you want to display the children of this group as individual columns. This
117
+ will only work for top level groups.
117
118
  </FieldCaption>
118
119
  </div>
119
120
 
@@ -3,7 +3,7 @@ import { StringPropertyValidation } from "./validation/StringPropertyValidation"
3
3
  import { ValidationPanel } from "./validation/ValidationPanel";
4
4
  import { Field, getIn, useFormex } from "@firecms/formex";
5
5
 
6
- import { DebouncedTextField, ExpandablePanel, FileUploadIcon, TextField, Typography } from "@firecms/ui";
6
+ import { CloudUploadIcon, DebouncedTextField, ExpandablePanel, TextField, Typography } from "@firecms/ui";
7
7
 
8
8
  export function MarkdownPropertyField({
9
9
  disabled,
@@ -54,8 +54,8 @@ export function MarkdownPropertyField({
54
54
  <div className={"col-span-12"}>
55
55
  <ExpandablePanel
56
56
  title={
57
- <div className="flex flex-row text-gray-500">
58
- <FileUploadIcon/>
57
+ <div className="flex flex-row text-surface-500">
58
+ <CloudUploadIcon/>
59
59
  <Typography variant={"subtitle2"}
60
60
  className="ml-2">
61
61
  File upload config
@@ -89,6 +89,8 @@ export function CollectionsSelect({
89
89
  value={value ?? ""}
90
90
  position={"item-aligned"}
91
91
  name={pathPath}
92
+ size={"large"}
93
+ fullWidth={true}
92
94
  onChange={handleChange}
93
95
  label={"Target collection"}
94
96
  renderValue={(selected) => {
@@ -1,9 +1,9 @@
1
1
  import React from "react";
2
2
  import {
3
3
  Button,
4
+ CloudUploadIcon,
4
5
  DebouncedTextField,
5
6
  ExpandablePanel,
6
- FileUploadIcon,
7
7
  MultiSelect,
8
8
  MultiSelectItem,
9
9
  Typography
@@ -74,8 +74,8 @@ export function StoragePropertyField({
74
74
 
75
75
  <ExpandablePanel
76
76
  title={
77
- <div className="flex flex-row text-gray-500">
78
- <FileUploadIcon/>
77
+ <div className="flex flex-row text-surface-500">
78
+ <CloudUploadIcon/>
79
79
  <Typography variant={"subtitle2"}
80
80
  className="ml-2">
81
81
  File upload config
@@ -24,6 +24,7 @@ export function UrlPropertyField({
24
24
  <Select
25
25
  disabled={disabled}
26
26
  position={"item-aligned"}
27
+ fullWidth={true}
27
28
  onValueChange={(value: string) => {
28
29
  if (value === "[NONE]")
29
30
  setFieldValue("url", true);
@@ -12,7 +12,7 @@ export function ValidationPanel({
12
12
  asField={true}
13
13
  innerClassName="p-4"
14
14
  title={
15
- <div className="flex flex-row text-gray-500">
15
+ <div className="flex flex-row text-surface-500">
16
16
  <RuleIcon/>
17
17
  <Typography variant={"subtitle2"}
18
18
  className="ml-2">
@@ -15,7 +15,7 @@ import { useCollectionEditorController } from "./useCollectionEditorController";
15
15
  import { EditorCollectionActionStart } from "./ui/EditorCollectionActionStart";
16
16
  import { NewCollectionCard } from "./ui/NewCollectionCard";
17
17
 
18
- export interface CollectionConfigControllerProps<EC extends PersistedCollection = PersistedCollection, UserType extends User = User> {
18
+ export interface CollectionConfigControllerProps<EC extends PersistedCollection = PersistedCollection, USER extends User = User> {
19
19
 
20
20
  /**
21
21
  * Firebase app where the configuration is saved.
@@ -25,7 +25,7 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
25
25
  /**
26
26
  * Define what actions can be performed on the configuration.
27
27
  */
28
- configPermissions?: CollectionEditorPermissionsBuilder<UserType, EC>;
28
+ configPermissions?: CollectionEditorPermissionsBuilder<USER, EC>;
29
29
 
30
30
  /**
31
31
  * The words you define here will not be allowed to be used as group
@@ -47,7 +47,7 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
47
47
 
48
48
  getData?: (path: string, parentPaths: string[]) => Promise<object[]>;
49
49
 
50
- getUser?: (uid: string) => UserType | null;
50
+ getUser?: (uid: string) => USER | null;
51
51
 
52
52
  onAnalyticsEvent?: (event: string, params?: object) => void;
53
53
 
@@ -71,7 +71,7 @@ export interface CollectionConfigControllerProps<EC extends PersistedCollection
71
71
  * @param getUser
72
72
  * @param collectionInference
73
73
  */
74
- export function useCollectionEditorPlugin<EC extends PersistedCollection = PersistedCollection, UserType extends User = User>
74
+ export function useCollectionEditorPlugin<EC extends PersistedCollection = PersistedCollection, USER extends User = User>
75
75
  ({
76
76
  collectionConfigController,
77
77
  configPermissions,
@@ -83,7 +83,7 @@ export function useCollectionEditorPlugin<EC extends PersistedCollection = Persi
83
83
  getData,
84
84
  onAnalyticsEvent,
85
85
  components
86
- }: CollectionConfigControllerProps<EC, UserType>): FireCMSPlugin<any, any, PersistedCollection> {
86
+ }: CollectionConfigControllerProps<EC, USER>): FireCMSPlugin<any, any, PersistedCollection> {
87
87
 
88
88
  return {
89
89
  key: "collection_editor",
@@ -140,7 +140,7 @@ export function IntroWidget({}: {}) {
140
140
 
141
141
  return (
142
142
  <Paper
143
- className={"my-4 px-4 py-6 flex flex-col bg-white dark:bg-slate-800 gap-2"}>
143
+ className={"my-4 px-4 py-6 flex flex-col bg-white dark:bg-surface-accent-800 gap-2"}>
144
144
  <Typography variant={"subtitle2"} className={"uppercase"}>No collections found</Typography>
145
145
  <Typography>
146
146
  Start building collections in FireCMS easily. Map them to your existing