@sheinx/hooks 3.8.6-beta.5 → 3.8.6-beta.6
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/get-sizing-style.js +1 -1
- package/cjs/common/use-position-style/index.d.ts +1 -0
- package/cjs/common/use-position-style/index.d.ts.map +1 -1
- package/cjs/common/use-position-style/index.js +24 -16
- 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/esm/common/use-position-style/get-sizing-style.js +1 -1
- package/esm/common/use-position-style/index.d.ts +1 -0
- package/esm/common/use-position-style/index.d.ts.map +1 -1
- package/esm/common/use-position-style/index.js +24 -17
- 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/package.json +1 -1
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.getSizingStyle = void 0;
|
7
|
-
//
|
7
|
+
// 第一阶段:支持上下边界的高度限制,为vertical模式的Menu实现的
|
8
8
|
// TODO 后续支持左右边界的宽度限制
|
9
9
|
var getSizingStyle = exports.getSizingStyle = function getSizingStyle(position, _ref) {
|
10
10
|
var boundary = _ref.boundary,
|
@@ -19,6 +19,7 @@ export interface PositionStyleConfig {
|
|
19
19
|
checkPosition?: boolean;
|
20
20
|
offset?: [number, number];
|
21
21
|
boundary?: () => HTMLElement | null;
|
22
|
+
setSizingStyle?: (v?: React.CSSProperties) => void;
|
22
23
|
}
|
23
24
|
export declare const usePositionStyle: (config: PositionStyleConfig) => {
|
24
25
|
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;AAWpE,MAAM,MAAM,kBAAkB,GAC1B,aAAa,GACb,UAAU,GACV,cA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B,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;IAErE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IACpC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;CACpD;AAsBD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;CA+V3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
@@ -18,11 +18,6 @@ var _utils = require("../../utils");
|
|
18
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
19
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); }
|
20
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); }
|
26
21
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
27
22
|
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."); }
|
28
23
|
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); }
|
@@ -67,12 +62,15 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
67
62
|
updateKey = _ref.updateKey,
|
68
63
|
adjust = _ref.adjust,
|
69
64
|
offset = _ref.offset,
|
70
|
-
checkPosition = _ref.checkPosition
|
65
|
+
checkPosition = _ref.checkPosition,
|
66
|
+
setSizingStyle = _ref.setSizingStyle;
|
71
67
|
// 初次渲染无样式的时候, 隐藏展示
|
72
68
|
var _useState = (0, _react.useState)(hideStyle),
|
73
69
|
_useState2 = _slicedToArray(_useState, 2),
|
74
70
|
style = _useState2[0],
|
75
71
|
setStyle = _useState2[1];
|
72
|
+
// const [sizingStyle, setSizingStyle] = useState<React.CSSProperties>();
|
73
|
+
|
76
74
|
var _React$useRef = _react.default.useRef({
|
77
75
|
containerRect: {
|
78
76
|
left: 0,
|
@@ -241,7 +239,7 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
241
239
|
if (verticalPosition.includes(targetPosition)) {
|
242
240
|
var _targetPosition$split = targetPosition.split('-'),
|
243
241
|
_targetPosition$split2 = _slicedToArray(_targetPosition$split, 2),
|
244
|
-
|
242
|
+
_v = _targetPosition$split2[0],
|
245
243
|
h = _targetPosition$split2[1];
|
246
244
|
var overRight = 0;
|
247
245
|
var overLeft = 0;
|
@@ -279,7 +277,7 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
279
277
|
style.left += overLeft;
|
280
278
|
}
|
281
279
|
}
|
282
|
-
if (
|
280
|
+
if (_v === 'bottom') {
|
283
281
|
style.top = rect.bottom - containerRect.top + containerScroll.top + popupGap;
|
284
282
|
} else {
|
285
283
|
style.top = rect.top - containerRect.top + containerScroll.top - popupGap;
|
@@ -289,11 +287,11 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
289
287
|
var _targetPosition$split3 = targetPosition.split('-'),
|
290
288
|
_targetPosition$split4 = _slicedToArray(_targetPosition$split3, 2),
|
291
289
|
_h = _targetPosition$split4[0],
|
292
|
-
|
293
|
-
if (
|
290
|
+
_v2 = _targetPosition$split4[1];
|
291
|
+
if (_v2 === 'top') {
|
294
292
|
style.top = rect.top - containerRect.top + containerScroll.top - (offset ? offset[1] : 0);
|
295
293
|
setTransform(style, 'translateX(0%)');
|
296
|
-
} else if (
|
294
|
+
} else if (_v2 === 'bottom') {
|
297
295
|
style.top = rect.bottom - containerRect.top + containerScroll.top + (offset ? offset[1] : 0);
|
298
296
|
setTransform(style, 'translateY(-100%)');
|
299
297
|
} else {
|
@@ -359,7 +357,9 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
359
357
|
var _ref2 = config || {},
|
360
358
|
position = _ref2.position,
|
361
359
|
absolute = _ref2.absolute;
|
362
|
-
if (!position || !show || !parentElRef.current) return
|
360
|
+
if (!position || !show || !parentElRef.current) return {
|
361
|
+
newStyle: style
|
362
|
+
};
|
363
363
|
context.parentRect = parentElRef.current.getBoundingClientRect();
|
364
364
|
var realPosition = position;
|
365
365
|
if (adjust) {
|
@@ -387,19 +387,27 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
387
387
|
newStyle.transformOrigin = 'center top';
|
388
388
|
}
|
389
389
|
if (boundary && show && popupElRef.current) {
|
390
|
-
var
|
390
|
+
var newSizingStyle = (0, _getSizingStyle.getSizingStyle)(realPosition, {
|
391
391
|
boundary: boundary,
|
392
392
|
parentRect: context.parentRect
|
393
393
|
});
|
394
|
-
return
|
394
|
+
return {
|
395
|
+
newStyle: newStyle,
|
396
|
+
newSizingStyle: newSizingStyle
|
397
|
+
};
|
395
398
|
}
|
396
|
-
return
|
399
|
+
return {
|
400
|
+
newStyle: newStyle
|
401
|
+
};
|
397
402
|
};
|
398
403
|
var updateStyle = (0, _usePersistFn.default)(function () {
|
399
|
-
var
|
404
|
+
var _getStyle = getStyle(),
|
405
|
+
newStyle = _getStyle.newStyle,
|
406
|
+
newSizingStyle = _getStyle.newSizingStyle;
|
400
407
|
if (newStyle && !(0, _shallowEqual.default)(style, newStyle)) {
|
401
408
|
setStyle(newStyle);
|
402
409
|
}
|
410
|
+
setSizingStyle === null || setSizingStyle === void 0 || setSizingStyle(newSizingStyle);
|
403
411
|
|
404
412
|
// 当父元素的滚动容器滚动时,判断是否需要更新弹出层位置,包括是否隐藏弹出层(通过hideStyle隐藏,不是show状态)
|
405
413
|
if (show) {
|
@@ -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" | "
|
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;
|
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" | "
|
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;
|
11
11
|
};
|
12
12
|
export default useNumberFormat;
|
13
13
|
//# sourceMappingURL=use-input-number.d.ts.map
|
@@ -19,6 +19,7 @@ export interface PositionStyleConfig {
|
|
19
19
|
checkPosition?: boolean;
|
20
20
|
offset?: [number, number];
|
21
21
|
boundary?: () => HTMLElement | null;
|
22
|
+
setSizingStyle?: (v?: React.CSSProperties) => void;
|
22
23
|
}
|
23
24
|
export declare const usePositionStyle: (config: PositionStyleConfig) => {
|
24
25
|
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;AAWpE,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,C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;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;IAErE,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,WAAW,GAAG,IAAI,CAAC;IACpC,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,aAAa,KAAK,IAAI,CAAC;CACpD;AAsBD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;CA+V3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
@@ -1,10 +1,4 @@
|
|
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); }
|
8
2
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
9
3
|
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."); }
|
10
4
|
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); }
|
@@ -59,12 +53,15 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
59
53
|
updateKey = _ref.updateKey,
|
60
54
|
adjust = _ref.adjust,
|
61
55
|
offset = _ref.offset,
|
62
|
-
checkPosition = _ref.checkPosition
|
56
|
+
checkPosition = _ref.checkPosition,
|
57
|
+
setSizingStyle = _ref.setSizingStyle;
|
63
58
|
// 初次渲染无样式的时候, 隐藏展示
|
64
59
|
var _useState = useState(hideStyle),
|
65
60
|
_useState2 = _slicedToArray(_useState, 2),
|
66
61
|
style = _useState2[0],
|
67
62
|
setStyle = _useState2[1];
|
63
|
+
// const [sizingStyle, setSizingStyle] = useState<React.CSSProperties>();
|
64
|
+
|
68
65
|
var _React$useRef = React.useRef({
|
69
66
|
containerRect: {
|
70
67
|
left: 0,
|
@@ -233,7 +230,7 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
233
230
|
if (verticalPosition.includes(targetPosition)) {
|
234
231
|
var _targetPosition$split = targetPosition.split('-'),
|
235
232
|
_targetPosition$split2 = _slicedToArray(_targetPosition$split, 2),
|
236
|
-
|
233
|
+
_v = _targetPosition$split2[0],
|
237
234
|
h = _targetPosition$split2[1];
|
238
235
|
var overRight = 0;
|
239
236
|
var overLeft = 0;
|
@@ -271,7 +268,7 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
271
268
|
style.left += overLeft;
|
272
269
|
}
|
273
270
|
}
|
274
|
-
if (
|
271
|
+
if (_v === 'bottom') {
|
275
272
|
style.top = rect.bottom - containerRect.top + containerScroll.top + popupGap;
|
276
273
|
} else {
|
277
274
|
style.top = rect.top - containerRect.top + containerScroll.top - popupGap;
|
@@ -281,11 +278,11 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
281
278
|
var _targetPosition$split3 = targetPosition.split('-'),
|
282
279
|
_targetPosition$split4 = _slicedToArray(_targetPosition$split3, 2),
|
283
280
|
_h = _targetPosition$split4[0],
|
284
|
-
|
285
|
-
if (
|
281
|
+
_v2 = _targetPosition$split4[1];
|
282
|
+
if (_v2 === 'top') {
|
286
283
|
style.top = rect.top - containerRect.top + containerScroll.top - (offset ? offset[1] : 0);
|
287
284
|
setTransform(style, 'translateX(0%)');
|
288
|
-
} else if (
|
285
|
+
} else if (_v2 === 'bottom') {
|
289
286
|
style.top = rect.bottom - containerRect.top + containerScroll.top + (offset ? offset[1] : 0);
|
290
287
|
setTransform(style, 'translateY(-100%)');
|
291
288
|
} else {
|
@@ -351,7 +348,9 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
351
348
|
var _ref2 = config || {},
|
352
349
|
position = _ref2.position,
|
353
350
|
absolute = _ref2.absolute;
|
354
|
-
if (!position || !show || !parentElRef.current) return
|
351
|
+
if (!position || !show || !parentElRef.current) return {
|
352
|
+
newStyle: style
|
353
|
+
};
|
355
354
|
context.parentRect = parentElRef.current.getBoundingClientRect();
|
356
355
|
var realPosition = position;
|
357
356
|
if (adjust) {
|
@@ -379,19 +378,27 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
379
378
|
newStyle.transformOrigin = 'center top';
|
380
379
|
}
|
381
380
|
if (boundary && show && popupElRef.current) {
|
382
|
-
var
|
381
|
+
var newSizingStyle = getSizingStyle(realPosition, {
|
383
382
|
boundary: boundary,
|
384
383
|
parentRect: context.parentRect
|
385
384
|
});
|
386
|
-
return
|
385
|
+
return {
|
386
|
+
newStyle: newStyle,
|
387
|
+
newSizingStyle: newSizingStyle
|
388
|
+
};
|
387
389
|
}
|
388
|
-
return
|
390
|
+
return {
|
391
|
+
newStyle: newStyle
|
392
|
+
};
|
389
393
|
};
|
390
394
|
var updateStyle = usePersistFn(function () {
|
391
|
-
var
|
395
|
+
var _getStyle = getStyle(),
|
396
|
+
newStyle = _getStyle.newStyle,
|
397
|
+
newSizingStyle = _getStyle.newSizingStyle;
|
392
398
|
if (newStyle && !shallowEqual(style, newStyle)) {
|
393
399
|
setStyle(newStyle);
|
394
400
|
}
|
401
|
+
setSizingStyle === null || setSizingStyle === void 0 || setSizingStyle(newSizingStyle);
|
395
402
|
|
396
403
|
// 当父元素的滚动容器滚动时,判断是否需要更新弹出层位置,包括是否隐藏弹出层(通过hideStyle隐藏,不是show状态)
|
397
404
|
if (show) {
|
@@ -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" | "
|
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;
|
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" | "
|
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;
|
11
11
|
};
|
12
12
|
export default useNumberFormat;
|
13
13
|
//# sourceMappingURL=use-input-number.d.ts.map
|