@sheinx/hooks 3.4.0-beta.9 → 3.4.1
Sign up to get free protection for your applications and to get access to all the features.
- package/cjs/common/use-scrollbar-width/index.d.ts +3 -0
- package/cjs/common/use-scrollbar-width/index.d.ts.map +1 -0
- package/cjs/common/use-scrollbar-width/index.js +55 -0
- package/cjs/common/use-transform/use-transform.d.ts.map +1 -1
- package/cjs/common/use-transform/use-transform.js +5 -1
- package/cjs/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
- package/cjs/components/use-datepicker/use-datepicker-format.js +7 -0
- package/cjs/components/use-table/use-table-layout.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-layout.js +1 -0
- package/cjs/components/use-table/use-table-virtual.d.ts.map +1 -1
- package/cjs/components/use-table/use-table-virtual.js +2 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +12 -0
- package/esm/common/use-scrollbar-width/index.d.ts +3 -0
- package/esm/common/use-scrollbar-width/index.d.ts.map +1 -0
- package/esm/common/use-scrollbar-width/index.js +48 -0
- package/esm/common/use-transform/use-transform.d.ts.map +1 -1
- package/esm/common/use-transform/use-transform.js +5 -1
- package/esm/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
- package/esm/components/use-datepicker/use-datepicker-format.js +7 -0
- package/esm/components/use-table/use-table-layout.d.ts.map +1 -1
- package/esm/components/use-table/use-table-layout.js +1 -0
- package/esm/components/use-table/use-table-virtual.d.ts.map +1 -1
- package/esm/components/use-table/use-table-virtual.js +2 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/package.json +1 -1
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AA+BA,wBAAgB,iBAAiB,WAWhC;AAGD,eAAe,iBAAiB,CAAC"}
|
@@ -0,0 +1,55 @@
|
|
1
|
+
"use strict";
|
2
|
+
"use client";
|
3
|
+
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
5
|
+
value: true
|
6
|
+
});
|
7
|
+
exports.default = void 0;
|
8
|
+
exports.useScrollbarWidth = useScrollbarWidth;
|
9
|
+
var _react = require("react");
|
10
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
11
|
+
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."); }
|
12
|
+
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); }
|
13
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
14
|
+
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; } }
|
15
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
16
|
+
var scrollbarWidthCache;
|
17
|
+
function getScrollbarWidth() {
|
18
|
+
// 检查是否在服务器端运行
|
19
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
20
|
+
return 0;
|
21
|
+
}
|
22
|
+
|
23
|
+
// 如果我们的缓存变量已经存在,则直接返回该值
|
24
|
+
if (scrollbarWidthCache !== undefined) {
|
25
|
+
return scrollbarWidthCache;
|
26
|
+
}
|
27
|
+
|
28
|
+
// 客户端环境,计算滚动条宽度
|
29
|
+
var outer = document.createElement("div");
|
30
|
+
outer.style.visibility = "hidden";
|
31
|
+
outer.style.overflow = "scroll";
|
32
|
+
document.body.appendChild(outer);
|
33
|
+
var inner = document.createElement("div");
|
34
|
+
outer.appendChild(inner);
|
35
|
+
var scrollbarWidth = outer.offsetWidth - inner.offsetWidth;
|
36
|
+
if (outer.parentNode) outer.parentNode.removeChild(outer);
|
37
|
+
|
38
|
+
// 缓存并返回计算结果
|
39
|
+
scrollbarWidthCache = scrollbarWidth;
|
40
|
+
return scrollbarWidth;
|
41
|
+
}
|
42
|
+
function useScrollbarWidth() {
|
43
|
+
var _useState = (0, _react.useState)(0),
|
44
|
+
_useState2 = _slicedToArray(_useState, 2),
|
45
|
+
scrollbarWidth = _useState2[0],
|
46
|
+
setScrollbarWidth = _useState2[1];
|
47
|
+
(0, _react.useEffect)(function () {
|
48
|
+
// 只有在客户端时才计算滚动条宽度
|
49
|
+
if (typeof window !== 'undefined') {
|
50
|
+
setScrollbarWidth(getScrollbarWidth());
|
51
|
+
}
|
52
|
+
}, []);
|
53
|
+
return scrollbarWidth;
|
54
|
+
}
|
55
|
+
var _default = exports.default = useScrollbarWidth;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-transform.d.ts","sourceRoot":"","sources":["use-transform.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,QAAA,MAAM,YAAY,aAAc,iBAAiB;;;;;;;;8BAwBd,MAAM;;;
|
1
|
+
{"version":3,"file":"use-transform.d.ts","sourceRoot":"","sources":["use-transform.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,QAAA,MAAM,YAAY,aAAc,iBAAiB;;;;;;;;8BAwBd,MAAM;;;CA0FxC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
@@ -116,13 +116,17 @@ var useTransform = function useTransform(props) {
|
|
116
116
|
setAtStart(true);
|
117
117
|
}
|
118
118
|
var removeWheelListener;
|
119
|
+
var removeScrollerListener;
|
119
120
|
if (autoScroll) {
|
120
121
|
var removeMouse = shouldScroll ? (0, _scrollBehavior.banOverScrollx)(container) : null;
|
121
122
|
removeWheelListener = (0, _element.addResizeObserver)(container, handleResize);
|
123
|
+
// 同时需要监听tabs-header-scroll的resize事件,防止tabs-header-scroll的宽度变化后不出现左右箭头的问题
|
124
|
+
removeScrollerListener = (0, _element.addResizeObserver)(target, handleResize);
|
122
125
|
return function () {
|
123
|
-
var _removeWheelListener;
|
126
|
+
var _removeWheelListener, _removeScrollerListen;
|
124
127
|
removeMouse === null || removeMouse === void 0 || removeMouse();
|
125
128
|
(_removeWheelListener = removeWheelListener) === null || _removeWheelListener === void 0 || _removeWheelListener();
|
129
|
+
(_removeScrollerListen = removeScrollerListener) === null || _removeScrollerListen === void 0 || _removeScrollerListen();
|
126
130
|
};
|
127
131
|
}
|
128
132
|
}, [containerRef.current, targetRef.current, shouldScroll]);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-datepicker-format.d.ts","sourceRoot":"","sources":["use-datepicker-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,8BAA8B,CAAC;AAkEtC,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"use-datepicker-format.d.ts","sourceRoot":"","sources":["use-datepicker-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,8BAA8B,CAAC;AAkEtC,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;0BAiJe,gBAAgB;iCAgCT,MAAM,SAAS,MAAM;yCA/HrD,OAAO,GAAG,KAAK,GAAG,SAAS,QAAQ,MAAM,UAAU,IAAI,KAAK,OAAO;uCAWvE,MAAM,cAAc,CAAC,IAAI,EAAE,CAAC,QAC3B,MAAM;kBACG,MAAM,SAAS;mBAAS,GAAG;;+BAQH,IAAI,YAAY,OAAO,GAAG,KAAK,GAAG,SAAS;;CA0KvF,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
@@ -92,6 +92,13 @@ var useDatePickerFormat = function useDatePickerFormat(props) {
|
|
92
92
|
var getCurrentArr = function getCurrentArr() {
|
93
93
|
var arr = convertValueToDateArr(value, format, options);
|
94
94
|
var currentArr = convertValueToDateArr(props.defaultCurrent, 'YYYY-MM-DD', options);
|
95
|
+
var validArr = arr.filter(function (item) {
|
96
|
+
return item;
|
97
|
+
});
|
98
|
+
var validCurrentArr = currentArr.filter(function (item) {
|
99
|
+
return item;
|
100
|
+
});
|
101
|
+
if (!validArr.length && currentArr.length) return validCurrentArr;
|
95
102
|
if (!arr[0]) arr[0] = arr[1] || currentArr[0] || new Date();
|
96
103
|
if (range && !arr[1]) arr[1] = arr[0] || currentArr[1] || new Date();
|
97
104
|
return arr;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;yBA+CX,MAAM,UAAU,MAAM;;;;;;;;CAmO5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
@@ -103,6 +103,7 @@ var useTableLayout = function useTableLayout(props) {
|
|
103
103
|
return;
|
104
104
|
}
|
105
105
|
context.clientWidth = scrollEl.clientWidth;
|
106
|
+
if (scrollEl.clientHeight === 0) return;
|
106
107
|
var overHeight = scrollEl.scrollHeight > scrollEl.clientHeight;
|
107
108
|
var overWidth = scrollEl.scrollWidth > context.clientWidth;
|
108
109
|
var newScrollBarWidth = overHeight ? scrollEl.offsetWidth - scrollEl.clientWidth : 0;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACnC;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;
|
1
|
+
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACnC;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;oBAqLpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BAzFuB,MAAM,UAAU,MAAM;0BAxBtB,MAAM,QAAQ,MAAM;2BAqJnB,MAAM,aAAa,MAAM,IAAI;CA8FzE,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
@@ -283,6 +283,8 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
283
283
|
}, [startIndex]);
|
284
284
|
(0, _react.useEffect)(function () {
|
285
285
|
// 数据变化的时候清空掉 preIndex, 如果之前有缓存的index, setRowHeight 会有问题
|
286
|
+
setTop(0);
|
287
|
+
setStartIndex(0);
|
286
288
|
return function () {
|
287
289
|
context.preIndex = null;
|
288
290
|
};
|
package/cjs/index.d.ts
CHANGED
@@ -21,6 +21,7 @@ export * from './common/use-transform';
|
|
21
21
|
export * from './common/use-drag-mock';
|
22
22
|
export * from './common/use-pagination-list';
|
23
23
|
export * from './common/use-filter';
|
24
|
+
export * from './common/use-scrollbar-width';
|
24
25
|
export * from './components/use-input';
|
25
26
|
export * from './components/use-textarea';
|
26
27
|
export * from './components/use-form';
|
package/cjs/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,UAAU,CAAC;AAEjC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAE5B,OAAO,EAAE,IAAI,EAAE,CAAC;AAGhB,cAAc,eAAe,CAAC;AAE9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;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,CAAC;AACtC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;;AAE1C,wBAAkB"}
|
package/cjs/index.js
CHANGED
@@ -263,6 +263,18 @@ Object.keys(_useFilter).forEach(function (key) {
|
|
263
263
|
}
|
264
264
|
});
|
265
265
|
});
|
266
|
+
var _useScrollbarWidth = require("./common/use-scrollbar-width");
|
267
|
+
Object.keys(_useScrollbarWidth).forEach(function (key) {
|
268
|
+
if (key === "default" || key === "__esModule") return;
|
269
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
270
|
+
if (key in exports && exports[key] === _useScrollbarWidth[key]) return;
|
271
|
+
Object.defineProperty(exports, key, {
|
272
|
+
enumerable: true,
|
273
|
+
get: function get() {
|
274
|
+
return _useScrollbarWidth[key];
|
275
|
+
}
|
276
|
+
});
|
277
|
+
});
|
266
278
|
var _useInput = require("./components/use-input");
|
267
279
|
Object.keys(_useInput).forEach(function (key) {
|
268
280
|
if (key === "default" || key === "__esModule") return;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AA+BA,wBAAgB,iBAAiB,WAWhC;AAGD,eAAe,iBAAiB,CAAC"}
|
@@ -0,0 +1,48 @@
|
|
1
|
+
"use client";
|
2
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
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."); }
|
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); }
|
5
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
6
|
+
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; } }
|
7
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
8
|
+
import { useState, useEffect } from 'react';
|
9
|
+
var scrollbarWidthCache;
|
10
|
+
function getScrollbarWidth() {
|
11
|
+
// 检查是否在服务器端运行
|
12
|
+
if (typeof window === 'undefined' || typeof document === 'undefined') {
|
13
|
+
return 0;
|
14
|
+
}
|
15
|
+
|
16
|
+
// 如果我们的缓存变量已经存在,则直接返回该值
|
17
|
+
if (scrollbarWidthCache !== undefined) {
|
18
|
+
return scrollbarWidthCache;
|
19
|
+
}
|
20
|
+
|
21
|
+
// 客户端环境,计算滚动条宽度
|
22
|
+
var outer = document.createElement("div");
|
23
|
+
outer.style.visibility = "hidden";
|
24
|
+
outer.style.overflow = "scroll";
|
25
|
+
document.body.appendChild(outer);
|
26
|
+
var inner = document.createElement("div");
|
27
|
+
outer.appendChild(inner);
|
28
|
+
var scrollbarWidth = outer.offsetWidth - inner.offsetWidth;
|
29
|
+
if (outer.parentNode) outer.parentNode.removeChild(outer);
|
30
|
+
|
31
|
+
// 缓存并返回计算结果
|
32
|
+
scrollbarWidthCache = scrollbarWidth;
|
33
|
+
return scrollbarWidth;
|
34
|
+
}
|
35
|
+
export function useScrollbarWidth() {
|
36
|
+
var _useState = useState(0),
|
37
|
+
_useState2 = _slicedToArray(_useState, 2),
|
38
|
+
scrollbarWidth = _useState2[0],
|
39
|
+
setScrollbarWidth = _useState2[1];
|
40
|
+
useEffect(function () {
|
41
|
+
// 只有在客户端时才计算滚动条宽度
|
42
|
+
if (typeof window !== 'undefined') {
|
43
|
+
setScrollbarWidth(getScrollbarWidth());
|
44
|
+
}
|
45
|
+
}, []);
|
46
|
+
return scrollbarWidth;
|
47
|
+
}
|
48
|
+
export default useScrollbarWidth;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-transform.d.ts","sourceRoot":"","sources":["use-transform.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,QAAA,MAAM,YAAY,aAAc,iBAAiB;;;;;;;;8BAwBd,MAAM;;;
|
1
|
+
{"version":3,"file":"use-transform.d.ts","sourceRoot":"","sources":["use-transform.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,QAAA,MAAM,YAAY,aAAc,iBAAiB;;;;;;;;8BAwBd,MAAM;;;CA0FxC,CAAC;AAEF,eAAe,YAAY,CAAC"}
|
@@ -110,13 +110,17 @@ var useTransform = function useTransform(props) {
|
|
110
110
|
setAtStart(true);
|
111
111
|
}
|
112
112
|
var removeWheelListener;
|
113
|
+
var removeScrollerListener;
|
113
114
|
if (autoScroll) {
|
114
115
|
var removeMouse = shouldScroll ? banOverScrollx(container) : null;
|
115
116
|
removeWheelListener = addResizeObserver(container, handleResize);
|
117
|
+
// 同时需要监听tabs-header-scroll的resize事件,防止tabs-header-scroll的宽度变化后不出现左右箭头的问题
|
118
|
+
removeScrollerListener = addResizeObserver(target, handleResize);
|
116
119
|
return function () {
|
117
|
-
var _removeWheelListener;
|
120
|
+
var _removeWheelListener, _removeScrollerListen;
|
118
121
|
removeMouse === null || removeMouse === void 0 || removeMouse();
|
119
122
|
(_removeWheelListener = removeWheelListener) === null || _removeWheelListener === void 0 || _removeWheelListener();
|
123
|
+
(_removeScrollerListen = removeScrollerListener) === null || _removeScrollerListen === void 0 || _removeScrollerListen();
|
120
124
|
};
|
121
125
|
}
|
122
126
|
}, [containerRef.current, targetRef.current, shouldScroll]);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-datepicker-format.d.ts","sourceRoot":"","sources":["use-datepicker-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,8BAA8B,CAAC;AAkEtC,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"use-datepicker-format.d.ts","sourceRoot":"","sources":["use-datepicker-format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAE3D,OAAO,KAAK,EACV,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACzB,MAAM,8BAA8B,CAAC;AAkEtC,QAAA,MAAM,mBAAmB;;;;;;;;;;;;;;;;0BAiJe,gBAAgB;iCAgCT,MAAM,SAAS,MAAM;yCA/HrD,OAAO,GAAG,KAAK,GAAG,SAAS,QAAQ,MAAM,UAAU,IAAI,KAAK,OAAO;uCAWvE,MAAM,cAAc,CAAC,IAAI,EAAE,CAAC,QAC3B,MAAM;kBACG,MAAM,SAAS;mBAAS,GAAG;;+BAQH,IAAI,YAAY,OAAO,GAAG,KAAK,GAAG,SAAS;;CA0KvF,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
@@ -85,6 +85,13 @@ var useDatePickerFormat = function useDatePickerFormat(props) {
|
|
85
85
|
var getCurrentArr = function getCurrentArr() {
|
86
86
|
var arr = convertValueToDateArr(value, format, options);
|
87
87
|
var currentArr = convertValueToDateArr(props.defaultCurrent, 'YYYY-MM-DD', options);
|
88
|
+
var validArr = arr.filter(function (item) {
|
89
|
+
return item;
|
90
|
+
});
|
91
|
+
var validCurrentArr = currentArr.filter(function (item) {
|
92
|
+
return item;
|
93
|
+
});
|
94
|
+
if (!validArr.length && currentArr.length) return validCurrentArr;
|
88
95
|
if (!arr[0]) arr[0] = arr[1] || currentArr[0] || new Date();
|
89
96
|
if (range && !arr[1]) arr[1] = arr[0] || currentArr[1] || new Date();
|
90
97
|
return arr;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;
|
1
|
+
{"version":3,"file":"use-table-layout.d.ts","sourceRoot":"","sources":["use-table-layout.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6C,MAAM,OAAO,CAAC;AAKlE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAcrE,MAAM,WAAW,mBACf,SAAQ,IAAI,CACV,cAAc,CAAC,GAAG,CAAC,EACnB,MAAM,GAAG,kBAAkB,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,OAAO,CAC7E;IACD,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACvC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC;IACxC,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,QAAA,MAAM,cAAc,UAAW,mBAAmB;;;;;;;;;;;yBA+CX,MAAM,UAAU,MAAM;;;;;;;;CAmO5D,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
@@ -94,6 +94,7 @@ var useTableLayout = function useTableLayout(props) {
|
|
94
94
|
return;
|
95
95
|
}
|
96
96
|
context.clientWidth = scrollEl.clientWidth;
|
97
|
+
if (scrollEl.clientHeight === 0) return;
|
97
98
|
var overHeight = scrollEl.scrollHeight > scrollEl.clientHeight;
|
98
99
|
var overWidth = scrollEl.scrollWidth > context.clientWidth;
|
99
100
|
var newScrollBarWidth = overHeight ? scrollEl.offsetWidth - scrollEl.clientWidth : 0;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACnC;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;
|
1
|
+
{"version":3,"file":"use-table-virtual.d.ts","sourceRoot":"","sources":["use-table-virtual.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAGrD,UAAU,oBAAoB;IAC5B,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC3C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,iBAAiB,CAAC,GAAG,CAAC,EAAE,CAAC;CACnC;AACD,QAAA,MAAM,eAAe,UAAW,oBAAoB;;;;;;;oBAqLpC,MAAM;mBACP,MAAM;WACd,MAAM;gBACD,MAAM;kBACJ,OAAO;;0BAzFuB,MAAM,UAAU,MAAM;0BAxBtB,MAAM,QAAQ,MAAM;2BAqJnB,MAAM,aAAa,MAAM,IAAI;CA8FzE,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
@@ -277,6 +277,8 @@ var useTableVirtual = function useTableVirtual(props) {
|
|
277
277
|
}, [startIndex]);
|
278
278
|
useEffect(function () {
|
279
279
|
// 数据变化的时候清空掉 preIndex, 如果之前有缓存的index, setRowHeight 会有问题
|
280
|
+
setTop(0);
|
281
|
+
setStartIndex(0);
|
280
282
|
return function () {
|
281
283
|
context.preIndex = null;
|
282
284
|
};
|
package/esm/index.d.ts
CHANGED
@@ -21,6 +21,7 @@ export * from './common/use-transform';
|
|
21
21
|
export * from './common/use-drag-mock';
|
22
22
|
export * from './common/use-pagination-list';
|
23
23
|
export * from './common/use-filter';
|
24
|
+
export * from './common/use-scrollbar-width';
|
24
25
|
export * from './components/use-input';
|
25
26
|
export * from './components/use-textarea';
|
26
27
|
export * from './components/use-form';
|
package/esm/index.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,UAAU,CAAC;AAEjC,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAE5B,OAAO,EAAE,IAAI,EAAE,CAAC;AAGhB,cAAc,eAAe,CAAC;AAE9B,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.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BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,2BAA2B,CAAC;;AAE1C,wBAAkB"}
|
package/esm/index.js
CHANGED
@@ -24,6 +24,7 @@ export * from "./common/use-transform";
|
|
24
24
|
export * from "./common/use-drag-mock";
|
25
25
|
export * from "./common/use-pagination-list";
|
26
26
|
export * from "./common/use-filter";
|
27
|
+
export * from "./common/use-scrollbar-width";
|
27
28
|
|
28
29
|
//components
|
29
30
|
export * from "./components/use-input";
|