@mailstep/design-system 0.5.0-beta.13 → 0.5.0-beta.15
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 +3 -2
- package/ui/Blocks/CommonGrid/StandardButtons.js +1 -2
- package/ui/Blocks/CommonGrid/components/ActionHead/ActionHead.js +1 -6
- package/ui/Blocks/CommonGrid/components/BooleanSelect/BooleanSelect.js +7 -5
- package/ui/Blocks/CommonGrid/components/DatePickerRange/DatePickerRange.js +3 -3
- package/ui/Blocks/CommonGrid/components/IconList/IconList.d.ts +2 -1
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/ManageColumnForm.js +3 -2
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/components/ActionRow.js +2 -5
- package/ui/Blocks/CommonGrid/components/NumberRange/NumberRange.js +9 -9
- package/ui/Blocks/CommonGrid/components/NumberRange/types.d.ts +2 -1
- package/ui/Blocks/CommonGrid/components/TextRange/TextRange.js +11 -12
- package/ui/Blocks/CommonGrid/types.d.ts +1 -1
- package/ui/Elements/DatePicker/DatePicker.d.ts +1 -1
- package/ui/Elements/DatePicker/Datetime/types.d.ts +1 -1
- package/ui/Elements/Select/Select.js +4 -4
- package/ui/Elements/Select/types.d.ts +1 -1
- package/ui/Elements/SingleSelect/SingleSelect.js +12 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mailstep/design-system",
|
|
3
|
-
"version": "0.5.0-beta.
|
|
3
|
+
"version": "0.5.0-beta.15",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./ui/index.js",
|
|
@@ -125,7 +125,8 @@
|
|
|
125
125
|
"styled-components": "^5.3.10",
|
|
126
126
|
"swiper": "^11.0.3",
|
|
127
127
|
"tslib": "^2.6.2",
|
|
128
|
-
"typescript": "^5.0.4"
|
|
128
|
+
"typescript": "^5.0.4",
|
|
129
|
+
"babel-plugin-macros": "^3.1.0"
|
|
129
130
|
},
|
|
130
131
|
"resolutions": {
|
|
131
132
|
"jackspeak": "2.1.1"
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Trans } from '@lingui/react';
|
|
3
3
|
import { x } from '@xstyled/styled-components';
|
|
4
|
-
import { t } from '@lingui/macro';
|
|
5
4
|
import Select from '../../Elements/Select';
|
|
6
5
|
import ButtonMore from './components/ButtonMore/ButtonMore';
|
|
7
6
|
export var getCreateButton = function (onCreate, canCreate, disabled) { return ({
|
|
@@ -43,7 +42,7 @@ export var getEshopSelect = function (eshopOptions, selectedEshop, onChange, isC
|
|
|
43
42
|
if (eshopOptions.length > 1) {
|
|
44
43
|
eshops.push({
|
|
45
44
|
position: 'top-right',
|
|
46
|
-
node: (_jsx(x.div, { w: "200px", "data-cy": "eshopSelect", children: _jsx(Select, { name: "eshop", options: eshopOptions, value: selectedEshop, onChange: onChange, isSearchable: false, isClearable: isClearable, disabled: !eshopOptions.length, placeholder:
|
|
45
|
+
node: (_jsx(x.div, { w: "200px", "data-cy": "eshopSelect", children: _jsx(Select, { name: "eshop", options: eshopOptions, value: selectedEshop, onChange: onChange, isSearchable: false, isClearable: isClearable, disabled: !eshopOptions.length, placeholder: '1' }) })),
|
|
47
46
|
});
|
|
48
47
|
}
|
|
49
48
|
return eshops;
|
|
@@ -6,7 +6,6 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
6
6
|
import { useCallback, useMemo } from 'react';
|
|
7
7
|
import styled from '@xstyled/styled-components';
|
|
8
8
|
import { Trans } from '@lingui/react';
|
|
9
|
-
import { t } from '@lingui/macro';
|
|
10
9
|
import { useGridActionTrigger, useToggleAllCheckbox } from '../../utils/public';
|
|
11
10
|
import { useModal } from '../../../Modal/hooks/useModal';
|
|
12
11
|
import { Button } from '../../../../Elements/Button';
|
|
@@ -43,11 +42,7 @@ var ActionHead = function (_a) {
|
|
|
43
42
|
return [];
|
|
44
43
|
}, [actionColumn, onSubmit]);
|
|
45
44
|
var canExport = typeof onExport === 'function';
|
|
46
|
-
return (_jsx(Wrap, { children: checkedRowsCount > 0 && (_jsx(ActionsWrap, { children: _jsxs(ContentWrap, { children: [_jsx(StyledText, { children:
|
|
47
|
-
id: 'dataGrid.checkedRowsCount',
|
|
48
|
-
message: "Selected {checkedRowsCount} items",
|
|
49
|
-
values: { checkedRowsCount: checkedRowsCount },
|
|
50
|
-
}) }), _jsxs(ButtonsWrap, { children: [_jsx(Button, { type: "button", onClick: checkAll, appearance: "secondaryLg", "data-cy": "checkAllBtn", disabled: checked, children: _jsx(Trans, { id: "dataGrid.checkAll", message: "Check all" }) }), canExport && (_jsx(Button, { type: "button", onClick: onExportClick, appearance: "primary", "data-cy": "exportBtn", disabled: !rowsData.length, children: _jsx(Trans, { id: "dataGrid.actionOptions.export", message: "Export" }) })), ((_b = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.actionOptions) === null || _b === void 0 ? void 0 : _b.length) && (_jsx(ButtonMore, { items: actionsOptions, disabled: !enabledActions.length || !rowsData.length, dropdownPosition: "top" }))] })] }) })) }));
|
|
45
|
+
return (_jsx(Wrap, { children: checkedRowsCount > 0 && (_jsx(ActionsWrap, { children: _jsxs(ContentWrap, { children: [_jsx(StyledText, { children: _jsx(Trans, { id: "dataGrid.checkedRowsCount", message: "Selected {checkedRowsCount} items", values: { checkedRowsCount: checkedRowsCount } }) }), _jsxs(ButtonsWrap, { children: [_jsx(Button, { type: "button", onClick: checkAll, appearance: "secondaryLg", "data-cy": "checkAllBtn", disabled: checked, children: _jsx(Trans, { id: "dataGrid.checkAll", message: "Check all" }) }), canExport && (_jsx(Button, { type: "button", onClick: onExportClick, appearance: "primary", "data-cy": "exportBtn", disabled: !rowsData.length, children: _jsx(Trans, { id: "dataGrid.actionOptions.export", message: "Export" }) })), ((_b = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.actionOptions) === null || _b === void 0 ? void 0 : _b.length) && (_jsx(ButtonMore, { items: actionsOptions, disabled: !enabledActions.length || !rowsData.length, dropdownPosition: "top" }))] })] }) })) }));
|
|
51
46
|
};
|
|
52
47
|
export default ActionHead;
|
|
53
48
|
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
|
|
@@ -21,15 +21,17 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
-
import {
|
|
24
|
+
import { useMemo } from 'react';
|
|
25
25
|
import GridSelect from '../GridSelect';
|
|
26
|
+
import { Trans } from '@lingui/react';
|
|
26
27
|
var getFlagOptions = function () { return [
|
|
27
|
-
{ value: '', label:
|
|
28
|
-
{ value: '1', label:
|
|
29
|
-
{ value: '0', label:
|
|
28
|
+
{ value: '', label: _jsx(Trans, { id: "dataGrid.columnActive.filterOptions.all", message: "All" }) },
|
|
29
|
+
{ value: '1', label: _jsx(Trans, { id: "dataGrid.columnActive.filterOptions.yes", message: "Yes" }) },
|
|
30
|
+
{ value: '0', label: _jsx(Trans, { id: "dataGrid.columnActive.filterOptions.no", message: "No" }) },
|
|
30
31
|
]; };
|
|
31
32
|
var SelectFilter = function (_a) {
|
|
32
33
|
var restProps = __rest(_a, []);
|
|
33
|
-
|
|
34
|
+
var options = useMemo(function () { return getFlagOptions(); }, []);
|
|
35
|
+
return _jsx(GridSelect, __assign({ options: options }, restProps));
|
|
34
36
|
};
|
|
35
37
|
export default SelectFilter;
|
|
@@ -29,10 +29,10 @@ import React, { useState, useCallback, useMemo } from 'react';
|
|
|
29
29
|
import { DateTime } from 'luxon';
|
|
30
30
|
import styled from '@xstyled/styled-components';
|
|
31
31
|
import { sameDate } from './utils/sameDate';
|
|
32
|
-
import { t } from '@lingui/macro';
|
|
33
32
|
import { useClickOutside } from '../../../Modal/hooks/useClickOutside';
|
|
34
33
|
import DatePicker from '../../../../Elements/DatePicker';
|
|
35
34
|
import Input from '../../../../Forms/Input';
|
|
35
|
+
import { Trans } from '@lingui/react';
|
|
36
36
|
var RangeWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: inline-flex;\n margin-right: 20px;\n"], ["\n display: inline-flex;\n margin-right: 20px;\n"
|
|
37
37
|
// User readable date range.
|
|
38
38
|
])));
|
|
@@ -64,7 +64,7 @@ var DatePickerRange = function (props) {
|
|
|
64
64
|
var _e = useState((_a = value === null || value === void 0 ? void 0 : value[0]) !== null && _a !== void 0 ? _a : undefined), startRangeValue = _e[0], setStartRangeValue = _e[1];
|
|
65
65
|
var _f = useState((_b = value === null || value === void 0 ? void 0 : value[1]) !== null && _b !== void 0 ? _b : undefined), endRangeValue = _f[0], setEndRangeValue = _f[1];
|
|
66
66
|
var timeFormat = filterTime ? 'HH:mm' : false;
|
|
67
|
-
var placeholder =
|
|
67
|
+
var placeholder = '1';
|
|
68
68
|
var cleanValue = React.useMemo(function () { return [
|
|
69
69
|
typeof (value === null || value === void 0 ? void 0 : value[0]) === 'string' ? new Date(value[0]) : (value === null || value === void 0 ? void 0 : value[0]) || undefined,
|
|
70
70
|
typeof (value === null || value === void 0 ? void 0 : value[1]) === 'string' ? new Date(value[1]) : (value === null || value === void 0 ? void 0 : value[1]) || undefined,
|
|
@@ -107,7 +107,7 @@ var DatePickerRange = function (props) {
|
|
|
107
107
|
// Check if the second value is not selected and the first value is the same as the initial value
|
|
108
108
|
var secondDatePickerValue = cleanValue[1] === null ? cleanValue[0] : cleanValue[1];
|
|
109
109
|
var ref = useClickOutside({ onClose: onClose });
|
|
110
|
-
return (_jsxs("div", { ref: ref, children: [_jsx(Input, { name: props.name, placeholder: placeholder, type: "text", icon: "calendar", value: pickerRangeToString(cleanValue), label: props.label, onFocus: openPicker, iconOnClick: openPicker, appearance: "grid", onClear: clear, error: error, readOnly: true }), _jsx(OverlayComponent, { children: _jsx(_Fragment, { children: isOpen && (_jsxs(RangeWrapper, { className: "ignore-element-for-closing-hook", children: [_jsx(DatePicker, __assign({}, rest, { timeFormat: timeFormat, value: (_c = cleanValue[0]) !== null && _c !== void 0 ? _c : '', initialViewDate: initialViewDate[0], secondValue: endRangeValue, onChange: setDateFrom, icon: false, label: isOpen &&
|
|
110
|
+
return (_jsxs("div", { ref: ref, children: [_jsx(Input, { name: props.name, placeholder: placeholder, type: "text", icon: "calendar", value: pickerRangeToString(cleanValue), label: props.label, onFocus: openPicker, iconOnClick: openPicker, appearance: "grid", onClear: clear, error: error, readOnly: true }), _jsx(OverlayComponent, { children: _jsx(_Fragment, { children: isOpen && (_jsxs(RangeWrapper, { className: "ignore-element-for-closing-hook", children: [_jsx(DatePicker, __assign({}, rest, { timeFormat: timeFormat, value: (_c = cleanValue[0]) !== null && _c !== void 0 ? _c : '', initialViewDate: initialViewDate[0], secondValue: endRangeValue, onChange: setDateFrom, icon: false, label: isOpen && _jsx(Trans, { id: "dataGrid.filterCell.from", message: "From" }), isValidDate: isValidDateFrom, input: false, spaceAround: true, open: true, disabled: cleanValue[0] === null })), _jsx(DatePicker, __assign({}, rest, { timeFormat: timeFormat, value: secondDatePickerValue, initialViewDate: initialViewDate[1], secondValue: startRangeValue, onChange: setDateTo, icon: false, label: isOpen && _jsx(Trans, { id: "dataGrid.filterCell.to", message: "To" }), isValidDate: isValidDateTo, input: false, spaceAround: true, open: true, disabled: secondDatePickerValue === null }))] })) }) })] }));
|
|
111
111
|
};
|
|
112
112
|
export default DatePickerRange;
|
|
113
113
|
var templateObject_1;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export declare const List: import("styled-components").StyledComponent<"ul", import("@xstyled/system").Theme, {}, never>;
|
|
2
3
|
export declare const ListItem: import("styled-components").StyledComponent<"li", import("@xstyled/system").Theme, {}, never>;
|
|
3
4
|
export declare const ListItemContent: import("styled-components").StyledComponent<"span", import("@xstyled/system").Theme, {
|
|
@@ -7,7 +8,7 @@ export declare const ListItemIcon: import("styled-components").StyledComponent<"
|
|
|
7
8
|
type Item = {
|
|
8
9
|
value: string;
|
|
9
10
|
icon: string;
|
|
10
|
-
label: string;
|
|
11
|
+
label: string | JSX.Element;
|
|
11
12
|
};
|
|
12
13
|
type IconListProps = {
|
|
13
14
|
list: Item[];
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useCallback, useState } from 'react';
|
|
3
|
-
import { t } from '@lingui/macro';
|
|
4
3
|
import { x } from '@xstyled/styled-components';
|
|
5
4
|
import { ActionRow } from './components/ActionRow';
|
|
6
5
|
import { Input } from '../../../../Forms/Input/Input';
|
|
@@ -13,7 +12,9 @@ var ManageColumnForm = function (_a) {
|
|
|
13
12
|
var clear = useCallback(function () {
|
|
14
13
|
setSearchedValue('');
|
|
15
14
|
}, [setSearchedValue]);
|
|
16
|
-
return (_jsxs(x.div, { children: [_jsx(Input, { icon: "search", type: "text", value: searchedValue,
|
|
15
|
+
return (_jsxs(x.div, { children: [_jsx(Input, { icon: "search", type: "text", value: searchedValue,
|
|
16
|
+
// placeholder={<Trans id="manageColumn.searchPlaceholder" message="Find column..." />}
|
|
17
|
+
onChange: onChangeInputValue, onClear: clear, variant: "gray" }), _jsx(x.div, { h: "400px", overflowY: "scroll", mt: "20px", children: columns === null || columns === void 0 ? void 0 : columns.map(function (column, index) {
|
|
17
18
|
return (_jsx(ActionRow, { column: column, columnsConfigValues: columnsConfigValues, setColumnsConfigOptions: setColumnsConfigOptions, searchedValue: searchedValue }, index));
|
|
18
19
|
}) })] }));
|
|
19
20
|
};
|
|
@@ -16,12 +16,12 @@ var __assign = (this && this.__assign) || function () {
|
|
|
16
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
17
|
import { useCallback, useState } from 'react';
|
|
18
18
|
import { x, th } from '@xstyled/styled-components';
|
|
19
|
-
import { t } from '@lingui/macro';
|
|
20
19
|
import styled from 'styled-components';
|
|
21
20
|
import Toggle from '../../../../../Elements/Toggle/Toggle';
|
|
22
21
|
import { Group } from '../../../../../Elements/Icon/icons/Group';
|
|
23
22
|
import { isObject } from 'lodash';
|
|
24
23
|
import { H6 } from '../../../../../Elements/Typography/Typography';
|
|
24
|
+
import { Trans } from '@lingui/react';
|
|
25
25
|
var RowLayout = styled(x.div)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: ", ";\n align-items: center;\n justify-content: space-between;\n padding: 16px;\n height: 52px;\n border: 1px solid ", ";\n border-radius: 8px;\n margin-bottom: 15px;\n"], ["\n display: ", ";\n align-items: center;\n justify-content: space-between;\n padding: 16px;\n height: 52px;\n border: 1px solid ", ";\n border-radius: 8px;\n margin-bottom: 15px;\n"])), function (_a) {
|
|
26
26
|
var $isVisible = _a.$isVisible;
|
|
27
27
|
return ($isVisible ? 'flex' : 'none');
|
|
@@ -30,10 +30,7 @@ export var ActionRow = function (_a) {
|
|
|
30
30
|
var _b, _c, _d, _e, _f;
|
|
31
31
|
var column = _a.column, columnsConfigValues = _a.columnsConfigValues, setColumnsConfigOptions = _a.setColumnsConfigOptions, searchedValue = _a.searchedValue;
|
|
32
32
|
var _g = useState((_b = columnsConfigValues === null || columnsConfigValues === void 0 ? void 0 : columnsConfigValues.includes(column.name)) !== null && _b !== void 0 ? _b : false), isSelected = _g[0], setIsSelected = _g[1];
|
|
33
|
-
var translatedValue = isObject(column === null || column === void 0 ? void 0 : column.title) &&
|
|
34
|
-
'props' in column.title &&
|
|
35
|
-
((_c = column.title) === null || _c === void 0 ? void 0 : _c.props) &&
|
|
36
|
-
t({ id: (_e = (_d = column.title) === null || _d === void 0 ? void 0 : _d.props) === null || _e === void 0 ? void 0 : _e.id, message: (_f = column.title) === null || _f === void 0 ? void 0 : _f.props.message });
|
|
33
|
+
var translatedValue = isObject(column === null || column === void 0 ? void 0 : column.title) && 'props' in column.title && ((_c = column.title) === null || _c === void 0 ? void 0 : _c.props) && (_jsx(Trans, { id: (_e = (_d = column.title) === null || _d === void 0 ? void 0 : _d.props) === null || _e === void 0 ? void 0 : _e.id, values: (_f = column.title) === null || _f === void 0 ? void 0 : _f.props.message }));
|
|
37
34
|
var isVisible = translatedValue && translatedValue.toLocaleLowerCase().includes(searchedValue.toLocaleLowerCase());
|
|
38
35
|
var handleToggleChange = useCallback(function () {
|
|
39
36
|
setColumnsConfigOptions(function (prevOptions) {
|
|
@@ -22,33 +22,33 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
24
|
import { useCallback, useState } from 'react';
|
|
25
|
-
import { t } from '@lingui/macro';
|
|
26
25
|
import { useClickOutside } from '../../../Modal/hooks/useClickOutside';
|
|
27
26
|
import { Input } from '../../../../Forms/Input/Input';
|
|
28
27
|
import IconList from '../IconList';
|
|
28
|
+
import { Trans } from '@lingui/react';
|
|
29
29
|
var OverlayComponentDefault = function (_a) {
|
|
30
30
|
var children = _a.children;
|
|
31
31
|
return _jsx("div", { children: children });
|
|
32
32
|
};
|
|
33
33
|
var createNumberComparators = function () { return [
|
|
34
|
-
{ label:
|
|
35
|
-
{ label:
|
|
36
|
-
{ label:
|
|
34
|
+
{ label: _jsx(Trans, { id: "dataGrid.comparator.equals", message: "Equals" }), value: 'eq', icon: 'equals' },
|
|
35
|
+
{ label: _jsx(Trans, { id: "dataGrid.comparator.notEquals", message: "Not equal" }), value: 'neq', icon: 'notEqual' },
|
|
36
|
+
{ label: _jsx(Trans, { id: "dataGrid.comparator.lessThan", message: "Less than" }), value: 'lt', icon: 'lessThen' },
|
|
37
37
|
{
|
|
38
|
-
label:
|
|
38
|
+
label: _jsx(Trans, { id: "dataGrid.comparator.lessThanOrEquals", message: "Less than or equals" }),
|
|
39
39
|
value: 'lte',
|
|
40
40
|
icon: 'lessThanEqual',
|
|
41
41
|
},
|
|
42
|
-
{ label:
|
|
42
|
+
{ label: _jsx(Trans, { id: "dataGrid.comparator.greaterThan", message: "Greater than" }), value: 'gt', icon: 'greaterThan' },
|
|
43
43
|
{
|
|
44
|
-
label:
|
|
44
|
+
label: _jsx(Trans, { id: "dataGrid.comparator.greaterThanOrEquals", message: "Greater than or equal" }),
|
|
45
45
|
value: 'gte',
|
|
46
46
|
icon: 'greaterThanEqual',
|
|
47
47
|
},
|
|
48
48
|
]; };
|
|
49
49
|
var createEqualComparators = [
|
|
50
|
-
{ label:
|
|
51
|
-
{ label:
|
|
50
|
+
{ label: _jsx(Trans, { id: "dataGrid.comparator.equals", message: "Equals" }), value: 'eq', icon: 'equals' },
|
|
51
|
+
{ label: _jsx(Trans, { id: "dataGrid.comparator.notEquals", message: "Not equal" }), value: 'neq', icon: 'notEqual' },
|
|
52
52
|
];
|
|
53
53
|
var NumberRange = function (props) {
|
|
54
54
|
var numberComparators = createNumberComparators();
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { FilterComponentProps } from '../../types';
|
|
2
3
|
export type ComparatorValue = 'eq' | 'neq' | 'lt' | 'lte' | 'gt' | 'gte';
|
|
3
4
|
export type NumberRangeValue = {
|
|
@@ -5,7 +6,7 @@ export type NumberRangeValue = {
|
|
|
5
6
|
value?: string | number;
|
|
6
7
|
};
|
|
7
8
|
export type Comparator = {
|
|
8
|
-
label: string;
|
|
9
|
+
label: string | JSX.Element;
|
|
9
10
|
value: string;
|
|
10
11
|
icon: string;
|
|
11
12
|
};
|
|
@@ -22,7 +22,6 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
};
|
|
23
23
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
24
24
|
import { useCallback, useState } from 'react';
|
|
25
|
-
import { t } from '@lingui/macro';
|
|
26
25
|
import { Trans } from '@lingui/react';
|
|
27
26
|
import { useClickOutside } from '../../../Modal/hooks/useClickOutside';
|
|
28
27
|
import { Input } from '../../../../Forms/Input/Input';
|
|
@@ -33,20 +32,20 @@ var OverlayComponentDefault = function (_a) {
|
|
|
33
32
|
};
|
|
34
33
|
export var ipv4 = /^([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.([01]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/;
|
|
35
34
|
var createTextComparators = function () { return [
|
|
36
|
-
{ label:
|
|
37
|
-
{ label:
|
|
38
|
-
{ label:
|
|
39
|
-
{ label:
|
|
40
|
-
{ label:
|
|
41
|
-
{ label:
|
|
35
|
+
{ label: '1', value: 'like', icon: 'check' },
|
|
36
|
+
{ label: '1', value: 'notLike', icon: 'false' },
|
|
37
|
+
{ label: '1', value: 'eq', icon: 'equals' },
|
|
38
|
+
{ label: '1', value: 'neq', icon: 'notEqual' },
|
|
39
|
+
{ label: '1', value: 'startsWith', icon: 'startsWith' },
|
|
40
|
+
{ label: '1', value: 'endsWith', icon: 'endsWith' },
|
|
42
41
|
]; };
|
|
43
42
|
var createPresentTextComparators = function () { return [
|
|
44
|
-
{ label:
|
|
45
|
-
{ label:
|
|
43
|
+
{ label: '1', value: 'like', icon: 'check' },
|
|
44
|
+
{ label: '1', value: 'in', icon: 'equals' },
|
|
46
45
|
]; };
|
|
47
46
|
var createEqualComparators = function () { return [
|
|
48
|
-
{ label:
|
|
49
|
-
{ label:
|
|
47
|
+
{ label: '1', value: 'eq', icon: 'equals' },
|
|
48
|
+
{ label: '1', value: 'neq', icon: 'notEqual' },
|
|
50
49
|
]; };
|
|
51
50
|
var validations = {
|
|
52
51
|
ip: {
|
|
@@ -56,7 +55,7 @@ var validations = {
|
|
|
56
55
|
};
|
|
57
56
|
var TextRange = function (props) {
|
|
58
57
|
var name = props.name, _a = props.value, value = _a === void 0 ? {} : _a, label = props.label, onChange = props.onChange, className = props.className, _b = props.OverlayComponent, OverlayComponent = _b === void 0 ? OverlayComponentDefault : _b, eqOnly = props.eqOnly, isPresent = props.isPresent, isEqual = props.isEqual, defaultComparator = props.defaultComparator, validationKey = props.validation, rest = __rest(props, ["name", "value", "label", "onChange", "className", "OverlayComponent", "eqOnly", "isPresent", "isEqual", "defaultComparator", "validation"]);
|
|
59
|
-
var eqOnlyTxt =
|
|
58
|
+
var eqOnlyTxt = '1';
|
|
60
59
|
var _c = useState(false), isOpen = _c[0], setOpen = _c[1];
|
|
61
60
|
var textComparators = createTextComparators();
|
|
62
61
|
var presentTextComparators = createPresentTextComparators();
|
|
@@ -4,7 +4,7 @@ import { DatetimepickerProps } from './Datetime/types';
|
|
|
4
4
|
export type DatePickerType = DatetimepickerProps & {
|
|
5
5
|
onChange: (value: string | Date) => void;
|
|
6
6
|
disabled?: boolean;
|
|
7
|
-
label?: string;
|
|
7
|
+
label?: string | JSX.Element;
|
|
8
8
|
name?: string;
|
|
9
9
|
initialViewDate?: Date | null;
|
|
10
10
|
secondValue?: Date | null;
|
|
@@ -46,7 +46,7 @@ export interface DatetimepickerProps {
|
|
|
46
46
|
timeConstraints?: TimeConstraints;
|
|
47
47
|
closeOnClickOutside?: boolean;
|
|
48
48
|
secondValue?: Date | null;
|
|
49
|
-
label?: string;
|
|
49
|
+
label?: string | JSX.Element;
|
|
50
50
|
}
|
|
51
51
|
export interface DatetimepickerState {
|
|
52
52
|
updateOn: string;
|
|
@@ -25,13 +25,13 @@ import { useCallback, useMemo } from 'react';
|
|
|
25
25
|
import { Wrapper, StyledReactSelect, StyledAsyncSelect } from './styles';
|
|
26
26
|
import { useStylesAndComponents } from './themes';
|
|
27
27
|
import { useTheme } from '@xstyled/styled-components';
|
|
28
|
-
import { t } from '@lingui/macro';
|
|
29
28
|
import SpaceAroundWrap from '../SpaceAround';
|
|
30
29
|
import { FieldLabel } from '../Label';
|
|
31
30
|
import { ErrorMessage } from '../ErrorMessage';
|
|
31
|
+
import { Trans } from '@lingui/react';
|
|
32
32
|
var emptyOptions = [];
|
|
33
|
-
var noOptionsMessage = function () { return
|
|
34
|
-
var loadingMessage = function () { return
|
|
33
|
+
var noOptionsMessage = function () { return _jsx(Trans, { id: "select.noOptions", message: "no options" }); };
|
|
34
|
+
var loadingMessage = function () { return _jsx(Trans, { id: "components.dropdown.loading", message: "Loading..." }); };
|
|
35
35
|
var Select = function (_a) {
|
|
36
36
|
var label = _a.label, name = _a.name, _b = _a.value, value = _b === void 0 ? '' : _b, _c = _a.options, options = _c === void 0 ? emptyOptions : _c, defaultOptions = _a.defaultOptions, loadOptions = _a.loadOptions, onChange = _a.onChange, onBlur = _a.onBlur, error = _a.error, isInvalid = _a.isInvalid, isLoading = _a.isLoading, isDarkPlaceholderText = _a.isDarkPlaceholderText, _d = _a.spaceAround, spaceAround = _d === void 0 ? false : _d, disabled = _a.disabled, onInputChange = _a.onInputChange, isSearchable = _a.isSearchable, isMulti = _a.isMulti, className = _a.className, _e = _a.useSimplifiedOptions, useSimplifiedOptions = _e === void 0 ? false : _e, _f = _a.showSelectAllButton, showSelectAllButton = _f === void 0 ? false : _f, _g = _a.showResetGridButton, showResetGridButton = _g === void 0 ? false : _g, style = _a.style, optionVariant = _a.optionVariant, multiLabelVariant = _a.multiLabelVariant, containerVariant = _a.containerVariant, placeholder = _a.placeholder, placeholderIcon = _a.placeholderIcon, innerRef = _a.innerRef, maxMenuHeight = _a.maxMenuHeight, getOptionValue = _a.getOptionValue, resetGrid = _a.resetGrid, passTroughProps = __rest(_a, ["label", "name", "value", "options", "defaultOptions", "loadOptions", "onChange", "onBlur", "error", "isInvalid", "isLoading", "isDarkPlaceholderText", "spaceAround", "disabled", "onInputChange", "isSearchable", "isMulti", "className", "useSimplifiedOptions", "showSelectAllButton", "showResetGridButton", "style", "optionVariant", "multiLabelVariant", "containerVariant", "placeholder", "placeholderIcon", "innerRef", "maxMenuHeight", "getOptionValue", "resetGrid"]);
|
|
37
37
|
var isAsync = !!loadOptions;
|
|
@@ -64,6 +64,6 @@ var Select = function (_a) {
|
|
|
64
64
|
var handleLoadOptions = useMemo(function () {
|
|
65
65
|
return loadOptions ? function (fulltext) { return loadOptions(fulltext); } : undefined;
|
|
66
66
|
}, [loadOptions]);
|
|
67
|
-
return (_jsxs(SpaceAroundWrap, { spaceAround: spaceAround, className: className, children: [_jsxs(Wrapper, { children: [label && _jsx(FieldLabel, { htmlFor: name, children: label }), _jsx(RenderComponent, __assign({ id: name, name: name, options: options, loadOptions: handleLoadOptions, defaultOptions: defaultOptions, value: selectedOption, onChange: onChange, onBlur: onBlur, isDisabled: disabled || isLoading, isLoading: isLoading, isInvalid: isInvalid !== undefined ? isInvalid : !!error, isDarkPlaceholderText: isDarkPlaceholderText, placeholder: placeholder
|
|
67
|
+
return (_jsxs(SpaceAroundWrap, { spaceAround: spaceAround, className: className, children: [_jsxs(Wrapper, { children: [label && _jsx(FieldLabel, { htmlFor: name, children: label }), _jsx(RenderComponent, __assign({ id: name, name: name, options: options, loadOptions: handleLoadOptions, defaultOptions: defaultOptions, value: selectedOption, onChange: onChange, onBlur: onBlur, isDisabled: disabled || isLoading, isLoading: isLoading, isInvalid: isInvalid !== undefined ? isInvalid : !!error, isDarkPlaceholderText: isDarkPlaceholderText, placeholder: placeholder, styles: customStyles, theme: customTheme, icon: icon, hideSelectedOptions: !!(isMulti && multiLabelVariant != 'count'), onInputChange: onInputChange, isSearchable: isAsync || isSearchable, isMulti: isMulti, classNamePrefix: "react-select", components: customComponents, closeMenuOnSelect: isMulti ? false : undefined }, passTroughProps, { ref: innerRef, tabIndex: null, systemTheme: theme, resetGrid: resetGrid, onCustomSelectAll: setAllOptions, onCustomDeselectAll: unsetAllOptions, selectAllButton: showSelectAllButton, resetGridButton: showResetGridButton, maxMenuHeight: modifiedMaxMenuHeight, getOptionValue: getOptionValue, noOptionsMessage: noOptionsMessage, loadingMessage: loadingMessage }))] }), error && _jsx(ErrorMessage, { children: error })] }));
|
|
68
68
|
};
|
|
69
69
|
export default Select;
|
|
@@ -3,7 +3,7 @@ import { SpaceAround } from '../SpaceAround/types';
|
|
|
3
3
|
import { Theme } from 'react-select';
|
|
4
4
|
export type Option<Value = string | number> = {
|
|
5
5
|
value: Value;
|
|
6
|
-
label: string | number;
|
|
6
|
+
label: string | number | JSX.Element;
|
|
7
7
|
isDisabled?: boolean;
|
|
8
8
|
isFixed?: boolean;
|
|
9
9
|
color?: string;
|
|
@@ -54,13 +54,14 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
54
54
|
}
|
|
55
55
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
56
|
};
|
|
57
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
57
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
58
58
|
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
59
59
|
import { createFilter } from 'react-select';
|
|
60
60
|
import Select from '../Select';
|
|
61
61
|
import omit from 'lodash/fp/omit';
|
|
62
|
-
import { t } from '@lingui/macro';
|
|
63
62
|
import { nanoid } from 'nanoid';
|
|
63
|
+
import { Trans } from '@lingui/react';
|
|
64
|
+
import { t } from '@lingui/macro';
|
|
64
65
|
var CREATE = "_create_".concat(nanoid(), "_");
|
|
65
66
|
var defaultFilterOption = createFilter();
|
|
66
67
|
var creatableFilterOption = function (option, rawInput) {
|
|
@@ -79,18 +80,15 @@ var getOptionValue = function (selectedOption) {
|
|
|
79
80
|
return selectedOption.value;
|
|
80
81
|
}
|
|
81
82
|
};
|
|
83
|
+
var loadingMessage = function () { return _jsx(Trans, { id: "components.dropdown.loading", message: "Loading..." }); };
|
|
82
84
|
var SingleSelect = function (props) {
|
|
83
|
-
var name = props.name, onChange = props.onChange, onBlur = props.onBlur, onValueChange = props.onValueChange, loadOptions = props.loadOptions, _a = props.asyncLoadMinChars, asyncLoadMinChars = _a === void 0 ? 0 : _a, isLocked = props.isLocked,
|
|
84
|
-
|
|
85
|
+
var name = props.name, onChange = props.onChange, onBlur = props.onBlur, onValueChange = props.onValueChange, loadOptions = props.loadOptions, _a = props.asyncLoadMinChars, asyncLoadMinChars = _a === void 0 ? 0 : _a, isLocked = props.isLocked, lockedText = props.lockedText, //= <Trans id="components.dropdown.notReact" message="Select related values first..." />,
|
|
86
|
+
disabled = props.disabled, placeholder = props.placeholder, // = <Trans id="components.dropdown.placeholder" message="Select..." />,
|
|
87
|
+
preload = props.preload, initialOptions = props.initialOptions, onCreateOption = props.onCreateOption, options = props.options, filterOption = props.filterOption;
|
|
88
|
+
var _b = useState(false), isCreating = _b[0], setIsCreating = _b[1];
|
|
85
89
|
var asAsync = !!loadOptions || !!onCreateOption;
|
|
86
|
-
var loadingMessage = useCallback(function () { return t({ id: 'components.dropdown.loading', message: 'Loading...' }); }, []);
|
|
87
90
|
var noOptionsMessage = useCallback(function (inputValue) {
|
|
88
|
-
return loadOptions && inputValue.length < asyncLoadMinChars
|
|
89
|
-
? t({
|
|
90
|
-
id: 'components.dropdown.writeMoreChars',
|
|
91
|
-
message: 'Write at least ${asyncLoadMinChars} characters.',
|
|
92
|
-
})
|
|
93
|
-
: t({ id: 'components.dropdown.noOptions', message: 'No options' });
|
|
91
|
+
return loadOptions && inputValue.length < asyncLoadMinChars ? (_jsx(Trans, { id: "components.dropdown.writeMoreChars", message: "Write at least ${asyncLoadMinChars} characters." })) : (_jsx(Trans, { id: "components.dropdown.noOptions", message: "No options" }));
|
|
94
92
|
}, [loadOptions, asyncLoadMinChars]);
|
|
95
93
|
var handleLoadOptions = useCallback(function (inputValue) {
|
|
96
94
|
if (onCreateOption) {
|
|
@@ -99,7 +97,7 @@ var SingleSelect = function (props) {
|
|
|
99
97
|
return Promise.resolve(__spreadArray(__spreadArray([], (options || []), true), [
|
|
100
98
|
{
|
|
101
99
|
value: CREATE,
|
|
102
|
-
label: ""
|
|
100
|
+
label: (_jsxs(_Fragment, { children: ["$", inputValue, " ", _jsx(Trans, { id: "components.dropdown.newOption", message: "new value" })] })),
|
|
103
101
|
inputValue: inputValue,
|
|
104
102
|
},
|
|
105
103
|
], false));
|
|
@@ -111,13 +109,13 @@ var SingleSelect = function (props) {
|
|
|
111
109
|
return loadOptions(inputValue, false);
|
|
112
110
|
}
|
|
113
111
|
}, [onCreateOption, loadOptions, asyncLoadMinChars, options]);
|
|
114
|
-
var
|
|
112
|
+
var _c = useState(options || []), loadedDefaultOptions = _c[0], setLoadedDefaultOptions = _c[1];
|
|
115
113
|
useEffect(function () {
|
|
116
114
|
if (loadOptions && preload && !props.value)
|
|
117
115
|
loadOptions('', false).then(setLoadedDefaultOptions);
|
|
118
116
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
119
117
|
}, [loadOptions]); // this is intentional
|
|
120
|
-
var
|
|
118
|
+
var _d = useState(null), storedSelectedOption = _d[0], setStoredSelectedOption = _d[1];
|
|
121
119
|
useEffect(function () {
|
|
122
120
|
if (initialOptions && initialOptions.length) {
|
|
123
121
|
var selectedOption = initialOptions.find(function (option) { return option.value == props.value; }) || null;
|