forstok-ui-lib 8.5.21 → 8.5.22

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": "forstok-ui-lib",
3
- "version": "8.5.21",
3
+ "version": "8.5.22",
4
4
  "description": "Forstok UI Components Library",
5
5
  "path": "dist",
6
6
  "main": "dist/index.js",
@@ -8,6 +8,7 @@ import type { TDropdown } from './typed';
8
8
 
9
9
  const DEFAULT_TOP_OFFSET = 40;
10
10
  const DEFAULT_BOTTOM_OFFSET = 35;
11
+ const MOBILE_BREAKPOINT = 768;
11
12
 
12
13
  const DropDownComponent = ({ children, title, subTitle, $externalWidth, $externalMinWidth, $internalWidth, $area, $openPosition, $placement, $top, onClick, $alias, type, portalId, $bottom, $isPopup, ...props }: TDropdown) => {
13
14
  const buttonRef = useRef<HTMLElement>(null);
@@ -19,6 +20,7 @@ const DropDownComponent = ({ children, title, subTitle, $externalWidth, $externa
19
20
 
20
21
  const getViewportHeight = () => window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
21
22
  const getViewportWidth = () => window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
23
+ const isMobileViewport = () => getViewportWidth() < MOBILE_BREAKPOINT;
22
24
 
23
25
  const getDropdownWrapperElement = (parentEl: ParentNode | null) => parentEl?.querySelector('._refDropdownWrapper') as HTMLElement | null;
24
26
  const withNextFrame = (callback: () => void) => window.requestAnimationFrame(() => callback());
@@ -61,6 +63,14 @@ const DropDownComponent = ({ children, title, subTitle, $externalWidth, $externa
61
63
  wrapperEl.style.bottom = 'auto';
62
64
  };
63
65
 
66
+ const applyMobileDropdownPlacement = (wrapperEl: HTMLElement) => {
67
+ wrapperEl.style.top = 'auto';
68
+ wrapperEl.style.bottom = '0';
69
+ wrapperEl.style.left = '0';
70
+ wrapperEl.style.right = 'auto';
71
+ wrapperEl.style.transform = 'none';
72
+ };
73
+
64
74
  const resetDropdownInlineStyle = (parentEl: ParentNode | null) => {
65
75
  const wrapperEl = getDropdownWrapperElement(parentEl);
66
76
  if (wrapperEl) {
@@ -93,6 +103,14 @@ const DropDownComponent = ({ children, title, subTitle, $externalWidth, $externa
93
103
  return;
94
104
  }
95
105
 
106
+ if (isMobileViewport()) {
107
+ applyMobileDropdownPlacement(wrapperRef);
108
+ portalContainerRef.style.left = '0';
109
+ portalContainerRef.style.top = '0';
110
+ portalContainerRef.style.zIndex = $isPopup ? '101' : '8';
111
+ return;
112
+ }
113
+
96
114
  const offsetPos = containerEl.getBoundingClientRect();
97
115
  const placement = getDropdownPlacement(containerEl, wrapperRef);
98
116
  const wrapperWidth = wrapperRef.getBoundingClientRect().width || wrapperRef.offsetWidth;
@@ -124,6 +142,11 @@ const DropDownComponent = ({ children, title, subTitle, $externalWidth, $externa
124
142
  return;
125
143
  }
126
144
 
145
+ if (isMobileViewport()) {
146
+ applyMobileDropdownPlacement(wrapperRef);
147
+ return;
148
+ }
149
+
127
150
  const placement = getDropdownPlacement(containerEl, wrapperRef);
128
151
  applyDropdownPlacement(wrapperRef, placement);
129
152
  };
@@ -61,8 +61,9 @@ const getDropDownContainerModifiedStyled = ({ $top, $bottom, $placement, $alias,
61
61
  @media only screen and (max-width: 767px) {
62
62
  & ${DropDownWrapper} {
63
63
  display: grid;
64
- left: 0;
65
- bottom:0;
64
+ left: 0 !important;
65
+ top: auto !important;
66
+ bottom: 0 !important;
66
67
  ${$placement === 'top' ? 'animation: dropgoup .075s;' : 'animation: droptoup .075s;'}
67
68
  overflow-x: hidden;
68
69
  }
@@ -330,4 +331,4 @@ export const DropdownPortalContainer = styled.div`
330
331
  display: block;
331
332
  }
332
333
  }
333
- `;
334
+ `;