@atlaskit/calendar 16.3.0 → 16.3.2

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,19 @@
1
1
  # @atlaskit/calendar
2
2
 
3
+ ## 16.3.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#114277](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/114277)
8
+ [`f10877b44dc55`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f10877b44dc55) -
9
+ Update depdencies and remove old codemods.
10
+
11
+ ## 16.3.1
12
+
13
+ ### Patch Changes
14
+
15
+ - Updated dependencies
16
+
3
17
  ## 16.3.0
4
18
 
5
19
  ### Minor Changes
@@ -38,7 +38,7 @@ var styles = {
38
38
  var analyticsAttributes = {
39
39
  componentName: 'calendar',
40
40
  packageName: "@atlaskit/calendar",
41
- packageVersion: "16.3.0"
41
+ packageVersion: "16.3.2"
42
42
  };
43
43
  var InnerCalendar = /*#__PURE__*/(0, _react.forwardRef)(function Calendar(_ref, ref) {
44
44
  var day = _ref.day,
@@ -1,7 +1,6 @@
1
1
 
2
2
  ._kkk2n7od{all:unset}
3
3
  ._11c81oud{font:var(--ds-font-body,normal 400 14px/20px ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,system-ui,"Helvetica Neue",sans-serif)}
4
- ._1yt432tv{padding:var(--_1arop38)}
5
4
  ._2rko1l7b{border-radius:3px}
6
5
  ._189eyh40{border-width:2px}
7
6
  ._1dqonqa1{border-style:solid}
@@ -12,14 +11,17 @@
12
11
  ._1e0c1ule{display:block}
13
12
  ._1gufv77o:after{inset-block-end:var(--ds-space-025,2px)}
14
13
  ._1hfk1r31:after{background-color:currentColor}
14
+ ._1q511b66{padding-block-start:var(--ds-space-050,4px)}
15
15
  ._1qdgyh40:after{height:2px}
16
16
  ._1ywu1ule:after{display:block}
17
17
  ._80om13gf{cursor:not-allowed}
18
18
  ._80omtlke{cursor:pointer}
19
+ ._85i51b66{padding-block-end:var(--ds-space-050,4px)}
19
20
  ._aetrb3bt:after{content:""}
20
21
  ._bfhk18uv{background-color:initial}
21
22
  ._bfhk1kxl{background-color:var(--_rryx0a)}
22
23
  ._bfhky9dz{background-color:var(--_7nwbia)}
24
+ ._bozgrdoj{padding-inline-start:9px}
23
25
  ._g0nfv77o:after{inset-inline-start:var(--ds-space-025,2px)}
24
26
  ._k48p1igg{font-weight:var(--ds-font-weight-bold,bold)}
25
27
  ._kqswh2mm{position:relative}
@@ -29,7 +31,8 @@
29
31
  ._syazln51{color:var(--_1hfkvbo)}
30
32
  ._syazovqm{color:var(--_5xk3r4)}
31
33
  ._syazpsu8{color:var(--_vrm7dk)}
32
- ._y3gn1h6o{text-align:center}._10knnqa1:focus-visible{border-style:solid}
34
+ ._y3gn1h6o{text-align:center}
35
+ ._y4tirdoj{padding-inline-end:9px}._10knnqa1:focus-visible{border-style:solid}
33
36
  ._1wysyh40:focus-visible{border-width:2px}
34
37
  ._pojj3zdg:focus-visible{border-color:var(--_xjqa3d)}
35
38
  ._30l31a5u:hover{color:var(--_1oh641w)}
@@ -98,9 +98,8 @@ var Date = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(fu
98
98
  "data-sibling": isSibling || undefined,
99
99
  "data-today": isToday || undefined,
100
100
  "data-testid": testId && (isSelected ? "".concat(testId, "--selected-day") : "".concat(testId, "--day")),
101
- className: (0, _runtime.ax)(["_kkk2n7od _1yt432tv _2rko1l7b _11c81oud _1h6d1j28 _1dqonqa1 _189eyh40 _1e0c1ule _kqswh2mm _16jlkb7n _bfhk18uv _syazovqm _80omtlke _y3gn1h6o _pojj3zdg _10knnqa1 _1wysyh40 _irr32tgk _30l3ovqm _1di618xb _9h8hovqm", isSibling && "_syazpsu8 _30l3psu8", isToday && "_syazln51 _k48p1igg _1ywu1ule _1qdgyh40 _18postnw _1hfk1r31 _aetrb3bt _1gufv77o _1czdv77o _g0nfv77o", isPreviouslySelected && "_bfhk1kxl _syaz1a5u _30l31a5u", isSelected && "_bfhky9dz _syaz11g7 _irr3j4m7 _30l3dgff", isDisabled && "_syazf50w _80om13gf _irr318uv _30l3f50w"]),
101
+ className: (0, _runtime.ax)(["_kkk2n7od _2rko1l7b _11c81oud _1h6d1j28 _1dqonqa1 _189eyh40 _1e0c1ule _kqswh2mm _16jlkb7n _bfhk18uv _syazovqm _80omtlke _85i51b66 _1q511b66 _y4tirdoj _bozgrdoj _y3gn1h6o _pojj3zdg _10knnqa1 _1wysyh40 _irr32tgk _30l3ovqm _1di618xb _9h8hovqm", isSibling && "_syazpsu8 _30l3psu8", isToday && "_syazln51 _k48p1igg _1ywu1ule _1qdgyh40 _18postnw _1hfk1r31 _aetrb3bt _1gufv77o _1czdv77o _g0nfv77o", isPreviouslySelected && "_bfhk1kxl _syaz1a5u _30l31a5u", isSelected && "_bfhky9dz _syaz11g7 _irr3j4m7 _30l3dgff", isDisabled && "_syazf50w _80om13gf _irr318uv _30l3f50w"]),
102
102
  style: {
103
- "--_1arop38": (0, _runtime.ix)("var(--ds-space-050, 4px)".concat(" 9px")),
104
103
  "--_5xk3r4": (0, _runtime.ix)("var(--ds-text, ".concat(_colors.N900, ")")),
105
104
  "--_xjqa3d": (0, _runtime.ix)("var(--ds-border-focused, ".concat(_colors.B200, ")")),
106
105
  "--_1y60f1n": (0, _runtime.ix)("var(--ds-background-neutral-subtle-hovered, ".concat(_colors.N30, ")")),
@@ -24,7 +24,7 @@ const styles = {
24
24
  const analyticsAttributes = {
25
25
  componentName: 'calendar',
26
26
  packageName: "@atlaskit/calendar",
27
- packageVersion: "16.3.0"
27
+ packageVersion: "16.3.2"
28
28
  };
29
29
  const InnerCalendar = /*#__PURE__*/forwardRef(function Calendar({
30
30
  day,
@@ -1,7 +1,6 @@
1
1
 
2
2
  ._kkk2n7od{all:unset}
3
3
  ._11c81oud{font:var(--ds-font-body,normal 400 14px/20px ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,system-ui,"Helvetica Neue",sans-serif)}
4
- ._1yt41qfp{padding:var(--ds-space-050,4px) 9px}
5
4
  ._2rko1l7b{border-radius:3px}
6
5
  ._189eyh40{border-width:2px}
7
6
  ._1dqonqa1{border-style:solid}
@@ -12,14 +11,17 @@
12
11
  ._1e0c1ule{display:block}
13
12
  ._1gufv77o:after{inset-block-end:var(--ds-space-025,2px)}
14
13
  ._1hfk1r31:after{background-color:currentColor}
14
+ ._1q511b66{padding-block-start:var(--ds-space-050,4px)}
15
15
  ._1qdgyh40:after{height:2px}
16
16
  ._1ywu1ule:after{display:block}
17
17
  ._80om13gf{cursor:not-allowed}
18
18
  ._80omtlke{cursor:pointer}
19
+ ._85i51b66{padding-block-end:var(--ds-space-050,4px)}
19
20
  ._aetrb3bt:after{content:""}
20
21
  ._bfhk18uv{background-color:initial}
21
22
  ._bfhk1p4p{background-color:var(--ds-background-selected,#42526e)}
22
23
  ._bfhk29zg{background-color:var(--ds-background-selected,#deebff)}
24
+ ._bozgrdoj{padding-inline-start:9px}
23
25
  ._g0nfv77o:after{inset-inline-start:var(--ds-space-025,2px)}
24
26
  ._k48p1igg{font-weight:var(--ds-font-weight-bold,bold)}
25
27
  ._kqswh2mm{position:relative}
@@ -29,7 +31,8 @@
29
31
  ._syazc8hx{color:var(--ds-text-subtle,#344563)}
30
32
  ._syazj3m3{color:var(--ds-text,#091e42)}
31
33
  ._syazqueg{color:var(--ds-text-selected,#fff)}
32
- ._y3gn1h6o{text-align:center}._10knnqa1:focus-visible{border-style:solid}
34
+ ._y3gn1h6o{text-align:center}
35
+ ._y4tirdoj{padding-inline-end:9px}._10knnqa1:focus-visible{border-style:solid}
33
36
  ._1wysyh40:focus-visible{border-width:2px}
34
37
  ._pojj194a:focus-visible{border-color:var(--ds-border-focused,#2684ff)}
35
38
  ._30l31uqy:hover{color:var(--ds-text-selected,#344563)}
@@ -83,7 +83,7 @@ const Date = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Date({
83
83
  "data-sibling": isSibling || undefined,
84
84
  "data-today": isToday || undefined,
85
85
  "data-testid": testId && (isSelected ? `${testId}--selected-day` : `${testId}--day`),
86
- className: ax(["_kkk2n7od _1yt41qfp _2rko1l7b _11c81oud _1h6d1j28 _1dqonqa1 _189eyh40 _1e0c1ule _kqswh2mm _16jlkb7n _bfhk18uv _syazj3m3 _80omtlke _y3gn1h6o _pojj194a _10knnqa1 _1wysyh40 _irr314ae _30l3j3m3 _1di61l7b _9h8hj3m3", isSibling && "_syaz1wmz _30l31wmz", isToday && "_syaz1ldt _k48p1igg _1ywu1ule _1qdgyh40 _18postnw _1hfk1r31 _aetrb3bt _1gufv77o _1czdv77o _g0nfv77o", isPreviouslySelected && "_bfhk29zg _syazc8hx _30l3c8hx", isSelected && "_bfhk1p4p _syazqueg _irr3quvt _30l31uqy", isDisabled && "_syaz7dlb _80om13gf _irr318uv _30l37dlb"])
86
+ className: ax(["_kkk2n7od _2rko1l7b _11c81oud _1h6d1j28 _1dqonqa1 _189eyh40 _1e0c1ule _kqswh2mm _16jlkb7n _bfhk18uv _syazj3m3 _80omtlke _85i51b66 _1q511b66 _y4tirdoj _bozgrdoj _y3gn1h6o _pojj194a _10knnqa1 _1wysyh40 _irr314ae _30l3j3m3 _1di61l7b _9h8hj3m3", isSibling && "_syaz1wmz _30l31wmz", isToday && "_syaz1ldt _k48p1igg _1ywu1ule _1qdgyh40 _18postnw _1hfk1r31 _aetrb3bt _1gufv77o _1czdv77o _g0nfv77o", isPreviouslySelected && "_bfhk29zg _syazc8hx _30l3c8hx", isSelected && "_bfhk1p4p _syazqueg _irr3quvt _30l31uqy", isDisabled && "_syaz7dlb _80om13gf _irr318uv _30l37dlb"])
87
87
  }, day));
88
88
  }));
89
89
  Date.displayName = 'Date';
@@ -28,7 +28,7 @@ var styles = {
28
28
  var analyticsAttributes = {
29
29
  componentName: 'calendar',
30
30
  packageName: "@atlaskit/calendar",
31
- packageVersion: "16.3.0"
31
+ packageVersion: "16.3.2"
32
32
  };
33
33
  var InnerCalendar = /*#__PURE__*/forwardRef(function Calendar(_ref, ref) {
34
34
  var day = _ref.day,
@@ -1,7 +1,6 @@
1
1
 
2
2
  ._kkk2n7od{all:unset}
3
3
  ._11c81oud{font:var(--ds-font-body,normal 400 14px/20px ui-sans-serif,-apple-system,BlinkMacSystemFont,"Segoe UI",Ubuntu,system-ui,"Helvetica Neue",sans-serif)}
4
- ._1yt432tv{padding:var(--_1arop38)}
5
4
  ._2rko1l7b{border-radius:3px}
6
5
  ._189eyh40{border-width:2px}
7
6
  ._1dqonqa1{border-style:solid}
@@ -12,14 +11,17 @@
12
11
  ._1e0c1ule{display:block}
13
12
  ._1gufv77o:after{inset-block-end:var(--ds-space-025,2px)}
14
13
  ._1hfk1r31:after{background-color:currentColor}
14
+ ._1q511b66{padding-block-start:var(--ds-space-050,4px)}
15
15
  ._1qdgyh40:after{height:2px}
16
16
  ._1ywu1ule:after{display:block}
17
17
  ._80om13gf{cursor:not-allowed}
18
18
  ._80omtlke{cursor:pointer}
19
+ ._85i51b66{padding-block-end:var(--ds-space-050,4px)}
19
20
  ._aetrb3bt:after{content:""}
20
21
  ._bfhk18uv{background-color:initial}
21
22
  ._bfhk1kxl{background-color:var(--_rryx0a)}
22
23
  ._bfhky9dz{background-color:var(--_7nwbia)}
24
+ ._bozgrdoj{padding-inline-start:9px}
23
25
  ._g0nfv77o:after{inset-inline-start:var(--ds-space-025,2px)}
24
26
  ._k48p1igg{font-weight:var(--ds-font-weight-bold,bold)}
25
27
  ._kqswh2mm{position:relative}
@@ -29,7 +31,8 @@
29
31
  ._syazln51{color:var(--_1hfkvbo)}
30
32
  ._syazovqm{color:var(--_5xk3r4)}
31
33
  ._syazpsu8{color:var(--_vrm7dk)}
32
- ._y3gn1h6o{text-align:center}._10knnqa1:focus-visible{border-style:solid}
34
+ ._y3gn1h6o{text-align:center}
35
+ ._y4tirdoj{padding-inline-end:9px}._10knnqa1:focus-visible{border-style:solid}
33
36
  ._1wysyh40:focus-visible{border-width:2px}
34
37
  ._pojj3zdg:focus-visible{border-color:var(--_xjqa3d)}
35
38
  ._30l31a5u:hover{color:var(--_1oh641w)}
@@ -88,9 +88,8 @@ var Date = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Date(_ref2, _ref)
88
88
  "data-sibling": isSibling || undefined,
89
89
  "data-today": isToday || undefined,
90
90
  "data-testid": testId && (isSelected ? "".concat(testId, "--selected-day") : "".concat(testId, "--day")),
91
- className: ax(["_kkk2n7od _1yt432tv _2rko1l7b _11c81oud _1h6d1j28 _1dqonqa1 _189eyh40 _1e0c1ule _kqswh2mm _16jlkb7n _bfhk18uv _syazovqm _80omtlke _y3gn1h6o _pojj3zdg _10knnqa1 _1wysyh40 _irr32tgk _30l3ovqm _1di618xb _9h8hovqm", isSibling && "_syazpsu8 _30l3psu8", isToday && "_syazln51 _k48p1igg _1ywu1ule _1qdgyh40 _18postnw _1hfk1r31 _aetrb3bt _1gufv77o _1czdv77o _g0nfv77o", isPreviouslySelected && "_bfhk1kxl _syaz1a5u _30l31a5u", isSelected && "_bfhky9dz _syaz11g7 _irr3j4m7 _30l3dgff", isDisabled && "_syazf50w _80om13gf _irr318uv _30l3f50w"]),
91
+ className: ax(["_kkk2n7od _2rko1l7b _11c81oud _1h6d1j28 _1dqonqa1 _189eyh40 _1e0c1ule _kqswh2mm _16jlkb7n _bfhk18uv _syazovqm _80omtlke _85i51b66 _1q511b66 _y4tirdoj _bozgrdoj _y3gn1h6o _pojj3zdg _10knnqa1 _1wysyh40 _irr32tgk _30l3ovqm _1di618xb _9h8hovqm", isSibling && "_syazpsu8 _30l3psu8", isToday && "_syazln51 _k48p1igg _1ywu1ule _1qdgyh40 _18postnw _1hfk1r31 _aetrb3bt _1gufv77o _1czdv77o _g0nfv77o", isPreviouslySelected && "_bfhk1kxl _syaz1a5u _30l31a5u", isSelected && "_bfhky9dz _syaz11g7 _irr3j4m7 _30l3dgff", isDisabled && "_syazf50w _80om13gf _irr318uv _30l3f50w"]),
92
92
  style: {
93
- "--_1arop38": ix("var(--ds-space-050, 4px)".concat(" 9px")),
94
93
  "--_5xk3r4": ix("var(--ds-text, ".concat(N900, ")")),
95
94
  "--_xjqa3d": ix("var(--ds-border-focused, ".concat(B200, ")")),
96
95
  "--_1y60f1n": ix("var(--ds-background-neutral-subtle-hovered, ".concat(N30, ")")),
@@ -10,5 +10,5 @@ interface WeekDayGridProps extends React.HTMLAttributes<HTMLElement> {
10
10
  * A week day grid aligns elements in a 7 wide grid layout.
11
11
  *
12
12
  */
13
- declare const WeekDayGrid: ({ testId, children, isHidden }: WeekDayGridProps) => JSX.Element;
13
+ declare const WeekDayGrid: ({ testId, children, isHidden }: WeekDayGridProps) => React.JSX.Element;
14
14
  export default WeekDayGrid;
@@ -10,5 +10,5 @@ interface WeekDayGridProps extends React.HTMLAttributes<HTMLElement> {
10
10
  * A week day grid aligns elements in a 7 wide grid layout.
11
11
  *
12
12
  */
13
- declare const WeekDayGrid: ({ testId, children, isHidden }: WeekDayGridProps) => JSX.Element;
13
+ declare const WeekDayGrid: ({ testId, children, isHidden }: WeekDayGridProps) => React.JSX.Element;
14
14
  export default WeekDayGrid;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/calendar",
3
- "version": "16.3.0",
3
+ "version": "16.3.2",
4
4
  "description": "An interactive calendar for date selection experiences.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -26,15 +26,15 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "@atlaskit/analytics-next": "^10.3.0",
29
- "@atlaskit/button": "^20.4.0",
29
+ "@atlaskit/button": "^20.5.0",
30
30
  "@atlaskit/css": "^0.8.0",
31
31
  "@atlaskit/ds-lib": "^3.5.0",
32
32
  "@atlaskit/heading": "^4.1.0",
33
- "@atlaskit/icon": "^23.5.0",
33
+ "@atlaskit/icon": "^23.9.0",
34
34
  "@atlaskit/locale": "^2.8.0",
35
35
  "@atlaskit/platform-feature-flags": "*",
36
- "@atlaskit/primitives": "^13.4.0",
37
- "@atlaskit/theme": "^14.1.0",
36
+ "@atlaskit/primitives": "^13.5.0",
37
+ "@atlaskit/theme": "^15.0.0",
38
38
  "@atlaskit/tokens": "^3.3.0",
39
39
  "@babel/runtime": "^7.0.0",
40
40
  "@compiled/react": "^0.18.1",
@@ -55,13 +55,10 @@
55
55
  "@atlaskit/ssr": "*",
56
56
  "@atlaskit/visual-regression": "*",
57
57
  "@atlassian/feature-flags-test-utils": "*",
58
- "@testing-library/dom": "^10.1.0",
59
58
  "@testing-library/react": "^13.4.0",
60
59
  "@testing-library/user-event": "^14.4.3",
61
60
  "jest-in-case": "^1.0.2",
62
- "jscodeshift": "^0.13.0",
63
61
  "react-dom": "^18.2.0",
64
- "storybook-addon-performance": "^0.17.3",
65
62
  "typescript": "~5.4.2"
66
63
  },
67
64
  "techstack": {
@@ -1,10 +0,0 @@
1
- import { flattenCertainInnerPropsAsProp } from './migrations/flatten-certain-inner-props-as-prop';
2
- import { removeInnerProps } from './migrations/remove-inner-props';
3
- import { createTransformer } from './utils';
4
-
5
- const transformer = createTransformer('@atlaskit/calendar', [
6
- flattenCertainInnerPropsAsProp,
7
- removeInnerProps,
8
- ]);
9
-
10
- export default transformer;
@@ -1,166 +0,0 @@
1
- jest.autoMockOff();
2
-
3
- import transformer from '../11.0.0-lite-mode';
4
-
5
- const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
6
-
7
- describe('Calendar code-mods', () => {
8
- defineInlineTest(
9
- { default: transformer, parser: 'tsx' },
10
- {},
11
- `
12
- import React from 'react';
13
- import Calendar from '@atlaskit/calendar';
14
-
15
- const SimpleCalendar= () => {
16
- return (
17
- <Calendar
18
- defaultDisabled={['2020-12-04']}
19
- defaultPreviouslySelected={['2020-12-06']}
20
- defaultSelected={['2020-12-08']}
21
- defaultMonth={12}
22
- defaultYear={2020}
23
- innerProps={{
24
- className: 'myClass',
25
- style: {
26
- border: '1px solid red',
27
- display: 'inline-block',
28
- },
29
- }}
30
- testId="the-calendar"
31
- />
32
- );
33
- }
34
- `,
35
- `
36
- /* TODO: (from codemod) This file uses the @atlaskit/calendar \`innerProps\` which
37
- has now been removed due to its poor performance characteristics. Codemod
38
- has auto flattened 'className' & 'style' properties inside it if present as a standalone props to calendar.
39
- Rest other properties if any inside innerProps will get auto-removed along with it,
40
- & might have to be handled manually as per need. */
41
- import React from 'react';
42
- import Calendar from '@atlaskit/calendar';
43
-
44
- const SimpleCalendar= () => {
45
- return (
46
- <Calendar
47
- defaultDisabled={['2020-12-04']}
48
- defaultPreviouslySelected={['2020-12-06']}
49
- defaultSelected={['2020-12-08']}
50
- defaultMonth={12}
51
- defaultYear={2020}
52
- testId="the-calendar"
53
- className={'myClass'}
54
- style={{
55
- border: '1px solid red',
56
- display: 'inline-block',
57
- }} />
58
- );
59
- }
60
- `,
61
- `should flatten style & className in innerProps as standalone prop
62
- & then remove innerProps`,
63
- );
64
- defineInlineTest(
65
- { default: transformer, parser: 'tsx' },
66
- {},
67
- `
68
- import React from 'react';
69
- import Calendar from '@atlaskit/calendar';
70
-
71
- const SimpleCalendar= () => {
72
- return (
73
- <Calendar
74
- defaultDisabled={['2020-12-04']}
75
- defaultPreviouslySelected={['2020-12-06']}
76
- defaultSelected={['2020-12-08']}
77
- defaultMonth={12}
78
- defaultYear={2020}
79
- innerProps={{
80
- className: 'myClass',
81
- theme: 'dark',
82
- style: {
83
- border: '1px solid red',
84
- display: 'inline-block',
85
- },
86
- }}
87
- testId="the-calendar"
88
- />
89
- );
90
- }
91
- `,
92
- `
93
- /* TODO: (from codemod) This file uses the @atlaskit/calendar \`innerProps\` which
94
- has now been removed due to its poor performance characteristics. Codemod
95
- has auto flattened 'className' & 'style' properties inside it if present as a standalone props to calendar.
96
- Rest other properties if any inside innerProps will get auto-removed along with it,
97
- & might have to be handled manually as per need. */
98
- import React from 'react';
99
- import Calendar from '@atlaskit/calendar';
100
-
101
- const SimpleCalendar= () => {
102
- return (
103
- <Calendar
104
- defaultDisabled={['2020-12-04']}
105
- defaultPreviouslySelected={['2020-12-06']}
106
- defaultSelected={['2020-12-08']}
107
- defaultMonth={12}
108
- defaultYear={2020}
109
- testId="the-calendar"
110
- className={'myClass'}
111
- style={{
112
- border: '1px solid red',
113
- display: 'inline-block',
114
- }} />
115
- );
116
- }
117
- `,
118
- `should only flatten style & className in innerProps as standalone prop
119
- & then remove innerProps`,
120
- );
121
- defineInlineTest(
122
- { default: transformer, parser: 'tsx' },
123
- {},
124
- `
125
- import React from 'react';
126
- import Calendar from '@atlaskit/calendar';
127
- const SimpleCalendar= () => {
128
- return (
129
- <Calendar
130
- defaultDisabled={['2020-12-04']}
131
- defaultPreviouslySelected={['2020-12-06']}
132
- defaultSelected={['2020-12-08']}
133
- defaultMonth={12}
134
- defaultYear={2020}
135
- innerProps={{
136
- dummyInnerProp: 'dummy'
137
- }}
138
- testId="the-calendar"
139
- />
140
- );
141
- }
142
- `,
143
- `
144
- /* TODO: (from codemod) This file uses the @atlaskit/calendar \`innerProps\` which
145
- has now been removed due to its poor performance characteristics. Codemod
146
- has auto flattened 'className' & 'style' properties inside it if present as a standalone props to calendar.
147
- Rest other properties if any inside innerProps will get auto-removed along with it,
148
- & might have to be handled manually as per need. */
149
- import React from 'react';
150
- import Calendar from '@atlaskit/calendar';
151
- const SimpleCalendar= () => {
152
- return (
153
- <Calendar
154
- defaultDisabled={['2020-12-04']}
155
- defaultPreviouslySelected={['2020-12-06']}
156
- defaultSelected={['2020-12-08']}
157
- defaultMonth={12}
158
- defaultYear={2020}
159
- testId="the-calendar" />
160
- );
161
- }
162
- `,
163
- `should not flatten any other prop apart from style & className in innerProps
164
- & just remove innerProps`,
165
- );
166
- });
@@ -1,156 +0,0 @@
1
- jest.autoMockOff();
2
-
3
- import { flattenCertainInnerPropsAsProp } from '../migrations/flatten-certain-inner-props-as-prop';
4
- import { createTransformer } from '../utils';
5
-
6
- const transformer = createTransformer('@atlaskit/calendar', [flattenCertainInnerPropsAsProp]);
7
-
8
- const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
9
-
10
- describe('Flatten Inner Prop Style As Prop', () => {
11
- defineInlineTest(
12
- { default: transformer, parser: 'tsx' },
13
- {},
14
- `
15
- import React from 'react';
16
- import Calendar from '@atlaskit/calendar';
17
- const SimpleCalendar = () => {
18
- return (
19
- <Calendar
20
- innerProps={{
21
- style: {
22
- border: '1px solid red',
23
- display: 'inline-block',
24
- },
25
- className: 'abc',
26
- }}
27
- />
28
- )
29
- };
30
- `,
31
- `
32
- import React from 'react';
33
- import Calendar from '@atlaskit/calendar';
34
- const SimpleCalendar = () => {
35
- return (
36
- <Calendar
37
- innerProps={{
38
- style: {
39
- border: '1px solid red',
40
- display: 'inline-block',
41
- },
42
- className: 'abc',
43
- }}
44
- style={{
45
- border: '1px solid red',
46
- display: 'inline-block',
47
- }}
48
- className={'abc'} />
49
- );
50
- };
51
- `,
52
- 'should flatten style & className properties in inner props as a new standalone props',
53
- );
54
- defineInlineTest(
55
- { default: transformer, parser: 'tsx' },
56
- {},
57
- `
58
- import React from 'react';
59
- import Calendar from '@atlaskit/calendar';
60
- const SimpleCalendar = () => {
61
- return (
62
- <Calendar
63
- innerProps={{
64
- className: 'abc',
65
- }}
66
- />
67
- )
68
- };
69
- `,
70
- `
71
- import React from 'react';
72
- import Calendar from '@atlaskit/calendar';
73
- const SimpleCalendar = () => {
74
- return (
75
- <Calendar
76
- innerProps={{
77
- className: 'abc',
78
- }}
79
- className={'abc'} />
80
- );
81
- };
82
- `,
83
- 'should just flatten className property in inner props as a new standalone prop',
84
- );
85
- defineInlineTest(
86
- { default: transformer, parser: 'tsx' },
87
- {},
88
- `
89
- import React from 'react';
90
- import Calendar from '@atlaskit/calendar';
91
- const SimpleCalendar = () => {
92
- return (
93
- <Calendar
94
- innerProps={{
95
- style: {
96
- border: '1px solid red',
97
- display: 'inline-block',
98
- },
99
- }}
100
- />
101
- )
102
- };
103
- `,
104
- `
105
- import React from 'react';
106
- import Calendar from '@atlaskit/calendar';
107
- const SimpleCalendar = () => {
108
- return (
109
- <Calendar
110
- innerProps={{
111
- style: {
112
- border: '1px solid red',
113
- display: 'inline-block',
114
- },
115
- }}
116
- style={{
117
- border: '1px solid red',
118
- display: 'inline-block',
119
- }} />
120
- );
121
- };
122
- `,
123
- 'should just flatten style property in inner props as a new standalone prop',
124
- );
125
- defineInlineTest(
126
- { default: transformer, parser: 'tsx' },
127
- {},
128
- `
129
- import React from 'react';
130
- import Calendar from '@atlaskit/calendar';
131
- const SimpleCalendar = () => {
132
- return (
133
- <Calendar
134
- innerProps={{
135
- theme: 'dark'
136
- }}
137
- />
138
- )
139
- };
140
- `,
141
- `
142
- import React from 'react';
143
- import Calendar from '@atlaskit/calendar';
144
- const SimpleCalendar = () => {
145
- return (
146
- <Calendar
147
- innerProps={{
148
- theme: 'dark'
149
- }}
150
- />
151
- )
152
- };
153
- `,
154
- 'should not flatten any other prop in inner props if className & style prop is not present',
155
- );
156
- });
@@ -1,160 +0,0 @@
1
- jest.autoMockOff();
2
-
3
- import { removeInnerProps } from '../migrations/remove-inner-props';
4
- import { createTransformer } from '../utils';
5
-
6
- const transformer = createTransformer('@atlaskit/calendar', [removeInnerProps]);
7
-
8
- const defineInlineTest = require('jscodeshift/dist/testUtils').defineInlineTest;
9
-
10
- describe('Remove innerProps', () => {
11
- defineInlineTest(
12
- { default: transformer, parser: 'tsx' },
13
- {},
14
- `
15
- import React from 'react';
16
- import Calendar from '@atlaskit/calendar';
17
-
18
- const SimpleCalendar = () => {
19
- return (
20
- <Calendar
21
- innerProps={{
22
- style: {
23
- border: '1px solid red',
24
- display: 'inline-block',
25
- },
26
- }}
27
- />
28
- );
29
- }
30
- `,
31
- `
32
- /* TODO: (from codemod) This file uses the @atlaskit/calendar \`innerProps\` which
33
- has now been removed due to its poor performance characteristics. Codemod
34
- has auto flattened 'className' & 'style' properties inside it if present as a standalone props to calendar.
35
- Rest other properties if any inside innerProps will get auto-removed along with it,
36
- & might have to be handled manually as per need. */
37
- import React from 'react';
38
- import Calendar from '@atlaskit/calendar';
39
-
40
- const SimpleCalendar = () => {
41
- return <Calendar />;
42
- }
43
- `,
44
- 'should remove innerProps from Calendar and leave a TODO comment',
45
- );
46
-
47
- defineInlineTest(
48
- { default: transformer, parser: 'tsx' },
49
- {},
50
- `
51
- import React from 'react';
52
- import AkCalendar from '@atlaskit/calendar';
53
-
54
- const SimpleCalendar = () => {
55
- return (
56
- <AkCalendar
57
- innerProps={{
58
- style: {
59
- border: '1px solid red',
60
- display: 'inline-block',
61
- },
62
- }}
63
- />
64
- );
65
- }
66
- `,
67
- `
68
- /* TODO: (from codemod) This file uses the @atlaskit/calendar \`innerProps\` which
69
- has now been removed due to its poor performance characteristics. Codemod
70
- has auto flattened 'className' & 'style' properties inside it if present as a standalone props to calendar.
71
- Rest other properties if any inside innerProps will get auto-removed along with it,
72
- & might have to be handled manually as per need. */
73
- import React from 'react';
74
- import AkCalendar from '@atlaskit/calendar';
75
-
76
- const SimpleCalendar = () => {
77
- return <AkCalendar />;
78
- }
79
- `,
80
- 'should also remove innerProps from some random default import name of Calendar (eg: AkCalendar) and leave a TODO comment',
81
- );
82
-
83
- defineInlineTest(
84
- { default: transformer, parser: 'tsx' },
85
- {},
86
- `
87
- import React from 'react';
88
- import Calendar from '@atlaskit/calendar';
89
-
90
- const SimpleCalendar = () => {
91
- return (
92
- <Calendar
93
- defaultDisabled={['2020-12-04']}
94
- defaultPreviouslySelected={['2020-12-06']}
95
- defaultSelected={['2020-12-08']}
96
- innerProps={{
97
- style: {
98
- border: '1px solid red',
99
- display: 'inline-block',
100
- },
101
- }}
102
- />
103
- );
104
- }
105
- `,
106
- `
107
- /* TODO: (from codemod) This file uses the @atlaskit/calendar \`innerProps\` which
108
- has now been removed due to its poor performance characteristics. Codemod
109
- has auto flattened 'className' & 'style' properties inside it if present as a standalone props to calendar.
110
- Rest other properties if any inside innerProps will get auto-removed along with it,
111
- & might have to be handled manually as per need. */
112
- import React from 'react';
113
- import Calendar from '@atlaskit/calendar';
114
-
115
- const SimpleCalendar = () => {
116
- return (
117
- <Calendar
118
- defaultDisabled={['2020-12-04']}
119
- defaultPreviouslySelected={['2020-12-06']}
120
- defaultSelected={['2020-12-08']} />
121
- );
122
- }
123
- `,
124
- 'should remove innerProps from Calendar, leave a TODO comment & just keep other props intact',
125
- );
126
-
127
- defineInlineTest(
128
- { default: transformer, parser: 'tsx' },
129
- {},
130
- `
131
- import React from 'react';
132
- import Calendar from '@atlaskit/calendar';
133
-
134
- const SimpleCalendar = () => {
135
- return (
136
- <Calendar
137
- defaultDisabled={['2020-12-04']}
138
- defaultPreviouslySelected={['2020-12-06']}
139
- defaultSelected={['2020-12-08']}
140
- />
141
- );
142
- }
143
- `,
144
- `
145
- import React from 'react';
146
- import Calendar from '@atlaskit/calendar';
147
-
148
- const SimpleCalendar = () => {
149
- return (
150
- <Calendar
151
- defaultDisabled={['2020-12-04']}
152
- defaultPreviouslySelected={['2020-12-06']}
153
- defaultSelected={['2020-12-08']}
154
- />
155
- );
156
- }
157
- `,
158
- 'should not remove & leave a TODO comment when innerProps is itself not present',
159
- );
160
- });
@@ -1,11 +0,0 @@
1
- import { flattenCertainChildPropsAsProp } from '../utils';
2
-
3
- const component = '@atlaskit/calendar';
4
- const prop = 'innerProps';
5
- const childProps = ['style', 'className'];
6
-
7
- export const flattenCertainInnerPropsAsProp = flattenCertainChildPropsAsProp(
8
- component,
9
- prop,
10
- childProps,
11
- );
@@ -1,11 +0,0 @@
1
- import { createRemoveFuncFor } from '../utils';
2
-
3
- const component = '@atlaskit/calendar';
4
- const prop = 'innerProps';
5
- const comment = `This file uses the @atlaskit/calendar \`innerProps\` which
6
- has now been removed due to its poor performance characteristics. Codemod
7
- has auto flattened 'className' & 'style' properties inside it if present as a standalone props to calendar.
8
- Rest other properties if any inside innerProps will get auto-removed along with it,
9
- & might have to be handled manually as per need.`;
10
-
11
- export const removeInnerProps = createRemoveFuncFor(component, prop, comment);
@@ -1,192 +0,0 @@
1
- import type {
2
- API,
3
- ASTPath,
4
- default as core,
5
- FileInfo,
6
- ImportDeclaration,
7
- ImportSpecifier,
8
- JSXAttribute,
9
- ObjectExpression,
10
- Options,
11
- Program,
12
- } from 'jscodeshift';
13
- import { type Collection } from 'jscodeshift/src/Collection';
14
-
15
- export type Nullable<T> = T | null;
16
-
17
- export function getDefaultSpecifier(j: core.JSCodeshift, source: any, specifier: string) {
18
- const specifiers = source
19
- .find(j.ImportDeclaration)
20
- .filter((path: ASTPath<ImportDeclaration>) => path.node.source.value === specifier)
21
- .find(j.ImportDefaultSpecifier);
22
-
23
- if (!specifiers.length) {
24
- return null;
25
- }
26
- return specifiers.nodes()[0]!.local!.name;
27
- }
28
- export function getNamedSpecifier(
29
- j: core.JSCodeshift,
30
- source: any,
31
- specifier: string,
32
- importName: string,
33
- ) {
34
- const specifiers = source
35
- .find(j.ImportDeclaration)
36
- .filter((path: ASTPath<ImportDeclaration>) => path.node.source.value === specifier)
37
- .find(j.ImportSpecifier)
38
- .filter((path: ASTPath<ImportSpecifier>) => path.node.imported.name === importName);
39
-
40
- if (!specifiers.length) {
41
- return null;
42
- }
43
- return specifiers.nodes()[0]!.local!.name;
44
- }
45
-
46
- export function getJSXAttributesByName(
47
- j: core.JSCodeshift,
48
- element: ASTPath<any>,
49
- attributeName: string,
50
- ): Collection<JSXAttribute> {
51
- return j(element)
52
- .find(j.JSXOpeningElement)
53
- .find(j.JSXAttribute)
54
- .filter((attribute) => {
55
- const matches = j(attribute)
56
- .find(j.JSXIdentifier)
57
- .filter((identifier) => identifier.value.name === attributeName);
58
- return Boolean(matches.length);
59
- });
60
- }
61
-
62
- export function hasImportDeclaration(j: core.JSCodeshift, source: any, importPath: string) {
63
- const imports = source
64
- .find(j.ImportDeclaration)
65
- .filter(
66
- (path: ASTPath<ImportDeclaration>) =>
67
- typeof path.node.source.value === 'string' && path.node.source.value.startsWith(importPath),
68
- );
69
-
70
- return Boolean(imports.length);
71
- }
72
- // not replacing newlines (which \s does)
73
- const spacesAndTabs: RegExp = /[ \t]{2,}/g;
74
- const lineStartWithSpaces: RegExp = /^[ \t]*/gm;
75
-
76
- function clean(value: string): string {
77
- return (
78
- value
79
- .replace(spacesAndTabs, ' ')
80
- .replace(lineStartWithSpaces, '')
81
- // using .trim() to clear the any newlines before the first text and after last text
82
- .trim()
83
- );
84
- }
85
-
86
- export function addCommentToStartOfFile({
87
- j,
88
- base,
89
- message,
90
- }: {
91
- j: core.JSCodeshift;
92
- base: Collection<Node>;
93
- message: string;
94
- }) {
95
- addCommentBefore({
96
- j,
97
- target: base.find(j.Program),
98
- message,
99
- });
100
- }
101
-
102
- export function addCommentBefore({
103
- j,
104
- target,
105
- message,
106
- }: {
107
- j: core.JSCodeshift;
108
- target: Collection<Program> | Collection<ImportDeclaration>;
109
- message: string;
110
- }) {
111
- const content: string = ` TODO: (from codemod) ${clean(message)} `;
112
- target.forEach((path: ASTPath<Program | ImportDeclaration>) => {
113
- path.value.comments = path.value.comments || [];
114
-
115
- const exists = path.value.comments.find((comment) => comment.value === content);
116
-
117
- // avoiding duplicates of the same comment
118
- if (exists) {
119
- return;
120
- }
121
-
122
- path.value.comments.push(j.commentBlock(content));
123
- });
124
- }
125
-
126
- export const createRemoveFuncFor =
127
- (component: string, prop: string, comment?: string) =>
128
- (j: core.JSCodeshift, source: Collection<Node>) => {
129
- const defaultSpecifier = getDefaultSpecifier(j, source, component);
130
-
131
- if (!defaultSpecifier) {
132
- return;
133
- }
134
-
135
- source.findJSXElements(defaultSpecifier).forEach((element) => {
136
- getJSXAttributesByName(j, element, prop).forEach((attribute) => {
137
- j(attribute).remove();
138
- if (comment) {
139
- addCommentToStartOfFile({ j, base: source, message: comment });
140
- }
141
- });
142
- });
143
- };
144
-
145
- export const flattenCertainChildPropsAsProp =
146
- (component: string, propName: string, childProps: string[]) =>
147
- (j: core.JSCodeshift, source: Collection<Node>) => {
148
- const defaultSpecifier = getDefaultSpecifier(j, source, component);
149
- if (!defaultSpecifier) {
150
- return;
151
- }
152
- source.findJSXElements(defaultSpecifier).forEach((element) => {
153
- getJSXAttributesByName(j, element, propName).forEach((attribute) => {
154
- j(attribute)
155
- .find(j.JSXExpressionContainer)
156
- .find(j.ObjectExpression)
157
- .forEach((objectExpression) => {
158
- objectExpression.node.properties.forEach((property) => {
159
- childProps.forEach((childProp) => {
160
- if (
161
- property.type === 'ObjectProperty' &&
162
- property.key.type === 'Identifier' &&
163
- property.key.name === childProp &&
164
- element.node.openingElement.attributes
165
- ) {
166
- element.node.openingElement.attributes.push(
167
- j.jsxAttribute(
168
- j.jsxIdentifier(childProp),
169
- j.jsxExpressionContainer(property.value as ObjectExpression),
170
- ),
171
- );
172
- }
173
- });
174
- });
175
- });
176
- });
177
- });
178
- };
179
-
180
- export const createTransformer =
181
- (component: string, migrates: { (j: core.JSCodeshift, source: Collection<Node>): void }[]) =>
182
- (fileInfo: FileInfo, { jscodeshift: j }: API, options: Options) => {
183
- const source: Collection<Node> = j(fileInfo.source);
184
-
185
- if (!hasImportDeclaration(j, source, component)) {
186
- return fileInfo.source;
187
- }
188
-
189
- migrates.forEach((tf) => tf(j, source));
190
-
191
- return source.toSource(options.printOptions || { quote: 'single' });
192
- };