@pingux/astro 2.97.0 → 2.98.0-alpha.0
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/lib/cjs/components/Radio/Radio.d.ts +12 -0
- package/lib/cjs/components/Radio/Radio.js +2 -1
- package/lib/cjs/components/Radio/Radio.styles.d.ts +53 -0
- package/lib/cjs/components/Radio/Radio.styles.js +4 -2
- package/lib/cjs/components/Radio/index.d.ts +1 -0
- package/lib/cjs/components/RadioField/RadioField.d.ts +12 -0
- package/lib/cjs/components/RadioField/RadioField.js +6 -57
- package/lib/cjs/components/RadioField/RadioField.test.d.ts +1 -0
- package/lib/cjs/components/RadioField/RadioField.test.js +7 -4
- package/lib/cjs/components/RadioField/index.d.ts +2 -0
- package/lib/cjs/components/RadioGroupField/RadioGroupField.d.ts +4 -0
- package/lib/cjs/components/RadioGroupField/RadioGroupField.js +2 -47
- package/lib/cjs/components/RadioGroupField/RadioGroupField.stories.d.ts +42 -0
- package/lib/cjs/components/RadioGroupField/RadioGroupField.stories.js +7 -0
- package/lib/cjs/components/RadioGroupField/RadioGroupField.test.d.ts +1 -0
- package/lib/cjs/components/RadioGroupField/RadioGroupField.test.js +4 -4
- package/lib/cjs/components/RadioGroupField/index.d.ts +1 -0
- package/lib/cjs/types/radio.d.ts +3 -0
- package/lib/cjs/types/radio.js +6 -0
- package/lib/cjs/types/radioField.d.ts +42 -0
- package/lib/cjs/types/radioField.js +6 -0
- package/lib/cjs/types/radioGroupField.d.ts +15 -0
- package/lib/cjs/types/radioGroupField.js +6 -0
- package/lib/cjs/utils/designUtils/figmaLinks.d.ts +3 -0
- package/lib/cjs/utils/designUtils/figmaLinks.js +3 -0
- package/lib/components/Radio/Radio.js +1 -2
- package/lib/components/Radio/Radio.styles.js +4 -2
- package/lib/components/RadioField/RadioField.js +8 -59
- package/lib/components/RadioField/RadioField.test.js +7 -4
- package/lib/components/RadioGroupField/RadioGroupField.js +0 -47
- package/lib/components/RadioGroupField/RadioGroupField.stories.js +7 -0
- package/lib/components/RadioGroupField/RadioGroupField.test.js +4 -4
- package/lib/types/radio.js +1 -0
- package/lib/types/radioField.js +1 -0
- package/lib/types/radioGroupField.js +1 -0
- package/lib/utils/designUtils/figmaLinks.js +3 -0
- package/package.json +1 -1
@@ -0,0 +1,12 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { RadioProps } from '../../types/radio';
|
3
|
+
/**
|
4
|
+
* Basic radio input wrapped in a label.
|
5
|
+
* Built on top of the [Radio from Theme-UI](https://theme-ui.com/components/radio/) and uses the
|
6
|
+
* available [props from Theme-UI](https://theme-ui.com/sx-prop).
|
7
|
+
*
|
8
|
+
* **Note: Requires a label. It's recommended to use `RadioGroupField` with `RadioField` for a**
|
9
|
+
* **solution.**
|
10
|
+
*/
|
11
|
+
declare const Radio: React.ForwardRefExoticComponent<RadioProps & React.RefAttributes<HTMLInputElement>>;
|
12
|
+
export default Radio;
|
@@ -22,7 +22,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
22
22
|
*
|
23
23
|
* **Note: Requires a label. It's recommended to use `RadioGroupField` with `RadioField` for a**
|
24
24
|
* **solution.**
|
25
|
-
*/
|
25
|
+
*/
|
26
|
+
var Radio = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
26
27
|
return (0, _react2.jsx)(_themeUi.Radio, (0, _extends2["default"])({
|
27
28
|
ref: ref
|
28
29
|
}, props));
|
@@ -0,0 +1,53 @@
|
|
1
|
+
declare const _default: {
|
2
|
+
base: {
|
3
|
+
width: number;
|
4
|
+
height: number;
|
5
|
+
color: string;
|
6
|
+
mr: string;
|
7
|
+
'input:focus ~ &': {
|
8
|
+
bg: string;
|
9
|
+
boxSizing: string;
|
10
|
+
};
|
11
|
+
'input ~ &.is-focused': {
|
12
|
+
boxShadow: string;
|
13
|
+
outline: string;
|
14
|
+
outlineColor: string;
|
15
|
+
outlineOffset: string;
|
16
|
+
} | {
|
17
|
+
boxShadow: string;
|
18
|
+
border: string;
|
19
|
+
borderColor: string;
|
20
|
+
boxSizing: string;
|
21
|
+
transform: string;
|
22
|
+
transformOrigin: string;
|
23
|
+
};
|
24
|
+
};
|
25
|
+
outerContainer: {
|
26
|
+
'.is-horizontal &': {
|
27
|
+
mr: string;
|
28
|
+
};
|
29
|
+
'&.is-disabled': {
|
30
|
+
opacity: string;
|
31
|
+
};
|
32
|
+
};
|
33
|
+
controlWrapper: {
|
34
|
+
'&.is-disabled': {
|
35
|
+
opacity: string;
|
36
|
+
};
|
37
|
+
};
|
38
|
+
container: {
|
39
|
+
borderWidth: number;
|
40
|
+
borderStyle: string;
|
41
|
+
borderColor: string;
|
42
|
+
borderRadius: number;
|
43
|
+
padding: string;
|
44
|
+
mb: string;
|
45
|
+
};
|
46
|
+
checkedContent: {
|
47
|
+
pb: string;
|
48
|
+
pl: string;
|
49
|
+
color: string;
|
50
|
+
fontSize: string;
|
51
|
+
};
|
52
|
+
};
|
53
|
+
export default _default;
|
@@ -20,14 +20,16 @@ var base = {
|
|
20
20
|
bg: 'transparent',
|
21
21
|
boxSizing: 'border-box'
|
22
22
|
},
|
23
|
-
'input ~ &.is-focused':
|
23
|
+
'input ~ &.is-focused': /* istanbul ignore next */
|
24
|
+
_safariAgent.isSafari ? {
|
24
25
|
boxShadow: 'none',
|
25
26
|
border: '1px solid',
|
26
27
|
borderColor: 'focus',
|
27
28
|
boxSizing: 'border-box',
|
28
29
|
transform: 'scale(1.1)',
|
29
30
|
transformOrigin: 'center'
|
30
|
-
}
|
31
|
+
}
|
32
|
+
/* istanbul ignore next */ : _Buttons.focusWithCroppedOutline
|
31
33
|
};
|
32
34
|
var outerContainer = {
|
33
35
|
'.is-horizontal &': {
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './Radio';
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import { RadioGroupState } from 'react-stately';
|
3
|
+
import { RadioFieldProps } from '../../types/radioField';
|
4
|
+
export declare const RadioContext: React.Context<RadioGroupState>;
|
5
|
+
/**
|
6
|
+
* Combines a radio, label, and helper text for a complete, form-ready solution.
|
7
|
+
*
|
8
|
+
* Utilizes [useRadio](https://react-spectrum.adobe.com/react-aria/useRadioGroup.html) from React
|
9
|
+
* Aria.
|
10
|
+
*/
|
11
|
+
declare const RadioField: React.ForwardRefExoticComponent<RadioFieldProps & React.RefAttributes<HTMLInputElement>>;
|
12
|
+
export default RadioField;
|
@@ -19,10 +19,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/e
|
|
19
19
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
20
20
|
var _react = _interopRequireWildcard(require("react"));
|
21
21
|
var _reactAria = require("react-aria");
|
22
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
23
22
|
var _hooks = require("../../hooks");
|
24
|
-
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
25
|
-
var _statusProp = require("../../utils/docUtils/statusProp");
|
26
23
|
var _Box = _interopRequireDefault(require("../Box"));
|
27
24
|
var _FieldHelperText = _interopRequireDefault(require("../FieldHelperText"));
|
28
25
|
var _Label = _interopRequireDefault(require("../Label"));
|
@@ -32,7 +29,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "functi
|
|
32
29
|
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; }
|
33
30
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
34
31
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
35
|
-
var
|
32
|
+
var defaultValue = {};
|
33
|
+
var RadioContext = /*#__PURE__*/(0, _react.createContext)(defaultValue);
|
36
34
|
|
37
35
|
/**
|
38
36
|
* Combines a radio, label, and helper text for a complete, form-ready solution.
|
@@ -49,20 +47,17 @@ var RadioField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
49
47
|
radioDisabled = props.isDisabled,
|
50
48
|
label = props.label,
|
51
49
|
status = props.status;
|
52
|
-
var radioFieldRef = (0, _react.useRef)();
|
53
50
|
(0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
|
54
|
-
|
55
|
-
(0, _react.useImperativeHandle)(ref, function () {
|
56
|
-
return radioFieldRef.current;
|
57
|
-
});
|
51
|
+
var radioFieldRef = (0, _hooks.useLocalOrForwardRef)(ref);
|
58
52
|
var state = (0, _react.useContext)(RadioContext);
|
59
53
|
var groupDisabled = state.isDisabled;
|
60
54
|
var isDisabled = radioDisabled || groupDisabled;
|
61
55
|
var _useRadio = (0, _reactAria.useRadio)(_objectSpread(_objectSpread({
|
62
56
|
children: label,
|
63
|
-
autoFocus: hasAutoFocus
|
57
|
+
autoFocus: hasAutoFocus
|
58
|
+
}, props), {}, {
|
64
59
|
isDisabled: isDisabled
|
65
|
-
},
|
60
|
+
}, controlProps), state, radioFieldRef),
|
66
61
|
inputProps = _useRadio.inputProps;
|
67
62
|
var isChecked = inputProps.checked;
|
68
63
|
var statusClasses = {
|
@@ -94,52 +89,6 @@ var RadioField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
94
89
|
variant: "forms.radio.checkedContent"
|
95
90
|
}, checkedContent));
|
96
91
|
});
|
97
|
-
RadioField.propTypes = _objectSpread(_objectSpread({
|
98
|
-
/** Content to display when the radio is checked. */
|
99
|
-
checkedContent: _propTypes["default"].node,
|
100
|
-
/** The rendered label for the field. */
|
101
|
-
label: _propTypes["default"].node,
|
102
|
-
/** Whether the element should receive focus on render. */
|
103
|
-
hasAutoFocus: _propTypes["default"].bool,
|
104
|
-
/** Text rendered below the input. */
|
105
|
-
helperText: _propTypes["default"].node,
|
106
|
-
/** If present this prop will cause a help hint to render in the label of the field. */
|
107
|
-
hintText: _propTypes["default"].string,
|
108
|
-
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
109
|
-
id: _propTypes["default"].string,
|
110
|
-
/**
|
111
|
-
* Whether the radio button is disabled or not. Shows that a selection exists, but is not
|
112
|
-
* available in that circumstance.
|
113
|
-
*/
|
114
|
-
isDisabled: _propTypes["default"].bool,
|
115
|
-
/** Whether the Radio can be interacted with but cannot have its selection state changed. */
|
116
|
-
isReadOnly: _propTypes["default"].bool,
|
117
|
-
/** Whether the Radio is required. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required). */
|
118
|
-
isRequired: _propTypes["default"].bool,
|
119
|
-
/** The value of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefvalue). */
|
120
|
-
value: _propTypes["default"].string,
|
121
|
-
/** Handler that is called when the element receives focus. */
|
122
|
-
onFocus: _propTypes["default"].func,
|
123
|
-
/** Handler that is called when the element loses focus. */
|
124
|
-
onBlur: _propTypes["default"].func,
|
125
|
-
/** Handler that is called when the element's focus status changes. */
|
126
|
-
onFocusChange: _propTypes["default"].func,
|
127
|
-
/** Handler that is called when a key is pressed. */
|
128
|
-
onKeyDown: _propTypes["default"].func,
|
129
|
-
/** Handler that is called when a key is released. */
|
130
|
-
onKeyUp: _propTypes["default"].func,
|
131
|
-
/** Defines a string value that labels the current element. */
|
132
|
-
'aria-label': _propTypes["default"].string,
|
133
|
-
/** Identifies the element (or elements) that labels the current element. */
|
134
|
-
'aria-labelledby': _propTypes["default"].string,
|
135
|
-
/** Identifies the element (or elements) that describes the object. */
|
136
|
-
'aria-describedby': _propTypes["default"].string,
|
137
|
-
/**
|
138
|
-
* Identifies the element (or elements) that provide a detailed, extended description for the
|
139
|
-
* object.
|
140
|
-
*/
|
141
|
-
'aria-details': _propTypes["default"].string
|
142
|
-
}, _statusProp.statusPropTypes), _ariaAttributes.ariaAttributesBasePropTypes);
|
143
92
|
RadioField.displayName = 'RadioField';
|
144
93
|
var _default = RadioField;
|
145
94
|
exports["default"] = _default;
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -25,7 +25,9 @@ var defaultProps = {
|
|
25
25
|
value: testValue
|
26
26
|
};
|
27
27
|
var defaultState = {
|
28
|
-
setLastFocusedValue: function setLastFocusedValue() {
|
28
|
+
setLastFocusedValue: function setLastFocusedValue() {
|
29
|
+
return jest.fn();
|
30
|
+
}
|
29
31
|
};
|
30
32
|
var getComponent = function getComponent() {
|
31
33
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
@@ -78,11 +80,12 @@ test('radio with checked content does not display if not checked', function () {
|
|
78
80
|
});
|
79
81
|
test('radio with checked content displays if checked', function () {
|
80
82
|
var testContent = 'test content';
|
83
|
+
var customState = {
|
84
|
+
selectedValue: testValue
|
85
|
+
};
|
81
86
|
getComponent({
|
82
87
|
checkedContent: (0, _react2.jsx)("div", null, testContent)
|
83
|
-
},
|
84
|
-
selectedValue: testValue
|
85
|
-
});
|
88
|
+
}, customState);
|
86
89
|
var content = _testWrapper.screen.queryByText(testContent);
|
87
90
|
expect(content).toBeInTheDocument();
|
88
91
|
});
|
@@ -1,40 +1,27 @@
|
|
1
1
|
"use strict";
|
2
2
|
|
3
3
|
var _typeof = require("@babel/runtime-corejs3/helpers/typeof");
|
4
|
-
var _Object$keys = require("@babel/runtime-corejs3/core-js-stable/object/keys");
|
5
|
-
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols");
|
6
|
-
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/filter");
|
7
|
-
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
8
|
-
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js-stable/instance/for-each");
|
9
|
-
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors");
|
10
|
-
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js-stable/object/define-properties");
|
11
|
-
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
12
4
|
var _WeakMap = require("@babel/runtime-corejs3/core-js-stable/weak-map");
|
5
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
6
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor");
|
13
7
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
14
8
|
_Object$defineProperty(exports, "__esModule", {
|
15
9
|
value: true
|
16
10
|
});
|
17
11
|
exports["default"] = void 0;
|
18
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/defineProperty"));
|
19
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/extends"));
|
20
13
|
var _react = _interopRequireWildcard(require("react"));
|
21
14
|
var _reactAria = require("react-aria");
|
22
15
|
var _reactStately = require("react-stately");
|
23
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
24
16
|
var _uuid = require("uuid");
|
25
17
|
var _ = require("../..");
|
26
18
|
var _hooks = require("../../hooks");
|
27
19
|
var _orientation = _interopRequireDefault(require("../../utils/devUtils/constants/orientation"));
|
28
20
|
var _pendoID = require("../../utils/devUtils/constants/pendoID");
|
29
|
-
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
30
|
-
var _fieldAttributes = require("../../utils/docUtils/fieldAttributes");
|
31
|
-
var _statusProp = require("../../utils/docUtils/statusProp");
|
32
21
|
var _RadioField = require("../RadioField");
|
33
22
|
var _react2 = require("@emotion/react");
|
34
23
|
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); }
|
35
24
|
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; }
|
36
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
37
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
38
25
|
var displayName = 'RadioGroupField';
|
39
26
|
var RadioGroupField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
40
27
|
var children = props.children,
|
@@ -84,37 +71,5 @@ var RadioGroupField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
84
71
|
id: helperTextId
|
85
72
|
}, helperText));
|
86
73
|
});
|
87
|
-
RadioGroupField.propTypes = _objectSpread(_objectSpread(_objectSpread({
|
88
|
-
/** The name of the RadioGroupField, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name_and_radio_buttons). */
|
89
|
-
name: _propTypes["default"].string,
|
90
|
-
/** The current value (controlled). */
|
91
|
-
value: _propTypes["default"].string,
|
92
|
-
/** The default value (uncontrolled). */
|
93
|
-
defaultValue: _propTypes["default"].string,
|
94
|
-
/** Text to display after the radio group label. Useful for errors or other info. */
|
95
|
-
helperText: _propTypes["default"].node,
|
96
|
-
/** If present this prop will cause a help hint to render in the label of the field. */
|
97
|
-
hintText: _propTypes["default"].string,
|
98
|
-
/** Determines the arrangement of the radios. */
|
99
|
-
orientation: _propTypes["default"].oneOf(['horizontal', 'vertical']),
|
100
|
-
/**
|
101
|
-
* Handler that is called when the value changes.
|
102
|
-
*
|
103
|
-
* `(newValue) => void`
|
104
|
-
*/
|
105
|
-
onChange: _propTypes["default"].func,
|
106
|
-
/** Whether the radio group is disabled. */
|
107
|
-
isDisabled: _propTypes["default"].bool,
|
108
|
-
/** Whether user input is required on the input before form submission. */
|
109
|
-
isRequired: _propTypes["default"].bool,
|
110
|
-
/**
|
111
|
-
* The content to display as the label. If not set, It is recommended to set an aria-label or
|
112
|
-
* aria-labelledby attribute for accessibility.
|
113
|
-
*/
|
114
|
-
label: _propTypes["default"].node,
|
115
|
-
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
116
|
-
id: _propTypes["default"].string
|
117
|
-
}, _statusProp.statusPropTypes), _ariaAttributes.ariaAttributesBasePropTypes), _fieldAttributes.inputFieldAttributesBasePropTypes);
|
118
|
-
RadioGroupField.displayName = displayName;
|
119
74
|
var _default = RadioGroupField;
|
120
75
|
exports["default"] = _default;
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
declare const _default: {
|
3
|
+
title: string;
|
4
|
+
component: React.ForwardRefExoticComponent<import("../../types/radioGroupField").RadioGroupFieldProps & React.RefAttributes<HTMLDivElement>>;
|
5
|
+
parameters: {
|
6
|
+
docs: {
|
7
|
+
page: () => React.JSX.Element;
|
8
|
+
};
|
9
|
+
};
|
10
|
+
argTypes: any;
|
11
|
+
args: {
|
12
|
+
label: string;
|
13
|
+
defaultValue: string;
|
14
|
+
};
|
15
|
+
};
|
16
|
+
export default _default;
|
17
|
+
export declare const Default: {
|
18
|
+
(args: any): React.JSX.Element;
|
19
|
+
parameters: {
|
20
|
+
design: {
|
21
|
+
type: string;
|
22
|
+
url: string;
|
23
|
+
};
|
24
|
+
};
|
25
|
+
};
|
26
|
+
export declare const Controlled: () => React.JSX.Element;
|
27
|
+
export declare const Required: () => React.JSX.Element;
|
28
|
+
export declare const CheckedContent: () => React.JSX.Element;
|
29
|
+
export declare const HelperText: {
|
30
|
+
(): React.JSX.Element;
|
31
|
+
parameters: {
|
32
|
+
a11y: {
|
33
|
+
config: {
|
34
|
+
rules: {
|
35
|
+
id: string;
|
36
|
+
enabled: boolean;
|
37
|
+
}[];
|
38
|
+
};
|
39
|
+
};
|
40
|
+
};
|
41
|
+
};
|
42
|
+
export declare const HorizontalOrientation: () => React.JSX.Element;
|
@@ -20,6 +20,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime-corejs3/he
|
|
20
20
|
var _react = _interopRequireWildcard(require("react"));
|
21
21
|
var _storybookDocsLayout = _interopRequireDefault(require("../../../.storybook/storybookDocsLayout"));
|
22
22
|
var _index = require("../../index");
|
23
|
+
var _figmaLinks = require("../../utils/designUtils/figmaLinks");
|
23
24
|
var _ariaAttributes = require("../../utils/docUtils/ariaAttributes");
|
24
25
|
var _statusProp = require("../../utils/docUtils/statusProp");
|
25
26
|
var _RadioGroupField = _interopRequireDefault(require("./RadioGroupField.mdx"));
|
@@ -85,6 +86,12 @@ var Default = function Default(args) {
|
|
85
86
|
}));
|
86
87
|
};
|
87
88
|
exports.Default = Default;
|
89
|
+
Default.parameters = {
|
90
|
+
design: {
|
91
|
+
type: 'figma',
|
92
|
+
url: _figmaLinks.FIGMA_LINKS.radioGroup["default"]
|
93
|
+
}
|
94
|
+
};
|
88
95
|
var Controlled = function Controlled() {
|
89
96
|
var _useState = (0, _react.useState)('A'),
|
90
97
|
_useState2 = (0, _slicedToArray2["default"])(_useState, 2),
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -34,16 +34,16 @@ var defaultProps = {
|
|
34
34
|
var getComponent = function getComponent() {
|
35
35
|
var groupProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
36
36
|
var radioProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
37
|
-
return (0, _testWrapper.render)((0, _react2.jsx)(_["default"], (0, _extends2["default"])({}, defaultProps, groupProps), (0, _react2.jsx)(_RadioField["default"],
|
37
|
+
return (0, _testWrapper.render)((0, _react2.jsx)(_["default"], (0, _extends2["default"])({}, defaultProps, groupProps), (0, _react2.jsx)(_RadioField["default"], {
|
38
38
|
value: testValues[0],
|
39
39
|
label: testValues[0]
|
40
|
-
}
|
40
|
+
}), (0, _react2.jsx)(_RadioField["default"], {
|
41
41
|
value: testValues[1],
|
42
42
|
label: testValues[1]
|
43
|
-
}
|
43
|
+
}), (0, _react2.jsx)(_RadioField["default"], {
|
44
44
|
value: testValues[2],
|
45
45
|
label: testValues[2]
|
46
|
-
}
|
46
|
+
})));
|
47
47
|
};
|
48
48
|
|
49
49
|
// Needs to be added to each components test file
|
@@ -0,0 +1 @@
|
|
1
|
+
export { default } from './RadioGroupField';
|
@@ -0,0 +1,42 @@
|
|
1
|
+
import { ReactNode } from 'react';
|
2
|
+
import { Status } from './item';
|
3
|
+
import { DOMAttributes } from './shared';
|
4
|
+
export interface RadioFieldProps extends DOMAttributes {
|
5
|
+
/** Content to display when the radio is checked. */
|
6
|
+
checkedContent?: ReactNode;
|
7
|
+
/** props spread into the input element */
|
8
|
+
controlProps?: object;
|
9
|
+
/** The rendered label for the field. */
|
10
|
+
label?: ReactNode;
|
11
|
+
/** Whether the element should receive focus on render. */
|
12
|
+
hasAutoFocus?: boolean;
|
13
|
+
/** Text rendered below the input. */
|
14
|
+
helperText?: ReactNode;
|
15
|
+
/** If present this prop will cause a help hint to render in the label of the field. */
|
16
|
+
hintText?: string;
|
17
|
+
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
18
|
+
id?: string;
|
19
|
+
/**
|
20
|
+
* Whether the radio button is disabled or not. Shows that a selection exists, but is not
|
21
|
+
* available in that circumstance.
|
22
|
+
*/
|
23
|
+
isDisabled?: boolean;
|
24
|
+
/** Whether the Radio can be interacted with but cannot have its selection state changed. */
|
25
|
+
isReadOnly?: boolean;
|
26
|
+
/** Whether the Radio is required. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required). */
|
27
|
+
isRequired?: boolean;
|
28
|
+
/** the status of the radio field */
|
29
|
+
status?: Status;
|
30
|
+
/** The value of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefvalue). */
|
31
|
+
value: string;
|
32
|
+
/** Handler that is called when the element receives focus. */
|
33
|
+
onFocus?: () => void;
|
34
|
+
/** Handler that is called when the element loses focus. */
|
35
|
+
onBlur?: () => void;
|
36
|
+
/** Handler that is called when the element's focus status changes. */
|
37
|
+
onFocusChange?: () => void;
|
38
|
+
/** Handler that is called when a key is pressed. */
|
39
|
+
onKeyDown?: () => void;
|
40
|
+
/** Handler that is called when a key is released. */
|
41
|
+
onKeyUp?: () => void;
|
42
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { ReactNode } from 'react';
|
2
|
+
import { AriaRadioGroupProps } from 'react-aria';
|
3
|
+
import { SharedFieldProps } from './shared/fieldProps';
|
4
|
+
export interface RadioGroupFieldProps extends Omit<AriaRadioGroupProps, 'label'>, SharedFieldProps {
|
5
|
+
className?: string;
|
6
|
+
id?: string;
|
7
|
+
isDisabled?: boolean;
|
8
|
+
isRequired?: boolean;
|
9
|
+
children?: ReactNode;
|
10
|
+
name?: string;
|
11
|
+
value?: string;
|
12
|
+
defaultValue?: string;
|
13
|
+
orientation?: 'horizontal' | 'vertical';
|
14
|
+
onChange?: (value: string) => void;
|
15
|
+
}
|
@@ -156,6 +156,9 @@ var FIGMA_LINKS = {
|
|
156
156
|
popoverMenu: {
|
157
157
|
"default": 'https://www.figma.com/file/Oa6VYtJcUJzEJuuRp0p4ls/Astro?type=design&node-id=0%3A3073&t=We3h7LaaFJQnxdSy-1'
|
158
158
|
},
|
159
|
+
radioGroup: {
|
160
|
+
"default": 'https://embed.figma.com/design/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?m=auto&node-id=3613-12435&embed-host=share'
|
161
|
+
},
|
159
162
|
requirementsList: {
|
160
163
|
"default": 'https://www.figma.com/file/Oa6VYtJcUJzEJuuRp0p4ls/Astro?type=design&node-id=0%3A4039&t=We3h7LaaFJQnxdSy-1'
|
161
164
|
},
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
2
2
|
import React, { forwardRef } from 'react';
|
3
3
|
import { Radio as ThemeUIRadio } from 'theme-ui';
|
4
|
-
|
4
|
+
import { jsx as ___EmotionJSX } from "@emotion/react";
|
5
5
|
/**
|
6
6
|
* Basic radio input wrapped in a label.
|
7
7
|
* Built on top of the [Radio from Theme-UI](https://theme-ui.com/components/radio/) and uses the
|
@@ -10,7 +10,6 @@ import { Radio as ThemeUIRadio } from 'theme-ui';
|
|
10
10
|
* **Note: Requires a label. It's recommended to use `RadioGroupField` with `RadioField` for a**
|
11
11
|
* **solution.**
|
12
12
|
*/
|
13
|
-
import { jsx as ___EmotionJSX } from "@emotion/react";
|
14
13
|
var Radio = /*#__PURE__*/forwardRef(function (props, ref) {
|
15
14
|
return ___EmotionJSX(ThemeUIRadio, _extends({
|
16
15
|
ref: ref
|
@@ -14,14 +14,16 @@ var base = {
|
|
14
14
|
bg: 'transparent',
|
15
15
|
boxSizing: 'border-box'
|
16
16
|
},
|
17
|
-
'input ~ &.is-focused':
|
17
|
+
'input ~ &.is-focused': /* istanbul ignore next */
|
18
|
+
isSafari ? {
|
18
19
|
boxShadow: 'none',
|
19
20
|
border: '1px solid',
|
20
21
|
borderColor: 'focus',
|
21
22
|
boxSizing: 'border-box',
|
22
23
|
transform: 'scale(1.1)',
|
23
24
|
transformOrigin: 'center'
|
24
|
-
}
|
25
|
+
}
|
26
|
+
/* istanbul ignore next */ : focusWithCroppedOutline
|
25
27
|
};
|
26
28
|
var outerContainer = {
|
27
29
|
'.is-horizontal &': {
|
@@ -10,18 +10,16 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
10
10
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
11
11
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
12
12
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
13
|
-
import React, { createContext, forwardRef, useContext
|
13
|
+
import React, { createContext, forwardRef, useContext } from 'react';
|
14
14
|
import { useRadio } from 'react-aria';
|
15
|
-
import
|
16
|
-
import { useField, usePropWarning } from '../../hooks';
|
17
|
-
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
18
|
-
import { statusPropTypes } from '../../utils/docUtils/statusProp';
|
15
|
+
import { useField, useLocalOrForwardRef, usePropWarning } from '../../hooks';
|
19
16
|
import Box from '../Box';
|
20
17
|
import FieldHelperText from '../FieldHelperText';
|
21
18
|
import Label from '../Label';
|
22
19
|
import Radio from '../Radio';
|
23
20
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
24
|
-
|
21
|
+
var defaultValue = {};
|
22
|
+
export var RadioContext = /*#__PURE__*/createContext(defaultValue);
|
25
23
|
|
26
24
|
/**
|
27
25
|
* Combines a radio, label, and helper text for a complete, form-ready solution.
|
@@ -37,20 +35,17 @@ var RadioField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
37
35
|
radioDisabled = props.isDisabled,
|
38
36
|
label = props.label,
|
39
37
|
status = props.status;
|
40
|
-
var radioFieldRef = useRef();
|
41
38
|
usePropWarning(props, 'disabled', 'isDisabled');
|
42
|
-
|
43
|
-
useImperativeHandle(ref, function () {
|
44
|
-
return radioFieldRef.current;
|
45
|
-
});
|
39
|
+
var radioFieldRef = useLocalOrForwardRef(ref);
|
46
40
|
var state = useContext(RadioContext);
|
47
41
|
var groupDisabled = state.isDisabled;
|
48
42
|
var isDisabled = radioDisabled || groupDisabled;
|
49
43
|
var _useRadio = useRadio(_objectSpread(_objectSpread({
|
50
44
|
children: label,
|
51
|
-
autoFocus: hasAutoFocus
|
45
|
+
autoFocus: hasAutoFocus
|
46
|
+
}, props), {}, {
|
52
47
|
isDisabled: isDisabled
|
53
|
-
},
|
48
|
+
}, controlProps), state, radioFieldRef),
|
54
49
|
inputProps = _useRadio.inputProps;
|
55
50
|
var isChecked = inputProps.checked;
|
56
51
|
var statusClasses = {
|
@@ -82,51 +77,5 @@ var RadioField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
82
77
|
variant: "forms.radio.checkedContent"
|
83
78
|
}, checkedContent));
|
84
79
|
});
|
85
|
-
RadioField.propTypes = _objectSpread(_objectSpread({
|
86
|
-
/** Content to display when the radio is checked. */
|
87
|
-
checkedContent: PropTypes.node,
|
88
|
-
/** The rendered label for the field. */
|
89
|
-
label: PropTypes.node,
|
90
|
-
/** Whether the element should receive focus on render. */
|
91
|
-
hasAutoFocus: PropTypes.bool,
|
92
|
-
/** Text rendered below the input. */
|
93
|
-
helperText: PropTypes.node,
|
94
|
-
/** If present this prop will cause a help hint to render in the label of the field. */
|
95
|
-
hintText: PropTypes.string,
|
96
|
-
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
97
|
-
id: PropTypes.string,
|
98
|
-
/**
|
99
|
-
* Whether the radio button is disabled or not. Shows that a selection exists, but is not
|
100
|
-
* available in that circumstance.
|
101
|
-
*/
|
102
|
-
isDisabled: PropTypes.bool,
|
103
|
-
/** Whether the Radio can be interacted with but cannot have its selection state changed. */
|
104
|
-
isReadOnly: PropTypes.bool,
|
105
|
-
/** Whether the Radio is required. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/required). */
|
106
|
-
isRequired: PropTypes.bool,
|
107
|
-
/** The value of the input element, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#htmlattrdefvalue). */
|
108
|
-
value: PropTypes.string,
|
109
|
-
/** Handler that is called when the element receives focus. */
|
110
|
-
onFocus: PropTypes.func,
|
111
|
-
/** Handler that is called when the element loses focus. */
|
112
|
-
onBlur: PropTypes.func,
|
113
|
-
/** Handler that is called when the element's focus status changes. */
|
114
|
-
onFocusChange: PropTypes.func,
|
115
|
-
/** Handler that is called when a key is pressed. */
|
116
|
-
onKeyDown: PropTypes.func,
|
117
|
-
/** Handler that is called when a key is released. */
|
118
|
-
onKeyUp: PropTypes.func,
|
119
|
-
/** Defines a string value that labels the current element. */
|
120
|
-
'aria-label': PropTypes.string,
|
121
|
-
/** Identifies the element (or elements) that labels the current element. */
|
122
|
-
'aria-labelledby': PropTypes.string,
|
123
|
-
/** Identifies the element (or elements) that describes the object. */
|
124
|
-
'aria-describedby': PropTypes.string,
|
125
|
-
/**
|
126
|
-
* Identifies the element (or elements) that provide a detailed, extended description for the
|
127
|
-
* object.
|
128
|
-
*/
|
129
|
-
'aria-details': PropTypes.string
|
130
|
-
}, statusPropTypes), ariaAttributesBasePropTypes);
|
131
80
|
RadioField.displayName = 'RadioField';
|
132
81
|
export default RadioField;
|
@@ -16,7 +16,9 @@ var defaultProps = {
|
|
16
16
|
value: testValue
|
17
17
|
};
|
18
18
|
var defaultState = {
|
19
|
-
setLastFocusedValue: function setLastFocusedValue() {
|
19
|
+
setLastFocusedValue: function setLastFocusedValue() {
|
20
|
+
return jest.fn();
|
21
|
+
}
|
20
22
|
};
|
21
23
|
var getComponent = function getComponent() {
|
22
24
|
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
@@ -69,11 +71,12 @@ test('radio with checked content does not display if not checked', function () {
|
|
69
71
|
});
|
70
72
|
test('radio with checked content displays if checked', function () {
|
71
73
|
var testContent = 'test content';
|
74
|
+
var customState = {
|
75
|
+
selectedValue: testValue
|
76
|
+
};
|
72
77
|
getComponent({
|
73
78
|
checkedContent: ___EmotionJSX("div", null, testContent)
|
74
|
-
},
|
75
|
-
selectedValue: testValue
|
76
|
-
});
|
79
|
+
}, customState);
|
77
80
|
var content = screen.queryByText(testContent);
|
78
81
|
expect(content).toBeInTheDocument();
|
79
82
|
});
|
@@ -1,27 +1,12 @@
|
|
1
|
-
import _Object$keys from "@babel/runtime-corejs3/core-js-stable/object/keys";
|
2
|
-
import _Object$getOwnPropertySymbols from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-symbols";
|
3
|
-
import _filterInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/filter";
|
4
|
-
import _Object$getOwnPropertyDescriptor from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptor";
|
5
|
-
import _forEachInstanceProperty from "@babel/runtime-corejs3/core-js-stable/instance/for-each";
|
6
|
-
import _Object$getOwnPropertyDescriptors from "@babel/runtime-corejs3/core-js-stable/object/get-own-property-descriptors";
|
7
|
-
import _Object$defineProperties from "@babel/runtime-corejs3/core-js-stable/object/define-properties";
|
8
|
-
import _Object$defineProperty from "@babel/runtime-corejs3/core-js-stable/object/define-property";
|
9
|
-
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
10
1
|
import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
11
|
-
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
12
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
13
2
|
import React, { forwardRef, useMemo } from 'react';
|
14
3
|
import { useRadioGroup } from 'react-aria';
|
15
4
|
import { useRadioGroupState } from 'react-stately';
|
16
|
-
import PropTypes from 'prop-types';
|
17
5
|
import { v4 as uuid } from 'uuid';
|
18
6
|
import { Box, FieldHelperText, Label } from '../..';
|
19
7
|
import { usePropWarning, useStatusClasses } from '../../hooks';
|
20
8
|
import ORIENTATION from '../../utils/devUtils/constants/orientation';
|
21
9
|
import { getPendoID } from '../../utils/devUtils/constants/pendoID';
|
22
|
-
import { ariaAttributesBasePropTypes } from '../../utils/docUtils/ariaAttributes';
|
23
|
-
import { inputFieldAttributesBasePropTypes } from '../../utils/docUtils/fieldAttributes';
|
24
|
-
import { statusPropTypes } from '../../utils/docUtils/statusProp';
|
25
10
|
import { RadioContext } from '../RadioField';
|
26
11
|
import { jsx as ___EmotionJSX } from "@emotion/react";
|
27
12
|
var displayName = 'RadioGroupField';
|
@@ -73,36 +58,4 @@ var RadioGroupField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
73
58
|
id: helperTextId
|
74
59
|
}, helperText));
|
75
60
|
});
|
76
|
-
RadioGroupField.propTypes = _objectSpread(_objectSpread(_objectSpread({
|
77
|
-
/** The name of the RadioGroupField, used when submitting an HTML form. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#name_and_radio_buttons). */
|
78
|
-
name: PropTypes.string,
|
79
|
-
/** The current value (controlled). */
|
80
|
-
value: PropTypes.string,
|
81
|
-
/** The default value (uncontrolled). */
|
82
|
-
defaultValue: PropTypes.string,
|
83
|
-
/** Text to display after the radio group label. Useful for errors or other info. */
|
84
|
-
helperText: PropTypes.node,
|
85
|
-
/** If present this prop will cause a help hint to render in the label of the field. */
|
86
|
-
hintText: PropTypes.string,
|
87
|
-
/** Determines the arrangement of the radios. */
|
88
|
-
orientation: PropTypes.oneOf(['horizontal', 'vertical']),
|
89
|
-
/**
|
90
|
-
* Handler that is called when the value changes.
|
91
|
-
*
|
92
|
-
* `(newValue) => void`
|
93
|
-
*/
|
94
|
-
onChange: PropTypes.func,
|
95
|
-
/** Whether the radio group is disabled. */
|
96
|
-
isDisabled: PropTypes.bool,
|
97
|
-
/** Whether user input is required on the input before form submission. */
|
98
|
-
isRequired: PropTypes.bool,
|
99
|
-
/**
|
100
|
-
* The content to display as the label. If not set, It is recommended to set an aria-label or
|
101
|
-
* aria-labelledby attribute for accessibility.
|
102
|
-
*/
|
103
|
-
label: PropTypes.node,
|
104
|
-
/** The element's unique identifier. See [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/id). */
|
105
|
-
id: PropTypes.string
|
106
|
-
}, statusPropTypes), ariaAttributesBasePropTypes), inputFieldAttributesBasePropTypes);
|
107
|
-
RadioGroupField.displayName = displayName;
|
108
61
|
export default RadioGroupField;
|
@@ -13,6 +13,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
13
13
|
import React, { useState } from 'react';
|
14
14
|
import DocsLayout from '../../../.storybook/storybookDocsLayout';
|
15
15
|
import { RadioField, RadioGroupField } from '../../index';
|
16
|
+
import { FIGMA_LINKS } from '../../utils/designUtils/figmaLinks';
|
16
17
|
import { ariaAttributeBaseArgTypes } from '../../utils/docUtils/ariaAttributes';
|
17
18
|
import { statusArgTypes } from '../../utils/docUtils/statusProp';
|
18
19
|
import RadioGroupFieldReadme from './RadioGroupField.mdx';
|
@@ -72,6 +73,12 @@ export var Default = function Default(args) {
|
|
72
73
|
label: "C"
|
73
74
|
}));
|
74
75
|
};
|
76
|
+
Default.parameters = {
|
77
|
+
design: {
|
78
|
+
type: 'figma',
|
79
|
+
url: FIGMA_LINKS.radioGroup["default"]
|
80
|
+
}
|
81
|
+
};
|
75
82
|
export var Controlled = function Controlled() {
|
76
83
|
var _useState = useState('A'),
|
77
84
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -30,16 +30,16 @@ var defaultProps = {
|
|
30
30
|
var getComponent = function getComponent() {
|
31
31
|
var groupProps = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
32
32
|
var radioProps = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
33
|
-
return render(___EmotionJSX(RadioGroupField, _extends({}, defaultProps, groupProps), ___EmotionJSX(RadioField,
|
33
|
+
return render(___EmotionJSX(RadioGroupField, _extends({}, defaultProps, groupProps), ___EmotionJSX(RadioField, {
|
34
34
|
value: testValues[0],
|
35
35
|
label: testValues[0]
|
36
|
-
}
|
36
|
+
}), ___EmotionJSX(RadioField, {
|
37
37
|
value: testValues[1],
|
38
38
|
label: testValues[1]
|
39
|
-
}
|
39
|
+
}), ___EmotionJSX(RadioField, {
|
40
40
|
value: testValues[2],
|
41
41
|
label: testValues[2]
|
42
|
-
}
|
42
|
+
})));
|
43
43
|
};
|
44
44
|
|
45
45
|
// Needs to be added to each components test file
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -149,6 +149,9 @@ export var FIGMA_LINKS = {
|
|
149
149
|
popoverMenu: {
|
150
150
|
"default": 'https://www.figma.com/file/Oa6VYtJcUJzEJuuRp0p4ls/Astro?type=design&node-id=0%3A3073&t=We3h7LaaFJQnxdSy-1'
|
151
151
|
},
|
152
|
+
radioGroup: {
|
153
|
+
"default": 'https://embed.figma.com/design/bpbEw54gTTcdIiZs4PKK1p/Astro-Specs?m=auto&node-id=3613-12435&embed-host=share'
|
154
|
+
},
|
152
155
|
requirementsList: {
|
153
156
|
"default": 'https://www.figma.com/file/Oa6VYtJcUJzEJuuRp0p4ls/Astro?type=design&node-id=0%3A4039&t=We3h7LaaFJQnxdSy-1'
|
154
157
|
},
|