@sheinx/hooks 3.7.1-beta.5 → 3.7.1-beta.6
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.
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":"AA+BA,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAGhB,gBAAgB,EAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;
|
1
|
+
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":"AA+BA,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAGhB,gBAAgB,EAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAoSC;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;gBAAC,WAAW,CAAC,EAAE,OAAO,CAAA;aAAE;8BArPnB,MAAM;oCAgUD,OAAO,aAAoB,MAAM,IAAI;;6BAf3C,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCA3RxC,MAAM,GAAG,MAAM,EAAE,WAAU,gBAAgB;qCA8VvB,MAAM,WAAW,gBAAgB;gCAhDzB,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;kCAjJpD,MAAM,0BAAyB,qBAAqB;;;;;;oBA2EjD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,WAAW,CAAC,EAAE,OAAO,CAAA;SAAE;0BArPnB,MAAM;gCAgUD,OAAO,aAAoB,MAAM,IAAI;;yBAf3C,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCA3RxC,MAAM,GAAG,MAAM,EAAE,WAAU,gBAAgB;iCA8VvB,MAAM,WAAW,gBAAgB;4BAhDzB,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;8BAjJpD,MAAM,0BAAyB,qBAAqB;;CAqb9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -73,85 +73,6 @@ var useForm = function useForm(props) {
|
|
73
73
|
removeLock: false
|
74
74
|
}),
|
75
75
|
context = _React$useRef.current;
|
76
|
-
var update = function update(name) {
|
77
|
-
var _context$flowMap$glob;
|
78
|
-
if (!name) {
|
79
|
-
Object.keys(context.updateMap).forEach(function (key) {
|
80
|
-
var _context$updateMap$ke;
|
81
|
-
(_context$updateMap$ke = context.updateMap[key]) === null || _context$updateMap$ke === void 0 || _context$updateMap$ke.forEach(function (update) {
|
82
|
-
update(context.value, context.errors, context.serverErrors);
|
83
|
-
});
|
84
|
-
});
|
85
|
-
Object.keys(context.flowMap).forEach(function (key) {
|
86
|
-
context.flowMap[key].forEach(function (update) {
|
87
|
-
update();
|
88
|
-
});
|
89
|
-
});
|
90
|
-
} else {
|
91
|
-
var names = (0, _utils.isArray)(name) ? name : [name];
|
92
|
-
names.forEach(function (key) {
|
93
|
-
var _context$flowMap$key;
|
94
|
-
// 外部直接设置user.name这种格式的,但是又没有显性的声明user.name绑定的表单元素;
|
95
|
-
// 这里需要手动触发,否则会导致Input输入过程中光标跳到末尾的异常
|
96
|
-
if (!context.updateMap[key]) {
|
97
|
-
var _context$updateMap$pa;
|
98
|
-
var parentKey = key.split('.')[0];
|
99
|
-
(_context$updateMap$pa = context.updateMap[parentKey]) === null || _context$updateMap$pa === void 0 || _context$updateMap$pa.forEach(function (update) {
|
100
|
-
update(context.value, context.errors, context.serverErrors);
|
101
|
-
});
|
102
|
-
} else {
|
103
|
-
var _context$updateMap$ke2;
|
104
|
-
(_context$updateMap$ke2 = context.updateMap[key]) === null || _context$updateMap$ke2 === void 0 || _context$updateMap$ke2.forEach(function (update) {
|
105
|
-
update(context.value, context.errors, context.serverErrors);
|
106
|
-
});
|
107
|
-
}
|
108
|
-
(_context$flowMap$key = context.flowMap[key]) === null || _context$flowMap$key === void 0 || _context$flowMap$key.forEach(function (update) {
|
109
|
-
update();
|
110
|
-
});
|
111
|
-
});
|
112
|
-
}
|
113
|
-
(_context$flowMap$glob = context.flowMap[globalKey]) === null || _context$flowMap$glob === void 0 || _context$flowMap$glob.forEach(function (update) {
|
114
|
-
update();
|
115
|
-
});
|
116
|
-
};
|
117
|
-
var updateFieldsets = (0, _usePersistFn.default)(function (name) {
|
118
|
-
var na = "".concat(name, "[");
|
119
|
-
var no = "".concat(name, ".");
|
120
|
-
context.names.forEach(function (key) {
|
121
|
-
if (key.startsWith(na) || key.startsWith(no)) {
|
122
|
-
update(key);
|
123
|
-
}
|
124
|
-
});
|
125
|
-
});
|
126
|
-
var handleSubmitError = function handleSubmitError(err) {
|
127
|
-
onError === null || onError === void 0 || onError(err);
|
128
|
-
if (!props.scrollToError) return;
|
129
|
-
setTimeout(function () {
|
130
|
-
var _props$formElRef$curr;
|
131
|
-
var selector = "[".concat((0, _attribute.getDataAttributeName)('status'), "=\"error\"]");
|
132
|
-
var el = (_props$formElRef$curr = props.formElRef.current) === null || _props$formElRef$curr === void 0 ? void 0 : _props$formElRef$curr.querySelector(selector);
|
133
|
-
if (el) {
|
134
|
-
el.scrollIntoView();
|
135
|
-
var focusableSelectors = 'textarea, input,[tabindex]:not([tabindex="-1"])';
|
136
|
-
var focusEl = el.querySelector(focusableSelectors);
|
137
|
-
if (focusEl && focusEl.focus) focusEl.focus();
|
138
|
-
}
|
139
|
-
if (typeof scrollToError === 'number' && scrollToError !== 0) {
|
140
|
-
var scrollEl = scrollParent === null || scrollParent === void 0 ? void 0 : scrollParent();
|
141
|
-
if (scrollEl) {
|
142
|
-
scrollEl.scrollTop -= scrollToError;
|
143
|
-
} else {
|
144
|
-
_utils.docScroll.top -= scrollToError;
|
145
|
-
}
|
146
|
-
}
|
147
|
-
});
|
148
|
-
};
|
149
|
-
var onChange = (0, _usePersistFn.default)(function (change) {
|
150
|
-
var _props$onChange;
|
151
|
-
var newValue = typeof change === 'function' ? (0, _immer.produce)(context.value, change) : change;
|
152
|
-
context.value = newValue;
|
153
|
-
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, context.value);
|
154
|
-
});
|
155
76
|
var getValue = (0, _usePersistFn.default)(function (name) {
|
156
77
|
if (name) {
|
157
78
|
return (0, _utils.deepGet)(context.value, name);
|
@@ -234,6 +155,88 @@ var useForm = function useForm(props) {
|
|
234
155
|
}
|
235
156
|
});
|
236
157
|
});
|
158
|
+
var update = function update(name) {
|
159
|
+
var _context$flowMap$glob;
|
160
|
+
if (!name) {
|
161
|
+
Object.keys(context.updateMap).forEach(function (key) {
|
162
|
+
var _context$updateMap$ke;
|
163
|
+
(_context$updateMap$ke = context.updateMap[key]) === null || _context$updateMap$ke === void 0 || _context$updateMap$ke.forEach(function (update) {
|
164
|
+
update(context.value, context.errors, context.serverErrors);
|
165
|
+
if (context.errors[key]) {
|
166
|
+
validateFields(key).catch(function () {});
|
167
|
+
}
|
168
|
+
});
|
169
|
+
});
|
170
|
+
Object.keys(context.flowMap).forEach(function (key) {
|
171
|
+
context.flowMap[key].forEach(function (update) {
|
172
|
+
update();
|
173
|
+
});
|
174
|
+
});
|
175
|
+
} else {
|
176
|
+
var names = (0, _utils.isArray)(name) ? name : [name];
|
177
|
+
names.forEach(function (key) {
|
178
|
+
var _context$flowMap$key;
|
179
|
+
// 外部直接设置user.name这种格式的,但是又没有显性的声明user.name绑定的表单元素;
|
180
|
+
// 这里需要手动触发,否则会导致Input输入过程中光标跳到末尾的异常
|
181
|
+
if (!context.updateMap[key]) {
|
182
|
+
var _context$updateMap$pa;
|
183
|
+
var parentKey = key.split('.')[0];
|
184
|
+
(_context$updateMap$pa = context.updateMap[parentKey]) === null || _context$updateMap$pa === void 0 || _context$updateMap$pa.forEach(function (update) {
|
185
|
+
update(context.value, context.errors, context.serverErrors);
|
186
|
+
});
|
187
|
+
} else {
|
188
|
+
var _context$updateMap$ke2;
|
189
|
+
(_context$updateMap$ke2 = context.updateMap[key]) === null || _context$updateMap$ke2 === void 0 || _context$updateMap$ke2.forEach(function (update) {
|
190
|
+
update(context.value, context.errors, context.serverErrors);
|
191
|
+
});
|
192
|
+
}
|
193
|
+
(_context$flowMap$key = context.flowMap[key]) === null || _context$flowMap$key === void 0 || _context$flowMap$key.forEach(function (update) {
|
194
|
+
update();
|
195
|
+
});
|
196
|
+
});
|
197
|
+
}
|
198
|
+
(_context$flowMap$glob = context.flowMap[globalKey]) === null || _context$flowMap$glob === void 0 || _context$flowMap$glob.forEach(function (update) {
|
199
|
+
update();
|
200
|
+
});
|
201
|
+
};
|
202
|
+
var updateFieldsets = (0, _usePersistFn.default)(function (name) {
|
203
|
+
var na = "".concat(name, "[");
|
204
|
+
var no = "".concat(name, ".");
|
205
|
+
context.names.forEach(function (key) {
|
206
|
+
if (key.startsWith(na) || key.startsWith(no)) {
|
207
|
+
update(key);
|
208
|
+
}
|
209
|
+
});
|
210
|
+
});
|
211
|
+
var handleSubmitError = function handleSubmitError(err) {
|
212
|
+
onError === null || onError === void 0 || onError(err);
|
213
|
+
if (!props.scrollToError) return;
|
214
|
+
setTimeout(function () {
|
215
|
+
var _props$formElRef$curr;
|
216
|
+
var selector = "[".concat((0, _attribute.getDataAttributeName)('status'), "=\"error\"]");
|
217
|
+
var el = (_props$formElRef$curr = props.formElRef.current) === null || _props$formElRef$curr === void 0 ? void 0 : _props$formElRef$curr.querySelector(selector);
|
218
|
+
if (el) {
|
219
|
+
el.scrollIntoView();
|
220
|
+
var focusableSelectors = 'textarea, input,[tabindex]:not([tabindex="-1"])';
|
221
|
+
var focusEl = el.querySelector(focusableSelectors);
|
222
|
+
if (focusEl && focusEl.focus) focusEl.focus();
|
223
|
+
}
|
224
|
+
if (typeof scrollToError === 'number' && scrollToError !== 0) {
|
225
|
+
var scrollEl = scrollParent === null || scrollParent === void 0 ? void 0 : scrollParent();
|
226
|
+
if (scrollEl) {
|
227
|
+
scrollEl.scrollTop -= scrollToError;
|
228
|
+
} else {
|
229
|
+
_utils.docScroll.top -= scrollToError;
|
230
|
+
}
|
231
|
+
}
|
232
|
+
});
|
233
|
+
};
|
234
|
+
var onChange = (0, _usePersistFn.default)(function (change) {
|
235
|
+
var _props$onChange;
|
236
|
+
var newValue = typeof change === 'function' ? (0, _immer.produce)(context.value, change) : change;
|
237
|
+
context.value = newValue;
|
238
|
+
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, context.value);
|
239
|
+
});
|
237
240
|
var scrollToField = (0, _usePersistFn.default)(function (name) {
|
238
241
|
var _document;
|
239
242
|
var scrollIntoViewOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":"AA+BA,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAGhB,gBAAgB,EAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;
|
1
|
+
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":"AA+BA,OAAO,EAEL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAGhB,gBAAgB,EAEjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAe,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAI5D,QAAA,MAAM,OAAO;;;;;;;;;wBAoSC;gBAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;gBAAC,WAAW,CAAC,EAAE,OAAO,CAAA;aAAE;8BArPnB,MAAM;oCAgUD,OAAO,aAAoB,MAAM,IAAI;;6BAf3C,MAAM,KAAK,KAAK,GAAG,SAAS;;oCAdrB,MAAM,EAAE;sCA3RxC,MAAM,GAAG,MAAM,EAAE,WAAU,gBAAgB;qCA8VvB,MAAM,WAAW,gBAAgB;gCAhDzB,MAAM,SAAS,MAAM,UAAU,KAAK;gCAKpC,MAAM,SAAS,MAAM;kCAjJpD,MAAM,0BAAyB,qBAAqB;;;;;;oBA2EjD;YAAE,QAAQ,CAAC,EAAE,OAAO,CAAC;YAAC,WAAW,CAAC,EAAE,OAAO,CAAA;SAAE;0BArPnB,MAAM;gCAgUD,OAAO,aAAoB,MAAM,IAAI;;yBAf3C,MAAM,KAAK,KAAK,GAAG,SAAS;;gCAdrB,MAAM,EAAE;kCA3RxC,MAAM,GAAG,MAAM,EAAE,WAAU,gBAAgB;iCA8VvB,MAAM,WAAW,gBAAgB;4BAhDzB,MAAM,SAAS,MAAM,UAAU,KAAK;4BAKpC,MAAM,SAAS,MAAM;8BAjJpD,MAAM,0BAAyB,qBAAqB;;CAqb9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
@@ -64,85 +64,6 @@ var useForm = function useForm(props) {
|
|
64
64
|
removeLock: false
|
65
65
|
}),
|
66
66
|
context = _React$useRef.current;
|
67
|
-
var update = function update(name) {
|
68
|
-
var _context$flowMap$glob;
|
69
|
-
if (!name) {
|
70
|
-
Object.keys(context.updateMap).forEach(function (key) {
|
71
|
-
var _context$updateMap$ke;
|
72
|
-
(_context$updateMap$ke = context.updateMap[key]) === null || _context$updateMap$ke === void 0 || _context$updateMap$ke.forEach(function (update) {
|
73
|
-
update(context.value, context.errors, context.serverErrors);
|
74
|
-
});
|
75
|
-
});
|
76
|
-
Object.keys(context.flowMap).forEach(function (key) {
|
77
|
-
context.flowMap[key].forEach(function (update) {
|
78
|
-
update();
|
79
|
-
});
|
80
|
-
});
|
81
|
-
} else {
|
82
|
-
var names = isArray(name) ? name : [name];
|
83
|
-
names.forEach(function (key) {
|
84
|
-
var _context$flowMap$key;
|
85
|
-
// 外部直接设置user.name这种格式的,但是又没有显性的声明user.name绑定的表单元素;
|
86
|
-
// 这里需要手动触发,否则会导致Input输入过程中光标跳到末尾的异常
|
87
|
-
if (!context.updateMap[key]) {
|
88
|
-
var _context$updateMap$pa;
|
89
|
-
var parentKey = key.split('.')[0];
|
90
|
-
(_context$updateMap$pa = context.updateMap[parentKey]) === null || _context$updateMap$pa === void 0 || _context$updateMap$pa.forEach(function (update) {
|
91
|
-
update(context.value, context.errors, context.serverErrors);
|
92
|
-
});
|
93
|
-
} else {
|
94
|
-
var _context$updateMap$ke2;
|
95
|
-
(_context$updateMap$ke2 = context.updateMap[key]) === null || _context$updateMap$ke2 === void 0 || _context$updateMap$ke2.forEach(function (update) {
|
96
|
-
update(context.value, context.errors, context.serverErrors);
|
97
|
-
});
|
98
|
-
}
|
99
|
-
(_context$flowMap$key = context.flowMap[key]) === null || _context$flowMap$key === void 0 || _context$flowMap$key.forEach(function (update) {
|
100
|
-
update();
|
101
|
-
});
|
102
|
-
});
|
103
|
-
}
|
104
|
-
(_context$flowMap$glob = context.flowMap[globalKey]) === null || _context$flowMap$glob === void 0 || _context$flowMap$glob.forEach(function (update) {
|
105
|
-
update();
|
106
|
-
});
|
107
|
-
};
|
108
|
-
var updateFieldsets = usePersistFn(function (name) {
|
109
|
-
var na = "".concat(name, "[");
|
110
|
-
var no = "".concat(name, ".");
|
111
|
-
context.names.forEach(function (key) {
|
112
|
-
if (key.startsWith(na) || key.startsWith(no)) {
|
113
|
-
update(key);
|
114
|
-
}
|
115
|
-
});
|
116
|
-
});
|
117
|
-
var handleSubmitError = function handleSubmitError(err) {
|
118
|
-
onError === null || onError === void 0 || onError(err);
|
119
|
-
if (!props.scrollToError) return;
|
120
|
-
setTimeout(function () {
|
121
|
-
var _props$formElRef$curr;
|
122
|
-
var selector = "[".concat(getDataAttributeName('status'), "=\"error\"]");
|
123
|
-
var el = (_props$formElRef$curr = props.formElRef.current) === null || _props$formElRef$curr === void 0 ? void 0 : _props$formElRef$curr.querySelector(selector);
|
124
|
-
if (el) {
|
125
|
-
el.scrollIntoView();
|
126
|
-
var focusableSelectors = 'textarea, input,[tabindex]:not([tabindex="-1"])';
|
127
|
-
var focusEl = el.querySelector(focusableSelectors);
|
128
|
-
if (focusEl && focusEl.focus) focusEl.focus();
|
129
|
-
}
|
130
|
-
if (typeof scrollToError === 'number' && scrollToError !== 0) {
|
131
|
-
var scrollEl = scrollParent === null || scrollParent === void 0 ? void 0 : scrollParent();
|
132
|
-
if (scrollEl) {
|
133
|
-
scrollEl.scrollTop -= scrollToError;
|
134
|
-
} else {
|
135
|
-
docScroll.top -= scrollToError;
|
136
|
-
}
|
137
|
-
}
|
138
|
-
});
|
139
|
-
};
|
140
|
-
var onChange = usePersistFn(function (change) {
|
141
|
-
var _props$onChange;
|
142
|
-
var newValue = typeof change === 'function' ? produce(context.value, change) : change;
|
143
|
-
context.value = newValue;
|
144
|
-
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, context.value);
|
145
|
-
});
|
146
67
|
var getValue = usePersistFn(function (name) {
|
147
68
|
if (name) {
|
148
69
|
return deepGet(context.value, name);
|
@@ -225,6 +146,88 @@ var useForm = function useForm(props) {
|
|
225
146
|
}
|
226
147
|
});
|
227
148
|
});
|
149
|
+
var update = function update(name) {
|
150
|
+
var _context$flowMap$glob;
|
151
|
+
if (!name) {
|
152
|
+
Object.keys(context.updateMap).forEach(function (key) {
|
153
|
+
var _context$updateMap$ke;
|
154
|
+
(_context$updateMap$ke = context.updateMap[key]) === null || _context$updateMap$ke === void 0 || _context$updateMap$ke.forEach(function (update) {
|
155
|
+
update(context.value, context.errors, context.serverErrors);
|
156
|
+
if (context.errors[key]) {
|
157
|
+
validateFields(key).catch(function () {});
|
158
|
+
}
|
159
|
+
});
|
160
|
+
});
|
161
|
+
Object.keys(context.flowMap).forEach(function (key) {
|
162
|
+
context.flowMap[key].forEach(function (update) {
|
163
|
+
update();
|
164
|
+
});
|
165
|
+
});
|
166
|
+
} else {
|
167
|
+
var names = isArray(name) ? name : [name];
|
168
|
+
names.forEach(function (key) {
|
169
|
+
var _context$flowMap$key;
|
170
|
+
// 外部直接设置user.name这种格式的,但是又没有显性的声明user.name绑定的表单元素;
|
171
|
+
// 这里需要手动触发,否则会导致Input输入过程中光标跳到末尾的异常
|
172
|
+
if (!context.updateMap[key]) {
|
173
|
+
var _context$updateMap$pa;
|
174
|
+
var parentKey = key.split('.')[0];
|
175
|
+
(_context$updateMap$pa = context.updateMap[parentKey]) === null || _context$updateMap$pa === void 0 || _context$updateMap$pa.forEach(function (update) {
|
176
|
+
update(context.value, context.errors, context.serverErrors);
|
177
|
+
});
|
178
|
+
} else {
|
179
|
+
var _context$updateMap$ke2;
|
180
|
+
(_context$updateMap$ke2 = context.updateMap[key]) === null || _context$updateMap$ke2 === void 0 || _context$updateMap$ke2.forEach(function (update) {
|
181
|
+
update(context.value, context.errors, context.serverErrors);
|
182
|
+
});
|
183
|
+
}
|
184
|
+
(_context$flowMap$key = context.flowMap[key]) === null || _context$flowMap$key === void 0 || _context$flowMap$key.forEach(function (update) {
|
185
|
+
update();
|
186
|
+
});
|
187
|
+
});
|
188
|
+
}
|
189
|
+
(_context$flowMap$glob = context.flowMap[globalKey]) === null || _context$flowMap$glob === void 0 || _context$flowMap$glob.forEach(function (update) {
|
190
|
+
update();
|
191
|
+
});
|
192
|
+
};
|
193
|
+
var updateFieldsets = usePersistFn(function (name) {
|
194
|
+
var na = "".concat(name, "[");
|
195
|
+
var no = "".concat(name, ".");
|
196
|
+
context.names.forEach(function (key) {
|
197
|
+
if (key.startsWith(na) || key.startsWith(no)) {
|
198
|
+
update(key);
|
199
|
+
}
|
200
|
+
});
|
201
|
+
});
|
202
|
+
var handleSubmitError = function handleSubmitError(err) {
|
203
|
+
onError === null || onError === void 0 || onError(err);
|
204
|
+
if (!props.scrollToError) return;
|
205
|
+
setTimeout(function () {
|
206
|
+
var _props$formElRef$curr;
|
207
|
+
var selector = "[".concat(getDataAttributeName('status'), "=\"error\"]");
|
208
|
+
var el = (_props$formElRef$curr = props.formElRef.current) === null || _props$formElRef$curr === void 0 ? void 0 : _props$formElRef$curr.querySelector(selector);
|
209
|
+
if (el) {
|
210
|
+
el.scrollIntoView();
|
211
|
+
var focusableSelectors = 'textarea, input,[tabindex]:not([tabindex="-1"])';
|
212
|
+
var focusEl = el.querySelector(focusableSelectors);
|
213
|
+
if (focusEl && focusEl.focus) focusEl.focus();
|
214
|
+
}
|
215
|
+
if (typeof scrollToError === 'number' && scrollToError !== 0) {
|
216
|
+
var scrollEl = scrollParent === null || scrollParent === void 0 ? void 0 : scrollParent();
|
217
|
+
if (scrollEl) {
|
218
|
+
scrollEl.scrollTop -= scrollToError;
|
219
|
+
} else {
|
220
|
+
docScroll.top -= scrollToError;
|
221
|
+
}
|
222
|
+
}
|
223
|
+
});
|
224
|
+
};
|
225
|
+
var onChange = usePersistFn(function (change) {
|
226
|
+
var _props$onChange;
|
227
|
+
var newValue = typeof change === 'function' ? produce(context.value, change) : change;
|
228
|
+
context.value = newValue;
|
229
|
+
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, context.value);
|
230
|
+
});
|
228
231
|
var scrollToField = usePersistFn(function (name) {
|
229
232
|
var _document;
|
230
233
|
var scrollIntoViewOptions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|