@mailstep/design-system 0.7.30 → 0.7.31-beta.0

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",
3
+ "version": "0.7.31-beta.0",
4
4
  "license": "ISC",
5
5
  "type": "module",
6
6
  "main": "./ui/index.js",
@@ -4,7 +4,7 @@ type InitialView = 'past' | 'future';
4
4
  type DatePickerRangeProps = FilterComponentProps<Date[]> & {
5
5
  filterTime?: number;
6
6
  initialView?: InitialView;
7
- onChange: (value: Date[], others?: DateTimeOthers) => void;
7
+ onChange: (value: Date[], others?: DateTimeOthers[]) => void;
8
8
  };
9
9
  type DateRangeProps = DatePickerRangeProps & {
10
10
  error?: string;
@@ -71,9 +71,12 @@ var DatePickerRange = function (props) {
71
71
  setEndRangeValue(v);
72
72
  onChange([cleanValue[0], v], others);
73
73
  }, [onChange, others, cleanValue]);
74
- var handleOthersChange = useCallback(function (others) {
75
- onChange(cleanValue, others);
76
- }, [onChange, cleanValue]);
74
+ var handleOthersChangeFrom = useCallback(function (othersFrom) {
75
+ onChange(cleanValue, [othersFrom, others === null || others === void 0 ? void 0 : others[1]]);
76
+ }, [onChange, cleanValue, others]);
77
+ var handleOthersChangeTo = useCallback(function (othersTo) {
78
+ onChange(cleanValue, [others === null || others === void 0 ? void 0 : others[0], othersTo]);
79
+ }, [onChange, cleanValue, others]);
77
80
  var openPicker = useCallback(function () {
78
81
  setOpen(true);
79
82
  }, [setOpen]);
@@ -90,7 +93,8 @@ var DatePickerRange = function (props) {
90
93
  // Check if the second value is not selected and the first value is the same as the initial value
91
94
  var secondDatePickerValue = cleanValue[1] === null ? cleanValue[0] : cleanValue[1];
92
95
  var ref = useClickOutside({ onClose: onClose });
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: 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 }))] })) }) })] }));
96
+ console.log(others);
97
+ 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 === null || others === void 0 ? void 0 : others[0], onChangeOthers: handleOthersChangeFrom, 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, others: others === null || others === void 0 ? void 0 : others[1], onChangeOthers: handleOthersChangeTo, 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
98
  };
95
99
  export default DatePickerRange;
96
100
  var templateObject_1;
@@ -29,11 +29,12 @@ export var Timepicker = function (_a) {
29
29
  var onChange = useCallback(function (e) {
30
30
  var value = e.target.value;
31
31
  var _a = value.split(':'), hours = _a[0], minutes = _a[1];
32
- var timeTypeRepeater = (others === null || others === void 0 ? void 0 : others.dateTypeRepeater) ? (others === null || others === void 0 ? void 0 : others.timeTypeRepeater) || TimePickerRepeat.FROM : undefined;
32
+ var defaultTimePickerType = isSecondDatePicker ? TimePickerRepeat.TO : TimePickerRepeat.FROM;
33
+ var timeTypeRepeater = (others === null || others === void 0 ? void 0 : others.dateTypeRepeater) ? (others === null || others === void 0 ? void 0 : others.timeTypeRepeater) || defaultTimePickerType : undefined;
33
34
  setHours(Number(hours));
34
35
  setMinutes(Number(minutes));
35
36
  onChangeOthers === null || onChangeOthers === void 0 ? void 0 : onChangeOthers(__assign(__assign({}, others), { timeTypeRepeater: timeTypeRepeater, time: { h: Number(hours), m: Number(minutes) } }));
36
- }, [onChangeOthers, others]);
37
+ }, [onChangeOthers, others, isSecondDatePicker]);
37
38
  var handleChangeTimer = useCallback(function (e) {
38
39
  onChangeOthers === null || onChangeOthers === void 0 ? void 0 : onChangeOthers(__assign(__assign({}, others), { timeTypeRepeater: e.target.value }));
39
40
  }, [onChangeOthers, others]);
@@ -123,6 +123,7 @@ var DaysView = /** @class */ (function (_super) {
123
123
  var value = this.props.value;
124
124
  var others = this.props.others;
125
125
  var disabled = this.props.disabled;
126
+ console.log('foooter: ', others);
126
127
  return (_jsx("tfoot", { children: _jsx("tr", { children: _jsxs("td", { colSpan: 7, children: [onChangeOthers && _jsx(DateRepeater, { onChangeOthers: onChangeOthers, others: others, reset: reset }), this.props.timeFormat && (_jsx(Timepicker, { setTime: setTime, value: value, disabled: disabled || (!value && !(others === null || others === void 0 ? void 0 : others.dateTypeRepeater)), others: others, onChangeOthers: onChangeOthers, isSecondDatePicker: this.props.isSecondDatePicker }))] }) }) }));
127
128
  };
128
129
  DaysView.defaultProps = {