@dhis2-ui/switch 9.11.0 → 9.11.1-beta.1
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/index.js +0 -2
- package/build/cjs/switch/__tests__/switch.test.js +1 -7
- package/build/cjs/switch/features/accepts_initial_focus/index.js +1 -2
- package/build/cjs/switch/features/accepts_label/index.js +0 -1
- package/build/cjs/switch/features/can_be_blurred/index.js +1 -2
- package/build/cjs/switch/features/can_be_changed/index.js +1 -2
- package/build/cjs/switch/features/can_be_disabled/index.js +0 -1
- package/build/cjs/switch/features/can_be_focused/index.js +1 -2
- package/build/cjs/switch/index.js +0 -1
- package/build/cjs/switch/switch-icons.js +21 -22
- package/build/cjs/switch/switch.e2e.stories.js +57 -0
- package/build/cjs/switch/switch.js +7 -40
- package/build/cjs/switch/{switch.stories.js → switch.prod.stories.js} +53 -73
- package/build/cjs/switch-field/__tests__/switch-field.test.js +1 -7
- package/build/cjs/switch-field/features/can_be_required/index.js +0 -1
- package/build/cjs/switch-field/index.js +0 -1
- package/build/cjs/switch-field/switch-field.e2e.stories.js +19 -0
- package/build/cjs/switch-field/switch-field.js +4 -30
- package/build/cjs/switch-field/{switch-field.stories.js → switch-field.prod.stories.js} +59 -72
- package/build/es/switch/features/accepts_initial_focus/index.js +1 -1
- package/build/es/switch/features/can_be_blurred/index.js +1 -1
- package/build/es/switch/features/can_be_changed/index.js +1 -1
- package/build/es/switch/features/can_be_focused/index.js +1 -1
- package/build/es/switch/switch-icons.js +20 -13
- package/build/es/switch/{switch.stories.e2e.js → switch.e2e.stories.js} +15 -8
- package/build/es/switch/switch.js +4 -29
- package/build/es/switch/{switch.stories.js → switch.prod.stories.js} +33 -25
- package/build/es/switch-field/switch-field.e2e.stories.js +11 -0
- package/build/es/switch-field/switch-field.js +3 -22
- package/build/es/switch-field/{switch-field.stories.js → switch-field.prod.stories.js} +38 -23
- package/package.json +7 -7
- package/build/cjs/switch/switch.stories.e2e.js +0 -44
- package/build/cjs/switch-field/switch-field.stories.e2e.js +0 -16
- package/build/es/switch-field/switch-field.stories.e2e.js +0 -9
|
@@ -4,50 +4,44 @@ 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.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 = _interopRequireWildcard(require("react"));
|
|
11
|
-
|
|
12
9
|
var _index = require("./index.js");
|
|
13
|
-
|
|
14
|
-
function
|
|
15
|
-
|
|
16
|
-
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; }
|
|
17
|
-
|
|
18
|
-
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
19
|
-
|
|
10
|
+
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); }
|
|
11
|
+
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; }
|
|
12
|
+
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); }
|
|
20
13
|
const subtitle = 'An input control that allows an on and an off state';
|
|
21
|
-
const description =
|
|
14
|
+
const description = `
|
|
15
|
+
**Switches are used sparingly in DHIS2, as they are not yet an accepted input control on the web. Users are not always used to the concept of a switch, but understanding is growing with wide adoption on mobile platforms.**
|
|
16
|
+
|
|
17
|
+
Use switches only when the user can toggle between on/off. Never use a switch for yes/no or any other states, use a checkbox instead. It is often safer to use a checkbox for things like turning options on/off, as users understand this pattern. Switches can be useful for ongoing or active processes, where turning them on/off makes more sense conceptually. An example of this may be toggling on/off 'Logging' or 'Update automatically', both processes that are ongoing.
|
|
22
18
|
|
|
19
|
+
\`\`\`js
|
|
20
|
+
import { Switch } from '@dhis2/ui'
|
|
21
|
+
\`\`\`
|
|
22
|
+
`;
|
|
23
23
|
window.onChange = (payload, event) => {
|
|
24
24
|
console.log('onClick payload', payload);
|
|
25
25
|
console.log('onClick event', event);
|
|
26
26
|
};
|
|
27
|
-
|
|
28
27
|
window.onFocus = (payload, event) => {
|
|
29
28
|
console.log('onFocus payload', payload);
|
|
30
29
|
console.log('onFocus event', event);
|
|
31
30
|
};
|
|
32
|
-
|
|
33
31
|
window.onBlur = (payload, event) => {
|
|
34
32
|
console.log('onBlur payload', payload);
|
|
35
33
|
console.log('onBlur event', event);
|
|
36
34
|
};
|
|
37
|
-
|
|
38
35
|
const onChange = function () {
|
|
39
36
|
return window.onChange(...arguments);
|
|
40
37
|
};
|
|
41
|
-
|
|
42
38
|
const onFocus = function () {
|
|
43
39
|
return window.onFocus(...arguments);
|
|
44
40
|
};
|
|
45
|
-
|
|
46
41
|
const onBlur = function () {
|
|
47
42
|
return window.onBlur(...arguments);
|
|
48
43
|
};
|
|
49
|
-
|
|
50
|
-
var _default = {
|
|
44
|
+
var _default = exports.default = {
|
|
51
45
|
title: 'Switch',
|
|
52
46
|
component: _index.Switch,
|
|
53
47
|
parameters: {
|
|
@@ -68,41 +62,36 @@ var _default = {
|
|
|
68
62
|
onBlur
|
|
69
63
|
},
|
|
70
64
|
argTypes: {
|
|
71
|
-
valid: {
|
|
65
|
+
valid: {
|
|
66
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
72
67
|
},
|
|
73
|
-
error: {
|
|
68
|
+
error: {
|
|
69
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
74
70
|
},
|
|
75
|
-
warning: {
|
|
71
|
+
warning: {
|
|
72
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
76
73
|
}
|
|
77
74
|
}
|
|
78
75
|
};
|
|
79
|
-
exports.default = _default;
|
|
80
|
-
|
|
81
76
|
const Template = args => /*#__PURE__*/_react.default.createElement(_index.Switch, args);
|
|
82
|
-
|
|
83
77
|
const CheckedUncheckedTemplate = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.Switch, args), /*#__PURE__*/_react.default.createElement(_index.Switch, _extends({}, args, {
|
|
84
78
|
checked: true
|
|
85
79
|
})));
|
|
86
|
-
|
|
87
|
-
const Default = Template.bind({});
|
|
88
|
-
exports.Default = Default;
|
|
89
|
-
|
|
80
|
+
const Default = exports.Default = Template.bind({});
|
|
90
81
|
const FocusedUnchecked = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.Switch, _extends({}, args, {
|
|
91
82
|
initialFocus: true,
|
|
92
83
|
className: "initially-focused"
|
|
93
84
|
})), /*#__PURE__*/_react.default.createElement(_index.Switch, _extends({}, args, {
|
|
94
85
|
className: "initially-unfocused"
|
|
95
|
-
})));
|
|
96
|
-
|
|
97
|
-
|
|
86
|
+
})));
|
|
87
|
+
// Stories with initial focus are distracting on docs page
|
|
98
88
|
exports.FocusedUnchecked = FocusedUnchecked;
|
|
99
89
|
FocusedUnchecked.parameters = {
|
|
100
90
|
docs: {
|
|
101
91
|
disable: true
|
|
102
92
|
}
|
|
103
93
|
};
|
|
104
|
-
const FocusedChecked = FocusedUnchecked.bind({});
|
|
105
|
-
exports.FocusedChecked = FocusedChecked;
|
|
94
|
+
const FocusedChecked = exports.FocusedChecked = FocusedUnchecked.bind({});
|
|
106
95
|
FocusedChecked.args = {
|
|
107
96
|
checked: true
|
|
108
97
|
};
|
|
@@ -111,53 +100,46 @@ FocusedChecked.parameters = {
|
|
|
111
100
|
disable: true
|
|
112
101
|
}
|
|
113
102
|
};
|
|
114
|
-
const Checked = Template.bind({});
|
|
115
|
-
exports.Checked = Checked;
|
|
103
|
+
const Checked = exports.Checked = Template.bind({});
|
|
116
104
|
Checked.args = {
|
|
117
105
|
checked: true,
|
|
118
106
|
value: 'checked'
|
|
119
107
|
};
|
|
120
|
-
const Disabled = CheckedUncheckedTemplate.bind({});
|
|
121
|
-
exports.Disabled = Disabled;
|
|
108
|
+
const Disabled = exports.Disabled = CheckedUncheckedTemplate.bind({});
|
|
122
109
|
Disabled.args = {
|
|
123
110
|
disabled: true,
|
|
124
111
|
value: 'disabled'
|
|
125
112
|
};
|
|
126
|
-
const Valid = CheckedUncheckedTemplate.bind({});
|
|
127
|
-
exports.Valid = Valid;
|
|
113
|
+
const Valid = exports.Valid = CheckedUncheckedTemplate.bind({});
|
|
128
114
|
Valid.args = {
|
|
129
115
|
valid: true,
|
|
130
116
|
value: 'valid'
|
|
131
117
|
};
|
|
132
|
-
const Warning = CheckedUncheckedTemplate.bind({});
|
|
133
|
-
exports.Warning = Warning;
|
|
118
|
+
const Warning = exports.Warning = CheckedUncheckedTemplate.bind({});
|
|
134
119
|
Warning.args = {
|
|
135
120
|
warning: true,
|
|
136
121
|
value: 'warning'
|
|
137
122
|
};
|
|
138
|
-
const Error = CheckedUncheckedTemplate.bind({});
|
|
139
|
-
exports.Error = Error;
|
|
123
|
+
const Error = exports.Error = CheckedUncheckedTemplate.bind({});
|
|
140
124
|
Error.args = {
|
|
141
125
|
error: true,
|
|
142
126
|
value: 'error'
|
|
143
127
|
};
|
|
144
|
-
const ImageLabel = Template.bind({});
|
|
145
|
-
exports.ImageLabel = ImageLabel;
|
|
128
|
+
const ImageLabel = exports.ImageLabel = Template.bind({});
|
|
146
129
|
ImageLabel.args = {
|
|
147
130
|
label: /*#__PURE__*/_react.default.createElement("img", {
|
|
148
131
|
src: "https://picsum.photos/id/82/200/100"
|
|
149
132
|
}),
|
|
150
133
|
value: 'with-help'
|
|
151
134
|
};
|
|
152
|
-
const DefaultDense = Template.bind({});
|
|
153
|
-
exports.DefaultDense = DefaultDense;
|
|
135
|
+
const DefaultDense = exports.DefaultDense = Template.bind({});
|
|
154
136
|
DefaultDense.args = {
|
|
155
137
|
dense: true
|
|
156
138
|
};
|
|
157
139
|
DefaultDense.storyName = 'Default - Dense';
|
|
158
|
-
const FocusedUncheckedDense = FocusedUnchecked.bind({});
|
|
159
|
-
|
|
160
|
-
|
|
140
|
+
const FocusedUncheckedDense = exports.FocusedUncheckedDense = FocusedUnchecked.bind({});
|
|
141
|
+
FocusedUncheckedDense.args = {
|
|
142
|
+
...DefaultDense.args
|
|
161
143
|
};
|
|
162
144
|
FocusedUncheckedDense.storyName = 'Focused unchecked - Dense';
|
|
163
145
|
FocusedUncheckedDense.parameters = {
|
|
@@ -165,9 +147,9 @@ FocusedUncheckedDense.parameters = {
|
|
|
165
147
|
disable: true
|
|
166
148
|
}
|
|
167
149
|
};
|
|
168
|
-
const FocusedCheckedDense = FocusedUnchecked.bind({});
|
|
169
|
-
|
|
170
|
-
|
|
150
|
+
const FocusedCheckedDense = exports.FocusedCheckedDense = FocusedUnchecked.bind({});
|
|
151
|
+
FocusedCheckedDense.args = {
|
|
152
|
+
...DefaultDense.args,
|
|
171
153
|
checked: true
|
|
172
154
|
};
|
|
173
155
|
FocusedCheckedDense.storyName = 'Focused checked - Dense';
|
|
@@ -176,43 +158,42 @@ FocusedCheckedDense.parameters = {
|
|
|
176
158
|
disable: true
|
|
177
159
|
}
|
|
178
160
|
};
|
|
179
|
-
const CheckedDense = Template.bind({});
|
|
180
|
-
|
|
181
|
-
|
|
161
|
+
const CheckedDense = exports.CheckedDense = Template.bind({});
|
|
162
|
+
CheckedDense.args = {
|
|
163
|
+
...Checked.args,
|
|
182
164
|
...DefaultDense.args
|
|
183
165
|
};
|
|
184
166
|
CheckedDense.storyName = 'Checked - Dense';
|
|
185
|
-
const DisabledDense = CheckedUncheckedTemplate.bind({});
|
|
186
|
-
|
|
187
|
-
|
|
167
|
+
const DisabledDense = exports.DisabledDense = CheckedUncheckedTemplate.bind({});
|
|
168
|
+
DisabledDense.args = {
|
|
169
|
+
...Disabled.args,
|
|
188
170
|
...DefaultDense.args
|
|
189
171
|
};
|
|
190
172
|
DisabledDense.storyName = 'Disabled - Dense';
|
|
191
|
-
const ValidDense = CheckedUncheckedTemplate.bind({});
|
|
192
|
-
|
|
193
|
-
|
|
173
|
+
const ValidDense = exports.ValidDense = CheckedUncheckedTemplate.bind({});
|
|
174
|
+
ValidDense.args = {
|
|
175
|
+
...Valid.args,
|
|
194
176
|
...DefaultDense.args
|
|
195
177
|
};
|
|
196
178
|
ValidDense.storyName = 'Valid - Dense';
|
|
197
|
-
const WarningDense = CheckedUncheckedTemplate.bind({});
|
|
198
|
-
|
|
199
|
-
|
|
179
|
+
const WarningDense = exports.WarningDense = CheckedUncheckedTemplate.bind({});
|
|
180
|
+
WarningDense.args = {
|
|
181
|
+
...Warning.args,
|
|
200
182
|
...DefaultDense.args
|
|
201
183
|
};
|
|
202
184
|
WarningDense.storyName = 'Warning - Dense';
|
|
203
|
-
const ErrorDense = CheckedUncheckedTemplate.bind({});
|
|
204
|
-
|
|
205
|
-
|
|
185
|
+
const ErrorDense = exports.ErrorDense = CheckedUncheckedTemplate.bind({});
|
|
186
|
+
ErrorDense.args = {
|
|
187
|
+
...Error.args,
|
|
206
188
|
...DefaultDense.args
|
|
207
189
|
};
|
|
208
190
|
ErrorDense.storyName = 'Error - Dense';
|
|
209
|
-
const ImageLabelDense = Template.bind({});
|
|
210
|
-
|
|
211
|
-
|
|
191
|
+
const ImageLabelDense = exports.ImageLabelDense = Template.bind({});
|
|
192
|
+
ImageLabelDense.args = {
|
|
193
|
+
...ImageLabel.args,
|
|
212
194
|
...DefaultDense.args
|
|
213
195
|
};
|
|
214
196
|
ImageLabelDense.storyName = 'Image label - Dense';
|
|
215
|
-
|
|
216
197
|
const RTL = args => {
|
|
217
198
|
(0, _react.useEffect)(() => {
|
|
218
199
|
document.documentElement.setAttribute('dir', 'rtl');
|
|
@@ -231,5 +212,4 @@ const RTL = args => {
|
|
|
231
212
|
value: "error"
|
|
232
213
|
}));
|
|
233
214
|
};
|
|
234
|
-
|
|
235
215
|
exports.RTL = RTL;
|
|
@@ -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 _switchField = require("../switch-field.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('<Switch />', () => {
|
|
12
8
|
it('should call the onKeyDown callback when provided', () => {
|
|
13
9
|
const onKeyDown = jest.fn();
|
|
@@ -18,13 +14,11 @@ describe('<Switch />', () => {
|
|
|
18
14
|
checked: false,
|
|
19
15
|
onKeyDown: onKeyDown
|
|
20
16
|
}));
|
|
21
|
-
|
|
22
17
|
_react.fireEvent.keyDown(_react.screen.getByRole('switch'), {
|
|
23
18
|
key: 'Enter',
|
|
24
19
|
code: 'Enter',
|
|
25
20
|
charCode: 13
|
|
26
21
|
});
|
|
27
|
-
|
|
28
22
|
expect(onKeyDown).toHaveBeenCalledWith({
|
|
29
23
|
name: 'foo',
|
|
30
24
|
value: 'bar',
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _cypressCucumberPreprocessor = require("@badeball/cypress-cucumber-preprocessor");
|
|
4
|
-
|
|
5
4
|
(0, _cypressCucumberPreprocessor.Given)('a SwitchField with label and a required flag is rendered', () => {
|
|
6
5
|
cy.visitStory('SwitchField', 'With label and required');
|
|
7
6
|
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = exports.WithLabelAndRequired = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _index = require("./index.js");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
var _default = exports.default = {
|
|
11
|
+
title: 'SwitchField'
|
|
12
|
+
};
|
|
13
|
+
const WithLabelAndRequired = () => /*#__PURE__*/_react.default.createElement(_index.SwitchField, {
|
|
14
|
+
name: "Ex",
|
|
15
|
+
label: "SwitchField",
|
|
16
|
+
required: true,
|
|
17
|
+
value: "checked"
|
|
18
|
+
});
|
|
19
|
+
exports.WithLabelAndRequired = WithLabelAndRequired;
|
|
@@ -4,21 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.SwitchField = void 0;
|
|
7
|
-
|
|
7
|
+
var _uiConstants = require("@dhis2/ui-constants");
|
|
8
8
|
var _field = require("@dhis2-ui/field");
|
|
9
|
-
|
|
10
9
|
var _required = require("@dhis2-ui/required");
|
|
11
|
-
|
|
12
|
-
var _uiConstants = require("@dhis2/ui-constants");
|
|
13
|
-
|
|
14
10
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
15
|
-
|
|
16
11
|
var _react = _interopRequireDefault(require("react"));
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
|
-
|
|
12
|
+
var _index = require("../switch/index.js");
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
22
14
|
const AddRequired = _ref => {
|
|
23
15
|
let {
|
|
24
16
|
label,
|
|
@@ -26,16 +18,14 @@ const AddRequired = _ref => {
|
|
|
26
18
|
dataTest
|
|
27
19
|
} = _ref;
|
|
28
20
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, label, required && /*#__PURE__*/_react.default.createElement(_required.Required, {
|
|
29
|
-
dataTest:
|
|
21
|
+
dataTest: `${dataTest}-required`
|
|
30
22
|
}));
|
|
31
23
|
};
|
|
32
|
-
|
|
33
24
|
AddRequired.propTypes = {
|
|
34
25
|
dataTest: _propTypes.default.string,
|
|
35
26
|
label: _propTypes.default.node,
|
|
36
27
|
required: _propTypes.default.bool
|
|
37
28
|
};
|
|
38
|
-
|
|
39
29
|
const SwitchField = _ref2 => {
|
|
40
30
|
let {
|
|
41
31
|
value,
|
|
@@ -92,7 +82,6 @@ const SwitchField = _ref2 => {
|
|
|
92
82
|
initialFocus: initialFocus
|
|
93
83
|
}));
|
|
94
84
|
};
|
|
95
|
-
|
|
96
85
|
exports.SwitchField = SwitchField;
|
|
97
86
|
SwitchField.defaultProps = {
|
|
98
87
|
dataTest: 'dhis2-uiwidgets-switchfield'
|
|
@@ -101,51 +90,36 @@ SwitchField.propTypes = {
|
|
|
101
90
|
checked: _propTypes.default.bool,
|
|
102
91
|
className: _propTypes.default.string,
|
|
103
92
|
dataTest: _propTypes.default.string,
|
|
104
|
-
|
|
105
93
|
/** Smaller dimensions for information-dense layouts */
|
|
106
94
|
dense: _propTypes.default.bool,
|
|
107
|
-
|
|
108
95
|
/** Disables the switch */
|
|
109
96
|
disabled: _propTypes.default.bool,
|
|
110
|
-
|
|
111
97
|
/** Applies 'error' styling to switch and validation text for feedback. Mutually exclusive with `warning` and `valid` props */
|
|
112
98
|
error: _uiConstants.sharedPropTypes.statusPropType,
|
|
113
|
-
|
|
114
99
|
/** Useful instructions for the user */
|
|
115
100
|
helpText: _propTypes.default.string,
|
|
116
101
|
initialFocus: _propTypes.default.bool,
|
|
117
|
-
|
|
118
102
|
/** Labels the switch */
|
|
119
103
|
label: _propTypes.default.node,
|
|
120
|
-
|
|
121
104
|
/** Name associate with the switch. Passed in object as argument to event handlers */
|
|
122
105
|
name: _propTypes.default.string,
|
|
123
|
-
|
|
124
106
|
/** Adds an asterisk to indicate this field is required */
|
|
125
107
|
required: _propTypes.default.bool,
|
|
126
108
|
tabIndex: _propTypes.default.string,
|
|
127
|
-
|
|
128
109
|
/** Applies 'valid' styling to switch and validation text for feedback. Mutually exclusive with `warning` and `error` props */
|
|
129
110
|
valid: _uiConstants.sharedPropTypes.statusPropType,
|
|
130
|
-
|
|
131
111
|
/** Adds text below the switch to provide validation feedback. Acquires styles from `valid`, `warning` and `error` statuses */
|
|
132
112
|
validationText: _propTypes.default.string,
|
|
133
|
-
|
|
134
113
|
/** Value associated with the switch. Passed in object as argument to event handlers */
|
|
135
114
|
value: _propTypes.default.string,
|
|
136
|
-
|
|
137
115
|
/** Applies 'warning' styling to switch and validation text for feedback. Mutually exclusive with `valid` and `error` props */
|
|
138
116
|
warning: _uiConstants.sharedPropTypes.statusPropType,
|
|
139
|
-
|
|
140
117
|
/** Called with signature ({ name: string, value: string, checked: bool }, event) */
|
|
141
118
|
onBlur: _propTypes.default.func,
|
|
142
|
-
|
|
143
119
|
/** Called with signature ({ name: string, value: string, checked: bool }, event) */
|
|
144
120
|
onChange: _propTypes.default.func,
|
|
145
|
-
|
|
146
121
|
/** Called with signature ({ name: string, value: string, checked: bool }, event) */
|
|
147
122
|
onFocus: _propTypes.default.func,
|
|
148
|
-
|
|
149
123
|
/** Called with signature ({ name: string, value: string, checked: bool }, event) */
|
|
150
124
|
onKeyDown: _propTypes.default.func
|
|
151
125
|
};
|