@atlaskit/checkbox 12.3.4 → 12.3.8
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 +27 -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 +121 -75
- package/dist/cjs/index.js +5 -9
- package/dist/cjs/internal/checkbox-icon.js +73 -0
- package/dist/cjs/internal/constants.js +13 -0
- package/dist/cjs/internal/index.js +3 -3
- package/dist/cjs/internal/label-text.js +6 -9
- package/dist/cjs/internal/label.js +87 -25
- package/dist/cjs/internal/required-indicator.js +10 -15
- 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 -15
- package/dist/es2019/internal/required-indicator.js +11 -13
- package/dist/es2019/internal/theme.js +56 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/checkbox.js +121 -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 -21
- package/dist/esm/internal/required-indicator.js +11 -13
- 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 +1 -4
- package/dist/types/internal/label.d.ts +1 -2
- package/dist/types/internal/required-indicator.d.ts +2 -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 +14 -11
- package/dist/cjs/internal/styles.js +0 -85
- package/dist/es2019/internal/styles.js +0 -226
- package/dist/esm/internal/styles.js +0 -72
- package/dist/types/internal/styles.d.ts +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @atlaskit/checkbox
|
|
2
2
|
|
|
3
|
+
## 12.3.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`5d27b03c5cf`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5d27b03c5cf) - Styles have been rewritten in preparation for migration to compiled.
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
|
|
10
|
+
## 12.3.7
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- [`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
|
|
15
|
+
- Updated dependencies
|
|
16
|
+
|
|
17
|
+
## 12.3.6
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
|
|
23
|
+
## 12.3.5
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- [`f460cc7c411`](https://bitbucket.org/atlassian/atlassian-frontend/commits/f460cc7c411) - Builds for this package now pass through a tokens babel plugin, removing runtime invocations of the tokens() function and improving bundle size.
|
|
28
|
+
- Updated dependencies
|
|
29
|
+
|
|
3
30
|
## 12.3.4
|
|
4
31
|
|
|
5
32
|
### 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,61 +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
|
-
|
|
31
|
-
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
26
|
+
var _excluded = ["isChecked", "isDisabled", "isInvalid", "defaultChecked", "isIndeterminate", "size", "onChange", "analyticsContext", "label", "name", "value", "isRequired", "testId"];
|
|
32
27
|
// firefox doesn't handle cmd+click/ctrl+click properly
|
|
33
28
|
var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
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
|
+
}
|
|
45
129
|
}
|
|
46
|
-
|
|
47
|
-
if (isChecked) {
|
|
48
|
-
return (0, _core.jsx)("path", {
|
|
49
|
-
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",
|
|
50
|
-
fill: "inherit"
|
|
51
|
-
});
|
|
52
|
-
} // No icon
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
return null;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
var CheckboxIcon = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
59
|
-
var size = _ref.size,
|
|
60
|
-
isIndeterminate = _ref.isIndeterminate,
|
|
61
|
-
isChecked = _ref.isChecked;
|
|
62
|
-
return (0, _core.jsx)(_svg.default, {
|
|
63
|
-
label: "",
|
|
64
|
-
size: size,
|
|
65
|
-
primaryColor: "var(--checkbox-background-color)",
|
|
66
|
-
secondaryColor: "var(--checkbox-tick-color)"
|
|
67
|
-
}, (0, _core.jsx)("g", {
|
|
68
|
-
fillRule: "evenodd"
|
|
69
|
-
}, (0, _core.jsx)("rect", {
|
|
70
|
-
fill: "currentColor",
|
|
71
|
-
x: "6",
|
|
72
|
-
y: "6",
|
|
73
|
-
width: "12",
|
|
74
|
-
height: "12",
|
|
75
|
-
rx: "2"
|
|
76
|
-
}), getIcon(isIndeterminate, isChecked)));
|
|
77
130
|
});
|
|
78
|
-
|
|
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) {
|
|
79
144
|
var isCheckedProp = props.isChecked,
|
|
80
145
|
_props$isDisabled = props.isDisabled,
|
|
81
146
|
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
|
@@ -90,12 +155,11 @@ var CheckboxWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Checkbox(pro
|
|
|
90
155
|
onChangeProps = props.onChange,
|
|
91
156
|
analyticsContext = props.analyticsContext,
|
|
92
157
|
label = props.label,
|
|
93
|
-
mode = props.mode,
|
|
94
158
|
name = props.name,
|
|
95
159
|
value = props.value,
|
|
96
160
|
isRequired = props.isRequired,
|
|
97
161
|
testId = props.testId,
|
|
98
|
-
rest = (0, _objectWithoutProperties2.default)(props,
|
|
162
|
+
rest = (0, _objectWithoutProperties2.default)(props, _excluded);
|
|
99
163
|
|
|
100
164
|
var _useState = (0, _react.useState)(isCheckedProp !== undefined ? isCheckedProp : defaultChecked),
|
|
101
165
|
_useState2 = (0, _slicedToArray2.default)(_useState, 2),
|
|
@@ -115,7 +179,7 @@ var CheckboxWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Checkbox(pro
|
|
|
115
179
|
analyticsData: analyticsContext,
|
|
116
180
|
componentName: 'checkbox',
|
|
117
181
|
packageName: "@atlaskit/checkbox",
|
|
118
|
-
packageVersion: "12.3.
|
|
182
|
+
packageVersion: "12.3.8"
|
|
119
183
|
});
|
|
120
184
|
var internalRef = (0, _react.useRef)(null);
|
|
121
185
|
var mergedRefs = (0, _mergeRefs.default)([internalRef, ref]); // firefox doesn't properly dispatch events from label to its child input elements
|
|
@@ -129,13 +193,7 @@ var CheckboxWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Checkbox(pro
|
|
|
129
193
|
}; // Use isChecked from the state if it is controlled
|
|
130
194
|
|
|
131
195
|
|
|
132
|
-
var isChecked = isCheckedProp === undefined ? isCheckedState : isCheckedProp;
|
|
133
|
-
// applied to the svg with a sibling selector so we have access
|
|
134
|
-
// to the pseudo-classes of the input
|
|
135
|
-
|
|
136
|
-
var styles = (0, _react.useMemo)(function () {
|
|
137
|
-
return (0, _internal.getCheckboxStyles)(mode);
|
|
138
|
-
}, [mode]);
|
|
196
|
+
var isChecked = isCheckedProp === undefined ? isCheckedState : isCheckedProp;
|
|
139
197
|
return (0, _core.jsx)(_internal.Label, {
|
|
140
198
|
isDisabled: isDisabled,
|
|
141
199
|
testId: testId && "".concat(testId, "--checkbox-label"),
|
|
@@ -148,30 +206,18 @@ var CheckboxWithMode = /*#__PURE__*/(0, _react.forwardRef)(function Checkbox(pro
|
|
|
148
206
|
value: value,
|
|
149
207
|
name: name,
|
|
150
208
|
required: isRequired,
|
|
151
|
-
css:
|
|
209
|
+
css: checkboxStyles,
|
|
152
210
|
onChange: onChangeAnalytics,
|
|
153
211
|
"aria-checked": isIndeterminate ? 'mixed' : isChecked,
|
|
154
212
|
"aria-invalid": isInvalid ? 'true' : undefined,
|
|
155
213
|
"data-testid": testId && "".concat(testId, "--hidden-checkbox"),
|
|
156
214
|
"data-invalid": isInvalid ? 'true' : undefined
|
|
157
|
-
})), (0, _core.jsx)(CheckboxIcon, {
|
|
215
|
+
})), (0, _core.jsx)(_internal.CheckboxIcon, {
|
|
158
216
|
size: size,
|
|
159
217
|
isIndeterminate: isIndeterminate,
|
|
160
218
|
isChecked: isChecked
|
|
161
|
-
}), label && (0, _core.jsx)(_internal.LabelText, null, label, isRequired && (0, _core.jsx)(_internal.RequiredIndicator,
|
|
162
|
-
"aria-hidden": "true"
|
|
163
|
-
})));
|
|
164
|
-
});
|
|
165
|
-
var Checkbox = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function Checkbox(props, ref) {
|
|
166
|
-
return (0, _core.jsx)(_components.default.Consumer, null, function (_ref2) {
|
|
167
|
-
var mode = _ref2.mode;
|
|
168
|
-
return (0, _core.jsx)(CheckboxWithMode, (0, _extends2.default)({}, props, {
|
|
169
|
-
ref: ref,
|
|
170
|
-
mode: mode
|
|
171
|
-
}));
|
|
172
|
-
});
|
|
219
|
+
}), label && (0, _core.jsx)(_internal.LabelText, null, label, isRequired && (0, _core.jsx)(_internal.RequiredIndicator, null)));
|
|
173
220
|
}));
|
|
174
|
-
exports.Checkbox = Checkbox;
|
|
175
221
|
Checkbox.displayName = 'Checkbox';
|
|
176
222
|
var _default = Checkbox;
|
|
177
223
|
exports.default = _default;
|
package/dist/cjs/index.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
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
|
|
7
7
|
});
|
|
8
|
-
Object.defineProperty(exports, "
|
|
8
|
+
Object.defineProperty(exports, "Checkbox", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function get() {
|
|
11
11
|
return _checkbox.default;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
|
-
Object.defineProperty(exports, "
|
|
14
|
+
Object.defineProperty(exports, "default", {
|
|
15
15
|
enumerable: true,
|
|
16
16
|
get: function get() {
|
|
17
|
-
return _checkbox.
|
|
17
|
+
return _checkbox.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,10 +5,10 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
Object.defineProperty(exports, "
|
|
8
|
+
Object.defineProperty(exports, "CheckboxIcon", {
|
|
9
9
|
enumerable: true,
|
|
10
10
|
get: function get() {
|
|
11
|
-
return
|
|
11
|
+
return _checkboxIcon.default;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "Label", {
|
|
@@ -30,7 +30,7 @@ Object.defineProperty(exports, "RequiredIndicator", {
|
|
|
30
30
|
}
|
|
31
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,50 +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");
|
|
16
17
|
|
|
17
|
-
var
|
|
18
|
+
var _theme = _interopRequireDefault(require("./theme"));
|
|
18
19
|
|
|
19
20
|
/** @jsx jsx */
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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,
|
|
35
43
|
|
|
36
|
-
|
|
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
|
+
};
|
|
37
98
|
|
|
38
99
|
function Label(_ref) {
|
|
39
100
|
var children = _ref.children,
|
|
40
101
|
isDisabled = _ref.isDisabled,
|
|
41
102
|
testId = _ref.testId,
|
|
42
103
|
onClick = _ref.onClick;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
104
|
+
|
|
105
|
+
var _useGlobalTheme = (0, _components.useGlobalTheme)(),
|
|
106
|
+
mode = _useGlobalTheme.mode;
|
|
107
|
+
|
|
46
108
|
return (0, _core.jsx)("label", {
|
|
47
|
-
css:
|
|
109
|
+
css: [labelStyles, isDisabled && disabledStyles, mode === 'light' && themeStyles.light, mode === 'dark' && themeStyles.dark],
|
|
48
110
|
"data-testid": testId,
|
|
49
111
|
"data-disabled": isDisabled || undefined,
|
|
50
112
|
onClick: onClick
|
|
@@ -1,30 +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("
|
|
17
|
-
|
|
18
|
-
var _tokens = require("@atlaskit/tokens");
|
|
12
|
+
var _constants = require("./constants");
|
|
19
13
|
|
|
20
14
|
/** @jsx jsx */
|
|
21
|
-
var
|
|
15
|
+
var requiredIndicatorStyles = (0, _core.css)({
|
|
16
|
+
paddingLeft: _constants.gridSize * 0.25,
|
|
17
|
+
color: "var(--ds-text-danger, ".concat(_colors.R500, ")")
|
|
18
|
+
});
|
|
22
19
|
|
|
23
|
-
function RequiredIndicator(
|
|
24
|
-
return (0, _core.jsx)("span",
|
|
25
|
-
css:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
}, props), "*");
|
|
20
|
+
function RequiredIndicator() {
|
|
21
|
+
return (0, _core.jsx)("span", {
|
|
22
|
+
css: requiredIndicatorStyles,
|
|
23
|
+
"aria-hidden": true
|
|
24
|
+
}, "*");
|
|
30
25
|
}
|