@apify/ui-library 0.68.1-feattabs-4feb6d.103 → 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/dist/src/components/badge.js +1 -1
- package/dist/src/components/badge.js.map +1 -1
- package/dist/src/components/tabs/tab.d.ts +5 -0
- package/dist/src/components/tabs/tab.d.ts.map +1 -1
- package/dist/src/components/tabs/tab.js +9 -4
- package/dist/src/components/tabs/tab.js.map +1 -1
- package/dist/src/components/tabs/tabs.d.ts.map +1 -1
- package/dist/src/components/tabs/tabs.js +2 -3
- package/dist/src/components/tabs/tabs.js.map +1 -1
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +1 -0
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/resize_observer.d.ts +3 -0
- package/dist/src/utils/resize_observer.d.ts.map +1 -0
- package/dist/src/utils/resize_observer.js +12 -0
- package/dist/src/utils/resize_observer.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -3
- package/src/components/badge.tsx +1 -1
- package/src/components/tabs/tab.tsx +22 -7
- package/src/components/tabs/tabs.tsx +2 -3
- package/src/utils/index.ts +1 -0
- package/src/utils/resize_observer.ts +18 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apify/ui-library",
|
|
3
|
-
"version": "0.68.1-feattabs-4feb6d.
|
|
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": "
|
|
69
|
+
"gitHead": "d7d865c072540b0f249548378976fe3bb43051d1"
|
|
71
70
|
}
|
package/src/components/badge.tsx
CHANGED
|
@@ -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
|
-
.
|
|
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
|
-
.
|
|
176
|
+
.${TAB_CLASSNAMES.TITLE} {
|
|
171
177
|
overflow: hidden;
|
|
172
178
|
text-overflow: ellipsis;
|
|
173
179
|
white-space: nowrap;
|
|
174
180
|
}
|
|
175
181
|
|
|
176
|
-
.
|
|
182
|
+
.${TAB_CLASSNAMES.BADGE} {
|
|
177
183
|
flex-shrink: 0;
|
|
178
184
|
text-transform: uppercase;
|
|
179
185
|
}
|
|
@@ -189,14 +195,23 @@ export const Tab = ({ variant = 'default', id, to, Icon, title, chip, rollout, c
|
|
|
189
195
|
to={to}
|
|
190
196
|
role="tab"
|
|
191
197
|
data-test="tab"
|
|
198
|
+
data-test-url={href}
|
|
192
199
|
className={clsx(className, { active, disabled })}
|
|
193
200
|
onClick={onSelect ? (event) => onSelect({ id, href, event }) : undefined}
|
|
194
201
|
$variant={variant}
|
|
195
202
|
>
|
|
196
|
-
{Icon && <Icon size="16" className=
|
|
197
|
-
<Text size={tabVariantTextSize[variant]} className=
|
|
198
|
-
{chip &&
|
|
199
|
-
|
|
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>}
|
|
200
215
|
</TabWrapper>
|
|
201
216
|
);
|
|
202
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
|
-
|
|
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
|
}, []);
|
package/src/utils/index.ts
CHANGED
|
@@ -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
|
+
};
|