@sheinx/hooks 3.6.0-beta.15 → 3.6.0-beta.16
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-input/use-input-format.d.ts +1 -1
- package/cjs/components/use-input/use-input-number.d.ts +1 -1
- package/cjs/utils/dom/element.d.ts +1 -1
- package/cjs/utils/dom/element.d.ts.map +1 -1
- package/cjs/utils/dom/element.js +5 -3
- package/cjs/utils/lazyload.d.ts.map +1 -1
- package/cjs/utils/lazyload.js +2 -2
- package/esm/components/use-input/use-input-format.d.ts +1 -1
- package/esm/components/use-input/use-input-number.d.ts +1 -1
- package/esm/utils/dom/element.d.ts +1 -1
- package/esm/utils/dom/element.d.ts.map +1 -1
- package/esm/utils/dom/element.js +4 -2
- package/esm/utils/lazyload.d.ts.map +1 -1
- package/esm/utils/lazyload.js +3 -3
- package/package.json +1 -1
@@ -5,7 +5,7 @@ declare const useInputFormat: (props: InputFormatProps) => {
|
|
5
5
|
onBlur: (e: React.FocusEvent) => void;
|
6
6
|
onFocus: (e: React.FocusEvent) => void;
|
7
7
|
value: string | undefined;
|
8
|
-
type: "search" | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" |
|
8
|
+
type: "search" | (string & {}) | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" | "hidden" | "checkbox" | "radio" | "text" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "week" | undefined;
|
9
9
|
};
|
10
10
|
export default useInputFormat;
|
11
11
|
//# sourceMappingURL=use-input-format.d.ts.map
|
@@ -7,7 +7,7 @@ declare const useNumberFormat: (props: InputNumberProps) => {
|
|
7
7
|
onBlur: (e: React.FocusEvent<Element, Element>) => void;
|
8
8
|
onFocus: (e: React.FocusEvent<Element, Element>) => void;
|
9
9
|
value: string | undefined;
|
10
|
-
type: "search" | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" |
|
10
|
+
type: "search" | (string & {}) | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" | "hidden" | "checkbox" | "radio" | "text" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "week" | undefined;
|
11
11
|
};
|
12
12
|
export default useNumberFormat;
|
13
13
|
//# sourceMappingURL=use-input-number.d.ts.map
|
@@ -13,7 +13,7 @@ export declare const addResizeObserver: (el: HTMLElement, handler: any, options?
|
|
13
13
|
}) => () => void;
|
14
14
|
export declare function getParent(el: HTMLElement | null | Element, target?: string | HTMLElement): Element | null;
|
15
15
|
export declare function getClosestScrollContainer(element: HTMLElement | null): HTMLElement | null;
|
16
|
-
export declare function
|
16
|
+
export declare function getClosestPositionedContainer(element: Element | HTMLElement | null, positions?: React.CSSProperties['position'][]): HTMLElement | null;
|
17
17
|
export declare function cssSupport(attr: keyof CSSStyleDeclaration, value: string): boolean;
|
18
18
|
export declare const parsePxToNumber: (str: string) => number;
|
19
19
|
export declare const getFieldId: (name?: string, formName?: string) => string | undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["element.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,WAAW,UAAQ,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,KAAK,CAAC,SAAS,CASjB;AAGD,eAAO,MAAM,iBAAiB,OACxB,WAAW,WACN,GAAG;;;gBA4Cb,CAAC;AAEF,wBAAgB,SAAS,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,kBAmBxF;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAmCzF;AAED,wBAAgB,
|
1
|
+
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["element.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,WAAW,UAAQ,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,KAAK,CAAC,SAAS,CASjB;AAGD,eAAO,MAAM,iBAAiB,OACxB,WAAW,WACN,GAAG;;;gBA4Cb,CAAC;AAEF,wBAAgB,SAAS,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,kBAmBxF;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAmCzF;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,EACrC,SAAS,GAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,EAA0B,sBAuBrE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,mBAAmB,EAAE,KAAK,EAAE,MAAM,WAYxE;AAED,eAAO,MAAM,eAAe,QAAS,MAAM,WAAwC,CAAC;AAEpF,eAAO,MAAM,UAAU,UAAW,MAAM,aAAa,MAAM,uBAG1D,CAAC"}
|
package/cjs/utils/dom/element.js
CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.addResizeObserver = void 0;
|
7
7
|
exports.cssSupport = cssSupport;
|
8
|
-
exports.
|
8
|
+
exports.getClosestPositionedContainer = getClosestPositionedContainer;
|
9
9
|
exports.getClosestScrollContainer = getClosestScrollContainer;
|
10
10
|
exports.getFieldId = void 0;
|
11
11
|
exports.getParent = getParent;
|
@@ -158,13 +158,15 @@ function getClosestScrollContainer(element) {
|
|
158
158
|
// 如果没有找到可滚动的祖先,返回 body 或 documentElement
|
159
159
|
return document.scrollingElement || document.documentElement;
|
160
160
|
}
|
161
|
-
function
|
161
|
+
function getClosestPositionedContainer(element) {
|
162
|
+
var positions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['fixed', 'absolute'];
|
162
163
|
if (!element) {
|
163
164
|
return null;
|
164
165
|
}
|
165
166
|
var isFixable = function isFixable(el) {
|
166
167
|
var style = window.getComputedStyle(el);
|
167
|
-
|
168
|
+
var position = style.position;
|
169
|
+
return positions.includes(position);
|
168
170
|
};
|
169
171
|
|
170
172
|
// 遍历父元素
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"lazyload.d.ts","sourceRoot":"","sources":["lazyload.ts"],"names":[],"mappings":"AAKA,KAAK,UAAU,GAAG;IAChB,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC,CAAC;AAsBF,wBAAgB,QAAQ,SAgBvB;AAWD,wBAAgB,WAAW,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,QAUvE;
|
1
|
+
{"version":3,"file":"lazyload.d.ts","sourceRoot":"","sources":["lazyload.ts"],"names":[],"mappings":"AAKA,KAAK,UAAU,GAAG;IAChB,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC,CAAC;AAsBF,wBAAgB,QAAQ,SAgBvB;AAWD,wBAAgB,WAAW,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,QAUvE;AA0BD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,UAAU,iBA4BvC"}
|
package/cjs/utils/lazyload.js
CHANGED
@@ -19,7 +19,6 @@ var getRect = function getRect(el) {
|
|
19
19
|
if (el) {
|
20
20
|
_utils.devUseWarning.error("the ".concat(el, " is not a element"));
|
21
21
|
}
|
22
|
-
;
|
23
22
|
return {
|
24
23
|
top: 0,
|
25
24
|
bottom: winHeight
|
@@ -75,13 +74,14 @@ function getObserver(obj, id) {
|
|
75
74
|
render = obj.render,
|
76
75
|
offscreen = obj.offscreen,
|
77
76
|
noRemove = obj.noRemove;
|
78
|
-
var fixedContainer = (0, _element.
|
77
|
+
var fixedContainer = (0, _element.getClosestPositionedContainer)(element, ['fixed', 'absolute']);
|
79
78
|
var observer = new IntersectionObserver(function (entries) {
|
80
79
|
entries.forEach(function (en) {
|
81
80
|
if (en.isIntersecting || en.intersectionRatio > 0) {
|
82
81
|
render();
|
83
82
|
if (!noRemove) removeStack(id);
|
84
83
|
} else {
|
84
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
85
85
|
offscreen && offscreen();
|
86
86
|
}
|
87
87
|
});
|
@@ -5,7 +5,7 @@ declare const useInputFormat: (props: InputFormatProps) => {
|
|
5
5
|
onBlur: (e: React.FocusEvent) => void;
|
6
6
|
onFocus: (e: React.FocusEvent) => void;
|
7
7
|
value: string | undefined;
|
8
|
-
type: "search" | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" |
|
8
|
+
type: "search" | (string & {}) | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" | "hidden" | "checkbox" | "radio" | "text" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "week" | undefined;
|
9
9
|
};
|
10
10
|
export default useInputFormat;
|
11
11
|
//# sourceMappingURL=use-input-format.d.ts.map
|
@@ -7,7 +7,7 @@ declare const useNumberFormat: (props: InputNumberProps) => {
|
|
7
7
|
onBlur: (e: React.FocusEvent<Element, Element>) => void;
|
8
8
|
onFocus: (e: React.FocusEvent<Element, Element>) => void;
|
9
9
|
value: string | undefined;
|
10
|
-
type: "search" | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" |
|
10
|
+
type: "search" | (string & {}) | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" | "hidden" | "checkbox" | "radio" | "text" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "week" | undefined;
|
11
11
|
};
|
12
12
|
export default useNumberFormat;
|
13
13
|
//# sourceMappingURL=use-input-number.d.ts.map
|
@@ -13,7 +13,7 @@ export declare const addResizeObserver: (el: HTMLElement, handler: any, options?
|
|
13
13
|
}) => () => void;
|
14
14
|
export declare function getParent(el: HTMLElement | null | Element, target?: string | HTMLElement): Element | null;
|
15
15
|
export declare function getClosestScrollContainer(element: HTMLElement | null): HTMLElement | null;
|
16
|
-
export declare function
|
16
|
+
export declare function getClosestPositionedContainer(element: Element | HTMLElement | null, positions?: React.CSSProperties['position'][]): HTMLElement | null;
|
17
17
|
export declare function cssSupport(attr: keyof CSSStyleDeclaration, value: string): boolean;
|
18
18
|
export declare const parsePxToNumber: (str: string) => number;
|
19
19
|
export declare const getFieldId: (name?: string, formName?: string) => string | undefined;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["element.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,WAAW,UAAQ,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,KAAK,CAAC,SAAS,CASjB;AAGD,eAAO,MAAM,iBAAiB,OACxB,WAAW,WACN,GAAG;;;gBA4Cb,CAAC;AAEF,wBAAgB,SAAS,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,kBAmBxF;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAmCzF;AAED,wBAAgB,
|
1
|
+
{"version":3,"file":"element.d.ts","sourceRoot":"","sources":["element.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAa1B;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,WAAW,UAAQ,EACnB,SAAS,CAAC,EAAE,MAAM,GACjB,KAAK,CAAC,SAAS,CASjB;AAGD,eAAO,MAAM,iBAAiB,OACxB,WAAW,WACN,GAAG;;;gBA4Cb,CAAC;AAEF,wBAAgB,SAAS,CAAC,EAAE,EAAE,WAAW,GAAG,IAAI,GAAG,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,kBAmBxF;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAmCzF;AAED,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,EACrC,SAAS,GAAE,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,EAA0B,sBAuBrE;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,mBAAmB,EAAE,KAAK,EAAE,MAAM,WAYxE;AAED,eAAO,MAAM,eAAe,QAAS,MAAM,WAAwC,CAAC;AAEpF,eAAO,MAAM,UAAU,UAAW,MAAM,aAAa,MAAM,uBAG1D,CAAC"}
|
package/esm/utils/dom/element.js
CHANGED
@@ -145,13 +145,15 @@ export function getClosestScrollContainer(element) {
|
|
145
145
|
// 如果没有找到可滚动的祖先,返回 body 或 documentElement
|
146
146
|
return document.scrollingElement || document.documentElement;
|
147
147
|
}
|
148
|
-
export function
|
148
|
+
export function getClosestPositionedContainer(element) {
|
149
|
+
var positions = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['fixed', 'absolute'];
|
149
150
|
if (!element) {
|
150
151
|
return null;
|
151
152
|
}
|
152
153
|
var isFixable = function isFixable(el) {
|
153
154
|
var style = window.getComputedStyle(el);
|
154
|
-
|
155
|
+
var position = style.position;
|
156
|
+
return positions.includes(position);
|
155
157
|
};
|
156
158
|
|
157
159
|
// 遍历父元素
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"lazyload.d.ts","sourceRoot":"","sources":["lazyload.ts"],"names":[],"mappings":"AAKA,KAAK,UAAU,GAAG;IAChB,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC,CAAC;AAsBF,wBAAgB,QAAQ,SAgBvB;AAWD,wBAAgB,WAAW,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,QAUvE;
|
1
|
+
{"version":3,"file":"lazyload.d.ts","sourceRoot":"","sources":["lazyload.ts"],"names":[],"mappings":"AAKA,KAAK,UAAU,GAAG;IAChB,SAAS,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC,CAAC;AAsBF,wBAAgB,QAAQ,SAgBvB;AAWD,wBAAgB,WAAW,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,cAAc,CAAC,EAAE,OAAO,QAUvE;AA0BD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,UAAU,iBA4BvC"}
|
package/esm/utils/lazyload.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { generateUUID, docSize, devUseWarning } from "../utils";
|
2
|
-
import {
|
2
|
+
import { getClosestPositionedContainer } from "./dom/element";
|
3
3
|
var throttle = 80;
|
4
4
|
var components = {};
|
5
5
|
var timeout = null;
|
@@ -11,7 +11,6 @@ var getRect = function getRect(el) {
|
|
11
11
|
if (el) {
|
12
12
|
devUseWarning.error("the ".concat(el, " is not a element"));
|
13
13
|
}
|
14
|
-
;
|
15
14
|
return {
|
16
15
|
top: 0,
|
17
16
|
bottom: winHeight
|
@@ -67,13 +66,14 @@ function getObserver(obj, id) {
|
|
67
66
|
render = obj.render,
|
68
67
|
offscreen = obj.offscreen,
|
69
68
|
noRemove = obj.noRemove;
|
70
|
-
var fixedContainer =
|
69
|
+
var fixedContainer = getClosestPositionedContainer(element, ['fixed', 'absolute']);
|
71
70
|
var observer = new IntersectionObserver(function (entries) {
|
72
71
|
entries.forEach(function (en) {
|
73
72
|
if (en.isIntersecting || en.intersectionRatio > 0) {
|
74
73
|
render();
|
75
74
|
if (!noRemove) removeStack(id);
|
76
75
|
} else {
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
77
77
|
offscreen && offscreen();
|
78
78
|
}
|
79
79
|
});
|