react-formule 1.4.0 → 1.6.0
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/README.md +235 -11
- package/dist/admin/formComponents/PropKeyEditorObjectFieldTemplate.d.ts +4 -0
- package/dist/admin/formComponents/SortableBox.d.ts +15 -17
- package/dist/admin/utils/fieldTypes.d.ts +852 -410
- package/dist/admin/utils/index.d.ts +1 -0
- package/dist/ai/AiChatFooter.d.ts +9 -0
- package/dist/ai/AiDiff.d.ts +9 -0
- package/dist/ai/AiSettingsDialog.d.ts +7 -0
- package/dist/ai/defaults.d.ts +4 -0
- package/dist/ai/hooks.d.ts +4 -0
- package/dist/ai/utils.d.ts +5 -0
- package/dist/contexts/CustomizationContext.d.ts +3 -1
- package/dist/exposed.d.ts +8 -18
- package/dist/forms/Form.d.ts +2 -0
- package/dist/forms/fields/base/CodeEditorField.d.ts +1 -2
- package/dist/forms/fields/base/FileField.d.ts +12 -0
- package/dist/forms/fields/base/index.d.ts +2 -0
- package/dist/forms/templates/ArrayFieldTemplates/{NormalArrayFieldTemplate.d.ts → ArrayFieldTemplate.d.ts} +3 -3
- package/dist/forms/templates/Field/FieldCollapsible.d.ts +6 -0
- package/dist/forms/templates/utils/index.d.ts +1 -0
- package/dist/forms/widgets/base/MaskedInput/MaskedInput.d.ts +2 -1
- package/dist/index.d.ts +8 -1
- package/dist/react-formule.js +153784 -143696
- package/dist/react-formule.umd.cjs +693 -544
- package/dist/store/configureStore.d.ts +8 -0
- package/dist/store/schemaWizard.d.ts +16 -1
- package/dist/types/index.d.ts +108 -0
- package/dist/utils/CodeDiffViewer.d.ts +2 -1
- package/dist/utils/FieldMessageTag.d.ts +4 -0
- package/package.json +7 -4
- package/dist/admin/formComponents/RenderSortable.d.ts +0 -2
- package/dist/vite.svg +0 -1
|
@@ -20,6 +20,10 @@ declare const store: import('@reduxjs/toolkit/dist/configureStore').ToolkitStore
|
|
|
20
20
|
id: string;
|
|
21
21
|
field: {};
|
|
22
22
|
formData: {};
|
|
23
|
+
files: {
|
|
24
|
+
new: {};
|
|
25
|
+
deleted: string[];
|
|
26
|
+
};
|
|
23
27
|
};
|
|
24
28
|
}, import('redux').AnyAction, import('@reduxjs/toolkit').MiddlewareArray<[import('redux-thunk').ThunkMiddleware<{
|
|
25
29
|
schemaWizard: {
|
|
@@ -39,6 +43,10 @@ declare const store: import('@reduxjs/toolkit/dist/configureStore').ToolkitStore
|
|
|
39
43
|
id: string;
|
|
40
44
|
field: {};
|
|
41
45
|
formData: {};
|
|
46
|
+
files: {
|
|
47
|
+
new: {};
|
|
48
|
+
deleted: string[];
|
|
49
|
+
};
|
|
42
50
|
};
|
|
43
51
|
}, import('redux').AnyAction>, ({ getState }: {
|
|
44
52
|
getState: any;
|
|
@@ -15,12 +15,23 @@ export declare const initialState: {
|
|
|
15
15
|
id: string;
|
|
16
16
|
field: {};
|
|
17
17
|
formData: {};
|
|
18
|
+
files: {
|
|
19
|
+
new: {};
|
|
20
|
+
deleted: string[];
|
|
21
|
+
};
|
|
18
22
|
};
|
|
19
23
|
export type SchemaWizardState = typeof initialState;
|
|
20
24
|
export declare const schemaInit: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
21
25
|
data: any;
|
|
22
26
|
id: any;
|
|
23
|
-
}, "schemaWizard/schemaInit">, enableCreateMode: import('@reduxjs/toolkit').ActionCreatorWithoutPayload<"schemaWizard/enableCreateMode">, selectProperty: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/selectProperty">, updateSchemaByPath: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/updateSchemaByPath">, updateUiSchemaByPath: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/updateUiSchemaByPath">, addByPath: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/addByPath">, deleteByPath: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/deleteByPath">, renameIdByPath: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/renameIdByPath">, updateRequired: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/updateRequired">, updateFormData: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/updateFormData"
|
|
27
|
+
}, "schemaWizard/schemaInit">, enableCreateMode: import('@reduxjs/toolkit').ActionCreatorWithoutPayload<"schemaWizard/enableCreateMode">, selectProperty: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/selectProperty">, updateByPath: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/updateByPath">, updateSchemaByPath: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/updateSchemaByPath">, updateUiSchemaByPath: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/updateUiSchemaByPath">, addByPath: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/addByPath">, deleteByPath: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/deleteByPath">, renameIdByPath: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/renameIdByPath">, updateRequired: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/updateRequired">, updateFormData: import('@reduxjs/toolkit').ActionCreatorWithPayload<any, "schemaWizard/updateFormData">, addFile: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
28
|
+
uid: string;
|
|
29
|
+
objectUrl: string;
|
|
30
|
+
}, "schemaWizard/addFile">, removeNewFile: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
31
|
+
uid: string;
|
|
32
|
+
}, "schemaWizard/removeNewFile">, removeExistingFile: import('@reduxjs/toolkit').ActionCreatorWithPayload<{
|
|
33
|
+
uid: string;
|
|
34
|
+
}, "schemaWizard/removeExistingFile">;
|
|
24
35
|
declare const _default: import('redux').Reducer<{
|
|
25
36
|
current: {
|
|
26
37
|
schema: {
|
|
@@ -38,5 +49,9 @@ declare const _default: import('redux').Reducer<{
|
|
|
38
49
|
id: string;
|
|
39
50
|
field: {};
|
|
40
51
|
formData: {};
|
|
52
|
+
files: {
|
|
53
|
+
new: {};
|
|
54
|
+
deleted: string[];
|
|
55
|
+
};
|
|
41
56
|
}>;
|
|
42
57
|
export default _default;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { ThemeConfig } from 'antd';
|
|
3
|
+
import { SchemaWizardState } from '../store/schemaWizard';
|
|
4
|
+
|
|
5
|
+
export type CustomFunctions = {
|
|
6
|
+
file?: {
|
|
7
|
+
/**
|
|
8
|
+
* Function to fetch a file based on a file UID. Formule will call this function with
|
|
9
|
+
* each of the file UIDs in a Files field's formData to initialize it with the files
|
|
10
|
+
* fetched from the URL returned by this function.
|
|
11
|
+
* @param uid The UID of the file to fetch
|
|
12
|
+
* @returns An object URL for the file which can be a promise. This can be:
|
|
13
|
+
* - Simply a url to your backend, requiring no processing from your side
|
|
14
|
+
* - If you have a more complex use case, where you need to configure authentication,
|
|
15
|
+
* etc, you can instead fetch the file inside this function using your custom logic
|
|
16
|
+
* and then create and return an object URL with URL.createObjectURL()
|
|
17
|
+
*/
|
|
18
|
+
fetchFile: (uid: string) => string | Promise<string>;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type TokenUsage = {
|
|
22
|
+
prompt: number;
|
|
23
|
+
completion: number;
|
|
24
|
+
total: number;
|
|
25
|
+
cached?: number;
|
|
26
|
+
};
|
|
27
|
+
export type AISuggestion = {
|
|
28
|
+
schema: object;
|
|
29
|
+
uiSchema: object;
|
|
30
|
+
usage?: TokenUsage;
|
|
31
|
+
};
|
|
32
|
+
export type AIError = {
|
|
33
|
+
error: string;
|
|
34
|
+
usage?: TokenUsage;
|
|
35
|
+
};
|
|
36
|
+
export type AIResponse = AISuggestion | AIError;
|
|
37
|
+
/**
|
|
38
|
+
* Configuration for an AI Provider. New providers will override the defaults.
|
|
39
|
+
* If you want to add a new provider while keeping the defaults, you can import
|
|
40
|
+
* and include `...defaultProviders`.
|
|
41
|
+
*/
|
|
42
|
+
export type AIProvider = {
|
|
43
|
+
/** Label for the AI provider in the UI */
|
|
44
|
+
label: ReactNode;
|
|
45
|
+
/**
|
|
46
|
+
* Optional provider API key. If not provided here, you should request it from the user,
|
|
47
|
+
* for example using the `AiSettingsDialog` component.
|
|
48
|
+
*/
|
|
49
|
+
apiKey?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Optional model identifier. If not provided, you need to pass a
|
|
52
|
+
* `fetchModels` function to be called by `AiSettingsDialog`.
|
|
53
|
+
*/
|
|
54
|
+
model?: string;
|
|
55
|
+
/** Show this model as a recommended default in the `AiSettingsDialog` panel.
|
|
56
|
+
* If not provided, no model will be recommended.
|
|
57
|
+
*/
|
|
58
|
+
recommendedModel?: {
|
|
59
|
+
id: string;
|
|
60
|
+
name: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Function to retrieve available models (used in the AiSettingsDialog component).
|
|
64
|
+
* Not needed when the api key and model are provided directly.
|
|
65
|
+
* @param apiKey - Provider API key
|
|
66
|
+
* @returns Promise containing an array of available models with their IDs and display names
|
|
67
|
+
*/
|
|
68
|
+
fetchModels?: (apiKey: string) => Promise<{
|
|
69
|
+
id: string;
|
|
70
|
+
name: string;
|
|
71
|
+
}[]>;
|
|
72
|
+
/**
|
|
73
|
+
* Main function to generate schema modifications. You must use your own system prompt.
|
|
74
|
+
* @param prompt - User prompt
|
|
75
|
+
* @param currentSchema - Current form state (schema and uiSchema)
|
|
76
|
+
* @param fieldTypes - Field type specification
|
|
77
|
+
* @param apiKey - Provider API key
|
|
78
|
+
* @param model - Model identifier to use
|
|
79
|
+
* @returns Promise containing the generated schema (or otherwise error) with optional token usage information
|
|
80
|
+
*/
|
|
81
|
+
generateSchema: (prompt: string, currentSchema: object, fieldTypes: object, apiKey: string, model: string) => Promise<AIResponse>;
|
|
82
|
+
};
|
|
83
|
+
export type AIConfig = {
|
|
84
|
+
providers: {
|
|
85
|
+
[key: string]: AIProvider;
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
export type FormuleContextProps = {
|
|
89
|
+
children: ReactNode;
|
|
90
|
+
customFieldTypes?: object;
|
|
91
|
+
customFields?: object;
|
|
92
|
+
customWidgets?: object;
|
|
93
|
+
customPublishedFields?: object;
|
|
94
|
+
customPublishedWidgets?: object;
|
|
95
|
+
customFunctions?: CustomFunctions;
|
|
96
|
+
theme?: ThemeConfig;
|
|
97
|
+
separator?: string;
|
|
98
|
+
errorBoundary?: ReactNode;
|
|
99
|
+
synchronizeState?: (state: SchemaWizardState) => void;
|
|
100
|
+
transformSchema?: (schema: object) => object;
|
|
101
|
+
ai?: AIConfig;
|
|
102
|
+
};
|
|
103
|
+
export type CustomizationContextProps = Omit<FormuleContextProps, "children" | "customFieldTypes" | "synchronizeState" | "theme"> & {
|
|
104
|
+
allFieldTypes: object;
|
|
105
|
+
separator: string;
|
|
106
|
+
transformSchema: (schema: object) => object;
|
|
107
|
+
ai: AIConfig;
|
|
108
|
+
};
|
|
@@ -3,6 +3,7 @@ type CodeDiffViewerProps = {
|
|
|
3
3
|
right: string;
|
|
4
4
|
lang?: string;
|
|
5
5
|
height?: string;
|
|
6
|
+
unified?: boolean;
|
|
6
7
|
};
|
|
7
|
-
declare const CodeDiffViewer: ({ left, right, lang, height }: CodeDiffViewerProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare const CodeDiffViewer: ({ left, right, lang, height, unified, }: CodeDiffViewerProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export default CodeDiffViewer;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-formule",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.6.0",
|
|
5
5
|
"author": "CERN",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"dist"
|
|
14
14
|
],
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
16
|
+
"main": "./dist/react-formule.umd.cjs",
|
|
16
17
|
"exports": {
|
|
17
18
|
".": {
|
|
18
19
|
"types": "./dist/index.d.ts",
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
"prepare": "husky"
|
|
32
33
|
},
|
|
33
34
|
"dependencies": {
|
|
35
|
+
"@ant-design/icons": "^5.6.1",
|
|
34
36
|
"@ant-design/pro-layout": "^7.16.4",
|
|
35
37
|
"@codemirror/lang-json": "^6.0.1",
|
|
36
38
|
"@codemirror/language": "^6.8.0",
|
|
@@ -42,11 +44,12 @@
|
|
|
42
44
|
"@rjsf/core": "^5.21.0",
|
|
43
45
|
"@rjsf/utils": "^5.21.0",
|
|
44
46
|
"@rjsf/validator-ajv8": "^5.21.0",
|
|
45
|
-
"
|
|
47
|
+
"ajv": "^8.17.1",
|
|
48
|
+
"antd": "^5.21.0",
|
|
46
49
|
"axios": "^1.4.0",
|
|
47
50
|
"codemirror": "^6.0.1",
|
|
48
51
|
"codemirror-json-schema": "0.7.1",
|
|
49
|
-
"
|
|
52
|
+
"just-diff": "^6.0.2",
|
|
50
53
|
"katex": "^0.16.8",
|
|
51
54
|
"markdown-it": "^13.0.1",
|
|
52
55
|
"markdown-it-texmath": "^1.0.0",
|
|
@@ -93,7 +96,7 @@
|
|
|
93
96
|
"vite": "^5.0.2",
|
|
94
97
|
"vite-plugin-css-injected-by-js": "^3.3.0",
|
|
95
98
|
"vite-plugin-dts": "^3.6.3",
|
|
96
|
-
"vitest": "^
|
|
99
|
+
"vitest": "^2.1.8"
|
|
97
100
|
},
|
|
98
101
|
"peerDependencies": {
|
|
99
102
|
"react": ">=18.2.0",
|
package/dist/vite.svg
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|