@atlaskit/checkbox 14.0.3 → 15.0.0

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 CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/checkbox
2
2
 
3
+ ## 15.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#153563](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/153563)
8
+ [`c30346996e058`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/c30346996e058) -
9
+ Removes `size` prop from checkbox, using the default "medium" size for all checkboxes. There is a
10
+ codemod included that removes this prop for you.
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
3
16
  ## 14.0.3
4
17
 
5
18
  ### Patch Changes
@@ -0,0 +1,6 @@
1
+ import { removeSize } from './migrations/remove-props';
2
+ import { createTransformer } from './utils';
3
+
4
+ const transformer = createTransformer('@atlaskit/checkbox', [removeSize]);
5
+
6
+ export default transformer;
@@ -0,0 +1,92 @@
1
+ jest.autoMockOff();
2
+
3
+ import transformer from '../15.0.0-size-removal';
4
+
5
+ const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
6
+
7
+ describe('Remove size prop', () => {
8
+ defineInlineTest(
9
+ { default: transformer, parser: 'tsx' },
10
+ {},
11
+ `
12
+ import React from 'react';
13
+ import Checkbox from '@atlaskit/checkbox';
14
+
15
+ const SimpleCheckbox = () => {
16
+ return <Checkbox size="large" />;
17
+ }
18
+ `,
19
+ `
20
+ import React from 'react';
21
+ import Checkbox from '@atlaskit/checkbox';
22
+
23
+ const SimpleCheckbox = () => {
24
+ return <Checkbox />;
25
+ }
26
+ `,
27
+ 'should remove size prop from default import',
28
+ );
29
+ defineInlineTest(
30
+ { default: transformer, parser: 'tsx' },
31
+ {},
32
+ `
33
+ import React from 'react';
34
+ import { Checkbox } from '@atlaskit/checkbox';
35
+
36
+ const SimpleCheckbox = () => {
37
+ return <Checkbox size="large" />;
38
+ }
39
+ `,
40
+ `
41
+ import React from 'react';
42
+ import { Checkbox } from '@atlaskit/checkbox';
43
+
44
+ const SimpleCheckbox = () => {
45
+ return <Checkbox />;
46
+ }
47
+ `,
48
+ 'should remove size prop from named import',
49
+ );
50
+ defineInlineTest(
51
+ { default: transformer, parser: 'tsx' },
52
+ {},
53
+ `
54
+ import React from 'react';
55
+ import { Checkbox } from '@foo/bar';
56
+
57
+ const SimpleCheckbox = () => {
58
+ return <Checkbox size="large" />;
59
+ }
60
+ `,
61
+ `
62
+ import React from 'react';
63
+ import { Checkbox } from '@foo/bar';
64
+
65
+ const SimpleCheckbox = () => {
66
+ return <Checkbox size="large" />;
67
+ }
68
+ `,
69
+ 'should do nothing if not correct import',
70
+ );
71
+ defineInlineTest(
72
+ { default: transformer, parser: 'tsx' },
73
+ {},
74
+ `
75
+ import React from 'react';
76
+ import { Checkbox as AkCheckbox } from '@atlaskit/checkbox';
77
+
78
+ const SimpleCheckbox = () => {
79
+ return <AkCheckbox size="large" />;
80
+ }
81
+ `,
82
+ `
83
+ import React from 'react';
84
+ import { Checkbox as AkCheckbox } from '@atlaskit/checkbox';
85
+
86
+ const SimpleCheckbox = () => {
87
+ return <AkCheckbox />;
88
+ }
89
+ `,
90
+ 'should remove size prop with aliased import',
91
+ );
92
+ });
@@ -23,3 +23,5 @@ export const removeTheme = createRemoveFuncFor(
23
23
  were using theme to customise the size of the checkbox there is now a \`size\` prop.
24
24
  The appearance of Checkbox will have likely changed.`,
25
25
  );
26
+
27
+ export const removeSize = createRemoveFuncFor('@atlaskit/checkbox', 'Checkbox', 'size');
@@ -33,6 +33,18 @@ export function getNamedSpecifier(
33
33
  return specifiers.nodes()[0]!.local!.name;
34
34
  }
35
35
 
36
+ function getDefaultSpecifier(j: core.JSCodeshift, source: ReturnType<typeof j>, specifier: string) {
37
+ const specifiers = source
38
+ .find(j.ImportDeclaration)
39
+ .filter((path: ASTPath<ImportDeclaration>) => path.node.source.value === specifier)
40
+ .find(j.ImportDefaultSpecifier);
41
+
42
+ if (!specifiers.length) {
43
+ return null;
44
+ }
45
+ return specifiers.nodes()[0]!.local!.name;
46
+ }
47
+
36
48
  export function getJSXAttributesByName(
37
49
  j: core.JSCodeshift,
38
50
  element: ASTPath<any>,
@@ -244,7 +256,9 @@ export const createRenameFuncFor =
244
256
  export const createRemoveFuncFor =
245
257
  (component: string, importName: string, prop: string, comment?: string) =>
246
258
  (j: core.JSCodeshift, source: Collection<Node>) => {
247
- const specifier = getNamedSpecifier(j, source, component, importName);
259
+ const specifier =
260
+ getNamedSpecifier(j, source, component, importName) ||
261
+ getDefaultSpecifier(j, source, component);
248
262
 
249
263
  if (!specifier) {
250
264
  return;
@@ -14,7 +14,7 @@ var _usePlatformLeafEventHandler = require("@atlaskit/analytics-next/usePlatform
14
14
  var _mergeRefs = _interopRequireDefault(require("@atlaskit/ds-lib/merge-refs"));
15
15
  var _colors = require("@atlaskit/theme/colors");
16
16
  var _internal = require("./internal");
17
- var _excluded = ["isChecked", "isDisabled", "isInvalid", "defaultChecked", "isIndeterminate", "size", "onChange", "analyticsContext", "label", "name", "value", "isRequired", "testId", "xcss"];
17
+ var _excluded = ["isChecked", "isDisabled", "isInvalid", "defaultChecked", "isIndeterminate", "onChange", "analyticsContext", "label", "name", "value", "isRequired", "testId", "xcss"];
18
18
  /**
19
19
  * @jsxRuntime classic
20
20
  * @jsx jsx
@@ -171,8 +171,6 @@ var Checkbox = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
171
171
  defaultChecked = _props$defaultChecked === void 0 ? false : _props$defaultChecked,
172
172
  _props$isIndeterminat = props.isIndeterminate,
173
173
  isIndeterminate = _props$isIndeterminat === void 0 ? false : _props$isIndeterminat,
174
- _props$size = props.size,
175
- size = _props$size === void 0 ? 'medium' : _props$size,
176
174
  onChangeProps = props.onChange,
177
175
  analyticsContext = props.analyticsContext,
178
176
  label = props.label,
@@ -198,7 +196,7 @@ var Checkbox = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
198
196
  analyticsData: analyticsContext,
199
197
  componentName: 'checkbox',
200
198
  packageName: "@atlaskit/checkbox",
201
- packageVersion: "14.0.3"
199
+ packageVersion: "15.0.0"
202
200
  });
203
201
  var internalRef = (0, _react.useRef)(null);
204
202
  var mergedRefs = (0, _mergeRefs.default)([internalRef, ref]);
@@ -237,7 +235,6 @@ var Checkbox = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef
237
235
  "data-testid": testId && "".concat(testId, "--hidden-checkbox"),
238
236
  "data-invalid": isInvalid ? 'true' : undefined
239
237
  })), (0, _react2.jsx)(_internal.CheckboxIcon, {
240
- size: size,
241
238
  isIndeterminate: isIndeterminate,
242
239
  isChecked: isChecked
243
240
  }), label && (0, _react2.jsx)(_internal.LabelText, null, label, isRequired && (0, _react2.jsx)(_internal.RequiredIndicator, null)));
@@ -46,15 +46,13 @@ function getIcon(isIndeterminate, isChecked) {
46
46
  * @internal
47
47
  */
48
48
  var CheckboxIcon = /*#__PURE__*/(0, _react.memo)(function (_ref) {
49
- var size = _ref.size,
50
- isIndeterminate = _ref.isIndeterminate,
49
+ var isIndeterminate = _ref.isIndeterminate,
51
50
  isChecked = _ref.isChecked;
52
51
  var icon = (0, _react.useMemo)(function () {
53
52
  return getIcon(isIndeterminate, isChecked);
54
53
  }, [isIndeterminate, isChecked]);
55
54
  return (0, _react2.jsx)(_svg.default, {
56
55
  label: "",
57
- size: size,
58
56
  primaryColor: "var(--checkbox-background-color)",
59
57
  secondaryColor: "var(--checkbox-tick-color)"
60
58
  }, (0, _react2.jsx)("g", {
@@ -159,7 +159,6 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Checkbox(pr
159
159
  isInvalid = false,
160
160
  defaultChecked = false,
161
161
  isIndeterminate = false,
162
- size = 'medium',
163
162
  onChange: onChangeProps,
164
163
  analyticsContext,
165
164
  label,
@@ -183,7 +182,7 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Checkbox(pr
183
182
  analyticsData: analyticsContext,
184
183
  componentName: 'checkbox',
185
184
  packageName: "@atlaskit/checkbox",
186
- packageVersion: "14.0.3"
185
+ packageVersion: "15.0.0"
187
186
  });
188
187
  const internalRef = useRef(null);
189
188
  const mergedRefs = mergeRefs([internalRef, ref]);
@@ -222,7 +221,6 @@ const Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Checkbox(pr
222
221
  "data-testid": testId && `${testId}--hidden-checkbox`,
223
222
  "data-invalid": isInvalid ? 'true' : undefined
224
223
  })), jsx(CheckboxIcon, {
225
- size: size,
226
224
  isIndeterminate: isIndeterminate,
227
225
  isChecked: isChecked
228
226
  }), label && jsx(LabelText, null, label, isRequired && jsx(RequiredIndicator, null)));
@@ -38,14 +38,12 @@ function getIcon(isIndeterminate, isChecked) {
38
38
  * @internal
39
39
  */
40
40
  const CheckboxIcon = /*#__PURE__*/memo(({
41
- size,
42
41
  isIndeterminate,
43
42
  isChecked
44
43
  }) => {
45
44
  const icon = useMemo(() => getIcon(isIndeterminate, isChecked), [isIndeterminate, isChecked]);
46
45
  return jsx(PrimitiveSVGIcon, {
47
46
  label: "",
48
- size: size,
49
47
  primaryColor: "var(--checkbox-background-color)",
50
48
  secondaryColor: "var(--checkbox-tick-color)"
51
49
  }, jsx("g", {
@@ -1,7 +1,7 @@
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", "name", "value", "isRequired", "testId", "xcss"];
4
+ var _excluded = ["isChecked", "isDisabled", "isInvalid", "defaultChecked", "isIndeterminate", "onChange", "analyticsContext", "label", "name", "value", "isRequired", "testId", "xcss"];
5
5
  /**
6
6
  * @jsxRuntime classic
7
7
  * @jsx jsx
@@ -165,8 +165,6 @@ var Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Checkbox(prop
165
165
  defaultChecked = _props$defaultChecked === void 0 ? false : _props$defaultChecked,
166
166
  _props$isIndeterminat = props.isIndeterminate,
167
167
  isIndeterminate = _props$isIndeterminat === void 0 ? false : _props$isIndeterminat,
168
- _props$size = props.size,
169
- size = _props$size === void 0 ? 'medium' : _props$size,
170
168
  onChangeProps = props.onChange,
171
169
  analyticsContext = props.analyticsContext,
172
170
  label = props.label,
@@ -192,7 +190,7 @@ var Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Checkbox(prop
192
190
  analyticsData: analyticsContext,
193
191
  componentName: 'checkbox',
194
192
  packageName: "@atlaskit/checkbox",
195
- packageVersion: "14.0.3"
193
+ packageVersion: "15.0.0"
196
194
  });
197
195
  var internalRef = useRef(null);
198
196
  var mergedRefs = mergeRefs([internalRef, ref]);
@@ -231,7 +229,6 @@ var Checkbox = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Checkbox(prop
231
229
  "data-testid": testId && "".concat(testId, "--hidden-checkbox"),
232
230
  "data-invalid": isInvalid ? 'true' : undefined
233
231
  })), jsx(CheckboxIcon, {
234
- size: size,
235
232
  isIndeterminate: isIndeterminate,
236
233
  isChecked: isChecked
237
234
  }), label && jsx(LabelText, null, label, isRequired && jsx(RequiredIndicator, null)));
@@ -38,15 +38,13 @@ function getIcon(isIndeterminate, isChecked) {
38
38
  * @internal
39
39
  */
40
40
  var CheckboxIcon = /*#__PURE__*/memo(function (_ref) {
41
- var size = _ref.size,
42
- isIndeterminate = _ref.isIndeterminate,
41
+ var isIndeterminate = _ref.isIndeterminate,
43
42
  isChecked = _ref.isChecked;
44
43
  var icon = useMemo(function () {
45
44
  return getIcon(isIndeterminate, isChecked);
46
45
  }, [isIndeterminate, isChecked]);
47
46
  return jsx(PrimitiveSVGIcon, {
48
47
  label: "",
49
- size: size,
50
48
  primaryColor: "var(--checkbox-background-color)",
51
49
  secondaryColor: "var(--checkbox-tick-color)"
52
50
  }, jsx("g", {
@@ -8,5 +8,5 @@
8
8
  * - [Code](https://atlassian.design/components/checkbox/code)
9
9
  * - [Usage](https://atlassian.design/components/checkbox/usage)
10
10
  */
11
- declare const Checkbox: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "disabled" | "required" | "checked" | "css">, keyof import("./types").OwnProps> & import("./types").OwnProps & import("react").RefAttributes<HTMLInputElement>>>;
11
+ declare const Checkbox: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "css" | "disabled" | "required" | "checked">, keyof import("./types").OwnProps> & import("./types").OwnProps & import("react").RefAttributes<HTMLInputElement>>>;
12
12
  export default Checkbox;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- import type { Size } from '../types';
3
2
  /**
4
3
  * __Checkbox icon__
5
4
  *
@@ -9,7 +8,6 @@ import type { Size } from '../types';
9
8
  * @internal
10
9
  */
11
10
  declare const CheckboxIcon: import("react").NamedExoticComponent<{
12
- size: Size;
13
11
  isIndeterminate: boolean;
14
12
  isChecked: boolean;
15
13
  }>;
@@ -1,7 +1,6 @@
1
1
  import type React from 'react';
2
2
  import type UIAnalyticsEvent from '@atlaskit/analytics-next/UIAnalyticsEvent';
3
3
  import { type StrictXCSSProp } from '@atlaskit/css';
4
- export type Size = 'medium' | 'large';
5
4
  /**
6
5
  *
7
6
  *
@@ -57,13 +56,6 @@ export type OwnProps = {
57
56
  * The value to be used in the checkbox input. This is the value that will be returned on form submission.
58
57
  */
59
58
  value?: number | string;
60
- /**
61
- * The size of the checkbox.
62
- *
63
- * @deprecated This will later be removed and all checkboxes will be size
64
- * `medium`.
65
- */
66
- size?: Size;
67
59
  /**
68
60
  * 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
69
61
  * we have generated testid based on the one you pass to the Checkbox component:
@@ -8,5 +8,5 @@
8
8
  * - [Code](https://atlassian.design/components/checkbox/code)
9
9
  * - [Usage](https://atlassian.design/components/checkbox/usage)
10
10
  */
11
- declare const Checkbox: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "disabled" | "required" | "checked" | "css">, keyof import("./types").OwnProps> & import("./types").OwnProps & import("react").RefAttributes<HTMLInputElement>>>;
11
+ declare const Checkbox: import("react").MemoExoticComponent<import("react").ForwardRefExoticComponent<Omit<Omit<import("react").InputHTMLAttributes<HTMLInputElement>, "css" | "disabled" | "required" | "checked">, keyof import("./types").OwnProps> & import("./types").OwnProps & import("react").RefAttributes<HTMLInputElement>>>;
12
12
  export default Checkbox;
@@ -1,5 +1,4 @@
1
1
  /// <reference types="react" />
2
- import type { Size } from '../types';
3
2
  /**
4
3
  * __Checkbox icon__
5
4
  *
@@ -9,7 +8,6 @@ import type { Size } from '../types';
9
8
  * @internal
10
9
  */
11
10
  declare const CheckboxIcon: import("react").NamedExoticComponent<{
12
- size: Size;
13
11
  isIndeterminate: boolean;
14
12
  isChecked: boolean;
15
13
  }>;
@@ -1,7 +1,6 @@
1
1
  import type React from 'react';
2
2
  import type UIAnalyticsEvent from '@atlaskit/analytics-next/UIAnalyticsEvent';
3
3
  import { type StrictXCSSProp } from '@atlaskit/css';
4
- export type Size = 'medium' | 'large';
5
4
  /**
6
5
  *
7
6
  *
@@ -57,13 +56,6 @@ export type OwnProps = {
57
56
  * The value to be used in the checkbox input. This is the value that will be returned on form submission.
58
57
  */
59
58
  value?: number | string;
60
- /**
61
- * The size of the checkbox.
62
- *
63
- * @deprecated This will later be removed and all checkboxes will be size
64
- * `medium`.
65
- */
66
- size?: Size;
67
59
  /**
68
60
  * 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
69
61
  * we have generated testid based on the one you pass to the Checkbox component:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/checkbox",
3
- "version": "14.0.3",
3
+ "version": "15.0.0",
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,9 +36,9 @@
36
36
  "dependencies": {
37
37
  "@atlaskit/analytics-next": "^10.1.0",
38
38
  "@atlaskit/css": "^0.5.0",
39
- "@atlaskit/ds-lib": "^3.0.0",
40
- "@atlaskit/icon": "^22.20.0",
41
- "@atlaskit/theme": "^13.0.0",
39
+ "@atlaskit/ds-lib": "^3.1.0",
40
+ "@atlaskit/icon": "^22.22.0",
41
+ "@atlaskit/theme": "^14.0.0",
42
42
  "@atlaskit/tokens": "^2.0.0",
43
43
  "@babel/runtime": "^7.0.0",
44
44
  "@emotion/react": "^11.7.1"