@sheinx/hooks 3.6.1-beta.5 → 3.6.1-beta.7
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-in-view/use-in-view.d.ts.map +1 -1
- package/cjs/common/use-in-view/use-in-view.js +2 -1
- package/cjs/common/use-position-style/check-position.d.ts +2 -0
- package/cjs/common/use-position-style/check-position.d.ts.map +1 -1
- package/cjs/common/use-position-style/check-position.js +7 -3
- package/cjs/common/use-position-style/index.d.ts +0 -1
- package/cjs/common/use-position-style/index.d.ts.map +1 -1
- package/cjs/common/use-position-style/index.js +7 -46
- 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/components/use-input/use-input-number.js +1 -1
- package/cjs/components/use-popup/use-popup.d.ts +0 -1
- package/cjs/components/use-popup/use-popup.d.ts.map +1 -1
- package/cjs/components/use-popup/use-popup.js +0 -2
- package/cjs/utils/dom/element.d.ts +1 -0
- package/cjs/utils/dom/element.d.ts.map +1 -1
- package/cjs/utils/dom/element.js +7 -8
- package/esm/common/use-in-view/use-in-view.d.ts.map +1 -1
- package/esm/common/use-in-view/use-in-view.js +2 -1
- package/esm/common/use-position-style/check-position.d.ts +2 -0
- package/esm/common/use-position-style/check-position.d.ts.map +1 -1
- package/esm/common/use-position-style/check-position.js +7 -3
- package/esm/common/use-position-style/index.d.ts +0 -1
- package/esm/common/use-position-style/index.d.ts.map +1 -1
- package/esm/common/use-position-style/index.js +7 -46
- 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/components/use-input/use-input-number.js +1 -1
- package/esm/components/use-popup/use-popup.d.ts +0 -1
- package/esm/components/use-popup/use-popup.d.ts.map +1 -1
- package/esm/components/use-popup/use-popup.js +0 -2
- package/esm/utils/dom/element.d.ts +1 -0
- package/esm/utils/dom/element.d.ts.map +1 -1
- package/esm/utils/dom/element.js +6 -8
- package/package.json +1 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-in-view.d.ts","sourceRoot":"","sources":["use-in-view.ts"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"use-in-view.d.ts","sourceRoot":"","sources":["use-in-view.ts"],"names":[],"mappings":";AAKA,UAAU,gBAAgB;IACxB,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,QAAA,MAAM,SAAS,oCAAoC,gBAAgB;;;;CA2ClE,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.default = void 0;
|
7
7
|
var _react = require("react");
|
8
|
+
var _dom = require("../../utils/dom");
|
8
9
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
9
10
|
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
11
|
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); }
|
@@ -43,7 +44,7 @@ var useInView = function useInView() {
|
|
43
44
|
}
|
44
45
|
}
|
45
46
|
}, {
|
46
|
-
root: options.root
|
47
|
+
root: options.root && (0, _dom.isScrollable)(options.root) ? options.root : null,
|
47
48
|
rootMargin: options.rootMargin || '0px',
|
48
49
|
threshold: options.threshold || 0
|
49
50
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"check-position.d.ts","sourceRoot":"","sources":["check-position.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"check-position.d.ts","sourceRoot":"","sources":["check-position.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,8BAA8B;IAEtC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,uBAAuB,eACtB,MAAM,SAAS,CAAC,WAAW,CAAC,YAC/B,8BAA8B,KACtC,QAAQ,GAAG,IAkFb,CAAC"}
|
@@ -34,15 +34,19 @@ var useCheckElementPosition = exports.useCheckElementPosition = function useChec
|
|
34
34
|
if (scrollContainerRect) {
|
35
35
|
newPosition = {
|
36
36
|
top: rect.top - scrollContainerRect.top,
|
37
|
-
left: rect.left - scrollContainerRect.left
|
37
|
+
left: rect.left - scrollContainerRect.left,
|
38
|
+
width: rect.width,
|
39
|
+
height: rect.height
|
38
40
|
};
|
39
41
|
} else {
|
40
42
|
newPosition = {
|
41
43
|
top: rect.top,
|
42
|
-
left: rect.left
|
44
|
+
left: rect.left,
|
45
|
+
width: rect.width,
|
46
|
+
height: rect.height
|
43
47
|
};
|
44
48
|
}
|
45
|
-
if (newPosition.top !== lastPosition.current.top || newPosition.left !== lastPosition.current.left) {
|
49
|
+
if (newPosition.top !== lastPosition.current.top || newPosition.left !== lastPosition.current.left || newPosition.width !== lastPosition.current.width || newPosition.height !== lastPosition.current.height) {
|
46
50
|
setPosition(newPosition);
|
47
51
|
lastPosition.current = newPosition;
|
48
52
|
}
|
@@ -19,7 +19,6 @@ export interface PositionStyleConfig {
|
|
19
19
|
}
|
20
20
|
export declare const usePositionStyle: (config: PositionStyleConfig) => {
|
21
21
|
style: React.CSSProperties;
|
22
|
-
arrayStyle: React.CSSProperties;
|
23
22
|
};
|
24
23
|
export default usePositionStyle;
|
25
24
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AASnD,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,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3B;AAOD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AASnD,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,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3B;AAOD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;CA4R3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
@@ -51,10 +51,6 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
51
51
|
_useState2 = _slicedToArray(_useState, 2),
|
52
52
|
style = _useState2[0],
|
53
53
|
setStyle = _useState2[1];
|
54
|
-
var _useState3 = (0, _react.useState)({}),
|
55
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
56
|
-
arrayStyle = _useState4[0],
|
57
|
-
setArrayStyle = _useState4[1];
|
58
54
|
var _React$useRef = _react.default.useRef({
|
59
55
|
containerRect: {
|
60
56
|
left: 0,
|
@@ -139,7 +135,6 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
139
135
|
position: 'absolute',
|
140
136
|
zIndex: zIndex
|
141
137
|
};
|
142
|
-
var arrayStyle = {};
|
143
138
|
if (fixedWidth) {
|
144
139
|
var widthKey = fixedWidth === 'min' ? 'minWidth' : 'width';
|
145
140
|
style[widthKey] = rect.width;
|
@@ -166,7 +161,6 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
166
161
|
if (h === 'left') {
|
167
162
|
style.left = rect.left - containerRect.left + containerScroll.left - (offset ? offset[0] : 0);
|
168
163
|
style.transform = '';
|
169
|
-
arrayStyle.left = "8px";
|
170
164
|
if (adjust) {
|
171
165
|
overRight = rect.left + context.popUpWidth - bodyRect.right + containerScrollBarWidth;
|
172
166
|
if (style.left < 0 && targetRect) {
|
@@ -177,7 +171,6 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
177
171
|
style.right = containerRect.right - rect.right + containerScrollBarWidth - containerScroll.left - (offset ? offset[0] : 0);
|
178
172
|
style.left = 'auto';
|
179
173
|
style.transform = '';
|
180
|
-
arrayStyle.right = "8px";
|
181
174
|
if (adjust) {
|
182
175
|
overLeft = bodyRect.left - (rect.right - context.popUpWidth);
|
183
176
|
if (style.right < 0 && targetRect) {
|
@@ -193,9 +186,6 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
193
186
|
overRight = rect.left + rect.width / 2 + context.popUpWidth / 2 - bodyRect.width + containerScrollBarWidth;
|
194
187
|
overLeft = bodyRect.left - (rect.left + rect.width / 2 - context.popUpWidth / 2);
|
195
188
|
}
|
196
|
-
if (targetRect) {
|
197
|
-
arrayStyle.left = "".concat(targetRect.width / 2 - 5.9, "px");
|
198
|
-
}
|
199
189
|
}
|
200
190
|
if (adjust) {
|
201
191
|
// 调节左右溢出
|
@@ -204,26 +194,16 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
204
194
|
style.left -= overRight;
|
205
195
|
// 扣除触发器距离页面右侧的距离,以保证从右侧弹出的窗口最右边对齐触发器最右边
|
206
196
|
style.left -= toRightDistance;
|
207
|
-
if (targetRect) {
|
208
|
-
arrayStyle.left = "".concat((targetRect === null || targetRect === void 0 ? void 0 : targetRect.width) - context.parentRect.width / 2 - 5.9, "px");
|
209
|
-
}
|
210
197
|
}
|
211
198
|
if (overLeft > 0) {
|
212
199
|
style.left += overLeft;
|
213
|
-
arrayStyle.left = "".concat(rect.width / 2 - 5.9, "px");
|
214
200
|
}
|
215
201
|
}
|
216
202
|
if (v === 'bottom') {
|
217
203
|
style.top = rect.bottom - containerRect.top + containerScroll.top + popupGap;
|
218
|
-
if (targetRect) {
|
219
|
-
arrayStyle.top = "".concat(0, "px");
|
220
|
-
}
|
221
204
|
} else {
|
222
205
|
style.top = rect.top - containerRect.top + containerScroll.top - popupGap;
|
223
206
|
style.transform += 'translateY(-100%)';
|
224
|
-
if (targetRect) {
|
225
|
-
arrayStyle.top = "".concat(targetRect.height - 5.9 - 4, "px");
|
226
|
-
}
|
227
207
|
}
|
228
208
|
} else if (horizontalPosition.includes(targetPosition)) {
|
229
209
|
var _targetPosition$split3 = targetPosition.split('-'),
|
@@ -233,35 +213,25 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
233
213
|
if (_v === 'top') {
|
234
214
|
style.top = rect.top - containerRect.top + containerScroll.top - (offset ? offset[1] : 0);
|
235
215
|
style.transform = '';
|
236
|
-
arrayStyle.top = "8px";
|
237
216
|
} else if (_v === 'bottom') {
|
238
217
|
style.top = rect.bottom - containerRect.top + containerScroll.top + (offset ? offset[1] : 0);
|
239
|
-
arrayStyle.bottom = "8px";
|
240
218
|
style.transform = 'translateY(-100%)';
|
241
219
|
} else {
|
242
220
|
// 居中对齐
|
243
221
|
style.top = rect.top - containerRect.top + containerScroll.top + rect.height / 2;
|
244
|
-
if (targetRect) {
|
245
|
-
arrayStyle.top = "".concat(targetRect.height / 2 - 5.9 / 2, "px");
|
246
|
-
}
|
247
222
|
style.transform = 'translateY(-50%)';
|
248
223
|
}
|
249
224
|
if (_h === 'right') {
|
250
225
|
style.left = rect.right - containerRect.left + containerScroll.left + popupGap;
|
251
|
-
arrayStyle.left = '0px';
|
252
|
-
arrayStyle.right = 'auto';
|
253
226
|
} else {
|
254
227
|
style.right = containerRect.right - rect.left;
|
255
|
-
arrayStyle.right = '0px';
|
256
|
-
arrayStyle.left = 'auto';
|
257
228
|
}
|
258
229
|
} else if (position === 'cover') {
|
259
230
|
style.top = rect.top - containerRect.top + containerScroll.top;
|
260
231
|
style.left = rect.left - containerRect.left + containerScroll.left;
|
261
232
|
}
|
262
233
|
return {
|
263
|
-
style: style
|
264
|
-
arrayStyle: arrayStyle
|
234
|
+
style: style
|
265
235
|
};
|
266
236
|
};
|
267
237
|
var getAbsoluteStyle = function getAbsoluteStyle(position) {
|
@@ -281,8 +251,7 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
281
251
|
}
|
282
252
|
}
|
283
253
|
var _getAbsolutePositionS = getAbsolutePositionStyle(rect, position),
|
284
|
-
style = _getAbsolutePositionS.style
|
285
|
-
arrayStyle = _getAbsolutePositionS.arrayStyle;
|
254
|
+
style = _getAbsolutePositionS.style;
|
286
255
|
var currentCSSZoom = (0, _utils.getCurrentCSSZoom)();
|
287
256
|
if (currentCSSZoom && currentCSSZoom !== 1) {
|
288
257
|
if (style.left && typeof style.left === 'number') {
|
@@ -299,13 +268,11 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
299
268
|
}
|
300
269
|
}
|
301
270
|
return {
|
302
|
-
style: style
|
303
|
-
arrayStyle: arrayStyle
|
271
|
+
style: style
|
304
272
|
};
|
305
273
|
};
|
306
274
|
var getStyle = function getStyle() {
|
307
275
|
var newStyle = {};
|
308
|
-
var newArrayStyle = {};
|
309
276
|
var _ref2 = config || {},
|
310
277
|
position = _ref2.position,
|
311
278
|
absolute = _ref2.absolute;
|
@@ -329,10 +296,8 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
329
296
|
});
|
330
297
|
} else {
|
331
298
|
var _ref3 = getAbsoluteStyle(realPosition),
|
332
|
-
nextStyle = _ref3.style
|
333
|
-
nextArrayStyle = _ref3.arrayStyle;
|
299
|
+
nextStyle = _ref3.style;
|
334
300
|
newStyle = nextStyle;
|
335
|
-
newArrayStyle = nextArrayStyle;
|
336
301
|
}
|
337
302
|
// for animation
|
338
303
|
if (realPosition.indexOf('top') === 0) {
|
@@ -341,17 +306,14 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
341
306
|
newStyle.transformOrigin = 'center top';
|
342
307
|
}
|
343
308
|
return {
|
344
|
-
newStyle: newStyle
|
345
|
-
newArrayStyle: newArrayStyle
|
309
|
+
newStyle: newStyle
|
346
310
|
};
|
347
311
|
};
|
348
312
|
var updateStyle = (0, _usePersistFn.default)(function () {
|
349
313
|
var _getStyle = getStyle(),
|
350
|
-
newStyle = _getStyle.newStyle
|
351
|
-
newArrayStyle = _getStyle.newArrayStyle;
|
314
|
+
newStyle = _getStyle.newStyle;
|
352
315
|
if (newStyle && !(0, _shallowEqual.default)(style, newStyle)) {
|
353
316
|
setStyle(newStyle);
|
354
|
-
setArrayStyle(newArrayStyle || {});
|
355
317
|
}
|
356
318
|
|
357
319
|
// 当父元素的滚动容器滚动时,判断是否需要更新弹出层位置,包括是否隐藏弹出层(通过hideStyle隐藏,不是show状态)
|
@@ -359,8 +321,7 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
359
321
|
});
|
360
322
|
(0, _react.useEffect)(updateStyle, [show, position, absolute, updateKey, fixedWidth, parentElNewPosition]);
|
361
323
|
return {
|
362
|
-
style: style
|
363
|
-
arrayStyle: arrayStyle
|
324
|
+
style: style
|
364
325
|
};
|
365
326
|
};
|
366
327
|
var _default = exports.default = usePositionStyle;
|
@@ -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" | (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<Element, Element>) => void;
|
8
8
|
onFocus: (e: React.FocusEvent<Element, 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
|
@@ -75,7 +75,7 @@ var useNumberFormat = function useNumberFormat(props) {
|
|
75
75
|
var onInnerChange = (0, _usePersistFn.default)(function (val) {
|
76
76
|
setInternalInputValue(getStringValue(val));
|
77
77
|
if (typeof val === 'string') {
|
78
|
-
if (val.endsWith('.')) return;
|
78
|
+
if (val.endsWith('.') || val.includes('.') && val.endsWith('0')) return;
|
79
79
|
var num = parseFloat(val);
|
80
80
|
if (val === '') {
|
81
81
|
// 如果允许空值,则返回 null,否则返回 undefined
|
@@ -5,7 +5,6 @@ declare const usePopup: (props: BasePopupProps) => {
|
|
5
5
|
position: PositionType;
|
6
6
|
targetRef: React.MutableRefObject<HTMLDivElement | null>;
|
7
7
|
popupRef: React.MutableRefObject<HTMLDivElement | null>;
|
8
|
-
arrowRef: React.MutableRefObject<HTMLSpanElement | null>;
|
9
8
|
getTargetProps: () => {
|
10
9
|
onMouseEnter: (e: {
|
11
10
|
target: EventTarget | null;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-popup.d.ts","sourceRoot":"","sources":["use-popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhE,QAAA,MAAM,QAAQ,UAAW,cAAc
|
1
|
+
{"version":3,"file":"use-popup.d.ts","sourceRoot":"","sources":["use-popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhE,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;;0BA6HK;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;0BAM9B;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;;;;;qBA5B7B;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;;;;;;;;;;;;;;;;;;;;;;;;;2BA6ElD,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;6BAGxC,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;;CAqBpE,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
@@ -37,7 +37,6 @@ var usePopup = function usePopup(props) {
|
|
37
37
|
removeChild = _useContext.removeChild;
|
38
38
|
var targetRef = (0, _react.useRef)(null);
|
39
39
|
var popupRef = (0, _react.useRef)(null);
|
40
|
-
var arrowRef = (0, _react.useRef)(null);
|
41
40
|
(0, _react.useEffect)(function () {
|
42
41
|
bindChild(popupRef);
|
43
42
|
return function () {
|
@@ -206,7 +205,6 @@ var usePopup = function usePopup(props) {
|
|
206
205
|
position: position,
|
207
206
|
targetRef: targetRef,
|
208
207
|
popupRef: popupRef,
|
209
|
-
arrowRef: arrowRef,
|
210
208
|
getTargetProps: getTargetProps,
|
211
209
|
openPop: openPop,
|
212
210
|
closePop: closePop,
|
@@ -12,6 +12,7 @@ export declare const addResizeObserver: (el: HTMLElement, handler: any, options?
|
|
12
12
|
timer?: number | undefined;
|
13
13
|
}) => () => void;
|
14
14
|
export declare function getParent(el: HTMLElement | null | Element, target?: string | HTMLElement): Element | null;
|
15
|
+
export declare function isScrollable(el: HTMLElement): boolean;
|
15
16
|
export declare function getClosestScrollContainer(element: HTMLElement | null): HTMLElement | null;
|
16
17
|
export declare function getClosestPositionedContainer(element: Element | HTMLElement | null, positions?: React.CSSProperties['position'][]): HTMLElement | null;
|
17
18
|
export declare function cssSupport(attr: keyof CSSStyleDeclaration, value: string): boolean;
|
@@ -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,
|
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,YAAY,CAAC,EAAE,EAAE,WAAW,WAW3C;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAqBzF;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
@@ -9,6 +9,7 @@ exports.getClosestPositionedContainer = getClosestPositionedContainer;
|
|
9
9
|
exports.getClosestScrollContainer = getClosestScrollContainer;
|
10
10
|
exports.getFieldId = void 0;
|
11
11
|
exports.getParent = getParent;
|
12
|
+
exports.isScrollable = isScrollable;
|
12
13
|
exports.parsePxToNumber = void 0;
|
13
14
|
exports.wrapSpan = wrapSpan;
|
14
15
|
var _react = _interopRequireDefault(require("react"));
|
@@ -128,19 +129,17 @@ function getParent(el, target) {
|
|
128
129
|
}
|
129
130
|
return null;
|
130
131
|
}
|
132
|
+
function isScrollable(el) {
|
133
|
+
var style = window.getComputedStyle(el);
|
134
|
+
var overflowX = style.overflowX;
|
135
|
+
var overflowY = style.overflowY;
|
136
|
+
return (overflowX === 'auto' || overflowX === 'scroll' || overflowY === 'auto' || overflowY === 'scroll') && (el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth);
|
137
|
+
}
|
131
138
|
function getClosestScrollContainer(element) {
|
132
139
|
if (!element) {
|
133
140
|
return null;
|
134
141
|
}
|
135
142
|
|
136
|
-
// 检查元素是否可滚动
|
137
|
-
var isScrollable = function isScrollable(el) {
|
138
|
-
var style = window.getComputedStyle(el);
|
139
|
-
var overflowX = style.overflowX;
|
140
|
-
var overflowY = style.overflowY;
|
141
|
-
return (overflowX === 'auto' || overflowX === 'scroll' || overflowY === 'auto' || overflowY === 'scroll') && (el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth);
|
142
|
-
};
|
143
|
-
|
144
143
|
// 如果元素本身是可滚动的,直接返回
|
145
144
|
if (isScrollable(element)) {
|
146
145
|
return element;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-in-view.d.ts","sourceRoot":"","sources":["use-in-view.ts"],"names":[],"mappings":";
|
1
|
+
{"version":3,"file":"use-in-view.d.ts","sourceRoot":"","sources":["use-in-view.ts"],"names":[],"mappings":";AAKA,UAAU,gBAAgB;IACxB,IAAI,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC9B,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB;AAED,QAAA,MAAM,SAAS,oCAAoC,gBAAgB;;;;CA2ClE,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
@@ -5,6 +5,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
5
5
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
6
6
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
7
7
|
import { useEffect, useRef, useState } from 'react';
|
8
|
+
import { isScrollable } from "../../utils/dom";
|
8
9
|
var useInView = function useInView() {
|
9
10
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
10
11
|
var elementRef = useRef(null);
|
@@ -37,7 +38,7 @@ var useInView = function useInView() {
|
|
37
38
|
}
|
38
39
|
}
|
39
40
|
}, {
|
40
|
-
root: options.root
|
41
|
+
root: options.root && isScrollable(options.root) ? options.root : null,
|
41
42
|
rootMargin: options.rootMargin || '0px',
|
42
43
|
threshold: options.threshold || 0
|
43
44
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"check-position.d.ts","sourceRoot":"","sources":["check-position.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;
|
1
|
+
{"version":3,"file":"check-position.d.ts","sourceRoot":"","sources":["check-position.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,QAAQ;IACvB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,UAAU,8BAA8B;IAEtC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,eAAe,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;CACtC;AAED,eAAO,MAAM,uBAAuB,eACtB,MAAM,SAAS,CAAC,WAAW,CAAC,YAC/B,8BAA8B,KACtC,QAAQ,GAAG,IAkFb,CAAC"}
|
@@ -28,15 +28,19 @@ export var useCheckElementPosition = function useCheckElementPosition(elementRef
|
|
28
28
|
if (scrollContainerRect) {
|
29
29
|
newPosition = {
|
30
30
|
top: rect.top - scrollContainerRect.top,
|
31
|
-
left: rect.left - scrollContainerRect.left
|
31
|
+
left: rect.left - scrollContainerRect.left,
|
32
|
+
width: rect.width,
|
33
|
+
height: rect.height
|
32
34
|
};
|
33
35
|
} else {
|
34
36
|
newPosition = {
|
35
37
|
top: rect.top,
|
36
|
-
left: rect.left
|
38
|
+
left: rect.left,
|
39
|
+
width: rect.width,
|
40
|
+
height: rect.height
|
37
41
|
};
|
38
42
|
}
|
39
|
-
if (newPosition.top !== lastPosition.current.top || newPosition.left !== lastPosition.current.left) {
|
43
|
+
if (newPosition.top !== lastPosition.current.top || newPosition.left !== lastPosition.current.left || newPosition.width !== lastPosition.current.width || newPosition.height !== lastPosition.current.height) {
|
40
44
|
setPosition(newPosition);
|
41
45
|
lastPosition.current = newPosition;
|
42
46
|
}
|
@@ -19,7 +19,6 @@ export interface PositionStyleConfig {
|
|
19
19
|
}
|
20
20
|
export declare const usePositionStyle: (config: PositionStyleConfig) => {
|
21
21
|
style: React.CSSProperties;
|
22
|
-
arrayStyle: React.CSSProperties;
|
23
22
|
};
|
24
23
|
export default usePositionStyle;
|
25
24
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AASnD,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,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3B;AAOD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;AASnD,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,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC3B;AAOD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;CA4R3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
@@ -42,10 +42,6 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
42
42
|
_useState2 = _slicedToArray(_useState, 2),
|
43
43
|
style = _useState2[0],
|
44
44
|
setStyle = _useState2[1];
|
45
|
-
var _useState3 = useState({}),
|
46
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
47
|
-
arrayStyle = _useState4[0],
|
48
|
-
setArrayStyle = _useState4[1];
|
49
45
|
var _React$useRef = React.useRef({
|
50
46
|
containerRect: {
|
51
47
|
left: 0,
|
@@ -130,7 +126,6 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
130
126
|
position: 'absolute',
|
131
127
|
zIndex: zIndex
|
132
128
|
};
|
133
|
-
var arrayStyle = {};
|
134
129
|
if (fixedWidth) {
|
135
130
|
var widthKey = fixedWidth === 'min' ? 'minWidth' : 'width';
|
136
131
|
style[widthKey] = rect.width;
|
@@ -157,7 +152,6 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
157
152
|
if (h === 'left') {
|
158
153
|
style.left = rect.left - containerRect.left + containerScroll.left - (offset ? offset[0] : 0);
|
159
154
|
style.transform = '';
|
160
|
-
arrayStyle.left = "8px";
|
161
155
|
if (adjust) {
|
162
156
|
overRight = rect.left + context.popUpWidth - bodyRect.right + containerScrollBarWidth;
|
163
157
|
if (style.left < 0 && targetRect) {
|
@@ -168,7 +162,6 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
168
162
|
style.right = containerRect.right - rect.right + containerScrollBarWidth - containerScroll.left - (offset ? offset[0] : 0);
|
169
163
|
style.left = 'auto';
|
170
164
|
style.transform = '';
|
171
|
-
arrayStyle.right = "8px";
|
172
165
|
if (adjust) {
|
173
166
|
overLeft = bodyRect.left - (rect.right - context.popUpWidth);
|
174
167
|
if (style.right < 0 && targetRect) {
|
@@ -184,9 +177,6 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
184
177
|
overRight = rect.left + rect.width / 2 + context.popUpWidth / 2 - bodyRect.width + containerScrollBarWidth;
|
185
178
|
overLeft = bodyRect.left - (rect.left + rect.width / 2 - context.popUpWidth / 2);
|
186
179
|
}
|
187
|
-
if (targetRect) {
|
188
|
-
arrayStyle.left = "".concat(targetRect.width / 2 - 5.9, "px");
|
189
|
-
}
|
190
180
|
}
|
191
181
|
if (adjust) {
|
192
182
|
// 调节左右溢出
|
@@ -195,26 +185,16 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
195
185
|
style.left -= overRight;
|
196
186
|
// 扣除触发器距离页面右侧的距离,以保证从右侧弹出的窗口最右边对齐触发器最右边
|
197
187
|
style.left -= toRightDistance;
|
198
|
-
if (targetRect) {
|
199
|
-
arrayStyle.left = "".concat((targetRect === null || targetRect === void 0 ? void 0 : targetRect.width) - context.parentRect.width / 2 - 5.9, "px");
|
200
|
-
}
|
201
188
|
}
|
202
189
|
if (overLeft > 0) {
|
203
190
|
style.left += overLeft;
|
204
|
-
arrayStyle.left = "".concat(rect.width / 2 - 5.9, "px");
|
205
191
|
}
|
206
192
|
}
|
207
193
|
if (v === 'bottom') {
|
208
194
|
style.top = rect.bottom - containerRect.top + containerScroll.top + popupGap;
|
209
|
-
if (targetRect) {
|
210
|
-
arrayStyle.top = "".concat(0, "px");
|
211
|
-
}
|
212
195
|
} else {
|
213
196
|
style.top = rect.top - containerRect.top + containerScroll.top - popupGap;
|
214
197
|
style.transform += 'translateY(-100%)';
|
215
|
-
if (targetRect) {
|
216
|
-
arrayStyle.top = "".concat(targetRect.height - 5.9 - 4, "px");
|
217
|
-
}
|
218
198
|
}
|
219
199
|
} else if (horizontalPosition.includes(targetPosition)) {
|
220
200
|
var _targetPosition$split3 = targetPosition.split('-'),
|
@@ -224,35 +204,25 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
224
204
|
if (_v === 'top') {
|
225
205
|
style.top = rect.top - containerRect.top + containerScroll.top - (offset ? offset[1] : 0);
|
226
206
|
style.transform = '';
|
227
|
-
arrayStyle.top = "8px";
|
228
207
|
} else if (_v === 'bottom') {
|
229
208
|
style.top = rect.bottom - containerRect.top + containerScroll.top + (offset ? offset[1] : 0);
|
230
|
-
arrayStyle.bottom = "8px";
|
231
209
|
style.transform = 'translateY(-100%)';
|
232
210
|
} else {
|
233
211
|
// 居中对齐
|
234
212
|
style.top = rect.top - containerRect.top + containerScroll.top + rect.height / 2;
|
235
|
-
if (targetRect) {
|
236
|
-
arrayStyle.top = "".concat(targetRect.height / 2 - 5.9 / 2, "px");
|
237
|
-
}
|
238
213
|
style.transform = 'translateY(-50%)';
|
239
214
|
}
|
240
215
|
if (_h === 'right') {
|
241
216
|
style.left = rect.right - containerRect.left + containerScroll.left + popupGap;
|
242
|
-
arrayStyle.left = '0px';
|
243
|
-
arrayStyle.right = 'auto';
|
244
217
|
} else {
|
245
218
|
style.right = containerRect.right - rect.left;
|
246
|
-
arrayStyle.right = '0px';
|
247
|
-
arrayStyle.left = 'auto';
|
248
219
|
}
|
249
220
|
} else if (position === 'cover') {
|
250
221
|
style.top = rect.top - containerRect.top + containerScroll.top;
|
251
222
|
style.left = rect.left - containerRect.left + containerScroll.left;
|
252
223
|
}
|
253
224
|
return {
|
254
|
-
style: style
|
255
|
-
arrayStyle: arrayStyle
|
225
|
+
style: style
|
256
226
|
};
|
257
227
|
};
|
258
228
|
var getAbsoluteStyle = function getAbsoluteStyle(position) {
|
@@ -272,8 +242,7 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
272
242
|
}
|
273
243
|
}
|
274
244
|
var _getAbsolutePositionS = getAbsolutePositionStyle(rect, position),
|
275
|
-
style = _getAbsolutePositionS.style
|
276
|
-
arrayStyle = _getAbsolutePositionS.arrayStyle;
|
245
|
+
style = _getAbsolutePositionS.style;
|
277
246
|
var currentCSSZoom = getCurrentCSSZoom();
|
278
247
|
if (currentCSSZoom && currentCSSZoom !== 1) {
|
279
248
|
if (style.left && typeof style.left === 'number') {
|
@@ -290,13 +259,11 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
290
259
|
}
|
291
260
|
}
|
292
261
|
return {
|
293
|
-
style: style
|
294
|
-
arrayStyle: arrayStyle
|
262
|
+
style: style
|
295
263
|
};
|
296
264
|
};
|
297
265
|
var getStyle = function getStyle() {
|
298
266
|
var newStyle = {};
|
299
|
-
var newArrayStyle = {};
|
300
267
|
var _ref2 = config || {},
|
301
268
|
position = _ref2.position,
|
302
269
|
absolute = _ref2.absolute;
|
@@ -320,10 +287,8 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
320
287
|
});
|
321
288
|
} else {
|
322
289
|
var _ref3 = getAbsoluteStyle(realPosition),
|
323
|
-
nextStyle = _ref3.style
|
324
|
-
nextArrayStyle = _ref3.arrayStyle;
|
290
|
+
nextStyle = _ref3.style;
|
325
291
|
newStyle = nextStyle;
|
326
|
-
newArrayStyle = nextArrayStyle;
|
327
292
|
}
|
328
293
|
// for animation
|
329
294
|
if (realPosition.indexOf('top') === 0) {
|
@@ -332,17 +297,14 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
332
297
|
newStyle.transformOrigin = 'center top';
|
333
298
|
}
|
334
299
|
return {
|
335
|
-
newStyle: newStyle
|
336
|
-
newArrayStyle: newArrayStyle
|
300
|
+
newStyle: newStyle
|
337
301
|
};
|
338
302
|
};
|
339
303
|
var updateStyle = usePersistFn(function () {
|
340
304
|
var _getStyle = getStyle(),
|
341
|
-
newStyle = _getStyle.newStyle
|
342
|
-
newArrayStyle = _getStyle.newArrayStyle;
|
305
|
+
newStyle = _getStyle.newStyle;
|
343
306
|
if (newStyle && !shallowEqual(style, newStyle)) {
|
344
307
|
setStyle(newStyle);
|
345
|
-
setArrayStyle(newArrayStyle || {});
|
346
308
|
}
|
347
309
|
|
348
310
|
// 当父元素的滚动容器滚动时,判断是否需要更新弹出层位置,包括是否隐藏弹出层(通过hideStyle隐藏,不是show状态)
|
@@ -350,8 +312,7 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
350
312
|
});
|
351
313
|
useEffect(updateStyle, [show, position, absolute, updateKey, fixedWidth, parentElNewPosition]);
|
352
314
|
return {
|
353
|
-
style: style
|
354
|
-
arrayStyle: arrayStyle
|
315
|
+
style: style
|
355
316
|
};
|
356
317
|
};
|
357
318
|
export default usePositionStyle;
|
@@ -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" | (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<Element, Element>) => void;
|
8
8
|
onFocus: (e: React.FocusEvent<Element, 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
|
@@ -66,7 +66,7 @@ var useNumberFormat = function useNumberFormat(props) {
|
|
66
66
|
var onInnerChange = usePersistFn(function (val) {
|
67
67
|
setInternalInputValue(getStringValue(val));
|
68
68
|
if (typeof val === 'string') {
|
69
|
-
if (val.endsWith('.')) return;
|
69
|
+
if (val.endsWith('.') || val.includes('.') && val.endsWith('0')) return;
|
70
70
|
var num = parseFloat(val);
|
71
71
|
if (val === '') {
|
72
72
|
// 如果允许空值,则返回 null,否则返回 undefined
|
@@ -5,7 +5,6 @@ declare const usePopup: (props: BasePopupProps) => {
|
|
5
5
|
position: PositionType;
|
6
6
|
targetRef: React.MutableRefObject<HTMLDivElement | null>;
|
7
7
|
popupRef: React.MutableRefObject<HTMLDivElement | null>;
|
8
|
-
arrowRef: React.MutableRefObject<HTMLSpanElement | null>;
|
9
8
|
getTargetProps: () => {
|
10
9
|
onMouseEnter: (e: {
|
11
10
|
target: EventTarget | null;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-popup.d.ts","sourceRoot":"","sources":["use-popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhE,QAAA,MAAM,QAAQ,UAAW,cAAc
|
1
|
+
{"version":3,"file":"use-popup.d.ts","sourceRoot":"","sources":["use-popup.ts"],"names":[],"mappings":"AAAA,OAAO,KAA2D,MAAM,OAAO,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAOhE,QAAA,MAAM,QAAQ,UAAW,cAAc;;;;;;0BA6HK;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;0BAM9B;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;;;;;qBA5B7B;YAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAA;SAAE;;;;;;;;;;;;;;;;;;;;;;;;;2BA6ElD,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;6BAGxC,MAAM,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC;;CAqBpE,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
@@ -30,7 +30,6 @@ var usePopup = function usePopup(props) {
|
|
30
30
|
removeChild = _useContext.removeChild;
|
31
31
|
var targetRef = useRef(null);
|
32
32
|
var popupRef = useRef(null);
|
33
|
-
var arrowRef = useRef(null);
|
34
33
|
useEffect(function () {
|
35
34
|
bindChild(popupRef);
|
36
35
|
return function () {
|
@@ -199,7 +198,6 @@ var usePopup = function usePopup(props) {
|
|
199
198
|
position: position,
|
200
199
|
targetRef: targetRef,
|
201
200
|
popupRef: popupRef,
|
202
|
-
arrowRef: arrowRef,
|
203
201
|
getTargetProps: getTargetProps,
|
204
202
|
openPop: openPop,
|
205
203
|
closePop: closePop,
|
@@ -12,6 +12,7 @@ export declare const addResizeObserver: (el: HTMLElement, handler: any, options?
|
|
12
12
|
timer?: number | undefined;
|
13
13
|
}) => () => void;
|
14
14
|
export declare function getParent(el: HTMLElement | null | Element, target?: string | HTMLElement): Element | null;
|
15
|
+
export declare function isScrollable(el: HTMLElement): boolean;
|
15
16
|
export declare function getClosestScrollContainer(element: HTMLElement | null): HTMLElement | null;
|
16
17
|
export declare function getClosestPositionedContainer(element: Element | HTMLElement | null, positions?: React.CSSProperties['position'][]): HTMLElement | null;
|
17
18
|
export declare function cssSupport(attr: keyof CSSStyleDeclaration, value: string): boolean;
|
@@ -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,
|
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,YAAY,CAAC,EAAE,EAAE,WAAW,WAW3C;AAED,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,GAAG,WAAW,GAAG,IAAI,CAqBzF;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
@@ -115,19 +115,17 @@ export function getParent(el, target) {
|
|
115
115
|
}
|
116
116
|
return null;
|
117
117
|
}
|
118
|
+
export function isScrollable(el) {
|
119
|
+
var style = window.getComputedStyle(el);
|
120
|
+
var overflowX = style.overflowX;
|
121
|
+
var overflowY = style.overflowY;
|
122
|
+
return (overflowX === 'auto' || overflowX === 'scroll' || overflowY === 'auto' || overflowY === 'scroll') && (el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth);
|
123
|
+
}
|
118
124
|
export function getClosestScrollContainer(element) {
|
119
125
|
if (!element) {
|
120
126
|
return null;
|
121
127
|
}
|
122
128
|
|
123
|
-
// 检查元素是否可滚动
|
124
|
-
var isScrollable = function isScrollable(el) {
|
125
|
-
var style = window.getComputedStyle(el);
|
126
|
-
var overflowX = style.overflowX;
|
127
|
-
var overflowY = style.overflowY;
|
128
|
-
return (overflowX === 'auto' || overflowX === 'scroll' || overflowY === 'auto' || overflowY === 'scroll') && (el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth);
|
129
|
-
};
|
130
|
-
|
131
129
|
// 如果元素本身是可滚动的,直接返回
|
132
130
|
if (isScrollable(element)) {
|
133
131
|
return element;
|