@apify/ui-library 0.74.2-featCodeBlockWithTabsoptimis-e30911.3 → 0.75.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apify/ui-library",
3
- "version": "0.74.2-featCodeBlockWithTabsoptimis-e30911.3+cef0941ab85",
3
+ "version": "0.75.0",
4
4
  "description": "React UI library used by apify.com",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -66,5 +66,5 @@
66
66
  "typescript": "^5.1.6",
67
67
  "typescript-eslint": "^8.24.0"
68
68
  },
69
- "gitHead": "cef0941ab85d9a8d282c8e4e7fee14500fb39fe9"
69
+ "gitHead": "a4c4ceee13ae2580b5fc2257759fc60eadf010c9"
70
70
  }
@@ -74,8 +74,6 @@ type CodeBlockWithTabsProps = SharedBoxProps & {
74
74
  codeBlockProps: SharedCodeBlockProps;
75
75
  currentTabKey: CodeBlockTabKey;
76
76
  tabs: CodeBlockTabProps[];
77
- // Optional prop to set the selected tab, does not influence the content of the code block, used to improve interactivity
78
- optimisticCurrentTabKey?: CodeBlockTabKey;
79
77
  };
80
78
 
81
79
  export const CODE_BLOCK_WITH_TABS_CLASSNAMES = {
@@ -192,7 +190,7 @@ const IMG_RESIZE = {
192
190
  height: 20,
193
191
  };
194
192
 
195
- export const CodeBlockWithTabs = ({ className, codeBlockProps, currentTabKey, tabs, optimisticCurrentTabKey, ...props }: CodeBlockWithTabsProps) => {
193
+ export const CodeBlockWithTabs = ({ className, codeBlockProps, currentTabKey, tabs, ...props }: CodeBlockWithTabsProps) => {
196
194
  const { generateProxyImageUrl } = useSharedUiDependencies();
197
195
  const currentTab = tabs.find((tab) => tab.key === currentTabKey) ?? tabs[0];
198
196
 
@@ -201,7 +199,7 @@ export const CodeBlockWithTabs = ({ className, codeBlockProps, currentTabKey, ta
201
199
  <div className={CODE_BLOCK_WITH_TABS_CLASSNAMES.TABS}>
202
200
  {tabs.map((tab) => {
203
201
  const { label, src } = CODE_BLOCK_TAB_CATALOG[tab.key];
204
- const selected = (optimisticCurrentTabKey ?? currentTabKey) === tab.key;
202
+ const selected = tab.key === currentTab?.key;
205
203
 
206
204
  const commonProps = {
207
205
  className: clsx(CODE_BLOCK_WITH_TABS_CLASSNAMES.TAB, { selected }),
@@ -1,3 +1,3 @@
1
1
  export { useActorTitleHeadingFilter } from './utils.js';
2
2
  export { pythonizeValue } from './pythonize_value.js';
3
- export { TableOfContents } from './table_of_contents.js';
3
+ export { TableOfContents, useShowTableOfContents } from './table_of_contents.js';
@@ -14,6 +14,8 @@ import { Link } from '../link.js';
14
14
  import { Text } from '../text/index.js';
15
15
  import { cleanMarkdown, slugifyHeadingChildren } from './utils.js';
16
16
 
17
+ export const useShowTableOfContents = (markdown: string | null | undefined) => useMemo(() => markdown && !!markdown.match(/^(#{1,3})\s.+$/m), [markdown]);
18
+
17
19
  const TOC_HEADING_ID = 'Contents';
18
20
 
19
21
  const StyledTOCLink = styled(Text)`