@atlaskit/checkbox 12.3.6 → 12.3.9
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/CHANGELOG.md +20 -0
- package/codemods/{12.0.0-lite-mode.ts → 12.0.0-lite-mode.tsx} +1 -1
- package/codemods/__tests__/{12.0.0-lite-mode.ts → 12.0.0-lite-mode.tsx} +0 -0
- package/codemods/migrations/{remove-imports.ts → remove-imports.tsx} +0 -0
- package/codemods/migrations/{remove-props.ts → remove-props.tsx} +0 -0
- package/codemods/migrations/{rename-import.ts → rename-import.tsx} +0 -0
- package/codemods/migrations/{rename-inputRef-to-ref.ts → rename-input-ref-to-ref.tsx} +0 -0
- package/codemods/{utils.ts → utils.tsx} +0 -0
- package/dist/cjs/checkbox.js +120 -73
- package/dist/cjs/index.js +3 -7
- package/dist/cjs/internal/checkbox-icon.js +73 -0
- package/dist/cjs/internal/constants.js +13 -0
- package/dist/cjs/internal/index.js +7 -7
- package/dist/cjs/internal/label-text.js +6 -9
- package/dist/cjs/internal/label.js +88 -24
- package/dist/cjs/internal/required-indicator.js +10 -13
- package/dist/cjs/internal/theme.js +65 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/checkbox.js +119 -66
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/internal/checkbox-icon.js +60 -0
- package/dist/es2019/internal/constants.js +3 -0
- package/dist/es2019/internal/index.js +1 -1
- package/dist/es2019/internal/label-text.js +7 -8
- package/dist/es2019/internal/label.js +82 -14
- package/dist/es2019/internal/required-indicator.js +11 -12
- package/dist/es2019/internal/theme.js +56 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/checkbox.js +120 -71
- package/dist/esm/index.js +1 -1
- package/dist/esm/internal/checkbox-icon.js +61 -0
- package/dist/esm/internal/constants.js +3 -0
- package/dist/esm/internal/index.js +1 -1
- package/dist/esm/internal/label-text.js +7 -8
- package/dist/esm/internal/label.js +85 -20
- package/dist/esm/internal/required-indicator.js +11 -12
- package/dist/esm/internal/theme.js +56 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/checkbox.d.ts +11 -19
- package/dist/types/index.d.ts +1 -1
- package/dist/types/internal/checkbox-icon.d.ts +16 -0
- package/dist/types/internal/constants.d.ts +2 -0
- package/dist/types/internal/index.d.ts +1 -1
- package/dist/types/internal/label-text.d.ts +0 -4
- package/dist/types/internal/label.d.ts +0 -2
- package/dist/types/internal/required-indicator.d.ts +1 -2
- package/dist/types/internal/theme.d.ts +55 -0
- package/dist/types/types.d.ts +51 -63
- package/extract-react-types/checkbox-props.tsx +2 -2
- package/package.json +9 -7
- package/dist/cjs/internal/styles.js +0 -83
- package/dist/es2019/internal/styles.js +0 -225
- package/dist/esm/internal/styles.js +0 -71
- package/dist/types/internal/styles.d.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @atlaskit/checkbox
|
|
2
2
|
|
|
3
|
+
## 12.3.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 12.3.8
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`5d27b03c5cf`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5d27b03c5cf) - Styles have been rewritten in preparation for migration to compiled.
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
|
|
16
|
+
## 12.3.7
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- [`19d72473dfb`](https://bitbucket.org/atlassian/atlassian-frontend/commits/19d72473dfb) - Updates usage of deprecated token names so they're aligned with the latest naming conventions. No UI or visual changes
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
3
23
|
## 12.3.6
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
renameDeepTypeImport,
|
|
10
10
|
renameTypeImport,
|
|
11
11
|
} from './migrations/rename-import';
|
|
12
|
-
import { renameInputRef } from './migrations/rename-
|
|
12
|
+
import { renameInputRef } from './migrations/rename-input-ref-to-ref';
|
|
13
13
|
import { createTransformer } from './utils';
|
|
14
14
|
|
|
15
15
|
const transformer = createTransformer('@atlaskit/checkbox', [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/cjs/checkbox.js
CHANGED
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.default =
|
|
8
|
+
exports.default = void 0;
|
|
9
9
|
|
|
10
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
11
|
|
|
@@ -21,60 +21,126 @@ var _usePlatformLeafEventHandler = require("@atlaskit/analytics-next/usePlatform
|
|
|
21
21
|
|
|
22
22
|
var _mergeRefs = _interopRequireDefault(require("@atlaskit/ds-lib/merge-refs"));
|
|
23
23
|
|
|
24
|
-
var _svg = _interopRequireDefault(require("@atlaskit/icon/svg"));
|
|
25
|
-
|
|
26
|
-
var _components = _interopRequireDefault(require("@atlaskit/theme/components"));
|
|
27
|
-
|
|
28
24
|
var _internal = require("./internal");
|
|
29
25
|
|
|
30
|
-
var _excluded = ["isChecked", "isDisabled", "isInvalid", "defaultChecked", "isIndeterminate", "size", "onChange", "analyticsContext", "label", "
|
|
26
|
+
var _excluded = ["isChecked", "isDisabled", "isInvalid", "defaultChecked", "isIndeterminate", "size", "onChange", "analyticsContext", "label", "name", "value", "isRequired", "testId"];
|
|
31
27
|
// firefox doesn't handle cmd+click/ctrl+click properly
|
|
32
28
|
var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
29
|
+
/* eslint-disable @repo/internal/styles/no-nested-styles */
|
|
30
|
+
|
|
31
|
+
var checkboxStyles = (0, _core.css)({
|
|
32
|
+
width: 0,
|
|
33
|
+
// Necessary to hide correctly on mobile Safari
|
|
34
|
+
height: 0,
|
|
35
|
+
// Necessary to hide correctly on mobile Safari
|
|
36
|
+
margin: 0,
|
|
37
|
+
appearance: 'none',
|
|
38
|
+
border: 'none',
|
|
39
|
+
// Necessary to hide correctly on mobile Safari
|
|
40
|
+
outline: 'none',
|
|
41
|
+
// Necessary to hide focus ring on Firefox
|
|
42
|
+
'& + svg': {
|
|
43
|
+
flexShrink: 0,
|
|
44
|
+
alignSelf: 'flex-start',
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Change the variables --checkbox-background-color, --checkbox-border-color
|
|
48
|
+
* and --checkbox-tick-color according to user interactions.
|
|
49
|
+
* All other variables are constant.
|
|
50
|
+
* All styles from the input target the sibling svg.
|
|
51
|
+
*/
|
|
52
|
+
'--checkbox-background-color': 'var(--local-background)',
|
|
53
|
+
'--checkbox-border-color': 'var(--local-border)',
|
|
54
|
+
'--checkbox-tick-color': 'var(--local-tick-rest)',
|
|
55
|
+
color: 'var(--checkbox-background-color)',
|
|
56
|
+
fill: 'var(--checkbox-tick-color)',
|
|
57
|
+
transition: 'color 0.2s ease-in-out, fill 0.2s ease-in-out',
|
|
58
|
+
'rect:first-of-type': {
|
|
59
|
+
stroke: 'var(--checkbox-border-color)',
|
|
60
|
+
strokeWidth: 2,
|
|
61
|
+
transition: 'stroke 0.2s ease-in-out'
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
'&&:focus + svg, &&:checked:focus + svg': {
|
|
65
|
+
'--checkbox-border-color': 'var(--local-border-focus)'
|
|
66
|
+
},
|
|
67
|
+
'&:hover + svg': {
|
|
68
|
+
'--checkbox-background-color': 'var(--local-background-hover)',
|
|
69
|
+
'--checkbox-border-color': 'var(--local-border-hover)'
|
|
70
|
+
},
|
|
71
|
+
'&:checked:hover + svg': {
|
|
72
|
+
'--checkbox-background-color': 'var(--local-background-checked-hover)',
|
|
73
|
+
'--checkbox-border-color': 'var(--local-border-checked-hover)'
|
|
74
|
+
},
|
|
75
|
+
'&:checked + svg': {
|
|
76
|
+
'--checkbox-background-color': 'var(--local-background-checked)',
|
|
77
|
+
'--checkbox-border-color': 'var(--local-border-checked)',
|
|
78
|
+
'--checkbox-tick-color': 'var(--local-tick-checked)'
|
|
79
|
+
},
|
|
80
|
+
'&[data-invalid] + svg': {
|
|
81
|
+
'--checkbox-border-color': 'var(--local-border-invalid)'
|
|
82
|
+
},
|
|
83
|
+
'&:checked[data-invalid] + svg': {
|
|
84
|
+
'--checkbox-border-color': 'var(--local-border-checked-invalid)'
|
|
85
|
+
},
|
|
86
|
+
'&:active + svg': {
|
|
87
|
+
'--checkbox-background-color': 'var(--local-background-active)',
|
|
88
|
+
'--checkbox-border-color': 'var(--local-border-active)'
|
|
89
|
+
},
|
|
90
|
+
'&:checked:active + svg': {
|
|
91
|
+
'--checkbox-background-color': 'var(--local-background-active)',
|
|
92
|
+
'--checkbox-border-color': 'var(--local-border-active)',
|
|
93
|
+
'--checkbox-tick-color': 'var(--local-tick-active)'
|
|
94
|
+
},
|
|
95
|
+
'&:disabled + svg, &:disabled:hover + svg, &:disabled:focus + svg, &:disabled:active + svg, &:disabled[data-invalid] + svg': {
|
|
96
|
+
'--checkbox-background-color': 'var(--local-background-disabled)',
|
|
97
|
+
'--checkbox-border-color': 'var(--local-border-disabled)',
|
|
98
|
+
cursor: 'not-allowed',
|
|
99
|
+
pointerEvents: 'none'
|
|
100
|
+
},
|
|
101
|
+
'&:disabled:checked + svg': {
|
|
102
|
+
'--checkbox-tick-color': 'var(--local-tick-disabled)'
|
|
103
|
+
},
|
|
104
|
+
'@media screen and (forced-colors: active)': {
|
|
105
|
+
'& + svg': {
|
|
106
|
+
'--checkbox-background-color': 'Canvas',
|
|
107
|
+
'--checkbox-border-color': 'CanvasText',
|
|
108
|
+
'--checkbox-tick-color': 'CanvasText'
|
|
109
|
+
},
|
|
110
|
+
'&:checked + svg, &:checked:hover + svg': {
|
|
111
|
+
'--checkbox-background-color': 'Canvas',
|
|
112
|
+
'--checkbox-border-color': 'CanvasText',
|
|
113
|
+
'--checkbox-tick-color': 'CanvasText'
|
|
114
|
+
},
|
|
115
|
+
'&:focus + svg rect:first-of-type': {
|
|
116
|
+
stroke: 'Highlight'
|
|
117
|
+
},
|
|
118
|
+
'&[data-invalid] + svg': {
|
|
119
|
+
'--checkbox-border-color': 'Highlight'
|
|
120
|
+
},
|
|
121
|
+
'&:checked[data-invalid] + svg': {
|
|
122
|
+
'--checkbox-border-color': 'Highlight'
|
|
123
|
+
},
|
|
124
|
+
'&:disabled + svg, &:disabled:hover + svg, &:disabled:focus + svg, &:disabled:active + svg, &:disabled[data-invalid] + svg': {
|
|
125
|
+
'--checkbox-background-color': 'Canvas',
|
|
126
|
+
'--checkbox-border-color': 'GrayText',
|
|
127
|
+
'--checkbox-tick-color': 'GrayText'
|
|
128
|
+
}
|
|
44
129
|
}
|
|
45
|
-
|
|
46
|
-
if (isChecked) {
|
|
47
|
-
return (0, _core.jsx)("path", {
|
|
48
|
-
d: "M9.707 11.293a1 1 0 1 0-1.414 1.414l2 2a1 1 0 0 0 1.414 0l4-4a1 1 0 1 0-1.414-1.414L11 12.586l-1.293-1.293z",
|
|
49
|
-
fill: "inherit"
|
|
50
|
-
});
|
|
51
|
-
} // No icon
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
var CheckboxIcon = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
58
|
-
var size = _ref.size,
|
|
59
|
-
isIndeterminate = _ref.isIndeterminate,
|
|
60
|
-
isChecked = _ref.isChecked;
|
|
61
|
-
return (0, _core.jsx)(_svg.default, {
|
|
62
|
-
label: "",
|
|
63
|
-
size: size,
|
|
64
|
-
primaryColor: "var(--checkbox-background-color)",
|
|
65
|
-
secondaryColor: "var(--checkbox-tick-color)"
|
|
66
|
-
}, (0, _core.jsx)("g", {
|
|
67
|
-
fillRule: "evenodd"
|
|
68
|
-
}, (0, _core.jsx)("rect", {
|
|
69
|
-
fill: "currentColor",
|
|
70
|
-
x: "6",
|
|
71
|
-
y: "6",
|
|
72
|
-
width: "12",
|
|
73
|
-
height: "12",
|
|
74
|
-
rx: "2"
|
|
75
|
-
}), getIcon(isIndeterminate, isChecked)));
|
|
76
130
|
});
|
|
77
|
-
|
|
131
|
+
/* eslint-enable @repo/internal/styles/no-nested-styles */
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* __Checkbox__
|
|
135
|
+
*
|
|
136
|
+
* A checkbox an input control that allows a user to select one or more options from a number of choices.
|
|
137
|
+
*
|
|
138
|
+
* - [Examples](https://atlassian.design/components/checkbox/examples)
|
|
139
|
+
* - [Code](https://atlassian.design/components/checkbox/code)
|
|
140
|
+
* - [Usage](https://atlassian.design/components/checkbox/usage)
|
|
141
|
+
*/
|
|
142
|
+
|
|
143
|
+
var Checkbox = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function Checkbox(props, ref) {
|
|
78
144
|
var isCheckedProp = props.isChecked,
|
|
79
145
|
_props$isDisabled = props.isDisabled,
|
|
80
146
|
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
|
@@ -89,7 +155,6 @@ var CheckboxWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Checkbox(pro
|
|
|
89
155
|
onChangeProps = props.onChange,
|
|
90
156
|
analyticsContext = props.analyticsContext,
|
|
91
157
|
label = props.label,
|
|
92
|
-
mode = props.mode,
|
|
93
158
|
name = props.name,
|
|
94
159
|
value = props.value,
|
|
95
160
|
isRequired = props.isRequired,
|
|
@@ -114,7 +179,7 @@ var CheckboxWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Checkbox(pro
|
|
|
114
179
|
analyticsData: analyticsContext,
|
|
115
180
|
componentName: 'checkbox',
|
|
116
181
|
packageName: "@atlaskit/checkbox",
|
|
117
|
-
packageVersion: "12.3.
|
|
182
|
+
packageVersion: "12.3.9"
|
|
118
183
|
});
|
|
119
184
|
var internalRef = (0, _react.useRef)(null);
|
|
120
185
|
var mergedRefs = (0, _mergeRefs.default)([internalRef, ref]); // firefox doesn't properly dispatch events from label to its child input elements
|
|
@@ -128,13 +193,7 @@ var CheckboxWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Checkbox(pro
|
|
|
128
193
|
}; // Use isChecked from the state if it is controlled
|
|
129
194
|
|
|
130
195
|
|
|
131
|
-
var isChecked = isCheckedProp === undefined ? isCheckedState : isCheckedProp;
|
|
132
|
-
// applied to the svg with a sibling selector so we have access
|
|
133
|
-
// to the pseudo-classes of the input
|
|
134
|
-
|
|
135
|
-
var styles = (0, _react.useMemo)(function () {
|
|
136
|
-
return (0, _internal.getCheckboxStyles)(mode);
|
|
137
|
-
}, [mode]);
|
|
196
|
+
var isChecked = isCheckedProp === undefined ? isCheckedState : isCheckedProp;
|
|
138
197
|
return (0, _core.jsx)(_internal.Label, {
|
|
139
198
|
isDisabled: isDisabled,
|
|
140
199
|
testId: testId && "".concat(testId, "--checkbox-label"),
|
|
@@ -147,30 +206,18 @@ var CheckboxWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Checkbox(pro
|
|
|
147
206
|
value: value,
|
|
148
207
|
name: name,
|
|
149
208
|
required: isRequired,
|
|
150
|
-
css:
|
|
209
|
+
css: checkboxStyles,
|
|
151
210
|
onChange: onChangeAnalytics,
|
|
152
211
|
"aria-checked": isIndeterminate ? 'mixed' : isChecked,
|
|
153
212
|
"aria-invalid": isInvalid ? 'true' : undefined,
|
|
154
213
|
"data-testid": testId && "".concat(testId, "--hidden-checkbox"),
|
|
155
214
|
"data-invalid": isInvalid ? 'true' : undefined
|
|
156
|
-
})), (0, _core.jsx)(CheckboxIcon, {
|
|
215
|
+
})), (0, _core.jsx)(_internal.CheckboxIcon, {
|
|
157
216
|
size: size,
|
|
158
217
|
isIndeterminate: isIndeterminate,
|
|
159
218
|
isChecked: isChecked
|
|
160
|
-
}), label && (0, _core.jsx)(_internal.LabelText, null, label, isRequired && (0, _core.jsx)(_internal.RequiredIndicator,
|
|
161
|
-
"aria-hidden": "true"
|
|
162
|
-
})));
|
|
163
|
-
});
|
|
164
|
-
var Checkbox = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function Checkbox(props, ref) {
|
|
165
|
-
return (0, _core.jsx)(_components.default.Consumer, null, function (_ref2) {
|
|
166
|
-
var mode = _ref2.mode;
|
|
167
|
-
return (0, _core.jsx)(CheckboxWithMode, (0, _extends2.default)({}, props, {
|
|
168
|
-
ref: ref,
|
|
169
|
-
mode: mode
|
|
170
|
-
}));
|
|
171
|
-
});
|
|
219
|
+
}), label && (0, _core.jsx)(_internal.LabelText, null, label, isRequired && (0, _core.jsx)(_internal.RequiredIndicator, null)));
|
|
172
220
|
}));
|
|
173
|
-
exports.Checkbox = Checkbox;
|
|
174
221
|
Checkbox.displayName = 'Checkbox';
|
|
175
222
|
var _default = Checkbox;
|
|
176
223
|
exports.default = _default;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
@@ -8,7 +8,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
8
|
Object.defineProperty(exports, "Checkbox", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function get() {
|
|
11
|
-
return _checkbox.
|
|
11
|
+
return _checkbox.default;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "default", {
|
|
@@ -18,8 +18,4 @@ Object.defineProperty(exports, "default", {
|
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
var _checkbox =
|
|
22
|
-
|
|
23
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
|
-
|
|
25
|
-
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; }
|
|
21
|
+
var _checkbox = _interopRequireDefault(require("./checkbox"));
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
|
|
12
|
+
var _core = require("@emotion/core");
|
|
13
|
+
|
|
14
|
+
var _svg = _interopRequireDefault(require("@atlaskit/icon/svg"));
|
|
15
|
+
|
|
16
|
+
/** @jsx jsx */
|
|
17
|
+
function getIcon(isIndeterminate, isChecked) {
|
|
18
|
+
if (isIndeterminate) {
|
|
19
|
+
return (0, _core.jsx)("rect", {
|
|
20
|
+
fill: "inherit",
|
|
21
|
+
x: "8",
|
|
22
|
+
y: "11",
|
|
23
|
+
width: "8",
|
|
24
|
+
height: "2",
|
|
25
|
+
rx: "1"
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (isChecked) {
|
|
30
|
+
return (0, _core.jsx)("path", {
|
|
31
|
+
d: "M9.707 11.293a1 1 0 1 0-1.414 1.414l2 2a1 1 0 0 0 1.414 0l4-4a1 1 0 1 0-1.414-1.414L11 12.586l-1.293-1.293z",
|
|
32
|
+
fill: "inherit"
|
|
33
|
+
});
|
|
34
|
+
} // No icon
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
return null;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* __Checkbox icon__
|
|
41
|
+
*
|
|
42
|
+
* A checkbox icon is the visual representation of checkbox state,
|
|
43
|
+
* which is shown instead of the native input.
|
|
44
|
+
*
|
|
45
|
+
* @internal
|
|
46
|
+
*/
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
var CheckboxIcon = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
50
|
+
var size = _ref.size,
|
|
51
|
+
isIndeterminate = _ref.isIndeterminate,
|
|
52
|
+
isChecked = _ref.isChecked;
|
|
53
|
+
var icon = (0, _react.useMemo)(function () {
|
|
54
|
+
return getIcon(isIndeterminate, isChecked);
|
|
55
|
+
}, [isIndeterminate, isChecked]);
|
|
56
|
+
return (0, _core.jsx)(_svg.default, {
|
|
57
|
+
label: "",
|
|
58
|
+
size: size,
|
|
59
|
+
primaryColor: "var(--checkbox-background-color)",
|
|
60
|
+
secondaryColor: "var(--checkbox-tick-color)"
|
|
61
|
+
}, (0, _core.jsx)("g", {
|
|
62
|
+
fillRule: "evenodd"
|
|
63
|
+
}, (0, _core.jsx)("rect", {
|
|
64
|
+
fill: "currentColor",
|
|
65
|
+
x: "6",
|
|
66
|
+
y: "6",
|
|
67
|
+
width: "12",
|
|
68
|
+
height: "12",
|
|
69
|
+
rx: "2"
|
|
70
|
+
}), icon));
|
|
71
|
+
});
|
|
72
|
+
var _default = CheckboxIcon;
|
|
73
|
+
exports.default = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.gridSize = exports.fontFamily = void 0;
|
|
7
|
+
|
|
8
|
+
var _constants = require("@atlaskit/theme/constants");
|
|
9
|
+
|
|
10
|
+
var fontFamily = (0, _constants.fontFamily)();
|
|
11
|
+
exports.fontFamily = fontFamily;
|
|
12
|
+
var gridSize = (0, _constants.gridSize)();
|
|
13
|
+
exports.gridSize = gridSize;
|
|
@@ -5,6 +5,12 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
+
Object.defineProperty(exports, "CheckboxIcon", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _checkboxIcon.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
8
14
|
Object.defineProperty(exports, "Label", {
|
|
9
15
|
enumerable: true,
|
|
10
16
|
get: function get() {
|
|
@@ -23,14 +29,8 @@ Object.defineProperty(exports, "RequiredIndicator", {
|
|
|
23
29
|
return _requiredIndicator.default;
|
|
24
30
|
}
|
|
25
31
|
});
|
|
26
|
-
Object.defineProperty(exports, "getCheckboxStyles", {
|
|
27
|
-
enumerable: true,
|
|
28
|
-
get: function get() {
|
|
29
|
-
return _styles.default;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
32
|
|
|
33
|
-
var
|
|
33
|
+
var _checkboxIcon = _interopRequireDefault(require("./checkbox-icon"));
|
|
34
34
|
|
|
35
35
|
var _label = _interopRequireDefault(require("./label"));
|
|
36
36
|
|
|
@@ -4,23 +4,20 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = LabelText;
|
|
7
|
-
exports.labelTextCSS = void 0;
|
|
8
7
|
|
|
9
8
|
var _core = require("@emotion/core");
|
|
10
9
|
|
|
11
|
-
var _constants = require("
|
|
10
|
+
var _constants = require("./constants");
|
|
12
11
|
|
|
13
12
|
/** @jsx jsx */
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
exports.labelTextCSS = labelTextCSS;
|
|
13
|
+
var labelTextStyles = (0, _core.css)({
|
|
14
|
+
paddingRight: 0.5 * _constants.gridSize,
|
|
15
|
+
paddingLeft: 0.5 * _constants.gridSize
|
|
16
|
+
});
|
|
20
17
|
|
|
21
18
|
function LabelText(_ref) {
|
|
22
19
|
var children = _ref.children;
|
|
23
20
|
return (0, _core.jsx)("span", {
|
|
24
|
-
css:
|
|
21
|
+
css: labelTextStyles
|
|
25
22
|
}, children);
|
|
26
23
|
}
|
|
@@ -1,48 +1,112 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
Object.defineProperty(exports, "__esModule", {
|
|
4
6
|
value: true
|
|
5
7
|
});
|
|
6
8
|
exports.default = Label;
|
|
7
|
-
exports.labelCSS = void 0;
|
|
8
|
-
|
|
9
|
-
var _react = require("react");
|
|
10
9
|
|
|
11
10
|
var _core = require("@emotion/core");
|
|
12
11
|
|
|
13
12
|
var _colors = require("@atlaskit/theme/colors");
|
|
14
13
|
|
|
15
|
-
var
|
|
14
|
+
var _components = require("@atlaskit/theme/components");
|
|
15
|
+
|
|
16
|
+
var _constants = require("./constants");
|
|
17
|
+
|
|
18
|
+
var _theme = _interopRequireDefault(require("./theme"));
|
|
16
19
|
|
|
17
20
|
/** @jsx jsx */
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
var labelStyles = (0, _core.css)({
|
|
22
|
+
display: 'flex',
|
|
23
|
+
alignItems: 'center',
|
|
24
|
+
color: "var(--ds-text, ".concat(_colors.N900, ")"),
|
|
25
|
+
cursor: 'default',
|
|
26
|
+
fontFamily: _constants.fontFamily
|
|
27
|
+
});
|
|
28
|
+
var disabledStyles = (0, _core.css)({
|
|
29
|
+
color: "var(--ds-text-disabled, ".concat(_colors.N80, ")"),
|
|
30
|
+
cursor: 'not-allowed'
|
|
31
|
+
});
|
|
32
|
+
var themeStyles = {
|
|
33
|
+
light: (0, _core.css)({
|
|
34
|
+
/**
|
|
35
|
+
* Background
|
|
36
|
+
*/
|
|
37
|
+
'--local-background': _theme.default.light.boxColor.rest,
|
|
38
|
+
'--local-background-active': _theme.default.light.boxColor.active,
|
|
39
|
+
'--local-background-checked': _theme.default.light.boxColor.checked,
|
|
40
|
+
'--local-background-checked-hover': _theme.default.light.boxColor.hoveredAndChecked,
|
|
41
|
+
'--local-background-disabled': _theme.default.light.boxColor.disabled,
|
|
42
|
+
'--local-background-hover': _theme.default.light.boxColor.hovered,
|
|
33
43
|
|
|
34
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Border
|
|
46
|
+
*/
|
|
47
|
+
'--local-border': _theme.default.light.borderColor.rest,
|
|
48
|
+
'--local-border-active': _theme.default.light.borderColor.active,
|
|
49
|
+
'--local-border-checked': _theme.default.light.borderColor.checked,
|
|
50
|
+
'--local-border-checked-hover': _theme.default.light.borderColor.hoveredAndChecked,
|
|
51
|
+
'--local-border-checked-invalid': _theme.default.light.borderColor.invalidAndChecked,
|
|
52
|
+
'--local-border-disabled': _theme.default.light.borderColor.disabled,
|
|
53
|
+
'--local-border-focus': _theme.default.light.borderColor.focused,
|
|
54
|
+
'--local-border-hover': _theme.default.light.borderColor.hovered,
|
|
55
|
+
'--local-border-invalid': _theme.default.light.borderColor.invalid,
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Tick
|
|
59
|
+
*/
|
|
60
|
+
'--local-tick-active': _theme.default.light.tickColor.activeAndChecked,
|
|
61
|
+
'--local-tick-checked': _theme.default.light.tickColor.checked,
|
|
62
|
+
'--local-tick-disabled': _theme.default.light.tickColor.disabledAndChecked,
|
|
63
|
+
'--local-tick-rest': 'transparent'
|
|
64
|
+
}),
|
|
65
|
+
dark: (0, _core.css)({
|
|
66
|
+
/**
|
|
67
|
+
* Background
|
|
68
|
+
*/
|
|
69
|
+
'--local-background': _theme.default.dark.boxColor.rest,
|
|
70
|
+
'--local-background-active': _theme.default.dark.boxColor.active,
|
|
71
|
+
'--local-background-checked': _theme.default.dark.boxColor.checked,
|
|
72
|
+
'--local-background-checked-hover': _theme.default.dark.boxColor.hoveredAndChecked,
|
|
73
|
+
'--local-background-disabled': _theme.default.dark.boxColor.disabled,
|
|
74
|
+
'--local-background-hover': _theme.default.dark.boxColor.hovered,
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Border
|
|
78
|
+
*/
|
|
79
|
+
'--local-border': _theme.default.dark.borderColor.rest,
|
|
80
|
+
'--local-border-active': _theme.default.dark.borderColor.active,
|
|
81
|
+
'--local-border-checked': _theme.default.dark.borderColor.checked,
|
|
82
|
+
'--local-border-checked-hover': _theme.default.dark.borderColor.hoveredAndChecked,
|
|
83
|
+
'--local-border-checked-invalid': _theme.default.dark.borderColor.invalidAndChecked,
|
|
84
|
+
'--local-border-disabled': _theme.default.dark.borderColor.disabled,
|
|
85
|
+
'--local-border-focus': _theme.default.dark.borderColor.focused,
|
|
86
|
+
'--local-border-hover': _theme.default.dark.borderColor.hovered,
|
|
87
|
+
'--local-border-invalid': _theme.default.dark.borderColor.invalid,
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Tick
|
|
91
|
+
*/
|
|
92
|
+
'--local-tick-active': _theme.default.dark.tickColor.activeAndChecked,
|
|
93
|
+
'--local-tick-checked': _theme.default.dark.tickColor.checked,
|
|
94
|
+
'--local-tick-disabled': _theme.default.dark.tickColor.disabledAndChecked,
|
|
95
|
+
'--local-tick-rest': 'transparent'
|
|
96
|
+
})
|
|
97
|
+
};
|
|
35
98
|
|
|
36
99
|
function Label(_ref) {
|
|
37
100
|
var children = _ref.children,
|
|
38
101
|
isDisabled = _ref.isDisabled,
|
|
39
102
|
testId = _ref.testId,
|
|
40
103
|
onClick = _ref.onClick;
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
104
|
+
|
|
105
|
+
var _useGlobalTheme = (0, _components.useGlobalTheme)(),
|
|
106
|
+
mode = _useGlobalTheme.mode;
|
|
107
|
+
|
|
44
108
|
return (0, _core.jsx)("label", {
|
|
45
|
-
css:
|
|
109
|
+
css: [labelStyles, isDisabled && disabledStyles, mode === 'light' && themeStyles.light, mode === 'dark' && themeStyles.dark],
|
|
46
110
|
"data-testid": testId,
|
|
47
111
|
"data-disabled": isDisabled || undefined,
|
|
48
112
|
onClick: onClick
|
|
@@ -1,28 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
3
|
Object.defineProperty(exports, "__esModule", {
|
|
6
4
|
value: true
|
|
7
5
|
});
|
|
8
6
|
exports.default = RequiredIndicator;
|
|
9
7
|
|
|
10
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
-
|
|
12
8
|
var _core = require("@emotion/core");
|
|
13
9
|
|
|
14
10
|
var _colors = require("@atlaskit/theme/colors");
|
|
15
11
|
|
|
16
|
-
var _constants = require("
|
|
12
|
+
var _constants = require("./constants");
|
|
17
13
|
|
|
18
14
|
/** @jsx jsx */
|
|
19
|
-
var
|
|
15
|
+
var requiredIndicatorStyles = (0, _core.css)({
|
|
16
|
+
paddingLeft: _constants.gridSize * 0.25,
|
|
17
|
+
color: "var(--ds-text-danger, ".concat(_colors.R500, ")")
|
|
18
|
+
});
|
|
20
19
|
|
|
21
|
-
function RequiredIndicator(
|
|
22
|
-
return (0, _core.jsx)("span",
|
|
23
|
-
css:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
}, props), "*");
|
|
20
|
+
function RequiredIndicator() {
|
|
21
|
+
return (0, _core.jsx)("span", {
|
|
22
|
+
css: requiredIndicatorStyles,
|
|
23
|
+
"aria-hidden": true
|
|
24
|
+
}, "*");
|
|
28
25
|
}
|