@atlaskit/radio 5.4.6 → 5.4.7

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/radio
2
2
 
3
+ ## 5.4.7
4
+
5
+ ### Patch Changes
6
+
7
+ - [`18aeca8c199`](https://bitbucket.org/atlassian/atlassian-frontend/commits/18aeca8c199) - Internal change to update token references. There is no expected behaviour or visual change.
8
+
3
9
  ## 5.4.6
4
10
 
5
11
  ### Patch Changes
package/dist/cjs/index.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -17,7 +16,5 @@ Object.defineProperty(exports, "RadioGroup", {
17
16
  return _radioGroup.default;
18
17
  }
19
18
  });
20
-
21
19
  var _radioGroup = _interopRequireDefault(require("./radio-group"));
22
-
23
20
  var _radio = _interopRequireDefault(require("./radio"));
@@ -1,70 +1,55 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.default = RadioGroup;
11
-
12
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
-
14
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
15
-
16
11
  var _react = _interopRequireWildcard(require("react"));
17
-
18
12
  var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
19
-
20
13
  var _radio = _interopRequireDefault(require("./radio"));
21
-
22
14
  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); }
23
-
24
15
  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; }
25
-
26
16
  var noOptions = [];
27
-
28
17
  function RadioGroup(props) {
29
18
  var onChange = props.onChange,
30
- _props$options = props.options,
31
- options = _props$options === void 0 ? noOptions : _props$options,
32
- propValue = props.value,
33
- defaultValue = props.defaultValue,
34
- isDisabled = props.isDisabled,
35
- isRequired = props.isRequired,
36
- isInvalid = props.isInvalid,
37
- _props$onInvalid = props.onInvalid,
38
- onInvalid = _props$onInvalid === void 0 ? _noop.default : _props$onInvalid,
39
- name = props.name,
40
- analyticsContext = props.analyticsContext,
41
- ariaLabelledBy = props['aria-labelledby'];
42
-
19
+ _props$options = props.options,
20
+ options = _props$options === void 0 ? noOptions : _props$options,
21
+ propValue = props.value,
22
+ defaultValue = props.defaultValue,
23
+ isDisabled = props.isDisabled,
24
+ isRequired = props.isRequired,
25
+ isInvalid = props.isInvalid,
26
+ _props$onInvalid = props.onInvalid,
27
+ onInvalid = _props$onInvalid === void 0 ? _noop.default : _props$onInvalid,
28
+ name = props.name,
29
+ analyticsContext = props.analyticsContext,
30
+ ariaLabelledBy = props['aria-labelledby'];
43
31
  var _useState = (0, _react.useState)(propValue !== undefined ? propValue : defaultValue),
44
- _useState2 = (0, _slicedToArray2.default)(_useState, 2),
45
- selectedValue = _useState2[0],
46
- setSelectedValue = _useState2[1];
47
-
32
+ _useState2 = (0, _slicedToArray2.default)(_useState, 2),
33
+ selectedValue = _useState2[0],
34
+ setSelectedValue = _useState2[1];
48
35
  var onRadioChange = (0, _react.useCallback)(function (e, analyticsEvent) {
49
36
  setSelectedValue(e.currentTarget.value);
50
-
51
37
  if (onChange) {
52
38
  onChange(e, analyticsEvent);
53
39
  }
54
- }, [onChange]); // If propValue is provided than act as a controlled component
55
- // If not then act as an uncontrolled component using the value from state
40
+ }, [onChange]);
56
41
 
42
+ // If propValue is provided than act as a controlled component
43
+ // If not then act as an uncontrolled component using the value from state
57
44
  var value = typeof propValue !== 'undefined' ? propValue : selectedValue;
58
45
  return /*#__PURE__*/_react.default.createElement("div", {
59
46
  role: "radiogroup",
60
47
  "aria-labelledby": ariaLabelledBy
61
48
  }, options.map(function (_ref, index) {
62
49
  var optionProps = (0, _extends2.default)({}, _ref);
63
-
64
50
  if (typeof isDisabled !== 'undefined') {
65
51
  optionProps.isDisabled = isDisabled;
66
52
  }
67
-
68
53
  var isChecked = value != null && optionProps.value === value;
69
54
  return /*#__PURE__*/_react.default.createElement(_radio.default, (0, _extends2.default)({}, optionProps, {
70
55
  name: name || optionProps.name,
package/dist/cjs/radio.js CHANGED
@@ -1,39 +1,27 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.default = void 0;
9
-
10
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
-
12
9
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
-
14
10
  var _react = require("react");
15
-
16
11
  var _react2 = require("@emotion/react");
17
-
18
12
  var _usePlatformLeafEventHandler = require("@atlaskit/analytics-next/usePlatformLeafEventHandler");
19
-
20
13
  var _noop = _interopRequireDefault(require("@atlaskit/ds-lib/noop"));
21
-
22
14
  var _colors = require("@atlaskit/theme/colors");
23
-
24
15
  var _components = _interopRequireDefault(require("@atlaskit/theme/components"));
25
-
26
16
  var _constants = require("@atlaskit/theme/constants");
27
-
28
17
  var _styles = _interopRequireDefault(require("./styles"));
29
-
30
18
  var _excluded = ["ariaLabel", "isDisabled", "isRequired", "isInvalid", "isChecked", "label", "mode", "name", "onChange", "value", "testId", "analyticsContext"];
31
19
  var packageName = "@atlaskit/radio";
32
- var packageVersion = "5.4.6";
20
+ var packageVersion = "5.4.7";
33
21
  var fontFamily = (0, _constants.fontFamily)();
34
22
  var noop = _noop.default;
35
23
  var labelPaddingStyles = (0, _react2.css)({
36
- padding: "var(--ds-scale-025, 2px)".concat(" ", "var(--ds-scale-050, 4px)")
24
+ padding: "var(--ds-space-025, 2px)".concat(" ", "var(--ds-space-050, 4px)")
37
25
  });
38
26
  var labelStyles = (0, _react2.css)({
39
27
  display: 'flex',
@@ -55,7 +43,6 @@ var darkLabelStyles = (0, _react2.css)({
55
43
  });
56
44
  var radioStyles = (0, _react2.css)({
57
45
  display: 'flex',
58
-
59
46
  /*
60
47
  The circle should be 14px * 14px centred in a 24px * 24px box.
61
48
  This is inclusive of a 2px border and inner circle with 2px radius.
@@ -65,20 +52,17 @@ var radioStyles = (0, _react2.css)({
65
52
  */
66
53
  width: '24px',
67
54
  height: '24px',
68
- // TODO Delete this comment after verifying spacing token -> previous value `0`
69
- margin: "var(--ds-scale-0, 0px)",
55
+ margin: "var(--ds-space-0, 0px)",
70
56
  position: 'relative',
71
57
  alignItems: 'center',
72
58
  justifyContent: 'center',
73
59
  flexShrink: 0,
74
60
  backgroundColor: 'var(--radio-background-color)',
75
-
76
61
  /* Border should be 2px, multiply by 24/14 to offset scale */
77
62
  border: 'calc(2px * 12 / 7) solid var(--radio-border-color)',
78
63
  borderRadius: '50%',
79
64
  MozAppearance: 'none',
80
65
  outline: 'none',
81
-
82
66
  /*
83
67
  Change the variables --radio-background-color, --radio-border-color,
84
68
  -radio-dot-color and -radio-dot-opacity according to user interactions.
@@ -88,7 +72,6 @@ var radioStyles = (0, _react2.css)({
88
72
  '--radio-border-color': 'var(--local-border)',
89
73
  '--radio-dot-color': 'var(--local-dot-checked)',
90
74
  '--radio-dot-opacity': 0,
91
-
92
75
  /* 24px * 7 / 12 === 14px height and width */
93
76
  transform: 'scale(calc(7 / 12))',
94
77
  transition: 'border-color 0.2s ease-in-out, background-color 0.2s ease-in-out',
@@ -145,22 +128,22 @@ var radioStyles = (0, _react2.css)({
145
128
  });
146
129
  var RadioWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Radio(props, ref) {
147
130
  var ariaLabel = props.ariaLabel,
148
- _props$isDisabled = props.isDisabled,
149
- isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
150
- isRequired = props.isRequired,
151
- _props$isInvalid = props.isInvalid,
152
- isInvalid = _props$isInvalid === void 0 ? false : _props$isInvalid,
153
- _props$isChecked = props.isChecked,
154
- isChecked = _props$isChecked === void 0 ? false : _props$isChecked,
155
- label = props.label,
156
- mode = props.mode,
157
- name = props.name,
158
- _props$onChange = props.onChange,
159
- onChange = _props$onChange === void 0 ? noop : _props$onChange,
160
- value = props.value,
161
- testId = props.testId,
162
- analyticsContext = props.analyticsContext,
163
- rest = (0, _objectWithoutProperties2.default)(props, _excluded);
131
+ _props$isDisabled = props.isDisabled,
132
+ isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
133
+ isRequired = props.isRequired,
134
+ _props$isInvalid = props.isInvalid,
135
+ isInvalid = _props$isInvalid === void 0 ? false : _props$isInvalid,
136
+ _props$isChecked = props.isChecked,
137
+ isChecked = _props$isChecked === void 0 ? false : _props$isChecked,
138
+ label = props.label,
139
+ mode = props.mode,
140
+ name = props.name,
141
+ _props$onChange = props.onChange,
142
+ onChange = _props$onChange === void 0 ? noop : _props$onChange,
143
+ value = props.value,
144
+ testId = props.testId,
145
+ analyticsContext = props.analyticsContext,
146
+ rest = (0, _objectWithoutProperties2.default)(props, _excluded);
164
147
  var onChangeAnalytics = (0, _usePlatformLeafEventHandler.usePlatformLeafEventHandler)({
165
148
  fn: onChange,
166
149
  action: 'changed',
@@ -172,11 +155,13 @@ var RadioWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Radio(props, re
172
155
  var radioCustomProperties = (0, _react.useMemo)(function () {
173
156
  return (0, _react2.css)((0, _styles.default)(mode));
174
157
  }, [mode]);
175
- return (// https://product-fabric.atlassian.net/browse/DST-1971
158
+ return (
159
+ // https://product-fabric.atlassian.net/browse/DST-1971
176
160
  // eslint-disable-next-line jsx-a11y/label-has-associated-control,jsx-a11y/label-has-for
177
161
  (0, _react2.jsx)("label", {
178
162
  "data-testid": testId && "".concat(testId, "--radio-label"),
179
- "data-disabled": isDisabled ? 'true' : undefined // TODO these will no longer be dynamic styles when legacy theming removed
163
+ "data-disabled": isDisabled ? 'true' : undefined
164
+ // TODO these will no longer be dynamic styles when legacy theming removed
180
165
  // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
181
166
  ,
182
167
  css: [labelStyles, mode === 'light' ? lightLabelStyles : darkLabelStyles]
@@ -189,10 +174,12 @@ var RadioWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Radio(props, re
189
174
  required: isRequired,
190
175
  type: "radio",
191
176
  value: value,
192
- "data-testid": testId && "".concat(testId, "--radio-input") // isInvalid is used in a nonstandard way so cannot
177
+ "data-testid": testId && "".concat(testId, "--radio-input")
178
+ // isInvalid is used in a nonstandard way so cannot
193
179
  // use :invalid selector
194
180
  ,
195
- "data-invalid": isInvalid ? 'true' : undefined // TODO radioCustomProperties can be defined at top of file when legacy theming removed
181
+ "data-invalid": isInvalid ? 'true' : undefined
182
+ // TODO radioCustomProperties can be defined at top of file when legacy theming removed
196
183
  // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
197
184
  ,
198
185
  css: [radioStyles, radioCustomProperties],
@@ -202,6 +189,7 @@ var RadioWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Radio(props, re
202
189
  }, label) : null)
203
190
  );
204
191
  });
192
+
205
193
  /**
206
194
  * __Radio__
207
195
  *
@@ -211,7 +199,6 @@ var RadioWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Radio(props, re
211
199
  * - [Code](https://atlassian.design/components/radio/code)
212
200
  * - [Usage](https://atlassian.design/components/radio/usage)
213
201
  */
214
-
215
202
  var Radio = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function Radio(props, ref) {
216
203
  return (0, _react2.jsx)(_components.default.Consumer, null, function (_ref) {
217
204
  var mode = _ref.mode;
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = getRadioCustomProperties;
7
-
8
7
  var _colors = require("@atlaskit/theme/colors");
9
-
10
8
  var radioThemeColors = {
11
9
  light: {
12
10
  background: "var(--ds-background-input, ".concat(_colors.N10, ")"),
@@ -41,7 +39,6 @@ var radioThemeColors = {
41
39
  borderFocus: "var(--ds-border-focused, ".concat(_colors.B75, ")")
42
40
  }
43
41
  };
44
-
45
42
  function getRadioCustomProperties(mode) {
46
43
  var radioColors = radioThemeColors[mode];
47
44
  return {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/radio",
3
- "version": "5.4.6",
3
+ "version": "5.4.7",
4
4
  "sideEffects": false
5
5
  }
@@ -20,23 +20,23 @@ export default function RadioGroup(props) {
20
20
  const [selectedValue, setSelectedValue] = useState(propValue !== undefined ? propValue : defaultValue);
21
21
  const onRadioChange = useCallback((e, analyticsEvent) => {
22
22
  setSelectedValue(e.currentTarget.value);
23
-
24
23
  if (onChange) {
25
24
  onChange(e, analyticsEvent);
26
25
  }
27
- }, [onChange]); // If propValue is provided than act as a controlled component
28
- // If not then act as an uncontrolled component using the value from state
26
+ }, [onChange]);
29
27
 
28
+ // If propValue is provided than act as a controlled component
29
+ // If not then act as an uncontrolled component using the value from state
30
30
  const value = typeof propValue !== 'undefined' ? propValue : selectedValue;
31
31
  return /*#__PURE__*/React.createElement("div", {
32
32
  role: "radiogroup",
33
33
  "aria-labelledby": ariaLabelledBy
34
- }, options.map(({ ...optionProps
34
+ }, options.map(({
35
+ ...optionProps
35
36
  }, index) => {
36
37
  if (typeof isDisabled !== 'undefined') {
37
38
  optionProps.isDisabled = isDisabled;
38
39
  }
39
-
40
40
  const isChecked = value != null && optionProps.value === value;
41
41
  return /*#__PURE__*/React.createElement(Radio, _extends({}, optionProps, {
42
42
  name: name || optionProps.name,
@@ -1,5 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /** @jsx jsx */
4
3
  import { forwardRef, memo, useMemo } from 'react';
5
4
  import { css, jsx } from '@emotion/react';
@@ -10,11 +9,11 @@ import GlobalTheme from '@atlaskit/theme/components';
10
9
  import { fontFamily as getFontFamily } from '@atlaskit/theme/constants';
11
10
  import getRadioCustomProperties from './styles';
12
11
  const packageName = "@atlaskit/radio";
13
- const packageVersion = "5.4.6";
12
+ const packageVersion = "5.4.7";
14
13
  const fontFamily = getFontFamily();
15
14
  const noop = __noop;
16
15
  const labelPaddingStyles = css({
17
- padding: `${"var(--ds-scale-025, 2px)"} ${"var(--ds-scale-050, 4px)"}`
16
+ padding: `${"var(--ds-space-025, 2px)"} ${"var(--ds-space-050, 4px)"}`
18
17
  });
19
18
  const labelStyles = css({
20
19
  display: 'flex',
@@ -36,7 +35,6 @@ const darkLabelStyles = css({
36
35
  });
37
36
  const radioStyles = css({
38
37
  display: 'flex',
39
-
40
38
  /*
41
39
  The circle should be 14px * 14px centred in a 24px * 24px box.
42
40
  This is inclusive of a 2px border and inner circle with 2px radius.
@@ -46,20 +44,17 @@ const radioStyles = css({
46
44
  */
47
45
  width: '24px',
48
46
  height: '24px',
49
- // TODO Delete this comment after verifying spacing token -> previous value `0`
50
- margin: "var(--ds-scale-0, 0px)",
47
+ margin: "var(--ds-space-0, 0px)",
51
48
  position: 'relative',
52
49
  alignItems: 'center',
53
50
  justifyContent: 'center',
54
51
  flexShrink: 0,
55
52
  backgroundColor: 'var(--radio-background-color)',
56
-
57
53
  /* Border should be 2px, multiply by 24/14 to offset scale */
58
54
  border: 'calc(2px * 12 / 7) solid var(--radio-border-color)',
59
55
  borderRadius: '50%',
60
56
  MozAppearance: 'none',
61
57
  outline: 'none',
62
-
63
58
  /*
64
59
  Change the variables --radio-background-color, --radio-border-color,
65
60
  -radio-dot-color and -radio-dot-opacity according to user interactions.
@@ -69,7 +64,6 @@ const radioStyles = css({
69
64
  '--radio-border-color': 'var(--local-border)',
70
65
  '--radio-dot-color': 'var(--local-dot-checked)',
71
66
  '--radio-dot-opacity': 0,
72
-
73
67
  /* 24px * 7 / 12 === 14px height and width */
74
68
  transform: 'scale(calc(7 / 12))',
75
69
  transition: 'border-color 0.2s ease-in-out, background-color 0.2s ease-in-out',
@@ -150,11 +144,13 @@ const RadioWithMode = /*#__PURE__*/forwardRef(function Radio(props, ref) {
150
144
  packageVersion
151
145
  });
152
146
  const radioCustomProperties = useMemo(() => css(getRadioCustomProperties(mode)), [mode]);
153
- return (// https://product-fabric.atlassian.net/browse/DST-1971
147
+ return (
148
+ // https://product-fabric.atlassian.net/browse/DST-1971
154
149
  // eslint-disable-next-line jsx-a11y/label-has-associated-control,jsx-a11y/label-has-for
155
150
  jsx("label", {
156
151
  "data-testid": testId && `${testId}--radio-label`,
157
- "data-disabled": isDisabled ? 'true' : undefined // TODO these will no longer be dynamic styles when legacy theming removed
152
+ "data-disabled": isDisabled ? 'true' : undefined
153
+ // TODO these will no longer be dynamic styles when legacy theming removed
158
154
  // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
159
155
  ,
160
156
  css: [labelStyles, mode === 'light' ? lightLabelStyles : darkLabelStyles]
@@ -167,10 +163,12 @@ const RadioWithMode = /*#__PURE__*/forwardRef(function Radio(props, ref) {
167
163
  required: isRequired,
168
164
  type: "radio",
169
165
  value: value,
170
- "data-testid": testId && `${testId}--radio-input` // isInvalid is used in a nonstandard way so cannot
166
+ "data-testid": testId && `${testId}--radio-input`
167
+ // isInvalid is used in a nonstandard way so cannot
171
168
  // use :invalid selector
172
169
  ,
173
- "data-invalid": isInvalid ? 'true' : undefined // TODO radioCustomProperties can be defined at top of file when legacy theming removed
170
+ "data-invalid": isInvalid ? 'true' : undefined
171
+ // TODO radioCustomProperties can be defined at top of file when legacy theming removed
174
172
  // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
175
173
  ,
176
174
  css: [radioStyles, radioCustomProperties],
@@ -180,6 +178,7 @@ const RadioWithMode = /*#__PURE__*/forwardRef(function Radio(props, ref) {
180
178
  }, label) : null)
181
179
  );
182
180
  });
181
+
183
182
  /**
184
183
  * __Radio__
185
184
  *
@@ -189,7 +188,6 @@ const RadioWithMode = /*#__PURE__*/forwardRef(function Radio(props, ref) {
189
188
  * - [Code](https://atlassian.design/components/radio/code)
190
189
  * - [Usage](https://atlassian.design/components/radio/usage)
191
190
  */
192
-
193
191
  const Radio = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Radio(props, ref) {
194
192
  return jsx(GlobalTheme.Consumer, null, ({
195
193
  mode
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/radio",
3
- "version": "5.4.6",
3
+ "version": "5.4.7",
4
4
  "sideEffects": false
5
5
  }
@@ -6,44 +6,40 @@ import Radio from './radio';
6
6
  var noOptions = [];
7
7
  export default function RadioGroup(props) {
8
8
  var onChange = props.onChange,
9
- _props$options = props.options,
10
- options = _props$options === void 0 ? noOptions : _props$options,
11
- propValue = props.value,
12
- defaultValue = props.defaultValue,
13
- isDisabled = props.isDisabled,
14
- isRequired = props.isRequired,
15
- isInvalid = props.isInvalid,
16
- _props$onInvalid = props.onInvalid,
17
- onInvalid = _props$onInvalid === void 0 ? noop : _props$onInvalid,
18
- name = props.name,
19
- analyticsContext = props.analyticsContext,
20
- ariaLabelledBy = props['aria-labelledby'];
21
-
9
+ _props$options = props.options,
10
+ options = _props$options === void 0 ? noOptions : _props$options,
11
+ propValue = props.value,
12
+ defaultValue = props.defaultValue,
13
+ isDisabled = props.isDisabled,
14
+ isRequired = props.isRequired,
15
+ isInvalid = props.isInvalid,
16
+ _props$onInvalid = props.onInvalid,
17
+ onInvalid = _props$onInvalid === void 0 ? noop : _props$onInvalid,
18
+ name = props.name,
19
+ analyticsContext = props.analyticsContext,
20
+ ariaLabelledBy = props['aria-labelledby'];
22
21
  var _useState = useState(propValue !== undefined ? propValue : defaultValue),
23
- _useState2 = _slicedToArray(_useState, 2),
24
- selectedValue = _useState2[0],
25
- setSelectedValue = _useState2[1];
26
-
22
+ _useState2 = _slicedToArray(_useState, 2),
23
+ selectedValue = _useState2[0],
24
+ setSelectedValue = _useState2[1];
27
25
  var onRadioChange = useCallback(function (e, analyticsEvent) {
28
26
  setSelectedValue(e.currentTarget.value);
29
-
30
27
  if (onChange) {
31
28
  onChange(e, analyticsEvent);
32
29
  }
33
- }, [onChange]); // If propValue is provided than act as a controlled component
34
- // If not then act as an uncontrolled component using the value from state
30
+ }, [onChange]);
35
31
 
32
+ // If propValue is provided than act as a controlled component
33
+ // If not then act as an uncontrolled component using the value from state
36
34
  var value = typeof propValue !== 'undefined' ? propValue : selectedValue;
37
35
  return /*#__PURE__*/React.createElement("div", {
38
36
  role: "radiogroup",
39
37
  "aria-labelledby": ariaLabelledBy
40
38
  }, options.map(function (_ref, index) {
41
39
  var optionProps = _extends({}, _ref);
42
-
43
40
  if (typeof isDisabled !== 'undefined') {
44
41
  optionProps.isDisabled = isDisabled;
45
42
  }
46
-
47
43
  var isChecked = value != null && optionProps.value === value;
48
44
  return /*#__PURE__*/React.createElement(Radio, _extends({}, optionProps, {
49
45
  name: name || optionProps.name,
package/dist/esm/radio.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["ariaLabel", "isDisabled", "isRequired", "isInvalid", "isChecked", "label", "mode", "name", "onChange", "value", "testId", "analyticsContext"];
4
-
5
4
  /** @jsx jsx */
6
5
  import { forwardRef, memo, useMemo } from 'react';
7
6
  import { css, jsx } from '@emotion/react';
@@ -12,11 +11,11 @@ import GlobalTheme from '@atlaskit/theme/components';
12
11
  import { fontFamily as getFontFamily } from '@atlaskit/theme/constants';
13
12
  import getRadioCustomProperties from './styles';
14
13
  var packageName = "@atlaskit/radio";
15
- var packageVersion = "5.4.6";
14
+ var packageVersion = "5.4.7";
16
15
  var fontFamily = getFontFamily();
17
16
  var noop = __noop;
18
17
  var labelPaddingStyles = css({
19
- padding: "var(--ds-scale-025, 2px)".concat(" ", "var(--ds-scale-050, 4px)")
18
+ padding: "var(--ds-space-025, 2px)".concat(" ", "var(--ds-space-050, 4px)")
20
19
  });
21
20
  var labelStyles = css({
22
21
  display: 'flex',
@@ -38,7 +37,6 @@ var darkLabelStyles = css({
38
37
  });
39
38
  var radioStyles = css({
40
39
  display: 'flex',
41
-
42
40
  /*
43
41
  The circle should be 14px * 14px centred in a 24px * 24px box.
44
42
  This is inclusive of a 2px border and inner circle with 2px radius.
@@ -48,20 +46,17 @@ var radioStyles = css({
48
46
  */
49
47
  width: '24px',
50
48
  height: '24px',
51
- // TODO Delete this comment after verifying spacing token -> previous value `0`
52
- margin: "var(--ds-scale-0, 0px)",
49
+ margin: "var(--ds-space-0, 0px)",
53
50
  position: 'relative',
54
51
  alignItems: 'center',
55
52
  justifyContent: 'center',
56
53
  flexShrink: 0,
57
54
  backgroundColor: 'var(--radio-background-color)',
58
-
59
55
  /* Border should be 2px, multiply by 24/14 to offset scale */
60
56
  border: 'calc(2px * 12 / 7) solid var(--radio-border-color)',
61
57
  borderRadius: '50%',
62
58
  MozAppearance: 'none',
63
59
  outline: 'none',
64
-
65
60
  /*
66
61
  Change the variables --radio-background-color, --radio-border-color,
67
62
  -radio-dot-color and -radio-dot-opacity according to user interactions.
@@ -71,7 +66,6 @@ var radioStyles = css({
71
66
  '--radio-border-color': 'var(--local-border)',
72
67
  '--radio-dot-color': 'var(--local-dot-checked)',
73
68
  '--radio-dot-opacity': 0,
74
-
75
69
  /* 24px * 7 / 12 === 14px height and width */
76
70
  transform: 'scale(calc(7 / 12))',
77
71
  transition: 'border-color 0.2s ease-in-out, background-color 0.2s ease-in-out',
@@ -128,23 +122,22 @@ var radioStyles = css({
128
122
  });
129
123
  var RadioWithMode = /*#__PURE__*/forwardRef(function Radio(props, ref) {
130
124
  var ariaLabel = props.ariaLabel,
131
- _props$isDisabled = props.isDisabled,
132
- isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
133
- isRequired = props.isRequired,
134
- _props$isInvalid = props.isInvalid,
135
- isInvalid = _props$isInvalid === void 0 ? false : _props$isInvalid,
136
- _props$isChecked = props.isChecked,
137
- isChecked = _props$isChecked === void 0 ? false : _props$isChecked,
138
- label = props.label,
139
- mode = props.mode,
140
- name = props.name,
141
- _props$onChange = props.onChange,
142
- onChange = _props$onChange === void 0 ? noop : _props$onChange,
143
- value = props.value,
144
- testId = props.testId,
145
- analyticsContext = props.analyticsContext,
146
- rest = _objectWithoutProperties(props, _excluded);
147
-
125
+ _props$isDisabled = props.isDisabled,
126
+ isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
127
+ isRequired = props.isRequired,
128
+ _props$isInvalid = props.isInvalid,
129
+ isInvalid = _props$isInvalid === void 0 ? false : _props$isInvalid,
130
+ _props$isChecked = props.isChecked,
131
+ isChecked = _props$isChecked === void 0 ? false : _props$isChecked,
132
+ label = props.label,
133
+ mode = props.mode,
134
+ name = props.name,
135
+ _props$onChange = props.onChange,
136
+ onChange = _props$onChange === void 0 ? noop : _props$onChange,
137
+ value = props.value,
138
+ testId = props.testId,
139
+ analyticsContext = props.analyticsContext,
140
+ rest = _objectWithoutProperties(props, _excluded);
148
141
  var onChangeAnalytics = usePlatformLeafEventHandler({
149
142
  fn: onChange,
150
143
  action: 'changed',
@@ -156,11 +149,13 @@ var RadioWithMode = /*#__PURE__*/forwardRef(function Radio(props, ref) {
156
149
  var radioCustomProperties = useMemo(function () {
157
150
  return css(getRadioCustomProperties(mode));
158
151
  }, [mode]);
159
- return (// https://product-fabric.atlassian.net/browse/DST-1971
152
+ return (
153
+ // https://product-fabric.atlassian.net/browse/DST-1971
160
154
  // eslint-disable-next-line jsx-a11y/label-has-associated-control,jsx-a11y/label-has-for
161
155
  jsx("label", {
162
156
  "data-testid": testId && "".concat(testId, "--radio-label"),
163
- "data-disabled": isDisabled ? 'true' : undefined // TODO these will no longer be dynamic styles when legacy theming removed
157
+ "data-disabled": isDisabled ? 'true' : undefined
158
+ // TODO these will no longer be dynamic styles when legacy theming removed
164
159
  // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
165
160
  ,
166
161
  css: [labelStyles, mode === 'light' ? lightLabelStyles : darkLabelStyles]
@@ -173,10 +168,12 @@ var RadioWithMode = /*#__PURE__*/forwardRef(function Radio(props, ref) {
173
168
  required: isRequired,
174
169
  type: "radio",
175
170
  value: value,
176
- "data-testid": testId && "".concat(testId, "--radio-input") // isInvalid is used in a nonstandard way so cannot
171
+ "data-testid": testId && "".concat(testId, "--radio-input")
172
+ // isInvalid is used in a nonstandard way so cannot
177
173
  // use :invalid selector
178
174
  ,
179
- "data-invalid": isInvalid ? 'true' : undefined // TODO radioCustomProperties can be defined at top of file when legacy theming removed
175
+ "data-invalid": isInvalid ? 'true' : undefined
176
+ // TODO radioCustomProperties can be defined at top of file when legacy theming removed
180
177
  // eslint-disable-next-line @repo/internal/react/consistent-css-prop-usage
181
178
  ,
182
179
  css: [radioStyles, radioCustomProperties],
@@ -186,6 +183,7 @@ var RadioWithMode = /*#__PURE__*/forwardRef(function Radio(props, ref) {
186
183
  }, label) : null)
187
184
  );
188
185
  });
186
+
189
187
  /**
190
188
  * __Radio__
191
189
  *
@@ -195,7 +193,6 @@ var RadioWithMode = /*#__PURE__*/forwardRef(function Radio(props, ref) {
195
193
  * - [Code](https://atlassian.design/components/radio/code)
196
194
  * - [Usage](https://atlassian.design/components/radio/usage)
197
195
  */
198
-
199
196
  var Radio = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Radio(props, ref) {
200
197
  return jsx(GlobalTheme.Consumer, null, function (_ref) {
201
198
  var mode = _ref.mode;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/radio",
3
- "version": "5.4.6",
3
+ "version": "5.4.7",
4
4
  "sideEffects": false
5
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/radio",
3
- "version": "5.4.6",
3
+ "version": "5.4.7",
4
4
  "description": "A radio input allows users to select only one option from a number of choices. Radio is generally displayed in a radio group.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
package/report.api.md CHANGED
@@ -8,6 +8,7 @@
8
8
  ### Table of contents
9
9
 
10
10
  - [Main Entry Types](#main-entry-types)
11
+ - [Peer Dependencies](#peer-dependencies)
11
12
 
12
13
  ### Main Entry Types
13
14
 
@@ -411,3 +412,15 @@ type RadioValue = string;
411
412
  ```
412
413
 
413
414
  <!--SECTION END: Main Entry Types-->
415
+
416
+ ### Peer Dependencies
417
+
418
+ <!--SECTION START: Peer Dependencies-->
419
+
420
+ ```json
421
+ {
422
+ "react": "^16.8.0"
423
+ }
424
+ ```
425
+
426
+ <!--SECTION END: Peer Dependencies-->