@dhis2-ui/switch 9.10.3 → 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
|
@@ -1,38 +1,38 @@
|
|
|
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, { useEffect } from 'react';
|
|
5
4
|
import { Switch } from './index.js';
|
|
6
5
|
const subtitle = 'An input control that allows an on and an off state';
|
|
7
|
-
const description =
|
|
6
|
+
const description = `
|
|
7
|
+
**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.**
|
|
8
|
+
|
|
9
|
+
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.
|
|
8
10
|
|
|
11
|
+
\`\`\`js
|
|
12
|
+
import { Switch } from '@dhis2/ui'
|
|
13
|
+
\`\`\`
|
|
14
|
+
`;
|
|
9
15
|
window.onChange = (payload, event) => {
|
|
10
16
|
console.log('onClick payload', payload);
|
|
11
17
|
console.log('onClick event', event);
|
|
12
18
|
};
|
|
13
|
-
|
|
14
19
|
window.onFocus = (payload, event) => {
|
|
15
20
|
console.log('onFocus payload', payload);
|
|
16
21
|
console.log('onFocus event', event);
|
|
17
22
|
};
|
|
18
|
-
|
|
19
23
|
window.onBlur = (payload, event) => {
|
|
20
24
|
console.log('onBlur payload', payload);
|
|
21
25
|
console.log('onBlur event', event);
|
|
22
26
|
};
|
|
23
|
-
|
|
24
27
|
const onChange = function () {
|
|
25
28
|
return window.onChange(...arguments);
|
|
26
29
|
};
|
|
27
|
-
|
|
28
30
|
const onFocus = function () {
|
|
29
31
|
return window.onFocus(...arguments);
|
|
30
32
|
};
|
|
31
|
-
|
|
32
33
|
const onBlur = function () {
|
|
33
34
|
return window.onBlur(...arguments);
|
|
34
35
|
};
|
|
35
|
-
|
|
36
36
|
export default {
|
|
37
37
|
title: 'Switch',
|
|
38
38
|
component: Switch,
|
|
@@ -54,29 +54,29 @@ export default {
|
|
|
54
54
|
onBlur
|
|
55
55
|
},
|
|
56
56
|
argTypes: {
|
|
57
|
-
valid: {
|
|
57
|
+
valid: {
|
|
58
|
+
...sharedPropTypes.statusArgType
|
|
58
59
|
},
|
|
59
|
-
error: {
|
|
60
|
+
error: {
|
|
61
|
+
...sharedPropTypes.statusArgType
|
|
60
62
|
},
|
|
61
|
-
warning: {
|
|
63
|
+
warning: {
|
|
64
|
+
...sharedPropTypes.statusArgType
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
};
|
|
65
|
-
|
|
66
68
|
const Template = args => /*#__PURE__*/React.createElement(Switch, args);
|
|
67
|
-
|
|
68
69
|
const CheckedUncheckedTemplate = args => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Switch, args), /*#__PURE__*/React.createElement(Switch, _extends({}, args, {
|
|
69
70
|
checked: true
|
|
70
71
|
})));
|
|
71
|
-
|
|
72
72
|
export const Default = Template.bind({});
|
|
73
73
|
export const FocusedUnchecked = args => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Switch, _extends({}, args, {
|
|
74
74
|
initialFocus: true,
|
|
75
75
|
className: "initially-focused"
|
|
76
76
|
})), /*#__PURE__*/React.createElement(Switch, _extends({}, args, {
|
|
77
77
|
className: "initially-unfocused"
|
|
78
|
-
})));
|
|
79
|
-
|
|
78
|
+
})));
|
|
79
|
+
// Stories with initial focus are distracting on docs page
|
|
80
80
|
FocusedUnchecked.parameters = {
|
|
81
81
|
docs: {
|
|
82
82
|
disable: true
|
|
@@ -129,7 +129,8 @@ DefaultDense.args = {
|
|
|
129
129
|
};
|
|
130
130
|
DefaultDense.storyName = 'Default - Dense';
|
|
131
131
|
export const FocusedUncheckedDense = FocusedUnchecked.bind({});
|
|
132
|
-
FocusedUncheckedDense.args = {
|
|
132
|
+
FocusedUncheckedDense.args = {
|
|
133
|
+
...DefaultDense.args
|
|
133
134
|
};
|
|
134
135
|
FocusedUncheckedDense.storyName = 'Focused unchecked - Dense';
|
|
135
136
|
FocusedUncheckedDense.parameters = {
|
|
@@ -138,7 +139,8 @@ FocusedUncheckedDense.parameters = {
|
|
|
138
139
|
}
|
|
139
140
|
};
|
|
140
141
|
export const FocusedCheckedDense = FocusedUnchecked.bind({});
|
|
141
|
-
FocusedCheckedDense.args = {
|
|
142
|
+
FocusedCheckedDense.args = {
|
|
143
|
+
...DefaultDense.args,
|
|
142
144
|
checked: true
|
|
143
145
|
};
|
|
144
146
|
FocusedCheckedDense.storyName = 'Focused checked - Dense';
|
|
@@ -148,32 +150,38 @@ FocusedCheckedDense.parameters = {
|
|
|
148
150
|
}
|
|
149
151
|
};
|
|
150
152
|
export const CheckedDense = Template.bind({});
|
|
151
|
-
CheckedDense.args = {
|
|
153
|
+
CheckedDense.args = {
|
|
154
|
+
...Checked.args,
|
|
152
155
|
...DefaultDense.args
|
|
153
156
|
};
|
|
154
157
|
CheckedDense.storyName = 'Checked - Dense';
|
|
155
158
|
export const DisabledDense = CheckedUncheckedTemplate.bind({});
|
|
156
|
-
DisabledDense.args = {
|
|
159
|
+
DisabledDense.args = {
|
|
160
|
+
...Disabled.args,
|
|
157
161
|
...DefaultDense.args
|
|
158
162
|
};
|
|
159
163
|
DisabledDense.storyName = 'Disabled - Dense';
|
|
160
164
|
export const ValidDense = CheckedUncheckedTemplate.bind({});
|
|
161
|
-
ValidDense.args = {
|
|
165
|
+
ValidDense.args = {
|
|
166
|
+
...Valid.args,
|
|
162
167
|
...DefaultDense.args
|
|
163
168
|
};
|
|
164
169
|
ValidDense.storyName = 'Valid - Dense';
|
|
165
170
|
export const WarningDense = CheckedUncheckedTemplate.bind({});
|
|
166
|
-
WarningDense.args = {
|
|
171
|
+
WarningDense.args = {
|
|
172
|
+
...Warning.args,
|
|
167
173
|
...DefaultDense.args
|
|
168
174
|
};
|
|
169
175
|
WarningDense.storyName = 'Warning - Dense';
|
|
170
176
|
export const ErrorDense = CheckedUncheckedTemplate.bind({});
|
|
171
|
-
ErrorDense.args = {
|
|
177
|
+
ErrorDense.args = {
|
|
178
|
+
...Error.args,
|
|
172
179
|
...DefaultDense.args
|
|
173
180
|
};
|
|
174
181
|
ErrorDense.storyName = 'Error - Dense';
|
|
175
182
|
export const ImageLabelDense = Template.bind({});
|
|
176
|
-
ImageLabelDense.args = {
|
|
183
|
+
ImageLabelDense.args = {
|
|
184
|
+
...ImageLabel.args,
|
|
177
185
|
...DefaultDense.args
|
|
178
186
|
};
|
|
179
187
|
ImageLabelDense.storyName = 'Image label - Dense';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { SwitchField } from './index.js';
|
|
3
|
+
export default {
|
|
4
|
+
title: 'SwitchField'
|
|
5
|
+
};
|
|
6
|
+
export const WithLabelAndRequired = () => /*#__PURE__*/React.createElement(SwitchField, {
|
|
7
|
+
name: "Ex",
|
|
8
|
+
label: "SwitchField",
|
|
9
|
+
required: true,
|
|
10
|
+
value: "checked"
|
|
11
|
+
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { sharedPropTypes } from '@dhis2/ui-constants';
|
|
1
2
|
import { Field } from '@dhis2-ui/field';
|
|
2
3
|
import { Required } from '@dhis2-ui/required';
|
|
3
|
-
import { sharedPropTypes } from '@dhis2/ui-constants';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import { Switch } from '../index.js';
|
|
7
|
-
|
|
6
|
+
import { Switch } from '../switch/index.js';
|
|
8
7
|
const AddRequired = _ref => {
|
|
9
8
|
let {
|
|
10
9
|
label,
|
|
@@ -12,16 +11,14 @@ const AddRequired = _ref => {
|
|
|
12
11
|
dataTest
|
|
13
12
|
} = _ref;
|
|
14
13
|
return /*#__PURE__*/React.createElement(React.Fragment, null, label, required && /*#__PURE__*/React.createElement(Required, {
|
|
15
|
-
dataTest:
|
|
14
|
+
dataTest: `${dataTest}-required`
|
|
16
15
|
}));
|
|
17
16
|
};
|
|
18
|
-
|
|
19
17
|
AddRequired.propTypes = {
|
|
20
18
|
dataTest: PropTypes.string,
|
|
21
19
|
label: PropTypes.node,
|
|
22
20
|
required: PropTypes.bool
|
|
23
21
|
};
|
|
24
|
-
|
|
25
22
|
const SwitchField = _ref2 => {
|
|
26
23
|
let {
|
|
27
24
|
value,
|
|
@@ -78,7 +75,6 @@ const SwitchField = _ref2 => {
|
|
|
78
75
|
initialFocus: initialFocus
|
|
79
76
|
}));
|
|
80
77
|
};
|
|
81
|
-
|
|
82
78
|
SwitchField.defaultProps = {
|
|
83
79
|
dataTest: 'dhis2-uiwidgets-switchfield'
|
|
84
80
|
};
|
|
@@ -86,51 +82,36 @@ SwitchField.propTypes = {
|
|
|
86
82
|
checked: PropTypes.bool,
|
|
87
83
|
className: PropTypes.string,
|
|
88
84
|
dataTest: PropTypes.string,
|
|
89
|
-
|
|
90
85
|
/** Smaller dimensions for information-dense layouts */
|
|
91
86
|
dense: PropTypes.bool,
|
|
92
|
-
|
|
93
87
|
/** Disables the switch */
|
|
94
88
|
disabled: PropTypes.bool,
|
|
95
|
-
|
|
96
89
|
/** Applies 'error' styling to switch and validation text for feedback. Mutually exclusive with `warning` and `valid` props */
|
|
97
90
|
error: sharedPropTypes.statusPropType,
|
|
98
|
-
|
|
99
91
|
/** Useful instructions for the user */
|
|
100
92
|
helpText: PropTypes.string,
|
|
101
93
|
initialFocus: PropTypes.bool,
|
|
102
|
-
|
|
103
94
|
/** Labels the switch */
|
|
104
95
|
label: PropTypes.node,
|
|
105
|
-
|
|
106
96
|
/** Name associate with the switch. Passed in object as argument to event handlers */
|
|
107
97
|
name: PropTypes.string,
|
|
108
|
-
|
|
109
98
|
/** Adds an asterisk to indicate this field is required */
|
|
110
99
|
required: PropTypes.bool,
|
|
111
100
|
tabIndex: PropTypes.string,
|
|
112
|
-
|
|
113
101
|
/** Applies 'valid' styling to switch and validation text for feedback. Mutually exclusive with `warning` and `error` props */
|
|
114
102
|
valid: sharedPropTypes.statusPropType,
|
|
115
|
-
|
|
116
103
|
/** Adds text below the switch to provide validation feedback. Acquires styles from `valid`, `warning` and `error` statuses */
|
|
117
104
|
validationText: PropTypes.string,
|
|
118
|
-
|
|
119
105
|
/** Value associated with the switch. Passed in object as argument to event handlers */
|
|
120
106
|
value: PropTypes.string,
|
|
121
|
-
|
|
122
107
|
/** Applies 'warning' styling to switch and validation text for feedback. Mutually exclusive with `valid` and `error` props */
|
|
123
108
|
warning: sharedPropTypes.statusPropType,
|
|
124
|
-
|
|
125
109
|
/** Called with signature ({ name: string, value: string, checked: bool }, event) */
|
|
126
110
|
onBlur: PropTypes.func,
|
|
127
|
-
|
|
128
111
|
/** Called with signature ({ name: string, value: string, checked: bool }, event) */
|
|
129
112
|
onChange: PropTypes.func,
|
|
130
|
-
|
|
131
113
|
/** Called with signature ({ name: string, value: string, checked: bool }, event) */
|
|
132
114
|
onFocus: PropTypes.func,
|
|
133
|
-
|
|
134
115
|
/** Called with signature ({ name: string, value: string, checked: bool }, event) */
|
|
135
116
|
onKeyDown: PropTypes.func
|
|
136
117
|
};
|
|
@@ -1,19 +1,24 @@
|
|
|
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 { SwitchField } from './index.js';
|
|
6
|
-
const description =
|
|
5
|
+
const description = `
|
|
6
|
+
A \`SwitchField\` is a Switch component wrapped with extra form utilities, including the ability to add a label, help text, and validation text. Validation styles like 'error' apply to all of these subcomponents.
|
|
7
|
+
|
|
8
|
+
See the basic Switch for usage and design system guidelines.
|
|
7
9
|
|
|
10
|
+
\`\`\`js
|
|
11
|
+
import { SwitchField } from '@dhis2/ui'
|
|
12
|
+
\`\`\`
|
|
13
|
+
`;
|
|
8
14
|
const logger = _ref => {
|
|
9
15
|
let {
|
|
10
16
|
name,
|
|
11
17
|
value,
|
|
12
18
|
checked
|
|
13
19
|
} = _ref;
|
|
14
|
-
return console.log(
|
|
20
|
+
return console.log(`name: ${name}, value: ${value}, checked: ${checked}`);
|
|
15
21
|
};
|
|
16
|
-
|
|
17
22
|
export default {
|
|
18
23
|
title: 'Switch Field',
|
|
19
24
|
component: SwitchField,
|
|
@@ -32,34 +37,35 @@ export default {
|
|
|
32
37
|
onChange: logger
|
|
33
38
|
},
|
|
34
39
|
argTypes: {
|
|
35
|
-
valid: {
|
|
40
|
+
valid: {
|
|
41
|
+
...sharedPropTypes.statusArgType
|
|
36
42
|
},
|
|
37
|
-
warning: {
|
|
43
|
+
warning: {
|
|
44
|
+
...sharedPropTypes.statusArgType
|
|
38
45
|
},
|
|
39
|
-
error: {
|
|
46
|
+
error: {
|
|
47
|
+
...sharedPropTypes.statusArgType
|
|
40
48
|
}
|
|
41
49
|
}
|
|
42
50
|
};
|
|
43
|
-
|
|
44
51
|
const Template = args => /*#__PURE__*/React.createElement(SwitchField, args);
|
|
45
|
-
|
|
46
52
|
const CheckedUncheckedTemplate = args => /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(SwitchField, args), /*#__PURE__*/React.createElement(SwitchField, _extends({}, args, {
|
|
47
53
|
checked: true
|
|
48
54
|
})));
|
|
49
|
-
|
|
50
55
|
export const Default = Template.bind({});
|
|
51
56
|
export const FocusedUnchecked = Template.bind({});
|
|
52
57
|
FocusedUnchecked.args = {
|
|
53
58
|
initialFocus: true
|
|
54
|
-
};
|
|
55
|
-
|
|
59
|
+
};
|
|
60
|
+
// Disable stories on docs page that grab focus
|
|
56
61
|
FocusedUnchecked.parameters = {
|
|
57
62
|
docs: {
|
|
58
63
|
disable: true
|
|
59
64
|
}
|
|
60
65
|
};
|
|
61
66
|
export const FocusedChecked = Template.bind({});
|
|
62
|
-
FocusedChecked.args = {
|
|
67
|
+
FocusedChecked.args = {
|
|
68
|
+
...FocusedUnchecked.args,
|
|
63
69
|
checked: true
|
|
64
70
|
};
|
|
65
71
|
FocusedChecked.parameters = {
|
|
@@ -117,7 +123,8 @@ DefaultDense.args = {
|
|
|
117
123
|
dense: true
|
|
118
124
|
};
|
|
119
125
|
export const FocusedUncheckedDense = Template.bind({});
|
|
120
|
-
FocusedUncheckedDense.args = {
|
|
126
|
+
FocusedUncheckedDense.args = {
|
|
127
|
+
...DefaultDense.args,
|
|
121
128
|
...FocusedUnchecked.args
|
|
122
129
|
};
|
|
123
130
|
FocusedUncheckedDense.parameters = {
|
|
@@ -127,7 +134,8 @@ FocusedUncheckedDense.parameters = {
|
|
|
127
134
|
};
|
|
128
135
|
FocusedUncheckedDense.storyName = 'Focused unchecked - Dense';
|
|
129
136
|
export const FocusedCheckedDense = Template.bind({});
|
|
130
|
-
FocusedCheckedDense.args = {
|
|
137
|
+
FocusedCheckedDense.args = {
|
|
138
|
+
...DefaultDense.args,
|
|
131
139
|
...FocusedChecked.args
|
|
132
140
|
};
|
|
133
141
|
FocusedCheckedDense.parameters = {
|
|
@@ -137,37 +145,44 @@ FocusedCheckedDense.parameters = {
|
|
|
137
145
|
};
|
|
138
146
|
FocusedCheckedDense.storyName = 'Focused checked - Dense';
|
|
139
147
|
export const CheckedDense = Template.bind({});
|
|
140
|
-
CheckedDense.args = {
|
|
148
|
+
CheckedDense.args = {
|
|
149
|
+
...DefaultDense.args,
|
|
141
150
|
...Checked.args
|
|
142
151
|
};
|
|
143
152
|
CheckedDense.storyName = 'Checked - Dense';
|
|
144
153
|
export const RequiredDense = Template.bind({});
|
|
145
|
-
RequiredDense.args = {
|
|
154
|
+
RequiredDense.args = {
|
|
155
|
+
...DefaultDense.args,
|
|
146
156
|
...Required.args
|
|
147
157
|
};
|
|
148
158
|
RequiredDense.storyName = 'Required - Dense';
|
|
149
159
|
export const DisabledDense = CheckedUncheckedTemplate.bind({});
|
|
150
|
-
DisabledDense.args = {
|
|
160
|
+
DisabledDense.args = {
|
|
161
|
+
...DefaultDense.args,
|
|
151
162
|
...Disabled.args
|
|
152
163
|
};
|
|
153
164
|
DisabledDense.storyName = 'Disabled - Dense';
|
|
154
165
|
export const ValidDense = CheckedUncheckedTemplate.bind({});
|
|
155
|
-
ValidDense.args = {
|
|
166
|
+
ValidDense.args = {
|
|
167
|
+
...DefaultDense.args,
|
|
156
168
|
...Valid.args
|
|
157
169
|
};
|
|
158
170
|
ValidDense.storyName = 'Valid - Dense';
|
|
159
171
|
export const WarningDense = CheckedUncheckedTemplate.bind({});
|
|
160
|
-
WarningDense.args = {
|
|
172
|
+
WarningDense.args = {
|
|
173
|
+
...DefaultDense.args,
|
|
161
174
|
...Warning.args
|
|
162
175
|
};
|
|
163
176
|
WarningDense.storyName = 'Warning - Dense';
|
|
164
177
|
export const ErrorDense = CheckedUncheckedTemplate.bind({});
|
|
165
|
-
ErrorDense.args = {
|
|
178
|
+
ErrorDense.args = {
|
|
179
|
+
...DefaultDense.args,
|
|
166
180
|
...Error.args
|
|
167
181
|
};
|
|
168
182
|
ErrorDense.storyName = 'Error - Dense';
|
|
169
183
|
export const ImageLabelDense = Template.bind({});
|
|
170
|
-
ImageLabelDense.args = {
|
|
184
|
+
ImageLabelDense.args = {
|
|
185
|
+
...DefaultDense.args,
|
|
171
186
|
...ImageLabel.args
|
|
172
187
|
};
|
|
173
188
|
ImageLabelDense.storyName = 'Image label - Dense';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dhis2-ui/switch",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.11.1-beta.1",
|
|
4
4
|
"description": "UI Switch",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,20 +22,20 @@
|
|
|
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/field": "9.
|
|
37
|
-
"@dhis2-ui/required": "9.
|
|
38
|
-
"@dhis2/ui-constants": "9.
|
|
36
|
+
"@dhis2-ui/field": "9.11.1-beta.1",
|
|
37
|
+
"@dhis2-ui/required": "9.11.1-beta.1",
|
|
38
|
+
"@dhis2/ui-constants": "9.11.1-beta.1",
|
|
39
39
|
"classnames": "^2.3.1",
|
|
40
40
|
"prop-types": "^15.7.2"
|
|
41
41
|
},
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@storybook/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _index = require("./index.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)('Switch', module).add('With onChange', () => /*#__PURE__*/_react2.default.createElement(_index.Switch, {
|
|
15
|
-
name: "Ex",
|
|
16
|
-
label: "Switch",
|
|
17
|
-
value: "default",
|
|
18
|
-
onChange: window.onChange
|
|
19
|
-
})).add('With initialFocus and onBlur', () => /*#__PURE__*/_react2.default.createElement(_index.Switch, {
|
|
20
|
-
initialFocus: true,
|
|
21
|
-
name: "Ex",
|
|
22
|
-
label: "Switch",
|
|
23
|
-
value: "default",
|
|
24
|
-
onBlur: window.onBlur
|
|
25
|
-
})).add('With onFocus', () => /*#__PURE__*/_react2.default.createElement(_index.Switch, {
|
|
26
|
-
name: "Ex",
|
|
27
|
-
label: "Switch",
|
|
28
|
-
value: "default",
|
|
29
|
-
onFocus: window.onFocus
|
|
30
|
-
})).add('With disabled', () => /*#__PURE__*/_react2.default.createElement(_index.Switch, {
|
|
31
|
-
name: "Ex",
|
|
32
|
-
label: "Switch",
|
|
33
|
-
value: "default",
|
|
34
|
-
disabled: true
|
|
35
|
-
})).add('With label', () => /*#__PURE__*/_react2.default.createElement(_index.Switch, {
|
|
36
|
-
name: "Ex",
|
|
37
|
-
label: "The label",
|
|
38
|
-
value: "default"
|
|
39
|
-
})).add('With initialFocus', () => /*#__PURE__*/_react2.default.createElement(_index.Switch, {
|
|
40
|
-
name: "Ex",
|
|
41
|
-
label: "The label",
|
|
42
|
-
value: "default",
|
|
43
|
-
initialFocus: true
|
|
44
|
-
}));
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _react = require("@storybook/react");
|
|
4
|
-
|
|
5
|
-
var _react2 = _interopRequireDefault(require("react"));
|
|
6
|
-
|
|
7
|
-
var _index = require("./index.js");
|
|
8
|
-
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
|
|
11
|
-
(0, _react.storiesOf)('SwitchField', module).add('With label and required', () => /*#__PURE__*/_react2.default.createElement(_index.SwitchField, {
|
|
12
|
-
name: "Ex",
|
|
13
|
-
label: "SwitchField",
|
|
14
|
-
required: true,
|
|
15
|
-
value: "checked"
|
|
16
|
-
}));
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { storiesOf } from '@storybook/react';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { SwitchField } from './index.js';
|
|
4
|
-
storiesOf('SwitchField', module).add('With label and required', () => /*#__PURE__*/React.createElement(SwitchField, {
|
|
5
|
-
name: "Ex",
|
|
6
|
-
label: "SwitchField",
|
|
7
|
-
required: true,
|
|
8
|
-
value: "checked"
|
|
9
|
-
}));
|