@sheinx/hooks 3.5.8-beta.11 → 3.5.8-beta.13
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/check-border.d.ts +6 -0
- package/cjs/common/use-position-style/check-border.d.ts.map +1 -0
- package/cjs/common/use-position-style/check-border.js +35 -0
- package/cjs/common/use-position-style/get-position-style.d.ts +1 -0
- package/cjs/common/use-position-style/get-position-style.d.ts.map +1 -1
- package/cjs/common/use-position-style/get-position-style.js +14 -8
- package/cjs/common/use-position-style/index.d.ts.map +1 -1
- package/cjs/common/use-position-style/index.js +8 -2
- package/cjs/components/use-tree/index.d.ts +1 -1
- package/cjs/components/use-tree/index.d.ts.map +1 -1
- package/cjs/components/use-tree/index.js +11 -2
- package/esm/common/use-position-style/check-border.d.ts +6 -0
- package/esm/common/use-position-style/check-border.d.ts.map +1 -0
- package/esm/common/use-position-style/check-border.js +29 -0
- package/esm/common/use-position-style/get-position-style.d.ts +1 -0
- package/esm/common/use-position-style/get-position-style.d.ts.map +1 -1
- package/esm/common/use-position-style/get-position-style.js +14 -8
- package/esm/common/use-position-style/index.d.ts.map +1 -1
- package/esm/common/use-position-style/index.js +8 -2
- package/esm/components/use-tree/index.d.ts +1 -1
- package/esm/components/use-tree/index.d.ts.map +1 -1
- package/esm/components/use-tree/index.js +1 -1
- package/package.json +1 -1
@@ -0,0 +1,6 @@
|
|
1
|
+
interface UseCheckElementBorderWidthOptions {
|
2
|
+
direction?: 'horizontal' | 'vertical';
|
3
|
+
}
|
4
|
+
export declare const useCheckElementBorderWidth: (elementRef: React.RefObject<HTMLElement>, options?: UseCheckElementBorderWidthOptions) => number;
|
5
|
+
export {};
|
6
|
+
//# sourceMappingURL=check-border.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"check-border.d.ts","sourceRoot":"","sources":["check-border.ts"],"names":[],"mappings":"AAEA,UAAU,iCAAiC;IAGzC,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;CACvC;AAGD,eAAO,MAAM,0BAA0B,eACzB,MAAM,SAAS,CAAC,WAAW,CAAC,YAC/B,iCAAiC,KACzC,MAqBF,CAAC"}
|
@@ -0,0 +1,35 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.useCheckElementBorderWidth = void 0;
|
7
|
+
var _react = require("react");
|
8
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
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."); }
|
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); }
|
11
|
+
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; }
|
12
|
+
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; } }
|
13
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
14
|
+
var useCheckElementBorderWidth = exports.useCheckElementBorderWidth = function useCheckElementBorderWidth(elementRef) {
|
15
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
16
|
+
var _useState = (0, _react.useState)(0),
|
17
|
+
_useState2 = _slicedToArray(_useState, 2),
|
18
|
+
borderWidth = _useState2[0],
|
19
|
+
setBorderWidth = _useState2[1];
|
20
|
+
|
21
|
+
// 获取指定方向上的border宽度之和
|
22
|
+
var getBorderWidth = (0, _react.useCallback)(function () {
|
23
|
+
if (elementRef.current) {
|
24
|
+
var _options$direction = options.direction,
|
25
|
+
direction = _options$direction === void 0 ? 'horizontal' : _options$direction;
|
26
|
+
var style = window.getComputedStyle(elementRef.current);
|
27
|
+
var _borderWidth = direction === 'horizontal' ? parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth) : parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
|
28
|
+
setBorderWidth(_borderWidth);
|
29
|
+
}
|
30
|
+
}, [elementRef]);
|
31
|
+
(0, _react.useEffect)(function () {
|
32
|
+
getBorderWidth();
|
33
|
+
}, [getBorderWidth]);
|
34
|
+
return borderWidth;
|
35
|
+
};
|
@@ -3,5 +3,6 @@ export declare const getPositionStyle: (position: string, config?: {
|
|
3
3
|
popupGap?: number | undefined;
|
4
4
|
zIndex?: number | undefined;
|
5
5
|
fixedWidth?: boolean | "min" | undefined;
|
6
|
+
parentBorderWidth?: number | undefined;
|
6
7
|
} | undefined) => React.CSSProperties;
|
7
8
|
//# sourceMappingURL=get-position-style.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"get-position-style.d.ts","sourceRoot":"","sources":["get-position-style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"get-position-style.d.ts","sourceRoot":"","sources":["get-position-style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,eAAO,MAAM,gBAAgB,aACjB,MAAM;;;;;qCA+CjB,CAAC"}
|
@@ -28,6 +28,9 @@ var getPositionStyle = exports.getPositionStyle = function getPositionStyle(posi
|
|
28
28
|
if (config !== null && config !== void 0 && config.fixedWidth) {
|
29
29
|
var key = config.fixedWidth === 'min' ? 'minWidth' : 'width';
|
30
30
|
newStyle[key] = '100%';
|
31
|
+
if (config.parentBorderWidth) {
|
32
|
+
newStyle[key] = "calc(100% + ".concat(config.parentBorderWidth, "px)");
|
33
|
+
}
|
31
34
|
}
|
32
35
|
if (position === 'drop-down') {
|
33
36
|
newStyle.top = mainMargin;
|
@@ -39,19 +42,22 @@ var getPositionStyle = exports.getPositionStyle = function getPositionStyle(posi
|
|
39
42
|
var positionArr = (position || '').split('-');
|
40
43
|
if (positionArr.length === 2) {
|
41
44
|
var _positionArr = _slicedToArray(positionArr, 2),
|
42
|
-
|
43
|
-
|
44
|
-
newStyle[ReverseDir[
|
45
|
-
newStyle[
|
45
|
+
vDirection = _positionArr[0],
|
46
|
+
hDirection = _positionArr[1];
|
47
|
+
newStyle[ReverseDir[vDirection]] = mainMargin;
|
48
|
+
newStyle[hDirection] = 0;
|
49
|
+
if (config !== null && config !== void 0 && config.parentBorderWidth) {
|
50
|
+
newStyle[hDirection] = -config.parentBorderWidth / 2;
|
51
|
+
}
|
46
52
|
} else {
|
47
53
|
var _positionArr2 = _slicedToArray(positionArr, 1),
|
48
|
-
|
49
|
-
newStyle[ReverseDir[
|
50
|
-
if (
|
54
|
+
_vDirection = _positionArr2[0];
|
55
|
+
newStyle[ReverseDir[_vDirection]] = mainMargin;
|
56
|
+
if (_vDirection === 'left' || _vDirection === 'right') {
|
51
57
|
newStyle.top = halfMargin;
|
52
58
|
newStyle.transform = 'translateY(-50%)';
|
53
59
|
}
|
54
|
-
if (
|
60
|
+
if (_vDirection === 'top' || _vDirection === 'bottom') {
|
55
61
|
newStyle.left = halfMargin;
|
56
62
|
newStyle.transform = 'translateX(-50%)';
|
57
63
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
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;CAClB;AAOD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;;CA6S3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
@@ -9,6 +9,7 @@ exports.usePositionStyle = exports.default = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
10
10
|
var _getPositionStyle = require("./get-position-style");
|
11
11
|
var _checkPosition = require("./check-position");
|
12
|
+
var _checkBorder = require("./check-border");
|
12
13
|
var _shallowEqual = _interopRequireDefault(require("../../utils/shallow-equal"));
|
13
14
|
var _usePersistFn = _interopRequireDefault(require("../use-persist-fn"));
|
14
15
|
var _utils = require("../../utils");
|
@@ -74,6 +75,9 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
74
75
|
scrollContainer: scrollElRef === null || scrollElRef === void 0 ? void 0 : scrollElRef.current,
|
75
76
|
enable: show && adjust
|
76
77
|
});
|
78
|
+
var parentElBorderWidth = (0, _checkBorder.useCheckElementBorderWidth)(parentElRef, {
|
79
|
+
direction: 'horizontal'
|
80
|
+
});
|
77
81
|
var adjustPosition = function adjustPosition(position) {
|
78
82
|
var winHeight = _utils.docSize.height;
|
79
83
|
if (!verticalPosition.includes(position)) return position;
|
@@ -304,17 +308,19 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
|
|
304
308
|
newStyle: style
|
305
309
|
};
|
306
310
|
context.parentRect = parentElRef.current.getBoundingClientRect();
|
311
|
+
var realPosition = position;
|
307
312
|
if (adjust) {
|
308
313
|
var popupInfo = getPopUpInfo(context.parentRect);
|
309
314
|
context.popUpHeight = popupInfo.height;
|
310
315
|
context.popUpWidth = popupInfo.width;
|
316
|
+
realPosition = adjustPosition(position);
|
311
317
|
}
|
312
|
-
var realPosition = adjust ? adjustPosition(position) : position;
|
313
318
|
if (!absolute) {
|
314
319
|
newStyle = (0, _getPositionStyle.getPositionStyle)(realPosition, {
|
315
320
|
popupGap: popupGap,
|
316
321
|
zIndex: zIndex,
|
317
|
-
fixedWidth: fixedWidth
|
322
|
+
fixedWidth: fixedWidth,
|
323
|
+
parentBorderWidth: parentElBorderWidth
|
318
324
|
});
|
319
325
|
} else {
|
320
326
|
var _ref3 = getAbsoluteStyle(realPosition),
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { default, default as useTree } from './use-tree';
|
1
|
+
export { default, default as useTree, MODE } from './use-tree';
|
2
2
|
export type { BaseTreeProps, UpdateFunc, TreePathType, TreeModeType, DisabledOption, } from './use-tree.type';
|
3
3
|
export { default as useTreeNode } from './use-tree-node';
|
4
4
|
export type { BaseTreeNodeProps, UpdateType } from './use-tree-node.type';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAC/D,YAAY,EACV,aAAa,EACb,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,cAAc,GACf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC"}
|
@@ -1,9 +1,16 @@
|
|
1
1
|
"use strict";
|
2
2
|
"use client";
|
3
3
|
|
4
|
+
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); }
|
4
5
|
Object.defineProperty(exports, "__esModule", {
|
5
6
|
value: true
|
6
7
|
});
|
8
|
+
Object.defineProperty(exports, "MODE", {
|
9
|
+
enumerable: true,
|
10
|
+
get: function get() {
|
11
|
+
return _useTree.MODE;
|
12
|
+
}
|
13
|
+
});
|
7
14
|
Object.defineProperty(exports, "default", {
|
8
15
|
enumerable: true,
|
9
16
|
get: function get() {
|
@@ -22,6 +29,8 @@ Object.defineProperty(exports, "useTreeNode", {
|
|
22
29
|
return _useTreeNode.default;
|
23
30
|
}
|
24
31
|
});
|
25
|
-
var _useTree =
|
32
|
+
var _useTree = _interopRequireWildcard(require("./use-tree"));
|
26
33
|
var _useTreeNode = _interopRequireDefault(require("./use-tree-node"));
|
27
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
34
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
35
|
+
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); }
|
36
|
+
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; }
|
@@ -0,0 +1,6 @@
|
|
1
|
+
interface UseCheckElementBorderWidthOptions {
|
2
|
+
direction?: 'horizontal' | 'vertical';
|
3
|
+
}
|
4
|
+
export declare const useCheckElementBorderWidth: (elementRef: React.RefObject<HTMLElement>, options?: UseCheckElementBorderWidthOptions) => number;
|
5
|
+
export {};
|
6
|
+
//# sourceMappingURL=check-border.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"check-border.d.ts","sourceRoot":"","sources":["check-border.ts"],"names":[],"mappings":"AAEA,UAAU,iCAAiC;IAGzC,SAAS,CAAC,EAAE,YAAY,GAAG,UAAU,CAAC;CACvC;AAGD,eAAO,MAAM,0BAA0B,eACzB,MAAM,SAAS,CAAC,WAAW,CAAC,YAC/B,iCAAiC,KACzC,MAqBF,CAAC"}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
2
|
+
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."); }
|
3
|
+
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); }
|
4
|
+
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; }
|
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
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
7
|
+
import { useCallback, useEffect, useState } from 'react';
|
8
|
+
export var useCheckElementBorderWidth = function useCheckElementBorderWidth(elementRef) {
|
9
|
+
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
10
|
+
var _useState = useState(0),
|
11
|
+
_useState2 = _slicedToArray(_useState, 2),
|
12
|
+
borderWidth = _useState2[0],
|
13
|
+
setBorderWidth = _useState2[1];
|
14
|
+
|
15
|
+
// 获取指定方向上的border宽度之和
|
16
|
+
var getBorderWidth = useCallback(function () {
|
17
|
+
if (elementRef.current) {
|
18
|
+
var _options$direction = options.direction,
|
19
|
+
direction = _options$direction === void 0 ? 'horizontal' : _options$direction;
|
20
|
+
var style = window.getComputedStyle(elementRef.current);
|
21
|
+
var _borderWidth = direction === 'horizontal' ? parseFloat(style.borderLeftWidth) + parseFloat(style.borderRightWidth) : parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
|
22
|
+
setBorderWidth(_borderWidth);
|
23
|
+
}
|
24
|
+
}, [elementRef]);
|
25
|
+
useEffect(function () {
|
26
|
+
getBorderWidth();
|
27
|
+
}, [getBorderWidth]);
|
28
|
+
return borderWidth;
|
29
|
+
};
|
@@ -3,5 +3,6 @@ export declare const getPositionStyle: (position: string, config?: {
|
|
3
3
|
popupGap?: number | undefined;
|
4
4
|
zIndex?: number | undefined;
|
5
5
|
fixedWidth?: boolean | "min" | undefined;
|
6
|
+
parentBorderWidth?: number | undefined;
|
6
7
|
} | undefined) => React.CSSProperties;
|
7
8
|
//# sourceMappingURL=get-position-style.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"get-position-style.d.ts","sourceRoot":"","sources":["get-position-style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;
|
1
|
+
{"version":3,"file":"get-position-style.d.ts","sourceRoot":"","sources":["get-position-style.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAU1B,eAAO,MAAM,gBAAgB,aACjB,MAAM;;;;;qCA+CjB,CAAC"}
|
@@ -22,6 +22,9 @@ export var getPositionStyle = function getPositionStyle(position, config) {
|
|
22
22
|
if (config !== null && config !== void 0 && config.fixedWidth) {
|
23
23
|
var key = config.fixedWidth === 'min' ? 'minWidth' : 'width';
|
24
24
|
newStyle[key] = '100%';
|
25
|
+
if (config.parentBorderWidth) {
|
26
|
+
newStyle[key] = "calc(100% + ".concat(config.parentBorderWidth, "px)");
|
27
|
+
}
|
25
28
|
}
|
26
29
|
if (position === 'drop-down') {
|
27
30
|
newStyle.top = mainMargin;
|
@@ -33,19 +36,22 @@ export var getPositionStyle = function getPositionStyle(position, config) {
|
|
33
36
|
var positionArr = (position || '').split('-');
|
34
37
|
if (positionArr.length === 2) {
|
35
38
|
var _positionArr = _slicedToArray(positionArr, 2),
|
36
|
-
|
37
|
-
|
38
|
-
newStyle[ReverseDir[
|
39
|
-
newStyle[
|
39
|
+
vDirection = _positionArr[0],
|
40
|
+
hDirection = _positionArr[1];
|
41
|
+
newStyle[ReverseDir[vDirection]] = mainMargin;
|
42
|
+
newStyle[hDirection] = 0;
|
43
|
+
if (config !== null && config !== void 0 && config.parentBorderWidth) {
|
44
|
+
newStyle[hDirection] = -config.parentBorderWidth / 2;
|
45
|
+
}
|
40
46
|
} else {
|
41
47
|
var _positionArr2 = _slicedToArray(positionArr, 1),
|
42
|
-
|
43
|
-
newStyle[ReverseDir[
|
44
|
-
if (
|
48
|
+
_vDirection = _positionArr2[0];
|
49
|
+
newStyle[ReverseDir[_vDirection]] = mainMargin;
|
50
|
+
if (_vDirection === 'left' || _vDirection === 'right') {
|
45
51
|
newStyle.top = halfMargin;
|
46
52
|
newStyle.transform = 'translateY(-50%)';
|
47
53
|
}
|
48
|
-
if (
|
54
|
+
if (_vDirection === 'top' || _vDirection === 'bottom') {
|
49
55
|
newStyle.left = halfMargin;
|
50
56
|
newStyle.transform = 'translateX(-50%)';
|
51
57
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,KAA8B,MAAM,OAAO,CAAC;
|
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;CAClB;AAOD,eAAO,MAAM,gBAAgB,WAAY,mBAAmB;;;CA6S3D,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
@@ -8,6 +8,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
8
8
|
import React, { useEffect, useState } from 'react';
|
9
9
|
import { getPositionStyle } from "./get-position-style";
|
10
10
|
import { useCheckElementPosition } from "./check-position";
|
11
|
+
import { useCheckElementBorderWidth } from "./check-border";
|
11
12
|
import shallowEqual from "../../utils/shallow-equal";
|
12
13
|
import usePersistFn from "../use-persist-fn";
|
13
14
|
import { getCurrentCSSZoom } from "../../utils";
|
@@ -65,6 +66,9 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
65
66
|
scrollContainer: scrollElRef === null || scrollElRef === void 0 ? void 0 : scrollElRef.current,
|
66
67
|
enable: show && adjust
|
67
68
|
});
|
69
|
+
var parentElBorderWidth = useCheckElementBorderWidth(parentElRef, {
|
70
|
+
direction: 'horizontal'
|
71
|
+
});
|
68
72
|
var adjustPosition = function adjustPosition(position) {
|
69
73
|
var winHeight = docSize.height;
|
70
74
|
if (!verticalPosition.includes(position)) return position;
|
@@ -295,17 +299,19 @@ export var usePositionStyle = function usePositionStyle(config) {
|
|
295
299
|
newStyle: style
|
296
300
|
};
|
297
301
|
context.parentRect = parentElRef.current.getBoundingClientRect();
|
302
|
+
var realPosition = position;
|
298
303
|
if (adjust) {
|
299
304
|
var popupInfo = getPopUpInfo(context.parentRect);
|
300
305
|
context.popUpHeight = popupInfo.height;
|
301
306
|
context.popUpWidth = popupInfo.width;
|
307
|
+
realPosition = adjustPosition(position);
|
302
308
|
}
|
303
|
-
var realPosition = adjust ? adjustPosition(position) : position;
|
304
309
|
if (!absolute) {
|
305
310
|
newStyle = getPositionStyle(realPosition, {
|
306
311
|
popupGap: popupGap,
|
307
312
|
zIndex: zIndex,
|
308
|
-
fixedWidth: fixedWidth
|
313
|
+
fixedWidth: fixedWidth,
|
314
|
+
parentBorderWidth: parentElBorderWidth
|
309
315
|
});
|
310
316
|
} else {
|
311
317
|
var _ref3 = getAbsoluteStyle(realPosition),
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { default, default as useTree } from './use-tree';
|
1
|
+
export { default, default as useTree, MODE } from './use-tree';
|
2
2
|
export type { BaseTreeProps, UpdateFunc, TreePathType, TreeModeType, DisabledOption, } from './use-tree.type';
|
3
3
|
export { default as useTreeNode } from './use-tree-node';
|
4
4
|
export type { BaseTreeNodeProps, UpdateType } from './use-tree-node.type';
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,YAAY,CAAC;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAC/D,YAAY,EACV,aAAa,EACb,UAAU,EACV,YAAY,EACZ,YAAY,EACZ,cAAc,GACf,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACzD,YAAY,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC"}
|