dtable-ui-component 6.0.52-beta.2 → 6.0.53-beta.1

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,54 +14,77 @@ function ColorPickerPortal(_ref) {
14
14
  let {
15
15
  target,
16
16
  scrollContainerId,
17
- throttleDelay,
17
+ throttleDelay = 16,
18
18
  children
19
19
  } = _ref;
20
20
  const containerRef = (0, _react.useRef)(null);
21
- const [position, setPosition] = (0, _react.useState)({
22
- top: 0,
23
- left: 0
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
+ };
24
28
  });
25
- (0, _react.useEffect)(() => {
29
+ const updatePosition = (0, _react.useCallback)(() => {
26
30
  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
- });
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
+ (0, _react.useEffect)(() => {
55
+ if (!target) return;
56
+ const initialPosition = () => {
57
+ updatePosition();
58
+ requestAnimationFrame(updatePosition);
45
59
  };
46
- updatePosition();
60
+ const timer = setTimeout(initialPosition, 0);
47
61
  const throttledUpdatePosition = (0, _utils.throttle)(updatePosition, throttleDelay);
48
62
  const scrollContainer = scrollContainerId ? document.getElementById(scrollContainerId) : null;
49
- scrollContainer && scrollContainer.addEventListener('scroll', throttledUpdatePosition);
50
- window.addEventListener('resize', updatePosition);
63
+ scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.addEventListener('scroll', throttledUpdatePosition, {
64
+ passive: true
65
+ });
66
+ window.addEventListener('resize', throttledUpdatePosition, {
67
+ passive: true
68
+ });
51
69
  return () => {
52
- window.removeEventListener('resize', updatePosition);
53
- scrollContainer && scrollContainer.removeEventListener('scroll', throttledUpdatePosition);
70
+ clearTimeout(timer);
71
+ window.removeEventListener('resize', throttledUpdatePosition);
72
+ scrollContainer === null || scrollContainer === void 0 ? void 0 : scrollContainer.removeEventListener('scroll', throttledUpdatePosition);
54
73
  };
55
- }, [target, containerRef, scrollContainerId, throttleDelay]);
74
+ }, [target, scrollContainerId, throttleDelay, updatePosition]);
75
+ if (!target) return null;
56
76
  return /*#__PURE__*/_reactDom.default.createPortal( /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
57
77
  className: "dtable-color-picker-portal",
58
78
  style: {
59
- position: 'absolute',
60
- zIndex: '10',
79
+ position: 'fixed',
80
+ zIndex: '1049',
61
81
  left: position.left,
62
82
  top: position.top,
63
83
  width: '240px',
64
- height: '370px'
84
+ height: '370px',
85
+ visibility: position.visibility,
86
+ opacity: isPositioned ? 1 : 0,
87
+ transition: 'opacity 0.15s ease-in-out'
65
88
  },
66
89
  ref: containerRef,
67
90
  children: children
@@ -20,7 +20,7 @@
20
20
  }
21
21
 
22
22
  .dtable-switch.sm .custom-switch .custom-switch-description {
23
- width: auto;
23
+ width: 192px;
24
24
  margin: 0;
25
25
  padding-right: 5px;
26
26
  color: #212529;
@@ -19,7 +19,6 @@ function DTableSwitch(_ref) {
19
19
  size = 'sm',
20
20
  switchPosition = 'right',
21
21
  switchClassName,
22
- innerClassName,
23
22
  inputId
24
23
  } = _ref;
25
24
  const switchNode = /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
@@ -38,9 +37,7 @@ function DTableSwitch(_ref) {
38
37
  [switchClassName]: switchClassName
39
38
  }),
40
39
  children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("label", {
41
- className: (0, _classnames.default)('custom-switch', {
42
- [innerClassName]: innerClassName
43
- }),
40
+ className: "custom-switch",
44
41
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
45
42
  className: "custom-switch-input",
46
43
  type: "checkbox",
@@ -63,9 +63,13 @@ class Toaster {
63
63
  });
64
64
  };
65
65
  if (!isBrowser) return;
66
- const container = document.createElement('div');
67
- container.setAttribute('data-evergreen-toaster-container', '');
68
- document.body.appendChild(container);
66
+ let container = document.querySelector('[data-evergreen-toaster-container]');
67
+ console.log('container 是!!!', container);
68
+ if (!container) {
69
+ container = document.createElement('div');
70
+ container.setAttribute('data-evergreen-toaster-container', '');
71
+ document.body.appendChild(container);
72
+ }
69
73
  const root = (0, _client.createRoot)(container);
70
74
  root.render( /*#__PURE__*/(0, _jsxRuntime.jsx)(_toastManager.default, {
71
75
  bindNotify: this._bindNotify,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dtable-ui-component",
3
- "version": "6.0.52-beta.2",
3
+ "version": "6.0.53-beta.1",
4
4
  "main": "./lib/index.js",
5
5
  "dependencies": {
6
6
  "@seafile/react-image-lightbox": "4.0.2",