@mailstep/design-system 0.5.0-beta.13 → 0.5.0-beta.14
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/StandardButtons.js +1 -2
- package/ui/Blocks/CommonGrid/components/ActionHead/ActionHead.js +1 -6
- package/ui/Blocks/CommonGrid/components/BooleanSelect/BooleanSelect.js +3 -4
- package/ui/Blocks/CommonGrid/components/DatePickerRange/DatePickerRange.js +2 -3
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/ManageColumnForm.js +1 -2
- package/ui/Blocks/CommonGrid/components/ManageColumnForm/components/ActionRow.js +3 -7
- package/ui/Blocks/CommonGrid/components/NumberRange/NumberRange.js +8 -9
- package/ui/Blocks/CommonGrid/components/TextRange/TextRange.js +11 -12
- package/ui/Elements/Select/Select.js +3 -4
- package/ui/Elements/SingleSelect/SingleSelect.js +5 -11
package/package.json
CHANGED
|
@@ -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: 1 }), _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,12 +21,11 @@ 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 { t } from '@lingui/macro';
|
|
25
24
|
import GridSelect from '../GridSelect';
|
|
26
25
|
var getFlagOptions = function () { return [
|
|
27
|
-
{ value: '', label:
|
|
28
|
-
{ value: '1', label:
|
|
29
|
-
{ value: '0', label:
|
|
26
|
+
{ value: '', label: 1 },
|
|
27
|
+
{ value: '1', label: 1 },
|
|
28
|
+
{ value: '0', label: 1 },
|
|
30
29
|
]; };
|
|
31
30
|
var SelectFilter = function (_a) {
|
|
32
31
|
var restProps = __rest(_a, []);
|
|
@@ -29,7 +29,6 @@ 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';
|
|
@@ -64,7 +63,7 @@ var DatePickerRange = function (props) {
|
|
|
64
63
|
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
64
|
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
65
|
var timeFormat = filterTime ? 'HH:mm' : false;
|
|
67
|
-
var placeholder =
|
|
66
|
+
var placeholder = '1';
|
|
68
67
|
var cleanValue = React.useMemo(function () { return [
|
|
69
68
|
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
69
|
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 +106,7 @@ var DatePickerRange = function (props) {
|
|
|
107
106
|
// Check if the second value is not selected and the first value is the same as the initial value
|
|
108
107
|
var secondDatePickerValue = cleanValue[1] === null ? cleanValue[0] : cleanValue[1];
|
|
109
108
|
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 &&
|
|
109
|
+
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 && '1', 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 && '1', isValidDate: isValidDateTo, input: false, spaceAround: true, open: true, disabled: secondDatePickerValue === null }))] })) }) })] }));
|
|
111
110
|
};
|
|
112
111
|
export default DatePickerRange;
|
|
113
112
|
var templateObject_1;
|
|
@@ -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,7 @@ 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, placeholder:
|
|
15
|
+
return (_jsxs(x.div, { children: [_jsx(Input, { icon: "search", type: "text", value: searchedValue, placeholder: '1', 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
16
|
return (_jsx(ActionRow, { column: column, columnsConfigValues: columnsConfigValues, setColumnsConfigOptions: setColumnsConfigOptions, searchedValue: searchedValue }, index));
|
|
18
17
|
}) })] }));
|
|
19
18
|
};
|
|
@@ -16,7 +16,6 @@ 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';
|
|
@@ -27,13 +26,10 @@ var RowLayout = styled(x.div)(templateObject_1 || (templateObject_1 = __makeTemp
|
|
|
27
26
|
return ($isVisible ? 'flex' : 'none');
|
|
28
27
|
}, th.color('lightGray6'));
|
|
29
28
|
export var ActionRow = function (_a) {
|
|
30
|
-
var _b, _c
|
|
29
|
+
var _b, _c;
|
|
31
30
|
var column = _a.column, columnsConfigValues = _a.columnsConfigValues, setColumnsConfigOptions = _a.setColumnsConfigOptions, searchedValue = _a.searchedValue;
|
|
32
|
-
var
|
|
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 });
|
|
31
|
+
var _d = useState((_b = columnsConfigValues === null || columnsConfigValues === void 0 ? void 0 : columnsConfigValues.includes(column.name)) !== null && _b !== void 0 ? _b : false), isSelected = _d[0], setIsSelected = _d[1];
|
|
32
|
+
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) && 12;
|
|
37
33
|
var isVisible = translatedValue && translatedValue.toLocaleLowerCase().includes(searchedValue.toLocaleLowerCase());
|
|
38
34
|
var handleToggleChange = useCallback(function () {
|
|
39
35
|
setColumnsConfigOptions(function (prevOptions) {
|
|
@@ -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 { useClickOutside } from '../../../Modal/hooks/useClickOutside';
|
|
27
26
|
import { Input } from '../../../../Forms/Input/Input';
|
|
28
27
|
import IconList from '../IconList';
|
|
@@ -31,24 +30,24 @@ var OverlayComponentDefault = function (_a) {
|
|
|
31
30
|
return _jsx("div", { children: children });
|
|
32
31
|
};
|
|
33
32
|
var createNumberComparators = function () { return [
|
|
34
|
-
{ label:
|
|
35
|
-
{ label:
|
|
36
|
-
{ label:
|
|
33
|
+
{ label: '1', value: 'eq', icon: 'equals' },
|
|
34
|
+
{ label: '1', value: 'neq', icon: 'notEqual' },
|
|
35
|
+
{ label: '1', value: 'lt', icon: 'lessThen' },
|
|
37
36
|
{
|
|
38
|
-
label:
|
|
37
|
+
label: '1',
|
|
39
38
|
value: 'lte',
|
|
40
39
|
icon: 'lessThanEqual',
|
|
41
40
|
},
|
|
42
|
-
{ label:
|
|
41
|
+
{ label: '1', value: 'gt', icon: 'greaterThan' },
|
|
43
42
|
{
|
|
44
|
-
label:
|
|
43
|
+
label: '1',
|
|
45
44
|
value: 'gte',
|
|
46
45
|
icon: 'greaterThanEqual',
|
|
47
46
|
},
|
|
48
47
|
]; };
|
|
49
48
|
var createEqualComparators = [
|
|
50
|
-
{ label:
|
|
51
|
-
{ label:
|
|
49
|
+
{ label: '1', value: 'eq', icon: 'equals' },
|
|
50
|
+
{ label: '1', value: 'neq', icon: 'notEqual' },
|
|
52
51
|
];
|
|
53
52
|
var NumberRange = function (props) {
|
|
54
53
|
var numberComparators = createNumberComparators();
|
|
@@ -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();
|
|
@@ -25,13 +25,12 @@ 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';
|
|
32
31
|
var emptyOptions = [];
|
|
33
|
-
var noOptionsMessage = function () { return
|
|
34
|
-
var loadingMessage = function () { return
|
|
32
|
+
var noOptionsMessage = function () { return '1'; };
|
|
33
|
+
var loadingMessage = function () { return '1'; };
|
|
35
34
|
var Select = function (_a) {
|
|
36
35
|
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
36
|
var isAsync = !!loadOptions;
|
|
@@ -64,6 +63,6 @@ var Select = function (_a) {
|
|
|
64
63
|
var handleLoadOptions = useMemo(function () {
|
|
65
64
|
return loadOptions ? function (fulltext) { return loadOptions(fulltext); } : undefined;
|
|
66
65
|
}, [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 ||
|
|
66
|
+
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 || '1', 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
67
|
};
|
|
69
68
|
export default Select;
|
|
@@ -59,7 +59,6 @@ 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';
|
|
64
63
|
var CREATE = "_create_".concat(nanoid(), "_");
|
|
65
64
|
var defaultFilterOption = createFilter();
|
|
@@ -80,17 +79,12 @@ var getOptionValue = function (selectedOption) {
|
|
|
80
79
|
}
|
|
81
80
|
};
|
|
82
81
|
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, _b = props.lockedText, lockedText = _b === void 0 ?
|
|
82
|
+
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, _b = props.lockedText, lockedText = _b === void 0 ? '1' : _b, disabled = props.disabled, _c = props.placeholder, placeholder = _c === void 0 ? '1' : _c, preload = props.preload, initialOptions = props.initialOptions, onCreateOption = props.onCreateOption, options = props.options, filterOption = props.filterOption;
|
|
84
83
|
var _d = useState(false), isCreating = _d[0], setIsCreating = _d[1];
|
|
85
84
|
var asAsync = !!loadOptions || !!onCreateOption;
|
|
86
|
-
var loadingMessage = useCallback(function () { return
|
|
85
|
+
var loadingMessage = useCallback(function () { return '1'; }, []);
|
|
87
86
|
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' });
|
|
87
|
+
return loadOptions && inputValue.length < asyncLoadMinChars ? '1' : '1';
|
|
94
88
|
}, [loadOptions, asyncLoadMinChars]);
|
|
95
89
|
var handleLoadOptions = useCallback(function (inputValue) {
|
|
96
90
|
if (onCreateOption) {
|
|
@@ -99,7 +93,7 @@ var SingleSelect = function (props) {
|
|
|
99
93
|
return Promise.resolve(__spreadArray(__spreadArray([], (options || []), true), [
|
|
100
94
|
{
|
|
101
95
|
value: CREATE,
|
|
102
|
-
label: "".concat(inputValue, " (
|
|
96
|
+
label: "".concat(inputValue, " ()"),
|
|
103
97
|
inputValue: inputValue,
|
|
104
98
|
},
|
|
105
99
|
], false));
|
|
@@ -138,7 +132,7 @@ var SingleSelect = function (props) {
|
|
|
138
132
|
if (!(onCreateOption && (option === null || option === void 0 ? void 0 : option.value) == CREATE)) return [3 /*break*/, 4];
|
|
139
133
|
if (!((option === null || option === void 0 ? void 0 : option.inputValue) && ((_b = (_a = option === null || option === void 0 ? void 0 : option.inputValue) === null || _a === void 0 ? void 0 : _a.trim()) === null || _b === void 0 ? void 0 : _b.length) < 2)) return [3 /*break*/, 1];
|
|
140
134
|
props === null || props === void 0 ? void 0 : props.form.setFieldTouched(name, true, true);
|
|
141
|
-
props === null || props === void 0 ? void 0 : props.form.setFieldError(name,
|
|
135
|
+
props === null || props === void 0 ? void 0 : props.form.setFieldError(name, '');
|
|
142
136
|
return [2 /*return*/];
|
|
143
137
|
case 1:
|
|
144
138
|
setIsCreating(true);
|