@reltio/components 1.4.1919 → 1.4.1921
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/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.js +1 -0
- package/cjs/CollaborationItem/components/TextFieldWithMentions/styles.d.ts +1 -1
- package/cjs/CollaborationItem/components/TextFieldWithMentions/styles.js +4 -1
- package/cjs/EntitySelector/components/EntityOption/EntityOption.d.ts +2 -1
- package/cjs/EntitySelector/components/EntityOption/EntityOption.js +3 -2
- package/cjs/EntitySelector/components/EntityOption/styles.js +4 -1
- package/cjs/NumberEditor/NumberEditor.test.js +165 -69
- package/esm/CollaborationItem/components/TextFieldWithMentions/TextFieldWithMentions.js +1 -0
- package/esm/CollaborationItem/components/TextFieldWithMentions/styles.d.ts +1 -1
- package/esm/CollaborationItem/components/TextFieldWithMentions/styles.js +4 -1
- package/esm/EntitySelector/components/EntityOption/EntityOption.d.ts +2 -1
- package/esm/EntitySelector/components/EntityOption/EntityOption.js +3 -2
- package/esm/EntitySelector/components/EntityOption/styles.js +4 -1
- package/esm/NumberEditor/NumberEditor.test.js +165 -69
- package/package.json +2 -2
|
@@ -75,6 +75,7 @@ var TextFieldWithMentions = function (_a) {
|
|
|
75
75
|
_b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions")] = styles.mentionsSuggestions,
|
|
76
76
|
_b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions__list")] = styles.mentionsSuggestionsList,
|
|
77
77
|
_b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions__item")] = styles.mentionsSuggestionsItem,
|
|
78
|
+
_b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions__item--focused")] = styles.mentionsSuggestionsItemFocused,
|
|
78
79
|
_b) }),
|
|
79
80
|
react_1.default.createElement(react_mentions_1.Mention, { trigger: "+", data: users.map(function (_a) {
|
|
80
81
|
var username = _a.username;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type StylesProps = {
|
|
2
2
|
placeholder?: string;
|
|
3
3
|
};
|
|
4
|
-
export declare const useStyles: (props: StylesProps) => import("@mui/styles").ClassNameMap<"root" | "mentionsControl" | "mentionsHighlighter" | "mentionsInput" | "mentionsSuggestions" | "mentionsSuggestionsList" | "mentionsSuggestionsItem" | "mention">;
|
|
4
|
+
export declare const useStyles: (props: StylesProps) => import("@mui/styles").ClassNameMap<"root" | "mentionsControl" | "mentionsHighlighter" | "mentionsInput" | "mentionsSuggestions" | "mentionsSuggestionsList" | "mentionsSuggestionsItem" | "mentionsSuggestionsItemFocused" | "mention">;
|
|
5
5
|
export {};
|
|
@@ -45,10 +45,13 @@ exports.useStyles = (0, styles_1.makeStyles)(function (theme) { return ({
|
|
|
45
45
|
color: theme.palette.text.primary,
|
|
46
46
|
fontSize: '13px',
|
|
47
47
|
transition: theme.transitions.create(['background-color']),
|
|
48
|
-
'&:hover
|
|
48
|
+
'&:hover': {
|
|
49
49
|
backgroundColor: 'rgba(0,0,0,0.04)'
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
|
+
mentionsSuggestionsItemFocused: {
|
|
53
|
+
backgroundColor: 'rgba(0,0,0,0.04)'
|
|
54
|
+
},
|
|
52
55
|
mention: {
|
|
53
56
|
position: 'relative',
|
|
54
57
|
zIndex: 1,
|
|
@@ -6,6 +6,7 @@ type Props = {
|
|
|
6
6
|
innerRef: ForwardedRef<HTMLLIElement>;
|
|
7
7
|
selectOption: (option: Partial<EntityOptionType>) => void;
|
|
8
8
|
data: EntityOptionType;
|
|
9
|
+
isFocused: boolean;
|
|
9
10
|
};
|
|
10
|
-
export declare const EntityOption: ({ innerRef, innerProps, selectOption, data }: Props) => JSX.Element;
|
|
11
|
+
export declare const EntityOption: ({ innerRef, innerProps, selectOption, data, isFocused }: Props) => JSX.Element;
|
|
11
12
|
export {};
|
|
@@ -17,16 +17,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
exports.EntityOption = void 0;
|
|
18
18
|
var react_1 = __importDefault(require("react"));
|
|
19
19
|
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
20
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
20
21
|
var MenuItem_1 = __importDefault(require("@mui/material/MenuItem"));
|
|
21
22
|
var EntityTypeIcon_1 = require("../../../EntityTypeIcon");
|
|
22
23
|
var ExpandedValueTooltip_1 = require("../../../ExpandedValueTooltip");
|
|
23
24
|
var styles_1 = require("./styles");
|
|
24
25
|
var EntityOption = function (_a) {
|
|
25
|
-
var innerRef = _a.innerRef, innerProps = _a.innerProps, selectOption = _a.selectOption, data = _a.data;
|
|
26
|
+
var innerRef = _a.innerRef, innerProps = _a.innerProps, selectOption = _a.selectOption, data = _a.data, isFocused = _a.isFocused;
|
|
26
27
|
var styles = (0, styles_1.useStyles)();
|
|
27
28
|
var uri = data.uri, entityType = data.entityType, label = data.label, secondaryLabel = data.secondaryLabel;
|
|
28
29
|
if (uri !== '') {
|
|
29
|
-
return (react_1.default.createElement(MenuItem_1.default, __assign({ className: styles.entityContainer, ref: innerRef, key: uri, onClick: function () { return selectOption({ label: label, uri: uri, entityType: entityType }); } }, innerProps),
|
|
30
|
+
return (react_1.default.createElement(MenuItem_1.default, __assign({ className: (0, classnames_1.default)(styles.entityContainer, { focused: isFocused }), ref: innerRef, key: uri, onClick: function () { return selectOption({ label: label, uri: uri, entityType: entityType }); } }, innerProps),
|
|
30
31
|
react_1.default.createElement(EntityTypeIcon_1.EntityTypeIcon, { className: styles.entityAvatar, entityType: entityType }),
|
|
31
32
|
react_1.default.createElement(ExpandedValueTooltip_1.ExpandedValueTooltip, { value: "".concat(label).concat(secondaryLabel ? ', ' + secondaryLabel : '') },
|
|
32
33
|
react_1.default.createElement("span", { className: styles.entityLabel },
|
|
@@ -1,91 +1,187 @@
|
|
|
1
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;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "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
|
+
};
|
|
2
49
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
51
|
};
|
|
5
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var enzyme_1 = require("enzyme");
|
|
7
|
-
var react_number_format_1 = __importDefault(require("react-number-format"));
|
|
8
53
|
var react_1 = __importDefault(require("react"));
|
|
9
|
-
var
|
|
54
|
+
var react_2 = require("@testing-library/react");
|
|
55
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
10
56
|
var NumberEditor_1 = require("./NumberEditor");
|
|
11
57
|
describe('NumberEditor', function () {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
58
|
+
var defaultProps = { value: undefined, onChange: jest.fn() };
|
|
59
|
+
var setUp = function (_a) {
|
|
60
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? {} : _c;
|
|
61
|
+
var user = user_event_1.default.setup();
|
|
62
|
+
return __assign({ user: user }, (0, react_2.render)(react_1.default.createElement(NumberEditor_1.NumberEditor, __assign({}, defaultProps, props))));
|
|
63
|
+
};
|
|
64
|
+
beforeEach(function () {
|
|
65
|
+
jest.clearAllMocks();
|
|
66
|
+
});
|
|
67
|
+
it('should render input', function () {
|
|
68
|
+
setUp();
|
|
69
|
+
expect(react_2.screen.getByRole('textbox')).toBeInTheDocument();
|
|
16
70
|
});
|
|
17
71
|
it('should show correct value if it is 0', function () {
|
|
18
|
-
|
|
19
|
-
expect(
|
|
72
|
+
setUp({ props: { value: 0 } });
|
|
73
|
+
expect(react_2.screen.getByRole('textbox')).toHaveValue('0');
|
|
20
74
|
});
|
|
21
75
|
describe('single mode', function () {
|
|
22
76
|
it('should format value', function () {
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
77
|
+
var props = {
|
|
78
|
+
value: '-1234.5',
|
|
79
|
+
format: {
|
|
80
|
+
prefix: '<',
|
|
81
|
+
suffix: '>',
|
|
82
|
+
thousandSeparator: ',',
|
|
83
|
+
decimalSeparator: '_'
|
|
84
|
+
}
|
|
28
85
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
expect(wrapper.find('input').prop('value')).toBe(formattedValue);
|
|
32
|
-
});
|
|
33
|
-
it('should call props.onChange with actual value', function () {
|
|
34
|
-
var value = '<-123,456abc_78>', onChange = jest.fn();
|
|
35
|
-
var format = {
|
|
36
|
-
prefix: '<',
|
|
37
|
-
suffix: '>',
|
|
38
|
-
thousandSeparator: ',',
|
|
39
|
-
decimalSeparator: '_'
|
|
40
|
-
};
|
|
41
|
-
var wrapper = (0, enzyme_1.mount)(react_1.default.createElement(NumberEditor_1.NumberEditor, { format: format, onChange: onChange }));
|
|
42
|
-
var input = wrapper.find('input');
|
|
43
|
-
input.simulate('change', { target: { value: value, focus: function () { } } });
|
|
44
|
-
input.simulate('blur');
|
|
45
|
-
expect(onChange).toBeCalledWith('-123456.78');
|
|
46
|
-
});
|
|
47
|
-
it('should discard fraction part if integer', function () {
|
|
48
|
-
var value = '123.45', onChange = jest.fn();
|
|
49
|
-
var wrapper = (0, enzyme_1.mount)(react_1.default.createElement(NumberEditor_1.NumberEditor, { integer: true, onChange: onChange }));
|
|
50
|
-
var input = wrapper.find('input');
|
|
51
|
-
input.simulate('change', { target: { value: value, focus: function () { } } });
|
|
52
|
-
input.simulate('blur');
|
|
53
|
-
expect(onChange).toBeCalledWith('123');
|
|
86
|
+
setUp({ props: props });
|
|
87
|
+
expect(react_2.screen.getByRole('textbox')).toHaveValue('-<1,234_5>');
|
|
54
88
|
});
|
|
89
|
+
it('should call props.onChange with actual value', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
90
|
+
var props, user;
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
switch (_a.label) {
|
|
93
|
+
case 0:
|
|
94
|
+
props = {
|
|
95
|
+
format: {
|
|
96
|
+
prefix: '<',
|
|
97
|
+
suffix: '>',
|
|
98
|
+
thousandSeparator: ',',
|
|
99
|
+
decimalSeparator: '_'
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
user = setUp({ props: props }).user;
|
|
103
|
+
return [4 /*yield*/, user.type(react_2.screen.getByRole('textbox'), '<-123,456abc_78>{enter}')];
|
|
104
|
+
case 1:
|
|
105
|
+
_a.sent();
|
|
106
|
+
expect(defaultProps.onChange).toBeCalledWith('-123456.78');
|
|
107
|
+
return [2 /*return*/];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
}); });
|
|
111
|
+
it('should discard fraction part if integer', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
112
|
+
var props, user;
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
switch (_a.label) {
|
|
115
|
+
case 0:
|
|
116
|
+
props = {
|
|
117
|
+
value: 123.45,
|
|
118
|
+
integer: true
|
|
119
|
+
};
|
|
120
|
+
user = setUp({ props: props }).user;
|
|
121
|
+
return [4 /*yield*/, user.type(react_2.screen.getByRole('textbox'), '{enter}')];
|
|
122
|
+
case 1:
|
|
123
|
+
_a.sent();
|
|
124
|
+
expect(defaultProps.onChange).toBeCalledWith('123');
|
|
125
|
+
return [2 /*return*/];
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}); });
|
|
55
129
|
});
|
|
56
130
|
describe('multiple mode', function () {
|
|
57
131
|
it('should format value', function () {
|
|
58
|
-
var
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
132
|
+
var props = {
|
|
133
|
+
value: '-1234.5',
|
|
134
|
+
multiple: true,
|
|
135
|
+
format: {
|
|
136
|
+
prefix: '<',
|
|
137
|
+
suffix: '>',
|
|
138
|
+
thousandSeparator: ',',
|
|
139
|
+
decimalSeparator: '_'
|
|
140
|
+
}
|
|
63
141
|
};
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
expect(wrapper.text()).toBe(formattedValue);
|
|
67
|
-
});
|
|
68
|
-
it('should call props.onChange with actual value', function () {
|
|
69
|
-
var onChange = jest.fn();
|
|
70
|
-
var value = '<-123,456abc_78>';
|
|
71
|
-
var format = {
|
|
72
|
-
prefix: '<',
|
|
73
|
-
suffix: '>',
|
|
74
|
-
thousandSeparator: ',',
|
|
75
|
-
decimalSeparator: '_'
|
|
76
|
-
};
|
|
77
|
-
var wrapper = (0, enzyme_1.mount)(react_1.default.createElement(NumberEditor_1.NumberEditor, { multiple: true, format: format, onChange: onChange }));
|
|
78
|
-
wrapper.find('input').simulate('change', { target: { value: value, focus: function () { } } });
|
|
79
|
-
wrapper.find('input').simulate('keyPress', { key: 'Enter' });
|
|
80
|
-
expect(onChange).toBeCalledWith(['-123456.78']);
|
|
81
|
-
});
|
|
82
|
-
it('should discard fraction part if integer', function () {
|
|
83
|
-
var value = '123.45';
|
|
84
|
-
var onChange = jest.fn();
|
|
85
|
-
var wrapper = (0, enzyme_1.mount)(react_1.default.createElement(NumberEditor_1.NumberEditor, { multiple: true, integer: true, onChange: onChange }));
|
|
86
|
-
wrapper.find('input').simulate('change', { target: { value: value, focus: function () { } } });
|
|
87
|
-
wrapper.find('input').simulate('keyPress', { key: 'Enter' });
|
|
88
|
-
expect(onChange).toBeCalledWith(['123']);
|
|
142
|
+
setUp({ props: props });
|
|
143
|
+
expect(react_2.screen.getByText('<-1,234_5>')).toBeInTheDocument();
|
|
89
144
|
});
|
|
145
|
+
it('should call props.onChange with actual value', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
146
|
+
var props, user;
|
|
147
|
+
return __generator(this, function (_a) {
|
|
148
|
+
switch (_a.label) {
|
|
149
|
+
case 0:
|
|
150
|
+
props = {
|
|
151
|
+
multiple: true,
|
|
152
|
+
format: {
|
|
153
|
+
prefix: '<',
|
|
154
|
+
suffix: '>',
|
|
155
|
+
thousandSeparator: ',',
|
|
156
|
+
decimalSeparator: '_'
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
user = setUp({ props: props }).user;
|
|
160
|
+
return [4 /*yield*/, user.type(react_2.screen.getByRole('textbox'), '<-123,456abc_78>{enter}')];
|
|
161
|
+
case 1:
|
|
162
|
+
_a.sent();
|
|
163
|
+
expect(defaultProps.onChange).toBeCalledWith(['-123456.78']);
|
|
164
|
+
return [2 /*return*/];
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}); });
|
|
168
|
+
it('should discard fraction part if integer', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
169
|
+
var props, user;
|
|
170
|
+
return __generator(this, function (_a) {
|
|
171
|
+
switch (_a.label) {
|
|
172
|
+
case 0:
|
|
173
|
+
props = {
|
|
174
|
+
multiple: true,
|
|
175
|
+
integer: true
|
|
176
|
+
};
|
|
177
|
+
user = setUp({ props: props }).user;
|
|
178
|
+
return [4 /*yield*/, user.type(react_2.screen.getByRole('textbox'), '123.45{enter}')];
|
|
179
|
+
case 1:
|
|
180
|
+
_a.sent();
|
|
181
|
+
expect(defaultProps.onChange).toBeCalledWith(['12345']);
|
|
182
|
+
return [2 /*return*/];
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
}); });
|
|
90
186
|
});
|
|
91
187
|
});
|
|
@@ -46,6 +46,7 @@ export var TextFieldWithMentions = function (_a) {
|
|
|
46
46
|
_b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions")] = styles.mentionsSuggestions,
|
|
47
47
|
_b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions__list")] = styles.mentionsSuggestionsList,
|
|
48
48
|
_b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions__item")] = styles.mentionsSuggestionsItem,
|
|
49
|
+
_b["".concat(MENTIONS_TEXTAREA_CLASSNAME, "__suggestions__item--focused")] = styles.mentionsSuggestionsItemFocused,
|
|
49
50
|
_b) }),
|
|
50
51
|
React.createElement(Mention, { trigger: "+", data: users.map(function (_a) {
|
|
51
52
|
var username = _a.username;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type StylesProps = {
|
|
2
2
|
placeholder?: string;
|
|
3
3
|
};
|
|
4
|
-
export declare const useStyles: (props: StylesProps) => import("@mui/styles").ClassNameMap<"root" | "mentionsControl" | "mentionsHighlighter" | "mentionsInput" | "mentionsSuggestions" | "mentionsSuggestionsList" | "mentionsSuggestionsItem" | "mention">;
|
|
4
|
+
export declare const useStyles: (props: StylesProps) => import("@mui/styles").ClassNameMap<"root" | "mentionsControl" | "mentionsHighlighter" | "mentionsInput" | "mentionsSuggestions" | "mentionsSuggestionsList" | "mentionsSuggestionsItem" | "mentionsSuggestionsItemFocused" | "mention">;
|
|
5
5
|
export {};
|
|
@@ -42,10 +42,13 @@ export var useStyles = makeStyles(function (theme) { return ({
|
|
|
42
42
|
color: theme.palette.text.primary,
|
|
43
43
|
fontSize: '13px',
|
|
44
44
|
transition: theme.transitions.create(['background-color']),
|
|
45
|
-
'&:hover
|
|
45
|
+
'&:hover': {
|
|
46
46
|
backgroundColor: 'rgba(0,0,0,0.04)'
|
|
47
47
|
}
|
|
48
48
|
},
|
|
49
|
+
mentionsSuggestionsItemFocused: {
|
|
50
|
+
backgroundColor: 'rgba(0,0,0,0.04)'
|
|
51
|
+
},
|
|
49
52
|
mention: {
|
|
50
53
|
position: 'relative',
|
|
51
54
|
zIndex: 1,
|
|
@@ -6,6 +6,7 @@ type Props = {
|
|
|
6
6
|
innerRef: ForwardedRef<HTMLLIElement>;
|
|
7
7
|
selectOption: (option: Partial<EntityOptionType>) => void;
|
|
8
8
|
data: EntityOptionType;
|
|
9
|
+
isFocused: boolean;
|
|
9
10
|
};
|
|
10
|
-
export declare const EntityOption: ({ innerRef, innerProps, selectOption, data }: Props) => JSX.Element;
|
|
11
|
+
export declare const EntityOption: ({ innerRef, innerProps, selectOption, data, isFocused }: Props) => JSX.Element;
|
|
11
12
|
export {};
|
|
@@ -11,16 +11,17 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import React from 'react';
|
|
13
13
|
import i18n from 'ui-i18n';
|
|
14
|
+
import classNames from 'classnames';
|
|
14
15
|
import MenuItem from '@mui/material/MenuItem';
|
|
15
16
|
import { EntityTypeIcon } from '../../../EntityTypeIcon';
|
|
16
17
|
import { ExpandedValueTooltip } from '../../../ExpandedValueTooltip';
|
|
17
18
|
import { useStyles } from './styles';
|
|
18
19
|
export var EntityOption = function (_a) {
|
|
19
|
-
var innerRef = _a.innerRef, innerProps = _a.innerProps, selectOption = _a.selectOption, data = _a.data;
|
|
20
|
+
var innerRef = _a.innerRef, innerProps = _a.innerProps, selectOption = _a.selectOption, data = _a.data, isFocused = _a.isFocused;
|
|
20
21
|
var styles = useStyles();
|
|
21
22
|
var uri = data.uri, entityType = data.entityType, label = data.label, secondaryLabel = data.secondaryLabel;
|
|
22
23
|
if (uri !== '') {
|
|
23
|
-
return (React.createElement(MenuItem, __assign({ className: styles.entityContainer, ref: innerRef, key: uri, onClick: function () { return selectOption({ label: label, uri: uri, entityType: entityType }); } }, innerProps),
|
|
24
|
+
return (React.createElement(MenuItem, __assign({ className: classNames(styles.entityContainer, { focused: isFocused }), ref: innerRef, key: uri, onClick: function () { return selectOption({ label: label, uri: uri, entityType: entityType }); } }, innerProps),
|
|
24
25
|
React.createElement(EntityTypeIcon, { className: styles.entityAvatar, entityType: entityType }),
|
|
25
26
|
React.createElement(ExpandedValueTooltip, { value: "".concat(label).concat(secondaryLabel ? ', ' + secondaryLabel : '') },
|
|
26
27
|
React.createElement("span", { className: styles.entityLabel },
|
|
@@ -1,86 +1,182 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
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
|
+
};
|
|
3
48
|
import React from 'react';
|
|
4
|
-
import {
|
|
49
|
+
import { render, screen } from '@testing-library/react';
|
|
50
|
+
import userEvent from '@testing-library/user-event';
|
|
5
51
|
import { NumberEditor } from './NumberEditor';
|
|
6
52
|
describe('NumberEditor', function () {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
53
|
+
var defaultProps = { value: undefined, onChange: jest.fn() };
|
|
54
|
+
var setUp = function (_a) {
|
|
55
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? {} : _c;
|
|
56
|
+
var user = userEvent.setup();
|
|
57
|
+
return __assign({ user: user }, render(React.createElement(NumberEditor, __assign({}, defaultProps, props))));
|
|
58
|
+
};
|
|
59
|
+
beforeEach(function () {
|
|
60
|
+
jest.clearAllMocks();
|
|
61
|
+
});
|
|
62
|
+
it('should render input', function () {
|
|
63
|
+
setUp();
|
|
64
|
+
expect(screen.getByRole('textbox')).toBeInTheDocument();
|
|
11
65
|
});
|
|
12
66
|
it('should show correct value if it is 0', function () {
|
|
13
|
-
|
|
14
|
-
expect(
|
|
67
|
+
setUp({ props: { value: 0 } });
|
|
68
|
+
expect(screen.getByRole('textbox')).toHaveValue('0');
|
|
15
69
|
});
|
|
16
70
|
describe('single mode', function () {
|
|
17
71
|
it('should format value', function () {
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
expect(wrapper.find('input').prop('value')).toBe(formattedValue);
|
|
27
|
-
});
|
|
28
|
-
it('should call props.onChange with actual value', function () {
|
|
29
|
-
var value = '<-123,456abc_78>', onChange = jest.fn();
|
|
30
|
-
var format = {
|
|
31
|
-
prefix: '<',
|
|
32
|
-
suffix: '>',
|
|
33
|
-
thousandSeparator: ',',
|
|
34
|
-
decimalSeparator: '_'
|
|
72
|
+
var props = {
|
|
73
|
+
value: '-1234.5',
|
|
74
|
+
format: {
|
|
75
|
+
prefix: '<',
|
|
76
|
+
suffix: '>',
|
|
77
|
+
thousandSeparator: ',',
|
|
78
|
+
decimalSeparator: '_'
|
|
79
|
+
}
|
|
35
80
|
};
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
input.simulate('change', { target: { value: value, focus: function () { } } });
|
|
39
|
-
input.simulate('blur');
|
|
40
|
-
expect(onChange).toBeCalledWith('-123456.78');
|
|
41
|
-
});
|
|
42
|
-
it('should discard fraction part if integer', function () {
|
|
43
|
-
var value = '123.45', onChange = jest.fn();
|
|
44
|
-
var wrapper = mount(React.createElement(NumberEditor, { integer: true, onChange: onChange }));
|
|
45
|
-
var input = wrapper.find('input');
|
|
46
|
-
input.simulate('change', { target: { value: value, focus: function () { } } });
|
|
47
|
-
input.simulate('blur');
|
|
48
|
-
expect(onChange).toBeCalledWith('123');
|
|
81
|
+
setUp({ props: props });
|
|
82
|
+
expect(screen.getByRole('textbox')).toHaveValue('-<1,234_5>');
|
|
49
83
|
});
|
|
84
|
+
it('should call props.onChange with actual value', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
85
|
+
var props, user;
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
switch (_a.label) {
|
|
88
|
+
case 0:
|
|
89
|
+
props = {
|
|
90
|
+
format: {
|
|
91
|
+
prefix: '<',
|
|
92
|
+
suffix: '>',
|
|
93
|
+
thousandSeparator: ',',
|
|
94
|
+
decimalSeparator: '_'
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
user = setUp({ props: props }).user;
|
|
98
|
+
return [4 /*yield*/, user.type(screen.getByRole('textbox'), '<-123,456abc_78>{enter}')];
|
|
99
|
+
case 1:
|
|
100
|
+
_a.sent();
|
|
101
|
+
expect(defaultProps.onChange).toBeCalledWith('-123456.78');
|
|
102
|
+
return [2 /*return*/];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
}); });
|
|
106
|
+
it('should discard fraction part if integer', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
|
+
var props, user;
|
|
108
|
+
return __generator(this, function (_a) {
|
|
109
|
+
switch (_a.label) {
|
|
110
|
+
case 0:
|
|
111
|
+
props = {
|
|
112
|
+
value: 123.45,
|
|
113
|
+
integer: true
|
|
114
|
+
};
|
|
115
|
+
user = setUp({ props: props }).user;
|
|
116
|
+
return [4 /*yield*/, user.type(screen.getByRole('textbox'), '{enter}')];
|
|
117
|
+
case 1:
|
|
118
|
+
_a.sent();
|
|
119
|
+
expect(defaultProps.onChange).toBeCalledWith('123');
|
|
120
|
+
return [2 /*return*/];
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}); });
|
|
50
124
|
});
|
|
51
125
|
describe('multiple mode', function () {
|
|
52
126
|
it('should format value', function () {
|
|
53
|
-
var
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
-
it('should call props.onChange with actual value', function () {
|
|
64
|
-
var onChange = jest.fn();
|
|
65
|
-
var value = '<-123,456abc_78>';
|
|
66
|
-
var format = {
|
|
67
|
-
prefix: '<',
|
|
68
|
-
suffix: '>',
|
|
69
|
-
thousandSeparator: ',',
|
|
70
|
-
decimalSeparator: '_'
|
|
127
|
+
var props = {
|
|
128
|
+
value: '-1234.5',
|
|
129
|
+
multiple: true,
|
|
130
|
+
format: {
|
|
131
|
+
prefix: '<',
|
|
132
|
+
suffix: '>',
|
|
133
|
+
thousandSeparator: ',',
|
|
134
|
+
decimalSeparator: '_'
|
|
135
|
+
}
|
|
71
136
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
wrapper.find('input').simulate('keyPress', { key: 'Enter' });
|
|
75
|
-
expect(onChange).toBeCalledWith(['-123456.78']);
|
|
76
|
-
});
|
|
77
|
-
it('should discard fraction part if integer', function () {
|
|
78
|
-
var value = '123.45';
|
|
79
|
-
var onChange = jest.fn();
|
|
80
|
-
var wrapper = mount(React.createElement(NumberEditor, { multiple: true, integer: true, onChange: onChange }));
|
|
81
|
-
wrapper.find('input').simulate('change', { target: { value: value, focus: function () { } } });
|
|
82
|
-
wrapper.find('input').simulate('keyPress', { key: 'Enter' });
|
|
83
|
-
expect(onChange).toBeCalledWith(['123']);
|
|
137
|
+
setUp({ props: props });
|
|
138
|
+
expect(screen.getByText('<-1,234_5>')).toBeInTheDocument();
|
|
84
139
|
});
|
|
140
|
+
it('should call props.onChange with actual value', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
141
|
+
var props, user;
|
|
142
|
+
return __generator(this, function (_a) {
|
|
143
|
+
switch (_a.label) {
|
|
144
|
+
case 0:
|
|
145
|
+
props = {
|
|
146
|
+
multiple: true,
|
|
147
|
+
format: {
|
|
148
|
+
prefix: '<',
|
|
149
|
+
suffix: '>',
|
|
150
|
+
thousandSeparator: ',',
|
|
151
|
+
decimalSeparator: '_'
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
user = setUp({ props: props }).user;
|
|
155
|
+
return [4 /*yield*/, user.type(screen.getByRole('textbox'), '<-123,456abc_78>{enter}')];
|
|
156
|
+
case 1:
|
|
157
|
+
_a.sent();
|
|
158
|
+
expect(defaultProps.onChange).toBeCalledWith(['-123456.78']);
|
|
159
|
+
return [2 /*return*/];
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
}); });
|
|
163
|
+
it('should discard fraction part if integer', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
164
|
+
var props, user;
|
|
165
|
+
return __generator(this, function (_a) {
|
|
166
|
+
switch (_a.label) {
|
|
167
|
+
case 0:
|
|
168
|
+
props = {
|
|
169
|
+
multiple: true,
|
|
170
|
+
integer: true
|
|
171
|
+
};
|
|
172
|
+
user = setUp({ props: props }).user;
|
|
173
|
+
return [4 /*yield*/, user.type(screen.getByRole('textbox'), '123.45{enter}')];
|
|
174
|
+
case 1:
|
|
175
|
+
_a.sent();
|
|
176
|
+
expect(defaultProps.onChange).toBeCalledWith(['12345']);
|
|
177
|
+
return [2 /*return*/];
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}); });
|
|
85
181
|
});
|
|
86
182
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1921",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"react-input-autosize": "^2.2.2",
|
|
31
31
|
"react-lifecycles-compat": "^3.0.4",
|
|
32
32
|
"react-mentions": "4.3.0",
|
|
33
|
-
"react-number-format": "^4.
|
|
33
|
+
"react-number-format": "^4.9.2",
|
|
34
34
|
"react-resizable-panels": "^2.0.20",
|
|
35
35
|
"react-resize-detector": "^4.2.0",
|
|
36
36
|
"react-router-dom": "^6.2.1",
|