dtable-ui-component 6.0.52-alpha.2 → 6.0.52

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.
@@ -14,84 +14,54 @@ function ColorPickerPortal(_ref) {
14
14
  let {
15
15
  target,
16
16
  scrollContainerId,
17
- throttleDelay = 16,
17
+ throttleDelay,
18
18
  children
19
19
  } = _ref;
20
20
  const containerRef = (0, _react.useRef)(null);
21
- const [isPositioned, setIsPositioned] = (0, _react.useState)(false);
22
- const [position, setPosition] = (0, _react.useState)(() => {
23
- return {
24
- top: '-9999px',
25
- left: '-9999px',
26
- visibility: 'hidden'
27
- };
21
+ const [position, setPosition] = (0, _react.useState)({
22
+ top: 0,
23
+ left: 0
28
24
  });
29
- const updatePosition = (0, _react.useCallback)(() => {
30
- if (!target || !containerRef.current) return;
31
- const targetRect = target.getBoundingClientRect();
32
- const {
33
- top: spaceAbove,
34
- left
35
- } = targetRect;
36
- const portalRectHeight = containerRef.current.clientHeight;
37
- const newPosition = {
38
- left: "".concat(left + 1, "px"),
39
- visibility: 'visible'
40
- };
41
- if (spaceAbove < portalRectHeight) {
42
- newPosition.top = "calc(".concat(spaceAbove, "px + 2.375rem)");
43
- } else {
44
- newPosition.top = "calc(".concat(spaceAbove - portalRectHeight, "px)");
45
- }
46
- setPosition(prev => ({
47
- ...prev,
48
- ...newPosition
49
- }));
50
- if (!isPositioned) {
51
- setIsPositioned(true);
52
- }
53
- }, [target, isPositioned]);
54
25
  (0, _react.useEffect)(() => {
55
- if (!target) return;
56
-
57
- // 初始计算位置
58
- const initialPosition = () => {
59
- updatePosition();
60
- // 强制重排,确保位置计算准确
61
- requestAnimationFrame(updatePosition);
26
+ if (!target || !containerRef.current) return;
27
+ const updatePosition = () => {
28
+ const targetRect = target.getBoundingClientRect();
29
+ const {
30
+ top: spaceAbove,
31
+ left
32
+ } = targetRect;
33
+ const portalRectHeight = containerRef.current.clientHeight;
34
+ if (spaceAbove < portalRectHeight) {
35
+ setPosition({
36
+ top: "calc(".concat(spaceAbove, "px + 2.375rem)"),
37
+ left: left + 1 + 'px'
38
+ });
39
+ return;
40
+ }
41
+ setPosition({
42
+ top: "calc(".concat(spaceAbove - portalRectHeight, "px)"),
43
+ left: left + 1 + 'px'
44
+ });
62
45
  };
63
-
64
- // 使用setTimeout确保DOM更新后再计算位置
65
- const timer = setTimeout(initialPosition, 0);
46
+ updatePosition();
66
47
  const throttledUpdatePosition = (0, _utils.throttle)(updatePosition, throttleDelay);
67
48
  const scrollContainer = scrollContainerId ? document.getElementById(scrollContainerId) : null;
68
-
69
- // 添加事件监听
70
- scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.addEventListener('scroll', throttledUpdatePosition, {
71
- passive: true
72
- });
73
- window.addEventListener('resize', throttledUpdatePosition, {
74
- passive: true
75
- });
49
+ scrollContainer && scrollContainer.addEventListener('scroll', throttledUpdatePosition);
50
+ window.addEventListener('resize', updatePosition);
76
51
  return () => {
77
- clearTimeout(timer);
78
- window.removeEventListener('resize', throttledUpdatePosition);
79
- scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.removeEventListener('scroll', throttledUpdatePosition);
52
+ window.removeEventListener('resize', updatePosition);
53
+ scrollContainer && scrollContainer.removeEventListener('scroll', throttledUpdatePosition);
80
54
  };
81
- }, [target, scrollContainerId, throttleDelay, updatePosition]);
82
- if (!target) return null;
55
+ }, [target, containerRef, scrollContainerId, throttleDelay]);
83
56
  return /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
84
57
  className: "dtable-color-picker-portal",
85
58
  style: {
86
- position: 'fixed',
87
- zIndex: '1049',
59
+ position: 'absolute',
60
+ zIndex: '10',
88
61
  left: position.left,
89
62
  top: position.top,
90
63
  width: '240px',
91
- height: '370px',
92
- visibility: position.visibility,
93
- opacity: isPositioned ? 1 : 0,
94
- transition: 'opacity 0.15s ease-in-out'
64
+ height: '370px'
95
65
  },
96
66
  ref: containerRef,
97
67
  children: children
@@ -15,10 +15,6 @@
15
15
  cursor: default;
16
16
  }
17
17
 
18
- .dtable-switch.sm .custom-switch {
19
- width: 100%;
20
- }
21
-
22
18
  .dtable-switch.sm .custom-switch .custom-switch-description {
23
19
  width: 192px;
24
20
  margin: 0;
@@ -19,6 +19,7 @@ function DTableSwitch(_ref) {
19
19
  size = 'sm',
20
20
  switchPosition = 'right',
21
21
  switchClassName,
22
+ innerClassName,
22
23
  inputId
23
24
  } = _ref;
24
25
  const switchNode = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
@@ -37,7 +38,9 @@ function DTableSwitch(_ref) {
37
38
  [switchClassName]: switchClassName
38
39
  }),
39
40
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
40
- className: "custom-switch",
41
+ className: (0, _classnames.default)('custom-switch', {
42
+ [innerClassName]: innerClassName
43
+ }),
41
44
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
42
45
  className: "custom-switch-input",
43
46
  type: "checkbox",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "6.0.52-alpha.2",
3
+ "version": "6.0.52",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "4.0.2",