oolib 2.68.5 → 2.69.1
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/dist/components/DateTimePicker/index.d.ts +2 -0
- package/dist/components/DateTimePicker/index.js +82 -0
- package/dist/components/DateTimeRangePicker/index.d.ts +2 -0
- package/dist/components/DateTimeRangePicker/index.js +91 -0
- package/dist/components/EmptyStates/config.js +1 -1
- package/dist/components/EmptyStates/index.d.ts +2 -1
- package/dist/components/EmptyStates/index.js +11 -10
- package/dist/components/TimePicker/handlers/handleTimeValidation.d.ts +1 -0
- package/dist/components/TimePicker/handlers/handleTimeValidation.js +58 -0
- package/dist/components/TimePicker/index.d.ts +2 -0
- package/dist/components/TimePicker/index.js +136 -0
- package/dist/components/TimePicker/styled.d.ts +6 -0
- package/dist/components/TimePicker/styled.js +60 -0
- package/dist/components/TimePicker/utils/convertTo12Hour.d.ts +1 -0
- package/dist/components/TimePicker/utils/convertTo12Hour.js +27 -0
- package/dist/components/TimePicker/utils/convertToMiltaryTime.d.ts +1 -0
- package/dist/components/TimePicker/utils/convertToMiltaryTime.js +26 -0
- package/dist/components/TimePicker/utils/getNearestTimeToCurrentTime.d.ts +1 -0
- package/dist/components/TimePicker/utils/getNearestTimeToCurrentTime.js +26 -0
- package/dist/components/TimePicker/utils/highLightTime.d.ts +1 -0
- package/dist/components/TimePicker/utils/highLightTime.js +9 -0
- package/dist/components/TimePicker/utils/timeToMinutes.d.ts +1 -0
- package/dist/components/TimePicker/utils/timeToMinutes.js +20 -0
- package/dist/components/TimeRangePicker/index.d.ts +2 -0
- package/dist/components/TimeRangePicker/index.js +70 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +15 -5
- package/package.json +1 -1
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.DateTimePicker = void 0;
|
|
41
|
+
var react_1 = __importStar(require("react"));
|
|
42
|
+
var BlockLabel_1 = require("../BlockLabel");
|
|
43
|
+
var TimePicker_1 = require("../TimePicker");
|
|
44
|
+
var getBlockLabelProps_1 = require("../../utils/getBlockLabelProps");
|
|
45
|
+
var DatePicker_1 = __importDefault(require("../DatePicker"));
|
|
46
|
+
var convertTo12Hour_1 = require("../TimePicker/utils/convertTo12Hour");
|
|
47
|
+
var DateTimePicker = function (props) {
|
|
48
|
+
var parentOnChange = props.onChange, value = props.value, id = props.id, readOnly = props.readOnly, futureDateOnly = props.futureDateOnly, previousDateOnly = props.previousDateOnly, passChangeHandlerOps = props.passChangeHandlerOps, invert = props.invert, disabled = props.disabled;
|
|
49
|
+
var _a = (0, react_1.useState)({ date: value === null || value === void 0 ? void 0 : value.date, time: (value === null || value === void 0 ? void 0 : value.time) && (0, convertTo12Hour_1.convertTo12Hour)(value === null || value === void 0 ? void 0 : value.time) }), _value = _a[0], _setValue = _a[1];
|
|
50
|
+
var handleOnChange = function (k, v) {
|
|
51
|
+
var _a;
|
|
52
|
+
var newVal = __assign(__assign({}, _value), (_a = {}, _a[k] = v, _a));
|
|
53
|
+
if (newVal.date && newVal.time) {
|
|
54
|
+
// date returned by datepicker is ISO (meaning GMT time)
|
|
55
|
+
// we need to get IST. Date class will convert it to IST.
|
|
56
|
+
var date = new Date(newVal.date);
|
|
57
|
+
var timeSplit = newVal.time.split(':');
|
|
58
|
+
//set the time within the date string using the timeValue numbers
|
|
59
|
+
date.setHours(timeSplit[0]);
|
|
60
|
+
date.setMinutes(timeSplit[1]);
|
|
61
|
+
date.setSeconds(timeSplit[2] || '00');
|
|
62
|
+
newVal = __assign(__assign({}, newVal), { date: date.toISOString() });
|
|
63
|
+
}
|
|
64
|
+
_setValue(newVal);
|
|
65
|
+
newVal.date &&
|
|
66
|
+
parentOnChange &&
|
|
67
|
+
parentOnChange(id, { date: newVal === null || newVal === void 0 ? void 0 : newVal.date, time: newVal === null || newVal === void 0 ? void 0 : newVal.time }, passChangeHandlerOps && props);
|
|
68
|
+
};
|
|
69
|
+
(0, react_1.useEffect)(function () {
|
|
70
|
+
if (value && (value.date !== _value.date || value.time !== _value.time)) {
|
|
71
|
+
// if there is a change basically
|
|
72
|
+
_setValue({ date: value === null || value === void 0 ? void 0 : value.date, time: (value === null || value === void 0 ? void 0 : value.time) && (0, convertTo12Hour_1.convertTo12Hour)(value === null || value === void 0 ? void 0 : value.time) });
|
|
73
|
+
}
|
|
74
|
+
}, [value]);
|
|
75
|
+
return (react_1.default.createElement("div", { id: id },
|
|
76
|
+
react_1.default.createElement(BlockLabel_1.BlockLabel, __assign({}, (0, getBlockLabelProps_1.getBlockLabelProps)(props))),
|
|
77
|
+
react_1.default.createElement("div", { style: { display: 'flex', alignItems: 'center', gap: '2rem' } },
|
|
78
|
+
react_1.default.createElement(DatePicker_1.default, { value: _value.date, onChange: function (k, v) { return handleOnChange('date', v); }, readOnly: readOnly, futureDateOnly: futureDateOnly, previousDateOnly: previousDateOnly, invert: invert, disabled: disabled }),
|
|
79
|
+
react_1.default.createElement(TimePicker_1.TimePicker, { value: _value.time, onChange: function (k, v) { return handleOnChange('time', v); }, readOnly: readOnly, invert: invert, disabled: disabled }))));
|
|
80
|
+
};
|
|
81
|
+
exports.DateTimePicker = DateTimePicker;
|
|
82
|
+
// export default React.memo(DateTimePickerV2);
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
37
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.DateTimeRangePicker = void 0;
|
|
41
|
+
var react_1 = __importStar(require("react"));
|
|
42
|
+
var InlineAlert_1 = require("../InlineAlert");
|
|
43
|
+
var DatePicker_1 = __importDefault(require("../DatePicker"));
|
|
44
|
+
var TimeRangePicker_1 = require("../TimeRangePicker");
|
|
45
|
+
var BlockLabel_1 = require("../BlockLabel");
|
|
46
|
+
var getBlockLabelProps_1 = require("../../utils/getBlockLabelProps");
|
|
47
|
+
var DateTimeRangePicker = function (props) {
|
|
48
|
+
var onChange = props.onChange, value = props.value, id = props.id, readOnly = props.readOnly, futureDateOnly = props.futureDateOnly, previousDateOnly = props.previousDateOnly, passChangeHandlerOps = props.passChangeHandlerOps, invert = props.invert, isPassedText = props.isPassedText, disabled = props.disabled;
|
|
49
|
+
var _a = (0, react_1.useState)(value), _value = _a[0], _setValue = _a[1];
|
|
50
|
+
var checkIfDatePassed = function (date) {
|
|
51
|
+
if (!date)
|
|
52
|
+
return false;
|
|
53
|
+
var givenDate = new Date(date);
|
|
54
|
+
var today = new Date();
|
|
55
|
+
return givenDate > today ? false : true;
|
|
56
|
+
};
|
|
57
|
+
var _b = (0, react_1.useState)(checkIfDatePassed(value === null || value === void 0 ? void 0 : value.date)), isPassed = _b[0], setIsPassed = _b[1];
|
|
58
|
+
var handleOnChange = function (k, v) {
|
|
59
|
+
var _a;
|
|
60
|
+
var newVal = __assign(__assign({}, _value), (_a = {}, _a[k] = v, _a));
|
|
61
|
+
if (newVal.date && newVal.timeRange && newVal.timeRange[0]) {
|
|
62
|
+
// date returned by datepicker is ISO (meaning GMT time)
|
|
63
|
+
// we need to get IST. Date class will convert it to IST.
|
|
64
|
+
var date = new Date(newVal.date);
|
|
65
|
+
var timeSplit = newVal.timeRange[0].split(':');
|
|
66
|
+
//set the time within the date string using the timeValue numbers
|
|
67
|
+
date.setHours(timeSplit[0]);
|
|
68
|
+
date.setMinutes(timeSplit[1]);
|
|
69
|
+
date.setSeconds(timeSplit[2] || "00");
|
|
70
|
+
newVal = (__assign(__assign({}, newVal), { date: date.toISOString() }));
|
|
71
|
+
}
|
|
72
|
+
_setValue(newVal);
|
|
73
|
+
setIsPassed(checkIfDatePassed(newVal.date));
|
|
74
|
+
if (newVal.date && newVal.timeRange && newVal.timeRange[0] && newVal.timeRange[1]) {
|
|
75
|
+
onChange && onChange(id, newVal, passChangeHandlerOps && props);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
(0, react_1.useEffect)(function () {
|
|
79
|
+
if (value && (value.date !== _value.date ||
|
|
80
|
+
(value.timeRange && _value.timeRange && value.timeRange.some(function (v, i) { return v !== _value.timeRange[i]; })))) { // if there is a change basically
|
|
81
|
+
_setValue(value);
|
|
82
|
+
}
|
|
83
|
+
}, [value]);
|
|
84
|
+
return (react_1.default.createElement("div", { id: id },
|
|
85
|
+
react_1.default.createElement(BlockLabel_1.BlockLabel, __assign({}, (0, getBlockLabelProps_1.getBlockLabelProps)(props))),
|
|
86
|
+
react_1.default.createElement("div", { style: { display: 'flex', flexWrap: 'wrap', columnGap: '4rem', rowGap: '2rem' } },
|
|
87
|
+
react_1.default.createElement(DatePicker_1.default, { value: _value === null || _value === void 0 ? void 0 : _value.date, onChange: function (k, v) { return handleOnChange('date', v); }, readOnly: readOnly, futureDateOnly: futureDateOnly, previousDateOnly: previousDateOnly, invert: invert, disabled: disabled }),
|
|
88
|
+
react_1.default.createElement(TimeRangePicker_1.TimeRangePicker, { value: _value === null || _value === void 0 ? void 0 : _value.timeRange, onChange: function (k, v) { return handleOnChange('timeRange', v); }, readOnly: readOnly, invert: invert, disabled: disabled })),
|
|
89
|
+
isPassed && react_1.default.createElement(InlineAlert_1.InlineAlert, { type: 'danger', text: isPassedText || 'This Date Is Passed' })));
|
|
90
|
+
};
|
|
91
|
+
exports.DateTimeRangePicker = DateTimeRangePicker;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
export function EmptyStates({ preset, actionOnClick, additionalActionOnClick, titleStyle, subTitleStyle }: {
|
|
1
|
+
export function EmptyStates({ preset, actionOnClick, additionalActionOnClick, titleStyle, subTitleStyle, title: titleProp }: {
|
|
2
2
|
preset: any;
|
|
3
3
|
actionOnClick: any;
|
|
4
4
|
additionalActionOnClick: any;
|
|
5
5
|
titleStyle: any;
|
|
6
6
|
subTitleStyle: any;
|
|
7
|
+
title: any;
|
|
7
8
|
}): React.JSX.Element;
|
|
8
9
|
import React from "react";
|
|
@@ -29,10 +29,11 @@ var congratulationsImg_svg_1 = __importDefault(require("../../assets/images/cong
|
|
|
29
29
|
var searchDashBoardListing_svg_1 = __importDefault(require("../../assets/images/searchDashBoardListing.svg"));
|
|
30
30
|
var dashboardListing_svg_1 = __importDefault(require("../../assets/images/dashboardListing.svg"));
|
|
31
31
|
var styled_components_1 = __importDefault(require("styled-components"));
|
|
32
|
-
var StyledContainer = (0, styled_components_1.default)(Container_1.Container)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["
|
|
32
|
+
var StyledContainer = (0, styled_components_1.default)(Container_1.Container)(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n padding: ", ";\n display: ", ";\n justify-content: \"center\";\n text-align: ", ";\n\n ", " {\n padding: ", ";\n }\n"], ["\n padding: ", ";\n display: ", ";\n justify-content: \"center\";\n text-align: ", ";\n\n ", " {\n padding: ", ";\n }\n"])), function (props) { return (props.layout === "center" ? "2rem 0rem" : "4rem 0"); }, function (props) { return props.layout === "center" && "flex"; }, function (props) { return props.layout === "center" && "center"; }, (0, mixins_1.mediaQuery)("sm"), function (props) { return (props.layout === "center" ? "4rem 0" : "6rem 0"); });
|
|
33
33
|
var EmptyStates = function (_a) {
|
|
34
|
-
var preset = _a.preset, actionOnClick = _a.actionOnClick, additionalActionOnClick = _a.additionalActionOnClick, titleStyle = _a.titleStyle, subTitleStyle = _a.subTitleStyle;
|
|
35
|
-
var _b = config_1.emptyStatesConfig[preset], img = _b.img, imgSize = _b.imgSize,
|
|
34
|
+
var preset = _a.preset, actionOnClick = _a.actionOnClick, additionalActionOnClick = _a.additionalActionOnClick, titleStyle = _a.titleStyle, subTitleStyle = _a.subTitleStyle, titleProp = _a.title;
|
|
35
|
+
var _b = config_1.emptyStatesConfig[preset], img = _b.img, imgSize = _b.imgSize, titleConfig = _b.title, subTitle = _b.subTitle, action = _b.action, additionalAction = _b.additionalAction, layout = _b.layout, opacity = _b.opacity;
|
|
36
|
+
var title = titleProp || titleConfig; //if a title prop is provided, it overrides title from config
|
|
36
37
|
var imgConfig = {
|
|
37
38
|
publishedListing: publishedListing_svg_1.default,
|
|
38
39
|
contentListing: contentListing_svg_1.default,
|
|
@@ -44,22 +45,22 @@ var EmptyStates = function (_a) {
|
|
|
44
45
|
mailBoxImg: mailBoxImg_svg_1.default,
|
|
45
46
|
congratulationsImg: congratulationsImg_svg_1.default,
|
|
46
47
|
searchDashBoardListing: searchDashBoardListing_svg_1.default,
|
|
47
|
-
dashboardListing: dashboardListing_svg_1.default
|
|
48
|
+
dashboardListing: dashboardListing_svg_1.default,
|
|
48
49
|
};
|
|
49
|
-
var Title = (0, styled_components_1.default)(Typo_1.SERIF_5_6)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n
|
|
50
|
-
var SubTitle = (0, styled_components_1.default)(Typo_1.SANS_3_4)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n
|
|
50
|
+
var Title = (0, styled_components_1.default)(Typo_1.SERIF_5_6)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n ", "\n "], ["\n ", "\n "])), titleStyle ? titleStyle : { marginTop: "2rem" });
|
|
51
|
+
var SubTitle = (0, styled_components_1.default)(Typo_1.SANS_3_4)(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", "\n "], ["\n ", "\n "])), subTitleStyle ? subTitleStyle : { marginTop: "1rem" });
|
|
51
52
|
return (react_1.default.createElement(StyledContainer, { layout: layout },
|
|
52
53
|
react_1.default.createElement(Wrappers_1.Wrapper650, { style: { margin: layout === "center" ? "auto" : 0 } },
|
|
53
|
-
img && (react_1.default.createElement("img", { src: imgConfig[img], alt:
|
|
54
|
-
opacity: opacity ? opacity : layout === "center" ?
|
|
55
|
-
height: imgSize ? imgSize +
|
|
54
|
+
img && (react_1.default.createElement("img", { src: imgConfig[img], alt: "", style: {
|
|
55
|
+
opacity: opacity ? opacity : layout === "center" ? "0.6" : "0.5",
|
|
56
|
+
height: imgSize ? imgSize + "px" : "120px",
|
|
56
57
|
} })),
|
|
57
58
|
title && react_1.default.createElement(Title, null, title),
|
|
58
59
|
subTitle && react_1.default.createElement(SubTitle, null, subTitle),
|
|
59
60
|
additionalAction && (react_1.default.createElement(Paddings_1.PaddingTop10, null,
|
|
60
61
|
react_1.default.createElement(Typo_1.SANS_3, null,
|
|
61
62
|
react_1.default.createElement(OKELink_1.OKELink, { to: "#", onClick: additionalActionOnClick }, additionalAction.text))))),
|
|
62
|
-
action && (react_1.default.createElement(Buttons_1.ButtonPrimary, { onClick: actionOnClick, style: { marginTop:
|
|
63
|
+
action && (react_1.default.createElement(Buttons_1.ButtonPrimary, { onClick: actionOnClick, style: { marginTop: "2rem", opacity: "1" } }, action === null || action === void 0 ? void 0 : action.btnText))));
|
|
63
64
|
};
|
|
64
65
|
exports.EmptyStates = EmptyStates;
|
|
65
66
|
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function handleTimeValidation(newValue: any, setErrorMessage: any, setInputValue: any): void;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.handleTimeValidation = void 0;
|
|
4
|
+
function handleTimeValidation(newValue, setErrorMessage, setInputValue) {
|
|
5
|
+
// Check if the input has at least 2 characters
|
|
6
|
+
if (newValue.length >= 2) {
|
|
7
|
+
// Parse the first 2 characters as hours
|
|
8
|
+
var hours = parseInt(newValue.substring(0, 2));
|
|
9
|
+
// Validate the hours: should be between 1 and 12
|
|
10
|
+
if (isNaN(hours) || hours < 1 || hours > 12) {
|
|
11
|
+
setErrorMessage('Invalid hour');
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// Check if the input has at least 4 characters
|
|
16
|
+
if (newValue.length >= 4) {
|
|
17
|
+
// Validate the format of the input: should have a colon (:) at the right position
|
|
18
|
+
if ((newValue[2] !== ':' && newValue[1] !== ':') || (newValue[2] === ':' && newValue[1] === ':')) {
|
|
19
|
+
setErrorMessage('Invalid format');
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
// Check if the input has at least 5 characters
|
|
24
|
+
if (newValue.length >= 5) {
|
|
25
|
+
// Parse the last 2 characters as minutes
|
|
26
|
+
var minutes = parseInt(newValue.substring(3, 5));
|
|
27
|
+
// Validate the minutes: should be between 0 and 59
|
|
28
|
+
if (isNaN(minutes) || minutes < 0 || minutes > 59) {
|
|
29
|
+
setErrorMessage('Invalid minutes');
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// Check if the input has at least 7 characters
|
|
34
|
+
if (newValue.length >= 7) {
|
|
35
|
+
// Validate the AM/PM part and ensure there's a space after the time
|
|
36
|
+
if (newValue[2] === ':' && (newValue[6] !== 'A' && newValue[6] !== 'P' && newValue[7] !== 'M')) {
|
|
37
|
+
setErrorMessage('Invalid AM/PM, Add space after time');
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
if (newValue[3] === ':' && (newValue[7] !== 'A' && newValue[7] !== 'P' && newValue[8] !== 'M')) {
|
|
41
|
+
setErrorMessage('Invalid AM/PM, Add space after time');
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
// Convert AM/PM to uppercase and truncate the input to 8 characters
|
|
45
|
+
newValue = newValue.substring(0, 8).toUpperCase();
|
|
46
|
+
}
|
|
47
|
+
// Set the cleaned and validated value, and clear any previous error message
|
|
48
|
+
setInputValue(newValue);
|
|
49
|
+
setErrorMessage(null);
|
|
50
|
+
}
|
|
51
|
+
exports.handleTimeValidation = handleTimeValidation;
|
|
52
|
+
// The current behaviour of this component works well with format of 00:00 AM/PM values, not validating correctly when 0:00 AM/PM is entered
|
|
53
|
+
// This will be important to solve. It should let you input 230 and then take you to 2:30PM. ->
|
|
54
|
+
// This happens because we are not allowing user to enter hours before ":" >= than 12 (12 hours format), so if user enters 13 it is invalid hour
|
|
55
|
+
// may be regex can be applied to autoformat
|
|
56
|
+
// The keyboard function is not working - but this can be layer 2 -
|
|
57
|
+
// [need to figure out functionality, right now if Enter is pressed it selects nearest time if to current time If incorrect time is entered,
|
|
58
|
+
// and if right time is entered blur gets called]
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37
|
+
exports.TimePicker = void 0;
|
|
38
|
+
var react_1 = __importStar(require("react"));
|
|
39
|
+
var BlockLabel_1 = require("../BlockLabel");
|
|
40
|
+
var getBlockLabelProps_1 = require("../../utils/getBlockLabelProps");
|
|
41
|
+
var styled_1 = require("./styled");
|
|
42
|
+
var Typo_1 = require("../Typo");
|
|
43
|
+
var convertToMiltaryTime_1 = require("./utils/convertToMiltaryTime");
|
|
44
|
+
var getNearestTimeToCurrentTime_1 = require("./utils/getNearestTimeToCurrentTime");
|
|
45
|
+
var highLightTime_1 = require("./utils/highLightTime");
|
|
46
|
+
var handleTimeValidation_1 = require("./handlers/handleTimeValidation");
|
|
47
|
+
var convertTo12Hour_1 = require("./utils/convertTo12Hour");
|
|
48
|
+
var TimePicker = function (props) {
|
|
49
|
+
var readOnly = props.readOnly, invert = props.invert, disabled = props.disabled, onParentChange = props.onChange, id = props.id, value = props.value;
|
|
50
|
+
var _a = (0, react_1.useState)(value ? (0, convertTo12Hour_1.convertTo12Hour)(value) : null), inputValue = _a[0], setInputValue = _a[1];
|
|
51
|
+
var _b = (0, react_1.useState)(""), errorMessage = _b[0], setErrorMessage = _b[1];
|
|
52
|
+
var inputRef = (0, react_1.useRef)();
|
|
53
|
+
var timeStripRef = (0, react_1.useRef)();
|
|
54
|
+
var timeStripArray = [];
|
|
55
|
+
// generate Time array for dropdown
|
|
56
|
+
for (var hour = 0; hour <= 23; hour++) {
|
|
57
|
+
for (var minute = 0; minute <= 45; minute += 15) {
|
|
58
|
+
var formattedHour = hour % 12 || 12; // Convert to 12-hour format
|
|
59
|
+
var formattedMinute = minute === 0 ? "00" : "".concat(minute);
|
|
60
|
+
var period = hour < 12 ? "AM" : "PM";
|
|
61
|
+
var timeString = "".concat(formattedHour, ":").concat(formattedMinute, " ").concat(period);
|
|
62
|
+
timeStripArray.push(timeString);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
(0, react_1.useEffect)(function () {
|
|
66
|
+
// Function to scroll the element (specific Time) to the top
|
|
67
|
+
var scrollTimeElementToTop = function () {
|
|
68
|
+
var list = timeStripRef.current;
|
|
69
|
+
if (!list)
|
|
70
|
+
return;
|
|
71
|
+
// Find all elements with data-value attribute
|
|
72
|
+
var allListElements = list.querySelectorAll('[data-value]');
|
|
73
|
+
// Initialize variables to keep track of the closest match
|
|
74
|
+
var closestMatch = null;
|
|
75
|
+
var closestMatchValue = Number.MAX_SAFE_INTEGER;
|
|
76
|
+
// Loop through all elements and find the closest match
|
|
77
|
+
allListElements.forEach(function (element) {
|
|
78
|
+
var elementValue = element.getAttribute('data-value');
|
|
79
|
+
if (elementValue.startsWith(inputValue)) {
|
|
80
|
+
var diff = elementValue.length - inputValue.length;
|
|
81
|
+
if (diff < closestMatchValue) {
|
|
82
|
+
closestMatch = element;
|
|
83
|
+
closestMatchValue = diff;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
if (!closestMatch) {
|
|
88
|
+
// When there is no exact match, highlight the closest time to the current time
|
|
89
|
+
closestMatch = list.querySelector("[data-value=\"".concat((0, getNearestTimeToCurrentTime_1.getNearestTimeToCurrentTime)(timeStripArray), "\"]"));
|
|
90
|
+
}
|
|
91
|
+
if (closestMatch) {
|
|
92
|
+
(0, highLightTime_1.highLightTime)(closestMatch, invert);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
scrollTimeElementToTop();
|
|
96
|
+
}, [inputValue, timeStripRef]);
|
|
97
|
+
// useEffect(() => {
|
|
98
|
+
// if(value){
|
|
99
|
+
// setInputValue(convertTo12Hour(value))
|
|
100
|
+
// }
|
|
101
|
+
// }, [])
|
|
102
|
+
var handleTimeClick = function (e, item) {
|
|
103
|
+
setInputValue(item);
|
|
104
|
+
};
|
|
105
|
+
var handleOnFocus = function () {
|
|
106
|
+
setInputValue(undefined);
|
|
107
|
+
};
|
|
108
|
+
var handleOnBlur = function () {
|
|
109
|
+
if ((0, convertToMiltaryTime_1.convertToMiltaryTime)(inputValue) === "Invalid time input") {
|
|
110
|
+
setInputValue((0, getNearestTimeToCurrentTime_1.getNearestTimeToCurrentTime)(timeStripArray));
|
|
111
|
+
setErrorMessage(null);
|
|
112
|
+
}
|
|
113
|
+
onParentChange && onParentChange(id, (0, convertToMiltaryTime_1.convertToMiltaryTime)(inputValue));
|
|
114
|
+
};
|
|
115
|
+
var handleInputChange = function (e) {
|
|
116
|
+
var newValue = e.target.value;
|
|
117
|
+
(0, handleTimeValidation_1.handleTimeValidation)(newValue, setErrorMessage, setInputValue);
|
|
118
|
+
};
|
|
119
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
120
|
+
react_1.default.createElement(BlockLabel_1.BlockLabel, __assign({}, (0, getBlockLabelProps_1.getBlockLabelProps)(props))),
|
|
121
|
+
react_1.default.createElement("div", { style: { display: "flex", position: 'relative' } },
|
|
122
|
+
readOnly ? (react_1.default.createElement(Typo_1.SANS_3, null, inputValue)) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
123
|
+
react_1.default.createElement(styled_1.StyledTimeInputWrapper, { invert: invert },
|
|
124
|
+
react_1.default.createElement(styled_1.StyledTimeInput, { type: "test", className: "SANS_3", placeholder: "HH:MM AA", maxLength: "8", invert: invert, value: inputValue, ref: inputRef, autoCapitalize: "characters", onChange: function (e) { return handleInputChange(e); }, onBlur: function () { return handleOnBlur(); }, onFocus: function () { return handleOnFocus(); }, onKeyDown: function (e) {
|
|
125
|
+
if (e.key === 'Enter') {
|
|
126
|
+
e.target.blur();
|
|
127
|
+
}
|
|
128
|
+
}, disabled: disabled }),
|
|
129
|
+
react_1.default.createElement(styled_1.StyledDropDown, { className: "drop-down", invert: invert },
|
|
130
|
+
react_1.default.createElement(styled_1.StyledDropDownList, { className: "drop-list", ref: timeStripRef },
|
|
131
|
+
" ",
|
|
132
|
+
timeStripArray.map(function (item) { return (react_1.default.createElement(styled_1.StyledListItem, { "data-value": item, key: item, onMouseDown: function (e) { return handleTimeClick(e, item); }, invert: invert, className: "listElement" },
|
|
133
|
+
react_1.default.createElement(Typo_1.SANS_3, { invert: invert }, item))); })))))),
|
|
134
|
+
errorMessage && react_1.default.createElement(Typo_1.SANS_0, { color: "red", style: { position: 'absolute', top: '-1.5rem' } }, errorMessage))));
|
|
135
|
+
};
|
|
136
|
+
exports.TimePicker = TimePicker;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export const StyledTimeInputWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export const StyledTimeInput: import("styled-components").StyledComponent<"input", any, {}, never>;
|
|
3
|
+
export const StyledDropDown: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
4
|
+
export const StyledMotionDiv: import("styled-components").StyledComponent<any, any, object, string | number | symbol>;
|
|
5
|
+
export const StyledDropDownList: import("styled-components").StyledComponent<"ul", any, {}, never>;
|
|
6
|
+
export const StyledListItem: import("styled-components").StyledComponent<"li", any, {}, never>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
3
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
4
|
+
return cooked;
|
|
5
|
+
};
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
23
|
+
if (mod && mod.__esModule) return mod;
|
|
24
|
+
var result = {};
|
|
25
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
26
|
+
__setModuleDefault(result, mod);
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
|
+
exports.StyledListItem = exports.StyledDropDownList = exports.StyledMotionDiv = exports.StyledDropDown = exports.StyledTimeInput = exports.StyledTimeInputWrapper = void 0;
|
|
31
|
+
var styled_components_1 = __importStar(require("styled-components"));
|
|
32
|
+
var themes_1 = require("../../themes");
|
|
33
|
+
var globalVariables_1 = require("../../globalStyles/globalVariables");
|
|
34
|
+
var mixins_1 = require("../../themes/mixins");
|
|
35
|
+
var framer_motion_1 = require("framer-motion");
|
|
36
|
+
var greyColor80 = themes_1.colors.greyColor80, greyColor10 = themes_1.colors.greyColor10, greyColor5 = themes_1.colors.greyColor5, greyColor15 = themes_1.colors.greyColor15, greyColor70 = themes_1.colors.greyColor70, greyColor40 = themes_1.colors.greyColor40;
|
|
37
|
+
exports.StyledTimeInputWrapper = styled_components_1.default.div(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n position: relative;\n ", "\n &:focus-within {\n background-color: ", ";\n\n &::after {\n width: 100%;\n }\n\n &:focus-within .drop-down {\n display: block;\n }\n }\n\n \n"], ["\n position: relative;\n ", "\n &:focus-within {\n background-color: ", ";\n\n &::after {\n width: 100%;\n }\n\n &:focus-within .drop-down {\n display: block;\n }\n }\n\n \n"])), globalVariables_1.globalInputElemFocused, greyColor10);
|
|
38
|
+
exports.StyledTimeInput = styled_components_1.default.input(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n ", "\n /* padding: 0rem 3rem; */\n background: ", ";\n outline: none;\n border: none;\n width: 10rem;\n height: 4rem;\n color: ", ";\n\n ", "\n &:focus {\n background-color: ", ";\n }\n\n ", "\n\n &::placeholder {\n color: ", ";\n }\n\n ", "\n\n &:placeholder-shown {\n width: 11.5rem;\n }\n"], ["\n ", "\n /* padding: 0rem 3rem; */\n background: ", ";\n outline: none;\n border: none;\n width: 10rem;\n height: 4rem;\n color: ", ";\n\n ", "\n &:focus {\n background-color: ", ";\n }\n\n ", "\n\n &::placeholder {\n color: ", ";\n }\n\n ", "\n\n &:placeholder-shown {\n width: 11.5rem;\n }\n"])), globalVariables_1.globalInputElemPadding, function (_a) {
|
|
39
|
+
var invert = _a.invert;
|
|
40
|
+
return (invert ? greyColor80 : greyColor5);
|
|
41
|
+
}, function (_a) {
|
|
42
|
+
var invert = _a.invert, disabled = _a.disabled;
|
|
43
|
+
return invert
|
|
44
|
+
? (disabled ? themes_1.colors.greyColor40 : themes_1.colors.white)
|
|
45
|
+
: disabled ? themes_1.colors.greyColor40 : themes_1.colors.greyColor100;
|
|
46
|
+
}, function (_a) {
|
|
47
|
+
var disabled = _a.disabled;
|
|
48
|
+
return (disabled ? '' : globalVariables_1.globalInputElemHover);
|
|
49
|
+
}, function (_a) {
|
|
50
|
+
var invert = _a.invert, disabled = _a.disabled;
|
|
51
|
+
return disabled ? greyColor15 : invert ? greyColor70 : greyColor10;
|
|
52
|
+
}, function (_a) {
|
|
53
|
+
var disabled = _a.disabled;
|
|
54
|
+
return disabled && (0, styled_components_1.css)(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n color: ", "\n background-color: ", ";\n cursor: not-allowed;\n &:hover{\n background-color: none !important;\n }\n "], ["\n color: ", "\n background-color: ", ";\n cursor: not-allowed;\n &:hover{\n background-color: none !important;\n }\n "])), greyColor40, greyColor15);
|
|
55
|
+
}, greyColor40, (0, mixins_1.transition)('background-color', 'width'));
|
|
56
|
+
exports.StyledDropDown = styled_components_1.default.div(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n ", "\n position: absolute;\n display: none;\n left: 0;\n overflow-y: scroll;\n /* scroll-behavior: smooth; */\n height: 20rem;\n width: 15rem;\n z-index: 1;\n"], ["\n ", "\n position: absolute;\n display: none;\n left: 0;\n overflow-y: scroll;\n /* scroll-behavior: smooth; */\n height: 20rem;\n width: 15rem;\n z-index: 1;\n"])), globalVariables_1.globalLightboxStyle);
|
|
57
|
+
exports.StyledMotionDiv = (0, styled_components_1.default)(framer_motion_1.motion.div)(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n\n"], ["\n\n"])));
|
|
58
|
+
exports.StyledDropDownList = styled_components_1.default.ul(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n list-style: none;\n padding-left: 0;\n\n &:hover{\n .drop-list{\n background-color: inherit;\n }\n }\n"], ["\n list-style: none;\n padding-left: 0;\n\n &:hover{\n .drop-list{\n background-color: inherit;\n }\n }\n"])));
|
|
59
|
+
exports.StyledListItem = styled_components_1.default.li(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n padding: 9px 20px;\n cursor: pointer;\n ", "\n\n .highlight{\n background-color: red;\n }\n"], ["\n padding: 9px 20px;\n cursor: pointer;\n ", "\n\n .highlight{\n background-color: red;\n }\n"])), globalVariables_1.globalHoverOnWhiteBG);
|
|
60
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function convertTo12Hour(time24: any): any;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// This function converts a 24-hour time format to a 12-hour time format with AM or PM.
|
|
3
|
+
// Also if passed valued is already in 12 Hour format with AM PM then it just returns it as is
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.convertTo12Hour = void 0;
|
|
6
|
+
function convertTo12Hour(time24) {
|
|
7
|
+
// Check if the input is already in the expected format
|
|
8
|
+
if (/^\d{1,2}:\d{2} [APM]{2}$/i.test(time24)) {
|
|
9
|
+
return time24.toUpperCase();
|
|
10
|
+
}
|
|
11
|
+
var _a = time24.split(':').map(Number), hours = _a[0], minutes = _a[1];
|
|
12
|
+
if (hours >= 0 && hours <= 11) {
|
|
13
|
+
// Convert to 12-hour format with "AM"
|
|
14
|
+
var amTime = "".concat(hours === 0 ? 12 : hours, ":").concat(minutes.toString().padStart(2, '0'), " AM");
|
|
15
|
+
return amTime.toUpperCase();
|
|
16
|
+
}
|
|
17
|
+
else if (hours >= 12 && hours <= 23) {
|
|
18
|
+
// Convert to 12-hour format with "PM"
|
|
19
|
+
var pmTime = "".concat(hours === 12 ? 12 : hours - 12, ":").concat(minutes.toString().padStart(2, '0'), " PM");
|
|
20
|
+
return pmTime.toUpperCase();
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
// Handle invalid input
|
|
24
|
+
return 'Invalid Time';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.convertTo12Hour = convertTo12Hour;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function convertToMiltaryTime(time: any): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.convertToMiltaryTime = void 0;
|
|
4
|
+
function convertToMiltaryTime(time) {
|
|
5
|
+
var _a = time === null || time === void 0 ? void 0 : time.split(/[:\s]/), hh = _a[0], mm = _a[1], period = _a[2];
|
|
6
|
+
var hour = parseInt(hh);
|
|
7
|
+
var minute = mm;
|
|
8
|
+
if (isNaN(hour) || isNaN(minute) || hour < 1 || hour > 12 || minute < 0 || minute > 59) {
|
|
9
|
+
// Invalid input, return an error message or handle as needed.
|
|
10
|
+
return "Invalid time input";
|
|
11
|
+
}
|
|
12
|
+
if (period === "PM" && hour !== 12) {
|
|
13
|
+
hour += 12;
|
|
14
|
+
}
|
|
15
|
+
else if (period === "AM" && hour === 12) {
|
|
16
|
+
// Handle "12:00 AM" as midnight (00:00)
|
|
17
|
+
hour = 0;
|
|
18
|
+
}
|
|
19
|
+
// Format hour and minute as two-digit strings
|
|
20
|
+
var formattedHour = hour.toString().padStart(2, "0");
|
|
21
|
+
var formattedMinute = minute.padStart(2, "0");
|
|
22
|
+
// Construct and return the military time string
|
|
23
|
+
var militaryTime = "".concat(formattedHour, ":").concat(formattedMinute);
|
|
24
|
+
return militaryTime;
|
|
25
|
+
}
|
|
26
|
+
exports.convertToMiltaryTime = convertToMiltaryTime;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function getNearestTimeToCurrentTime(timeArray: any): any;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getNearestTimeToCurrentTime = void 0;
|
|
4
|
+
var convertTo12Hour_1 = require("./convertTo12Hour");
|
|
5
|
+
var timeToMinutes_1 = require("./timeToMinutes");
|
|
6
|
+
function getNearestTimeToCurrentTime(timeArray) {
|
|
7
|
+
var currentTime = new Date();
|
|
8
|
+
var hours = currentTime.getHours().toString().padStart(2, "0");
|
|
9
|
+
var minutes = currentTime.getMinutes().toString().padStart(2, "0");
|
|
10
|
+
// let's format time to match timeArray so it can be compared, example 00:00 = 12:00 AM
|
|
11
|
+
var formattedTime = (0, convertTo12Hour_1.convertTo12Hour)("".concat(hours, ":").concat(minutes));
|
|
12
|
+
//format time to minutes, example, formatedTime === 12:45 AM, it will converted to "765", with help of timeToMinutes()
|
|
13
|
+
var formattedTimeMinutes = (0, timeToMinutes_1.timeToMinutes)(formattedTime);
|
|
14
|
+
var nearestTime = timeArray[0];
|
|
15
|
+
// now find minimum difference between current form formattedTimeMinutes and timeArray[0]
|
|
16
|
+
var minDifference = Math.abs(formattedTimeMinutes - (0, timeToMinutes_1.timeToMinutes)(timeArray[0]));
|
|
17
|
+
for (var i = 1; i < timeArray.length; i++) {
|
|
18
|
+
var currentDifference = Math.abs(formattedTimeMinutes - (0, timeToMinutes_1.timeToMinutes)(timeArray[i]));
|
|
19
|
+
if (currentDifference < minDifference) {
|
|
20
|
+
nearestTime = timeArray[i];
|
|
21
|
+
minDifference = currentDifference;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return nearestTime;
|
|
25
|
+
}
|
|
26
|
+
exports.getNearestTimeToCurrentTime = getNearestTimeToCurrentTime;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function highLightTime(elementToScroll: any, invert: any): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.highLightTime = void 0;
|
|
4
|
+
var themes_1 = require("../../../themes");
|
|
5
|
+
function highLightTime(elementToScroll, invert) {
|
|
6
|
+
elementToScroll.scrollIntoView({ behavior: "auto" });
|
|
7
|
+
// elementToScroll.style.backgroundColor = invert ? colors.greyColor70 : colors.greyColor10;
|
|
8
|
+
}
|
|
9
|
+
exports.highLightTime = highLightTime;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function timeToMinutes(time: any): number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.timeToMinutes = void 0;
|
|
4
|
+
function timeToMinutes(time) {
|
|
5
|
+
// Split the input time string into three parts: hours (hh), minutes (mm), and period (AM/PM).
|
|
6
|
+
var _a = time.split(/[:\s]/), hh = _a[0], mm = _a[1], period = _a[2];
|
|
7
|
+
// Convert the hours and minutes to minutes since midnight.
|
|
8
|
+
var minutes = parseInt(hh) * 60 + parseInt(mm);
|
|
9
|
+
// Check if the period is "PM" and if the hour is not already 12 (noon).
|
|
10
|
+
if (period === "PM" && hh !== "12") {
|
|
11
|
+
// If it's "PM" and not noon, add 12 hours' worth of minutes to the total.
|
|
12
|
+
minutes += 12 * 60;
|
|
13
|
+
}
|
|
14
|
+
else if (period === "AM" && hh === "12") {
|
|
15
|
+
// Handle "12:00 AM" as midnight (00:00)
|
|
16
|
+
minutes = 0;
|
|
17
|
+
}
|
|
18
|
+
return minutes;
|
|
19
|
+
}
|
|
20
|
+
exports.timeToMinutes = timeToMinutes;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
35
|
+
};
|
|
36
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
37
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
38
|
+
if (ar || !(i in from)) {
|
|
39
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
40
|
+
ar[i] = from[i];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.TimeRangePicker = void 0;
|
|
47
|
+
var react_1 = __importStar(require("react"));
|
|
48
|
+
var BlockLabel_1 = require("../BlockLabel");
|
|
49
|
+
var getBlockLabelProps_1 = require("../../utils/getBlockLabelProps");
|
|
50
|
+
var TimePicker_1 = require("../TimePicker");
|
|
51
|
+
var TimeRangePicker = function (props) {
|
|
52
|
+
var value = props.value, onChange = props.onChange, id = props.id, readOnly = props.readOnly, invert = props.invert, disabled = props.disabled;
|
|
53
|
+
var _a = (0, react_1.useState)(value || [null, null]), _value = _a[0], _setValue = _a[1];
|
|
54
|
+
var handleOnchange = function (i, v) {
|
|
55
|
+
var newValue = value ? __spreadArray([], value, true) : [];
|
|
56
|
+
newValue[i] = v;
|
|
57
|
+
onChange && onChange(id, newValue);
|
|
58
|
+
};
|
|
59
|
+
(0, react_1.useEffect)(function () {
|
|
60
|
+
if (value) {
|
|
61
|
+
_setValue(value);
|
|
62
|
+
}
|
|
63
|
+
}, [value]);
|
|
64
|
+
return (react_1.default.createElement("div", null,
|
|
65
|
+
react_1.default.createElement(BlockLabel_1.BlockLabel, __assign({}, (0, getBlockLabelProps_1.getBlockLabelProps)(props))),
|
|
66
|
+
react_1.default.createElement("div", { style: { display: "flex", columnGap: '2rem', flexWrap: 'wrap', rowGap: '1rem' } },
|
|
67
|
+
react_1.default.createElement(TimePicker_1.TimePicker, { value: _value && _value[0], id: 0, onChange: handleOnchange, readOnly: readOnly, invert: invert, disabled: disabled }),
|
|
68
|
+
react_1.default.createElement(TimePicker_1.TimePicker, { value: _value && _value[1], id: 1, onChange: handleOnchange, readOnly: readOnly, invert: invert, disabled: disabled }))));
|
|
69
|
+
};
|
|
70
|
+
exports.TimeRangePicker = TimeRangePicker;
|
package/dist/index.d.ts
CHANGED
|
@@ -32,10 +32,14 @@ export { ModalSmall } from "./components/Modals/ModalSmall";
|
|
|
32
32
|
export { EmptyStates } from "./components/EmptyStates";
|
|
33
33
|
export { HomeCover } from "./components/HomeCover";
|
|
34
34
|
export { PageScrollIndicator } from "./components/PageScrollIndicator";
|
|
35
|
-
export { default as DatePicker } from "./components/DatePicker";
|
|
36
|
-
export { default as DateRangePicker } from "./components/DateRangePicker";
|
|
37
35
|
export { BarChart } from "./components/dataViz/comps/BarChart";
|
|
38
36
|
export { TextLoader } from "./components/LoadersAndProgress/TextLoader";
|
|
37
|
+
export { default as DatePicker } from "./components/DatePicker";
|
|
38
|
+
export { default as DateRangePicker } from "./components/DateRangePicker";
|
|
39
|
+
export { TimePicker } from "./components/TimePicker";
|
|
40
|
+
export { TimeRangePicker } from "./components/TimeRangePicker";
|
|
41
|
+
export { DateTimePicker } from "./components/DateTimePicker";
|
|
42
|
+
export { DateTimeRangePicker } from "./components/DateTimeRangePicker";
|
|
39
43
|
export { CardContent } from "./components/cards/CardContent";
|
|
40
44
|
export { ListContent } from "./components/cards/ListContent";
|
|
41
45
|
export { CardEmbed } from "./components/cards/CardEmbed";
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.
|
|
20
|
+
exports.useBannerContext = exports.BannerContext = exports.BannerInfo = exports.BannerAlert = exports.VideoInput = exports.ProfileImageInput = exports.ImageInput = exports.MetaBlock = exports.HintsProvider = exports.genTagComp = exports.generateOptions = exports.OptionsSingle = exports.DropdownMulti = exports.DropdownSingle = exports.parseCardConfig = exports.ListProfile = exports.CardProfile = exports.CardEmbed = exports.ListContent = exports.CardContent = exports.DateTimeRangePicker = exports.DateTimePicker = exports.TimeRangePicker = exports.TimePicker = exports.DateRangePicker = exports.DatePicker = exports.TextLoader = exports.BarChart = exports.PageScrollIndicator = exports.HomeCover = exports.EmptyStates = exports.ModalSmall = exports.ModalLarge = exports.ModalConfirm = exports.SkeletonLoader = exports.Divider = exports.PercentCompletedPie = exports.Accordion = exports.ActionMenu = exports.Tooltip = exports.OKELink = exports.UserRoleBadge = exports.Section = exports.LoaderOverlay = exports.Loader = exports.ProgressBar = exports.LoaderCircle = exports.icons = exports.colors = exports.GlobalStyles = void 0;
|
|
21
|
+
exports.SimpleTable = exports.BannerProvider = void 0;
|
|
21
22
|
//css and styling related ( styled-components )
|
|
22
23
|
var globalStyles_1 = require("./globalStyles");
|
|
23
24
|
Object.defineProperty(exports, "GlobalStyles", { enumerable: true, get: function () { return globalStyles_1.GlobalStyles; } });
|
|
@@ -78,14 +79,23 @@ var HomeCover_1 = require("./components/HomeCover");
|
|
|
78
79
|
Object.defineProperty(exports, "HomeCover", { enumerable: true, get: function () { return HomeCover_1.HomeCover; } });
|
|
79
80
|
var PageScrollIndicator_1 = require("./components/PageScrollIndicator");
|
|
80
81
|
Object.defineProperty(exports, "PageScrollIndicator", { enumerable: true, get: function () { return PageScrollIndicator_1.PageScrollIndicator; } });
|
|
81
|
-
var DatePicker_1 = require("./components/DatePicker");
|
|
82
|
-
Object.defineProperty(exports, "DatePicker", { enumerable: true, get: function () { return __importDefault(DatePicker_1).default; } });
|
|
83
|
-
var DateRangePicker_1 = require("./components/DateRangePicker");
|
|
84
|
-
Object.defineProperty(exports, "DateRangePicker", { enumerable: true, get: function () { return __importDefault(DateRangePicker_1).default; } });
|
|
85
82
|
var BarChart_1 = require("./components/dataViz/comps/BarChart");
|
|
86
83
|
Object.defineProperty(exports, "BarChart", { enumerable: true, get: function () { return BarChart_1.BarChart; } });
|
|
87
84
|
var TextLoader_1 = require("./components/LoadersAndProgress/TextLoader");
|
|
88
85
|
Object.defineProperty(exports, "TextLoader", { enumerable: true, get: function () { return TextLoader_1.TextLoader; } });
|
|
86
|
+
// tpl blocks
|
|
87
|
+
var DatePicker_1 = require("./components/DatePicker");
|
|
88
|
+
Object.defineProperty(exports, "DatePicker", { enumerable: true, get: function () { return __importDefault(DatePicker_1).default; } });
|
|
89
|
+
var DateRangePicker_1 = require("./components/DateRangePicker");
|
|
90
|
+
Object.defineProperty(exports, "DateRangePicker", { enumerable: true, get: function () { return __importDefault(DateRangePicker_1).default; } });
|
|
91
|
+
var TimePicker_1 = require("./components/TimePicker");
|
|
92
|
+
Object.defineProperty(exports, "TimePicker", { enumerable: true, get: function () { return TimePicker_1.TimePicker; } });
|
|
93
|
+
var TimeRangePicker_1 = require("./components/TimeRangePicker");
|
|
94
|
+
Object.defineProperty(exports, "TimeRangePicker", { enumerable: true, get: function () { return TimeRangePicker_1.TimeRangePicker; } });
|
|
95
|
+
var DateTimePicker_1 = require("./components/DateTimePicker");
|
|
96
|
+
Object.defineProperty(exports, "DateTimePicker", { enumerable: true, get: function () { return DateTimePicker_1.DateTimePicker; } });
|
|
97
|
+
var DateTimeRangePicker_1 = require("./components/DateTimeRangePicker");
|
|
98
|
+
Object.defineProperty(exports, "DateTimeRangePicker", { enumerable: true, get: function () { return DateTimeRangePicker_1.DateTimeRangePicker; } });
|
|
89
99
|
//cards
|
|
90
100
|
var CardContent_1 = require("./components/cards/CardContent");
|
|
91
101
|
Object.defineProperty(exports, "CardContent", { enumerable: true, get: function () { return CardContent_1.CardContent; } });
|