@firecms/collection_editor 3.0.1 → 3.1.0-canary.24c8270
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/ConfigControllerProvider.d.ts +6 -0
- package/dist/api/generateCollectionApi.d.ts +71 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.es.js +9466 -5588
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +9461 -5583
- package/dist/index.umd.js.map +1 -1
- package/dist/types/collection_editor_controller.d.ts +14 -0
- package/dist/types/collection_inference.d.ts +8 -2
- package/dist/types/config_controller.d.ts +23 -2
- package/dist/ui/AddKanbanColumnAction.d.ts +11 -0
- package/dist/ui/KanbanSetupAction.d.ts +10 -0
- package/dist/ui/collection_editor/AICollectionGeneratorPopover.d.ts +37 -0
- package/dist/ui/collection_editor/AIModifiedPathsContext.d.ts +20 -0
- package/dist/ui/collection_editor/CollectionDetailsForm.d.ts +2 -3
- package/dist/ui/collection_editor/CollectionEditorDialog.d.ts +24 -0
- package/dist/ui/collection_editor/CollectionEditorWelcomeView.d.ts +4 -1
- package/dist/ui/collection_editor/CollectionJsonImportDialog.d.ts +7 -0
- package/dist/ui/collection_editor/CollectionYupValidation.d.ts +9 -13
- package/dist/ui/collection_editor/DisplaySettingsForm.d.ts +3 -0
- package/dist/ui/collection_editor/EntityActionsEditTab.d.ts +2 -1
- package/dist/ui/collection_editor/ExtendSettingsForm.d.ts +14 -0
- package/dist/ui/collection_editor/GeneralSettingsForm.d.ts +7 -0
- package/dist/ui/collection_editor/KanbanConfigSection.d.ts +4 -0
- package/dist/ui/collection_editor/PropertyEditView.d.ts +6 -1
- package/dist/ui/collection_editor/PropertyTree.d.ts +2 -1
- package/dist/ui/collection_editor/SubcollectionsEditTab.d.ts +2 -1
- package/dist/ui/collection_editor/ViewModeSwitch.d.ts +6 -0
- package/dist/ui/collection_editor/properties/EnumPropertyField.d.ts +2 -1
- package/dist/ui/collection_editor/properties/conditions/ConditionsEditor.d.ts +10 -0
- package/dist/ui/collection_editor/properties/conditions/ConditionsPanel.d.ts +2 -0
- package/dist/ui/collection_editor/properties/conditions/EnumConditionsEditor.d.ts +6 -0
- package/dist/ui/collection_editor/properties/conditions/index.d.ts +6 -0
- package/dist/ui/collection_editor/properties/conditions/property_paths.d.ts +19 -0
- package/dist/useCollectionEditorPlugin.d.ts +7 -1
- package/dist/utils/validateCollectionJson.d.ts +22 -0
- package/package.json +15 -15
- package/src/ConfigControllerProvider.tsx +82 -47
- package/src/api/generateCollectionApi.ts +119 -0
- package/src/api/index.ts +1 -0
- package/src/index.ts +28 -1
- package/src/types/collection_editor_controller.tsx +16 -3
- package/src/types/collection_inference.ts +15 -2
- package/src/types/config_controller.tsx +27 -2
- package/src/ui/AddKanbanColumnAction.tsx +203 -0
- package/src/ui/EditorCollectionActionStart.tsx +1 -2
- package/src/ui/HomePageEditorCollectionAction.tsx +41 -13
- package/src/ui/KanbanSetupAction.tsx +38 -0
- package/src/ui/MissingReferenceWidget.tsx +1 -1
- package/src/ui/NewCollectionButton.tsx +1 -1
- package/src/ui/PropertyAddColumnComponent.tsx +1 -1
- package/src/ui/collection_editor/AICollectionGeneratorPopover.tsx +242 -0
- package/src/ui/collection_editor/AIModifiedPathsContext.tsx +88 -0
- package/src/ui/collection_editor/CollectionDetailsForm.tsx +212 -259
- package/src/ui/collection_editor/CollectionEditorDialog.tsx +237 -169
- package/src/ui/collection_editor/CollectionEditorWelcomeView.tsx +133 -67
- package/src/ui/collection_editor/CollectionJsonImportDialog.tsx +171 -0
- package/src/ui/collection_editor/CollectionPropertiesEditorForm.tsx +190 -91
- package/src/ui/collection_editor/DisplaySettingsForm.tsx +333 -0
- package/src/ui/collection_editor/EntityActionsEditTab.tsx +106 -96
- package/src/ui/collection_editor/EntityActionsSelectDialog.tsx +6 -7
- package/src/ui/collection_editor/EntityCustomViewsSelectDialog.tsx +1 -3
- package/src/ui/collection_editor/EnumForm.tsx +147 -100
- package/src/ui/collection_editor/ExtendSettingsForm.tsx +93 -0
- package/src/ui/collection_editor/GeneralSettingsForm.tsx +337 -0
- package/src/ui/collection_editor/GetCodeDialog.tsx +57 -36
- package/src/ui/collection_editor/KanbanConfigSection.tsx +207 -0
- package/src/ui/collection_editor/LayoutModeSwitch.tsx +22 -41
- package/src/ui/collection_editor/PropertyEditView.tsx +206 -142
- package/src/ui/collection_editor/PropertyFieldPreview.tsx +1 -1
- package/src/ui/collection_editor/PropertyTree.tsx +130 -58
- package/src/ui/collection_editor/SubcollectionsEditTab.tsx +171 -162
- package/src/ui/collection_editor/UnsavedChangesDialog.tsx +0 -2
- package/src/ui/collection_editor/ViewModeSwitch.tsx +41 -0
- package/src/ui/collection_editor/properties/BlockPropertyField.tsx +0 -2
- package/src/ui/collection_editor/properties/BooleanPropertyField.tsx +1 -0
- package/src/ui/collection_editor/properties/DateTimePropertyField.tsx +117 -35
- package/src/ui/collection_editor/properties/EnumPropertyField.tsx +28 -21
- package/src/ui/collection_editor/properties/MapPropertyField.tsx +0 -2
- package/src/ui/collection_editor/properties/MarkdownPropertyField.tsx +115 -39
- package/src/ui/collection_editor/properties/StoragePropertyField.tsx +1 -1
- package/src/ui/collection_editor/properties/conditions/ConditionsEditor.tsx +861 -0
- package/src/ui/collection_editor/properties/conditions/ConditionsPanel.tsx +28 -0
- package/src/ui/collection_editor/properties/conditions/EnumConditionsEditor.tsx +599 -0
- package/src/ui/collection_editor/properties/conditions/index.ts +6 -0
- package/src/ui/collection_editor/properties/conditions/property_paths.ts +92 -0
- package/src/ui/collection_editor/properties/validation/ValidationPanel.tsx +1 -1
- package/src/useCollectionEditorPlugin.tsx +32 -17
- package/src/utils/validateCollectionJson.ts +380 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import React, { createContext, useCallback, useContext, useState } from "react";
|
|
2
|
+
import { CollectionOperation } from "../../api/generateCollectionApi";
|
|
3
|
+
|
|
4
|
+
export interface AIModifiedPathsContextType {
|
|
5
|
+
/** Set of paths that were modified by AI */
|
|
6
|
+
modifiedPaths: Set<string>;
|
|
7
|
+
/** Counter that increments each time AI modifies the collection - use in keys to force remount */
|
|
8
|
+
generationCounter: number;
|
|
9
|
+
/** Add paths from operations */
|
|
10
|
+
addModifiedPaths: (operations: CollectionOperation[]) => void;
|
|
11
|
+
/** Clear a specific path (when user edits that field) */
|
|
12
|
+
clearPath: (path: string) => void;
|
|
13
|
+
/** Clear all paths (on save or cancel) */
|
|
14
|
+
clearAllPaths: () => void;
|
|
15
|
+
/** Check if a path is modified */
|
|
16
|
+
isPathModified: (path: string) => boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const AIModifiedPathsContext = createContext<AIModifiedPathsContextType | null>(null);
|
|
20
|
+
|
|
21
|
+
export function AIModifiedPathsProvider({ children }: { children: React.ReactNode }) {
|
|
22
|
+
const [modifiedPaths, setModifiedPaths] = useState<Set<string>>(new Set());
|
|
23
|
+
const [generationCounter, setGenerationCounter] = useState(0);
|
|
24
|
+
|
|
25
|
+
const addModifiedPaths = useCallback((operations: CollectionOperation[]) => {
|
|
26
|
+
setModifiedPaths(prev => {
|
|
27
|
+
const newSet = new Set(prev);
|
|
28
|
+
operations.forEach(op => {
|
|
29
|
+
// Add the path and all parent paths for nested modifications
|
|
30
|
+
newSet.add(op.path);
|
|
31
|
+
// For properties modifications, also mark the property itself
|
|
32
|
+
// e.g., "properties.email.description" -> also adds "properties.email"
|
|
33
|
+
const parts = op.path.split(".");
|
|
34
|
+
if (parts[0] === "properties" && parts.length >= 2) {
|
|
35
|
+
newSet.add(`properties.${parts[1]}`);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return newSet;
|
|
39
|
+
});
|
|
40
|
+
// Increment counter to force property form remount
|
|
41
|
+
setGenerationCounter(prev => prev + 1);
|
|
42
|
+
}, []);
|
|
43
|
+
|
|
44
|
+
const clearPath = useCallback((path: string) => {
|
|
45
|
+
setModifiedPaths(prev => {
|
|
46
|
+
const newSet = new Set(prev);
|
|
47
|
+
// Remove exact path and any child paths
|
|
48
|
+
for (const p of newSet) {
|
|
49
|
+
if (p === path || p.startsWith(path + ".")) {
|
|
50
|
+
newSet.delete(p);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return newSet;
|
|
54
|
+
});
|
|
55
|
+
}, []);
|
|
56
|
+
|
|
57
|
+
const clearAllPaths = useCallback(() => {
|
|
58
|
+
setModifiedPaths(new Set());
|
|
59
|
+
}, []);
|
|
60
|
+
|
|
61
|
+
const isPathModified = useCallback((path: string): boolean => {
|
|
62
|
+
// Check if this exact path or any parent path is modified
|
|
63
|
+
if (modifiedPaths.has(path)) return true;
|
|
64
|
+
// Check if any child paths are modified
|
|
65
|
+
for (const p of modifiedPaths) {
|
|
66
|
+
if (p.startsWith(path + ".")) return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}, [modifiedPaths]);
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<AIModifiedPathsContext.Provider value={{
|
|
73
|
+
modifiedPaths,
|
|
74
|
+
generationCounter,
|
|
75
|
+
addModifiedPaths,
|
|
76
|
+
clearPath,
|
|
77
|
+
clearAllPaths,
|
|
78
|
+
isPathModified
|
|
79
|
+
}}>
|
|
80
|
+
{children}
|
|
81
|
+
</AIModifiedPathsContext.Provider>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function useAIModifiedPaths(): AIModifiedPathsContextType | null {
|
|
86
|
+
return useContext(AIModifiedPathsContext);
|
|
87
|
+
}
|
|
88
|
+
|