@sheinx/hooks 3.7.8-beta.9 → 3.7.8-fix.1
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/common/use-input-able/use-Input-able.d.ts.map +1 -1
- package/cjs/common/use-input-able/use-Input-able.js +6 -7
- package/cjs/common/use-position-style/index.d.ts.map +1 -1
- package/cjs/common/use-position-style/index.js +7 -6
- package/cjs/components/use-form/use-form.d.ts.map +1 -1
- package/cjs/components/use-form/use-form.js +1 -1
- package/cjs/utils/dom/document.d.ts +4 -0
- package/cjs/utils/dom/document.d.ts.map +1 -1
- package/cjs/utils/dom/document.js +19 -2
- package/esm/common/use-input-able/use-Input-able.d.ts.map +1 -1
- package/esm/common/use-input-able/use-Input-able.js +7 -8
- package/esm/common/use-position-style/index.d.ts.map +1 -1
- package/esm/common/use-position-style/index.js +8 -7
- package/esm/components/use-form/use-form.d.ts.map +1 -1
- package/esm/components/use-form/use-form.js +1 -1
- package/esm/utils/dom/document.d.ts +4 -0
- package/esm/utils/dom/document.d.ts.map +1 -1
- package/esm/utils/dom/document.js +18 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;
|
|
1
|
+
{"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;EA0E3F"}
|
|
@@ -46,19 +46,18 @@ function useInputAble(props) {
|
|
|
46
46
|
var render = (0, _useRender.useRender)(syncValue);
|
|
47
47
|
var shouldUseState = delay || !control;
|
|
48
48
|
var value = shouldUseState ? stateValue : valuePo;
|
|
49
|
-
(0, _react.
|
|
50
|
-
if (context.timer) {
|
|
51
|
-
clearTimeout(context.timer);
|
|
52
|
-
context.timer = null;
|
|
53
|
-
}
|
|
49
|
+
(0, _react.useLayoutEffect)(function () {
|
|
54
50
|
if (delay && control && props.value !== stateValue) {
|
|
55
51
|
changeStateValue(props.value);
|
|
52
|
+
} else if (context.timer) {
|
|
53
|
+
clearTimeout(context.timer);
|
|
54
|
+
context.timer = null;
|
|
56
55
|
}
|
|
57
56
|
}, [props.value, delay, control]);
|
|
58
57
|
var forceDelayChange = (0, _usePersistFn.default)(function () {
|
|
59
|
-
if (context.
|
|
58
|
+
if (context.delayChange) context.delayChange();
|
|
59
|
+
if (context.timer) {
|
|
60
60
|
clearTimeout(context.timer);
|
|
61
|
-
context.delayChange();
|
|
62
61
|
context.timer = null;
|
|
63
62
|
context.delayChange = null;
|
|
64
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAUpE,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,UAAU,GACV,cAAc,GACd,WAAW,GACX,MAAM,GACN,OAAO,CAAC;AACZ,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,cAAc,GACd,UAAU,GACV,WAAW,GACX,KAAK,GACL,QAAQ,CAAC;AAYb,KAAK,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,OAAO,CAAC;AACpE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,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AAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAEzC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3B;AAOD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;CA+S3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -255,17 +255,18 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
|
255
255
|
};
|
|
256
256
|
};
|
|
257
257
|
var getAbsoluteStyle = function getAbsoluteStyle(position) {
|
|
258
|
-
var _scrollElRef$current
|
|
258
|
+
var _scrollElRef$current;
|
|
259
259
|
if (!parentElRef.current) return {
|
|
260
260
|
style: hideStyle
|
|
261
261
|
};
|
|
262
262
|
var rect = context.parentRect;
|
|
263
263
|
var needCheck = !show || !(0, _shallowEqual.default)(context.prevParentPosition, parentElNewPosition);
|
|
264
|
-
var
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
var
|
|
264
|
+
var _getScrollPosition = (0, _utils.getScrollPosition)(scrollElRef === null || scrollElRef === void 0 ? void 0 : scrollElRef.current),
|
|
265
|
+
scrollTop = _getScrollPosition.scrollTop,
|
|
266
|
+
scrollLeft = _getScrollPosition.scrollLeft;
|
|
267
|
+
if (needCheck && scrollElRef !== null && scrollElRef !== void 0 && scrollElRef.current && (_scrollElRef$current = scrollElRef.current) !== null && _scrollElRef$current !== void 0 && _scrollElRef$current.contains(parentElRef.current)) {
|
|
268
|
+
var _scrollElRef$current2;
|
|
269
|
+
var visibleRect = ((_scrollElRef$current2 = scrollElRef.current) === null || _scrollElRef$current2 === void 0 ? void 0 : _scrollElRef$current2.getBoundingClientRect()) || {};
|
|
269
270
|
if (rect.bottom < visibleRect.top || rect.top > visibleRect.bottom + scrollTop || rect.right < visibleRect.left || rect.left > visibleRect.right + scrollLeft) {
|
|
270
271
|
return {
|
|
271
272
|
style: hideStyle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":"AAiCA,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":"AAiCA,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;;CAsb9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -236,7 +236,7 @@ var useForm = function useForm(props) {
|
|
|
236
236
|
var _props$onChange;
|
|
237
237
|
var newValue = typeof change === 'function' ? (0, _immer.produce)(context.value, change) : change;
|
|
238
238
|
context.value = newValue;
|
|
239
|
-
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props,
|
|
239
|
+
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, newValue);
|
|
240
240
|
});
|
|
241
241
|
var scrollToField = (0, _usePersistFn.default)(function (name) {
|
|
242
242
|
var _document;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["document.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,QAAO,MAqBpC,CAAA"}
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["document.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,QAAO,MAqBpC,CAAA;AA6BD,eAAO,MAAM,iBAAiB,aAAc,WAAW,GAAG,IAAI;;;CAc7D,CAAC"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getCurrentCSSZoom = void 0;
|
|
6
|
+
exports.getScrollPosition = exports.getCurrentCSSZoom = void 0;
|
|
7
7
|
var cachedZoom = 0;
|
|
8
8
|
var getCurrentCSSZoom = exports.getCurrentCSSZoom = function getCurrentCSSZoom() {
|
|
9
9
|
if (cachedZoom) return cachedZoom;
|
|
@@ -46,4 +46,21 @@ var getCurrentCSSZoom = exports.getCurrentCSSZoom = function getCurrentCSSZoom()
|
|
|
46
46
|
// width: rect.width * zoomRatio,
|
|
47
47
|
// height: rect.height * zoomRatio,
|
|
48
48
|
// }
|
|
49
|
-
// }
|
|
49
|
+
// }
|
|
50
|
+
|
|
51
|
+
var getScrollPosition = exports.getScrollPosition = function getScrollPosition(element) {
|
|
52
|
+
if (!element) return {
|
|
53
|
+
scrollTop: 0,
|
|
54
|
+
scrollLeft: 0
|
|
55
|
+
};
|
|
56
|
+
if (element === document.documentElement || element === document.body) {
|
|
57
|
+
return {
|
|
58
|
+
scrollTop: document.documentElement.scrollTop || document.body.scrollTop,
|
|
59
|
+
scrollLeft: document.documentElement.scrollLeft || document.body.scrollLeft
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
scrollTop: element.scrollTop,
|
|
64
|
+
scrollLeft: element.scrollLeft
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;
|
|
1
|
+
{"version":3,"file":"use-Input-able.d.ts","sourceRoot":"","sources":["use-Input-able.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC;;;;EA0E3F"}
|
|
@@ -4,7 +4,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
4
4
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
-
import {
|
|
7
|
+
import { useLayoutEffect, useRef, useState } from 'react';
|
|
8
8
|
import { isFunc } from "../../utils/is";
|
|
9
9
|
import { shallowEqual } from "../../utils/shallow-equal";
|
|
10
10
|
import usePersistFn from "../use-persist-fn";
|
|
@@ -39,19 +39,18 @@ export default function useInputAble(props) {
|
|
|
39
39
|
var render = useRender(syncValue);
|
|
40
40
|
var shouldUseState = delay || !control;
|
|
41
41
|
var value = shouldUseState ? stateValue : valuePo;
|
|
42
|
-
|
|
43
|
-
if (context.timer) {
|
|
44
|
-
clearTimeout(context.timer);
|
|
45
|
-
context.timer = null;
|
|
46
|
-
}
|
|
42
|
+
useLayoutEffect(function () {
|
|
47
43
|
if (delay && control && props.value !== stateValue) {
|
|
48
44
|
changeStateValue(props.value);
|
|
45
|
+
} else if (context.timer) {
|
|
46
|
+
clearTimeout(context.timer);
|
|
47
|
+
context.timer = null;
|
|
49
48
|
}
|
|
50
49
|
}, [props.value, delay, control]);
|
|
51
50
|
var forceDelayChange = usePersistFn(function () {
|
|
52
|
-
if (context.
|
|
51
|
+
if (context.delayChange) context.delayChange();
|
|
52
|
+
if (context.timer) {
|
|
53
53
|
clearTimeout(context.timer);
|
|
54
|
-
context.delayChange();
|
|
55
54
|
context.timer = null;
|
|
56
55
|
context.delayChange = null;
|
|
57
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA+C,MAAM,OAAO,CAAC;AAUpE,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,UAAU,GACV,cAAc,GACd,WAAW,GACX,MAAM,GACN,OAAO,CAAC;AACZ,MAAM,MAAM,gBAAgB,GACxB,aAAa,GACb,cAAc,GACd,UAAU,GACV,WAAW,GACX,KAAK,GACL,QAAQ,CAAC;AAYb,KAAK,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,GAAG,OAAO,CAAC;AACpE,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,YAAY,GAAG,SAAS,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IAEd,WAAW,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAE1C,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAEzC,WAAW,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IAC3C,YAAY,EAAE,MAAM,WAAW,GAAG,IAAI,GAAG,SAAS,CAAC;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,C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CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -12,7 +12,7 @@ import { useCheckElementBorderWidth } from "./check-border";
|
|
|
12
12
|
import { useCheckElementSize } from "./check-element-size";
|
|
13
13
|
import shallowEqual from "../../utils/shallow-equal";
|
|
14
14
|
import usePersistFn from "../use-persist-fn";
|
|
15
|
-
import { getCurrentCSSZoom } from "../../utils";
|
|
15
|
+
import { getCurrentCSSZoom, getScrollPosition } from "../../utils";
|
|
16
16
|
import { docSize } from "../../utils";
|
|
17
17
|
var horizontalPosition = ['left-bottom', 'left-top', 'right-bottom', 'right-top', 'left', 'right'];
|
|
18
18
|
var verticalPosition = ['bottom-left', 'bottom-right', 'top-left', 'top-right', 'bottom', 'top'];
|
|
@@ -246,17 +246,18 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
|
246
246
|
};
|
|
247
247
|
};
|
|
248
248
|
var getAbsoluteStyle = function getAbsoluteStyle(position) {
|
|
249
|
-
var _scrollElRef$current
|
|
249
|
+
var _scrollElRef$current;
|
|
250
250
|
if (!parentElRef.current) return {
|
|
251
251
|
style: hideStyle
|
|
252
252
|
};
|
|
253
253
|
var rect = context.parentRect;
|
|
254
254
|
var needCheck = !show || !shallowEqual(context.prevParentPosition, parentElNewPosition);
|
|
255
|
-
var
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
var
|
|
255
|
+
var _getScrollPosition = getScrollPosition(scrollElRef === null || scrollElRef === void 0 ? void 0 : scrollElRef.current),
|
|
256
|
+
scrollTop = _getScrollPosition.scrollTop,
|
|
257
|
+
scrollLeft = _getScrollPosition.scrollLeft;
|
|
258
|
+
if (needCheck && scrollElRef !== null && scrollElRef !== void 0 && scrollElRef.current && (_scrollElRef$current = scrollElRef.current) !== null && _scrollElRef$current !== void 0 && _scrollElRef$current.contains(parentElRef.current)) {
|
|
259
|
+
var _scrollElRef$current2;
|
|
260
|
+
var visibleRect = ((_scrollElRef$current2 = scrollElRef.current) === null || _scrollElRef$current2 === void 0 ? void 0 : _scrollElRef$current2.getBoundingClientRect()) || {};
|
|
260
261
|
if (rect.bottom < visibleRect.top || rect.top > visibleRect.bottom + scrollTop || rect.right < visibleRect.left || rect.left > visibleRect.right + scrollLeft) {
|
|
261
262
|
return {
|
|
262
263
|
style: hideStyle
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-form.d.ts","sourceRoot":"","sources":["use-form.ts"],"names":[],"mappings":"AAiCA,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":"AAiCA,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;;CAsb9D,CAAC;AAEF,eAAe,OAAO,CAAC"}
|
|
@@ -227,7 +227,7 @@ var useForm = function useForm(props) {
|
|
|
227
227
|
var _props$onChange;
|
|
228
228
|
var newValue = typeof change === 'function' ? produce(context.value, change) : change;
|
|
229
229
|
context.value = newValue;
|
|
230
|
-
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props,
|
|
230
|
+
(_props$onChange = props.onChange) === null || _props$onChange === void 0 || _props$onChange.call(props, newValue);
|
|
231
231
|
});
|
|
232
232
|
var scrollToField = usePersistFn(function (name) {
|
|
233
233
|
var _document;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["document.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,QAAO,MAqBpC,CAAA"}
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["document.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,iBAAiB,QAAO,MAqBpC,CAAA;AA6BD,eAAO,MAAM,iBAAiB,aAAc,WAAW,GAAG,IAAI;;;CAc7D,CAAC"}
|
|
@@ -40,4 +40,21 @@ export var getCurrentCSSZoom = function getCurrentCSSZoom() {
|
|
|
40
40
|
// width: rect.width * zoomRatio,
|
|
41
41
|
// height: rect.height * zoomRatio,
|
|
42
42
|
// }
|
|
43
|
-
// }
|
|
43
|
+
// }
|
|
44
|
+
|
|
45
|
+
export var getScrollPosition = function getScrollPosition(element) {
|
|
46
|
+
if (!element) return {
|
|
47
|
+
scrollTop: 0,
|
|
48
|
+
scrollLeft: 0
|
|
49
|
+
};
|
|
50
|
+
if (element === document.documentElement || element === document.body) {
|
|
51
|
+
return {
|
|
52
|
+
scrollTop: document.documentElement.scrollTop || document.body.scrollTop,
|
|
53
|
+
scrollLeft: document.documentElement.scrollLeft || document.body.scrollLeft
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
scrollTop: element.scrollTop,
|
|
58
|
+
scrollLeft: element.scrollLeft
|
|
59
|
+
};
|
|
60
|
+
};
|