@mailstep/design-system 0.5.0-beta.14 → 0.5.0-beta.16

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailstep/design-system",
3
- "version": "0.5.0-beta.14",
3
+ "version": "0.5.0-beta.16",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -21,7 +21,6 @@
21
21
  "devDependencies": {
22
22
  "@babel/preset-env": "^7.22.4",
23
23
  "@babel/preset-react": "^7.22.3",
24
- "@babel/preset-typescript": "^7.21.5",
25
24
  "@fortawesome/fontawesome-svg-core": "^6.3.0",
26
25
  "@fortawesome/free-brands-svg-icons": "^6.1.1",
27
26
  "@fortawesome/pro-duotone-svg-icons": "^6.0.0",
@@ -54,8 +53,6 @@
54
53
  "@types/styled-components": "^5.1.26",
55
54
  "@vitejs/plugin-react": "^4.2.1",
56
55
  "@xstyled/styled-components": "^3.8.0",
57
- "babel-loader": "^9.1.2",
58
- "babel-plugin-macros": "^3.1.0",
59
56
  "babel-plugin-named-exports-order": "^0.0.2",
60
57
  "eslint-plugin-storybook": "0.6.15",
61
58
  "faker": "^5.1.0",
@@ -88,7 +85,11 @@
88
85
  "vite": "^5.0.10",
89
86
  "vite-plugin-dts": "^3.6.4",
90
87
  "vite-plugin-static-copy": "^1.0.0",
91
- "webpack": "^5.82.1"
88
+ "webpack": "^5.82.1",
89
+ "@babel/core": "^7.20.12",
90
+ "@babel/preset-typescript": "^7.23.3",
91
+ "babel-loader": "^9.1.3",
92
+ "babel-plugin-macros": "^3.1.0"
92
93
  },
93
94
  "peerDependencies": {
94
95
  "@fortawesome/fontawesome-svg-core": "^6.3.0",
@@ -125,7 +126,11 @@
125
126
  "styled-components": "^5.3.10",
126
127
  "swiper": "^11.0.3",
127
128
  "tslib": "^2.6.2",
128
- "typescript": "^5.0.4"
129
+ "typescript": "^5.0.4",
130
+ "@babel/core": "^7.20.12",
131
+ "@babel/preset-typescript": "^7.23.3",
132
+ "babel-loader": "^9.1.3",
133
+ "babel-plugin-macros": "^3.1.0"
129
134
  },
130
135
  "resolutions": {
131
136
  "jackspeak": "2.1.1"
@@ -42,7 +42,7 @@ var ActionHead = function (_a) {
42
42
  return [];
43
43
  }, [actionColumn, onSubmit]);
44
44
  var canExport = typeof onExport === 'function';
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" }))] })] }) })) }));
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" }))] })] }) })) }));
46
46
  };
47
47
  export default ActionHead;
48
48
  var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5;
@@ -8,7 +8,7 @@ import styled from '@xstyled/styled-components';
8
8
  import { th } from '@xstyled/system';
9
9
  import { Trans } from '@lingui/react';
10
10
  import ActionDropdownMenu from './ActionDropdownMenu';
11
- import { Popover } from '../../../../Popover';
11
+ import Popover from '../../../../Popover';
12
12
  import Icon from '../../../../../Elements/Icon/Icon';
13
13
  var Content = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n display: flex;\n align-items: center;\n padding: 1 2;\n min-width: 9rem;\n height: 28px;\n background-color: ", ";\n color: ", ";\n border: slim;\n border-color: ", ";\n font-size: 12px;\n font-weight: 600;\n border-radius: 6px;\n cursor: ", ";\n transition: 0.2s;\n &:not(:disabled):hover {\n color: ", ";\n border-color: ", ";\n }\n p {\n margin: 0;\n margin-right: auto;\n padding-right: 36px;\n }\n"], ["\n position: relative;\n display: flex;\n align-items: center;\n padding: 1 2;\n min-width: 9rem;\n height: 28px;\n background-color: ", ";\n color: ", ";\n border: slim;\n border-color: ", ";\n font-size: 12px;\n font-weight: 600;\n border-radius: 6px;\n cursor: ", ";\n transition: 0.2s;\n &:not(:disabled):hover {\n color: ", ";\n border-color: ", ";\n }\n p {\n margin: 0;\n margin-right: auto;\n padding-right: 36px;\n }\n"])), th.color('white'), function (_a) {
14
14
  var $isDisabled = _a.$isDisabled;
@@ -21,14 +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 { useMemo } from 'react';
24
25
  import GridSelect from '../GridSelect';
26
+ import { Trans } from '@lingui/react';
25
27
  var getFlagOptions = function () { return [
26
- { value: '', label: 1 },
27
- { value: '1', label: 1 },
28
- { value: '0', label: 1 },
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" }) },
29
31
  ]; };
30
32
  var SelectFilter = function (_a) {
31
33
  var restProps = __rest(_a, []);
32
- return _jsx(GridSelect, __assign({ options: getFlagOptions() }, restProps));
34
+ var options = useMemo(function () { return getFlagOptions(); }, []);
35
+ return _jsx(GridSelect, __assign({ options: options }, restProps));
33
36
  };
34
37
  export default SelectFilter;
@@ -32,6 +32,7 @@ import { sameDate } from './utils/sameDate';
32
32
  import { useClickOutside } from '../../../Modal/hooks/useClickOutside';
33
33
  import DatePicker from '../../../../Elements/DatePicker';
34
34
  import Input from '../../../../Forms/Input';
35
+ import { Trans } from '@lingui/react';
35
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"
36
37
  // User readable date range.
37
38
  ])));
@@ -106,7 +107,7 @@ var DatePickerRange = function (props) {
106
107
  // Check if the second value is not selected and the first value is the same as the initial value
107
108
  var secondDatePickerValue = cleanValue[1] === null ? cleanValue[0] : cleanValue[1];
108
109
  var ref = useClickOutside({ onClose: onClose });
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 }))] })) }) })] }));
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 }))] })) }) })] }));
110
111
  };
111
112
  export default DatePickerRange;
112
113
  var templateObject_1;
@@ -8,7 +8,7 @@ import styled from '@xstyled/styled-components';
8
8
  import Icon from '../../../../Elements/Icon/Icon';
9
9
  import DropdownMenu from '../../../../Elements/DropdownMenu';
10
10
  import Button from '../../../../Elements/Button';
11
- import { Popover } from '../../../Popover';
11
+ import Popover from '../../../Popover';
12
12
  var ArrowIcon = styled(Icon)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n flex-shrink: 0;\n margin-left: 2;\n"], ["\n flex-shrink: 0;\n margin-left: 2;\n"])));
13
13
  var CustomIconWrap = styled.div(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n margin-right: 1;\n"], ["\n margin-right: 1;\n"])));
14
14
  var StyledDropdownMenu = styled(DropdownMenu)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: absolute;\n top: 8px;\n min-width: ", ";\n width: max-content;\n"], ["\n position: absolute;\n top: 8px;\n min-width: ", ";\n width: max-content;\n"])), function (_a) {
@@ -6,7 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  import { useCallback, useMemo, useRef, useState } from 'react';
7
7
  import styled from '@xstyled/styled-components';
8
8
  import DropdownMenu from '../../../../Elements/DropdownMenu';
9
- import { Popover } from '../../../Popover';
9
+ import Popover from '../../../Popover';
10
10
  var StyledDropdownMenu = styled(DropdownMenu)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n min-width: 160px;\n width: max-content;\n"], ["\n min-width: 160px;\n width: max-content;\n"])));
11
11
  export var StyledButton = styled.button(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: 56px;\n height: 56px;\n border-radius: 50%;\n border: none;\n background-color: red1;\n display: flex;\n z-index: 1;\n justify-content: center;\n align-items: center;\n position: fixed;\n bottom: 65px;\n right: 24px;\n\n :hover {\n cursor: pointer;\n }\n"], ["\n width: 56px;\n height: 56px;\n border-radius: 50%;\n border: none;\n background-color: red1;\n display: flex;\n z-index: 1;\n justify-content: center;\n align-items: center;\n position: fixed;\n bottom: 65px;\n right: 24px;\n\n :hover {\n cursor: pointer;\n }\n"])));
12
12
  export var StyledCross = styled.div(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n .line {\n border: 1px solid white;\n display: flex;\n width: 16px;\n background-color: white;\n transition: 0.3s;\n }\n > :nth-child(1) {\n transform: ", ";\n }\n > :nth-child(2) {\n transform: ", ";\n }\n"], ["\n .line {\n border: 1px solid white;\n display: flex;\n width: 16px;\n background-color: white;\n transition: 0.3s;\n }\n > :nth-child(1) {\n transform: ", ";\n }\n > :nth-child(2) {\n transform: ", ";\n }\n"])), function (_a) {
@@ -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[];
@@ -12,7 +12,9 @@ var ManageColumnForm = function (_a) {
12
12
  var clear = useCallback(function () {
13
13
  setSearchedValue('');
14
14
  }, [setSearchedValue]);
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) {
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) {
16
18
  return (_jsx(ActionRow, { column: column, columnsConfigValues: columnsConfigValues, setColumnsConfigOptions: setColumnsConfigOptions, searchedValue: searchedValue }, index));
17
19
  }) })] }));
18
20
  };
@@ -21,15 +21,16 @@ import Toggle from '../../../../../Elements/Toggle/Toggle';
21
21
  import { Group } from '../../../../../Elements/Icon/icons/Group';
22
22
  import { isObject } from 'lodash';
23
23
  import { H6 } from '../../../../../Elements/Typography/Typography';
24
+ import { Trans } from '@lingui/react';
24
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) {
25
26
  var $isVisible = _a.$isVisible;
26
27
  return ($isVisible ? 'flex' : 'none');
27
28
  }, th.color('lightGray6'));
28
29
  export var ActionRow = function (_a) {
29
- var _b, _c;
30
+ var _b, _c, _d, _e, _f;
30
31
  var column = _a.column, columnsConfigValues = _a.columnsConfigValues, setColumnsConfigOptions = _a.setColumnsConfigOptions, searchedValue = _a.searchedValue;
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;
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) && '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 }));
33
34
  var isVisible = translatedValue && translatedValue.toLocaleLowerCase().includes(searchedValue.toLocaleLowerCase());
34
35
  var handleToggleChange = useCallback(function () {
35
36
  setColumnsConfigOptions(function (prevOptions) {
@@ -25,29 +25,30 @@ import { useCallback, useState } from 'react';
25
25
  import { useClickOutside } from '../../../Modal/hooks/useClickOutside';
26
26
  import { Input } from '../../../../Forms/Input/Input';
27
27
  import IconList from '../IconList';
28
+ import { Trans } from '@lingui/react';
28
29
  var OverlayComponentDefault = function (_a) {
29
30
  var children = _a.children;
30
31
  return _jsx("div", { children: children });
31
32
  };
32
33
  var createNumberComparators = function () { return [
33
- { label: '1', value: 'eq', icon: 'equals' },
34
- { label: '1', value: 'neq', icon: 'notEqual' },
35
- { label: '1', value: 'lt', icon: 'lessThen' },
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' },
36
37
  {
37
- label: '1',
38
+ label: _jsx(Trans, { id: "dataGrid.comparator.lessThanOrEquals", message: "Less than or equals" }),
38
39
  value: 'lte',
39
40
  icon: 'lessThanEqual',
40
41
  },
41
- { label: '1', value: 'gt', icon: 'greaterThan' },
42
+ { label: _jsx(Trans, { id: "dataGrid.comparator.greaterThan", message: "Greater than" }), value: 'gt', icon: 'greaterThan' },
42
43
  {
43
- label: '1',
44
+ label: _jsx(Trans, { id: "dataGrid.comparator.greaterThanOrEquals", message: "Greater than or equal" }),
44
45
  value: 'gte',
45
46
  icon: 'greaterThanEqual',
46
47
  },
47
48
  ]; };
48
49
  var createEqualComparators = [
49
- { label: '1', value: 'eq', icon: 'equals' },
50
- { label: '1', value: 'neq', icon: 'notEqual' },
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' },
51
52
  ];
52
53
  var NumberRange = function (props) {
53
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
  };
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  export declare const rowClassSymbol: unique symbol;
3
3
  type Option = {
4
4
  value: string | number;
5
- label: string | number;
5
+ label: string | number | JSX.Element;
6
6
  };
7
7
  type ButtonPublicInterfaceProps = {
8
8
  children?: React.ReactNode;
@@ -6,5 +6,5 @@ type DropdownMenuProps = {
6
6
  children: React.ReactChild;
7
7
  placement?: Placement;
8
8
  };
9
- export declare const Popover: FC<DropdownMenuProps>;
10
- export {};
9
+ declare const Popover: FC<DropdownMenuProps>;
10
+ export default Popover;
@@ -8,7 +8,7 @@ import { Popper } from 'react-popper';
8
8
  import { useClickOutside } from '../Modal/hooks/useClickOutside';
9
9
  import Portal from '../../Elements/Portal';
10
10
  var PopoverWrapper = styled.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n z-index: 5;\n"], ["\n z-index: 5;\n"])));
11
- export var Popover = function (_a) {
11
+ var Popover = function (_a) {
12
12
  var placement = _a.placement, children = _a.children, onClose = _a.onClose, parentRef = _a.parentRef;
13
13
  var popperRef = useClickOutside({ onClose: onClose, parentRef: parentRef });
14
14
  return (_jsx(Portal, { children: _jsx("div", { ref: popperRef, children: _jsx(Popper, { innerRef: popperRef, referenceElement: parentRef.current, placement: placement, children: function (_a) {
@@ -16,4 +16,5 @@ export var Popover = function (_a) {
16
16
  return (_jsx(PopoverWrapper, { ref: ref, style: style, children: children }));
17
17
  } }) }) }));
18
18
  };
19
+ export default Popover;
19
20
  var templateObject_1;
@@ -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;
@@ -28,9 +28,10 @@ import { useTheme } from '@xstyled/styled-components';
28
28
  import SpaceAroundWrap from '../SpaceAround';
29
29
  import { FieldLabel } from '../Label';
30
30
  import { ErrorMessage } from '../ErrorMessage';
31
+ import { Trans } from '@lingui/react';
31
32
  var emptyOptions = [];
32
- var noOptionsMessage = function () { return '1'; };
33
- var loadingMessage = function () { return '1'; };
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..." }); };
34
35
  var Select = function (_a) {
35
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"]);
36
37
  var isAsync = !!loadOptions;
@@ -63,6 +64,6 @@ var Select = function (_a) {
63
64
  var handleLoadOptions = useMemo(function () {
64
65
  return loadOptions ? function (fulltext) { return loadOptions(fulltext); } : undefined;
65
66
  }, [loadOptions]);
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 })] }));
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 })] }));
67
68
  };
68
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,12 +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
62
  import { nanoid } from 'nanoid';
63
+ import { Trans } from '@lingui/react';
64
+ import { t } from '@lingui/macro';
63
65
  var CREATE = "_create_".concat(nanoid(), "_");
64
66
  var defaultFilterOption = createFilter();
65
67
  var creatableFilterOption = function (option, rawInput) {
@@ -78,13 +80,15 @@ var getOptionValue = function (selectedOption) {
78
80
  return selectedOption.value;
79
81
  }
80
82
  };
83
+ var loadingMessage = function () { return _jsx(Trans, { id: "components.dropdown.loading", message: "Loading..." }); };
81
84
  var SingleSelect = function (props) {
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;
83
- var _d = useState(false), isCreating = _d[0], setIsCreating = _d[1];
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];
84
89
  var asAsync = !!loadOptions || !!onCreateOption;
85
- var loadingMessage = useCallback(function () { return '1'; }, []);
86
90
  var noOptionsMessage = useCallback(function (inputValue) {
87
- return loadOptions && inputValue.length < asyncLoadMinChars ? '1' : '1';
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" }));
88
92
  }, [loadOptions, asyncLoadMinChars]);
89
93
  var handleLoadOptions = useCallback(function (inputValue) {
90
94
  if (onCreateOption) {
@@ -93,7 +97,7 @@ var SingleSelect = function (props) {
93
97
  return Promise.resolve(__spreadArray(__spreadArray([], (options || []), true), [
94
98
  {
95
99
  value: CREATE,
96
- label: "".concat(inputValue, " ()"),
100
+ label: (_jsxs(_Fragment, { children: ["$", inputValue, " ", _jsx(Trans, { id: "components.dropdown.newOption", message: "new value" })] })),
97
101
  inputValue: inputValue,
98
102
  },
99
103
  ], false));
@@ -105,13 +109,13 @@ var SingleSelect = function (props) {
105
109
  return loadOptions(inputValue, false);
106
110
  }
107
111
  }, [onCreateOption, loadOptions, asyncLoadMinChars, options]);
108
- var _e = useState(options || []), loadedDefaultOptions = _e[0], setLoadedDefaultOptions = _e[1];
112
+ var _c = useState(options || []), loadedDefaultOptions = _c[0], setLoadedDefaultOptions = _c[1];
109
113
  useEffect(function () {
110
114
  if (loadOptions && preload && !props.value)
111
115
  loadOptions('', false).then(setLoadedDefaultOptions);
112
116
  // eslint-disable-next-line react-hooks/exhaustive-deps
113
117
  }, [loadOptions]); // this is intentional
114
- var _f = useState(null), storedSelectedOption = _f[0], setStoredSelectedOption = _f[1];
118
+ var _d = useState(null), storedSelectedOption = _d[0], setStoredSelectedOption = _d[1];
115
119
  useEffect(function () {
116
120
  if (initialOptions && initialOptions.length) {
117
121
  var selectedOption = initialOptions.find(function (option) { return option.value == props.value; }) || null;
@@ -132,7 +136,7 @@ var SingleSelect = function (props) {
132
136
  if (!(onCreateOption && (option === null || option === void 0 ? void 0 : option.value) == CREATE)) return [3 /*break*/, 4];
133
137
  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];
134
138
  props === null || props === void 0 ? void 0 : props.form.setFieldTouched(name, true, true);
135
- props === null || props === void 0 ? void 0 : props.form.setFieldError(name, '');
139
+ props === null || props === void 0 ? void 0 : props.form.setFieldError(name, t({ id: 'form.general.min2Chars', message: 'Minimal length is 2 characters.' }));
136
140
  return [2 /*return*/];
137
141
  case 1:
138
142
  setIsCreating(true);
package/ui/index.d.ts CHANGED
@@ -33,7 +33,13 @@ import Input from './Forms/Input';
33
33
  import RadioButton from './Forms/RadioButton';
34
34
  import ThemeProvider from './ThemeProvider';
35
35
  import utils from './utils';
36
- export { Card, CornerDialog, ImageList, LightBox, Modal, Tabs, Alert, Avatar, Badge, BorderedBox, Button, Dropdown, ErrorMessage, Icon, Image, Label, Line, Link, Logo, Pagination, Paragraph, Portal, ProgressBar, SimpleLink, SpaceAround, Spinner, Tag, Toast, Toggle, Typography, Checkbox, Input, RadioButton, ThemeProvider, utils };
36
+ import DatePicker from './Elements/DatePicker';
37
+ import CommonGrid from './Blocks/CommonGrid';
38
+ import Popover from './Blocks/Popover';
39
+ import SingleSelect from './Elements/SingleSelect';
40
+ import MultiSelect from './Elements/MultiSelect';
41
+ import Select from './Elements/Select';
42
+ export { DatePicker, CommonGrid, Popover, SingleSelect, MultiSelect, Select, Card, CornerDialog, ImageList, LightBox, Modal, Tabs, Alert, Avatar, Badge, BorderedBox, Button, Dropdown, ErrorMessage, Icon, Image, Label, Line, Link, Logo, Pagination, Paragraph, Portal, ProgressBar, SimpleLink, SpaceAround, Spinner, Tag, Toast, Toggle, Typography, Checkbox, Input, RadioButton, ThemeProvider, utils, };
37
43
  export * from './Blocks/CornerDialog';
38
44
  export * from './Blocks/ImageList';
39
45
  export * from './Blocks/LightBox';
@@ -69,3 +75,9 @@ export * from './Forms/Input';
69
75
  export * from './Forms/RadioButton';
70
76
  export * from './ThemeProvider';
71
77
  export * from './utils';
78
+ export * from './Elements/DatePicker';
79
+ export * from './Blocks/CommonGrid';
80
+ export * from './Blocks/Popover';
81
+ export * from './Elements/SingleSelect';
82
+ export * from './Elements/MultiSelect';
83
+ export * from './Elements/Select';