react-diff-viewer-continued 3.2.6 → 3.3.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,22 @@
1
+ ## [3.3.1](https://github.com/aeolun/react-diff-viewer-continued/compare/v3.3.0...v3.3.1) (2023-10-18)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * correct imports (fixes [#31](https://github.com/aeolun/react-diff-viewer-continued/issues/31)) ([64a05a9](https://github.com/aeolun/react-diff-viewer-continued/commit/64a05a99e4cbde494597d923b73b9740cb1661cb))
7
+
8
+ # [3.3.0](https://github.com/aeolun/react-diff-viewer-continued/compare/v3.2.6...v3.3.0) (2023-10-17)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * update dependencies and correct zero width extraLines (fixes [#29](https://github.com/aeolun/react-diff-viewer-continued/issues/29)) ([c4b317a](https://github.com/aeolun/react-diff-viewer-continued/commit/c4b317af31935740dd9fe8ac526ceb8fd63db6a9))
14
+
15
+
16
+ ### Features
17
+
18
+ * add ability to always show certain lines ([896eb32](https://github.com/aeolun/react-diff-viewer-continued/commit/896eb323389cec2055abc7dede40adcbcbf6b506))
19
+
1
20
  ## [3.2.6](https://github.com/aeolun/react-diff-viewer-continued/compare/v3.2.5...v3.2.6) (2023-03-02)
2
21
 
3
22
 
package/README.md CHANGED
@@ -68,17 +68,18 @@ class Diff extends PureComponent {
68
68
  ## Props
69
69
 
70
70
  | Prop | Type | Default | Description |
71
- | ------------------------- | ------------------------- | ------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
72
- | oldValue | `string | Object` | `''` | Old value as string (or Object if using `diffJson`). |
73
- | newValue | `string | Object` | `''` | New value as string (or Object if using `diffJson`). |
71
+ |---------------------------|---------------------------|--------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
72
+ | oldValue | `string | Object` | `''` | Old value as string (or Object if using `diffJson`). |
73
+ | newValue | `string | Object` | `''` | New value as string (or Object if using `diffJson`). |
74
74
  | splitView | `boolean` | `true` | Switch between `unified` and `split` view. |
75
75
  | disableWordDiff | `boolean` | `false` | Show and hide word diff in a diff line. |
76
76
  | compareMethod | `DiffMethod` | `DiffMethod.CHARS` | JsDiff text diff method used for diffing strings. Check out the [guide](https://github.com/praneshr/react-diff-viewer/tree/v3.0.0#text-block-diff-comparison) to use different methods. |
77
77
  | renderGutter | `(diffData) => ReactNode` | `undefined` | Function that can be used to render an extra gutter with various information next to the line number. |
78
78
  | hideLineNumbers | `boolean` | `false` | Show and hide line numbers. |
79
+ | alwaysShowLines | `string[]` | `[]` | List of lines to always be shown, regardless of diff status. Line number are prefixed with `L` and `R` for the left and right section of the diff viewer, respectively. For example, `L-20` means 20th line in the left pane. `extraLinesSurroundingDiff` applies to these lines as well. |
79
80
  | renderContent | `function` | `undefined` | Render Prop API to render code in the diff viewer. Helpful for [syntax highlighting](#syntax-highlighting) |
80
81
  | onLineNumberClick | `function` | `undefined` | Event handler for line number click. `(lineId: string) => void` |
81
- | highlightLines | `array[string]` | `[]` | List of lines to be highlighted. Works together with `onLineNumberClick`. Line number are prefixed with `L` and `R` for the left and right section of the diff viewer, respectively. For example, `L-20` means 20th line in the left pane. To highlight a range of line numbers, pass the prefixed line number as an array. For example, `[L-2, L-3, L-4, L-5]` will highlight the lines `2-5` in the left pane. |
82
+ | highlightLines | `string[]` | `[]` | List of lines to be highlighted. Works together with `onLineNumberClick`. Line number are prefixed with `L` and `R` for the left and right section of the diff viewer, respectively. For example, `L-20` means 20th line in the left pane. To highlight a range of line numbers, pass the prefixed line number as an array. For example, `[L-2, L-3, L-4, L-5]` will highlight the lines `2-5` in the left pane. |
82
83
  | showDiffOnly | `boolean` | `true` | Shows only the diffed lines and folds the unchanged lines |
83
84
  | extraLinesSurroundingDiff | `number` | `3` | Number of extra unchanged lines surrounding the diff. Works along with `showDiffOnly`. |
84
85
  | codeFoldMessageRenderer | `function` | `Expand {number} of lines ...` | Render Prop API to render code fold message. |
@@ -0,0 +1,13 @@
1
+ import { LineInformation } from "./compute-lines";
2
+ interface Block {
3
+ index: number;
4
+ startLine: number;
5
+ endLine: number;
6
+ lines: number;
7
+ }
8
+ interface HiddenBlocks {
9
+ lineBlocks: Record<number, number>;
10
+ blocks: Block[];
11
+ }
12
+ export declare function computeHiddenBlocks(lineInformation: LineInformation[], diffLines: number[], extraLines: number): HiddenBlocks;
13
+ export {};
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computeHiddenBlocks = void 0;
4
+ function computeHiddenBlocks(lineInformation, diffLines, extraLines) {
5
+ let newBlockIndex = 0;
6
+ let currentBlock;
7
+ let lineBlocks = {};
8
+ let blocks = [];
9
+ lineInformation.forEach((line, lineIndex) => {
10
+ const isDiffLine = diffLines.some(diffLine => diffLine >= lineIndex - extraLines && diffLine <= lineIndex + extraLines);
11
+ if (!isDiffLine && currentBlock == undefined) {
12
+ // block begins
13
+ currentBlock = {
14
+ index: newBlockIndex,
15
+ startLine: lineIndex,
16
+ endLine: lineIndex,
17
+ lines: 1
18
+ };
19
+ blocks.push(currentBlock);
20
+ lineBlocks[lineIndex] = currentBlock.index;
21
+ newBlockIndex++;
22
+ }
23
+ else if (!isDiffLine) {
24
+ // block continues
25
+ currentBlock.endLine = lineIndex;
26
+ currentBlock.lines++;
27
+ lineBlocks[lineIndex] = currentBlock.index;
28
+ }
29
+ else {
30
+ // not a block anymore
31
+ currentBlock = undefined;
32
+ }
33
+ });
34
+ return {
35
+ lineBlocks,
36
+ blocks: blocks
37
+ };
38
+ }
39
+ exports.computeHiddenBlocks = computeHiddenBlocks;
@@ -49,6 +49,7 @@ export interface JsDiffChangeObject {
49
49
  * @param disableWordDiff Flag to enable/disable word diff.
50
50
  * @param lineCompareMethod JsDiff text diff method from https://github.com/kpdecker/jsdiff/tree/v4.0.1#api
51
51
  * @param linesOffset line number to start counting from
52
+ * @param showLines lines that are always shown, regardless of diff
52
53
  */
53
- declare const computeLineInformation: (oldString: string | Object, newString: string | Object, disableWordDiff?: boolean, lineCompareMethod?: string, linesOffset?: number) => ComputedLineInformation;
54
+ declare const computeLineInformation: (oldString: string | Object, newString: string | Object, disableWordDiff?: boolean, lineCompareMethod?: string, linesOffset?: number, showLines?: string[]) => ComputedLineInformation;
54
55
  export { computeLineInformation };
@@ -1,7 +1,30 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  Object.defineProperty(exports, "__esModule", { value: true });
3
26
  exports.computeLineInformation = exports.DiffMethod = exports.DiffType = void 0;
4
- const diff = require("diff");
27
+ const diff = __importStar(require("diff"));
5
28
  const jsDiff = diff;
6
29
  var DiffType;
7
30
  (function (DiffType) {
@@ -9,7 +32,7 @@ var DiffType;
9
32
  DiffType[DiffType["ADDED"] = 1] = "ADDED";
10
33
  DiffType[DiffType["REMOVED"] = 2] = "REMOVED";
11
34
  DiffType[DiffType["CHANGED"] = 3] = "CHANGED";
12
- })(DiffType = exports.DiffType || (exports.DiffType = {}));
35
+ })(DiffType || (exports.DiffType = DiffType = {}));
13
36
  // See https://github.com/kpdecker/jsdiff/tree/v4.0.1#api for more info on the below JsDiff methods
14
37
  var DiffMethod;
15
38
  (function (DiffMethod) {
@@ -21,7 +44,7 @@ var DiffMethod;
21
44
  DiffMethod["SENTENCES"] = "diffSentences";
22
45
  DiffMethod["CSS"] = "diffCss";
23
46
  DiffMethod["JSON"] = "diffJson";
24
- })(DiffMethod = exports.DiffMethod || (exports.DiffMethod = {}));
47
+ })(DiffMethod || (exports.DiffMethod = DiffMethod = {}));
25
48
  /**
26
49
  * Splits diff text by new line and computes final list of diff lines based on
27
50
  * conditions.
@@ -83,8 +106,9 @@ const computeDiff = (oldValue, newValue, compareMethod = DiffMethod.CHARS) => {
83
106
  * @param disableWordDiff Flag to enable/disable word diff.
84
107
  * @param lineCompareMethod JsDiff text diff method from https://github.com/kpdecker/jsdiff/tree/v4.0.1#api
85
108
  * @param linesOffset line number to start counting from
109
+ * @param showLines lines that are always shown, regardless of diff
86
110
  */
87
- const computeLineInformation = (oldString, newString, disableWordDiff = false, lineCompareMethod = DiffMethod.CHARS, linesOffset = 0) => {
111
+ const computeLineInformation = (oldString, newString, disableWordDiff = false, lineCompareMethod = DiffMethod.CHARS, linesOffset = 0, showLines = []) => {
88
112
  let diffArray = [];
89
113
  // Use diffLines for strings, and diffJson for objects...
90
114
  if (typeof oldString === 'string' && typeof newString === 'string') {
@@ -180,6 +204,9 @@ const computeLineInformation = (oldString, newString, disableWordDiff = false, l
180
204
  right.type = DiffType.DEFAULT;
181
205
  right.value = line;
182
206
  }
207
+ if ((showLines === null || showLines === void 0 ? void 0 : showLines.includes(`L-${left.lineNumber}`)) || (showLines === null || showLines === void 0 ? void 0 : showLines.includes(`R-${right.lineNumber}`)) && !diffLines.includes(counter)) {
208
+ diffLines.push(counter);
209
+ }
183
210
  if (!evaluateOnlyFirstLine) {
184
211
  counter += 1;
185
212
  }
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
- import * as PropTypes from 'prop-types';
3
2
  import { DiffInformation, DiffMethod, DiffType, LineInformation } from './compute-lines';
4
3
  import { ReactDiffViewerStyles, ReactDiffViewerStylesOverride } from './styles';
4
+ import { ReactElement } from "react";
5
5
  export declare enum LineNumberPrefix {
6
6
  LEFT = "L",
7
7
  RIGHT = "R"
@@ -15,9 +15,13 @@ export interface ReactDiffViewerProps {
15
15
  compareMethod?: DiffMethod;
16
16
  extraLinesSurroundingDiff?: number;
17
17
  hideLineNumbers?: boolean;
18
+ /**
19
+ * Show the lines indicated here. Specified as L20 or R18 for respectively line 20 on the left or line 18 on the right.
20
+ */
21
+ alwaysShowLines?: string[];
18
22
  showDiffOnly?: boolean;
19
- renderContent?: (source: string) => JSX.Element;
20
- codeFoldMessageRenderer?: (totalFoldedLines: number, leftStartLineNumber: number, rightStartLineNumber: number) => JSX.Element;
23
+ renderContent?: (source: string) => ReactElement;
24
+ codeFoldMessageRenderer?: (totalFoldedLines: number, leftStartLineNumber: number, rightStartLineNumber: number) => ReactElement;
21
25
  onLineNumberClick?: (lineId: string, event: React.MouseEvent<HTMLTableCellElement>) => void;
22
26
  renderGutter?: (data: {
23
27
  lineNumber: number;
@@ -27,12 +31,13 @@ export interface ReactDiffViewerProps {
27
31
  additionalLineNumber: number;
28
32
  additionalPrefix: LineNumberPrefix;
29
33
  styles: ReactDiffViewerStyles;
30
- }) => JSX.Element;
34
+ }) => ReactElement;
31
35
  highlightLines?: string[];
32
36
  styles?: ReactDiffViewerStylesOverride;
33
37
  useDarkTheme?: boolean;
34
- leftTitle?: string | JSX.Element;
35
- rightTitle?: string | JSX.Element;
38
+ leftTitle?: string | ReactElement;
39
+ rightTitle?: string | ReactElement;
40
+ nonce?: string;
36
41
  }
37
42
  export interface ReactDiffViewerState {
38
43
  expandedBlocks?: number[];
@@ -40,24 +45,6 @@ export interface ReactDiffViewerState {
40
45
  declare class DiffViewer extends React.Component<ReactDiffViewerProps, ReactDiffViewerState> {
41
46
  private styles;
42
47
  static defaultProps: ReactDiffViewerProps;
43
- static propTypes: {
44
- oldValue: PropTypes.Validator<any>;
45
- newValue: PropTypes.Validator<any>;
46
- splitView: PropTypes.Requireable<boolean>;
47
- disableWordDiff: PropTypes.Requireable<boolean>;
48
- compareMethod: PropTypes.Requireable<DiffMethod>;
49
- renderContent: PropTypes.Requireable<(...args: any[]) => any>;
50
- renderGutter: PropTypes.Requireable<(...args: any[]) => any>;
51
- onLineNumberClick: PropTypes.Requireable<(...args: any[]) => any>;
52
- extraLinesSurroundingDiff: PropTypes.Requireable<number>;
53
- styles: PropTypes.Requireable<object>;
54
- hideLineNumbers: PropTypes.Requireable<boolean>;
55
- showDiffOnly: PropTypes.Requireable<boolean>;
56
- highlightLines: PropTypes.Requireable<string[]>;
57
- leftTitle: PropTypes.Requireable<string | PropTypes.ReactElementLike>;
58
- rightTitle: PropTypes.Requireable<string | PropTypes.ReactElementLike>;
59
- linesOffset: PropTypes.Requireable<number>;
60
- };
61
48
  constructor(props: ReactDiffViewerProps);
62
49
  /**
63
50
  * Resets code block expand to the initial stage. Will be exposed to the parent component via
@@ -121,7 +108,7 @@ declare class DiffViewer extends React.Component<ReactDiffViewerProps, ReactDiff
121
108
  * @param obj.right Life diff information for the removed section of the inline view.
122
109
  * @param index React key for the lines.
123
110
  */
124
- renderInlineView: ({ left, right }: LineInformation, index: number) => JSX.Element;
111
+ renderInlineView: ({ left, right }: LineInformation, index: number) => ReactElement;
125
112
  /**
126
113
  * Returns a function with clicked block number in the closure.
127
114
  *
@@ -142,7 +129,7 @@ declare class DiffViewer extends React.Component<ReactDiffViewerProps, ReactDiff
142
129
  * Generates the entire diff view.
143
130
  */
144
131
  private renderDiff;
145
- render: () => JSX.Element;
132
+ render: () => ReactElement;
146
133
  }
147
134
  export default DiffViewer;
148
135
  export { ReactDiffViewerStylesOverride, DiffMethod };
@@ -1,19 +1,46 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
2
28
  Object.defineProperty(exports, "__esModule", { value: true });
3
29
  exports.DiffMethod = exports.LineNumberPrefix = void 0;
4
- const React = require("react");
5
- const PropTypes = require("prop-types");
6
- const classnames_1 = require("classnames");
30
+ const jsx_runtime_1 = require("react/jsx-runtime");
31
+ const React = __importStar(require("react"));
32
+ const classnames_1 = __importDefault(require("classnames"));
7
33
  const compute_lines_1 = require("./compute-lines");
8
34
  Object.defineProperty(exports, "DiffMethod", { enumerable: true, get: function () { return compute_lines_1.DiffMethod; } });
9
- const styles_1 = require("./styles");
35
+ const styles_1 = __importDefault(require("./styles"));
36
+ const compute_hidden_blocks_1 = require("./compute-hidden-blocks");
10
37
  const m = require('memoize-one');
11
38
  const memoize = m.default || m;
12
39
  var LineNumberPrefix;
13
40
  (function (LineNumberPrefix) {
14
41
  LineNumberPrefix["LEFT"] = "L";
15
42
  LineNumberPrefix["RIGHT"] = "R";
16
- })(LineNumberPrefix = exports.LineNumberPrefix || (exports.LineNumberPrefix = {}));
43
+ })(LineNumberPrefix || (exports.LineNumberPrefix = LineNumberPrefix = {}));
17
44
  class DiffViewer extends React.Component {
18
45
  constructor(props) {
19
46
  super(props);
@@ -68,10 +95,10 @@ class DiffViewer extends React.Component {
68
95
  */
69
96
  this.renderWordDiff = (diffArray, renderer) => {
70
97
  return diffArray.map((wordDiff, i) => {
71
- return (React.createElement("span", { key: i, className: (0, classnames_1.default)(this.styles.wordDiff, {
98
+ return ((0, jsx_runtime_1.jsx)("span", { className: (0, classnames_1.default)(this.styles.wordDiff, {
72
99
  [this.styles.wordAdded]: wordDiff.type === compute_lines_1.DiffType.ADDED,
73
100
  [this.styles.wordRemoved]: wordDiff.type === compute_lines_1.DiffType.REMOVED,
74
- }) }, renderer ? renderer(wordDiff.value) : wordDiff.value));
101
+ }), children: renderer ? renderer(wordDiff.value) : wordDiff.value }, i));
75
102
  });
76
103
  };
77
104
  /**
@@ -105,53 +132,42 @@ class DiffViewer extends React.Component {
105
132
  else {
106
133
  content = value;
107
134
  }
108
- return (React.createElement(React.Fragment, null,
109
- !this.props.hideLineNumbers && (React.createElement("td", { onClick: lineNumber && this.onLineNumberClickProxy(lineNumberTemplate), className: (0, classnames_1.default)(this.styles.gutter, {
110
- [this.styles.emptyGutter]: !lineNumber,
111
- [this.styles.diffAdded]: added,
112
- [this.styles.diffRemoved]: removed,
113
- [this.styles.diffChanged]: changed,
114
- [this.styles.highlightedGutter]: highlightLine,
115
- }) },
116
- React.createElement("pre", { className: this.styles.lineNumber }, lineNumber))),
117
- !this.props.splitView && !this.props.hideLineNumbers && (React.createElement("td", { onClick: additionalLineNumber &&
118
- this.onLineNumberClickProxy(additionalLineNumberTemplate), className: (0, classnames_1.default)(this.styles.gutter, {
119
- [this.styles.emptyGutter]: !additionalLineNumber,
120
- [this.styles.diffAdded]: added,
121
- [this.styles.diffRemoved]: removed,
122
- [this.styles.diffChanged]: changed,
123
- [this.styles.highlightedGutter]: highlightLine,
124
- }) },
125
- React.createElement("pre", { className: this.styles.lineNumber }, additionalLineNumber))),
126
- this.props.renderGutter
127
- ? this.props.renderGutter({
128
- lineNumber,
129
- type,
130
- prefix,
131
- value,
132
- additionalLineNumber,
133
- additionalPrefix,
134
- styles: this.styles,
135
- })
136
- : null,
137
- React.createElement("td", { className: (0, classnames_1.default)(this.styles.marker, {
138
- [this.styles.emptyLine]: !content,
139
- [this.styles.diffAdded]: added,
140
- [this.styles.diffRemoved]: removed,
141
- [this.styles.diffChanged]: changed,
142
- [this.styles.highlightedLine]: highlightLine,
143
- }) },
144
- React.createElement("pre", null,
145
- added && '+',
146
- removed && '-')),
147
- React.createElement("td", { className: (0, classnames_1.default)(this.styles.content, {
148
- [this.styles.emptyLine]: !content,
149
- [this.styles.diffAdded]: added,
150
- [this.styles.diffRemoved]: removed,
151
- [this.styles.diffChanged]: changed,
152
- [this.styles.highlightedLine]: highlightLine,
153
- }) },
154
- React.createElement("pre", { className: this.styles.contentText }, content))));
135
+ return ((0, jsx_runtime_1.jsxs)(React.Fragment, { children: [!this.props.hideLineNumbers && ((0, jsx_runtime_1.jsx)("td", { onClick: lineNumber && this.onLineNumberClickProxy(lineNumberTemplate), className: (0, classnames_1.default)(this.styles.gutter, {
136
+ [this.styles.emptyGutter]: !lineNumber,
137
+ [this.styles.diffAdded]: added,
138
+ [this.styles.diffRemoved]: removed,
139
+ [this.styles.diffChanged]: changed,
140
+ [this.styles.highlightedGutter]: highlightLine,
141
+ }), children: (0, jsx_runtime_1.jsx)("pre", { className: this.styles.lineNumber, children: lineNumber }) })), !this.props.splitView && !this.props.hideLineNumbers && ((0, jsx_runtime_1.jsx)("td", { onClick: additionalLineNumber &&
142
+ this.onLineNumberClickProxy(additionalLineNumberTemplate), className: (0, classnames_1.default)(this.styles.gutter, {
143
+ [this.styles.emptyGutter]: !additionalLineNumber,
144
+ [this.styles.diffAdded]: added,
145
+ [this.styles.diffRemoved]: removed,
146
+ [this.styles.diffChanged]: changed,
147
+ [this.styles.highlightedGutter]: highlightLine,
148
+ }), children: (0, jsx_runtime_1.jsx)("pre", { className: this.styles.lineNumber, children: additionalLineNumber }) })), this.props.renderGutter
149
+ ? this.props.renderGutter({
150
+ lineNumber,
151
+ type,
152
+ prefix,
153
+ value,
154
+ additionalLineNumber,
155
+ additionalPrefix,
156
+ styles: this.styles,
157
+ })
158
+ : null, (0, jsx_runtime_1.jsx)("td", { className: (0, classnames_1.default)(this.styles.marker, {
159
+ [this.styles.emptyLine]: !content,
160
+ [this.styles.diffAdded]: added,
161
+ [this.styles.diffRemoved]: removed,
162
+ [this.styles.diffChanged]: changed,
163
+ [this.styles.highlightedLine]: highlightLine,
164
+ }), children: (0, jsx_runtime_1.jsxs)("pre", { children: [added && '+', removed && '-'] }) }), (0, jsx_runtime_1.jsx)("td", { className: (0, classnames_1.default)(this.styles.content, {
165
+ [this.styles.emptyLine]: !content,
166
+ [this.styles.diffAdded]: added,
167
+ [this.styles.diffRemoved]: removed,
168
+ [this.styles.diffChanged]: changed,
169
+ [this.styles.highlightedLine]: highlightLine,
170
+ }), children: (0, jsx_runtime_1.jsx)("pre", { className: this.styles.contentText, children: content }) })] }));
155
171
  };
156
172
  /**
157
173
  * Generates lines for split view.
@@ -162,9 +178,7 @@ class DiffViewer extends React.Component {
162
178
  * @param index React key for the lines.
163
179
  */
164
180
  this.renderSplitView = ({ left, right }, index) => {
165
- return (React.createElement("tr", { key: index, className: this.styles.line },
166
- this.renderLine(left.lineNumber, left.type, LineNumberPrefix.LEFT, left.value),
167
- this.renderLine(right.lineNumber, right.type, LineNumberPrefix.RIGHT, right.value)));
181
+ return ((0, jsx_runtime_1.jsxs)("tr", { className: this.styles.line, children: [this.renderLine(left.lineNumber, left.type, LineNumberPrefix.LEFT, left.value), this.renderLine(right.lineNumber, right.type, LineNumberPrefix.RIGHT, right.value)] }, index));
168
182
  };
169
183
  /**
170
184
  * Generates lines for inline view.
@@ -177,9 +191,7 @@ class DiffViewer extends React.Component {
177
191
  this.renderInlineView = ({ left, right }, index) => {
178
192
  let content;
179
193
  if (left.type === compute_lines_1.DiffType.REMOVED && right.type === compute_lines_1.DiffType.ADDED) {
180
- return (React.createElement(React.Fragment, { key: index },
181
- React.createElement("tr", { className: this.styles.line }, this.renderLine(left.lineNumber, left.type, LineNumberPrefix.LEFT, left.value, null)),
182
- React.createElement("tr", { className: this.styles.line }, this.renderLine(null, right.type, LineNumberPrefix.RIGHT, right.value, right.lineNumber))));
194
+ return ((0, jsx_runtime_1.jsxs)(React.Fragment, { children: [(0, jsx_runtime_1.jsx)("tr", { className: this.styles.line, children: this.renderLine(left.lineNumber, left.type, LineNumberPrefix.LEFT, left.value, null) }), (0, jsx_runtime_1.jsx)("tr", { className: this.styles.line, children: this.renderLine(null, right.type, LineNumberPrefix.RIGHT, right.value, right.lineNumber) })] }, index));
183
195
  }
184
196
  if (left.type === compute_lines_1.DiffType.REMOVED) {
185
197
  content = this.renderLine(left.lineNumber, left.type, LineNumberPrefix.LEFT, left.value, null);
@@ -190,7 +202,7 @@ class DiffViewer extends React.Component {
190
202
  if (right.type === compute_lines_1.DiffType.ADDED) {
191
203
  content = this.renderLine(null, right.type, LineNumberPrefix.RIGHT, right.value, right.lineNumber);
192
204
  }
193
- return (React.createElement("tr", { key: index, className: this.styles.line }, content));
205
+ return ((0, jsx_runtime_1.jsx)("tr", { className: this.styles.line, children: content }, index));
194
206
  };
195
207
  /**
196
208
  * Returns a function with clicked block number in the closure.
@@ -209,98 +221,59 @@ class DiffViewer extends React.Component {
209
221
  */
210
222
  this.renderSkippedLineIndicator = (num, blockNumber, leftBlockLineNumber, rightBlockLineNumber) => {
211
223
  const { hideLineNumbers, splitView } = this.props;
212
- const message = this.props.codeFoldMessageRenderer ? (this.props.codeFoldMessageRenderer(num, leftBlockLineNumber, rightBlockLineNumber)) : (React.createElement("pre", { className: this.styles.codeFoldContent },
213
- "Expand ",
214
- num,
215
- " lines ..."));
216
- const content = (React.createElement("td", null,
217
- React.createElement("a", { onClick: this.onBlockClickProxy(blockNumber), tabIndex: 0 }, message)));
224
+ const message = this.props.codeFoldMessageRenderer ? (this.props.codeFoldMessageRenderer(num, leftBlockLineNumber, rightBlockLineNumber)) : ((0, jsx_runtime_1.jsxs)("pre", { className: this.styles.codeFoldContent, children: ["Expand ", num, " lines ..."] }));
225
+ const content = ((0, jsx_runtime_1.jsx)("td", { children: (0, jsx_runtime_1.jsx)("a", { onClick: this.onBlockClickProxy(blockNumber), tabIndex: 0, children: message }) }));
218
226
  const isUnifiedViewWithoutLineNumbers = !splitView && !hideLineNumbers;
219
- return (React.createElement("tr", { key: `${leftBlockLineNumber}-${rightBlockLineNumber}`, className: this.styles.codeFold },
220
- !hideLineNumbers && React.createElement("td", { className: this.styles.codeFoldGutter }),
221
- this.props.renderGutter ? (React.createElement("td", { className: this.styles.codeFoldGutter })) : null,
222
- React.createElement("td", { className: (0, classnames_1.default)({
223
- [this.styles.codeFoldGutter]: isUnifiedViewWithoutLineNumbers,
224
- }) }),
225
- isUnifiedViewWithoutLineNumbers ? (React.createElement(React.Fragment, null,
226
- React.createElement("td", null),
227
- content)) : (React.createElement(React.Fragment, null,
228
- content,
229
- this.props.renderGutter ? React.createElement("td", null) : null,
230
- React.createElement("td", null))),
231
- React.createElement("td", null),
232
- React.createElement("td", null)));
227
+ return ((0, jsx_runtime_1.jsxs)("tr", { className: this.styles.codeFold, children: [!hideLineNumbers && (0, jsx_runtime_1.jsx)("td", { className: this.styles.codeFoldGutter }), this.props.renderGutter ? ((0, jsx_runtime_1.jsx)("td", { className: this.styles.codeFoldGutter })) : null, (0, jsx_runtime_1.jsx)("td", { className: (0, classnames_1.default)({
228
+ [this.styles.codeFoldGutter]: isUnifiedViewWithoutLineNumbers,
229
+ }) }), isUnifiedViewWithoutLineNumbers ? ((0, jsx_runtime_1.jsxs)(React.Fragment, { children: [(0, jsx_runtime_1.jsx)("td", {}), content] })) : ((0, jsx_runtime_1.jsxs)(React.Fragment, { children: [content, this.props.renderGutter ? (0, jsx_runtime_1.jsx)("td", {}) : null, (0, jsx_runtime_1.jsx)("td", {})] })), (0, jsx_runtime_1.jsx)("td", {}), (0, jsx_runtime_1.jsx)("td", {})] }, `${leftBlockLineNumber}-${rightBlockLineNumber}`));
233
230
  };
234
231
  /**
235
232
  * Generates the entire diff view.
236
233
  */
237
234
  this.renderDiff = () => {
238
235
  const { oldValue, newValue, splitView, disableWordDiff, compareMethod, linesOffset, } = this.props;
239
- const { lineInformation, diffLines } = (0, compute_lines_1.computeLineInformation)(oldValue, newValue, disableWordDiff, compareMethod, linesOffset);
236
+ const { lineInformation, diffLines } = (0, compute_lines_1.computeLineInformation)(oldValue, newValue, disableWordDiff, compareMethod, linesOffset, this.props.alwaysShowLines);
240
237
  const extraLines = this.props.extraLinesSurroundingDiff < 0
241
238
  ? 0
242
- : this.props.extraLinesSurroundingDiff;
243
- let skippedLines = [];
244
- return lineInformation.map((line, i) => {
245
- const diffBlockStart = diffLines[0];
246
- const currentPosition = diffBlockStart - i;
239
+ : Math.round(this.props.extraLinesSurroundingDiff);
240
+ const { lineBlocks, blocks } = (0, compute_hidden_blocks_1.computeHiddenBlocks)(lineInformation, diffLines, extraLines);
241
+ return lineInformation.map((line, lineIndex) => {
247
242
  if (this.props.showDiffOnly) {
248
- if (currentPosition === -extraLines) {
249
- skippedLines = [];
250
- diffLines.shift();
251
- }
252
- if (line.left.type === compute_lines_1.DiffType.DEFAULT &&
253
- (currentPosition > extraLines ||
254
- typeof diffBlockStart === 'undefined') &&
255
- !this.state.expandedBlocks.includes(diffBlockStart)) {
256
- skippedLines.push(i + 1);
257
- // show skipped line indicator only if there is more than one line to hide
258
- if (i === lineInformation.length - 1 && skippedLines.length > 1) {
259
- return this.renderSkippedLineIndicator(skippedLines.length, diffBlockStart, line.left.lineNumber, line.right.lineNumber);
260
- // if we are trying to hide the last line, just show it
243
+ const blockIndex = lineBlocks[lineIndex];
244
+ if (blockIndex !== undefined) {
245
+ const lastLineOfBlock = blocks[blockIndex].endLine === lineIndex;
246
+ if (!this.state.expandedBlocks.includes(blockIndex) && lastLineOfBlock) {
247
+ return ((0, jsx_runtime_1.jsx)(React.Fragment, { children: this.renderSkippedLineIndicator(blocks[blockIndex].lines, blockIndex, line.left.lineNumber, line.right.lineNumber) }, lineIndex));
261
248
  }
262
- else if (i < lineInformation.length - 1) {
249
+ else if (!this.state.expandedBlocks.includes(blockIndex)) {
263
250
  return null;
264
251
  }
265
252
  }
266
253
  }
267
254
  const diffNodes = splitView
268
- ? this.renderSplitView(line, i)
269
- : this.renderInlineView(line, i);
270
- if (currentPosition === extraLines && skippedLines.length > 0) {
271
- const { length } = skippedLines;
272
- skippedLines = [];
273
- return (React.createElement(React.Fragment, { key: i },
274
- this.renderSkippedLineIndicator(length, diffBlockStart, line.left.lineNumber, line.right.lineNumber),
275
- diffNodes));
276
- }
255
+ ? this.renderSplitView(line, lineIndex)
256
+ : this.renderInlineView(line, lineIndex);
277
257
  return diffNodes;
278
258
  });
279
259
  };
280
260
  this.render = () => {
281
- const { oldValue, newValue, useDarkTheme, leftTitle, rightTitle, splitView, hideLineNumbers, } = this.props;
261
+ const { oldValue, newValue, useDarkTheme, leftTitle, rightTitle, splitView, hideLineNumbers, nonce, } = this.props;
282
262
  if (this.props.compareMethod !== compute_lines_1.DiffMethod.JSON) {
283
263
  if (typeof oldValue !== 'string' || typeof newValue !== 'string') {
284
264
  throw Error('"oldValue" and "newValue" should be strings');
285
265
  }
286
266
  }
287
- this.styles = this.computeStyles(this.props.styles, useDarkTheme);
267
+ this.styles = this.computeStyles(this.props.styles, useDarkTheme, nonce);
288
268
  const nodes = this.renderDiff();
289
269
  const colSpanOnSplitView = hideLineNumbers ? 2 : 3;
290
270
  const colSpanOnInlineView = hideLineNumbers ? 2 : 4;
291
271
  let columnExtension = this.props.renderGutter ? 1 : 0;
292
- const title = (leftTitle || rightTitle) && (React.createElement("tr", null,
293
- React.createElement("td", { colSpan: (splitView ? colSpanOnSplitView : colSpanOnInlineView) +
294
- columnExtension, className: this.styles.titleBlock },
295
- React.createElement("pre", { className: this.styles.contentText }, leftTitle)),
296
- splitView && (React.createElement("td", { colSpan: colSpanOnSplitView + columnExtension, className: this.styles.titleBlock },
297
- React.createElement("pre", { className: this.styles.contentText }, rightTitle)))));
298
- return (React.createElement("table", { className: (0, classnames_1.default)(this.styles.diffContainer, {
272
+ const title = (leftTitle || rightTitle) && ((0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("td", { colSpan: (splitView ? colSpanOnSplitView : colSpanOnInlineView) +
273
+ columnExtension, className: this.styles.titleBlock, children: (0, jsx_runtime_1.jsx)("pre", { className: this.styles.contentText, children: leftTitle }) }), splitView && ((0, jsx_runtime_1.jsx)("td", { colSpan: colSpanOnSplitView + columnExtension, className: this.styles.titleBlock, children: (0, jsx_runtime_1.jsx)("pre", { className: this.styles.contentText, children: rightTitle }) }))] }));
274
+ return ((0, jsx_runtime_1.jsx)("table", { className: (0, classnames_1.default)(this.styles.diffContainer, {
299
275
  [this.styles.splitView]: splitView,
300
- }) },
301
- React.createElement("tbody", null,
302
- title,
303
- nodes)));
276
+ }), children: (0, jsx_runtime_1.jsxs)("tbody", { children: [title, nodes] }) }));
304
277
  };
305
278
  this.state = {
306
279
  expandedBlocks: [],
@@ -320,23 +293,6 @@ DiffViewer.defaultProps = {
320
293
  showDiffOnly: true,
321
294
  useDarkTheme: false,
322
295
  linesOffset: 0,
323
- };
324
- DiffViewer.propTypes = {
325
- oldValue: PropTypes.any.isRequired,
326
- newValue: PropTypes.any.isRequired,
327
- splitView: PropTypes.bool,
328
- disableWordDiff: PropTypes.bool,
329
- compareMethod: PropTypes.oneOf(Object.values(compute_lines_1.DiffMethod)),
330
- renderContent: PropTypes.func,
331
- renderGutter: PropTypes.func,
332
- onLineNumberClick: PropTypes.func,
333
- extraLinesSurroundingDiff: PropTypes.number,
334
- styles: PropTypes.object,
335
- hideLineNumbers: PropTypes.bool,
336
- showDiffOnly: PropTypes.bool,
337
- highlightLines: PropTypes.arrayOf(PropTypes.string),
338
- leftTitle: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
339
- rightTitle: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
340
- linesOffset: PropTypes.number,
296
+ nonce: '',
341
297
  };
342
298
  exports.default = DiffViewer;
@@ -77,5 +77,5 @@ export interface ReactDiffViewerStylesOverride {
77
77
  titleBlock?: CSSInterpolation;
78
78
  splitView?: CSSInterpolation;
79
79
  }
80
- declare const _default: (styleOverride: ReactDiffViewerStylesOverride, useDarkTheme?: boolean) => ReactDiffViewerStyles;
80
+ declare const _default: (styleOverride: ReactDiffViewerStylesOverride, useDarkTheme?: boolean, nonce?: string) => ReactDiffViewerStyles;
81
81
  export default _default;
@@ -10,10 +10,13 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  }
11
11
  return t;
12
12
  };
13
+ var __importDefault = (this && this.__importDefault) || function (mod) {
14
+ return (mod && mod.__esModule) ? mod : { "default": mod };
15
+ };
13
16
  Object.defineProperty(exports, "__esModule", { value: true });
14
- const css_1 = require("@emotion/css");
17
+ const create_instance_1 = __importDefault(require("@emotion/css/create-instance"));
15
18
  // eslint-disable-next-line import/no-anonymous-default-export
16
- exports.default = (styleOverride, useDarkTheme = false) => {
19
+ exports.default = (styleOverride, useDarkTheme = false, nonce = '') => {
17
20
  const { variables: overrideVariables = {} } = styleOverride, styles = __rest(styleOverride, ["variables"]);
18
21
  const themeVariables = {
19
22
  light: Object.assign({
@@ -72,17 +75,18 @@ exports.default = (styleOverride, useDarkTheme = false) => {
72
75
  }, (overrideVariables.dark || {})),
73
76
  };
74
77
  const variables = useDarkTheme ? themeVariables.dark : themeVariables.light;
75
- const content = (0, css_1.css)({
78
+ const { css, cx } = (0, create_instance_1.default)({ key: 'react-diff', nonce });
79
+ const content = css({
76
80
  width: '100%',
77
81
  label: 'content',
78
82
  });
79
- const splitView = (0, css_1.css)({
83
+ const splitView = css({
80
84
  [`.${content}`]: {
81
85
  width: '50%',
82
86
  },
83
87
  label: 'split-view',
84
88
  });
85
- const diffContainer = (0, css_1.css)({
89
+ const diffContainer = css({
86
90
  width: '100%',
87
91
  background: variables.diffViewerBackground,
88
92
  pre: {
@@ -93,15 +97,15 @@ exports.default = (styleOverride, useDarkTheme = false) => {
93
97
  label: 'diff-container',
94
98
  borderCollapse: 'collapse',
95
99
  });
96
- const codeFoldContent = (0, css_1.css)({
100
+ const codeFoldContent = css({
97
101
  color: variables.codeFoldContentColor,
98
102
  label: 'code-fold-content',
99
103
  });
100
- const contentText = (0, css_1.css)({
104
+ const contentText = css({
101
105
  color: variables.diffViewerColor,
102
106
  label: 'content-text',
103
107
  });
104
- const titleBlock = (0, css_1.css)({
108
+ const titleBlock = css({
105
109
  background: variables.diffViewerTitleBackground,
106
110
  padding: 10,
107
111
  borderBottom: `1px solid ${variables.diffViewerTitleBorderColor}`,
@@ -113,11 +117,11 @@ exports.default = (styleOverride, useDarkTheme = false) => {
113
117
  color: variables.diffViewerTitleColor,
114
118
  },
115
119
  });
116
- const lineNumber = (0, css_1.css)({
120
+ const lineNumber = css({
117
121
  color: variables.gutterColor,
118
122
  label: 'line-number',
119
123
  });
120
- const diffRemoved = (0, css_1.css)({
124
+ const diffRemoved = css({
121
125
  background: variables.removedBackground,
122
126
  color: variables.removedColor,
123
127
  pre: {
@@ -128,7 +132,7 @@ exports.default = (styleOverride, useDarkTheme = false) => {
128
132
  },
129
133
  label: 'diff-removed',
130
134
  });
131
- const diffAdded = (0, css_1.css)({
135
+ const diffAdded = css({
132
136
  background: variables.addedBackground,
133
137
  color: variables.addedColor,
134
138
  pre: {
@@ -139,33 +143,33 @@ exports.default = (styleOverride, useDarkTheme = false) => {
139
143
  },
140
144
  label: 'diff-added',
141
145
  });
142
- const diffChanged = (0, css_1.css)({
146
+ const diffChanged = css({
143
147
  background: variables.changedBackground,
144
148
  [`.${lineNumber}`]: {
145
149
  color: variables.gutterColor,
146
150
  },
147
151
  label: 'diff-changed',
148
152
  });
149
- const wordDiff = (0, css_1.css)({
153
+ const wordDiff = css({
150
154
  padding: 2,
151
155
  display: 'inline-flex',
152
156
  borderRadius: 4,
153
157
  wordBreak: 'break-all',
154
158
  label: 'word-diff',
155
159
  });
156
- const wordAdded = (0, css_1.css)({
160
+ const wordAdded = css({
157
161
  background: variables.wordAddedBackground,
158
162
  label: 'word-added',
159
163
  });
160
- const wordRemoved = (0, css_1.css)({
164
+ const wordRemoved = css({
161
165
  background: variables.wordRemovedBackground,
162
166
  label: 'word-removed',
163
167
  });
164
- const codeFoldGutter = (0, css_1.css)({
168
+ const codeFoldGutter = css({
165
169
  backgroundColor: variables.codeFoldGutterBackground,
166
170
  label: 'code-fold-gutter',
167
171
  });
168
- const codeFold = (0, css_1.css)({
172
+ const codeFold = css({
169
173
  backgroundColor: variables.codeFoldBackground,
170
174
  height: 40,
171
175
  fontSize: 14,
@@ -179,11 +183,11 @@ exports.default = (styleOverride, useDarkTheme = false) => {
179
183
  },
180
184
  },
181
185
  });
182
- const emptyLine = (0, css_1.css)({
186
+ const emptyLine = css({
183
187
  backgroundColor: variables.emptyLineBackground,
184
188
  label: 'empty-line',
185
189
  });
186
- const marker = (0, css_1.css)({
190
+ const marker = css({
187
191
  width: 25,
188
192
  paddingLeft: 10,
189
193
  paddingRight: 10,
@@ -200,17 +204,17 @@ exports.default = (styleOverride, useDarkTheme = false) => {
200
204
  },
201
205
  },
202
206
  });
203
- const highlightedLine = (0, css_1.css)({
207
+ const highlightedLine = css({
204
208
  background: variables.highlightBackground,
205
209
  label: 'highlighted-line',
206
210
  [`.${wordAdded}, .${wordRemoved}`]: {
207
211
  backgroundColor: 'initial',
208
212
  },
209
213
  });
210
- const highlightedGutter = (0, css_1.css)({
214
+ const highlightedGutter = css({
211
215
  label: 'highlighted-gutter',
212
216
  });
213
- const gutter = (0, css_1.css)({
217
+ const gutter = css({
214
218
  userSelect: 'none',
215
219
  minWidth: 50,
216
220
  padding: '0 10px',
@@ -241,14 +245,14 @@ exports.default = (styleOverride, useDarkTheme = false) => {
241
245
  },
242
246
  },
243
247
  });
244
- const emptyGutter = (0, css_1.css)({
248
+ const emptyGutter = css({
245
249
  '&:hover': {
246
250
  background: variables.gutterBackground,
247
251
  cursor: 'initial',
248
252
  },
249
253
  label: 'empty-gutter',
250
254
  });
251
- const line = (0, css_1.css)({
255
+ const line = css({
252
256
  verticalAlign: 'baseline',
253
257
  label: 'line',
254
258
  });
@@ -277,11 +281,11 @@ exports.default = (styleOverride, useDarkTheme = false) => {
277
281
  titleBlock,
278
282
  };
279
283
  const computerOverrideStyles = Object.keys(styles).reduce((acc, key) => (Object.assign(Object.assign({}, acc), {
280
- [key]: (0, css_1.css)(styles[key]),
284
+ [key]: css(styles[key]),
281
285
  })), {});
282
286
  return Object.keys(defaultStyles).reduce((acc, key) => (Object.assign(Object.assign({}, acc), {
283
287
  [key]: computerOverrideStyles[key]
284
- ? (0, css_1.cx)(defaultStyles[key], computerOverrideStyles[key])
288
+ ? cx(defaultStyles[key], computerOverrideStyles[key])
285
289
  : defaultStyles[key],
286
290
  })), {});
287
291
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-diff-viewer-continued",
3
- "version": "3.2.6",
3
+ "version": "3.3.1",
4
4
  "private": false,
5
5
  "description": "Continuation of a simple and beautiful text diff viewer component made with diff and React",
6
6
  "keywords": [
@@ -19,8 +19,8 @@
19
19
  "Pranesh Ravi<praneshpranesh@gmail.com>",
20
20
  "Bart Riepe <bart@serial-experiments.com>"
21
21
  ],
22
- "main": "lib/index",
23
- "typings": "lib/index",
22
+ "main": "lib/src/index",
23
+ "typings": "lib/src/index",
24
24
  "scripts": {
25
25
  "build": "tsc --outDir lib/",
26
26
  "build:examples": "webpack --progress",
@@ -35,60 +35,60 @@
35
35
  "prettier": "prettier --write ."
36
36
  },
37
37
  "dependencies": {
38
- "@emotion/css": "^11.10.5",
39
- "classnames": "^2.3.1",
38
+ "@emotion/css": "^11.11.2",
39
+ "classnames": "^2.3.2",
40
40
  "diff": "^5.1.0",
41
41
  "memoize-one": "^6.0.0",
42
42
  "prop-types": "^15.8.1"
43
43
  },
44
44
  "devDependencies": {
45
- "@babel/core": "^7.18.6",
46
- "@babel/preset-env": "^7.18.6",
47
- "@babel/preset-react": "^7.18.6",
48
- "@babel/preset-typescript": "^7.18.6",
45
+ "@babel/core": "^7.23.2",
46
+ "@babel/preset-env": "^7.23.2",
47
+ "@babel/preset-react": "^7.22.15",
48
+ "@babel/preset-typescript": "^7.23.2",
49
49
  "@semantic-release/changelog": "6.0.1",
50
50
  "@semantic-release/git": "10.0.1",
51
51
  "@testing-library/react": "^13.4.0",
52
- "@types/diff": "^5.0.2",
53
- "@types/expect": "^1.20.3",
52
+ "@types/diff": "^5.0.6",
53
+ "@types/expect": "^1.20.4",
54
54
  "@types/memoize-one": "^4.1.1",
55
- "@types/mocha": "^5.2.5",
56
- "@types/node": "^12.0.12",
55
+ "@types/mocha": "^5.2.7",
56
+ "@types/node": "^12.20.55",
57
57
  "@types/prop-types": "15.7.5",
58
- "@types/react": "^16.4.14",
59
- "@types/react-dom": "^16.0.8",
60
- "@types/webpack": "^4.4.13",
61
- "@typescript-eslint/eslint-plugin": "^5.30.5",
62
- "@typescript-eslint/parser": "^5.30.5",
63
- "css-loader": "^6.7.1",
64
- "eslint": "^8.19.0",
58
+ "@types/react": "^16.14.49",
59
+ "@types/react-dom": "^16.9.20",
60
+ "@types/webpack": "^4.41.34",
61
+ "@typescript-eslint/eslint-plugin": "^5.62.0",
62
+ "@typescript-eslint/parser": "^5.62.0",
63
+ "css-loader": "^6.8.1",
64
+ "eslint": "^8.51.0",
65
65
  "eslint-config-airbnb": "^19.0.4",
66
- "eslint-plugin-import": "^2.26.0",
67
- "eslint-plugin-jsx-a11y": "^6.6.0",
68
- "eslint-plugin-react": "^7.30.1",
66
+ "eslint-plugin-import": "^2.28.1",
67
+ "eslint-plugin-jsx-a11y": "^6.7.1",
68
+ "eslint-plugin-react": "^7.33.2",
69
69
  "eslint-plugin-react-hooks": "^4.6.0",
70
- "expect": "^28.1.1",
70
+ "expect": "^28.1.3",
71
71
  "file-loader": "^6.2.0",
72
72
  "gh-pages": "^4.0.0",
73
- "html-webpack-plugin": "^5.5.0",
74
- "jest": "^28.1.2",
75
- "jest-environment-jsdom": "^28.1.2",
76
- "mini-css-extract-plugin": "^2.6.1",
77
- "mocha": "^10.0.0",
78
- "prettier": "^2.7.1",
73
+ "html-webpack-plugin": "^5.5.3",
74
+ "jest": "^28.1.3",
75
+ "jest-environment-jsdom": "^28.1.3",
76
+ "mini-css-extract-plugin": "^2.7.6",
77
+ "mocha": "^10.2.0",
78
+ "prettier": "^2.8.8",
79
79
  "raw-loader": "^4.0.2",
80
- "react": "^18.0.0",
81
- "react-dom": "^18.0.0",
82
- "sass": "^1.53.0",
83
- "sass-loader": "^13.0.2",
84
- "semantic-release": "^19.0.3",
80
+ "react": "^18.2.0",
81
+ "react-dom": "^18.2.0",
82
+ "sass": "^1.69.3",
83
+ "sass-loader": "^13.3.2",
84
+ "semantic-release": "^19.0.5",
85
85
  "spy": "^1.0.0",
86
- "ts-loader": "^9.3.1",
87
- "ts-node": "^10.8.2",
88
- "typescript": "^4.7.4",
89
- "webpack": "^5.73.0",
86
+ "ts-loader": "^9.5.0",
87
+ "ts-node": "^10.9.1",
88
+ "typescript": "^5.2.2",
89
+ "webpack": "^5.89.0",
90
90
  "webpack-cli": "^4.10.0",
91
- "webpack-dev-server": "^4.9.3"
91
+ "webpack-dev-server": "^4.15.1"
92
92
  },
93
93
  "peerDependencies": {
94
94
  "react": "^15.3.0 || ^16.0.0 || ^17.0.0 || ^18.0.0",
package/tsconfig.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "experimentalDecorators": true,
4
- "jsx": "react",
4
+ "jsx": "react-jsx",
5
5
  "module": "commonjs",
6
6
  "moduleResolution": "node",
7
7
  "noImplicitAny": true,
8
+ "esModuleInterop": true,
8
9
  "target": "es2015",
9
10
  "declaration": true,
10
11
  "downlevelIteration": true,
11
12
  "lib": ["es2017", "dom"],
12
13
  "types": ["jest", "node"]
13
14
  },
14
- "include": ["./src/*"],
15
+ "include": ["src/", "examples/"],
15
16
  "exclude": ["node_modules"]
16
17
  }
package/webpack.config.js CHANGED
@@ -29,7 +29,7 @@ module.exports = {
29
29
  {
30
30
  loader: 'ts-loader',
31
31
  options: {
32
- configFile: 'tsconfig.examples.json',
32
+ configFile: 'tsconfig.json',
33
33
  },
34
34
  },
35
35
  ],
@@ -1,14 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "experimentalDecorators": true,
4
- "jsx": "react-jsx",
5
- "module": "es6",
6
- "moduleResolution": "node",
7
- "allowSyntheticDefaultImports": true,
8
- "noImplicitAny": true,
9
- "target": "es5",
10
- "downlevelIteration": true,
11
- "lib": ["es2017", "dom"]
12
- },
13
- "exclude": ["node_modules"]
14
- }