@firecms/core 3.0.0-beta.1 → 3.0.0-beta.2-pre.2
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/dist/components/ArrayContainer.d.ts +1 -3
- package/dist/components/EntityCollectionTable/EntityCollectionTableProps.d.ts +1 -2
- package/dist/components/EntityCollectionTable/{SimpleEntityCollectionTable.d.ts → SimpleTable.d.ts} +7 -26
- package/dist/components/EntityCollectionTable/index.d.ts +1 -1
- package/dist/components/EntityCollectionTable/useDataSourceEntityCollectionTableController.d.ts +1 -1
- package/dist/components/{FieldConfigBadge.d.ts → PropertyConfigBadge.d.ts} +1 -1
- package/dist/components/index.d.ts +1 -1
- package/dist/core/Scaffold.d.ts +5 -2
- package/dist/form/components/CustomIdField.d.ts +2 -1
- package/dist/index.es.js +4269 -4446
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +5 -5
- package/dist/index.umd.js.map +1 -1
- package/dist/types/datasource.d.ts +3 -3
- package/dist/types/entity_callbacks.d.ts +1 -1
- package/dist/util/strings.d.ts +1 -1
- package/package.json +16 -16
- package/src/components/ArrayContainer.tsx +31 -67
- package/src/components/EntityCollectionTable/EntityCollectionTable.tsx +78 -262
- package/src/components/EntityCollectionTable/EntityCollectionTableProps.tsx +1 -2
- package/src/components/EntityCollectionTable/{SimpleEntityCollectionTable.tsx → SimpleTable.tsx} +36 -73
- package/src/components/EntityCollectionTable/index.tsx +1 -1
- package/src/components/EntityCollectionTable/useDataSourceEntityCollectionTableController.tsx +1 -1
- package/src/components/EntityCollectionView/EntityCollectionView.tsx +9 -8
- package/src/components/EntityPreview.tsx +0 -1
- package/src/components/LabelWithIcon.tsx +1 -1
- package/src/components/{FieldConfigBadge.tsx → PropertyConfigBadge.tsx} +1 -1
- package/src/components/ReferenceSelectionInner.tsx +0 -1
- package/src/components/index.tsx +1 -1
- package/src/core/NavigationRoutes.tsx +0 -1
- package/src/core/Scaffold.tsx +11 -8
- package/src/form/EntityForm.tsx +12 -2
- package/src/form/components/CustomIdField.tsx +16 -4
- package/src/form/components/ErrorFocus.tsx +1 -1
- package/src/form/field_bindings/ArrayOfReferencesFieldBinding.tsx +1 -2
- package/src/form/field_bindings/MarkdownFieldBinding.tsx +2 -2
- package/src/form/field_bindings/ReadOnlyFieldBinding.tsx +1 -2
- package/src/form/field_bindings/ReferenceFieldBinding.tsx +1 -2
- package/src/hooks/useLargeLayout.tsx +10 -7
- package/src/internal/useBuildDataSource.ts +9 -9
- package/src/preview/PropertyPreviewProps.tsx +1 -1
- package/src/types/datasource.ts +3 -3
- package/src/types/entity_callbacks.ts +2 -1
- package/src/util/strings.ts +2 -1
|
@@ -24,7 +24,7 @@ export interface FetchCollectionProps<M extends Record<string, any> = any> {
|
|
|
24
24
|
collection?: EntityCollection<M> | ResolvedEntityCollection<M>;
|
|
25
25
|
filter?: FilterValues<Extract<keyof M, string>>;
|
|
26
26
|
limit?: number;
|
|
27
|
-
startAfter?: any
|
|
27
|
+
startAfter?: any;
|
|
28
28
|
orderBy?: string;
|
|
29
29
|
searchString?: string;
|
|
30
30
|
order?: "desc" | "asc";
|
|
@@ -139,7 +139,7 @@ export interface DataSource {
|
|
|
139
139
|
/**
|
|
140
140
|
* Count the number of entities in a collection
|
|
141
141
|
*/
|
|
142
|
-
countEntities
|
|
142
|
+
countEntities?<M extends Record<string, any> = any>(props: FetchCollectionProps<M>): Promise<number>;
|
|
143
143
|
/**
|
|
144
144
|
* Check if the given filter combination is valid
|
|
145
145
|
* @param props
|
|
@@ -235,7 +235,7 @@ export interface DataSourceDelegate {
|
|
|
235
235
|
/**
|
|
236
236
|
* Count the number of entities in a collection
|
|
237
237
|
*/
|
|
238
|
-
countEntities
|
|
238
|
+
countEntities?<M extends Record<string, any> = any>(props: FetchCollectionDelegateProps<M>): Promise<number>;
|
|
239
239
|
/**
|
|
240
240
|
* Check if the given filter combination is valid
|
|
241
241
|
* @param props
|
|
@@ -53,7 +53,7 @@ export type EntityCallbacks<M extends Record<string, any> = any, UserType extend
|
|
|
53
53
|
*
|
|
54
54
|
* @param idUpdateProps
|
|
55
55
|
*/
|
|
56
|
-
onIdUpdate?(idUpdateProps: EntityIdUpdateProps<M>): string
|
|
56
|
+
onIdUpdate?(idUpdateProps: EntityIdUpdateProps<M>): string | Promise<string>;
|
|
57
57
|
};
|
|
58
58
|
/**
|
|
59
59
|
* Parameters passed to hooks when an entity is fetched
|
package/dist/util/strings.d.ts
CHANGED
|
@@ -3,4 +3,4 @@ export declare const toSnakeCase: (str: string) => string;
|
|
|
3
3
|
export declare function randomString(strLength?: number): string;
|
|
4
4
|
export declare function randomColor(): string;
|
|
5
5
|
export declare function slugify(text?: string, separator?: string, lowercase?: boolean): string;
|
|
6
|
-
export declare function unslugify(slug
|
|
6
|
+
export declare function unslugify(slug?: string): string;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@firecms/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.0-beta.
|
|
4
|
+
"version": "3.0.0-beta.2-pre.2",
|
|
5
5
|
"description": "Awesome Firebase/Firestore-based headless open-source CMS",
|
|
6
6
|
"funding": {
|
|
7
7
|
"url": "https://github.com/sponsors/firecmsco"
|
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"generateIcons": "ts-node --esm src/icons/generateIcons.ts"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@firecms/ui": "^3.0.0-beta.
|
|
41
|
+
"@firecms/ui": "^3.0.0-beta.2-pre.2",
|
|
42
42
|
"@fontsource/ibm-plex-mono": "^5.0.8",
|
|
43
43
|
"@fontsource/roboto": "^5.0.8",
|
|
44
44
|
"@hello-pangea/dnd": "^16.5.0",
|
|
45
|
-
"date-fns": "^3.
|
|
45
|
+
"date-fns": "^3.3.1",
|
|
46
46
|
"formik": "^2.4.5",
|
|
47
47
|
"history": "^5.3.0",
|
|
48
48
|
"js-search": "^2.0.1",
|
|
@@ -73,41 +73,41 @@
|
|
|
73
73
|
"devDependencies": {
|
|
74
74
|
"@jest/globals": "^29.7.0",
|
|
75
75
|
"@testing-library/jest-dom": "^5.17.0",
|
|
76
|
-
"@testing-library/react": "^14.
|
|
77
|
-
"@testing-library/user-event": "^14.5.
|
|
78
|
-
"@types/jest": "^29.5.
|
|
79
|
-
"@types/node": "^20.
|
|
76
|
+
"@testing-library/react": "^14.2.1",
|
|
77
|
+
"@testing-library/user-event": "^14.5.2",
|
|
78
|
+
"@types/jest": "^29.5.12",
|
|
79
|
+
"@types/node": "^20.11.16",
|
|
80
80
|
"@types/object-hash": "^3.0.6",
|
|
81
|
-
"@types/react": "^18.2.
|
|
82
|
-
"@types/react-dom": "^18.2.
|
|
81
|
+
"@types/react": "^18.2.54",
|
|
82
|
+
"@types/react-dom": "^18.2.18",
|
|
83
83
|
"@types/react-measure": "^2.0.12",
|
|
84
84
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
|
85
85
|
"@typescript-eslint/parser": "^5.62.0",
|
|
86
86
|
"@vitejs/plugin-react": "^4.2.1",
|
|
87
87
|
"cross-env": "^7.0.3",
|
|
88
|
-
"eslint": "^8.
|
|
88
|
+
"eslint": "^8.56.0",
|
|
89
89
|
"eslint-config-standard": "^17.1.0",
|
|
90
90
|
"eslint-plugin-import": "^2.29.1",
|
|
91
91
|
"eslint-plugin-n": "^15.7.0",
|
|
92
92
|
"eslint-plugin-promise": "^6.1.1",
|
|
93
93
|
"eslint-plugin-react": "^7.33.2",
|
|
94
94
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
95
|
-
"firebase": "^10.
|
|
95
|
+
"firebase": "^10.8.0",
|
|
96
96
|
"jest": "^29.7.0",
|
|
97
97
|
"npm-run-all": "^4.1.5",
|
|
98
|
-
"react-router": "^6.
|
|
99
|
-
"react-router-dom": "^6.
|
|
100
|
-
"ts-jest": "^29.1.
|
|
98
|
+
"react-router": "^6.22.0",
|
|
99
|
+
"react-router-dom": "^6.22.0",
|
|
100
|
+
"ts-jest": "^29.1.2",
|
|
101
101
|
"ts-node": "^10.9.2",
|
|
102
102
|
"tsd": "^0.28.1",
|
|
103
103
|
"typescript": "^5.3.3",
|
|
104
|
-
"vite": "^4.5.
|
|
104
|
+
"vite": "^4.5.2"
|
|
105
105
|
},
|
|
106
106
|
"files": [
|
|
107
107
|
"dist",
|
|
108
108
|
"src"
|
|
109
109
|
],
|
|
110
|
-
"gitHead": "
|
|
110
|
+
"gitHead": "f3f62fc3cbc4f0d9d1a26817a14cff06393b7c2b",
|
|
111
111
|
"publishConfig": {
|
|
112
112
|
"access": "public"
|
|
113
113
|
}
|
|
@@ -3,7 +3,6 @@ import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
|
3
3
|
import { DragDropContext, Draggable, DraggableProvided, Droppable } from "@hello-pangea/dnd";
|
|
4
4
|
|
|
5
5
|
import { getHashValue } from "../util";
|
|
6
|
-
import useMeasure from "react-use-measure";
|
|
7
6
|
import {
|
|
8
7
|
AddIcon,
|
|
9
8
|
Button,
|
|
@@ -12,9 +11,9 @@ import {
|
|
|
12
11
|
IconButton,
|
|
13
12
|
Menu,
|
|
14
13
|
MenuItem,
|
|
15
|
-
MoreVertIcon,
|
|
16
14
|
RemoveIcon,
|
|
17
|
-
Tooltip
|
|
15
|
+
Tooltip,
|
|
16
|
+
useOutsideAlerter
|
|
18
17
|
} from "@firecms/ui";
|
|
19
18
|
|
|
20
19
|
interface ArrayContainerProps<T> {
|
|
@@ -224,11 +223,6 @@ export function ArrayContainerItem({
|
|
|
224
223
|
isDragging
|
|
225
224
|
}: ArrayContainerItemProps) {
|
|
226
225
|
|
|
227
|
-
const [measureRef, bounds] = useMeasure();
|
|
228
|
-
|
|
229
|
-
const measuring = size !== "small" && bounds.height === 0;
|
|
230
|
-
const menuOverflow = size !== "small" && bounds.height < 100;
|
|
231
|
-
|
|
232
226
|
const [onHover, setOnHover] = React.useState(false);
|
|
233
227
|
const setOnHoverTrue = useCallback(() => setOnHover(true), []);
|
|
234
228
|
const setOnHoverFalse = useCallback(() => setOnHover(false), []);
|
|
@@ -246,9 +240,7 @@ export function ArrayContainerItem({
|
|
|
246
240
|
>
|
|
247
241
|
<div
|
|
248
242
|
className="flex items-start">
|
|
249
|
-
<div
|
|
250
|
-
className="flex-grow w-[calc(100%-48px)] text-text-primary dark:text-text-primary-dark"
|
|
251
|
-
>
|
|
243
|
+
<div className="flex-grow w-[calc(100%-48px)] text-text-primary dark:text-text-primary-dark">
|
|
252
244
|
{buildEntry(index, internalId)}
|
|
253
245
|
</div>
|
|
254
246
|
<ArrayItemOptions direction={size === "small" ? "row" : "column"}
|
|
@@ -256,8 +248,6 @@ export function ArrayContainerItem({
|
|
|
256
248
|
remove={remove}
|
|
257
249
|
index={index}
|
|
258
250
|
provided={provided}
|
|
259
|
-
measuring={measuring}
|
|
260
|
-
contentOverflow={menuOverflow}
|
|
261
251
|
copy={copy}/>
|
|
262
252
|
</div>
|
|
263
253
|
</div>;
|
|
@@ -270,12 +260,8 @@ export function ArrayItemOptions({
|
|
|
270
260
|
index,
|
|
271
261
|
provided,
|
|
272
262
|
copy,
|
|
273
|
-
contentOverflow,
|
|
274
|
-
measuring
|
|
275
263
|
}: {
|
|
276
264
|
direction?: "row" | "column",
|
|
277
|
-
contentOverflow: boolean,
|
|
278
|
-
measuring: boolean,
|
|
279
265
|
disabled: boolean,
|
|
280
266
|
remove: (index: number) => void,
|
|
281
267
|
index: number,
|
|
@@ -283,65 +269,41 @@ export function ArrayItemOptions({
|
|
|
283
269
|
copy: (index: number) => void
|
|
284
270
|
}) {
|
|
285
271
|
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
>
|
|
272
|
+
const [menuOpen, setMenuOpen] = useState(false);
|
|
273
|
+
|
|
274
|
+
const iconRef = React.useRef<HTMLDivElement>(null);
|
|
275
|
+
useOutsideAlerter(iconRef, () => setMenuOpen(false));
|
|
276
|
+
|
|
277
|
+
return <div className={`ml-2 flex ${direction === "row" ? "flex-row-reverse" : "flex-col"} items-center`}
|
|
278
|
+
ref={iconRef}
|
|
279
|
+
{...provided.dragHandleProps}>
|
|
289
280
|
<Tooltip
|
|
281
|
+
delayDuration={400}
|
|
282
|
+
open={menuOpen ? false : undefined}
|
|
290
283
|
side={direction === "column" ? "left" : undefined}
|
|
291
|
-
title="
|
|
284
|
+
title="Drag to move. Click for more options">
|
|
285
|
+
|
|
292
286
|
<IconButton
|
|
293
287
|
size="small"
|
|
294
288
|
disabled={disabled}
|
|
289
|
+
onClick={() => setMenuOpen(true)}
|
|
290
|
+
onDragStart={(e: any) => {
|
|
291
|
+
setMenuOpen(false);
|
|
292
|
+
}}
|
|
295
293
|
className={`cursor-${disabled ? "inherit" : "grab"}`}>
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
<
|
|
294
|
+
<svg width="24" height="24" viewBox="0 0 100 100" fill="none">
|
|
295
|
+
<circle cx="28" cy="50" r="9" fill={"currentColor"}/>
|
|
296
|
+
<circle cx="28" cy="21" r="9" fill={"currentColor"}/>
|
|
297
|
+
<circle cx="71" cy="21" r="9" fill={"currentColor"}/>
|
|
298
|
+
<circle cx="71" cy="50" r="9" fill={"currentColor"}/>
|
|
299
|
+
<circle cx="71" cy="78" r="9" fill={"currentColor"}/>
|
|
300
|
+
<circle cx="28" cy="78" r="9" fill={"currentColor"}/>
|
|
302
301
|
</svg>
|
|
303
|
-
{/*<DragHandleIcon*/}
|
|
304
|
-
{/* size={"small"}*/}
|
|
305
|
-
{/* color={disabled ? "disabled" : "inherit"}/>*/}
|
|
306
302
|
</IconButton>
|
|
307
|
-
</Tooltip>
|
|
308
|
-
|
|
309
|
-
{!measuring && !contentOverflow && <>
|
|
310
|
-
<Tooltip
|
|
311
|
-
title="Remove"
|
|
312
|
-
side={direction === "column" ? "left" : undefined}>
|
|
313
|
-
<IconButton
|
|
314
|
-
size="small"
|
|
315
|
-
aria-label="remove"
|
|
316
|
-
disabled={disabled}
|
|
317
|
-
onClick={() => remove(index)}>
|
|
318
|
-
<RemoveIcon
|
|
319
|
-
size={"small"}/>
|
|
320
|
-
</IconButton>
|
|
321
|
-
</Tooltip>
|
|
322
|
-
|
|
323
|
-
<Tooltip
|
|
324
|
-
side={direction === "column" ? "left" : undefined}
|
|
325
|
-
title="Copy in this position">
|
|
326
|
-
<IconButton
|
|
327
|
-
size="small"
|
|
328
|
-
aria-label="copy"
|
|
329
|
-
disabled={disabled}
|
|
330
|
-
onClick={() => copy(index)}>
|
|
331
|
-
<ContentCopyIcon
|
|
332
|
-
size={"small"}/>
|
|
333
|
-
</IconButton>
|
|
334
|
-
</Tooltip>
|
|
335
|
-
</>}
|
|
336
|
-
|
|
337
|
-
{!measuring && contentOverflow && <>
|
|
338
303
|
|
|
339
304
|
<Menu
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
size={"small"}/>
|
|
343
|
-
</IconButton>}
|
|
344
|
-
>
|
|
305
|
+
open={menuOpen}
|
|
306
|
+
trigger={<div/>}>
|
|
345
307
|
|
|
346
308
|
<MenuItem dense onClick={() => remove(index)}>
|
|
347
309
|
<RemoveIcon size={"small"}/>
|
|
@@ -353,7 +315,9 @@ export function ArrayItemOptions({
|
|
|
353
315
|
</MenuItem>
|
|
354
316
|
|
|
355
317
|
</Menu>
|
|
356
|
-
|
|
318
|
+
|
|
319
|
+
</Tooltip>
|
|
320
|
+
|
|
357
321
|
</div>;
|
|
358
322
|
}
|
|
359
323
|
|