colibri-ui 0.7.108 → 0.7.110

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.
@@ -6,4 +6,4 @@ export declare const DEFAULT_TIME: {
6
6
  export declare const formatTime: (date: Date) => string;
7
7
  export declare const generateSuggest: (interval?: number) => Timestamp[];
8
8
  export declare const checkIsBeforeNow: (time: string, currentDate?: Date | null) => boolean;
9
- export declare const checkIsBeforeSelectedDate: (time: string, date?: Date | null) => boolean;
9
+ export declare const checkIsBeforeSelectedDate: (time: string, interval: number, date?: Date | null) => boolean;
@@ -25,8 +25,13 @@ var generateSuggest = function generateSuggest(interval) {
25
25
  var checkIsBeforeNow = function checkIsBeforeNow(time, currentDate) {
26
26
  return currentDate ? dateFns.isBefore(dateFns.parse(time, "HH:mm", currentDate), new Date()) : false;
27
27
  };
28
- var checkIsBeforeSelectedDate = function checkIsBeforeSelectedDate(time, date) {
29
- return date ? dateFns.isBefore(dateFns.parse(time, "HH:mm", date), new Date(date)) : false;
28
+ var checkIsBeforeSelectedDate = function checkIsBeforeSelectedDate(time, interval, date) {
29
+ if (date) {
30
+ var selectedDate = new Date(date);
31
+ selectedDate.setMinutes(selectedDate.getMinutes() + interval);
32
+ return dateFns.isBefore(dateFns.parse(time, "HH:mm", date), selectedDate);
33
+ }
34
+ return false;
30
35
  };
31
36
 
32
37
  exports.DEFAULT_TIME = DEFAULT_TIME;
@@ -5,6 +5,7 @@ interface TimeSelectProps extends Omit<SelectProps<string>, 'options'> {
5
5
  currentDate?: Date | null;
6
6
  selectedDate?: Date | null;
7
7
  name?: string;
8
+ disabled?: boolean;
8
9
  }
9
10
  declare const TimeSelect: FC<TimeSelectProps>;
10
11
  export default TimeSelect;
@@ -21,7 +21,8 @@ var TimeSelect = function TimeSelect(_a) {
21
21
  _b = _a.interval,
22
22
  interval = _b === void 0 ? 15 : _b,
23
23
  onChange = _a.onChange,
24
- props = tslib.__rest(_a, ["value", "name", "currentDate", "selectedDate", "label", "interval", "onChange"]);
24
+ disabled = _a.disabled,
25
+ props = tslib.__rest(_a, ["value", "name", "currentDate", "selectedDate", "label", "interval", "onChange", "disabled"]);
25
26
  var baseOptions = React.useMemo(function () {
26
27
  return helpers.generateSuggest(interval).map(function (item) {
27
28
  return {
@@ -35,16 +36,17 @@ var TimeSelect = function TimeSelect(_a) {
35
36
  var options = React.useMemo(function () {
36
37
  return baseOptions.map(function (option) {
37
38
  return tslib.__assign(tslib.__assign({}, option), {
38
- disabled: !!selectedDate && helpers.checkIsBeforeSelectedDate(option.value, selectedDate) || !!currentDate && helpers.checkIsBeforeNow(option.value, currentDate)
39
+ disabled: !!selectedDate && helpers.checkIsBeforeSelectedDate(option.value, interval, selectedDate) || !!currentDate && helpers.checkIsBeforeNow(option.value, currentDate)
39
40
  });
40
41
  });
41
- }, [baseOptions, currentDate, selectedDate]);
42
+ }, [baseOptions, currentDate, selectedDate, interval]);
42
43
  return /*#__PURE__*/React__default.default.createElement(index$1.default, tslib.__assign({}, props, {
43
44
  name: name,
44
45
  value: value,
45
46
  label: label,
46
47
  options: options,
47
- onChange: onChange
48
+ onChange: onChange,
49
+ disabled: disabled
48
50
  }));
49
51
  };
50
52
 
@@ -6,4 +6,4 @@ export declare const DEFAULT_TIME: {
6
6
  export declare const formatTime: (date: Date) => string;
7
7
  export declare const generateSuggest: (interval?: number) => Timestamp[];
8
8
  export declare const checkIsBeforeNow: (time: string, currentDate?: Date | null) => boolean;
9
- export declare const checkIsBeforeSelectedDate: (time: string, date?: Date | null) => boolean;
9
+ export declare const checkIsBeforeSelectedDate: (time: string, interval: number, date?: Date | null) => boolean;
@@ -23,8 +23,13 @@ var generateSuggest = function generateSuggest(interval) {
23
23
  var checkIsBeforeNow = function checkIsBeforeNow(time, currentDate) {
24
24
  return currentDate ? isBefore(parse(time, "HH:mm", currentDate), new Date()) : false;
25
25
  };
26
- var checkIsBeforeSelectedDate = function checkIsBeforeSelectedDate(time, date) {
27
- return date ? isBefore(parse(time, "HH:mm", date), new Date(date)) : false;
26
+ var checkIsBeforeSelectedDate = function checkIsBeforeSelectedDate(time, interval, date) {
27
+ if (date) {
28
+ var selectedDate = new Date(date);
29
+ selectedDate.setMinutes(selectedDate.getMinutes() + interval);
30
+ return isBefore(parse(time, "HH:mm", date), selectedDate);
31
+ }
32
+ return false;
28
33
  };
29
34
 
30
35
  export { DEFAULT_TIME, checkIsBeforeNow, checkIsBeforeSelectedDate, formatTime, generateSuggest };
@@ -5,6 +5,7 @@ interface TimeSelectProps extends Omit<SelectProps<string>, 'options'> {
5
5
  currentDate?: Date | null;
6
6
  selectedDate?: Date | null;
7
7
  name?: string;
8
+ disabled?: boolean;
8
9
  }
9
10
  declare const TimeSelect: FC<TimeSelectProps>;
10
11
  export default TimeSelect;
@@ -13,7 +13,8 @@ var TimeSelect = function TimeSelect(_a) {
13
13
  _b = _a.interval,
14
14
  interval = _b === void 0 ? 15 : _b,
15
15
  onChange = _a.onChange,
16
- props = __rest(_a, ["value", "name", "currentDate", "selectedDate", "label", "interval", "onChange"]);
16
+ disabled = _a.disabled,
17
+ props = __rest(_a, ["value", "name", "currentDate", "selectedDate", "label", "interval", "onChange", "disabled"]);
17
18
  var baseOptions = useMemo(function () {
18
19
  return generateSuggest(interval).map(function (item) {
19
20
  return {
@@ -27,16 +28,17 @@ var TimeSelect = function TimeSelect(_a) {
27
28
  var options = useMemo(function () {
28
29
  return baseOptions.map(function (option) {
29
30
  return __assign(__assign({}, option), {
30
- disabled: !!selectedDate && checkIsBeforeSelectedDate(option.value, selectedDate) || !!currentDate && checkIsBeforeNow(option.value, currentDate)
31
+ disabled: !!selectedDate && checkIsBeforeSelectedDate(option.value, interval, selectedDate) || !!currentDate && checkIsBeforeNow(option.value, currentDate)
31
32
  });
32
33
  });
33
- }, [baseOptions, currentDate, selectedDate]);
34
+ }, [baseOptions, currentDate, selectedDate, interval]);
34
35
  return /*#__PURE__*/React__default.createElement(Select, __assign({}, props, {
35
36
  name: name,
36
37
  value: value,
37
38
  label: label,
38
39
  options: options,
39
- onChange: onChange
40
+ onChange: onChange,
41
+ disabled: disabled
40
42
  }));
41
43
  };
42
44
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "colibri-ui",
3
- "version": "0.7.108",
3
+ "version": "0.7.110",
4
4
  "description": "React UI components library",
5
5
  "main": "index.js",
6
6
  "scripts": {},