@automattic/vip-design-system 0.10.2 → 0.11.1
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/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/Table/Table.js +15 -15
- package/build/system/Table/Table.stories.js +46 -3
- package/build/system/Table/TableCell.js +57 -0
- package/build/system/Table/TableRow.js +12 -57
- package/build/system/Table/index.js +5 -1
- package/build/system/Time/index.js +1 -1
- package/build/system/Wizard/Wizard.stories.js +1 -1
- package/build/system/index.js +1 -0
- 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 +10 -9
- package/src/system/Table/Table.stories.jsx +39 -9
- package/src/system/Table/TableCell.js +48 -0
- package/src/system/Table/TableRow.js +10 -47
- package/src/system/Table/index.js +2 -2
- 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/index.js +2 -1
- package/src/system/theme/index.js +3 -4
- package/tokens/valet-color.json +1919 -0
- package/build/system/UsageChart/UsageChart.stories.js +0 -20
|
@@ -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,
|
package/src/system/Form/Input.js
CHANGED
|
@@ -11,51 +11,49 @@ import PropTypes from 'prop-types';
|
|
|
11
11
|
*/
|
|
12
12
|
import { Validation, Label } from '../';
|
|
13
13
|
|
|
14
|
-
const Input = React.forwardRef(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
|
|
20
|
-
'*'
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
</React.Fragment>
|
|
58
|
-
) );
|
|
14
|
+
const Input = React.forwardRef(
|
|
15
|
+
( { variant, label, forLabel, hasError, required, errorMessage, ...props }, ref ) => (
|
|
16
|
+
<React.Fragment>
|
|
17
|
+
{ label && (
|
|
18
|
+
<Label htmlFor={ forLabel }>
|
|
19
|
+
{ label }
|
|
20
|
+
{ required && '*' }
|
|
21
|
+
</Label>
|
|
22
|
+
) }
|
|
23
|
+
<input
|
|
24
|
+
{ ...props }
|
|
25
|
+
ref={ ref }
|
|
26
|
+
id={ forLabel }
|
|
27
|
+
required={ required }
|
|
28
|
+
sx={ {
|
|
29
|
+
border: '1px solid',
|
|
30
|
+
borderColor: 'border',
|
|
31
|
+
backgroundColor: 'card',
|
|
32
|
+
borderRadius: 1,
|
|
33
|
+
lineHeight: 'inherit',
|
|
34
|
+
px: 3,
|
|
35
|
+
py: 2,
|
|
36
|
+
fontSize: 2,
|
|
37
|
+
mb: 2,
|
|
38
|
+
color: 'text',
|
|
39
|
+
display: 'block',
|
|
40
|
+
width: '100%',
|
|
41
|
+
'&:focus': {
|
|
42
|
+
borderColor: 'brand.60',
|
|
43
|
+
outline: 'none',
|
|
44
|
+
},
|
|
45
|
+
'&:disabled': {
|
|
46
|
+
bg: 'backgroundSecondary',
|
|
47
|
+
},
|
|
48
|
+
'&::placeholder': {
|
|
49
|
+
color: 'placeholder',
|
|
50
|
+
},
|
|
51
|
+
} }
|
|
52
|
+
/>
|
|
53
|
+
{ hasError && errorMessage && <Validation>{ errorMessage }</Validation> }
|
|
54
|
+
</React.Fragment>
|
|
55
|
+
)
|
|
56
|
+
);
|
|
59
57
|
|
|
60
58
|
Input.propTypes = {
|
|
61
59
|
variant: PropTypes.string,
|
package/src/system/Form/Label.js
CHANGED
|
@@ -20,41 +20,43 @@ const RadioBoxGroup = ( { onChange, groupLabel, value, options, ...props } ) =>
|
|
|
20
20
|
sx={ {
|
|
21
21
|
display: 'flex',
|
|
22
22
|
gap: 2,
|
|
23
|
-
|
|
24
23
|
} }
|
|
25
24
|
{ ...props }
|
|
26
25
|
>
|
|
27
|
-
{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
'
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
'
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
>
|
|
50
|
-
<
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
26
|
+
{ options.map( ( option, index ) => (
|
|
27
|
+
<RadioGroupPrimitive.Item
|
|
28
|
+
key={ option.value }
|
|
29
|
+
value={ option.value }
|
|
30
|
+
id={ `o${ index }` }
|
|
31
|
+
sx={ {
|
|
32
|
+
p: 3,
|
|
33
|
+
background: 'none',
|
|
34
|
+
cursor: 'pointer',
|
|
35
|
+
borderRadius: 2,
|
|
36
|
+
textAlign: 'left',
|
|
37
|
+
border: '1px solid',
|
|
38
|
+
borderColor: 'border',
|
|
39
|
+
position: 'relative',
|
|
40
|
+
'&:hover': {
|
|
41
|
+
borderColor: 'grey.10',
|
|
42
|
+
},
|
|
43
|
+
'&[data-state=checked]': {
|
|
44
|
+
borderColor: 'primary',
|
|
45
|
+
},
|
|
46
|
+
} }
|
|
47
|
+
>
|
|
48
|
+
<RadioGroupPrimitive.Indicator>
|
|
49
|
+
<MdCheckCircle
|
|
50
|
+
size={ 16 }
|
|
51
|
+
sx={ { position: 'absolute', top: 2, right: 2, color: 'primary' } }
|
|
52
|
+
/>
|
|
53
|
+
</RadioGroupPrimitive.Indicator>
|
|
54
|
+
<Heading variant="h4" as="label" htmlFor={ `o${ index }` } sx={ { mb: 0 } }>
|
|
55
|
+
{ option.label }
|
|
56
|
+
</Heading>
|
|
57
|
+
<Text sx={ { color: 'muted', mb: 0, fontSize: 1 } }>{ option.description }</Text>
|
|
58
|
+
</RadioGroupPrimitive.Item>
|
|
59
|
+
) ) }
|
|
58
60
|
</RadioGroupPrimitive.Root>
|
|
59
61
|
);
|
|
60
62
|
|
|
@@ -33,5 +33,12 @@ const options = [
|
|
|
33
33
|
|
|
34
34
|
export const Default = () => {
|
|
35
35
|
const [ value, setValue ] = useState( 'one' );
|
|
36
|
-
return
|
|
36
|
+
return (
|
|
37
|
+
<RadioBoxGroup
|
|
38
|
+
value={ value }
|
|
39
|
+
onChange={ newValue => setValue( newValue ) }
|
|
40
|
+
groupLabel="group"
|
|
41
|
+
options={ options }
|
|
42
|
+
/>
|
|
43
|
+
);
|
|
37
44
|
};
|
|
@@ -14,14 +14,14 @@ import { Flex, Text } from '..';
|
|
|
14
14
|
|
|
15
15
|
// Option component
|
|
16
16
|
export const Option = ( { label, isSelected, ...props } ) => (
|
|
17
|
-
<components.Option {...props}>
|
|
18
|
-
<Flex sx={{ alignItems: 'center' }}>
|
|
19
|
-
{isSelected && (
|
|
20
|
-
<Text as="span" sx={{ mb: 0, mr: 2, color: 'green.80', svg: { display: 'block' } }}>
|
|
17
|
+
<components.Option { ...props }>
|
|
18
|
+
<Flex sx={ { alignItems: 'center' } }>
|
|
19
|
+
{ isSelected && (
|
|
20
|
+
<Text as="span" sx={ { mb: 0, mr: 2, color: 'green.80', svg: { display: 'block' } } }>
|
|
21
21
|
<MdDone />
|
|
22
22
|
</Text>
|
|
23
|
-
)}
|
|
24
|
-
<Text as="span" sx={{ mb: 0, flex: '1 1 auto', color: 'heading' }}>
|
|
23
|
+
) }
|
|
24
|
+
<Text as="span" sx={ { mb: 0, flex: '1 1 auto', color: 'heading' } }>
|
|
25
25
|
{ label }
|
|
26
26
|
</Text>
|
|
27
27
|
</Flex>
|
|
@@ -73,7 +73,7 @@ DropdownIndicator.propTypes = {
|
|
|
73
73
|
|
|
74
74
|
// ClearIndicator component
|
|
75
75
|
const ClearIndicator = ( { innerProps: { ref, ...restInnerProps }, ...props } ) => (
|
|
76
|
-
<MdClose ref={ref} {...restInnerProps} {...props} sx={{ color: 'text', mr: 2 }} />
|
|
76
|
+
<MdClose ref={ ref } { ...restInnerProps } { ...props } sx={ { color: 'text', mr: 2 } } />
|
|
77
77
|
);
|
|
78
78
|
|
|
79
79
|
ClearIndicator.propTypes = {
|
|
@@ -13,7 +13,16 @@ import { SearchSelect } from './SearchSelect';
|
|
|
13
13
|
import { InlineSelect } from './InlineSelect';
|
|
14
14
|
import { AsyncSearchSelect } from './AsyncSearchSelect';
|
|
15
15
|
|
|
16
|
-
const Select = ( {
|
|
16
|
+
const Select = ( {
|
|
17
|
+
isMulti = false,
|
|
18
|
+
isInline,
|
|
19
|
+
isAsync,
|
|
20
|
+
options,
|
|
21
|
+
label,
|
|
22
|
+
isSearch,
|
|
23
|
+
usePortal,
|
|
24
|
+
...props
|
|
25
|
+
} ) => {
|
|
17
26
|
let Component;
|
|
18
27
|
const selectRef = React.useRef();
|
|
19
28
|
const portalProps = {};
|
|
@@ -36,7 +45,17 @@ const Select = ( { isMulti = false, isInline, isAsync, options, label, isSearch,
|
|
|
36
45
|
break;
|
|
37
46
|
}
|
|
38
47
|
|
|
39
|
-
return
|
|
48
|
+
return (
|
|
49
|
+
<div ref={ selectRef } className="vip-select-component">
|
|
50
|
+
<Component
|
|
51
|
+
isMulti={ isMulti }
|
|
52
|
+
label={ label }
|
|
53
|
+
options={ options }
|
|
54
|
+
{ ...portalProps }
|
|
55
|
+
{ ...props }
|
|
56
|
+
/>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
40
59
|
};
|
|
41
60
|
|
|
42
61
|
Select.propTypes = {
|
|
@@ -39,32 +39,32 @@ export const Multi = () => {
|
|
|
39
39
|
const [ value, setValue ] = useState( [] );
|
|
40
40
|
|
|
41
41
|
return (
|
|
42
|
-
<Box sx={{ mr: 2, width: 400 }}>
|
|
42
|
+
<Box sx={ { mr: 2, width: 400 } }>
|
|
43
43
|
<Select
|
|
44
44
|
label="Type"
|
|
45
|
-
value={value}
|
|
45
|
+
value={ value }
|
|
46
46
|
isMulti
|
|
47
47
|
placeholder="Select domains..."
|
|
48
|
-
options={options}
|
|
49
|
-
onChange={newValue => setValue( newValue )}
|
|
48
|
+
options={ options }
|
|
49
|
+
onChange={ newValue => setValue( newValue ) }
|
|
50
50
|
/>
|
|
51
51
|
</Box>
|
|
52
52
|
);
|
|
53
53
|
};
|
|
54
54
|
|
|
55
|
-
export const
|
|
55
|
+
export const UsePortal = () => {
|
|
56
56
|
const [ value, setValue ] = useState( [] );
|
|
57
57
|
|
|
58
58
|
return (
|
|
59
|
-
<Box sx={{ mr: 2, width: 400 }}>
|
|
59
|
+
<Box sx={ { mr: 2, width: 400 } }>
|
|
60
60
|
<Select
|
|
61
61
|
label="Type"
|
|
62
|
-
value={value}
|
|
62
|
+
value={ value }
|
|
63
63
|
isMulti
|
|
64
64
|
placeholder="Select domains..."
|
|
65
65
|
usePortal
|
|
66
|
-
options={options}
|
|
67
|
-
onChange={newValue => setValue( newValue )}
|
|
66
|
+
options={ options }
|
|
67
|
+
onChange={ newValue => setValue( newValue ) }
|
|
68
68
|
/>
|
|
69
69
|
</Box>
|
|
70
70
|
);
|
|
@@ -74,13 +74,13 @@ export const Single = () => {
|
|
|
74
74
|
const [ value, setValue ] = useState( [] );
|
|
75
75
|
|
|
76
76
|
return (
|
|
77
|
-
<Box sx={{ mr: 2, width: 200 }}>
|
|
77
|
+
<Box sx={ { mr: 2, width: 200 } }>
|
|
78
78
|
<Select
|
|
79
79
|
label="User"
|
|
80
|
-
value={value}
|
|
80
|
+
value={ value }
|
|
81
81
|
placeholder="Select a domain..."
|
|
82
|
-
options={options}
|
|
83
|
-
onChange={newValue => setValue( newValue )}
|
|
82
|
+
options={ options }
|
|
83
|
+
onChange={ newValue => setValue( newValue ) }
|
|
84
84
|
/>
|
|
85
85
|
</Box>
|
|
86
86
|
);
|
|
@@ -90,16 +90,16 @@ export const Inline = () => {
|
|
|
90
90
|
const [ value, setValue ] = useState( [] );
|
|
91
91
|
|
|
92
92
|
return (
|
|
93
|
-
<Box sx={{ mr: 2, width: 200 }}>
|
|
93
|
+
<Box sx={ { mr: 2, width: 200 } }>
|
|
94
94
|
<Select
|
|
95
95
|
label="User"
|
|
96
|
-
value={value}
|
|
96
|
+
value={ value }
|
|
97
97
|
isInline
|
|
98
98
|
isMulti
|
|
99
99
|
noneLabel="Everyone"
|
|
100
100
|
placeholder="Filter by user..."
|
|
101
|
-
options={options}
|
|
102
|
-
onChange={newValue => setValue( newValue )}
|
|
101
|
+
options={ options }
|
|
102
|
+
onChange={ newValue => setValue( newValue ) }
|
|
103
103
|
/>
|
|
104
104
|
</Box>
|
|
105
105
|
);
|
|
@@ -107,29 +107,26 @@ export const Inline = () => {
|
|
|
107
107
|
|
|
108
108
|
export const Async = () => {
|
|
109
109
|
const [ value, setValue ] = useState( [] );
|
|
110
|
-
const loadOptions = async () =>
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
...options,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
}, 2000 );
|
|
119
|
-
} );
|
|
110
|
+
const loadOptions = async () =>
|
|
111
|
+
new Promise( resolve => {
|
|
112
|
+
setTimeout( () => {
|
|
113
|
+
resolve( {
|
|
114
|
+
options: [ ...options, { value: 'newvanilla', label: 'New Vanilla' } ],
|
|
115
|
+
} );
|
|
116
|
+
}, 2000 );
|
|
117
|
+
} );
|
|
120
118
|
|
|
121
119
|
return (
|
|
122
|
-
<Box sx={{ mr: 2, width: 200 }}>
|
|
120
|
+
<Box sx={ { mr: 2, width: 200 } }>
|
|
123
121
|
<Select
|
|
124
122
|
label="Async Select"
|
|
125
|
-
value={value}
|
|
123
|
+
value={ value }
|
|
126
124
|
isAsync
|
|
127
|
-
usePortal
|
|
128
125
|
loadOptions={ loadOptions }
|
|
129
126
|
noneLabel="Everyone"
|
|
130
127
|
placeholder="Load async..."
|
|
131
|
-
options={options}
|
|
132
|
-
onChange={newValue => setValue( newValue )}
|
|
128
|
+
options={ options }
|
|
129
|
+
onChange={ newValue => setValue( newValue ) }
|
|
133
130
|
/>
|
|
134
131
|
</Box>
|
|
135
132
|
);
|
|
@@ -137,8 +134,8 @@ export const Async = () => {
|
|
|
137
134
|
|
|
138
135
|
export const DropdownMenu = () => {
|
|
139
136
|
return (
|
|
140
|
-
<Box sx={{ mr: 2, width: 200 }}>
|
|
141
|
-
<Dialog trigger={DropdownTrigger} content={DropdownContent} sx={{ width: 200 }} />
|
|
137
|
+
<Box sx={ { mr: 2, width: 200 } }>
|
|
138
|
+
<Dialog trigger={ DropdownTrigger } content={ DropdownContent } sx={ { width: 200 } } />
|
|
142
139
|
</Box>
|
|
143
140
|
);
|
|
144
141
|
};
|
|
@@ -5,18 +5,13 @@ import { render, screen } from '@testing-library/react';
|
|
|
5
5
|
import { axe } from 'jest-axe';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
10
|
import { Select } from './Select';
|
|
11
11
|
|
|
12
12
|
describe( '<Select />', () => {
|
|
13
13
|
it( 'renders the Select component with the specified placeholder', () => {
|
|
14
|
-
render(
|
|
15
|
-
<Select
|
|
16
|
-
inputId={ 'search-select' }
|
|
17
|
-
placeholder={ 'Search...' }
|
|
18
|
-
/>
|
|
19
|
-
);
|
|
14
|
+
render( <Select inputId={ 'search-select' } placeholder={ 'Search...' } /> );
|
|
20
15
|
|
|
21
16
|
// Can't use `getByPlaceholderText` here since it's not actually being rendered as a placeholder element
|
|
22
17
|
const placeholder = screen.getByText( 'Search...' );
|
|
@@ -11,46 +11,44 @@ import PropTypes from 'prop-types';
|
|
|
11
11
|
*/
|
|
12
12
|
import { Validation, Label } from '../';
|
|
13
13
|
|
|
14
|
-
const Textarea = React.forwardRef(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
{
|
|
19
|
-
|
|
20
|
-
'*'
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
</React.Fragment>
|
|
53
|
-
) );
|
|
14
|
+
const Textarea = React.forwardRef(
|
|
15
|
+
( { variant, label, forLabel, hasError, required, errorMessage, ...props }, ref ) => (
|
|
16
|
+
<React.Fragment>
|
|
17
|
+
{ label && (
|
|
18
|
+
<Label htmlFor={ forLabel }>
|
|
19
|
+
{ label }
|
|
20
|
+
{ required && '*' }
|
|
21
|
+
</Label>
|
|
22
|
+
) }
|
|
23
|
+
<textarea
|
|
24
|
+
{ ...props }
|
|
25
|
+
ref={ ref }
|
|
26
|
+
sx={ {
|
|
27
|
+
border: '1px solid',
|
|
28
|
+
borderColor: 'border',
|
|
29
|
+
backgroundColor: 'card',
|
|
30
|
+
borderRadius: 1,
|
|
31
|
+
lineHeight: 'inherit',
|
|
32
|
+
px: 3,
|
|
33
|
+
py: 2,
|
|
34
|
+
fontSize: 2,
|
|
35
|
+
mb: 2,
|
|
36
|
+
color: 'text',
|
|
37
|
+
display: 'block',
|
|
38
|
+
width: '100%',
|
|
39
|
+
'&:focus': {
|
|
40
|
+
borderColor: 'brand.60',
|
|
41
|
+
outline: 'none',
|
|
42
|
+
},
|
|
43
|
+
'&:disabled': {
|
|
44
|
+
backgroundColor: 'background',
|
|
45
|
+
},
|
|
46
|
+
} }
|
|
47
|
+
/>
|
|
48
|
+
{ hasError && errorMessage && <Validation>{ errorMessage }</Validation> }
|
|
49
|
+
</React.Fragment>
|
|
50
|
+
)
|
|
51
|
+
);
|
|
54
52
|
|
|
55
53
|
Textarea.propTypes = {
|
|
56
54
|
variant: PropTypes.string,
|
|
@@ -8,8 +8,8 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
|
|
9
9
|
const Toggle = ( { name = 'toggle', className = null, ...props } ) => (
|
|
10
10
|
<CheckBoxWrapper className={ classNames( 'vip-checkbox-component', className ) }>
|
|
11
|
-
<CheckBox name={name} id={name} type="checkbox" {...props} />
|
|
12
|
-
<CheckBoxLabel htmlFor={name} />
|
|
11
|
+
<CheckBox name={ name } id={ name } type="checkbox" { ...props } />
|
|
12
|
+
<CheckBoxLabel htmlFor={ name } />
|
|
13
13
|
</CheckBoxWrapper>
|
|
14
14
|
);
|
|
15
15
|
|
|
@@ -20,13 +20,11 @@ Toggle.propTypes = {
|
|
|
20
20
|
|
|
21
21
|
export { Toggle };
|
|
22
22
|
|
|
23
|
-
const CheckBoxWrapper = props =>
|
|
24
|
-
<div sx={{ position: 'relative' }} {...props} />
|
|
25
|
-
);
|
|
23
|
+
const CheckBoxWrapper = props => <div sx={ { position: 'relative' } } { ...props } />;
|
|
26
24
|
|
|
27
25
|
const CheckBoxLabel = props => (
|
|
28
26
|
<label
|
|
29
|
-
sx={{
|
|
27
|
+
sx={ {
|
|
30
28
|
position: 'absolute',
|
|
31
29
|
top: '0',
|
|
32
30
|
left: '0',
|
|
@@ -46,14 +44,14 @@ const CheckBoxLabel = props => (
|
|
|
46
44
|
boxShadow: 'low',
|
|
47
45
|
transition: '0.2s',
|
|
48
46
|
},
|
|
49
|
-
}}
|
|
50
|
-
{...props}
|
|
47
|
+
} }
|
|
48
|
+
{ ...props }
|
|
51
49
|
/>
|
|
52
50
|
);
|
|
53
51
|
|
|
54
52
|
const CheckBox = props => (
|
|
55
53
|
<input
|
|
56
|
-
sx={{
|
|
54
|
+
sx={ {
|
|
57
55
|
opacity: '0',
|
|
58
56
|
zIndex: '1',
|
|
59
57
|
borderRadius: '15px',
|
|
@@ -74,7 +72,7 @@ const CheckBox = props => (
|
|
|
74
72
|
transition: '0.2s',
|
|
75
73
|
},
|
|
76
74
|
},
|
|
77
|
-
}}
|
|
78
|
-
{...props}
|
|
75
|
+
} }
|
|
76
|
+
{ ...props }
|
|
79
77
|
/>
|
|
80
78
|
);
|