@atlaskit/checkbox 12.3.7 → 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 +7 -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 +81 -13
- 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 +7 -5
- 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/dist/esm/checkbox.js
CHANGED
|
@@ -1,64 +1,131 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
-
var _excluded = ["isChecked", "isDisabled", "isInvalid", "defaultChecked", "isIndeterminate", "size", "onChange", "analyticsContext", "label", "
|
|
4
|
+
var _excluded = ["isChecked", "isDisabled", "isInvalid", "defaultChecked", "isIndeterminate", "size", "onChange", "analyticsContext", "label", "name", "value", "isRequired", "testId"];
|
|
5
5
|
|
|
6
6
|
/** @jsx jsx */
|
|
7
|
-
import { forwardRef, memo, useCallback,
|
|
8
|
-
import { jsx } from '@emotion/core';
|
|
7
|
+
import { forwardRef, memo, useCallback, useRef, useState } from 'react';
|
|
8
|
+
import { css, jsx } from '@emotion/core';
|
|
9
9
|
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatformLeafEventHandler';
|
|
10
|
-
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
11
|
-
|
|
12
|
-
import PrimitiveSVGIcon from '@atlaskit/icon/svg';
|
|
13
|
-
import GlobalTheme from '@atlaskit/theme/components';
|
|
14
|
-
import { getCheckboxStyles, Label, LabelText, RequiredIndicator } from './internal';
|
|
10
|
+
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
11
|
+
import { CheckboxIcon, Label, LabelText, RequiredIndicator } from './internal';
|
|
15
12
|
// firefox doesn't handle cmd+click/ctrl+click properly
|
|
16
13
|
var isFirefox = typeof navigator !== 'undefined' && navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
|
14
|
+
/* eslint-disable @repo/internal/styles/no-nested-styles */
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
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",
|
|
33
|
-
fill: "inherit"
|
|
34
|
-
});
|
|
35
|
-
} // No icon
|
|
16
|
+
var checkboxStyles = css({
|
|
17
|
+
width: 0,
|
|
18
|
+
// Necessary to hide correctly on mobile Safari
|
|
19
|
+
height: 0,
|
|
20
|
+
// Necessary to hide correctly on mobile Safari
|
|
21
|
+
margin: 0,
|
|
22
|
+
appearance: 'none',
|
|
23
|
+
border: 'none',
|
|
24
|
+
// Necessary to hide correctly on mobile Safari
|
|
25
|
+
outline: 'none',
|
|
26
|
+
// Necessary to hide focus ring on Firefox
|
|
27
|
+
'& + svg': {
|
|
28
|
+
flexShrink: 0,
|
|
29
|
+
alignSelf: 'flex-start',
|
|
36
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Change the variables --checkbox-background-color, --checkbox-border-color
|
|
33
|
+
* and --checkbox-tick-color according to user interactions.
|
|
34
|
+
* All other variables are constant.
|
|
35
|
+
* All styles from the input target the sibling svg.
|
|
36
|
+
*/
|
|
37
|
+
'--checkbox-background-color': 'var(--local-background)',
|
|
38
|
+
'--checkbox-border-color': 'var(--local-border)',
|
|
39
|
+
'--checkbox-tick-color': 'var(--local-tick-rest)',
|
|
40
|
+
color: 'var(--checkbox-background-color)',
|
|
41
|
+
fill: 'var(--checkbox-tick-color)',
|
|
42
|
+
transition: 'color 0.2s ease-in-out, fill 0.2s ease-in-out',
|
|
43
|
+
'rect:first-of-type': {
|
|
44
|
+
stroke: 'var(--checkbox-border-color)',
|
|
45
|
+
strokeWidth: 2,
|
|
46
|
+
transition: 'stroke 0.2s ease-in-out'
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
'&&:focus + svg, &&:checked:focus + svg': {
|
|
50
|
+
'--checkbox-border-color': 'var(--local-border-focus)'
|
|
51
|
+
},
|
|
52
|
+
'&:hover + svg': {
|
|
53
|
+
'--checkbox-background-color': 'var(--local-background-hover)',
|
|
54
|
+
'--checkbox-border-color': 'var(--local-border-hover)'
|
|
55
|
+
},
|
|
56
|
+
'&:checked:hover + svg': {
|
|
57
|
+
'--checkbox-background-color': 'var(--local-background-checked-hover)',
|
|
58
|
+
'--checkbox-border-color': 'var(--local-border-checked-hover)'
|
|
59
|
+
},
|
|
60
|
+
'&:checked + svg': {
|
|
61
|
+
'--checkbox-background-color': 'var(--local-background-checked)',
|
|
62
|
+
'--checkbox-border-color': 'var(--local-border-checked)',
|
|
63
|
+
'--checkbox-tick-color': 'var(--local-tick-checked)'
|
|
64
|
+
},
|
|
65
|
+
'&[data-invalid] + svg': {
|
|
66
|
+
'--checkbox-border-color': 'var(--local-border-invalid)'
|
|
67
|
+
},
|
|
68
|
+
'&:checked[data-invalid] + svg': {
|
|
69
|
+
'--checkbox-border-color': 'var(--local-border-checked-invalid)'
|
|
70
|
+
},
|
|
71
|
+
'&:active + svg': {
|
|
72
|
+
'--checkbox-background-color': 'var(--local-background-active)',
|
|
73
|
+
'--checkbox-border-color': 'var(--local-border-active)'
|
|
74
|
+
},
|
|
75
|
+
'&:checked:active + svg': {
|
|
76
|
+
'--checkbox-background-color': 'var(--local-background-active)',
|
|
77
|
+
'--checkbox-border-color': 'var(--local-border-active)',
|
|
78
|
+
'--checkbox-tick-color': 'var(--local-tick-active)'
|
|
79
|
+
},
|
|
80
|
+
'&:disabled + svg, &:disabled:hover + svg, &:disabled:focus + svg, &:disabled:active + svg, &:disabled[data-invalid] + svg': {
|
|
81
|
+
'--checkbox-background-color': 'var(--local-background-disabled)',
|
|
82
|
+
'--checkbox-border-color': 'var(--local-border-disabled)',
|
|
83
|
+
cursor: 'not-allowed',
|
|
84
|
+
pointerEvents: 'none'
|
|
85
|
+
},
|
|
86
|
+
'&:disabled:checked + svg': {
|
|
87
|
+
'--checkbox-tick-color': 'var(--local-tick-disabled)'
|
|
88
|
+
},
|
|
89
|
+
'@media screen and (forced-colors: active)': {
|
|
90
|
+
'& + svg': {
|
|
91
|
+
'--checkbox-background-color': 'Canvas',
|
|
92
|
+
'--checkbox-border-color': 'CanvasText',
|
|
93
|
+
'--checkbox-tick-color': 'CanvasText'
|
|
94
|
+
},
|
|
95
|
+
'&:checked + svg, &:checked:hover + svg': {
|
|
96
|
+
'--checkbox-background-color': 'Canvas',
|
|
97
|
+
'--checkbox-border-color': 'CanvasText',
|
|
98
|
+
'--checkbox-tick-color': 'CanvasText'
|
|
99
|
+
},
|
|
100
|
+
'&:focus + svg rect:first-of-type': {
|
|
101
|
+
stroke: 'Highlight'
|
|
102
|
+
},
|
|
103
|
+
'&[data-invalid] + svg': {
|
|
104
|
+
'--checkbox-border-color': 'Highlight'
|
|
105
|
+
},
|
|
106
|
+
'&:checked[data-invalid] + svg': {
|
|
107
|
+
'--checkbox-border-color': 'Highlight'
|
|
108
|
+
},
|
|
109
|
+
'&:disabled + svg, &:disabled:hover + svg, &:disabled:focus + svg, &:disabled:active + svg, &:disabled[data-invalid] + svg': {
|
|
110
|
+
'--checkbox-background-color': 'Canvas',
|
|
111
|
+
'--checkbox-border-color': 'GrayText',
|
|
112
|
+
'--checkbox-tick-color': 'GrayText'
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
/* eslint-enable @repo/internal/styles/no-nested-styles */
|
|
37
117
|
|
|
38
|
-
|
|
39
|
-
|
|
118
|
+
/**
|
|
119
|
+
* __Checkbox__
|
|
120
|
+
*
|
|
121
|
+
* A checkbox an input control that allows a user to select one or more options from a number of choices.
|
|
122
|
+
*
|
|
123
|
+
* - [Examples](https://atlassian.design/components/checkbox/examples)
|
|
124
|
+
* - [Code](https://atlassian.design/components/checkbox/code)
|
|
125
|
+
* - [Usage](https://atlassian.design/components/checkbox/usage)
|
|
126
|
+
*/
|
|
40
127
|
|
|
41
|
-
var
|
|
42
|
-
var size = _ref.size,
|
|
43
|
-
isIndeterminate = _ref.isIndeterminate,
|
|
44
|
-
isChecked = _ref.isChecked;
|
|
45
|
-
return jsx(PrimitiveSVGIcon, {
|
|
46
|
-
label: "",
|
|
47
|
-
size: size,
|
|
48
|
-
primaryColor: "var(--checkbox-background-color)",
|
|
49
|
-
secondaryColor: "var(--checkbox-tick-color)"
|
|
50
|
-
}, jsx("g", {
|
|
51
|
-
fillRule: "evenodd"
|
|
52
|
-
}, jsx("rect", {
|
|
53
|
-
fill: "currentColor",
|
|
54
|
-
x: "6",
|
|
55
|
-
y: "6",
|
|
56
|
-
width: "12",
|
|
57
|
-
height: "12",
|
|
58
|
-
rx: "2"
|
|
59
|
-
}), getIcon(isIndeterminate, isChecked)));
|
|
60
|
-
});
|
|
61
|
-
var CheckboxWithMode = /*#__PURE__*/forwardRef(function Checkbox(props, ref) {
|
|
128
|
+
var Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Checkbox(props, ref) {
|
|
62
129
|
var isCheckedProp = props.isChecked,
|
|
63
130
|
_props$isDisabled = props.isDisabled,
|
|
64
131
|
isDisabled = _props$isDisabled === void 0 ? false : _props$isDisabled,
|
|
@@ -73,7 +140,6 @@ var CheckboxWithMode = /*#__PURE__*/forwardRef(function Checkbox(props, ref) {
|
|
|
73
140
|
onChangeProps = props.onChange,
|
|
74
141
|
analyticsContext = props.analyticsContext,
|
|
75
142
|
label = props.label,
|
|
76
|
-
mode = props.mode,
|
|
77
143
|
name = props.name,
|
|
78
144
|
value = props.value,
|
|
79
145
|
isRequired = props.isRequired,
|
|
@@ -98,7 +164,7 @@ var CheckboxWithMode = /*#__PURE__*/forwardRef(function Checkbox(props, ref) {
|
|
|
98
164
|
analyticsData: analyticsContext,
|
|
99
165
|
componentName: 'checkbox',
|
|
100
166
|
packageName: "@atlaskit/checkbox",
|
|
101
|
-
packageVersion: "12.3.
|
|
167
|
+
packageVersion: "12.3.8"
|
|
102
168
|
});
|
|
103
169
|
var internalRef = useRef(null);
|
|
104
170
|
var mergedRefs = mergeRefs([internalRef, ref]); // firefox doesn't properly dispatch events from label to its child input elements
|
|
@@ -112,13 +178,7 @@ var CheckboxWithMode = /*#__PURE__*/forwardRef(function Checkbox(props, ref) {
|
|
|
112
178
|
}; // Use isChecked from the state if it is controlled
|
|
113
179
|
|
|
114
180
|
|
|
115
|
-
var isChecked = isCheckedProp === undefined ? isCheckedState : isCheckedProp;
|
|
116
|
-
// applied to the svg with a sibling selector so we have access
|
|
117
|
-
// to the pseudo-classes of the input
|
|
118
|
-
|
|
119
|
-
var styles = useMemo(function () {
|
|
120
|
-
return getCheckboxStyles(mode);
|
|
121
|
-
}, [mode]);
|
|
181
|
+
var isChecked = isCheckedProp === undefined ? isCheckedState : isCheckedProp;
|
|
122
182
|
return jsx(Label, {
|
|
123
183
|
isDisabled: isDisabled,
|
|
124
184
|
testId: testId && "".concat(testId, "--checkbox-label"),
|
|
@@ -131,7 +191,7 @@ var CheckboxWithMode = /*#__PURE__*/forwardRef(function Checkbox(props, ref) {
|
|
|
131
191
|
value: value,
|
|
132
192
|
name: name,
|
|
133
193
|
required: isRequired,
|
|
134
|
-
css:
|
|
194
|
+
css: checkboxStyles,
|
|
135
195
|
onChange: onChangeAnalytics,
|
|
136
196
|
"aria-checked": isIndeterminate ? 'mixed' : isChecked,
|
|
137
197
|
"aria-invalid": isInvalid ? 'true' : undefined,
|
|
@@ -141,18 +201,7 @@ var CheckboxWithMode = /*#__PURE__*/forwardRef(function Checkbox(props, ref) {
|
|
|
141
201
|
size: size,
|
|
142
202
|
isIndeterminate: isIndeterminate,
|
|
143
203
|
isChecked: isChecked
|
|
144
|
-
}), label && jsx(LabelText, null, label, isRequired && jsx(RequiredIndicator,
|
|
145
|
-
"aria-hidden": "true"
|
|
146
|
-
})));
|
|
147
|
-
});
|
|
148
|
-
export var Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Checkbox(props, ref) {
|
|
149
|
-
return jsx(GlobalTheme.Consumer, null, function (_ref2) {
|
|
150
|
-
var mode = _ref2.mode;
|
|
151
|
-
return jsx(CheckboxWithMode, _extends({}, props, {
|
|
152
|
-
ref: ref,
|
|
153
|
-
mode: mode
|
|
154
|
-
}));
|
|
155
|
-
});
|
|
204
|
+
}), label && jsx(LabelText, null, label, isRequired && jsx(RequiredIndicator, null)));
|
|
156
205
|
}));
|
|
157
206
|
Checkbox.displayName = 'Checkbox';
|
|
158
207
|
export default Checkbox;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// This allows you to import Checkbox as a default or named export
|
|
2
|
-
export { default, Checkbox } from './checkbox';
|
|
2
|
+
export { default, default as Checkbox } from './checkbox';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { memo, useMemo } from 'react';
|
|
3
|
+
import { jsx } from '@emotion/core';
|
|
4
|
+
import PrimitiveSVGIcon from '@atlaskit/icon/svg';
|
|
5
|
+
|
|
6
|
+
function getIcon(isIndeterminate, isChecked) {
|
|
7
|
+
if (isIndeterminate) {
|
|
8
|
+
return jsx("rect", {
|
|
9
|
+
fill: "inherit",
|
|
10
|
+
x: "8",
|
|
11
|
+
y: "11",
|
|
12
|
+
width: "8",
|
|
13
|
+
height: "2",
|
|
14
|
+
rx: "1"
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
if (isChecked) {
|
|
19
|
+
return jsx("path", {
|
|
20
|
+
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",
|
|
21
|
+
fill: "inherit"
|
|
22
|
+
});
|
|
23
|
+
} // No icon
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* __Checkbox icon__
|
|
30
|
+
*
|
|
31
|
+
* A checkbox icon is the visual representation of checkbox state,
|
|
32
|
+
* which is shown instead of the native input.
|
|
33
|
+
*
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
var CheckboxIcon = /*#__PURE__*/memo(function (_ref) {
|
|
39
|
+
var size = _ref.size,
|
|
40
|
+
isIndeterminate = _ref.isIndeterminate,
|
|
41
|
+
isChecked = _ref.isChecked;
|
|
42
|
+
var icon = useMemo(function () {
|
|
43
|
+
return getIcon(isIndeterminate, isChecked);
|
|
44
|
+
}, [isIndeterminate, isChecked]);
|
|
45
|
+
return jsx(PrimitiveSVGIcon, {
|
|
46
|
+
label: "",
|
|
47
|
+
size: size,
|
|
48
|
+
primaryColor: "var(--checkbox-background-color)",
|
|
49
|
+
secondaryColor: "var(--checkbox-tick-color)"
|
|
50
|
+
}, jsx("g", {
|
|
51
|
+
fillRule: "evenodd"
|
|
52
|
+
}, jsx("rect", {
|
|
53
|
+
fill: "currentColor",
|
|
54
|
+
x: "6",
|
|
55
|
+
y: "6",
|
|
56
|
+
width: "12",
|
|
57
|
+
height: "12",
|
|
58
|
+
rx: "2"
|
|
59
|
+
}), icon));
|
|
60
|
+
});
|
|
61
|
+
export default CheckboxIcon;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { default as
|
|
1
|
+
export { default as CheckboxIcon } from './checkbox-icon';
|
|
2
2
|
export { default as Label } from './label';
|
|
3
3
|
export { default as LabelText } from './label-text';
|
|
4
4
|
export { default as RequiredIndicator } from './required-indicator';
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import { jsx } from '@emotion/core';
|
|
3
|
-
import { gridSize } from '
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
2
|
+
import { css, jsx } from '@emotion/core';
|
|
3
|
+
import { gridSize } from './constants';
|
|
4
|
+
var labelTextStyles = css({
|
|
5
|
+
paddingRight: 0.5 * gridSize,
|
|
6
|
+
paddingLeft: 0.5 * gridSize
|
|
7
|
+
});
|
|
9
8
|
export default function LabelText(_ref) {
|
|
10
9
|
var children = _ref.children;
|
|
11
10
|
return jsx("span", {
|
|
12
|
-
css:
|
|
11
|
+
css: labelTextStyles
|
|
13
12
|
}, children);
|
|
14
13
|
}
|
|
@@ -1,32 +1,97 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
|
-
import {
|
|
3
|
-
import { jsx } from '@emotion/core';
|
|
2
|
+
import { css, jsx } from '@emotion/core';
|
|
4
3
|
import { N80, N900 } from '@atlaskit/theme/colors';
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
4
|
+
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
5
|
+
import { fontFamily } from './constants';
|
|
6
|
+
import theme from './theme';
|
|
7
|
+
var labelStyles = css({
|
|
8
|
+
display: 'flex',
|
|
9
|
+
alignItems: 'center',
|
|
10
|
+
color: "var(--ds-text, ".concat(N900, ")"),
|
|
11
|
+
cursor: 'default',
|
|
12
|
+
fontFamily: fontFamily
|
|
13
|
+
});
|
|
14
|
+
var disabledStyles = css({
|
|
15
|
+
color: "var(--ds-text-disabled, ".concat(N80, ")"),
|
|
16
|
+
cursor: 'not-allowed'
|
|
17
|
+
});
|
|
18
|
+
var themeStyles = {
|
|
19
|
+
light: css({
|
|
20
|
+
/**
|
|
21
|
+
* Background
|
|
22
|
+
*/
|
|
23
|
+
'--local-background': theme.light.boxColor.rest,
|
|
24
|
+
'--local-background-active': theme.light.boxColor.active,
|
|
25
|
+
'--local-background-checked': theme.light.boxColor.checked,
|
|
26
|
+
'--local-background-checked-hover': theme.light.boxColor.hoveredAndChecked,
|
|
27
|
+
'--local-background-disabled': theme.light.boxColor.disabled,
|
|
28
|
+
'--local-background-hover': theme.light.boxColor.hovered,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Border
|
|
32
|
+
*/
|
|
33
|
+
'--local-border': theme.light.borderColor.rest,
|
|
34
|
+
'--local-border-active': theme.light.borderColor.active,
|
|
35
|
+
'--local-border-checked': theme.light.borderColor.checked,
|
|
36
|
+
'--local-border-checked-hover': theme.light.borderColor.hoveredAndChecked,
|
|
37
|
+
'--local-border-checked-invalid': theme.light.borderColor.invalidAndChecked,
|
|
38
|
+
'--local-border-disabled': theme.light.borderColor.disabled,
|
|
39
|
+
'--local-border-focus': theme.light.borderColor.focused,
|
|
40
|
+
'--local-border-hover': theme.light.borderColor.hovered,
|
|
41
|
+
'--local-border-invalid': theme.light.borderColor.invalid,
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Tick
|
|
45
|
+
*/
|
|
46
|
+
'--local-tick-active': theme.light.tickColor.activeAndChecked,
|
|
47
|
+
'--local-tick-checked': theme.light.tickColor.checked,
|
|
48
|
+
'--local-tick-disabled': theme.light.tickColor.disabledAndChecked,
|
|
49
|
+
'--local-tick-rest': 'transparent'
|
|
50
|
+
}),
|
|
51
|
+
dark: css({
|
|
52
|
+
/**
|
|
53
|
+
* Background
|
|
54
|
+
*/
|
|
55
|
+
'--local-background': theme.dark.boxColor.rest,
|
|
56
|
+
'--local-background-active': theme.dark.boxColor.active,
|
|
57
|
+
'--local-background-checked': theme.dark.boxColor.checked,
|
|
58
|
+
'--local-background-checked-hover': theme.dark.boxColor.hoveredAndChecked,
|
|
59
|
+
'--local-background-disabled': theme.dark.boxColor.disabled,
|
|
60
|
+
'--local-background-hover': theme.dark.boxColor.hovered,
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Border
|
|
64
|
+
*/
|
|
65
|
+
'--local-border': theme.dark.borderColor.rest,
|
|
66
|
+
'--local-border-active': theme.dark.borderColor.active,
|
|
67
|
+
'--local-border-checked': theme.dark.borderColor.checked,
|
|
68
|
+
'--local-border-checked-hover': theme.dark.borderColor.hoveredAndChecked,
|
|
69
|
+
'--local-border-checked-invalid': theme.dark.borderColor.invalidAndChecked,
|
|
70
|
+
'--local-border-disabled': theme.dark.borderColor.disabled,
|
|
71
|
+
'--local-border-focus': theme.dark.borderColor.focused,
|
|
72
|
+
'--local-border-hover': theme.dark.borderColor.hovered,
|
|
73
|
+
'--local-border-invalid': theme.dark.borderColor.invalid,
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Tick
|
|
77
|
+
*/
|
|
78
|
+
'--local-tick-active': theme.dark.tickColor.activeAndChecked,
|
|
79
|
+
'--local-tick-checked': theme.dark.tickColor.checked,
|
|
80
|
+
'--local-tick-disabled': theme.dark.tickColor.disabledAndChecked,
|
|
81
|
+
'--local-tick-rest': 'transparent'
|
|
82
|
+
})
|
|
19
83
|
};
|
|
20
84
|
export default function Label(_ref) {
|
|
21
85
|
var children = _ref.children,
|
|
22
86
|
isDisabled = _ref.isDisabled,
|
|
23
87
|
testId = _ref.testId,
|
|
24
88
|
onClick = _ref.onClick;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
89
|
+
|
|
90
|
+
var _useGlobalTheme = useGlobalTheme(),
|
|
91
|
+
mode = _useGlobalTheme.mode;
|
|
92
|
+
|
|
28
93
|
return jsx("label", {
|
|
29
|
-
css:
|
|
94
|
+
css: [labelStyles, isDisabled && disabledStyles, mode === 'light' && themeStyles.light, mode === 'dark' && themeStyles.dark],
|
|
30
95
|
"data-testid": testId,
|
|
31
96
|
"data-disabled": isDisabled || undefined,
|
|
32
97
|
onClick: onClick
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
1
|
/** @jsx jsx */
|
|
4
|
-
import { jsx } from '@emotion/core';
|
|
2
|
+
import { css, jsx } from '@emotion/core';
|
|
5
3
|
import { R500 } from '@atlaskit/theme/colors';
|
|
6
|
-
import { gridSize } from '
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
import { gridSize } from './constants';
|
|
5
|
+
var requiredIndicatorStyles = css({
|
|
6
|
+
paddingLeft: gridSize * 0.25,
|
|
7
|
+
color: "var(--ds-text-danger, ".concat(R500, ")")
|
|
8
|
+
});
|
|
9
|
+
export default function RequiredIndicator() {
|
|
10
|
+
return jsx("span", {
|
|
11
|
+
css: requiredIndicatorStyles,
|
|
12
|
+
"aria-hidden": true
|
|
13
|
+
}, "*");
|
|
15
14
|
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { B100, B200, B300, B400, B50, B75, DN10, DN200, DN30, DN80, DN90, N10, N20, N30, N40, N70, R300 } from '@atlaskit/theme/colors';
|
|
2
|
+
var theme = {
|
|
3
|
+
light: {
|
|
4
|
+
borderColor: {
|
|
5
|
+
rest: "var(--ds-border, ".concat(N40, ")"),
|
|
6
|
+
hovered: "var(--ds-border, ".concat(N40, ")"),
|
|
7
|
+
disabled: "var(--ds-background-disabled, ".concat(N20, ")"),
|
|
8
|
+
checked: "var(--ds-background-brand-bold, ".concat(B400, ")"),
|
|
9
|
+
active: "var(--ds-border, ".concat(B50, ")"),
|
|
10
|
+
invalid: "var(--ds-border-danger, ".concat(R300, ")"),
|
|
11
|
+
invalidAndChecked: "var(--ds-border-danger, ".concat(R300, ")"),
|
|
12
|
+
focused: "var(--ds-border-focused, ".concat(B100, ")"),
|
|
13
|
+
hoveredAndChecked: "var(--ds-background-brand-bold-hovered, ".concat(B300, ")")
|
|
14
|
+
},
|
|
15
|
+
boxColor: {
|
|
16
|
+
rest: "var(--ds-background-input, ".concat(N10, ")"),
|
|
17
|
+
hovered: "var(--ds-surface, ".concat(N30, ")"),
|
|
18
|
+
disabled: "var(--ds-background-disabled, ".concat(N20, ")"),
|
|
19
|
+
active: "var(--ds-background-input-pressed, ".concat(B50, ")"),
|
|
20
|
+
hoveredAndChecked: "var(--ds-background-brand-bold-hovered, ".concat(B300, ")"),
|
|
21
|
+
checked: "var(--ds-background-brand-bold, ".concat(B400, ")")
|
|
22
|
+
},
|
|
23
|
+
tickColor: {
|
|
24
|
+
disabledAndChecked: "var(--ds-text-disabled, ".concat(N70, ")"),
|
|
25
|
+
activeAndChecked: "var(--ds-text-inverse, ".concat(B400, ")"),
|
|
26
|
+
checked: "var(--ds-text-inverse, ".concat(N10, ")")
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
dark: {
|
|
30
|
+
borderColor: {
|
|
31
|
+
rest: "var(--ds-border, ".concat(DN80, ")"),
|
|
32
|
+
hovered: "var(--ds-border, ".concat(DN200, ")"),
|
|
33
|
+
disabled: "var(--ds-background-disabled, ".concat(DN10, ")"),
|
|
34
|
+
checked: "var(--ds-background-brand-bold, ".concat(B400, ")"),
|
|
35
|
+
active: "var(--ds-border, ".concat(B200, ")"),
|
|
36
|
+
invalid: "var(--ds-border-danger, ".concat(R300, ")"),
|
|
37
|
+
invalidAndChecked: "var(--ds-border-danger, ".concat(R300, ")"),
|
|
38
|
+
focused: "var(--ds-border-focused, ".concat(B75, ")"),
|
|
39
|
+
hoveredAndChecked: "var(--ds-background-brand-bold-hovered, ".concat(B75, ")")
|
|
40
|
+
},
|
|
41
|
+
boxColor: {
|
|
42
|
+
rest: "var(--ds-background-input, ".concat(DN10, ")"),
|
|
43
|
+
hovered: "var(--ds-surface, ".concat(DN30, ")"),
|
|
44
|
+
disabled: "var(--ds-background-disabled, ".concat(DN10, ")"),
|
|
45
|
+
active: "var(--ds-background-input-pressed, ".concat(B200, ")"),
|
|
46
|
+
hoveredAndChecked: "var(--ds-background-brand-bold-hovered, ".concat(B75, ")"),
|
|
47
|
+
checked: "var(--ds-background-brand-bold, ".concat(B400, ")")
|
|
48
|
+
},
|
|
49
|
+
tickColor: {
|
|
50
|
+
disabledAndChecked: "var(--ds-text-disabled, ".concat(DN90, ")"),
|
|
51
|
+
activeAndChecked: "var(--ds-text-inverse, ".concat(DN10, ")"),
|
|
52
|
+
checked: "var(--ds-text-inverse, ".concat(DN10, ")")
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
export default theme;
|
package/dist/esm/version.json
CHANGED