@swan-io/lake 5.2.0 → 6.0.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-io/lake",
3
- "version": "5.2.0",
3
+ "version": "6.0.0",
4
4
  "engines": {
5
5
  "node": ">=18.0.0",
6
6
  "yarn": "^1.22.0"
@@ -78,16 +78,17 @@ export const Popover = memo(({ children, id, label, role = "dialog", describedBy
78
78
  const rect = element.getBoundingClientRect();
79
79
  const availableSpaceAbove = rect.top;
80
80
  const availableSpaceBelow = window.innerHeight - rect.bottom;
81
- const visualViewportOffsetTop = (_b = (_a = window.visualViewport) === null || _a === void 0 ? void 0 : _a.offsetTop) !== null && _b !== void 0 ? _b : 0;
81
+ const visualViewportOffsetTop = (_a = window.scrollY) !== null && _a !== void 0 ? _a : 0;
82
+ const visualViewportOffsetLeft = (_b = window.scrollX) !== null && _b !== void 0 ? _b : 0;
82
83
  setViewportInformation({
83
84
  availableSpaceAbove,
84
85
  availableSpaceBelow,
85
86
  availableSpaceBefore: rect.left,
86
87
  availableSpaceAfter: window.innerWidth - rect.right,
87
88
  top: visualViewportOffsetTop + Math.max(rect.bottom, safetyMargin),
88
- bottom: Math.max(window.innerHeight - rect.top, safetyMargin),
89
- left: Math.max(rect.left, safetyMargin),
90
- right: Math.max(window.innerWidth - rect.right, safetyMargin),
89
+ bottom: Math.max(window.innerHeight - rect.top, safetyMargin) - visualViewportOffsetTop,
90
+ left: visualViewportOffsetLeft + Math.max(rect.left, safetyMargin),
91
+ right: Math.max(window.innerWidth - rect.right, safetyMargin) - visualViewportOffsetLeft,
91
92
  availableHeight: field || availableSpaceAbove <= availableSpaceBelow
92
93
  ? window.innerHeight - rect.top - (rect.bottom - rect.top) - 20
93
94
  : availableSpaceAbove - 20,
@@ -136,7 +137,7 @@ export const Popover = memo(({ children, id, label, role = "dialog", describedBy
136
137
  if (mode === "BottomPanel") {
137
138
  return (_jsx(BottomPanel, { visible: visible, onPressClose: onDismiss, returnFocus: false, children: typeof children == "function" ? children({ mode: "panel" }) : children }));
138
139
  }
139
- return (_jsx(Portal, { container: rootElement, children: _jsx(TransitionView, { style: styles.container, ...animation, children: visible ? (_jsxs(View, { style: styles.contents, children: [underlay ? (_jsx(Pressable, { ref: underlayRef, style: styles.underlay, onPress: onPressUnderlay, "aria-label": "Close" })) : null, availableHeight > 0 ? (_jsx(ScrollView, { style: [
140
+ return (_jsxs(Portal, { container: rootElement, children: [visible && underlay ? (_jsx(Pressable, { ref: underlayRef, style: styles.underlay, onPress: onPressUnderlay, "aria-label": "Close" })) : null, _jsx(TransitionView, { style: styles.container, ...animation, children: visible ? (_jsx(View, { style: styles.contents, children: availableHeight > 0 ? (_jsx(ScrollView, { style: [
140
141
  styles.popover,
141
142
  (field || availableSpaceAbove <= availableSpaceBelow) && { top },
142
143
  !field && availableSpaceAbove > availableSpaceBelow && { bottom },
@@ -150,5 +151,5 @@ export const Popover = memo(({ children, id, label, role = "dialog", describedBy
150
151
  {
151
152
  justifyContent: !field && availableSpaceAbove > availableSpaceBelow ? FLEX_END : FLEX_START,
152
153
  },
153
- ], id: id, role: role, "aria-describedby": describedBy, "aria-label": label, children: _jsx(FocusTrap, { focusLock: true, returnFocus: returnFocus, autoFocus: autoFocus, onEscapeKey: onEscapeKey, onClickOutside: underlay ? undefined : onClickOutside, children: _jsx(Pressable, { tabIndex: -1, onPress: onPress, style: styles.defaultCursor, children: typeof children == "function" ? children({ mode: "dropdown" }) : children }) }) })) : null] })) : null }) }));
154
+ ], id: id, role: role, "aria-describedby": describedBy, "aria-label": label, children: _jsx(FocusTrap, { focusLock: true, returnFocus: returnFocus, autoFocus: autoFocus, onEscapeKey: onEscapeKey, onClickOutside: underlay ? undefined : onClickOutside, children: _jsx(Pressable, { tabIndex: -1, onPress: onPress, style: styles.defaultCursor, children: typeof children == "function" ? children({ mode: "dropdown" }) : children }) }) })) : null })) : null })] }));
154
155
  });