@mailstep/design-system 0.6.9 → 0.6.10
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/package.json +1 -1
- package/ui/Blocks/CommonGrid/components/NumberRange/NumberRange.js +6 -7
- package/ui/Blocks/CommonGrid/components/TextRange/TextRange.js +5 -4
- package/ui/Blocks/CommonGrid/hooks/useEvent.d.ts +3 -0
- package/ui/Blocks/CommonGrid/hooks/useEvent.js +17 -0
- package/ui/Blocks/CommonGrid/index.d.ts +2 -1
- package/ui/Blocks/CommonGrid/index.js +2 -1
- package/ui/index.es.js +8422 -8411
- package/ui/index.umd.js +321 -321
package/package.json
CHANGED
|
@@ -26,6 +26,7 @@ import { useClickOutside } from '../../../Modal/hooks/useClickOutside';
|
|
|
26
26
|
import { Input } from '../../../../Forms/Input/Input';
|
|
27
27
|
import IconList from '../IconList';
|
|
28
28
|
import { i18n } from '@lingui/core';
|
|
29
|
+
import { useEvent } from '../../hooks/useEvent';
|
|
29
30
|
var OverlayComponentDefault = function (_a) {
|
|
30
31
|
var children = _a.children;
|
|
31
32
|
return _jsx("div", { children: children });
|
|
@@ -60,17 +61,15 @@ var NumberRange = function (props) {
|
|
|
60
61
|
var onClose = useCallback(function () { return setOpen(false); }, []);
|
|
61
62
|
var pickerRef = useClickOutside({ onClose: onClose });
|
|
62
63
|
var togglePicker = useCallback(function () { return setOpen(!isOpen); }, [isOpen, setOpen]);
|
|
63
|
-
var onChangeTextInput =
|
|
64
|
+
var onChangeTextInput = useEvent(function (event) {
|
|
64
65
|
var fieldValue = event.target.value.replace(',', '.');
|
|
65
|
-
var number = !decimals
|
|
66
|
-
? parseInt(fieldValue)
|
|
67
|
-
: (parseFloat(fieldValue) || 0).toFixed(decimals).substr(0, fieldValue.length);
|
|
66
|
+
var number = !decimals ? parseInt(fieldValue) : (parseFloat(fieldValue) || 0).toFixed(decimals).substr(0, fieldValue.length);
|
|
68
67
|
var isValid = number || number === 0;
|
|
69
68
|
onChange({ comparator: comparator, value: isValid ? number : '' });
|
|
70
|
-
}
|
|
71
|
-
var onChangeComparator =
|
|
69
|
+
});
|
|
70
|
+
var onChangeComparator = useEvent(function (option) {
|
|
72
71
|
onChange({ comparator: option.value, value: fieldValue });
|
|
73
|
-
}
|
|
72
|
+
});
|
|
74
73
|
return (_jsxs("div", { ref: pickerRef, children: [_jsx(Input, __assign({ name: name, value: fieldValue, label: label, "data-cy": "".concat(name, "Inp"), onChange: onChangeTextInput, iconOnClick: togglePicker, appearance: "grid", icon: "ellipsisVertical", iconPlacement: "right", type: "text", className: className, autoComplete: "off" }, rest)), isOpen && (_jsx(OverlayComponent, { children: _jsx(IconList, { list: renderedComparator, selected: comparator, onClick: onChangeComparator }) }))] }));
|
|
75
74
|
};
|
|
76
75
|
export default NumberRange;
|
|
@@ -27,6 +27,7 @@ import { useClickOutside } from '../../../Modal/hooks/useClickOutside';
|
|
|
27
27
|
import { Input } from '../../../../Forms/Input/Input';
|
|
28
28
|
import IconList from '../IconList/IconList';
|
|
29
29
|
import { i18n } from '@lingui/core';
|
|
30
|
+
import { useEvent } from '../../hooks/useEvent';
|
|
30
31
|
var OverlayComponentDefault = function (_a) {
|
|
31
32
|
var children = _a.children;
|
|
32
33
|
return _jsx("div", { children: children });
|
|
@@ -72,7 +73,7 @@ var TextRange = function (props) {
|
|
|
72
73
|
var togglePicker = useCallback(function () { return setOpen(!isOpen); }, [isOpen, setOpen]);
|
|
73
74
|
var validation = !!validationKey && validations[validationKey];
|
|
74
75
|
var isInvalid = validation && Boolean(fieldValue && !validation.check(String(fieldValue)));
|
|
75
|
-
var onChangeTextInput =
|
|
76
|
+
var onChangeTextInput = useEvent(function (event) {
|
|
76
77
|
var txtValue = event.target.value;
|
|
77
78
|
if (txtValue) {
|
|
78
79
|
onChange({ comparator: comparator, value: txtValue, isInvalid: validation && !validation.check(txtValue) });
|
|
@@ -80,10 +81,10 @@ var TextRange = function (props) {
|
|
|
80
81
|
else {
|
|
81
82
|
onChange(null);
|
|
82
83
|
}
|
|
83
|
-
}
|
|
84
|
-
var onChangeComparator =
|
|
84
|
+
});
|
|
85
|
+
var onChangeComparator = useEvent(function (option) {
|
|
85
86
|
onChange({ comparator: option.value, value: fieldValue, isInvalid: isInvalid });
|
|
86
|
-
}
|
|
87
|
+
});
|
|
87
88
|
return (_jsxs("div", { ref: pickerRef, children: [_jsx(Input, __assign({ name: name, "data-test": name, "data-cy": "".concat(name, "Inp"), value: fieldValue, label: label, onChange: onChangeTextInput, iconOnClick: !eqOnly ? togglePicker : undefined, appearance: "grid", icon: !eqOnly ? 'ellipsisVertical' : 'warning', iconPlacement: "right", iconTooltip: eqOnly ? eqOnlyTxt : undefined, type: "text", className: className, error: (!!validation && isInvalid && validation.errorMsg) || '', errorAppearance: 'tooltip', autoComplete: "off" }, rest)), isOpen && (_jsx(OverlayComponent, { children: _jsx(IconList, { list: renderedComparator, selected: comparator, onClick: onChangeComparator }) }))] }));
|
|
88
89
|
};
|
|
89
90
|
export default TextRange;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { useCallback, useLayoutEffect, useRef } from 'react';
|
|
2
|
+
export var useEvent = function (callback) {
|
|
3
|
+
var ref = useRef(function () {
|
|
4
|
+
throw new Error('Cannot call an event handler while rendering.');
|
|
5
|
+
});
|
|
6
|
+
useLayoutEffect(function () {
|
|
7
|
+
ref.current = callback;
|
|
8
|
+
});
|
|
9
|
+
return useCallback(function () {
|
|
10
|
+
var _a;
|
|
11
|
+
var args = [];
|
|
12
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
13
|
+
args[_i] = arguments[_i];
|
|
14
|
+
}
|
|
15
|
+
return (_a = ref.current) === null || _a === void 0 ? void 0 : _a.apply(null, args);
|
|
16
|
+
}, []);
|
|
17
|
+
};
|
|
@@ -6,5 +6,6 @@ import * as Types from './types';
|
|
|
6
6
|
export * from './StandardButtons';
|
|
7
7
|
export * from './components/gridCells';
|
|
8
8
|
import { useAddFilter } from './hooks/useAddFilter';
|
|
9
|
+
import { useEvent } from './hooks/useEvent';
|
|
9
10
|
export default CommonGrid;
|
|
10
|
-
export { withReduxActions, reducer, actionPrefix, actionTypes, createActions, createSelectors, createFullSelector, Types, useFloatingButton, useAddFilter, };
|
|
11
|
+
export { withReduxActions, reducer, actionPrefix, actionTypes, createActions, createSelectors, createFullSelector, Types, useFloatingButton, useAddFilter, useEvent, };
|
|
@@ -6,5 +6,6 @@ import * as Types from './types';
|
|
|
6
6
|
export * from './StandardButtons';
|
|
7
7
|
export * from './components/gridCells';
|
|
8
8
|
import { useAddFilter } from './hooks/useAddFilter';
|
|
9
|
+
import { useEvent } from './hooks/useEvent';
|
|
9
10
|
export default CommonGrid;
|
|
10
|
-
export { withReduxActions, reducer, actionPrefix, actionTypes, createActions, createSelectors, createFullSelector, Types, useFloatingButton, useAddFilter, };
|
|
11
|
+
export { withReduxActions, reducer, actionPrefix, actionTypes, createActions, createSelectors, createFullSelector, Types, useFloatingButton, useAddFilter, useEvent, };
|