@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.
@@ -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" | (string & {}) | "hidden" | "checkbox" | "radio" | "text" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "week" | undefined;
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" | (string & {}) | "hidden" | "checkbox" | "radio" | "text" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "week" | undefined;
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 getClosestFixedContainer(element: Element | HTMLElement | null): HTMLElement | null;
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,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,sBAqB7E;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"}
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"}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.addResizeObserver = void 0;
7
7
  exports.cssSupport = cssSupport;
8
- exports.getClosestFixedContainer = getClosestFixedContainer;
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 getClosestFixedContainer(element) {
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
- return style.position === 'fixed';
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;AAyBD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,UAAU,iBA4BvC"}
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"}
@@ -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.getClosestFixedContainer)(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" | (string & {}) | "hidden" | "checkbox" | "radio" | "text" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "week" | undefined;
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" | (string & {}) | "hidden" | "checkbox" | "radio" | "text" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "week" | undefined;
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 getClosestFixedContainer(element: Element | HTMLElement | null): HTMLElement | null;
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,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,sBAqB7E;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"}
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"}
@@ -145,13 +145,15 @@ export function getClosestScrollContainer(element) {
145
145
  // 如果没有找到可滚动的祖先,返回 body 或 documentElement
146
146
  return document.scrollingElement || document.documentElement;
147
147
  }
148
- export function getClosestFixedContainer(element) {
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
- return style.position === 'fixed';
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;AAyBD,wBAAgB,QAAQ,CAAC,GAAG,EAAE,UAAU,iBA4BvC"}
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"}
@@ -1,5 +1,5 @@
1
1
  import { generateUUID, docSize, devUseWarning } from "../utils";
2
- import { getClosestFixedContainer } from "./dom/element";
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 = getClosestFixedContainer(element);
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
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.6.0-beta.15",
3
+ "version": "3.6.0-beta.16",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",