@automattic/vip-design-system 0.10.3 → 0.11.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/.eslines.json +8 -8
- package/.eslintrc.json +9 -4
- package/.github/PULL_REQUEST_TEMPLATE.md +1 -1
- package/.github/workflows/nodejs.yaml +14 -14
- package/.prettierrc +1 -2
- package/.storybook/main.js +1 -1
- package/.storybook/preview.js +4 -8
- package/README.md +1 -0
- package/babel.config.js +1 -1
- package/build/system/Avatar/Avatar.js +2 -1
- package/build/system/BlankState/BlankState.stories.js +3 -3
- package/build/system/BlankState/BlankState.test.js +2 -2
- package/build/system/Card/Card.test.js +0 -2
- package/build/system/Code/Code.js +7 -2
- package/build/system/Code/Code.test.js +22 -57
- package/build/system/Form/MultiSelect.js +45 -25
- package/build/system/Form/Select.stories.js +3 -4
- package/build/system/Form/Select.test.js +2 -2
- package/build/system/Notification/Notification.js +24 -15
- package/build/system/Notification/Notification.stories.js +14 -4
- package/build/system/OptionRow/OptionRow.js +23 -17
- package/build/system/OptionRow/OptionRow.stories.js +5 -5
- package/build/system/OptionRow/OptionRow.test.js +4 -4
- package/build/system/ResourceList/ResourceList.js +34 -25
- package/build/system/ResourceList/ResourceList.stories.js +2 -0
- package/build/system/ScreenReaderText/ScreenReader.test.js +37 -0
- package/build/system/ScreenReaderText/ScreenReaderText.js +49 -0
- package/build/system/ScreenReaderText/index.js +7 -0
- package/build/system/Time/index.js +1 -1
- package/build/system/UsageChart/UsageChart.js +47 -45
- package/build/system/UsageChart/UsageChart.stories.js +8 -8
- package/build/system/UsageChart/index.js +3 -3
- package/build/system/Wizard/Wizard.stories.js +1 -1
- package/package.json +8 -4
- package/src/system/Avatar/Avatar.js +1 -0
- package/src/system/Avatar/index.js +0 -1
- package/src/system/Badge/index.js +0 -1
- package/src/system/BlankState/BlankState.js +8 -5
- package/src/system/BlankState/BlankState.stories.jsx +5 -4
- package/src/system/BlankState/BlankState.test.js +21 -21
- package/src/system/BlankState/index.js +0 -1
- package/src/system/Box/Box.js +7 -1
- package/src/system/Box/index.js +0 -1
- package/src/system/Button/Button.js +3 -3
- package/src/system/Button/Button.stories.jsx +2 -2
- package/src/system/Button/index.js +0 -1
- package/src/system/Card/Card.js +4 -4
- package/src/system/Card/Card.test.js +1 -2
- package/src/system/Card/index.js +0 -1
- package/src/system/Code/Code.js +6 -2
- package/src/system/Code/Code.stories.jsx +10 -5
- package/src/system/Code/Code.test.js +3 -16
- package/src/system/ConfirmationDialog/ConfirmationDialog.js +8 -1
- package/src/system/Dialog/Dialog.js +17 -8
- package/src/system/Dialog/Dialog.stories.jsx +9 -13
- package/src/system/Dialog/DialogButton.js +18 -14
- package/src/system/Dialog/DialogDivider.js +1 -1
- package/src/system/Dialog/DialogMenu.js +1 -5
- package/src/system/Dialog/DialogMenuItem.js +4 -8
- package/src/system/Dialog/DialogTrigger.js +1 -1
- package/src/system/Dialog/index.js +0 -1
- package/src/system/Flex/Flex.js +1 -1
- package/src/system/Flex/index.js +0 -1
- package/src/system/Form/AsyncSearchSelect.js +3 -7
- package/src/system/Form/Checkbox.js +32 -28
- package/src/system/Form/InlineSelect.js +21 -17
- package/src/system/Form/Input.js +43 -45
- package/src/system/Form/Label.js +2 -2
- package/src/system/Form/RadioBoxGroup.js +34 -32
- package/src/system/Form/RadioBoxGroup.stories.jsx +8 -1
- package/src/system/Form/SearchSelect.js +7 -7
- package/src/system/Form/Select.js +21 -2
- package/src/system/Form/Select.stories.jsx +31 -34
- package/src/system/Form/Select.test.js +3 -8
- package/src/system/Form/Textarea.js +38 -40
- package/src/system/Form/Toggle.js +9 -11
- package/src/system/Form/ToggleGroup.js +29 -31
- package/src/system/Form/ToggleGroup.stories.jsx +8 -1
- package/src/system/Form/ToggleRow.js +6 -1
- package/src/system/Form/Validation.js +6 -1
- package/src/system/Form/index.js +13 -1
- package/src/system/Grid/Grid.js +1 -1
- package/src/system/Grid/index.js +0 -1
- package/src/system/Heading/Heading.js +4 -4
- package/src/system/Heading/index.js +0 -1
- package/src/system/Link/index.js +0 -1
- package/src/system/Notice/Notice.js +27 -13
- package/src/system/Notice/Notice.stories.jsx +6 -8
- package/src/system/Notice/index.js +0 -1
- package/src/system/Notification/Notification.js +25 -20
- package/src/system/Notification/Notification.stories.jsx +4 -4
- package/src/system/Notification/index.js +0 -1
- package/src/system/OptionRow/OptionRow.js +46 -44
- package/src/system/OptionRow/OptionRow.stories.jsx +10 -8
- package/src/system/OptionRow/OptionRow.test.js +12 -11
- package/src/system/OptionRow/index.js +0 -1
- package/src/system/Progress/Progress.js +3 -1
- package/src/system/Progress/Progress.stories.jsx +4 -4
- package/src/system/Progress/index.js +0 -1
- package/src/system/ResourceList/ResourceItem.js +15 -15
- package/src/system/ResourceList/ResourceList.js +28 -16
- package/src/system/ResourceList/ResourceList.stories.jsx +77 -71
- package/src/system/ScreenReaderText/ScreenReader.test.js +22 -0
- package/src/system/ScreenReaderText/ScreenReaderText.js +40 -0
- package/src/system/ScreenReaderText/index.js +7 -0
- package/src/system/Spinner/Spinner.js +4 -4
- package/src/system/Spinner/index.js +0 -1
- package/src/system/Table/Table.js +5 -5
- package/src/system/Table/Table.stories.jsx +10 -8
- package/src/system/Table/index.js +0 -1
- package/src/system/Tabs/Tabs.js +3 -3
- package/src/system/Tabs/index.js +0 -1
- package/src/system/Text/Text.js +3 -3
- package/src/system/Text/Text.stories.jsx +4 -6
- package/src/system/Text/index.js +0 -1
- package/src/system/Time/Time.stories.jsx +2 -6
- package/src/system/Time/index.js +5 -5
- package/src/system/Timeline/Timeline.js +6 -12
- package/src/system/Timeline/Timeline.stories.jsx +3 -12
- package/src/system/Timeline/index.js +0 -1
- package/src/system/Tooltip/Tooltip.js +4 -8
- package/src/system/Wizard/Wizard.js +23 -21
- package/src/system/Wizard/Wizard.stories.jsx +7 -12
- package/src/system/Wizard/WizardStep.js +8 -8
- package/src/system/Wizard/WizardStepHorizontal.js +4 -4
- package/src/system/Wizard/index.js +0 -1
- package/src/system/theme/index.js +3 -4
- package/tokens/valet-color.json +1919 -0
package/src/system/Box/Box.js
CHANGED
|
@@ -8,7 +8,13 @@ import classNames from 'classnames';
|
|
|
8
8
|
import { forwardRef } from 'react';
|
|
9
9
|
import { Box as ThemeBox } from 'theme-ui';
|
|
10
10
|
|
|
11
|
-
const Box = forwardRef( ( props, ref ) =>
|
|
11
|
+
const Box = forwardRef( ( props, ref ) => (
|
|
12
|
+
<ThemeBox
|
|
13
|
+
ref={ ref }
|
|
14
|
+
className={ classNames( 'vip-box-component', props.className ) }
|
|
15
|
+
{ ...props }
|
|
16
|
+
/>
|
|
17
|
+
) );
|
|
12
18
|
|
|
13
19
|
Box.displayName = 'Box';
|
|
14
20
|
Box.propTypes = {
|
package/src/system/Box/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import classNames from 'classnames';
|
|
|
9
9
|
|
|
10
10
|
const Button = ( { sx, ...props } ) => (
|
|
11
11
|
<ThemeButton
|
|
12
|
-
sx={{
|
|
12
|
+
sx={ {
|
|
13
13
|
verticalAlign: 'middle',
|
|
14
14
|
display: 'inline-flex',
|
|
15
15
|
alignItems: 'center',
|
|
@@ -22,9 +22,9 @@ const Button = ( { sx, ...props } ) => (
|
|
|
22
22
|
pointerEvents: 'all',
|
|
23
23
|
},
|
|
24
24
|
...sx,
|
|
25
|
-
}}
|
|
25
|
+
} }
|
|
26
26
|
className={ classNames( 'vip-button-component', props.className ) }
|
|
27
|
-
{...props}
|
|
27
|
+
{ ...props }
|
|
28
28
|
/>
|
|
29
29
|
);
|
|
30
30
|
|
|
@@ -15,8 +15,8 @@ export default {
|
|
|
15
15
|
|
|
16
16
|
export const Default = () => (
|
|
17
17
|
<React.Fragment>
|
|
18
|
-
<Button sx={{ mr: 2 }}>Primary</Button>
|
|
19
|
-
<Button variant="secondary" sx={{ ml: 2 }}>
|
|
18
|
+
<Button sx={ { mr: 2 } }>Primary</Button>
|
|
19
|
+
<Button variant="secondary" sx={ { ml: 2 } }>
|
|
20
20
|
Secondary
|
|
21
21
|
</Button>
|
|
22
22
|
</React.Fragment>
|
package/src/system/Card/Card.js
CHANGED
|
@@ -15,15 +15,15 @@ import classNames from 'classnames';
|
|
|
15
15
|
const Card = React.forwardRef( ( { variant = 'primary', sx = {}, className, ...props }, ref ) => {
|
|
16
16
|
return (
|
|
17
17
|
<Box
|
|
18
|
-
ref={ref}
|
|
19
|
-
sx={{
|
|
18
|
+
ref={ ref }
|
|
19
|
+
sx={ {
|
|
20
20
|
// pass variant prop to sx
|
|
21
21
|
variant: `cards.${ variant }`,
|
|
22
22
|
overflow: 'hidden',
|
|
23
23
|
...sx,
|
|
24
|
-
}}
|
|
24
|
+
} }
|
|
25
25
|
className={ classNames( 'vip-card-component', className ) }
|
|
26
|
-
{...props}
|
|
26
|
+
{ ...props }
|
|
27
27
|
/>
|
|
28
28
|
);
|
|
29
29
|
} );
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { render, screen
|
|
4
|
+
import { render, screen } from '@testing-library/react';
|
|
5
5
|
import { axe } from 'jest-axe';
|
|
6
|
-
import { MdContentCopy } from 'react-icons/md';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Internal dependencies
|
package/src/system/Card/index.js
CHANGED
package/src/system/Code/Code.js
CHANGED
|
@@ -50,7 +50,7 @@ const Code = ( { prompt = false, showCopy = false, onCopy = null, className, ...
|
|
|
50
50
|
{ codeDom }
|
|
51
51
|
{
|
|
52
52
|
<button
|
|
53
|
-
aria-label="Copy"
|
|
53
|
+
aria-label="Copy code"
|
|
54
54
|
sx={ {
|
|
55
55
|
bg: 'grey.10',
|
|
56
56
|
borderTopRightRadius: 1,
|
|
@@ -79,7 +79,11 @@ const Code = ( { prompt = false, showCopy = false, onCopy = null, className, ...
|
|
|
79
79
|
}
|
|
80
80
|
} }
|
|
81
81
|
>
|
|
82
|
-
{ copied ?
|
|
82
|
+
{ copied ? (
|
|
83
|
+
<span role="alert">Code copied to clipboard</span>
|
|
84
|
+
) : (
|
|
85
|
+
<MdContentCopy aria-hidden="true" />
|
|
86
|
+
) }
|
|
83
87
|
</button>
|
|
84
88
|
}
|
|
85
89
|
</div>
|
|
@@ -17,11 +17,16 @@ export const Default = () => (
|
|
|
17
17
|
<React.Fragment>
|
|
18
18
|
<Code>Code</Code>
|
|
19
19
|
<br />
|
|
20
|
-
<Code showCopy={true}>Code with Icon</Code>
|
|
20
|
+
<Code showCopy={ true }>Code with Icon</Code>
|
|
21
21
|
<br />
|
|
22
|
-
<Code
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
<Code
|
|
23
|
+
showCopy={ true }
|
|
24
|
+
onCopy={
|
|
25
|
+
// eslint-disable-next-line no-console
|
|
26
|
+
() => console.info( 'Hello world' )
|
|
27
|
+
}
|
|
28
|
+
>
|
|
29
|
+
Code with Icon and Click callback — console.info
|
|
30
|
+
</Code>
|
|
26
31
|
</React.Fragment>
|
|
27
32
|
);
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
|
|
5
5
|
import { axe } from 'jest-axe';
|
|
6
|
-
import { MdContentCopy } from 'react-icons/md';
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Internal dependencies
|
|
@@ -31,23 +30,11 @@ describe( '<Code />', () => {
|
|
|
31
30
|
await expect( await axe( container ) ).toHaveNoViolations();
|
|
32
31
|
} );
|
|
33
32
|
|
|
34
|
-
// jsdom currently doesn't support pseudo-elements with getComputedStyle
|
|
35
|
-
it.skip( 'renders "$" in front of the code when in prompt mode', async () => {
|
|
36
|
-
const props = { ...defaultProps, prompt: true };
|
|
37
|
-
const { container } = render( <Code { ...props }>This is a code</Code> );
|
|
38
|
-
const codeElement = screen.getByText( 'This is a code' );
|
|
39
|
-
|
|
40
|
-
expect( window.getComputedStyle( codeElement, ':before' ).content ).toEqual( '$' );
|
|
41
|
-
|
|
42
|
-
// Check for accessibility issues
|
|
43
|
-
await expect( await axe( container ) ).toHaveNoViolations();
|
|
44
|
-
} );
|
|
45
|
-
|
|
46
33
|
it( 'renders the Code component with a copy button', async () => {
|
|
47
34
|
const props = { ...defaultProps, showCopy: true };
|
|
48
35
|
const { container } = render( <Code { ...props }>This is a code</Code> );
|
|
49
36
|
|
|
50
|
-
expect( screen.getByRole( 'button', { name: 'Copy' } ) ).toBeInTheDocument();
|
|
37
|
+
expect( screen.getByRole( 'button', { name: 'Copy code' } ) ).toBeInTheDocument();
|
|
51
38
|
|
|
52
39
|
// Check for accessibility issues
|
|
53
40
|
await expect( await axe( container ) ).toHaveNoViolations();
|
|
@@ -57,11 +44,11 @@ describe( '<Code />', () => {
|
|
|
57
44
|
const props = { ...defaultProps, showCopy: true };
|
|
58
45
|
const { container } = render( <Code { ...props }>This is a code</Code> );
|
|
59
46
|
|
|
60
|
-
fireEvent.click( screen.getByRole( 'button', { name: 'Copy' } ) );
|
|
47
|
+
fireEvent.click( screen.getByRole( 'button', { name: 'Copy code' } ) );
|
|
61
48
|
|
|
62
49
|
await waitFor( () => new Promise( res => setTimeout( res, 0 ) ) );
|
|
63
50
|
|
|
64
|
-
expect( screen.getByText( '
|
|
51
|
+
expect( screen.getByText( 'Code copied to clipboard' ) ).toBeInTheDocument();
|
|
65
52
|
|
|
66
53
|
// Check for accessibility issues
|
|
67
54
|
await expect( await axe( container ) ).toHaveNoViolations();
|
|
@@ -12,7 +12,14 @@ import React from 'react';
|
|
|
12
12
|
*/
|
|
13
13
|
import { Dialog, Box, Heading, Text, Flex, Button } from '../';
|
|
14
14
|
|
|
15
|
-
const ConfirmationDialogContent = ( {
|
|
15
|
+
const ConfirmationDialogContent = ( {
|
|
16
|
+
title,
|
|
17
|
+
body,
|
|
18
|
+
onClose,
|
|
19
|
+
label = 'Confirm',
|
|
20
|
+
onConfirm,
|
|
21
|
+
className = null,
|
|
22
|
+
} ) => (
|
|
16
23
|
<Box p={ 4 } className={ classNames( 'vip-confirmation-dialog-component', className ) }>
|
|
17
24
|
<Heading variant="h3" sx={ { mb: 2 } }>
|
|
18
25
|
{ title }
|
|
@@ -8,11 +8,18 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import { useEffect, useRef, useState } from 'react';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* Internal dependencies
|
|
12
|
-
*/
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
13
|
import { DialogContent, DialogTrigger } from '.';
|
|
14
14
|
|
|
15
|
-
const Dialog = ( {
|
|
15
|
+
const Dialog = ( {
|
|
16
|
+
trigger,
|
|
17
|
+
position = 'left',
|
|
18
|
+
startOpen = false,
|
|
19
|
+
content,
|
|
20
|
+
disabled = false,
|
|
21
|
+
...props
|
|
22
|
+
} ) => {
|
|
16
23
|
const [ isOpen, setIsOpen ] = useState( startOpen );
|
|
17
24
|
const dialogRef = useRef( null );
|
|
18
25
|
|
|
@@ -46,7 +53,12 @@ const Dialog = ( { trigger, position = 'left', startOpen = false, content, disab
|
|
|
46
53
|
};
|
|
47
54
|
|
|
48
55
|
return (
|
|
49
|
-
<div
|
|
56
|
+
<div
|
|
57
|
+
onClick={ e => e.stopPropagation() }
|
|
58
|
+
sx={ { position: 'relative' } }
|
|
59
|
+
ref={ dialogRef }
|
|
60
|
+
className="vip-dialog-component"
|
|
61
|
+
>
|
|
50
62
|
<DialogTrigger
|
|
51
63
|
tabIndex="0"
|
|
52
64
|
sx={ { display: 'inline' } }
|
|
@@ -73,10 +85,7 @@ Dialog.propTypes = {
|
|
|
73
85
|
disabled: PropTypes.bool,
|
|
74
86
|
position: PropTypes.string,
|
|
75
87
|
startOpen: PropTypes.bool,
|
|
76
|
-
content: PropTypes.oneOfType( [
|
|
77
|
-
PropTypes.node,
|
|
78
|
-
PropTypes.func,
|
|
79
|
-
] ),
|
|
88
|
+
content: PropTypes.oneOfType( [ PropTypes.node, PropTypes.func ] ),
|
|
80
89
|
};
|
|
81
90
|
|
|
82
91
|
export { Dialog };
|
|
@@ -19,7 +19,7 @@ export default {
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
const DropdownTrigger = <Button>Trigger Dropdown</Button>;
|
|
22
|
-
const ModalTrigger = <Button sx={{ mr: 3 }}>Trigger Modal</Button>;
|
|
22
|
+
const ModalTrigger = <Button sx={ { mr: 3 } }>Trigger Modal</Button>;
|
|
23
23
|
|
|
24
24
|
const DropdownContent = (
|
|
25
25
|
<div>
|
|
@@ -36,11 +36,11 @@ const DropdownContent = (
|
|
|
36
36
|
);
|
|
37
37
|
|
|
38
38
|
const ModalContent = (
|
|
39
|
-
<Box p={5}>
|
|
39
|
+
<Box p={ 5 }>
|
|
40
40
|
<Heading>This is a Modal</Heading>
|
|
41
|
-
<Text sx={{ fontSize: 3 }}>
|
|
42
|
-
A modal is used to perform more detailed actions that don‘t
|
|
43
|
-
|
|
41
|
+
<Text sx={ { fontSize: 3 } }>
|
|
42
|
+
A modal is used to perform more detailed actions that don‘t necessarily need the context
|
|
43
|
+
behind.
|
|
44
44
|
</Text>
|
|
45
45
|
</Box>
|
|
46
46
|
);
|
|
@@ -49,16 +49,12 @@ export const Default = () => (
|
|
|
49
49
|
<Flex>
|
|
50
50
|
<Box>
|
|
51
51
|
<Dialog
|
|
52
|
-
trigger={ModalTrigger}
|
|
53
|
-
content={ModalContent}
|
|
54
|
-
sx={{ width: 480 }}
|
|
52
|
+
trigger={ ModalTrigger }
|
|
53
|
+
content={ ModalContent }
|
|
54
|
+
sx={ { width: 480 } }
|
|
55
55
|
variant="modal"
|
|
56
56
|
/>
|
|
57
57
|
</Box>
|
|
58
|
-
<Dialog
|
|
59
|
-
trigger={DropdownTrigger}
|
|
60
|
-
content={DropdownContent}
|
|
61
|
-
sx={{ width: 200 }}
|
|
62
|
-
/>
|
|
58
|
+
<Dialog trigger={ DropdownTrigger } content={ DropdownContent } sx={ { width: 200 } } />
|
|
63
59
|
</Flex>
|
|
64
60
|
);
|
|
@@ -7,26 +7,30 @@ import PropTypes from 'prop-types';
|
|
|
7
7
|
import { MdExpandMore } from 'react-icons/md';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
12
|
import { Button, Text } from '../';
|
|
13
13
|
|
|
14
14
|
const DialogButton = ( { label, variant = 'secondary', value, children, ...props } ) => (
|
|
15
|
-
<Button
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
<Button
|
|
16
|
+
variant={ variant }
|
|
17
|
+
sx={ {
|
|
18
|
+
textAlign: 'left',
|
|
19
|
+
display: 'inline-flex',
|
|
20
|
+
py: 2,
|
|
21
|
+
pl: 3,
|
|
22
|
+
pr: 2,
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
} }
|
|
25
|
+
{ ...props }
|
|
22
26
|
>
|
|
23
27
|
{ children }
|
|
24
|
-
{ label &&
|
|
25
|
-
<Text as="span" sx={{ mb: 0, color: 'muted', mr: 2, flex: '0 0 auto' }}>
|
|
28
|
+
{ label && (
|
|
29
|
+
<Text as="span" sx={ { mb: 0, color: 'muted', mr: 2, flex: '0 0 auto' } }>
|
|
26
30
|
{ label }:
|
|
27
31
|
</Text>
|
|
28
|
-
}
|
|
29
|
-
{ value &&
|
|
32
|
+
) }
|
|
33
|
+
{ value && (
|
|
30
34
|
<Text
|
|
31
35
|
as="span"
|
|
32
36
|
sx={ {
|
|
@@ -40,7 +44,7 @@ const DialogButton = ( { label, variant = 'secondary', value, children, ...props
|
|
|
40
44
|
>
|
|
41
45
|
{ value }
|
|
42
46
|
</Text>
|
|
43
|
-
}
|
|
47
|
+
) }
|
|
44
48
|
<MdExpandMore sx={ { ml: 2, top: 0, display: 'block', flex: '0 0 auto' } } />
|
|
45
49
|
</Button>
|
|
46
50
|
);
|
|
@@ -7,8 +7,8 @@ import PropTypes from 'prop-types';
|
|
|
7
7
|
import { useEffect, useRef } from 'react';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
12
|
import { Box, Spinner } from '../';
|
|
13
13
|
|
|
14
14
|
const DialogMenuItem = ( { loading = false, children, ...props } ) => {
|
|
@@ -57,12 +57,8 @@ const DialogMenuItem = ( { loading = false, children, ...props } ) => {
|
|
|
57
57
|
} }
|
|
58
58
|
{ ...props }
|
|
59
59
|
>
|
|
60
|
-
<Box sx={ { flex: '1 1 auto' } }>
|
|
61
|
-
|
|
62
|
-
</Box>
|
|
63
|
-
{ loading &&
|
|
64
|
-
<Spinner sx={ { width: 12 } } />
|
|
65
|
-
}
|
|
60
|
+
<Box sx={ { flex: '1 1 auto' } }>{ children }</Box>
|
|
61
|
+
{ loading && <Spinner sx={ { width: 12 } } /> }
|
|
66
62
|
</Box>
|
|
67
63
|
</li>
|
|
68
64
|
);
|
package/src/system/Flex/Flex.js
CHANGED
package/src/system/Flex/index.js
CHANGED
|
@@ -7,19 +7,15 @@ import PropTypes from 'prop-types';
|
|
|
7
7
|
import { withAsyncPaginate } from 'react-select-async-paginate';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
12
|
import { SearchSelect } from './SearchSelect';
|
|
13
13
|
|
|
14
14
|
// Asynchronous search select to load paginated results asynchronously
|
|
15
15
|
const CustomAsyncPaginate = withAsyncPaginate( SearchSelect );
|
|
16
16
|
|
|
17
17
|
const AsyncSearchSelect = ( { options, ...props } ) => (
|
|
18
|
-
<CustomAsyncPaginate
|
|
19
|
-
SelectComponent={ SearchSelect }
|
|
20
|
-
loadOptions={ options }
|
|
21
|
-
{ ...props }
|
|
22
|
-
/>
|
|
18
|
+
<CustomAsyncPaginate SelectComponent={ SearchSelect } loadOptions={ options } { ...props } />
|
|
23
19
|
);
|
|
24
20
|
|
|
25
21
|
AsyncSearchSelect.propTypes = {
|
|
@@ -7,35 +7,39 @@ import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { MdDone } from 'react-icons/md';
|
|
9
9
|
|
|
10
|
-
const StyledCheckbox = props =>
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
10
|
+
const StyledCheckbox = props => (
|
|
11
|
+
<CheckboxPrimitive.Root
|
|
12
|
+
sx={ {
|
|
13
|
+
all: 'unset',
|
|
14
|
+
backgroundColor: 'grey.10',
|
|
15
|
+
width: 16,
|
|
16
|
+
height: 16,
|
|
17
|
+
borderRadius: 1,
|
|
18
|
+
display: 'flex',
|
|
19
|
+
alignItems: 'center',
|
|
20
|
+
justifyContent: 'center',
|
|
21
|
+
'&:hover': { backgroundColor: 'grey.20' },
|
|
22
|
+
'&:focus': { boxShadow: '0 0 0 2px black' },
|
|
23
|
+
'&[data-state=checked]': {
|
|
24
|
+
backgroundColor: 'primary',
|
|
25
|
+
color: 'brand.0',
|
|
26
|
+
},
|
|
27
|
+
svg: {
|
|
28
|
+
display: 'block',
|
|
29
|
+
},
|
|
30
|
+
} }
|
|
31
|
+
{ ...props }
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
32
34
|
|
|
33
|
-
const StyledIndicator = props =>
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
const StyledIndicator = props => (
|
|
36
|
+
<CheckboxPrimitive.Indicator
|
|
37
|
+
sx={ {
|
|
38
|
+
color: 'brand.0',
|
|
39
|
+
} }
|
|
40
|
+
{ ...props }
|
|
41
|
+
/>
|
|
42
|
+
);
|
|
39
43
|
|
|
40
44
|
const Checkbox = ( { disabled, ...props } ) => (
|
|
41
45
|
<StyledCheckbox
|
|
@@ -32,7 +32,14 @@ const selectStyles = {
|
|
|
32
32
|
menu: () => ( { boxShadow: 'none', borderTop: '1px solid' } ),
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
-
const InlineSelect = ( {
|
|
35
|
+
const InlineSelect = ( {
|
|
36
|
+
label,
|
|
37
|
+
value,
|
|
38
|
+
options,
|
|
39
|
+
noneLabel = 'All',
|
|
40
|
+
position = 'left',
|
|
41
|
+
...props
|
|
42
|
+
} ) => {
|
|
36
43
|
let valueLabel = noneLabel;
|
|
37
44
|
|
|
38
45
|
if ( Array.isArray( value ) && value.length ) {
|
|
@@ -49,18 +56,18 @@ const InlineSelect = ( { label, value, options, noneLabel = 'All', position = 'l
|
|
|
49
56
|
<Box>
|
|
50
57
|
<Select
|
|
51
58
|
autoFocus
|
|
52
|
-
backspaceRemovesValue={false}
|
|
53
|
-
components={{ Option, DropdownIndicator: null, IndicatorSeparator: null }}
|
|
54
|
-
controlShouldRenderValue={false}
|
|
55
|
-
hideSelectedOptions={false}
|
|
56
|
-
isClearable={false}
|
|
59
|
+
backspaceRemovesValue={ false }
|
|
60
|
+
components={ { Option, DropdownIndicator: null, IndicatorSeparator: null } }
|
|
61
|
+
controlShouldRenderValue={ false }
|
|
62
|
+
hideSelectedOptions={ false }
|
|
63
|
+
isClearable={ false }
|
|
57
64
|
menuIsOpen
|
|
58
|
-
styles={selectStyles}
|
|
65
|
+
styles={ selectStyles }
|
|
59
66
|
classNamePrefix={ 'select' }
|
|
60
|
-
options={options}
|
|
67
|
+
options={ options }
|
|
61
68
|
placeholder="Search..."
|
|
62
|
-
tabSelectsValue={false}
|
|
63
|
-
value={value}
|
|
69
|
+
tabSelectsValue={ false }
|
|
70
|
+
value={ value }
|
|
64
71
|
sx={ {
|
|
65
72
|
'.select__control': {
|
|
66
73
|
background: 'none',
|
|
@@ -83,16 +90,16 @@ const InlineSelect = ( { label, value, options, noneLabel = 'All', position = 'l
|
|
|
83
90
|
borderColor: 'border',
|
|
84
91
|
},
|
|
85
92
|
} }
|
|
86
|
-
{...props}
|
|
93
|
+
{ ...props }
|
|
87
94
|
/>
|
|
88
95
|
</Box>
|
|
89
96
|
);
|
|
90
97
|
|
|
91
98
|
return (
|
|
92
99
|
<Dialog
|
|
93
|
-
content={Content}
|
|
100
|
+
content={ Content }
|
|
94
101
|
position={ position }
|
|
95
|
-
trigger={<DialogButton sx={{ width: '100%' }} label={label} value={valueLabel} />}
|
|
102
|
+
trigger={ <DialogButton sx={ { width: '100%' } } label={ label } value={ valueLabel } /> }
|
|
96
103
|
/>
|
|
97
104
|
);
|
|
98
105
|
};
|
|
@@ -100,10 +107,7 @@ const InlineSelect = ( { label, value, options, noneLabel = 'All', position = 'l
|
|
|
100
107
|
InlineSelect.propTypes = {
|
|
101
108
|
label: PropTypes.string,
|
|
102
109
|
// https://react-select.com/props
|
|
103
|
-
value: PropTypes.oneOfType( [
|
|
104
|
-
PropTypes.array,
|
|
105
|
-
PropTypes.object,
|
|
106
|
-
] ),
|
|
110
|
+
value: PropTypes.oneOfType( [ PropTypes.array, PropTypes.object ] ),
|
|
107
111
|
options: PropTypes.array,
|
|
108
112
|
position: PropTypes.string,
|
|
109
113
|
noneLabel: PropTypes.string,
|