@fairys/rn-valtio-form-basic 0.0.13 → 1.0.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 +482 -0
- package/esm/form.d.ts +7 -3
- package/esm/form.item.d.ts +5 -5
- package/esm/form.js +3 -1
- package/esm/hooks/form.d.ts +3 -31
- package/esm/hooks/form.item.d.ts +20 -19
- package/esm/hooks/form.item.js +8 -2
- package/esm/hooks/layout.d.ts +2 -12039
- package/package.json +2 -2
- package/src/form.item.tsx +8 -6
- package/src/form.tsx +13 -2
- package/src/hooks/form.item.ts +42 -21
- package/src/hooks/form.ts +7 -9
- package/src/hooks/layout.ts +3 -9
package/esm/hooks/form.item.js
CHANGED
|
@@ -16,7 +16,7 @@ function useFairysValtioFormItemAttrs(props) {
|
|
|
16
16
|
const parent_isInvalidBorderRed = layoutAttrs.isInvalidBorderRed;
|
|
17
17
|
const parent_isInvalidTextRed = layoutAttrs.isInvalidTextRed;
|
|
18
18
|
const parent_showColon = layoutAttrs.showColon;
|
|
19
|
-
const { name, valuePropName = 'value', getValuePath = 'text', getValueFromEvent, formatValue, onAfterUpdate, trigger = 'onChange', style, labelStyle, bodyStyle, children, labelMode = parent_labelMode, errorLayout = parent_errorLayout, colSpan = 1, isRequired: _isRequired, itemBorderType = parent_borderedType, attrs = {}, showColon = parent_showColon, itemBorderColor = parent_itemBorderColor, isInvalidBorderRed = parent_isInvalidBorderRed, isInvalidTextRed = parent_isInvalidTextRed, isJoinParentField = true, rules } = props;
|
|
19
|
+
const { name, valuePropName = 'value', getValuePath = 'text', getValueFromEvent, formatValue, onAfterUpdate, trigger = 'onChange', style, labelStyle, bodyStyle, children, labelMode = parent_labelMode, errorLayout = parent_errorLayout, colSpan = 1, isRequired: _isRequired, itemBorderType = parent_borderedType, attrs = {}, showColon = parent_showColon, itemBorderColor = parent_itemBorderColor, isInvalidBorderRed = parent_isInvalidBorderRed, isInvalidTextRed = parent_isInvalidTextRed, isJoinParentField = true, rules, isRemoveValueOnUnmount = true } = props;
|
|
20
20
|
const { name: _name, paths, parentName, formAttrsNameInstance } = useFairysValtioFormAttrsName({
|
|
21
21
|
name,
|
|
22
22
|
isJoinParentField
|
|
@@ -50,6 +50,9 @@ function useFairysValtioFormItemAttrs(props) {
|
|
|
50
50
|
_name,
|
|
51
51
|
rules
|
|
52
52
|
]);
|
|
53
|
+
useEffect(()=>()=>{
|
|
54
|
+
if (isRemoveValueOnUnmount) formInstance.removeValueByPaths(_name);
|
|
55
|
+
}, []);
|
|
53
56
|
const onValueChange = (event)=>{
|
|
54
57
|
let newValue = event;
|
|
55
58
|
const target = event?.nativeEvent;
|
|
@@ -213,7 +216,7 @@ function useFairysValtioFormItemAttrs(props) {
|
|
|
213
216
|
};
|
|
214
217
|
}
|
|
215
218
|
function useFairysValtioFormItemNoStyleAttrs(props) {
|
|
216
|
-
const { name, valuePropName = 'value', getValuePath = 'text', getValueFromEvent, formatValue, onAfterUpdate, trigger = 'onChange', children, attrs = {}, isJoinParentField = true, rules, isRequired: _isRequired } = props;
|
|
219
|
+
const { name, valuePropName = 'value', getValuePath = 'text', getValueFromEvent, formatValue, onAfterUpdate, trigger = 'onChange', children, attrs = {}, isJoinParentField = true, rules, isRequired: _isRequired, isRemoveValueOnUnmount = true } = props;
|
|
217
220
|
const [state, errorState, formInstance] = useFairysValtioFormInstanceContextState();
|
|
218
221
|
const { name: _name, paths, parentName, formAttrsNameInstance } = useFairysValtioFormAttrsName({
|
|
219
222
|
name,
|
|
@@ -236,6 +239,9 @@ function useFairysValtioFormItemNoStyleAttrs(props) {
|
|
|
236
239
|
_name,
|
|
237
240
|
rules
|
|
238
241
|
]);
|
|
242
|
+
useEffect(()=>()=>{
|
|
243
|
+
if (isRemoveValueOnUnmount) formInstance.removeValueByPaths(_name);
|
|
244
|
+
}, []);
|
|
239
245
|
const onValueChange = (event)=>{
|
|
240
246
|
let newValue = event;
|
|
241
247
|
const target = event?.nativeEvent;
|