@reltio/components 1.4.1956 → 1.4.1958

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 (53) hide show
  1. package/cjs/AttributesFiltersBuilder/AttributesFiltersBuilder.js +1 -1
  2. package/cjs/AttributesFiltersBuilder/helpers.d.ts +1 -1
  3. package/cjs/AttributesFiltersBuilder/helpers.js +25 -22
  4. package/cjs/AttributesFiltersButton/AttributesFiltersButton.js +1 -1
  5. package/cjs/AttributesFiltersButton/components/ActionButtons/styles.js +2 -2
  6. package/cjs/AttributesFiltersButton/styles.d.ts +1 -1
  7. package/cjs/AttributesFiltersButton/styles.js +10 -7
  8. package/cjs/CustomDateRangeEditor/CustomDateRangeEditor.js +1 -1
  9. package/cjs/DateIntervalSelector/DateIntervalSelector.js +1 -1
  10. package/cjs/DateRangeSelector/DateRangeSelector.d.ts +9 -0
  11. package/cjs/DateRangeSelector/DateRangeSelector.js +144 -0
  12. package/cjs/DateRangeSelector/DateRangeSelector.specs.js +294 -0
  13. package/cjs/DateRangeSelector/index.d.ts +1 -0
  14. package/cjs/DateRangeSelector/index.js +5 -0
  15. package/cjs/DateRangeSelector/styles.d.ts +1 -0
  16. package/cjs/DateRangeSelector/styles.js +30 -0
  17. package/cjs/UpSetChart/UpSetChart.js +3 -38
  18. package/cjs/features/activity-log/ActivityFilterEditor/components/DateRangeSelector/DateRangeSelector.js +3 -108
  19. package/cjs/features/activity-log/ActivityFilterEditor/components/DateRangeSelector/styles.d.ts +1 -1
  20. package/cjs/features/activity-log/ActivityFilterEditor/components/DateRangeSelector/styles.js +0 -54
  21. package/cjs/index.d.ts +1 -0
  22. package/cjs/index.js +6 -4
  23. package/esm/AttributesFiltersBuilder/AttributesFiltersBuilder.js +2 -2
  24. package/esm/AttributesFiltersBuilder/helpers.d.ts +1 -1
  25. package/esm/AttributesFiltersBuilder/helpers.js +24 -21
  26. package/esm/AttributesFiltersButton/AttributesFiltersButton.js +1 -1
  27. package/esm/AttributesFiltersButton/components/ActionButtons/styles.js +2 -2
  28. package/esm/AttributesFiltersButton/styles.d.ts +1 -1
  29. package/esm/AttributesFiltersButton/styles.js +10 -7
  30. package/esm/CustomDateRangeEditor/CustomDateRangeEditor.js +1 -1
  31. package/esm/DateIntervalSelector/DateIntervalSelector.js +1 -1
  32. package/esm/DateRangeSelector/DateRangeSelector.d.ts +9 -0
  33. package/esm/DateRangeSelector/DateRangeSelector.js +114 -0
  34. package/esm/DateRangeSelector/DateRangeSelector.specs.js +289 -0
  35. package/esm/DateRangeSelector/index.d.ts +1 -0
  36. package/esm/DateRangeSelector/index.js +1 -0
  37. package/esm/DateRangeSelector/styles.d.ts +1 -0
  38. package/esm/DateRangeSelector/styles.js +27 -0
  39. package/esm/UpSetChart/UpSetChart.js +3 -15
  40. package/esm/features/activity-log/ActivityFilterEditor/components/DateRangeSelector/DateRangeSelector.js +3 -85
  41. package/esm/features/activity-log/ActivityFilterEditor/components/DateRangeSelector/styles.d.ts +1 -1
  42. package/esm/features/activity-log/ActivityFilterEditor/components/DateRangeSelector/styles.js +0 -54
  43. package/esm/index.d.ts +1 -0
  44. package/esm/index.js +1 -0
  45. package/package.json +2 -6
  46. package/cjs/UpSetChart/UpSetChart.test.d.ts +0 -1
  47. package/cjs/UpSetChart/UpSetChart.test.js +0 -67
  48. package/cjs/features/activity-log/ActivityFilterEditor/components/DateRangeSelector/DateRangeSelector.specs.js +0 -185
  49. package/esm/UpSetChart/UpSetChart.test.d.ts +0 -1
  50. package/esm/UpSetChart/UpSetChart.test.js +0 -62
  51. package/esm/features/activity-log/ActivityFilterEditor/components/DateRangeSelector/DateRangeSelector.specs.js +0 -180
  52. /package/cjs/{features/activity-log/ActivityFilterEditor/components/DateRangeSelector → DateRangeSelector}/DateRangeSelector.specs.d.ts +0 -0
  53. /package/esm/{features/activity-log/ActivityFilterEditor/components/DateRangeSelector → DateRangeSelector}/DateRangeSelector.specs.d.ts +0 -0
@@ -0,0 +1,114 @@
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
+ import React, { useState } from 'react';
13
+ import i18n from 'ui-i18n';
14
+ import { pipe } from 'ramda';
15
+ import classnames from 'classnames';
16
+ import { DateRangeTypes } from '@reltio/mdm-sdk';
17
+ import FormControlLabel from '@mui/material/FormControlLabel';
18
+ import Radio from '@mui/material/Radio';
19
+ import RadioGroup from '@mui/material/RadioGroup';
20
+ import Typography from '@mui/material/Typography';
21
+ import { DateIntervalSelector } from '../DateIntervalSelector';
22
+ import { CustomDateRangeEditor } from '../CustomDateRangeEditor';
23
+ import { useDidUpdateEffect } from '../hooks/useDidUpdateEffect';
24
+ import { getValue } from '../helpers/events';
25
+ import { useStyles } from './styles';
26
+ var emptyDates = [null, null];
27
+ var emptyInterval = [null, 'minutes'];
28
+ export var DateRangeSelector = function (_a) {
29
+ var value = _a.value, onChange = _a.onChange, dateRangeTypes = _a.dateRangeTypes;
30
+ var styles = useStyles();
31
+ var getInitPeriodByType = function (type) {
32
+ if ((value === null || value === void 0 ? void 0 : value.type) === type) {
33
+ return value.period;
34
+ }
35
+ else if (type === DateRangeTypes.WITHIN || type === DateRangeTypes.AGO) {
36
+ return emptyInterval;
37
+ }
38
+ else if (type === DateRangeTypes.BETWEEN) {
39
+ return emptyDates;
40
+ }
41
+ };
42
+ var _b = useState(getInitPeriodByType(DateRangeTypes.BETWEEN)), datesInterval = _b[0], setDatesInterval = _b[1];
43
+ var _c = useState(getInitPeriodByType(DateRangeTypes.WITHIN)), withinInterval = _c[0], setWithinInterval = _c[1];
44
+ var _d = useState(getInitPeriodByType(DateRangeTypes.AGO)), agoInterval = _d[0], setAgoInterval = _d[1];
45
+ var getCurrentPeriodByType = function (type) {
46
+ if (type === DateRangeTypes.WITHIN) {
47
+ return withinInterval;
48
+ }
49
+ else if (type === DateRangeTypes.AGO) {
50
+ return agoInterval;
51
+ }
52
+ else if (type === DateRangeTypes.BETWEEN) {
53
+ return datesInterval;
54
+ }
55
+ };
56
+ var changeType = function (type) {
57
+ if ((value === null || value === void 0 ? void 0 : value.type) !== type) {
58
+ onChange({ period: getCurrentPeriodByType(type), type: type });
59
+ }
60
+ };
61
+ var changePeriod = function (period) {
62
+ onChange(__assign(__assign({}, value), { period: period }));
63
+ };
64
+ var isEditorVisible = function (_a) {
65
+ var type = _a.type;
66
+ return !dateRangeTypes || dateRangeTypes.includes(type);
67
+ };
68
+ useDidUpdateEffect(function () {
69
+ if (value) {
70
+ if (value.type === DateRangeTypes.WITHIN) {
71
+ setWithinInterval(value.period);
72
+ }
73
+ else if (value.type === DateRangeTypes.AGO) {
74
+ setAgoInterval(value.period);
75
+ }
76
+ else if (value.type === DateRangeTypes.BETWEEN) {
77
+ setDatesInterval(value.period);
78
+ }
79
+ }
80
+ else {
81
+ setDatesInterval(emptyDates);
82
+ setWithinInterval(emptyInterval);
83
+ setAgoInterval(emptyInterval);
84
+ }
85
+ }, [value]);
86
+ var editors = [
87
+ {
88
+ label: i18n.text('Within the last'),
89
+ type: DateRangeTypes.WITHIN,
90
+ editor: (React.createElement(DateIntervalSelector, { interval: withinInterval, onChange: changePeriod, onFocus: function () { return changeType(DateRangeTypes.WITHIN); } })),
91
+ className: styles.dateOptionWithin
92
+ },
93
+ {
94
+ label: i18n.text('More than'),
95
+ type: DateRangeTypes.AGO,
96
+ editor: (React.createElement(React.Fragment, null,
97
+ React.createElement(DateIntervalSelector, { interval: agoInterval, onChange: changePeriod, onFocus: function () { return changeType(DateRangeTypes.AGO); } }),
98
+ React.createElement(Typography, { className: styles.agoLabel, variant: 'subtitle1' }, i18n.text('Ago')))),
99
+ className: styles.dateOptionAgo
100
+ },
101
+ {
102
+ label: i18n.text('Date range'),
103
+ type: DateRangeTypes.BETWEEN,
104
+ editor: (React.createElement(CustomDateRangeEditor, { values: datesInterval, onChange: changePeriod, onFocus: function () { return changeType(DateRangeTypes.BETWEEN); } })),
105
+ className: styles.dateOption
106
+ }
107
+ ];
108
+ return (React.createElement(RadioGroup, { value: (value === null || value === void 0 ? void 0 : value.type) || null, onChange: pipe(getValue, changeType), "data-reltio-id": "reltio-date-range-selector" }, editors.filter(isEditorVisible).map(function (_a) {
109
+ var type = _a.type, editor = _a.editor, label = _a.label, className = _a.className;
110
+ return (React.createElement("div", { key: type, className: className },
111
+ React.createElement(FormControlLabel, { value: type, label: label, control: React.createElement(Radio, { color: "primary" }), classes: { label: classnames(styles.dateOptionLabel, styles.labels) } }),
112
+ editor));
113
+ })));
114
+ };
@@ -0,0 +1,289 @@
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;
23
+ return g = { next: verb(0), "throw": verb(1), "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 { DateRangeTypes } from '@reltio/mdm-sdk';
52
+ import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
53
+ import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
54
+ import { DateRangeSelector } from './DateRangeSelector';
55
+ describe('DateRangeSelector tests', function () {
56
+ var value = {
57
+ type: DateRangeTypes.WITHIN,
58
+ period: [4, 'months']
59
+ };
60
+ var defaultProps = { value: value, onChange: jest.fn() };
61
+ var setUp = function (props) {
62
+ if (props === void 0) { props = {}; }
63
+ var user = userEvent.setup();
64
+ var Providers = function (_a) {
65
+ var children = _a.children;
66
+ return (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment }, children));
67
+ };
68
+ return __assign({ user: user }, render(React.createElement(DateRangeSelector, __assign({}, defaultProps, props)), { wrapper: Providers }));
69
+ };
70
+ beforeEach(function () {
71
+ jest.clearAllMocks();
72
+ });
73
+ it('should render correct default state', function () {
74
+ setUp();
75
+ var radios = screen.getAllByRole('radio');
76
+ expect(radios).toHaveLength(3);
77
+ expect(radios[0]).toBeChecked();
78
+ var selectors = screen.getAllByTestId('date-interval-selector');
79
+ var valueEditors = screen.getAllByRole('spinbutton');
80
+ var periodSelectors = screen.getAllByRole('combobox');
81
+ expect(selectors).toHaveLength(2);
82
+ expect(valueEditors).toHaveLength(2);
83
+ expect(periodSelectors).toHaveLength(2);
84
+ screen.getByText('Within the last');
85
+ expect(valueEditors[0]).toHaveValue(4);
86
+ screen.getByText('Months');
87
+ screen.getByText('More than');
88
+ expect(valueEditors[1]).not.toHaveValue();
89
+ screen.getByText('Minutes');
90
+ screen.getByText('Ago');
91
+ screen.getByText('Date range');
92
+ screen.getByTestId('custom-date-range-editor');
93
+ });
94
+ it('should render correctly with empty value', function () {
95
+ setUp({ value: null });
96
+ var radios = screen.getAllByRole('radio');
97
+ expect(radios[0]).not.toBeChecked();
98
+ expect(radios[1]).not.toBeChecked();
99
+ expect(radios[2]).not.toBeChecked();
100
+ var selectors = screen.getAllByTestId('date-interval-selector');
101
+ var valueEditors = screen.getAllByRole('spinbutton');
102
+ var periodSelectors = screen.getAllByRole('combobox');
103
+ var selectorsValues = screen.getAllByText('Minutes');
104
+ expect(selectors).toHaveLength(2);
105
+ expect(valueEditors).toHaveLength(2);
106
+ expect(periodSelectors).toHaveLength(2);
107
+ expect(selectorsValues).toHaveLength(2);
108
+ screen.getByText('Within the last');
109
+ expect(valueEditors[0]).not.toHaveValue();
110
+ screen.getByText('More than');
111
+ expect(valueEditors[1]).not.toHaveValue();
112
+ screen.getByText('Ago');
113
+ screen.getByText('Date range');
114
+ screen.getByTestId('custom-date-range-editor');
115
+ });
116
+ describe('Within', function () {
117
+ it('should call props.onChange when type is changed to withing', function () { return __awaiter(void 0, void 0, void 0, function () {
118
+ var value, user;
119
+ return __generator(this, function (_a) {
120
+ switch (_a.label) {
121
+ case 0:
122
+ value = {
123
+ type: DateRangeTypes.AGO,
124
+ period: [4, 'months']
125
+ };
126
+ user = setUp({ value: value }).user;
127
+ return [4 /*yield*/, user.click(screen.getByLabelText('Within the last'))];
128
+ case 1:
129
+ _a.sent();
130
+ expect(defaultProps.onChange).toHaveBeenCalledWith({
131
+ type: DateRangeTypes.WITHIN,
132
+ period: [null, 'minutes']
133
+ });
134
+ return [2 /*return*/];
135
+ }
136
+ });
137
+ }); });
138
+ it('should call props.onChange when within number is changed', function () { return __awaiter(void 0, void 0, void 0, function () {
139
+ var user;
140
+ return __generator(this, function (_a) {
141
+ switch (_a.label) {
142
+ case 0:
143
+ user = setUp().user;
144
+ return [4 /*yield*/, user.type(screen.getAllByRole('spinbutton')[0], '3')];
145
+ case 1:
146
+ _a.sent();
147
+ expect(defaultProps.onChange).toHaveBeenCalledWith({
148
+ type: DateRangeTypes.WITHIN,
149
+ period: [43, 'months']
150
+ });
151
+ return [2 /*return*/];
152
+ }
153
+ });
154
+ }); });
155
+ it('should call props.onChange when ago period is changed', function () { return __awaiter(void 0, void 0, void 0, function () {
156
+ var user;
157
+ return __generator(this, function (_a) {
158
+ switch (_a.label) {
159
+ case 0:
160
+ user = setUp().user;
161
+ return [4 /*yield*/, user.click(screen.getAllByRole('combobox')[0])];
162
+ case 1:
163
+ _a.sent();
164
+ return [4 /*yield*/, user.click(screen.getByText('Days'))];
165
+ case 2:
166
+ _a.sent();
167
+ expect(defaultProps.onChange).toHaveBeenCalledWith({
168
+ type: DateRangeTypes.WITHIN,
169
+ period: [4, 'days']
170
+ });
171
+ return [2 /*return*/];
172
+ }
173
+ });
174
+ }); });
175
+ });
176
+ describe('Ago', function () {
177
+ it('should call props.onChange when type is changed to ago', function () { return __awaiter(void 0, void 0, void 0, function () {
178
+ var user;
179
+ return __generator(this, function (_a) {
180
+ switch (_a.label) {
181
+ case 0:
182
+ user = setUp().user;
183
+ return [4 /*yield*/, user.click(screen.getByLabelText('More than'))];
184
+ case 1:
185
+ _a.sent();
186
+ expect(defaultProps.onChange).toHaveBeenCalledWith({
187
+ type: DateRangeTypes.AGO,
188
+ period: [null, 'minutes']
189
+ });
190
+ return [2 /*return*/];
191
+ }
192
+ });
193
+ }); });
194
+ it('should call props.onChange when within number is changed', function () { return __awaiter(void 0, void 0, void 0, function () {
195
+ var value, user;
196
+ return __generator(this, function (_a) {
197
+ switch (_a.label) {
198
+ case 0:
199
+ value = {
200
+ type: DateRangeTypes.AGO,
201
+ period: [1, 'months']
202
+ };
203
+ user = setUp({ value: value }).user;
204
+ return [4 /*yield*/, user.type(screen.getAllByRole('spinbutton')[1], '3')];
205
+ case 1:
206
+ _a.sent();
207
+ expect(defaultProps.onChange).toHaveBeenCalledWith({
208
+ type: DateRangeTypes.AGO,
209
+ period: [13, 'months']
210
+ });
211
+ return [2 /*return*/];
212
+ }
213
+ });
214
+ }); });
215
+ it('should call props.onChange when ago period is changed', function () { return __awaiter(void 0, void 0, void 0, function () {
216
+ var value, user;
217
+ return __generator(this, function (_a) {
218
+ switch (_a.label) {
219
+ case 0:
220
+ value = {
221
+ type: DateRangeTypes.AGO,
222
+ period: [4, 'months']
223
+ };
224
+ user = setUp({ value: value }).user;
225
+ return [4 /*yield*/, user.click(screen.getAllByRole('combobox')[1])];
226
+ case 1:
227
+ _a.sent();
228
+ return [4 /*yield*/, user.click(screen.getByText('Days'))];
229
+ case 2:
230
+ _a.sent();
231
+ expect(defaultProps.onChange).toHaveBeenCalledWith({
232
+ type: DateRangeTypes.AGO,
233
+ period: [4, 'days']
234
+ });
235
+ return [2 /*return*/];
236
+ }
237
+ });
238
+ }); });
239
+ });
240
+ describe('Between', function () {
241
+ it('should call props.onChange when type is changed to between', function () { return __awaiter(void 0, void 0, void 0, function () {
242
+ var user;
243
+ return __generator(this, function (_a) {
244
+ switch (_a.label) {
245
+ case 0:
246
+ user = setUp().user;
247
+ return [4 /*yield*/, user.click(screen.getByLabelText('Date range'))];
248
+ case 1:
249
+ _a.sent();
250
+ expect(defaultProps.onChange).toHaveBeenCalledWith({
251
+ type: DateRangeTypes.BETWEEN,
252
+ period: [null, null]
253
+ });
254
+ return [2 /*return*/];
255
+ }
256
+ });
257
+ }); });
258
+ it('should call props.onChange when between period is changed', function () { return __awaiter(void 0, void 0, void 0, function () {
259
+ var value, user;
260
+ return __generator(this, function (_a) {
261
+ switch (_a.label) {
262
+ case 0:
263
+ value = {
264
+ type: DateRangeTypes.BETWEEN,
265
+ period: [new Date(123), new Date(456)]
266
+ };
267
+ user = setUp({ value: value }).user;
268
+ return [4 /*yield*/, user.click(screen.getByRole('textbox'))];
269
+ case 1:
270
+ _a.sent();
271
+ return [4 /*yield*/, user.type(screen.getByText('From'), '01/03/2022')];
272
+ case 2:
273
+ _a.sent();
274
+ return [4 /*yield*/, user.type(screen.getByText('To'), '02/03/2022')];
275
+ case 3:
276
+ _a.sent();
277
+ return [4 /*yield*/, user.click(screen.getByText('Update'))];
278
+ case 4:
279
+ _a.sent();
280
+ expect(defaultProps.onChange).toHaveBeenCalledWith({
281
+ type: DateRangeTypes.BETWEEN,
282
+ period: [new Date('01/03/2022'), new Date('02/03/2022')]
283
+ });
284
+ return [2 /*return*/];
285
+ }
286
+ });
287
+ }); });
288
+ });
289
+ });
@@ -0,0 +1 @@
1
+ export { DateRangeSelector } from './DateRangeSelector';
@@ -0,0 +1 @@
1
+ export { DateRangeSelector } from './DateRangeSelector';
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"labels" | "agoLabel" | "dateOption" | "dateOptionAgo" | "dateOptionWithin" | "dateOptionLabel">;
@@ -0,0 +1,27 @@
1
+ import { makeStyles } from '@mui/styles';
2
+ export var useStyles = makeStyles({
3
+ labels: {
4
+ fontSize: '14px'
5
+ },
6
+ agoLabel: {
7
+ minWidth: '30px',
8
+ textAlign: 'end',
9
+ margin: 'auto'
10
+ },
11
+ dateOption: {
12
+ display: 'flex',
13
+ marginRight: '30px'
14
+ },
15
+ dateOptionAgo: {
16
+ display: 'flex',
17
+ marginBottom: '10px'
18
+ },
19
+ dateOptionWithin: {
20
+ display: 'flex',
21
+ marginRight: '30px',
22
+ marginBottom: '10px'
23
+ },
24
+ dateOptionLabel: {
25
+ minWidth: '100px'
26
+ }
27
+ });
@@ -1,19 +1,7 @@
1
- import React, { useMemo, useState } from 'react';
2
- import i18n from 'ui-i18n';
3
- import { extractCombinations, UpSetJS } from '@upsetjs/react';
4
- import { NOT_MEMBER_COLOR, PRIMARY_COLOR, SECONDARY_COLOR, TEXT_COLOR } from './constants';
5
- import { useStyles } from './styles';
1
+ import React from 'react';
6
2
  export var UpSetChart = function (_a) {
7
3
  var width = _a.width, height = _a.height, data = _a.data;
8
- var styles = useStyles();
9
- var _b = useState(null), selection = _b[0], setSelection = _b[1];
10
- var _c = useMemo(function () { return extractCombinations(data); }, [data]), sets = _c.sets, combinations = _c.combinations;
11
- if (!width || !height)
4
+ if (!width || !height || !data)
12
5
  return null;
13
- return (React.createElement(UpSetJS, { width: width, height: height, sets: sets, combinations: combinations, selection: selection, onHover: setSelection, barPadding: 0.6, dotPadding: 0.5, barLabelOffset: 4, exportButtons: false, heightRatios: [0.65], combinationName: i18n.text('No. of unified profiles'), setName: "", setLabelAlignment: "left", alternatingBackgroundColor: "transparent", notMemberColor: NOT_MEMBER_COLOR, hasSelectionColor: SECONDARY_COLOR, selectionColor: PRIMARY_COLOR, color: PRIMARY_COLOR, textColor: TEXT_COLOR, fontFamily: "inherit", classNames: {
14
- setLabel: styles.setLabel,
15
- barLabel: styles.barLabel,
16
- axisTick: styles.axisTick,
17
- chartLabel: styles.chartLabel
18
- } }));
6
+ return React.createElement("div", null, "UpSet");
19
7
  };
@@ -1,95 +1,13 @@
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
- import React, { useState } from 'react';
1
+ import React from 'react';
13
2
  import i18n from 'ui-i18n';
14
- import { pipe } from 'ramda';
15
3
  import classnames from 'classnames';
16
- import { DateRangeTypes } from '@reltio/mdm-sdk';
17
- import FormControlLabel from '@mui/material/FormControlLabel';
18
- import Radio from '@mui/material/Radio';
19
- import RadioGroup from '@mui/material/RadioGroup';
20
4
  import Typography from '@mui/material/Typography';
21
- import { DateIntervalSelector } from '../../../../../DateIntervalSelector';
22
- import { getValue } from '../../../../../helpers/events';
23
- import { CustomDateRangeEditor } from '../../../../../CustomDateRangeEditor';
24
- import { useDidUpdateEffect } from '../../../../../hooks/useDidUpdateEffect';
5
+ import { DateRangeSelector as BaseDateRangeSelector } from '../../../../../DateRangeSelector';
25
6
  import { useStyles } from '../../styles';
26
- var emptyDates = [null, null];
27
- var emptyInterval = [null, 'minutes'];
28
7
  export var DateRangeSelector = function (_a) {
29
8
  var value = _a.value, onChange = _a.onChange;
30
9
  var styles = useStyles();
31
- var getInitPeriodByType = function (type) {
32
- if ((value === null || value === void 0 ? void 0 : value.type) === type) {
33
- return value.period;
34
- }
35
- else if (type === DateRangeTypes.WITHIN || type === DateRangeTypes.AGO) {
36
- return emptyInterval;
37
- }
38
- else if (type === DateRangeTypes.BETWEEN) {
39
- return emptyDates;
40
- }
41
- };
42
- var _b = useState(getInitPeriodByType(DateRangeTypes.BETWEEN)), datesInterval = _b[0], setDatesInterval = _b[1];
43
- var _c = useState(getInitPeriodByType(DateRangeTypes.WITHIN)), withinInterval = _c[0], setWithinInterval = _c[1];
44
- var _d = useState(getInitPeriodByType(DateRangeTypes.AGO)), agoInterval = _d[0], setAgoInterval = _d[1];
45
- var getCurrentPeriodByType = function (type) {
46
- if (type === DateRangeTypes.WITHIN) {
47
- return withinInterval;
48
- }
49
- else if (type === DateRangeTypes.AGO) {
50
- return agoInterval;
51
- }
52
- else if (type === DateRangeTypes.BETWEEN) {
53
- return datesInterval;
54
- }
55
- };
56
- var changeType = function (type) {
57
- if ((value === null || value === void 0 ? void 0 : value.type) !== type) {
58
- onChange({ period: getCurrentPeriodByType(type), type: type });
59
- }
60
- };
61
- var changePeriod = function (period) {
62
- onChange(__assign(__assign({}, value), { period: period }));
63
- };
64
- useDidUpdateEffect(function () {
65
- if (value) {
66
- if (value.type === DateRangeTypes.WITHIN) {
67
- setWithinInterval(value.period);
68
- }
69
- else if (value.type === DateRangeTypes.AGO) {
70
- setAgoInterval(value.period);
71
- }
72
- else if (value.type === DateRangeTypes.BETWEEN) {
73
- setDatesInterval(value.period);
74
- }
75
- }
76
- else {
77
- setDatesInterval(emptyDates);
78
- setWithinInterval(emptyInterval);
79
- setAgoInterval(emptyInterval);
80
- }
81
- }, [value]);
82
10
  return (React.createElement("div", { className: styles.selectorWrapper, "data-reltio-id": "date-range-selector" },
83
11
  React.createElement(Typography, { className: classnames(styles.filterSubtitle, styles.labels), variant: 'subtitle1' }, i18n.text('Date')),
84
- React.createElement(RadioGroup, { value: (value === null || value === void 0 ? void 0 : value.type) || null, onChange: pipe(getValue, changeType) },
85
- React.createElement("div", { className: styles.dateOptionWithin },
86
- React.createElement(FormControlLabel, { value: DateRangeTypes.WITHIN, control: React.createElement(Radio, { color: "primary" }), label: i18n.text('Within the last'), classes: { label: classnames(styles.dateOptionLabel, styles.labels) } }),
87
- React.createElement(DateIntervalSelector, { interval: withinInterval, onChange: changePeriod, onFocus: function () { return changeType(DateRangeTypes.WITHIN); } })),
88
- React.createElement("div", { className: styles.dateOptionAgo },
89
- React.createElement(FormControlLabel, { value: DateRangeTypes.AGO, control: React.createElement(Radio, { color: "primary" }), label: i18n.text('More than'), classes: { label: classnames(styles.dateOptionLabel, styles.labels) } }),
90
- React.createElement(DateIntervalSelector, { interval: agoInterval, onChange: changePeriod, onFocus: function () { return changeType(DateRangeTypes.AGO); } }),
91
- React.createElement(Typography, { className: classnames(styles.agoLabel, styles.labels), variant: 'subtitle1' }, i18n.text('Ago'))),
92
- React.createElement("div", { className: styles.dateOption },
93
- React.createElement(FormControlLabel, { value: DateRangeTypes.BETWEEN, control: React.createElement(Radio, { color: "primary" }), label: i18n.text('Date range'), classes: { label: classnames(styles.dateOptionLabel, styles.labels) } }),
94
- React.createElement(CustomDateRangeEditor, { values: datesInterval, onChange: changePeriod, onFocus: function () { return changeType(DateRangeTypes.BETWEEN); } })))));
12
+ React.createElement(BaseDateRangeSelector, { value: value, onChange: onChange })));
95
13
  };
@@ -1 +1 @@
1
- export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"container" | "option" | "labels" | "divider" | "clearButton" | "filterSubtitle" | "agoLabel" | "dateOption" | "dateOptionAgo" | "dateOptionWithin" | "dateOptionLabel" | "dropDownInput" | "editorFields" | "selectorWrapper" | "selectorsGroup" | "selectorHint">;
1
+ export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"labels" | "filterSubtitle" | "selectorWrapper">;
@@ -1,9 +1,5 @@
1
1
  import { makeStyles } from '@mui/styles';
2
2
  export var useStyles = makeStyles({
3
- container: {
4
- width: 500,
5
- boxSizing: 'border-box'
6
- },
7
3
  labels: {
8
4
  fontSize: '14px'
9
5
  },
@@ -11,57 +7,7 @@ export var useStyles = makeStyles({
11
7
  paddingBottom: '10px',
12
8
  paddingLeft: '5px'
13
9
  },
14
- agoLabel: {
15
- minWidth: '30px',
16
- textAlign: 'end',
17
- margin: 'auto'
18
- },
19
- dateOption: {
20
- display: 'flex',
21
- marginRight: '30px'
22
- },
23
- dateOptionAgo: {
24
- display: 'flex',
25
- marginBottom: '10px'
26
- },
27
- dateOptionWithin: {
28
- display: 'flex',
29
- marginRight: '30px',
30
- marginBottom: '10px'
31
- },
32
- dateOptionLabel: {
33
- minWidth: '100px'
34
- },
35
- dropDownInput: {
36
- width: '100%',
37
- justifyContent: 'center',
38
- backgroundColor: 'rgba(0, 0, 0, 0.03)',
39
- borderTop: '4px'
40
- },
41
- editorFields: {
42
- maxHeight: 400,
43
- borderColor: 'rgba(0,0,0,0.12)'
44
- },
45
- clearButton: {
46
- marginRight: 'auto'
47
- },
48
10
  selectorWrapper: {
49
11
  marginBottom: '12px'
50
- },
51
- option: {
52
- fontSize: '14px',
53
- height: '32px'
54
- },
55
- selectorsGroup: {
56
- display: 'flex',
57
- flexDirection: 'column'
58
- },
59
- selectorHint: {
60
- fontSize: 12,
61
- lineHeight: '16px',
62
- color: 'rgba(0,0,0,0.54)'
63
- },
64
- divider: {
65
- marginBottom: 12
66
12
  }
67
13
  });
package/esm/index.d.ts CHANGED
@@ -176,6 +176,7 @@ export { ReltioMap } from './ReltioMap';
176
176
  export { RelationEditor } from './RelationEditor';
177
177
  export { GaugeChart } from './GaugeChart';
178
178
  export { UpSetChart } from './UpSetChart';
179
+ export { DateRangeSelector } from './DateRangeSelector';
179
180
  export { withTooltip } from './HOCs/withTooltip';
180
181
  export { withAsyncMount } from './HOCs/withAsyncMount';
181
182
  export { withDragHandle } from './HOCs/withDragHandle';
package/esm/index.js CHANGED
@@ -177,6 +177,7 @@ export { ReltioMap } from './ReltioMap';
177
177
  export { RelationEditor } from './RelationEditor';
178
178
  export { GaugeChart } from './GaugeChart';
179
179
  export { UpSetChart } from './UpSetChart';
180
+ export { DateRangeSelector } from './DateRangeSelector';
180
181
  // HOCs
181
182
  export { withTooltip } from './HOCs/withTooltip';
182
183
  export { withAsyncMount } from './HOCs/withAsyncMount';