@sheinx/hooks 3.3.6-beta.1 → 3.3.6-beta.2
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":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAMnD,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,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAQD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB,
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAMnD,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,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAQD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB,wBA4P3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
@@ -217,6 +217,9 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
217
217
|
var getAbsoluteStyle = function getAbsoluteStyle(position) {
|
218
218
|
if (!parentElRef.current) return hideStyle;
|
219
219
|
var rect = context.parentRect;
|
220
|
+
console.log('======================');
|
221
|
+
console.log('rect: >>', rect);
|
222
|
+
console.log('======================');
|
220
223
|
if (scrollElRef !== null && scrollElRef !== void 0 && scrollElRef.current) {
|
221
224
|
var _scrollElRef$current;
|
222
225
|
var visibleRect = ((_scrollElRef$current = scrollElRef.current) === null || _scrollElRef$current === void 0 ? void 0 : _scrollElRef$current.getBoundingClientRect()) || {};
|
@@ -225,6 +228,25 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
225
228
|
}
|
226
229
|
}
|
227
230
|
var style = getAbsolutePositionStyle(rect, position);
|
231
|
+
|
232
|
+
// TODO: 如果是版本大于chrome128,需要根据currentCSSZoom处理chrome的bug
|
233
|
+
if (!(0, _utils.isChromeLowerThan)(128)) {
|
234
|
+
// @ts-ignore currentCSSZoom
|
235
|
+
var currentCSSZoom = document.body.currentCSSZoom;
|
236
|
+
if (currentCSSZoom === 1 || !currentCSSZoom) return style;
|
237
|
+
if (style.left && typeof style.left === 'number') {
|
238
|
+
style.left = style.left * (1 / currentCSSZoom);
|
239
|
+
}
|
240
|
+
if (style.top && typeof style.top === 'number') {
|
241
|
+
style.top = style.top * (1 / currentCSSZoom);
|
242
|
+
}
|
243
|
+
if (style.right && typeof style.right === 'number') {
|
244
|
+
style.right = style.right * (1 / currentCSSZoom);
|
245
|
+
}
|
246
|
+
if (style.bottom && typeof style.bottom === 'number') {
|
247
|
+
style.bottom = style.bottom * (1 / currentCSSZoom);
|
248
|
+
}
|
249
|
+
}
|
228
250
|
return style;
|
229
251
|
};
|
230
252
|
var getStyle = function getStyle() {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AAMnD,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,kBA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AC;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,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAQD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB,wBA4P3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
@@ -9,7 +9,7 @@ import React, { useEffect, useState } from 'react';
|
|
9
9
|
import { getPositionStyle } from "./get-position-style";
|
10
10
|
import shallowEqual from "../../utils/shallow-equal";
|
11
11
|
import usePersistFn from "../use-persist-fn";
|
12
|
-
import { docSize } from "../../utils";
|
12
|
+
import { docSize, isChromeLowerThan } from "../../utils";
|
13
13
|
var horizontalPosition = ['left-bottom', 'left-top', 'right-bottom', 'right-top', 'left', 'right'];
|
14
14
|
var verticalPosition = ['bottom-left', 'bottom-right', 'top-left', 'top-right', 'bottom', 'top'];
|
15
15
|
var hideStyle = {
|
@@ -207,6 +207,9 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
207
207
|
var getAbsoluteStyle = function getAbsoluteStyle(position) {
|
208
208
|
if (!parentElRef.current) return hideStyle;
|
209
209
|
var rect = context.parentRect;
|
210
|
+
console.log('======================');
|
211
|
+
console.log('rect: >>', rect);
|
212
|
+
console.log('======================');
|
210
213
|
if (scrollElRef !== null && scrollElRef !== void 0 && scrollElRef.current) {
|
211
214
|
var _scrollElRef$current;
|
212
215
|
var visibleRect = ((_scrollElRef$current = scrollElRef.current) === null || _scrollElRef$current === void 0 ? void 0 : _scrollElRef$current.getBoundingClientRect()) || {};
|
@@ -215,6 +218,25 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
215
218
|
}
|
216
219
|
}
|
217
220
|
var style = getAbsolutePositionStyle(rect, position);
|
221
|
+
|
222
|
+
// TODO: 如果是版本大于chrome128,需要根据currentCSSZoom处理chrome的bug
|
223
|
+
if (!isChromeLowerThan(128)) {
|
224
|
+
// @ts-ignore currentCSSZoom
|
225
|
+
var currentCSSZoom = document.body.currentCSSZoom;
|
226
|
+
if (currentCSSZoom === 1 || !currentCSSZoom) return style;
|
227
|
+
if (style.left && typeof style.left === 'number') {
|
228
|
+
style.left = style.left * (1 / currentCSSZoom);
|
229
|
+
}
|
230
|
+
if (style.top && typeof style.top === 'number') {
|
231
|
+
style.top = style.top * (1 / currentCSSZoom);
|
232
|
+
}
|
233
|
+
if (style.right && typeof style.right === 'number') {
|
234
|
+
style.right = style.right * (1 / currentCSSZoom);
|
235
|
+
}
|
236
|
+
if (style.bottom && typeof style.bottom === 'number') {
|
237
|
+
style.bottom = style.bottom * (1 / currentCSSZoom);
|
238
|
+
}
|
239
|
+
}
|
218
240
|
return style;
|
219
241
|
};
|
220
242
|
var getStyle = function getStyle() {
|