@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
package/.storybook/preview.js
CHANGED
|
@@ -116,6 +116,9 @@ var Trigger = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, forward
|
|
|
116
116
|
backgroundColor: 'backgroundSecondary',
|
|
117
117
|
borderBottom: function borderBottom(theme) {
|
|
118
118
|
return "1px solid " + theme.colors.border;
|
|
119
|
+
},
|
|
120
|
+
'.vip-accordion-trigger-indicator': {
|
|
121
|
+
transform: 'rotate(270deg)'
|
|
119
122
|
}
|
|
120
123
|
},
|
|
121
124
|
'&:hover': {
|
|
@@ -125,14 +128,12 @@ var Trigger = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, forward
|
|
|
125
128
|
}, props, {
|
|
126
129
|
ref: forwardedRef,
|
|
127
130
|
children: [children, (0, _jsxRuntime.jsx)(_md.MdChevronRight, {
|
|
131
|
+
className: "vip-accordion-trigger-indicator",
|
|
128
132
|
sx: {
|
|
129
133
|
fontSize: 3,
|
|
130
134
|
color: 'text',
|
|
131
135
|
transform: 'rotate(90deg)',
|
|
132
|
-
transition: 'transform 300ms cubic-bezier(0.87, 0, 0.13, 1)'
|
|
133
|
-
'[data-state=open] &': {
|
|
134
|
-
transform: 'rotate(270deg)'
|
|
135
|
-
}
|
|
136
|
+
transition: 'transform 300ms cubic-bezier(0.87, 0, 0.13, 1)'
|
|
136
137
|
},
|
|
137
138
|
"aria-hidden": true
|
|
138
139
|
})]
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = exports.Default = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = require("react");
|
|
7
|
+
|
|
8
|
+
var _ = require("..");
|
|
9
|
+
|
|
10
|
+
var _Checkbox = require("./Checkbox");
|
|
11
|
+
|
|
12
|
+
var _Label = require("./Label");
|
|
13
|
+
|
|
14
|
+
var _Flex = require("../Flex");
|
|
15
|
+
|
|
16
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* External dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Internal dependencies
|
|
24
|
+
*/
|
|
25
|
+
var _default = {
|
|
26
|
+
title: 'Form/Checkbox',
|
|
27
|
+
component: _Checkbox.Checkbox
|
|
28
|
+
};
|
|
29
|
+
exports["default"] = _default;
|
|
30
|
+
|
|
31
|
+
var Default = function Default() {
|
|
32
|
+
var _useState = (0, _react.useState)(true),
|
|
33
|
+
checked = _useState[0],
|
|
34
|
+
setChecked = _useState[1];
|
|
35
|
+
|
|
36
|
+
var _useState2 = (0, _react.useState)(false),
|
|
37
|
+
checked2 = _useState2[0],
|
|
38
|
+
setChecked2 = _useState2[1];
|
|
39
|
+
|
|
40
|
+
return (0, _jsxRuntime.jsx)(_.Form.Root, {
|
|
41
|
+
children: (0, _jsxRuntime.jsxs)("fieldset", {
|
|
42
|
+
children: [(0, _jsxRuntime.jsx)("legend", {
|
|
43
|
+
children: "Tell me your prefereces"
|
|
44
|
+
}), (0, _jsxRuntime.jsxs)(_Flex.Flex, {
|
|
45
|
+
sx: {
|
|
46
|
+
alignItems: 'center'
|
|
47
|
+
},
|
|
48
|
+
children: [(0, _jsxRuntime.jsx)(_Checkbox.Checkbox, {
|
|
49
|
+
id: "check1",
|
|
50
|
+
checked: checked,
|
|
51
|
+
"aria-labelledby": "label-check1",
|
|
52
|
+
onCheckedChange: setChecked
|
|
53
|
+
}), (0, _jsxRuntime.jsx)(_Label.Label, {
|
|
54
|
+
sx: {
|
|
55
|
+
m: 0,
|
|
56
|
+
ml: 2
|
|
57
|
+
},
|
|
58
|
+
htmlFor: "check1",
|
|
59
|
+
id: "label-check1",
|
|
60
|
+
children: "This option"
|
|
61
|
+
})]
|
|
62
|
+
}), (0, _jsxRuntime.jsxs)(_Flex.Flex, {
|
|
63
|
+
sx: {
|
|
64
|
+
alignItems: 'center'
|
|
65
|
+
},
|
|
66
|
+
children: [(0, _jsxRuntime.jsx)(_Checkbox.Checkbox, {
|
|
67
|
+
id: "check2",
|
|
68
|
+
checked: checked2,
|
|
69
|
+
"aria-labelledby": "label-check2",
|
|
70
|
+
onCheckedChange: setChecked2
|
|
71
|
+
}), (0, _jsxRuntime.jsx)(_Label.Label, {
|
|
72
|
+
sx: {
|
|
73
|
+
m: 0,
|
|
74
|
+
ml: 2
|
|
75
|
+
},
|
|
76
|
+
htmlFor: "check2",
|
|
77
|
+
id: "label-check2",
|
|
78
|
+
children: "This option too"
|
|
79
|
+
})]
|
|
80
|
+
})]
|
|
81
|
+
})
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
exports.Default = Default;
|
|
@@ -15,9 +15,51 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
15
15
|
|
|
16
16
|
var _ = require("../");
|
|
17
17
|
|
|
18
|
+
var _themeUi = require("theme-ui");
|
|
19
|
+
|
|
18
20
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
19
21
|
|
|
20
|
-
var _excluded = ["variant", "label", "forLabel", "hasError", "required", "errorMessage"];
|
|
22
|
+
var _excluded = ["variant", "label", "forLabel", "hasError", "required", "sx", "errorMessage"];
|
|
23
|
+
|
|
24
|
+
var RequiredLabel = function RequiredLabel() {
|
|
25
|
+
return (0, _jsxRuntime.jsx)("span", {
|
|
26
|
+
sx: {
|
|
27
|
+
color: 'error',
|
|
28
|
+
display: 'inline-block',
|
|
29
|
+
ml: 2,
|
|
30
|
+
fontSize: 1
|
|
31
|
+
},
|
|
32
|
+
children: "(Required)"
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
var inputStyles = {
|
|
37
|
+
unset: 'all',
|
|
38
|
+
border: '1px solid',
|
|
39
|
+
borderColor: 'border',
|
|
40
|
+
backgroundColor: 'card',
|
|
41
|
+
borderRadius: 1,
|
|
42
|
+
lineHeight: 'inherit',
|
|
43
|
+
px: 3,
|
|
44
|
+
py: 2,
|
|
45
|
+
fontSize: 2,
|
|
46
|
+
mb: 2,
|
|
47
|
+
color: 'text',
|
|
48
|
+
display: 'block',
|
|
49
|
+
width: '100%',
|
|
50
|
+
'&:focus': function focus(theme) {
|
|
51
|
+
return theme.outline;
|
|
52
|
+
},
|
|
53
|
+
'&:focus-visible': function focusVisible(theme) {
|
|
54
|
+
return theme.outline;
|
|
55
|
+
},
|
|
56
|
+
'&:disabled': {
|
|
57
|
+
bg: 'backgroundSecondary'
|
|
58
|
+
},
|
|
59
|
+
'&::placeholder': {
|
|
60
|
+
color: 'placeholder'
|
|
61
|
+
}
|
|
62
|
+
};
|
|
21
63
|
|
|
22
64
|
var Input = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
23
65
|
var variant = _ref.variant,
|
|
@@ -25,43 +67,24 @@ var Input = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
|
|
|
25
67
|
forLabel = _ref.forLabel,
|
|
26
68
|
hasError = _ref.hasError,
|
|
27
69
|
required = _ref.required,
|
|
70
|
+
_ref$sx = _ref.sx,
|
|
71
|
+
sx = _ref$sx === void 0 ? {} : _ref$sx,
|
|
28
72
|
errorMessage = _ref.errorMessage,
|
|
29
73
|
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
30
74
|
return (0, _jsxRuntime.jsxs)(_react["default"].Fragment, {
|
|
31
75
|
children: [label && (0, _jsxRuntime.jsxs)(_.Label, {
|
|
32
76
|
htmlFor: forLabel,
|
|
33
|
-
children: [label, required &&
|
|
34
|
-
}), (0, _jsxRuntime.jsx)(
|
|
77
|
+
children: [label, required && (0, _jsxRuntime.jsx)(RequiredLabel, {})]
|
|
78
|
+
}), (0, _jsxRuntime.jsx)(_themeUi.Input, (0, _extends2["default"])({
|
|
35
79
|
ref: ref,
|
|
36
80
|
id: forLabel,
|
|
37
81
|
required: required,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
px: 3,
|
|
45
|
-
py: 2,
|
|
46
|
-
fontSize: 2,
|
|
47
|
-
mb: 2,
|
|
48
|
-
color: 'text',
|
|
49
|
-
display: 'block',
|
|
50
|
-
width: '100%',
|
|
51
|
-
'&:focus': function focus(theme) {
|
|
52
|
-
return theme.outline;
|
|
53
|
-
},
|
|
54
|
-
'&:focus-visible': function focusVisible(theme) {
|
|
55
|
-
return theme.outline;
|
|
56
|
-
},
|
|
57
|
-
'&:disabled': {
|
|
58
|
-
bg: 'backgroundSecondary'
|
|
59
|
-
},
|
|
60
|
-
'&::placeholder': {
|
|
61
|
-
color: 'placeholder'
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
})), hasError && errorMessage && (0, _jsxRuntime.jsx)(_.Validation, {
|
|
82
|
+
noValidate: true,
|
|
83
|
+
"aria-describedby": hasError ? "describe-" + forLabel + "-validation" : undefined,
|
|
84
|
+
sx: (0, _extends2["default"])({}, inputStyles, sx)
|
|
85
|
+
}, props)), hasError && errorMessage && (0, _jsxRuntime.jsx)(_.Validation, {
|
|
86
|
+
isValid: false,
|
|
87
|
+
describedId: forLabel,
|
|
65
88
|
children: errorMessage
|
|
66
89
|
})]
|
|
67
90
|
});
|
|
@@ -74,6 +97,7 @@ Input.propTypes = {
|
|
|
74
97
|
hasError: _propTypes["default"].bool,
|
|
75
98
|
required: _propTypes["default"].bool,
|
|
76
99
|
forLabel: _propTypes["default"].string,
|
|
77
|
-
errorMessage: _propTypes["default"].string
|
|
100
|
+
errorMessage: _propTypes["default"].string,
|
|
101
|
+
sx: _propTypes["default"].object
|
|
78
102
|
};
|
|
79
103
|
Input.displayName = 'Input';
|
|
@@ -13,14 +13,44 @@ var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
15
|
var _default = {
|
|
16
|
-
title: 'Input'
|
|
17
|
-
component: _.Input
|
|
16
|
+
title: 'Form/Input'
|
|
18
17
|
};
|
|
19
18
|
exports["default"] = _default;
|
|
20
19
|
|
|
21
20
|
var Default = function Default() {
|
|
22
|
-
return (0, _jsxRuntime.
|
|
23
|
-
|
|
21
|
+
return (0, _jsxRuntime.jsxs)(_.Form.Root, {
|
|
22
|
+
children: [(0, _jsxRuntime.jsx)(_.Form.Input, {
|
|
23
|
+
placeholder: "Your input here...",
|
|
24
|
+
label: "Always add a label to inputs",
|
|
25
|
+
forLabel: "input-simple"
|
|
26
|
+
}), (0, _jsxRuntime.jsx)("hr", {
|
|
27
|
+
sx: {
|
|
28
|
+
my: 4
|
|
29
|
+
}
|
|
30
|
+
}), (0, _jsxRuntime.jsx)(_.Form.Input, {
|
|
31
|
+
forLabel: "input-with-error",
|
|
32
|
+
label: "Error Input",
|
|
33
|
+
errorMessage: "Please type numeric characters only",
|
|
34
|
+
hasError: true
|
|
35
|
+
}), (0, _jsxRuntime.jsx)("hr", {
|
|
36
|
+
sx: {
|
|
37
|
+
my: 4
|
|
38
|
+
}
|
|
39
|
+
}), (0, _jsxRuntime.jsx)(_.Form.Input, {
|
|
40
|
+
forLabel: "input-with-required",
|
|
41
|
+
label: "Required",
|
|
42
|
+
required: true
|
|
43
|
+
}), (0, _jsxRuntime.jsx)("hr", {
|
|
44
|
+
sx: {
|
|
45
|
+
my: 4
|
|
46
|
+
}
|
|
47
|
+
}), (0, _jsxRuntime.jsx)(_.Form.Label, {
|
|
48
|
+
htmlFor: "input-with-custom-label",
|
|
49
|
+
children: "Custom Label outside the Input"
|
|
50
|
+
}), (0, _jsxRuntime.jsx)(_.Form.Input, {
|
|
51
|
+
forLabel: "input-with-custom-label",
|
|
52
|
+
required: true
|
|
53
|
+
})]
|
|
24
54
|
});
|
|
25
55
|
};
|
|
26
56
|
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = exports.Default = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = require("react");
|
|
7
|
+
|
|
8
|
+
var _ = require("..");
|
|
9
|
+
|
|
10
|
+
var _Radio = require("./Radio");
|
|
11
|
+
|
|
12
|
+
var _Label = require("./Label");
|
|
13
|
+
|
|
14
|
+
var _Flex = require("../Flex");
|
|
15
|
+
|
|
16
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* External dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Internal dependencies
|
|
24
|
+
*/
|
|
25
|
+
var _default = {
|
|
26
|
+
title: 'Form/Radio',
|
|
27
|
+
component: _Radio.Radio
|
|
28
|
+
};
|
|
29
|
+
exports["default"] = _default;
|
|
30
|
+
|
|
31
|
+
var Default = function Default() {
|
|
32
|
+
var _useState = (0, _react.useState)('a'),
|
|
33
|
+
checked = _useState[0],
|
|
34
|
+
setChecked = _useState[1];
|
|
35
|
+
|
|
36
|
+
return (0, _jsxRuntime.jsxs)(_.Form.Root, {
|
|
37
|
+
children: [(0, _jsxRuntime.jsxs)("p", {
|
|
38
|
+
children: ["Per recommendation, if you have a Radio button, use a Fieldset with a legend as wrapper to your options.", ' ', (0, _jsxRuntime.jsx)("a", {
|
|
39
|
+
href: "https://a11y-collective.github.io/demos/en/accessible-code/form-fieldsets.html",
|
|
40
|
+
children: "Reference to Form fieldsets"
|
|
41
|
+
})]
|
|
42
|
+
}), (0, _jsxRuntime.jsxs)("fieldset", {
|
|
43
|
+
children: [(0, _jsxRuntime.jsx)("legend", {
|
|
44
|
+
sx: {
|
|
45
|
+
mb: 0,
|
|
46
|
+
fontSize: 2,
|
|
47
|
+
fontWeight: 'bold'
|
|
48
|
+
},
|
|
49
|
+
children: "Apply the policy to these domains"
|
|
50
|
+
}), (0, _jsxRuntime.jsxs)(_Flex.Flex, {
|
|
51
|
+
sx: {
|
|
52
|
+
alignItems: 'center'
|
|
53
|
+
},
|
|
54
|
+
children: [(0, _jsxRuntime.jsx)(_Radio.Radio, {
|
|
55
|
+
name: "includeSubdomains",
|
|
56
|
+
id: "include-all-domains-opt",
|
|
57
|
+
onChange: function onChange() {
|
|
58
|
+
return setChecked('a');
|
|
59
|
+
},
|
|
60
|
+
value: 'a',
|
|
61
|
+
checked: checked === 'a'
|
|
62
|
+
}), (0, _jsxRuntime.jsx)(_Label.Label, {
|
|
63
|
+
htmlFor: "include-all-domains-opt",
|
|
64
|
+
sx: {
|
|
65
|
+
mb: 0
|
|
66
|
+
},
|
|
67
|
+
children: "All domains listed on this environment, and all subdomains"
|
|
68
|
+
})]
|
|
69
|
+
}), (0, _jsxRuntime.jsxs)(_Flex.Flex, {
|
|
70
|
+
sx: {
|
|
71
|
+
alignItems: 'center',
|
|
72
|
+
mb: 1
|
|
73
|
+
},
|
|
74
|
+
children: [(0, _jsxRuntime.jsx)(_Radio.Radio, {
|
|
75
|
+
name: "includeSubdomains",
|
|
76
|
+
id: "include-subdomains-opt",
|
|
77
|
+
onChange: function onChange() {
|
|
78
|
+
return setChecked('b');
|
|
79
|
+
},
|
|
80
|
+
checked: checked === 'b',
|
|
81
|
+
value: 'b'
|
|
82
|
+
}), (0, _jsxRuntime.jsx)(_Label.Label, {
|
|
83
|
+
id: "exclude-subdomains",
|
|
84
|
+
htmlFor: "include-subdomains-opt",
|
|
85
|
+
sx: {
|
|
86
|
+
mb: 0
|
|
87
|
+
},
|
|
88
|
+
children: "All domains listed on this environment"
|
|
89
|
+
})]
|
|
90
|
+
})]
|
|
91
|
+
})]
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
exports.Default = Default;
|
|
@@ -7,66 +7,27 @@ exports.Textarea = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
9
|
|
|
10
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
|
11
|
-
|
|
12
10
|
var _react = _interopRequireDefault(require("react"));
|
|
13
11
|
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
var _ = require("../");
|
|
12
|
+
var _Input = require("./Input");
|
|
17
13
|
|
|
18
14
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
19
15
|
|
|
20
|
-
|
|
16
|
+
/** @jsxImportSource theme-ui */
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* External dependencies
|
|
20
|
+
*/
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return (0, _jsxRuntime.jsxs)(_react["default"].Fragment, {
|
|
31
|
-
children: [label && (0, _jsxRuntime.jsxs)(_.Label, {
|
|
32
|
-
htmlFor: forLabel,
|
|
33
|
-
children: [label, required && '*']
|
|
34
|
-
}), (0, _jsxRuntime.jsx)("textarea", (0, _extends2["default"])({}, props, {
|
|
35
|
-
ref: ref,
|
|
36
|
-
sx: {
|
|
37
|
-
border: '1px solid',
|
|
38
|
-
borderColor: 'border',
|
|
39
|
-
backgroundColor: 'card',
|
|
40
|
-
borderRadius: 1,
|
|
41
|
-
lineHeight: 'inherit',
|
|
42
|
-
px: 3,
|
|
43
|
-
py: 2,
|
|
44
|
-
fontSize: 2,
|
|
45
|
-
mb: 2,
|
|
46
|
-
color: 'text',
|
|
47
|
-
display: 'block',
|
|
48
|
-
width: '100%',
|
|
49
|
-
'&:focus': {
|
|
50
|
-
borderColor: 'brand.60',
|
|
51
|
-
outline: 'none'
|
|
52
|
-
},
|
|
53
|
-
'&:disabled': {
|
|
54
|
-
backgroundColor: 'background'
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
})), hasError && errorMessage && (0, _jsxRuntime.jsx)(_.Validation, {
|
|
58
|
-
children: errorMessage
|
|
59
|
-
})]
|
|
60
|
-
});
|
|
22
|
+
/**
|
|
23
|
+
* Internal dependencies
|
|
24
|
+
*/
|
|
25
|
+
var Textarea = /*#__PURE__*/_react["default"].forwardRef(function (props, ref) {
|
|
26
|
+
return (0, _jsxRuntime.jsx)(_Input.Input, (0, _extends2["default"])({
|
|
27
|
+
ref: ref,
|
|
28
|
+
as: "textarea"
|
|
29
|
+
}, props));
|
|
61
30
|
});
|
|
62
31
|
|
|
63
32
|
exports.Textarea = Textarea;
|
|
64
|
-
Textarea.propTypes = {
|
|
65
|
-
variant: _propTypes["default"].string,
|
|
66
|
-
label: _propTypes["default"].string,
|
|
67
|
-
hasError: _propTypes["default"].bool,
|
|
68
|
-
required: _propTypes["default"].bool,
|
|
69
|
-
forLabel: _propTypes["default"].string,
|
|
70
|
-
errorMessage: _propTypes["default"].string
|
|
71
|
-
};
|
|
72
33
|
Textarea.displayName = 'Textarea';
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = exports.Default = void 0;
|
|
5
|
+
|
|
6
|
+
var Form = _interopRequireWildcard(require("../NewForm"));
|
|
7
|
+
|
|
8
|
+
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
9
|
+
|
|
10
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
11
|
+
|
|
12
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
13
|
+
|
|
14
|
+
/** @jsxImportSource theme-ui */
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
var _default = {
|
|
20
|
+
title: 'Form/Textarea',
|
|
21
|
+
argTypes: {
|
|
22
|
+
placeholder: {
|
|
23
|
+
type: {
|
|
24
|
+
name: 'string',
|
|
25
|
+
required: false
|
|
26
|
+
},
|
|
27
|
+
control: {
|
|
28
|
+
type: 'text'
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
label: {
|
|
32
|
+
type: {
|
|
33
|
+
name: 'string',
|
|
34
|
+
required: false
|
|
35
|
+
},
|
|
36
|
+
control: {
|
|
37
|
+
type: 'text'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports["default"] = _default;
|
|
43
|
+
|
|
44
|
+
var DefaultComponent = function DefaultComponent() {
|
|
45
|
+
return (0, _jsxRuntime.jsxs)(Form.Root, {
|
|
46
|
+
children: [(0, _jsxRuntime.jsx)(Form.Textarea, {
|
|
47
|
+
forLabel: "my-text-area",
|
|
48
|
+
rows: "5",
|
|
49
|
+
label: "Regular textarea"
|
|
50
|
+
}), (0, _jsxRuntime.jsx)("hr", {
|
|
51
|
+
sx: {
|
|
52
|
+
my: 4
|
|
53
|
+
}
|
|
54
|
+
}), (0, _jsxRuntime.jsx)(Form.Textarea, {
|
|
55
|
+
forLabel: "my-text-area-error",
|
|
56
|
+
rows: "5",
|
|
57
|
+
label: "Error textarea",
|
|
58
|
+
errorMessage: "Please type numeric characters only",
|
|
59
|
+
required: true,
|
|
60
|
+
hasError: true
|
|
61
|
+
})]
|
|
62
|
+
});
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
var Default = DefaultComponent.bind({});
|
|
66
|
+
exports.Default = Default;
|
|
67
|
+
Default.args = {};
|
|
@@ -13,30 +13,36 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
13
13
|
|
|
14
14
|
var _md = require("react-icons/md");
|
|
15
15
|
|
|
16
|
-
var _ = require("..");
|
|
17
|
-
|
|
18
16
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
19
17
|
|
|
20
|
-
var _excluded = ["children", "isValid"];
|
|
18
|
+
var _excluded = ["children", "isValid", "describedId"];
|
|
21
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Internal dependencies
|
|
22
|
+
*/
|
|
22
23
|
var Validation = function Validation(_ref) {
|
|
23
24
|
var children = _ref.children,
|
|
24
25
|
isValid = _ref.isValid,
|
|
26
|
+
_ref$describedId = _ref.describedId,
|
|
27
|
+
describedId = _ref$describedId === void 0 ? null : _ref$describedId,
|
|
25
28
|
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
26
29
|
var Icon = isValid ? _md.MdCheckCircle : _md.MdErrorOutline;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
as: "p",
|
|
30
|
+
var IconLabel = isValid ? 'Valid' : 'Invalid';
|
|
31
|
+
return (0, _jsxRuntime.jsxs)("p", (0, _extends2["default"])({
|
|
30
32
|
sx: {
|
|
31
33
|
color: isValid ? 'success' : 'error',
|
|
32
34
|
display: 'flex',
|
|
33
|
-
alignItems: 'center'
|
|
34
|
-
|
|
35
|
+
alignItems: 'center',
|
|
36
|
+
m: 0,
|
|
37
|
+
fontSize: 1
|
|
38
|
+
},
|
|
39
|
+
id: describedId ? "describe-" + describedId + "-validation" : undefined
|
|
35
40
|
}, props, {
|
|
36
41
|
children: [(0, _jsxRuntime.jsx)(Icon, {
|
|
37
42
|
sx: {
|
|
38
43
|
mr: 1
|
|
39
|
-
}
|
|
44
|
+
},
|
|
45
|
+
"aria-label": IconLabel
|
|
40
46
|
}), children]
|
|
41
47
|
}));
|
|
42
48
|
};
|
|
@@ -44,5 +50,6 @@ var Validation = function Validation(_ref) {
|
|
|
44
50
|
exports.Validation = Validation;
|
|
45
51
|
Validation.propTypes = {
|
|
46
52
|
children: _propTypes["default"].node,
|
|
47
|
-
isValid: _propTypes["default"].bool
|
|
53
|
+
isValid: _propTypes["default"].bool,
|
|
54
|
+
describedId: _propTypes["default"].string
|
|
48
55
|
};
|
|
@@ -79,6 +79,9 @@ var defaultStyles = {
|
|
|
79
79
|
'&.autocomplete__input--focused': {
|
|
80
80
|
outlineWidth: 0,
|
|
81
81
|
boxShadow: 'none'
|
|
82
|
+
},
|
|
83
|
+
'&.autocomplete__input--show-all-values': {
|
|
84
|
+
paddingRight: '40px'
|
|
82
85
|
}
|
|
83
86
|
},
|
|
84
87
|
'& .autocomplete__menu': {
|
|
@@ -93,8 +96,7 @@ var defaultStyles = {
|
|
|
93
96
|
fontSize: 'inherit'
|
|
94
97
|
},
|
|
95
98
|
'& .autocomplete__wrapper': {
|
|
96
|
-
width: '100%'
|
|
97
|
-
paddingRight: '40px'
|
|
99
|
+
width: '100%'
|
|
98
100
|
},
|
|
99
101
|
'& .autocomplete__input--show-all-values': {
|
|
100
102
|
paddingRight: 0
|
|
@@ -122,6 +124,10 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
|
|
|
122
124
|
id = _ref$id === void 0 ? 'vip-autocomplete' : _ref$id,
|
|
123
125
|
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
|
|
124
126
|
|
|
127
|
+
var _useState = (0, _react.useState)(false),
|
|
128
|
+
isDirty = _useState[0],
|
|
129
|
+
setIsDirty = _useState[1];
|
|
130
|
+
|
|
125
131
|
var SelectLabel = function SelectLabel() {
|
|
126
132
|
return (0, _jsxRuntime.jsx)(_Label.Label, {
|
|
127
133
|
htmlFor: forLabel || id,
|
|
@@ -155,19 +161,29 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
|
|
|
155
161
|
}
|
|
156
162
|
}, [onChange, getOptionByLabel]);
|
|
157
163
|
var suggest = (0, _react.useCallback)(function (query, populateResults) {
|
|
158
|
-
var data = options
|
|
159
|
-
|
|
160
|
-
|
|
164
|
+
var data = options;
|
|
165
|
+
|
|
166
|
+
if (isDirty) {
|
|
167
|
+
data = options.filter(function (option) {
|
|
168
|
+
return optionLabel(option).toLowerCase().indexOf(query.toLowerCase()) >= 0;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
161
172
|
populateResults(data.map(function (option) {
|
|
162
173
|
return optionLabel(option);
|
|
163
174
|
}));
|
|
164
|
-
}, [options]);
|
|
175
|
+
}, [options, isDirty]);
|
|
165
176
|
(0, _react.useEffect)(function () {
|
|
166
177
|
global.document.querySelector('.autocomplete__input').setAttribute('aria-activedescendant', '');
|
|
167
178
|
}, []);
|
|
168
179
|
(0, _react.useEffect)(function () {
|
|
169
180
|
global.document.querySelector('.autocomplete__menu').setAttribute('aria-label', label + " list");
|
|
170
181
|
}, [label]);
|
|
182
|
+
(0, _react.useEffect)(function () {
|
|
183
|
+
global.document.querySelector("#" + id).addEventListener('keydown', function () {
|
|
184
|
+
setIsDirty(true);
|
|
185
|
+
});
|
|
186
|
+
}, [setIsDirty]);
|
|
171
187
|
return (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
172
188
|
children: [label && !isInline && (0, _jsxRuntime.jsx)(SelectLabel, {}), (0, _jsxRuntime.jsx)("div", {
|
|
173
189
|
sx: (0, _extends2["default"])({}, defaultStyles, isInline && inlineStyles),
|