@dhis2-ui/radio 9.11.0 → 9.11.1-beta.10
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/cjs/__tests__/radio.test.js +1 -7
- package/build/cjs/features/accepts_initial_focus/index.js +1 -2
- package/build/cjs/features/accepts_label/index.js +0 -1
- package/build/cjs/features/can_be_blurred/index.js +1 -2
- package/build/cjs/features/can_be_changed/index.js +1 -2
- package/build/cjs/features/can_be_disabled/index.js +0 -1
- package/build/cjs/features/can_be_focused/index.js +1 -2
- package/build/cjs/index.js +0 -1
- package/build/cjs/radio-icons.js +12 -22
- package/build/cjs/radio.e2e.stories.js +58 -0
- package/build/cjs/radio.js +7 -35
- package/build/cjs/{radio.stories.js → radio.prod.stories.js} +61 -71
- package/build/es/features/accepts_initial_focus/index.js +1 -1
- package/build/es/features/can_be_blurred/index.js +1 -1
- package/build/es/features/can_be_changed/index.js +1 -1
- package/build/es/features/can_be_focused/index.js +1 -1
- package/build/es/radio-icons.js +11 -11
- package/build/es/{radio.stories.e2e.js → radio.e2e.stories.js} +15 -8
- package/build/es/radio.js +4 -24
- package/build/es/{radio.stories.js → radio.prod.stories.js} +44 -26
- package/package.json +5 -5
- package/build/cjs/radio.stories.e2e.js +0 -45
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _react = require("@testing-library/react");
|
|
4
|
-
|
|
5
4
|
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
5
|
var _radio = require("../radio.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
6
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
7
|
describe('<Radio />', () => {
|
|
12
8
|
it('should call the onKeyDown callback when provided', () => {
|
|
13
9
|
const onKeyDown = jest.fn();
|
|
@@ -17,13 +13,11 @@ describe('<Radio />', () => {
|
|
|
17
13
|
checked: false,
|
|
18
14
|
onKeyDown: onKeyDown
|
|
19
15
|
}));
|
|
20
|
-
|
|
21
16
|
_react.fireEvent.keyDown(_react.screen.getByRole('radio'), {
|
|
22
17
|
key: 'Enter',
|
|
23
18
|
code: 'Enter',
|
|
24
19
|
charCode: 13
|
|
25
20
|
});
|
|
26
|
-
|
|
27
21
|
expect(onKeyDown).toHaveBeenCalledWith({
|
|
28
22
|
name: 'foo',
|
|
29
23
|
value: 'bar',
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a Radio with initialFocus is rendered', () => {
|
|
6
|
-
cy.visitStory('Radio', 'With
|
|
5
|
+
cy.visitStory('Radio', 'With initial focus');
|
|
7
6
|
});
|
|
8
7
|
(0, _cypressCucumberPreprocessor.Then)('the Radio is focused', () => {
|
|
9
8
|
cy.focused().parent('[data-test="dhis2-uicore-radio"]').should('exist');
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a Radio with initialFocus and onBlur handler is rendered', () => {
|
|
6
|
-
cy.visitStory('Radio', 'With
|
|
5
|
+
cy.visitStory('Radio', 'With initial focus and on blur');
|
|
7
6
|
});
|
|
8
7
|
(0, _cypressCucumberPreprocessor.When)('the Radio is blurred', () => {
|
|
9
8
|
cy.get('[data-test="dhis2-uicore-radio"] input').blur();
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a Radio with onChange handler is rendered', () => {
|
|
6
|
-
cy.visitStory('Radio', 'With
|
|
5
|
+
cy.visitStory('Radio', 'With on change');
|
|
7
6
|
});
|
|
8
7
|
(0, _cypressCucumberPreprocessor.When)('the Radio is checked', () => {
|
|
9
8
|
cy.get('[data-test="dhis2-uicore-radio"]').click();
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a Radio with onFocus handler is rendered', () => {
|
|
6
|
-
cy.visitStory('Radio', 'With
|
|
5
|
+
cy.visitStory('Radio', 'With on focus');
|
|
7
6
|
});
|
|
8
7
|
(0, _cypressCucumberPreprocessor.When)('the Radio is focused', () => {
|
|
9
8
|
cy.get('[data-test="dhis2-uicore-radio"] input').focus();
|
package/build/cjs/index.js
CHANGED
package/build/cjs/radio-icons.js
CHANGED
|
@@ -5,20 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.RadioDense = RadioDense;
|
|
7
7
|
exports.RadioRegular = RadioRegular;
|
|
8
|
-
|
|
9
8
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
10
|
-
|
|
11
9
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
12
|
-
|
|
13
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
14
|
-
|
|
15
11
|
var _react = _interopRequireDefault(require("react"));
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const styles = ["svg.jsx-1120332023{display:block;pointer-events:none;}", "svg.jsx-1120332023{fill:".concat(_uiConstants.colors.grey800, ";}"), "circle.background.jsx-1120332023{fill:".concat(_uiConstants.colors.white, ";}"), "svg.checked.jsx-1120332023{fill:".concat(_uiConstants.colors.teal700, ";}"), "svg.disabled.jsx-1120332023{fill:".concat(_uiConstants.colors.grey400, ";}"), "svg.error.jsx-1120332023{fill:".concat(_uiConstants.theme.error, ";}"), "svg.valid.jsx-1120332023{fill:".concat(_uiConstants.theme.valid, ";}"), "svg.warning.jsx-1120332023{fill:".concat(_uiConstants.theme.warning, ";}"), "svg.jsx-1120332023:not(.checked) .inner.jsx-1120332023,svg.jsx-1120332023:not(.checked) .outer.checked.jsx-1120332023{fill:none;}"];
|
|
12
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
|
+
const styles = ["svg.jsx-1120332023{display:block;pointer-events:none;}", `svg.jsx-1120332023{fill:${_uiConstants.colors.grey800};}`, `circle.background.jsx-1120332023{fill:${_uiConstants.colors.white};}`, `svg.checked.jsx-1120332023{fill:${_uiConstants.colors.teal700};}`, `svg.disabled.jsx-1120332023{fill:${_uiConstants.colors.grey400};}`, `svg.error.jsx-1120332023{fill:${_uiConstants.theme.error};}`, `svg.valid.jsx-1120332023{fill:${_uiConstants.theme.valid};}`, `svg.warning.jsx-1120332023{fill:${_uiConstants.theme.warning};}`, "svg.jsx-1120332023:not(.checked) .inner.jsx-1120332023,svg.jsx-1120332023:not(.checked) .outer.checked.jsx-1120332023{fill:none;}"];
|
|
20
14
|
styles.__hash = "1120332023";
|
|
21
|
-
|
|
22
15
|
function RadioRegular(_ref) {
|
|
23
16
|
let {
|
|
24
17
|
className
|
|
@@ -26,34 +19,32 @@ function RadioRegular(_ref) {
|
|
|
26
19
|
return /*#__PURE__*/_react.default.createElement("svg", {
|
|
27
20
|
xmlns: "http://www.w3.org/2000/svg",
|
|
28
21
|
viewBox: "0 0 18 18",
|
|
29
|
-
className: "jsx-1260643562 " +
|
|
22
|
+
className: "jsx-1260643562 " + `jsx-${styles.__hash}` + " " + (className || "")
|
|
30
23
|
}, /*#__PURE__*/_react.default.createElement("circle", {
|
|
31
24
|
cx: "9",
|
|
32
25
|
cy: "9",
|
|
33
26
|
r: "9",
|
|
34
|
-
className: "jsx-1260643562 " +
|
|
27
|
+
className: "jsx-1260643562 " + `jsx-${styles.__hash}` + " " + "background"
|
|
35
28
|
}), /*#__PURE__*/_react.default.createElement("path", {
|
|
36
29
|
d: "M9,0 C13.9705627,0 18,4.02943725 18,9 C18,13.9705627 13.9705627,18 9,18 C4.02943725,18 0,13.9705627 0,9 C0,4.02943725 4.02943725,0 9,0 Z M9,1 C4.581722,1 1,4.581722 1,9 C1,13.418278 4.581722,17 9,17 C13.418278,17 17,13.418278 17,9 C17,4.581722 13.418278,1 9,1 Z",
|
|
37
|
-
className: "jsx-1260643562 " +
|
|
30
|
+
className: "jsx-1260643562 " + `jsx-${styles.__hash}` + " " + "outer unchecked"
|
|
38
31
|
}), /*#__PURE__*/_react.default.createElement("path", {
|
|
39
32
|
d: "M9,18 C13.9705627,18 18,13.9705627 18,9 C18,4.02943725 13.9705627,0 9,0 C4.02943725,0 0,4.02943725 0,9 C0,13.9705627 4.02943725,18 9,18 Z M9,16 C5.13400675,16 2,12.8659932 2,9 C2,5.13400675 5.13400675,2 9,2 C12.8659932,2 16,5.13400675 16,9 C16,12.8659932 12.8659932,16 9,16 Z",
|
|
40
|
-
className: "jsx-1260643562 " +
|
|
33
|
+
className: "jsx-1260643562 " + `jsx-${styles.__hash}` + " " + "outer checked"
|
|
41
34
|
}), /*#__PURE__*/_react.default.createElement("circle", {
|
|
42
35
|
cx: "9",
|
|
43
36
|
cy: "9",
|
|
44
37
|
r: "5",
|
|
45
|
-
className: "jsx-1260643562 " +
|
|
38
|
+
className: "jsx-1260643562 " + `jsx-${styles.__hash}` + " " + "inner"
|
|
46
39
|
}), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
47
40
|
id: "1260643562"
|
|
48
41
|
}, ["svg.jsx-1260643562{height:18px;width:18px;}"]), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
49
42
|
id: styles.__hash
|
|
50
43
|
}, styles));
|
|
51
44
|
}
|
|
52
|
-
|
|
53
45
|
RadioRegular.propTypes = {
|
|
54
46
|
className: _propTypes.default.string
|
|
55
47
|
};
|
|
56
|
-
|
|
57
48
|
function RadioDense(_ref2) {
|
|
58
49
|
let {
|
|
59
50
|
className
|
|
@@ -61,30 +52,29 @@ function RadioDense(_ref2) {
|
|
|
61
52
|
return /*#__PURE__*/_react.default.createElement("svg", {
|
|
62
53
|
xmlns: "http://www.w3.org/2000/svg",
|
|
63
54
|
viewBox: "0 0 14 14",
|
|
64
|
-
className: "jsx-1659897952 " +
|
|
55
|
+
className: "jsx-1659897952 " + `jsx-${styles.__hash}` + " " + (className || "")
|
|
65
56
|
}, /*#__PURE__*/_react.default.createElement("circle", {
|
|
66
57
|
cx: "7",
|
|
67
58
|
cy: "7",
|
|
68
59
|
r: "7",
|
|
69
|
-
className: "jsx-1659897952 " +
|
|
60
|
+
className: "jsx-1659897952 " + `jsx-${styles.__hash}` + " " + "background"
|
|
70
61
|
}), /*#__PURE__*/_react.default.createElement("path", {
|
|
71
62
|
d: "M7,14 C10.8659932,14 14,10.8659932 14,7 C14,3.13400675 10.8659932,0 7,0 C3.13400675,0 0,3.13400675 0,7 C0,10.8659932 3.13400675,14 7,14 Z M7,13 C3.6862915,13 1,10.3137085 1,7 C1,3.6862915 3.6862915,1 7,1 C10.3137085,1 13,3.6862915 13,7 C13,10.3137085 10.3137085,13 7,13 Z",
|
|
72
|
-
className: "jsx-1659897952 " +
|
|
63
|
+
className: "jsx-1659897952 " + `jsx-${styles.__hash}` + " " + "outer unchecked"
|
|
73
64
|
}), /*#__PURE__*/_react.default.createElement("path", {
|
|
74
65
|
d: "M7,14 C10.8659932,14 14,10.8659932 14,7 C14,3.13400675 10.8659932,0 7,0 C3.13400675,0 0,3.13400675 0,7 C0,10.8659932 3.13400675,14 7,14 Z M7,12 C4.23857625,12 2,9.76142375 2,7 C2,4.23857625 4.23857625,2 7,2 C9.76142375,2 12,4.23857625 12,7 C12,9.76142375 9.76142375,12 7,12 Z",
|
|
75
|
-
className: "jsx-1659897952 " +
|
|
66
|
+
className: "jsx-1659897952 " + `jsx-${styles.__hash}` + " " + "outer checked"
|
|
76
67
|
}), /*#__PURE__*/_react.default.createElement("circle", {
|
|
77
68
|
cx: "7",
|
|
78
69
|
cy: "7",
|
|
79
70
|
r: "3",
|
|
80
|
-
className: "jsx-1659897952 " +
|
|
71
|
+
className: "jsx-1659897952 " + `jsx-${styles.__hash}` + " " + "inner"
|
|
81
72
|
}), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
82
73
|
id: "1659897952"
|
|
83
74
|
}, ["svg.jsx-1659897952{height:14px;width:14px;}"]), /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
84
75
|
id: styles.__hash
|
|
85
76
|
}, styles));
|
|
86
77
|
}
|
|
87
|
-
|
|
88
78
|
RadioDense.propTypes = {
|
|
89
79
|
className: _propTypes.default.string
|
|
90
80
|
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithOnFocus = exports.WithOnChange = exports.WithLabel = exports.WithInitialFocusAndOnBlur = exports.WithInitialFocus = exports.WithDisabled = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _radio = require("./radio.js");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
window.onChange = window.Cypress && window.Cypress.cy.stub();
|
|
11
|
+
window.onBlur = window.Cypress && window.Cypress.cy.stub();
|
|
12
|
+
window.onFocus = window.Cypress && window.Cypress.cy.stub();
|
|
13
|
+
var _default = exports.default = {
|
|
14
|
+
title: 'Radio'
|
|
15
|
+
};
|
|
16
|
+
const WithOnChange = () => /*#__PURE__*/_react.default.createElement(_radio.Radio, {
|
|
17
|
+
name: "Ex",
|
|
18
|
+
label: "Radio",
|
|
19
|
+
value: "default",
|
|
20
|
+
onChange: window.onChange
|
|
21
|
+
});
|
|
22
|
+
exports.WithOnChange = WithOnChange;
|
|
23
|
+
const WithInitialFocusAndOnBlur = () => /*#__PURE__*/_react.default.createElement(_radio.Radio, {
|
|
24
|
+
name: "Ex",
|
|
25
|
+
label: "Radio",
|
|
26
|
+
value: "default",
|
|
27
|
+
initialFocus: true,
|
|
28
|
+
onBlur: window.onBlur
|
|
29
|
+
});
|
|
30
|
+
exports.WithInitialFocusAndOnBlur = WithInitialFocusAndOnBlur;
|
|
31
|
+
const WithOnFocus = () => /*#__PURE__*/_react.default.createElement(_radio.Radio, {
|
|
32
|
+
initialFocus: true,
|
|
33
|
+
name: "Ex",
|
|
34
|
+
label: "Radio",
|
|
35
|
+
value: "default",
|
|
36
|
+
onFocus: window.onFocus
|
|
37
|
+
});
|
|
38
|
+
exports.WithOnFocus = WithOnFocus;
|
|
39
|
+
const WithDisabled = () => /*#__PURE__*/_react.default.createElement(_radio.Radio, {
|
|
40
|
+
name: "Ex",
|
|
41
|
+
label: "Radio",
|
|
42
|
+
value: "default",
|
|
43
|
+
disabled: true
|
|
44
|
+
});
|
|
45
|
+
exports.WithDisabled = WithDisabled;
|
|
46
|
+
const WithLabel = () => /*#__PURE__*/_react.default.createElement(_radio.Radio, {
|
|
47
|
+
name: "Ex",
|
|
48
|
+
label: "The label",
|
|
49
|
+
value: "default"
|
|
50
|
+
});
|
|
51
|
+
exports.WithLabel = WithLabel;
|
|
52
|
+
const WithInitialFocus = () => /*#__PURE__*/_react.default.createElement(_radio.Radio, {
|
|
53
|
+
name: "Ex",
|
|
54
|
+
label: "The label",
|
|
55
|
+
value: "default",
|
|
56
|
+
initialFocus: true
|
|
57
|
+
});
|
|
58
|
+
exports.WithInitialFocus = WithInitialFocus;
|
package/build/cjs/radio.js
CHANGED
|
@@ -4,64 +4,48 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Radio = void 0;
|
|
7
|
-
|
|
8
7
|
var _style = _interopRequireDefault(require("styled-jsx/style"));
|
|
9
|
-
|
|
10
8
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
11
|
-
|
|
12
9
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
-
|
|
14
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
17
|
-
|
|
18
12
|
var _radioIcons = require("./radio-icons.js");
|
|
19
|
-
|
|
20
|
-
function
|
|
21
|
-
|
|
22
|
-
function
|
|
23
|
-
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
27
|
-
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
17
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
18
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
28
19
|
class Radio extends _react.Component {
|
|
29
20
|
constructor() {
|
|
30
21
|
super(...arguments);
|
|
31
|
-
|
|
32
22
|
_defineProperty(this, "ref", /*#__PURE__*/(0, _react.createRef)());
|
|
33
|
-
|
|
34
23
|
_defineProperty(this, "handleChange", e => {
|
|
35
24
|
if (this.props.onChange) {
|
|
36
25
|
this.props.onChange(this.createHandlerPayload(), e);
|
|
37
26
|
}
|
|
38
27
|
});
|
|
39
|
-
|
|
40
28
|
_defineProperty(this, "handleBlur", e => {
|
|
41
29
|
if (this.props.onBlur) {
|
|
42
30
|
this.props.onBlur(this.createHandlerPayload(), e);
|
|
43
31
|
}
|
|
44
32
|
});
|
|
45
|
-
|
|
46
33
|
_defineProperty(this, "handleFocus", e => {
|
|
47
34
|
if (this.props.onFocus) {
|
|
48
35
|
this.props.onFocus(this.createHandlerPayload(), e);
|
|
49
36
|
}
|
|
50
37
|
});
|
|
51
|
-
|
|
52
38
|
_defineProperty(this, "handleKeyDown", e => {
|
|
53
39
|
if (this.props.onKeyDown) {
|
|
54
40
|
this.props.onKeyDown(this.createHandlerPayload(), e);
|
|
55
41
|
}
|
|
56
42
|
});
|
|
57
43
|
}
|
|
58
|
-
|
|
59
44
|
componentDidMount() {
|
|
60
45
|
if (this.props.initialFocus) {
|
|
61
46
|
this.ref.current.focus();
|
|
62
47
|
}
|
|
63
48
|
}
|
|
64
|
-
|
|
65
49
|
createHandlerPayload() {
|
|
66
50
|
return {
|
|
67
51
|
value: this.props.value,
|
|
@@ -69,7 +53,6 @@ class Radio extends _react.Component {
|
|
|
69
53
|
checked: !this.props.checked
|
|
70
54
|
};
|
|
71
55
|
}
|
|
72
|
-
|
|
73
56
|
render() {
|
|
74
57
|
const {
|
|
75
58
|
checked = false,
|
|
@@ -122,11 +105,9 @@ class Radio extends _react.Component {
|
|
|
122
105
|
})), label, /*#__PURE__*/_react.default.createElement(_style.default, {
|
|
123
106
|
id: "2849316266",
|
|
124
107
|
dynamic: [_uiConstants.colors.grey900, _uiConstants.theme.disabled, label ? _uiConstants.spacers.dp4 : 0, _uiConstants.theme.focus]
|
|
125
|
-
}, [
|
|
108
|
+
}, [`label.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;position:relative;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:start;-webkit-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start;color:${_uiConstants.colors.grey900};font-size:14px;line-height:19px;}`, "label.dense.__jsx-style-dynamic-selector{font-size:14px;line-height:16px;}", `label.disabled.__jsx-style-dynamic-selector{cursor:not-allowed;color:${_uiConstants.theme.disabled};}`, "input.__jsx-style-dynamic-selector{opacity:0;position:absolute;height:18px;width:18px;inset-inline-start:3px;}", "label.dense.__jsx-style-dynamic-selector input.__jsx-style-dynamic-selector{height:14px;width:14px;}", `.icon.__jsx-style-dynamic-selector{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;margin-inline-end:${label ? _uiConstants.spacers.dp4 : 0};border:2px solid transparent;padding:1px;border-radius:50%;}`, "label.dense.__jsx-style-dynamic-selector .icon.__jsx-style-dynamic-selector{margin-inline-end:3px;}", `input.__jsx-style-dynamic-selector:focus+.icon.__jsx-style-dynamic-selector{outline:3px solid ${_uiConstants.theme.focus};outline-offset:-3px;}`]));
|
|
126
109
|
}
|
|
127
|
-
|
|
128
110
|
}
|
|
129
|
-
|
|
130
111
|
exports.Radio = Radio;
|
|
131
112
|
Radio.defaultProps = {
|
|
132
113
|
dataTest: 'dhis2-uicore-radio'
|
|
@@ -137,34 +118,25 @@ Radio.propTypes = {
|
|
|
137
118
|
dataTest: _propTypes.default.string,
|
|
138
119
|
dense: _propTypes.default.bool,
|
|
139
120
|
disabled: _propTypes.default.bool,
|
|
140
|
-
|
|
141
121
|
/** Adds 'error' styling for feedback. Mutually exclusive with `valid` and `warning` props */
|
|
142
122
|
error: _uiConstants.sharedPropTypes.statusPropType,
|
|
143
123
|
initialFocus: _propTypes.default.bool,
|
|
144
124
|
label: _propTypes.default.node,
|
|
145
|
-
|
|
146
125
|
/** Name associated with this element. Passed in object to event handler functions */
|
|
147
126
|
name: _propTypes.default.string,
|
|
148
127
|
tabIndex: _propTypes.default.string,
|
|
149
|
-
|
|
150
128
|
/** Adds 'valid' styling for feedback. Mutually exclusive with `error` and `warning` props */
|
|
151
129
|
valid: _uiConstants.sharedPropTypes.statusPropType,
|
|
152
|
-
|
|
153
130
|
/** Value associated with this element. Passed in object to event handler functions */
|
|
154
131
|
value: _propTypes.default.string,
|
|
155
|
-
|
|
156
132
|
/** Adds 'warning' styling for feedback. Mutually exclusive with `valid` and `error` props */
|
|
157
133
|
warning: _uiConstants.sharedPropTypes.statusPropType,
|
|
158
|
-
|
|
159
134
|
/** Called with the signature `({ name: string, value: string, checked: bool }, event)` */
|
|
160
135
|
onBlur: _propTypes.default.func,
|
|
161
|
-
|
|
162
136
|
/** Called with the signature `({ name: string, value: string, checked: bool }, event)` */
|
|
163
137
|
onChange: _propTypes.default.func,
|
|
164
|
-
|
|
165
138
|
/** Called with the signature `({ name: string, value: string, checked: bool }, event)` */
|
|
166
139
|
onFocus: _propTypes.default.func,
|
|
167
|
-
|
|
168
140
|
/** Called with the signature `({ name: string, value: string, checked: bool }, event)` */
|
|
169
141
|
onKeyDown: _propTypes.default.func
|
|
170
142
|
};
|
|
@@ -4,48 +4,53 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.WarningDense = exports.Warning = exports.ValidDense = exports.Valid = exports.RTL = exports.NoLabel = exports.ImageLabelDense = exports.ImageLabel = exports.FocusedUncheckedDense = exports.FocusedUnchecked = exports.FocusedCheckedDense = exports.FocusedChecked = exports.ErrorDense = exports.Error = exports.DisabledDense = exports.Disabled = exports.DefaultDense = exports.Default = exports.CheckedDense = exports.Checked = void 0;
|
|
7
|
-
|
|
8
7
|
var _uiConstants = require("@dhis2/ui-constants");
|
|
9
|
-
|
|
10
8
|
var _react = _interopRequireDefault(require("react"));
|
|
11
|
-
|
|
12
9
|
var _radio = require("./radio.js");
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
12
|
+
const subtitle = `A control that allows a user to select a single option from a choice of several`;
|
|
13
|
+
const description = `
|
|
14
|
+
Radio buttons are used where a user has the choice of several options but must select only one. Radio buttons should be used where the user has to make a choice, there is no 'off' or 'none' state unless explicitly defined. Radio buttons should be used when there are 5 or less options available. With more than five, a dropdown/Select menu should be used instead.
|
|
15
|
+
|
|
16
|
+
Do not use a radio button if only a single option is available; use a Checkbox here instead.
|
|
17
|
+
|
|
18
|
+
If there are many options that need to select from, consider using a Select instead.
|
|
19
|
+
|
|
20
|
+
#### Size
|
|
13
21
|
|
|
14
|
-
|
|
22
|
+
Radio buttons are available in Regular and Dense sizes. Regular size is usually used in forms and whenever radio buttons are used standalone. Dense size radio buttons are used inside other complex components, not as main elements of a UI.
|
|
15
23
|
|
|
16
|
-
|
|
24
|
+
#### See more
|
|
17
25
|
|
|
18
|
-
|
|
19
|
-
const description = "\nRadio buttons are used where a user has the choice of several options but must select only one. Radio buttons should be used where the user has to make a choice, there is no 'off' or 'none' state unless explicitly defined. Radio buttons should be used when there are 5 or less options available. With more than five, a dropdown/Select menu should be used instead.\n\nDo not use a radio button if only a single option is available; use a Checkbox here instead.\n\nIf there are many options that need to select from, consider using a Select instead.\n\n#### Size\n\nRadio buttons are available in Regular and Dense sizes. Regular size is usually used in forms and whenever radio buttons are used standalone. Dense size radio buttons are used inside other complex components, not as main elements of a UI.\n\n#### See more\n\nLearn more about Radio buttons at [Design System: Radio](https://github.com/dhis2/design-system/blob/master/atoms/radio.md).\n\n```js\nimport { Radio } from '@dhis2/ui'\n```\n";
|
|
26
|
+
Learn more about Radio buttons at [Design System: Radio](https://github.com/dhis2/design-system/blob/master/atoms/radio.md).
|
|
20
27
|
|
|
28
|
+
\`\`\`js
|
|
29
|
+
import { Radio } from '@dhis2/ui'
|
|
30
|
+
\`\`\`
|
|
31
|
+
`;
|
|
21
32
|
window.onChange = (payload, event) => {
|
|
22
33
|
console.log('onChange payload', payload);
|
|
23
34
|
console.log('onChange event', event);
|
|
24
35
|
};
|
|
25
|
-
|
|
26
36
|
window.onFocus = (payload, event) => {
|
|
27
37
|
console.log('onFocus payload', payload);
|
|
28
38
|
console.log('onFocus event', event);
|
|
29
39
|
};
|
|
30
|
-
|
|
31
40
|
window.onBlur = (payload, event) => {
|
|
32
41
|
console.log('onBlur payload', payload);
|
|
33
42
|
console.log('onBlur event', event);
|
|
34
43
|
};
|
|
35
|
-
|
|
36
44
|
const onChange = function () {
|
|
37
45
|
return window.onChange(...arguments);
|
|
38
46
|
};
|
|
39
|
-
|
|
40
47
|
const onFocus = function () {
|
|
41
48
|
return window.onFocus(...arguments);
|
|
42
49
|
};
|
|
43
|
-
|
|
44
50
|
const onBlur = function () {
|
|
45
51
|
return window.onBlur(...arguments);
|
|
46
52
|
};
|
|
47
|
-
|
|
48
|
-
var _default = {
|
|
53
|
+
var _default = exports.default = {
|
|
49
54
|
title: 'Radio',
|
|
50
55
|
component: _radio.Radio,
|
|
51
56
|
parameters: {
|
|
@@ -66,41 +71,36 @@ var _default = {
|
|
|
66
71
|
onBlur: onBlur
|
|
67
72
|
},
|
|
68
73
|
argTypes: {
|
|
69
|
-
valid: {
|
|
74
|
+
valid: {
|
|
75
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
70
76
|
},
|
|
71
|
-
error: {
|
|
77
|
+
error: {
|
|
78
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
72
79
|
},
|
|
73
|
-
warning: {
|
|
80
|
+
warning: {
|
|
81
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
74
82
|
}
|
|
75
83
|
}
|
|
76
84
|
};
|
|
77
|
-
exports.default = _default;
|
|
78
|
-
|
|
79
85
|
const Template = args => /*#__PURE__*/_react.default.createElement(_radio.Radio, args);
|
|
80
|
-
|
|
81
86
|
const CheckedUncheckedTemplate = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_radio.Radio, args), /*#__PURE__*/_react.default.createElement(_radio.Radio, _extends({}, args, {
|
|
82
87
|
checked: true
|
|
83
88
|
})));
|
|
84
|
-
|
|
85
|
-
const Default = Template.bind({});
|
|
86
|
-
exports.Default = Default;
|
|
87
|
-
|
|
89
|
+
const Default = exports.Default = Template.bind({});
|
|
88
90
|
const FocusedUnchecked = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_radio.Radio, _extends({}, args, {
|
|
89
91
|
initialFocus: true,
|
|
90
92
|
className: "initially-focused"
|
|
91
93
|
})), /*#__PURE__*/_react.default.createElement(_radio.Radio, _extends({}, args, {
|
|
92
94
|
className: "initially-unfocused"
|
|
93
|
-
})));
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
})));
|
|
96
|
+
// Stories with initial focus are distracting on docs page
|
|
96
97
|
exports.FocusedUnchecked = FocusedUnchecked;
|
|
97
98
|
FocusedUnchecked.parameters = {
|
|
98
99
|
docs: {
|
|
99
100
|
disable: true
|
|
100
101
|
}
|
|
101
102
|
};
|
|
102
|
-
const FocusedChecked = FocusedUnchecked.bind({});
|
|
103
|
-
exports.FocusedChecked = FocusedChecked;
|
|
103
|
+
const FocusedChecked = exports.FocusedChecked = FocusedUnchecked.bind({});
|
|
104
104
|
FocusedChecked.args = {
|
|
105
105
|
checked: true
|
|
106
106
|
};
|
|
@@ -109,53 +109,46 @@ FocusedChecked.parameters = {
|
|
|
109
109
|
disable: true
|
|
110
110
|
}
|
|
111
111
|
};
|
|
112
|
-
const Checked = Template.bind({});
|
|
113
|
-
exports.Checked = Checked;
|
|
112
|
+
const Checked = exports.Checked = Template.bind({});
|
|
114
113
|
Checked.args = {
|
|
115
114
|
checked: true,
|
|
116
115
|
value: 'checked'
|
|
117
116
|
};
|
|
118
|
-
const Disabled = CheckedUncheckedTemplate.bind({});
|
|
119
|
-
exports.Disabled = Disabled;
|
|
117
|
+
const Disabled = exports.Disabled = CheckedUncheckedTemplate.bind({});
|
|
120
118
|
Disabled.args = {
|
|
121
119
|
disabled: true,
|
|
122
120
|
value: 'disabled'
|
|
123
121
|
};
|
|
124
|
-
const Valid = CheckedUncheckedTemplate.bind({});
|
|
125
|
-
exports.Valid = Valid;
|
|
122
|
+
const Valid = exports.Valid = CheckedUncheckedTemplate.bind({});
|
|
126
123
|
Valid.args = {
|
|
127
124
|
valid: true,
|
|
128
125
|
value: 'valid'
|
|
129
126
|
};
|
|
130
|
-
const Warning = CheckedUncheckedTemplate.bind({});
|
|
131
|
-
exports.Warning = Warning;
|
|
127
|
+
const Warning = exports.Warning = CheckedUncheckedTemplate.bind({});
|
|
132
128
|
Warning.args = {
|
|
133
129
|
warning: true,
|
|
134
130
|
value: 'warning'
|
|
135
131
|
};
|
|
136
|
-
const Error = CheckedUncheckedTemplate.bind({});
|
|
137
|
-
exports.Error = Error;
|
|
132
|
+
const Error = exports.Error = CheckedUncheckedTemplate.bind({});
|
|
138
133
|
Error.args = {
|
|
139
134
|
error: true,
|
|
140
135
|
value: 'error'
|
|
141
136
|
};
|
|
142
|
-
const ImageLabel = Template.bind({});
|
|
143
|
-
exports.ImageLabel = ImageLabel;
|
|
137
|
+
const ImageLabel = exports.ImageLabel = Template.bind({});
|
|
144
138
|
ImageLabel.args = {
|
|
145
139
|
label: /*#__PURE__*/_react.default.createElement("img", {
|
|
146
140
|
src: "https://picsum.photos/id/82/200/100"
|
|
147
141
|
}),
|
|
148
142
|
value: 'with-help'
|
|
149
143
|
};
|
|
150
|
-
const DefaultDense = Template.bind({});
|
|
151
|
-
exports.DefaultDense = DefaultDense;
|
|
144
|
+
const DefaultDense = exports.DefaultDense = Template.bind({});
|
|
152
145
|
DefaultDense.args = {
|
|
153
146
|
dense: true
|
|
154
147
|
};
|
|
155
148
|
DefaultDense.storyName = 'Default - Dense';
|
|
156
|
-
const FocusedUncheckedDense = FocusedUnchecked.bind({});
|
|
157
|
-
|
|
158
|
-
|
|
149
|
+
const FocusedUncheckedDense = exports.FocusedUncheckedDense = FocusedUnchecked.bind({});
|
|
150
|
+
FocusedUncheckedDense.args = {
|
|
151
|
+
...DefaultDense.args
|
|
159
152
|
};
|
|
160
153
|
FocusedUncheckedDense.storyName = 'Focused unchecked - Dense';
|
|
161
154
|
FocusedUncheckedDense.parameters = {
|
|
@@ -163,9 +156,9 @@ FocusedUncheckedDense.parameters = {
|
|
|
163
156
|
disable: true
|
|
164
157
|
}
|
|
165
158
|
};
|
|
166
|
-
const FocusedCheckedDense = FocusedUnchecked.bind({});
|
|
167
|
-
|
|
168
|
-
|
|
159
|
+
const FocusedCheckedDense = exports.FocusedCheckedDense = FocusedUnchecked.bind({});
|
|
160
|
+
FocusedCheckedDense.args = {
|
|
161
|
+
...DefaultDense.args,
|
|
169
162
|
checked: true
|
|
170
163
|
};
|
|
171
164
|
FocusedCheckedDense.storyName = 'Focused checked - Dense';
|
|
@@ -174,51 +167,48 @@ FocusedCheckedDense.parameters = {
|
|
|
174
167
|
disable: true
|
|
175
168
|
}
|
|
176
169
|
};
|
|
177
|
-
const CheckedDense = Template.bind({});
|
|
178
|
-
|
|
179
|
-
|
|
170
|
+
const CheckedDense = exports.CheckedDense = Template.bind({});
|
|
171
|
+
CheckedDense.args = {
|
|
172
|
+
...Checked.args,
|
|
180
173
|
...DefaultDense.args
|
|
181
174
|
};
|
|
182
175
|
CheckedDense.storyName = 'Checked - Dense';
|
|
183
|
-
const DisabledDense = CheckedUncheckedTemplate.bind({});
|
|
184
|
-
|
|
185
|
-
|
|
176
|
+
const DisabledDense = exports.DisabledDense = CheckedUncheckedTemplate.bind({});
|
|
177
|
+
DisabledDense.args = {
|
|
178
|
+
...Disabled.args,
|
|
186
179
|
...DefaultDense.args
|
|
187
180
|
};
|
|
188
181
|
DisabledDense.storyName = 'Disabled - Dense';
|
|
189
|
-
const ValidDense = CheckedUncheckedTemplate.bind({});
|
|
190
|
-
|
|
191
|
-
|
|
182
|
+
const ValidDense = exports.ValidDense = CheckedUncheckedTemplate.bind({});
|
|
183
|
+
ValidDense.args = {
|
|
184
|
+
...Valid.args,
|
|
192
185
|
...DefaultDense.args
|
|
193
186
|
};
|
|
194
187
|
ValidDense.storyName = 'Valid - Dense';
|
|
195
|
-
const WarningDense = CheckedUncheckedTemplate.bind({});
|
|
196
|
-
|
|
197
|
-
|
|
188
|
+
const WarningDense = exports.WarningDense = CheckedUncheckedTemplate.bind({});
|
|
189
|
+
WarningDense.args = {
|
|
190
|
+
...Warning.args,
|
|
198
191
|
...DefaultDense.args
|
|
199
192
|
};
|
|
200
193
|
WarningDense.storyName = 'Warning - Dense';
|
|
201
|
-
const ErrorDense = CheckedUncheckedTemplate.bind({});
|
|
202
|
-
|
|
203
|
-
|
|
194
|
+
const ErrorDense = exports.ErrorDense = CheckedUncheckedTemplate.bind({});
|
|
195
|
+
ErrorDense.args = {
|
|
196
|
+
...Error.args,
|
|
204
197
|
...DefaultDense.args
|
|
205
198
|
};
|
|
206
199
|
ErrorDense.storyName = 'Error - Dense';
|
|
207
|
-
const ImageLabelDense = Template.bind({});
|
|
208
|
-
|
|
209
|
-
|
|
200
|
+
const ImageLabelDense = exports.ImageLabelDense = Template.bind({});
|
|
201
|
+
ImageLabelDense.args = {
|
|
202
|
+
...ImageLabel.args,
|
|
210
203
|
...DefaultDense.args
|
|
211
204
|
};
|
|
212
205
|
ImageLabelDense.storyName = 'Image label - Dense';
|
|
213
|
-
const NoLabel = Template.bind({});
|
|
214
|
-
exports.NoLabel = NoLabel;
|
|
206
|
+
const NoLabel = exports.NoLabel = Template.bind({});
|
|
215
207
|
NoLabel.args = {
|
|
216
208
|
label: null,
|
|
217
209
|
className: 'some-name'
|
|
218
210
|
};
|
|
219
|
-
|
|
220
211
|
const RTL = args => /*#__PURE__*/_react.default.createElement("div", {
|
|
221
212
|
dir: "rtl"
|
|
222
213
|
}, /*#__PURE__*/_react.default.createElement(Template, args));
|
|
223
|
-
|
|
224
214
|
exports.RTL = RTL;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Given, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a Radio with initialFocus is rendered', () => {
|
|
3
|
-
cy.visitStory('Radio', 'With
|
|
3
|
+
cy.visitStory('Radio', 'With initial focus');
|
|
4
4
|
});
|
|
5
5
|
Then('the Radio is focused', () => {
|
|
6
6
|
cy.focused().parent('[data-test="dhis2-uicore-radio"]').should('exist');
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a Radio with initialFocus and onBlur handler is rendered', () => {
|
|
3
|
-
cy.visitStory('Radio', 'With
|
|
3
|
+
cy.visitStory('Radio', 'With initial focus and on blur');
|
|
4
4
|
});
|
|
5
5
|
When('the Radio is blurred', () => {
|
|
6
6
|
cy.get('[data-test="dhis2-uicore-radio"] input').blur();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a Radio with onChange handler is rendered', () => {
|
|
3
|
-
cy.visitStory('Radio', 'With
|
|
3
|
+
cy.visitStory('Radio', 'With on change');
|
|
4
4
|
});
|
|
5
5
|
When('the Radio is checked', () => {
|
|
6
6
|
cy.get('[data-test="dhis2-uicore-radio"]').click();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor';
|
|
2
2
|
Given('a Radio with onFocus handler is rendered', () => {
|
|
3
|
-
cy.visitStory('Radio', 'With
|
|
3
|
+
cy.visitStory('Radio', 'With on focus');
|
|
4
4
|
});
|
|
5
5
|
When('the Radio is focused', () => {
|
|
6
6
|
cy.get('[data-test="dhis2-uicore-radio"] input').focus();
|
package/build/es/radio-icons.js
CHANGED
|
@@ -2,7 +2,7 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
import { colors, theme } from '@dhis2/ui-constants';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
const styles = ["svg.jsx-1120332023{display:block;pointer-events:none;}",
|
|
5
|
+
const styles = ["svg.jsx-1120332023{display:block;pointer-events:none;}", `svg.jsx-1120332023{fill:${colors.grey800};}`, `circle.background.jsx-1120332023{fill:${colors.white};}`, `svg.checked.jsx-1120332023{fill:${colors.teal700};}`, `svg.disabled.jsx-1120332023{fill:${colors.grey400};}`, `svg.error.jsx-1120332023{fill:${theme.error};}`, `svg.valid.jsx-1120332023{fill:${theme.valid};}`, `svg.warning.jsx-1120332023{fill:${theme.warning};}`, "svg.jsx-1120332023:not(.checked) .inner.jsx-1120332023,svg.jsx-1120332023:not(.checked) .outer.checked.jsx-1120332023{fill:none;}"];
|
|
6
6
|
styles.__hash = "1120332023";
|
|
7
7
|
export function RadioRegular(_ref) {
|
|
8
8
|
let {
|
|
@@ -11,23 +11,23 @@ export function RadioRegular(_ref) {
|
|
|
11
11
|
return /*#__PURE__*/React.createElement("svg", {
|
|
12
12
|
xmlns: "http://www.w3.org/2000/svg",
|
|
13
13
|
viewBox: "0 0 18 18",
|
|
14
|
-
className: "jsx-1260643562 " +
|
|
14
|
+
className: "jsx-1260643562 " + `jsx-${styles.__hash}` + " " + (className || "")
|
|
15
15
|
}, /*#__PURE__*/React.createElement("circle", {
|
|
16
16
|
cx: "9",
|
|
17
17
|
cy: "9",
|
|
18
18
|
r: "9",
|
|
19
|
-
className: "jsx-1260643562 " +
|
|
19
|
+
className: "jsx-1260643562 " + `jsx-${styles.__hash}` + " " + "background"
|
|
20
20
|
}), /*#__PURE__*/React.createElement("path", {
|
|
21
21
|
d: "M9,0 C13.9705627,0 18,4.02943725 18,9 C18,13.9705627 13.9705627,18 9,18 C4.02943725,18 0,13.9705627 0,9 C0,4.02943725 4.02943725,0 9,0 Z M9,1 C4.581722,1 1,4.581722 1,9 C1,13.418278 4.581722,17 9,17 C13.418278,17 17,13.418278 17,9 C17,4.581722 13.418278,1 9,1 Z",
|
|
22
|
-
className: "jsx-1260643562 " +
|
|
22
|
+
className: "jsx-1260643562 " + `jsx-${styles.__hash}` + " " + "outer unchecked"
|
|
23
23
|
}), /*#__PURE__*/React.createElement("path", {
|
|
24
24
|
d: "M9,18 C13.9705627,18 18,13.9705627 18,9 C18,4.02943725 13.9705627,0 9,0 C4.02943725,0 0,4.02943725 0,9 C0,13.9705627 4.02943725,18 9,18 Z M9,16 C5.13400675,16 2,12.8659932 2,9 C2,5.13400675 5.13400675,2 9,2 C12.8659932,2 16,5.13400675 16,9 C16,12.8659932 12.8659932,16 9,16 Z",
|
|
25
|
-
className: "jsx-1260643562 " +
|
|
25
|
+
className: "jsx-1260643562 " + `jsx-${styles.__hash}` + " " + "outer checked"
|
|
26
26
|
}), /*#__PURE__*/React.createElement("circle", {
|
|
27
27
|
cx: "9",
|
|
28
28
|
cy: "9",
|
|
29
29
|
r: "5",
|
|
30
|
-
className: "jsx-1260643562 " +
|
|
30
|
+
className: "jsx-1260643562 " + `jsx-${styles.__hash}` + " " + "inner"
|
|
31
31
|
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
32
32
|
id: "1260643562"
|
|
33
33
|
}, ["svg.jsx-1260643562{height:18px;width:18px;}"]), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
@@ -44,23 +44,23 @@ export function RadioDense(_ref2) {
|
|
|
44
44
|
return /*#__PURE__*/React.createElement("svg", {
|
|
45
45
|
xmlns: "http://www.w3.org/2000/svg",
|
|
46
46
|
viewBox: "0 0 14 14",
|
|
47
|
-
className: "jsx-1659897952 " +
|
|
47
|
+
className: "jsx-1659897952 " + `jsx-${styles.__hash}` + " " + (className || "")
|
|
48
48
|
}, /*#__PURE__*/React.createElement("circle", {
|
|
49
49
|
cx: "7",
|
|
50
50
|
cy: "7",
|
|
51
51
|
r: "7",
|
|
52
|
-
className: "jsx-1659897952 " +
|
|
52
|
+
className: "jsx-1659897952 " + `jsx-${styles.__hash}` + " " + "background"
|
|
53
53
|
}), /*#__PURE__*/React.createElement("path", {
|
|
54
54
|
d: "M7,14 C10.8659932,14 14,10.8659932 14,7 C14,3.13400675 10.8659932,0 7,0 C3.13400675,0 0,3.13400675 0,7 C0,10.8659932 3.13400675,14 7,14 Z M7,13 C3.6862915,13 1,10.3137085 1,7 C1,3.6862915 3.6862915,1 7,1 C10.3137085,1 13,3.6862915 13,7 C13,10.3137085 10.3137085,13 7,13 Z",
|
|
55
|
-
className: "jsx-1659897952 " +
|
|
55
|
+
className: "jsx-1659897952 " + `jsx-${styles.__hash}` + " " + "outer unchecked"
|
|
56
56
|
}), /*#__PURE__*/React.createElement("path", {
|
|
57
57
|
d: "M7,14 C10.8659932,14 14,10.8659932 14,7 C14,3.13400675 10.8659932,0 7,0 C3.13400675,0 0,3.13400675 0,7 C0,10.8659932 3.13400675,14 7,14 Z M7,12 C4.23857625,12 2,9.76142375 2,7 C2,4.23857625 4.23857625,2 7,2 C9.76142375,2 12,4.23857625 12,7 C12,9.76142375 9.76142375,12 7,12 Z",
|
|
58
|
-
className: "jsx-1659897952 " +
|
|
58
|
+
className: "jsx-1659897952 " + `jsx-${styles.__hash}` + " " + "outer checked"
|
|
59
59
|
}), /*#__PURE__*/React.createElement("circle", {
|
|
60
60
|
cx: "7",
|
|
61
61
|
cy: "7",
|
|
62
62
|
r: "3",
|
|
63
|
-
className: "jsx-1659897952 " +
|
|
63
|
+
className: "jsx-1659897952 " + `jsx-${styles.__hash}` + " " + "inner"
|
|
64
64
|
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
65
65
|
id: "1659897952"
|
|
66
66
|
}, ["svg.jsx-1659897952{height:14px;width:14px;}"]), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
@@ -1,38 +1,45 @@
|
|
|
1
|
-
import { storiesOf } from '@storybook/react';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { Radio } from './radio.js';
|
|
4
3
|
window.onChange = window.Cypress && window.Cypress.cy.stub();
|
|
5
4
|
window.onBlur = window.Cypress && window.Cypress.cy.stub();
|
|
6
5
|
window.onFocus = window.Cypress && window.Cypress.cy.stub();
|
|
7
|
-
|
|
6
|
+
export default {
|
|
7
|
+
title: 'Radio'
|
|
8
|
+
};
|
|
9
|
+
export const WithOnChange = () => /*#__PURE__*/React.createElement(Radio, {
|
|
8
10
|
name: "Ex",
|
|
9
11
|
label: "Radio",
|
|
10
12
|
value: "default",
|
|
11
13
|
onChange: window.onChange
|
|
12
|
-
})
|
|
14
|
+
});
|
|
15
|
+
export const WithInitialFocusAndOnBlur = () => /*#__PURE__*/React.createElement(Radio, {
|
|
13
16
|
name: "Ex",
|
|
14
17
|
label: "Radio",
|
|
15
18
|
value: "default",
|
|
16
19
|
initialFocus: true,
|
|
17
20
|
onBlur: window.onBlur
|
|
18
|
-
})
|
|
21
|
+
});
|
|
22
|
+
export const WithOnFocus = () => /*#__PURE__*/React.createElement(Radio, {
|
|
19
23
|
initialFocus: true,
|
|
20
24
|
name: "Ex",
|
|
21
25
|
label: "Radio",
|
|
22
26
|
value: "default",
|
|
23
27
|
onFocus: window.onFocus
|
|
24
|
-
})
|
|
28
|
+
});
|
|
29
|
+
export const WithDisabled = () => /*#__PURE__*/React.createElement(Radio, {
|
|
25
30
|
name: "Ex",
|
|
26
31
|
label: "Radio",
|
|
27
32
|
value: "default",
|
|
28
33
|
disabled: true
|
|
29
|
-
})
|
|
34
|
+
});
|
|
35
|
+
export const WithLabel = () => /*#__PURE__*/React.createElement(Radio, {
|
|
30
36
|
name: "Ex",
|
|
31
37
|
label: "The label",
|
|
32
38
|
value: "default"
|
|
33
|
-
})
|
|
39
|
+
});
|
|
40
|
+
export const WithInitialFocus = () => /*#__PURE__*/React.createElement(Radio, {
|
|
34
41
|
name: "Ex",
|
|
35
42
|
label: "The label",
|
|
36
43
|
value: "default",
|
|
37
44
|
initialFocus: true
|
|
38
|
-
})
|
|
45
|
+
});
|
package/build/es/radio.js
CHANGED
|
@@ -1,50 +1,42 @@
|
|
|
1
1
|
import _JSXStyle from "styled-jsx/style";
|
|
2
|
-
|
|
3
|
-
function
|
|
4
|
-
|
|
2
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
3
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
|
|
4
|
+
function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
5
5
|
import { colors, spacers, theme, sharedPropTypes } from '@dhis2/ui-constants';
|
|
6
6
|
import cx from 'classnames';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import React, { Component, createRef } from 'react';
|
|
9
9
|
import { RadioRegular, RadioDense } from './radio-icons.js';
|
|
10
|
-
|
|
11
10
|
class Radio extends Component {
|
|
12
11
|
constructor() {
|
|
13
12
|
super(...arguments);
|
|
14
|
-
|
|
15
13
|
_defineProperty(this, "ref", /*#__PURE__*/createRef());
|
|
16
|
-
|
|
17
14
|
_defineProperty(this, "handleChange", e => {
|
|
18
15
|
if (this.props.onChange) {
|
|
19
16
|
this.props.onChange(this.createHandlerPayload(), e);
|
|
20
17
|
}
|
|
21
18
|
});
|
|
22
|
-
|
|
23
19
|
_defineProperty(this, "handleBlur", e => {
|
|
24
20
|
if (this.props.onBlur) {
|
|
25
21
|
this.props.onBlur(this.createHandlerPayload(), e);
|
|
26
22
|
}
|
|
27
23
|
});
|
|
28
|
-
|
|
29
24
|
_defineProperty(this, "handleFocus", e => {
|
|
30
25
|
if (this.props.onFocus) {
|
|
31
26
|
this.props.onFocus(this.createHandlerPayload(), e);
|
|
32
27
|
}
|
|
33
28
|
});
|
|
34
|
-
|
|
35
29
|
_defineProperty(this, "handleKeyDown", e => {
|
|
36
30
|
if (this.props.onKeyDown) {
|
|
37
31
|
this.props.onKeyDown(this.createHandlerPayload(), e);
|
|
38
32
|
}
|
|
39
33
|
});
|
|
40
34
|
}
|
|
41
|
-
|
|
42
35
|
componentDidMount() {
|
|
43
36
|
if (this.props.initialFocus) {
|
|
44
37
|
this.ref.current.focus();
|
|
45
38
|
}
|
|
46
39
|
}
|
|
47
|
-
|
|
48
40
|
createHandlerPayload() {
|
|
49
41
|
return {
|
|
50
42
|
value: this.props.value,
|
|
@@ -52,7 +44,6 @@ class Radio extends Component {
|
|
|
52
44
|
checked: !this.props.checked
|
|
53
45
|
};
|
|
54
46
|
}
|
|
55
|
-
|
|
56
47
|
render() {
|
|
57
48
|
const {
|
|
58
49
|
checked = false,
|
|
@@ -105,11 +96,9 @@ class Radio extends Component {
|
|
|
105
96
|
})), label, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
106
97
|
id: "2849316266",
|
|
107
98
|
dynamic: [colors.grey900, theme.disabled, label ? spacers.dp4 : 0, theme.focus]
|
|
108
|
-
}, [
|
|
99
|
+
}, [`label.__jsx-style-dynamic-selector{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;position:relative;-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-webkit-box-pack:start;-webkit-justify-content:flex-start;-ms-flex-pack:start;justify-content:flex-start;color:${colors.grey900};font-size:14px;line-height:19px;}`, "label.dense.__jsx-style-dynamic-selector{font-size:14px;line-height:16px;}", `label.disabled.__jsx-style-dynamic-selector{cursor:not-allowed;color:${theme.disabled};}`, "input.__jsx-style-dynamic-selector{opacity:0;position:absolute;height:18px;width:18px;inset-inline-start:3px;}", "label.dense.__jsx-style-dynamic-selector input.__jsx-style-dynamic-selector{height:14px;width:14px;}", `.icon.__jsx-style-dynamic-selector{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;margin-inline-end:${label ? spacers.dp4 : 0};border:2px solid transparent;padding:1px;border-radius:50%;}`, "label.dense.__jsx-style-dynamic-selector .icon.__jsx-style-dynamic-selector{margin-inline-end:3px;}", `input.__jsx-style-dynamic-selector:focus+.icon.__jsx-style-dynamic-selector{outline:3px solid ${theme.focus};outline-offset:-3px;}`]));
|
|
109
100
|
}
|
|
110
|
-
|
|
111
101
|
}
|
|
112
|
-
|
|
113
102
|
Radio.defaultProps = {
|
|
114
103
|
dataTest: 'dhis2-uicore-radio'
|
|
115
104
|
};
|
|
@@ -119,34 +108,25 @@ Radio.propTypes = {
|
|
|
119
108
|
dataTest: PropTypes.string,
|
|
120
109
|
dense: PropTypes.bool,
|
|
121
110
|
disabled: PropTypes.bool,
|
|
122
|
-
|
|
123
111
|
/** Adds 'error' styling for feedback. Mutually exclusive with `valid` and `warning` props */
|
|
124
112
|
error: sharedPropTypes.statusPropType,
|
|
125
113
|
initialFocus: PropTypes.bool,
|
|
126
114
|
label: PropTypes.node,
|
|
127
|
-
|
|
128
115
|
/** Name associated with this element. Passed in object to event handler functions */
|
|
129
116
|
name: PropTypes.string,
|
|
130
117
|
tabIndex: PropTypes.string,
|
|
131
|
-
|
|
132
118
|
/** Adds 'valid' styling for feedback. Mutually exclusive with `error` and `warning` props */
|
|
133
119
|
valid: sharedPropTypes.statusPropType,
|
|
134
|
-
|
|
135
120
|
/** Value associated with this element. Passed in object to event handler functions */
|
|
136
121
|
value: PropTypes.string,
|
|
137
|
-
|
|
138
122
|
/** Adds 'warning' styling for feedback. Mutually exclusive with `valid` and `error` props */
|
|
139
123
|
warning: sharedPropTypes.statusPropType,
|
|
140
|
-
|
|
141
124
|
/** Called with the signature `({ name: string, value: string, checked: bool }, event)` */
|
|
142
125
|
onBlur: PropTypes.func,
|
|
143
|
-
|
|
144
126
|
/** Called with the signature `({ name: string, value: string, checked: bool }, event)` */
|
|
145
127
|
onChange: PropTypes.func,
|
|
146
|
-
|
|
147
128
|
/** Called with the signature `({ name: string, value: string, checked: bool }, event)` */
|
|
148
129
|
onFocus: PropTypes.func,
|
|
149
|
-
|
|
150
130
|
/** Called with the signature `({ name: string, value: string, checked: bool }, event)` */
|
|
151
131
|
onKeyDown: PropTypes.func
|
|
152
132
|
};
|
|
@@ -1,38 +1,48 @@
|
|
|
1
|
-
function _extends() { _extends = Object.assign
|
|
2
|
-
|
|
1
|
+
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
|
|
3
2
|
import { sharedPropTypes } from '@dhis2/ui-constants';
|
|
4
3
|
import React from 'react';
|
|
5
4
|
import { Radio } from './radio.js';
|
|
6
|
-
const subtitle =
|
|
7
|
-
const description =
|
|
5
|
+
const subtitle = `A control that allows a user to select a single option from a choice of several`;
|
|
6
|
+
const description = `
|
|
7
|
+
Radio buttons are used where a user has the choice of several options but must select only one. Radio buttons should be used where the user has to make a choice, there is no 'off' or 'none' state unless explicitly defined. Radio buttons should be used when there are 5 or less options available. With more than five, a dropdown/Select menu should be used instead.
|
|
8
|
+
|
|
9
|
+
Do not use a radio button if only a single option is available; use a Checkbox here instead.
|
|
10
|
+
|
|
11
|
+
If there are many options that need to select from, consider using a Select instead.
|
|
12
|
+
|
|
13
|
+
#### Size
|
|
14
|
+
|
|
15
|
+
Radio buttons are available in Regular and Dense sizes. Regular size is usually used in forms and whenever radio buttons are used standalone. Dense size radio buttons are used inside other complex components, not as main elements of a UI.
|
|
8
16
|
|
|
17
|
+
#### See more
|
|
18
|
+
|
|
19
|
+
Learn more about Radio buttons at [Design System: Radio](https://github.com/dhis2/design-system/blob/master/atoms/radio.md).
|
|
20
|
+
|
|
21
|
+
\`\`\`js
|
|
22
|
+
import { Radio } from '@dhis2/ui'
|
|
23
|
+
\`\`\`
|
|
24
|
+
`;
|
|
9
25
|
window.onChange = (payload, event) => {
|
|
10
26
|
console.log('onChange payload', payload);
|
|
11
27
|
console.log('onChange event', event);
|
|
12
28
|
};
|
|
13
|
-
|
|
14
29
|
window.onFocus = (payload, event) => {
|
|
15
30
|
console.log('onFocus payload', payload);
|
|
16
31
|
console.log('onFocus event', event);
|
|
17
32
|
};
|
|
18
|
-
|
|
19
33
|
window.onBlur = (payload, event) => {
|
|
20
34
|
console.log('onBlur payload', payload);
|
|
21
35
|
console.log('onBlur event', event);
|
|
22
36
|
};
|
|
23
|
-
|
|
24
37
|
const onChange = function () {
|
|
25
38
|
return window.onChange(...arguments);
|
|
26
39
|
};
|
|
27
|
-
|
|
28
40
|
const onFocus = function () {
|
|
29
41
|
return window.onFocus(...arguments);
|
|
30
42
|
};
|
|
31
|
-
|
|
32
43
|
const onBlur = function () {
|
|
33
44
|
return window.onBlur(...arguments);
|
|
34
45
|
};
|
|
35
|
-
|
|
36
46
|
export default {
|
|
37
47
|
title: 'Radio',
|
|
38
48
|
component: Radio,
|
|
@@ -54,29 +64,29 @@ export default {
|
|
|
54
64
|
onBlur: onBlur
|
|
55
65
|
},
|
|
56
66
|
argTypes: {
|
|
57
|
-
valid: {
|
|
67
|
+
valid: {
|
|
68
|
+
...sharedPropTypes.statusArgType
|
|
58
69
|
},
|
|
59
|
-
error: {
|
|
70
|
+
error: {
|
|
71
|
+
...sharedPropTypes.statusArgType
|
|
60
72
|
},
|
|
61
|
-
warning: {
|
|
73
|
+
warning: {
|
|
74
|
+
...sharedPropTypes.statusArgType
|
|
62
75
|
}
|
|
63
76
|
}
|
|
64
77
|
};
|
|
65
|
-
|
|
66
78
|
const Template = args => /*#__PURE__*/React.createElement(Radio, args);
|
|
67
|
-
|
|
68
79
|
const CheckedUncheckedTemplate = args => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Radio, args), /*#__PURE__*/React.createElement(Radio, _extends({}, args, {
|
|
69
80
|
checked: true
|
|
70
81
|
})));
|
|
71
|
-
|
|
72
82
|
export const Default = Template.bind({});
|
|
73
83
|
export const FocusedUnchecked = args => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Radio, _extends({}, args, {
|
|
74
84
|
initialFocus: true,
|
|
75
85
|
className: "initially-focused"
|
|
76
86
|
})), /*#__PURE__*/React.createElement(Radio, _extends({}, args, {
|
|
77
87
|
className: "initially-unfocused"
|
|
78
|
-
})));
|
|
79
|
-
|
|
88
|
+
})));
|
|
89
|
+
// Stories with initial focus are distracting on docs page
|
|
80
90
|
FocusedUnchecked.parameters = {
|
|
81
91
|
docs: {
|
|
82
92
|
disable: true
|
|
@@ -129,7 +139,8 @@ DefaultDense.args = {
|
|
|
129
139
|
};
|
|
130
140
|
DefaultDense.storyName = 'Default - Dense';
|
|
131
141
|
export const FocusedUncheckedDense = FocusedUnchecked.bind({});
|
|
132
|
-
FocusedUncheckedDense.args = {
|
|
142
|
+
FocusedUncheckedDense.args = {
|
|
143
|
+
...DefaultDense.args
|
|
133
144
|
};
|
|
134
145
|
FocusedUncheckedDense.storyName = 'Focused unchecked - Dense';
|
|
135
146
|
FocusedUncheckedDense.parameters = {
|
|
@@ -138,7 +149,8 @@ FocusedUncheckedDense.parameters = {
|
|
|
138
149
|
}
|
|
139
150
|
};
|
|
140
151
|
export const FocusedCheckedDense = FocusedUnchecked.bind({});
|
|
141
|
-
FocusedCheckedDense.args = {
|
|
152
|
+
FocusedCheckedDense.args = {
|
|
153
|
+
...DefaultDense.args,
|
|
142
154
|
checked: true
|
|
143
155
|
};
|
|
144
156
|
FocusedCheckedDense.storyName = 'Focused checked - Dense';
|
|
@@ -148,32 +160,38 @@ FocusedCheckedDense.parameters = {
|
|
|
148
160
|
}
|
|
149
161
|
};
|
|
150
162
|
export const CheckedDense = Template.bind({});
|
|
151
|
-
CheckedDense.args = {
|
|
163
|
+
CheckedDense.args = {
|
|
164
|
+
...Checked.args,
|
|
152
165
|
...DefaultDense.args
|
|
153
166
|
};
|
|
154
167
|
CheckedDense.storyName = 'Checked - Dense';
|
|
155
168
|
export const DisabledDense = CheckedUncheckedTemplate.bind({});
|
|
156
|
-
DisabledDense.args = {
|
|
169
|
+
DisabledDense.args = {
|
|
170
|
+
...Disabled.args,
|
|
157
171
|
...DefaultDense.args
|
|
158
172
|
};
|
|
159
173
|
DisabledDense.storyName = 'Disabled - Dense';
|
|
160
174
|
export const ValidDense = CheckedUncheckedTemplate.bind({});
|
|
161
|
-
ValidDense.args = {
|
|
175
|
+
ValidDense.args = {
|
|
176
|
+
...Valid.args,
|
|
162
177
|
...DefaultDense.args
|
|
163
178
|
};
|
|
164
179
|
ValidDense.storyName = 'Valid - Dense';
|
|
165
180
|
export const WarningDense = CheckedUncheckedTemplate.bind({});
|
|
166
|
-
WarningDense.args = {
|
|
181
|
+
WarningDense.args = {
|
|
182
|
+
...Warning.args,
|
|
167
183
|
...DefaultDense.args
|
|
168
184
|
};
|
|
169
185
|
WarningDense.storyName = 'Warning - Dense';
|
|
170
186
|
export const ErrorDense = CheckedUncheckedTemplate.bind({});
|
|
171
|
-
ErrorDense.args = {
|
|
187
|
+
ErrorDense.args = {
|
|
188
|
+
...Error.args,
|
|
172
189
|
...DefaultDense.args
|
|
173
190
|
};
|
|
174
191
|
ErrorDense.storyName = 'Error - Dense';
|
|
175
192
|
export const ImageLabelDense = Template.bind({});
|
|
176
|
-
ImageLabelDense.args = {
|
|
193
|
+
ImageLabelDense.args = {
|
|
194
|
+
...ImageLabel.args,
|
|
177
195
|
...DefaultDense.args
|
|
178
196
|
};
|
|
179
197
|
ImageLabelDense.storyName = 'Image label - Dense';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/radio",
|
|
3
|
-
"version": "9.11.
|
|
3
|
+
"version": "9.11.1-beta.10",
|
|
4
4
|
"description": "UI Radio",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,18 +22,18 @@
|
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
-
"start": "
|
|
25
|
+
"start": "storybook dev -c ../../storybook/config --port 5000",
|
|
26
26
|
"build": "d2-app-scripts build",
|
|
27
27
|
"test": "d2-app-scripts test --jestConfig ../../jest.config.shared.js"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"react": "^16.
|
|
31
|
-
"react-dom": "^16.
|
|
30
|
+
"react": "^16.13",
|
|
31
|
+
"react-dom": "^16.13",
|
|
32
32
|
"styled-jsx": "^4"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@dhis2/prop-types": "^3.1.2",
|
|
36
|
-
"@dhis2/ui-constants": "9.11.
|
|
36
|
+
"@dhis2/ui-constants": "9.11.1-beta.10",
|
|
37
37
|
"classnames": "^2.3.1",
|
|
38
38
|
"prop-types": "^15.7.2"
|
|
39
39
|
},
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@storybook/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _radio = require("./radio.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
window.onChange = window.Cypress && window.Cypress.cy.stub();
|
|
12
|
-
window.onBlur = window.Cypress && window.Cypress.cy.stub();
|
|
13
|
-
window.onFocus = window.Cypress && window.Cypress.cy.stub();
|
|
14
|
-
(0, _react.storiesOf)('Radio', module).add('With onChange', () => /*#__PURE__*/_react2.default.createElement(_radio.Radio, {
|
|
15
|
-
name: "Ex",
|
|
16
|
-
label: "Radio",
|
|
17
|
-
value: "default",
|
|
18
|
-
onChange: window.onChange
|
|
19
|
-
})).add('With initialFocus and onBlur', () => /*#__PURE__*/_react2.default.createElement(_radio.Radio, {
|
|
20
|
-
name: "Ex",
|
|
21
|
-
label: "Radio",
|
|
22
|
-
value: "default",
|
|
23
|
-
initialFocus: true,
|
|
24
|
-
onBlur: window.onBlur
|
|
25
|
-
})).add('With onFocus', () => /*#__PURE__*/_react2.default.createElement(_radio.Radio, {
|
|
26
|
-
initialFocus: true,
|
|
27
|
-
name: "Ex",
|
|
28
|
-
label: "Radio",
|
|
29
|
-
value: "default",
|
|
30
|
-
onFocus: window.onFocus
|
|
31
|
-
})).add('With disabled', () => /*#__PURE__*/_react2.default.createElement(_radio.Radio, {
|
|
32
|
-
name: "Ex",
|
|
33
|
-
label: "Radio",
|
|
34
|
-
value: "default",
|
|
35
|
-
disabled: true
|
|
36
|
-
})).add('With label', () => /*#__PURE__*/_react2.default.createElement(_radio.Radio, {
|
|
37
|
-
name: "Ex",
|
|
38
|
-
label: "The label",
|
|
39
|
-
value: "default"
|
|
40
|
-
})).add('With initialFocus', () => /*#__PURE__*/_react2.default.createElement(_radio.Radio, {
|
|
41
|
-
name: "Ex",
|
|
42
|
-
label: "The label",
|
|
43
|
-
value: "default",
|
|
44
|
-
initialFocus: true
|
|
45
|
-
}));
|