@atlaskit/code 15.2.0 → 15.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.
- package/CHANGELOG.md +653 -645
- package/__perf__/code-block-syntax-highlighting.tsx +4 -1
- package/__perf__/source-code-examples/100-line-example.tsx +52 -40
- package/codemods/13.0.0-remove-unnecessary-code-props.tsx +61 -75
- package/codemods/13.0.0-rename-imports.tsx +214 -251
- package/codemods/14.0.0-lite-mode.tsx +5 -9
- package/codemods/__tests__/13.0.0-remove-unnecessary-code-props.tsx +43 -43
- package/codemods/__tests__/13.0.0-rename-imports.tsx +143 -143
- package/codemods/__tests__/14.0.0-lite-mode/14.0.0-lite-mode.tsx +35 -35
- package/codemods/__tests__/14.0.0-lite-mode/remove-language.tsx +21 -21
- package/codemods/__tests__/14.0.0-lite-mode/text-to-child.tsx +35 -35
- package/codemods/migrations/14.0.0-lite-mode/remove-language.tsx +1 -6
- package/codemods/migrations/14.0.0-lite-mode/text-to-child.tsx +53 -61
- package/codemods/utils/helpers.tsx +161 -201
- package/dist/cjs/bidi-warning/ui/styled.js +7 -0
- package/dist/cjs/code-block.js +8 -1
- package/dist/cjs/code.js +5 -0
- package/dist/cjs/internal/theme/styles.js +3 -2
- package/dist/cjs/syntax-highlighter/types.js +1 -0
- package/dist/es2019/bidi-warning/ui/styled.js +7 -0
- package/dist/es2019/code-block.js +8 -1
- package/dist/es2019/code.js +6 -0
- package/dist/es2019/internal/theme/styles.js +4 -1
- package/dist/es2019/syntax-highlighter/types.js +3 -0
- package/dist/esm/bidi-warning/ui/styled.js +7 -0
- package/dist/esm/code-block.js +8 -1
- package/dist/esm/code.js +6 -0
- package/dist/esm/internal/theme/styles.js +4 -1
- package/dist/esm/syntax-highlighter/types.js +3 -0
- package/dist/types/bidi-warning/ui/index.d.ts +1 -1
- package/dist/types/bidi-warning/ui/styled.d.ts +4 -1
- package/dist/types/code.d.ts +3 -0
- package/dist/types/extract-react-types/code-block.d.ts +16 -16
- package/dist/types/internal/hooks/use-highlight.d.ts +1 -1
- package/dist/types/internal/utils/get-normalized-language.d.ts +1 -1
- package/dist/types/syntax-highlighter/async.d.ts +1 -1
- package/dist/types/syntax-highlighter/lib/highlight.d.ts +1 -1
- package/dist/types/syntax-highlighter/lib/process/create-line-element.d.ts +1 -1
- package/dist/types/syntax-highlighter/lib/process/create-line.d.ts +1 -1
- package/dist/types/syntax-highlighter/lib/process/flatten-code-tree.d.ts +1 -1
- package/dist/types/syntax-highlighter/lib/process/get-code-tree.d.ts +1 -1
- package/dist/types/syntax-highlighter/lib/process/get-inline-line-number.d.ts +1 -1
- package/dist/types/syntax-highlighter/lib/process/index.d.ts +1 -1
- package/dist/types/syntax-highlighter/lib/react-renderer/create-children.d.ts +2 -2
- package/dist/types/syntax-highlighter/lib/react-renderer/create-element.d.ts +2 -2
- package/dist/types/syntax-highlighter/lib/react-renderer/index.d.ts +1 -1
- package/dist/types/syntax-highlighter/types.d.ts +2 -2
- package/dist/types/types.d.ts +1 -1
- package/dist/types-ts4.5/bidi-warning/ui/index.d.ts +1 -1
- package/dist/types-ts4.5/bidi-warning/ui/styled.d.ts +4 -1
- package/dist/types-ts4.5/code.d.ts +3 -0
- package/dist/types-ts4.5/extract-react-types/code-block.d.ts +16 -16
- package/dist/types-ts4.5/internal/hooks/use-highlight.d.ts +1 -1
- package/dist/types-ts4.5/internal/utils/get-normalized-language.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/async.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/lib/highlight.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/lib/process/create-line-element.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/lib/process/create-line.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/lib/process/flatten-code-tree.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/lib/process/get-code-tree.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/lib/process/get-inline-line-number.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/lib/process/index.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/lib/react-renderer/create-children.d.ts +2 -2
- package/dist/types-ts4.5/syntax-highlighter/lib/react-renderer/create-element.d.ts +2 -2
- package/dist/types-ts4.5/syntax-highlighter/lib/react-renderer/index.d.ts +1 -1
- package/dist/types-ts4.5/syntax-highlighter/types.d.ts +2 -2
- package/dist/types-ts4.5/types.d.ts +1 -1
- package/package.json +108 -110
- package/report.api.md +807 -807
|
@@ -1,266 +1,226 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
j: JSCodeshift,
|
|
19
|
+
collection: Collection<any>,
|
|
20
|
+
importPath: string,
|
|
23
21
|
) {
|
|
24
|
-
|
|
22
|
+
return getImportDeclarationCollection(j, collection, importPath).length > 0;
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
export function getImportDeclarationCollection(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
j: JSCodeshift,
|
|
27
|
+
collection: Collection<any>,
|
|
28
|
+
importPath: string,
|
|
31
29
|
) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
j: JSCodeshift,
|
|
41
|
+
collection: Collection<any>,
|
|
42
|
+
importPath: string,
|
|
52
43
|
) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
callExpressionPath.node;
|
|
44
|
+
return collection.find(j.CallExpression).filter((callExpressionPath) => {
|
|
45
|
+
const { callee, arguments: callExpressionArguments } = callExpressionPath.node;
|
|
56
46
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
-
|
|
55
|
+
return callee && callee.type === 'Import';
|
|
70
56
|
}
|
|
71
57
|
function isCallExpressionArgumentStringLiteralType(
|
|
72
|
-
|
|
58
|
+
callExpressionArguments: CallExpression['arguments'],
|
|
73
59
|
) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
60
|
+
return (
|
|
61
|
+
callExpressionArguments &&
|
|
62
|
+
callExpressionArguments.length &&
|
|
63
|
+
callExpressionArguments[0].type === 'StringLiteral'
|
|
64
|
+
);
|
|
79
65
|
}
|
|
80
66
|
function isCallExpressionArgumentValueMatches(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
67
|
+
callExpressionArgument: CallExpression['arguments'][0],
|
|
68
|
+
j: JSCodeshift,
|
|
69
|
+
value: string,
|
|
84
70
|
) {
|
|
85
|
-
|
|
71
|
+
return j(callExpressionArgument).some((path) => path.node.value === value);
|
|
86
72
|
}
|
|
87
73
|
|
|
88
74
|
export function getImportSpecifierCollection(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
75
|
+
j: JSCodeshift,
|
|
76
|
+
importDeclarationCollection: Collection<ImportDeclaration>,
|
|
77
|
+
importName: string,
|
|
92
78
|
) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
84
|
+
export function getImportSpecifierName(importSpecifierCollection: Collection<ImportSpecifier>) {
|
|
85
|
+
if (importSpecifierCollection.length === 0) {
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
107
88
|
|
|
108
|
-
|
|
89
|
+
return importSpecifierCollection.nodes()[0]!.local!.name;
|
|
109
90
|
}
|
|
110
91
|
|
|
111
92
|
export function isVariableDeclaratorIdentifierPresent(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
93
|
+
j: JSCodeshift,
|
|
94
|
+
collection: Collection<any>,
|
|
95
|
+
variableName: string,
|
|
115
96
|
) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
97
|
+
return collection
|
|
98
|
+
.find(j.VariableDeclaration)
|
|
99
|
+
.find(j.VariableDeclarator)
|
|
100
|
+
.some((variableDeclaratorPath) => {
|
|
101
|
+
const { id } = variableDeclaratorPath.node;
|
|
121
102
|
|
|
122
|
-
|
|
123
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
108
|
+
j: JSCodeshift,
|
|
109
|
+
collection: Collection<any>,
|
|
110
|
+
variableName: string,
|
|
134
111
|
) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
.some((functionDeclarationPath) => {
|
|
138
|
-
const { id } = functionDeclarationPath.node;
|
|
112
|
+
return collection.find(j.FunctionDeclaration).some((functionDeclarationPath) => {
|
|
113
|
+
const { id } = functionDeclarationPath.node;
|
|
139
114
|
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
120
|
+
j: JSCodeshift,
|
|
121
|
+
collection: Collection<any>,
|
|
122
|
+
variableName: string,
|
|
152
123
|
) {
|
|
153
|
-
|
|
154
|
-
|
|
124
|
+
return collection.find(j.ClassDeclaration).some((classDeclarationPath) => {
|
|
125
|
+
const { id } = classDeclarationPath.node;
|
|
155
126
|
|
|
156
|
-
|
|
157
|
-
|
|
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
|
-
|
|
166
|
-
|
|
167
|
-
|
|
132
|
+
j: JSCodeshift,
|
|
133
|
+
collection: Collection<any>,
|
|
134
|
+
variableName: string,
|
|
168
135
|
) {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
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
|
-
|
|
177
|
-
|
|
178
|
-
|
|
143
|
+
j: JSCodeshift,
|
|
144
|
+
jsxElementPath: ASTPath<JSXElement>,
|
|
145
|
+
attributeName: string,
|
|
179
146
|
): Collection<JSXAttribute> {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
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
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
158
|
+
j: JSCodeshift,
|
|
159
|
+
collection: Collection<any>,
|
|
160
|
+
jsxElementPath: ASTPath<JSXElement>,
|
|
161
|
+
attributeName: string,
|
|
197
162
|
): Collection<ObjectProperty> | null {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
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
|
-
|
|
234
|
-
|
|
235
|
-
|
|
193
|
+
j: JSCodeshift,
|
|
194
|
+
jsxElementPath: ASTPath<JSXElement>,
|
|
195
|
+
attributeName: string,
|
|
236
196
|
) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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
|
+
};
|
|
@@ -9,8 +9,13 @@ var _react = require("react");
|
|
|
9
9
|
var _react2 = require("@emotion/react");
|
|
10
10
|
var _colors = require("@atlaskit/theme/colors");
|
|
11
11
|
var _visuallyHidden = _interopRequireDefault(require("@atlaskit/visually-hidden"));
|
|
12
|
+
/**
|
|
13
|
+
* @jsxRuntime classic
|
|
14
|
+
*/
|
|
12
15
|
/** @jsx jsx */
|
|
13
16
|
|
|
17
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
18
|
+
|
|
14
19
|
var decoration = (0, _react2.css)({
|
|
15
20
|
// Required as otherwise the following bidi characters cause the span
|
|
16
21
|
// to not receive hover events.
|
|
@@ -18,6 +23,7 @@ var decoration = (0, _react2.css)({
|
|
|
18
23
|
// U+2066 LEFT-TO-RIGHT ISOLATE (when using pseudo element before)
|
|
19
24
|
// U+202E RIGHT-TO-LEFT OVERRIDE' (when using pseudo element after)
|
|
20
25
|
position: 'relative',
|
|
26
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
21
27
|
':before': {
|
|
22
28
|
display: 'inline-flex',
|
|
23
29
|
padding: "var(--ds-space-0, 0px)".concat(" ", "var(--ds-space-050, 4px)"),
|
|
@@ -36,6 +42,7 @@ var decoration = (0, _react2.css)({
|
|
|
36
42
|
*/
|
|
37
43
|
pointerEvents: 'auto'
|
|
38
44
|
},
|
|
45
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
39
46
|
':hover:before': {
|
|
40
47
|
background: "var(--ds-background-warning-hovered, ".concat(_colors.Y75, ")"),
|
|
41
48
|
color: "var(--ds-text-warning, #533F04)"
|
package/dist/cjs/code-block.js
CHANGED
|
@@ -11,8 +11,13 @@ var _useHighlight = require("./internal/hooks/use-highlight");
|
|
|
11
11
|
var _styles = require("./internal/theme/styles");
|
|
12
12
|
var _getNormalizedLanguage = require("./internal/utils/get-normalized-language");
|
|
13
13
|
var _syntaxHighlighter = _interopRequireDefault(require("./syntax-highlighter"));
|
|
14
|
+
/**
|
|
15
|
+
* @jsxRuntime classic
|
|
16
|
+
*/
|
|
14
17
|
/** @jsx jsx */
|
|
15
18
|
|
|
19
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
20
|
+
|
|
16
21
|
/**
|
|
17
22
|
* __Code block__
|
|
18
23
|
*
|
|
@@ -50,7 +55,9 @@ var CodeBlock = /*#__PURE__*/(0, _react.memo)(function CodeBlock(_ref) {
|
|
|
50
55
|
return (0, _styles.getCodeBlockStyles)(theme);
|
|
51
56
|
}, [theme]);
|
|
52
57
|
var styles = (0, _react.useMemo)(function () {
|
|
53
|
-
return (0, _react2.css)(
|
|
58
|
+
return (0, _react2.css)(
|
|
59
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
60
|
+
getStyles(highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines));
|
|
54
61
|
}, [highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines, getStyles]);
|
|
55
62
|
var _useHighlightLines = (0, _useHighlight.useHighlightLines)({
|
|
56
63
|
highlight: highlight,
|
package/dist/cjs/code.js
CHANGED
|
@@ -21,7 +21,11 @@ var _bidiWarningDecorator = _interopRequireDefault(require("./bidi-warning/bidi-
|
|
|
21
21
|
var _styles = require("./internal/theme/styles");
|
|
22
22
|
var _excluded = ["testId"],
|
|
23
23
|
_excluded2 = ["children", "codeBidiWarnings", "codeBidiWarningLabel", "codeBidiWarningTooltipEnabled"];
|
|
24
|
+
/**
|
|
25
|
+
* @jsxRuntime classic
|
|
26
|
+
*/
|
|
24
27
|
/** @jsx jsx */
|
|
28
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
25
29
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
26
30
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
27
31
|
/**
|
|
@@ -36,6 +40,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
36
40
|
var Code = /*#__PURE__*/(0, _react.memo)( /*#__PURE__*/(0, _react.forwardRef)(function Code(_ref, ref) {
|
|
37
41
|
var testId = _ref.testId,
|
|
38
42
|
props = (0, _objectWithoutProperties2.default)(_ref, _excluded);
|
|
43
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
39
44
|
var styles = (0, _react2.css)((0, _styles.getCodeStyles)());
|
|
40
45
|
var children = props.children,
|
|
41
46
|
_props$codeBidiWarnin = props.codeBidiWarnings,
|
|
@@ -9,7 +9,7 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
9
9
|
var _constants = require("./constants");
|
|
10
10
|
var _getTheme = require("./get-theme");
|
|
11
11
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
12
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
13
13
|
var getLineNumWidth = exports.getLineNumWidth = function getLineNumWidth(numLines) {
|
|
14
14
|
if (!numLines) {
|
|
15
15
|
return '1ch';
|
|
@@ -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,
|
|
@@ -13,6 +13,7 @@ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/ge
|
|
|
13
13
|
var _react = _interopRequireDefault(require("react"));
|
|
14
14
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
15
15
|
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
16
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
16
17
|
// This wrapper supports the async loading of refractor and language grammars. The internal Highlight is a memo() functional component as expected
|
|
17
18
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
18
19
|
var SyntaxHighlighter = exports.SyntaxHighlighter = /*#__PURE__*/function (_React$PureComponent) {
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
*/
|
|
1
4
|
/** @jsx jsx */
|
|
2
5
|
import { Fragment } from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
8
|
import { css, jsx } from '@emotion/react';
|
|
4
9
|
import { Y75 } from '@atlaskit/theme/colors';
|
|
5
10
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
@@ -10,6 +15,7 @@ const decoration = css({
|
|
|
10
15
|
// U+2066 LEFT-TO-RIGHT ISOLATE (when using pseudo element before)
|
|
11
16
|
// U+202E RIGHT-TO-LEFT OVERRIDE' (when using pseudo element after)
|
|
12
17
|
position: 'relative',
|
|
18
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
13
19
|
':before': {
|
|
14
20
|
display: 'inline-flex',
|
|
15
21
|
padding: `${"var(--ds-space-0, 0px)"} ${"var(--ds-space-050, 4px)"}`,
|
|
@@ -28,6 +34,7 @@ const decoration = css({
|
|
|
28
34
|
*/
|
|
29
35
|
pointerEvents: 'auto'
|
|
30
36
|
},
|
|
37
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
31
38
|
':hover:before': {
|
|
32
39
|
background: `var(--ds-background-warning-hovered, ${Y75})`,
|
|
33
40
|
color: "var(--ds-text-warning, #533F04)"
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
*/
|
|
1
4
|
/** @jsx jsx */
|
|
2
5
|
import { memo, useCallback, useMemo } from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
8
|
import { css, jsx } from '@emotion/react';
|
|
4
9
|
import { useHighlightLines } from './internal/hooks/use-highlight';
|
|
5
10
|
import { getCodeBlockStyles, getCodeBlockTheme } from './internal/theme/styles';
|
|
@@ -31,7 +36,9 @@ const CodeBlock = /*#__PURE__*/memo(function CodeBlock({
|
|
|
31
36
|
const numLines = (text || '').split('\n').length;
|
|
32
37
|
const theme = useMemo(() => getCodeBlockTheme(numLines), [numLines]);
|
|
33
38
|
const getStyles = useMemo(() => getCodeBlockStyles(theme), [theme]);
|
|
34
|
-
const styles = useMemo(() => css(
|
|
39
|
+
const styles = useMemo(() => css(
|
|
40
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
41
|
+
getStyles(highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines)), [highlightedStartText, highlightedEndText, showLineNumbers, shouldWrapLongLines, getStyles]);
|
|
35
42
|
const {
|
|
36
43
|
getHighlightStyles,
|
|
37
44
|
highlightedLines
|
package/dist/es2019/code.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
/**
|
|
3
|
+
* @jsxRuntime classic
|
|
4
|
+
*/
|
|
2
5
|
/** @jsx jsx */
|
|
3
6
|
import React, { forwardRef, memo } from 'react';
|
|
7
|
+
|
|
8
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
4
9
|
import { css, jsx } from '@emotion/react';
|
|
5
10
|
import CodeBidiWarning from './bidi-warning';
|
|
6
11
|
import codeBidiWarningDecorator from './bidi-warning/bidi-warning-decorator';
|
|
@@ -18,6 +23,7 @@ const Code = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Code({
|
|
|
18
23
|
testId,
|
|
19
24
|
...props
|
|
20
25
|
}, ref) {
|
|
26
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
21
27
|
const styles = css(getCodeStyles());
|
|
22
28
|
const {
|
|
23
29
|
children,
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
2
|
+
|
|
1
3
|
import { CODE_FONT_SIZE, CODE_LINE_HEIGHT, HIGHLIGHT_BORDER_WIDTH, LINE_NUMBER_GUTTER, SPACING, VAR_CODE_BG_COLOR, VAR_CODE_LINE_NUMBER_BG_COLOR } from './constants';
|
|
2
4
|
import { getBaseTheme, getColorPalette } from './get-theme';
|
|
3
5
|
export const getLineNumWidth = numLines => {
|
|
@@ -201,7 +203,8 @@ export const getCodeBlockStyles = theme => (highlightedStartText, highlightedEnd
|
|
|
201
203
|
// this is required to account for prismjs styles leaking into the codeblock
|
|
202
204
|
'code[class*="language-"], pre[class*="language-"], code': {
|
|
203
205
|
all: 'unset',
|
|
204
|
-
padding: showLineNumbers ? `${SPACING}px 0` : SPACING
|
|
206
|
+
padding: showLineNumbers ? `${SPACING}px 0` : SPACING,
|
|
207
|
+
tabSize: 4
|
|
205
208
|
},
|
|
206
209
|
display: 'flex',
|
|
207
210
|
lineHeight: CODE_LINE_HEIGHT,
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
|
|
3
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
4
|
+
|
|
2
5
|
// This wrapper supports the async loading of refractor and language grammars. The internal Highlight is a memo() functional component as expected
|
|
3
6
|
// eslint-disable-next-line @repo/internal/react/no-class-components
|
|
4
7
|
export class SyntaxHighlighter extends React.PureComponent {}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @jsxRuntime classic
|
|
3
|
+
*/
|
|
1
4
|
/** @jsx jsx */
|
|
2
5
|
import { Fragment } from 'react';
|
|
6
|
+
|
|
7
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
3
8
|
import { css, jsx } from '@emotion/react';
|
|
4
9
|
import { Y75 } from '@atlaskit/theme/colors';
|
|
5
10
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
@@ -10,6 +15,7 @@ var decoration = css({
|
|
|
10
15
|
// U+2066 LEFT-TO-RIGHT ISOLATE (when using pseudo element before)
|
|
11
16
|
// U+202E RIGHT-TO-LEFT OVERRIDE' (when using pseudo element after)
|
|
12
17
|
position: 'relative',
|
|
18
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
13
19
|
':before': {
|
|
14
20
|
display: 'inline-flex',
|
|
15
21
|
padding: "var(--ds-space-0, 0px)".concat(" ", "var(--ds-space-050, 4px)"),
|
|
@@ -28,6 +34,7 @@ var decoration = css({
|
|
|
28
34
|
*/
|
|
29
35
|
pointerEvents: 'auto'
|
|
30
36
|
},
|
|
37
|
+
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
|
|
31
38
|
':hover:before': {
|
|
32
39
|
background: "var(--ds-background-warning-hovered, ".concat(Y75, ")"),
|
|
33
40
|
color: "var(--ds-text-warning, #533F04)"
|