colibri-ui 0.7.106 → 0.7.107

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