@atlaskit/side-navigation 3.2.0 → 3.3.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.
Files changed (56) hide show
  1. package/CHANGELOG.md +20 -1
  2. package/README.md +7 -3
  3. package/afm-jira/tsconfig.json +3 -0
  4. package/codemods/0.8.0-change-css-fn-prop.tsx +136 -164
  5. package/codemods/__tests__/0.8.0-change-css-fn-prop.tsx +77 -77
  6. package/codemods/helpers/generic.tsx +528 -564
  7. package/constellation/index/examples.mdx +20 -20
  8. package/constellation/index/props.mdx +8 -8
  9. package/constellation/index/usage.mdx +27 -11
  10. package/dist/cjs/components/Header/index.js +4 -0
  11. package/dist/cjs/components/Item/link-item.js +3 -1
  12. package/dist/cjs/components/LoadingItems/index.js +7 -3
  13. package/dist/cjs/components/NavigationContent/index.js +8 -1
  14. package/dist/cjs/components/NavigationHeader/index.js +4 -0
  15. package/dist/cjs/components/NestableNavigationContent/index.js +5 -0
  16. package/dist/cjs/components/NestableNavigationContent/nesting-motion.js +3 -1
  17. package/dist/cjs/components/NestingItem/index.js +4 -0
  18. package/dist/cjs/components/SideNavigation/index.js +5 -0
  19. package/dist/es2019/components/Header/index.js +5 -0
  20. package/dist/es2019/components/Item/link-item.js +3 -1
  21. package/dist/es2019/components/LoadingItems/index.js +7 -3
  22. package/dist/es2019/components/NavigationContent/index.js +8 -1
  23. package/dist/es2019/components/NavigationHeader/index.js +4 -0
  24. package/dist/es2019/components/NestableNavigationContent/index.js +5 -0
  25. package/dist/es2019/components/NestableNavigationContent/nesting-motion.js +4 -0
  26. package/dist/es2019/components/NestingItem/index.js +5 -0
  27. package/dist/es2019/components/SideNavigation/index.js +5 -0
  28. package/dist/esm/components/Header/index.js +5 -0
  29. package/dist/esm/components/Item/link-item.js +3 -1
  30. package/dist/esm/components/LoadingItems/index.js +7 -3
  31. package/dist/esm/components/NavigationContent/index.js +8 -1
  32. package/dist/esm/components/NavigationHeader/index.js +4 -0
  33. package/dist/esm/components/NestableNavigationContent/index.js +5 -0
  34. package/dist/esm/components/NestableNavigationContent/nesting-motion.js +4 -0
  35. package/dist/esm/components/NestingItem/index.js +5 -0
  36. package/dist/esm/components/SideNavigation/index.js +5 -0
  37. package/dist/types/components/LoadingItems/index.d.ts +1 -1
  38. package/dist/types/components/NavigationContent/index.d.ts +3 -0
  39. package/dist/types/components/NavigationHeader/index.d.ts +3 -0
  40. package/dist/types/components/NestableNavigationContent/index.d.ts +0 -1
  41. package/dist/types/components/NestableNavigationContent/nesting-motion.d.ts +3 -0
  42. package/dist/types/components/NestingItem/index.d.ts +3 -0
  43. package/dist/types/components/index.d.ts +2 -2
  44. package/dist/types/index.d.ts +1 -1
  45. package/dist/types-ts4.5/components/LoadingItems/index.d.ts +1 -1
  46. package/dist/types-ts4.5/components/NavigationContent/index.d.ts +3 -0
  47. package/dist/types-ts4.5/components/NavigationHeader/index.d.ts +3 -0
  48. package/dist/types-ts4.5/components/NestableNavigationContent/index.d.ts +0 -1
  49. package/dist/types-ts4.5/components/NestableNavigationContent/nesting-motion.d.ts +3 -0
  50. package/dist/types-ts4.5/components/NestingItem/index.d.ts +3 -0
  51. package/dist/types-ts4.5/components/index.d.ts +2 -2
  52. package/dist/types-ts4.5/index.d.ts +1 -1
  53. package/docs/00-intro.tsx +4 -6
  54. package/docs/ert/footer.tsx +6 -6
  55. package/package.json +97 -97
  56. package/report.api.md +102 -123
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # @atlaskit/side-navigation
2
2
 
3
+ ## 3.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#110836](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/110836)
8
+ [`a8bd419fd70b9`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/a8bd419fd70b9) -
9
+ Explicitly set jsxRuntime to classic via pragma comments in order to avoid issues where jsxRuntime
10
+ is implicitly set to automatic.
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
16
+ ## 3.2.1
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
3
22
  ## 3.2.0
4
23
 
5
24
  ### Minor Changes
@@ -37,7 +56,7 @@
37
56
 
38
57
  - [#94389](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/94389)
39
58
  [`5ca1173e141e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/5ca1173e141e) -
40
- Add support for React 18.
59
+ Add support for React 18 in non-strict mode.
41
60
 
42
61
  ## 3.0.10
43
62
 
package/README.md CHANGED
@@ -10,7 +10,11 @@ yarn add @atlaskit/side-navigation
10
10
 
11
11
  ## Usage
12
12
 
13
- Detailed docs and example usage can be found [here](https://atlassian.design/components/side-navigation).
13
+ Detailed docs and example usage can be found
14
+ [here](https://atlassian.design/components/side-navigation).
14
15
 
15
- To add a top navigation, use [@atlaskit/atlassian-navigation](https://atlassian.design/components/atlassian-navigation)
16
- To control the layout of these navigation elements and add expand/collapse functionality to `side-navigation`, use [@atlaskit/page-layout](https://atlaskit.atlassian.com/packages/design-system/page-layout).
16
+ To add a top navigation, use
17
+ [@atlaskit/atlassian-navigation](https://atlassian.design/components/atlassian-navigation) To
18
+ control the layout of these navigation elements and add expand/collapse functionality to
19
+ `side-navigation`, use
20
+ [@atlaskit/page-layout](https://atlaskit.atlassian.com/packages/design-system/page-layout).
@@ -30,6 +30,9 @@
30
30
  {
31
31
  "path": "../../motion/afm-jira/tsconfig.json"
32
32
  },
33
+ {
34
+ "path": "../../../platform/feature-flags/afm-jira/tsconfig.json"
35
+ },
33
36
  {
34
37
  "path": "../../primitives/afm-jira/tsconfig.json"
35
38
  },
@@ -1,185 +1,157 @@
1
1
  import { type NodePath } from 'ast-types/lib/node-path';
2
2
  import {
3
- type API,
4
- type ASTPath,
5
- type default as core,
6
- type FileInfo,
7
- type ImportDeclaration,
8
- type ImportSpecifier,
9
- type Options,
3
+ type API,
4
+ type ASTPath,
5
+ type default as core,
6
+ type FileInfo,
7
+ type ImportDeclaration,
8
+ type ImportSpecifier,
9
+ type Options,
10
10
  } from 'jscodeshift';
11
11
 
12
- import {
13
- addCommentBeforeJSX,
14
- getDefaultSpecifierName,
15
- } from './helpers/generic';
16
-
17
- function getJSXAttributesByName(
18
- j: core.JSCodeshift,
19
- element: ASTPath<any>,
20
- attributeName: string,
21
- ) {
22
- return j(element)
23
- .find(j.JSXOpeningElement)
24
- .find(j.JSXAttribute)
25
- .filter((attribute) => {
26
- const matches = j(attribute)
27
- .find(j.JSXIdentifier)
28
- .filter((identifier) => identifier.value.name === attributeName);
29
- return Boolean(matches.length);
30
- });
12
+ import { addCommentBeforeJSX, getDefaultSpecifierName } from './helpers/generic';
13
+
14
+ function getJSXAttributesByName(j: core.JSCodeshift, element: ASTPath<any>, attributeName: string) {
15
+ return j(element)
16
+ .find(j.JSXOpeningElement)
17
+ .find(j.JSXAttribute)
18
+ .filter((attribute) => {
19
+ const matches = j(attribute)
20
+ .find(j.JSXIdentifier)
21
+ .filter((identifier) => identifier.value.name === attributeName);
22
+ return Boolean(matches.length);
23
+ });
31
24
  }
32
25
 
33
26
  function getImportSpecifier(
34
- j: core.JSCodeshift,
35
- source: ReturnType<typeof j>,
36
- specifier: string,
37
- imported: string,
27
+ j: core.JSCodeshift,
28
+ source: ReturnType<typeof j>,
29
+ specifier: string,
30
+ imported: string,
38
31
  ) {
39
- const specifiers = source
40
- .find(j.ImportDeclaration)
41
- .filter(
42
- (path: ASTPath<ImportDeclaration>) =>
43
- path.node.source.value === specifier,
44
- )
45
- .find(j.ImportSpecifier)
46
- .filter(
47
- (path: ASTPath<ImportSpecifier>) => path.value.imported.name === imported,
48
- );
49
-
50
- if (!specifiers.length) {
51
- return null;
52
- }
53
-
54
- return specifiers.nodes()[0]!.local!.name;
32
+ const specifiers = source
33
+ .find(j.ImportDeclaration)
34
+ .filter((path: ASTPath<ImportDeclaration>) => path.node.source.value === specifier)
35
+ .find(j.ImportSpecifier)
36
+ .filter((path: ASTPath<ImportSpecifier>) => path.value.imported.name === imported);
37
+
38
+ if (!specifiers.length) {
39
+ return null;
40
+ }
41
+
42
+ return specifiers.nodes()[0]!.local!.name;
55
43
  }
56
44
 
57
- function updateCssFnProp(
58
- j: core.JSCodeshift,
59
- source: ReturnType<typeof j>,
60
- specifier: string,
61
- ) {
62
- source.findJSXElements(specifier).forEach((element) => {
63
- const cssFnPropCollection = getJSXAttributesByName(j, element, 'cssFn');
64
-
65
- // no cssProp usage for this element
66
- if (!cssFnPropCollection.length) {
67
- return;
68
- }
69
-
70
- const cssFnProp = cssFnPropCollection.get();
71
-
72
- const cssFnExpression: NodePath = j(cssFnProp)
73
- .find(j.JSXExpressionContainer)
74
- .find(j.Expression)
75
- .get();
76
-
77
- if (cssFnExpression) {
78
- // just remove the state styles param
79
- try {
80
- const [stylePropName] = cssFnExpression!.value.params;
81
- j(cssFnExpression)
82
- .find(j.SpreadElement)
83
- .forEach((n) => {
84
- // discerns whether there are multiple identifiers here
85
- const isComplexIdentifier = j(n).find(j.Identifier).length > 1;
86
-
87
- if (isComplexIdentifier) {
88
- throw new Error(
89
- 'CSSFn Prop codemod: Unable to parse spread element',
90
- );
91
- }
92
-
93
- const hasStyleProp = !!j(n)
94
- .find(j.Identifier)
95
- .filter((node) => node.value.name === stylePropName.name).length;
96
- if (hasStyleProp) {
97
- j(n).remove();
98
- }
99
- });
100
-
101
- cssFnExpression!.value.params.shift();
102
- } catch (e) {
103
- addCommentBeforeJSX(
104
- j,
105
- cssFnProp,
106
- `
45
+ function updateCssFnProp(j: core.JSCodeshift, source: ReturnType<typeof j>, specifier: string) {
46
+ source.findJSXElements(specifier).forEach((element) => {
47
+ const cssFnPropCollection = getJSXAttributesByName(j, element, 'cssFn');
48
+
49
+ // no cssProp usage for this element
50
+ if (!cssFnPropCollection.length) {
51
+ return;
52
+ }
53
+
54
+ const cssFnProp = cssFnPropCollection.get();
55
+
56
+ const cssFnExpression: NodePath = j(cssFnProp)
57
+ .find(j.JSXExpressionContainer)
58
+ .find(j.Expression)
59
+ .get();
60
+
61
+ if (cssFnExpression) {
62
+ // just remove the state styles param
63
+ try {
64
+ const [stylePropName] = cssFnExpression!.value.params;
65
+ j(cssFnExpression)
66
+ .find(j.SpreadElement)
67
+ .forEach((n) => {
68
+ // discerns whether there are multiple identifiers here
69
+ const isComplexIdentifier = j(n).find(j.Identifier).length > 1;
70
+
71
+ if (isComplexIdentifier) {
72
+ throw new Error('CSSFn Prop codemod: Unable to parse spread element');
73
+ }
74
+
75
+ const hasStyleProp = !!j(n)
76
+ .find(j.Identifier)
77
+ .filter((node) => node.value.name === stylePropName.name).length;
78
+ if (hasStyleProp) {
79
+ j(n).remove();
80
+ }
81
+ });
82
+
83
+ cssFnExpression!.value.params.shift();
84
+ } catch (e) {
85
+ addCommentBeforeJSX(
86
+ j,
87
+ cssFnProp,
88
+ `
107
89
  The usage of the 'cssFn' prop in this component could not be transformed and requires manual intervention.
108
90
  The 'cssFn' prop has been simplified so that users no longer need to merge the inherited styles with their own overrides.
109
91
  For more info please reach out to #help-design-system-code.
110
92
  `,
111
- );
112
- }
113
- }
114
- });
93
+ );
94
+ }
95
+ }
96
+ });
115
97
  }
116
98
 
117
99
  function hasImportDeclaration(
118
- j: core.JSCodeshift,
119
- source: ReturnType<typeof j>,
120
- importPath: string,
100
+ j: core.JSCodeshift,
101
+ source: ReturnType<typeof j>,
102
+ importPath: string,
121
103
  ) {
122
- return !!source
123
- .find(j.ImportDeclaration)
124
- .filter((path) => path.node.source.value === importPath).length;
104
+ return !!source.find(j.ImportDeclaration).filter((path) => path.node.source.value === importPath)
105
+ .length;
125
106
  }
126
107
 
127
- export default function transformer(
128
- fileInfo: FileInfo,
129
- { jscodeshift: j }: API,
130
- options: Options,
131
- ) {
132
- const source = j(fileInfo.source);
133
-
134
- if (hasImportDeclaration(j, source, '@atlaskit/side-navigation')) {
135
- const defaultSpecifier = getDefaultSpecifierName({
136
- j,
137
- base: source,
138
- packageName: '@atlaskit/side-navigation',
139
- });
140
-
141
- if (defaultSpecifier != null) {
142
- updateCssFnProp(j, source, defaultSpecifier);
143
- }
144
-
145
- [
146
- 'SideNavigation',
147
- 'Header',
148
- 'NavigationHeader',
149
- 'NavigationContent',
150
- 'Section',
151
- 'HeadingItem',
152
- 'SkeletonHeadingItem',
153
- 'NestableNavigationContent',
154
- 'NestingItem',
155
- 'ButtonItem',
156
- 'LinkItem',
157
- 'GoBackItem',
158
- 'CustomItem',
159
- 'SkeletonItem',
160
- 'Footer',
161
- 'NavigationFooter',
162
- 'LoadingItems',
163
- ].forEach((pkg) => {
164
- const importSpecifier = getImportSpecifier(
165
- j,
166
- source,
167
- '@atlaskit/side-navigation',
168
- pkg,
169
- );
170
-
171
- if (importSpecifier != null) {
172
- updateCssFnProp(j, source, importSpecifier);
173
- }
174
- });
175
-
176
- return source.toSource(
177
- options.printOptions || {
178
- quote: 'single',
179
- trailingComma: true,
180
- },
181
- );
182
- }
183
-
184
- return fileInfo.source;
108
+ export default function transformer(fileInfo: FileInfo, { jscodeshift: j }: API, options: Options) {
109
+ const source = j(fileInfo.source);
110
+
111
+ if (hasImportDeclaration(j, source, '@atlaskit/side-navigation')) {
112
+ const defaultSpecifier = getDefaultSpecifierName({
113
+ j,
114
+ base: source,
115
+ packageName: '@atlaskit/side-navigation',
116
+ });
117
+
118
+ if (defaultSpecifier != null) {
119
+ updateCssFnProp(j, source, defaultSpecifier);
120
+ }
121
+
122
+ [
123
+ 'SideNavigation',
124
+ 'Header',
125
+ 'NavigationHeader',
126
+ 'NavigationContent',
127
+ 'Section',
128
+ 'HeadingItem',
129
+ 'SkeletonHeadingItem',
130
+ 'NestableNavigationContent',
131
+ 'NestingItem',
132
+ 'ButtonItem',
133
+ 'LinkItem',
134
+ 'GoBackItem',
135
+ 'CustomItem',
136
+ 'SkeletonItem',
137
+ 'Footer',
138
+ 'NavigationFooter',
139
+ 'LoadingItems',
140
+ ].forEach((pkg) => {
141
+ const importSpecifier = getImportSpecifier(j, source, '@atlaskit/side-navigation', pkg);
142
+
143
+ if (importSpecifier != null) {
144
+ updateCssFnProp(j, source, importSpecifier);
145
+ }
146
+ });
147
+
148
+ return source.toSource(
149
+ options.printOptions || {
150
+ quote: 'single',
151
+ trailingComma: true,
152
+ },
153
+ );
154
+ }
155
+
156
+ return fileInfo.source;
185
157
  }