@sheinx/hooks 3.8.6-beta.2 → 3.8.6-beta.4

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.
@@ -0,0 +1,10 @@
1
+ interface Options {
2
+ parentRect: DOMRect;
3
+ boundary: HTMLElement;
4
+ }
5
+ export declare const getSizingStyle: (position: string, { boundary, parentRect }: Options) => {
6
+ maxHeight: number | undefined;
7
+ overflowY: "auto";
8
+ };
9
+ export {};
10
+ //# sourceMappingURL=get-sizing-style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-sizing-style.d.ts","sourceRoot":"","sources":["get-sizing-style.ts"],"names":[],"mappings":"AAAA,UAAU,OAAO;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,WAAW,CAAC;CACvB;AAID,eAAO,MAAO,cAAc,aAAc,MAAM,4BAAyB,OAAO;;;CAU/E,CAAA"}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getSizingStyle = void 0;
7
+ // 第一阶段:支持上下边界的高度限制
8
+ // TODO 后续支持左右边界的宽度限制
9
+ var getSizingStyle = exports.getSizingStyle = function getSizingStyle(position, _ref) {
10
+ var boundary = _ref.boundary,
11
+ parentRect = _ref.parentRect;
12
+ var boundaryRect = boundary.getBoundingClientRect();
13
+ var maxHeight;
14
+ if (position.endsWith('-top')) {
15
+ maxHeight = boundaryRect.bottom - parentRect.top;
16
+ } else if (position.endsWith('-bottom')) {
17
+ maxHeight = parentRect.bottom - boundaryRect.top;
18
+ }
19
+ return {
20
+ maxHeight: maxHeight,
21
+ overflowY: 'auto'
22
+ };
23
+ };
@@ -18,6 +18,7 @@ export interface PositionStyleConfig {
18
18
  onAdjust?: (position: HorizontalPosition | VerticalPosition) => void;
19
19
  checkPosition?: boolean;
20
20
  offset?: [number, number];
21
+ boundary?: HTMLElement | null;
21
22
  }
22
23
  export declare const usePositionStyle: (config: PositionStyleConfig) => {
23
24
  style: React.CSSProperties;
@@ -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,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,GAAG,gBAAgB,KAAK,IAAI,CAAC;IACrE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3B;AAsBD,eAAO,MAAM,gBAA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AAG,IAAI,CAAC;CAC/B;AAsBD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;CA4V3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.usePositionStyle = exports.default = void 0;
9
9
  var _react = _interopRequireWildcard(require("react"));
10
10
  var _getPositionStyle = require("./get-position-style");
11
+ var _getSizingStyle = require("./get-sizing-style");
11
12
  var _checkPosition = require("./check-position");
12
13
  var _checkBorder = require("./check-border");
13
14
  var _checkElementSize = require("./check-element-size");
@@ -17,6 +18,11 @@ var _utils = require("../../utils");
17
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
18
19
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
19
20
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
22
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
23
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
24
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
25
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
20
26
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
21
27
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
22
28
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -57,6 +63,7 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
57
63
  parentElRef = _ref.parentElRef,
58
64
  popupElRef = _ref.popupElRef,
59
65
  scrollElRef = _ref.scrollElRef,
66
+ boundary = _ref.boundary,
60
67
  updateKey = _ref.updateKey,
61
68
  adjust = _ref.adjust,
62
69
  offset = _ref.offset,
@@ -352,9 +359,7 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
352
359
  var _ref2 = config || {},
353
360
  position = _ref2.position,
354
361
  absolute = _ref2.absolute;
355
- if (!position || !show || !parentElRef.current) return {
356
- newStyle: style
357
- };
362
+ if (!position || !show || !parentElRef.current) return style;
358
363
  context.parentRect = parentElRef.current.getBoundingClientRect();
359
364
  var realPosition = position;
360
365
  if (adjust) {
@@ -381,13 +386,17 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
381
386
  } else if (realPosition.indexOf('bottom') === 0) {
382
387
  newStyle.transformOrigin = 'center top';
383
388
  }
384
- return {
385
- newStyle: newStyle
386
- };
389
+ if (boundary && show && popupElRef.current) {
390
+ var sizingStyle = (0, _getSizingStyle.getSizingStyle)(realPosition, {
391
+ boundary: boundary,
392
+ parentRect: context.parentRect
393
+ });
394
+ return _objectSpread(_objectSpread({}, newStyle), sizingStyle);
395
+ }
396
+ return newStyle;
387
397
  };
388
398
  var updateStyle = (0, _usePersistFn.default)(function () {
389
- var _getStyle = getStyle(),
390
- newStyle = _getStyle.newStyle;
399
+ var newStyle = getStyle();
391
400
  if (newStyle && !(0, _shallowEqual.default)(style, newStyle)) {
392
401
  setStyle(newStyle);
393
402
  }
@@ -5,7 +5,7 @@ declare const useInputFormat: (props: InputFormatProps) => {
5
5
  onBlur: (e: React.FocusEvent<HTMLInputElement>) => void;
6
6
  onFocus: (e: React.FocusEvent<HTMLInputElement>) => void;
7
7
  value: string | undefined;
8
- type: "search" | (string & {}) | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" | "hidden" | "checkbox" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "radio" | "text" | "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<HTMLInputElement, Element>) => void;
8
8
  onFocus: (e: React.FocusEvent<HTMLInputElement, Element>) => void;
9
9
  value: string | undefined;
10
- type: "search" | (string & {}) | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" | "hidden" | "checkbox" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "radio" | "text" | "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
@@ -0,0 +1,10 @@
1
+ interface Options {
2
+ parentRect: DOMRect;
3
+ boundary: HTMLElement;
4
+ }
5
+ export declare const getSizingStyle: (position: string, { boundary, parentRect }: Options) => {
6
+ maxHeight: number | undefined;
7
+ overflowY: "auto";
8
+ };
9
+ export {};
10
+ //# sourceMappingURL=get-sizing-style.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-sizing-style.d.ts","sourceRoot":"","sources":["get-sizing-style.ts"],"names":[],"mappings":"AAAA,UAAU,OAAO;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,WAAW,CAAC;CACvB;AAID,eAAO,MAAO,cAAc,aAAc,MAAM,4BAAyB,OAAO;;;CAU/E,CAAA"}
@@ -0,0 +1,17 @@
1
+ // 第一阶段:支持上下边界的高度限制
2
+ // TODO 后续支持左右边界的宽度限制
3
+ export var getSizingStyle = function getSizingStyle(position, _ref) {
4
+ var boundary = _ref.boundary,
5
+ parentRect = _ref.parentRect;
6
+ var boundaryRect = boundary.getBoundingClientRect();
7
+ var maxHeight;
8
+ if (position.endsWith('-top')) {
9
+ maxHeight = boundaryRect.bottom - parentRect.top;
10
+ } else if (position.endsWith('-bottom')) {
11
+ maxHeight = parentRect.bottom - boundaryRect.top;
12
+ }
13
+ return {
14
+ maxHeight: maxHeight,
15
+ overflowY: 'auto'
16
+ };
17
+ };
@@ -18,6 +18,7 @@ export interface PositionStyleConfig {
18
18
  onAdjust?: (position: HorizontalPosition | VerticalPosition) => void;
19
19
  checkPosition?: boolean;
20
20
  offset?: [number, number];
21
+ boundary?: HTMLElement | null;
21
22
  }
22
23
  export declare const usePositionStyle: (config: PositionStyleConfig) => {
23
24
  style: React.CSSProperties;
@@ -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,CAAC;IAC5B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ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AAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,GAAG,gBAAgB,KAAK,IAAI,CAAC;IACrE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CAC/B;AAsBD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;CA4V3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -1,4 +1,10 @@
1
1
  "use client";
2
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
7
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
2
8
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
9
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
10
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
@@ -7,6 +13,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
7
13
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
14
  import React, { useEffect, useLayoutEffect, useState } from 'react';
9
15
  import { getPositionStyle } from "./get-position-style";
16
+ import { getSizingStyle } from "./get-sizing-style";
10
17
  import { useCheckElementPosition } from "./check-position";
11
18
  import { useCheckElementBorderWidth } from "./check-border";
12
19
  import { useCheckElementSize } from "./check-element-size";
@@ -48,6 +55,7 @@ export var usePositionStyle = function usePositionStyle(config) {
48
55
  parentElRef = _ref.parentElRef,
49
56
  popupElRef = _ref.popupElRef,
50
57
  scrollElRef = _ref.scrollElRef,
58
+ boundary = _ref.boundary,
51
59
  updateKey = _ref.updateKey,
52
60
  adjust = _ref.adjust,
53
61
  offset = _ref.offset,
@@ -343,9 +351,7 @@ export var usePositionStyle = function usePositionStyle(config) {
343
351
  var _ref2 = config || {},
344
352
  position = _ref2.position,
345
353
  absolute = _ref2.absolute;
346
- if (!position || !show || !parentElRef.current) return {
347
- newStyle: style
348
- };
354
+ if (!position || !show || !parentElRef.current) return style;
349
355
  context.parentRect = parentElRef.current.getBoundingClientRect();
350
356
  var realPosition = position;
351
357
  if (adjust) {
@@ -372,13 +378,17 @@ export var usePositionStyle = function usePositionStyle(config) {
372
378
  } else if (realPosition.indexOf('bottom') === 0) {
373
379
  newStyle.transformOrigin = 'center top';
374
380
  }
375
- return {
376
- newStyle: newStyle
377
- };
381
+ if (boundary && show && popupElRef.current) {
382
+ var sizingStyle = getSizingStyle(realPosition, {
383
+ boundary: boundary,
384
+ parentRect: context.parentRect
385
+ });
386
+ return _objectSpread(_objectSpread({}, newStyle), sizingStyle);
387
+ }
388
+ return newStyle;
378
389
  };
379
390
  var updateStyle = usePersistFn(function () {
380
- var _getStyle = getStyle(),
381
- newStyle = _getStyle.newStyle;
391
+ var newStyle = getStyle();
382
392
  if (newStyle && !shallowEqual(style, newStyle)) {
383
393
  setStyle(newStyle);
384
394
  }
@@ -5,7 +5,7 @@ declare const useInputFormat: (props: InputFormatProps) => {
5
5
  onBlur: (e: React.FocusEvent<HTMLInputElement>) => void;
6
6
  onFocus: (e: React.FocusEvent<HTMLInputElement>) => void;
7
7
  value: string | undefined;
8
- type: "search" | (string & {}) | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" | "hidden" | "checkbox" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "radio" | "text" | "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<HTMLInputElement, Element>) => void;
8
8
  onFocus: (e: React.FocusEvent<HTMLInputElement, Element>) => void;
9
9
  value: string | undefined;
10
- type: "search" | (string & {}) | "color" | "button" | "time" | "reset" | "submit" | "email" | "url" | "range" | "tel" | "hidden" | "checkbox" | "date" | "datetime-local" | "file" | "image" | "month" | "password" | "radio" | "text" | "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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.8.6-beta.2",
3
+ "version": "3.8.6-beta.4",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",