@automattic/vip-design-system 0.32.0 → 0.32.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/README.md CHANGED
@@ -92,7 +92,7 @@ npm run build
92
92
  npm publish
93
93
  ```
94
94
 
95
- Note: You need to have two-factor enabled in your npm account. The publish command will request a two-factor code to complete the publishing process.
95
+ Note: You need to have two-factor enabled in your npm account. The publish command will request a two-factor code to complete the publishing process. You can also add `--otp=CODE` to the `npm publish` command if you already have the code.
96
96
 
97
97
  7. Push the tags to the repository and trunk updates.
98
98
 
@@ -103,6 +103,8 @@ git push origin trunk
103
103
 
104
104
  8. For major versions or breaking changes, it's recommended to [create a RELEASE](https://github.com/Automattic/vip-design-system/releases) with the published tag.
105
105
 
106
+ Ps: Add a `BREAKING CHANGES` section to the release. This will avoid folks trying to figure out why their code is not working on the VIP Dashboard or any other system.
107
+
106
108
  ### Troubleshooting
107
109
 
108
110
  ### Dialog + Dropdown usage
@@ -15,6 +15,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
15
15
 
16
16
  var _ScreenReaderText = _interopRequireDefault(require("../ScreenReaderText"));
17
17
 
18
+ var _Label = require("./Label");
19
+
18
20
  var _jsxRuntime = require("theme-ui/jsx-runtime");
19
21
 
20
22
  var _excluded = ["id", "value", "className", "label", "description", "labelProps"],
@@ -43,8 +45,12 @@ var RadioOption = function RadioOption(_ref) {
43
45
  name = _ref.name,
44
46
  onChangeHandler = _ref.onChangeHandler;
45
47
  var forLabel = id || value;
48
+ var checked = "" + defaultValue === "" + value;
49
+
50
+ var ref = _react["default"].useRef(null);
51
+
52
+ var describedById = "input-radio-box-" + forLabel + "-description";
46
53
  return (0, _jsxRuntime.jsxs)("div", {
47
- value: value,
48
54
  id: "o" + forLabel,
49
55
  sx: (0, _extends2["default"])({
50
56
  width: width,
@@ -62,13 +68,19 @@ var RadioOption = function RadioOption(_ref) {
62
68
  backgroundColor: 'input.radio-box.background.hover',
63
69
  borderColor: 'input.radio-box.border.default'
64
70
  }
65
- }, "" + defaultValue === "" + value && {
71
+ }, checked && {
66
72
  borderColor: 'input.radio-box.border.active'
67
73
  }, disabled && {
68
74
  borderColor: 'input.radio-box.border.disabled'
69
75
  }),
76
+ onClick: function onClick() {
77
+ var _ref$current;
78
+
79
+ (_ref$current = ref.current) == null ? void 0 : _ref$current.click();
80
+ },
70
81
  children: [(0, _jsxRuntime.jsx)("input", (0, _extends2["default"])({
71
- checked: "" + defaultValue === "" + value,
82
+ ref: ref,
83
+ checked: checked,
72
84
  type: "radio",
73
85
  name: name,
74
86
  id: forLabel,
@@ -77,32 +89,32 @@ var RadioOption = function RadioOption(_ref) {
77
89
  sx: {
78
90
  mr: 3,
79
91
  mt: 3
80
- }
81
- }, restOption)), (0, _jsxRuntime.jsxs)("label", (0, _extends2["default"])({
82
- htmlFor: forLabel,
92
+ },
93
+ "aria-describedby": describedById
94
+ }, restOption)), (0, _jsxRuntime.jsxs)("div", {
83
95
  sx: {
84
96
  mb: 0,
85
97
  color: 'input.radio-box.label.primary.default',
86
98
  p: 3,
87
99
  pr: 0,
88
100
  flex: 'auto'
89
- }
90
- }, labelProps, {
91
- children: [label, description && (0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
92
- children: [(0, _jsxRuntime.jsx)(_ScreenReaderText["default"], {
93
- children: "."
94
- }), (0, _jsxRuntime.jsx)("span", {
95
- sx: {
96
- color: 'input.radio-box.label.secondary.default',
97
- mb: 0,
98
- fontSize: 1,
99
- display: 'block'
100
- },
101
- children: description
102
- })]
101
+ },
102
+ children: [(0, _jsxRuntime.jsx)("label", (0, _extends2["default"])({
103
+ htmlFor: forLabel
104
+ }, labelProps, {
105
+ children: label
106
+ })), description && (0, _jsxRuntime.jsx)("span", {
107
+ sx: {
108
+ color: 'input.radio-box.label.secondary.default',
109
+ mb: 0,
110
+ fontSize: 1,
111
+ display: 'block'
112
+ },
113
+ id: describedById,
114
+ children: description
103
115
  })]
104
- }))]
105
- }, value);
116
+ })]
117
+ });
106
118
  };
107
119
 
108
120
  RadioOption.propTypes = {
@@ -144,18 +156,26 @@ var RadioBoxGroup = /*#__PURE__*/_react["default"].forwardRef(function (_ref2, f
144
156
  });
145
157
  return (0, _jsxRuntime.jsxs)("fieldset", (0, _extends2["default"])({
146
158
  sx: {
147
- display: 'flex',
148
- gap: 2,
149
159
  border: 0,
150
160
  padding: 0
151
161
  },
152
162
  ref: forwardRef
153
163
  }, props, {
154
- children: [groupLabel ? (0, _jsxRuntime.jsx)("legend", {
164
+ children: [groupLabel ? (0, _jsxRuntime.jsx)(_Label.Label, {
165
+ as: "legend",
166
+ sx: {
167
+ mb: 2
168
+ },
155
169
  children: groupLabel
156
170
  }) : (0, _jsxRuntime.jsx)(_ScreenReaderText["default"], {
157
171
  children: "Choose an option"
158
- }), renderedOptions]
172
+ }), (0, _jsxRuntime.jsx)("div", {
173
+ sx: {
174
+ display: 'flex',
175
+ gap: 2
176
+ },
177
+ children: renderedOptions
178
+ })]
159
179
  }));
160
180
  });
161
181
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@automattic/vip-design-system",
3
- "version": "0.32.0",
3
+ "version": "0.32.2",
4
4
  "main": "build/system/index.js",
5
5
  "scripts": {
6
6
  "build-storybook": "build-storybook",
@@ -6,6 +6,7 @@
6
6
  import React, { useCallback } from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import ScreenReaderText from '../ScreenReaderText';
9
+ import { Label } from './Label';
9
10
 
10
11
  /**
11
12
  * Internal dependencies
@@ -20,10 +21,12 @@ const RadioOption = ( {
20
21
  onChangeHandler,
21
22
  } ) => {
22
23
  const forLabel = id || value;
24
+ const checked = `${ defaultValue }` === `${ value }`;
25
+ const ref = React.useRef( null );
26
+ const describedById = `input-radio-box-${ forLabel }-description`;
27
+
23
28
  return (
24
29
  <div
25
- key={ value }
26
- value={ value }
27
30
  id={ `o${ forLabel }` }
28
31
  sx={ {
29
32
  width,
@@ -41,46 +44,49 @@ const RadioOption = ( {
41
44
  backgroundColor: 'input.radio-box.background.hover',
42
45
  borderColor: 'input.radio-box.border.default',
43
46
  },
44
- ...( `${ defaultValue }` === `${ value }` && {
47
+ ...( checked && {
45
48
  borderColor: 'input.radio-box.border.active',
46
49
  } ),
47
50
  ...( disabled && {
48
51
  borderColor: 'input.radio-box.border.disabled',
49
52
  } ),
50
53
  } }
54
+ onClick={ () => {
55
+ ref.current?.click();
56
+ } }
51
57
  >
52
58
  <input
53
- checked={ `${ defaultValue }` === `${ value }` }
59
+ ref={ ref }
60
+ checked={ checked }
54
61
  type="radio"
55
62
  name={ name }
56
63
  id={ forLabel }
57
64
  onChange={ onChangeHandler }
58
65
  value={ `${ value }` }
59
66
  sx={ { mr: 3, mt: 3 } }
67
+ aria-describedby={ describedById }
60
68
  { ...restOption }
61
69
  />
62
- <label
63
- htmlFor={ forLabel }
70
+ <div
64
71
  sx={ { mb: 0, color: 'input.radio-box.label.primary.default', p: 3, pr: 0, flex: 'auto' } }
65
- { ...labelProps }
66
72
  >
67
- { label }
73
+ <label htmlFor={ forLabel } { ...labelProps }>
74
+ { label }
75
+ </label>
68
76
  { description && (
69
- <>
70
- <ScreenReaderText>.</ScreenReaderText>
71
- <span
72
- sx={ {
73
- color: 'input.radio-box.label.secondary.default',
74
- mb: 0,
75
- fontSize: 1,
76
- display: 'block',
77
- } }
78
- >
79
- { description }
80
- </span>
81
- </>
77
+ <span
78
+ sx={ {
79
+ color: 'input.radio-box.label.secondary.default',
80
+ mb: 0,
81
+ fontSize: 1,
82
+ display: 'block',
83
+ } }
84
+ id={ describedById }
85
+ >
86
+ { description }
87
+ </span>
82
88
  ) }
83
- </label>
89
+ </div>
84
90
  </div>
85
91
  );
86
92
  };
@@ -134,8 +140,6 @@ const RadioBoxGroup = React.forwardRef(
134
140
  return (
135
141
  <fieldset
136
142
  sx={ {
137
- display: 'flex',
138
- gap: 2,
139
143
  border: 0,
140
144
  padding: 0,
141
145
  } }
@@ -143,11 +147,20 @@ const RadioBoxGroup = React.forwardRef(
143
147
  { ...props }
144
148
  >
145
149
  { groupLabel ? (
146
- <legend>{ groupLabel }</legend>
150
+ <Label as="legend" sx={ { mb: 2 } }>
151
+ { groupLabel }
152
+ </Label>
147
153
  ) : (
148
154
  <ScreenReaderText>Choose an option</ScreenReaderText>
149
155
  ) }
150
- { renderedOptions }
156
+ <div
157
+ sx={ {
158
+ display: 'flex',
159
+ gap: 2,
160
+ } }
161
+ >
162
+ { renderedOptions }
163
+ </div>
151
164
  </fieldset>
152
165
  );
153
166
  }