oolib 2.68.4 → 2.69.0

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.
Files changed (42) hide show
  1. package/dist/UIContent/index.d.ts +5 -0
  2. package/dist/UIContent/index.js +6 -1
  3. package/dist/components/DateTimePicker/index.d.ts +2 -0
  4. package/dist/components/DateTimePicker/index.js +82 -0
  5. package/dist/components/DateTimeRangePicker/index.d.ts +2 -0
  6. package/dist/components/DateTimeRangePicker/index.js +91 -0
  7. package/dist/components/SimpleTable/comps/AddRowColButtons/index.d.ts +2 -1
  8. package/dist/components/SimpleTable/comps/AddRowColButtons/index.js +3 -3
  9. package/dist/components/SimpleTable/comps/rowColActionMenus/ColActionsMenu/index.d.ts +2 -1
  10. package/dist/components/SimpleTable/comps/rowColActionMenus/ColActionsMenu/index.js +7 -3
  11. package/dist/components/SimpleTable/comps/rowColActionMenus/RowActionsMenu/index.d.ts +2 -1
  12. package/dist/components/SimpleTable/comps/rowColActionMenus/RowActionsMenu/index.js +14 -8
  13. package/dist/components/SimpleTable/handlers/handleColActions.d.ts +6 -0
  14. package/dist/components/SimpleTable/handlers/handleColActions.js +15 -1
  15. package/dist/components/SimpleTable/handlers/handleRowActions.d.ts +6 -0
  16. package/dist/components/SimpleTable/handlers/handleRowActions.js +10 -1
  17. package/dist/components/SimpleTable/handlers/handleStretchToFullWidth.d.ts +8 -0
  18. package/dist/components/SimpleTable/handlers/handleStretchToFullWidth.js +34 -0
  19. package/dist/components/SimpleTable/handlers/handleToggleRowHeader.d.ts +5 -0
  20. package/dist/components/SimpleTable/handlers/handleToggleRowHeader.js +31 -0
  21. package/dist/components/SimpleTable/index.js +96 -25
  22. package/dist/components/TimePicker/handlers/handleTimeValidation.d.ts +1 -0
  23. package/dist/components/TimePicker/handlers/handleTimeValidation.js +58 -0
  24. package/dist/components/TimePicker/index.d.ts +2 -0
  25. package/dist/components/TimePicker/index.js +136 -0
  26. package/dist/components/TimePicker/styled.d.ts +6 -0
  27. package/dist/components/TimePicker/styled.js +60 -0
  28. package/dist/components/TimePicker/utils/convertTo12Hour.d.ts +1 -0
  29. package/dist/components/TimePicker/utils/convertTo12Hour.js +27 -0
  30. package/dist/components/TimePicker/utils/convertToMiltaryTime.d.ts +1 -0
  31. package/dist/components/TimePicker/utils/convertToMiltaryTime.js +26 -0
  32. package/dist/components/TimePicker/utils/getNearestTimeToCurrentTime.d.ts +1 -0
  33. package/dist/components/TimePicker/utils/getNearestTimeToCurrentTime.js +26 -0
  34. package/dist/components/TimePicker/utils/highLightTime.d.ts +1 -0
  35. package/dist/components/TimePicker/utils/highLightTime.js +9 -0
  36. package/dist/components/TimePicker/utils/timeToMinutes.d.ts +1 -0
  37. package/dist/components/TimePicker/utils/timeToMinutes.js +20 -0
  38. package/dist/components/TimeRangePicker/index.d.ts +2 -0
  39. package/dist/components/TimeRangePicker/index.js +70 -0
  40. package/dist/index.d.ts +6 -2
  41. package/dist/index.js +15 -5
  42. package/package.json +1 -1
@@ -52,15 +52,18 @@ var BlockLabel_1 = require("../BlockLabel");
52
52
  var styled_components_1 = require("styled-components");
53
53
  var utilsOolib_1 = require("../../utilsOolib");
54
54
  var AddRowColButtons_1 = require("./comps/AddRowColButtons");
55
+ var UIContent_1 = require("../../UIContent");
56
+ var ActionMenu_1 = require("../ActionMenu");
55
57
  var ColActionsMenu_1 = require("./comps/rowColActionMenus/ColActionsMenu");
56
58
  var RowActionsMenu_1 = require("./comps/rowColActionMenus/RowActionsMenu");
57
59
  var handleColActions_1 = require("./handlers/handleColActions");
58
60
  var handleRowActions_1 = require("./handlers/handleRowActions");
61
+ var handleStretchToFullWidth_1 = require("./handlers/handleStretchToFullWidth");
62
+ var handleToggleRowHeader_1 = require("./handlers/handleToggleRowHeader");
59
63
  var styled_1 = require("./styled");
60
64
  var useResizeTableColumns_1 = require("./useResizeTableColumns");
61
65
  var convertColHeaderConfigToRowData_1 = require("./utils/convertColHeaderConfigToRowData");
62
66
  var prepInitValueFromConfigIfNoValue_1 = require("./utils/prepInitValueFromConfigIfNoValue");
63
- var lodash_1 = require("lodash");
64
67
  var greyColor100 = themes_1.colors.greyColor100;
65
68
  /*pending:
66
69
  - first test whatever is done on okf
@@ -93,11 +96,14 @@ function SimpleTable(_a) {
93
96
  // }
94
97
  // return _RichTextEditor && React.memo(_RichTextEditor, checkMemoFn)
95
98
  // },[])
96
- var _e = (0, react_1.useMemo)(function () { return (0, prepInitValueFromConfigIfNoValue_1.prepInitValueFromConfigIfNoValue)({
97
- _value: _value,
98
- config: config,
99
- defaultColWidth: defaultColWidth,
100
- }); }, [_value]), value = _e.value, enableColActions = _e.enableColActions, //returns all possible actions config if no config.colHeaderData is defined. else undefined\
99
+ var _e = (0, react_1.useMemo)(function () {
100
+ return (0, prepInitValueFromConfigIfNoValue_1.prepInitValueFromConfigIfNoValue)({
101
+ //memo v.imp cuz otherwise cell and row id keep changing on rerender if value doesnt exist, and this messes with their react keys, this leads to bugs
102
+ _value: _value,
103
+ config: config,
104
+ defaultColWidth: defaultColWidth,
105
+ });
106
+ }, [_value]), value = _e.value, enableColActions = _e.enableColActions, //returns all possible actions config if no config.colHeaderData is defined. else undefined\
101
107
  enableRowActions = _e.enableRowActions, canToggleColHeaderStyle = _e.canToggleColHeaderStyle;
102
108
  var _f = (0, useResizeTableColumns_1.useResizeTableColumns)({
103
109
  setColWidthConfig: function (setterFn) {
@@ -128,7 +134,7 @@ function SimpleTable(_a) {
128
134
  typo: "SANS_3",
129
135
  placeholder: " ",
130
136
  style: {
131
- padding: "0.8rem 1rem",
137
+ padding: "0.9rem 1rem",
132
138
  },
133
139
  },
134
140
  // KPDropdown: {
@@ -151,6 +157,16 @@ function SimpleTable(_a) {
151
157
  newData[rowIdx].cellData[cellIdx].value = v;
152
158
  onChange && onChange(id, { data: newData, colWidthConfig: colWidthConfig });
153
159
  };
160
+ /**
161
+ * we are explicitly defining this here and passing it on to AddColButton comp
162
+ * since we need this width to calculate stretch to full width
163
+ */
164
+ var addColButtonWidth = 20;
165
+ // these are explicitly defined here cuz we need to calc offset padding and margin using these, so that overflowX doesnt hide them
166
+ var rowActionsButtonWidth = 15;
167
+ var colActionsButtonHeight = 15;
168
+ var primaryTableActionsMenuHeight = 30;
169
+ var primaryTableActionsMenuGap = 5;
154
170
  var genRow = function (_a) {
155
171
  var row = _a.row, rowIdx = _a.rowIdx;
156
172
  var StyledWrapper = row.isColHeader
@@ -196,38 +212,93 @@ function SimpleTable(_a) {
196
212
  onChange: onChange,
197
213
  id: id,
198
214
  defaultColWidth: defaultColWidth,
215
+ colActionsButtonHeight: colActionsButtonHeight,
199
216
  }))),
200
217
  !readOnly &&
201
218
  enableRowActions &&
202
219
  cellIdx === 0 &&
203
220
  rowIdx !== undefined && //cuz for fixed col headers, rowIdx is undefined
204
- hoveredRowAndCol.rowIdx === rowIdx && (react_1.default.createElement(RowActionsMenu_1.RowActionsMenu, __assign({}, { value: value, rowIdx: rowIdx, onChange: onChange, id: id, setActionsActiveOnRow: setActionsActiveOnRow }))),
221
+ hoveredRowAndCol.rowIdx === rowIdx && (react_1.default.createElement(RowActionsMenu_1.RowActionsMenu, __assign({}, {
222
+ value: value,
223
+ rowIdx: rowIdx,
224
+ onChange: onChange,
225
+ id: id,
226
+ setActionsActiveOnRow: setActionsActiveOnRow,
227
+ rowActionsButtonWidth: rowActionsButtonWidth,
228
+ }))),
205
229
  react_1.default.createElement(CellComp, __assign({}, cellProps, { id: "kp_table_cell__".concat(cell.id, "__rich_input") /*dont mess with this id nomenclature. it needs to stay this way. check out the handleCellInputChange fn to understand */, value: cellValue, readOnly: readOnly || cell.readOnly, onChange: function (k, v) {
206
230
  return handleCellInputChange({ v: v, rowIdx: rowIdx, cellIdx: cellIdx });
207
231
  } }))));
208
232
  })));
209
233
  };
234
+ var fullWidthCompWrapper = (0, react_1.useRef)(null);
210
235
  return (react_1.default.createElement("div", null,
211
236
  react_1.default.createElement(BlockLabel_1.BlockLabel, __assign({}, (0, getBlockLabelProps_1.getBlockLabelProps)(props))),
212
237
  react_1.default.createElement("div", { style: {
213
- display: "flex",
214
- alignItems: "stretch" /**without stretch AddColButton will be wonky */,
238
+ overflowX: "auto",
239
+ paddingLeft: rowActionsButtonWidth / 2 + "px",
240
+ marginLeft: "-" + rowActionsButtonWidth / 2 + "px",
241
+ paddingTop: primaryTableActionsMenuGap + primaryTableActionsMenuHeight + 'px'
215
242
  } },
216
- react_1.default.createElement("div", null,
217
- react_1.default.createElement(styled_1.StyledSimpleTable, { onMouseLeave: function () {
218
- return setHoveredRowAndCol({ rowIdx: undefined, colIdx: undefined });
219
- } },
220
- config.colHeaderData &&
221
- genRow({
222
- row: (0, convertColHeaderConfigToRowData_1.convertColHeaderConfigToRowData)({
223
- colHeaderData: config.colHeaderData,
224
- convertToRichText: convertToRichText,
243
+ react_1.default.createElement("div", { ref: fullWidthCompWrapper, style: {
244
+ display: "flex",
245
+ alignItems: "stretch" /**without stretch AddColButton will be wonky */,
246
+ } },
247
+ react_1.default.createElement("div", { style: { position: "relative" } },
248
+ react_1.default.createElement("div", { style: {
249
+ position: "absolute",
250
+ right: 0,
251
+ top: "-" + primaryTableActionsMenuGap + "px",
252
+ transform: "translateY(-100%)",
253
+ zIndex: 1,
254
+ } },
255
+ react_1.default.createElement(ActionMenu_1.ActionMenu, { ButtonComp: "ButtonPrimary", actions: __spreadArray(__spreadArray([
256
+ {
257
+ display: UIContent_1.UIContent.SimpleTable.stretchToFullWidth,
258
+ onClick: function () {
259
+ return (0, handleStretchToFullWidth_1.handleStretchToFullWidth)({
260
+ value: value,
261
+ onChange: onChange,
262
+ id: id,
263
+ enableColActions: enableColActions,
264
+ addColButtonWidth: addColButtonWidth,
265
+ fullWidthCompWrapper: fullWidthCompWrapper,
266
+ });
267
+ },
268
+ }
269
+ ], (enableRowActions
270
+ ? [
271
+ {
272
+ display: UIContent_1.UIContent.SimpleTable.addHeaderCol,
273
+ onClick: function () { },
274
+ },
275
+ ]
276
+ : []), true), (enableColActions
277
+ ? [
278
+ {
279
+ display: value.data[0].isColHeader
280
+ ? UIContent_1.UIContent.SimpleTable.removeHeaderRow
281
+ : UIContent_1.UIContent.SimpleTable.addHeaderRow,
282
+ onClick: function () {
283
+ return (0, handleToggleRowHeader_1.handleToggleRowHeader)({ value: value, onChange: onChange, id: id });
284
+ },
285
+ },
286
+ ]
287
+ : []), true) })),
288
+ react_1.default.createElement(styled_1.StyledSimpleTable, { onMouseLeave: function () {
289
+ return setHoveredRowAndCol({ rowIdx: undefined, colIdx: undefined });
290
+ } },
291
+ config.colHeaderData &&
292
+ genRow({
293
+ row: (0, convertColHeaderConfigToRowData_1.convertColHeaderConfigToRowData)({
294
+ colHeaderData: config.colHeaderData,
295
+ convertToRichText: convertToRichText,
296
+ }),
225
297
  }),
226
- }),
227
- value.data.map(function (row, rowIdx) { return genRow({ row: row, rowIdx: rowIdx }); })),
228
- !readOnly && enableRowActions && (react_1.default.createElement(AddRowColButtons_1.AddRowButton, { onClick: function () { return (0, handleRowActions_1.handleAddRow)(value, props); } }))),
229
- !readOnly && enableColActions && (react_1.default.createElement(AddRowColButtons_1.AddColButton, { onClick: function () {
230
- return (0, handleColActions_1.handleAddCol)({ value: value, onChange: onChange, id: id, defaultColWidth: defaultColWidth });
231
- } })))));
298
+ value.data.map(function (row, rowIdx) { return genRow({ row: row, rowIdx: rowIdx }); })),
299
+ !readOnly && enableRowActions && (react_1.default.createElement(AddRowColButtons_1.AddRowButton, { onClick: function () { return (0, handleRowActions_1.handleAddRow)(value, props); } }))),
300
+ !readOnly && enableColActions && (react_1.default.createElement(AddRowColButtons_1.AddColButton, { addColButtonWidth: addColButtonWidth, onClick: function () {
301
+ return (0, handleColActions_1.handleAddCol)({ value: value, onChange: onChange, id: id, defaultColWidth: defaultColWidth });
302
+ } }))))));
232
303
  }
233
304
  exports.SimpleTable = SimpleTable;
@@ -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,2 @@
1
+ export function TimePicker(props: any): React.JSX.Element;
2
+ import React from "react";
@@ -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,2 @@
1
+ export function TimeRangePicker(props: any): React.JSX.Element;
2
+ import React from "react";