@apify/ui-library 0.60.1 → 0.61.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.
Files changed (119) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/src/components/badge.d.ts +3 -3
  3. package/dist/src/components/badge.d.ts.map +1 -1
  4. package/dist/src/components/badge.js +32 -32
  5. package/dist/src/components/badge.js.map +1 -1
  6. package/dist/src/components/banner.d.ts.map +1 -1
  7. package/dist/src/components/banner.js +0 -2
  8. package/dist/src/components/banner.js.map +1 -1
  9. package/dist/src/components/button.d.ts +1 -1
  10. package/dist/src/components/button.d.ts.map +1 -1
  11. package/dist/src/components/button.js +1 -3
  12. package/dist/src/components/button.js.map +1 -1
  13. package/dist/src/components/code/code_block/code_block.d.ts +2 -2
  14. package/dist/src/components/code/code_block/code_block.d.ts.map +1 -1
  15. package/dist/src/components/code/code_block/code_block.js +2 -2
  16. package/dist/src/components/code/code_block/code_block.js.map +1 -1
  17. package/dist/src/components/code/one_line_code/one_line_code.js +1 -1
  18. package/dist/src/components/code/one_line_code/one_line_code.js.map +1 -1
  19. package/dist/src/components/code/syntax_highlighter.d.ts +2 -2
  20. package/dist/src/components/code/syntax_highlighter.d.ts.map +1 -1
  21. package/dist/src/components/code/syntax_highlighter.js +0 -1
  22. package/dist/src/components/code/syntax_highlighter.js.map +1 -1
  23. package/dist/src/components/floating/menu.js +2 -2
  24. package/dist/src/components/floating/menu.js.map +1 -1
  25. package/dist/src/components/floating/menu_common.js +1 -1
  26. package/dist/src/components/floating/menu_common.js.map +1 -1
  27. package/dist/src/components/floating/menu_components.d.ts +9 -5
  28. package/dist/src/components/floating/menu_components.d.ts.map +1 -1
  29. package/dist/src/components/floating/menu_components.js.map +1 -1
  30. package/dist/src/components/readme_renderer/index.d.ts +2 -2
  31. package/dist/src/components/readme_renderer/index.d.ts.map +1 -1
  32. package/dist/src/components/readme_renderer/index.js +2 -2
  33. package/dist/src/components/readme_renderer/index.js.map +1 -1
  34. package/dist/src/components/readme_renderer/pythonize_value.d.ts +1 -2
  35. package/dist/src/components/readme_renderer/pythonize_value.d.ts.map +1 -1
  36. package/dist/src/components/readme_renderer/pythonize_value.js +2 -3
  37. package/dist/src/components/readme_renderer/pythonize_value.js.map +1 -1
  38. package/dist/src/components/readme_renderer/table_of_contents.d.ts +1 -2
  39. package/dist/src/components/readme_renderer/table_of_contents.d.ts.map +1 -1
  40. package/dist/src/components/readme_renderer/table_of_contents.js +11 -9
  41. package/dist/src/components/readme_renderer/table_of_contents.js.map +1 -1
  42. package/dist/src/components/simple_markdown/simple_markdown.d.ts.map +1 -1
  43. package/dist/src/components/simple_markdown/simple_markdown.js +33 -33
  44. package/dist/src/components/simple_markdown/simple_markdown.js.map +1 -1
  45. package/dist/src/components/simple_markdown/simple_markdown_components.d.ts +1 -1
  46. package/dist/src/components/simple_markdown/simple_markdown_components.d.ts.map +1 -1
  47. package/dist/src/components/simple_markdown/simple_markdown_components.js +11 -13
  48. package/dist/src/components/simple_markdown/simple_markdown_components.js.map +1 -1
  49. package/dist/src/components/tag.d.ts +2 -2
  50. package/dist/src/components/tag.d.ts.map +1 -1
  51. package/dist/src/components/tag.js +1 -2
  52. package/dist/src/components/tag.js.map +1 -1
  53. package/dist/src/components/text/heading_content.js +0 -1
  54. package/dist/src/components/text/heading_content.js.map +1 -1
  55. package/dist/src/components/text/heading_marketing.js +0 -1
  56. package/dist/src/components/text/heading_marketing.js.map +1 -1
  57. package/dist/src/components/text/heading_shared.d.ts +2 -2
  58. package/dist/src/components/text/heading_shared.d.ts.map +1 -1
  59. package/dist/src/components/text/heading_shared.js +1 -3
  60. package/dist/src/components/text/heading_shared.js.map +1 -1
  61. package/dist/src/components/text/index.d.ts +2 -2
  62. package/dist/src/components/text/index.d.ts.map +1 -1
  63. package/dist/src/components/text/index.js +2 -2
  64. package/dist/src/components/text/index.js.map +1 -1
  65. package/dist/src/components/text/text_base.js +0 -1
  66. package/dist/src/components/text/text_base.js.map +1 -1
  67. package/dist/src/components/text/text_content.js +0 -1
  68. package/dist/src/components/text/text_content.js.map +1 -1
  69. package/dist/src/components/text/text_marketing.js +0 -1
  70. package/dist/src/components/text/text_marketing.js.map +1 -1
  71. package/dist/src/components/text/text_shared.d.ts +1 -2
  72. package/dist/src/components/text/text_shared.d.ts.map +1 -1
  73. package/dist/src/components/text/text_shared.js +1 -4
  74. package/dist/src/components/text/text_shared.js.map +1 -1
  75. package/dist/src/components/to_consolidate/card.js +0 -2
  76. package/dist/src/components/to_consolidate/card.js.map +1 -1
  77. package/dist/src/components/to_consolidate/markdown.d.ts.map +1 -1
  78. package/dist/src/components/to_consolidate/markdown.js +2 -1
  79. package/dist/src/components/to_consolidate/markdown.js.map +1 -1
  80. package/dist/src/design_system/theme.js +1 -1
  81. package/dist/src/design_system/theme.js.map +1 -1
  82. package/dist/src/design_system/tokens/spaces.d.ts +1 -1
  83. package/dist/src/design_system/tokens/spaces.d.ts.map +1 -1
  84. package/dist/src/design_system/tokens/spaces.js.map +1 -1
  85. package/dist/tsconfig.build.tsbuildinfo +1 -1
  86. package/eslint.config.mjs +36 -0
  87. package/package.json +9 -10
  88. package/src/codemods/generate_color_property_tokens.mjs +2 -1
  89. package/src/codemods/generate_color_theme_files.mjs +2 -1
  90. package/src/codemods/generate_typograpy_tokens_files.mjs +2 -1
  91. package/src/components/badge.tsx +47 -47
  92. package/src/components/banner.tsx +1 -2
  93. package/src/components/button.tsx +4 -4
  94. package/src/components/code/code_block/code_block.tsx +22 -22
  95. package/src/components/code/one_line_code/one_line_code.tsx +1 -1
  96. package/src/components/code/syntax_highlighter.tsx +3 -5
  97. package/src/components/floating/menu.tsx +8 -8
  98. package/src/components/floating/menu_common.tsx +2 -2
  99. package/src/components/floating/menu_components.tsx +7 -2
  100. package/src/components/readme_renderer/index.ts +2 -2
  101. package/src/components/readme_renderer/pythonize_value.ts +2 -4
  102. package/src/components/readme_renderer/table_of_contents.tsx +26 -11
  103. package/src/components/simple_markdown/simple_markdown.tsx +36 -36
  104. package/src/components/simple_markdown/simple_markdown_components.tsx +26 -28
  105. package/src/components/tag.tsx +29 -28
  106. package/src/components/text/heading_content.tsx +1 -1
  107. package/src/components/text/heading_marketing.tsx +1 -1
  108. package/src/components/text/heading_shared.tsx +2 -4
  109. package/src/components/text/index.ts +2 -2
  110. package/src/components/text/text_base.tsx +1 -1
  111. package/src/components/text/text_content.tsx +1 -1
  112. package/src/components/text/text_marketing.tsx +1 -1
  113. package/src/components/text/text_shared.tsx +2 -5
  114. package/src/components/to_consolidate/card.tsx +2 -2
  115. package/src/components/to_consolidate/markdown.tsx +2 -1
  116. package/src/design_system/generate_color_definitions.js +4 -3
  117. package/src/design_system/theme.ts +4 -4
  118. package/src/design_system/tokens/spaces.ts +2 -2
  119. package/.eslintrc +0 -41
@@ -0,0 +1,36 @@
1
+ import react from 'eslint-plugin-react';
2
+ import reactHooks from 'eslint-plugin-react-hooks';
3
+ import sonarjs from 'eslint-plugin-sonarjs';
4
+
5
+ import apifyJestConfig from '@apify/eslint-config/jest.js';
6
+ import apifyTypescriptConfig from '@apify/eslint-config/ts.js';
7
+
8
+ // eslint-disable-next-line import/no-default-export
9
+ export default [
10
+ { ignores: ['**/dist'] }, // Ignores need to happen first
11
+ ...apifyTypescriptConfig,
12
+ ...apifyJestConfig,
13
+ {
14
+
15
+ plugins: {
16
+ sonarjs,
17
+ react,
18
+ 'react-hooks': reactHooks,
19
+ },
20
+
21
+ languageOptions: {
22
+ sourceType: 'module',
23
+
24
+ parserOptions: {
25
+ projectService: true,
26
+ tsconfigRootDir: import.meta.dirname,
27
+ },
28
+ },
29
+ rules: {
30
+ 'react/react-in-jsx-scope': 'off',
31
+ 'no-void': 'off',
32
+ 'react/display-name': 'off',
33
+ 'react-hooks/exhaustive-deps': 'error',
34
+ },
35
+ },
36
+ ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apify/ui-library",
3
- "version": "0.60.1",
3
+ "version": "0.61.0",
4
4
  "description": "React UI library used by apify.com",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -12,8 +12,8 @@
12
12
  },
13
13
  "scripts": {
14
14
  "test": "echo \"Warning: no test specified\" && exit 0",
15
- "lint": "eslint . --ext .ts,.tsx",
16
- "lint:fix": "eslint . --ext .ts,.tsx --fix",
15
+ "lint": "eslint .",
16
+ "lint:fix": "eslint . --fix",
17
17
  "build": "npm run clean && npm run compile",
18
18
  "clean": "rimraf ./dist",
19
19
  "compile": "tsc -p tsconfig.build.json",
@@ -27,7 +27,7 @@
27
27
  ],
28
28
  "dependencies": {
29
29
  "@apify/log": "^2.5.11",
30
- "@apify/ui-icons": "^0.6.0",
30
+ "@apify/ui-icons": "^0.7.0",
31
31
  "@floating-ui/react": "^0.26.2",
32
32
  "clsx": "^2.0.0",
33
33
  "dayjs": "1.11.9",
@@ -51,21 +51,20 @@
51
51
  "styled-components": "^5.3.3"
52
52
  },
53
53
  "devDependencies": {
54
- "@apify/eslint-config-ts": "^0.4.1",
54
+ "@apify/eslint-config": "^1.0.0",
55
55
  "@types/lodash": "^4.14.200",
56
56
  "@types/node": "^22.10.5",
57
57
  "@types/react": "^18.2.74",
58
58
  "@types/react-syntax-highlighter": "^15.5.9",
59
59
  "@types/styled-components": "^5.1.34",
60
- "@typescript-eslint/eslint-plugin": "^5.62.0",
61
- "@typescript-eslint/parser": "^5.62.0",
62
- "eslint": "^8.45.0",
60
+ "eslint": "^9.22.0",
63
61
  "eslint-plugin-import": "2.26.0",
64
62
  "eslint-plugin-react": "^7.32.2",
65
63
  "eslint-plugin-react-hooks": "^4.6.0",
66
64
  "eslint-plugin-sonarjs": "^1.0.3",
67
65
  "recast": "^0.23.9",
68
- "typescript": "^5.1.6"
66
+ "typescript": "^5.1.6",
67
+ "typescript-eslint": "^8.24.0"
69
68
  },
70
- "gitHead": "dfdbb5bda58c1888fb240f6e163f4785b73fa39f"
69
+ "gitHead": "6550fb6340288c759acf80f9c07fa68aec85f094"
71
70
  }
@@ -1,5 +1,6 @@
1
- import { readFileSync, writeFileSync } from 'fs';
1
+ import { readFileSync, writeFileSync } from 'node:fs';
2
2
 
3
+ // eslint-disable-next-line import/no-extraneous-dependencies
3
4
  import { print, types } from 'recast';
4
5
 
5
6
  const { builders } = types;
@@ -1,5 +1,6 @@
1
- import { readFileSync, writeFileSync } from 'fs';
1
+ import { readFileSync, writeFileSync } from 'node:fs';
2
2
 
3
+ // eslint-disable-next-line import/no-extraneous-dependencies
3
4
  import { print, types } from 'recast';
4
5
 
5
6
  const { builders } = types;
@@ -1,5 +1,6 @@
1
- import { readFileSync, writeFileSync } from 'fs';
1
+ import { readFileSync, writeFileSync } from 'node:fs';
2
2
 
3
+ // eslint-disable-next-line import/no-extraneous-dependencies
3
4
  import { print, types } from 'recast';
4
5
 
5
6
  const { builders } = types;
@@ -5,17 +5,29 @@ import type { IconComponent, IconSize } from '@apify/ui-icons';
5
5
 
6
6
  import { theme } from '../design_system/theme.js';
7
7
  import type { WithTransientProps } from '../type_utils.js';
8
- import { type RegularBoxProps, type MarginSpacingProps, Box } from './box.js';
9
-
10
- type BadgeSize = typeof BADGE_SIZES[number];
8
+ import { Box, type MarginSpacingProps, type RegularBoxProps } from './box.js';
11
9
 
12
10
  export const BADGE_SIZES = ['medium', 'small'] as const;
13
11
 
12
+ type BadgeSize = typeof BADGE_SIZES[number];
13
+
14
14
  const BADGE_ICON_SIZES = {
15
15
  medium: '16',
16
16
  small: '12',
17
17
  } satisfies Record<BadgeSize, IconSize>;
18
18
 
19
+ export const BADGE_VARIANTS = ['neutral', 'neutral_muted', 'neutral_subtle', 'primary_black', 'primary_blue', 'success', 'warning', 'danger'] as const;
20
+
21
+ type BadgeVariant = typeof BADGE_VARIANTS[number];
22
+
23
+ export type BadgeProps = Omit<RegularBoxProps, 'onClick'> & MarginSpacingProps & {
24
+ as?: Exclude<React.ElementType, 'a' | 'button'>;
25
+ size?: BadgeSize;
26
+ variant?: BadgeVariant;
27
+ LeadingIcon?: IconComponent;
28
+ code?: boolean;
29
+ };
30
+
19
31
  const badgeSizeStyle = {
20
32
  medium: ($code) => css`
21
33
  padding: ${theme.space.space4} ${theme.space.space8};
@@ -36,82 +48,70 @@ const badgeSizeStyle = {
36
48
  `,
37
49
  } satisfies Record<BadgeSize, (code: boolean) => FlattenSimpleInterpolation>;
38
50
 
39
- type BadgeVariant = typeof BADGE_VARIANTS[number];
40
-
41
- export const BADGE_VARIANTS = ['neutral', 'neutral_muted', 'neutral_subtle', 'primary_black', 'primary_blue', 'success', 'warning', 'danger'] as const;
42
-
43
51
  const badgeVariantStyle = {
44
52
  neutral: css`
45
53
  color: ${theme.color.neutral.text};
46
54
  fill: ${theme.color.neutral.text};
47
55
  background: ${theme.color.neutral.background};
48
56
  box-shadow: inset 0 0 0 1px ${theme.color.neutral.border};
49
- `,
57
+ `,
50
58
  neutral_muted: css`
51
- color: ${theme.color.neutral.text};
52
- fill: ${theme.color.neutral.text};
53
- background: ${theme.color.neutral.chipBackground};
59
+ color: ${theme.color.neutral.text};
60
+ fill: ${theme.color.neutral.text};
61
+ background: ${theme.color.neutral.chipBackground};
54
62
  `,
55
63
  neutral_subtle: css`
56
- color: ${theme.color.neutral.textSubtle};
57
- fill: ${theme.color.neutral.textSubtle};
58
- background: ${theme.color.neutral.backgroundSubtle};
64
+ color: ${theme.color.neutral.textSubtle};
65
+ fill: ${theme.color.neutral.textSubtle};
66
+ background: ${theme.color.neutral.backgroundSubtle};
59
67
  `,
60
68
  primary_black: css`
61
69
  color: ${theme.color.primaryBlack.chipText};
62
70
  fill: ${theme.color.primaryBlack.chipText};
63
71
  background: ${theme.color.primaryBlack.background};
64
- `,
72
+ `,
65
73
  primary_blue: css`
66
- color: ${theme.color.primary.chipText};
67
- fill: ${theme.color.primaryBlack.chipText};
68
- background: ${theme.color.primary.background};
74
+ color: ${theme.color.primary.chipText};
75
+ fill: ${theme.color.primaryBlack.chipText};
76
+ background: ${theme.color.primary.background};
69
77
  `,
70
78
  success: css`
71
- color: ${theme.color.success.chipText};
72
- fill: ${theme.color.success.chipText};
73
- background: ${theme.color.success.background};
79
+ color: ${theme.color.success.chipText};
80
+ fill: ${theme.color.success.chipText};
81
+ background: ${theme.color.success.background};
74
82
  `,
75
83
  warning: css`
76
- color: ${theme.color.warning.chipText};
77
- fill: ${theme.color.warning.chipText};
78
- background: ${theme.color.warning.background};
84
+ color: ${theme.color.warning.chipText};
85
+ fill: ${theme.color.warning.chipText};
86
+ background: ${theme.color.warning.background};
79
87
  `,
80
88
  danger: css`
81
- color: ${theme.color.danger.chipText};
82
- fill: ${theme.color.danger.chipText};
83
- background: ${theme.color.danger.background};
89
+ color: ${theme.color.danger.chipText};
90
+ fill: ${theme.color.danger.chipText};
91
+ background: ${theme.color.danger.background};
84
92
  `,
85
93
  } satisfies Record<BadgeVariant, FlattenSimpleInterpolation>;
86
94
 
87
95
  type StyledBadgeProps = WithTransientProps<
88
- Required<Pick<BadgeProps, 'size' | 'variant' | 'code'>>
96
+ Required<Pick<BadgeProps, 'size' | 'variant' | 'code'>>
89
97
  >;
90
98
 
91
99
  const StyledBadge = styled(Box)<StyledBadgeProps>`
92
- ${({ $size, $code }) => badgeSizeStyle[$size]($code)};
93
- ${({ $variant }) => badgeVariantStyle[$variant]};
100
+ ${({ $size, $code }) => badgeSizeStyle[$size]($code)};
101
+ ${({ $variant }) => badgeVariantStyle[$variant]};
94
102
 
95
103
  /* Static styles */
96
- width: fit-content;
97
- border: none;
98
- outline: none;
99
- display: flex;
100
- flex-direction: row;
101
- justify-content: center;
102
- align-items: center;
103
- white-space: nowrap;
104
- gap: ${theme.space.space4};
104
+ width: fit-content;
105
+ border: none;
106
+ outline: none;
107
+ display: flex;
108
+ flex-direction: row;
109
+ justify-content: center;
110
+ align-items: center;
111
+ white-space: nowrap;
112
+ gap: ${theme.space.space4};
105
113
  `;
106
114
 
107
- export type BadgeProps = Omit<RegularBoxProps, 'onClick'> & MarginSpacingProps & {
108
- as?: Exclude<React.ElementType, 'a' | 'button'>;
109
- size?: BadgeSize;
110
- variant?: BadgeVariant;
111
- LeadingIcon?: IconComponent;
112
- code?: boolean;
113
- };
114
-
115
115
  /**
116
116
  * Component for displaying non-interactive chip descendant.
117
117
  */
@@ -3,7 +3,6 @@ import styled, { css } from 'styled-components';
3
3
 
4
4
  import { theme } from '../design_system/theme.js';
5
5
 
6
- /* eslint-disable max-len */
7
6
  const BANNER_GRADIENT_BACKGROUND_SVG = `<svg width="1200" height="148" viewBox="0 0 1200 148" fill="none" xmlns="http://www.w3.org/2000/svg">
8
7
  <g clip-path="url(#clip0_2285_34756)">
9
8
  <g filter="url(#filter0_f_2285_34756)">
@@ -57,7 +56,7 @@ interface BannerProps {
57
56
  width?: string,
58
57
  className?: string,
59
58
  children: React.ReactNode,
60
- };
59
+ }
61
60
 
62
61
  const getBannerBackground = (background?: string, useGradientBackground?: boolean) => {
63
62
  return css`
@@ -6,8 +6,8 @@ import { ExternalLinkIcon } from '@apify/ui-icons';
6
6
  import { theme } from '../design_system/theme.js';
7
7
  import { type WithRequired, type WithTransientProps } from '../type_utils.js';
8
8
  import { useSharedUiDependencies } from '../ui_dependency_provider.js';
9
- import { Box, type RegularBoxProps, type MarginSpacingProps } from './box.js';
10
- import { Link, isUrlExternal, type LinkProps } from './link.js';
9
+ import { Box, type MarginSpacingProps, type RegularBoxProps } from './box.js';
10
+ import { isUrlExternal, Link, type LinkProps } from './link.js';
11
11
 
12
12
  type ButtonSize = 'medium' | 'small';
13
13
  type ButtonColor = 'default' | 'success' | 'danger';
@@ -17,7 +17,7 @@ export interface TransientButtonProps {
17
17
  size?: ButtonSize;
18
18
  color?: ButtonColor;
19
19
  variant?: ButtonVariant;
20
- };
20
+ }
21
21
 
22
22
  export interface RegularButtonProps {
23
23
  trackingId?: string,
@@ -25,7 +25,7 @@ export interface RegularButtonProps {
25
25
  LeftIcon?: React.ElementType,
26
26
  RightIcon?: React.ElementType,
27
27
  disabled?: boolean;
28
- };
28
+ }
29
29
 
30
30
  // Props shared for both types of the button
31
31
  export type CommonButtonProps = RegularButtonProps & TransientButtonProps & MarginSpacingProps;
@@ -7,10 +7,31 @@ import { Link } from '../../link.js';
7
7
  import { Text } from '../../text/index.js';
8
8
  import type { SharedTextSize } from '../../text/text_shared.js';
9
9
  import { ActionButton, CopyButton } from '../action_button.js';
10
- import SyntaxHighlighter from '../syntax_highlighter.js';
10
+ import { SyntaxHighlighter } from '../syntax_highlighter.js';
11
11
  import { CodeBlockWrapper } from './code_block.styled.js';
12
12
  import { mapPrefixToBashLine } from './utils.js';
13
13
 
14
+ type CodeTab = {
15
+ key: string;
16
+ label: string;
17
+ code: string;
18
+ id?: string;
19
+ highlightLines?: number[];
20
+ language?: string;
21
+ bashCommandsStart?: number[];
22
+ to?: string;
23
+ }
24
+
25
+ type HeaderProps = {
26
+ tabs: CodeTab[] | null;
27
+ currentTab: CodeTab | null;
28
+ onTabChange: (tab: CodeTab, e: React.MouseEvent) => void;
29
+ title?: string;
30
+ showBashHeader?: boolean;
31
+ }
32
+
33
+ const LANGUAGES_WITHOUT_LINE_NUMBERS = ['json', 'jsonp', 'jsonp', 'rss', 'yaml', 'xml', 'html', 'bash', 'text', 'dockerfile', 'http'];
34
+
14
35
  function HeaderDots() {
15
36
  return (
16
37
  <div className="CodeBlock-HederDotsWrapper">
@@ -21,14 +42,6 @@ function HeaderDots() {
21
42
  );
22
43
  }
23
44
 
24
- interface HeaderProps {
25
- tabs: CodeTab[] | null;
26
- currentTab: CodeTab | null;
27
- onTabChange: (tab: CodeTab, e: React.MouseEvent) => void;
28
- title?: string;
29
- showBashHeader?: boolean;
30
- }
31
-
32
45
  function Header({
33
46
  tabs,
34
47
  currentTab,
@@ -76,19 +89,6 @@ function Header({
76
89
  );
77
90
  }
78
91
 
79
- const LANGUAGES_WITHOUT_LINE_NUMBERS = ['json', 'jsonp', 'jsonp', 'rss', 'yaml', 'xml', 'html', 'bash', 'text', 'dockerfile', 'http'];
80
-
81
- interface CodeTab {
82
- key: string;
83
- label: string;
84
- code: string;
85
- id?: string;
86
- highlightLines?: number[];
87
- language?: string;
88
- bashCommandsStart?: number[];
89
- to?: string;
90
- }
91
-
92
92
  type CodeBlockProps = RegularBoxProps & {
93
93
  content: string | CodeTab[]; // TODO: Try to make it work with children props
94
94
  size?: SharedTextSize;
@@ -8,8 +8,8 @@ import type { BoxProps } from '../../box.js';
8
8
  import { Text } from '../../text/index.js';
9
9
  import type { SharedTextSize } from '../../text/text_shared.js';
10
10
  import { ActionButton, CopyButton } from '../action_button.js';
11
- import SyntaxHighlighter, { SyntaxHighlighterBaseStylesWrapper } from '../syntax_highlighter.js';
12
11
  import type { SyntaxHighlighterBaseStylesWrapperProps } from '../syntax_highlighter.js';
12
+ import { SyntaxHighlighter, SyntaxHighlighterBaseStylesWrapper } from '../syntax_highlighter.js';
13
13
 
14
14
  export const oneLineCodeClassNames = {
15
15
  gradientWrapper: 'OneLineCode-GradientWrapper',
@@ -34,7 +34,7 @@ import styled, { css } from 'styled-components';
34
34
  import { theme } from '../../design_system/theme.js';
35
35
  import { useSharedUiDependencies } from '../../ui_dependency_provider.js';
36
36
  import { Box } from '../box.js';
37
- import { Text, type SharedTextProps } from '../text/index.js';
37
+ import { type SharedTextProps, Text } from '../text/index.js';
38
38
  import type { SharedTextSize } from '../text/text_shared.js';
39
39
 
40
40
  ReactSyntaxHighlighter.registerLanguage('typescript', ts);
@@ -96,7 +96,7 @@ export const SyntaxHighlighter = forwardRef<HTMLPreElement, SyntaxHighlighterPro
96
96
  }, ref) => {
97
97
  const { uiTheme } = useSharedUiDependencies();
98
98
 
99
- const PreTag = (preProps: any) => {
99
+ const PreTag = (preProps: ReactSyntaxHighlighterProps) => {
100
100
  return <StyledPre {...preProps} size={size} forwardedAs='pre' type='code' ref={ref}/>;
101
101
  };
102
102
 
@@ -116,7 +116,7 @@ export const SyntaxHighlighter = forwardRef<HTMLPreElement, SyntaxHighlighterPro
116
116
  export type SyntaxHighlighterBaseStylesWrapperProps = SharedTextProps & {
117
117
  $fullWidth?: boolean;
118
118
  $fullHeight?: string;
119
- $showLineNumbers?: any;
119
+ $showLineNumbers?: boolean;
120
120
  }
121
121
 
122
122
  export const SyntaxHighlighterBaseStylesWrapper = styled(Box)<SyntaxHighlighterBaseStylesWrapperProps>`
@@ -132,5 +132,3 @@ export const SyntaxHighlighterBaseStylesWrapper = styled(Box)<SyntaxHighlighterB
132
132
  background-color: transparent;
133
133
  position: relative;
134
134
  `;
135
-
136
- export default SyntaxHighlighter;
@@ -1,18 +1,18 @@
1
1
  import {
2
- useRole,
3
- useListNavigation,
4
- useTypeahead,
2
+ FloatingFocusManager,
3
+ FloatingPortal,
5
4
  useClick,
6
5
  useDismiss,
7
6
  useInteractions,
8
- FloatingPortal,
9
- FloatingFocusManager,
7
+ useListNavigation,
8
+ useRole,
9
+ useTypeahead,
10
10
  } from '@floating-ui/react';
11
11
  import clsx from 'clsx';
12
12
  import React, {
13
- useState,
14
- useRef,
15
13
  useMemo,
14
+ useRef,
15
+ useState,
16
16
  } from 'react';
17
17
 
18
18
  import {
@@ -91,7 +91,7 @@ export const Menu = <T extends MenuOption>({
91
91
  if (closeOnSelect) setIsOpen(false);
92
92
  };
93
93
 
94
- const listRef = useRef<Array<HTMLElement | null>>([]);
94
+ const listRef = useRef<(HTMLElement | null)[]>([]);
95
95
  const isTypingRef = useRef(false);
96
96
  const listContentRef = useRef(options.map((option) => option.label));
97
97
 
@@ -1,8 +1,8 @@
1
1
  import {
2
- useFloating,
2
+ autoUpdate,
3
3
  offset,
4
4
  size,
5
- autoUpdate,
5
+ useFloating,
6
6
  } from '@floating-ui/react';
7
7
 
8
8
  export const useFloatingMenu = ({
@@ -1,6 +1,6 @@
1
1
  import {
2
- type UseFloatingReturn,
3
2
  type ReferenceType,
3
+ type UseFloatingReturn,
4
4
  } from '@floating-ui/react';
5
5
  import { forwardRef } from 'react';
6
6
  import styled, { css } from 'styled-components';
@@ -8,6 +8,7 @@ import styled, { css } from 'styled-components';
8
8
  import { ChevronDownIcon } from '@apify/ui-icons';
9
9
 
10
10
  import { theme } from '../../design_system/theme.js';
11
+ import type { BoxProps } from '../box.js';
11
12
  import { Box } from '../box.js';
12
13
 
13
14
  export type FloatingContext = Pick<UseFloatingReturn<ReferenceType>, 'context'>['context'];
@@ -78,10 +79,14 @@ export const PlainMenuBaseComponent = styled(Box)`
78
79
  }
79
80
  `;
80
81
 
82
+ type DropdownMenuBaseComponentProps = {
83
+ children: React.ReactNode;
84
+ } & BoxProps;
85
+
81
86
  /**
82
87
  * Menu base component WITH dropdown icon
83
88
  */
84
- export const DropdownMenuBaseComponent = forwardRef<HTMLElement, any>(({
89
+ export const DropdownMenuBaseComponent = forwardRef<HTMLElement, DropdownMenuBaseComponentProps>(({
85
90
  children,
86
91
  ...props
87
92
  }, ref) => {
@@ -1,3 +1,3 @@
1
1
  export { useActorTitleHeadingFilter } from './utils.js';
2
- export { default as pythonizeValue } from './pythonize_value.js';
3
- export { default as TableOfContents } from './table_of_contents.js';
2
+ export { pythonizeValue } from './pythonize_value.js';
3
+ export { TableOfContents } from './table_of_contents.js';
@@ -22,7 +22,7 @@ const escapeChar = (character: string) => {
22
22
  // Escapes special characters in a string and surrounds it with proper quotes
23
23
  const pythonQuoteString = (str: string, escapeNewlines = true) => {
24
24
  const escapedValue = str.replace(/[\x00-\x09\x0b-\x1f\x22\x5c]/g, escapeChar);
25
- if (!escapeNewlines && /\n/.test(escapedValue)) {
25
+ if (!escapeNewlines && escapedValue.includes('\n')) {
26
26
  return '"""' + escapedValue + '"""';
27
27
  }
28
28
  return '"' + escapedValue.replace(/\n/g, '\\n') + '"';
@@ -34,7 +34,7 @@ const INDENT = ' ';
34
34
  // Doesn't support everything, because that would be impossible,
35
35
  // only the values which are supported in an input schema prefill (booleans, numbers, strings, arrays, objects)
36
36
  // Tries to keep the representation short, but readable.
37
- const pythonizeValue = <T>(value: T, depth = 0): string | T => {
37
+ export const pythonizeValue = <T>(value: T, depth = 0): string | T => {
38
38
  // None-like values
39
39
  if (value === undefined) return 'None';
40
40
  if (value === null) return 'None';
@@ -74,5 +74,3 @@ const pythonizeValue = <T>(value: T, depth = 0): string | T => {
74
74
  // This should never happen, if it did, something went wrong
75
75
  return 'UNSUPPORTED VALUE';
76
76
  };
77
-
78
- export default pythonizeValue;
@@ -1,7 +1,7 @@
1
1
  import _ from 'lodash';
2
2
  import React, {
3
- useMemo,
4
3
  useCallback,
4
+ useMemo,
5
5
  } from 'react';
6
6
  import ReactMarkdown from 'react-markdown';
7
7
  import type { AllowElement } from 'react-markdown/lib/rehype-filter';
@@ -87,10 +87,11 @@ interface CustomHTMLAnchorElement extends Omit<HTMLAnchorElement, 'children' | '
87
87
  hash: string;
88
88
  tagName: string;
89
89
  type: string;
90
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
90
91
  parentNode: any;
91
92
  }
92
93
 
93
- const handleScroll = (anchors: CustomHTMLAnchorElement[] | null, headlines: HTMLElement[], anchorLists: HTMLUListElement[] | null, headingOffsetPx: number) => {
94
+ const handleScroll = (anchors: CustomHTMLAnchorElement[], headlines: HTMLElement[], anchorLists: HTMLUListElement[] | null, headingOffsetPx: number) => {
94
95
  if (!anchors || !headlines) return;
95
96
 
96
97
  // Items that are past scroll
@@ -132,17 +133,31 @@ const handleScroll = (anchors: CustomHTMLAnchorElement[] | null, headlines: HTML
132
133
  }
133
134
  };
134
135
 
135
- const assignHeadingLevelsRecursively = ({ children, tagName, properties }: any, level: number) => {
136
+ const assignHeadingLevelsRecursively = (
137
+ {
138
+ children,
139
+ tagName,
140
+ properties,
141
+ }: {
142
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
143
+ children: any[],
144
+ tagName: string,
145
+ properties: { className: string }
146
+ },
147
+ level: number,
148
+ ) => {
136
149
  if (level > 3) return;
150
+ let currentLevel = level;
137
151
  if (tagName === 'ul') {
138
- properties.className = `level-${level}`; // assign level className
139
- level += 1; // increase current heading level;
152
+ // eslint-disable-next-line no-param-reassign
153
+ properties.className = `level-${currentLevel}`; // assign level className
154
+ currentLevel += 1; // increase current heading level;
140
155
  }
141
156
 
142
- children?.forEach((child: { type: string }) => {
157
+ children?.forEach((child) => {
143
158
  // We only care about ul and li elements - we don't need to traverse any other
144
159
  if (child.type === 'element' && (tagName === 'ul' || tagName === 'li')) {
145
- assignHeadingLevelsRecursively(child, level);
160
+ assignHeadingLevelsRecursively(child, currentLevel);
146
161
  }
147
162
  });
148
163
  };
@@ -154,7 +169,7 @@ export interface TableOfContentsProps {
154
169
  allowElement?: AllowElement;
155
170
  }
156
171
 
157
- const TableOfContents = ({
172
+ const TableOfContentsComponent = ({
158
173
  markdown,
159
174
  headingOffsetPx = 10,
160
175
  allowElement,
@@ -168,9 +183,9 @@ const TableOfContents = ({
168
183
  const hasTopLevelHeading = useMemo(() => !!cleanedMarkdown.match(/^#\s.+$/m), [cleanedMarkdown]);
169
184
 
170
185
  const tocRef = useCallback((node: HTMLElement | null) => {
171
- const anchors = node ? Array.from(node.querySelectorAll('a')) : null;
186
+ const anchors = node ? Array.from(node.querySelectorAll('a')) : [];
172
187
  const anchorLists = node ? Array.from(node.querySelectorAll('ul')) : null;
173
- const headlines = (anchors || [])
188
+ const headlines = (anchors)
174
189
  .map((anchor) => document.getElementById(anchor.hash.substr(1)))
175
190
  .filter((headline) => headline !== undefined && headline !== null) as HTMLElement[];
176
191
 
@@ -254,4 +269,4 @@ const TableOfContents = ({
254
269
  );
255
270
  };
256
271
 
257
- export default React.memo(TableOfContents, (prevProps, nextProps) => _.isEqual(prevProps, nextProps));
272
+ export const TableOfContents = React.memo(TableOfContentsComponent, (prevProps, nextProps) => _.isEqual(prevProps, nextProps));