@reltio/components 1.4.1998 → 1.4.1999
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/cjs/UpSetChart/UpSetChart.d.ts +5 -8
- package/cjs/UpSetChart/UpSetChart.js +61 -5
- package/cjs/UpSetChart/UpSetChart.test.d.ts +1 -0
- package/cjs/UpSetChart/UpSetChart.test.js +198 -0
- package/cjs/UpSetChart/components/IntersectionsChart/IntersectionsChart.d.ts +15 -0
- package/cjs/UpSetChart/components/IntersectionsChart/IntersectionsChart.js +66 -0
- package/cjs/UpSetChart/components/IntersectionsChart/index.d.ts +1 -0
- package/cjs/UpSetChart/components/IntersectionsChart/index.js +5 -0
- package/cjs/UpSetChart/components/IntersectionsChart/styles.d.ts +1 -0
- package/cjs/UpSetChart/components/IntersectionsChart/styles.js +32 -0
- package/cjs/UpSetChart/components/IntersectionsChartAxis/IntersectionsChartAxis.d.ts +10 -0
- package/cjs/UpSetChart/components/IntersectionsChartAxis/IntersectionsChartAxis.js +64 -0
- package/cjs/UpSetChart/components/IntersectionsChartAxis/index.d.ts +1 -0
- package/cjs/UpSetChart/components/IntersectionsChartAxis/index.js +5 -0
- package/cjs/UpSetChart/components/IntersectionsChartAxis/styles.d.ts +1 -0
- package/cjs/UpSetChart/components/IntersectionsChartAxis/styles.js +32 -0
- package/cjs/UpSetChart/components/IntersectionsMatrix/IntersectionsMatrix.d.ts +13 -0
- package/cjs/UpSetChart/components/IntersectionsMatrix/IntersectionsMatrix.js +56 -0
- package/cjs/UpSetChart/components/IntersectionsMatrix/index.d.ts +1 -0
- package/cjs/UpSetChart/components/IntersectionsMatrix/index.js +5 -0
- package/cjs/UpSetChart/components/IntersectionsMatrix/styles.d.ts +1 -0
- package/cjs/UpSetChart/components/IntersectionsMatrix/styles.js +27 -0
- package/cjs/UpSetChart/components/SetsChart/SetsChart.d.ts +15 -0
- package/cjs/UpSetChart/components/SetsChart/SetsChart.js +58 -0
- package/cjs/UpSetChart/components/SetsChart/index.d.ts +1 -0
- package/cjs/UpSetChart/components/SetsChart/index.js +5 -0
- package/cjs/UpSetChart/components/SetsChart/styles.d.ts +1 -0
- package/cjs/UpSetChart/components/SetsChart/styles.js +43 -0
- package/cjs/UpSetChart/components/SetsChartAxis/SetsChartAxis.d.ts +6 -0
- package/cjs/UpSetChart/components/SetsChartAxis/SetsChartAxis.js +20 -0
- package/cjs/UpSetChart/components/SetsChartAxis/index.d.ts +1 -0
- package/cjs/UpSetChart/components/SetsChartAxis/index.js +5 -0
- package/cjs/UpSetChart/components/SetsChartAxis/styles.d.ts +1 -0
- package/cjs/UpSetChart/components/SetsChartAxis/styles.js +17 -0
- package/cjs/UpSetChart/constants.d.ts +16 -3
- package/cjs/UpSetChart/constants.js +20 -4
- package/cjs/UpSetChart/gameOfThrones.test-data.d.ts +4 -0
- package/cjs/UpSetChart/gameOfThrones.test-data.js +26 -0
- package/cjs/UpSetChart/helpers.d.ts +20 -0
- package/cjs/UpSetChart/helpers.js +127 -0
- package/cjs/UpSetChart/styles.d.ts +4 -1
- package/cjs/UpSetChart/styles.js +11 -12
- package/cjs/UpSetChart/types.d.ts +16 -0
- package/cjs/UpSetChart/types.js +2 -0
- package/cjs/UpSetChart/useUpSetChartSizes.d.ts +20 -0
- package/cjs/UpSetChart/useUpSetChartSizes.js +34 -0
- package/esm/UpSetChart/UpSetChart.d.ts +5 -8
- package/esm/UpSetChart/UpSetChart.js +38 -5
- package/esm/UpSetChart/UpSetChart.test.d.ts +1 -0
- package/esm/UpSetChart/UpSetChart.test.js +193 -0
- package/esm/UpSetChart/components/IntersectionsChart/IntersectionsChart.d.ts +15 -0
- package/esm/UpSetChart/components/IntersectionsChart/IntersectionsChart.js +39 -0
- package/esm/UpSetChart/components/IntersectionsChart/index.d.ts +1 -0
- package/esm/UpSetChart/components/IntersectionsChart/index.js +1 -0
- package/esm/UpSetChart/components/IntersectionsChart/styles.d.ts +1 -0
- package/esm/UpSetChart/components/IntersectionsChart/styles.js +29 -0
- package/esm/UpSetChart/components/IntersectionsChartAxis/IntersectionsChartAxis.d.ts +10 -0
- package/esm/UpSetChart/components/IntersectionsChartAxis/IntersectionsChartAxis.js +34 -0
- package/esm/UpSetChart/components/IntersectionsChartAxis/index.d.ts +1 -0
- package/esm/UpSetChart/components/IntersectionsChartAxis/index.js +1 -0
- package/esm/UpSetChart/components/IntersectionsChartAxis/styles.d.ts +1 -0
- package/esm/UpSetChart/components/IntersectionsChartAxis/styles.js +29 -0
- package/esm/UpSetChart/components/IntersectionsMatrix/IntersectionsMatrix.d.ts +13 -0
- package/esm/UpSetChart/components/IntersectionsMatrix/IntersectionsMatrix.js +26 -0
- package/esm/UpSetChart/components/IntersectionsMatrix/index.d.ts +1 -0
- package/esm/UpSetChart/components/IntersectionsMatrix/index.js +1 -0
- package/esm/UpSetChart/components/IntersectionsMatrix/styles.d.ts +1 -0
- package/esm/UpSetChart/components/IntersectionsMatrix/styles.js +24 -0
- package/esm/UpSetChart/components/SetsChart/SetsChart.d.ts +15 -0
- package/esm/UpSetChart/components/SetsChart/SetsChart.js +31 -0
- package/esm/UpSetChart/components/SetsChart/index.d.ts +1 -0
- package/esm/UpSetChart/components/SetsChart/index.js +1 -0
- package/esm/UpSetChart/components/SetsChart/styles.d.ts +1 -0
- package/esm/UpSetChart/components/SetsChart/styles.js +40 -0
- package/esm/UpSetChart/components/SetsChartAxis/SetsChartAxis.d.ts +6 -0
- package/esm/UpSetChart/components/SetsChartAxis/SetsChartAxis.js +13 -0
- package/esm/UpSetChart/components/SetsChartAxis/index.d.ts +1 -0
- package/esm/UpSetChart/components/SetsChartAxis/index.js +1 -0
- package/esm/UpSetChart/components/SetsChartAxis/styles.d.ts +1 -0
- package/esm/UpSetChart/components/SetsChartAxis/styles.js +14 -0
- package/esm/UpSetChart/constants.d.ts +16 -3
- package/esm/UpSetChart/constants.js +19 -3
- package/esm/UpSetChart/gameOfThrones.test-data.d.ts +4 -0
- package/esm/UpSetChart/gameOfThrones.test-data.js +23 -0
- package/esm/UpSetChart/helpers.d.ts +20 -0
- package/esm/UpSetChart/helpers.js +120 -0
- package/esm/UpSetChart/styles.d.ts +4 -1
- package/esm/UpSetChart/styles.js +11 -12
- package/esm/UpSetChart/types.d.ts +16 -0
- package/esm/UpSetChart/types.js +1 -0
- package/esm/UpSetChart/useUpSetChartSizes.d.ts +20 -0
- package/esm/UpSetChart/useUpSetChartSizes.js +30 -0
- package/package.json +1 -1
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
|
|
3
|
-
name: string;
|
|
4
|
-
sets: string[];
|
|
5
|
-
};
|
|
2
|
+
import { UpSetChartData } from './types';
|
|
6
3
|
type Props = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
data: UpSetChartData;
|
|
5
|
+
width?: number;
|
|
6
|
+
height?: number;
|
|
10
7
|
};
|
|
11
|
-
export declare const UpSetChart: ({ width, height
|
|
8
|
+
export declare const UpSetChart: ({ data, width, height }: Props) => React.JSX.Element;
|
|
12
9
|
export {};
|
|
@@ -1,14 +1,70 @@
|
|
|
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
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.UpSetChart = void 0;
|
|
7
|
-
var react_1 =
|
|
30
|
+
var react_1 = __importStar(require("react"));
|
|
31
|
+
var d3_scale_1 = require("d3-scale");
|
|
32
|
+
var Tooltip_1 = __importDefault(require("@mui/material/Tooltip"));
|
|
33
|
+
var SetsChart_1 = require("./components/SetsChart");
|
|
34
|
+
var IntersectionsMatrix_1 = require("./components/IntersectionsMatrix");
|
|
35
|
+
var IntersectionsChart_1 = require("./components/IntersectionsChart");
|
|
36
|
+
var useUpSetChartSizes_1 = require("./useUpSetChartSizes");
|
|
37
|
+
var constants_1 = require("./constants");
|
|
38
|
+
var helpers_1 = require("./helpers");
|
|
39
|
+
var styles_1 = require("./styles");
|
|
8
40
|
var UpSetChart = function (_a) {
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
41
|
+
var data = _a.data, width = _a.width, height = _a.height;
|
|
42
|
+
var styles = (0, styles_1.useStyles)({ width: width, height: height });
|
|
43
|
+
var containerRef = (0, react_1.useRef)(null);
|
|
44
|
+
var _b = (0, react_1.useState)(null), hoveredSet = _b[0], setHoveredSet = _b[1];
|
|
45
|
+
var _c = (0, react_1.useState)(null), hoveredIntersection = _c[0], setHoveredIntersection = _c[1];
|
|
46
|
+
var _d = (0, react_1.useState)([width, height]), _e = _d[0], availableWidth = _e[0], availableHeight = _e[1], setAvailableSize = _d[1];
|
|
47
|
+
var _f = (0, react_1.useMemo)(function () { return (0, helpers_1.findIntersections)(data); }, [data]), intersections = _f.intersections, sets = _f.sets;
|
|
48
|
+
var hoveredElements = (hoveredIntersection === null || hoveredIntersection === void 0 ? void 0 : hoveredIntersection.elements) || (hoveredSet === null || hoveredSet === void 0 ? void 0 : hoveredSet.elements);
|
|
49
|
+
var tooltipTitle = hoveredIntersection === null || hoveredIntersection === void 0 ? void 0 : hoveredIntersection.sets.join(' ∩ ');
|
|
50
|
+
var _g = (0, useUpSetChartSizes_1.useUpSetChartSizes)({ width: availableWidth, height: availableHeight, intersections: intersections, sets: sets }), labels = _g.labels, svgWidth = _g.svgWidth, svgHeight = _g.svgHeight, intersectionsChartWidth = _g.intersectionsChartWidth, intersectionsChartHeight = _g.intersectionsChartHeight, matrixY = _g.matrixY, matrixHeight = _g.matrixHeight, setsChartWidth = _g.setsChartWidth, leftPadding = _g.leftPadding;
|
|
51
|
+
var matrixXScale = (0, react_1.useMemo)(function () {
|
|
52
|
+
var domain = intersections.map(function (_, i) { return String(i); });
|
|
53
|
+
return (0, d3_scale_1.scaleBand)([0, intersectionsChartWidth]).domain(domain).paddingInner(0.2);
|
|
54
|
+
}, [intersections, intersectionsChartWidth]);
|
|
55
|
+
var matrixYScale = (0, react_1.useMemo)(function () {
|
|
56
|
+
var domain = sets.map(function (set) { return set.name; });
|
|
57
|
+
return (0, d3_scale_1.scaleBand)([0, matrixHeight]).domain(domain);
|
|
58
|
+
}, [sets, matrixHeight]);
|
|
59
|
+
(0, react_1.useEffect)(function () {
|
|
60
|
+
var _a = containerRef.current || {}, clientWidth = _a.clientWidth, clientHeight = _a.clientHeight;
|
|
61
|
+
setAvailableSize([clientWidth || width, clientHeight || height]);
|
|
62
|
+
}, [width, height]);
|
|
63
|
+
return (react_1.default.createElement("div", { ref: containerRef, className: styles.wrapper },
|
|
64
|
+
react_1.default.createElement(Tooltip_1.default, { title: tooltipTitle, followCursor: true },
|
|
65
|
+
react_1.default.createElement("svg", { className: styles.svg, width: svgWidth, height: svgHeight },
|
|
66
|
+
react_1.default.createElement(IntersectionsMatrix_1.IntersectionsMatrix, { xScale: matrixXScale, yScale: matrixYScale, intersections: intersections, sets: sets, transform: "translate(".concat(leftPadding, ",").concat(matrixY, ")"), hoveredIntersection: hoveredIntersection }),
|
|
67
|
+
react_1.default.createElement(SetsChart_1.SetsChart, { yScale: matrixYScale, width: setsChartWidth, sets: sets, labels: labels, hoveredElements: hoveredElements, hoverAreaWidth: svgWidth, transform: "translate(".concat(constants_1.GAP_BEFORE_LEFT_BAR, ",").concat(matrixY, ")"), onSetHover: setHoveredSet }),
|
|
68
|
+
react_1.default.createElement(IntersectionsChart_1.IntersectionsChart, { xScale: matrixXScale, width: intersectionsChartWidth, height: intersectionsChartHeight, intersections: intersections, highlightedElements: hoveredElements, transform: "translate(".concat(leftPadding, ",").concat(constants_1.TOP_GAP, ")"), matrixHeight: matrixHeight, onIntersectionHover: setHoveredIntersection })))));
|
|
13
69
|
};
|
|
14
70
|
exports.UpSetChart = UpSetChart;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
var react_1 = __importDefault(require("react"));
|
|
54
|
+
var react_2 = require("@testing-library/react");
|
|
55
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
56
|
+
var gameOfThrones_test_data_1 = require("./gameOfThrones.test-data");
|
|
57
|
+
var UpSetChart_1 = require("./UpSetChart");
|
|
58
|
+
var originalGetBBox = Object.getOwnPropertyDescriptor(SVGElement.prototype, 'getBBox');
|
|
59
|
+
describe('UpSetChart', function () {
|
|
60
|
+
beforeAll(function () {
|
|
61
|
+
Object.defineProperty(SVGElement.prototype, 'getBBox', {
|
|
62
|
+
configurable: true,
|
|
63
|
+
value: function () { return ({ x: 0, y: 0, width: 150 }); }
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
afterAll(function () {
|
|
67
|
+
Object.defineProperty(SVGElement.prototype, 'getBBox', { value: originalGetBBox });
|
|
68
|
+
});
|
|
69
|
+
var setUp = function (_a) {
|
|
70
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.data, data = _c === void 0 ? gameOfThrones_test_data_1.gameOfThronesData : _c, _d = _b.width, width = _d === void 0 ? 1400 : _d, _e = _b.height, height = _e === void 0 ? 400 : _e;
|
|
71
|
+
var user = user_event_1.default.setup();
|
|
72
|
+
return __assign({ user: user }, (0, react_2.render)(react_1.default.createElement(UpSetChart_1.UpSetChart, { data: data, width: width, height: height })));
|
|
73
|
+
};
|
|
74
|
+
it('should work fine with complex data', function () {
|
|
75
|
+
var asFragment = setUp().asFragment;
|
|
76
|
+
expect(asFragment()).toMatchSnapshot();
|
|
77
|
+
});
|
|
78
|
+
it('should truncate labels and add scrollbar when chart not fit in width', function () {
|
|
79
|
+
var asFragment = setUp({ width: 800 }).asFragment;
|
|
80
|
+
expect(asFragment()).toMatchSnapshot();
|
|
81
|
+
});
|
|
82
|
+
it('should add scrollbar when chart not fit in height', function () {
|
|
83
|
+
var asFragment = setUp({ width: 200 }).asFragment;
|
|
84
|
+
expect(asFragment()).toMatchSnapshot();
|
|
85
|
+
});
|
|
86
|
+
it('should highlight intersection column on hover', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
87
|
+
var _a, user, asFragment, _b, maleAndWasKilled;
|
|
88
|
+
return __generator(this, function (_c) {
|
|
89
|
+
switch (_c.label) {
|
|
90
|
+
case 0:
|
|
91
|
+
_a = setUp(), user = _a.user, asFragment = _a.asFragment;
|
|
92
|
+
_b = react_2.screen.getAllByTestId('intersection-hover-area'), maleAndWasKilled = _b[2];
|
|
93
|
+
return [4 /*yield*/, user.hover(maleAndWasKilled)];
|
|
94
|
+
case 1:
|
|
95
|
+
_c.sent();
|
|
96
|
+
expect(asFragment()).toMatchSnapshot();
|
|
97
|
+
return [2 /*return*/];
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}); });
|
|
101
|
+
it('should highlight set row on hover', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
102
|
+
var _a, user, asFragment, _b, lannister;
|
|
103
|
+
return __generator(this, function (_c) {
|
|
104
|
+
switch (_c.label) {
|
|
105
|
+
case 0:
|
|
106
|
+
_a = setUp(), user = _a.user, asFragment = _a.asFragment;
|
|
107
|
+
_b = react_2.screen.getAllByTestId('set-hover-area'), lannister = _b[1];
|
|
108
|
+
return [4 /*yield*/, user.hover(lannister)];
|
|
109
|
+
case 1:
|
|
110
|
+
_c.sent();
|
|
111
|
+
expect(asFragment()).toMatchSnapshot();
|
|
112
|
+
return [2 /*return*/];
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}); });
|
|
116
|
+
it('should show correct tooltip on hover', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
117
|
+
var user, _a, wasKilled, maleAndWasKilled;
|
|
118
|
+
return __generator(this, function (_b) {
|
|
119
|
+
switch (_b.label) {
|
|
120
|
+
case 0:
|
|
121
|
+
user = setUp().user;
|
|
122
|
+
expect(react_2.screen.queryByRole('tooltip')).not.toBeInTheDocument();
|
|
123
|
+
_a = react_2.screen.getAllByTestId('intersection-hover-area'), wasKilled = _a[0], maleAndWasKilled = _a[2];
|
|
124
|
+
return [4 /*yield*/, user.hover(wasKilled)];
|
|
125
|
+
case 1:
|
|
126
|
+
_b.sent();
|
|
127
|
+
expect(react_2.screen.getByRole('tooltip').textContent).toBe('was killed');
|
|
128
|
+
return [4 /*yield*/, user.hover(maleAndWasKilled)];
|
|
129
|
+
case 2:
|
|
130
|
+
_b.sent();
|
|
131
|
+
expect(react_2.screen.getByRole('tooltip').textContent).toBe('male ∩ was killed');
|
|
132
|
+
return [4 /*yield*/, user.unhover(maleAndWasKilled)];
|
|
133
|
+
case 3:
|
|
134
|
+
_b.sent();
|
|
135
|
+
expect(react_2.screen.queryByRole('tooltip')).not.toBeInTheDocument();
|
|
136
|
+
return [2 /*return*/];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
}); });
|
|
140
|
+
it('should work correctly with simple data', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
141
|
+
var data, _a, user, asFragment;
|
|
142
|
+
return __generator(this, function (_b) {
|
|
143
|
+
switch (_b.label) {
|
|
144
|
+
case 0:
|
|
145
|
+
data = [
|
|
146
|
+
{ name: 'A', sets: ['S1', 'S2'] },
|
|
147
|
+
{ name: 'B', sets: ['S1'] },
|
|
148
|
+
{ name: 'C', sets: ['S2'] },
|
|
149
|
+
{ name: 'D', sets: ['S1', 'S3'] }
|
|
150
|
+
];
|
|
151
|
+
_a = setUp({ data: data, width: 400, height: 300 }), user = _a.user, asFragment = _a.asFragment;
|
|
152
|
+
expect(asFragment()).toMatchSnapshot();
|
|
153
|
+
return [4 /*yield*/, user.hover(react_2.screen.getAllByTestId('set-hover-area')[0])];
|
|
154
|
+
case 1:
|
|
155
|
+
_b.sent();
|
|
156
|
+
expect(asFragment()).toMatchSnapshot();
|
|
157
|
+
return [2 /*return*/];
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}); });
|
|
161
|
+
it('should work correctly with long labels', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
162
|
+
var data, asFragment;
|
|
163
|
+
return __generator(this, function (_a) {
|
|
164
|
+
data = [
|
|
165
|
+
{ name: 'A', sets: ['S1', 'S2'] },
|
|
166
|
+
{ name: 'B', sets: ['S1'] },
|
|
167
|
+
{ name: 'C', sets: ['S2'] },
|
|
168
|
+
{ name: 'D', sets: ['S1', 'S3testS3testS3testS3test'] }
|
|
169
|
+
];
|
|
170
|
+
asFragment = setUp({ data: data, width: 400, height: 300 }).asFragment;
|
|
171
|
+
expect(asFragment()).toMatchSnapshot();
|
|
172
|
+
return [2 /*return*/];
|
|
173
|
+
});
|
|
174
|
+
}); });
|
|
175
|
+
it('should work correctly with one set', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
176
|
+
var data, asFragment;
|
|
177
|
+
return __generator(this, function (_a) {
|
|
178
|
+
data = [
|
|
179
|
+
{ name: 'A', sets: ['S1'] },
|
|
180
|
+
{ name: 'B', sets: ['S1'] },
|
|
181
|
+
{ name: 'C', sets: ['S1'] },
|
|
182
|
+
{ name: 'D', sets: ['S1'] }
|
|
183
|
+
];
|
|
184
|
+
asFragment = setUp({ data: data, width: 400, height: 300 }).asFragment;
|
|
185
|
+
expect(asFragment()).toMatchSnapshot();
|
|
186
|
+
return [2 /*return*/];
|
|
187
|
+
});
|
|
188
|
+
}); });
|
|
189
|
+
it('should work correctly with one entry', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
190
|
+
var data, asFragment;
|
|
191
|
+
return __generator(this, function (_a) {
|
|
192
|
+
data = [{ name: 'A', sets: ['S1', 'S2', 'S3'] }];
|
|
193
|
+
asFragment = setUp({ data: data, width: 400, height: 300 }).asFragment;
|
|
194
|
+
expect(asFragment()).toMatchSnapshot();
|
|
195
|
+
return [2 /*return*/];
|
|
196
|
+
});
|
|
197
|
+
}); });
|
|
198
|
+
});
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScaleBand } from 'd3-scale';
|
|
3
|
+
import { Intersection } from '../../types';
|
|
4
|
+
type Props = {
|
|
5
|
+
xScale: ScaleBand<string>;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
transform?: string;
|
|
9
|
+
matrixHeight: number;
|
|
10
|
+
intersections: Intersection[];
|
|
11
|
+
highlightedElements?: string[];
|
|
12
|
+
onIntersectionHover: (intersection: Intersection) => void;
|
|
13
|
+
};
|
|
14
|
+
export declare const IntersectionsChart: ({ xScale, width, height, transform, matrixHeight, intersections, highlightedElements, onIntersectionHover }: Props) => React.JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
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 __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
26
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
27
|
+
if (ar || !(i in from)) {
|
|
28
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
29
|
+
ar[i] = from[i];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.IntersectionsChart = void 0;
|
|
36
|
+
var react_1 = __importStar(require("react"));
|
|
37
|
+
var d3_scale_1 = require("d3-scale");
|
|
38
|
+
var IntersectionsChartAxis_1 = require("../IntersectionsChartAxis");
|
|
39
|
+
var constants_1 = require("../../constants");
|
|
40
|
+
var styles_1 = require("./styles");
|
|
41
|
+
var IntersectionsChart = function (_a) {
|
|
42
|
+
var xScale = _a.xScale, width = _a.width, height = _a.height, transform = _a.transform, matrixHeight = _a.matrixHeight, intersections = _a.intersections, highlightedElements = _a.highlightedElements, onIntersectionHover = _a.onIntersectionHover;
|
|
43
|
+
var styles = (0, styles_1.useStyles)();
|
|
44
|
+
var yScale = (0, react_1.useMemo)(function () {
|
|
45
|
+
var intersectionsSizes = intersections.map(function (intersection) { return intersection.size; });
|
|
46
|
+
var domain = [0, Math.max.apply(Math, __spreadArray([0], intersectionsSizes, false))];
|
|
47
|
+
return (0, d3_scale_1.scaleLinear)([height, 0]).domain(domain);
|
|
48
|
+
}, [intersections, height]);
|
|
49
|
+
return (react_1.default.createElement("g", { transform: transform },
|
|
50
|
+
react_1.default.createElement(IntersectionsChartAxis_1.IntersectionsChartAxis, { xScale: xScale, yScale: yScale, width: width, height: height }),
|
|
51
|
+
intersections.map(function (intersection, i) {
|
|
52
|
+
var elements = intersection.elements, size = intersection.size;
|
|
53
|
+
var x = xScale(String(i));
|
|
54
|
+
var y = yScale(size);
|
|
55
|
+
var width = xScale.bandwidth();
|
|
56
|
+
var barY = highlightedElements
|
|
57
|
+
? yScale(elements.filter(function (el) { return highlightedElements.includes(el); }).length)
|
|
58
|
+
: y;
|
|
59
|
+
return (react_1.default.createElement("g", { key: "intersection-group-".concat(i) },
|
|
60
|
+
react_1.default.createElement("rect", { className: styles.barBackground, x: x, y: y, width: width, height: height - y }),
|
|
61
|
+
react_1.default.createElement("text", { className: styles.barLabel, x: x + width / 2, y: y - 4 }, size),
|
|
62
|
+
react_1.default.createElement("rect", { className: styles.bar, x: x, y: barY, width: width, height: height - barY }),
|
|
63
|
+
react_1.default.createElement("rect", { className: styles.hoverBar, "data-reltio-id": "intersection-hover-area", x: x, y: y, width: width, height: height - y + matrixHeight + constants_1.GAP_BETWEEN_TABLE_AND_CHART - 1, onMouseEnter: function () { return onIntersectionHover(intersection); }, onMouseLeave: function () { return onIntersectionHover(null); } })));
|
|
64
|
+
})));
|
|
65
|
+
};
|
|
66
|
+
exports.IntersectionsChart = IntersectionsChart;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { IntersectionsChart } from './IntersectionsChart';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntersectionsChart = void 0;
|
|
4
|
+
var IntersectionsChart_1 = require("./IntersectionsChart");
|
|
5
|
+
Object.defineProperty(exports, "IntersectionsChart", { enumerable: true, get: function () { return IntersectionsChart_1.IntersectionsChart; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"bar" | "hoverBar" | "barBackground" | "barLabel">;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStyles = void 0;
|
|
4
|
+
var styles_1 = require("@mui/styles");
|
|
5
|
+
var constants_1 = require("../../constants");
|
|
6
|
+
exports.useStyles = (0, styles_1.makeStyles)(function () { return ({
|
|
7
|
+
bar: {
|
|
8
|
+
fill: constants_1.PRIMARY_COLOR,
|
|
9
|
+
transition: 'y ease-in-out 0.3s, height ease-in-out 0.3s'
|
|
10
|
+
},
|
|
11
|
+
barBackground: {
|
|
12
|
+
fill: constants_1.PRIMARY_COLOR,
|
|
13
|
+
opacity: 0.2,
|
|
14
|
+
transition: 'y ease-in-out 0.3s, height ease-in-out 0.3s'
|
|
15
|
+
},
|
|
16
|
+
barLabel: {
|
|
17
|
+
fill: constants_1.TEXT_COLOR,
|
|
18
|
+
fontSize: '12px',
|
|
19
|
+
textAnchor: 'middle'
|
|
20
|
+
},
|
|
21
|
+
hoverBar: {
|
|
22
|
+
fill: 'transparent',
|
|
23
|
+
stroke: constants_1.PRIMARY_COLOR,
|
|
24
|
+
strokeWidth: '1px',
|
|
25
|
+
cursor: 'pointer',
|
|
26
|
+
transition: 'opacity ease-in-out 0.3s',
|
|
27
|
+
opacity: 0,
|
|
28
|
+
'&:hover': {
|
|
29
|
+
opacity: 1
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}); });
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScaleBand, ScaleLinear } from 'd3-scale';
|
|
3
|
+
type Props = {
|
|
4
|
+
xScale: ScaleBand<string>;
|
|
5
|
+
yScale: ScaleLinear<number, number>;
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const IntersectionsChartAxis: ({ xScale, yScale, width, height }: Props) => React.JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
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
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.IntersectionsChartAxis = void 0;
|
|
30
|
+
var react_1 = __importStar(require("react"));
|
|
31
|
+
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
32
|
+
var styles_1 = require("./styles");
|
|
33
|
+
var helpers_1 = require("../../helpers");
|
|
34
|
+
var IntersectionsChartAxis = function (_a) {
|
|
35
|
+
var xScale = _a.xScale, yScale = _a.yScale, width = _a.width, height = _a.height;
|
|
36
|
+
var styles = (0, styles_1.useStyles)();
|
|
37
|
+
var ticksRef = (0, react_1.useRef)(null);
|
|
38
|
+
var ticks = (0, react_1.useMemo)(function () {
|
|
39
|
+
return yScale
|
|
40
|
+
.nice()
|
|
41
|
+
.ticks()
|
|
42
|
+
.filter(function (tick) { return Number.isInteger(tick); });
|
|
43
|
+
}, [yScale]);
|
|
44
|
+
var ticksWidth = (0, react_1.useMemo)(function () { return (0, helpers_1.calculateTicksWidth)(ticks); }, [ticks]);
|
|
45
|
+
return (react_1.default.createElement("g", null,
|
|
46
|
+
xScale.domain().map(function (d, i) {
|
|
47
|
+
var x = xScale(d) + xScale.bandwidth() / 2;
|
|
48
|
+
return react_1.default.createElement("line", { key: "v-grid-".concat(i), className: styles.verticalGrid, x1: x, x2: x, y1: 0, y2: height });
|
|
49
|
+
}),
|
|
50
|
+
ticks.map(function (tick, i) {
|
|
51
|
+
var y = yScale(tick);
|
|
52
|
+
return react_1.default.createElement("line", { key: "h-grid-".concat(i), className: styles.horizontalGrid, x1: 0, x2: width, y1: y, y2: y });
|
|
53
|
+
}),
|
|
54
|
+
react_1.default.createElement("g", { ref: ticksRef }, ticks.map(function (tick, i) {
|
|
55
|
+
var y = yScale(tick);
|
|
56
|
+
return (react_1.default.createElement("g", { key: "x-tick-".concat(i), transform: "translate(0,".concat(y, ")") },
|
|
57
|
+
react_1.default.createElement("line", { className: styles.axis, x1: -4, x2: 0, y1: 0, y2: 0 }),
|
|
58
|
+
react_1.default.createElement("text", { className: styles.axisTickLabel, x: -8, y: 4 }, tick)));
|
|
59
|
+
})),
|
|
60
|
+
react_1.default.createElement("line", { className: styles.axis, x1: 0, x2: 0, y1: 0, y2: height }),
|
|
61
|
+
react_1.default.createElement("line", { className: styles.axis, x1: 0, x2: width, y1: height, y2: height }),
|
|
62
|
+
react_1.default.createElement("text", { className: styles.axisLabel, transform: "translate(".concat(-ticksWidth - 12, ",").concat(height / 2, ") rotate(-90)") }, ui_i18n_1.default.text('No. of unified profiles'))));
|
|
63
|
+
};
|
|
64
|
+
exports.IntersectionsChartAxis = IntersectionsChartAxis;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { IntersectionsChartAxis } from './IntersectionsChartAxis';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntersectionsChartAxis = void 0;
|
|
4
|
+
var IntersectionsChartAxis_1 = require("./IntersectionsChartAxis");
|
|
5
|
+
Object.defineProperty(exports, "IntersectionsChartAxis", { enumerable: true, get: function () { return IntersectionsChartAxis_1.IntersectionsChartAxis; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"axis" | "axisTickLabel" | "axisLabel" | "verticalGrid" | "horizontalGrid">;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStyles = void 0;
|
|
4
|
+
var styles_1 = require("@mui/styles");
|
|
5
|
+
var constants_1 = require("../../constants");
|
|
6
|
+
exports.useStyles = (0, styles_1.makeStyles)(function () { return ({
|
|
7
|
+
axis: {
|
|
8
|
+
stroke: '#000000',
|
|
9
|
+
strokeWidth: '1px'
|
|
10
|
+
},
|
|
11
|
+
axisLabel: {
|
|
12
|
+
fill: '#000000',
|
|
13
|
+
opacity: 0.54,
|
|
14
|
+
fontSize: '10px',
|
|
15
|
+
textAnchor: 'middle'
|
|
16
|
+
},
|
|
17
|
+
axisTickLabel: {
|
|
18
|
+
fontSize: constants_1.AXIS_TICK_LABEL_SIZE,
|
|
19
|
+
textAnchor: 'end'
|
|
20
|
+
},
|
|
21
|
+
verticalGrid: {
|
|
22
|
+
stroke: '#000000',
|
|
23
|
+
opacity: 0.04,
|
|
24
|
+
strokeWidth: '1px',
|
|
25
|
+
strokeDasharray: '2'
|
|
26
|
+
},
|
|
27
|
+
horizontalGrid: {
|
|
28
|
+
stroke: '#000000',
|
|
29
|
+
opacity: 0.04,
|
|
30
|
+
strokeWidth: '1px'
|
|
31
|
+
}
|
|
32
|
+
}); });
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ScaleBand } from 'd3-scale';
|
|
3
|
+
import { DataSet, Intersection } from '../../types';
|
|
4
|
+
type Props = {
|
|
5
|
+
xScale: ScaleBand<string>;
|
|
6
|
+
yScale: ScaleBand<string>;
|
|
7
|
+
intersections: Intersection[];
|
|
8
|
+
sets: DataSet[];
|
|
9
|
+
transform: string;
|
|
10
|
+
hoveredIntersection: Intersection;
|
|
11
|
+
};
|
|
12
|
+
export declare const IntersectionsMatrix: ({ xScale, yScale, intersections, sets, transform, hoveredIntersection }: Props) => React.JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.IntersectionsMatrix = void 0;
|
|
30
|
+
var react_1 = __importStar(require("react"));
|
|
31
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
32
|
+
var helpers_1 = require("../../helpers");
|
|
33
|
+
var styles_1 = require("./styles");
|
|
34
|
+
var IntersectionsMatrix = function (_a) {
|
|
35
|
+
var xScale = _a.xScale, yScale = _a.yScale, intersections = _a.intersections, sets = _a.sets, transform = _a.transform, hoveredIntersection = _a.hoveredIntersection;
|
|
36
|
+
var styles = (0, styles_1.useStyles)();
|
|
37
|
+
var _b = (0, react_1.useMemo)(function () { return (0, helpers_1.getMatrixData)(xScale, yScale, intersections, sets); }, [xScale, yScale, intersections, sets]), circles = _b.circles, lines = _b.lines;
|
|
38
|
+
var checkDimmed = function (i) { return hoveredIntersection && hoveredIntersection.index !== i; };
|
|
39
|
+
return (react_1.default.createElement("g", { transform: transform },
|
|
40
|
+
circles.map(function (_a, i) {
|
|
41
|
+
var _b;
|
|
42
|
+
var cx = _a.cx, cy = _a.cy, isPresent = _a.isPresent, intersectionIndex = _a.intersectionIndex;
|
|
43
|
+
return (react_1.default.createElement("circle", { key: "matrix-circle-".concat(i), cx: cx, cy: cy, r: 8, className: (0, classnames_1.default)(styles.circle, (_b = {},
|
|
44
|
+
_b[styles.activeCircle] = isPresent,
|
|
45
|
+
_b[styles.dimmedCircle] = isPresent && checkDimmed(intersectionIndex),
|
|
46
|
+
_b)) }));
|
|
47
|
+
}),
|
|
48
|
+
lines.map(function (_a, i) {
|
|
49
|
+
var _b;
|
|
50
|
+
var x = _a.x, y1 = _a.y1, y2 = _a.y2, intersectionIndex = _a.intersectionIndex;
|
|
51
|
+
return (react_1.default.createElement("line", { key: "matrix-line-".concat(i), x1: x, y1: y1, x2: x, y2: y2, className: (0, classnames_1.default)(styles.link, (_b = {},
|
|
52
|
+
_b[styles.dimmedLine] = checkDimmed(intersectionIndex),
|
|
53
|
+
_b)) }));
|
|
54
|
+
})));
|
|
55
|
+
};
|
|
56
|
+
exports.IntersectionsMatrix = IntersectionsMatrix;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { IntersectionsMatrix } from './IntersectionsMatrix';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IntersectionsMatrix = void 0;
|
|
4
|
+
var IntersectionsMatrix_1 = require("./IntersectionsMatrix");
|
|
5
|
+
Object.defineProperty(exports, "IntersectionsMatrix", { enumerable: true, get: function () { return IntersectionsMatrix_1.IntersectionsMatrix; } });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"circle" | "link" | "activeCircle" | "dimmedCircle" | "dimmedLine">;
|