@sheinx/hooks 3.7.8-beta.8 → 3.7.8
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-position-style/index.d.ts.map +1 -1
- package/cjs/common/use-position-style/index.js +10 -7
- 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-position-style/index.d.ts.map +1 -1
- package/esm/common/use-position-style/index.js +11 -8
- 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":"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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AC;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
|
@@ -339,7 +340,9 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
339
340
|
}
|
340
341
|
|
341
342
|
// 当父元素的滚动容器滚动时,判断是否需要更新弹出层位置,包括是否隐藏弹出层(通过hideStyle隐藏,不是show状态)
|
342
|
-
|
343
|
+
if (show) {
|
344
|
+
context.prevParentPosition = parentElNewPosition;
|
345
|
+
}
|
343
346
|
});
|
344
347
|
(0, _react.useEffect)(updateStyle, [show, position, absolute, updateKey, fixedWidth, parentElNewPosition, popupElSize]);
|
345
348
|
return {
|
@@ -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":"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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C3C,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"}
|
@@ -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
|
@@ -330,7 +331,9 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
330
331
|
}
|
331
332
|
|
332
333
|
// 当父元素的滚动容器滚动时,判断是否需要更新弹出层位置,包括是否隐藏弹出层(通过hideStyle隐藏,不是show状态)
|
333
|
-
|
334
|
+
if (show) {
|
335
|
+
context.prevParentPosition = parentElNewPosition;
|
336
|
+
}
|
334
337
|
});
|
335
338
|
useEffect(updateStyle, [show, position, absolute, updateKey, fixedWidth, parentElNewPosition, popupElSize]);
|
336
339
|
return {
|
@@ -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
|
+
};
|