@apify/ui-library 1.127.10 → 1.128.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/dist/src/components/collapsible_card/collapsible_card.d.ts +1 -0
- package/dist/src/components/collapsible_card/collapsible_card.d.ts.map +1 -1
- package/dist/src/components/collapsible_card/collapsible_card.js +3 -3
- package/dist/src/components/collapsible_card/collapsible_card.js.map +1 -1
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/components/index.js +1 -0
- package/dist/src/components/index.js.map +1 -1
- package/dist/src/components/switch/index.d.ts +2 -0
- package/dist/src/components/switch/index.d.ts.map +1 -0
- package/dist/src/components/switch/index.js +2 -0
- package/dist/src/components/switch/index.js.map +1 -0
- package/dist/src/components/switch/switch.d.ts +11 -0
- package/dist/src/components/switch/switch.d.ts.map +1 -0
- package/dist/src/components/switch/switch.js +25 -0
- package/dist/src/components/switch/switch.js.map +1 -0
- package/dist/src/components/switch/switch.style.d.ts +2 -0
- package/dist/src/components/switch/switch.style.d.ts.map +1 -0
- package/dist/src/components/switch/switch.style.js +53 -0
- package/dist/src/components/switch/switch.style.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/src/components/collapsible_card/collapsible_card.stories.tsx +16 -0
- package/src/components/collapsible_card/collapsible_card.tsx +5 -3
- package/src/components/index.ts +1 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/switch/switch.stories.jsx +38 -0
- package/src/components/switch/switch.style.ts +54 -0
- package/src/components/switch/switch.tsx +54 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@apify/ui-library",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.128.0",
|
|
4
4
|
"description": "React UI library used by apify.com",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@floating-ui/react": "^0.26.2",
|
|
32
32
|
"@radix-ui/react-checkbox": "^1.3.3",
|
|
33
33
|
"@radix-ui/react-collapsible": "^1.0.0",
|
|
34
|
+
"@radix-ui/react-switch": "^1.2.6",
|
|
34
35
|
"@react-hook/resize-observer": "^2.0.2",
|
|
35
36
|
"clsx": "^2.0.0",
|
|
36
37
|
"dayjs": "1.11.9",
|
|
@@ -68,5 +69,5 @@
|
|
|
68
69
|
"src",
|
|
69
70
|
"style"
|
|
70
71
|
],
|
|
71
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "8d4338c49c97cd1491d3522d888054e55036328e"
|
|
72
73
|
}
|
|
@@ -26,6 +26,10 @@ export default {
|
|
|
26
26
|
control: 'boolean',
|
|
27
27
|
description: 'Whether to hide the chevron icon',
|
|
28
28
|
},
|
|
29
|
+
noDivider: {
|
|
30
|
+
control: 'boolean',
|
|
31
|
+
description: 'Whether to hide the divider between header and content',
|
|
32
|
+
},
|
|
29
33
|
topSection: {
|
|
30
34
|
control: 'text',
|
|
31
35
|
description: 'Content rendered above the header',
|
|
@@ -120,6 +124,18 @@ export const GreyHeaderOnHover: Story = {
|
|
|
120
124
|
},
|
|
121
125
|
};
|
|
122
126
|
|
|
127
|
+
/**
|
|
128
|
+
* A collapsible card without the divider between header and content.
|
|
129
|
+
*/
|
|
130
|
+
export const NoDivider: Story = {
|
|
131
|
+
args: {
|
|
132
|
+
header: 'No divider between header and content',
|
|
133
|
+
noDivider: true,
|
|
134
|
+
isExpanded: true,
|
|
135
|
+
children: 'This card has no divider line between the header and content areas.',
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
|
|
123
139
|
/**
|
|
124
140
|
* A collapsible card without the outer border.
|
|
125
141
|
*/
|
|
@@ -29,6 +29,7 @@ export type CollapsibleCardProps = {
|
|
|
29
29
|
isExpanded?: boolean;
|
|
30
30
|
onIsExpandedChanged?: (expanded: boolean) => void;
|
|
31
31
|
noChevron?: boolean;
|
|
32
|
+
noDivider?: boolean;
|
|
32
33
|
topSection?: ReactNode;
|
|
33
34
|
isClosedHeaderGrey?: boolean;
|
|
34
35
|
isHeaderGreyOnHover?: boolean;
|
|
@@ -101,8 +102,8 @@ const StyledCardContent = styled.div`
|
|
|
101
102
|
overflow: auto;
|
|
102
103
|
`;
|
|
103
104
|
|
|
104
|
-
const CollapsibleContent = styled(Collapsible.Content)
|
|
105
|
-
border-top: 1px solid ${theme.color.neutral.border}
|
|
105
|
+
const CollapsibleContent = styled(Collapsible.Content)<{ $noDivider?: boolean }>`
|
|
106
|
+
${({ $noDivider }) => ($noDivider ? '' : `border-top: 1px solid ${theme.color.neutral.border};`)}
|
|
106
107
|
`;
|
|
107
108
|
|
|
108
109
|
export const CollapsibleCard: FC<CollapsibleCardProps> = ({
|
|
@@ -111,6 +112,7 @@ export const CollapsibleCard: FC<CollapsibleCardProps> = ({
|
|
|
111
112
|
isExpanded,
|
|
112
113
|
onIsExpandedChanged,
|
|
113
114
|
noChevron,
|
|
115
|
+
noDivider,
|
|
114
116
|
topSection,
|
|
115
117
|
hideOuterBorder,
|
|
116
118
|
hasShadow,
|
|
@@ -148,7 +150,7 @@ export const CollapsibleCard: FC<CollapsibleCardProps> = ({
|
|
|
148
150
|
<Collapsible.Root
|
|
149
151
|
open={isUncontrolled ? isOpen : isExpanded}
|
|
150
152
|
>
|
|
151
|
-
<CollapsibleContent className={collapsibleCardClassNames.COLLAPSIBLE_CONTENT_WRAPPER}>
|
|
153
|
+
<CollapsibleContent $noDivider={noDivider} className={collapsibleCardClassNames.COLLAPSIBLE_CONTENT_WRAPPER}>
|
|
152
154
|
<StyledCardContent className={collapsibleCardClassNames.CONTENT} data-test="card-content">
|
|
153
155
|
{children}
|
|
154
156
|
</StyledCardContent>
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './switch.js';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import styled from 'styled-components';
|
|
3
|
+
import { SwitchPrimitive as Switch } from './switch';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
title: 'UI-Library/Inputs/Switch',
|
|
7
|
+
args: {},
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const Grid = styled.div`
|
|
11
|
+
margin: 5rem 3rem;
|
|
12
|
+
display: grid;
|
|
13
|
+
grid-template-columns: repeat(2, auto);
|
|
14
|
+
gap: 1rem 5rem;
|
|
15
|
+
|
|
16
|
+
input{
|
|
17
|
+
width: 100%;
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
export const SwitchPrimitive = () => {
|
|
22
|
+
const [value, setValue] = useState(1);
|
|
23
|
+
return (
|
|
24
|
+
<Grid>
|
|
25
|
+
<Switch value={value} setValue={setValue}/> <p>checked vs unchecked</p>
|
|
26
|
+
<Switch name="Disabled"
|
|
27
|
+
disabled
|
|
28
|
+
value={false}
|
|
29
|
+
setValue={() => {}}
|
|
30
|
+
/> <p>disabled</p>
|
|
31
|
+
<Switch name="Error"
|
|
32
|
+
error='Test error'
|
|
33
|
+
value={value}
|
|
34
|
+
setValue={setValue}
|
|
35
|
+
/> <p>error</p>
|
|
36
|
+
</Grid>
|
|
37
|
+
);
|
|
38
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { css } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
import { theme } from '../../design_system/theme.js';
|
|
4
|
+
|
|
5
|
+
export const switchStyle = css`
|
|
6
|
+
width: 32px;
|
|
7
|
+
height: 16px;
|
|
8
|
+
background-color: ${theme.color.neutral.actionSecondary};
|
|
9
|
+
border-radius: 100px;
|
|
10
|
+
position: relative;
|
|
11
|
+
transition: border-color 120ms ease-out, background-color 120ms ease-out !important;
|
|
12
|
+
vertical-align: middle;
|
|
13
|
+
|
|
14
|
+
&:focus-visible {
|
|
15
|
+
outline: 2px solid ${theme.color.primary.fieldBorderActive}!important;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&:hover {
|
|
19
|
+
background-color: ${theme.color.neutral.actionSecondaryHover};
|
|
20
|
+
cursor: pointer;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.disabled {
|
|
24
|
+
background-color: ${theme.color.neutral.disabled};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&.error {
|
|
28
|
+
background-color: ${theme.color.danger.action};
|
|
29
|
+
|
|
30
|
+
&:hover {
|
|
31
|
+
background-color: ${theme.color.danger.actionHover};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&[data-state="checked"] {
|
|
36
|
+
background-color: ${theme.color.success.action};
|
|
37
|
+
|
|
38
|
+
&:hover {
|
|
39
|
+
background-color: ${theme.color.success.actionHover};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
&.disabled {
|
|
43
|
+
background-color: ${theme.color.success.chipBackground};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
&.error {
|
|
47
|
+
background-color: ${theme.color.danger.action};
|
|
48
|
+
|
|
49
|
+
&:hover {
|
|
50
|
+
background-color: ${theme.color.danger.actionHover};
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as SwitchPrimitiveReact from '@radix-ui/react-switch';
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
|
|
5
|
+
import { theme } from '../../design_system/theme.js';
|
|
6
|
+
import { switchStyle } from './switch.style';
|
|
7
|
+
|
|
8
|
+
const StyledSwitch = styled(SwitchPrimitiveReact.Root)`
|
|
9
|
+
all: unset;
|
|
10
|
+
${switchStyle}
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
const StyledThumb = styled(SwitchPrimitiveReact.Thumb)`
|
|
14
|
+
display: block;
|
|
15
|
+
background-color: ${theme.color.neutral.backgroundWhite};
|
|
16
|
+
width: 12px;
|
|
17
|
+
height: 12px;
|
|
18
|
+
border-radius: 100px;
|
|
19
|
+
transition: transform 100ms;
|
|
20
|
+
transform: translateX(2px);
|
|
21
|
+
will-change: transform;
|
|
22
|
+
&[data-state="checked"] {
|
|
23
|
+
transform: translateX(18px);
|
|
24
|
+
}
|
|
25
|
+
`;
|
|
26
|
+
type SwitchPrimitiveProps = {
|
|
27
|
+
value: boolean;
|
|
28
|
+
setValue: (checked: boolean) => void;
|
|
29
|
+
error?: string;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
readOnly?: boolean;
|
|
32
|
+
} & Omit<React.ComponentPropsWithoutRef<typeof SwitchPrimitiveReact.Root>, 'checked' | 'onCheckedChange' | 'value'>;
|
|
33
|
+
|
|
34
|
+
export const SwitchPrimitive = ({
|
|
35
|
+
value,
|
|
36
|
+
setValue,
|
|
37
|
+
error,
|
|
38
|
+
disabled,
|
|
39
|
+
readOnly,
|
|
40
|
+
...rest
|
|
41
|
+
}: SwitchPrimitiveProps) => (
|
|
42
|
+
<StyledSwitch
|
|
43
|
+
{...rest}
|
|
44
|
+
checked={value}
|
|
45
|
+
onCheckedChange={setValue}
|
|
46
|
+
disabled={disabled || readOnly}
|
|
47
|
+
className={clsx(
|
|
48
|
+
error && 'error',
|
|
49
|
+
(disabled || readOnly) && 'disabled',
|
|
50
|
+
)}
|
|
51
|
+
>
|
|
52
|
+
<StyledThumb />
|
|
53
|
+
</StyledSwitch>
|
|
54
|
+
);
|