@reactables/react-forms 0.4.0-alpha.1 → 0.4.0-alpha.3
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/Components/Form.d.ts +7 -6
- package/dist/Hooks/index.d.ts +1 -0
- package/dist/Hooks/useForm.d.ts +5 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +8 -10
- package/package.json +2 -2
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { ControlModels, RxFormActions } from '@reactables/forms';
|
|
3
|
+
interface HookedRxForm {
|
|
4
4
|
state: ControlModels.Form<unknown>;
|
|
5
5
|
actions: RxFormActions;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
7
|
+
export declare const FormContext: React.Context<HookedRxForm>;
|
|
7
8
|
export interface FormChildrenProps {
|
|
8
9
|
state: ControlModels.Form<unknown>;
|
|
9
10
|
actions: RxFormActions;
|
|
10
11
|
}
|
|
11
12
|
interface FormProps {
|
|
12
|
-
|
|
13
|
-
children?:
|
|
13
|
+
rxForm: HookedRxForm;
|
|
14
|
+
children?: React.ReactNode;
|
|
14
15
|
}
|
|
15
|
-
export declare const Form: ({
|
|
16
|
+
export declare const Form: ({ rxForm, children }: FormProps) => React.JSX.Element;
|
|
16
17
|
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useForm } from './useForm';
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -12,16 +12,8 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
12
12
|
|
|
13
13
|
var FormContext = React__default["default"].createContext(null);
|
|
14
14
|
var Form = function (_a) {
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
var formChildrenProps = {
|
|
18
|
-
state: state,
|
|
19
|
-
actions: actions
|
|
20
|
-
};
|
|
21
|
-
return (React__default["default"].createElement(FormContext.Provider, { value: {
|
|
22
|
-
state: state,
|
|
23
|
-
actions: actions
|
|
24
|
-
} }, state !== undefined && children && children(formChildrenProps)));
|
|
15
|
+
var rxForm = _a.rxForm, children = _a.children;
|
|
16
|
+
return React__default["default"].createElement(FormContext.Provider, { value: rxForm }, rxForm.state && children);
|
|
25
17
|
};
|
|
26
18
|
|
|
27
19
|
/******************************************************************************
|
|
@@ -103,9 +95,15 @@ var FormArray = function (_a) {
|
|
|
103
95
|
return React__default["default"].createElement("div", null, children && children(formArrayChildrenProps));
|
|
104
96
|
};
|
|
105
97
|
|
|
98
|
+
var useForm = function (config) {
|
|
99
|
+
var rxForm = reactHelpers.useReactable(forms.RxForm.build(config));
|
|
100
|
+
return rxForm;
|
|
101
|
+
};
|
|
102
|
+
|
|
106
103
|
exports.Field = Field;
|
|
107
104
|
exports.Form = Form;
|
|
108
105
|
exports.FormArray = FormArray;
|
|
106
|
+
exports.useForm = useForm;
|
|
109
107
|
Object.keys(forms).forEach(function (k) {
|
|
110
108
|
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
111
109
|
enumerable: true,
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@reactables/core": "*",
|
|
20
|
-
"@reactables/forms": "^0.4.0-alpha.
|
|
20
|
+
"@reactables/forms": "^0.4.0-alpha.3",
|
|
21
21
|
"@reactables/react-helpers": "*"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
@@ -25,5 +25,5 @@
|
|
|
25
25
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
26
26
|
"rxjs": "^6.0.0 || ^7.0.0"
|
|
27
27
|
},
|
|
28
|
-
"version": "0.4.0-alpha.
|
|
28
|
+
"version": "0.4.0-alpha.3"
|
|
29
29
|
}
|