@apify/ui-library 0.68.1-feattabs-4feb6d.112 → 0.68.1-feattabs-4feb6d.123

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": "@apify/ui-library",
3
- "version": "0.68.1-feattabs-4feb6d.112+7719fefdfd4",
3
+ "version": "0.68.1-feattabs-4feb6d.123+d7d865c0725",
4
4
  "description": "React UI library used by apify.com",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -28,7 +28,6 @@
28
28
  "dependencies": {
29
29
  "@apify/ui-icons": "^0.10.0",
30
30
  "@floating-ui/react": "^0.26.2",
31
- "@juggle/resize-observer": "^3.4.0",
32
31
  "@react-hook/resize-observer": "^2.0.2",
33
32
  "clsx": "^2.0.0",
34
33
  "dayjs": "1.11.9",
@@ -67,5 +66,5 @@
67
66
  "typescript": "^5.1.6",
68
67
  "typescript-eslint": "^8.24.0"
69
68
  },
70
- "gitHead": "7719fefdfd47a748e36ef561734584b7d38b7fdf"
69
+ "gitHead": "d7d865c072540b0f249548378976fe3bb43051d1"
71
70
  }
@@ -47,7 +47,7 @@ const badgeSizeStyle = {
47
47
  border-radius: ${theme.radius.radius4};
48
48
  `,
49
49
  extra_small: css`
50
- height: 1.6rem;
50
+ height: ${theme.space.space16};
51
51
  padding: ${theme.space.space2} ${theme.space.space4};
52
52
  border-radius: ${theme.radius.radius4};
53
53
  `,
@@ -142,6 +142,12 @@ type TabWrapperProps = WithTransientProps<Required<Pick<TabProps, 'variant'>>> &
142
142
  role?: React.AriaRole;
143
143
  };
144
144
 
145
+ export const TAB_CLASSNAMES = {
146
+ ICON: 'Tab-icon',
147
+ TITLE: 'Tab-title',
148
+ BADGE: 'Tab-badge',
149
+ };
150
+
145
151
  const TabWrapper = styled(Link)<TabWrapperProps>`
146
152
  display: inline-flex;
147
153
  align-items: center;
@@ -161,19 +167,19 @@ const TabWrapper = styled(Link)<TabWrapperProps>`
161
167
  pointer-events: none;
162
168
  }
163
169
 
164
- .Tab-icon {
170
+ .${TAB_CLASSNAMES.ICON} {
165
171
  color: inherit;
166
172
  flex-shrink: 0;
167
173
  transition: color ${theme.transition.fastEaseOut};
168
174
  }
169
175
 
170
- .Tab-title {
176
+ .${TAB_CLASSNAMES.TITLE} {
171
177
  overflow: hidden;
172
178
  text-overflow: ellipsis;
173
179
  white-space: nowrap;
174
180
  }
175
181
 
176
- .Tab-badge {
182
+ .${TAB_CLASSNAMES.BADGE} {
177
183
  flex-shrink: 0;
178
184
  text-transform: uppercase;
179
185
  }
@@ -194,10 +200,18 @@ export const Tab = ({ variant = 'default', id, to, Icon, title, chip, rollout, c
194
200
  onClick={onSelect ? (event) => onSelect({ id, href, event }) : undefined}
195
201
  $variant={variant}
196
202
  >
197
- {Icon && <Icon size="16" className="Tab-icon" />}
198
- <Text size={tabVariantTextSize[variant]} className="Tab-title" weight="bold" as="div">{title}</Text>
199
- {chip && <Badge size={tabVariantBadgeSize[variant]} variant={active ? 'primary_black' : 'neutral_subtle'} className="Tab-badge">{chip}</Badge>}
200
- {rollout && <Badge size={tabVariantBadgeSize[variant]} variant="primary_blue" className="Tab-badge">{rollout}</Badge>}
203
+ {Icon && <Icon size="16" className={TAB_CLASSNAMES.ICON} />}
204
+ <Text size={tabVariantTextSize[variant]} className={TAB_CLASSNAMES.ICON} weight="bold" as="div">{title}</Text>
205
+ {chip && (
206
+ <Badge
207
+ size={tabVariantBadgeSize[variant]}
208
+ variant={active ? 'primary_black' : 'neutral_subtle'}
209
+ className={TAB_CLASSNAMES.ICON}
210
+ >
211
+ {chip}
212
+ </Badge>
213
+ )}
214
+ {rollout && <Badge size={tabVariantBadgeSize[variant]} variant="primary_blue" className={TAB_CLASSNAMES.ICON}>{rollout}</Badge>}
201
215
  </TabWrapper>
202
216
  );
203
217
  };
@@ -1,11 +1,10 @@
1
- import { ResizeObserver } from '@juggle/resize-observer';
2
- import useResizeObserver from '@react-hook/resize-observer';
3
1
  import React, { useCallback, useRef, useState } from 'react';
4
2
  import type { FlattenSimpleInterpolation } from 'styled-components';
5
3
  import styled, { css } from 'styled-components';
6
4
 
7
5
  import { theme } from '../../design_system/theme.js';
8
6
  import type { WithTransientProps } from '../../type_utils.js';
7
+ import { useResizeObserverSsr } from '../../utils/resize_observer.js';
9
8
  import type { MarginSpacingProps, RegularBoxProps } from '../box.js';
10
9
  import { Box } from '../box.js';
11
10
  import type { TabData, TabVariant } from './tab.js';
@@ -147,7 +146,7 @@ export const Tabs = ({ variant = 'default', tabs, activeTab, onSelect, ...props
147
146
  const ref = useRef<HTMLDivElement>(null);
148
147
  const [overflowState, setOveflowState] = useState<TabOverflowState>();
149
148
 
150
- useResizeObserver(ref, (entry) => setOveflowState(isTabsOverflowing(entry.target as HTMLDivElement)), { polyfill: ResizeObserver });
149
+ useResizeObserverSsr(ref, (entry) => setOveflowState(isTabsOverflowing(entry.target as HTMLDivElement)));
151
150
  const scrollHandler = useCallback((event: React.SyntheticEvent<HTMLDivElement>) => {
152
151
  setOveflowState(isTabsOverflowing(event.currentTarget as HTMLDivElement));
153
152
  }, []);
@@ -1,3 +1,4 @@
1
1
  export * from './copy_to_clipboard.js';
2
2
  export * from './sanitization.js';
3
3
  export * from './image_color.js';
4
+ export * from './resize_observer.js';
@@ -0,0 +1,18 @@
1
+ /* eslint-disable @typescript-eslint/no-useless-constructor, @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars */
2
+ import type { UseResizeObserverCallback } from '@react-hook/resize-observer';
3
+ import useResizeObserver from '@react-hook/resize-observer';
4
+
5
+ class ServerSideResizeObserverPolyfill {
6
+ constructor(callback: ResizeObserverCallback) {}
7
+ observe(target: Element, options?: ResizeObserverOptions) {}
8
+ unobserve(target: Element) {}
9
+ }
10
+
11
+ export const useResizeObserverSsr = <T extends Element>(
12
+ target: React.RefObject<T> | React.ForwardedRef<T> | T | null,
13
+ callback: UseResizeObserverCallback,
14
+ ) => {
15
+ return useResizeObserver(target, callback, {
16
+ polyfill: typeof window === 'undefined' ? ServerSideResizeObserverPolyfill : null,
17
+ });
18
+ };