react-formule 1.2.1 → 1.3.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 +21 -12
- package/dist/admin/components/SchemaPreview.d.ts +3 -1
- package/dist/admin/utils/index.d.ts +0 -9
- package/dist/exposed.d.ts +23 -9
- package/dist/forms/Form.d.ts +0 -1
- package/dist/index.d.ts +5 -0
- package/dist/react-formule.js +22413 -22335
- package/dist/react-formule.umd.cjs +317 -317
- package/dist/store/configureStore.d.ts +21 -16
- package/dist/store/schemaWizard.d.ts +16 -16
- package/dist/utils/index.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ Formule consists of the following main components:
|
|
|
43
43
|
|
|
44
44
|
It also exports the following functions:
|
|
45
45
|
|
|
46
|
-
- **`initFormuleSchema`**: Inits the JSONSchema
|
|
46
|
+
- **`initFormuleSchema`**: Inits or resets the JSONSchema. You can also load an existing schema by passing it as an argument.
|
|
47
47
|
- **`getFormuleState`**: Formule has its own internal redux state. You can retrieve it at any moment if you so require for more advanced use cases. If you want to continuosly synchronize the Formule state in your app, you can pass a callback function to FormuleContext instead (see below), which will be called every time the form state changes.
|
|
48
48
|
|
|
49
49
|
And the following utilities:
|
|
@@ -52,6 +52,16 @@ And the following utilities:
|
|
|
52
52
|
- **`CodeViewer`**: Useful if you want to visualize the JSON schemas that are being generated (as you can see in the demo).
|
|
53
53
|
- **`CodeDiffViewer`**: Useful if you want to compare two different JSON schemas, for example to see the changes since the last save.
|
|
54
54
|
|
|
55
|
+
As well as the following utility functions to handle saving and loading schemas from local storage if you need and for unsaved change detection:
|
|
56
|
+
|
|
57
|
+
- `getAllFromLocalStorage`
|
|
58
|
+
- `saveToLocalStorage`
|
|
59
|
+
- `deleteFromLocalStorage`
|
|
60
|
+
- `loadFromLocalStorage`
|
|
61
|
+
- `isUnsaved`
|
|
62
|
+
|
|
63
|
+
Have a look at `src/index.ts` to see all exported components and functions. You can also have a look at `formule-demo` to see how they are used there.
|
|
64
|
+
|
|
55
65
|
### Field types
|
|
56
66
|
|
|
57
67
|
Formule includes a variety of predefined field types, grouped in three categories:
|
|
@@ -83,20 +93,19 @@ yarn add react-formule
|
|
|
83
93
|
|
|
84
94
|
```jsx
|
|
85
95
|
import {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
initFormuleSchema
|
|
96
|
+
FormuleContext,
|
|
97
|
+
SelectOrEdit,
|
|
98
|
+
SchemaPreview,
|
|
99
|
+
FormPreview,
|
|
91
100
|
} from "react-formule";
|
|
92
101
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
<FormuleContext>
|
|
102
|
+
return (
|
|
103
|
+
<FormuleContext>
|
|
96
104
|
<SelectOrEdit />
|
|
97
105
|
<SchemaPreview />
|
|
98
106
|
<FormPreview />
|
|
99
|
-
</FormuleContext>
|
|
107
|
+
</FormuleContext>
|
|
108
|
+
);
|
|
100
109
|
```
|
|
101
110
|
|
|
102
111
|
### Customizing and adding new field types
|
|
@@ -168,8 +177,8 @@ const handleFormuleStateChange = (newState) => {
|
|
|
168
177
|
Alternatively, you can pull the current state on demand by calling `getFormuleState` at any moment.
|
|
169
178
|
|
|
170
179
|
> [!TIP]
|
|
171
|
-
> For more examples, feel free to browse around the [CERN Analysis Preservation](https://github.com/cernanalysispreservation/analysispreservation.cern.ch) repository, where we use all the features mentioned above.
|
|
180
|
+
> For more examples, feel free to browse around formule-demo and the [CERN Analysis Preservation](https://github.com/cernanalysispreservation/analysispreservation.cern.ch) repository, where we use all the features mentioned above.
|
|
172
181
|
|
|
173
182
|
## :space_invader: Local demo & how to contribute
|
|
174
183
|
|
|
175
|
-
Apart from trying the online [demo](https://cern-sis.github.io/react-formule/) you can clone the repo and run `formule-demo` to play around. Follow the instructions in its [README](./formule-demo/README.md): it will explain how to install `react-formule` as a local dependency so that you can modify Formule and test the changes live in your host app, which will be ideal if you want to troubleshoot or contribute to the project.
|
|
184
|
+
Apart from trying the online [demo](https://cern-sis.github.io/react-formule/) you can clone the repo and run `formule-demo` to play around. Follow the instructions in its [README](./formule-demo/README.md): it will explain how to install `react-formule` as a local dependency so that you can modify Formule and test the changes live in your host app, which will be ideal if you want to troubleshoot or contribute to the project. Your contributions are welcome! :rocket:
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { default as PropTypes } from 'prop-types';
|
|
2
2
|
export default SchemaPreview;
|
|
3
|
-
declare function SchemaPreview(
|
|
3
|
+
declare function SchemaPreview({ hideSchemaKey }: {
|
|
4
|
+
hideSchemaKey: any;
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
4
6
|
declare namespace SchemaPreview {
|
|
5
7
|
namespace propTypes {
|
|
6
8
|
let schema: PropTypes.Requireable<object>;
|
|
@@ -5,15 +5,6 @@ export namespace SIZE_OPTIONS {
|
|
|
5
5
|
let large: number;
|
|
6
6
|
let xlarge: number;
|
|
7
7
|
}
|
|
8
|
-
export function initSchemaStructure(name?: string, description?: string): {
|
|
9
|
-
schema: {
|
|
10
|
-
title: string;
|
|
11
|
-
description: string;
|
|
12
|
-
type: string;
|
|
13
|
-
properties: {};
|
|
14
|
-
};
|
|
15
|
-
uiSchema: {};
|
|
16
|
-
};
|
|
17
8
|
export function _validate(formData: any, errors: any): any;
|
|
18
9
|
export function shoudDisplayGuideLinePopUp(schema: any): any;
|
|
19
10
|
export function isItTheArrayField(schema: any, uiSchema: any): boolean;
|
package/dist/exposed.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ThemeConfig } from 'antd';
|
|
2
|
-
import { ReactNode } from 'react';
|
|
2
|
+
import { ReactNode, SetStateAction } from 'react';
|
|
3
3
|
import { RJSFSchema } from '@rjsf/utils';
|
|
4
4
|
import { SchemaWizardState } from './store/schemaWizard';
|
|
5
5
|
|
|
@@ -17,23 +17,37 @@ type FormuleContextProps = {
|
|
|
17
17
|
transformSchema?: (schema: object) => object;
|
|
18
18
|
};
|
|
19
19
|
export declare const FormuleContext: ({ children, customFieldTypes, customFields, customWidgets, customPublishedFields, customPublishedWidgets, theme, separator, errorBoundary, synchronizeState, transformSchema, }: FormuleContextProps) => import("react/jsx-runtime").JSX.Element;
|
|
20
|
-
export declare const initFormuleSchema: (data?: RJSFSchema,
|
|
20
|
+
export declare const initFormuleSchema: (data?: RJSFSchema, title?: string, description?: string) => void;
|
|
21
21
|
export declare const getFormuleState: () => {
|
|
22
22
|
current: {
|
|
23
|
-
schema: {
|
|
23
|
+
schema: {
|
|
24
|
+
title: string;
|
|
25
|
+
description: string;
|
|
26
|
+
type: string;
|
|
27
|
+
properties: {};
|
|
28
|
+
};
|
|
24
29
|
uiSchema: {};
|
|
25
30
|
};
|
|
26
31
|
initial: {
|
|
27
32
|
schema: {};
|
|
28
33
|
uiSchema: {};
|
|
29
34
|
};
|
|
30
|
-
|
|
31
|
-
config: {};
|
|
35
|
+
id: string;
|
|
32
36
|
field: {};
|
|
33
37
|
formData: {};
|
|
34
|
-
propKeyEditor: null;
|
|
35
|
-
error: null;
|
|
36
|
-
loader: boolean;
|
|
37
|
-
version: null;
|
|
38
38
|
};
|
|
39
|
+
export declare const getAllFromLocalStorage: () => {
|
|
40
|
+
id: string;
|
|
41
|
+
value: any;
|
|
42
|
+
}[];
|
|
43
|
+
export declare const saveToLocalStorage: () => Promise<SetStateAction<{
|
|
44
|
+
id: string;
|
|
45
|
+
value: object;
|
|
46
|
+
}[]>>;
|
|
47
|
+
export declare const deleteFromLocalStorage: (id: string) => Promise<SetStateAction<{
|
|
48
|
+
id: string;
|
|
49
|
+
value: object;
|
|
50
|
+
}[]>>;
|
|
51
|
+
export declare const loadFromLocalStorage: (id: string) => void;
|
|
52
|
+
export declare const isUnsaved: () => boolean;
|
|
39
53
|
export {};
|
package/dist/forms/Form.d.ts
CHANGED
|
@@ -36,7 +36,6 @@ declare namespace RJSFForm {
|
|
|
36
36
|
let formContext: PropTypes.Requireable<object>;
|
|
37
37
|
let widgets: PropTypes.Requireable<object>;
|
|
38
38
|
let mode: PropTypes.Requireable<string>;
|
|
39
|
-
let draftEditor: PropTypes.Requireable<boolean>;
|
|
40
39
|
let readonly: PropTypes.Requireable<boolean>;
|
|
41
40
|
let className: PropTypes.Requireable<string>;
|
|
42
41
|
let liveValidate: PropTypes.Requireable<boolean>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
export { initFormuleSchema } from './exposed';
|
|
2
2
|
export { getFormuleState } from './exposed';
|
|
3
3
|
export { FormuleContext } from './exposed';
|
|
4
|
+
export { getAllFromLocalStorage } from './exposed';
|
|
5
|
+
export { saveToLocalStorage } from './exposed';
|
|
6
|
+
export { deleteFromLocalStorage } from './exposed';
|
|
7
|
+
export { loadFromLocalStorage } from './exposed';
|
|
8
|
+
export { isUnsaved } from './exposed';
|
|
4
9
|
export { default as PropertyEditor } from './admin/components/PropertyEditor';
|
|
5
10
|
export { default as SelectFieldType } from './admin/components/SelectFieldType';
|
|
6
11
|
export { default as SchemaPreview } from './admin/components/SchemaPreview';
|