funda-ui 4.7.254 → 4.7.255
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/Tooltip/index.d.ts +1 -0
- package/Tooltip/index.js +3 -2
- package/Utils/time.d.ts +5 -1
- package/Utils/time.js +18 -8
- package/lib/cjs/Tooltip/index.d.ts +1 -0
- package/lib/cjs/Tooltip/index.js +3 -2
- package/lib/cjs/Utils/time.d.ts +5 -1
- package/lib/cjs/Utils/time.js +18 -8
- package/lib/esm/Tooltip/index.tsx +6 -1
- package/lib/esm/Utils/libs/time.ts +25 -13
- package/package.json +1 -1
package/Tooltip/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export declare type TooltipProps = {
|
|
3
|
+
triggerClassName?: string;
|
|
3
4
|
wrapperClassName?: string;
|
|
4
5
|
/** The direction of the tip. Defaults to `top`. Possible values are: `top`, `top-right`, `top-left`, `bottom`, `bottom-right`, `bottom-left` */
|
|
5
6
|
direction?: string;
|
package/Tooltip/index.js
CHANGED
|
@@ -1473,7 +1473,8 @@ var useContainerDimensions = function useContainerDimensions(myRef) {
|
|
|
1473
1473
|
return dimensions;
|
|
1474
1474
|
};
|
|
1475
1475
|
var Tooltip = function Tooltip(props) {
|
|
1476
|
-
var
|
|
1476
|
+
var triggerClassName = props.triggerClassName,
|
|
1477
|
+
wrapperClassName = props.wrapperClassName,
|
|
1477
1478
|
direction = props.direction,
|
|
1478
1479
|
offset = props.offset,
|
|
1479
1480
|
exceededSidePosOffset = props.exceededSidePosOffset,
|
|
@@ -1648,7 +1649,7 @@ var Tooltip = function Tooltip(props) {
|
|
|
1648
1649
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1649
1650
|
ref: rootRef,
|
|
1650
1651
|
"data-overlay-id": "tooltip__wrapper-".concat(idRes),
|
|
1651
|
-
className:
|
|
1652
|
+
className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_5__.combinedCls)('tooltip__trigger', (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_5__.clsWrite)(triggerClassName, 'd-inline-block')),
|
|
1652
1653
|
"data-microtip-position": direction || 'top',
|
|
1653
1654
|
"data-microtip-size": size || 'auto',
|
|
1654
1655
|
onMouseEnter: handleMouseEnter,
|
package/Utils/time.d.ts
CHANGED
|
@@ -4,15 +4,19 @@
|
|
|
4
4
|
* @param {string} endTime - end time in format "HH:mm"
|
|
5
5
|
* @param {number} timeInterval - time interval in minutes
|
|
6
6
|
* @param {boolean} formatRange - if true returns ranges like "10:00 - 11:00", if false returns single times like "10:00"
|
|
7
|
+
* @param {boolean} forceShowSeconds - Whether to force the display of seconds.
|
|
8
|
+
* By default, seconds are displayed only when the timeInterval is less than 1
|
|
7
9
|
* @returns {string[]} Array of time slots
|
|
8
10
|
* @example
|
|
9
11
|
|
|
10
12
|
console.log(getTimeslots("10:00", "14:00", 60, true)); //['10:00 - 11:00', '11:00 - 12:00', '12:00 - 13:00', '13:00 - 14:00']
|
|
11
13
|
console.log(getTimeslots("10:00", "14:00", 60)); // ['10:00', '11:00', '12:00', '13:00']
|
|
14
|
+
console.log(getTimeslots("10:00", "14:00", 60, false, true)); // ['10:00:00', '11:00:00', '12:00:00', '13:00:00', '14:00:00']
|
|
15
|
+
console.log(getTimeslots("10:00", "10:07", 1.188118811881188)); // ['10:00', '10:01', '10:02', '10:03', '10:04', '10:05']
|
|
12
16
|
console.log(getTimeslots("08:00:00", "08:02:00", 0.4)); // ['08:00:00', '08:00:24', '08:00:48', '08:01:12', '08:01:36', '08:02:00']
|
|
13
17
|
|
|
14
18
|
*/
|
|
15
|
-
declare function getTimeslots(startTime: string, endTime: string, timeInterval: number, formatRange?: boolean): string[];
|
|
19
|
+
declare function getTimeslots(startTime: string, endTime: string, timeInterval: number, formatRange?: boolean, forceShowSeconds?: boolean): string[];
|
|
16
20
|
/**
|
|
17
21
|
* Get minutes between two dates
|
|
18
22
|
* @param {Date} startDate - start date
|
package/Utils/time.js
CHANGED
|
@@ -57,17 +57,22 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
57
57
|
* @param {string} endTime - end time in format "HH:mm"
|
|
58
58
|
* @param {number} timeInterval - time interval in minutes
|
|
59
59
|
* @param {boolean} formatRange - if true returns ranges like "10:00 - 11:00", if false returns single times like "10:00"
|
|
60
|
+
* @param {boolean} forceShowSeconds - Whether to force the display of seconds.
|
|
61
|
+
* By default, seconds are displayed only when the timeInterval is less than 1
|
|
60
62
|
* @returns {string[]} Array of time slots
|
|
61
63
|
* @example
|
|
62
64
|
|
|
63
65
|
console.log(getTimeslots("10:00", "14:00", 60, true)); //['10:00 - 11:00', '11:00 - 12:00', '12:00 - 13:00', '13:00 - 14:00']
|
|
64
66
|
console.log(getTimeslots("10:00", "14:00", 60)); // ['10:00', '11:00', '12:00', '13:00']
|
|
67
|
+
console.log(getTimeslots("10:00", "14:00", 60, false, true)); // ['10:00:00', '11:00:00', '12:00:00', '13:00:00', '14:00:00']
|
|
68
|
+
console.log(getTimeslots("10:00", "10:07", 1.188118811881188)); // ['10:00', '10:01', '10:02', '10:03', '10:04', '10:05']
|
|
65
69
|
console.log(getTimeslots("08:00:00", "08:02:00", 0.4)); // ['08:00:00', '08:00:24', '08:00:48', '08:01:12', '08:01:36', '08:02:00']
|
|
66
70
|
|
|
67
71
|
*/
|
|
68
72
|
|
|
69
73
|
function getTimeslots(startTime, endTime, timeInterval) {
|
|
70
74
|
var formatRange = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
75
|
+
var forceShowSeconds = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
71
76
|
// Parse time string to seconds
|
|
72
77
|
var parseTime = function parseTime(s) {
|
|
73
78
|
var c = s.split(":").map(Number);
|
|
@@ -81,24 +86,32 @@ function getTimeslots(startTime, endTime, timeInterval) {
|
|
|
81
86
|
return str.length < max ? pad("0" + str, max) : str;
|
|
82
87
|
};
|
|
83
88
|
|
|
84
|
-
// Convert seconds to HH:mm:ss
|
|
85
|
-
var convertTime = function convertTime(secs) {
|
|
89
|
+
// Convert seconds to HH:mm or HH:mm:ss
|
|
90
|
+
var convertTime = function convertTime(secs, showSeconds) {
|
|
86
91
|
var hour = Math.floor(secs / 3600);
|
|
87
92
|
var min = Math.floor(secs % 3600 / 60);
|
|
88
93
|
var sec = secs % 60;
|
|
89
|
-
|
|
94
|
+
if (showSeconds) {
|
|
95
|
+
return pad(hour, 2) + ":" + pad(min, 2) + ":" + pad(sec, 2);
|
|
96
|
+
} else {
|
|
97
|
+
return pad(hour, 2) + ":" + pad(min, 2);
|
|
98
|
+
}
|
|
90
99
|
};
|
|
91
100
|
|
|
101
|
+
// Seconds are displayed only when timeInterval < 1
|
|
102
|
+
var showSeconds = forceShowSeconds || timeInterval < 1;
|
|
103
|
+
var intervalInSeconds = showSeconds ? Math.round(timeInterval * 60) : timeInterval * 60;
|
|
104
|
+
|
|
92
105
|
// Calculate time slots
|
|
93
106
|
var calculateTimeSlot = function calculateTimeSlot(_startTime, _endTime, _timeInterval) {
|
|
94
107
|
var timeSlots = [];
|
|
95
108
|
var currentTime = _startTime;
|
|
96
109
|
while (currentTime <= _endTime) {
|
|
97
110
|
if (formatRange) {
|
|
98
|
-
var t = convertTime(currentTime) + ' - ' + convertTime(Math.min(currentTime + _timeInterval, _endTime));
|
|
111
|
+
var t = convertTime(currentTime, showSeconds) + ' - ' + convertTime(Math.min(currentTime + _timeInterval, _endTime), showSeconds);
|
|
99
112
|
timeSlots.push(t);
|
|
100
113
|
} else {
|
|
101
|
-
timeSlots.push(convertTime(currentTime));
|
|
114
|
+
timeSlots.push(convertTime(currentTime, showSeconds));
|
|
102
115
|
}
|
|
103
116
|
currentTime += _timeInterval;
|
|
104
117
|
}
|
|
@@ -106,9 +119,6 @@ function getTimeslots(startTime, endTime, timeInterval) {
|
|
|
106
119
|
};
|
|
107
120
|
var inputStartTime = parseTime(startTime);
|
|
108
121
|
var inputEndTime = parseTime(endTime);
|
|
109
|
-
// If timeInterval is not an integer, treat as minutes with decimals, convert to seconds
|
|
110
|
-
var isDecimal = !Number.isInteger(timeInterval);
|
|
111
|
-
var intervalInSeconds = isDecimal ? Math.round(timeInterval * 60) : timeInterval * 60;
|
|
112
122
|
return calculateTimeSlot(inputStartTime, inputEndTime, intervalInSeconds);
|
|
113
123
|
}
|
|
114
124
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export declare type TooltipProps = {
|
|
3
|
+
triggerClassName?: string;
|
|
3
4
|
wrapperClassName?: string;
|
|
4
5
|
/** The direction of the tip. Defaults to `top`. Possible values are: `top`, `top-right`, `top-left`, `bottom`, `bottom-right`, `bottom-left` */
|
|
5
6
|
direction?: string;
|
package/lib/cjs/Tooltip/index.js
CHANGED
|
@@ -1473,7 +1473,8 @@ var useContainerDimensions = function useContainerDimensions(myRef) {
|
|
|
1473
1473
|
return dimensions;
|
|
1474
1474
|
};
|
|
1475
1475
|
var Tooltip = function Tooltip(props) {
|
|
1476
|
-
var
|
|
1476
|
+
var triggerClassName = props.triggerClassName,
|
|
1477
|
+
wrapperClassName = props.wrapperClassName,
|
|
1477
1478
|
direction = props.direction,
|
|
1478
1479
|
offset = props.offset,
|
|
1479
1480
|
exceededSidePosOffset = props.exceededSidePosOffset,
|
|
@@ -1648,7 +1649,7 @@ var Tooltip = function Tooltip(props) {
|
|
|
1648
1649
|
return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement((react__WEBPACK_IMPORTED_MODULE_0___default().Fragment), null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
|
|
1649
1650
|
ref: rootRef,
|
|
1650
1651
|
"data-overlay-id": "tooltip__wrapper-".concat(idRes),
|
|
1651
|
-
className:
|
|
1652
|
+
className: (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_5__.combinedCls)('tooltip__trigger', (0,funda_utils_dist_cjs_cls__WEBPACK_IMPORTED_MODULE_5__.clsWrite)(triggerClassName, 'd-inline-block')),
|
|
1652
1653
|
"data-microtip-position": direction || 'top',
|
|
1653
1654
|
"data-microtip-size": size || 'auto',
|
|
1654
1655
|
onMouseEnter: handleMouseEnter,
|
package/lib/cjs/Utils/time.d.ts
CHANGED
|
@@ -4,15 +4,19 @@
|
|
|
4
4
|
* @param {string} endTime - end time in format "HH:mm"
|
|
5
5
|
* @param {number} timeInterval - time interval in minutes
|
|
6
6
|
* @param {boolean} formatRange - if true returns ranges like "10:00 - 11:00", if false returns single times like "10:00"
|
|
7
|
+
* @param {boolean} forceShowSeconds - Whether to force the display of seconds.
|
|
8
|
+
* By default, seconds are displayed only when the timeInterval is less than 1
|
|
7
9
|
* @returns {string[]} Array of time slots
|
|
8
10
|
* @example
|
|
9
11
|
|
|
10
12
|
console.log(getTimeslots("10:00", "14:00", 60, true)); //['10:00 - 11:00', '11:00 - 12:00', '12:00 - 13:00', '13:00 - 14:00']
|
|
11
13
|
console.log(getTimeslots("10:00", "14:00", 60)); // ['10:00', '11:00', '12:00', '13:00']
|
|
14
|
+
console.log(getTimeslots("10:00", "14:00", 60, false, true)); // ['10:00:00', '11:00:00', '12:00:00', '13:00:00', '14:00:00']
|
|
15
|
+
console.log(getTimeslots("10:00", "10:07", 1.188118811881188)); // ['10:00', '10:01', '10:02', '10:03', '10:04', '10:05']
|
|
12
16
|
console.log(getTimeslots("08:00:00", "08:02:00", 0.4)); // ['08:00:00', '08:00:24', '08:00:48', '08:01:12', '08:01:36', '08:02:00']
|
|
13
17
|
|
|
14
18
|
*/
|
|
15
|
-
declare function getTimeslots(startTime: string, endTime: string, timeInterval: number, formatRange?: boolean): string[];
|
|
19
|
+
declare function getTimeslots(startTime: string, endTime: string, timeInterval: number, formatRange?: boolean, forceShowSeconds?: boolean): string[];
|
|
16
20
|
/**
|
|
17
21
|
* Get minutes between two dates
|
|
18
22
|
* @param {Date} startDate - start date
|
package/lib/cjs/Utils/time.js
CHANGED
|
@@ -57,17 +57,22 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
57
57
|
* @param {string} endTime - end time in format "HH:mm"
|
|
58
58
|
* @param {number} timeInterval - time interval in minutes
|
|
59
59
|
* @param {boolean} formatRange - if true returns ranges like "10:00 - 11:00", if false returns single times like "10:00"
|
|
60
|
+
* @param {boolean} forceShowSeconds - Whether to force the display of seconds.
|
|
61
|
+
* By default, seconds are displayed only when the timeInterval is less than 1
|
|
60
62
|
* @returns {string[]} Array of time slots
|
|
61
63
|
* @example
|
|
62
64
|
|
|
63
65
|
console.log(getTimeslots("10:00", "14:00", 60, true)); //['10:00 - 11:00', '11:00 - 12:00', '12:00 - 13:00', '13:00 - 14:00']
|
|
64
66
|
console.log(getTimeslots("10:00", "14:00", 60)); // ['10:00', '11:00', '12:00', '13:00']
|
|
67
|
+
console.log(getTimeslots("10:00", "14:00", 60, false, true)); // ['10:00:00', '11:00:00', '12:00:00', '13:00:00', '14:00:00']
|
|
68
|
+
console.log(getTimeslots("10:00", "10:07", 1.188118811881188)); // ['10:00', '10:01', '10:02', '10:03', '10:04', '10:05']
|
|
65
69
|
console.log(getTimeslots("08:00:00", "08:02:00", 0.4)); // ['08:00:00', '08:00:24', '08:00:48', '08:01:12', '08:01:36', '08:02:00']
|
|
66
70
|
|
|
67
71
|
*/
|
|
68
72
|
|
|
69
73
|
function getTimeslots(startTime, endTime, timeInterval) {
|
|
70
74
|
var formatRange = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
75
|
+
var forceShowSeconds = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
71
76
|
// Parse time string to seconds
|
|
72
77
|
var parseTime = function parseTime(s) {
|
|
73
78
|
var c = s.split(":").map(Number);
|
|
@@ -81,24 +86,32 @@ function getTimeslots(startTime, endTime, timeInterval) {
|
|
|
81
86
|
return str.length < max ? pad("0" + str, max) : str;
|
|
82
87
|
};
|
|
83
88
|
|
|
84
|
-
// Convert seconds to HH:mm:ss
|
|
85
|
-
var convertTime = function convertTime(secs) {
|
|
89
|
+
// Convert seconds to HH:mm or HH:mm:ss
|
|
90
|
+
var convertTime = function convertTime(secs, showSeconds) {
|
|
86
91
|
var hour = Math.floor(secs / 3600);
|
|
87
92
|
var min = Math.floor(secs % 3600 / 60);
|
|
88
93
|
var sec = secs % 60;
|
|
89
|
-
|
|
94
|
+
if (showSeconds) {
|
|
95
|
+
return pad(hour, 2) + ":" + pad(min, 2) + ":" + pad(sec, 2);
|
|
96
|
+
} else {
|
|
97
|
+
return pad(hour, 2) + ":" + pad(min, 2);
|
|
98
|
+
}
|
|
90
99
|
};
|
|
91
100
|
|
|
101
|
+
// Seconds are displayed only when timeInterval < 1
|
|
102
|
+
var showSeconds = forceShowSeconds || timeInterval < 1;
|
|
103
|
+
var intervalInSeconds = showSeconds ? Math.round(timeInterval * 60) : timeInterval * 60;
|
|
104
|
+
|
|
92
105
|
// Calculate time slots
|
|
93
106
|
var calculateTimeSlot = function calculateTimeSlot(_startTime, _endTime, _timeInterval) {
|
|
94
107
|
var timeSlots = [];
|
|
95
108
|
var currentTime = _startTime;
|
|
96
109
|
while (currentTime <= _endTime) {
|
|
97
110
|
if (formatRange) {
|
|
98
|
-
var t = convertTime(currentTime) + ' - ' + convertTime(Math.min(currentTime + _timeInterval, _endTime));
|
|
111
|
+
var t = convertTime(currentTime, showSeconds) + ' - ' + convertTime(Math.min(currentTime + _timeInterval, _endTime), showSeconds);
|
|
99
112
|
timeSlots.push(t);
|
|
100
113
|
} else {
|
|
101
|
-
timeSlots.push(convertTime(currentTime));
|
|
114
|
+
timeSlots.push(convertTime(currentTime, showSeconds));
|
|
102
115
|
}
|
|
103
116
|
currentTime += _timeInterval;
|
|
104
117
|
}
|
|
@@ -106,9 +119,6 @@ function getTimeslots(startTime, endTime, timeInterval) {
|
|
|
106
119
|
};
|
|
107
120
|
var inputStartTime = parseTime(startTime);
|
|
108
121
|
var inputEndTime = parseTime(endTime);
|
|
109
|
-
// If timeInterval is not an integer, treat as minutes with decimals, convert to seconds
|
|
110
|
-
var isDecimal = !Number.isInteger(timeInterval);
|
|
111
|
-
var intervalInSeconds = isDecimal ? Math.round(timeInterval * 60) : timeInterval * 60;
|
|
112
122
|
return calculateTimeSlot(inputStartTime, inputEndTime, intervalInSeconds);
|
|
113
123
|
}
|
|
114
124
|
|
|
@@ -14,6 +14,7 @@ import { getElCSS } from 'funda-utils/dist/cjs/inputsCalculation';
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
export type TooltipProps = {
|
|
17
|
+
triggerClassName?: string;
|
|
17
18
|
wrapperClassName?: string;
|
|
18
19
|
/** The direction of the tip. Defaults to `top`. Possible values are: `top`, `top-right`, `top-left`, `bottom`, `bottom-right`, `bottom-left` */
|
|
19
20
|
direction?: string;
|
|
@@ -64,6 +65,7 @@ const useContainerDimensions = (myRef: any) => {
|
|
|
64
65
|
|
|
65
66
|
const Tooltip = (props: TooltipProps) => {
|
|
66
67
|
const {
|
|
68
|
+
triggerClassName,
|
|
67
69
|
wrapperClassName,
|
|
68
70
|
direction,
|
|
69
71
|
offset,
|
|
@@ -267,7 +269,10 @@ const Tooltip = (props: TooltipProps) => {
|
|
|
267
269
|
<div
|
|
268
270
|
ref={rootRef}
|
|
269
271
|
data-overlay-id={`tooltip__wrapper-${idRes}`}
|
|
270
|
-
className=
|
|
272
|
+
className={combinedCls(
|
|
273
|
+
'tooltip__trigger',
|
|
274
|
+
clsWrite(triggerClassName, 'd-inline-block')
|
|
275
|
+
)}
|
|
271
276
|
data-microtip-position={direction || 'top'}
|
|
272
277
|
data-microtip-size={size || 'auto'}
|
|
273
278
|
onMouseEnter={handleMouseEnter}
|
|
@@ -1,14 +1,20 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Get timeslots from starting and ending time
|
|
3
5
|
* @param {string} startTime - start time in format "HH:mm"
|
|
4
6
|
* @param {string} endTime - end time in format "HH:mm"
|
|
5
7
|
* @param {number} timeInterval - time interval in minutes
|
|
6
8
|
* @param {boolean} formatRange - if true returns ranges like "10:00 - 11:00", if false returns single times like "10:00"
|
|
9
|
+
* @param {boolean} forceShowSeconds - Whether to force the display of seconds.
|
|
10
|
+
* By default, seconds are displayed only when the timeInterval is less than 1
|
|
7
11
|
* @returns {string[]} Array of time slots
|
|
8
12
|
* @example
|
|
9
13
|
|
|
10
14
|
console.log(getTimeslots("10:00", "14:00", 60, true)); //['10:00 - 11:00', '11:00 - 12:00', '12:00 - 13:00', '13:00 - 14:00']
|
|
11
15
|
console.log(getTimeslots("10:00", "14:00", 60)); // ['10:00', '11:00', '12:00', '13:00']
|
|
16
|
+
console.log(getTimeslots("10:00", "14:00", 60, false, true)); // ['10:00:00', '11:00:00', '12:00:00', '13:00:00', '14:00:00']
|
|
17
|
+
console.log(getTimeslots("10:00", "10:07", 1.188118811881188)); // ['10:00', '10:01', '10:02', '10:03', '10:04', '10:05']
|
|
12
18
|
console.log(getTimeslots("08:00:00", "08:02:00", 0.4)); // ['08:00:00', '08:00:24', '08:00:48', '08:01:12', '08:01:36', '08:02:00']
|
|
13
19
|
|
|
14
20
|
*/
|
|
@@ -17,7 +23,8 @@ function getTimeslots(
|
|
|
17
23
|
startTime: string,
|
|
18
24
|
endTime: string,
|
|
19
25
|
timeInterval: number,
|
|
20
|
-
formatRange: boolean = false
|
|
26
|
+
formatRange: boolean = false,
|
|
27
|
+
forceShowSeconds = false
|
|
21
28
|
): string[] {
|
|
22
29
|
// Parse time string to seconds
|
|
23
30
|
const parseTime = (s: string): number => {
|
|
@@ -32,24 +39,33 @@ function getTimeslots(
|
|
|
32
39
|
return str.length < max ? pad("0" + str, max) : str;
|
|
33
40
|
}
|
|
34
41
|
|
|
35
|
-
// Convert seconds to HH:mm:ss
|
|
36
|
-
const convertTime = (secs: number): string => {
|
|
42
|
+
// Convert seconds to HH:mm or HH:mm:ss
|
|
43
|
+
const convertTime = (secs: number, showSeconds: boolean): string => {
|
|
37
44
|
const hour = Math.floor(secs / 3600);
|
|
38
45
|
const min = Math.floor((secs % 3600) / 60);
|
|
39
46
|
const sec = secs % 60;
|
|
40
|
-
|
|
47
|
+
if (showSeconds) {
|
|
48
|
+
return pad(hour, 2) + ":" + pad(min, 2) + ":" + pad(sec, 2);
|
|
49
|
+
} else {
|
|
50
|
+
return pad(hour, 2) + ":" + pad(min, 2);
|
|
51
|
+
}
|
|
41
52
|
}
|
|
42
53
|
|
|
54
|
+
|
|
55
|
+
// Seconds are displayed only when timeInterval < 1
|
|
56
|
+
const showSeconds = forceShowSeconds || timeInterval < 1;
|
|
57
|
+
const intervalInSeconds = showSeconds ? Math.round(timeInterval * 60) : timeInterval * 60;
|
|
58
|
+
|
|
43
59
|
// Calculate time slots
|
|
44
60
|
const calculateTimeSlot = (_startTime: number, _endTime: number, _timeInterval: number): string[] => {
|
|
45
61
|
const timeSlots: string[] = [];
|
|
46
62
|
let currentTime = _startTime;
|
|
47
63
|
while (currentTime <= _endTime) {
|
|
48
64
|
if (formatRange) {
|
|
49
|
-
const t = convertTime(currentTime) + ' - ' + convertTime(Math.min(currentTime + _timeInterval, _endTime));
|
|
65
|
+
const t = convertTime(currentTime, showSeconds) + ' - ' + convertTime(Math.min(currentTime + _timeInterval, _endTime), showSeconds);
|
|
50
66
|
timeSlots.push(t);
|
|
51
67
|
} else {
|
|
52
|
-
timeSlots.push(convertTime(currentTime));
|
|
68
|
+
timeSlots.push(convertTime(currentTime, showSeconds));
|
|
53
69
|
}
|
|
54
70
|
currentTime += _timeInterval;
|
|
55
71
|
}
|
|
@@ -58,13 +74,12 @@ function getTimeslots(
|
|
|
58
74
|
|
|
59
75
|
const inputStartTime = parseTime(startTime);
|
|
60
76
|
const inputEndTime = parseTime(endTime);
|
|
61
|
-
|
|
62
|
-
const isDecimal = !Number.isInteger(timeInterval);
|
|
63
|
-
const intervalInSeconds = isDecimal ? Math.round(timeInterval * 60) : timeInterval * 60;
|
|
77
|
+
|
|
64
78
|
return calculateTimeSlot(inputStartTime, inputEndTime, intervalInSeconds);
|
|
65
79
|
}
|
|
66
80
|
|
|
67
81
|
|
|
82
|
+
|
|
68
83
|
/**
|
|
69
84
|
* Get minutes between two dates
|
|
70
85
|
* @param {Date} startDate - start date
|
|
@@ -93,7 +108,7 @@ function getMinutesBetweenTime(startTime: string, endTime: string) {
|
|
|
93
108
|
|
|
94
109
|
if (diff < 0) { sMin -= 12 * 60; diff = eMin - sMin }
|
|
95
110
|
const h = Math.floor(diff / 60),
|
|
96
|
-
|
|
111
|
+
m = diff % 60;
|
|
97
112
|
return "" + pad(h) + ":" + pad(m);
|
|
98
113
|
}
|
|
99
114
|
|
|
@@ -122,6 +137,3 @@ export {
|
|
|
122
137
|
convertTimeToMin
|
|
123
138
|
};
|
|
124
139
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"author": "UIUX Lab",
|
|
3
3
|
"email": "uiuxlab@gmail.com",
|
|
4
4
|
"name": "funda-ui",
|
|
5
|
-
"version": "4.7.
|
|
5
|
+
"version": "4.7.255",
|
|
6
6
|
"description": "React components using pure Bootstrap 5+ which does not contain any external style and script libraries.",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|