@apify/ui-library 0.67.4 → 0.67.5-featoutputschemacomponent-327312.55
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/code/inline_code/inline_code.d.ts +1 -0
- package/dist/src/components/code/inline_code/inline_code.d.ts.map +1 -1
- package/dist/src/components/code/inline_code/inline_code.js +14 -2
- package/dist/src/components/code/inline_code/inline_code.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/components/code/inline_code/inline_code.tsx +29 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apify/ui-library",
|
|
3
|
-
"version": "0.67.
|
|
3
|
+
"version": "0.67.5-featoutputschemacomponent-327312.55+a115a4da8fe",
|
|
4
4
|
"description": "React UI library used by apify.com",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"typescript": "^5.1.6",
|
|
66
66
|
"typescript-eslint": "^8.24.0"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "a115a4da8fe789c5ede403ec8548ff22e1b16c29"
|
|
69
69
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import styled, { css } from 'styled-components';
|
|
3
3
|
|
|
4
|
+
import { CheckIcon, CopyIcon } from '@apify/ui-icons';
|
|
5
|
+
|
|
4
6
|
import { theme } from '../../../design_system/theme.js';
|
|
7
|
+
import { useCopyToClipboard } from '../../../utils/copy_to_clipboard.js';
|
|
5
8
|
import type { RegularBoxProps } from '../../box.js';
|
|
6
9
|
import { Text } from '../../text/index.js';
|
|
7
10
|
import type { SharedTextSize } from '../../text/text_shared.js';
|
|
@@ -15,6 +18,20 @@ export const inlineCodeStyles = css`
|
|
|
15
18
|
border: 1px solid ${theme.color.neutral.border};
|
|
16
19
|
`;
|
|
17
20
|
|
|
21
|
+
const CopyButtonWrapper = styled.div`
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
vertical-align: text-top;
|
|
25
|
+
margin-left: ${theme.space.space4};
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
const CopyButton: React.FC<{ text: string }> = ({ text }) => {
|
|
29
|
+
const [isCopied, copyToClipboard] = useCopyToClipboard({ text });
|
|
30
|
+
return <CopyButtonWrapper role='button' onClick={copyToClipboard} title='Copy to clipboard'>
|
|
31
|
+
{isCopied ? <CheckIcon size="16" /> : <CopyIcon size="16" />}
|
|
32
|
+
</CopyButtonWrapper>;
|
|
33
|
+
};
|
|
34
|
+
|
|
18
35
|
const Wrapper = styled.span`
|
|
19
36
|
code {
|
|
20
37
|
${inlineCodeStyles}
|
|
@@ -24,21 +41,22 @@ const Wrapper = styled.span`
|
|
|
24
41
|
export type InlineCodeProps = RegularBoxProps & {
|
|
25
42
|
children: React.ReactNode,
|
|
26
43
|
size?: SharedTextSize,
|
|
44
|
+
withCopyButton?: boolean,
|
|
27
45
|
}
|
|
28
46
|
|
|
29
47
|
// This might be just a Chip component
|
|
30
48
|
export const InlineCode: React.FC<InlineCodeProps> = ({
|
|
31
49
|
children,
|
|
32
50
|
size,
|
|
51
|
+
withCopyButton,
|
|
33
52
|
...props
|
|
34
|
-
}) =>
|
|
35
|
-
<
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
);
|
|
53
|
+
}) => <Wrapper {...props}>
|
|
54
|
+
<Text
|
|
55
|
+
type="code"
|
|
56
|
+
as="code"
|
|
57
|
+
size={size}
|
|
58
|
+
>
|
|
59
|
+
{children}
|
|
60
|
+
{withCopyButton && <CopyButton text={children?.toString() ?? ''} />}
|
|
61
|
+
</Text>
|
|
62
|
+
</Wrapper>;
|