@apify/ui-library 0.73.1-fixa11yaudit-b2e9ed.39 → 0.74.1-featCodeBlockWithTabsoptimis-e30911.32
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/CHANGELOG.md +11 -0
- package/dist/src/components/button.d.ts +1 -3
- package/dist/src/components/button.d.ts.map +1 -1
- package/dist/src/components/button.js +3 -3
- package/dist/src/components/button.js.map +1 -1
- package/dist/src/components/code/action_button.js +1 -1
- package/dist/src/components/code/action_button.js.map +1 -1
- package/dist/src/components/code/code_block/code_block_with_tabs.d.ts +2 -1
- package/dist/src/components/code/code_block/code_block_with_tabs.d.ts.map +1 -1
- package/dist/src/components/code/code_block/code_block_with_tabs.js +2 -2
- package/dist/src/components/code/code_block/code_block_with_tabs.js.map +1 -1
- package/dist/src/components/code/prism_highlighter.d.ts.map +1 -1
- package/dist/src/components/code/prism_highlighter.js +2 -2
- package/dist/src/components/code/prism_highlighter.js.map +1 -1
- package/dist/src/components/floating/menu.d.ts +1 -2
- package/dist/src/components/floating/menu.d.ts.map +1 -1
- package/dist/src/components/floating/menu.js +2 -2
- package/dist/src/components/floating/menu.js.map +1 -1
- package/dist/src/components/tabs/tabs.js +2 -2
- package/dist/src/components/tabs/tabs.js.map +1 -1
- package/dist/src/components/to_consolidate/pagination.d.ts.map +1 -1
- package/dist/src/components/to_consolidate/pagination.js +2 -2
- package/dist/src/components/to_consolidate/pagination.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/components/button.tsx +4 -7
- package/src/components/code/action_button.tsx +1 -1
- package/src/components/code/code_block/code_block_with_tabs.tsx +4 -2
- package/src/components/code/prism_highlighter.tsx +6 -7
- package/src/components/floating/menu.tsx +1 -4
- package/src/components/tabs/tabs.tsx +3 -3
- package/src/components/to_consolidate/pagination.tsx +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apify/ui-library",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.74.1-featCodeBlockWithTabsoptimis-e30911.32+811aaea98c3",
|
|
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": "
|
|
69
|
+
"gitHead": "811aaea98c35d54fe5018e54ccbd73ca5ee946e1"
|
|
70
70
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { AriaAttributes } from 'react';
|
|
2
1
|
import React, { forwardRef } from 'react';
|
|
3
2
|
import styled, { css } from 'styled-components';
|
|
4
3
|
|
|
@@ -28,10 +27,8 @@ export interface RegularButtonProps {
|
|
|
28
27
|
disabled?: boolean;
|
|
29
28
|
}
|
|
30
29
|
|
|
31
|
-
type ButtonAriaProps = Pick<AriaAttributes, 'aria-label' | 'aria-labelledby'>;
|
|
32
|
-
|
|
33
30
|
// Props shared for both types of the button
|
|
34
|
-
export type CommonButtonProps = RegularButtonProps &
|
|
31
|
+
export type CommonButtonProps = RegularButtonProps & TransientButtonProps & MarginSpacingProps;
|
|
35
32
|
// Regular button must have onClick defined
|
|
36
33
|
export type ButtonProps = CommonButtonProps & WithRequired<RegularBoxProps, 'onClick'>;
|
|
37
34
|
// OR it can pass to to become anchor link - in that case onClick is not needed
|
|
@@ -75,21 +72,21 @@ type ButtonSizeCombinations = {
|
|
|
75
72
|
const BUTTON_COLOR_VARIANTS_CSS: ButtonColorCombinations = {
|
|
76
73
|
primary: {
|
|
77
74
|
default: {
|
|
78
|
-
textColor: theme.color.neutral.
|
|
75
|
+
textColor: theme.color.neutral.backgroundSubtle,
|
|
79
76
|
backgroundColor: theme.color.primary.action,
|
|
80
77
|
borderColor: theme.color.primary.action,
|
|
81
78
|
hoverColor: theme.color.primary.actionHover,
|
|
82
79
|
activeColor: theme.color.primary.actionActive,
|
|
83
80
|
},
|
|
84
81
|
success: {
|
|
85
|
-
textColor: theme.color.neutral.
|
|
82
|
+
textColor: theme.color.neutral.backgroundSubtle,
|
|
86
83
|
backgroundColor: theme.color.success.action,
|
|
87
84
|
borderColor: theme.color.success.action,
|
|
88
85
|
hoverColor: theme.color.success.actionHover,
|
|
89
86
|
activeColor: theme.color.success.actionActive,
|
|
90
87
|
},
|
|
91
88
|
danger: {
|
|
92
|
-
textColor: theme.color.neutral.
|
|
89
|
+
textColor: theme.color.neutral.backgroundSubtle,
|
|
93
90
|
backgroundColor: theme.color.danger.action,
|
|
94
91
|
borderColor: theme.color.danger.action,
|
|
95
92
|
hoverColor: theme.color.danger.actionHover,
|
|
@@ -89,7 +89,7 @@ interface CopyButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>
|
|
|
89
89
|
export const CopyButton = ({ code, ...props }: CopyButtonProps) => {
|
|
90
90
|
const [isCopied, handleClick] = useCopyToClipboard({ text: code });
|
|
91
91
|
return (
|
|
92
|
-
<ActionButton onClick={handleClick} data-test='copy_to_clipboard'
|
|
92
|
+
<ActionButton onClick={handleClick} data-test='copy_to_clipboard' {...props}>
|
|
93
93
|
{isCopied ? <CheckIcon size="16" /> : <CopyIcon size="16" />}
|
|
94
94
|
</ActionButton>
|
|
95
95
|
);
|
|
@@ -74,6 +74,8 @@ 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
|
+
optimisticsCurrentTabKey?: CodeBlockTabKey;
|
|
77
79
|
};
|
|
78
80
|
|
|
79
81
|
export const CODE_BLOCK_WITH_TABS_CLASSNAMES = {
|
|
@@ -190,7 +192,7 @@ const IMG_RESIZE = {
|
|
|
190
192
|
height: 20,
|
|
191
193
|
};
|
|
192
194
|
|
|
193
|
-
export const CodeBlockWithTabs = ({ className, codeBlockProps, currentTabKey, tabs, ...props }: CodeBlockWithTabsProps) => {
|
|
195
|
+
export const CodeBlockWithTabs = ({ className, codeBlockProps, currentTabKey, tabs, optimisticsCurrentTabKey, ...props }: CodeBlockWithTabsProps) => {
|
|
194
196
|
const { generateProxyImageUrl } = useSharedUiDependencies();
|
|
195
197
|
const currentTab = tabs.find((tab) => tab.key === currentTabKey) ?? tabs[0];
|
|
196
198
|
|
|
@@ -199,7 +201,7 @@ export const CodeBlockWithTabs = ({ className, codeBlockProps, currentTabKey, ta
|
|
|
199
201
|
<div className={CODE_BLOCK_WITH_TABS_CLASSNAMES.TABS}>
|
|
200
202
|
{tabs.map((tab) => {
|
|
201
203
|
const { label, src } = CODE_BLOCK_TAB_CATALOG[tab.key];
|
|
202
|
-
const selected = tab.key ===
|
|
204
|
+
const selected = optimisticsCurrentTabKey ? optimisticsCurrentTabKey === tab.key : currentTabKey === tab.key;
|
|
203
205
|
|
|
204
206
|
const commonProps = {
|
|
205
207
|
className: clsx(CODE_BLOCK_WITH_TABS_CLASSNAMES.TAB, { selected }),
|
|
@@ -46,12 +46,12 @@ const loadLanguages = async () => {
|
|
|
46
46
|
|
|
47
47
|
void loadLanguages();
|
|
48
48
|
|
|
49
|
-
type
|
|
49
|
+
type StyledPreProps = {
|
|
50
50
|
$hasLinePrefixes: boolean,
|
|
51
51
|
$isSingleLine: boolean
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
const
|
|
54
|
+
const StyledPre = styled.pre<StyledPreProps>`
|
|
55
55
|
width: 100%;
|
|
56
56
|
position: relative;
|
|
57
57
|
z-index: 2;
|
|
@@ -102,10 +102,10 @@ const PreWrapper = styled.pre<PreWrapperProps>`
|
|
|
102
102
|
}
|
|
103
103
|
`}
|
|
104
104
|
|
|
105
|
-
${({ $isSingleLine }) => ($isSingleLine ? css<
|
|
105
|
+
${({ $isSingleLine }) => ($isSingleLine ? css<StyledPreProps>`
|
|
106
106
|
white-space: nowrap;
|
|
107
107
|
vertical-align: text-top;
|
|
108
|
-
` : css<
|
|
108
|
+
` : css<StyledPreProps>`
|
|
109
109
|
padding-left: ${({ $hasLinePrefixes }) => ($hasLinePrefixes ? theme.space.space8 : theme.space.space16)};
|
|
110
110
|
padding-right: ${theme.space.space16};
|
|
111
111
|
|
|
@@ -162,8 +162,7 @@ export const PrismSyntaxHighlighter = forwardRef<HTMLPreElement, SyntaxHighlight
|
|
|
162
162
|
{...rest}
|
|
163
163
|
>
|
|
164
164
|
{({ className: prismClassName, tokens, getLineProps, getTokenProps }) => (
|
|
165
|
-
<
|
|
166
|
-
tabIndex={0}
|
|
165
|
+
<StyledPre
|
|
167
166
|
className={clsx(className, prismClassName)}
|
|
168
167
|
$hasLinePrefixes={hasLinePrefixes}
|
|
169
168
|
$isSingleLine={isSingleLine}
|
|
@@ -183,7 +182,7 @@ export const PrismSyntaxHighlighter = forwardRef<HTMLPreElement, SyntaxHighlight
|
|
|
183
182
|
</div>
|
|
184
183
|
))}
|
|
185
184
|
</Text>
|
|
186
|
-
</
|
|
185
|
+
</StyledPre>
|
|
187
186
|
)}
|
|
188
187
|
</Highlight>
|
|
189
188
|
);
|
|
@@ -44,7 +44,6 @@ export interface MenuOption {
|
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
export interface MenuProps<T = MenuOption> {
|
|
47
|
-
ariaLabel?: string,
|
|
48
47
|
options: T[],
|
|
49
48
|
value?: string,
|
|
50
49
|
onSelect: (newValue: string, selectedBy: SelectActionType) => void,
|
|
@@ -65,7 +64,6 @@ const defaultRenderOption = ({ label }: MenuOption) => (<Text as='span'>{label}<
|
|
|
65
64
|
* It tries to mimic API of react-select as closely as possible
|
|
66
65
|
*/
|
|
67
66
|
export const Menu = <T extends MenuOption>({
|
|
68
|
-
ariaLabel,
|
|
69
67
|
options,
|
|
70
68
|
value,
|
|
71
69
|
onSelect,
|
|
@@ -131,8 +129,7 @@ export const Menu = <T extends MenuOption>({
|
|
|
131
129
|
{...rest}
|
|
132
130
|
>
|
|
133
131
|
<MenuBaseComponent
|
|
134
|
-
aria-label
|
|
135
|
-
aria-labelledby={ariaLabel ? undefined : 'select-label'}
|
|
132
|
+
aria-labelledby="select-label"
|
|
136
133
|
aria-autocomplete="none"
|
|
137
134
|
ref={refs.setReference}
|
|
138
135
|
{...getReferenceProps()}
|
|
@@ -66,7 +66,7 @@ const TabsWrapper = styled(Box)<TabsWrapperProps>`
|
|
|
66
66
|
display: flex;
|
|
67
67
|
position: relative;
|
|
68
68
|
|
|
69
|
-
[role='
|
|
69
|
+
[role='tabpanel'] {
|
|
70
70
|
min-width: 0;
|
|
71
71
|
display: flex;
|
|
72
72
|
flex-grow: 1;
|
|
@@ -152,9 +152,9 @@ export const Tabs = ({ variant = 'default', tabs, activeTab, onSelect, ...props
|
|
|
152
152
|
setOveflowState(isTabsOverflowing(event.currentTarget as HTMLDivElement));
|
|
153
153
|
}, []);
|
|
154
154
|
|
|
155
|
-
return <TabsWrapper {...props} data-test="tabs-wrapper" $variant={variant}>
|
|
155
|
+
return <TabsWrapper {...props} role="tablist" data-test="tabs-wrapper" $variant={variant}>
|
|
156
156
|
<div role="cell" aria-hidden={!overflowState?.left} />
|
|
157
|
-
<div ref={ref} role="
|
|
157
|
+
<div ref={ref} role="tabpanel" onScroll={scrollHandler}>
|
|
158
158
|
{tabs.map((tab) => (
|
|
159
159
|
<Tab
|
|
160
160
|
{...tab}
|
|
@@ -83,7 +83,6 @@ export const PaginationButtons: FC<PaginationButtonsProps> = ({
|
|
|
83
83
|
disabled={page <= 0}
|
|
84
84
|
onClick={() => onPageChange(page - 1)}
|
|
85
85
|
trackingId='PaginationPrevPage'
|
|
86
|
-
aria-label="Previous page"
|
|
87
86
|
>
|
|
88
87
|
<ChevronLeftIcon size="16" />
|
|
89
88
|
</PaginationButtonBase>
|
|
@@ -129,7 +128,6 @@ export const PaginationButtons: FC<PaginationButtonsProps> = ({
|
|
|
129
128
|
disabled={page >= totalPages - 1}
|
|
130
129
|
onClick={() => onPageChange(page + 1)}
|
|
131
130
|
trackingId='PaginationNextPage'
|
|
132
|
-
aria-label="Next page"
|
|
133
131
|
>
|
|
134
132
|
<ChevronRightIcon size="16" />
|
|
135
133
|
</PaginationButtonBase>
|