@reactables/react-forms 0.6.0-alpha.0 → 0.7.0-alpha.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/dist/Components/Form.d.ts +1 -8
- package/dist/Hooks/useForm.d.ts +2 -6
- package/dist/index.js +4 -3
- package/package.json +2 -2
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ControlModels, RxFormActions } from '@reactables/forms';
|
|
3
|
-
|
|
4
|
-
state: ControlModels.Form<unknown>;
|
|
5
|
-
actions: RxFormActions;
|
|
6
|
-
}
|
|
3
|
+
export type HookedRxForm = [ControlModels.Form<unknown>, RxFormActions];
|
|
7
4
|
export declare const FormContext: React.Context<HookedRxForm>;
|
|
8
|
-
export interface FormChildrenProps {
|
|
9
|
-
state: ControlModels.Form<unknown>;
|
|
10
|
-
actions: RxFormActions;
|
|
11
|
-
}
|
|
12
5
|
interface FormProps {
|
|
13
6
|
rxForm: HookedRxForm;
|
|
14
7
|
children?: React.ReactNode;
|
package/dist/Hooks/useForm.d.ts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
1
|
import { AbstractControlConfig } from '@reactables/forms';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
actions: {
|
|
5
|
-
[x: string]: (payload?: any) => void;
|
|
6
|
-
} & import("@reactables/forms").RxFormActions;
|
|
7
|
-
};
|
|
2
|
+
import { HookedRxForm } from '../Components/Form';
|
|
3
|
+
export declare const useForm: (config: AbstractControlConfig) => HookedRxForm;
|
package/dist/index.js
CHANGED
|
@@ -13,7 +13,8 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
|
13
13
|
var FormContext = React__default["default"].createContext(null);
|
|
14
14
|
var Form = function (_a) {
|
|
15
15
|
var rxForm = _a.rxForm, children = _a.children;
|
|
16
|
-
|
|
16
|
+
var state = rxForm[0];
|
|
17
|
+
return React__default["default"].createElement(FormContext.Provider, { value: rxForm }, state && children);
|
|
17
18
|
};
|
|
18
19
|
|
|
19
20
|
/******************************************************************************
|
|
@@ -61,7 +62,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
61
62
|
|
|
62
63
|
var Field = function (_a) {
|
|
63
64
|
var Component = _a.component, _b = _a.name, name = _b === void 0 ? 'root' : _b, props = __rest(_a, ["component", "name"]);
|
|
64
|
-
var _c = React.useContext(FormContext), state = _c
|
|
65
|
+
var _c = React.useContext(FormContext), state = _c[0], _d = _c[1], markControlAsTouched = _d.markControlAsTouched, updateValues = _d.updateValues;
|
|
65
66
|
var _e = state[name], controlRef = _e.controlRef, touched = _e.touched, value = _e.value;
|
|
66
67
|
var inputProps = {
|
|
67
68
|
name: name,
|
|
@@ -97,7 +98,7 @@ var Field = function (_a) {
|
|
|
97
98
|
|
|
98
99
|
var FormArray = function (_a) {
|
|
99
100
|
var _b = _a.name, name = _b === void 0 ? 'root' : _b, children = _a.children;
|
|
100
|
-
var _c = React.useContext(FormContext), state = _c
|
|
101
|
+
var _c = React.useContext(FormContext), state = _c[0], _d = _c[1], pushControl = _d.pushControl, removeControl = _d.removeControl;
|
|
101
102
|
var controlRef = state[name].controlRef;
|
|
102
103
|
var items = forms.getArrayItems(controlRef, state);
|
|
103
104
|
var formArrayChildrenProps = {
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"license": "ISC",
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"@reactables/core": "*",
|
|
20
|
-
"@reactables/forms": "^0.
|
|
20
|
+
"@reactables/forms": "^0.7.0-alpha.0",
|
|
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.
|
|
28
|
+
"version": "0.7.0-alpha.0"
|
|
29
29
|
}
|