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