Skip to content

Commit ad4d9aa

Browse files
authored
Merge pull request #898 from rvsia/integrateManagerDdf
feat(manager): integrate manager with DDF
2 parents e210175 + 41511b4 commit ad4d9aa

File tree

77 files changed

+2726
-8929
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2726
-8929
lines changed

packages/ant-component-mapper/src/tests/components.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ describe('formFields generated tests', () => {
107107
const errorField = {
108108
...field,
109109
validate: [{ type: validatorTypes.REQUIRED, warning: true }],
110-
useWarnings: true,
111110
validateOnMount: true
112111
};
113112
let wrapper;

packages/ant-component-mapper/src/tests/dual-list-select.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ describe('DualListSelect', () => {
123123
wrapper.find('form').simulate('submit');
124124
});
125125

126-
expect(onSubmit).toHaveBeenCalledWith({});
126+
expect(onSubmit).toHaveBeenCalledWith({
127+
'dual-Menu': []
128+
});
127129
});
128130
});

packages/blueprint-component-mapper/src/tests/components.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ describe('formFields generated tests', () => {
112112
const errorField = {
113113
...field,
114114
validate: [{ type: validatorTypes.REQUIRED, warning: true }],
115-
useWarnings: true,
116115
validateOnMount: true
117116
};
118117
let wrapper;

packages/blueprint-component-mapper/src/tests/dual-list-select.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,9 @@ describe('DualListSelect', () => {
254254
wrapper.find('form').simulate('submit');
255255
});
256256

257-
expect(onSubmit).toHaveBeenCalledWith({});
257+
expect(onSubmit).toHaveBeenCalledWith({
258+
'dual-Menu': []
259+
});
258260
});
259261

260262
it('switch all to right', async () => {
@@ -288,7 +290,9 @@ describe('DualListSelect', () => {
288290
wrapper.find('form').simulate('submit');
289291
});
290292

291-
expect(onSubmit).toHaveBeenCalledWith({});
293+
expect(onSubmit).toHaveBeenCalledWith({
294+
'dual-Menu': []
295+
});
292296
});
293297

294298
it('filters options', async () => {

packages/carbon-component-mapper/src/tests/components.test.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ describe('component tests', () => {
103103
const errorField = {
104104
...field,
105105
validate: [{ type: validatorTypes.REQUIRED, warning: true }],
106-
useWarnings: true,
107106
validateOnMount: true
108107
};
109108
let wrapper;

packages/carbon-component-mapper/src/tests/dual-list-select.test.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,9 @@ describe('DualListSelect', () => {
249249
wrapper.find('form').simulate('submit');
250250
});
251251

252-
expect(onSubmit).toHaveBeenCalledWith({});
252+
expect(onSubmit).toHaveBeenCalledWith({
253+
'dual-StructuredListWrapper': []
254+
});
253255
});
254256

255257
it('switch all to right', async () => {
@@ -283,7 +285,9 @@ describe('DualListSelect', () => {
283285
wrapper.find('form').simulate('submit');
284286
});
285287

286-
expect(onSubmit).toHaveBeenCalledWith({});
288+
expect(onSubmit).toHaveBeenCalledWith({
289+
'dual-StructuredListWrapper': []
290+
});
287291
});
288292

289293
it('filters options', async () => {

packages/form-state-manager/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,16 @@
22
"name": "@data-driven-forms/form-state-manager",
33
"version": "0.0.1-beta.0",
44
"description": "Form state management library for data driven forms",
5-
"main": "index.js",
5+
"main": "dist/cjs/index.js",
6+
"module": "dist/esm/index.js",
67
"author": "Martin Marosi",
78
"typings": "dist/cjs/index.d.ts",
8-
"private": true,
9+
"repository": "[email protected]:data-driven-forms/react-forms.git",
10+
"keywords": [
11+
"react",
12+
"forms",
13+
"javascript"
14+
],
915
"devDependencies": {
1016
"@babel/core": "^7.2.2",
1117
"@babel/plugin-proposal-class-properties": "^7.1.0",

packages/form-state-manager/src/files/compose-validators.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import ComposeValidators from '../types/compose-validators';
99
* Synchronous validators are run in synchrounously and sync error is prioritized over async errors.
1010
* @returns {Function} New validation function
1111
*/
12-
const composeValidators: ComposeValidators = (validators = []) => (value, allValues) => {
12+
const composeValidators: ComposeValidators = (validators = []) => (value, allValues, meta) => {
1313
const promises: Promise<any>[] = [];
1414
let index = 0;
1515
let error: any;
1616
while (validators.length > 0 && !error && index < validators.length) {
17-
const result = validators[index](value, allValues);
17+
const result = validators[index](value, allValues, meta);
1818
if (isPromise(result)) {
1919
promises.push(result as Promise<any>);
2020
} else {

packages/form-state-manager/src/files/form-manager-context.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const FormManagerContext = createContext<ManagerContextValue>({
1919
}),
2020
formOptions: createManagerApi({
2121
onSubmit: noop
22-
}),
22+
})(),
2323
getFieldValue: noop,
2424
getFieldState: () => undefined,
2525
blur: noop,
@@ -39,7 +39,8 @@ const FormManagerContext = createContext<ManagerContextValue>({
3939
shift: noop,
4040
swap: noop,
4141
unshift: noop,
42-
update: noop
42+
update: noop,
43+
updateFieldConfig: noop
4344
});
4445

4546
export default FormManagerContext;

packages/form-state-manager/src/files/form-spy.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import FormManagerContext from './form-manager-context';
33
import generateId from '../utils/generate-id';
44
import FormSpyProps from '../types/form-spy';
55

6-
const FormSpy: React.FunctionComponent<FormSpyProps> = ({ children, subscription }) => {
7-
const { subscribe, unsubscribe, getState } = useContext(FormManagerContext);
6+
const FormSpy: React.FunctionComponent<FormSpyProps> = ({ children, onChange, subscription = { all: true } }) => {
7+
const { subscribe, unsubscribe, getState, formOptions } = useContext(FormManagerContext);
88
const [, rerender] = useReducer((prev) => prev + 1, 0);
99

1010
const [id] = useState(() => {
@@ -23,7 +23,14 @@ const FormSpy: React.FunctionComponent<FormSpyProps> = ({ children, subscription
2323
[]
2424
);
2525

26-
return children({ ...getState() });
26+
const newState = { ...getState(), form: formOptions };
27+
28+
if (onChange) {
29+
onChange(newState);
30+
return null;
31+
}
32+
33+
return children(newState);
2734
};
2835

2936
export default FormSpy;

0 commit comments

Comments
 (0)