colibri-ui 0.8.38 → 0.8.41
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/Calendar/components/Month/Month.js +1 -1
- package/Calendar/components/Month/index.module.css +3 -3
- package/Calendar/utils/getPresets.d.ts +6 -0
- package/Calendar/utils/getPresets.js +98 -0
- package/esm/Calendar/components/Month/Month.js +1 -1
- package/esm/Calendar/components/Month/index.module.css +3 -3
- package/esm/Calendar/utils/getPresets.d.ts +6 -0
- package/esm/Calendar/utils/getPresets.js +86 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +2 -0
- package/package.json +1 -1
|
@@ -93,7 +93,7 @@ var Month = function Month(props) {
|
|
|
93
93
|
key: "week-".concat(arguments.length <= 1 ? undefined : arguments[1]),
|
|
94
94
|
className: clx(styles__default.default.week)
|
|
95
95
|
}, days.map(function (day) {
|
|
96
|
-
var key = "".concat(
|
|
96
|
+
var key = "day-".concat(arguments.length <= 1 ? undefined : arguments[1]);
|
|
97
97
|
if (day.isDummy) {
|
|
98
98
|
return /*#__PURE__*/React__namespace.createElement("li", {
|
|
99
99
|
className: clx(styles__default.default.day),
|
|
@@ -80,17 +80,17 @@
|
|
|
80
80
|
display: block;
|
|
81
81
|
left: auto;
|
|
82
82
|
right: auto;
|
|
83
|
-
width:
|
|
83
|
+
width: 100%;
|
|
84
84
|
}
|
|
85
85
|
.selected-day:first-child::before {
|
|
86
86
|
display: block;
|
|
87
87
|
left: 50%;
|
|
88
|
-
width:
|
|
88
|
+
width: 100%;
|
|
89
89
|
}
|
|
90
90
|
.selected-day:last-child::before {
|
|
91
91
|
display: block;
|
|
92
92
|
right: 50%;
|
|
93
|
-
width:
|
|
93
|
+
width: 100%;
|
|
94
94
|
}
|
|
95
95
|
.selected-day + .selected-day, .selected-day + .selected-day:hover {
|
|
96
96
|
z-index: 4 !important;
|
|
@@ -3,4 +3,10 @@ export type DatePreset = {
|
|
|
3
3
|
date: string;
|
|
4
4
|
period: number;
|
|
5
5
|
};
|
|
6
|
+
export declare const addDays: (date: Date, days?: number) => Date;
|
|
7
|
+
export declare const getToday: () => DatePreset;
|
|
8
|
+
export declare const getTomorrow: () => DatePreset;
|
|
9
|
+
export declare const getWeekends: () => DatePreset;
|
|
10
|
+
export declare const getCurrWeek: () => DatePreset;
|
|
11
|
+
export declare const getNextWeek: () => DatePreset;
|
|
6
12
|
export declare function getPresets(presets: string[]): DatePreset[];
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
4
|
+
var index = require('../../helpers/date/index.js');
|
|
5
|
+
var index$1 = require('../components/Presets/index.js');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var _defineProperty__default = /*#__PURE__*/_interopDefault(_defineProperty);
|
|
10
|
+
|
|
11
|
+
var format = function format(date) {
|
|
12
|
+
return index.toISODate(date);
|
|
13
|
+
};
|
|
14
|
+
var addDays = function addDays(date) {
|
|
15
|
+
var days = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
16
|
+
var d = new Date(date);
|
|
17
|
+
d.setDate(d.getDate() + days);
|
|
18
|
+
return d;
|
|
19
|
+
};
|
|
20
|
+
var getToday = function getToday() {
|
|
21
|
+
return {
|
|
22
|
+
name: index$1.PRESETS.TODAY,
|
|
23
|
+
date: format(new Date()),
|
|
24
|
+
period: 1
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
var getTomorrow = function getTomorrow() {
|
|
28
|
+
var tomorrow = addDays(new Date());
|
|
29
|
+
return {
|
|
30
|
+
name: index$1.PRESETS.TOMORROW,
|
|
31
|
+
date: format(tomorrow),
|
|
32
|
+
period: 1
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
var getWeekends = function getWeekends() {
|
|
36
|
+
var date = new Date();
|
|
37
|
+
while (![0, 6].includes(date.getDay())) {
|
|
38
|
+
date = addDays(date);
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
name: index$1.PRESETS.WEEKENDS,
|
|
42
|
+
date: format(date),
|
|
43
|
+
period: date.getDay() === 6 ? 2 : 1
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
var getCurrWeek = function getCurrWeek() {
|
|
47
|
+
var today = new Date();
|
|
48
|
+
var date = new Date(today);
|
|
49
|
+
var days = 0;
|
|
50
|
+
// если сегодня понедельник, пропускаем его
|
|
51
|
+
if (today.getDay() === 1) {
|
|
52
|
+
date = addDays(date);
|
|
53
|
+
days++;
|
|
54
|
+
}
|
|
55
|
+
while (date.getDay() !== 1) {
|
|
56
|
+
date = addDays(date);
|
|
57
|
+
days++;
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
name: index$1.PRESETS.CURWEEK,
|
|
61
|
+
date: format(today),
|
|
62
|
+
period: days
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
var getNextWeek = function getNextWeek() {
|
|
66
|
+
var date = new Date();
|
|
67
|
+
// если сегодня понедельник — смещаемся на завтра
|
|
68
|
+
if (date.getDay() === 1) {
|
|
69
|
+
date = addDays(date);
|
|
70
|
+
}
|
|
71
|
+
while (date.getDay() !== 1) {
|
|
72
|
+
date = addDays(date);
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
name: index$1.PRESETS.NEXTWEEK,
|
|
76
|
+
date: format(date),
|
|
77
|
+
period: 7
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
var PRESET_MAP = _defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default(_defineProperty__default.default({}, index$1.PRESETS.TODAY, getToday), index$1.PRESETS.TOMORROW, getTomorrow), index$1.PRESETS.WEEKENDS, getWeekends), index$1.PRESETS.CURWEEK, getCurrWeek), index$1.PRESETS.NEXTWEEK, getNextWeek);
|
|
81
|
+
function getPresets(presets) {
|
|
82
|
+
return presets.map(function (preset) {
|
|
83
|
+
var _a;
|
|
84
|
+
var presetFn = PRESET_MAP[preset];
|
|
85
|
+
if (!presetFn) {
|
|
86
|
+
console.warn("Unknown preset: ".concat(preset, ", falling back to TODAY"));
|
|
87
|
+
}
|
|
88
|
+
return (_a = presetFn === null || presetFn === void 0 ? void 0 : presetFn()) !== null && _a !== void 0 ? _a : getToday();
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
exports.addDays = addDays;
|
|
93
|
+
exports.getCurrWeek = getCurrWeek;
|
|
94
|
+
exports.getNextWeek = getNextWeek;
|
|
95
|
+
exports.getPresets = getPresets;
|
|
96
|
+
exports.getToday = getToday;
|
|
97
|
+
exports.getTomorrow = getTomorrow;
|
|
98
|
+
exports.getWeekends = getWeekends;
|
|
@@ -66,7 +66,7 @@ var Month = function Month(props) {
|
|
|
66
66
|
key: "week-".concat(arguments.length <= 1 ? undefined : arguments[1]),
|
|
67
67
|
className: clx(styles.week)
|
|
68
68
|
}, days.map(function (day) {
|
|
69
|
-
var key = "".concat(
|
|
69
|
+
var key = "day-".concat(arguments.length <= 1 ? undefined : arguments[1]);
|
|
70
70
|
if (day.isDummy) {
|
|
71
71
|
return /*#__PURE__*/React.createElement("li", {
|
|
72
72
|
className: clx(styles.day),
|
|
@@ -80,17 +80,17 @@
|
|
|
80
80
|
display: block;
|
|
81
81
|
left: auto;
|
|
82
82
|
right: auto;
|
|
83
|
-
width:
|
|
83
|
+
width: 100%;
|
|
84
84
|
}
|
|
85
85
|
.selected-day:first-child::before {
|
|
86
86
|
display: block;
|
|
87
87
|
left: 50%;
|
|
88
|
-
width:
|
|
88
|
+
width: 100%;
|
|
89
89
|
}
|
|
90
90
|
.selected-day:last-child::before {
|
|
91
91
|
display: block;
|
|
92
92
|
right: 50%;
|
|
93
|
-
width:
|
|
93
|
+
width: 100%;
|
|
94
94
|
}
|
|
95
95
|
.selected-day + .selected-day, .selected-day + .selected-day:hover {
|
|
96
96
|
z-index: 4 !important;
|
|
@@ -3,4 +3,10 @@ export type DatePreset = {
|
|
|
3
3
|
date: string;
|
|
4
4
|
period: number;
|
|
5
5
|
};
|
|
6
|
+
export declare const addDays: (date: Date, days?: number) => Date;
|
|
7
|
+
export declare const getToday: () => DatePreset;
|
|
8
|
+
export declare const getTomorrow: () => DatePreset;
|
|
9
|
+
export declare const getWeekends: () => DatePreset;
|
|
10
|
+
export declare const getCurrWeek: () => DatePreset;
|
|
11
|
+
export declare const getNextWeek: () => DatePreset;
|
|
6
12
|
export declare function getPresets(presets: string[]): DatePreset[];
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import { toISODate } from '../../helpers/date/index.js';
|
|
3
|
+
import { PRESETS } from '../components/Presets/index.js';
|
|
4
|
+
|
|
5
|
+
var format = function format(date) {
|
|
6
|
+
return toISODate(date);
|
|
7
|
+
};
|
|
8
|
+
var addDays = function addDays(date) {
|
|
9
|
+
var days = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
10
|
+
var d = new Date(date);
|
|
11
|
+
d.setDate(d.getDate() + days);
|
|
12
|
+
return d;
|
|
13
|
+
};
|
|
14
|
+
var getToday = function getToday() {
|
|
15
|
+
return {
|
|
16
|
+
name: PRESETS.TODAY,
|
|
17
|
+
date: format(new Date()),
|
|
18
|
+
period: 1
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
var getTomorrow = function getTomorrow() {
|
|
22
|
+
var tomorrow = addDays(new Date());
|
|
23
|
+
return {
|
|
24
|
+
name: PRESETS.TOMORROW,
|
|
25
|
+
date: format(tomorrow),
|
|
26
|
+
period: 1
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
var getWeekends = function getWeekends() {
|
|
30
|
+
var date = new Date();
|
|
31
|
+
while (![0, 6].includes(date.getDay())) {
|
|
32
|
+
date = addDays(date);
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
name: PRESETS.WEEKENDS,
|
|
36
|
+
date: format(date),
|
|
37
|
+
period: date.getDay() === 6 ? 2 : 1
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
var getCurrWeek = function getCurrWeek() {
|
|
41
|
+
var today = new Date();
|
|
42
|
+
var date = new Date(today);
|
|
43
|
+
var days = 0;
|
|
44
|
+
// если сегодня понедельник, пропускаем его
|
|
45
|
+
if (today.getDay() === 1) {
|
|
46
|
+
date = addDays(date);
|
|
47
|
+
days++;
|
|
48
|
+
}
|
|
49
|
+
while (date.getDay() !== 1) {
|
|
50
|
+
date = addDays(date);
|
|
51
|
+
days++;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
name: PRESETS.CURWEEK,
|
|
55
|
+
date: format(today),
|
|
56
|
+
period: days
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
var getNextWeek = function getNextWeek() {
|
|
60
|
+
var date = new Date();
|
|
61
|
+
// если сегодня понедельник — смещаемся на завтра
|
|
62
|
+
if (date.getDay() === 1) {
|
|
63
|
+
date = addDays(date);
|
|
64
|
+
}
|
|
65
|
+
while (date.getDay() !== 1) {
|
|
66
|
+
date = addDays(date);
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
name: PRESETS.NEXTWEEK,
|
|
70
|
+
date: format(date),
|
|
71
|
+
period: 7
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
var PRESET_MAP = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, PRESETS.TODAY, getToday), PRESETS.TOMORROW, getTomorrow), PRESETS.WEEKENDS, getWeekends), PRESETS.CURWEEK, getCurrWeek), PRESETS.NEXTWEEK, getNextWeek);
|
|
75
|
+
function getPresets(presets) {
|
|
76
|
+
return presets.map(function (preset) {
|
|
77
|
+
var _a;
|
|
78
|
+
var presetFn = PRESET_MAP[preset];
|
|
79
|
+
if (!presetFn) {
|
|
80
|
+
console.warn("Unknown preset: ".concat(preset, ", falling back to TODAY"));
|
|
81
|
+
}
|
|
82
|
+
return (_a = presetFn === null || presetFn === void 0 ? void 0 : presetFn()) !== null && _a !== void 0 ? _a : getToday();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export { addDays, getCurrWeek, getNextWeek, getPresets, getToday, getTomorrow, getWeekends };
|
package/esm/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { default as Avatar } from "./Avatar";
|
|
|
3
3
|
export { default as Badge } from "./Badge";
|
|
4
4
|
export { default as Button } from "./Button";
|
|
5
5
|
export { default as Calendar } from "./Calendar";
|
|
6
|
+
export { getPresets } from "./Calendar/utils/getPresets";
|
|
6
7
|
export { default as Checkbox } from "./Checkbox";
|
|
7
8
|
export { default as Chip } from "./Chip";
|
|
8
9
|
export { default as ClickOutside } from "./ClickOutside";
|
package/esm/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { default as Avatar } from './Avatar/index.js';
|
|
|
3
3
|
export { default as Badge } from './Badge/index.js';
|
|
4
4
|
export { default as Button } from './Button/index.js';
|
|
5
5
|
export { default as Calendar } from './Calendar/index.js';
|
|
6
|
+
export { getPresets } from './Calendar/utils/getPresets.js';
|
|
6
7
|
export { default as Checkbox } from './Checkbox/index.js';
|
|
7
8
|
export { default as Chip } from './Chip/index.js';
|
|
8
9
|
export { default as ClickOutside } from './ClickOutside/index.js';
|
package/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { default as Avatar } from "./Avatar";
|
|
|
3
3
|
export { default as Badge } from "./Badge";
|
|
4
4
|
export { default as Button } from "./Button";
|
|
5
5
|
export { default as Calendar } from "./Calendar";
|
|
6
|
+
export { getPresets } from "./Calendar/utils/getPresets";
|
|
6
7
|
export { default as Checkbox } from "./Checkbox";
|
|
7
8
|
export { default as Chip } from "./Chip";
|
|
8
9
|
export { default as ClickOutside } from "./ClickOutside";
|
package/index.js
CHANGED
|
@@ -5,6 +5,7 @@ var index$1 = require('./Avatar/index.js');
|
|
|
5
5
|
var index$2 = require('./Badge/index.js');
|
|
6
6
|
var index$3 = require('./Button/index.js');
|
|
7
7
|
var index$4 = require('./Calendar/index.js');
|
|
8
|
+
var getPresets = require('./Calendar/utils/getPresets.js');
|
|
8
9
|
var index$5 = require('./Checkbox/index.js');
|
|
9
10
|
var index$6 = require('./Chip/index.js');
|
|
10
11
|
var index$7 = require('./ClickOutside/index.js');
|
|
@@ -65,6 +66,7 @@ exports.Avatar = index$1.default;
|
|
|
65
66
|
exports.Badge = index$2.default;
|
|
66
67
|
exports.Button = index$3.default;
|
|
67
68
|
exports.Calendar = index$4.default;
|
|
69
|
+
exports.getPresets = getPresets.getPresets;
|
|
68
70
|
exports.Checkbox = index$5.default;
|
|
69
71
|
exports.Chip = index$6.default;
|
|
70
72
|
exports.ClickOutside = index$7.default;
|