@dhis2-ui/checkbox 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/checkbox/__tests__/checkbox.test.js +1 -7
- package/build/cjs/checkbox/checkbox-icon.js +14 -24
- package/build/cjs/checkbox/checkbox.e2e.stories.js +72 -0
- package/build/cjs/checkbox/checkbox.js +7 -31
- package/build/cjs/checkbox/{checkbox.stories.js → checkbox.prod.stories.js} +54 -74
- package/build/cjs/checkbox/features/accepts_initial_focus/index.js +1 -2
- package/build/cjs/checkbox/features/accepts_label/index.js +0 -1
- package/build/cjs/checkbox/features/can_be_blurred/index.js +1 -2
- package/build/cjs/checkbox/features/can_be_changed/index.js +1 -2
- package/build/cjs/checkbox/features/can_be_disabled/index.js +1 -2
- package/build/cjs/checkbox/features/can_be_focused/index.js +1 -2
- package/build/cjs/checkbox/features/has_indeterminate_prop/index.js +0 -1
- package/build/cjs/checkbox/index.js +0 -1
- package/build/cjs/checkbox-field/__tests__/checkbox-field.test.js +1 -7
- package/build/cjs/checkbox-field/checkbox-field.e2e.stories.js +39 -0
- package/build/cjs/checkbox-field/checkbox-field.js +4 -30
- package/build/cjs/checkbox-field/{checkbox-field.stories.js → checkbox-field.prod.stories.js} +59 -74
- package/build/cjs/checkbox-field/features/accepts_help_text/index.js +0 -1
- package/build/cjs/checkbox-field/features/accepts_label/index.js +0 -1
- package/build/cjs/checkbox-field/features/accepts_validation_text/index.js +0 -1
- package/build/cjs/checkbox-field/features/can_be_required/index.js +0 -1
- package/build/cjs/checkbox-field/index.js +0 -1
- package/build/cjs/index.js +0 -2
- package/build/es/checkbox/checkbox-icon.js +13 -13
- package/build/es/checkbox/{checkbox.stories.e2e.js → checkbox.e2e.stories.js} +19 -10
- package/build/es/checkbox/checkbox.js +4 -19
- package/build/es/checkbox/{checkbox.stories.js → checkbox.prod.stories.js} +35 -25
- package/build/es/checkbox/features/accepts_initial_focus/index.js +1 -1
- package/build/es/checkbox/features/can_be_blurred/index.js +1 -1
- package/build/es/checkbox/features/can_be_changed/index.js +1 -1
- package/build/es/checkbox/features/can_be_disabled/index.js +1 -1
- package/build/es/checkbox/features/can_be_focused/index.js +1 -1
- package/build/es/checkbox-field/checkbox-field.e2e.stories.js +28 -0
- package/build/es/checkbox-field/checkbox-field.js +3 -22
- package/build/es/checkbox-field/{checkbox-field.stories.js → checkbox-field.prod.stories.js} +38 -23
- package/package.json +7 -7
- package/build/cjs/checkbox/checkbox.stories.e2e.js +0 -55
- package/build/cjs/checkbox-field/checkbox-field.stories.e2e.js +0 -30
- package/build/es/checkbox-field/checkbox-field.stories.e2e.js +0 -23
package/build/cjs/checkbox-field/{checkbox-field.stories.js → checkbox-field.prod.stories.js}
RENAMED
|
@@ -4,29 +4,29 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = exports.WarningDense = exports.Warning = exports.ValidDense = exports.Valid = exports.RequiredDense = exports.Required = exports.RTL = exports.ImageLabelDense = exports.ImageLabel = exports.HelpText = 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 _index = require("./index.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 description = `
|
|
13
|
+
A \`CheckboxField\` is a Checkbox 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.
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
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); }
|
|
17
|
-
|
|
18
|
-
const description = "\nA `CheckboxField` is a Checkbox 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.\n\nSee the basic Checkbox for usage and design system guidelines.\n\n```js\nimport { CheckboxField } from '@dhis2/ui'\n```\n";
|
|
15
|
+
See the basic Checkbox for usage and design system guidelines.
|
|
19
16
|
|
|
17
|
+
\`\`\`js
|
|
18
|
+
import { CheckboxField } from '@dhis2/ui'
|
|
19
|
+
\`\`\`
|
|
20
|
+
`;
|
|
20
21
|
const logger = _ref => {
|
|
21
22
|
let {
|
|
22
23
|
name,
|
|
23
24
|
value,
|
|
24
25
|
checked
|
|
25
26
|
} = _ref;
|
|
26
|
-
return console.log(
|
|
27
|
+
return console.log(`name: ${name}, value: ${value}, checked: ${checked}`);
|
|
27
28
|
};
|
|
28
|
-
|
|
29
|
-
var _default = {
|
|
29
|
+
var _default = exports.default = {
|
|
30
30
|
title: 'Checkbox Field',
|
|
31
31
|
component: _index.CheckboxField,
|
|
32
32
|
parameters: {
|
|
@@ -44,38 +44,35 @@ var _default = {
|
|
|
44
44
|
onChange: logger
|
|
45
45
|
},
|
|
46
46
|
argTypes: {
|
|
47
|
-
valid: {
|
|
47
|
+
valid: {
|
|
48
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
48
49
|
},
|
|
49
|
-
warning: {
|
|
50
|
+
warning: {
|
|
51
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
50
52
|
},
|
|
51
|
-
error: {
|
|
53
|
+
error: {
|
|
54
|
+
..._uiConstants.sharedPropTypes.statusArgType
|
|
52
55
|
}
|
|
53
56
|
}
|
|
54
57
|
};
|
|
55
|
-
exports.default = _default;
|
|
56
|
-
|
|
57
58
|
const Template = args => /*#__PURE__*/_react.default.createElement(_index.CheckboxField, args);
|
|
58
|
-
|
|
59
59
|
const CheckedUncheckedTemplate = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.CheckboxField, args), /*#__PURE__*/_react.default.createElement(_index.CheckboxField, _extends({}, args, {
|
|
60
60
|
checked: true
|
|
61
61
|
})));
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
exports.Default = Default;
|
|
65
|
-
const FocusedUnchecked = Template.bind({});
|
|
66
|
-
exports.FocusedUnchecked = FocusedUnchecked;
|
|
62
|
+
const Default = exports.Default = Template.bind({});
|
|
63
|
+
const FocusedUnchecked = exports.FocusedUnchecked = Template.bind({});
|
|
67
64
|
FocusedUnchecked.args = {
|
|
68
65
|
initialFocus: true
|
|
69
|
-
};
|
|
70
|
-
|
|
66
|
+
};
|
|
67
|
+
// Disable stories on docs page that grab focus
|
|
71
68
|
FocusedUnchecked.parameters = {
|
|
72
69
|
docs: {
|
|
73
70
|
disable: true
|
|
74
71
|
}
|
|
75
72
|
};
|
|
76
|
-
const FocusedChecked = Template.bind({});
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
const FocusedChecked = exports.FocusedChecked = Template.bind({});
|
|
74
|
+
FocusedChecked.args = {
|
|
75
|
+
...FocusedUnchecked.args,
|
|
79
76
|
checked: true
|
|
80
77
|
};
|
|
81
78
|
FocusedChecked.parameters = {
|
|
@@ -83,69 +80,59 @@ FocusedChecked.parameters = {
|
|
|
83
80
|
disable: true
|
|
84
81
|
}
|
|
85
82
|
};
|
|
86
|
-
const Checked = Template.bind({});
|
|
87
|
-
exports.Checked = Checked;
|
|
83
|
+
const Checked = exports.Checked = Template.bind({});
|
|
88
84
|
Checked.args = {
|
|
89
85
|
checked: true,
|
|
90
86
|
value: 'checkedValue'
|
|
91
87
|
};
|
|
92
|
-
const Required = Template.bind({});
|
|
93
|
-
exports.Required = Required;
|
|
88
|
+
const Required = exports.Required = Template.bind({});
|
|
94
89
|
Required.args = {
|
|
95
90
|
required: true
|
|
96
91
|
};
|
|
97
|
-
const Disabled = CheckedUncheckedTemplate.bind({});
|
|
98
|
-
exports.Disabled = Disabled;
|
|
92
|
+
const Disabled = exports.Disabled = CheckedUncheckedTemplate.bind({});
|
|
99
93
|
Disabled.args = {
|
|
100
94
|
disabled: true
|
|
101
95
|
};
|
|
102
|
-
|
|
103
96
|
const HelpText = args => /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.CheckboxField, args), /*#__PURE__*/_react.default.createElement(_index.CheckboxField, _extends({}, args, {
|
|
104
97
|
error: true,
|
|
105
98
|
validationText: "Validation text (error state)"
|
|
106
99
|
})));
|
|
107
|
-
|
|
108
100
|
exports.HelpText = HelpText;
|
|
109
101
|
HelpText.args = {
|
|
110
102
|
helpText: 'Help text'
|
|
111
103
|
};
|
|
112
|
-
const Valid = CheckedUncheckedTemplate.bind({});
|
|
113
|
-
exports.Valid = Valid;
|
|
104
|
+
const Valid = exports.Valid = CheckedUncheckedTemplate.bind({});
|
|
114
105
|
Valid.args = {
|
|
115
106
|
valid: true,
|
|
116
107
|
validationText: 'I am validation text',
|
|
117
108
|
value: 'validValue'
|
|
118
109
|
};
|
|
119
|
-
const Warning = CheckedUncheckedTemplate.bind({});
|
|
120
|
-
exports.Warning = Warning;
|
|
110
|
+
const Warning = exports.Warning = CheckedUncheckedTemplate.bind({});
|
|
121
111
|
Warning.args = {
|
|
122
112
|
warning: true,
|
|
123
113
|
value: 'warningValue',
|
|
124
114
|
validationText: 'I am validation text'
|
|
125
115
|
};
|
|
126
|
-
const Error = CheckedUncheckedTemplate.bind({});
|
|
127
|
-
exports.Error = Error;
|
|
116
|
+
const Error = exports.Error = CheckedUncheckedTemplate.bind({});
|
|
128
117
|
Error.args = {
|
|
129
118
|
error: true,
|
|
130
119
|
value: 'errorValue',
|
|
131
120
|
validationText: 'I am validation text'
|
|
132
121
|
};
|
|
133
|
-
const ImageLabel = Template.bind({});
|
|
134
|
-
exports.ImageLabel = ImageLabel;
|
|
122
|
+
const ImageLabel = exports.ImageLabel = Template.bind({});
|
|
135
123
|
ImageLabel.args = {
|
|
136
124
|
label: /*#__PURE__*/_react.default.createElement("img", {
|
|
137
125
|
src: "https://picsum.photos/id/82/200/100"
|
|
138
126
|
})
|
|
139
127
|
};
|
|
140
|
-
const DefaultDense = Template.bind({});
|
|
141
|
-
exports.DefaultDense = DefaultDense;
|
|
128
|
+
const DefaultDense = exports.DefaultDense = Template.bind({});
|
|
142
129
|
DefaultDense.storyName = 'Default - Dense';
|
|
143
130
|
DefaultDense.args = {
|
|
144
131
|
dense: true
|
|
145
132
|
};
|
|
146
|
-
const FocusedUncheckedDense = Template.bind({});
|
|
147
|
-
|
|
148
|
-
|
|
133
|
+
const FocusedUncheckedDense = exports.FocusedUncheckedDense = Template.bind({});
|
|
134
|
+
FocusedUncheckedDense.args = {
|
|
135
|
+
...DefaultDense.args,
|
|
149
136
|
...FocusedUnchecked.args
|
|
150
137
|
};
|
|
151
138
|
FocusedUncheckedDense.parameters = {
|
|
@@ -154,9 +141,9 @@ FocusedUncheckedDense.parameters = {
|
|
|
154
141
|
}
|
|
155
142
|
};
|
|
156
143
|
FocusedUncheckedDense.storyName = 'Focused unchecked - Dense';
|
|
157
|
-
const FocusedCheckedDense = Template.bind({});
|
|
158
|
-
|
|
159
|
-
|
|
144
|
+
const FocusedCheckedDense = exports.FocusedCheckedDense = Template.bind({});
|
|
145
|
+
FocusedCheckedDense.args = {
|
|
146
|
+
...DefaultDense.args,
|
|
160
147
|
...FocusedChecked.args
|
|
161
148
|
};
|
|
162
149
|
FocusedCheckedDense.parameters = {
|
|
@@ -165,51 +152,49 @@ FocusedCheckedDense.parameters = {
|
|
|
165
152
|
}
|
|
166
153
|
};
|
|
167
154
|
FocusedCheckedDense.storyName = 'Focused checked - Dense';
|
|
168
|
-
const CheckedDense = Template.bind({});
|
|
169
|
-
|
|
170
|
-
|
|
155
|
+
const CheckedDense = exports.CheckedDense = Template.bind({});
|
|
156
|
+
CheckedDense.args = {
|
|
157
|
+
...DefaultDense.args,
|
|
171
158
|
...Checked.args
|
|
172
159
|
};
|
|
173
160
|
CheckedDense.storyName = 'Checked - Dense';
|
|
174
|
-
const RequiredDense = Template.bind({});
|
|
175
|
-
|
|
176
|
-
|
|
161
|
+
const RequiredDense = exports.RequiredDense = Template.bind({});
|
|
162
|
+
RequiredDense.args = {
|
|
163
|
+
...DefaultDense.args,
|
|
177
164
|
...Required.args
|
|
178
165
|
};
|
|
179
166
|
RequiredDense.storyName = 'Required - Dense';
|
|
180
|
-
const DisabledDense = CheckedUncheckedTemplate.bind({});
|
|
181
|
-
|
|
182
|
-
|
|
167
|
+
const DisabledDense = exports.DisabledDense = CheckedUncheckedTemplate.bind({});
|
|
168
|
+
DisabledDense.args = {
|
|
169
|
+
...DefaultDense.args,
|
|
183
170
|
...Disabled.args
|
|
184
171
|
};
|
|
185
172
|
DisabledDense.storyName = 'Disabled - Dense';
|
|
186
|
-
const ValidDense = CheckedUncheckedTemplate.bind({});
|
|
187
|
-
|
|
188
|
-
|
|
173
|
+
const ValidDense = exports.ValidDense = CheckedUncheckedTemplate.bind({});
|
|
174
|
+
ValidDense.args = {
|
|
175
|
+
...DefaultDense.args,
|
|
189
176
|
...Valid.args
|
|
190
177
|
};
|
|
191
178
|
ValidDense.storyName = 'Valid - Dense';
|
|
192
|
-
const WarningDense = CheckedUncheckedTemplate.bind({});
|
|
193
|
-
|
|
194
|
-
|
|
179
|
+
const WarningDense = exports.WarningDense = CheckedUncheckedTemplate.bind({});
|
|
180
|
+
WarningDense.args = {
|
|
181
|
+
...DefaultDense.args,
|
|
195
182
|
...Warning.args
|
|
196
183
|
};
|
|
197
184
|
WarningDense.storyName = 'Warning - Dense';
|
|
198
|
-
const ErrorDense = CheckedUncheckedTemplate.bind({});
|
|
199
|
-
|
|
200
|
-
|
|
185
|
+
const ErrorDense = exports.ErrorDense = CheckedUncheckedTemplate.bind({});
|
|
186
|
+
ErrorDense.args = {
|
|
187
|
+
...DefaultDense.args,
|
|
201
188
|
...Error.args
|
|
202
189
|
};
|
|
203
190
|
ErrorDense.storyName = 'Error - Dense';
|
|
204
|
-
const ImageLabelDense = Template.bind({});
|
|
205
|
-
|
|
206
|
-
|
|
191
|
+
const ImageLabelDense = exports.ImageLabelDense = Template.bind({});
|
|
192
|
+
ImageLabelDense.args = {
|
|
193
|
+
...DefaultDense.args,
|
|
207
194
|
...ImageLabel.args
|
|
208
195
|
};
|
|
209
196
|
ImageLabelDense.storyName = 'Image label - Dense';
|
|
210
|
-
|
|
211
197
|
const RTL = args => /*#__PURE__*/_react.default.createElement("div", {
|
|
212
198
|
dir: "rtl"
|
|
213
199
|
}, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_index.CheckboxField, args)));
|
|
214
|
-
|
|
215
200
|
exports.RTL = RTL;
|
|
@@ -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 CheckboxField with validation text is rendered', () => {
|
|
6
5
|
cy.visitStory('CheckboxField', 'With validation text');
|
|
7
6
|
});
|
|
@@ -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 CheckboxField with label and a required flag is rendered', () => {
|
|
6
5
|
cy.visitStory('CheckboxField', 'With label and required');
|
|
7
6
|
});
|
package/build/cjs/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import _JSXStyle from "styled-jsx/style";
|
|
|
2
2
|
import { colors } from '@dhis2/ui-constants';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import React from 'react';
|
|
5
|
-
const commonStyles = ["svg.jsx-4069423049{display:block;pointer-events:none;}",
|
|
5
|
+
const commonStyles = ["svg.jsx-4069423049{display:block;pointer-events:none;}", `svg.jsx-4069423049 .border.jsx-4069423049{fill:${colors.grey800};}`, `svg.jsx-4069423049 .background.jsx-4069423049,svg.jsx-4069423049 .indeterminate.jsx-4069423049,svg.jsx-4069423049 .checkmark.jsx-4069423049{fill:${colors.white};}`, `svg.checked.jsx-4069423049 .background.jsx-4069423049,svg.indeterminate.jsx-4069423049 .background.jsx-4069423049{fill:${colors.teal500};}`, `svg.valid.jsx-4069423049 .background.jsx-4069423049{fill:${colors.blue600};}`, `svg.warning.jsx-4069423049 .background.jsx-4069423049{fill:${colors.yellow700};}`, `svg.error.jsx-4069423049 .background.jsx-4069423049{fill:${colors.red500};}`, `svg.checked.jsx-4069423049 .border.jsx-4069423049,svg.indeterminate.jsx-4069423049 .border.jsx-4069423049{fill:${colors.teal900};}`, "svg.jsx-4069423049:not(.checked) .checkmark.jsx-4069423049,svg.jsx-4069423049:not(.indeterminate) .indeterminate.jsx-4069423049{fill:none;}", `svg.jsx-4069423049:not(.checked):not(.indeterminate) .background.jsx-4069423049{fill:${colors.white};}`];
|
|
6
6
|
commonStyles.__hash = "4069423049";
|
|
7
7
|
export function CheckboxRegular(_ref) {
|
|
8
8
|
let {
|
|
@@ -11,33 +11,33 @@ export function CheckboxRegular(_ref) {
|
|
|
11
11
|
return /*#__PURE__*/React.createElement("svg", {
|
|
12
12
|
viewBox: "0 0 18 18",
|
|
13
13
|
xmlns: "http://www.w3.org/2000/svg",
|
|
14
|
-
className:
|
|
14
|
+
className: `jsx-${commonStyles.__hash}` + " " + _JSXStyle.dynamic([["2753140462", [colors.grey300, colors.grey400, colors.blue600, colors.blue700, colors.yellow700, colors.yellow800, colors.red500, colors.red700]]]) + " " + (className || "")
|
|
15
15
|
}, /*#__PURE__*/React.createElement("rect", {
|
|
16
16
|
x: "0",
|
|
17
17
|
y: "0",
|
|
18
18
|
width: "18",
|
|
19
19
|
height: "18",
|
|
20
20
|
rx: "3",
|
|
21
|
-
className:
|
|
21
|
+
className: `jsx-${commonStyles.__hash}` + " " + _JSXStyle.dynamic([["2753140462", [colors.grey300, colors.grey400, colors.blue600, colors.blue700, colors.yellow700, colors.yellow800, colors.red500, colors.red700]]]) + " " + "background"
|
|
22
22
|
}), /*#__PURE__*/React.createElement("path", {
|
|
23
23
|
d: "M15,0 C16.6568542,0 18,1.34314575 18,3 L18,15 C18,16.6568542 16.6568542,18 15,18 L3,18 C1.34314575,18 0,16.6568542 0,15 L0,3 C0,1.34314575 1.34314575,0 3,0 L15,0 Z M15,1 L3,1 C1.9456382,1 1.08183488,1.81587779 1.00548574,2.85073766 L1,3 L1,15 C1,16.0543618 1.81587779,16.9181651 2.85073766,16.9945143 L3,17 L15,17 C16.0543618,17 16.9181651,16.1841222 16.9945143,15.1492623 L17,15 L17,3 C17,1.9456382 16.1841222,1.08183488 15.1492623,1.00548574 L15,1 Z",
|
|
24
|
-
className:
|
|
24
|
+
className: `jsx-${commonStyles.__hash}` + " " + _JSXStyle.dynamic([["2753140462", [colors.grey300, colors.grey400, colors.blue600, colors.blue700, colors.yellow700, colors.yellow800, colors.red500, colors.red700]]]) + " " + "border"
|
|
25
25
|
}), /*#__PURE__*/React.createElement("path", {
|
|
26
26
|
d: "M4.74451387,8.02852516 C4.39595738,8.11985643 4.12375034,8.39235188 4.03251575,8.74127768 C3.94128115,9.09020348 4.04521722,9.46125864 4.30437605,9.71182782 L7.29823844,12.7078028 C7.68753993,13.0973991 8.31859767,13.0973991 8.70789916,12.7078028 L13.695624,6.71585285 C13.9547828,6.46528367 14.0587189,6.09422851 13.9674843,5.74530271 C13.8762497,5.39637691 13.6040426,5.12388146 13.2554861,5.0325502 C12.9069296,4.94121893 12.5362672,5.04526513 12.2859632,5.30469855 L8.0030688,10.5910713 L5.71403676,8.30067351 C5.46373279,8.0412401 5.09307036,7.9371939 4.74451387,8.02852516 Z",
|
|
27
|
-
className:
|
|
27
|
+
className: `jsx-${commonStyles.__hash}` + " " + _JSXStyle.dynamic([["2753140462", [colors.grey300, colors.grey400, colors.blue600, colors.blue700, colors.yellow700, colors.yellow800, colors.red500, colors.red700]]]) + " " + "checkmark"
|
|
28
28
|
}), /*#__PURE__*/React.createElement("rect", {
|
|
29
29
|
x: "4",
|
|
30
30
|
y: "8",
|
|
31
31
|
width: "10",
|
|
32
32
|
height: "2",
|
|
33
33
|
rx: "1",
|
|
34
|
-
className:
|
|
34
|
+
className: `jsx-${commonStyles.__hash}` + " " + _JSXStyle.dynamic([["2753140462", [colors.grey300, colors.grey400, colors.blue600, colors.blue700, colors.yellow700, colors.yellow800, colors.red500, colors.red700]]]) + " " + "indeterminate"
|
|
35
35
|
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
36
36
|
id: commonStyles.__hash
|
|
37
37
|
}, commonStyles), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
38
38
|
id: "2753140462",
|
|
39
39
|
dynamic: [colors.grey300, colors.grey400, colors.blue600, colors.blue700, colors.yellow700, colors.yellow800, colors.red500, colors.red700]
|
|
40
|
-
}, ["svg.__jsx-style-dynamic-selector{width:18px;height:18px;}",
|
|
40
|
+
}, ["svg.__jsx-style-dynamic-selector{width:18px;height:18px;}", `svg.disabled.__jsx-style-dynamic-selector .background.__jsx-style-dynamic-selector{fill:${colors.grey300};}`, `svg.disabled.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector{fill:${colors.grey400};}`, `svg.valid.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector{fill:${colors.blue600};}`, `svg.valid.checked.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector,svg.valid.indeterminate.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector{fill:${colors.blue700};}`, `svg.warning.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector{fill:${colors.yellow700};}`, `svg.warning.checked.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector,svg.warning.indeterminate.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector{fill:${colors.yellow800};}`, `svg.error.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector{fill:${colors.red500};}`, `svg.error.checked.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector,svg.error.indeterminate.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector{fill:${colors.red700};}`]));
|
|
41
41
|
}
|
|
42
42
|
CheckboxRegular.propTypes = {
|
|
43
43
|
className: PropTypes.string
|
|
@@ -49,32 +49,32 @@ export function CheckboxDense(_ref2) {
|
|
|
49
49
|
return /*#__PURE__*/React.createElement("svg", {
|
|
50
50
|
viewBox: "0 0 14 14",
|
|
51
51
|
xmlns: "http://www.w3.org/2000/svg",
|
|
52
|
-
className:
|
|
52
|
+
className: `jsx-${commonStyles.__hash}` + " " + _JSXStyle.dynamic([["86695588", [colors.grey400, colors.grey400, colors.grey500, colors.blue600, colors.blue800, colors.yellow700, colors.yellow800, colors.red500, colors.red800]]]) + " " + (className || "")
|
|
53
53
|
}, /*#__PURE__*/React.createElement("rect", {
|
|
54
54
|
x: "0",
|
|
55
55
|
y: "0",
|
|
56
56
|
width: "14",
|
|
57
57
|
height: "14",
|
|
58
58
|
rx: "2",
|
|
59
|
-
className:
|
|
59
|
+
className: `jsx-${commonStyles.__hash}` + " " + _JSXStyle.dynamic([["86695588", [colors.grey400, colors.grey400, colors.grey500, colors.blue600, colors.blue800, colors.yellow700, colors.yellow800, colors.red500, colors.red800]]]) + " " + "background"
|
|
60
60
|
}), /*#__PURE__*/React.createElement("path", {
|
|
61
61
|
d: "M2,0 L12,0 C13.1045695,0 14,0.8954305 14,2 L14,12 C14,13.1045695 13.1045695,14 12,14 L2,14 C0.8954305,14 0,13.1045695 0,12 L0,2 C0,0.8954305 0.8954305,0 2,0 Z M2,1 C1.44771525,1 1,1.44771525 1,2 L1,12 C1,12.5522847 1.44771525,13 2,13 L12,13 C12.5522847,13 13,12.5522847 13,12 L13,2 C13,1.44771525 12.5522847,1 12,1 L2,1 Z",
|
|
62
|
-
className:
|
|
62
|
+
className: `jsx-${commonStyles.__hash}` + " " + _JSXStyle.dynamic([["86695588", [colors.grey400, colors.grey400, colors.grey500, colors.blue600, colors.blue800, colors.yellow700, colors.yellow800, colors.red500, colors.red800]]]) + " " + "border"
|
|
63
63
|
}), /*#__PURE__*/React.createElement("path", {
|
|
64
64
|
d: "M10.3520005,3.30015877 L5.54268293,8.03252726 L3.64634146,6.16652726 L2.28668615,7.5044281 L5.54310367,10.7010587 L11.7145993,4.628307 L10.3520005,3.30015877 Z M5.54268293,9.43547274 L5.61193184,9.36733181 L5.54226219,9.29894127 L5.47309681,9.367 L5.54268293,9.43547274 Z M10.6496329,4.41023392 L10.6495057,4.35652297 L10.5648412,4.35672356 L10.2854007,4.631693 L10.3553166,4.69984123 L10.6496329,4.41023392 Z M3.42891348,7.22439304 L3.35030905,7.22439304 L3.35034135,7.27820863 L3.64634146,7.56947274 L3.71331385,7.5035719 L3.42891348,7.22439304 Z",
|
|
65
|
-
className:
|
|
65
|
+
className: `jsx-${commonStyles.__hash}` + " " + _JSXStyle.dynamic([["86695588", [colors.grey400, colors.grey400, colors.grey500, colors.blue600, colors.blue800, colors.yellow700, colors.yellow800, colors.red500, colors.red800]]]) + " " + "checkmark"
|
|
66
66
|
}), /*#__PURE__*/React.createElement("rect", {
|
|
67
67
|
x: "3",
|
|
68
68
|
y: "6",
|
|
69
69
|
width: "8",
|
|
70
70
|
height: "2",
|
|
71
|
-
className:
|
|
71
|
+
className: `jsx-${commonStyles.__hash}` + " " + _JSXStyle.dynamic([["86695588", [colors.grey400, colors.grey400, colors.grey500, colors.blue600, colors.blue800, colors.yellow700, colors.yellow800, colors.red500, colors.red800]]]) + " " + "indeterminate"
|
|
72
72
|
}), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
73
73
|
id: commonStyles.__hash
|
|
74
74
|
}, commonStyles), /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
75
75
|
id: "86695588",
|
|
76
76
|
dynamic: [colors.grey400, colors.grey400, colors.grey500, colors.blue600, colors.blue800, colors.yellow700, colors.yellow800, colors.red500, colors.red800]
|
|
77
|
-
}, ["svg.__jsx-style-dynamic-selector{width:14px;height:14px;}",
|
|
77
|
+
}, ["svg.__jsx-style-dynamic-selector{width:14px;height:14px;}", `svg.disabled.__jsx-style-dynamic-selector .background.__jsx-style-dynamic-selector{fill:${colors.grey400};}`, `svg.disabled.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector{fill:${colors.grey400};}`, `svg.disabled.checked.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector,svg.disabled.indeterminate.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector{fill:${colors.grey500};}`, `svg.valid.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector{fill:${colors.blue600};}`, `svg.valid.checked.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector,svg.valid.indeterminate.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector{fill:${colors.blue800};}`, `svg.warning.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector{fill:${colors.yellow700};}`, `svg.warning.checked.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector,svg.warning.indeterminate.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector{fill:${colors.yellow800};}`, `svg.error.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector{fill:${colors.red500};}`, `svg.error.checked.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector,svg.error.indeterminate.__jsx-style-dynamic-selector .border.__jsx-style-dynamic-selector{fill:${colors.red800};}`]));
|
|
78
78
|
}
|
|
79
79
|
CheckboxDense.propTypes = {
|
|
80
80
|
className: PropTypes.string
|
|
@@ -1,48 +1,57 @@
|
|
|
1
|
-
import { storiesOf } from '@storybook/react';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
import { Checkbox } from './index.js';
|
|
4
3
|
window.onClick = window.Cypress && window.Cypress.cy.stub();
|
|
5
4
|
window.onChange = window.Cypress && window.Cypress.cy.stub();
|
|
6
5
|
window.onBlur = window.Cypress && window.Cypress.cy.stub();
|
|
7
6
|
window.onFocus = window.Cypress && window.Cypress.cy.stub();
|
|
8
|
-
|
|
7
|
+
export default {
|
|
8
|
+
title: 'Checkbox'
|
|
9
|
+
};
|
|
10
|
+
export const WithOnChange = () => /*#__PURE__*/React.createElement(Checkbox, {
|
|
9
11
|
name: "Ex",
|
|
10
12
|
label: "Checkbox",
|
|
11
13
|
value: "default",
|
|
12
14
|
onChange: window.onChange
|
|
13
|
-
})
|
|
15
|
+
});
|
|
16
|
+
export const WithInitialFocusAndOnBlur = () => /*#__PURE__*/React.createElement(Checkbox, {
|
|
14
17
|
initialFocus: true,
|
|
15
18
|
name: "Ex",
|
|
16
19
|
label: "Checkbox",
|
|
17
20
|
value: "default",
|
|
18
21
|
onBlur: window.onBlur
|
|
19
|
-
})
|
|
22
|
+
});
|
|
23
|
+
export const WithOnFocus = () => /*#__PURE__*/React.createElement(Checkbox, {
|
|
20
24
|
name: "Ex",
|
|
21
25
|
label: "Checkbox",
|
|
22
26
|
value: "default",
|
|
23
27
|
onFocus: window.onFocus
|
|
24
|
-
})
|
|
28
|
+
});
|
|
29
|
+
export const DisabledWithOnClick = () => /*#__PURE__*/React.createElement(Checkbox, {
|
|
25
30
|
name: "Ex",
|
|
26
31
|
label: "Checkbox",
|
|
27
32
|
value: "default",
|
|
28
33
|
disabled: true,
|
|
29
34
|
onClick: window.onClick
|
|
30
|
-
})
|
|
35
|
+
});
|
|
36
|
+
export const WithLabel = () => /*#__PURE__*/React.createElement(Checkbox, {
|
|
31
37
|
name: "Ex",
|
|
32
38
|
label: "The label",
|
|
33
39
|
value: "default"
|
|
34
|
-
})
|
|
40
|
+
});
|
|
41
|
+
export const WithInitialFocus = () => /*#__PURE__*/React.createElement(Checkbox, {
|
|
35
42
|
name: "Ex",
|
|
36
43
|
label: "The label",
|
|
37
44
|
value: "default",
|
|
38
45
|
initialFocus: true
|
|
39
|
-
})
|
|
46
|
+
});
|
|
47
|
+
export const IndeterminateProp = () => /*#__PURE__*/React.createElement(Checkbox, {
|
|
40
48
|
name: "Ex",
|
|
41
49
|
label: "The label",
|
|
42
50
|
value: "default",
|
|
43
51
|
indeterminate: true
|
|
44
|
-
})
|
|
52
|
+
});
|
|
53
|
+
export const NoIndeterminateProp = () => /*#__PURE__*/React.createElement(Checkbox, {
|
|
45
54
|
name: "Ex",
|
|
46
55
|
label: "The label",
|
|
47
56
|
value: "default"
|
|
48
|
-
})
|
|
57
|
+
});
|
|
@@ -1,63 +1,52 @@
|
|
|
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 { mutuallyExclusive } from '@dhis2/prop-types';
|
|
6
6
|
import { colors, spacers, theme, sharedPropTypes } from '@dhis2/ui-constants';
|
|
7
7
|
import cx from 'classnames';
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import React, { Component, createRef } from 'react';
|
|
10
10
|
import { CheckboxRegular, CheckboxDense } from './checkbox-icon.js';
|
|
11
|
-
|
|
12
11
|
class Checkbox extends Component {
|
|
13
12
|
constructor() {
|
|
14
13
|
super(...arguments);
|
|
15
|
-
|
|
16
14
|
_defineProperty(this, "ref", /*#__PURE__*/createRef());
|
|
17
|
-
|
|
18
15
|
_defineProperty(this, "handleChange", e => {
|
|
19
16
|
if (this.props.onChange) {
|
|
20
17
|
this.props.onChange(this.createHandlerPayload(), e);
|
|
21
18
|
}
|
|
22
19
|
});
|
|
23
|
-
|
|
24
20
|
_defineProperty(this, "handleBlur", e => {
|
|
25
21
|
if (this.props.onBlur) {
|
|
26
22
|
this.props.onBlur(this.createHandlerPayload(), e);
|
|
27
23
|
}
|
|
28
24
|
});
|
|
29
|
-
|
|
30
25
|
_defineProperty(this, "handleFocus", e => {
|
|
31
26
|
if (this.props.onFocus) {
|
|
32
27
|
this.props.onFocus(this.createHandlerPayload(), e);
|
|
33
28
|
}
|
|
34
29
|
});
|
|
35
|
-
|
|
36
30
|
_defineProperty(this, "handleKeyDown", e => {
|
|
37
31
|
if (this.props.onKeyDown) {
|
|
38
32
|
this.props.onKeyDown(this.createHandlerPayload(), e);
|
|
39
33
|
}
|
|
40
34
|
});
|
|
41
35
|
}
|
|
42
|
-
|
|
43
36
|
componentDidMount() {
|
|
44
37
|
if (this.props.initialFocus) {
|
|
45
38
|
this.ref.current.focus();
|
|
46
39
|
}
|
|
47
|
-
|
|
48
40
|
this.setIndeterminate(this.props.indeterminate);
|
|
49
41
|
}
|
|
50
|
-
|
|
51
42
|
componentDidUpdate(prevProps) {
|
|
52
43
|
if (prevProps.indeterminate !== this.props.indeterminate) {
|
|
53
44
|
this.setIndeterminate(this.props.indeterminate);
|
|
54
45
|
}
|
|
55
46
|
}
|
|
56
|
-
|
|
57
47
|
setIndeterminate(indeterminate) {
|
|
58
48
|
this.ref.current.indeterminate = indeterminate;
|
|
59
49
|
}
|
|
60
|
-
|
|
61
50
|
createHandlerPayload() {
|
|
62
51
|
return {
|
|
63
52
|
value: this.props.value,
|
|
@@ -65,7 +54,6 @@ class Checkbox extends Component {
|
|
|
65
54
|
checked: !this.props.checked
|
|
66
55
|
};
|
|
67
56
|
}
|
|
68
|
-
|
|
69
57
|
render() {
|
|
70
58
|
const {
|
|
71
59
|
checked,
|
|
@@ -120,11 +108,9 @@ class Checkbox extends Component {
|
|
|
120
108
|
})), label, /*#__PURE__*/React.createElement(_JSXStyle, {
|
|
121
109
|
id: "1252368010",
|
|
122
110
|
dynamic: [colors.grey900, theme.disabled, spacers.dp4, theme.focus]
|
|
123
|
-
}, [
|
|
111
|
+
}, [`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;cursor:pointer;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:${spacers.dp4};border:2px solid transparent;padding:1px;border-radius:5px;}`, "label.dense.__jsx-style-dynamic-selector .icon.__jsx-style-dynamic-selector{margin-inline-end:3px;border-radius:4px;}", `input.__jsx-style-dynamic-selector:focus+.icon.__jsx-style-dynamic-selector{outline:3px solid ${theme.focus};outline-offset:-3px;}`]));
|
|
124
112
|
}
|
|
125
|
-
|
|
126
113
|
}
|
|
127
|
-
|
|
128
114
|
Checkbox.defaultProps = {
|
|
129
115
|
checked: false,
|
|
130
116
|
indeterminate: false,
|
|
@@ -147,7 +133,6 @@ Checkbox.propTypes = {
|
|
|
147
133
|
value: PropTypes.string,
|
|
148
134
|
warning: sharedPropTypes.statusPropType,
|
|
149
135
|
onBlur: PropTypes.func,
|
|
150
|
-
|
|
151
136
|
/** Called with signature `(object, event)` */
|
|
152
137
|
onChange: PropTypes.func,
|
|
153
138
|
onFocus: PropTypes.func,
|