@atlaskit/checkbox 17.3.2 → 17.3.4
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 +15 -0
- package/codemods/migrations/remove-imports.tsx +4 -1
- package/codemods/migrations/remove-props.tsx +16 -4
- package/codemods/migrations/rename-import.tsx +12 -3
- package/codemods/migrations/rename-input-ref-to-ref.tsx +4 -6
- package/codemods/utils.tsx +53 -16
- package/dist/cjs/checkbox.js +17 -4
- package/dist/cjs/internal/checkbox-icon.compiled.css +12 -2
- package/dist/cjs/internal/checkbox-icon.js +37 -2
- package/dist/cjs/internal/label.compiled.css +30 -1
- package/dist/cjs/internal/label.js +41 -1
- package/dist/es2019/checkbox.js +17 -4
- package/dist/es2019/internal/checkbox-icon.compiled.css +12 -2
- package/dist/es2019/internal/checkbox-icon.js +37 -2
- package/dist/es2019/internal/label.compiled.css +29 -1
- package/dist/es2019/internal/label.js +41 -1
- package/dist/esm/checkbox.js +17 -4
- package/dist/esm/internal/checkbox-icon.compiled.css +12 -2
- package/dist/esm/internal/checkbox-icon.js +37 -2
- package/dist/esm/internal/label.compiled.css +30 -1
- package/dist/esm/internal/label.js +41 -1
- package/dist/types/internal/checkbox-icon.d.ts +10 -4
- package/dist/types/internal/label.d.ts +1 -1
- package/dist/types/types.d.ts +15 -0
- package/dist/types-ts4.5/internal/checkbox-icon.d.ts +10 -4
- package/dist/types-ts4.5/internal/label.d.ts +1 -1
- package/dist/types-ts4.5/types.d.ts +15 -0
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @atlaskit/checkbox
|
|
2
2
|
|
|
3
|
+
## 17.3.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 17.3.3
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`bfa01f2ed5c65`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/bfa01f2ed5c65) -
|
|
14
|
+
Internal only CSS refactor to eliminate nested CSS selectors (specifically sibling combinators
|
|
15
|
+
like & + svg) in favor of an atomic-friendly styling approach using CSS custom properties. This
|
|
16
|
+
change is behind the `platform-checkbox-atomic-styles` feature gate.
|
|
17
|
+
|
|
3
18
|
## 17.3.2
|
|
4
19
|
|
|
5
20
|
### Patch Changes
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { createRemoveImportsFor } from '../utils';
|
|
2
2
|
|
|
3
|
-
export const removeThemeImports: (
|
|
3
|
+
export const removeThemeImports: (
|
|
4
|
+
j: import('jscodeshift/src/core').JSCodeshift,
|
|
5
|
+
source: import('jscodeshift/src/Collection').Collection<Node>,
|
|
6
|
+
) => void = createRemoveImportsFor({
|
|
4
7
|
importsToRemove: ['ComponentTokens', 'ThemeFn'],
|
|
5
8
|
packagePath: '@atlaskit/checkbox/types',
|
|
6
9
|
comment: `This file uses exports used to help theme @atlaskit/checkbox which
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { createRemoveFuncFor } from '../utils';
|
|
2
2
|
|
|
3
|
-
export const removeFullWidth: (
|
|
3
|
+
export const removeFullWidth: (
|
|
4
|
+
j: import('jscodeshift/src/core').JSCodeshift,
|
|
5
|
+
source: import('jscodeshift/src/Collection').Collection<Node>,
|
|
6
|
+
) => void = createRemoveFuncFor('@atlaskit/checkbox', 'Checkbox', 'isFullWidth');
|
|
4
7
|
|
|
5
|
-
export const removeOverrides: (
|
|
8
|
+
export const removeOverrides: (
|
|
9
|
+
j: import('jscodeshift/src/core').JSCodeshift,
|
|
10
|
+
source: import('jscodeshift/src/Collection').Collection<Node>,
|
|
11
|
+
) => void = createRemoveFuncFor(
|
|
6
12
|
'@atlaskit/checkbox',
|
|
7
13
|
'Checkbox',
|
|
8
14
|
'overrides',
|
|
@@ -13,7 +19,10 @@ export const removeOverrides: (j: import("jscodeshift/src/core").JSCodeshift, so
|
|
|
13
19
|
of Checkbox will have likely changed.`,
|
|
14
20
|
);
|
|
15
21
|
|
|
16
|
-
export const removeTheme: (
|
|
22
|
+
export const removeTheme: (
|
|
23
|
+
j: import('jscodeshift/src/core').JSCodeshift,
|
|
24
|
+
source: import('jscodeshift/src/Collection').Collection<Node>,
|
|
25
|
+
) => void = createRemoveFuncFor(
|
|
17
26
|
'@atlaskit/checkbox',
|
|
18
27
|
'Checkbox',
|
|
19
28
|
'theme',
|
|
@@ -24,4 +33,7 @@ export const removeTheme: (j: import("jscodeshift/src/core").JSCodeshift, source
|
|
|
24
33
|
The appearance of Checkbox will have likely changed.`,
|
|
25
34
|
);
|
|
26
35
|
|
|
27
|
-
export const removeSize: (
|
|
36
|
+
export const removeSize: (
|
|
37
|
+
j: import('jscodeshift/src/core').JSCodeshift,
|
|
38
|
+
source: import('jscodeshift/src/Collection').Collection<Node>,
|
|
39
|
+
) => void = createRemoveFuncFor('@atlaskit/checkbox', 'Checkbox', 'size');
|
|
@@ -4,19 +4,28 @@ import { createRenameImportFor } from '../utils';
|
|
|
4
4
|
// there are a lot of possible things to fix. Having searched on SourceTree
|
|
5
5
|
// these are the only things that need to be fixed
|
|
6
6
|
|
|
7
|
-
export const renameTypeImport: (
|
|
7
|
+
export const renameTypeImport: (
|
|
8
|
+
j: import('jscodeshift/src/core').JSCodeshift,
|
|
9
|
+
source: import('jscodeshift/src/Collection').Collection<Node>,
|
|
10
|
+
) => void = createRenameImportFor({
|
|
8
11
|
componentName: 'CheckboxProps',
|
|
9
12
|
oldPackagePath: '@atlaskit/checkbox/types',
|
|
10
13
|
newPackagePath: '@atlaskit/checkbox',
|
|
11
14
|
});
|
|
12
15
|
|
|
13
|
-
export const renameDeepTypeImport: (
|
|
16
|
+
export const renameDeepTypeImport: (
|
|
17
|
+
j: import('jscodeshift/src/core').JSCodeshift,
|
|
18
|
+
source: import('jscodeshift/src/Collection').Collection<Node>,
|
|
19
|
+
) => void = createRenameImportFor({
|
|
14
20
|
componentName: 'CheckboxProps',
|
|
15
21
|
oldPackagePath: '@atlaskit/checkbox/dist/cjs/types',
|
|
16
22
|
newPackagePath: '@atlaskit/checkbox',
|
|
17
23
|
});
|
|
18
24
|
|
|
19
|
-
export const renameCheckboxWithoutAnalyticsImport: (
|
|
25
|
+
export const renameCheckboxWithoutAnalyticsImport: (
|
|
26
|
+
j: import('jscodeshift/src/core').JSCodeshift,
|
|
27
|
+
source: import('jscodeshift/src/Collection').Collection<Node>,
|
|
28
|
+
) => void = createRenameImportFor({
|
|
20
29
|
componentName: 'CheckboxWithoutAnalytics',
|
|
21
30
|
newComponentName: 'Checkbox',
|
|
22
31
|
oldPackagePath: '@atlaskit/checkbox/Checkbox',
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { createRenameFuncFor } from '../utils';
|
|
2
2
|
|
|
3
|
-
export const renameInputRef: (
|
|
4
|
-
'
|
|
5
|
-
'
|
|
6
|
-
|
|
7
|
-
'ref',
|
|
8
|
-
);
|
|
3
|
+
export const renameInputRef: (
|
|
4
|
+
j: import('jscodeshift/src/core').JSCodeshift,
|
|
5
|
+
source: import('jscodeshift/src/Collection').Collection<Node>,
|
|
6
|
+
) => void = createRenameFuncFor('@atlaskit/checkbox', 'Checkbox', 'inputRef', 'ref');
|
package/codemods/utils.tsx
CHANGED
|
@@ -20,7 +20,7 @@ export function getNamedSpecifier(
|
|
|
20
20
|
source: any,
|
|
21
21
|
specifier: string,
|
|
22
22
|
importName: string,
|
|
23
|
-
) {
|
|
23
|
+
): any {
|
|
24
24
|
const specifiers = source
|
|
25
25
|
.find(j.ImportDeclaration)
|
|
26
26
|
.filter((path: ASTPath<ImportDeclaration>) => path.node.source.value === specifier)
|
|
@@ -61,7 +61,11 @@ export function getJSXAttributesByName(
|
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
63
|
|
|
64
|
-
export function hasImportDeclaration(
|
|
64
|
+
export function hasImportDeclaration(
|
|
65
|
+
j: core.JSCodeshift,
|
|
66
|
+
source: any,
|
|
67
|
+
importPath: string,
|
|
68
|
+
): boolean {
|
|
65
69
|
const imports = source
|
|
66
70
|
.find(j.ImportDeclaration)
|
|
67
71
|
.filter(
|
|
@@ -78,7 +82,7 @@ export function findIdentifierAndReplaceAttribute(
|
|
|
78
82
|
identifierName: string,
|
|
79
83
|
searchAttr: string,
|
|
80
84
|
replaceWithAttr: string,
|
|
81
|
-
) {
|
|
85
|
+
): void {
|
|
82
86
|
source
|
|
83
87
|
.find(j.JSXElement)
|
|
84
88
|
.find(j.JSXOpeningElement)
|
|
@@ -136,7 +140,7 @@ export function addCommentToStartOfFile({
|
|
|
136
140
|
j: core.JSCodeshift;
|
|
137
141
|
base: Collection<Node>;
|
|
138
142
|
message: string;
|
|
139
|
-
}) {
|
|
143
|
+
}): void {
|
|
140
144
|
addCommentBefore({
|
|
141
145
|
j,
|
|
142
146
|
target: base.find(j.Program),
|
|
@@ -152,7 +156,7 @@ export function addCommentBefore({
|
|
|
152
156
|
j: core.JSCodeshift;
|
|
153
157
|
target: Collection<Program> | Collection<ImportDeclaration>;
|
|
154
158
|
message: string;
|
|
155
|
-
}) {
|
|
159
|
+
}): void {
|
|
156
160
|
const content: string = ` TODO: (from codemod) ${clean(message)} `;
|
|
157
161
|
target.forEach((path: ASTPath<Program | ImportDeclaration>) => {
|
|
158
162
|
path.value.comments = path.value.comments || [];
|
|
@@ -178,7 +182,7 @@ export function tryCreateImport({
|
|
|
178
182
|
base: Collection<any>;
|
|
179
183
|
relativeToPackage: string;
|
|
180
184
|
packageName: string;
|
|
181
|
-
}) {
|
|
185
|
+
}): void {
|
|
182
186
|
const exists: boolean =
|
|
183
187
|
base.find(j.ImportDeclaration).filter((path) => path.value.source.value === packageName)
|
|
184
188
|
.length > 0;
|
|
@@ -203,7 +207,7 @@ export function addToImport({
|
|
|
203
207
|
base: Collection<any>;
|
|
204
208
|
importSpecifier: ImportSpecifier | ImportDefaultSpecifier;
|
|
205
209
|
packageName: string;
|
|
206
|
-
}) {
|
|
210
|
+
}): void {
|
|
207
211
|
base
|
|
208
212
|
.find(j.ImportDeclaration)
|
|
209
213
|
.filter((path) => path.value.source.value === packageName)
|
|
@@ -223,7 +227,12 @@ export function addToImport({
|
|
|
223
227
|
});
|
|
224
228
|
}
|
|
225
229
|
|
|
226
|
-
export const createRenameFuncFor
|
|
230
|
+
export const createRenameFuncFor: (
|
|
231
|
+
component: string,
|
|
232
|
+
importName: string,
|
|
233
|
+
from: string,
|
|
234
|
+
to: string,
|
|
235
|
+
) => (j: core.JSCodeshift, source: Collection<Node>) => void =
|
|
227
236
|
(component: string, importName: string, from: string, to: string) =>
|
|
228
237
|
(j: core.JSCodeshift, source: Collection<Node>) => {
|
|
229
238
|
const specifier = getNamedSpecifier(j, source, component, importName);
|
|
@@ -253,7 +262,12 @@ export const createRenameFuncFor =
|
|
|
253
262
|
}
|
|
254
263
|
};
|
|
255
264
|
|
|
256
|
-
export const createRemoveFuncFor
|
|
265
|
+
export const createRemoveFuncFor: (
|
|
266
|
+
component: string,
|
|
267
|
+
importName: string,
|
|
268
|
+
prop: string,
|
|
269
|
+
comment?: string,
|
|
270
|
+
) => (j: core.JSCodeshift, source: Collection<Node>) => void =
|
|
257
271
|
(component: string, importName: string, prop: string, comment?: string) =>
|
|
258
272
|
(j: core.JSCodeshift, source: Collection<Node>) => {
|
|
259
273
|
const specifier =
|
|
@@ -274,7 +288,17 @@ export const createRemoveFuncFor =
|
|
|
274
288
|
});
|
|
275
289
|
};
|
|
276
290
|
|
|
277
|
-
export const createRenameImportFor
|
|
291
|
+
export const createRenameImportFor: ({
|
|
292
|
+
componentName,
|
|
293
|
+
newComponentName,
|
|
294
|
+
oldPackagePath,
|
|
295
|
+
newPackagePath,
|
|
296
|
+
}: {
|
|
297
|
+
componentName: string;
|
|
298
|
+
newComponentName?: string;
|
|
299
|
+
oldPackagePath: string;
|
|
300
|
+
newPackagePath: string;
|
|
301
|
+
}) => (j: core.JSCodeshift, source: Collection<Node>) => void =
|
|
278
302
|
({
|
|
279
303
|
componentName,
|
|
280
304
|
newComponentName,
|
|
@@ -355,7 +379,15 @@ export const createRenameImportFor =
|
|
|
355
379
|
.remove();
|
|
356
380
|
};
|
|
357
381
|
|
|
358
|
-
export const createRemoveImportsFor
|
|
382
|
+
export const createRemoveImportsFor: ({
|
|
383
|
+
importsToRemove,
|
|
384
|
+
packagePath,
|
|
385
|
+
comment,
|
|
386
|
+
}: {
|
|
387
|
+
importsToRemove: string[];
|
|
388
|
+
packagePath: string;
|
|
389
|
+
comment: string;
|
|
390
|
+
}) => (j: core.JSCodeshift, source: Collection<Node>) => void =
|
|
359
391
|
({
|
|
360
392
|
importsToRemove,
|
|
361
393
|
packagePath,
|
|
@@ -425,16 +457,21 @@ export const createRemoveImportsFor =
|
|
|
425
457
|
}
|
|
426
458
|
};
|
|
427
459
|
|
|
428
|
-
export const createTransformer
|
|
460
|
+
export const createTransformer: (
|
|
461
|
+
component: string,
|
|
462
|
+
migrates: {
|
|
463
|
+
(j: core.JSCodeshift, source: Collection<Node>): void;
|
|
464
|
+
}[],
|
|
465
|
+
) => (fileInfo: FileInfo, { jscodeshift }: API, options: Options) => string =
|
|
429
466
|
(component: string, migrates: { (j: core.JSCodeshift, source: Collection<Node>): void }[]) =>
|
|
430
|
-
(fileInfo: FileInfo, { jscodeshift
|
|
431
|
-
const source: Collection<Node> =
|
|
467
|
+
(fileInfo: FileInfo, { jscodeshift }: API, options: Options) => {
|
|
468
|
+
const source: Collection<Node> = jscodeshift(fileInfo.source);
|
|
432
469
|
|
|
433
|
-
if (!hasImportDeclaration(
|
|
470
|
+
if (!hasImportDeclaration(jscodeshift, source, component)) {
|
|
434
471
|
return fileInfo.source;
|
|
435
472
|
}
|
|
436
473
|
|
|
437
|
-
migrates.forEach((tf) => tf(
|
|
474
|
+
migrates.forEach((tf) => tf(jscodeshift, source));
|
|
438
475
|
|
|
439
476
|
return source.toSource(options.printOptions || { quote: 'single' });
|
|
440
477
|
};
|
package/dist/cjs/checkbox.js
CHANGED
|
@@ -16,19 +16,29 @@ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/sli
|
|
|
16
16
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
17
17
|
var _usePlatformLeafEventHandler = require("@atlaskit/analytics-next/usePlatformLeafEventHandler");
|
|
18
18
|
var _mergeRefs = _interopRequireDefault(require("@atlaskit/ds-lib/merge-refs"));
|
|
19
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
19
20
|
var _internal = require("./internal");
|
|
20
21
|
var _excluded = ["isChecked", "isDisabled", "isInvalid", "defaultChecked", "isIndeterminate", "onChange", "analyticsContext", "label", "name", "value", "isRequired", "testId", "xcss", "className"];
|
|
21
22
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
22
23
|
/**
|
|
24
|
+
* The input is visually hidden but remains in the DOM for accessibility.
|
|
25
|
+
* State-based styling is handled by the Label component using CSS custom properties
|
|
26
|
+
* that cascade to the CheckboxIcon, avoiding nested sibling selectors.
|
|
27
|
+
*/
|
|
28
|
+
var checkboxStyles = {
|
|
29
|
+
root: "_19itglyw _nd5lfibj _12ji1r31 _1qu2glyw _12y31o36 _1bsb1osq _4t3i1osq _r06hglyw _6rthze3t _1pfhze3t _12l2ze3t _ahbqze3t _tzy4idpf"
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Legacy hidden input styles with nested sibling selectors.
|
|
34
|
+
* Used when the `platform-checkbox-atomic-styles` feature gate is disabled.
|
|
23
35
|
* Using `cssMap` to avoid a Compiled bug with the transformed styles.
|
|
24
36
|
* It was using a CSS variable for the outline template string,
|
|
25
37
|
* which broke because of the use of a sibling selector.
|
|
26
38
|
*
|
|
27
39
|
* Related to: https://github.com/atlassian-labs/compiled/pull/1795
|
|
28
|
-
*
|
|
29
|
-
* Using `cssMap` seems to be a workaround for this.
|
|
30
40
|
*/
|
|
31
|
-
var
|
|
41
|
+
var checkboxStylesLegacy = {
|
|
32
42
|
root: "_19itglyw _nd5lfibj _12ji1r31 _1qu2glyw _12y31o36 _1bsb1osq _4t3i1osq _r06hglyw _6rthze3t _1pfhze3t _12l2ze3t _ahbqze3t _tzy4idpf _r050fibj _9bg71mn3 _19op11so _a30fhteq _1610e4h9 _13wo93zu _q5a61gyf _8gq114p8 _wje2mov0 _1fo21cni _eyedglyw _1ef78r4n _1h6r8r4n _smzg1nfn _1dk71nfn _l71j1i6y _t34a1i6y _y32gkivo _1ah9199y _1frj180l _h78e1g3k _dwvb1ps2 _1bok170n _1mhr17cl _fx2i3rva _10oaq2ws _w12s155b _15y61vek _e6ww155b _sg1j1vek _rphw18jz _y9y9mz2b _141bmz2b _255gmz2b _jj67mz2b _swhgmz2b _axq81diq _1jiz1diq _s9051diq _1efy1diq _1oav1diq _10y313gf _1wt913gf _qq8613gf _1adw13gf _12sr13gf _16jiglyw _693jglyw _1niqglyw _cl9tglyw _1jbnglyw _j1ta1hou _18qu1ps2 _1g52170n _1log17cl _32hzmz2b _1vv91diq _yjhd1hou _w1cowc43 _jdqn1onz _4y4t1onz _lvfrwc43 _g68dwc43 _13dk1onz _w1el1onz _a9yw1onz _1l3g1onz _dcdpgir2 _wobcgir2 _rp9wgir2 _9ebfwc43 _e43iwc43 _1tkuwc43 _1lehwc43 _b9q3wc43 _tu2918qt _1uxv18qt _1ufw18qt _opo918qt _1e8318qt _1k3d18qt _25yv18qt _1igz18qt _c7cc18qt _1swg18qt"
|
|
33
43
|
};
|
|
34
44
|
|
|
@@ -91,6 +101,9 @@ var Checkbox = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
|
|
|
91
101
|
}, [isIndeterminate]);
|
|
92
102
|
return /*#__PURE__*/React.createElement(_internal.Label, {
|
|
93
103
|
isDisabled: isDisabled,
|
|
104
|
+
isChecked: (0, _platformFeatureFlags.fg)('platform-checkbox-atomic-styles') ? isChecked : undefined,
|
|
105
|
+
isIndeterminate: (0, _platformFeatureFlags.fg)('platform-checkbox-atomic-styles') ? isIndeterminate : undefined,
|
|
106
|
+
isInvalid: (0, _platformFeatureFlags.fg)('platform-checkbox-atomic-styles') ? isInvalid : undefined,
|
|
94
107
|
label: label,
|
|
95
108
|
id: rest.id ? "".concat(rest.id, "-label") : undefined,
|
|
96
109
|
testId: testId && "".concat(testId, "--checkbox-label")
|
|
@@ -110,7 +123,7 @@ var Checkbox = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
|
|
|
110
123
|
name: name,
|
|
111
124
|
required: isRequired,
|
|
112
125
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
113
|
-
className: (0, _runtime.ax)([checkboxStyles.root, className]),
|
|
126
|
+
className: (0, _runtime.ax)([(0, _platformFeatureFlags.fg)('platform-checkbox-atomic-styles') && checkboxStyles.root, !(0, _platformFeatureFlags.fg)('platform-checkbox-atomic-styles') && checkboxStylesLegacy.root, className]),
|
|
114
127
|
onChange: onChangeAnalytics,
|
|
115
128
|
"aria-invalid": isInvalid ? 'true' : undefined,
|
|
116
129
|
"data-testid": testId && "".concat(testId, "--hidden-checkbox"),
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
._1a3742bt{outline:var(--checkbox-outline)}
|
|
3
|
+
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
4
|
+
._nd5lfibj{grid-area:1/1/2/2}
|
|
5
|
+
._v56411so{transition:stroke .2s ease-in-out}
|
|
6
|
+
._v5641mn3{transition:color .2s ease-in-out,fill .2s ease-in-out}._18m915vq{overflow-y:hidden}
|
|
7
|
+
._1cwg1i6y{outline-offset:var(--ds-space-negative-025,-2px)}
|
|
2
8
|
._1reo15vq{overflow-x:hidden}
|
|
9
|
+
._1s17hteq{stroke:var(--checkbox-border-color)}
|
|
10
|
+
._1snbe4h9{stroke-width:var(--ds-border-width,1px)}
|
|
3
11
|
._lcxvglyw{pointer-events:none}
|
|
4
|
-
.
|
|
12
|
+
._lswu1kgh{fill:var(--checkbox-tick-color,var(--ds-surface,#fff))}
|
|
13
|
+
._lswuvuon{fill:var(--ds-surface,#fff)}
|
|
14
|
+
._syazmov0{color:var(--checkbox-background-color)}
|
|
@@ -10,8 +10,23 @@ require("./checkbox-icon.compiled.css");
|
|
|
10
10
|
var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
var React = _react;
|
|
12
12
|
var _runtime = require("@compiled/react/runtime");
|
|
13
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
14
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
14
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Styles for the checkbox icon.
|
|
17
|
+
* CSS custom properties for colors are set by the parent Label element
|
|
18
|
+
* and consumed directly in these styles.
|
|
19
|
+
*/
|
|
20
|
+
var svgStyles = {
|
|
21
|
+
root: "_nd5lfibj _1reo15vq _18m915vq _v5641mn3 _2rko12b0 _1a3742bt _lcxvglyw _syazmov0 _lswu1kgh _1cwg1i6y",
|
|
22
|
+
rect: "_v56411so _1snbe4h9 _1s17hteq"
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Legacy SVG styles.
|
|
27
|
+
* Used when the `platform-checkbox-atomic-styles` feature gate is disabled.
|
|
28
|
+
*/
|
|
29
|
+
var svgStylesLegacy = null;
|
|
15
30
|
function getIcon(isIndeterminate, isChecked) {
|
|
16
31
|
if (isIndeterminate) {
|
|
17
32
|
return /*#__PURE__*/React.createElement("path", {
|
|
@@ -33,7 +48,6 @@ function getIcon(isIndeterminate, isChecked) {
|
|
|
33
48
|
// No icon
|
|
34
49
|
return null;
|
|
35
50
|
}
|
|
36
|
-
|
|
37
51
|
/**
|
|
38
52
|
* __Checkbox icon__
|
|
39
53
|
*
|
|
@@ -48,6 +62,27 @@ var CheckboxIcon = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
|
48
62
|
var icon = (0, _react.useMemo)(function () {
|
|
49
63
|
return getIcon(isIndeterminate, isChecked);
|
|
50
64
|
}, [isIndeterminate, isChecked]);
|
|
65
|
+
if ((0, _platformFeatureFlags.fg)('platform-checkbox-atomic-styles')) {
|
|
66
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
67
|
+
width: 24,
|
|
68
|
+
height: 24,
|
|
69
|
+
viewBox: "0 0 24 24",
|
|
70
|
+
role: "presentation",
|
|
71
|
+
className: (0, _runtime.ax)([svgStyles.root])
|
|
72
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
73
|
+
fillRule: "evenodd"
|
|
74
|
+
}, /*#__PURE__*/React.createElement("rect", {
|
|
75
|
+
fill: "currentColor",
|
|
76
|
+
x: "5.5",
|
|
77
|
+
y: "5.5",
|
|
78
|
+
width: "13",
|
|
79
|
+
height: "13",
|
|
80
|
+
rx: "1.5",
|
|
81
|
+
className: (0, _runtime.ax)([svgStyles.rect])
|
|
82
|
+
}), icon));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// Legacy rendering with inline style props for CSS variable consumption
|
|
51
86
|
return /*#__PURE__*/React.createElement("svg", {
|
|
52
87
|
width: 24,
|
|
53
88
|
height: 24,
|
|
@@ -2,13 +2,20 @@
|
|
|
2
2
|
._zulp1nu5{gap:var(--ds-space-0,0) var(--ds-space-050,4px)}
|
|
3
3
|
._13hr1j28{--local-tick-rest:transparent}
|
|
4
4
|
._18q0snw8{--local-tick-disabled:var(--_1xmcmw9)}
|
|
5
|
+
._1c53glyw{--checkbox-outline:none}
|
|
5
6
|
._1dik1ehr{--local-border-checked-hover:var(--_14y1fod)}
|
|
6
7
|
._1e0c11p5{display:grid}
|
|
8
|
+
._1e9d1j28{--checkbox-tick-color:transparent}
|
|
9
|
+
._1e9d2sac{--checkbox-tick-color:var(--ds-icon-disabled,#080f214a)}
|
|
10
|
+
._1e9d5w2r{--checkbox-tick-color:var(--ds-icon-inverse,#fff)}
|
|
7
11
|
._1ejihkll{grid-auto-columns:1fr}
|
|
8
12
|
._1esz1j4g{--local-background-checked:var(--_1gcp7nr)}
|
|
9
13
|
._1g1fe69j{--local-border-active:var(--_rczcge)}
|
|
10
14
|
._1j3h1380{--local-border-invalid:var(--_1i4xulb)}
|
|
11
15
|
._1nzs1kc0{--local-background-active:var(--_1cd0fcx)}
|
|
16
|
+
._1qwn1j9a{--checkbox-background-color:var(--ds-background-input,#fff)}
|
|
17
|
+
._1qwnby5v{--checkbox-background-color:var(--ds-background-disabled,#17171708)}
|
|
18
|
+
._1qwnjmqp{--checkbox-background-color:var(--ds-background-selected-bold,#1868db)}
|
|
12
19
|
._1rdaeh7q{--local-tick-checked:var(--_jf353p)}
|
|
13
20
|
._1sfg1380{--local-border-checked-invalid:var(--_1i4xulb)}
|
|
14
21
|
._1yjc3zdg{--local-border-focus:var(--_xjqa3d)}
|
|
@@ -17,13 +24,35 @@
|
|
|
17
24
|
._ay2w1ouc{--local-background-disabled:var(--_r5pknd)}
|
|
18
25
|
._d51u12ci{--local-background-hover:var(--_1z08gfx)}
|
|
19
26
|
._eawbxz7c{--local-tick-active:var(--_uq1ko9)}
|
|
27
|
+
._f0gr1bqt{--checkbox-border-color:var(--ds-border-danger,#e2483d)}
|
|
28
|
+
._f0grby5v{--checkbox-border-color:var(--ds-background-disabled,#17171708)}
|
|
29
|
+
._f0grjmqp{--checkbox-border-color:var(--ds-background-selected-bold,#1868db)}
|
|
30
|
+
._f0grrsbi{--checkbox-border-color:var(--ds-border-input,#8c8f97)}
|
|
20
31
|
._fpdj1ouc{--local-border-disabled:var(--_r5pknd)}
|
|
21
32
|
._h5e31kd8{--local-background:var(--_4mkb4g)}
|
|
22
33
|
._l6wk1j4g{--local-border-checked:var(--_1gcp7nr)}
|
|
23
34
|
._oaj1ddza{--local-border-hover:var(--_vnm8xo)}
|
|
24
35
|
._phftddza{--local-border:var(--_vnm8xo)}
|
|
36
|
+
._syaz1tvo{color:var(--ds-text-disabled,#97a0af)}
|
|
25
37
|
._syaz7wap{color:var(--_1ynhf1h)}
|
|
38
|
+
._syazi7uo{color:var(--ds-text,#292a2e)}
|
|
26
39
|
._syazovqm{color:var(--_5xk3r4)}
|
|
27
40
|
._umai184x{grid-auto-rows:min-content}
|
|
28
41
|
._yp0j1ehr{--local-background-checked-hover:var(--_14y1fod)}
|
|
29
|
-
._yv0ey09t{grid-template-columns:min-content auto}
|
|
42
|
+
._yv0ey09t{grid-template-columns:min-content auto}
|
|
43
|
+
._ljcgdfik:focus-within{--checkbox-outline:var(--ds-border-width-focused,2px) solid var(--ds-border-focused,#4688ec)}
|
|
44
|
+
._1vj51q28:hover{--checkbox-background-color:var(--ds-background-selected-bold-hovered,#1558bc)}
|
|
45
|
+
._1vj5by5v:hover{--checkbox-background-color:var(--ds-background-disabled,#17171708)}
|
|
46
|
+
._1vj5l4ek:hover{--checkbox-background-color:var(--ds-background-input-hovered,#f8f8f8)}
|
|
47
|
+
._9js12sac:hover{--checkbox-tick-color:var(--ds-icon-disabled,#080f214a)}
|
|
48
|
+
._q29q1bqt:hover{--checkbox-border-color:var(--ds-border-danger,#e2483d)}
|
|
49
|
+
._q29q1q28:hover{--checkbox-border-color:var(--ds-background-selected-bold-hovered,#1558bc)}
|
|
50
|
+
._q29qby5v:hover{--checkbox-border-color:var(--ds-background-disabled,#17171708)}
|
|
51
|
+
._cz1u1bqt:active{--checkbox-border-color:var(--ds-border-danger,#e2483d)}
|
|
52
|
+
._cz1u1l7x:active{--checkbox-border-color:var(--ds-border,#0b120e24)}
|
|
53
|
+
._cz1uby5v:active{--checkbox-border-color:var(--ds-background-disabled,#17171708)}
|
|
54
|
+
._dh4gby5v:active{--checkbox-background-color:var(--ds-background-disabled,#17171708)}
|
|
55
|
+
._dh4gr01l:active{--checkbox-background-color:var(--ds-background-input-pressed,#fff)}
|
|
56
|
+
._zoo92sac:active{--checkbox-tick-color:var(--ds-icon-disabled,#080f214a)}
|
|
57
|
+
._zoo95w2r:active{--checkbox-tick-color:var(--ds-icon-inverse,#fff)}
|
|
58
|
+
@media screen and (forced-colors:active){._1s07gir2{--checkbox-border-color:Highlight}._jom5wc43{--checkbox-background-color:Canvas}._1s0718qt{--checkbox-border-color:GrayText}._106f18qt{--checkbox-tick-color:GrayText}._1s071onz{--checkbox-border-color:CanvasText}._106f1onz{--checkbox-tick-color:CanvasText}}
|
|
@@ -9,19 +9,59 @@ exports.default = Label;
|
|
|
9
9
|
require("./label.compiled.css");
|
|
10
10
|
var React = _interopRequireWildcard(require("react"));
|
|
11
11
|
var _runtime = require("@compiled/react/runtime");
|
|
12
|
+
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
12
13
|
var _colors = require("@atlaskit/theme/colors");
|
|
13
14
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
|
|
15
|
+
/**
|
|
16
|
+
* Base state styles with CSS custom properties.
|
|
17
|
+
* Pseudo-selectors (:hover, :focus-within, :active) on the label element
|
|
18
|
+
* update CSS variables that cascade to the CheckboxIcon.
|
|
19
|
+
* This avoids nested sibling selectors.
|
|
20
|
+
*
|
|
21
|
+
* Uses `css` over `cssMap` to work around a bug in Compiled types when
|
|
22
|
+
* using CSS variables in pseudo-selectors.
|
|
23
|
+
*/
|
|
14
24
|
var baseStyles = null;
|
|
15
25
|
var textLabelLayoutStyles = null;
|
|
26
|
+
|
|
27
|
+
// Checked/Indeterminate state
|
|
28
|
+
var checkedStyles = null;
|
|
29
|
+
|
|
30
|
+
// Invalid state - must override hover/active to maintain red border
|
|
31
|
+
var invalidStyles = null;
|
|
32
|
+
|
|
33
|
+
// Disabled state - must override hover/active to maintain disabled appearance
|
|
16
34
|
var disabledStyles = null;
|
|
17
|
-
|
|
35
|
+
|
|
36
|
+
// Disabled + Checked/Indeterminate
|
|
37
|
+
var disabledCheckedStyles = null;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Legacy label styles with --local-* CSS custom properties.
|
|
41
|
+
* These are consumed by the nested sibling selectors in checkbox.tsx.
|
|
42
|
+
*/
|
|
43
|
+
var legacyBaseStyles = null;
|
|
44
|
+
var legacyTextLabelLayoutStyles = null;
|
|
45
|
+
var legacyDisabledStyles = null;
|
|
46
|
+
var legacyLabelStyles = null;
|
|
18
47
|
function Label(_ref) {
|
|
19
48
|
var children = _ref.children,
|
|
20
49
|
isDisabled = _ref.isDisabled,
|
|
50
|
+
isChecked = _ref.isChecked,
|
|
51
|
+
isIndeterminate = _ref.isIndeterminate,
|
|
52
|
+
isInvalid = _ref.isInvalid,
|
|
21
53
|
testId = _ref.testId,
|
|
22
54
|
label = _ref.label,
|
|
23
55
|
id = _ref.id,
|
|
24
56
|
xcss = _ref.xcss;
|
|
57
|
+
if ((0, _platformFeatureFlags.fg)('platform-checkbox-atomic-styles')) {
|
|
58
|
+
return /*#__PURE__*/React.createElement("label", {
|
|
59
|
+
className: (0, _runtime.ax)(["_11c8fhey _1e0c11p5 _1ejihkll _umai184x _1qwn1j9a _f0grrsbi _1c53glyw _1e9d1j28 _syazi7uo _80om73ad _ljcgdfik _1vj5l4ek _dh4gr01l _cz1u1l7x _jom5wc43 _1s071onz _106f1onz", label && "_zulp1nu5 _yv0ey09t", (isChecked || isIndeterminate) && "_1qwnjmqp _f0grjmqp _1e9d5w2r _1vj51q28 _q29q1q28 _dh4gr01l _cz1u1l7x _zoo95w2r _jom5wc43 _1s071onz _106f1onz", isInvalid && "_f0gr1bqt _q29q1bqt _cz1u1bqt _1s07gir2", isDisabled && "_1qwnby5v _f0grby5v _syaz1tvo _80om13gf _1vj5by5v _q29qby5v _dh4gby5v _cz1uby5v _jom5wc43 _1s0718qt _106f18qt", isDisabled && (isChecked || isIndeterminate) && "_1e9d2sac _9js12sac _zoo92sac", xcss]),
|
|
60
|
+
"data-testid": testId,
|
|
61
|
+
"data-disabled": isDisabled || undefined,
|
|
62
|
+
id: id
|
|
63
|
+
}, children);
|
|
64
|
+
}
|
|
25
65
|
return /*#__PURE__*/React.createElement("label", {
|
|
26
66
|
className: (0, _runtime.ax)(["_11c8fhey _1e0c11p5 _1ejihkll _umai184x _syazovqm _80om73ad", label && "_zulp1nu5 _yv0ey09t", isDisabled && "_syaz7wap _80om13gf", "_h5e31kd8 _1nzs1kc0 _1esz1j4g _yp0j1ehr _ay2w1ouc _d51u12ci _phftddza _1g1fe69j _l6wk1j4g _1dik1ehr _1sfg1380 _fpdj1ouc _1yjc3zdg _oaj1ddza _1j3h1380 _eawbxz7c _1rdaeh7q _18q0snw8 _13hr1j28", xcss]),
|
|
27
67
|
"data-testid": testId,
|
package/dist/es2019/checkbox.js
CHANGED
|
@@ -6,17 +6,27 @@ import { ax, ix } from "@compiled/react/runtime";
|
|
|
6
6
|
import { forwardRef, memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
7
7
|
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatformLeafEventHandler';
|
|
8
8
|
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
9
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
10
|
import { CheckboxIcon, Label, LabelText, RequiredIndicator } from './internal';
|
|
10
11
|
/**
|
|
12
|
+
* The input is visually hidden but remains in the DOM for accessibility.
|
|
13
|
+
* State-based styling is handled by the Label component using CSS custom properties
|
|
14
|
+
* that cascade to the CheckboxIcon, avoiding nested sibling selectors.
|
|
15
|
+
*/
|
|
16
|
+
const checkboxStyles = {
|
|
17
|
+
root: "_19itglyw _nd5lfibj _12ji1r31 _1qu2glyw _12y31o36 _1bsb1osq _4t3i1osq _r06hglyw _6rthze3t _1pfhze3t _12l2ze3t _ahbqze3t _tzy4idpf"
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Legacy hidden input styles with nested sibling selectors.
|
|
22
|
+
* Used when the `platform-checkbox-atomic-styles` feature gate is disabled.
|
|
11
23
|
* Using `cssMap` to avoid a Compiled bug with the transformed styles.
|
|
12
24
|
* It was using a CSS variable for the outline template string,
|
|
13
25
|
* which broke because of the use of a sibling selector.
|
|
14
26
|
*
|
|
15
27
|
* Related to: https://github.com/atlassian-labs/compiled/pull/1795
|
|
16
|
-
*
|
|
17
|
-
* Using `cssMap` seems to be a workaround for this.
|
|
18
28
|
*/
|
|
19
|
-
const
|
|
29
|
+
const checkboxStylesLegacy = {
|
|
20
30
|
root: "_19itglyw _nd5lfibj _12ji1r31 _1qu2glyw _12y31o36 _1bsb1osq _4t3i1osq _r06hglyw _6rthze3t _1pfhze3t _12l2ze3t _ahbqze3t _tzy4idpf _r050fibj _9bg71mn3 _19op11so _a30fhteq _1610e4h9 _13wo93zu _q5a61gyf _8gq114p8 _wje2mov0 _1fo21cni _eyedglyw _1ef78r4n _1h6r8r4n _smzg1nfn _1dk71nfn _l71j1i6y _t34a1i6y _y32gkivo _1ah9199y _1frj180l _h78e1g3k _dwvb1ps2 _1bok170n _1mhr17cl _fx2i3rva _10oaq2ws _w12s155b _15y61vek _e6ww155b _sg1j1vek _rphw18jz _y9y9mz2b _141bmz2b _255gmz2b _jj67mz2b _swhgmz2b _axq81diq _1jiz1diq _s9051diq _1efy1diq _1oav1diq _10y313gf _1wt913gf _qq8613gf _1adw13gf _12sr13gf _16jiglyw _693jglyw _1niqglyw _cl9tglyw _1jbnglyw _j1ta1hou _18qu1ps2 _1g52170n _1log17cl _32hzmz2b _1vv91diq _yjhd1hou _w1cowc43 _jdqn1onz _4y4t1onz _lvfrwc43 _g68dwc43 _13dk1onz _w1el1onz _a9yw1onz _1l3g1onz _dcdpgir2 _wobcgir2 _rp9wgir2 _9ebfwc43 _e43iwc43 _1tkuwc43 _1lehwc43 _b9q3wc43 _tu2918qt _1uxv18qt _1ufw18qt _opo918qt _1e8318qt _1k3d18qt _25yv18qt _1igz18qt _c7cc18qt _1swg18qt"
|
|
21
31
|
};
|
|
22
32
|
|
|
@@ -73,6 +83,9 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Checkbox({
|
|
|
73
83
|
}, [isIndeterminate]);
|
|
74
84
|
return /*#__PURE__*/React.createElement(Label, {
|
|
75
85
|
isDisabled: isDisabled,
|
|
86
|
+
isChecked: fg('platform-checkbox-atomic-styles') ? isChecked : undefined,
|
|
87
|
+
isIndeterminate: fg('platform-checkbox-atomic-styles') ? isIndeterminate : undefined,
|
|
88
|
+
isInvalid: fg('platform-checkbox-atomic-styles') ? isInvalid : undefined,
|
|
76
89
|
label: label,
|
|
77
90
|
id: rest.id ? `${rest.id}-label` : undefined,
|
|
78
91
|
testId: testId && `${testId}--checkbox-label`
|
|
@@ -92,7 +105,7 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Checkbox({
|
|
|
92
105
|
name: name,
|
|
93
106
|
required: isRequired,
|
|
94
107
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
95
|
-
className: ax([checkboxStyles.root, className]),
|
|
108
|
+
className: ax([fg('platform-checkbox-atomic-styles') && checkboxStyles.root, !fg('platform-checkbox-atomic-styles') && checkboxStylesLegacy.root, className]),
|
|
96
109
|
onChange: onChangeAnalytics,
|
|
97
110
|
"aria-invalid": isInvalid ? 'true' : undefined,
|
|
98
111
|
"data-testid": testId && `${testId}--hidden-checkbox`,
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
._1a3742bt{outline:var(--checkbox-outline)}
|
|
3
|
+
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
4
|
+
._nd5lfibj{grid-area:1/1/2/2}
|
|
5
|
+
._v56411so{transition:stroke .2s ease-in-out}
|
|
6
|
+
._v5641mn3{transition:color .2s ease-in-out,fill .2s ease-in-out}._18m915vq{overflow-y:hidden}
|
|
7
|
+
._1cwg1i6y{outline-offset:var(--ds-space-negative-025,-2px)}
|
|
2
8
|
._1reo15vq{overflow-x:hidden}
|
|
9
|
+
._1s17hteq{stroke:var(--checkbox-border-color)}
|
|
10
|
+
._1snbe4h9{stroke-width:var(--ds-border-width,1px)}
|
|
3
11
|
._lcxvglyw{pointer-events:none}
|
|
4
|
-
.
|
|
12
|
+
._lswu1kgh{fill:var(--checkbox-tick-color,var(--ds-surface,#fff))}
|
|
13
|
+
._lswuvuon{fill:var(--ds-surface,#fff)}
|
|
14
|
+
._syazmov0{color:var(--checkbox-background-color)}
|
|
@@ -3,7 +3,22 @@ import "./checkbox-icon.compiled.css";
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
5
|
import { memo, useMemo } from 'react';
|
|
6
|
-
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
/**
|
|
8
|
+
* Styles for the checkbox icon.
|
|
9
|
+
* CSS custom properties for colors are set by the parent Label element
|
|
10
|
+
* and consumed directly in these styles.
|
|
11
|
+
*/
|
|
12
|
+
const svgStyles = {
|
|
13
|
+
root: "_nd5lfibj _1reo15vq _18m915vq _v5641mn3 _2rko12b0 _1a3742bt _lcxvglyw _syazmov0 _lswu1kgh _1cwg1i6y",
|
|
14
|
+
rect: "_v56411so _1snbe4h9 _1s17hteq"
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Legacy SVG styles.
|
|
19
|
+
* Used when the `platform-checkbox-atomic-styles` feature gate is disabled.
|
|
20
|
+
*/
|
|
21
|
+
const svgStylesLegacy = null;
|
|
7
22
|
function getIcon(isIndeterminate, isChecked) {
|
|
8
23
|
if (isIndeterminate) {
|
|
9
24
|
return /*#__PURE__*/React.createElement("path", {
|
|
@@ -25,7 +40,6 @@ function getIcon(isIndeterminate, isChecked) {
|
|
|
25
40
|
// No icon
|
|
26
41
|
return null;
|
|
27
42
|
}
|
|
28
|
-
|
|
29
43
|
/**
|
|
30
44
|
* __Checkbox icon__
|
|
31
45
|
*
|
|
@@ -39,6 +53,27 @@ const CheckboxIcon = /*#__PURE__*/memo(({
|
|
|
39
53
|
isChecked
|
|
40
54
|
}) => {
|
|
41
55
|
const icon = useMemo(() => getIcon(isIndeterminate, isChecked), [isIndeterminate, isChecked]);
|
|
56
|
+
if (fg('platform-checkbox-atomic-styles')) {
|
|
57
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
58
|
+
width: 24,
|
|
59
|
+
height: 24,
|
|
60
|
+
viewBox: "0 0 24 24",
|
|
61
|
+
role: "presentation",
|
|
62
|
+
className: ax([svgStyles.root])
|
|
63
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
64
|
+
fillRule: "evenodd"
|
|
65
|
+
}, /*#__PURE__*/React.createElement("rect", {
|
|
66
|
+
fill: "currentColor",
|
|
67
|
+
x: "5.5",
|
|
68
|
+
y: "5.5",
|
|
69
|
+
width: "13",
|
|
70
|
+
height: "13",
|
|
71
|
+
rx: "1.5",
|
|
72
|
+
className: ax([svgStyles.rect])
|
|
73
|
+
}), icon));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Legacy rendering with inline style props for CSS variable consumption
|
|
42
77
|
return /*#__PURE__*/React.createElement("svg", {
|
|
43
78
|
width: 24,
|
|
44
79
|
height: 24,
|
|
@@ -2,13 +2,20 @@
|
|
|
2
2
|
._zulp1nu5{gap:var(--ds-space-0,0) var(--ds-space-050,4px)}
|
|
3
3
|
._13hr1j28{--local-tick-rest:transparent}
|
|
4
4
|
._18q015t7{--local-tick-disabled:var(--ds-icon-disabled,#a5adba)}
|
|
5
|
+
._1c53glyw{--checkbox-outline:none}
|
|
5
6
|
._1dikhh5a{--local-border-checked-hover:var(--ds-background-selected-bold-hovered,#0065ff)}
|
|
6
7
|
._1e0c11p5{display:grid}
|
|
8
|
+
._1e9d1j28{--checkbox-tick-color:transparent}
|
|
9
|
+
._1e9d2sac{--checkbox-tick-color:var(--ds-icon-disabled,#080f214a)}
|
|
10
|
+
._1e9d5w2r{--checkbox-tick-color:var(--ds-icon-inverse,#fff)}
|
|
7
11
|
._1ejihkll{grid-auto-columns:1fr}
|
|
8
12
|
._1eszzyvw{--local-background-checked:var(--ds-background-selected-bold,#0052cc)}
|
|
9
13
|
._1g1funzk{--local-border-active:var(--ds-border,#deebff)}
|
|
10
14
|
._1j3h1q3k{--local-border-invalid:var(--ds-border-danger,#ff5630)}
|
|
11
15
|
._1nzs11d3{--local-background-active:var(--ds-background-input-pressed,#deebff)}
|
|
16
|
+
._1qwn1j9a{--checkbox-background-color:var(--ds-background-input,#fff)}
|
|
17
|
+
._1qwnby5v{--checkbox-background-color:var(--ds-background-disabled,#17171708)}
|
|
18
|
+
._1qwnjmqp{--checkbox-background-color:var(--ds-background-selected-bold,#1868db)}
|
|
12
19
|
._1rda1qbb{--local-tick-checked:var(--ds-icon-inverse,#fafbfc)}
|
|
13
20
|
._1sfg1q3k{--local-border-checked-invalid:var(--ds-border-danger,#ff5630)}
|
|
14
21
|
._1yjc194a{--local-border-focus:var(--ds-border-focused,#2684ff)}
|
|
@@ -17,13 +24,34 @@
|
|
|
17
24
|
._ay2w1y1w{--local-background-disabled:var(--ds-background-disabled,#f4f5f7)}
|
|
18
25
|
._d51u10ko{--local-background-hover:var(--ds-background-input-hovered,#ebecf0)}
|
|
19
26
|
._eawb1dzn{--local-tick-active:var(--ds-icon-inverse,#0052cc)}
|
|
27
|
+
._f0gr1bqt{--checkbox-border-color:var(--ds-border-danger,#e2483d)}
|
|
28
|
+
._f0grby5v{--checkbox-border-color:var(--ds-background-disabled,#17171708)}
|
|
29
|
+
._f0grjmqp{--checkbox-border-color:var(--ds-background-selected-bold,#1868db)}
|
|
30
|
+
._f0grrsbi{--checkbox-border-color:var(--ds-border-input,#8c8f97)}
|
|
20
31
|
._fpdj1y1w{--local-border-disabled:var(--ds-background-disabled,#f4f5f7)}
|
|
21
32
|
._h5e3mag2{--local-background:var(--ds-background-input,#fafbfc)}
|
|
22
33
|
._l6wkzyvw{--local-border-checked:var(--ds-background-selected-bold,#0052cc)}
|
|
23
34
|
._oaj11fmg{--local-border-hover:var(--ds-border-input,#7a869a)}
|
|
24
35
|
._phft1fmg{--local-border:var(--ds-border-input,#7a869a)}
|
|
25
36
|
._syaz1tvo{color:var(--ds-text-disabled,#97a0af)}
|
|
37
|
+
._syazi7uo{color:var(--ds-text,#292a2e)}
|
|
26
38
|
._syazj3m3{color:var(--ds-text,#091e42)}
|
|
27
39
|
._umai184x{grid-auto-rows:min-content}
|
|
28
40
|
._yp0jhh5a{--local-background-checked-hover:var(--ds-background-selected-bold-hovered,#0065ff)}
|
|
29
|
-
._yv0ey09t{grid-template-columns:min-content auto}
|
|
41
|
+
._yv0ey09t{grid-template-columns:min-content auto}
|
|
42
|
+
._ljcgdfik:focus-within{--checkbox-outline:var(--ds-border-width-focused,2px) solid var(--ds-border-focused,#4688ec)}
|
|
43
|
+
._1vj51q28:hover{--checkbox-background-color:var(--ds-background-selected-bold-hovered,#1558bc)}
|
|
44
|
+
._1vj5by5v:hover{--checkbox-background-color:var(--ds-background-disabled,#17171708)}
|
|
45
|
+
._1vj5l4ek:hover{--checkbox-background-color:var(--ds-background-input-hovered,#f8f8f8)}
|
|
46
|
+
._9js12sac:hover{--checkbox-tick-color:var(--ds-icon-disabled,#080f214a)}
|
|
47
|
+
._q29q1bqt:hover{--checkbox-border-color:var(--ds-border-danger,#e2483d)}
|
|
48
|
+
._q29q1q28:hover{--checkbox-border-color:var(--ds-background-selected-bold-hovered,#1558bc)}
|
|
49
|
+
._q29qby5v:hover{--checkbox-border-color:var(--ds-background-disabled,#17171708)}
|
|
50
|
+
._cz1u1bqt:active{--checkbox-border-color:var(--ds-border-danger,#e2483d)}
|
|
51
|
+
._cz1u1l7x:active{--checkbox-border-color:var(--ds-border,#0b120e24)}
|
|
52
|
+
._cz1uby5v:active{--checkbox-border-color:var(--ds-background-disabled,#17171708)}
|
|
53
|
+
._dh4gby5v:active{--checkbox-background-color:var(--ds-background-disabled,#17171708)}
|
|
54
|
+
._dh4gr01l:active{--checkbox-background-color:var(--ds-background-input-pressed,#fff)}
|
|
55
|
+
._zoo92sac:active{--checkbox-tick-color:var(--ds-icon-disabled,#080f214a)}
|
|
56
|
+
._zoo95w2r:active{--checkbox-tick-color:var(--ds-icon-inverse,#fff)}
|
|
57
|
+
@media screen and (forced-colors:active){._1s07gir2{--checkbox-border-color:Highlight}._jom5wc43{--checkbox-background-color:Canvas}._1s0718qt{--checkbox-border-color:GrayText}._106f18qt{--checkbox-tick-color:GrayText}._1s071onz{--checkbox-border-color:CanvasText}._106f1onz{--checkbox-tick-color:CanvasText}}
|
|
@@ -2,19 +2,59 @@
|
|
|
2
2
|
import "./label.compiled.css";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { B200, B300, B400, B50, N10, N100, N20, N30, N70, N80, N900, R300 } from '@atlaskit/theme/colors';
|
|
7
|
+
/**
|
|
8
|
+
* Base state styles with CSS custom properties.
|
|
9
|
+
* Pseudo-selectors (:hover, :focus-within, :active) on the label element
|
|
10
|
+
* update CSS variables that cascade to the CheckboxIcon.
|
|
11
|
+
* This avoids nested sibling selectors.
|
|
12
|
+
*
|
|
13
|
+
* Uses `css` over `cssMap` to work around a bug in Compiled types when
|
|
14
|
+
* using CSS variables in pseudo-selectors.
|
|
15
|
+
*/
|
|
6
16
|
const baseStyles = null;
|
|
7
17
|
const textLabelLayoutStyles = null;
|
|
18
|
+
|
|
19
|
+
// Checked/Indeterminate state
|
|
20
|
+
const checkedStyles = null;
|
|
21
|
+
|
|
22
|
+
// Invalid state - must override hover/active to maintain red border
|
|
23
|
+
const invalidStyles = null;
|
|
24
|
+
|
|
25
|
+
// Disabled state - must override hover/active to maintain disabled appearance
|
|
8
26
|
const disabledStyles = null;
|
|
9
|
-
|
|
27
|
+
|
|
28
|
+
// Disabled + Checked/Indeterminate
|
|
29
|
+
const disabledCheckedStyles = null;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Legacy label styles with --local-* CSS custom properties.
|
|
33
|
+
* These are consumed by the nested sibling selectors in checkbox.tsx.
|
|
34
|
+
*/
|
|
35
|
+
const legacyBaseStyles = null;
|
|
36
|
+
const legacyTextLabelLayoutStyles = null;
|
|
37
|
+
const legacyDisabledStyles = null;
|
|
38
|
+
const legacyLabelStyles = null;
|
|
10
39
|
export default function Label({
|
|
11
40
|
children,
|
|
12
41
|
isDisabled,
|
|
42
|
+
isChecked,
|
|
43
|
+
isIndeterminate,
|
|
44
|
+
isInvalid,
|
|
13
45
|
testId,
|
|
14
46
|
label,
|
|
15
47
|
id,
|
|
16
48
|
xcss
|
|
17
49
|
}) {
|
|
50
|
+
if (fg('platform-checkbox-atomic-styles')) {
|
|
51
|
+
return /*#__PURE__*/React.createElement("label", {
|
|
52
|
+
className: ax(["_11c8fhey _1e0c11p5 _1ejihkll _umai184x _1qwn1j9a _f0grrsbi _1c53glyw _1e9d1j28 _syazi7uo _80om73ad _ljcgdfik _1vj5l4ek _dh4gr01l _cz1u1l7x _jom5wc43 _1s071onz _106f1onz", label && "_zulp1nu5 _yv0ey09t", (isChecked || isIndeterminate) && "_1qwnjmqp _f0grjmqp _1e9d5w2r _1vj51q28 _q29q1q28 _dh4gr01l _cz1u1l7x _zoo95w2r _jom5wc43 _1s071onz _106f1onz", isInvalid && "_f0gr1bqt _q29q1bqt _cz1u1bqt _1s07gir2", isDisabled && "_1qwnby5v _f0grby5v _syaz1tvo _80om13gf _1vj5by5v _q29qby5v _dh4gby5v _cz1uby5v _jom5wc43 _1s0718qt _106f18qt", isDisabled && (isChecked || isIndeterminate) && "_1e9d2sac _9js12sac _zoo92sac", xcss]),
|
|
53
|
+
"data-testid": testId,
|
|
54
|
+
"data-disabled": isDisabled || undefined,
|
|
55
|
+
id: id
|
|
56
|
+
}, children);
|
|
57
|
+
}
|
|
18
58
|
return /*#__PURE__*/React.createElement("label", {
|
|
19
59
|
className: ax(["_11c8fhey _1e0c11p5 _1ejihkll _umai184x _syazj3m3 _80om73ad", label && "_zulp1nu5 _yv0ey09t", isDisabled && "_syaz1tvo _80om13gf", "_h5e3mag2 _1nzs11d3 _1eszzyvw _yp0jhh5a _ay2w1y1w _d51u10ko _phft1fmg _1g1funzk _l6wkzyvw _1dikhh5a _1sfg1q3k _fpdj1y1w _1yjc194a _oaj11fmg _1j3h1q3k _eawb1dzn _1rda1qbb _18q015t7 _13hr1j28", xcss]),
|
|
20
60
|
"data-testid": testId,
|
package/dist/esm/checkbox.js
CHANGED
|
@@ -9,17 +9,27 @@ import { ax, ix } from "@compiled/react/runtime";
|
|
|
9
9
|
import { forwardRef, memo, useCallback, useEffect, useRef, useState } from 'react';
|
|
10
10
|
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatformLeafEventHandler';
|
|
11
11
|
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
12
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
12
13
|
import { CheckboxIcon, Label, LabelText, RequiredIndicator } from './internal';
|
|
13
14
|
/**
|
|
15
|
+
* The input is visually hidden but remains in the DOM for accessibility.
|
|
16
|
+
* State-based styling is handled by the Label component using CSS custom properties
|
|
17
|
+
* that cascade to the CheckboxIcon, avoiding nested sibling selectors.
|
|
18
|
+
*/
|
|
19
|
+
var checkboxStyles = {
|
|
20
|
+
root: "_19itglyw _nd5lfibj _12ji1r31 _1qu2glyw _12y31o36 _1bsb1osq _4t3i1osq _r06hglyw _6rthze3t _1pfhze3t _12l2ze3t _ahbqze3t _tzy4idpf"
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Legacy hidden input styles with nested sibling selectors.
|
|
25
|
+
* Used when the `platform-checkbox-atomic-styles` feature gate is disabled.
|
|
14
26
|
* Using `cssMap` to avoid a Compiled bug with the transformed styles.
|
|
15
27
|
* It was using a CSS variable for the outline template string,
|
|
16
28
|
* which broke because of the use of a sibling selector.
|
|
17
29
|
*
|
|
18
30
|
* Related to: https://github.com/atlassian-labs/compiled/pull/1795
|
|
19
|
-
*
|
|
20
|
-
* Using `cssMap` seems to be a workaround for this.
|
|
21
31
|
*/
|
|
22
|
-
var
|
|
32
|
+
var checkboxStylesLegacy = {
|
|
23
33
|
root: "_19itglyw _nd5lfibj _12ji1r31 _1qu2glyw _12y31o36 _1bsb1osq _4t3i1osq _r06hglyw _6rthze3t _1pfhze3t _12l2ze3t _ahbqze3t _tzy4idpf _r050fibj _9bg71mn3 _19op11so _a30fhteq _1610e4h9 _13wo93zu _q5a61gyf _8gq114p8 _wje2mov0 _1fo21cni _eyedglyw _1ef78r4n _1h6r8r4n _smzg1nfn _1dk71nfn _l71j1i6y _t34a1i6y _y32gkivo _1ah9199y _1frj180l _h78e1g3k _dwvb1ps2 _1bok170n _1mhr17cl _fx2i3rva _10oaq2ws _w12s155b _15y61vek _e6ww155b _sg1j1vek _rphw18jz _y9y9mz2b _141bmz2b _255gmz2b _jj67mz2b _swhgmz2b _axq81diq _1jiz1diq _s9051diq _1efy1diq _1oav1diq _10y313gf _1wt913gf _qq8613gf _1adw13gf _12sr13gf _16jiglyw _693jglyw _1niqglyw _cl9tglyw _1jbnglyw _j1ta1hou _18qu1ps2 _1g52170n _1log17cl _32hzmz2b _1vv91diq _yjhd1hou _w1cowc43 _jdqn1onz _4y4t1onz _lvfrwc43 _g68dwc43 _13dk1onz _w1el1onz _a9yw1onz _1l3g1onz _dcdpgir2 _wobcgir2 _rp9wgir2 _9ebfwc43 _e43iwc43 _1tkuwc43 _1lehwc43 _b9q3wc43 _tu2918qt _1uxv18qt _1ufw18qt _opo918qt _1e8318qt _1k3d18qt _25yv18qt _1igz18qt _c7cc18qt _1swg18qt"
|
|
24
34
|
};
|
|
25
35
|
|
|
@@ -82,6 +92,9 @@ var Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Checkbox(_ref
|
|
|
82
92
|
}, [isIndeterminate]);
|
|
83
93
|
return /*#__PURE__*/React.createElement(Label, {
|
|
84
94
|
isDisabled: isDisabled,
|
|
95
|
+
isChecked: fg('platform-checkbox-atomic-styles') ? isChecked : undefined,
|
|
96
|
+
isIndeterminate: fg('platform-checkbox-atomic-styles') ? isIndeterminate : undefined,
|
|
97
|
+
isInvalid: fg('platform-checkbox-atomic-styles') ? isInvalid : undefined,
|
|
85
98
|
label: label,
|
|
86
99
|
id: rest.id ? "".concat(rest.id, "-label") : undefined,
|
|
87
100
|
testId: testId && "".concat(testId, "--checkbox-label")
|
|
@@ -101,7 +114,7 @@ var Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Checkbox(_ref
|
|
|
101
114
|
name: name,
|
|
102
115
|
required: isRequired,
|
|
103
116
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop
|
|
104
|
-
className: ax([checkboxStyles.root, className]),
|
|
117
|
+
className: ax([fg('platform-checkbox-atomic-styles') && checkboxStyles.root, !fg('platform-checkbox-atomic-styles') && checkboxStylesLegacy.root, className]),
|
|
105
118
|
onChange: onChangeAnalytics,
|
|
106
119
|
"aria-invalid": isInvalid ? 'true' : undefined,
|
|
107
120
|
"data-testid": testId && "".concat(testId, "--hidden-checkbox"),
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
._1a3742bt{outline:var(--checkbox-outline)}
|
|
3
|
+
._2rko12b0{border-radius:var(--ds-radius-small,4px)}
|
|
4
|
+
._nd5lfibj{grid-area:1/1/2/2}
|
|
5
|
+
._v56411so{transition:stroke .2s ease-in-out}
|
|
6
|
+
._v5641mn3{transition:color .2s ease-in-out,fill .2s ease-in-out}._18m915vq{overflow-y:hidden}
|
|
7
|
+
._1cwg1i6y{outline-offset:var(--ds-space-negative-025,-2px)}
|
|
2
8
|
._1reo15vq{overflow-x:hidden}
|
|
9
|
+
._1s17hteq{stroke:var(--checkbox-border-color)}
|
|
10
|
+
._1snbe4h9{stroke-width:var(--ds-border-width,1px)}
|
|
3
11
|
._lcxvglyw{pointer-events:none}
|
|
4
|
-
.
|
|
12
|
+
._lswu1kgh{fill:var(--checkbox-tick-color,var(--ds-surface,#fff))}
|
|
13
|
+
._lswuvuon{fill:var(--ds-surface,#fff)}
|
|
14
|
+
._syazmov0{color:var(--checkbox-background-color)}
|
|
@@ -3,7 +3,22 @@ import "./checkbox-icon.compiled.css";
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
5
|
import { memo, useMemo } from 'react';
|
|
6
|
-
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
7
|
+
/**
|
|
8
|
+
* Styles for the checkbox icon.
|
|
9
|
+
* CSS custom properties for colors are set by the parent Label element
|
|
10
|
+
* and consumed directly in these styles.
|
|
11
|
+
*/
|
|
12
|
+
var svgStyles = {
|
|
13
|
+
root: "_nd5lfibj _1reo15vq _18m915vq _v5641mn3 _2rko12b0 _1a3742bt _lcxvglyw _syazmov0 _lswu1kgh _1cwg1i6y",
|
|
14
|
+
rect: "_v56411so _1snbe4h9 _1s17hteq"
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Legacy SVG styles.
|
|
19
|
+
* Used when the `platform-checkbox-atomic-styles` feature gate is disabled.
|
|
20
|
+
*/
|
|
21
|
+
var svgStylesLegacy = null;
|
|
7
22
|
function getIcon(isIndeterminate, isChecked) {
|
|
8
23
|
if (isIndeterminate) {
|
|
9
24
|
return /*#__PURE__*/React.createElement("path", {
|
|
@@ -25,7 +40,6 @@ function getIcon(isIndeterminate, isChecked) {
|
|
|
25
40
|
// No icon
|
|
26
41
|
return null;
|
|
27
42
|
}
|
|
28
|
-
|
|
29
43
|
/**
|
|
30
44
|
* __Checkbox icon__
|
|
31
45
|
*
|
|
@@ -40,6 +54,27 @@ var CheckboxIcon = /*#__PURE__*/memo(function (_ref) {
|
|
|
40
54
|
var icon = useMemo(function () {
|
|
41
55
|
return getIcon(isIndeterminate, isChecked);
|
|
42
56
|
}, [isIndeterminate, isChecked]);
|
|
57
|
+
if (fg('platform-checkbox-atomic-styles')) {
|
|
58
|
+
return /*#__PURE__*/React.createElement("svg", {
|
|
59
|
+
width: 24,
|
|
60
|
+
height: 24,
|
|
61
|
+
viewBox: "0 0 24 24",
|
|
62
|
+
role: "presentation",
|
|
63
|
+
className: ax([svgStyles.root])
|
|
64
|
+
}, /*#__PURE__*/React.createElement("g", {
|
|
65
|
+
fillRule: "evenodd"
|
|
66
|
+
}, /*#__PURE__*/React.createElement("rect", {
|
|
67
|
+
fill: "currentColor",
|
|
68
|
+
x: "5.5",
|
|
69
|
+
y: "5.5",
|
|
70
|
+
width: "13",
|
|
71
|
+
height: "13",
|
|
72
|
+
rx: "1.5",
|
|
73
|
+
className: ax([svgStyles.rect])
|
|
74
|
+
}), icon));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// Legacy rendering with inline style props for CSS variable consumption
|
|
43
78
|
return /*#__PURE__*/React.createElement("svg", {
|
|
44
79
|
width: 24,
|
|
45
80
|
height: 24,
|
|
@@ -2,13 +2,20 @@
|
|
|
2
2
|
._zulp1nu5{gap:var(--ds-space-0,0) var(--ds-space-050,4px)}
|
|
3
3
|
._13hr1j28{--local-tick-rest:transparent}
|
|
4
4
|
._18q0snw8{--local-tick-disabled:var(--_1xmcmw9)}
|
|
5
|
+
._1c53glyw{--checkbox-outline:none}
|
|
5
6
|
._1dik1ehr{--local-border-checked-hover:var(--_14y1fod)}
|
|
6
7
|
._1e0c11p5{display:grid}
|
|
8
|
+
._1e9d1j28{--checkbox-tick-color:transparent}
|
|
9
|
+
._1e9d2sac{--checkbox-tick-color:var(--ds-icon-disabled,#080f214a)}
|
|
10
|
+
._1e9d5w2r{--checkbox-tick-color:var(--ds-icon-inverse,#fff)}
|
|
7
11
|
._1ejihkll{grid-auto-columns:1fr}
|
|
8
12
|
._1esz1j4g{--local-background-checked:var(--_1gcp7nr)}
|
|
9
13
|
._1g1fe69j{--local-border-active:var(--_rczcge)}
|
|
10
14
|
._1j3h1380{--local-border-invalid:var(--_1i4xulb)}
|
|
11
15
|
._1nzs1kc0{--local-background-active:var(--_1cd0fcx)}
|
|
16
|
+
._1qwn1j9a{--checkbox-background-color:var(--ds-background-input,#fff)}
|
|
17
|
+
._1qwnby5v{--checkbox-background-color:var(--ds-background-disabled,#17171708)}
|
|
18
|
+
._1qwnjmqp{--checkbox-background-color:var(--ds-background-selected-bold,#1868db)}
|
|
12
19
|
._1rdaeh7q{--local-tick-checked:var(--_jf353p)}
|
|
13
20
|
._1sfg1380{--local-border-checked-invalid:var(--_1i4xulb)}
|
|
14
21
|
._1yjc3zdg{--local-border-focus:var(--_xjqa3d)}
|
|
@@ -17,13 +24,35 @@
|
|
|
17
24
|
._ay2w1ouc{--local-background-disabled:var(--_r5pknd)}
|
|
18
25
|
._d51u12ci{--local-background-hover:var(--_1z08gfx)}
|
|
19
26
|
._eawbxz7c{--local-tick-active:var(--_uq1ko9)}
|
|
27
|
+
._f0gr1bqt{--checkbox-border-color:var(--ds-border-danger,#e2483d)}
|
|
28
|
+
._f0grby5v{--checkbox-border-color:var(--ds-background-disabled,#17171708)}
|
|
29
|
+
._f0grjmqp{--checkbox-border-color:var(--ds-background-selected-bold,#1868db)}
|
|
30
|
+
._f0grrsbi{--checkbox-border-color:var(--ds-border-input,#8c8f97)}
|
|
20
31
|
._fpdj1ouc{--local-border-disabled:var(--_r5pknd)}
|
|
21
32
|
._h5e31kd8{--local-background:var(--_4mkb4g)}
|
|
22
33
|
._l6wk1j4g{--local-border-checked:var(--_1gcp7nr)}
|
|
23
34
|
._oaj1ddza{--local-border-hover:var(--_vnm8xo)}
|
|
24
35
|
._phftddza{--local-border:var(--_vnm8xo)}
|
|
36
|
+
._syaz1tvo{color:var(--ds-text-disabled,#97a0af)}
|
|
25
37
|
._syaz7wap{color:var(--_1ynhf1h)}
|
|
38
|
+
._syazi7uo{color:var(--ds-text,#292a2e)}
|
|
26
39
|
._syazovqm{color:var(--_5xk3r4)}
|
|
27
40
|
._umai184x{grid-auto-rows:min-content}
|
|
28
41
|
._yp0j1ehr{--local-background-checked-hover:var(--_14y1fod)}
|
|
29
|
-
._yv0ey09t{grid-template-columns:min-content auto}
|
|
42
|
+
._yv0ey09t{grid-template-columns:min-content auto}
|
|
43
|
+
._ljcgdfik:focus-within{--checkbox-outline:var(--ds-border-width-focused,2px) solid var(--ds-border-focused,#4688ec)}
|
|
44
|
+
._1vj51q28:hover{--checkbox-background-color:var(--ds-background-selected-bold-hovered,#1558bc)}
|
|
45
|
+
._1vj5by5v:hover{--checkbox-background-color:var(--ds-background-disabled,#17171708)}
|
|
46
|
+
._1vj5l4ek:hover{--checkbox-background-color:var(--ds-background-input-hovered,#f8f8f8)}
|
|
47
|
+
._9js12sac:hover{--checkbox-tick-color:var(--ds-icon-disabled,#080f214a)}
|
|
48
|
+
._q29q1bqt:hover{--checkbox-border-color:var(--ds-border-danger,#e2483d)}
|
|
49
|
+
._q29q1q28:hover{--checkbox-border-color:var(--ds-background-selected-bold-hovered,#1558bc)}
|
|
50
|
+
._q29qby5v:hover{--checkbox-border-color:var(--ds-background-disabled,#17171708)}
|
|
51
|
+
._cz1u1bqt:active{--checkbox-border-color:var(--ds-border-danger,#e2483d)}
|
|
52
|
+
._cz1u1l7x:active{--checkbox-border-color:var(--ds-border,#0b120e24)}
|
|
53
|
+
._cz1uby5v:active{--checkbox-border-color:var(--ds-background-disabled,#17171708)}
|
|
54
|
+
._dh4gby5v:active{--checkbox-background-color:var(--ds-background-disabled,#17171708)}
|
|
55
|
+
._dh4gr01l:active{--checkbox-background-color:var(--ds-background-input-pressed,#fff)}
|
|
56
|
+
._zoo92sac:active{--checkbox-tick-color:var(--ds-icon-disabled,#080f214a)}
|
|
57
|
+
._zoo95w2r:active{--checkbox-tick-color:var(--ds-icon-inverse,#fff)}
|
|
58
|
+
@media screen and (forced-colors:active){._1s07gir2{--checkbox-border-color:Highlight}._jom5wc43{--checkbox-background-color:Canvas}._1s0718qt{--checkbox-border-color:GrayText}._106f18qt{--checkbox-tick-color:GrayText}._1s071onz{--checkbox-border-color:CanvasText}._106f1onz{--checkbox-tick-color:CanvasText}}
|
|
@@ -2,18 +2,58 @@
|
|
|
2
2
|
import "./label.compiled.css";
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { ax, ix } from "@compiled/react/runtime";
|
|
5
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
6
|
import { B200, B300, B400, B50, N10, N100, N20, N30, N70, N80, N900, R300 } from '@atlaskit/theme/colors';
|
|
7
|
+
/**
|
|
8
|
+
* Base state styles with CSS custom properties.
|
|
9
|
+
* Pseudo-selectors (:hover, :focus-within, :active) on the label element
|
|
10
|
+
* update CSS variables that cascade to the CheckboxIcon.
|
|
11
|
+
* This avoids nested sibling selectors.
|
|
12
|
+
*
|
|
13
|
+
* Uses `css` over `cssMap` to work around a bug in Compiled types when
|
|
14
|
+
* using CSS variables in pseudo-selectors.
|
|
15
|
+
*/
|
|
6
16
|
var baseStyles = null;
|
|
7
17
|
var textLabelLayoutStyles = null;
|
|
18
|
+
|
|
19
|
+
// Checked/Indeterminate state
|
|
20
|
+
var checkedStyles = null;
|
|
21
|
+
|
|
22
|
+
// Invalid state - must override hover/active to maintain red border
|
|
23
|
+
var invalidStyles = null;
|
|
24
|
+
|
|
25
|
+
// Disabled state - must override hover/active to maintain disabled appearance
|
|
8
26
|
var disabledStyles = null;
|
|
9
|
-
|
|
27
|
+
|
|
28
|
+
// Disabled + Checked/Indeterminate
|
|
29
|
+
var disabledCheckedStyles = null;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Legacy label styles with --local-* CSS custom properties.
|
|
33
|
+
* These are consumed by the nested sibling selectors in checkbox.tsx.
|
|
34
|
+
*/
|
|
35
|
+
var legacyBaseStyles = null;
|
|
36
|
+
var legacyTextLabelLayoutStyles = null;
|
|
37
|
+
var legacyDisabledStyles = null;
|
|
38
|
+
var legacyLabelStyles = null;
|
|
10
39
|
export default function Label(_ref) {
|
|
11
40
|
var children = _ref.children,
|
|
12
41
|
isDisabled = _ref.isDisabled,
|
|
42
|
+
isChecked = _ref.isChecked,
|
|
43
|
+
isIndeterminate = _ref.isIndeterminate,
|
|
44
|
+
isInvalid = _ref.isInvalid,
|
|
13
45
|
testId = _ref.testId,
|
|
14
46
|
label = _ref.label,
|
|
15
47
|
id = _ref.id,
|
|
16
48
|
xcss = _ref.xcss;
|
|
49
|
+
if (fg('platform-checkbox-atomic-styles')) {
|
|
50
|
+
return /*#__PURE__*/React.createElement("label", {
|
|
51
|
+
className: ax(["_11c8fhey _1e0c11p5 _1ejihkll _umai184x _1qwn1j9a _f0grrsbi _1c53glyw _1e9d1j28 _syazi7uo _80om73ad _ljcgdfik _1vj5l4ek _dh4gr01l _cz1u1l7x _jom5wc43 _1s071onz _106f1onz", label && "_zulp1nu5 _yv0ey09t", (isChecked || isIndeterminate) && "_1qwnjmqp _f0grjmqp _1e9d5w2r _1vj51q28 _q29q1q28 _dh4gr01l _cz1u1l7x _zoo95w2r _jom5wc43 _1s071onz _106f1onz", isInvalid && "_f0gr1bqt _q29q1bqt _cz1u1bqt _1s07gir2", isDisabled && "_1qwnby5v _f0grby5v _syaz1tvo _80om13gf _1vj5by5v _q29qby5v _dh4gby5v _cz1uby5v _jom5wc43 _1s0718qt _106f18qt", isDisabled && (isChecked || isIndeterminate) && "_1e9d2sac _9js12sac _zoo92sac", xcss]),
|
|
52
|
+
"data-testid": testId,
|
|
53
|
+
"data-disabled": isDisabled || undefined,
|
|
54
|
+
id: id
|
|
55
|
+
}, children);
|
|
56
|
+
}
|
|
17
57
|
return /*#__PURE__*/React.createElement("label", {
|
|
18
58
|
className: ax(["_11c8fhey _1e0c11p5 _1ejihkll _umai184x _syazovqm _80om73ad", label && "_zulp1nu5 _yv0ey09t", isDisabled && "_syaz7wap _80om13gf", "_h5e31kd8 _1nzs1kc0 _1esz1j4g _yp0j1ehr _ay2w1ouc _d51u12ci _phftddza _1g1fe69j _l6wk1j4g _1dik1ehr _1sfg1380 _fpdj1ouc _1yjc3zdg _oaj1ddza _1j3h1380 _eawbxz7c _1rdaeh7q _18q0snw8 _13hr1j28", xcss]),
|
|
19
59
|
"data-testid": testId,
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { type NamedExoticComponent } from 'react';
|
|
6
|
+
type CheckboxIconProps = {
|
|
7
|
+
isIndeterminate: boolean;
|
|
8
|
+
isChecked: boolean;
|
|
9
|
+
};
|
|
1
10
|
/**
|
|
2
11
|
* __Checkbox icon__
|
|
3
12
|
*
|
|
@@ -6,8 +15,5 @@
|
|
|
6
15
|
*
|
|
7
16
|
* @internal
|
|
8
17
|
*/
|
|
9
|
-
declare const CheckboxIcon:
|
|
10
|
-
isIndeterminate: boolean;
|
|
11
|
-
isChecked: boolean;
|
|
12
|
-
}>;
|
|
18
|
+
declare const CheckboxIcon: NamedExoticComponent<CheckboxIconProps>;
|
|
13
19
|
export default CheckboxIcon;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type LabelProps } from '../types';
|
|
2
|
-
export default function Label({ children, isDisabled, testId, label, id, xcss }: LabelProps): JSX.Element;
|
|
2
|
+
export default function Label({ children, isDisabled, isChecked, isIndeterminate, isInvalid, testId, label, id, xcss, }: LabelProps): JSX.Element;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -91,6 +91,21 @@ export interface LabelTextProps extends React.HTMLProps<HTMLSpanElement> {
|
|
|
91
91
|
}
|
|
92
92
|
export interface LabelProps extends React.HTMLProps<HTMLInputElement> {
|
|
93
93
|
isDisabled?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Whether the checkbox is checked.
|
|
96
|
+
* Used for conditional styling of the label.
|
|
97
|
+
*/
|
|
98
|
+
isChecked?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Whether the checkbox is in an indeterminate state.
|
|
101
|
+
* Used for conditional styling of the label.
|
|
102
|
+
*/
|
|
103
|
+
isIndeterminate?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Whether the checkbox is in an invalid state.
|
|
106
|
+
* Used for conditional styling of the label.
|
|
107
|
+
*/
|
|
108
|
+
isInvalid?: boolean;
|
|
94
109
|
/**
|
|
95
110
|
* A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
|
|
96
111
|
*/
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
* @jsx jsx
|
|
4
|
+
*/
|
|
5
|
+
import { type NamedExoticComponent } from 'react';
|
|
6
|
+
type CheckboxIconProps = {
|
|
7
|
+
isIndeterminate: boolean;
|
|
8
|
+
isChecked: boolean;
|
|
9
|
+
};
|
|
1
10
|
/**
|
|
2
11
|
* __Checkbox icon__
|
|
3
12
|
*
|
|
@@ -6,8 +15,5 @@
|
|
|
6
15
|
*
|
|
7
16
|
* @internal
|
|
8
17
|
*/
|
|
9
|
-
declare const CheckboxIcon:
|
|
10
|
-
isIndeterminate: boolean;
|
|
11
|
-
isChecked: boolean;
|
|
12
|
-
}>;
|
|
18
|
+
declare const CheckboxIcon: NamedExoticComponent<CheckboxIconProps>;
|
|
13
19
|
export default CheckboxIcon;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { type LabelProps } from '../types';
|
|
2
|
-
export default function Label({ children, isDisabled, testId, label, id, xcss }: LabelProps): JSX.Element;
|
|
2
|
+
export default function Label({ children, isDisabled, isChecked, isIndeterminate, isInvalid, testId, label, id, xcss, }: LabelProps): JSX.Element;
|
|
@@ -91,6 +91,21 @@ export interface LabelTextProps extends React.HTMLProps<HTMLSpanElement> {
|
|
|
91
91
|
}
|
|
92
92
|
export interface LabelProps extends React.HTMLProps<HTMLInputElement> {
|
|
93
93
|
isDisabled?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Whether the checkbox is checked.
|
|
96
|
+
* Used for conditional styling of the label.
|
|
97
|
+
*/
|
|
98
|
+
isChecked?: boolean;
|
|
99
|
+
/**
|
|
100
|
+
* Whether the checkbox is in an indeterminate state.
|
|
101
|
+
* Used for conditional styling of the label.
|
|
102
|
+
*/
|
|
103
|
+
isIndeterminate?: boolean;
|
|
104
|
+
/**
|
|
105
|
+
* Whether the checkbox is in an invalid state.
|
|
106
|
+
* Used for conditional styling of the label.
|
|
107
|
+
*/
|
|
108
|
+
isInvalid?: boolean;
|
|
94
109
|
/**
|
|
95
110
|
* A `testId` prop is provided for specified elements, which is a unique string that appears as a data attribute `data-testid` in the rendered code, serving as a hook for automated tests.
|
|
96
111
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/checkbox",
|
|
3
|
-
"version": "17.3.
|
|
3
|
+
"version": "17.3.4",
|
|
4
4
|
"description": "A checkbox is an input control that allows a user to select one or more options from a number of choices.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@atlaskit/css": "^0.19.0",
|
|
37
37
|
"@atlaskit/ds-lib": "^5.3.0",
|
|
38
38
|
"@atlaskit/platform-feature-flags": "^1.1.0",
|
|
39
|
-
"@atlaskit/theme": "^
|
|
39
|
+
"@atlaskit/theme": "^22.0.0",
|
|
40
40
|
"@atlaskit/tokens": "^11.0.0",
|
|
41
41
|
"@babel/runtime": "^7.0.0",
|
|
42
42
|
"@compiled/react": "^0.18.6"
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"@af/integration-testing": "workspace:^",
|
|
50
50
|
"@af/suppress-react-warnings": "workspace:^",
|
|
51
51
|
"@af/visual-regression": "workspace:^",
|
|
52
|
-
"@atlaskit/button": "^23.
|
|
53
|
-
"@atlaskit/docs": "^11.
|
|
52
|
+
"@atlaskit/button": "^23.10.0",
|
|
53
|
+
"@atlaskit/docs": "^11.5.0",
|
|
54
54
|
"@atlaskit/form": "^15.3.0",
|
|
55
55
|
"@atlaskit/link": "^3.3.0",
|
|
56
56
|
"@atlaskit/primitives": "^18.0.0",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
},
|
|
89
89
|
"homepage": "https://atlassian.design/components/checkbox/",
|
|
90
90
|
"platform-feature-flags": {
|
|
91
|
-
"platform-
|
|
91
|
+
"platform-checkbox-atomic-styles": {
|
|
92
92
|
"type": "boolean"
|
|
93
93
|
},
|
|
94
94
|
"platform-dst-shape-theme-default": {
|