@mailstep/design-system 0.7.30-beta.1 → 0.7.30-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailstep/design-system",
3
- "version": "0.7.30-beta.1",
3
+ "version": "0.7.30-beta.10",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -2,11 +2,12 @@ import type { ColumnDefinition, GridActionsType, FiltersConfig, CustomComparator
2
2
  type Props = {
3
3
  onChange: Required<GridActionsType>['addFilter'];
4
4
  value?: any;
5
+ others?: any;
5
6
  column: ColumnDefinition;
6
7
  displayColumnWidth: number;
7
8
  filters?: FiltersConfig;
8
9
  group?: Group;
9
10
  comparators?: CustomComparators;
10
11
  };
11
- declare const ColumnFilterCell: ({ onChange, value, displayColumnWidth, filters, column: columnDefinition, group, comparators }: Props) => JSX.Element;
12
+ declare const ColumnFilterCell: ({ onChange, value, others, displayColumnWidth, filters, column: columnDefinition, group, comparators }: Props) => JSX.Element;
12
13
  export default ColumnFilterCell;
@@ -17,7 +17,7 @@ import { x } from '@xstyled/styled-components';
17
17
  import OverlayComponent from './FilterDropdown';
18
18
  import { Cell } from './Table';
19
19
  var ColumnFilterCell = function (_a) {
20
- var onChange = _a.onChange, value = _a.value, displayColumnWidth = _a.displayColumnWidth, filters = _a.filters, columnDefinition = _a.column, group = _a.group, comparators = _a.comparators;
20
+ var onChange = _a.onChange, value = _a.value, others = _a.others, displayColumnWidth = _a.displayColumnWidth, filters = _a.filters, columnDefinition = _a.column, group = _a.group, comparators = _a.comparators;
21
21
  var cellSizeProps = getCellSizeProps(columnDefinition, displayColumnWidth);
22
22
  var handleAddFilter = useAddFilter(onChange);
23
23
  var handleChange = React.useCallback(function (event, others) {
@@ -35,6 +35,6 @@ var ColumnFilterCell = function (_a) {
35
35
  console.error("ERROR, using unknown filter type ".concat(filterType));
36
36
  return (_jsx(x.div, { children: _jsx("span", { children: "".concat(filterType, " filter") }) }));
37
37
  }
38
- return (_jsx(Cell, __assign({ className: cellClassName }, cellSizeProps, { children: _jsx(x.div, { children: _jsx(RenderComponent, __assign({ "data-test": columnDefinition.name, name: columnDefinition.name, onChange: handleChange, value: value, OverlayComponent: OverlayComponent, comparators: defaultComparators }, filterConfig === null || filterConfig === void 0 ? void 0 : filterConfig.defaultExtraProps, columnDefinition.filterExtraProps, (filterType == 'options' && { options: columnDefinition.filterOptions }))) }) })));
38
+ return (_jsx(Cell, __assign({ className: cellClassName }, cellSizeProps, { children: _jsx(x.div, { children: _jsx(RenderComponent, __assign({ "data-test": columnDefinition.name, name: columnDefinition.name, onChange: handleChange, value: value, others: others, OverlayComponent: OverlayComponent, comparators: defaultComparators }, filterConfig === null || filterConfig === void 0 ? void 0 : filterConfig.defaultExtraProps, columnDefinition.filterExtraProps, (filterType == 'options' && { options: columnDefinition.filterOptions }))) }) })));
39
39
  };
40
40
  export default ColumnFilterCell;
@@ -29,6 +29,6 @@ var FilterRow = function (_a) {
29
29
  var displayCheckbox = (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.checkAllPosition) === 'top' && (((_b = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.actionOptions) === null || _b === void 0 ? void 0 : _b.length) || (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.forceCheckboxes));
30
30
  var displayRowNumberLabel = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbers;
31
31
  var rowsNumberLabel = (_c = actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.addRowNumbersLabel) !== null && _c !== void 0 ? _c : '#';
32
- return (_jsxs(Row, { className: "filterRow", children: [displayCheckbox && (_jsx(Cell, { className: "cell", style: actionColumnStyle, children: _jsx(Checkbox, { checked: allChecked, onChange: toggleCheckbox, label: "" }, "check-all") })), displayRowNumberLabel && (_jsx(Cell, { className: "cell", style: actionColumnStyle, children: _jsx("div", { children: rowsNumberLabel }) })), !!(!displayCheckbox && !displayRowNumberLabel && actionColumn) && (_jsx(Cell, { className: "cell", style: actionColumnStyle }, 'actions')), columns.map(function (column, index) { return (_jsx(ColumnFilterCell, { column: column, onChange: handleOnChange, value: get([getFilterName(column), 'value'], filterValues), displayColumnWidth: displayColumnsWidth[column.name], filters: filters, comparators: comparators, group: groups === null || groups === void 0 ? void 0 : groups[index] }, index)); })] }));
32
+ return (_jsxs(Row, { className: "filterRow", children: [displayCheckbox && (_jsx(Cell, { className: "cell", style: actionColumnStyle, children: _jsx(Checkbox, { checked: allChecked, onChange: toggleCheckbox, label: "" }, "check-all") })), displayRowNumberLabel && (_jsx(Cell, { className: "cell", style: actionColumnStyle, children: _jsx("div", { children: rowsNumberLabel }) })), !!(!displayCheckbox && !displayRowNumberLabel && actionColumn) && (_jsx(Cell, { className: "cell", style: actionColumnStyle }, 'actions')), columns.map(function (column, index) { return (_jsx(ColumnFilterCell, { column: column, onChange: handleOnChange, value: get([getFilterName(column), 'value'], filterValues), others: get([getFilterName(column), 'others'], filterValues), displayColumnWidth: displayColumnsWidth[column.name], filters: filters, comparators: comparators, group: groups === null || groups === void 0 ? void 0 : groups[index] }, index)); })] }));
33
33
  };
34
34
  export default FilterRow;
@@ -41,10 +41,9 @@ var OverlayComponentDefault = function (_a) {
41
41
  };
42
42
  var DatePickerRange = function (props) {
43
43
  var _a, _b, _c;
44
- var onChange = props.onChange, error = props.error, label = props.label, value = props.value, filterTime = props.filterTime, initialView = props.initialView, _d = props.OverlayComponent, OverlayComponent = _d === void 0 ? OverlayComponentDefault : _d, rest = __rest(props, ["onChange", "error", "label", "value", "filterTime", "initialView", "OverlayComponent"]);
44
+ var onChange = props.onChange, error = props.error, label = props.label, value = props.value, others = props.others, filterTime = props.filterTime, initialView = props.initialView, _d = props.OverlayComponent, OverlayComponent = _d === void 0 ? OverlayComponentDefault : _d, rest = __rest(props, ["onChange", "error", "label", "value", "others", "filterTime", "initialView", "OverlayComponent"]);
45
45
  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];
46
46
  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];
47
- var _g = useState(undefined), others = _g[0], setOthersValues = _g[1];
48
47
  var timeFormat = filterTime ? 'HH:mm' : false;
49
48
  var placeholder = i18n._({ id: 'dataGrid.filterCell', message: 'Type to filter' });
50
49
  var cleanValue = React.useMemo(function () { return getCleanValues(value); }, [value]);
@@ -63,7 +62,7 @@ var DatePickerRange = function (props) {
63
62
  }
64
63
  return [cleanValue[0] || firstDate, cleanValue[1] || secondDate];
65
64
  }, [cleanValue, initialView]);
66
- var _h = useState(false), isOpen = _h[0], setOpen = _h[1];
65
+ var _g = useState(false), isOpen = _g[0], setOpen = _g[1];
67
66
  var setDateFrom = useCallback(function (v) {
68
67
  setStartRangeValue(v);
69
68
  onChange([v, cleanValue[1]], others);
@@ -72,6 +71,9 @@ var DatePickerRange = function (props) {
72
71
  setEndRangeValue(v);
73
72
  onChange([cleanValue[0], v], others);
74
73
  }, [onChange, others, cleanValue]);
74
+ var handleOthersChange = useCallback(function (others) {
75
+ onChange(cleanValue, others);
76
+ }, [onChange, cleanValue]);
75
77
  var openPicker = useCallback(function () {
76
78
  setOpen(true);
77
79
  }, [setOpen]);
@@ -79,7 +81,7 @@ var DatePickerRange = function (props) {
79
81
  onChange([]);
80
82
  setStartRangeValue(undefined);
81
83
  setEndRangeValue(undefined);
82
- setOthersValues(undefined);
84
+ // setOthersValues(undefined)
83
85
  }, [onChange]);
84
86
  var isValidDateFrom = useCallback(function (current) { return !cleanValue[1] || DateTime.fromJSDate(cleanValue[1]) >= DateTime.fromJSDate(current); }, [cleanValue]);
85
87
  var isValidDateTo = useCallback(function (current) { return !cleanValue[0] || DateTime.fromJSDate(current) >= DateTime.fromJSDate(cleanValue[0]); }, [cleanValue]);
@@ -89,8 +91,7 @@ var DatePickerRange = function (props) {
89
91
  // Check if the second value is not selected and the first value is the same as the initial value
90
92
  var secondDatePickerValue = cleanValue[1] === null ? cleanValue[0] : cleanValue[1];
91
93
  var ref = useClickOutside({ onClose: onClose });
92
- console.log('others', others);
93
- return (_jsxs("div", { ref: ref, children: [_jsx(Input, { name: props.name, placeholder: placeholder, type: "text", icon: "calendar", value: pickerRangeToString(cleanValue, others), label: props.label, onFocus: openPicker, iconOnClick: openPicker, 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, others: others, onChangeOthers: setOthersValues, icon: false, label: isOpen && i18n._({ 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 && i18n._({ id: 'dataGrid.filterCell.to', message: 'To' }), isValidDate: isValidDateTo, input: false, spaceAround: true, open: true, disabled: secondDatePickerValue === null || !!(others === null || others === void 0 ? void 0 : others.dateTypeRepeater), isSecondDatePicker: true }))] })) }) })] }));
94
+ return (_jsxs("div", { ref: ref, children: [_jsx(Input, { name: props.name, placeholder: placeholder, type: "text", icon: "calendar", value: pickerRangeToString(cleanValue, others), label: props.label, onFocus: openPicker, iconOnClick: openPicker, 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, others: others, onChangeOthers: handleOthersChange, icon: false, label: isOpen && i18n._({ 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 && i18n._({ id: 'dataGrid.filterCell.to', message: 'To' }), isValidDate: isValidDateTo, input: false, spaceAround: true, open: true, disabled: secondDatePickerValue === null || !!(others === null || others === void 0 ? void 0 : others.dateTypeRepeater), isSecondDatePicker: true }))] })) }) })] }));
94
95
  };
95
96
  export default DatePickerRange;
96
97
  var templateObject_1;
@@ -46,7 +46,7 @@ export declare const createActions: (gridName: string) => {
46
46
  setColumnsOrder: (columnsOrder: string[]) => Action;
47
47
  setRowsPerPage: (rowsPerPage: number) => Action;
48
48
  resetFilters: () => Action;
49
- addFilter: (column: string, value: any, filterProps: FilterProps) => Action;
49
+ addFilter: (column: string, value: any, filterProps: FilterProps, others?: any) => Action;
50
50
  setFilters: (filters: Filtering) => Action;
51
51
  addSorting: (column: string, direction: SortingValueType) => Action;
52
52
  clearSettings: () => Action;
@@ -195,12 +195,13 @@ export var createActions = function (gridName) { return ({
195
195
  }); },
196
196
  setRowsPerPage: function (rowsPerPage) { return ({ gridName: gridName, type: actionTypes.setRowsPerPage, rowsPerPage: rowsPerPage }); },
197
197
  resetFilters: function () { return ({ gridName: gridName, type: actionTypes.resetFilters }); },
198
- addFilter: function (column, value, filterProps) { return ({
198
+ addFilter: function (column, value, filterProps, others) { return ({
199
199
  gridName: gridName,
200
200
  type: actionTypes.addFilter,
201
201
  column: column,
202
202
  value: value,
203
- filterProps: filterProps
203
+ filterProps: filterProps,
204
+ others: others
204
205
  }); },
205
206
  setFilters: function (filters) { return ({ gridName: gridName, type: actionTypes.setFilters, filters: filters }); },
206
207
  addSorting: function (column, direction) { return ({
@@ -45,8 +45,8 @@ export var gridDummyActions = {
45
45
  // @see types for full list of actions
46
46
  setPage: function (number) { return console.log('setPage', number); },
47
47
  setRowsPerPage: function (number) { return console.log('setRowsPerPage', number); },
48
- addFilter: function (column, value, filterProps) {
49
- return console.log('setRowsPerPage', column, value, filterProps);
48
+ addFilter: function (column, value, filterProps, others) {
49
+ return console.log('addFilter', column, value, filterProps, others);
50
50
  }
51
51
  };
52
52
  export var createOversizedRandomData = function (count) {
@@ -72,6 +72,7 @@ export type Filtering = {
72
72
  [column: string]: {
73
73
  value: any;
74
74
  filterProps: FilterProps;
75
+ others?: any;
75
76
  };
76
77
  };
77
78
  export type Sorting = {
@@ -12,7 +12,8 @@ var __assign = (this && this.__assign) || function () {
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { useCallback } from 'react';
14
14
  import Icon from '../../../Icon';
15
- import { DatePickerRepeat, DatePickerRepeatTrans } from '../../utils/constants';
15
+ import { DatePickerRepeatTrans } from '../../utils/constants';
16
+ import { DatePickerRepeat } from '../types';
16
17
  import { i18n } from '@lingui/core';
17
18
  import { x } from '@xstyled/styled-components';
18
19
  import { FooterRow } from './FooterRow';
@@ -21,10 +22,10 @@ export var DateRepeater = function (_a) {
21
22
  var onChangeOthers = _a.onChangeOthers, others = _a.others, reset = _a.reset;
22
23
  var handleChange = useCallback(function (e) {
23
24
  var dateTypeRepeater = e.target.value;
24
- onChangeOthers === null || onChangeOthers === void 0 ? void 0 : onChangeOthers(__assign(__assign({}, others), { dateTypeRepeater: dateTypeRepeater }));
25
- if (dateTypeRepeater) {
25
+ if (!dateTypeRepeater) {
26
26
  reset();
27
27
  }
28
+ onChangeOthers === null || onChangeOthers === void 0 ? void 0 : onChangeOthers(__assign(__assign({}, others), { dateTypeRepeater: dateTypeRepeater }));
28
29
  }, [onChangeOthers, reset, others]);
29
30
  return (_jsx(x.div, { borderTop: "1px solid", borderColor: "lightGray2", mt: "8px", pt: "8px", mb: "8px", children: _jsxs(FooterRow, { children: [_jsxs(x.div, { display: "flex", alignItems: "center", flex: "1", children: [_jsx(Icon, { icon: "calendar" }), _jsx(FooterRowLabel, { children: i18n._({ id: 'dataGrid.repeat', message: 'Repeat' }) })] }), _jsxs(x.select, { textAlign: "right", onChange: handleChange, value: others === null || others === void 0 ? void 0 : others.dateTypeRepeater, border: "none", children: [_jsx("option", { value: "", children: i18n._({ id: 'dataGrid.noRepeat', message: 'No repeat' }) }), _jsx("option", { value: DatePickerRepeat.EVERY_TODAY, children: DatePickerRepeatTrans[DatePickerRepeat.EVERY_TODAY] }), _jsx("option", { value: DatePickerRepeat.EVERY_YESTERDAY, children: DatePickerRepeatTrans[DatePickerRepeat.EVERY_YESTERDAY] }), _jsx("option", { value: DatePickerRepeat.EVERY_LAST_WEEK, children: DatePickerRepeatTrans[DatePickerRepeat.EVERY_LAST_WEEK] })] })] }) }));
30
31
  };
@@ -12,7 +12,8 @@ var __assign = (this && this.__assign) || function () {
12
12
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
13
13
  import { useCallback, useEffect, useState } from 'react';
14
14
  import Icon from '../../../Icon';
15
- import { TimePickerRepeat, TimePickerRepeatTrans } from '../../utils/constants';
15
+ import { TimePickerRepeatTrans } from '../../utils/constants';
16
+ import { TimePickerRepeat } from '../types';
16
17
  import { i18n } from '@lingui/core';
17
18
  import { x } from '@xstyled/styled-components';
18
19
  import { FooterRow } from './FooterRow';
@@ -1,6 +1,5 @@
1
1
  import type { FocusEvent, FocusEventHandler } from 'react';
2
2
  import type { Moment } from 'moment';
3
- import type { DatePickerRepeat, TimePickerRepeat } from '../utils/constants';
4
3
  export type ViewMode = 'years' | 'months' | 'days' | 'time';
5
4
  export interface TimeConstraint {
6
5
  min: number;
@@ -68,4 +67,14 @@ export type DateTimeOthers = {
68
67
  m: number;
69
68
  };
70
69
  };
70
+ export declare enum DatePickerRepeat {
71
+ EVERY_TODAY = "every-today",
72
+ EVERY_YESTERDAY = "every-yesterday",
73
+ EVERY_LAST_WEEK = "every-last-week"
74
+ }
75
+ export declare enum TimePickerRepeat {
76
+ FROM = "from",
77
+ TO = "to",
78
+ AT = "at"
79
+ }
71
80
  export {};
@@ -1 +1,12 @@
1
- export {};
1
+ export var DatePickerRepeat;
2
+ (function (DatePickerRepeat) {
3
+ DatePickerRepeat["EVERY_TODAY"] = "every-today";
4
+ DatePickerRepeat["EVERY_YESTERDAY"] = "every-yesterday";
5
+ DatePickerRepeat["EVERY_LAST_WEEK"] = "every-last-week";
6
+ })(DatePickerRepeat || (DatePickerRepeat = {}));
7
+ export var TimePickerRepeat;
8
+ (function (TimePickerRepeat) {
9
+ TimePickerRepeat["FROM"] = "from";
10
+ TimePickerRepeat["TO"] = "to";
11
+ TimePickerRepeat["AT"] = "at";
12
+ })(TimePickerRepeat || (TimePickerRepeat = {}));
@@ -1,2 +1,3 @@
1
1
  import DatePicker from './DatePicker';
2
+ export { DatePickerRepeat, TimePickerRepeat } from './Datetime/types';
2
3
  export default DatePicker;
@@ -1,2 +1,3 @@
1
1
  import DatePicker from './DatePicker';
2
+ export { DatePickerRepeat, TimePickerRepeat } from './Datetime/types';
2
3
  export default DatePicker;
@@ -1,12 +1,3 @@
1
- export declare enum DatePickerRepeat {
2
- EVERY_TODAY = "every-today",
3
- EVERY_YESTERDAY = "every-yesterday",
4
- EVERY_LAST_WEEK = "every-last-week"
5
- }
1
+ import { DatePickerRepeat, TimePickerRepeat } from '../Datetime/types';
6
2
  export declare const DatePickerRepeatTrans: Record<DatePickerRepeat, string>;
7
- export declare enum TimePickerRepeat {
8
- FROM = "from",
9
- TO = "to",
10
- AT = "at"
11
- }
12
3
  export declare const TimePickerRepeatTrans: Record<TimePickerRepeat, string>;
@@ -1,22 +1,11 @@
1
1
  var _a, _b;
2
+ import { DatePickerRepeat, TimePickerRepeat } from '../Datetime/types';
2
3
  import { i18n } from '@lingui/core';
3
- export var DatePickerRepeat;
4
- (function (DatePickerRepeat) {
5
- DatePickerRepeat["EVERY_TODAY"] = "every-today";
6
- DatePickerRepeat["EVERY_YESTERDAY"] = "every-yesterday";
7
- DatePickerRepeat["EVERY_LAST_WEEK"] = "every-last-week";
8
- })(DatePickerRepeat || (DatePickerRepeat = {}));
9
4
  export var DatePickerRepeatTrans = (_a = {},
10
5
  _a[DatePickerRepeat.EVERY_TODAY] = i18n._({ id: 'dataGrid.everyToday', message: 'Every today' }),
11
6
  _a[DatePickerRepeat.EVERY_YESTERDAY] = i18n._({ id: 'dataGrid.everyYesterday', message: 'Every yesterday' }),
12
7
  _a[DatePickerRepeat.EVERY_LAST_WEEK] = i18n._({ id: 'dataGrid.everyLastWeek', message: 'Every last week' }),
13
8
  _a);
14
- export var TimePickerRepeat;
15
- (function (TimePickerRepeat) {
16
- TimePickerRepeat["FROM"] = "from";
17
- TimePickerRepeat["TO"] = "to";
18
- TimePickerRepeat["AT"] = "at";
19
- })(TimePickerRepeat || (TimePickerRepeat = {}));
20
9
  export var TimePickerRepeatTrans = (_b = {},
21
10
  _b[TimePickerRepeat.FROM] = i18n._({ id: 'dataGrid.timepicker.from', message: 'from' }),
22
11
  _b[TimePickerRepeat.TO] = i18n._({ id: 'dataGrid.timepicker.to', message: 'to' }),