@canonical/react-components 0.45.0 → 0.46.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.
@@ -15,7 +15,7 @@ export type Props = {
15
15
  /**
16
16
  * The code snippet to display.
17
17
  */
18
- code: string;
18
+ code: ReactNode;
19
19
  /**
20
20
  * Content to show below the code snippet.
21
21
  */
@@ -35,7 +35,16 @@ function CodeSnippetBlock(_ref) {
35
35
  className += "--numbered";
36
36
 
37
37
  // wrap code lines in spans (and preserve the whitespace)
38
- var lines = code.split(/\r?\n/);
38
+ var lines;
39
+ if (Array.isArray(code)) {
40
+ lines = code;
41
+ } else if (typeof code === "string") {
42
+ lines = code.split(/\r?\n/);
43
+ } else {
44
+ // If the code is not able to be split over multiple lines, then display
45
+ // a single line number.
46
+ lines = [code];
47
+ }
39
48
  numberedCode = lines.map(function (line, i) {
40
49
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
41
50
  key: "p-code-snippet__line-".concat(i)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonical/react-components",
3
- "version": "0.45.0",
3
+ "version": "0.46.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "dist/index.js",
6
6
  "author": "Huw Wilkins <huw.wilkins@canonical.com>",
@@ -79,7 +79,7 @@
79
79
  "ts-jest": "27.1.5",
80
80
  "tsc-alias": "1.8.6",
81
81
  "typescript": "4.9.5",
82
- "vanilla-framework": "4.0.0",
82
+ "vanilla-framework": "4.2.0",
83
83
  "wait-on": "5.3.0",
84
84
  "webpack": "5.88.0"
85
85
  },