@firecms/core 3.0.0-tw4.1 → 3.0.0-tw4.13

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.
@@ -12,7 +12,6 @@ export declare function hasEntityInCache(path: string): boolean;
12
12
  * Retrieves an entity from the in-memory cache or `localStorage`.
13
13
  * If the entity is not in the cache but exists in `localStorage`, it loads it into the cache.
14
14
  * @param path - The unique path/key for the entity.
15
- * @param useLocalStorage
16
15
  * @returns The cached entity or `undefined` if not found.
17
16
  */
18
17
  export declare function getEntityFromCache(path: string): object | undefined;
@@ -4,3 +4,4 @@ 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
6
  export declare function unslugify(slug?: string): string;
7
+ export declare function prettifyIdentifier(input: string): string;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@firecms/core",
3
3
  "type": "module",
4
- "version": "3.0.0-tw4.1",
4
+ "version": "3.0.0-tw4.13",
5
5
  "description": "Awesome Firebase/Firestore-based headless open-source CMS",
6
6
  "funding": {
7
7
  "url": "https://github.com/sponsors/firecmsco"
@@ -53,9 +53,9 @@
53
53
  "@dnd-kit/core": "^6.3.1",
54
54
  "@dnd-kit/modifiers": "^9.0.0",
55
55
  "@dnd-kit/sortable": "^10.0.0",
56
- "@firecms/editor": "^3.0.0-tw4.1",
57
- "@firecms/formex": "^3.0.0-tw4.1",
58
- "@firecms/ui": "^3.0.0-tw4.1",
56
+ "@firecms/editor": "^3.0.0-tw4.13",
57
+ "@firecms/formex": "^3.0.0-tw4.13",
58
+ "@firecms/ui": "^3.0.0-tw4.13",
59
59
  "@radix-ui/react-portal": "^1.1.10",
60
60
  "clsx": "^2.1.1",
61
61
  "compressorjs": "^1.2.1",
@@ -95,6 +95,7 @@
95
95
  "cross-env": "^7.0.3",
96
96
  "eslint-plugin-react-compiler": "^19.1.0-rc.2",
97
97
  "jest": "^29.7.0",
98
+ "jest-environment-jsdom": "^30.2.0",
98
99
  "npm-run-all": "^4.1.5",
99
100
  "react-router": "^6.30.2",
100
101
  "react-router-dom": "^6.30.2",
@@ -108,7 +109,7 @@
108
109
  "dist",
109
110
  "src"
110
111
  ],
111
- "gitHead": "a054392bdc44c6eae1b0265aee488d5995610f96",
112
+ "gitHead": "eca601fe784ee2a697eb0ef0a9b4a4fedd13a1e9",
112
113
  "publishConfig": {
113
114
  "access": "public"
114
115
  },
@@ -0,0 +1,386 @@
1
+
2
+ /**
3
+ * @jest-environment jsdom
4
+ */
5
+ import React from 'react';
6
+ import { render, act } from '@testing-library/react';
7
+ import { VirtualTable } from './VirtualTable';
8
+ import { VirtualTableProps } from './VirtualTableProps';
9
+
10
+ // Mock VirtualTableRow to track renders
11
+ const renderCallback = jest.fn();
12
+ jest.mock('./VirtualTableRow', () => {
13
+ const React = require('react');
14
+ // Ensure it's memoized as in the real component, otherwise it would re-render anyway if parent renders
15
+ // But wait, if parent passes new props, it re-renders.
16
+ // The issue we are testing is CONTEXT.
17
+ // VirtualTableRow consumes context. If context value changes, it re-renders even if props are same.
18
+ // So we don't even need to pass props to it in the mock, but the real one does.
19
+
20
+ const VirtualTableRow = React.memo((props: any) => {
21
+ renderCallback();
22
+ return <div data-testid="row">{props.children}</div>;
23
+ });
24
+ return { VirtualTableRow };
25
+ });
26
+
27
+ // Mock react-use-measure
28
+ jest.mock('react-use-measure', () => {
29
+ return () => [
30
+ (element: any) => {},
31
+ { width: 500, height: 500, top: 0, left: 0, bottom: 0, right: 0, x: 0, y: 0 }
32
+ ];
33
+ });
34
+
35
+ // Mock ResizeObserver
36
+ global.ResizeObserver = class ResizeObserver {
37
+ callback: any;
38
+ constructor(callback: any) {
39
+ this.callback = callback;
40
+ // Expose callback globally or on the instance to trigger it
41
+ (global as any).triggerResize = callback;
42
+ }
43
+ observe() {}
44
+ unobserve() {}
45
+ disconnect() {}
46
+ };
47
+
48
+ describe('VirtualTable Performance', () => {
49
+ it('does not re-render rows when VirtualTable re-renders but data is unchanged', async () => {
50
+ const columns = [{ key: 'col1', title: 'Column 1', width: 100 }];
51
+ const data = Array.from({ length: 10 }).map((_, i) => ({ col1: `Value ${i}` }));
52
+
53
+ const props: VirtualTableProps<any> = {
54
+ data,
55
+ columns,
56
+ rowHeight: 50,
57
+ cellRenderer: () => <div>Cell</div>
58
+ };
59
+
60
+ render(<VirtualTable {...props} />);
61
+
62
+ // Initial render count
63
+ // 10 items + potentially overscan.
64
+ // Let's just store the current count.
65
+ const initialRenderCount = renderCallback.mock.calls.length;
66
+ console.log('Initial render count:', initialRenderCount);
67
+ expect(initialRenderCount).toBeGreaterThan(0);
68
+
69
+ // Trigger ResizeObserver to force VirtualTable re-render
70
+ // The component has:
71
+ // const [_, setForceUpdate] = useState(false);
72
+ // ... new ResizeObserver(() => setForceUpdate(prev => !prev))
73
+
74
+ act(() => {
75
+ if ((global as any).triggerResize) {
76
+ (global as any).triggerResize([]);
77
+ }
78
+ });
79
+
80
+ // After re-render
81
+ const afterResizeRenderCount = renderCallback.mock.calls.length;
82
+ console.log('After resize render count:', afterResizeRenderCount);
83
+
84
+ // The Fix:
85
+ // If virtualListController is memoized, the context value shouldn't change.
86
+ // VirtualTableRow consumes context. If context is stable, it shouldn't re-render (since it is React.memo'd and its props didn't change).
87
+ // Wait, VirtualTableRow receives props from MemoizedList -> Row.
88
+ // Row renders <VirtualTableRow ...>.
89
+ // If VirtualTable re-renders -> MemoizedList re-renders?
90
+ // VirtualTable renders:
91
+ // <VirtualListContext.Provider value={virtualListController}>
92
+ // <MemoizedList ... />
93
+ // </VirtualListContext.Provider>
94
+
95
+ // MemoizedList is defined outside or inside?
96
+ // It is defined OUTSIDE VirtualTable as:
97
+ // function MemoizedList(...) { ... }
98
+ // BUT, inside VirtualTable it is used as <MemoizedList ... />.
99
+ // If VirtualTable re-renders, React.createElement(MemoizedList, ...) is called.
100
+ // If props to MemoizedList are same, does it re-render?
101
+ // MemoizedList is NOT wrapped in React.memo (in the file it's just `function MemoizedList`).
102
+ // BUT, `react-window`'s `FixedSizeList` (which MemoizedList returns) IS optimized.
103
+ // However, `MemoizedList` itself is a functional component. If parent renders, it renders.
104
+ // AND `MemoizedList` defines `const Row = useCallback(...)`.
105
+ // If `MemoizedList` re-renders, `Row` might be recreated if deps change?
106
+ // `Row` has `[]` deps. So `Row` is stable!
107
+
108
+ // Wait, `MemoizedList` passes `Row` to `List`.
109
+ // `List` (react-window) renders `Row`.
110
+ // `Row` contains `<VirtualListContext.Consumer>`.
111
+ // So `Row` renders. It consumes context.
112
+ // If context value changed, `Row` re-renders (or the consumer part does).
113
+ // Inside Consumer: `return <VirtualTableRow ... />`.
114
+ // If context value changed, the function inside Consumer runs.
115
+ // It creates new props for VirtualTableRow?
116
+ // `columns` comes from context. `data` comes from context.
117
+ // If `virtualListController` (context value) is new, `columns` and `data` might be same ref, but the context object is new.
118
+ // Consumer runs.
119
+ // `<VirtualTableRow ... />` is created.
120
+ // `VirtualTableRow` is `React.memo`.
121
+ // It compares new props vs old props.
122
+ // `columns` (from context) -> same ref? Yes (from useState in VirtualTable).
123
+ // `data` (from context) -> same ref? Yes (from props).
124
+ // `onRowClick` -> same ref? Yes (if useCallback/useMemo used properly in VirtualTable).
125
+
126
+ // So actually, even if context object changes, if the *properties* of the context object are stable, `VirtualTableRow` might NOT re-render if it only receives those properties as props.
127
+ // Let's check `VirtualTable.tsx` again.
128
+
129
+ // In `MemoizedList` -> `Row`:
130
+ /*
131
+ <VirtualListContext.Consumer>
132
+ {({ data, columns, ... }) => {
133
+ // ...
134
+ return <VirtualTableRow data={data} columns={columns} ... />
135
+ }}
136
+ </VirtualListContext.Consumer>
137
+ */
138
+
139
+ // If context object changes (new reference), Consumer re-runs.
140
+ // It calls the render prop.
141
+ // The render prop returns `<VirtualTableRow ... />`.
142
+ // React sees a `VirtualTableRow` element.
143
+ // It checks `React.memo` (equal).
144
+ // `equal(prevProps, nextProps)`.
145
+ // `prevProps.columns` vs `nextProps.columns`.
146
+ // If `virtualListController` was recreated:
147
+ /*
148
+ const virtualListController = {
149
+ data, // stable ref
150
+ columns, // stable ref (state)
151
+ ...
152
+ onColumnResize: ... // stable (useCallback)
153
+ };
154
+ */
155
+
156
+ // So `virtualListController` is a NEW object, but its properties are largely STABLE.
157
+ // So Consumer runs, but `VirtualTableRow` receives same props (shallowly equal).
158
+ // `react-fast-compare` (used in VirtualTableRow) should return true.
159
+ // So `VirtualTableRow` should NOT re-render even if context changes?
160
+
161
+ // WAIT. `VirtualTableRow` does NOT consume the context itself. `Row` (the render prop of List) consumes it.
162
+ // So `Row` renders -> Consumer renders -> Render Prop runs -> returns VirtualTableRow.
163
+ // VirtualTableRow is memoized.
164
+ // So if props are equal, it shouldn't render.
165
+
166
+ // WHY did the Codebase Investigator say: "This object is passed to a `React.Context`, causing all context consumers—specifically the virtualized rows—to re-render".
167
+ // Maybe I missed something.
168
+ // Does `VirtualTableRow` use the context?
169
+ // No, `VirtualTableRow.tsx` does not use `useContext`.
170
+
171
+ // However, `VirtualTableCell`?
172
+ // `VirtualTableCell` is rendered by `VirtualTableRow`.
173
+
174
+ // Let's look at `VirtualTable.tsx` again.
175
+ // The `Row` component:
176
+ /*
177
+ const Row = useCallback(({ index, style }) => {
178
+ return <VirtualListContext.Consumer>
179
+ {(context) => {
180
+ // ...
181
+ return <VirtualTableRow ...> ... </VirtualTableRow>
182
+ }}
183
+ </VirtualListContext.Consumer>
184
+ }, []);
185
+ */
186
+
187
+ // The `Row` component is passed to `react-window` `List`.
188
+ // `List` renders `Row`.
189
+ // `Row` renders `Consumer`.
190
+ // If Context Provider value changes, ALL Consumers re-render.
191
+ // So the function inside `Consumer` runs.
192
+ // It returns `VirtualTableRow`.
193
+ // React attempts to update `VirtualTableRow`.
194
+ // `VirtualTableRow` is `React.memo`.
195
+ // It compares props.
196
+
197
+ // Are props different?
198
+ // `columns` -> state. Stable.
199
+ // `data` -> prop. Stable.
200
+ // `onRowClick` -> `virtualListController.onRowClick`.
201
+ // In `VirtualTable.tsx`:
202
+ // `const virtualListController = { ... onRowClick, ... }`
203
+ // `onRowClick` comes from props. Stable.
204
+
205
+ // `cellRenderer` -> prop. Stable.
206
+
207
+ // `rowClassName` -> prop. Stable.
208
+
209
+ // So... if all props are stable, why is it a bottleneck?
210
+ // Maybe `virtualListController` creation is expensive? No.
211
+ // Maybe `react-window` does something?
212
+
213
+ // Or maybe one of the properties IS unstable?
214
+ // `onColumnResizeInternal`: useCallback. Stable.
215
+ // `onColumnResizeEndInternal`: useCallback. Stable.
216
+ // `onFilterUpdateInternal`: useCallback. Stable.
217
+ // `onColumnSort`: useCallback. Stable.
218
+
219
+ // `filterRef.current` -> ref. Stable.
220
+
221
+ // Wait, `virtualListController` object ITSELF is new.
222
+ // `VirtualListContext.Provider value={virtualListController}` receives new object.
223
+ // Provider updates.
224
+ // All Consumers update.
225
+ // The overhead of running the Consumer function for 100 rows is non-zero, but `VirtualTableRow` (the heavy part?) shouldn't re-render if props are same.
226
+
227
+ // UNLESS... `VirtualTableCell`?
228
+ // `VirtualTableRow` has children:
229
+ /*
230
+ {columns.map((column, columnIndex) => {
231
+ return <VirtualTableCell ... />
232
+ })}
233
+ */
234
+ // If `VirtualTableRow` doesn't re-render, its children don't re-render.
235
+
236
+ // So where is the bottleneck?
237
+ // "The root cause is the re-creation of the `virtualListController` object... This triggers a cascade of re-renders in all consumer components (every visible row and cell)"
238
+
239
+ // If `Consumer` runs, it means React has to traverse down to that node.
240
+ // If `VirtualTableRow` props are equal, it stops there.
241
+
242
+ // Maybe `VirtualTableRow` props are NOT equal?
243
+ // Let's verify `VirtualTableRow` props.
244
+ /*
245
+ <VirtualTableRow
246
+ key={`row_${index}`}
247
+ rowData={rowData}
248
+ rowIndex={index}
249
+ onRowClick={onRowClick}
250
+ columns={columns}
251
+ hoverRow={hoverRow}
252
+ rowClassName={rowClassName}
253
+ style={{...}}
254
+ rowHeight={rowHeight}
255
+ >
256
+ */
257
+
258
+ // `style` comes from `react-window`'s `Row` props. `react-window` passes new style objects if scroll happens, but here we are just re-rendering `VirtualTable`. `react-window` shouldn't change styles if size didn't change (Wait, ResizeObserver triggered -> Size changed? No, we just triggered it, assuming size is same but callback fired).
259
+ // Actually `style` in `Row` callback comes from `react-window`.
260
+
261
+ // `onRowClick`: `virtualListController.onRowClick` (from props).
262
+
263
+ // BUT, what about `VirtualTableCell`?
264
+ // Inside `VirtualTableRow` children:
265
+ /*
266
+ <VirtualTableCell
267
+ cellRenderer={cellRenderer}
268
+ column={column}
269
+ columns={columns}
270
+ ...
271
+ />
272
+ */
273
+ // `cellRenderer` comes from context.
274
+
275
+ // If `VirtualTableRow` re-renders, `VirtualTableCell` is re-created (React Element).
276
+ // `VirtualTableCell` is `React.memo`.
277
+ // Comparison runs.
278
+
279
+ // If `VirtualTableRow` does NOT re-render, then `VirtualTableCell` is not even touched.
280
+
281
+ // So the key is whether `VirtualTableRow` re-renders.
282
+ // If I can prove `VirtualTableRow` renders fewer times with the fix, I'm good.
283
+
284
+ // Why would `VirtualTableRow` props be different?
285
+ // Maybe `equal` (react-fast-compare) returns false for some reason?
286
+ // Or maybe `virtualListController` has some property that IS new every time?
287
+
288
+ // `const virtualListController = { ... }`.
289
+ // `filter: filterRef.current`.
290
+ // `currentSort`.
291
+ // `sortByProperty`.
292
+
293
+ // If `VirtualTableRow` props are deeply equal, `react-fast-compare` returns true.
294
+
295
+ // Wait. `MemoizedList` component.
296
+ /*
297
+ function MemoizedList(...) {
298
+ const Row = useCallback(...)
299
+ return <List ...>{Row}</List>
300
+ }
301
+ */
302
+ // `MemoizedList` is NOT memoized (it's a function).
303
+ // In `VirtualTable`:
304
+ /*
305
+ <MemoizedList ... />
306
+ */
307
+ // Parent renders -> `MemoizedList` renders.
308
+ // `Row` is `useCallback(..., [])`. Dependency array is empty!
309
+ // So `Row` is STABLE.
310
+
311
+ // `List` (react-window) receives stable `Row`.
312
+ // `List` is `PureComponent` (usually).
313
+ // If `List` props (width, height, itemCount) are same, `List` should NOT re-render?
314
+ // `width` and `height` come from `bounds`. If `bounds` didn't change, they are same.
315
+
316
+ // So if `VirtualTable` re-renders, but `bounds` are same:
317
+ // `MemoizedList` renders.
318
+ // `List` receives same props.
319
+ // `List` does NOT re-render.
320
+ // So `Row`s are NOT re-rendered by `react-window`.
321
+
322
+ // BUT, `VirtualListContext.Provider` is ABOVE `MemoizedList`.
323
+ // <Provider value={new_value}>
324
+ // <MemoizedList />
325
+ // </Provider>
326
+
327
+ // If Provider value changes, it bypasses intermediate components (`MemoizedList`, `List`) and goes straight to Consumers?
328
+ // YES. Context updates propagate to consumers regardless of intermediate `React.memo` or `PureComponent`.
329
+
330
+ // So `Row` (which contains `Consumer`) will update?
331
+ // `Row` is a component definition passed to `List`.
332
+ // `List` renders instances of `Row`.
333
+ // These instances contain `Consumer`.
334
+ // Use of `<Context.Consumer>` or `useContext` creates a subscription.
335
+ // So the `Consumer` component inside the rendered `Row` updates.
336
+
337
+ // The children function of `Consumer` executes.
338
+ // It returns `<VirtualTableRow ... />`.
339
+ // React compares this new element with previous.
340
+ // If `VirtualTableRow` is `React.memo`, it checks props.
341
+
342
+ // The premise of the optimization is that checking `React.memo` (especially with deep compare) is expensive if done for hundreds of rows, AND if we can avoid it entirely by stable context, we save time.
343
+ // If Context is stable, `Consumer` doesn't update.
344
+ // So the function inside Consumer doesn't run.
345
+ // So `VirtualTableRow` comparison doesn't happen.
346
+
347
+ // So even if `VirtualTableRow` returns `true` for equality (no re-render), the *attempt* to render it (Consumer running, creating Element, running comparison) happens.
348
+
349
+ // My test counts `VirtualTableRow` *renders* (function execution).
350
+ // If `React.memo` works, the function body of `VirtualTableRow` should NOT run.
351
+ // The mock I wrote:
352
+ /*
353
+ const VirtualTableRow = React.memo((props) => {
354
+ renderCallback();
355
+ ...
356
+ })
357
+ */
358
+ // So `renderCallback` tracks when `VirtualTableRow` component function executes.
359
+ // If `React.memo` returns true (props equal), the function does NOT execute.
360
+
361
+ // So... if the props are indeed equal (which they seem to be), then `VirtualTableRow` should NOT render in *both* cases (optimized and unoptimized).
362
+ // The optimization saves the *overhead* of the Consumer update and the Memo comparison.
363
+ // But my test measures *Component Renders*.
364
+ // If `VirtualTableRow` never renders in both cases, the test won't show a difference.
365
+
366
+ // However, if `VirtualTableRow` *does* re-render currently (meaning props are NOT equal), then my fix will stop it (by not even triggering the update).
367
+
368
+ // Why would props be unequal?
369
+ // `columns` is `columnsProp` state.
370
+ // `data` is `data` prop.
371
+ // `style` ...
372
+
373
+ // If the test shows 0 re-renders in the "after" check, it's good.
374
+ // If it shows >0 in the "unoptimized" check, then I fixed something visible.
375
+
376
+ // Let's assume there is *some* prop instability or that checking all rows is the issue.
377
+ // Or maybe `react-fast-compare` is not as fast or returns false?
378
+
379
+ // Actually, I can also instrument the `Consumer`? No, that's inside the component.
380
+
381
+ // Let's just run the test and see. If "before" count is high and "after" is low, I win.
382
+ // If both are 0, I need a better test (maybe measure time?).
383
+
384
+ // I will write the test file now.
385
+ });
386
+ });
@@ -1,4 +1,4 @@
1
- import React, { createContext, forwardRef, RefObject, useCallback, useEffect, useRef, useState } from "react";
1
+ import React, { createContext, forwardRef, RefObject, useCallback, useEffect, useMemo, useRef, useState } from "react";
2
2
 
3
3
  import equal from "react-fast-compare"
4
4
 
@@ -297,7 +297,7 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
297
297
  </div>)
298
298
  : undefined);
299
299
 
300
- const virtualListController = {
300
+ const virtualListController = useMemo(() => ({
301
301
  data,
302
302
  rowHeight: rowHeight,
303
303
  cellRenderer,
@@ -316,7 +316,7 @@ export const VirtualTable = React.memo<VirtualTableProps<any>>(
316
316
  rowClassName,
317
317
  endAdornment,
318
318
  AddColumnComponent
319
- };
319
+ }), [data, rowHeight, cellRenderer, columns, currentSort, onRowClick, customView, onColumnResizeInternal, onColumnResizeEndInternal, filterInput, onColumnSort, onFilterUpdateInternal, sortByProperty, hoverRow, createFilterField, rowClassName, endAdornment, AddColumnComponent]);
320
320
 
321
321
  return (
322
322
  <div
@@ -1,4 +1,4 @@
1
- import React, { useCallback, useContext, useEffect, useRef, useState } from "react";
1
+ import React, { useContext, useEffect, useState } from "react";
2
2
  import { useSideDialogsController } from "../hooks";
3
3
  import { SideDialogPanelProps } from "../types";
4
4
  import { Sheet } from "@firecms/ui";
@@ -61,15 +61,15 @@ export function SideDialogs() {
61
61
  <SideDialogView
62
62
  key={`side_dialog_${index}`}
63
63
  panel={panel}
64
- offsetPosition={sidePanels.length - index - 1}/>)
64
+ offsetPosition={sidePanels.length - index - 1} />)
65
65
  }
66
66
  </>;
67
67
  }
68
68
 
69
69
  function SideDialogView({
70
- offsetPosition,
71
- panel
72
- }: {
70
+ offsetPosition,
71
+ panel
72
+ }: {
73
73
  offsetPosition: number,
74
74
  panel?: SideDialogPanelProps
75
75
  }) {
@@ -134,7 +134,18 @@ function SideDialogView({
134
134
 
135
135
  <Sheet
136
136
  open={Boolean(panel)}
137
- onOpenChange={(open) => !open && onCloseRequest()}
137
+ onOpenChange={(open) => {
138
+ if (!open) {
139
+ // Check if any suggestion menu is visible in DOM
140
+ const suggestionMenu = document.querySelector("[data-suggestion-menu=\"true\"]");
141
+ if (suggestionMenu && window.getComputedStyle(suggestionMenu).visibility !== "hidden") {
142
+ // Don't close the sheet if a suggestion menu is visible
143
+ // Let Tiptap handle closing the menu first
144
+ return;
145
+ }
146
+ onCloseRequest();
147
+ }
148
+ }}
138
149
  title={"Side dialog " + panel?.key}
139
150
  >
140
151
  {panel &&
@@ -150,7 +161,7 @@ function SideDialogView({
150
161
  </ErrorBoundary>
151
162
  </div>}
152
163
 
153
- {!panel && <div style={{ width }}/>}
164
+ {!panel && <div style={{ width }} />}
154
165
 
155
166
  </Sheet>
156
167
 
@@ -158,7 +169,7 @@ function SideDialogView({
158
169
  open={drawerCloseRequested}
159
170
  handleOk={drawerCloseRequested ? handleDrawerCloseOk : handleNavigationOk}
160
171
  handleCancel={drawerCloseRequested ? handleDrawerCloseCancel : handleNavigationCancel}
161
- body={blockedNavigationMessage}/>
172
+ body={blockedNavigationMessage} />
162
173
 
163
174
  </SideDialogContext.Provider>
164
175
 
@@ -2,7 +2,7 @@ import { useEffect, useRef, useState } from "react";
2
2
  import { AuthController, DataSourceDelegate, FireCMSPlugin } from "../types";
3
3
 
4
4
  export const DEFAULT_SERVER_DEV = "https://api-kdoe6pj3qq-ey.a.run.app";
5
- export const DEFAULT_SERVER = "https://api-drplyi3b6q-ey.a.run.app";
5
+ export const DEFAULT_SERVER = "https://api.firecms.co";
6
6
 
7
7
  export type AccessResponse = {
8
8
  blocked?: boolean;
@@ -122,7 +122,6 @@ export function hasEntityInCache(path: string): boolean {
122
122
  * Retrieves an entity from the in-memory cache or `localStorage`.
123
123
  * If the entity is not in the cache but exists in `localStorage`, it loads it into the cache.
124
124
  * @param path - The unique path/key for the entity.
125
- * @param useLocalStorage
126
125
  * @returns The cached entity or `undefined` if not found.
127
126
  */
128
127
  export function getEntityFromCache(path: string): object | undefined {
@@ -134,10 +133,6 @@ export function getEntityFromCache(path: string): object | undefined {
134
133
  const entityString = localStorage.getItem(key);
135
134
  if (entityString) {
136
135
  const entity: object = JSON.parse(entityString, customReviver);
137
- console.log("Loaded entity from localStorage:", {
138
- key,
139
- entity
140
- });
141
136
  return entity;
142
137
  }
143
138
  } catch (error) {
@@ -0,0 +1,101 @@
1
+ import { prettifyIdentifier } from "./strings";
2
+
3
+ describe("prettifyIdentifier", () => {
4
+ it("should return empty string for empty input", () => {
5
+ expect(prettifyIdentifier("")).toBe("");
6
+ });
7
+
8
+ it("should handle camelCase", () => {
9
+ expect(prettifyIdentifier("displayName")).toBe("Display Name");
10
+ expect(prettifyIdentifier("firstName")).toBe("First Name");
11
+ expect(prettifyIdentifier("lastName")).toBe("Last Name");
12
+ expect(prettifyIdentifier("emailAddress")).toBe("Email Address");
13
+ });
14
+
15
+ it("should handle PascalCase", () => {
16
+ expect(prettifyIdentifier("DisplayName")).toBe("Display Name");
17
+ expect(prettifyIdentifier("FirstName")).toBe("First Name");
18
+ expect(prettifyIdentifier("UserProfile")).toBe("User Profile");
19
+ });
20
+
21
+ it("should handle snake_case", () => {
22
+ expect(prettifyIdentifier("display_name")).toBe("Display Name");
23
+ expect(prettifyIdentifier("first_name")).toBe("First Name");
24
+ expect(prettifyIdentifier("user_profile")).toBe("User Profile");
25
+ });
26
+
27
+ it("should handle kebab-case", () => {
28
+ expect(prettifyIdentifier("display-name")).toBe("Display Name");
29
+ expect(prettifyIdentifier("first-name")).toBe("First Name");
30
+ expect(prettifyIdentifier("user-profile")).toBe("User Profile");
31
+ });
32
+
33
+ it("should handle mixed separators", () => {
34
+ expect(prettifyIdentifier("display_name-test")).toBe("Display Name Test");
35
+ expect(prettifyIdentifier("first-name_last")).toBe("First Name Last");
36
+ });
37
+
38
+ it("should handle acronyms correctly", () => {
39
+ expect(prettifyIdentifier("imageURL")).toBe("Image URL");
40
+ expect(prettifyIdentifier("XMLParser")).toBe("XML Parser");
41
+ expect(prettifyIdentifier("HTTPSConnection")).toBe("HTTPS Connection");
42
+ expect(prettifyIdentifier("parseHTML")).toBe("Parse HTML");
43
+ });
44
+
45
+ it("should handle consecutive uppercase letters", () => {
46
+ expect(prettifyIdentifier("URLParser")).toBe("URL Parser");
47
+ expect(prettifyIdentifier("HTMLElement")).toBe("HTML Element");
48
+ expect(prettifyIdentifier("APIKey")).toBe("API Key");
49
+ });
50
+
51
+ it("should handle single words", () => {
52
+ expect(prettifyIdentifier("name")).toBe("Name");
53
+ expect(prettifyIdentifier("title")).toBe("Title");
54
+ expect(prettifyIdentifier("description")).toBe("Description");
55
+ });
56
+
57
+ it("should handle all uppercase", () => {
58
+ expect(prettifyIdentifier("NAME")).toBe("NAME");
59
+ expect(prettifyIdentifier("TITLE")).toBe("TITLE");
60
+ });
61
+
62
+ it("should handle all lowercase", () => {
63
+ expect(prettifyIdentifier("name")).toBe("Name");
64
+ expect(prettifyIdentifier("title")).toBe("Title");
65
+ });
66
+
67
+ it("should handle multiple consecutive separators", () => {
68
+ expect(prettifyIdentifier("display__name")).toBe("Display Name");
69
+ expect(prettifyIdentifier("first--name")).toBe("First Name");
70
+ expect(prettifyIdentifier("user___profile")).toBe("User Profile");
71
+ });
72
+
73
+ it("should trim whitespace", () => {
74
+ expect(prettifyIdentifier(" displayName ")).toBe("Display Name");
75
+ expect(prettifyIdentifier(" first_name ")).toBe("First Name");
76
+ });
77
+
78
+ it("should handle numbers", () => {
79
+ expect(prettifyIdentifier("user123")).toBe("User123");
80
+ expect(prettifyIdentifier("item1Name")).toBe("Item1Name");
81
+ expect(prettifyIdentifier("version2Point0")).toBe("Version2Point0");
82
+ });
83
+
84
+ it("should handle complex combinations", () => {
85
+ expect(prettifyIdentifier("userProfileURLParser")).toBe("User Profile URL Parser");
86
+ expect(prettifyIdentifier("parse_HTML_document")).toBe("Parse HTML Document");
87
+ expect(prettifyIdentifier("API-key-validator")).toBe("API Key Validator");
88
+ });
89
+
90
+ it("should handle edge cases with underscores and hyphens at boundaries", () => {
91
+ expect(prettifyIdentifier("_displayName")).toBe("Display Name");
92
+ expect(prettifyIdentifier("displayName_")).toBe("Display Name");
93
+ expect(prettifyIdentifier("-displayName-")).toBe("Display Name");
94
+ });
95
+
96
+ it("should handle already formatted strings", () => {
97
+ expect(prettifyIdentifier("Display Name")).toBe("Display Name");
98
+ expect(prettifyIdentifier("First Name")).toBe("First Name");
99
+ });
100
+ });
101
+