@apify/ui-library 1.164.1 → 1.164.3

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.
@@ -24,5 +24,16 @@ export type PolymorphicComponentProps<E extends ElementType, OwnProps extends ob
24
24
  export type PolymorphicComponentPropsWithRef<E extends ElementType, OwnProps extends object = object> = PolymorphicComponentProps<E, OwnProps> & {
25
25
  ref?: PolymorphicRef<E>;
26
26
  };
27
+ /**
28
+ * Cross-cutting `data-*` attribute props for testing and debugging.
29
+ * These are optional, but `Required<DataTestProps>` can be used to enforce them.
30
+ */
31
+ export type DataTestProps = {
32
+ 'data-test'?: string;
33
+ };
34
+ /** flows.sh related attributes to help with debugging and tracing. */
35
+ export type DataFlowsIdProps = {
36
+ 'data-flows-id'?: string;
37
+ };
27
38
  export {};
28
39
  //# sourceMappingURL=type_utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"type_utils.d.ts","sourceRoot":"","sources":["../src/type_utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,wBAAwB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAKrG,MAAM,MAAM,kBAAkB,CAAC,CAAC,IAAI;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,MAAM,IAAI,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC;CAAE,CAAC;AAEjF,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1E,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAElF;;;;GAIG;AAEH,4JAA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,sEAAsE;AACtE,MAAM,MAAM,gBAAgB,GAAG;IAAE,eAAe,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apify/ui-library",
3
- "version": "1.164.1",
3
+ "version": "1.164.3",
4
4
  "description": "React UI library used by apify.com",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -75,7 +75,7 @@
75
75
  "styled-components": "^6.1.19"
76
76
  },
77
77
  "devDependencies": {
78
- "@apify-packages/types": "^3.424.0",
78
+ "@apify-packages/types": "^3.425.0",
79
79
  "@storybook/react-vite": "^10.3.5",
80
80
  "@testing-library/react": "^16.3.2",
81
81
  "@types/hast": "^3.0.4",
@@ -95,5 +95,5 @@
95
95
  "src",
96
96
  "style"
97
97
  ],
98
- "gitHead": "a35af5ede0c200f2a17051a6a117ac74a5be2bbc"
98
+ "gitHead": "5b6f3b21ac0d6838bbcb3965fcdfe9c4b9b4d958"
99
99
  }
@@ -2,6 +2,7 @@ import * as DropdownMenu from '@radix-ui/react-dropdown-menu';
2
2
  import styled from 'styled-components';
3
3
 
4
4
  import { theme } from '../../design_system/theme';
5
+ import type { DataTestProps } from '../../type_utils';
5
6
  import { dropdownTestIds } from './dropdown.test_ids';
6
7
 
7
8
  export const DROPDOWN_ELEMENT_CLASSES = {
@@ -21,12 +22,12 @@ type StyledContentProps = {
21
22
  $zIndex?: number;
22
23
  };
23
24
 
24
- export const StyledContent = styled(DropdownMenu.Content).attrs<
25
- DropdownMenu.DropdownMenuContentProps & { 'data-test'?: string }
26
- >((props) => ({
27
- 'data-test': dropdownTestIds.WRAPPER,
28
- className: [DROPDOWN_ELEMENT_CLASSES.WRAPPER, props.className].filter(Boolean).join(' '),
29
- }))<StyledContentProps>`
25
+ export const StyledContent = styled(DropdownMenu.Content).attrs<DropdownMenu.DropdownMenuContentProps & DataTestProps>(
26
+ (props) => ({
27
+ 'data-test': dropdownTestIds.WRAPPER,
28
+ className: [DROPDOWN_ELEMENT_CLASSES.WRAPPER, props.className].filter(Boolean).join(' '),
29
+ }),
30
+ )<StyledContentProps>`
30
31
  background: ${theme.color.neutral.background};
31
32
  border: 1px solid ${theme.color.neutral.separatorSubtle};
32
33
  border-radius: ${theme.radius.radius12};
@@ -56,7 +56,8 @@ const sampleTabs = [
56
56
  { id: 'tab-2', title: 'Analytics', to: '#' },
57
57
  { id: 'tab-3', title: 'Settings', to: '#' },
58
58
  { id: 'tab-4', title: 'Users', to: '#' },
59
- { id: 'tab-5', title: 'Reports', to: '#' },
59
+ { id: 'tab-5', title: 'Disabled', to: '#', disabled: true, tooltip: 'Unavailable for this Actor.' },
60
+ { id: 'tab-6', title: 'Reports', to: '#' },
60
61
  ];
61
62
 
62
63
  export const TabVariants = (args: { Icon?: boolean; chip?: string; rollout?: 'alpha' | 'beta' | 'none' }) => {
@@ -6,11 +6,12 @@ import styled, { css } from 'styled-components';
6
6
  import type { IconComponent } from '@apify/ui-icons';
7
7
 
8
8
  import { theme } from '../../design_system/theme';
9
- import type { WithTransientProps } from '../../type_utils';
9
+ import type { DataFlowsIdProps, DataTestProps, WithTransientProps } from '../../type_utils';
10
10
  import type { FlattenSimpleInterpolation } from '../../utils/type_utils';
11
11
  import type { BadgeSize } from '../badge';
12
12
  import { Badge } from '../badge';
13
13
  import type { MarginSpacingProps, RegularBoxProps } from '../box';
14
+ import { Tooltip } from '../floating';
14
15
  import type { RegularLinkProps } from '../link';
15
16
  import { Link } from '../link';
16
17
  import type { SharedTextSize } from '../text';
@@ -23,14 +24,17 @@ type SharedTabProps = Omit<RegularBoxProps, 'as' | 'onClick'> &
23
24
 
24
25
  export type TabVariant = 'default' | 'boxed' | 'buttoned';
25
26
 
26
- export type TabData = SharedTabProps & {
27
- id: string;
28
- title: string;
29
- Icon?: IconComponent;
30
- chip?: number | string;
31
- rollout?: 'alpha' | 'beta';
32
- disabled?: boolean;
33
- };
27
+ export type TabData = SharedTabProps &
28
+ DataTestProps &
29
+ DataFlowsIdProps & {
30
+ id: string;
31
+ title: string;
32
+ Icon?: IconComponent;
33
+ chip?: number | string;
34
+ rollout?: 'alpha' | 'beta';
35
+ disabled?: boolean;
36
+ tooltip?: React.ReactNode;
37
+ };
34
38
 
35
39
  export type TabProps = TabData & {
36
40
  variant?: TabVariant;
@@ -195,40 +199,43 @@ export const Tab = ({
195
199
  onSelect,
196
200
  active = false,
197
201
  disabled = false,
202
+ tooltip,
198
203
  ...props
199
204
  }: TabProps) => {
200
205
  const href = typeof to === 'string' ? to : createPath(to);
201
206
  return (
202
- <TabWrapper
203
- data-test={tabTestIds.TAB}
204
- {...props}
205
- id={id}
206
- to={to}
207
- role="tab"
208
- data-test-url={href}
209
- className={clsx(className, { active, disabled })}
210
- onClick={onSelect ? (event) => onSelect({ id, href, event }) : undefined}
211
- $variant={variant}
212
- >
213
- {Icon && <Icon size="16" className={TAB_CLASSNAMES.ICON} />}
214
- <Text
215
- size={tabVariantTextSize[variant]}
216
- className={TAB_CLASSNAMES.TITLE}
217
- weight={active ? 'bold' : 'medium'}
218
- as="div"
207
+ <Tooltip content={tooltip}>
208
+ <TabWrapper
209
+ data-test={tabTestIds.TAB}
210
+ {...props}
211
+ id={id}
212
+ to={to}
213
+ role="tab"
214
+ data-test-url={href}
215
+ className={clsx(className, { active, disabled })}
216
+ onClick={onSelect ? (event) => onSelect({ id, href, event }) : undefined}
217
+ $variant={variant}
219
218
  >
220
- {title}
221
- </Text>
222
- {chip && (
223
- <Badge size={tabVariantBadgeSize[variant]} variant={active ? 'primary_black' : 'neutral_subtle'}>
224
- {chip}
225
- </Badge>
226
- )}
227
- {rollout && (
228
- <Badge size={tabVariantBadgeSize[variant]} variant="primary_blue">
229
- {rollout}
230
- </Badge>
231
- )}
232
- </TabWrapper>
219
+ {Icon && <Icon size="16" className={TAB_CLASSNAMES.ICON} />}
220
+ <Text
221
+ size={tabVariantTextSize[variant]}
222
+ className={TAB_CLASSNAMES.TITLE}
223
+ weight={active ? 'bold' : 'medium'}
224
+ as="div"
225
+ >
226
+ {title}
227
+ </Text>
228
+ {chip && (
229
+ <Badge size={tabVariantBadgeSize[variant]} variant={active ? 'primary_black' : 'neutral_subtle'}>
230
+ {chip}
231
+ </Badge>
232
+ )}
233
+ {rollout && (
234
+ <Badge size={tabVariantBadgeSize[variant]} variant="primary_blue">
235
+ {rollout}
236
+ </Badge>
237
+ )}
238
+ </TabWrapper>
239
+ </Tooltip>
233
240
  );
234
241
  };
package/src/type_utils.ts CHANGED
@@ -35,3 +35,12 @@ export type PolymorphicComponentPropsWithRef<
35
35
  E extends ElementType,
36
36
  OwnProps extends object = object,
37
37
  > = PolymorphicComponentProps<E, OwnProps> & { ref?: PolymorphicRef<E> };
38
+
39
+ /**
40
+ * Cross-cutting `data-*` attribute props for testing and debugging.
41
+ * These are optional, but `Required<DataTestProps>` can be used to enforce them.
42
+ */
43
+ export type DataTestProps = { 'data-test'?: string };
44
+
45
+ /** flows.sh related attributes to help with debugging and tracing. */
46
+ export type DataFlowsIdProps = { 'data-flows-id'?: string };
@@ -6,7 +6,12 @@
6
6
  */
7
7
  import { expectTypeOf } from 'vitest';
8
8
 
9
- import type { PolymorphicComponentProps, PolymorphicComponentPropsWithRef, PolymorphicRef } from './type_utils';
9
+ import type {
10
+ DataTestProps,
11
+ PolymorphicComponentProps,
12
+ PolymorphicComponentPropsWithRef,
13
+ PolymorphicRef,
14
+ } from './type_utils';
10
15
 
11
16
  type OwnProps = { variant?: 'a' | 'b' };
12
17
  type CustomClick = { onClick: (value: number) => void };
@@ -33,3 +38,10 @@ expectTypeOf<PolymorphicComponentProps<'div'>>().not.toHaveProperty('ref');
33
38
 
34
39
  // `PolymorphicRef` resolves to a concrete (non-`never`) ref type for a bound element.
35
40
  expectTypeOf<PolymorphicRef<'a'>>().not.toBeNever();
41
+
42
+ // `Required` turns the optional test id into a mandatory one.
43
+ expectTypeOf<Required<DataTestProps>>().toEqualTypeOf<{ 'data-test': string }>();
44
+
45
+ // They compose with native attribute typing rather than replacing it (`data-*` isn't in it).
46
+ expectTypeOf<PolymorphicComponentProps<'div', DataTestProps>>().toHaveProperty('data-test');
47
+ expectTypeOf<PolymorphicComponentProps<'div', DataTestProps>>().toHaveProperty('tabIndex');