@atlaskit/code 14.4.6 → 14.4.8

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 (47) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/__perf__/source-code-examples/100-line-example.tsx +5 -5
  3. package/dist/cjs/bidi-warning/bidi-warning-decorator.js +6 -19
  4. package/dist/cjs/bidi-warning/index.js +0 -2
  5. package/dist/cjs/bidi-warning/ui/index.js +6 -17
  6. package/dist/cjs/bidi-warning/ui/styled.js +6 -11
  7. package/dist/cjs/code-block.js +25 -34
  8. package/dist/cjs/code.js +11 -33
  9. package/dist/cjs/constants.js +0 -2
  10. package/dist/cjs/entry-points/block.js +0 -2
  11. package/dist/cjs/entry-points/constants.js +0 -1
  12. package/dist/cjs/entry-points/inline.js +0 -4
  13. package/dist/cjs/extract-react-types/code-block.js +0 -1
  14. package/dist/cjs/extract-react-types/code.js +0 -1
  15. package/dist/cjs/index.js +0 -7
  16. package/dist/cjs/internal/hooks/use-highlight.js +10 -24
  17. package/dist/cjs/internal/theme/constants.js +2 -3
  18. package/dist/cjs/internal/theme/get-theme.js +0 -16
  19. package/dist/cjs/internal/theme/styles.js +4 -23
  20. package/dist/cjs/internal/utils/get-normalized-language.js +2 -8
  21. package/dist/cjs/react-syntax-highlighter-bidi-warning-renderer.js +17 -41
  22. package/dist/cjs/version.json +1 -1
  23. package/dist/es2019/bidi-warning/bidi-warning-decorator.js +5 -9
  24. package/dist/es2019/bidi-warning/ui/index.js +0 -1
  25. package/dist/es2019/bidi-warning/ui/styled.js +4 -5
  26. package/dist/es2019/code-block.js +5 -3
  27. package/dist/es2019/code.js +0 -7
  28. package/dist/es2019/internal/hooks/use-highlight.js +4 -8
  29. package/dist/es2019/internal/theme/constants.js +2 -1
  30. package/dist/es2019/internal/theme/get-theme.js +2 -3
  31. package/dist/es2019/internal/theme/styles.js +8 -9
  32. package/dist/es2019/internal/utils/get-normalized-language.js +2 -3
  33. package/dist/es2019/react-syntax-highlighter-bidi-warning-renderer.js +14 -21
  34. package/dist/es2019/version.json +1 -1
  35. package/dist/esm/bidi-warning/bidi-warning-decorator.js +6 -16
  36. package/dist/esm/bidi-warning/ui/index.js +6 -9
  37. package/dist/esm/bidi-warning/ui/styled.js +6 -7
  38. package/dist/esm/code-block.js +26 -26
  39. package/dist/esm/code.js +11 -21
  40. package/dist/esm/internal/hooks/use-highlight.js +10 -19
  41. package/dist/esm/internal/theme/constants.js +2 -1
  42. package/dist/esm/internal/theme/get-theme.js +0 -5
  43. package/dist/esm/internal/theme/styles.js +4 -10
  44. package/dist/esm/internal/utils/get-normalized-language.js +2 -3
  45. package/dist/esm/react-syntax-highlighter-bidi-warning-renderer.js +20 -33
  46. package/dist/esm/version.json +1 -1
  47. package/package.json +2 -2
@@ -1,57 +1,46 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.useHighlightLines = void 0;
9
-
10
8
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
-
12
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
-
14
10
  var _react = require("react");
15
-
16
11
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
17
-
18
12
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
19
-
20
13
  var DEFAULT_LINE_EL_ATTR_OBJ = {
21
14
  'data-ds--code--row': ''
22
15
  };
23
-
24
16
  var getLineStyleObject = function getLineStyleObject(lineNumber, testId) {
25
17
  return testId ? _objectSpread({
26
18
  'data-testid': "".concat(testId, "-line-").concat(lineNumber)
27
19
  }, DEFAULT_LINE_EL_ATTR_OBJ) : DEFAULT_LINE_EL_ATTR_OBJ;
28
20
  };
29
-
30
21
  var useHighlightLines = function useHighlightLines(_ref) {
31
22
  var _ref$highlight = _ref.highlight,
32
- highlight = _ref$highlight === void 0 ? '' : _ref$highlight,
33
- testId = _ref.testId;
23
+ highlight = _ref$highlight === void 0 ? '' : _ref$highlight,
24
+ testId = _ref.testId;
34
25
  var highlightedLines = (0, _react.useMemo)(function () {
35
26
  if (!highlight) {
36
27
  return [];
37
28
  }
38
-
39
29
  return highlight.split(',').map(function (num) {
40
30
  if (num.indexOf('-') > 0) {
41
31
  // We found a line group, e.g. 1-3
42
- var _num$split$map$sort = num.split('-').map(Number) // Sort by lowest value first, highest value last.
43
- .sort(function (a, b) {
44
- return a - b;
45
- }),
46
- _num$split$map$sort2 = (0, _slicedToArray2.default)(_num$split$map$sort, 2),
47
- from = _num$split$map$sort2[0],
48
- to = _num$split$map$sort2[1];
49
-
32
+ var _num$split$map$sort = num.split('-').map(Number)
33
+ // Sort by lowest value first, highest value last.
34
+ .sort(function (a, b) {
35
+ return a - b;
36
+ }),
37
+ _num$split$map$sort2 = (0, _slicedToArray2.default)(_num$split$map$sort, 2),
38
+ from = _num$split$map$sort2[0],
39
+ to = _num$split$map$sort2[1];
50
40
  return Array(to + 1).fill(undefined).map(function (_, index) {
51
41
  return index;
52
42
  }).slice(from, to + 1);
53
43
  }
54
-
55
44
  return Number(num);
56
45
  }).reduce(function (acc, val) {
57
46
  return acc.concat(val);
@@ -61,14 +50,12 @@ var useHighlightLines = function useHighlightLines(_ref) {
61
50
  if (!highlight || highlightedLines.length === 0) {
62
51
  return getLineStyleObject(lineNumber, testId);
63
52
  }
64
-
65
53
  if (highlightedLines.includes(lineNumber)) {
66
54
  var highlightedDataAttrObj = {
67
55
  'data-ds--code--row--highlight': ''
68
56
  };
69
57
  return _objectSpread(_objectSpread({}, highlightedDataAttrObj), getLineStyleObject(lineNumber, testId));
70
58
  }
71
-
72
59
  return getLineStyleObject(lineNumber, testId);
73
60
  }, [highlight, testId]);
74
61
  return {
@@ -76,5 +63,4 @@ var useHighlightLines = function useHighlightLines(_ref) {
76
63
  highlightedLines: highlightedLines
77
64
  };
78
65
  };
79
-
80
66
  exports.useHighlightLines = useHighlightLines;
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.VAR_CODE_LINE_NUMBER_BG_COLOR = exports.VAR_CODE_BG_COLOR = exports.SPACING = exports.LINE_NUMBER_GUTTER = exports.HIGHLIGHT_BORDER_WIDTH = exports.CODE_LINE_HEIGHT = exports.CODE_FONT_SIZE = exports.CODE_BLOCK_SELECTOR = void 0;
7
-
8
7
  var _constants = require("@atlaskit/theme/constants");
9
-
10
8
  var CODE_FONT_SIZE = 12;
11
9
  exports.CODE_FONT_SIZE = CODE_FONT_SIZE;
12
10
  var CODE_LINE_HEIGHT = '20px';
@@ -19,8 +17,9 @@ var LINE_NUMBER_GUTTER = SPACING * 2;
19
17
  exports.LINE_NUMBER_GUTTER = LINE_NUMBER_GUTTER;
20
18
  var VAR_CODE_LINE_NUMBER_BG_COLOR = '--ds--code--line-number-bg-color';
21
19
  exports.VAR_CODE_LINE_NUMBER_BG_COLOR = VAR_CODE_LINE_NUMBER_BG_COLOR;
22
- var VAR_CODE_BG_COLOR = '--ds--code--bg-color'; // selector for codeblock
20
+ var VAR_CODE_BG_COLOR = '--ds--code--bg-color';
23
21
 
22
+ // selector for codeblock
24
23
  exports.VAR_CODE_BG_COLOR = VAR_CODE_BG_COLOR;
25
24
  var CODE_BLOCK_SELECTOR = "data-ds--code--code-block";
26
25
  exports.CODE_BLOCK_SELECTOR = CODE_BLOCK_SELECTOR;
@@ -1,38 +1,25 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  var _typeof = require("@babel/runtime/helpers/typeof");
6
-
7
5
  Object.defineProperty(exports, "__esModule", {
8
6
  value: true
9
7
  });
10
8
  exports.getColorPalette = exports.getBaseTheme = exports.defaultBaseTheme = exports.default = void 0;
11
-
12
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
-
14
10
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
15
-
16
11
  var colors = _interopRequireWildcard(require("@atlaskit/theme/colors"));
17
-
18
12
  var _components = require("@atlaskit/theme/components");
19
-
20
13
  var _constants = require("@atlaskit/theme/constants");
21
-
22
14
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
-
24
15
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
25
-
26
16
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
-
28
17
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
-
30
18
  // Hardcoded values have been used due to the current color palette not having any
31
19
  // accessible color options for Teal and Yellow and +20A
32
20
  var T800 = '#067384';
33
21
  var Y1100 = '#7A5D1A';
34
22
  var PLUS20 = '#3A434E';
35
-
36
23
  var getBaseTheme = function getBaseTheme(theme) {
37
24
  return {
38
25
  fontFamily: (0, _constants.codeFontFamily)(),
@@ -63,7 +50,6 @@ var getBaseTheme = function getBaseTheme(theme) {
63
50
  })
64
51
  };
65
52
  };
66
-
67
53
  exports.getBaseTheme = getBaseTheme;
68
54
  var defaultBaseTheme = getBaseTheme({
69
55
  mode: 'light'
@@ -253,10 +239,8 @@ var getColorPalette = (0, _memoizeOne.default)(function (theme) {
253
239
  };
254
240
  });
255
241
  exports.getColorPalette = getColorPalette;
256
-
257
242
  var getTheme = function getTheme(theme) {
258
243
  return _objectSpread(_objectSpread({}, getBaseTheme(theme)), getColorPalette(theme));
259
244
  };
260
-
261
245
  var _default = getTheme;
262
246
  exports.default = _default;
@@ -1,34 +1,23 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.getLineNumWidth = exports.getCodeStyles = exports.getCodeBlockTheme = exports.getCodeBlockStyles = exports.getBaseCodeStyles = void 0;
9
-
10
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
11
-
12
9
  var _constants = require("@atlaskit/theme/constants");
13
-
14
10
  var _constants2 = require("./constants");
15
-
16
11
  var _getTheme = require("./get-theme");
17
-
18
12
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
19
-
20
13
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
21
-
22
14
  var getLineNumWidth = function getLineNumWidth(numLines) {
23
15
  if (!numLines) {
24
16
  return '1ch';
25
17
  }
26
-
27
18
  return "".concat(numLines.toFixed(0).length, "ch");
28
19
  };
29
-
30
20
  exports.getLineNumWidth = getLineNumWidth;
31
-
32
21
  var lineNumberStyle = function lineNumberStyle(theme) {
33
22
  return {
34
23
  // width of the line number gutter
@@ -48,9 +37,9 @@ var lineNumberStyle = function lineNumberStyle(theme) {
48
37
  // this is to fix SSR spacing issue
49
38
  display: 'block'
50
39
  };
51
- }; // order of these keys does matter as it will affect the css precedence
52
-
40
+ };
53
41
 
42
+ // order of these keys does matter as it will affect the css precedence
54
43
  var syntaxKeywordColors = function syntaxKeywordColors(theme) {
55
44
  return {
56
45
  '.token': {
@@ -198,11 +187,10 @@ var syntaxKeywordColors = function syntaxKeywordColors(theme) {
198
187
  }
199
188
  };
200
189
  };
190
+
201
191
  /**
202
192
  * Styles applied at the root element level, common across code/codeblock
203
193
  */
204
-
205
-
206
194
  var getBaseCodeStyles = function getBaseCodeStyles(theme) {
207
195
  return {
208
196
  fontSize: _constants2.CODE_FONT_SIZE,
@@ -214,16 +202,14 @@ var getBaseCodeStyles = function getBaseCodeStyles(theme) {
214
202
  borderRadius: "".concat((0, _constants.borderRadius)(), "px")
215
203
  };
216
204
  };
205
+
217
206
  /**
218
207
  * Takes an implemented CodeBlock theme, and returns styles required for
219
208
  * react-syntax-highlighter.
220
209
  *
221
210
  * @param theme
222
211
  */
223
-
224
-
225
212
  exports.getBaseCodeStyles = getBaseCodeStyles;
226
-
227
213
  var getCodeBlockStyles = function getCodeBlockStyles(theme) {
228
214
  return function (highlightedStartText, highlightedEndText, hasLineNumbers) {
229
215
  return _objectSpread(_objectSpread(_objectSpread({
@@ -307,9 +293,7 @@ var getCodeBlockStyles = function getCodeBlockStyles(theme) {
307
293
  });
308
294
  };
309
295
  };
310
-
311
296
  exports.getCodeBlockStyles = getCodeBlockStyles;
312
-
313
297
  var getCodeStyles = function getCodeStyles(globalTheme) {
314
298
  // Required to have proper compatibility with styled components interpolations
315
299
  var akTheme = 'theme' in globalTheme ? globalTheme.theme : globalTheme;
@@ -325,13 +309,10 @@ var getCodeStyles = function getCodeStyles(globalTheme) {
325
309
  whiteSpace: 'pre-wrap'
326
310
  });
327
311
  };
328
-
329
312
  exports.getCodeStyles = getCodeStyles;
330
-
331
313
  var getCodeBlockTheme = function getCodeBlockTheme(globalTheme, maxLines) {
332
314
  return _objectSpread(_objectSpread(_objectSpread({}, (0, _getTheme.getBaseTheme)(globalTheme)), (0, _getTheme.getColorPalette)(globalTheme)), {}, {
333
315
  lineNumberWidth: maxLines ? getLineNumWidth(maxLines) : undefined
334
316
  });
335
317
  };
336
-
337
318
  exports.getCodeBlockTheme = getCodeBlockTheme;
@@ -1,26 +1,20 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.normalizeLanguage = void 0;
9
-
10
8
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
11
-
12
9
  var _constants = require("../../constants");
13
-
14
10
  var normalizeLanguage = (0, _memoizeOne.default)(function (language) {
15
11
  if (!language) {
16
12
  return '';
17
13
  }
18
-
19
14
  var match = _constants.SUPPORTED_LANGUAGES.find(function (val) {
20
15
  return val.name === language || val.alias.includes(language);
21
- }); // Fallback to plain monospaced text if language passed but not supported
22
-
23
-
16
+ });
17
+ // Fallback to plain monospaced text if language passed but not supported
24
18
  return match ? match.value : 'text';
25
19
  });
26
20
  exports.normalizeLanguage = normalizeLanguage;
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
@@ -9,26 +8,18 @@ exports.createBidiWarningRenderer = createBidiWarningRenderer;
9
8
  exports.createChildren = createChildren;
10
9
  exports.createClassNameString = createClassNameString;
11
10
  exports.createStyleObject = createStyleObject;
12
-
13
11
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
14
-
15
12
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
-
17
13
  var _react = _interopRequireDefault(require("react"));
18
-
19
14
  var _bidiWarning = _interopRequireDefault(require("./bidi-warning"));
20
-
21
15
  var _bidiWarningDecorator = _interopRequireDefault(require("./bidi-warning/bidi-warning-decorator"));
22
-
23
16
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
24
-
25
17
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
26
-
27
18
  function createBidiWarningRenderer(codeBidiWarningConfig) {
28
19
  return function bidiWarningRenderer(_ref) {
29
20
  var rows = _ref.rows,
30
- stylesheet = _ref.stylesheet,
31
- useInlineStyles = _ref.useInlineStyles;
21
+ stylesheet = _ref.stylesheet,
22
+ useInlineStyles = _ref.useInlineStyles;
32
23
  return rows.map(function (node, i) {
33
24
  return createElement({
34
25
  node: node,
@@ -39,51 +30,41 @@ function createBidiWarningRenderer(codeBidiWarningConfig) {
39
30
  });
40
31
  });
41
32
  };
42
- } // Get all possible permutations of all power sets
33
+ }
34
+
35
+ // Get all possible permutations of all power sets
43
36
  //
44
37
  // Super simple, non-algorithmic solution since the
45
38
  // number of class names will not be greater than 4
46
-
47
-
48
39
  function powerSetPermutations(arr) {
49
40
  var arrLength = arr.length;
50
-
51
41
  if (arrLength === 0 || arrLength === 1) {
52
42
  return arr;
53
43
  }
54
-
55
44
  if (arrLength === 2) {
56
45
  // prettier-ignore
57
46
  return [arr[0], arr[1], "".concat(arr[0], ".").concat(arr[1]), "".concat(arr[1], ".").concat(arr[0])];
58
47
  }
59
-
60
48
  if (arrLength === 3) {
61
49
  return [arr[0], arr[1], arr[2], "".concat(arr[0], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[0]), "".concat(arr[1], ".").concat(arr[2]), "".concat(arr[2], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[1], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[2], ".").concat(arr[1]), "".concat(arr[1], ".").concat(arr[0], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[2], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[0], ".").concat(arr[1]), "".concat(arr[2], ".").concat(arr[1], ".").concat(arr[0])];
62
50
  }
63
-
64
51
  if (arrLength >= 4) {
65
52
  // Currently does not support more than 4 extra
66
53
  // class names (after `.token` has been removed)
67
54
  return [arr[0], arr[1], arr[2], arr[3], "".concat(arr[0], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[3]), "".concat(arr[1], ".").concat(arr[0]), "".concat(arr[1], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[3]), "".concat(arr[2], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[1]), "".concat(arr[2], ".").concat(arr[3]), "".concat(arr[3], ".").concat(arr[0]), "".concat(arr[3], ".").concat(arr[1]), "".concat(arr[3], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[1], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[1], ".").concat(arr[3]), "".concat(arr[0], ".").concat(arr[2], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[2], ".").concat(arr[3]), "".concat(arr[0], ".").concat(arr[3], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[3], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[0], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[0], ".").concat(arr[3]), "".concat(arr[1], ".").concat(arr[2], ".").concat(arr[0]), "".concat(arr[1], ".").concat(arr[2], ".").concat(arr[3]), "".concat(arr[1], ".").concat(arr[3], ".").concat(arr[0]), "".concat(arr[1], ".").concat(arr[3], ".").concat(arr[2]), "".concat(arr[2], ".").concat(arr[0], ".").concat(arr[1]), "".concat(arr[2], ".").concat(arr[0], ".").concat(arr[3]), "".concat(arr[2], ".").concat(arr[1], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[1], ".").concat(arr[3]), "".concat(arr[2], ".").concat(arr[3], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[3], ".").concat(arr[1]), "".concat(arr[3], ".").concat(arr[0], ".").concat(arr[1]), "".concat(arr[3], ".").concat(arr[0], ".").concat(arr[2]), "".concat(arr[3], ".").concat(arr[1], ".").concat(arr[0]), "".concat(arr[3], ".").concat(arr[1], ".").concat(arr[2]), "".concat(arr[3], ".").concat(arr[2], ".").concat(arr[0]), "".concat(arr[3], ".").concat(arr[2], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[1], ".").concat(arr[2], ".").concat(arr[3]), "".concat(arr[0], ".").concat(arr[1], ".").concat(arr[3], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[2], ".").concat(arr[1], ".").concat(arr[3]), "".concat(arr[0], ".").concat(arr[2], ".").concat(arr[3], ".").concat(arr[1]), "".concat(arr[0], ".").concat(arr[3], ".").concat(arr[1], ".").concat(arr[2]), "".concat(arr[0], ".").concat(arr[3], ".").concat(arr[2], ".").concat(arr[1]), "".concat(arr[1], ".").concat(arr[0], ".").concat(arr[2], ".").concat(arr[3]), "".concat(arr[1], ".").concat(arr[0], ".").concat(arr[3], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[2], ".").concat(arr[0], ".").concat(arr[3]), "".concat(arr[1], ".").concat(arr[2], ".").concat(arr[3], ".").concat(arr[0]), "".concat(arr[1], ".").concat(arr[3], ".").concat(arr[0], ".").concat(arr[2]), "".concat(arr[1], ".").concat(arr[3], ".").concat(arr[2], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[0], ".").concat(arr[1], ".").concat(arr[3]), "".concat(arr[2], ".").concat(arr[0], ".").concat(arr[3], ".").concat(arr[1]), "".concat(arr[2], ".").concat(arr[1], ".").concat(arr[0], ".").concat(arr[3]), "".concat(arr[2], ".").concat(arr[1], ".").concat(arr[3], ".").concat(arr[0]), "".concat(arr[2], ".").concat(arr[3], ".").concat(arr[0], ".").concat(arr[1]), "".concat(arr[2], ".").concat(arr[3], ".").concat(arr[1], ".").concat(arr[0]), "".concat(arr[3], ".").concat(arr[0], ".").concat(arr[1], ".").concat(arr[2]), "".concat(arr[3], ".").concat(arr[0], ".").concat(arr[2], ".").concat(arr[1]), "".concat(arr[3], ".").concat(arr[1], ".").concat(arr[0], ".").concat(arr[2]), "".concat(arr[3], ".").concat(arr[1], ".").concat(arr[2], ".").concat(arr[0]), "".concat(arr[3], ".").concat(arr[2], ".").concat(arr[0], ".").concat(arr[1]), "".concat(arr[3], ".").concat(arr[2], ".").concat(arr[1], ".").concat(arr[0])];
68
55
  }
69
56
  }
70
-
71
57
  var classNameCombinations = {};
72
-
73
58
  function getClassNameCombinations(classNames) {
74
59
  if (classNames.length === 0 || classNames.length === 1) {
75
60
  return classNames;
76
61
  }
77
-
78
62
  var key = classNames.join('.');
79
-
80
63
  if (!classNameCombinations[key]) {
81
64
  classNameCombinations[key] = powerSetPermutations(classNames);
82
65
  }
83
-
84
66
  return classNameCombinations[key];
85
67
  }
86
-
87
68
  function createStyleObject(classNames) {
88
69
  var elementStyle = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
89
70
  var stylesheet = arguments.length > 2 ? arguments[2] : undefined;
@@ -95,11 +76,9 @@ function createStyleObject(classNames) {
95
76
  return _objectSpread(_objectSpread({}, styleObject), stylesheet[className]);
96
77
  }, elementStyle);
97
78
  }
98
-
99
79
  function createClassNameString(classNames) {
100
80
  return classNames.join(' ');
101
81
  }
102
-
103
82
  function createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig) {
104
83
  var childrenCount = 0;
105
84
  return function (children) {
@@ -115,27 +94,25 @@ function createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig) {
115
94
  });
116
95
  };
117
96
  }
118
-
119
97
  function createElement(_ref2) {
120
98
  var node = _ref2.node,
121
- stylesheet = _ref2.stylesheet,
122
- _ref2$style = _ref2.style,
123
- style = _ref2$style === void 0 ? {} : _ref2$style,
124
- useInlineStyles = _ref2.useInlineStyles,
125
- codeBidiWarningConfig = _ref2.codeBidiWarningConfig,
126
- key = _ref2.key;
99
+ stylesheet = _ref2.stylesheet,
100
+ _ref2$style = _ref2.style,
101
+ style = _ref2$style === void 0 ? {} : _ref2$style,
102
+ useInlineStyles = _ref2.useInlineStyles,
103
+ codeBidiWarningConfig = _ref2.codeBidiWarningConfig,
104
+ key = _ref2.key;
127
105
  var properties = node.properties,
128
- type = node.type,
129
- TagName = node.tagName,
130
- value = node.value;
131
-
106
+ type = node.type,
107
+ TagName = node.tagName,
108
+ value = node.value;
132
109
  if (type === 'text') {
133
110
  // occasionally react-syntax-highlighter passes a numeric value when the
134
111
  // type is text
135
112
  var textValue = value + '';
136
113
  var decorated = (0, _bidiWarningDecorator.default)(textValue, function (_ref3) {
137
114
  var bidiCharacter = _ref3.bidiCharacter,
138
- index = _ref3.index;
115
+ index = _ref3.index;
139
116
  return /*#__PURE__*/_react.default.createElement(_bidiWarning.default, {
140
117
  bidiCharacter: bidiCharacter,
141
118
  key: index,
@@ -147,7 +124,6 @@ function createElement(_ref2) {
147
124
  } else if (TagName) {
148
125
  var childrenCreator = createChildren(stylesheet, useInlineStyles, codeBidiWarningConfig);
149
126
  var props;
150
-
151
127
  if (!useInlineStyles) {
152
128
  props = _objectSpread(_objectSpread({}, properties), {}, {
153
129
  className: createClassNameString(properties.className)
@@ -160,8 +136,9 @@ function createElement(_ref2) {
160
136
  }
161
137
  });
162
138
  return classes;
163
- }, []); // For compatibility with older versions of react-syntax-highlighter
139
+ }, []);
164
140
 
141
+ // For compatibility with older versions of react-syntax-highlighter
165
142
  var startingClassName = properties.className && properties.className.includes('token') ? ['token'] : [];
166
143
  var className = properties.className && startingClassName.concat(properties.className.filter(function (className) {
167
144
  return !allStylesheetSelectors.includes(className);
@@ -171,7 +148,6 @@ function createElement(_ref2) {
171
148
  style: createStyleObject(properties.className, Object.assign({}, properties.style, style), stylesheet)
172
149
  });
173
150
  }
174
-
175
151
  var children = childrenCreator(node.children);
176
152
  return /*#__PURE__*/_react.default.createElement(TagName, (0, _extends2.default)({
177
153
  key: key
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/code",
3
- "version": "14.4.6",
3
+ "version": "14.4.8",
4
4
  "sideEffects": false
5
5
  }
@@ -1,15 +1,12 @@
1
1
  export const bidiCharacterRegex = /[\u202A-\u202E\u2066-\u2069]/g;
2
2
  export default function codeBidiWarningDecorator(originalText, decorate) {
3
3
  const matches = [...originalText.matchAll(bidiCharacterRegex)];
4
-
5
4
  if (matches.length === 0) {
6
5
  // No matches encountered, so we return the originalText value
7
6
  return originalText;
8
7
  }
9
-
10
8
  let children = [];
11
9
  let mappedTo = 0;
12
-
13
10
  for (const match of matches) {
14
11
  if (mappedTo !== match.index) {
15
12
  // There were unmatched characters prior to this match which haven't been
@@ -17,26 +14,25 @@ export default function codeBidiWarningDecorator(originalText, decorate) {
17
14
  // Add them as plain text.
18
15
  children.push(originalText.substring(mappedTo, match.index));
19
16
  }
20
-
21
17
  children.push(decorate({
22
18
  bidiCharacter: match[0],
23
19
  index: match.index
24
- })); // While index is guaranteed to be present, it needs to be asserted due
20
+ }));
21
+
22
+ // While index is guaranteed to be present, it needs to be asserted due
25
23
  // to a limitation of typescripts regex handling
26
24
  //
27
25
  // https://github.com/microsoft/TypeScript/issues/36788
28
26
  // Decorate bidi character
29
-
30
27
  mappedTo = match.index + match[0].length;
31
28
  }
32
-
33
29
  if (mappedTo !== originalText.length) {
34
30
  // There is text following the final match, which needs to be mapped
35
31
  // to the children.
36
32
  // Added as plain text.
37
33
  children.push(originalText.substring(mappedTo, originalText.length));
38
- } // return the mapped children with decorated bidi characters
39
-
34
+ }
40
35
 
36
+ // return the mapped children with decorated bidi characters
41
37
  return children;
42
38
  }
@@ -23,7 +23,6 @@ export default function BidiWarning({
23
23
  }, skipChildren ? null : bidiCharacter))
24
24
  );
25
25
  }
26
-
27
26
  return /*#__PURE__*/React.createElement(Decorator, {
28
27
  testId: testId,
29
28
  bidiCharacter: bidiCharacter
@@ -1,4 +1,5 @@
1
1
  /** @jsx jsx */
2
+
2
3
  import { css, jsx } from '@emotion/react';
3
4
  import { Y75 } from '@atlaskit/theme/colors';
4
5
  const decoration = css({
@@ -10,7 +11,7 @@ const decoration = css({
10
11
  position: 'relative',
11
12
  ':before': {
12
13
  display: 'inline-flex',
13
- padding: `${"var(--ds-scale-0, 0px)"} ${"var(--ds-scale-050, 4px)"}`,
14
+ padding: `${"var(--ds-space-0, 0px)"} ${"var(--ds-space-050, 4px)"}`,
14
15
  alignItems: 'center',
15
16
  justifyContent: 'center',
16
17
  flexDirection: 'row',
@@ -20,7 +21,6 @@ const decoration = css({
20
21
  fontSize: "var(--ds-font-size-100, 14px)",
21
22
  fontStyle: 'normal',
22
23
  lineHeight: '18px',
23
-
24
24
  /**
25
25
  * Ensures the decoration receives pointer events when it occurs with
26
26
  * an ancestor that disables them.
@@ -43,7 +43,8 @@ export function Decorator({
43
43
  }, jsx("span", {
44
44
  css: decoration,
45
45
  "data-testid": testId,
46
- "data-bidi-character-code": bidiCharacterCode // This is set to true so that the content is not read out by
46
+ "data-bidi-character-code": bidiCharacterCode
47
+ // This is set to true so that the content is not read out by
47
48
  // screen readers as the content includes angle brackets for
48
49
  // visual decoration purposes.
49
50
  // We use a span with the aria-label set to the bidi character code
@@ -52,10 +53,8 @@ export function Decorator({
52
53
  "aria-hidden": "true"
53
54
  }, children));
54
55
  }
55
-
56
56
  function getBidiCharacterCode(bidiCharacter) {
57
57
  var _bidiCharacter$codePo;
58
-
59
58
  const bidiCharacterCode = (_bidiCharacter$codePo = bidiCharacter.codePointAt(0)) === null || _bidiCharacter$codePo === void 0 ? void 0 : _bidiCharacter$codePo.toString(16);
60
59
  return `U+${bidiCharacterCode}`;
61
60
  }
@@ -7,6 +7,7 @@ import { useHighlightLines } from './internal/hooks/use-highlight';
7
7
  import { getCodeBlockStyles, getCodeBlockTheme } from './internal/theme/styles';
8
8
  import { normalizeLanguage } from './internal/utils/get-normalized-language';
9
9
  import { createBidiWarningRenderer } from './react-syntax-highlighter-bidi-warning-renderer';
10
+
10
11
  /**
11
12
  * __Code block__
12
13
  *
@@ -16,7 +17,6 @@ import { createBidiWarningRenderer } from './react-syntax-highlighter-bidi-warni
16
17
  * - [Code](https://atlassian.design/components/code/code-block/code)
17
18
  * - [Usage](https://atlassian.design/components/code/code-block/usage)
18
19
  */
19
-
20
20
  const CodeBlock = /*#__PURE__*/memo(function CodeBlock({
21
21
  showLineNumbers = true,
22
22
  language: providedLanguage = 'text',
@@ -42,8 +42,9 @@ const CodeBlock = /*#__PURE__*/memo(function CodeBlock({
42
42
  testId
43
43
  });
44
44
  const getLineProps = useCallback(line => getHighlightStyles(line, highlightedLines), [getHighlightStyles, highlightedLines]);
45
- const language = useMemo(() => normalizeLanguage(providedLanguage), [providedLanguage]); // https://product-fabric.atlassian.net/browse/DST-2472
45
+ const language = useMemo(() => normalizeLanguage(providedLanguage), [providedLanguage]);
46
46
 
47
+ // https://product-fabric.atlassian.net/browse/DST-2472
47
48
  const languageToUse = text ? language : 'text';
48
49
  const renderer = codeBidiWarnings ? createBidiWarningRenderer({
49
50
  codeBidiWarningLabel,
@@ -56,7 +57,8 @@ const CodeBlock = /*#__PURE__*/memo(function CodeBlock({
56
57
  css: styles,
57
58
  language: languageToUse,
58
59
  PreTag: "span",
59
- showLineNumbers: showLineNumbers // Wrap lines is needed to set styles on the line when highlighting.
60
+ showLineNumbers: showLineNumbers
61
+ // Wrap lines is needed to set styles on the line when highlighting.
60
62
  ,
61
63
  wrapLines: highlight.length > 0 || !!testId,
62
64
  lineProps: getLineProps,
@@ -1,5 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /** @jsx jsx */
4
3
  import React, { forwardRef, memo, useMemo } from 'react';
5
4
  import { css, jsx } from '@emotion/react';
@@ -7,7 +6,6 @@ import { useGlobalTheme } from '@atlaskit/theme/components';
7
6
  import CodeBidiWarning from './bidi-warning';
8
7
  import codeBidiWarningDecorator from './bidi-warning/bidi-warning-decorator';
9
8
  import { getCodeStyles } from './internal/theme/styles';
10
-
11
9
  /**
12
10
  * __Code__
13
11
  *
@@ -40,7 +38,6 @@ const Code = /*#__PURE__*/memo( /*#__PURE__*/forwardRef(function Code({
40
38
  css: styles
41
39
  }, otherProps), decoratedChildren);
42
40
  }));
43
-
44
41
  function RenderCodeChildrenWithBidiWarnings({
45
42
  children,
46
43
  codeBidiWarningLabel,
@@ -59,7 +56,6 @@ function RenderCodeChildrenWithBidiWarnings({
59
56
  }));
60
57
  return decorated;
61
58
  }
62
-
63
59
  if (isReactElement(childNode) && childNode.props.children) {
64
60
  // eslint-disable-next-line @repo/internal/react/no-clone-element
65
61
  const newChildNode = /*#__PURE__*/React.cloneElement(childNode, {
@@ -70,16 +66,13 @@ function RenderCodeChildrenWithBidiWarnings({
70
66
  });
71
67
  return newChildNode;
72
68
  }
73
-
74
69
  return childNode;
75
70
  });
76
71
  return jsx(React.Fragment, null, replacedChildren);
77
72
  }
78
-
79
73
  function isReactElement(child) {
80
74
  return !!child.type;
81
75
  }
82
-
83
76
  Code.displayName = 'Code';
84
77
  export { getCodeStyles };
85
78
  export default Code;