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