@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.
Files changed (128) hide show
  1. package/.eslines.json +8 -8
  2. package/.eslintrc.json +9 -4
  3. package/.github/PULL_REQUEST_TEMPLATE.md +1 -1
  4. package/.github/workflows/nodejs.yaml +14 -14
  5. package/.prettierrc +1 -2
  6. package/.storybook/main.js +1 -1
  7. package/.storybook/preview.js +4 -8
  8. package/README.md +1 -0
  9. package/babel.config.js +1 -1
  10. package/build/system/Avatar/Avatar.js +2 -1
  11. package/build/system/BlankState/BlankState.stories.js +3 -3
  12. package/build/system/BlankState/BlankState.test.js +2 -2
  13. package/build/system/Card/Card.test.js +0 -2
  14. package/build/system/Code/Code.js +7 -2
  15. package/build/system/Code/Code.test.js +22 -57
  16. package/build/system/Form/MultiSelect.js +45 -25
  17. package/build/system/Form/Select.stories.js +3 -4
  18. package/build/system/Form/Select.test.js +2 -2
  19. package/build/system/Notification/Notification.js +24 -15
  20. package/build/system/Notification/Notification.stories.js +14 -4
  21. package/build/system/OptionRow/OptionRow.js +23 -17
  22. package/build/system/OptionRow/OptionRow.stories.js +5 -5
  23. package/build/system/OptionRow/OptionRow.test.js +4 -4
  24. package/build/system/ResourceList/ResourceList.js +34 -25
  25. package/build/system/ResourceList/ResourceList.stories.js +2 -0
  26. package/build/system/ScreenReaderText/ScreenReader.test.js +37 -0
  27. package/build/system/ScreenReaderText/ScreenReaderText.js +49 -0
  28. package/build/system/ScreenReaderText/index.js +7 -0
  29. package/build/system/Time/index.js +1 -1
  30. package/build/system/UsageChart/UsageChart.js +47 -45
  31. package/build/system/UsageChart/UsageChart.stories.js +8 -8
  32. package/build/system/UsageChart/index.js +3 -3
  33. package/build/system/Wizard/Wizard.stories.js +1 -1
  34. package/package.json +8 -4
  35. package/src/system/Avatar/Avatar.js +1 -0
  36. package/src/system/Avatar/index.js +0 -1
  37. package/src/system/Badge/index.js +0 -1
  38. package/src/system/BlankState/BlankState.js +8 -5
  39. package/src/system/BlankState/BlankState.stories.jsx +5 -4
  40. package/src/system/BlankState/BlankState.test.js +21 -21
  41. package/src/system/BlankState/index.js +0 -1
  42. package/src/system/Box/Box.js +7 -1
  43. package/src/system/Box/index.js +0 -1
  44. package/src/system/Button/Button.js +3 -3
  45. package/src/system/Button/Button.stories.jsx +2 -2
  46. package/src/system/Button/index.js +0 -1
  47. package/src/system/Card/Card.js +4 -4
  48. package/src/system/Card/Card.test.js +1 -2
  49. package/src/system/Card/index.js +0 -1
  50. package/src/system/Code/Code.js +6 -2
  51. package/src/system/Code/Code.stories.jsx +10 -5
  52. package/src/system/Code/Code.test.js +3 -16
  53. package/src/system/ConfirmationDialog/ConfirmationDialog.js +8 -1
  54. package/src/system/Dialog/Dialog.js +17 -8
  55. package/src/system/Dialog/Dialog.stories.jsx +9 -13
  56. package/src/system/Dialog/DialogButton.js +18 -14
  57. package/src/system/Dialog/DialogDivider.js +1 -1
  58. package/src/system/Dialog/DialogMenu.js +1 -5
  59. package/src/system/Dialog/DialogMenuItem.js +4 -8
  60. package/src/system/Dialog/DialogTrigger.js +1 -1
  61. package/src/system/Dialog/index.js +0 -1
  62. package/src/system/Flex/Flex.js +1 -1
  63. package/src/system/Flex/index.js +0 -1
  64. package/src/system/Form/AsyncSearchSelect.js +3 -7
  65. package/src/system/Form/Checkbox.js +32 -28
  66. package/src/system/Form/InlineSelect.js +21 -17
  67. package/src/system/Form/Input.js +43 -45
  68. package/src/system/Form/Label.js +2 -2
  69. package/src/system/Form/RadioBoxGroup.js +34 -32
  70. package/src/system/Form/RadioBoxGroup.stories.jsx +8 -1
  71. package/src/system/Form/SearchSelect.js +7 -7
  72. package/src/system/Form/Select.js +21 -2
  73. package/src/system/Form/Select.stories.jsx +31 -34
  74. package/src/system/Form/Select.test.js +3 -8
  75. package/src/system/Form/Textarea.js +38 -40
  76. package/src/system/Form/Toggle.js +9 -11
  77. package/src/system/Form/ToggleGroup.js +29 -31
  78. package/src/system/Form/ToggleGroup.stories.jsx +8 -1
  79. package/src/system/Form/ToggleRow.js +6 -1
  80. package/src/system/Form/Validation.js +6 -1
  81. package/src/system/Form/index.js +13 -1
  82. package/src/system/Grid/Grid.js +1 -1
  83. package/src/system/Grid/index.js +0 -1
  84. package/src/system/Heading/Heading.js +4 -4
  85. package/src/system/Heading/index.js +0 -1
  86. package/src/system/Link/index.js +0 -1
  87. package/src/system/Notice/Notice.js +27 -13
  88. package/src/system/Notice/Notice.stories.jsx +6 -8
  89. package/src/system/Notice/index.js +0 -1
  90. package/src/system/Notification/Notification.js +25 -20
  91. package/src/system/Notification/Notification.stories.jsx +4 -4
  92. package/src/system/Notification/index.js +0 -1
  93. package/src/system/OptionRow/OptionRow.js +46 -44
  94. package/src/system/OptionRow/OptionRow.stories.jsx +10 -8
  95. package/src/system/OptionRow/OptionRow.test.js +12 -11
  96. package/src/system/OptionRow/index.js +0 -1
  97. package/src/system/Progress/Progress.js +3 -1
  98. package/src/system/Progress/Progress.stories.jsx +4 -4
  99. package/src/system/Progress/index.js +0 -1
  100. package/src/system/ResourceList/ResourceItem.js +15 -15
  101. package/src/system/ResourceList/ResourceList.js +28 -16
  102. package/src/system/ResourceList/ResourceList.stories.jsx +77 -71
  103. package/src/system/ScreenReaderText/ScreenReader.test.js +22 -0
  104. package/src/system/ScreenReaderText/ScreenReaderText.js +40 -0
  105. package/src/system/ScreenReaderText/index.js +7 -0
  106. package/src/system/Spinner/Spinner.js +4 -4
  107. package/src/system/Spinner/index.js +0 -1
  108. package/src/system/Table/Table.js +5 -5
  109. package/src/system/Table/Table.stories.jsx +10 -8
  110. package/src/system/Table/index.js +0 -1
  111. package/src/system/Tabs/Tabs.js +3 -3
  112. package/src/system/Tabs/index.js +0 -1
  113. package/src/system/Text/Text.js +3 -3
  114. package/src/system/Text/Text.stories.jsx +4 -6
  115. package/src/system/Text/index.js +0 -1
  116. package/src/system/Time/Time.stories.jsx +2 -6
  117. package/src/system/Time/index.js +5 -5
  118. package/src/system/Timeline/Timeline.js +6 -12
  119. package/src/system/Timeline/Timeline.stories.jsx +3 -12
  120. package/src/system/Timeline/index.js +0 -1
  121. package/src/system/Tooltip/Tooltip.js +4 -8
  122. package/src/system/Wizard/Wizard.js +23 -21
  123. package/src/system/Wizard/Wizard.stories.jsx +7 -12
  124. package/src/system/Wizard/WizardStep.js +8 -8
  125. package/src/system/Wizard/WizardStepHorizontal.js +4 -4
  126. package/src/system/Wizard/index.js +0 -1
  127. package/src/system/theme/index.js +3 -4
  128. package/tokens/valet-color.json +1919 -0
@@ -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 ) => <ThemeBox ref={ref} className={ classNames( 'vip-box-component', props.className ) } {...props} /> );
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 = {
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * Internal dependencies
4
3
  */
@@ -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>
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * Internal dependencies
4
3
  */
@@ -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, fireEvent, waitFor } from '@testing-library/react';
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
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * Internal dependencies
4
3
  */
@@ -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 ? 'Copied!' : <MdContentCopy /> }
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 showCopy={true} onCopy={
23
- // eslint-disable-next-line no-console
24
- () => console.info( 'Hello world' )
25
- }>Code with Icon and Click callback — console.info</Code>
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( 'Copied!' ) ).toBeInTheDocument();
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 = ( { title, body, onClose, label = 'Confirm', onConfirm, className = null } ) => (
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 = ( { trigger, position = 'left', startOpen = false, content, disabled = false, ...props } ) => {
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 onClick={ e => e.stopPropagation() } sx={ { position: 'relative' } } ref={ dialogRef } className="vip-dialog-component">
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&lsquo;t
43
- necessarily need the context behind.
41
+ <Text sx={ { fontSize: 3 } }>
42
+ A modal is used to perform more detailed actions that don&lsquo;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 variant={ variant } sx={ {
16
- textAlign: 'left',
17
- display: 'inline-flex',
18
- py: 2,
19
- pl: 3,
20
- pr: 2,
21
- alignItems: 'center' } } { ...props }
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
  );
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  const DialogDivider = props => (
8
- <div sx={{ height: 1, backgroundColor: 'border', my: 1 }} { ...props } />
8
+ <div sx={ { height: 1, backgroundColor: 'border', my: 1 } } { ...props } />
9
9
  );
10
10
 
11
11
  export { DialogDivider };
@@ -5,11 +5,7 @@
5
5
  */
6
6
 
7
7
  const DialogMenu = props => (
8
- <ul
9
- role="menu"
10
- sx={{ listStyleType: 'none', m: 0, px: 0, py: 1 }}
11
- {...props}
12
- />
8
+ <ul role="menu" sx={ { listStyleType: 'none', m: 0, px: 0, py: 1 } } { ...props } />
13
9
  );
14
10
 
15
11
  export { DialogMenu };
@@ -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
- { children }
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
  );
@@ -6,6 +6,6 @@
6
6
 
7
7
  import { Box } from '../';
8
8
 
9
- const DialogTrigger = props => <Box sx={{ display: 'inline' }} {...props} />;
9
+ const DialogTrigger = props => <Box sx={ { display: 'inline' } } { ...props } />;
10
10
 
11
11
  export { DialogTrigger };
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * Internal dependencies
4
3
  */
@@ -5,6 +5,6 @@
5
5
  */
6
6
  import { Flex as ThemeFlex } from 'theme-ui';
7
7
 
8
- const Flex = props => <ThemeFlex {...props} />;
8
+ const Flex = props => <ThemeFlex { ...props } />;
9
9
 
10
10
  export { Flex };
@@ -1,4 +1,3 @@
1
-
2
1
  /**
3
2
  * Internal dependencies
4
3
  */
@@ -7,19 +7,15 @@ import PropTypes from 'prop-types';
7
7
  import { withAsyncPaginate } from 'react-select-async-paginate';
8
8
 
9
9
  /**
10
- * Internal dependencies
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 => <CheckboxPrimitive.Root
11
- sx={ {
12
- all: 'unset',
13
- backgroundColor: 'grey.10',
14
- width: 16,
15
- height: 16,
16
- borderRadius: 1,
17
- display: 'flex',
18
- alignItems: 'center',
19
- justifyContent: 'center',
20
- '&:hover': { backgroundColor: 'grey.20' },
21
- '&:focus': { boxShadow: '0 0 0 2px black' },
22
- '&[data-state=checked]': {
23
- backgroundColor: 'primary',
24
- color: 'brand.0',
25
- },
26
- svg: {
27
- display: 'block',
28
- },
29
- } }
30
- { ...props }
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 => <CheckboxPrimitive.Indicator
34
- sx={ {
35
- color: 'brand.0',
36
- } }
37
- { ...props }
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 = ( { label, value, options, noneLabel = 'All', position = 'left', ...props } ) => {
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,