@atlaskit/code 15.1.2 → 15.2.1

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 (54) hide show
  1. package/CHANGELOG.md +444 -183
  2. package/__perf__/source-code-examples/100-line-example.tsx +49 -40
  3. package/codemods/13.0.0-remove-unnecessary-code-props.tsx +61 -75
  4. package/codemods/13.0.0-rename-imports.tsx +214 -251
  5. package/codemods/14.0.0-lite-mode.tsx +5 -9
  6. package/codemods/__tests__/13.0.0-remove-unnecessary-code-props.tsx +43 -43
  7. package/codemods/__tests__/13.0.0-rename-imports.tsx +143 -143
  8. package/codemods/__tests__/14.0.0-lite-mode/14.0.0-lite-mode.tsx +35 -35
  9. package/codemods/__tests__/14.0.0-lite-mode/remove-language.tsx +21 -21
  10. package/codemods/__tests__/14.0.0-lite-mode/text-to-child.tsx +35 -35
  11. package/codemods/migrations/14.0.0-lite-mode/remove-language.tsx +1 -6
  12. package/codemods/migrations/14.0.0-lite-mode/text-to-child.tsx +53 -61
  13. package/codemods/utils/helpers.tsx +161 -201
  14. package/dist/cjs/internal/theme/styles.js +2 -1
  15. package/dist/es2019/internal/theme/styles.js +2 -1
  16. package/dist/esm/internal/theme/styles.js +2 -1
  17. package/dist/types/bidi-warning/ui/index.d.ts +1 -1
  18. package/dist/types/bidi-warning/ui/styled.d.ts +1 -1
  19. package/dist/types/extract-react-types/code-block.d.ts +16 -16
  20. package/dist/types/internal/hooks/use-highlight.d.ts +1 -1
  21. package/dist/types/internal/utils/get-normalized-language.d.ts +1 -1
  22. package/dist/types/syntax-highlighter/async.d.ts +1 -1
  23. package/dist/types/syntax-highlighter/lib/highlight.d.ts +1 -1
  24. package/dist/types/syntax-highlighter/lib/process/create-line-element.d.ts +1 -1
  25. package/dist/types/syntax-highlighter/lib/process/create-line.d.ts +1 -1
  26. package/dist/types/syntax-highlighter/lib/process/flatten-code-tree.d.ts +1 -1
  27. package/dist/types/syntax-highlighter/lib/process/get-code-tree.d.ts +1 -1
  28. package/dist/types/syntax-highlighter/lib/process/get-inline-line-number.d.ts +1 -1
  29. package/dist/types/syntax-highlighter/lib/process/index.d.ts +1 -1
  30. package/dist/types/syntax-highlighter/lib/react-renderer/create-children.d.ts +2 -2
  31. package/dist/types/syntax-highlighter/lib/react-renderer/create-element.d.ts +2 -2
  32. package/dist/types/syntax-highlighter/lib/react-renderer/index.d.ts +1 -1
  33. package/dist/types/syntax-highlighter/types.d.ts +2 -2
  34. package/dist/types/types.d.ts +1 -1
  35. package/dist/types-ts4.5/bidi-warning/ui/index.d.ts +1 -1
  36. package/dist/types-ts4.5/bidi-warning/ui/styled.d.ts +1 -1
  37. package/dist/types-ts4.5/extract-react-types/code-block.d.ts +16 -16
  38. package/dist/types-ts4.5/internal/hooks/use-highlight.d.ts +1 -1
  39. package/dist/types-ts4.5/internal/utils/get-normalized-language.d.ts +1 -1
  40. package/dist/types-ts4.5/syntax-highlighter/async.d.ts +1 -1
  41. package/dist/types-ts4.5/syntax-highlighter/lib/highlight.d.ts +1 -1
  42. package/dist/types-ts4.5/syntax-highlighter/lib/process/create-line-element.d.ts +1 -1
  43. package/dist/types-ts4.5/syntax-highlighter/lib/process/create-line.d.ts +1 -1
  44. package/dist/types-ts4.5/syntax-highlighter/lib/process/flatten-code-tree.d.ts +1 -1
  45. package/dist/types-ts4.5/syntax-highlighter/lib/process/get-code-tree.d.ts +1 -1
  46. package/dist/types-ts4.5/syntax-highlighter/lib/process/get-inline-line-number.d.ts +1 -1
  47. package/dist/types-ts4.5/syntax-highlighter/lib/process/index.d.ts +1 -1
  48. package/dist/types-ts4.5/syntax-highlighter/lib/react-renderer/create-children.d.ts +2 -2
  49. package/dist/types-ts4.5/syntax-highlighter/lib/react-renderer/create-element.d.ts +2 -2
  50. package/dist/types-ts4.5/syntax-highlighter/lib/react-renderer/index.d.ts +1 -1
  51. package/dist/types-ts4.5/syntax-highlighter/types.d.ts +2 -2
  52. package/dist/types-ts4.5/types.d.ts +1 -1
  53. package/package.json +11 -11
  54. package/report.api.md +807 -807
@@ -1,266 +1,226 @@
1
- import core, {
2
- ASTPath,
3
- CallExpression,
4
- Identifier,
5
- ImportDeclaration,
6
- ImportSpecifier,
7
- JSCodeshift,
8
- JSXAttribute,
9
- JSXElement,
10
- ObjectProperty,
1
+ import type {
2
+ ASTPath,
3
+ CallExpression,
4
+ default as core,
5
+ Identifier,
6
+ ImportDeclaration,
7
+ ImportSpecifier,
8
+ JSCodeshift,
9
+ JSXAttribute,
10
+ JSXElement,
11
+ ObjectProperty,
11
12
  } from 'jscodeshift';
12
- import { Collection } from 'jscodeshift/src/Collection';
13
+ import { type Collection } from 'jscodeshift/src/Collection';
13
14
 
14
- import {
15
- addCommentToStartOfFile,
16
- getNamedSpecifier,
17
- } from '@atlaskit/codemod-utils';
15
+ import { addCommentToStartOfFile, getNamedSpecifier } from '@atlaskit/codemod-utils';
18
16
 
19
17
  export function hasImportDeclaration(
20
- j: JSCodeshift,
21
- collection: Collection<any>,
22
- importPath: string,
18
+ j: JSCodeshift,
19
+ collection: Collection<any>,
20
+ importPath: string,
23
21
  ) {
24
- return getImportDeclarationCollection(j, collection, importPath).length > 0;
22
+ return getImportDeclarationCollection(j, collection, importPath).length > 0;
25
23
  }
26
24
 
27
25
  export function getImportDeclarationCollection(
28
- j: JSCodeshift,
29
- collection: Collection<any>,
30
- importPath: string,
26
+ j: JSCodeshift,
27
+ collection: Collection<any>,
28
+ importPath: string,
31
29
  ) {
32
- return collection
33
- .find(j.ImportDeclaration)
34
- .filter(
35
- (importDeclarationPath) =>
36
- importDeclarationPath.node.source.value === importPath,
37
- );
30
+ return collection
31
+ .find(j.ImportDeclaration)
32
+ .filter((importDeclarationPath) => importDeclarationPath.node.source.value === importPath);
38
33
  }
39
34
 
40
- export function hasDynamicImport(
41
- j: JSCodeshift,
42
- collection: Collection<any>,
43
- importPath: string,
44
- ) {
45
- return getDynamicImportCollection(j, collection, importPath).length > 0;
35
+ export function hasDynamicImport(j: JSCodeshift, collection: Collection<any>, importPath: string) {
36
+ return getDynamicImportCollection(j, collection, importPath).length > 0;
46
37
  }
47
38
 
48
39
  export function getDynamicImportCollection(
49
- j: JSCodeshift,
50
- collection: Collection<any>,
51
- importPath: string,
40
+ j: JSCodeshift,
41
+ collection: Collection<any>,
42
+ importPath: string,
52
43
  ) {
53
- return collection.find(j.CallExpression).filter((callExpressionPath) => {
54
- const { callee, arguments: callExpressionArguments } =
55
- callExpressionPath.node;
44
+ return collection.find(j.CallExpression).filter((callExpressionPath) => {
45
+ const { callee, arguments: callExpressionArguments } = callExpressionPath.node;
56
46
 
57
- return !!(
58
- isCallExpressionCalleeImportType(callee) &&
59
- isCallExpressionArgumentStringLiteralType(callExpressionArguments) &&
60
- isCallExpressionArgumentValueMatches(
61
- callExpressionArguments[0],
62
- j,
63
- importPath,
64
- )
65
- );
66
- });
47
+ return !!(
48
+ isCallExpressionCalleeImportType(callee) &&
49
+ isCallExpressionArgumentStringLiteralType(callExpressionArguments) &&
50
+ isCallExpressionArgumentValueMatches(callExpressionArguments[0], j, importPath)
51
+ );
52
+ });
67
53
  }
68
54
  function isCallExpressionCalleeImportType(callee: CallExpression['callee']) {
69
- return callee && callee.type === 'Import';
55
+ return callee && callee.type === 'Import';
70
56
  }
71
57
  function isCallExpressionArgumentStringLiteralType(
72
- callExpressionArguments: CallExpression['arguments'],
58
+ callExpressionArguments: CallExpression['arguments'],
73
59
  ) {
74
- return (
75
- callExpressionArguments &&
76
- callExpressionArguments.length &&
77
- callExpressionArguments[0].type === 'StringLiteral'
78
- );
60
+ return (
61
+ callExpressionArguments &&
62
+ callExpressionArguments.length &&
63
+ callExpressionArguments[0].type === 'StringLiteral'
64
+ );
79
65
  }
80
66
  function isCallExpressionArgumentValueMatches(
81
- callExpressionArgument: CallExpression['arguments'][0],
82
- j: JSCodeshift,
83
- value: string,
67
+ callExpressionArgument: CallExpression['arguments'][0],
68
+ j: JSCodeshift,
69
+ value: string,
84
70
  ) {
85
- return j(callExpressionArgument).some((path) => path.node.value === value);
71
+ return j(callExpressionArgument).some((path) => path.node.value === value);
86
72
  }
87
73
 
88
74
  export function getImportSpecifierCollection(
89
- j: JSCodeshift,
90
- importDeclarationCollection: Collection<ImportDeclaration>,
91
- importName: string,
75
+ j: JSCodeshift,
76
+ importDeclarationCollection: Collection<ImportDeclaration>,
77
+ importName: string,
92
78
  ) {
93
- return importDeclarationCollection
94
- .find(j.ImportSpecifier)
95
- .filter(
96
- (importSpecifierPath) =>
97
- importSpecifierPath.node.imported.name === importName,
98
- );
79
+ return importDeclarationCollection
80
+ .find(j.ImportSpecifier)
81
+ .filter((importSpecifierPath) => importSpecifierPath.node.imported.name === importName);
99
82
  }
100
83
 
101
- export function getImportSpecifierName(
102
- importSpecifierCollection: Collection<ImportSpecifier>,
103
- ) {
104
- if (importSpecifierCollection.length === 0) {
105
- return null;
106
- }
84
+ export function getImportSpecifierName(importSpecifierCollection: Collection<ImportSpecifier>) {
85
+ if (importSpecifierCollection.length === 0) {
86
+ return null;
87
+ }
107
88
 
108
- return importSpecifierCollection.nodes()[0]!.local!.name;
89
+ return importSpecifierCollection.nodes()[0]!.local!.name;
109
90
  }
110
91
 
111
92
  export function isVariableDeclaratorIdentifierPresent(
112
- j: JSCodeshift,
113
- collection: Collection<any>,
114
- variableName: string,
93
+ j: JSCodeshift,
94
+ collection: Collection<any>,
95
+ variableName: string,
115
96
  ) {
116
- return collection
117
- .find(j.VariableDeclaration)
118
- .find(j.VariableDeclarator)
119
- .some((variableDeclaratorPath) => {
120
- const { id } = variableDeclaratorPath.node;
97
+ return collection
98
+ .find(j.VariableDeclaration)
99
+ .find(j.VariableDeclarator)
100
+ .some((variableDeclaratorPath) => {
101
+ const { id } = variableDeclaratorPath.node;
121
102
 
122
- return !!(
123
- id &&
124
- id.type === 'Identifier' &&
125
- (id as Identifier).name === variableName
126
- );
127
- });
103
+ return !!(id && id.type === 'Identifier' && (id as Identifier).name === variableName);
104
+ });
128
105
  }
129
106
 
130
107
  export function isFunctionDeclarationIdentifierPresent(
131
- j: JSCodeshift,
132
- collection: Collection<any>,
133
- variableName: string,
108
+ j: JSCodeshift,
109
+ collection: Collection<any>,
110
+ variableName: string,
134
111
  ) {
135
- return collection
136
- .find(j.FunctionDeclaration)
137
- .some((functionDeclarationPath) => {
138
- const { id } = functionDeclarationPath.node;
112
+ return collection.find(j.FunctionDeclaration).some((functionDeclarationPath) => {
113
+ const { id } = functionDeclarationPath.node;
139
114
 
140
- return !!(
141
- id &&
142
- id.type === 'Identifier' &&
143
- (id as Identifier).name === variableName
144
- );
145
- });
115
+ return !!(id && id.type === 'Identifier' && (id as Identifier).name === variableName);
116
+ });
146
117
  }
147
118
 
148
119
  export function isClassDeclarationIdentifierPresent(
149
- j: JSCodeshift,
150
- collection: Collection<any>,
151
- variableName: string,
120
+ j: JSCodeshift,
121
+ collection: Collection<any>,
122
+ variableName: string,
152
123
  ) {
153
- return collection.find(j.ClassDeclaration).some((classDeclarationPath) => {
154
- const { id } = classDeclarationPath.node;
124
+ return collection.find(j.ClassDeclaration).some((classDeclarationPath) => {
125
+ const { id } = classDeclarationPath.node;
155
126
 
156
- return !!(
157
- id &&
158
- id.type === 'Identifier' &&
159
- (id as Identifier).name === variableName
160
- );
161
- });
127
+ return !!(id && id.type === 'Identifier' && (id as Identifier).name === variableName);
128
+ });
162
129
  }
163
130
 
164
131
  export function isImportDeclarationIdentifierPresent(
165
- j: JSCodeshift,
166
- collection: Collection<any>,
167
- variableName: string,
132
+ j: JSCodeshift,
133
+ collection: Collection<any>,
134
+ variableName: string,
168
135
  ) {
169
- return collection
170
- .find(j.ImportDeclaration)
171
- .find(j.Identifier)
172
- .some((identifierPath) => identifierPath.node.name === variableName);
136
+ return collection
137
+ .find(j.ImportDeclaration)
138
+ .find(j.Identifier)
139
+ .some((identifierPath) => identifierPath.node.name === variableName);
173
140
  }
174
141
 
175
142
  export function getJSXAttributesByName(
176
- j: JSCodeshift,
177
- jsxElementPath: ASTPath<JSXElement>,
178
- attributeName: string,
143
+ j: JSCodeshift,
144
+ jsxElementPath: ASTPath<JSXElement>,
145
+ attributeName: string,
179
146
  ): Collection<JSXAttribute> {
180
- return j(jsxElementPath)
181
- .find(j.JSXOpeningElement)
182
- .find(j.JSXAttribute)
183
- .filter((jsxAttributePath) =>
184
- j(jsxAttributePath)
185
- .find(j.JSXIdentifier)
186
- .some(
187
- (jsxIdentifierPath) => jsxIdentifierPath.node.name === attributeName,
188
- ),
189
- );
147
+ return j(jsxElementPath)
148
+ .find(j.JSXOpeningElement)
149
+ .find(j.JSXAttribute)
150
+ .filter((jsxAttributePath) =>
151
+ j(jsxAttributePath)
152
+ .find(j.JSXIdentifier)
153
+ .some((jsxIdentifierPath) => jsxIdentifierPath.node.name === attributeName),
154
+ );
190
155
  }
191
156
 
192
157
  export function getJSXSpreadIdentifierAttributesByName(
193
- j: JSCodeshift,
194
- collection: Collection<any>,
195
- jsxElementPath: ASTPath<JSXElement>,
196
- attributeName: string,
158
+ j: JSCodeshift,
159
+ collection: Collection<any>,
160
+ jsxElementPath: ASTPath<JSXElement>,
161
+ attributeName: string,
197
162
  ): Collection<ObjectProperty> | null {
198
- const identifierCollection = j(jsxElementPath)
199
- .find(j.JSXOpeningElement)
200
- .find(j.JSXSpreadAttribute)
201
- .filter(
202
- (jsxSpreadAttributePath) =>
203
- jsxSpreadAttributePath.node.argument.type === 'Identifier',
204
- )
205
- .find(j.Identifier);
206
-
207
- if (identifierCollection.length === 0) {
208
- return null;
209
- }
210
-
211
- return collection
212
- .find(j.VariableDeclarator)
213
- .filter((variableDeclaratorPath) => {
214
- const { id } = variableDeclaratorPath.node;
215
-
216
- return (
217
- id.type === 'Identifier' &&
218
- identifierCollection.some(
219
- (identifierPath) => identifierPath.node.name === id.name,
220
- )
221
- );
222
- })
223
- .find(j.ObjectExpression)
224
- .find(j.ObjectProperty)
225
- .filter((objectPropertyPath) =>
226
- j(objectPropertyPath)
227
- .find(j.Identifier)
228
- .some((identifierPath) => identifierPath.node.name === attributeName),
229
- );
163
+ const identifierCollection = j(jsxElementPath)
164
+ .find(j.JSXOpeningElement)
165
+ .find(j.JSXSpreadAttribute)
166
+ .filter((jsxSpreadAttributePath) => jsxSpreadAttributePath.node.argument.type === 'Identifier')
167
+ .find(j.Identifier);
168
+
169
+ if (identifierCollection.length === 0) {
170
+ return null;
171
+ }
172
+
173
+ return collection
174
+ .find(j.VariableDeclarator)
175
+ .filter((variableDeclaratorPath) => {
176
+ const { id } = variableDeclaratorPath.node;
177
+
178
+ return (
179
+ id.type === 'Identifier' &&
180
+ identifierCollection.some((identifierPath) => identifierPath.node.name === id.name)
181
+ );
182
+ })
183
+ .find(j.ObjectExpression)
184
+ .find(j.ObjectProperty)
185
+ .filter((objectPropertyPath) =>
186
+ j(objectPropertyPath)
187
+ .find(j.Identifier)
188
+ .some((identifierPath) => identifierPath.node.name === attributeName),
189
+ );
230
190
  }
231
191
 
232
192
  export function getJSXSpreadObjectExpressionAttributesByName(
233
- j: JSCodeshift,
234
- jsxElementPath: ASTPath<JSXElement>,
235
- attributeName: string,
193
+ j: JSCodeshift,
194
+ jsxElementPath: ASTPath<JSXElement>,
195
+ attributeName: string,
236
196
  ) {
237
- return j(jsxElementPath)
238
- .find(j.JSXOpeningElement)
239
- .find(j.JSXSpreadAttribute)
240
- .find(j.ObjectExpression)
241
- .find(j.ObjectProperty)
242
- .filter((objectPropertyPath) =>
243
- j(objectPropertyPath)
244
- .find(j.Identifier)
245
- .some((identifierPath) => identifierPath.node.name === attributeName),
246
- );
197
+ return j(jsxElementPath)
198
+ .find(j.JSXOpeningElement)
199
+ .find(j.JSXSpreadAttribute)
200
+ .find(j.ObjectExpression)
201
+ .find(j.ObjectProperty)
202
+ .filter((objectPropertyPath) =>
203
+ j(objectPropertyPath)
204
+ .find(j.Identifier)
205
+ .some((identifierPath) => identifierPath.node.name === attributeName),
206
+ );
247
207
  }
248
208
 
249
209
  export const createRemoveFuncFor =
250
- (component: string, importName: string, prop: string, comment?: string) =>
251
- (j: core.JSCodeshift, source: Collection<Node>) => {
252
- const specifier = getNamedSpecifier(j, source, component, importName);
253
-
254
- if (!specifier) {
255
- return;
256
- }
257
-
258
- source.findJSXElements(specifier).forEach((element) => {
259
- getJSXAttributesByName(j, element, prop).forEach((attribute: any) => {
260
- j(attribute).remove();
261
- if (comment) {
262
- addCommentToStartOfFile({ j, base: source, message: comment });
263
- }
264
- });
265
- });
266
- };
210
+ (component: string, importName: string, prop: string, comment?: string) =>
211
+ (j: core.JSCodeshift, source: Collection<Node>) => {
212
+ const specifier = getNamedSpecifier(j, source, component, importName);
213
+
214
+ if (!specifier) {
215
+ return;
216
+ }
217
+
218
+ source.findJSXElements(specifier).forEach((element) => {
219
+ getJSXAttributesByName(j, element, prop).forEach((attribute: any) => {
220
+ j(attribute).remove();
221
+ if (comment) {
222
+ addCommentToStartOfFile({ j, base: source, message: comment });
223
+ }
224
+ });
225
+ });
226
+ };
@@ -219,7 +219,8 @@ var getCodeBlockStyles = exports.getCodeBlockStyles = function getCodeBlockStyle
219
219
  // this is required to account for prismjs styles leaking into the codeblock
220
220
  'code[class*="language-"], pre[class*="language-"], code': {
221
221
  all: 'unset',
222
- padding: showLineNumbers ? "".concat(_constants.SPACING, "px 0") : _constants.SPACING
222
+ padding: showLineNumbers ? "".concat(_constants.SPACING, "px 0") : _constants.SPACING,
223
+ tabSize: 4
223
224
  },
224
225
  display: 'flex',
225
226
  lineHeight: _constants.CODE_LINE_HEIGHT,
@@ -201,7 +201,8 @@ export const getCodeBlockStyles = theme => (highlightedStartText, highlightedEnd
201
201
  // this is required to account for prismjs styles leaking into the codeblock
202
202
  'code[class*="language-"], pre[class*="language-"], code': {
203
203
  all: 'unset',
204
- padding: showLineNumbers ? `${SPACING}px 0` : SPACING
204
+ padding: showLineNumbers ? `${SPACING}px 0` : SPACING,
205
+ tabSize: 4
205
206
  },
206
207
  display: 'flex',
207
208
  lineHeight: CODE_LINE_HEIGHT,
@@ -212,7 +212,8 @@ export var getCodeBlockStyles = function getCodeBlockStyles(theme) {
212
212
  // this is required to account for prismjs styles leaking into the codeblock
213
213
  'code[class*="language-"], pre[class*="language-"], code': {
214
214
  all: 'unset',
215
- padding: showLineNumbers ? "".concat(SPACING, "px 0") : SPACING
215
+ padding: showLineNumbers ? "".concat(SPACING, "px 0") : SPACING,
216
+ tabSize: 4
216
217
  },
217
218
  display: 'flex',
218
219
  lineHeight: CODE_LINE_HEIGHT,
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { CodeBidiWarningProps } from './types';
2
+ import { type CodeBidiWarningProps } from './types';
3
3
  /**
4
4
  * __Bidi Warning__
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
- import { ReactNode } from 'react';
2
+ import { type ReactNode } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
4
  export declare function Decorator({ bidiCharacter, children, testId, }: {
5
5
  bidiCharacter: string;
@@ -12,24 +12,24 @@ export default function CodeBlock(__: {
12
12
  */
13
13
  showLineNumbers?: boolean;
14
14
  /**
15
- Language reference designed to be populated from `SUPPORTED_LANGUAGES` in
16
- `design-system/code`. Run against language grammars from PrismJS (full list
17
- available at [PrismJS documentation](https://prismjs.com/#supported-languages)).
18
-
19
- When set to `text` will not perform highlighting. If unsupported language
20
- provided - code will be treated as "text" with no highlighting.
21
-
22
- Defaults to `text`.
23
- */
15
+ Language reference designed to be populated from `SUPPORTED_LANGUAGES` in
16
+ `design-system/code`. Run against language grammars from PrismJS (full list
17
+ available at [PrismJS documentation](https://prismjs.com/#supported-languages)).
18
+
19
+ When set to `text` will not perform highlighting. If unsupported language
20
+ provided - code will be treated as "text" with no highlighting.
21
+
22
+ Defaults to `text`.
23
+ */
24
24
  language?: string;
25
25
  /**
26
- Comma delimited lines to highlight.
27
-
28
- Example uses:
29
- - To highlight one line `highlight="3"`
30
- - To highlight a group of lines `highlight="1-5"`
31
- - To highlight multiple groups `highlight="1-5,7,10,15-20"`
32
- */
26
+ Comma delimited lines to highlight.
27
+
28
+ Example uses:
29
+ - To highlight one line `highlight="3"`
30
+ - To highlight a group of lines `highlight="1-5"`
31
+ - To highlight multiple groups `highlight="1-5,7,10,15-20"`
32
+ */
33
33
  highlight?: string;
34
34
  /**
35
35
  * Screen reader text for the start of a highlighted line.
@@ -1,4 +1,4 @@
1
- import { HTMLProps } from 'react';
1
+ import { type HTMLProps } from 'react';
2
2
  import type { CodeBlockProps } from '../types';
3
3
  export declare const useHighlightLines: ({ highlight, testId, }: Pick<CodeBlockProps, 'highlight' | 'testId'>) => {
4
4
  getHighlightStyles: (lineNumber: number, highlightedLines: number[]) => HTMLProps<HTMLElement>;
@@ -1,2 +1,2 @@
1
- import { SupportedLanguages } from '../types';
1
+ import { type SupportedLanguages } from '../types';
2
2
  export declare const normalizeLanguage: import("memoize-one").MemoizedFn<(language?: SupportedLanguages) => string>;
@@ -1,3 +1,3 @@
1
- import { SyntaxHighlighter } from './types';
1
+ import { type SyntaxHighlighter } from './types';
2
2
  declare const _default: typeof SyntaxHighlighter;
3
3
  export default _default;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { SyntaxHighlighterProps } from '../types';
2
+ import { type SyntaxHighlighterProps } from '../types';
3
3
  /**
4
4
  * Takes in a code string and (in the default behaviour):
5
5
  * - Uses refractor to turn it into a tree structure with highlighting metadata
@@ -1,4 +1,4 @@
1
- import { AST, RefractorNode, SyntaxHighlighterLineProps } from '../../types';
1
+ import { type AST, type RefractorNode, type SyntaxHighlighterLineProps } from '../../types';
2
2
  export type CreateLineElementProps = {
3
3
  children: RefractorNode[];
4
4
  lineNumber: number;
@@ -1,3 +1,3 @@
1
- import { RefractorNode, SyntaxHighlighterLineProps } from '../../types';
1
+ import { type RefractorNode, type SyntaxHighlighterLineProps } from '../../types';
2
2
  declare function createLineGenerator(lineProps: SyntaxHighlighterLineProps, shouldCreateParentElementForLines: boolean, showLineNumbers: boolean): (children: RefractorNode[], lineNumber: number, className?: string[]) => RefractorNode | RefractorNode[];
3
3
  export default createLineGenerator;
@@ -1,2 +1,2 @@
1
- import { RefractorNode } from '../../types';
1
+ import { type RefractorNode } from '../../types';
2
2
  export default function flattenCodeTree(tree: RefractorNode[], offset?: number, className?: string[]): RefractorNode[];
@@ -1,2 +1,2 @@
1
- import { AstGenerator, RefractorNode } from '../../types';
1
+ import { type AstGenerator, type RefractorNode } from '../../types';
2
2
  export default function getCodeTree(language: string, code: string, astGenerator?: AstGenerator): RefractorNode[];
@@ -1,2 +1,2 @@
1
- import { RefractorNode } from '../../types';
1
+ import { type RefractorNode } from '../../types';
2
2
  export default function getInlineLineNumber(lineNumber: number): RefractorNode;
@@ -1,4 +1,4 @@
1
- import { AstGenerator, RefractorNode, SyntaxHighlighterLineProps } from '../../types';
1
+ import { type AstGenerator, type RefractorNode, type SyntaxHighlighterLineProps } from '../../types';
2
2
  interface ProcessLines {
3
3
  astGenerator: AstGenerator;
4
4
  code: string;
@@ -1,3 +1,3 @@
1
- import { ReactNode } from 'react';
2
- import { CodeBidiWarningConfig, RefractorNode } from '../../types';
1
+ import { type ReactNode } from 'react';
2
+ import { type CodeBidiWarningConfig, type RefractorNode } from '../../types';
3
3
  export default function createChildren(codeBidiWarningConfig: CodeBidiWarningConfig): (children: RefractorNode[]) => ReactNode[];
@@ -1,5 +1,5 @@
1
- import { ReactNode } from 'react';
2
- import { CodeBidiWarningConfig, RefractorNode } from '../../types';
1
+ import { type ReactNode } from 'react';
2
+ import { type CodeBidiWarningConfig, type RefractorNode } from '../../types';
3
3
  export default function createElement({ node, codeBidiWarningConfig, key, }: {
4
4
  node: RefractorNode;
5
5
  codeBidiWarningConfig: CodeBidiWarningConfig;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { CodeBidiWarningConfig, RefractorNode } from '../../types';
2
+ import { type CodeBidiWarningConfig, type RefractorNode } from '../../types';
3
3
  /**
4
4
  * __React Renderer__
5
5
  *
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
- import { SerializedStyles } from '@emotion/react';
3
- import { AST, RefractorNode } from 'refractor';
2
+ import { type SerializedStyles } from '@emotion/react';
3
+ import { type AST, type RefractorNode } from 'refractor';
4
4
  export type { AST, RefractorNode } from 'refractor';
5
5
  export declare class SyntaxHighlighter extends React.PureComponent<SyntaxHighlighterProps> {
6
6
  }
@@ -1,5 +1,5 @@
1
1
  import type { HTMLProps, ReactNode } from 'react';
2
- export type { SupportedLanguages, Language, LanguageAlias, CodeBlockProps, } from './internal/types';
2
+ export type { SupportedLanguages, Language, LanguageAlias, CodeBlockProps } from './internal/types';
3
3
  export interface CodeProps extends HTMLProps<HTMLElement> {
4
4
  /**
5
5
  * A unique string that appears as a data attribute `data-testid`
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { CodeBidiWarningProps } from './types';
2
+ import { type CodeBidiWarningProps } from './types';
3
3
  /**
4
4
  * __Bidi Warning__
5
5
  *
@@ -1,5 +1,5 @@
1
1
  /** @jsx jsx */
2
- import { ReactNode } from 'react';
2
+ import { type ReactNode } from 'react';
3
3
  import { jsx } from '@emotion/react';
4
4
  export declare function Decorator({ bidiCharacter, children, testId, }: {
5
5
  bidiCharacter: string;