@automattic/vip-design-system 0.26.0 → 0.26.2
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/.storybook/preview.js +6 -0
- package/build/system/Accordion/Accordion.js +5 -4
- package/build/system/Form/Checkbox.stories.js +85 -0
- package/build/system/Form/Input.js +55 -31
- package/build/system/Form/Input.stories.js +34 -4
- package/build/system/Form/Radio.stories.js +95 -0
- package/build/system/Form/Select.stories.js +1 -1
- package/build/system/Form/Textarea.js +14 -53
- package/build/system/Form/Textarea.stories.js +67 -0
- package/build/system/Form/Validation.js +17 -10
- package/build/system/NewConfirmationDialog/NewConfirmationDialog.stories.js +1 -1
- package/build/system/NewDialog/NewDialog.stories.js +1 -1
- package/build/system/NewForm/FormAutocomplete.js +22 -6
- package/build/system/NewForm/FormAutocomplete.stories.js +13 -2
- package/build/system/NewForm/index.js +12 -0
- package/build/system/NewTabs/Tabs.stories.js +11 -5
- package/build/system/NewTabs/TabsList.js +1 -1
- package/build/system/ResourceList/ResourceList.js +35 -26
- package/build/system/ResourceList/ResourceList.stories.js +2 -0
- package/build/system/Tabs/Tabs.stories.js +1 -1
- package/package.json +1 -1
- package/src/system/Accordion/Accordion.js +2 -1
- package/src/system/Form/Checkbox.stories.jsx +54 -0
- package/src/system/Form/Input.js +44 -27
- package/src/system/Form/Input.stories.jsx +29 -4
- package/src/system/Form/Radio.stories.jsx +66 -0
- package/src/system/Form/Select.stories.jsx +1 -1
- package/src/system/Form/Textarea.js +4 -49
- package/src/system/Form/Textarea.stories.jsx +40 -0
- package/src/system/Form/Validation.js +14 -8
- package/src/system/NewConfirmationDialog/NewConfirmationDialog.stories.jsx +1 -1
- package/src/system/NewDialog/NewDialog.stories.jsx +1 -1
- package/src/system/NewForm/FormAutocomplete.js +17 -6
- package/src/system/NewForm/FormAutocomplete.stories.jsx +13 -0
- package/src/system/NewForm/index.js +4 -1
- package/src/system/NewTabs/Tabs.stories.jsx +7 -3
- package/src/system/NewTabs/TabsList.js +1 -1
- package/src/system/Tabs/Tabs.stories.jsx +1 -1
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
5
|
exports.__esModule = true;
|
|
6
|
-
exports["default"] = exports.Inline = exports.Default = void 0;
|
|
6
|
+
exports["default"] = exports.WithDefaultValue = exports.Inline = exports.Default = void 0;
|
|
7
7
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
|
|
@@ -96,4 +96,15 @@ var Inline = function Inline() {
|
|
|
96
96
|
});
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
exports.Inline = Inline;
|
|
99
|
+
exports.Inline = Inline;
|
|
100
|
+
|
|
101
|
+
var WithDefaultValue = function WithDefaultValue() {
|
|
102
|
+
var customArgs = (0, _extends2["default"])({}, args, {
|
|
103
|
+
value: 'Chocolate'
|
|
104
|
+
});
|
|
105
|
+
return (0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
106
|
+
children: (0, _jsxRuntime.jsx)(DefaultComponent, (0, _extends2["default"])({}, customArgs))
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
exports.WithDefaultValue = WithDefaultValue;
|
|
@@ -7,8 +7,20 @@ var _FormSelect = require("./FormSelect");
|
|
|
7
7
|
|
|
8
8
|
var _FormAutocomplete = require("./FormAutocomplete");
|
|
9
9
|
|
|
10
|
+
var _Textarea = require("../Form/Textarea");
|
|
11
|
+
|
|
12
|
+
exports.Textarea = _Textarea.Textarea;
|
|
13
|
+
|
|
14
|
+
var _Input = require("../Form/Input");
|
|
15
|
+
|
|
16
|
+
exports.Input = _Input.Input;
|
|
17
|
+
|
|
10
18
|
var _Form = require("./Form");
|
|
11
19
|
|
|
20
|
+
var _Label = require("../Form/Label");
|
|
21
|
+
|
|
22
|
+
exports.Label = _Label.Label;
|
|
23
|
+
|
|
12
24
|
/**
|
|
13
25
|
* Internal dependencies
|
|
14
26
|
*/
|
|
@@ -11,7 +11,7 @@ var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
13
|
var _default = {
|
|
14
|
-
title: '
|
|
14
|
+
title: 'Tabs',
|
|
15
15
|
component: _.NewTabs
|
|
16
16
|
};
|
|
17
17
|
exports["default"] = _default;
|
|
@@ -37,16 +37,22 @@ var Default = function Default() {
|
|
|
37
37
|
})]
|
|
38
38
|
}), (0, _jsxRuntime.jsx)(_.TabsContent, {
|
|
39
39
|
value: "all",
|
|
40
|
-
children: (0, _jsxRuntime.
|
|
41
|
-
children: "All content"
|
|
40
|
+
children: (0, _jsxRuntime.jsxs)(_.Text, {
|
|
41
|
+
children: ["All content ", (0, _jsxRuntime.jsx)("a", {
|
|
42
|
+
href: "https://google.com",
|
|
43
|
+
children: "https://google.com"
|
|
44
|
+
})]
|
|
42
45
|
})
|
|
43
46
|
}), (0, _jsxRuntime.jsx)(_.TabsContent, {
|
|
44
47
|
value: "live",
|
|
45
48
|
children: "Live content"
|
|
46
49
|
}), (0, _jsxRuntime.jsx)(_.TabsContent, {
|
|
47
50
|
value: "dev",
|
|
48
|
-
children: (0, _jsxRuntime.
|
|
49
|
-
children: "In Development content"
|
|
51
|
+
children: (0, _jsxRuntime.jsxs)(_.Text, {
|
|
52
|
+
children: ["In Development content ", (0, _jsxRuntime.jsx)("button", {
|
|
53
|
+
type: "button",
|
|
54
|
+
children: "Hey I am a button"
|
|
55
|
+
}), ' ']
|
|
50
56
|
})
|
|
51
57
|
})]
|
|
52
58
|
});
|
|
@@ -9,6 +9,8 @@ var _extends3 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
9
9
|
|
|
10
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
11
11
|
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
|
|
12
14
|
var _ = require("..");
|
|
13
15
|
|
|
14
16
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
@@ -51,7 +53,7 @@ var StyledListItem = function StyledListItem(props) {
|
|
|
51
53
|
sx: {
|
|
52
54
|
py: 2,
|
|
53
55
|
borderBottom: '1px solid',
|
|
54
|
-
borderColor: '
|
|
56
|
+
borderColor: 'borders.2',
|
|
55
57
|
listStyleType: 'none',
|
|
56
58
|
margin: 0,
|
|
57
59
|
px: 0
|
|
@@ -85,6 +87,37 @@ var ResourceList = function ResourceList(_ref) {
|
|
|
85
87
|
});
|
|
86
88
|
};
|
|
87
89
|
|
|
90
|
+
var renderGoupedItems = function renderGoupedItems() {
|
|
91
|
+
return (0, _react.useMemo)(function () {
|
|
92
|
+
return Object.keys(groupedItems).map(function (groupName, index) {
|
|
93
|
+
return (0, _jsxRuntime.jsxs)(_.Box, {
|
|
94
|
+
sx: {
|
|
95
|
+
mb: 4
|
|
96
|
+
},
|
|
97
|
+
as: "li",
|
|
98
|
+
children: [(0, _jsxRuntime.jsx)(_.Heading, {
|
|
99
|
+
variant: "h4",
|
|
100
|
+
as: "h4",
|
|
101
|
+
sx: {
|
|
102
|
+
mb: 3
|
|
103
|
+
},
|
|
104
|
+
children: groupName
|
|
105
|
+
}), (0, _jsxRuntime.jsx)(_.Box, {
|
|
106
|
+
as: "ul",
|
|
107
|
+
sx: {
|
|
108
|
+
listStyleType: 'none',
|
|
109
|
+
m: 0,
|
|
110
|
+
p: 0,
|
|
111
|
+
borderTop: '1px solid',
|
|
112
|
+
borderColor: 'border'
|
|
113
|
+
},
|
|
114
|
+
children: renderItemList(groupedItems[groupName])
|
|
115
|
+
})]
|
|
116
|
+
}, index);
|
|
117
|
+
});
|
|
118
|
+
}, [groupedItems]);
|
|
119
|
+
};
|
|
120
|
+
|
|
88
121
|
return (0, _jsxRuntime.jsx)(_.Box, {
|
|
89
122
|
as: "ul",
|
|
90
123
|
sx: {
|
|
@@ -93,31 +126,7 @@ var ResourceList = function ResourceList(_ref) {
|
|
|
93
126
|
p: 0
|
|
94
127
|
},
|
|
95
128
|
className: "vip-resource-list-component",
|
|
96
|
-
children: groupedByDay ?
|
|
97
|
-
return (0, _jsxRuntime.jsxs)(_.Box, {
|
|
98
|
-
sx: {
|
|
99
|
-
mb: 4
|
|
100
|
-
},
|
|
101
|
-
children: [(0, _jsxRuntime.jsx)(_.Heading, {
|
|
102
|
-
variant: "h4",
|
|
103
|
-
as: "h4",
|
|
104
|
-
sx: {
|
|
105
|
-
mb: 3
|
|
106
|
-
},
|
|
107
|
-
children: groupName
|
|
108
|
-
}), (0, _jsxRuntime.jsx)(_.Box, {
|
|
109
|
-
as: "ul",
|
|
110
|
-
sx: {
|
|
111
|
-
listStyleType: 'none',
|
|
112
|
-
m: 0,
|
|
113
|
-
p: 0,
|
|
114
|
-
borderTop: '1px solid',
|
|
115
|
-
borderColor: 'border'
|
|
116
|
-
},
|
|
117
|
-
children: renderItemList(groupedItems[groupName])
|
|
118
|
-
})]
|
|
119
|
-
}, index);
|
|
120
|
-
}) : renderItemList(items)
|
|
129
|
+
children: groupedByDay ? renderGoupedItems(groupedItems) : renderItemList(items)
|
|
121
130
|
});
|
|
122
131
|
};
|
|
123
132
|
|
|
@@ -129,6 +129,7 @@ var Grouped = function Grouped() {
|
|
|
129
129
|
children: "#443"
|
|
130
130
|
})]
|
|
131
131
|
}), (0, _jsxRuntime.jsxs)(_.Text, {
|
|
132
|
+
as: "div",
|
|
132
133
|
sx: {
|
|
133
134
|
mb: 0,
|
|
134
135
|
fontSize: 1,
|
|
@@ -337,6 +338,7 @@ var Relative = function Relative() {
|
|
|
337
338
|
children: "Running"
|
|
338
339
|
})]
|
|
339
340
|
}), (0, _jsxRuntime.jsxs)(_.Text, {
|
|
341
|
+
as: "div",
|
|
340
342
|
sx: {
|
|
341
343
|
mb: 0,
|
|
342
344
|
color: 'muted',
|
package/package.json
CHANGED
|
@@ -85,6 +85,7 @@ export const Trigger = React.forwardRef(
|
|
|
85
85
|
'&[data-state="open"]': {
|
|
86
86
|
backgroundColor: 'backgroundSecondary',
|
|
87
87
|
borderBottom: theme => `1px solid ${ theme.colors.border }`,
|
|
88
|
+
'.vip-accordion-trigger-indicator': { transform: 'rotate(270deg)' },
|
|
88
89
|
},
|
|
89
90
|
'&:hover': { backgroundColor: 'backgroundSecondary' },
|
|
90
91
|
} }
|
|
@@ -93,12 +94,12 @@ export const Trigger = React.forwardRef(
|
|
|
93
94
|
>
|
|
94
95
|
{ children }
|
|
95
96
|
<MdChevronRight
|
|
97
|
+
className="vip-accordion-trigger-indicator"
|
|
96
98
|
sx={ {
|
|
97
99
|
fontSize: 3,
|
|
98
100
|
color: 'text',
|
|
99
101
|
transform: 'rotate(90deg)',
|
|
100
102
|
transition: 'transform 300ms cubic-bezier(0.87, 0, 0.13, 1)',
|
|
101
|
-
'[data-state=open] &': { transform: 'rotate(270deg)' },
|
|
102
103
|
} }
|
|
103
104
|
aria-hidden
|
|
104
105
|
/>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Form } from '..';
|
|
10
|
+
import { Checkbox } from './Checkbox';
|
|
11
|
+
import { Label } from './Label';
|
|
12
|
+
import { Flex } from '../Flex';
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
title: 'Form/Checkbox',
|
|
16
|
+
component: Checkbox,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const Default = () => {
|
|
20
|
+
const [ checked, setChecked ] = useState( true );
|
|
21
|
+
const [ checked2, setChecked2 ] = useState( false );
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Form.Root>
|
|
25
|
+
<fieldset>
|
|
26
|
+
<legend>Tell me your prefereces</legend>
|
|
27
|
+
|
|
28
|
+
<Flex sx={ { alignItems: 'center' } }>
|
|
29
|
+
<Checkbox
|
|
30
|
+
id="check1"
|
|
31
|
+
checked={ checked }
|
|
32
|
+
aria-labelledby="label-check1"
|
|
33
|
+
onCheckedChange={ setChecked }
|
|
34
|
+
/>
|
|
35
|
+
<Label sx={ { m: 0, ml: 2 } } htmlFor="check1" id="label-check1">
|
|
36
|
+
This option
|
|
37
|
+
</Label>
|
|
38
|
+
</Flex>
|
|
39
|
+
|
|
40
|
+
<Flex sx={ { alignItems: 'center' } }>
|
|
41
|
+
<Checkbox
|
|
42
|
+
id="check2"
|
|
43
|
+
checked={ checked2 }
|
|
44
|
+
aria-labelledby="label-check2"
|
|
45
|
+
onCheckedChange={ setChecked2 }
|
|
46
|
+
/>
|
|
47
|
+
<Label sx={ { m: 0, ml: 2 } } htmlFor="check2" id="label-check2">
|
|
48
|
+
This option too
|
|
49
|
+
</Label>
|
|
50
|
+
</Flex>
|
|
51
|
+
</fieldset>
|
|
52
|
+
</Form.Root>
|
|
53
|
+
);
|
|
54
|
+
};
|
package/src/system/Form/Input.js
CHANGED
|
@@ -10,45 +10,61 @@ import PropTypes from 'prop-types';
|
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
12
|
import { Validation, Label } from '../';
|
|
13
|
+
import { Input as ThemeInput } from 'theme-ui';
|
|
14
|
+
|
|
15
|
+
const RequiredLabel = () => (
|
|
16
|
+
<span sx={ { color: 'error', display: 'inline-block', ml: 2, fontSize: 1 } }>(Required)</span>
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const inputStyles = {
|
|
20
|
+
unset: 'all',
|
|
21
|
+
border: '1px solid',
|
|
22
|
+
borderColor: 'border',
|
|
23
|
+
backgroundColor: 'card',
|
|
24
|
+
borderRadius: 1,
|
|
25
|
+
lineHeight: 'inherit',
|
|
26
|
+
px: 3,
|
|
27
|
+
py: 2,
|
|
28
|
+
fontSize: 2,
|
|
29
|
+
mb: 2,
|
|
30
|
+
color: 'text',
|
|
31
|
+
display: 'block',
|
|
32
|
+
width: '100%',
|
|
33
|
+
'&:focus': theme => theme.outline,
|
|
34
|
+
'&:focus-visible': theme => theme.outline,
|
|
35
|
+
'&:disabled': {
|
|
36
|
+
bg: 'backgroundSecondary',
|
|
37
|
+
},
|
|
38
|
+
'&::placeholder': {
|
|
39
|
+
color: 'placeholder',
|
|
40
|
+
},
|
|
41
|
+
};
|
|
13
42
|
|
|
14
43
|
const Input = React.forwardRef(
|
|
15
|
-
( { variant, label, forLabel, hasError, required, errorMessage, ...props }, ref ) => (
|
|
44
|
+
( { variant, label, forLabel, hasError, required, sx = {}, errorMessage, ...props }, ref ) => (
|
|
16
45
|
<React.Fragment>
|
|
17
46
|
{ label && (
|
|
18
47
|
<Label htmlFor={ forLabel }>
|
|
19
48
|
{ label }
|
|
20
|
-
{ required &&
|
|
49
|
+
{ required && <RequiredLabel /> }
|
|
21
50
|
</Label>
|
|
22
51
|
) }
|
|
23
|
-
|
|
24
|
-
|
|
52
|
+
|
|
53
|
+
<ThemeInput
|
|
25
54
|
ref={ ref }
|
|
26
55
|
id={ forLabel }
|
|
27
56
|
required={ required }
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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': theme => theme.outline,
|
|
42
|
-
'&:focus-visible': theme => theme.outline,
|
|
43
|
-
'&:disabled': {
|
|
44
|
-
bg: 'backgroundSecondary',
|
|
45
|
-
},
|
|
46
|
-
'&::placeholder': {
|
|
47
|
-
color: 'placeholder',
|
|
48
|
-
},
|
|
49
|
-
} }
|
|
57
|
+
noValidate
|
|
58
|
+
aria-describedby={ hasError ? `describe-${ forLabel }-validation` : undefined }
|
|
59
|
+
sx={ { ...inputStyles, ...sx } }
|
|
60
|
+
{ ...props }
|
|
50
61
|
/>
|
|
51
|
-
|
|
62
|
+
|
|
63
|
+
{ hasError && errorMessage && (
|
|
64
|
+
<Validation isValid={ false } describedId={ forLabel }>
|
|
65
|
+
{ errorMessage }
|
|
66
|
+
</Validation>
|
|
67
|
+
) }
|
|
52
68
|
</React.Fragment>
|
|
53
69
|
)
|
|
54
70
|
);
|
|
@@ -60,6 +76,7 @@ Input.propTypes = {
|
|
|
60
76
|
required: PropTypes.bool,
|
|
61
77
|
forLabel: PropTypes.string,
|
|
62
78
|
errorMessage: PropTypes.string,
|
|
79
|
+
sx: PropTypes.object,
|
|
63
80
|
};
|
|
64
81
|
|
|
65
82
|
Input.displayName = 'Input';
|
|
@@ -3,11 +3,36 @@
|
|
|
3
3
|
/**
|
|
4
4
|
* Internal dependencies
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
6
|
+
import { Form } from '..';
|
|
7
7
|
|
|
8
8
|
export default {
|
|
9
|
-
title: 'Input',
|
|
10
|
-
component: Input,
|
|
9
|
+
title: 'Form/Input',
|
|
11
10
|
};
|
|
12
11
|
|
|
13
|
-
export const Default = () =>
|
|
12
|
+
export const Default = () => (
|
|
13
|
+
<Form.Root>
|
|
14
|
+
<Form.Input
|
|
15
|
+
placeholder="Your input here..."
|
|
16
|
+
label="Always add a label to inputs"
|
|
17
|
+
forLabel="input-simple"
|
|
18
|
+
/>
|
|
19
|
+
|
|
20
|
+
<hr sx={ { my: 4 } } />
|
|
21
|
+
|
|
22
|
+
<Form.Input
|
|
23
|
+
forLabel="input-with-error"
|
|
24
|
+
label="Error Input"
|
|
25
|
+
errorMessage="Please type numeric characters only"
|
|
26
|
+
hasError
|
|
27
|
+
/>
|
|
28
|
+
|
|
29
|
+
<hr sx={ { my: 4 } } />
|
|
30
|
+
|
|
31
|
+
<Form.Input forLabel="input-with-required" label="Required" required />
|
|
32
|
+
|
|
33
|
+
<hr sx={ { my: 4 } } />
|
|
34
|
+
|
|
35
|
+
<Form.Label htmlFor="input-with-custom-label">Custom Label outside the Input</Form.Label>
|
|
36
|
+
<Form.Input forLabel="input-with-custom-label" required />
|
|
37
|
+
</Form.Root>
|
|
38
|
+
);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useState } from 'react';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { Form } from '..';
|
|
10
|
+
import { Radio } from './Radio';
|
|
11
|
+
import { Label } from './Label';
|
|
12
|
+
import { Flex } from '../Flex';
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
title: 'Form/Radio',
|
|
16
|
+
component: Radio,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const Default = () => {
|
|
20
|
+
const [ checked, setChecked ] = useState( 'a' );
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Form.Root>
|
|
24
|
+
<p>
|
|
25
|
+
Per recommendation, if you have a Radio button, use a Fieldset with a legend as wrapper to
|
|
26
|
+
your options.{ ' ' }
|
|
27
|
+
<a href="https://a11y-collective.github.io/demos/en/accessible-code/form-fieldsets.html">
|
|
28
|
+
Reference to Form fieldsets
|
|
29
|
+
</a>
|
|
30
|
+
</p>
|
|
31
|
+
<fieldset>
|
|
32
|
+
<legend sx={ { mb: 0, fontSize: 2, fontWeight: 'bold' } }>
|
|
33
|
+
Apply the policy to these domains
|
|
34
|
+
</legend>
|
|
35
|
+
|
|
36
|
+
<Flex sx={ { alignItems: 'center' } }>
|
|
37
|
+
<Radio
|
|
38
|
+
name="includeSubdomains"
|
|
39
|
+
id="include-all-domains-opt"
|
|
40
|
+
onChange={ () => setChecked( 'a' ) }
|
|
41
|
+
value={ 'a' }
|
|
42
|
+
checked={ checked === 'a' }
|
|
43
|
+
/>
|
|
44
|
+
|
|
45
|
+
<Label htmlFor="include-all-domains-opt" sx={ { mb: 0 } }>
|
|
46
|
+
All domains listed on this environment, and all subdomains
|
|
47
|
+
</Label>
|
|
48
|
+
</Flex>
|
|
49
|
+
|
|
50
|
+
<Flex sx={ { alignItems: 'center', mb: 1 } }>
|
|
51
|
+
<Radio
|
|
52
|
+
name="includeSubdomains"
|
|
53
|
+
id="include-subdomains-opt"
|
|
54
|
+
onChange={ () => setChecked( 'b' ) }
|
|
55
|
+
checked={ checked === 'b' }
|
|
56
|
+
value={ 'b' }
|
|
57
|
+
/>
|
|
58
|
+
|
|
59
|
+
<Label id="exclude-subdomains" htmlFor="include-subdomains-opt" sx={ { mb: 0 } }>
|
|
60
|
+
All domains listed on this environment
|
|
61
|
+
</Label>
|
|
62
|
+
</Flex>
|
|
63
|
+
</fieldset>
|
|
64
|
+
</Form.Root>
|
|
65
|
+
);
|
|
66
|
+
};
|
|
@@ -4,60 +4,15 @@
|
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
6
|
import React from 'react';
|
|
7
|
-
import PropTypes from 'prop-types';
|
|
8
7
|
|
|
9
8
|
/**
|
|
10
9
|
* Internal dependencies
|
|
11
10
|
*/
|
|
12
|
-
import {
|
|
11
|
+
import { Input } from './Input';
|
|
13
12
|
|
|
14
|
-
const Textarea = React.forwardRef(
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
);
|
|
52
|
-
|
|
53
|
-
Textarea.propTypes = {
|
|
54
|
-
variant: PropTypes.string,
|
|
55
|
-
label: PropTypes.string,
|
|
56
|
-
hasError: PropTypes.bool,
|
|
57
|
-
required: PropTypes.bool,
|
|
58
|
-
forLabel: PropTypes.string,
|
|
59
|
-
errorMessage: PropTypes.string,
|
|
60
|
-
};
|
|
13
|
+
const Textarea = React.forwardRef( ( props, ref ) => (
|
|
14
|
+
<Input ref={ ref } as="textarea" { ...props } />
|
|
15
|
+
) );
|
|
61
16
|
|
|
62
17
|
Textarea.displayName = 'Textarea';
|
|
63
18
|
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** @jsxImportSource theme-ui */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Internal dependencies
|
|
5
|
+
*/
|
|
6
|
+
import * as Form from '../NewForm';
|
|
7
|
+
|
|
8
|
+
export default {
|
|
9
|
+
title: 'Form/Textarea',
|
|
10
|
+
argTypes: {
|
|
11
|
+
placeholder: {
|
|
12
|
+
type: { name: 'string', required: false },
|
|
13
|
+
control: { type: 'text' },
|
|
14
|
+
},
|
|
15
|
+
label: {
|
|
16
|
+
type: { name: 'string', required: false },
|
|
17
|
+
control: { type: 'text' },
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const DefaultComponent = () => (
|
|
23
|
+
<Form.Root>
|
|
24
|
+
<Form.Textarea forLabel="my-text-area" rows="5" label="Regular textarea" />
|
|
25
|
+
|
|
26
|
+
<hr sx={ { my: 4 } } />
|
|
27
|
+
|
|
28
|
+
<Form.Textarea
|
|
29
|
+
forLabel="my-text-area-error"
|
|
30
|
+
rows="5"
|
|
31
|
+
label="Error textarea"
|
|
32
|
+
errorMessage="Please type numeric characters only"
|
|
33
|
+
required
|
|
34
|
+
hasError
|
|
35
|
+
/>
|
|
36
|
+
</Form.Root>
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
export const Default = DefaultComponent.bind( {} );
|
|
40
|
+
Default.args = {};
|
|
@@ -9,27 +9,33 @@ import { MdErrorOutline, MdCheckCircle } from 'react-icons/md';
|
|
|
9
9
|
/**
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
|
-
import { Heading } from '..';
|
|
13
12
|
|
|
14
|
-
const Validation = ( { children, isValid, ...props } ) => {
|
|
13
|
+
const Validation = ( { children, isValid, describedId = null, ...props } ) => {
|
|
15
14
|
const Icon = isValid ? MdCheckCircle : MdErrorOutline;
|
|
15
|
+
const IconLabel = isValid ? 'Valid' : 'Invalid';
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
<p
|
|
19
|
+
sx={ {
|
|
20
|
+
color: isValid ? 'success' : 'error',
|
|
21
|
+
display: 'flex',
|
|
22
|
+
alignItems: 'center',
|
|
23
|
+
m: 0,
|
|
24
|
+
fontSize: 1,
|
|
25
|
+
} }
|
|
26
|
+
id={ describedId ? `describe-${ describedId }-validation` : undefined }
|
|
22
27
|
{ ...props }
|
|
23
28
|
>
|
|
24
|
-
<Icon sx={ { mr: 1 } } />
|
|
29
|
+
<Icon sx={ { mr: 1 } } aria-label={ IconLabel } />
|
|
25
30
|
{ children }
|
|
26
|
-
</
|
|
31
|
+
</p>
|
|
27
32
|
);
|
|
28
33
|
};
|
|
29
34
|
|
|
30
35
|
Validation.propTypes = {
|
|
31
36
|
children: PropTypes.node,
|
|
32
37
|
isValid: PropTypes.bool,
|
|
38
|
+
describedId: PropTypes.string,
|
|
33
39
|
};
|
|
34
40
|
|
|
35
41
|
export { Validation };
|