@sheinx/hooks 3.7.1-beta.5 → 3.7.1-beta.7
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/cjs/components/use-form/use-form.d.ts.map +1 -1
- package/cjs/components/use-form/use-form.js +82 -79
- package/cjs/components/use-input/use-input-format.d.ts +2 -2
- package/cjs/components/use-input/use-input-format.d.ts.map +1 -1
- package/cjs/components/use-input/use-input-format.type.d.ts +2 -2
- package/cjs/components/use-input/use-input-format.type.d.ts.map +1 -1
- package/cjs/components/use-input/use-input-number.d.ts +2 -2
- package/cjs/components/use-input/use-input.type.d.ts +2 -2
- package/cjs/components/use-input/use-input.type.d.ts.map +1 -1
- package/cjs/components/use-textarea/use-textarea-format.d.ts +1 -1
- package/cjs/components/use-textarea/use-textarea-format.d.ts.map +1 -1
- package/cjs/components/use-textarea/use-textarea-format.type.d.ts +1 -1
- package/cjs/components/use-textarea/use-textarea-format.type.d.ts.map +1 -1
- package/cjs/components/use-textarea/use-textarea.type.d.ts +2 -2
- package/cjs/components/use-textarea/use-textarea.type.d.ts.map +1 -1
- package/esm/components/use-form/use-form.d.ts.map +1 -1
- package/esm/components/use-form/use-form.js +82 -79
- package/esm/components/use-input/use-input-format.d.ts +2 -2
- package/esm/components/use-input/use-input-format.d.ts.map +1 -1
- package/esm/components/use-input/use-input-format.type.d.ts +2 -2
- package/esm/components/use-input/use-input-format.type.d.ts.map +1 -1
- package/esm/components/use-input/use-input-number.d.ts +2 -2
- package/esm/components/use-input/use-input.type.d.ts +2 -2
- package/esm/components/use-input/use-input.type.d.ts.map +1 -1
- package/esm/components/use-textarea/use-textarea-format.d.ts +1 -1
- package/esm/components/use-textarea/use-textarea-format.d.ts.map +1 -1
- package/esm/components/use-textarea/use-textarea-format.type.d.ts +1 -1
- package/esm/components/use-textarea/use-textarea-format.type.d.ts.map +1 -1
- package/esm/components/use-textarea/use-textarea.type.d.ts +2 -2
- package/esm/components/use-textarea/use-textarea.type.d.ts.map +1 -1
- package/package.json +1 -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"}
|
@@ -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] : {};
|
@@ -2,8 +2,8 @@ import React from 'react';
|
|
2
2
|
import { InputFormatProps } from './use-input-format.type';
|
3
3
|
declare const useInputFormat: (props: InputFormatProps) => {
|
4
4
|
onChange: (v: string | undefined) => void;
|
5
|
-
onBlur: (e: React.FocusEvent) => void;
|
6
|
-
onFocus: (e: React.FocusEvent) => void;
|
5
|
+
onBlur: (e: React.FocusEvent<HTMLInputElement>) => void;
|
6
|
+
onFocus: (e: React.FocusEvent<HTMLInputElement>) => void;
|
7
7
|
value: string | undefined;
|
8
8
|
type: "search" | (string & {}) | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" | "hidden" | "checkbox" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "radio" | "text" | "week" | undefined;
|
9
9
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-input-format.d.ts","sourceRoot":"","sources":["use-input-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAM3D,QAAA,MAAM,cAAc,UAAW,gBAAgB;kBAsBP,MAAM,GAAG,SAAS;gBAoCpB,gBAAgB;
|
1
|
+
{"version":3,"file":"use-input-format.d.ts","sourceRoot":"","sources":["use-input-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAM3D,QAAA,MAAM,cAAc,UAAW,gBAAgB;kBAsBP,MAAM,GAAG,SAAS;gBAoCpB,gBAAgB,CAAC,gBAAgB,CAAC;iBAgDhC,gBAAgB,CAAC,gBAAgB,CAAC;;;CAyBzE,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
@@ -41,8 +41,8 @@ export interface InputFormatProps {
|
|
41
41
|
* @cn 是否自动补全小数位数, 仅在 type = number 下生效
|
42
42
|
*/
|
43
43
|
autoFix?: boolean;
|
44
|
-
onBlur?: React.FocusEventHandler
|
45
|
-
onFocus?: React.FocusEventHandler
|
44
|
+
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
45
|
+
onFocus?: React.FocusEventHandler<HTMLInputElement>;
|
46
46
|
/**
|
47
47
|
* @en Cancel blur trigger onChange, used for multi-layer nesting of formatting, only trigger onChange once at the outermost layer
|
48
48
|
* @cn 取消 blur 触发 onChange,用于多层嵌套的格式化,只在最外层触发一次onChange
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-input-format.type.d.ts","sourceRoot":"","sources":["use-input-format.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;OAKG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;IAC3D;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC;IACtC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"use-input-format.type.d.ts","sourceRoot":"","sources":["use-input-format.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;OAKG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;IAC3D;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC;IACtC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IACnD,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IACpD;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
|
@@ -4,8 +4,8 @@ declare const useNumberFormat: (props: InputNumberProps) => {
|
|
4
4
|
onPlus: () => void;
|
5
5
|
onMinus: () => void;
|
6
6
|
onChange: (v: string | undefined) => void;
|
7
|
-
onBlur: (e: React.FocusEvent<
|
8
|
-
onFocus: (e: React.FocusEvent<
|
7
|
+
onBlur: (e: React.FocusEvent<HTMLInputElement, Element>) => void;
|
8
|
+
onFocus: (e: React.FocusEvent<HTMLInputElement, Element>) => void;
|
9
9
|
value: string | undefined;
|
10
10
|
type: "search" | (string & {}) | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" | "hidden" | "checkbox" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "radio" | "text" | "week" | undefined;
|
11
11
|
};
|
@@ -16,12 +16,12 @@ export interface InputPropsOwn {
|
|
16
16
|
* @en The callback of blur
|
17
17
|
* @cn 失去焦点后的回调
|
18
18
|
*/
|
19
|
-
onBlur?: React.FocusEventHandler
|
19
|
+
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
20
20
|
/**
|
21
21
|
* @en The callback when Textarea focus
|
22
22
|
* @cn 聚焦后的回调
|
23
23
|
*/
|
24
|
-
onFocus?: React.FocusEventHandler
|
24
|
+
onFocus?: React.FocusEventHandler<HTMLInputElement>;
|
25
25
|
/**
|
26
26
|
* @en Click callback
|
27
27
|
* @cn 点击回调
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-input.type.d.ts","sourceRoot":"","sources":["use-input.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"use-input.type.d.ts","sourceRoot":"","sources":["use-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;AAED,MAAM,MAAM,qBAAqB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,IAAI,CACxE,MAAM,EAEN,MAAM,wBAAwB,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CACnE,GACC,wBAAwB,CAAC;AAE3B,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC;IACjC,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAChC,QAAQ,EAAE,KAAK,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACjC,KAAK,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,IAAI,CACpE,MAAM,EACN,MAAM,oBAAoB,CAC3B,GACC,oBAAoB,CAAC;AAEvB,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE,KAAK,CAAC,iBAAiB,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,UAAU,CAC3E,qBAAqB,EACrB,MAAM,CACP,CAAC"}
|
@@ -3,7 +3,7 @@ import { InputFormatProps } from './use-textarea-format.type';
|
|
3
3
|
declare const useTextareaFormat: (props: InputFormatProps) => {
|
4
4
|
value: string | undefined;
|
5
5
|
onChange: (value: string) => void;
|
6
|
-
onBlur: (e: React.FocusEvent) => void;
|
6
|
+
onBlur: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
|
7
7
|
};
|
8
8
|
export default useTextareaFormat;
|
9
9
|
//# sourceMappingURL=use-textarea-format.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-textarea-format.d.ts","sourceRoot":"","sources":["use-textarea-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,QAAA,MAAM,iBAAiB,UAAW,gBAAgB;;;gBAGZ,gBAAgB;
|
1
|
+
{"version":3,"file":"use-textarea-format.d.ts","sourceRoot":"","sources":["use-textarea-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,QAAA,MAAM,iBAAiB,UAAW,gBAAgB;;;gBAGZ,gBAAgB,CAAC,mBAAmB,CAAC;CA2B1E,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-textarea-format.type.d.ts","sourceRoot":"","sources":["use-textarea-format.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AACnC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"use-textarea-format.type.d.ts","sourceRoot":"","sources":["use-textarea-format.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AACnC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAC;CACvD"}
|
@@ -13,12 +13,12 @@ export interface TextAreaPropsOwn {
|
|
13
13
|
* @en The callback when Textarea blur
|
14
14
|
* @cn 失去焦点后的回调
|
15
15
|
*/
|
16
|
-
onBlur?: React.FocusEventHandler
|
16
|
+
onBlur?: React.FocusEventHandler<HTMLTextAreaElement>;
|
17
17
|
/**
|
18
18
|
* @en Callback function for blur focus
|
19
19
|
* @cn focus 事件回调函数
|
20
20
|
*/
|
21
|
-
onFocus?: React.FocusEventHandler
|
21
|
+
onFocus?: React.FocusEventHandler<HTMLTextAreaElement>;
|
22
22
|
/**
|
23
23
|
* @en Callback function for click
|
24
24
|
* @cn click 事件回调函数
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-textarea.type.d.ts","sourceRoot":"","sources":["use-textarea.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"use-textarea.type.d.ts","sourceRoot":"","sources":["use-textarea.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAC;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E,MAAM,EACN,MAAM,uBAAuB,CAC9B,GACC,uBAAuB,CAAC"}
|
@@ -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] : {};
|
@@ -2,8 +2,8 @@ import React from 'react';
|
|
2
2
|
import { InputFormatProps } from './use-input-format.type';
|
3
3
|
declare const useInputFormat: (props: InputFormatProps) => {
|
4
4
|
onChange: (v: string | undefined) => void;
|
5
|
-
onBlur: (e: React.FocusEvent) => void;
|
6
|
-
onFocus: (e: React.FocusEvent) => void;
|
5
|
+
onBlur: (e: React.FocusEvent<HTMLInputElement>) => void;
|
6
|
+
onFocus: (e: React.FocusEvent<HTMLInputElement>) => void;
|
7
7
|
value: string | undefined;
|
8
8
|
type: "search" | (string & {}) | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" | "hidden" | "checkbox" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "radio" | "text" | "week" | undefined;
|
9
9
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-input-format.d.ts","sourceRoot":"","sources":["use-input-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAM3D,QAAA,MAAM,cAAc,UAAW,gBAAgB;kBAsBP,MAAM,GAAG,SAAS;gBAoCpB,gBAAgB;
|
1
|
+
{"version":3,"file":"use-input-format.d.ts","sourceRoot":"","sources":["use-input-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAM3D,QAAA,MAAM,cAAc,UAAW,gBAAgB;kBAsBP,MAAM,GAAG,SAAS;gBAoCpB,gBAAgB,CAAC,gBAAgB,CAAC;iBAgDhC,gBAAgB,CAAC,gBAAgB,CAAC;;;CAyBzE,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
@@ -41,8 +41,8 @@ export interface InputFormatProps {
|
|
41
41
|
* @cn 是否自动补全小数位数, 仅在 type = number 下生效
|
42
42
|
*/
|
43
43
|
autoFix?: boolean;
|
44
|
-
onBlur?: React.FocusEventHandler
|
45
|
-
onFocus?: React.FocusEventHandler
|
44
|
+
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
45
|
+
onFocus?: React.FocusEventHandler<HTMLInputElement>;
|
46
46
|
/**
|
47
47
|
* @en Cancel blur trigger onChange, used for multi-layer nesting of formatting, only trigger onChange once at the outermost layer
|
48
48
|
* @cn 取消 blur 触发 onChange,用于多层嵌套的格式化,只在最外层触发一次onChange
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-input-format.type.d.ts","sourceRoot":"","sources":["use-input-format.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;OAKG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;IAC3D;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC;IACtC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"use-input-format.type.d.ts","sourceRoot":"","sources":["use-input-format.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,SAAS,CAAC;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,UAAU,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;IACtC;;;OAGG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;;;OAKG;IACH,IAAI,CAAC,EAAE,KAAK,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;IAC3D;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC;IACtC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IACnD,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IACpD;;;OAGG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B"}
|
@@ -4,8 +4,8 @@ declare const useNumberFormat: (props: InputNumberProps) => {
|
|
4
4
|
onPlus: () => void;
|
5
5
|
onMinus: () => void;
|
6
6
|
onChange: (v: string | undefined) => void;
|
7
|
-
onBlur: (e: React.FocusEvent<
|
8
|
-
onFocus: (e: React.FocusEvent<
|
7
|
+
onBlur: (e: React.FocusEvent<HTMLInputElement, Element>) => void;
|
8
|
+
onFocus: (e: React.FocusEvent<HTMLInputElement, Element>) => void;
|
9
9
|
value: string | undefined;
|
10
10
|
type: "search" | (string & {}) | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" | "hidden" | "checkbox" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "radio" | "text" | "week" | undefined;
|
11
11
|
};
|
@@ -16,12 +16,12 @@ export interface InputPropsOwn {
|
|
16
16
|
* @en The callback of blur
|
17
17
|
* @cn 失去焦点后的回调
|
18
18
|
*/
|
19
|
-
onBlur?: React.FocusEventHandler
|
19
|
+
onBlur?: React.FocusEventHandler<HTMLInputElement>;
|
20
20
|
/**
|
21
21
|
* @en The callback when Textarea focus
|
22
22
|
* @cn 聚焦后的回调
|
23
23
|
*/
|
24
|
-
onFocus?: React.FocusEventHandler
|
24
|
+
onFocus?: React.FocusEventHandler<HTMLInputElement>;
|
25
25
|
/**
|
26
26
|
* @en Click callback
|
27
27
|
* @cn 点击回调
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-input.type.d.ts","sourceRoot":"","sources":["use-input.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,MAAM,WAAW,aAAa;IAC5B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"use-input.type.d.ts","sourceRoot":"","sources":["use-input.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,m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,MAAM,EAEN,MAAM,wBAAwB,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CACnE,GACC,wBAAwB,CAAC;AAE3B,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,KAAK,CAAC,iBAAiB,CAAC;IACjC,MAAM,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAChC,QAAQ,EAAE,KAAK,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;IACrD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,GAAG,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACjC,KAAK,EAAE,GAAG,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,IAAI,CACpE,MAAM,EACN,MAAM,oBAAoB,CAC3B,GACC,oBAAoB,CAAC;AAEvB,MAAM,MAAM,qBAAqB,GAAG;IAClC,WAAW,EAAE,KAAK,CAAC,iBAAiB,CAAC;CACtC,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,UAAU,CAC3E,qBAAqB,EACrB,MAAM,CACP,CAAC"}
|
@@ -3,7 +3,7 @@ import { InputFormatProps } from './use-textarea-format.type';
|
|
3
3
|
declare const useTextareaFormat: (props: InputFormatProps) => {
|
4
4
|
value: string | undefined;
|
5
5
|
onChange: (value: string) => void;
|
6
|
-
onBlur: (e: React.FocusEvent) => void;
|
6
|
+
onBlur: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
|
7
7
|
};
|
8
8
|
export default useTextareaFormat;
|
9
9
|
//# sourceMappingURL=use-textarea-format.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-textarea-format.d.ts","sourceRoot":"","sources":["use-textarea-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,QAAA,MAAM,iBAAiB,UAAW,gBAAgB;;;gBAGZ,gBAAgB;
|
1
|
+
{"version":3,"file":"use-textarea-format.d.ts","sourceRoot":"","sources":["use-textarea-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAE9D,QAAA,MAAM,iBAAiB,UAAW,gBAAgB;;;gBAGZ,gBAAgB,CAAC,mBAAmB,CAAC;CA2B1E,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-textarea-format.type.d.ts","sourceRoot":"","sources":["use-textarea-format.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AACnC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"use-textarea-format.type.d.ts","sourceRoot":"","sources":["use-textarea-format.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC;AACnC,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,aAAa,GAAG,SAAS,CAAC;IACjC,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAC;CACvD"}
|
@@ -13,12 +13,12 @@ export interface TextAreaPropsOwn {
|
|
13
13
|
* @en The callback when Textarea blur
|
14
14
|
* @cn 失去焦点后的回调
|
15
15
|
*/
|
16
|
-
onBlur?: React.FocusEventHandler
|
16
|
+
onBlur?: React.FocusEventHandler<HTMLTextAreaElement>;
|
17
17
|
/**
|
18
18
|
* @en Callback function for blur focus
|
19
19
|
* @cn focus 事件回调函数
|
20
20
|
*/
|
21
|
-
onFocus?: React.FocusEventHandler
|
21
|
+
onFocus?: React.FocusEventHandler<HTMLTextAreaElement>;
|
22
22
|
/**
|
23
23
|
* @en Callback function for click
|
24
24
|
* @cn click 事件回调函数
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-textarea.type.d.ts","sourceRoot":"","sources":["use-textarea.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC;
|
1
|
+
{"version":3,"file":"use-textarea.type.d.ts","sourceRoot":"","sources":["use-textarea.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC;;;OAGG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAC;IACtD;;;OAGG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC,iBAAiB,CAAC,mBAAmB,CAAC,CAAC;IACvD;;;OAGG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