@firecms/core 3.0.0-beta.6 → 3.0.0-beta.8

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/dist/app/AppBar.d.ts +12 -0
  2. package/dist/app/Drawer.d.ts +17 -0
  3. package/dist/app/Scaffold.d.ts +30 -0
  4. package/dist/app/index.d.ts +4 -0
  5. package/dist/app/useApp.d.ts +16 -0
  6. package/dist/components/EntityCollectionTable/EntityCollectionTable.d.ts +1 -1
  7. package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +4 -2
  8. package/dist/components/EntityCollectionTable/PropertyTableCell.d.ts +1 -0
  9. package/dist/components/EntityCollectionTable/column_utils.d.ts +1 -2
  10. package/dist/components/EntityCollectionTable/fields/TableReferenceField.d.ts +2 -0
  11. package/dist/components/EntityCollectionTable/internal/EntityTableCell.d.ts +2 -2
  12. package/dist/components/EntityCollectionTable/internal/popup_field/PopupFormField.d.ts +1 -1
  13. package/dist/components/EntityPreview.d.ts +3 -2
  14. package/dist/components/ReferenceWidget.d.ts +3 -1
  15. package/dist/components/SelectableTable/filters/ReferenceFilterField.d.ts +2 -1
  16. package/dist/components/VirtualTable/VirtualTableProps.d.ts +5 -6
  17. package/dist/components/VirtualTable/types.d.ts +3 -3
  18. package/dist/components/{EntityCollectionTable/internal → common}/default_entity_actions.d.ts +1 -1
  19. package/dist/components/common/index.d.ts +1 -0
  20. package/dist/components/common/table_height.d.ts +5 -0
  21. package/dist/components/common/types.d.ts +3 -5
  22. package/dist/components/common/useDataSourceEntityCollectionTableController.d.ts +3 -0
  23. package/dist/components/index.d.ts +2 -1
  24. package/dist/{components/FireCMSAppBar.d.ts → core/DefaultAppBar.d.ts} +5 -8
  25. package/dist/core/DefaultDrawer.d.ts +19 -0
  26. package/dist/core/DrawerNavigationItem.d.ts +9 -0
  27. package/dist/core/EntityEditView.d.ts +17 -3
  28. package/dist/core/NavigationRoutes.d.ts +2 -2
  29. package/dist/core/index.d.ts +3 -4
  30. package/dist/form/PropertiesForm.d.ts +8 -0
  31. package/dist/form/components/FieldHelperText.d.ts +3 -3
  32. package/dist/form/components/StorageItemPreview.d.ts +4 -4
  33. package/dist/form/field_bindings/MapFieldBinding.d.ts +1 -1
  34. package/dist/form/field_bindings/StorageUploadFieldBinding.d.ts +2 -4
  35. package/dist/form/index.d.ts +0 -2
  36. package/dist/hooks/data/save.d.ts +1 -2
  37. package/dist/hooks/index.d.ts +1 -0
  38. package/dist/index.d.ts +1 -0
  39. package/dist/index.es.js +10199 -10140
  40. package/dist/index.es.js.map +1 -1
  41. package/dist/index.umd.js +5 -5
  42. package/dist/index.umd.js.map +1 -1
  43. package/dist/preview/PropertyPreviewProps.d.ts +5 -0
  44. package/dist/preview/components/ReferencePreview.d.ts +2 -1
  45. package/dist/preview/components/StorageThumbnail.d.ts +2 -1
  46. package/dist/preview/components/UrlComponentPreview.d.ts +2 -1
  47. package/dist/types/auth.d.ts +1 -1
  48. package/dist/types/collections.d.ts +22 -1
  49. package/dist/types/datasource.d.ts +18 -8
  50. package/dist/types/entity_actions.d.ts +14 -0
  51. package/dist/types/fields.d.ts +31 -30
  52. package/dist/types/navigation.d.ts +2 -2
  53. package/dist/types/plugins.d.ts +11 -3
  54. package/dist/types/properties.d.ts +15 -2
  55. package/dist/util/icon_synonyms.d.ts +1 -97
  56. package/dist/util/icons.d.ts +2 -2
  57. package/dist/util/objects.d.ts +1 -1
  58. package/dist/util/resolutions.d.ts +8 -8
  59. package/dist/util/storage.d.ts +23 -2
  60. package/dist/util/useStorageUploadController.d.ts +1 -1
  61. package/package.json +130 -122
  62. package/src/app/AppBar.tsx +18 -0
  63. package/src/app/Drawer.tsx +25 -0
  64. package/src/app/Scaffold.tsx +249 -0
  65. package/src/app/index.ts +4 -0
  66. package/src/app/useApp.tsx +32 -0
  67. package/src/components/EntityCollectionTable/EntityCollectionRowActions.tsx +8 -10
  68. package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +9 -7
  69. package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +9 -5
  70. package/src/components/EntityCollectionTable/PropertyTableCell.tsx +22 -15
  71. package/src/components/EntityCollectionTable/column_utils.tsx +3 -3
  72. package/src/components/EntityCollectionTable/fields/TableReferenceField.tsx +9 -1
  73. package/src/components/EntityCollectionTable/fields/TableStorageUpload.tsx +2 -2
  74. package/src/components/EntityCollectionTable/internal/CollectionTableToolbar.tsx +2 -2
  75. package/src/components/EntityCollectionTable/internal/EntityTableCell.tsx +5 -6
  76. package/src/components/EntityCollectionTable/internal/popup_field/PopupFormField.tsx +4 -5
  77. package/src/components/EntityCollectionView/EntityCollectionView.tsx +26 -24
  78. package/src/components/EntityPreview.tsx +9 -7
  79. package/src/components/EntityView.tsx +4 -4
  80. package/src/components/HomePage/NavigationCard.tsx +2 -2
  81. package/src/components/HomePage/SmallNavigationCard.tsx +5 -5
  82. package/src/components/PropertyIdCopyTooltipContent.tsx +2 -3
  83. package/src/components/ReferenceTable/ReferenceSelectionTable.tsx +1 -0
  84. package/src/components/ReferenceWidget.tsx +21 -11
  85. package/src/components/SearchIconsView.tsx +5 -5
  86. package/src/components/SelectableTable/SelectableTable.tsx +4 -2
  87. package/src/components/SelectableTable/filters/ReferenceFilterField.tsx +4 -1
  88. package/src/components/VirtualTable/VirtualTable.tsx +13 -12
  89. package/src/components/VirtualTable/VirtualTableHeader.tsx +4 -4
  90. package/src/components/VirtualTable/VirtualTableHeaderRow.tsx +2 -2
  91. package/src/components/VirtualTable/VirtualTableProps.tsx +6 -6
  92. package/src/components/VirtualTable/VirtualTableRow.tsx +4 -5
  93. package/src/components/VirtualTable/types.tsx +2 -3
  94. package/src/components/{EntityCollectionTable/internal → common}/default_entity_actions.tsx +2 -2
  95. package/src/components/common/index.ts +1 -0
  96. package/src/components/{VirtualTable/common.tsx → common/table_height.tsx} +5 -2
  97. package/src/components/common/types.tsx +3 -5
  98. package/src/components/common/useColumnsIds.tsx +10 -2
  99. package/src/components/common/useDataSourceEntityCollectionTableController.tsx +11 -0
  100. package/src/components/common/useTableSearchHelper.ts +52 -12
  101. package/src/components/index.tsx +2 -1
  102. package/src/contexts/DialogsProvider.tsx +2 -2
  103. package/src/{components/FireCMSAppBar.tsx → core/DefaultAppBar.tsx} +51 -36
  104. package/src/core/DefaultDrawer.tsx +177 -0
  105. package/src/core/DrawerNavigationItem.tsx +62 -0
  106. package/src/core/EntityEditView.tsx +673 -134
  107. package/src/core/EntitySidePanel.tsx +1 -2
  108. package/src/core/FireCMS.tsx +36 -40
  109. package/src/core/NavigationRoutes.tsx +6 -7
  110. package/src/core/field_configs.tsx +1 -1
  111. package/src/core/index.tsx +3 -4
  112. package/src/form/PropertiesForm.tsx +81 -0
  113. package/src/form/PropertyFieldBinding.tsx +29 -7
  114. package/src/form/components/FieldHelperText.tsx +3 -3
  115. package/src/form/components/StorageItemPreview.tsx +20 -11
  116. package/src/form/components/StorageUploadProgress.tsx +3 -3
  117. package/src/form/field_bindings/ArrayCustomShapedFieldBinding.tsx +8 -5
  118. package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +8 -5
  119. package/src/form/field_bindings/BlockFieldBinding.tsx +2 -2
  120. package/src/form/field_bindings/KeyValueFieldBinding.tsx +44 -39
  121. package/src/form/field_bindings/MapFieldBinding.tsx +11 -3
  122. package/src/form/field_bindings/MarkdownFieldBinding.tsx +2 -2
  123. package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +2 -9
  124. package/src/form/field_bindings/ReferenceFieldBinding.tsx +15 -13
  125. package/src/form/field_bindings/RepeatFieldBinding.tsx +10 -7
  126. package/src/form/field_bindings/SelectFieldBinding.tsx +3 -3
  127. package/src/form/field_bindings/StorageUploadFieldBinding.tsx +10 -39
  128. package/src/form/field_bindings/SwitchFieldBinding.tsx +1 -1
  129. package/src/form/index.tsx +4 -4
  130. package/src/form/validation.ts +1 -17
  131. package/src/hooks/data/save.ts +2 -1
  132. package/src/hooks/index.tsx +1 -0
  133. package/src/hooks/useBuildLocalConfigurationPersistence.tsx +2 -3
  134. package/src/hooks/useBuildNavigationController.tsx +1 -2
  135. package/src/hooks/useResolvedNavigationFrom.tsx +1 -1
  136. package/src/hooks/useValidateAuthenticator.tsx +15 -15
  137. package/src/index.ts +1 -0
  138. package/src/internal/useBuildDataSource.ts +12 -0
  139. package/src/internal/useBuildSideEntityController.tsx +72 -11
  140. package/src/preview/PropertyPreview.tsx +7 -4
  141. package/src/preview/PropertyPreviewProps.tsx +6 -0
  142. package/src/preview/components/BooleanPreview.tsx +2 -2
  143. package/src/preview/components/EnumValuesChip.tsx +1 -1
  144. package/src/preview/components/ImagePreview.tsx +21 -33
  145. package/src/preview/components/ReferencePreview.tsx +22 -22
  146. package/src/preview/components/StorageThumbnail.tsx +5 -1
  147. package/src/preview/components/UrlComponentPreview.tsx +44 -11
  148. package/src/preview/property_previews/ArrayOfMapsPreview.tsx +0 -1
  149. package/src/preview/property_previews/ArrayOfReferencesPreview.tsx +2 -1
  150. package/src/preview/property_previews/ArrayOfStorageComponentsPreview.tsx +0 -1
  151. package/src/preview/property_previews/ArrayOfStringsPreview.tsx +0 -1
  152. package/src/preview/property_previews/ArrayOneOfPreview.tsx +2 -3
  153. package/src/preview/property_previews/ArrayPropertyPreview.tsx +2 -3
  154. package/src/preview/property_previews/MapPropertyPreview.tsx +5 -5
  155. package/src/preview/property_previews/StringPropertyPreview.tsx +2 -2
  156. package/src/types/auth.tsx +1 -1
  157. package/src/types/collections.ts +28 -2
  158. package/src/types/customization_controller.tsx +0 -1
  159. package/src/types/datasource.ts +20 -16
  160. package/src/types/entity_actions.tsx +16 -3
  161. package/src/types/fields.tsx +33 -33
  162. package/src/types/navigation.ts +1 -2
  163. package/src/types/plugins.tsx +12 -3
  164. package/src/types/properties.ts +17 -2
  165. package/src/types/storage.ts +1 -1
  166. package/src/util/entities.ts +4 -3
  167. package/src/util/enums.ts +1 -1
  168. package/src/util/icon_list.ts +2 -2
  169. package/src/util/icon_synonyms.ts +3 -99
  170. package/src/util/objects.ts +25 -28
  171. package/src/util/permissions.ts +1 -0
  172. package/src/util/resolutions.ts +32 -31
  173. package/src/util/storage.ts +75 -21
  174. package/src/util/useStorageUploadController.tsx +21 -3
  175. package/dist/components/VirtualTable/common.d.ts +0 -2
  176. package/dist/core/Drawer.d.ts +0 -23
  177. package/dist/core/Scaffold.d.ts +0 -55
  178. package/dist/core/SideEntityView.d.ts +0 -7
  179. package/dist/form/EntityForm.d.ts +0 -77
  180. package/dist/internal/useBuildCustomizationController.d.ts +0 -2
  181. package/src/core/Drawer.tsx +0 -191
  182. package/src/core/Scaffold.tsx +0 -281
  183. package/src/core/SideEntityView.tsx +0 -38
  184. package/src/form/EntityForm.tsx +0 -728
  185. package/src/internal/useBuildCustomizationController.tsx +0 -5
package/package.json CHANGED
@@ -1,125 +1,133 @@
1
1
  {
2
- "name": "@firecms/core",
3
- "type": "module",
4
- "version": "3.0.0-beta.6",
5
- "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
- "funding": {
7
- "url": "https://github.com/sponsors/firecmsco"
8
- },
9
- "author": "FireCMS",
10
- "license": "MIT",
11
- "repository": "git@github.com:FireCMSco/firecms.git",
12
- "main": "./dist/index.umd.js",
13
- "module": "./dist/index.es.js",
14
- "types": "./dist/index.d.ts",
15
- "source": "src/index.ts",
16
- "engines": {
17
- "node": ">=14"
18
- },
19
- "keywords": [
20
- "firebase",
21
- "cms",
22
- "admin",
23
- "admin panel",
24
- "firebase panel",
25
- "firestore",
26
- "headless",
27
- "headless cms",
28
- "content manager"
29
- ],
30
- "scripts": {
31
- "watch": "vite build --watch",
32
- "build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
33
- "prepublishOnly": "run-s build",
34
- "createTag": "PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag v$PACKAGE_VERSION && git push --tags",
35
- "test:lint": "eslint \"src/**\" --quiet",
36
- "test": "jest",
37
- "clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f",
38
- "generateIcons": "ts-node --esm src/icons/generateIcons.ts"
39
- },
40
- "exports": {
41
- ".": {
42
- "import": "./dist/index.es.js",
43
- "require": "./dist/index.umd.js",
44
- "types": "./dist/index.d.ts"
2
+ "name": "@firecms/core",
3
+ "type": "module",
4
+ "version": "3.0.0-beta.8",
5
+ "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
+ "funding": {
7
+ "url": "https://github.com/sponsors/firecmsco"
45
8
  },
46
- "./package.json": "./package.json"
47
- },
48
- "dependencies": {
49
- "@firecms/formex": "^3.0.0-beta.6",
50
- "@firecms/ui": "^3.0.0-beta.6",
51
- "@fontsource/jetbrains-mono": "^5.0.19",
52
- "@hello-pangea/dnd": "^16.6.0",
53
- "@radix-ui/react-portal": "^1.0.4",
54
- "clsx": "^2.1.0",
55
- "date-fns": "^3.6.0",
56
- "history": "^5.3.0",
57
- "js-search": "^2.0.1",
58
- "markdown-it": "^14.1.0",
59
- "notistack": "^3.0.1",
60
- "object-hash": "^3.0.0",
61
- "react-dropzone": "^14.2.3",
62
- "react-fast-compare": "^3.2.2",
63
- "react-image-file-resizer": "^0.4.8",
64
- "react-markdown-editor-lite": "^1.3.4",
65
- "react-transition-group": "^4.4.5",
66
- "react-use-measure": "^2.1.1",
67
- "react-window": "^1.8.10",
68
- "typeface-rubik": "^1.1.13",
69
- "yup": "^0.32.11"
70
- },
71
- "peerDependencies": {
72
- "firebase": "^10.5.2",
73
- "react": "^18.2.0",
74
- "react-dom": "^18.2.0",
75
- "react-router": "^6.22.0",
76
- "react-router-dom": "^6.22.0"
77
- },
78
- "eslintConfig": {
79
- "extends": [
80
- "react-app",
81
- "react-app/jest"
82
- ]
83
- },
84
- "devDependencies": {
85
- "@jest/globals": "^29.7.0",
86
- "@testing-library/jest-dom": "^6.4.2",
87
- "@testing-library/react": "^14.3.1",
88
- "@testing-library/user-event": "^14.5.2",
89
- "@types/jest": "^29.5.12",
90
- "@types/node": "^20.12.7",
91
- "@types/object-hash": "^3.0.6",
92
- "@types/react": "^18.2.79",
93
- "@types/react-dom": "^18.2.25",
94
- "@types/react-measure": "^2.0.12",
95
- "@typescript-eslint/eslint-plugin": "^7.7.0",
96
- "@typescript-eslint/parser": "^7.7.0",
97
- "@vitejs/plugin-react": "^4.2.1",
98
- "cross-env": "^7.0.3",
99
- "eslint": "^8.57.0",
100
- "eslint-config-standard": "^17.1.0",
101
- "eslint-plugin-import": "^2.29.1",
102
- "eslint-plugin-n": "^16.6.2",
103
- "eslint-plugin-promise": "^6.1.1",
104
- "eslint-plugin-react": "^7.34.1",
105
- "eslint-plugin-react-hooks": "^4.6.0",
106
- "firebase": "^10.11.0",
107
- "jest": "^29.7.0",
108
- "npm-run-all": "^4.1.5",
109
- "react-router": "^6.22.3",
110
- "react-router-dom": "^6.22.3",
111
- "ts-jest": "^29.1.2",
112
- "ts-node": "^10.9.2",
113
- "tsd": "^0.31.0",
114
- "typescript": "^5.4.5",
115
- "vite": "^5.2.9"
116
- },
117
- "files": [
118
- "dist",
119
- "src"
120
- ],
121
- "gitHead": "ffcbddbd73211bb644ff7503c2c62790bff6202a",
122
- "publishConfig": {
123
- "access": "public"
124
- }
9
+ "author": "FireCMS",
10
+ "license": "MIT",
11
+ "repository": "git@github.com:FireCMSco/firecms.git",
12
+ "main": "./dist/index.umd.js",
13
+ "module": "./dist/index.es.js",
14
+ "types": "./dist/index.d.ts",
15
+ "source": "src/index.ts",
16
+ "engines": {
17
+ "node": ">=14"
18
+ },
19
+ "keywords": [
20
+ "firebase",
21
+ "cms",
22
+ "admin",
23
+ "admin panel",
24
+ "firebase panel",
25
+ "firestore",
26
+ "headless",
27
+ "headless cms",
28
+ "content manager"
29
+ ],
30
+ "scripts": {
31
+ "watch": "vite build --watch",
32
+ "build": "vite build && tsc --emitDeclarationOnly -p tsconfig.prod.json",
33
+ "prepublishOnly": "run-s build",
34
+ "createTag": "PACKAGE_VERSION=$(cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]') && git tag v$PACKAGE_VERSION && git push --tags",
35
+ "test:lint": "eslint \"src/**\" --quiet",
36
+ "test": "jest",
37
+ "clean": "rm -rf dist && find ./src -name '*.js' -type f | xargs rm -f",
38
+ "generateIcons": "ts-node --esm src/icons/generateIcons.ts"
39
+ },
40
+ "exports": {
41
+ ".": {
42
+ "import": "./dist/index.es.js",
43
+ "require": "./dist/index.umd.js",
44
+ "types": "./dist/index.d.ts"
45
+ },
46
+ "./package.json": "./package.json"
47
+ },
48
+ "dependencies": {
49
+ "@firecms/formex": "^3.0.0-beta.8",
50
+ "@firecms/ui": "^3.0.0-beta.8",
51
+ "@fontsource/jetbrains-mono": "^5.0.20",
52
+ "@hello-pangea/dnd": "^16.6.0",
53
+ "@radix-ui/react-portal": "^1.1.1",
54
+ "clsx": "^2.1.1",
55
+ "date-fns": "^3.6.0",
56
+ "history": "^5.3.0",
57
+ "js-search": "^2.0.1",
58
+ "markdown-it": "^14.1.0",
59
+ "notistack": "^3.0.1",
60
+ "object-hash": "^3.0.0",
61
+ "react-dropzone": "^14.2.3",
62
+ "react-fast-compare": "^3.2.2",
63
+ "react-image-file-resizer": "^0.4.8",
64
+ "react-markdown-editor-lite": "^1.3.4",
65
+ "react-transition-group": "^4.4.5",
66
+ "react-use-measure": "^2.1.1",
67
+ "react-window": "^1.8.10",
68
+ "typeface-rubik": "^1.1.13",
69
+ "yup": "^0.32.11"
70
+ },
71
+ "peerDependencies": {
72
+ "firebase": "^10.5.2",
73
+ "react": "^18.3.1",
74
+ "react-dom": "^18.3.1",
75
+ "react-router": "^6.22.0",
76
+ "react-router-dom": "^6.22.0"
77
+ },
78
+ "devDependencies": {
79
+ "@jest/globals": "^29.7.0",
80
+ "@testing-library/react": "^15.0.7",
81
+ "@testing-library/user-event": "^14.5.2",
82
+ "@types/jest": "^29.5.12",
83
+ "@types/node": "^20.14.9",
84
+ "@types/object-hash": "^3.0.6",
85
+ "@types/react": "^18.3.3",
86
+ "@types/react-dom": "^18.3.0",
87
+ "@types/react-measure": "^2.0.12",
88
+ "@vitejs/plugin-react": "^4.3.1",
89
+ "cross-env": "^7.0.3",
90
+ "firebase": "^10.12.2",
91
+ "jest": "^29.7.0",
92
+ "npm-run-all": "^4.1.5",
93
+ "react-router": "^6.24.0",
94
+ "react-router-dom": "^6.24.0",
95
+ "ts-jest": "^29.1.5",
96
+ "ts-node": "^10.9.2",
97
+ "tsd": "^0.31.1",
98
+ "typescript": "^5.5.3",
99
+ "vite": "^5.3.2"
100
+ },
101
+ "files": [
102
+ "dist",
103
+ "src"
104
+ ],
105
+ "gitHead": "4ef14d60f86cb2e581b908a1dc84ad6a87b14e2e",
106
+ "publishConfig": {
107
+ "access": "public"
108
+ },
109
+ "eslintConfig": {
110
+ "extends": [
111
+ "react-app",
112
+ "react-app/jest"
113
+ ]
114
+ },
115
+ "jest": {
116
+ "transform": {
117
+ "^.+\\.tsx?$": "ts-jest"
118
+ },
119
+ "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
120
+ "moduleFileExtensions": [
121
+ "ts",
122
+ "tsx",
123
+ "js",
124
+ "jsx",
125
+ "json",
126
+ "node"
127
+ ],
128
+ "testEnvironment": "node",
129
+ "moduleNameMapper": {
130
+ "\\.(css|less)$": "<rootDir>/test/__mocks__/styleMock.js"
131
+ }
132
+ }
125
133
  }
@@ -0,0 +1,18 @@
1
+ import { DefaultAppBar, DefaultAppBarProps } from "../core/DefaultAppBar";
2
+
3
+ /**
4
+ * This component renders the main app bar of FireCMS.
5
+ */
6
+ export function AppBar({
7
+ children,
8
+ ...props
9
+ }: {
10
+ children?: React.ReactNode,
11
+ className?: string,
12
+ style?: React.CSSProperties
13
+ } & DefaultAppBarProps) {
14
+ const usedChildren = children ?? <DefaultAppBar {...props}/>;
15
+ return <>{usedChildren}</>;
16
+ }
17
+
18
+ AppBar.componentType = "AppBar";
@@ -0,0 +1,25 @@
1
+ import { DefaultDrawer } from "../core";
2
+
3
+ /**
4
+ * This component is in charge of rendering the drawer.
5
+ * If you add this component under your {@link Scaffold}, it will be rendered
6
+ * as a drawer, and the open and close functionality will be handled automatically.
7
+ * If you want to customise the drawer, you can create your own component and pass it as a child.
8
+ * For custom drawers, you can use the {@link useApp} to open and close the drawer.
9
+ *
10
+ * @constructor
11
+ */
12
+ export function Drawer({
13
+ children,
14
+ className,
15
+ style
16
+ }: {
17
+ children?: React.ReactNode,
18
+ className?: string,
19
+ style?: React.CSSProperties
20
+ }) {
21
+ const usedChildren = children ?? <DefaultDrawer className={className} style={style}/>;
22
+ return <>{usedChildren}</>;
23
+ }
24
+
25
+ Drawer.componentType = "Drawer";
@@ -0,0 +1,249 @@
1
+ import React, { PropsWithChildren, useCallback } from "react";
2
+ import { ChevronLeftIcon, cls, defaultBorderMixin, IconButton, MenuIcon, Sheet, Tooltip } from "@firecms/ui";
3
+ import equal from "react-fast-compare"
4
+ import { useLargeLayout } from "../hooks";
5
+ import { ErrorBoundary } from "../components";
6
+ import { AppContext } from "./useApp";
7
+
8
+ export const DRAWER_WIDTH = 280;
9
+
10
+ /**
11
+ * @group Core
12
+ */
13
+ export interface ScaffoldProps {
14
+
15
+ /**
16
+ * Open the drawer on hover
17
+ */
18
+ autoOpenDrawer?: boolean;
19
+
20
+ /**
21
+ * Logo to be displayed in the top bar and drawer.
22
+ * Note that this has no effect if you are using a custom AppBar or Drawer.
23
+ */
24
+ logo?: string;
25
+
26
+ className?: string;
27
+
28
+ style?: React.CSSProperties;
29
+ }
30
+
31
+ /**
32
+ * This view acts as a scaffold for FireCMS.
33
+ *
34
+ * It is in charge of displaying the navigation drawer, top bar and main
35
+ * collection views.
36
+ * This component needs a parent {@link FireCMS}
37
+ *
38
+ * @param props
39
+ * @constructor
40
+ * @group Core
41
+ */
42
+ export const Scaffold = React.memo<PropsWithChildren<ScaffoldProps>>(
43
+ function Scaffold(props: PropsWithChildren<ScaffoldProps>) {
44
+
45
+ const {
46
+ children,
47
+ autoOpenDrawer,
48
+ logo,
49
+ className,
50
+ style
51
+ } = props;
52
+
53
+ const drawerChildren = React.Children.toArray(children).filter((child: any) => child.type.componentType === "Drawer");
54
+ if (drawerChildren.length > 1) {
55
+ throw Error("Only one Drawer component is allowed in Scaffold");
56
+ }
57
+ const appBarChildren = React.Children.toArray(children).filter((child: any) => child.type.componentType === "AppBar");
58
+ if (appBarChildren.length > 1) {
59
+ throw Error("Only one AppBar component is allowed in Scaffold");
60
+ }
61
+ const otherChildren = React.Children.toArray(children)
62
+ .filter((child: any) => child.type.componentType !== "Drawer" && child.type.componentType !== "AppBar");
63
+ const includeDrawer = drawerChildren.length > 0;
64
+ const largeLayout = useLargeLayout();
65
+
66
+ const [drawerOpen, setDrawerOpen] = React.useState(false);
67
+ const [onHover, setOnHover] = React.useState(false);
68
+
69
+ const setOnHoverTrue = useCallback(() => setOnHover(true), []);
70
+ const setOnHoverFalse = useCallback(() => setOnHover(false), []);
71
+
72
+ const handleDrawerOpen = useCallback(() => {
73
+ setDrawerOpen(true);
74
+ }, []);
75
+
76
+ const handleDrawerClose = useCallback(() => {
77
+ setDrawerOpen(false);
78
+ }, []);
79
+
80
+ const computedDrawerOpen: boolean = drawerOpen || Boolean(largeLayout && autoOpenDrawer && onHover);
81
+
82
+ return (
83
+ <AppContext.Provider value={{
84
+ logo,
85
+ hasDrawer: includeDrawer,
86
+ drawerHovered: onHover,
87
+ drawerOpen: computedDrawerOpen,
88
+ closeDrawer: handleDrawerClose,
89
+ openDrawer: handleDrawerOpen,
90
+ autoOpenDrawer
91
+ }}>
92
+ <div
93
+ className={cls("flex h-screen w-screen bg-gray-50 dark:bg-gray-900 text-gray-900 dark:text-white overflow-hidden", className)}
94
+ style={{
95
+ paddingTop: "env(safe-area-inset-top)",
96
+ paddingLeft: "env(safe-area-inset-left)",
97
+ paddingRight: "env(safe-area-inset-right)",
98
+ paddingBottom: "env(safe-area-inset-bottom)",
99
+ height: "100dvh",
100
+ ...style
101
+ }}>
102
+
103
+ {appBarChildren}
104
+
105
+ <DrawerWrapper
106
+ displayed={includeDrawer}
107
+ onMouseEnter={setOnHoverTrue}
108
+ onMouseMove={setOnHoverTrue}
109
+ onMouseLeave={setOnHoverFalse}
110
+ open={computedDrawerOpen}
111
+ hovered={onHover}
112
+ setDrawerOpen={setDrawerOpen}>
113
+ {includeDrawer && drawerChildren}
114
+ </DrawerWrapper>
115
+
116
+ <main
117
+ className="flex flex-col flex-grow overflow-auto">
118
+ <DrawerHeader/>
119
+ <div
120
+ className={cls(defaultBorderMixin, "flex-grow overflow-auto lg:m-0 lg:mx-4 lg:mb-4 lg:rounded-lg lg:border lg:border-solid m-0 mt-1")}>
121
+
122
+ <ErrorBoundary>
123
+ {otherChildren}
124
+ </ErrorBoundary>
125
+
126
+ </div>
127
+ </main>
128
+ </div>
129
+ </AppContext.Provider>
130
+ );
131
+ },
132
+ equal
133
+ )
134
+
135
+ const DrawerHeader = () => {
136
+ return (
137
+ <div className="flex flex-col min-h-[68px]"></div>
138
+ );
139
+ };
140
+
141
+ function DrawerWrapper(props: {
142
+ children: React.ReactNode,
143
+ displayed: boolean,
144
+ open: boolean,
145
+ logo?: string,
146
+ hovered: boolean,
147
+ setDrawerOpen: (open: boolean) => void,
148
+ onMouseEnter: () => void,
149
+ onMouseMove: () => void,
150
+ onMouseLeave: () => void
151
+ }) {
152
+
153
+ const width = !props.displayed ? 0 : (props.open ? DRAWER_WIDTH : 72);
154
+ const innerDrawer = <div
155
+ className={"relative h-full no-scrollbar overflow-y-auto overflow-x-hidden"}
156
+ style={{
157
+ width,
158
+ transition: "left 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, opacity 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, width 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms"
159
+ }}
160
+ >
161
+
162
+ {!props.open && props.displayed && (
163
+ <Tooltip title="Open menu"
164
+ side="right"
165
+ sideOffset={12}
166
+ className="fixed top-2 left-3 !bg-gray-50 dark:!bg-gray-900 rounded-full w-fit z-20"
167
+ >
168
+ <IconButton
169
+ color="inherit"
170
+ aria-label="Open menu"
171
+ className="sticky top-2 left-3 "
172
+ onClick={() => props.setDrawerOpen(true)}
173
+ size="large"
174
+ >
175
+ <MenuIcon/>
176
+ </IconButton>
177
+ </Tooltip>
178
+ )}
179
+
180
+ <div
181
+ className={`z-20 absolute right-0 top-4 ${
182
+ props.open ? "opacity-100" : "opacity-0 invisible"
183
+ } transition-opacity duration-200 ease-in-out`}>
184
+ <IconButton
185
+ aria-label="Close drawer"
186
+ onClick={() => props.setDrawerOpen(false)}
187
+ >
188
+ <ChevronLeftIcon/>
189
+ </IconButton>
190
+ </div>
191
+
192
+ <div className={"flex flex-col h-full"}>
193
+ {props.children}
194
+ </div>
195
+
196
+ </div>;
197
+
198
+ const largeLayout = useLargeLayout();
199
+ if (!largeLayout) {
200
+ if (!props.displayed)
201
+ return null;
202
+ return <>
203
+ <IconButton
204
+ color="inherit"
205
+ aria-label="Open drawer"
206
+ onClick={() => props.setDrawerOpen(true)}
207
+ size="large"
208
+ className="absolute top-2 left-6"
209
+ >
210
+ <MenuIcon/>
211
+ </IconButton>
212
+ <Sheet side={"left"}
213
+ transparent={true}
214
+ open={props.open}
215
+ onOpenChange={props.setDrawerOpen}
216
+ >
217
+ {innerDrawer}
218
+ </Sheet>
219
+ </>;
220
+ }
221
+
222
+ return (
223
+ <div
224
+ className="z-20 relative"
225
+ onMouseEnter={props.onMouseEnter}
226
+ onMouseMove={props.onMouseMove}
227
+ onMouseLeave={props.onMouseLeave}
228
+ style={{
229
+ width,
230
+ transition: "left 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, opacity 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms, width 100ms cubic-bezier(0.4, 0, 0.6, 1) 0ms"
231
+ }}>
232
+
233
+ {innerDrawer}
234
+
235
+ {/*<div*/}
236
+ {/* className={`z-20 absolute right-0 top-4 ${*/}
237
+ {/* props.open ? "opacity-100" : "opacity-0 invisible"*/}
238
+ {/* } transition-opacity duration-1000 ease-in-out`}>*/}
239
+ {/* <IconButton*/}
240
+ {/* aria-label="Close drawer"*/}
241
+ {/* onClick={() => props.setDrawerOpen(false)}*/}
242
+ {/* >*/}
243
+ {/* <ChevronLeftIcon/>*/}
244
+ {/* </IconButton>*/}
245
+ {/*</div>*/}
246
+
247
+ </div>
248
+ );
249
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./Drawer";
2
+ export * from "./AppBar";
3
+ export * from "./Scaffold";
4
+ export * from "./useApp";
@@ -0,0 +1,32 @@
1
+ import React from "react";
2
+
3
+ /**
4
+ * This context represents the state of the app in terms of layout.
5
+ * @group Core
6
+ */
7
+ export type AppState = {
8
+ hasDrawer: boolean,
9
+ drawerHovered: boolean,
10
+ drawerOpen: boolean,
11
+ openDrawer: () => void,
12
+ closeDrawer: () => void,
13
+ autoOpenDrawer?: boolean,
14
+ logo?: string
15
+ }
16
+
17
+ export const AppContext = React.createContext<AppState>({
18
+ hasDrawer: false,
19
+ drawerHovered: false,
20
+ drawerOpen: false,
21
+ openDrawer: () => {
22
+ throw new Error("openDrawer not implemented");
23
+ },
24
+ closeDrawer: () => {
25
+ throw new Error("closeDrawer not implemented");
26
+ },
27
+ autoOpenDrawer: false
28
+ });
29
+
30
+ export function useApp() {
31
+ return React.useContext(AppContext);
32
+ }
@@ -1,7 +1,7 @@
1
1
  import React, { MouseEvent, useCallback } from "react";
2
2
 
3
3
  import { CollectionSize, Entity, EntityAction, EntityCollection, SelectionController } from "../../types";
4
- import { Checkbox, cn, IconButton, Menu, MenuItem, MoreVertIcon, Skeleton, Tooltip, Typography } from "@firecms/ui";
4
+ import { Checkbox, cls, IconButton, Menu, MenuItem, MoreVertIcon, Skeleton, Tooltip } from "@firecms/ui";
5
5
  import { useFireCMSContext, useLargeLayout } from "../../hooks";
6
6
 
7
7
  /**
@@ -72,7 +72,7 @@ export const EntityCollectionRowActions = function EntityCollectionRowActions({
72
72
  return (
73
73
  <div
74
74
  onClick={onClick}
75
- className={cn(
75
+ className={cls(
76
76
  "h-full flex items-center justify-center flex-col bg-gray-50 dark:bg-gray-900 bg-opacity-90 dark:bg-opacity-90 z-10",
77
77
  frozen ? "sticky left-0" : ""
78
78
  )}
@@ -149,16 +149,14 @@ export const EntityCollectionRowActions = function EntityCollectionRowActions({
149
149
  </div>}
150
150
 
151
151
  {!hideId && size !== "xs" && (
152
- <div className="w-[138px] text-center overflow-hidden truncate">
152
+ <div
153
+ className="w-[138px] text-center overflow-hidden truncate font-mono text-xs text-text-secondary dark:text-text-secondary-dark max-w-full text-ellipsis px-2"
154
+ onClick={(event) => {
155
+ event.stopPropagation();
156
+ }}>
153
157
 
154
158
  {entity
155
- ? <Typography
156
- onClick={(event) => {
157
- event.stopPropagation();
158
- }}
159
- className={"font-mono select-all"}
160
- variant={"caption"}
161
- color={"secondary"}> {entity.id} </Typography>
159
+ ? entity.id
162
160
  : <Skeleton/>
163
161
  }
164
162
  </div>