@automattic/vip-design-system 0.33.1 → 0.33.3
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/build/system/Accordion/Accordion.js +4 -2
- package/build/system/Accordion/Accordion.stories.js +48 -33
- package/build/system/Form/RadioBoxGroup.js +45 -23
- package/build/system/Form/RadioBoxGroup.stories.js +22 -2
- package/build/system/NewForm/FormAutocomplete.js +5 -3
- package/build/system/Table/Table.js +2 -1
- package/package.json +1 -1
- package/src/system/Accordion/Accordion.js +3 -1
- package/src/system/Accordion/Accordion.stories.jsx +32 -28
- package/src/system/Form/RadioBoxGroup.js +42 -21
- package/src/system/Form/RadioBoxGroup.stories.jsx +16 -0
- package/src/system/NewForm/FormAutocomplete.js +2 -1
- package/src/system/Table/Table.js +5 -2
|
@@ -104,7 +104,7 @@ var Trigger = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, forward
|
|
|
104
104
|
all: 'unset',
|
|
105
105
|
fontFamily: 'inherit',
|
|
106
106
|
px: 3,
|
|
107
|
-
|
|
107
|
+
minHeight: 45,
|
|
108
108
|
flex: 1,
|
|
109
109
|
display: 'flex',
|
|
110
110
|
alignItems: 'center',
|
|
@@ -134,7 +134,9 @@ var Trigger = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, forward
|
|
|
134
134
|
fontSize: 3,
|
|
135
135
|
color: 'icon.primary',
|
|
136
136
|
transform: 'rotate(90deg)',
|
|
137
|
-
transition: 'transform 300ms cubic-bezier(0.87, 0, 0.13, 1)'
|
|
137
|
+
transition: 'transform 300ms cubic-bezier(0.87, 0, 0.13, 1)',
|
|
138
|
+
minHeight: '20px',
|
|
139
|
+
minWidth: '20px'
|
|
138
140
|
},
|
|
139
141
|
"aria-hidden": true
|
|
140
142
|
})]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports["default"] = exports.Default = void 0;
|
|
4
|
+
exports["default"] = exports.WithLargeText = exports.Default = void 0;
|
|
5
5
|
|
|
6
6
|
var _ri = require("react-icons/ri");
|
|
7
7
|
|
|
@@ -44,40 +44,55 @@ var ExampleContent = function ExampleContent() {
|
|
|
44
44
|
});
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
var ExampleAccordion = function ExampleAccordion() {
|
|
48
|
+
return (0, _jsxRuntime.jsxs)(_.Accordion.Root, {
|
|
49
|
+
defaultValue: "teamPermissions",
|
|
50
|
+
sx: {
|
|
51
|
+
width: '250px'
|
|
52
|
+
},
|
|
53
|
+
children: [(0, _jsxRuntime.jsxs)(_.Accordion.Item, {
|
|
54
|
+
value: "teamPermissions",
|
|
55
|
+
children: [(0, _jsxRuntime.jsx)(_.Accordion.TriggerWithIcon, {
|
|
56
|
+
icon: (0, _jsxRuntime.jsx)(_ri.RiUserAddLine, {}),
|
|
57
|
+
children: "Team & Permissions"
|
|
58
|
+
}), (0, _jsxRuntime.jsx)(_.Accordion.Content, {
|
|
59
|
+
children: (0, _jsxRuntime.jsx)(ExampleContent, {})
|
|
60
|
+
})]
|
|
61
|
+
}), (0, _jsxRuntime.jsxs)(_.Accordion.Item, {
|
|
62
|
+
value: "addContentMedia",
|
|
63
|
+
children: [(0, _jsxRuntime.jsx)(_.Accordion.TriggerWithIcon, {
|
|
64
|
+
icon: (0, _jsxRuntime.jsx)(_bi.BiBookContent, {}),
|
|
65
|
+
children: "Add Content & Media"
|
|
66
|
+
}), (0, _jsxRuntime.jsx)(_.Accordion.Content, {
|
|
67
|
+
children: (0, _jsxRuntime.jsx)(ExampleContent, {})
|
|
68
|
+
})]
|
|
69
|
+
}), (0, _jsxRuntime.jsxs)(_.Accordion.Item, {
|
|
70
|
+
value: "addCode",
|
|
71
|
+
children: [(0, _jsxRuntime.jsx)(_.Accordion.TriggerWithIcon, {
|
|
72
|
+
icon: (0, _jsxRuntime.jsx)(_ri.RiCodeSSlashFill, {}),
|
|
73
|
+
children: "Add Code"
|
|
74
|
+
}), (0, _jsxRuntime.jsx)(_.Accordion.Content, {
|
|
75
|
+
children: (0, _jsxRuntime.jsx)(ExampleContent, {})
|
|
76
|
+
})]
|
|
77
|
+
})]
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
|
|
47
81
|
var Default = function Default() {
|
|
82
|
+
return (0, _jsxRuntime.jsx)(ExampleAccordion, {});
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
exports.Default = Default;
|
|
86
|
+
|
|
87
|
+
var WithLargeText = function WithLargeText() {
|
|
48
88
|
return (0, _jsxRuntime.jsx)(_.Box, {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
value: "teamPermissions",
|
|
56
|
-
children: [(0, _jsxRuntime.jsx)(_.Accordion.TriggerWithIcon, {
|
|
57
|
-
icon: (0, _jsxRuntime.jsx)(_ri.RiUserAddLine, {}),
|
|
58
|
-
children: "Team & Permissions"
|
|
59
|
-
}), (0, _jsxRuntime.jsx)(_.Accordion.Content, {
|
|
60
|
-
children: (0, _jsxRuntime.jsx)(ExampleContent, {})
|
|
61
|
-
})]
|
|
62
|
-
}), (0, _jsxRuntime.jsxs)(_.Accordion.Item, {
|
|
63
|
-
value: "addContentMedia",
|
|
64
|
-
children: [(0, _jsxRuntime.jsx)(_.Accordion.TriggerWithIcon, {
|
|
65
|
-
icon: (0, _jsxRuntime.jsx)(_bi.BiBookContent, {}),
|
|
66
|
-
children: "Add Content & Media"
|
|
67
|
-
}), (0, _jsxRuntime.jsx)(_.Accordion.Content, {
|
|
68
|
-
children: (0, _jsxRuntime.jsx)(ExampleContent, {})
|
|
69
|
-
})]
|
|
70
|
-
}), (0, _jsxRuntime.jsxs)(_.Accordion.Item, {
|
|
71
|
-
value: "addCode",
|
|
72
|
-
children: [(0, _jsxRuntime.jsx)(_.Accordion.TriggerWithIcon, {
|
|
73
|
-
icon: (0, _jsxRuntime.jsx)(_ri.RiCodeSSlashFill, {}),
|
|
74
|
-
children: "Add Code"
|
|
75
|
-
}), (0, _jsxRuntime.jsx)(_.Accordion.Content, {
|
|
76
|
-
children: (0, _jsxRuntime.jsx)(ExampleContent, {})
|
|
77
|
-
})]
|
|
78
|
-
})]
|
|
79
|
-
})
|
|
89
|
+
sx: {
|
|
90
|
+
'.vip-heading-component > button': {
|
|
91
|
+
fontSize: '25px'
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
children: (0, _jsxRuntime.jsx)(ExampleAccordion, {})
|
|
80
95
|
});
|
|
81
96
|
};
|
|
82
97
|
|
|
83
|
-
exports.
|
|
98
|
+
exports.WithLargeText = WithLargeText;
|
|
@@ -17,10 +17,12 @@ var _ScreenReaderText = _interopRequireDefault(require("../ScreenReaderText"));
|
|
|
17
17
|
|
|
18
18
|
var _Label = require("./Label");
|
|
19
19
|
|
|
20
|
+
var _Validation = require("./Validation");
|
|
21
|
+
|
|
20
22
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
21
23
|
|
|
22
24
|
var _excluded = ["id", "value", "className", "label", "description", "labelProps"],
|
|
23
|
-
_excluded2 = ["optionWidth", "name", "onChange", "groupLabel", "defaultValue", "options", "disabled"];
|
|
25
|
+
_excluded2 = ["optionWidth", "name", "onChange", "groupLabel", "defaultValue", "options", "disabled", "errorMessage", "hasError", "required"];
|
|
24
26
|
|
|
25
27
|
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); }
|
|
26
28
|
|
|
@@ -137,6 +139,9 @@ var RadioBoxGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, f
|
|
|
137
139
|
defaultValue = _ref2.defaultValue,
|
|
138
140
|
options = _ref2.options,
|
|
139
141
|
disabled = _ref2.disabled,
|
|
142
|
+
errorMessage = _ref2.errorMessage,
|
|
143
|
+
hasError = _ref2.hasError,
|
|
144
|
+
required = _ref2.required,
|
|
140
145
|
props = (0, _objectWithoutPropertiesLoose2["default"])(_ref2, _excluded2);
|
|
141
146
|
var onChangeHandler = (0, _react.useCallback)(function (e) {
|
|
142
147
|
var optionTriggered = options.find(function (option) {
|
|
@@ -154,29 +159,42 @@ var RadioBoxGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, f
|
|
|
154
159
|
width: optionWidth
|
|
155
160
|
}, (option == null ? void 0 : option.id) || (option == null ? void 0 : option.value));
|
|
156
161
|
});
|
|
157
|
-
return (0, _jsxRuntime.jsxs)("
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}, props, {
|
|
164
|
-
children: [groupLabel ? (0, _jsxRuntime.jsx)(_Label.Label, {
|
|
165
|
-
as: "legend",
|
|
166
|
-
sx: {
|
|
162
|
+
return (0, _jsxRuntime.jsxs)("div", {
|
|
163
|
+
children: [(0, _jsxRuntime.jsxs)("fieldset", (0, _extends2["default"])({
|
|
164
|
+
sx: (0, _extends2["default"])({
|
|
165
|
+
border: 0,
|
|
166
|
+
p: hasError ? 2 : 0,
|
|
167
|
+
display: 'inline-block',
|
|
167
168
|
mb: 2
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
169
|
+
}, hasError ? {
|
|
170
|
+
border: '1px solid',
|
|
171
|
+
borderColor: 'input.border.error',
|
|
172
|
+
borderRadius: 2
|
|
173
|
+
} : {}),
|
|
174
|
+
ref: forwardRef
|
|
175
|
+
}, props, {
|
|
176
|
+
children: [groupLabel ? (0, _jsxRuntime.jsx)(_Label.Label, {
|
|
177
|
+
as: "legend",
|
|
178
|
+
sx: {
|
|
179
|
+
mb: 2
|
|
180
|
+
},
|
|
181
|
+
required: required,
|
|
182
|
+
children: groupLabel
|
|
183
|
+
}) : (0, _jsxRuntime.jsx)(_ScreenReaderText["default"], {
|
|
184
|
+
children: "Choose an option"
|
|
185
|
+
}), (0, _jsxRuntime.jsx)("div", {
|
|
186
|
+
sx: {
|
|
187
|
+
display: 'flex',
|
|
188
|
+
gap: 2
|
|
189
|
+
},
|
|
190
|
+
children: renderedOptions
|
|
191
|
+
})]
|
|
192
|
+
})), hasError && errorMessage && (0, _jsxRuntime.jsx)(_Validation.Validation, {
|
|
193
|
+
isValid: false,
|
|
194
|
+
describedId: groupLabel,
|
|
195
|
+
children: errorMessage
|
|
178
196
|
})]
|
|
179
|
-
})
|
|
197
|
+
});
|
|
180
198
|
});
|
|
181
199
|
|
|
182
200
|
exports.RadioBoxGroup = RadioBoxGroup;
|
|
@@ -188,5 +206,9 @@ RadioBoxGroup.propTypes = {
|
|
|
188
206
|
name: _propTypes["default"].string,
|
|
189
207
|
disabled: _propTypes["default"].bool,
|
|
190
208
|
groupLabel: _propTypes["default"].string,
|
|
191
|
-
|
|
209
|
+
id: _propTypes["default"].string,
|
|
210
|
+
optionWidth: _propTypes["default"].string,
|
|
211
|
+
errorMessage: _propTypes["default"].string,
|
|
212
|
+
hasError: _propTypes["default"].bool,
|
|
213
|
+
required: _propTypes["default"].bool
|
|
192
214
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports["default"] = exports.Default = void 0;
|
|
4
|
+
exports["default"] = exports.Errors = exports.Default = void 0;
|
|
5
5
|
|
|
6
6
|
var _react = require("react");
|
|
7
7
|
|
|
@@ -50,4 +50,24 @@ var Default = function Default() {
|
|
|
50
50
|
});
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
exports.Default = Default;
|
|
53
|
+
exports.Default = Default;
|
|
54
|
+
|
|
55
|
+
var Errors = function Errors() {
|
|
56
|
+
var _useState2 = (0, _react.useState)(null),
|
|
57
|
+
value = _useState2[0],
|
|
58
|
+
setValue = _useState2[1];
|
|
59
|
+
|
|
60
|
+
return (0, _jsxRuntime.jsx)(_.RadioBoxGroup, {
|
|
61
|
+
defaultValue: value,
|
|
62
|
+
onChange: function onChange(e) {
|
|
63
|
+
return setValue(e.target.value);
|
|
64
|
+
},
|
|
65
|
+
options: options,
|
|
66
|
+
required: true,
|
|
67
|
+
groupLabel: "Radio Box Group",
|
|
68
|
+
hasError: true,
|
|
69
|
+
errorMessage: "This is an error message"
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
exports.Errors = Errors;
|
|
@@ -37,7 +37,7 @@ var _Form = require("../Form");
|
|
|
37
37
|
|
|
38
38
|
var _jsxRuntime = require("theme-ui/jsx-runtime");
|
|
39
39
|
|
|
40
|
-
var _excluded = ["autoFilter", "className", "debounce", "displayMenu", "dropdownArrow", "
|
|
40
|
+
var _excluded = ["autoFilter", "className", "debounce", "displayMenu", "dropdownArrow", "forLabel", "getOptionLabel", "getOptionValue", "errorMessage", "hasError", "isInline", "label", "loading", "minLength", "noOptionsMessage", "onChange", "onInputChange", "options", "required", "searchIcon", "showAllValues", "resetOnBlur", "source", "value"];
|
|
41
41
|
|
|
42
42
|
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); }
|
|
43
43
|
|
|
@@ -147,11 +147,11 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
|
|
|
147
147
|
displayMenu = _ref$displayMenu === void 0 ? 'overlay' : _ref$displayMenu,
|
|
148
148
|
_ref$dropdownArrow = _ref.dropdownArrow,
|
|
149
149
|
dropdownArrow = _ref$dropdownArrow === void 0 ? DefaultArrow : _ref$dropdownArrow,
|
|
150
|
-
errorMessage = _ref.errorMessage,
|
|
151
150
|
_ref$forLabel = _ref.forLabel,
|
|
152
151
|
forLabel = _ref$forLabel === void 0 ? 'vip-autocomplete' : _ref$forLabel,
|
|
153
152
|
getOptionLabel = _ref.getOptionLabel,
|
|
154
153
|
getOptionValue = _ref.getOptionValue,
|
|
154
|
+
errorMessage = _ref.errorMessage,
|
|
155
155
|
hasError = _ref.hasError,
|
|
156
156
|
isInline = _ref.isInline,
|
|
157
157
|
label = _ref.label,
|
|
@@ -345,7 +345,9 @@ var FormAutocomplete = /*#__PURE__*/_react["default"].forwardRef(function (_ref,
|
|
|
345
345
|
return (0, _jsxRuntime.jsxs)("div", {
|
|
346
346
|
className: (0, _classnames["default"])('vip-form-autocomplete-component', className),
|
|
347
347
|
children: [label && !isInline && (0, _jsxRuntime.jsx)(SelectLabel, {}), (0, _jsxRuntime.jsx)("div", {
|
|
348
|
-
sx: (0, _extends2["default"])({}, defaultStyles, isInline && inlineStyles, searchIcon && searchIconStyles
|
|
348
|
+
sx: (0, _extends2["default"])({}, defaultStyles, isInline && inlineStyles, searchIcon && searchIconStyles, hasError ? {
|
|
349
|
+
borderColor: 'input.border.error'
|
|
350
|
+
} : {}),
|
|
349
351
|
children: (0, _jsxRuntime.jsxs)(_FormSelectContent.FormSelectContent, {
|
|
350
352
|
isInline: inlineLabel,
|
|
351
353
|
label: inlineLabel ? (0, _jsxRuntime.jsx)(SelectLabel, {}) : null,
|
|
@@ -37,6 +37,7 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (_ref, forwardRef
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
return (0, _jsxRuntime.jsx)(_.Box, {
|
|
40
|
+
className: (0, _classnames["default"])('vip-table-component', className),
|
|
40
41
|
sx: {
|
|
41
42
|
width: '100%',
|
|
42
43
|
overflowX: 'auto'
|
|
@@ -47,7 +48,7 @@ var Table = /*#__PURE__*/_react["default"].forwardRef(function (_ref, forwardRef
|
|
|
47
48
|
minWidth: '1024px',
|
|
48
49
|
borderSpacing: 0
|
|
49
50
|
}, sx),
|
|
50
|
-
className: (0, _classnames["default"])('vip-table-component', className),
|
|
51
|
+
className: (0, _classnames["default"])('vip-table-component-element', className),
|
|
51
52
|
ref: forwardRef
|
|
52
53
|
}, props, {
|
|
53
54
|
children: [caption && (0, _jsxRuntime.jsx)("caption", {
|
package/package.json
CHANGED
|
@@ -72,7 +72,7 @@ export const Trigger = React.forwardRef(
|
|
|
72
72
|
all: 'unset',
|
|
73
73
|
fontFamily: 'inherit',
|
|
74
74
|
px: 3,
|
|
75
|
-
|
|
75
|
+
minHeight: 45,
|
|
76
76
|
flex: 1,
|
|
77
77
|
display: 'flex',
|
|
78
78
|
alignItems: 'center',
|
|
@@ -103,6 +103,8 @@ export const Trigger = React.forwardRef(
|
|
|
103
103
|
color: 'icon.primary',
|
|
104
104
|
transform: 'rotate(90deg)',
|
|
105
105
|
transition: 'transform 300ms cubic-bezier(0.87, 0, 0.13, 1)',
|
|
106
|
+
minHeight: '20px',
|
|
107
|
+
minWidth: '20px',
|
|
106
108
|
} }
|
|
107
109
|
aria-hidden
|
|
108
110
|
/>
|
|
@@ -23,33 +23,37 @@ const ExampleContent = () => (
|
|
|
23
23
|
</Box>
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
<
|
|
28
|
-
<Accordion.
|
|
29
|
-
<Accordion.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
<Accordion.
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<Accordion.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
26
|
+
const ExampleAccordion = () => (
|
|
27
|
+
<Accordion.Root defaultValue="teamPermissions" sx={ { width: '250px' } }>
|
|
28
|
+
<Accordion.Item value="teamPermissions">
|
|
29
|
+
<Accordion.TriggerWithIcon icon={ <RiUserAddLine /> }>
|
|
30
|
+
Team & Permissions
|
|
31
|
+
</Accordion.TriggerWithIcon>
|
|
32
|
+
<Accordion.Content>
|
|
33
|
+
<ExampleContent />
|
|
34
|
+
</Accordion.Content>
|
|
35
|
+
</Accordion.Item>
|
|
36
|
+
<Accordion.Item value="addContentMedia">
|
|
37
|
+
<Accordion.TriggerWithIcon icon={ <BiBookContent /> }>
|
|
38
|
+
Add Content & Media
|
|
39
|
+
</Accordion.TriggerWithIcon>
|
|
40
|
+
<Accordion.Content>
|
|
41
|
+
<ExampleContent />
|
|
42
|
+
</Accordion.Content>
|
|
43
|
+
</Accordion.Item>
|
|
44
|
+
<Accordion.Item value="addCode">
|
|
45
|
+
<Accordion.TriggerWithIcon icon={ <RiCodeSSlashFill /> }>Add Code</Accordion.TriggerWithIcon>
|
|
46
|
+
<Accordion.Content>
|
|
47
|
+
<ExampleContent />
|
|
48
|
+
</Accordion.Content>
|
|
49
|
+
</Accordion.Item>
|
|
50
|
+
</Accordion.Root>
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
export const Default = () => <ExampleAccordion />;
|
|
54
|
+
|
|
55
|
+
export const WithLargeText = () => (
|
|
56
|
+
<Box sx={ { '.vip-heading-component > button': { fontSize: '25px' } } }>
|
|
57
|
+
<ExampleAccordion />
|
|
54
58
|
</Box>
|
|
55
59
|
);
|
|
@@ -7,6 +7,7 @@ import React, { useCallback } from 'react';
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import ScreenReaderText from '../ScreenReaderText';
|
|
9
9
|
import { Label } from './Label';
|
|
10
|
+
import { Validation } from './Validation';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Internal dependencies
|
|
@@ -111,6 +112,9 @@ const RadioBoxGroup = React.forwardRef(
|
|
|
111
112
|
defaultValue,
|
|
112
113
|
options,
|
|
113
114
|
disabled,
|
|
115
|
+
errorMessage,
|
|
116
|
+
hasError,
|
|
117
|
+
required,
|
|
114
118
|
...props
|
|
115
119
|
},
|
|
116
120
|
forwardRef
|
|
@@ -138,30 +142,43 @@ const RadioBoxGroup = React.forwardRef(
|
|
|
138
142
|
) );
|
|
139
143
|
|
|
140
144
|
return (
|
|
141
|
-
<
|
|
142
|
-
|
|
143
|
-
border: 0,
|
|
144
|
-
padding: 0,
|
|
145
|
-
} }
|
|
146
|
-
ref={ forwardRef }
|
|
147
|
-
{ ...props }
|
|
148
|
-
>
|
|
149
|
-
{ groupLabel ? (
|
|
150
|
-
<Label as="legend" sx={ { mb: 2 } }>
|
|
151
|
-
{ groupLabel }
|
|
152
|
-
</Label>
|
|
153
|
-
) : (
|
|
154
|
-
<ScreenReaderText>Choose an option</ScreenReaderText>
|
|
155
|
-
) }
|
|
156
|
-
<div
|
|
145
|
+
<div>
|
|
146
|
+
<fieldset
|
|
157
147
|
sx={ {
|
|
158
|
-
|
|
159
|
-
|
|
148
|
+
border: 0,
|
|
149
|
+
p: hasError ? 2 : 0,
|
|
150
|
+
display: 'inline-block',
|
|
151
|
+
mb: 2,
|
|
152
|
+
...( hasError
|
|
153
|
+
? { border: '1px solid', borderColor: 'input.border.error', borderRadius: 2 }
|
|
154
|
+
: {} ),
|
|
160
155
|
} }
|
|
156
|
+
ref={ forwardRef }
|
|
157
|
+
{ ...props }
|
|
161
158
|
>
|
|
162
|
-
{
|
|
163
|
-
|
|
164
|
-
|
|
159
|
+
{ groupLabel ? (
|
|
160
|
+
<Label as="legend" sx={ { mb: 2 } } required={ required }>
|
|
161
|
+
{ groupLabel }
|
|
162
|
+
</Label>
|
|
163
|
+
) : (
|
|
164
|
+
<ScreenReaderText>Choose an option</ScreenReaderText>
|
|
165
|
+
) }
|
|
166
|
+
<div
|
|
167
|
+
sx={ {
|
|
168
|
+
display: 'flex',
|
|
169
|
+
gap: 2,
|
|
170
|
+
} }
|
|
171
|
+
>
|
|
172
|
+
{ renderedOptions }
|
|
173
|
+
</div>
|
|
174
|
+
</fieldset>
|
|
175
|
+
|
|
176
|
+
{ hasError && errorMessage && (
|
|
177
|
+
<Validation isValid={ false } describedId={ groupLabel }>
|
|
178
|
+
{ errorMessage }
|
|
179
|
+
</Validation>
|
|
180
|
+
) }
|
|
181
|
+
</div>
|
|
165
182
|
);
|
|
166
183
|
}
|
|
167
184
|
);
|
|
@@ -175,7 +192,11 @@ RadioBoxGroup.propTypes = {
|
|
|
175
192
|
name: PropTypes.string,
|
|
176
193
|
disabled: PropTypes.bool,
|
|
177
194
|
groupLabel: PropTypes.string,
|
|
195
|
+
id: PropTypes.string,
|
|
178
196
|
optionWidth: PropTypes.string,
|
|
197
|
+
errorMessage: PropTypes.string,
|
|
198
|
+
hasError: PropTypes.bool,
|
|
199
|
+
required: PropTypes.bool,
|
|
179
200
|
};
|
|
180
201
|
|
|
181
202
|
export { RadioBoxGroup };
|
|
@@ -42,3 +42,19 @@ export const Default = () => {
|
|
|
42
42
|
/>
|
|
43
43
|
);
|
|
44
44
|
};
|
|
45
|
+
|
|
46
|
+
export const Errors = () => {
|
|
47
|
+
const [ value, setValue ] = useState( null );
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<RadioBoxGroup
|
|
51
|
+
defaultValue={ value }
|
|
52
|
+
onChange={ e => setValue( e.target.value ) }
|
|
53
|
+
options={ options }
|
|
54
|
+
required
|
|
55
|
+
groupLabel="Radio Box Group"
|
|
56
|
+
hasError={ true }
|
|
57
|
+
errorMessage="This is an error message"
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
@@ -103,10 +103,10 @@ const FormAutocomplete = React.forwardRef(
|
|
|
103
103
|
debounce = 0,
|
|
104
104
|
displayMenu = 'overlay',
|
|
105
105
|
dropdownArrow = DefaultArrow,
|
|
106
|
-
errorMessage,
|
|
107
106
|
forLabel = 'vip-autocomplete',
|
|
108
107
|
getOptionLabel,
|
|
109
108
|
getOptionValue,
|
|
109
|
+
errorMessage,
|
|
110
110
|
hasError,
|
|
111
111
|
isInline,
|
|
112
112
|
label,
|
|
@@ -304,6 +304,7 @@ const FormAutocomplete = React.forwardRef(
|
|
|
304
304
|
...defaultStyles,
|
|
305
305
|
...( isInline && inlineStyles ),
|
|
306
306
|
...( searchIcon && searchIconStyles ),
|
|
307
|
+
...( hasError ? { borderColor: 'input.border.error' } : {} ),
|
|
307
308
|
} }
|
|
308
309
|
>
|
|
309
310
|
<FormSelectContent
|
|
@@ -17,10 +17,13 @@ const Table = React.forwardRef(
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
return (
|
|
20
|
-
<Box
|
|
20
|
+
<Box
|
|
21
|
+
className={ classNames( 'vip-table-component', className ) }
|
|
22
|
+
sx={ { width: '100%', overflowX: 'auto' } }
|
|
23
|
+
>
|
|
21
24
|
<table
|
|
22
25
|
sx={ { width: '100%', minWidth: '1024px', borderSpacing: 0, ...sx } }
|
|
23
|
-
className={ classNames( 'vip-table-component', className ) }
|
|
26
|
+
className={ classNames( 'vip-table-component-element', className ) }
|
|
24
27
|
ref={ forwardRef }
|
|
25
28
|
{ ...props }
|
|
26
29
|
>
|