dce-reactkit 4.0.0 → 4.0.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/cjs/index.js +174 -53
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/components/SimpleDateChooser.d.ts +3 -1
- package/dist/cjs/types/components/SimpleTimeChooser.d.ts +20 -0
- package/dist/cjs/types/index.d.ts +2 -1
- package/dist/cjs/types/types/ReactKitErrorCode.d.ts +3 -1
- package/dist/esm/index.js +174 -54
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/components/SimpleDateChooser.d.ts +3 -1
- package/dist/esm/types/components/SimpleTimeChooser.d.ts +20 -0
- package/dist/esm/types/index.d.ts +2 -1
- package/dist/esm/types/types/ReactKitErrorCode.d.ts +3 -1
- package/dist/index.d.ts +41 -17
- package/package.json +1 -1
- package/src/components/LogReviewer.tsx +2 -2
- package/src/components/SimpleDateChooser.tsx +62 -26
- package/src/components/SimpleTimeChooser.tsx +196 -0
- package/src/index.ts +2 -0
- package/src/types/LogSource.ts +1 -1
- package/src/types/ReactKitErrorCode.tsx +3 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A very simple, lightweight date chooser
|
|
3
3
|
* @author Gabe Abrams
|
|
4
|
+
* @author Gardenia Liu
|
|
4
5
|
*/
|
|
5
6
|
import React from 'react';
|
|
6
7
|
type Props = {
|
|
@@ -17,7 +18,8 @@ type Props = {
|
|
|
17
18
|
*/
|
|
18
19
|
onChange: (month: number, day: number, year: number) => void;
|
|
19
20
|
numMonthsToShow?: number;
|
|
20
|
-
|
|
21
|
+
dontAllowPast?: boolean;
|
|
22
|
+
dontAllowFuture?: boolean;
|
|
21
23
|
};
|
|
22
24
|
declare const SimpleDateChooser: React.FC<Props>;
|
|
23
25
|
export default SimpleDateChooser;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A very simple, lightweight time chooser
|
|
3
|
+
* @author Gardenia Liu
|
|
4
|
+
*/
|
|
5
|
+
import React from 'react';
|
|
6
|
+
type Props = {
|
|
7
|
+
ariaLabel: string;
|
|
8
|
+
name: string;
|
|
9
|
+
hour: number;
|
|
10
|
+
minute: number;
|
|
11
|
+
/**
|
|
12
|
+
* Handler for when time changes
|
|
13
|
+
* @param hour new 24hr hour number
|
|
14
|
+
* @param minute new minute number
|
|
15
|
+
*/
|
|
16
|
+
onChange: (hour: number, minute: number) => void;
|
|
17
|
+
intervalMin?: number;
|
|
18
|
+
};
|
|
19
|
+
declare const SimpleTimeChooser: React.FC<Props>;
|
|
20
|
+
export default SimpleTimeChooser;
|
|
@@ -7,6 +7,7 @@ import RadioButton from './components/RadioButton';
|
|
|
7
7
|
import CheckboxButton from './components/CheckboxButton';
|
|
8
8
|
import ButtonInputGroup from './components/ButtonInputGroup';
|
|
9
9
|
import SimpleDateChooser from './components/SimpleDateChooser';
|
|
10
|
+
import SimpleTimeChooser from './components/SimpleTimeChooser';
|
|
10
11
|
import Drawer from './components/Drawer';
|
|
11
12
|
import PopSuccessMark from './components/PopSuccessMark';
|
|
12
13
|
import PopFailureMark from './components/PopFailureMark';
|
|
@@ -100,4 +101,4 @@ import PickableItem from './components/ItemPicker/types/PickableItem';
|
|
|
100
101
|
import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
|
|
101
102
|
import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
|
|
102
103
|
import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
|
|
103
|
-
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, alert, prompt, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_ROUTE_PATH, LOG_REVIEW_STATUS_ROUTE, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, ParamType, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, LogTypeSpecificInfo, LogMainInfo, LogSourceSpecificInfo, LogLevel, IntelliTableColumn, DropdownItemType, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, };
|
|
104
|
+
export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, SimpleTimeChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, Dropdown, alert, prompt, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_ROUTE_PATH, LOG_REVIEW_STATUS_ROUTE, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, prefixWithAOrAn, everyAsync, filterAsync, forEachAsync, mapAsync, someAsync, capitalize, shuffleArray, getWordCount, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, combineClassNames, useForceRender, setClientEventMetadataPopulator, ParamType, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, LogFunction, LogTypeSpecificInfo, LogMainInfo, LogSourceSpecificInfo, LogLevel, IntelliTableColumn, DropdownItemType, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, };
|
|
@@ -6,6 +6,8 @@ declare enum ReactKitErrorCode {
|
|
|
6
6
|
NoResponse = "DRK1",
|
|
7
7
|
NoCode = "DRK2",
|
|
8
8
|
SessionExpired = "DRK3",
|
|
9
|
-
NoCACCLSendRequestFunction = "DRK7"
|
|
9
|
+
NoCACCLSendRequestFunction = "DRK7",
|
|
10
|
+
SimpleDateChooserInvalidDateRange = "DRK35",
|
|
11
|
+
SimpleDateChooserInvalidNumMonths = "DRK36"
|
|
10
12
|
}
|
|
11
13
|
export default ReactKitErrorCode;
|
package/dist/esm/index.js
CHANGED
|
@@ -29,7 +29,7 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
// Highest error code =
|
|
32
|
+
// Highest error code = DRK36
|
|
33
33
|
/**
|
|
34
34
|
* List of error codes built into the react kit
|
|
35
35
|
* @author Gabe Abrams
|
|
@@ -40,6 +40,8 @@ var ReactKitErrorCode;
|
|
|
40
40
|
ReactKitErrorCode["NoCode"] = "DRK2";
|
|
41
41
|
ReactKitErrorCode["SessionExpired"] = "DRK3";
|
|
42
42
|
ReactKitErrorCode["NoCACCLSendRequestFunction"] = "DRK7";
|
|
43
|
+
ReactKitErrorCode["SimpleDateChooserInvalidDateRange"] = "DRK35";
|
|
44
|
+
ReactKitErrorCode["SimpleDateChooserInvalidNumMonths"] = "DRK36";
|
|
43
45
|
})(ReactKitErrorCode || (ReactKitErrorCode = {}));
|
|
44
46
|
var ReactKitErrorCode$1 = ReactKitErrorCode;
|
|
45
47
|
|
|
@@ -2521,6 +2523,19 @@ const ButtonInputGroup = (props) => {
|
|
|
2521
2523
|
: children))));
|
|
2522
2524
|
};
|
|
2523
2525
|
|
|
2526
|
+
// Constants
|
|
2527
|
+
const ORDINALS = ['th', 'st', 'nd', 'rd'];
|
|
2528
|
+
/**
|
|
2529
|
+
* Get a number's ordinal
|
|
2530
|
+
* @author Gabe Abrams
|
|
2531
|
+
* @param num the number being analyzed
|
|
2532
|
+
* @returns ordinal
|
|
2533
|
+
*/
|
|
2534
|
+
const getOrdinal = (num) => {
|
|
2535
|
+
var _a, _b;
|
|
2536
|
+
return ((_b = (_a = ORDINALS[(num - 20) % 10]) !== null && _a !== void 0 ? _a : ORDINALS[num]) !== null && _b !== void 0 ? _b : ORDINALS[0]);
|
|
2537
|
+
};
|
|
2538
|
+
|
|
2524
2539
|
const monthNames = [
|
|
2525
2540
|
{ short: 'Jan', full: 'January' },
|
|
2526
2541
|
{ short: 'Feb', full: 'February' },
|
|
@@ -2549,19 +2564,6 @@ const getMonthName = (month) => {
|
|
|
2549
2564
|
return ((_a = monthNames[month - 1]) !== null && _a !== void 0 ? _a : monthNames[0]);
|
|
2550
2565
|
};
|
|
2551
2566
|
|
|
2552
|
-
// Constants
|
|
2553
|
-
const ORDINALS = ['th', 'st', 'nd', 'rd'];
|
|
2554
|
-
/**
|
|
2555
|
-
* Get a number's ordinal
|
|
2556
|
-
* @author Gabe Abrams
|
|
2557
|
-
* @param num the number being analyzed
|
|
2558
|
-
* @returns ordinal
|
|
2559
|
-
*/
|
|
2560
|
-
const getOrdinal = (num) => {
|
|
2561
|
-
var _a, _b;
|
|
2562
|
-
return ((_b = (_a = ORDINALS[(num - 20) % 10]) !== null && _a !== void 0 ? _a : ORDINALS[num]) !== null && _b !== void 0 ? _b : ORDINALS[0]);
|
|
2563
|
-
};
|
|
2564
|
-
|
|
2565
2567
|
/**
|
|
2566
2568
|
* Get current time info in US Boston Eastern Time, independent of machine
|
|
2567
2569
|
* timezone
|
|
@@ -2625,6 +2627,7 @@ const getTimeInfoInET = (dateOrTimestamp) => {
|
|
|
2625
2627
|
/**
|
|
2626
2628
|
* A very simple, lightweight date chooser
|
|
2627
2629
|
* @author Gabe Abrams
|
|
2630
|
+
* @author Gardenia Liu
|
|
2628
2631
|
*/
|
|
2629
2632
|
/*------------------------------------------------------------------------*/
|
|
2630
2633
|
/* ------------------------------ Component ----------------------------- */
|
|
@@ -2634,7 +2637,7 @@ const SimpleDateChooser = (props) => {
|
|
|
2634
2637
|
/* -------------------------------- Setup ------------------------------- */
|
|
2635
2638
|
/*------------------------------------------------------------------------*/
|
|
2636
2639
|
/* -------------- Props ------------- */
|
|
2637
|
-
const { ariaLabel, name, onChange,
|
|
2640
|
+
const { ariaLabel, name, onChange, numMonthsToShow = 6, dontAllowFuture, dontAllowPast, } = props;
|
|
2638
2641
|
/*------------------------------------------------------------------------*/
|
|
2639
2642
|
/* ------------------------------- Render ------------------------------- */
|
|
2640
2643
|
/*------------------------------------------------------------------------*/
|
|
@@ -2646,14 +2649,28 @@ const SimpleDateChooser = (props) => {
|
|
|
2646
2649
|
const choices = [];
|
|
2647
2650
|
let startYear = today.year;
|
|
2648
2651
|
let startMonth = today.month;
|
|
2649
|
-
|
|
2652
|
+
// Don't allow past or future dates
|
|
2653
|
+
if (dontAllowPast && dontAllowFuture) {
|
|
2654
|
+
throw new ErrorWithCode('No past or future dates allowed', ReactKitErrorCode$1.SimpleDateChooserInvalidDateRange);
|
|
2655
|
+
}
|
|
2656
|
+
// Require numMonthsToShow to be positive
|
|
2657
|
+
if (numMonthsToShow <= 0) {
|
|
2658
|
+
throw new ErrorWithCode('numMonthsToShow must be positive', ReactKitErrorCode$1.SimpleDateChooserInvalidNumMonths);
|
|
2659
|
+
}
|
|
2660
|
+
// Recalculate startMonth and startYear when allowing past dates
|
|
2661
|
+
if (!dontAllowPast) {
|
|
2650
2662
|
startMonth -= Math.max(0, numMonthsToShow - 1);
|
|
2651
2663
|
while (startMonth <= 0) {
|
|
2652
2664
|
startMonth += 12;
|
|
2653
2665
|
startYear -= 1;
|
|
2654
2666
|
}
|
|
2655
2667
|
}
|
|
2656
|
-
|
|
2668
|
+
// Calculate total number of months to show
|
|
2669
|
+
let totalMonthsToShow = numMonthsToShow;
|
|
2670
|
+
if (!dontAllowPast && !dontAllowFuture) {
|
|
2671
|
+
totalMonthsToShow = totalMonthsToShow * 2 - 1;
|
|
2672
|
+
}
|
|
2673
|
+
for (let i = 0; i < totalMonthsToShow; i++) {
|
|
2657
2674
|
// Get month and year info
|
|
2658
2675
|
const unmoddedMonth = (startMonth + i);
|
|
2659
2676
|
let month = unmoddedMonth;
|
|
@@ -2672,23 +2689,25 @@ const SimpleDateChooser = (props) => {
|
|
|
2672
2689
|
// Figure out which days are allowed
|
|
2673
2690
|
const days = [];
|
|
2674
2691
|
const numDaysInMonth = (new Date(year, month, 0)).getDate();
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
days.push(day);
|
|
2692
|
+
// Current month
|
|
2693
|
+
if (month === today.month && year === today.year) {
|
|
2694
|
+
// Past selection: add all previous days of the month
|
|
2695
|
+
if (!dontAllowPast) {
|
|
2696
|
+
for (let day = 1; day < today.day; day++) {
|
|
2697
|
+
days.push(day);
|
|
2698
|
+
}
|
|
2683
2699
|
}
|
|
2684
|
-
|
|
2685
|
-
else {
|
|
2700
|
+
days.push(today.day); // Add current day
|
|
2686
2701
|
// Future selection: add all remaining days of the month
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2702
|
+
if (!dontAllowFuture) {
|
|
2703
|
+
for (let day = today.day + 1; day <= numDaysInMonth; day++) {
|
|
2704
|
+
days.push(day);
|
|
2705
|
+
}
|
|
2706
|
+
}
|
|
2707
|
+
}
|
|
2708
|
+
else { // Past or future month
|
|
2709
|
+
// Include all days in the month
|
|
2710
|
+
for (let day = 1; day <= numDaysInMonth; day++) {
|
|
2692
2711
|
days.push(day);
|
|
2693
2712
|
}
|
|
2694
2713
|
}
|
|
@@ -2708,8 +2727,8 @@ const SimpleDateChooser = (props) => {
|
|
|
2708
2727
|
monthOptions.push(React__default.createElement("option", { key: `${choice.year}-${choice.month}`, value: `${choice.month}-${choice.year}`, "aria-label": `choose ${choice.choiceName}`, onSelect: () => {
|
|
2709
2728
|
onChange(choice.month, choice.days[0], choice.year);
|
|
2710
2729
|
} }, choice.choiceName));
|
|
2730
|
+
// This is the currently selected month
|
|
2711
2731
|
if (month === choice.month) {
|
|
2712
|
-
// This is the currently selected month
|
|
2713
2732
|
// Create day options
|
|
2714
2733
|
choice.days.forEach((dayChoice) => {
|
|
2715
2734
|
const ordinal = getOrdinal(dayChoice);
|
|
@@ -2731,6 +2750,125 @@ const SimpleDateChooser = (props) => {
|
|
|
2731
2750
|
} }, dayOptions)));
|
|
2732
2751
|
};
|
|
2733
2752
|
|
|
2753
|
+
/**
|
|
2754
|
+
* Pad a number with zeros on the left (e.g. 5 becomes 05 with 2 digit padding)
|
|
2755
|
+
* @author Gabe Abrams
|
|
2756
|
+
* @param num the number to pad
|
|
2757
|
+
* @param numDigits the minimum number of digits before the decimal
|
|
2758
|
+
* @returns padded number
|
|
2759
|
+
*/
|
|
2760
|
+
const padZerosLeft = (num, numDigits) => {
|
|
2761
|
+
// Convert to string
|
|
2762
|
+
let out = String(num);
|
|
2763
|
+
// Add zeros
|
|
2764
|
+
while (out.split('.')[0].length < numDigits) {
|
|
2765
|
+
out = `0${out}`;
|
|
2766
|
+
}
|
|
2767
|
+
// Return
|
|
2768
|
+
return out;
|
|
2769
|
+
};
|
|
2770
|
+
|
|
2771
|
+
/**
|
|
2772
|
+
* A very simple, lightweight time chooser
|
|
2773
|
+
* @author Gardenia Liu
|
|
2774
|
+
*/
|
|
2775
|
+
/*------------------------------------------------------------------------*/
|
|
2776
|
+
/* ------------------------------ Constants ----------------------------- */
|
|
2777
|
+
/*------------------------------------------------------------------------*/
|
|
2778
|
+
// Allowed intervals between options
|
|
2779
|
+
const ALLOWED_INTERVALS = [15, 30, 60]; // min
|
|
2780
|
+
// Default interval to use if an unsupported interval is passed in
|
|
2781
|
+
const DEFAULT_INTERVAL = ALLOWED_INTERVALS[0]; // min
|
|
2782
|
+
/*------------------------------------------------------------------------*/
|
|
2783
|
+
/* ------------------------------ Component ----------------------------- */
|
|
2784
|
+
/*------------------------------------------------------------------------*/
|
|
2785
|
+
const SimpleTimeChooser = (props) => {
|
|
2786
|
+
/*------------------------------------------------------------------------*/
|
|
2787
|
+
/* -------------------------------- Setup ------------------------------- */
|
|
2788
|
+
/*------------------------------------------------------------------------*/
|
|
2789
|
+
/* -------------- Props ------------- */
|
|
2790
|
+
const { ariaLabel, name, hour, minute, onChange, } = props;
|
|
2791
|
+
let { intervalMin = DEFAULT_INTERVAL, } = props;
|
|
2792
|
+
// Use default interval if not supported
|
|
2793
|
+
if (!ALLOWED_INTERVALS.includes(intervalMin)) {
|
|
2794
|
+
intervalMin = DEFAULT_INTERVAL;
|
|
2795
|
+
}
|
|
2796
|
+
/*------------------------------------------------------------------------*/
|
|
2797
|
+
/* ------------------------- Component Functions ------------------------ */
|
|
2798
|
+
/*------------------------------------------------------------------------*/
|
|
2799
|
+
/**
|
|
2800
|
+
* Convert number of minutes since midnight into 24hour and minute format
|
|
2801
|
+
* @author Gabe Abrams
|
|
2802
|
+
* @param minSinceMidnight total minutes since midnight
|
|
2803
|
+
* @returns hours (24) and minutes
|
|
2804
|
+
*/
|
|
2805
|
+
const convertMinSinceMidnightToHoursAndMin = (minSinceMidnight) => {
|
|
2806
|
+
return {
|
|
2807
|
+
hours: Math.floor(minSinceMidnight / 60),
|
|
2808
|
+
minutes: minSinceMidnight % 60,
|
|
2809
|
+
};
|
|
2810
|
+
};
|
|
2811
|
+
/**
|
|
2812
|
+
* Convert time in minutes into HH:MM format
|
|
2813
|
+
* @author Gardenia Liu
|
|
2814
|
+
* @param totalMinutes total minutes since midnight
|
|
2815
|
+
* @returns formatted time string
|
|
2816
|
+
*/
|
|
2817
|
+
const formatTime = (totalMinutes) => {
|
|
2818
|
+
// Handle special cases
|
|
2819
|
+
if (totalMinutes === 0) {
|
|
2820
|
+
return '12:00 Midnight';
|
|
2821
|
+
}
|
|
2822
|
+
if (totalMinutes === 12 * 60) {
|
|
2823
|
+
return '12:00 Noon';
|
|
2824
|
+
}
|
|
2825
|
+
// All normal cases:
|
|
2826
|
+
const timeInfo = convertMinSinceMidnightToHoursAndMin(totalMinutes);
|
|
2827
|
+
let { hours } = timeInfo;
|
|
2828
|
+
const { minutes } = timeInfo;
|
|
2829
|
+
// Process 24hr -> 12hr
|
|
2830
|
+
const isAM = (hours < 12);
|
|
2831
|
+
if (hours === 0) {
|
|
2832
|
+
hours = 12;
|
|
2833
|
+
}
|
|
2834
|
+
else if (hours > 12) {
|
|
2835
|
+
hours %= 12;
|
|
2836
|
+
}
|
|
2837
|
+
// Pad with zeros
|
|
2838
|
+
const paddedMinutes = padZerosLeft(minutes, 2);
|
|
2839
|
+
// Assemble time string
|
|
2840
|
+
return `${hours}:${paddedMinutes} ${isAM ? 'AM' : 'PM'}`;
|
|
2841
|
+
};
|
|
2842
|
+
/*------------------------------------------------------------------------*/
|
|
2843
|
+
/* ------------------------------- Render ------------------------------- */
|
|
2844
|
+
/*------------------------------------------------------------------------*/
|
|
2845
|
+
/*----------------------------------------*/
|
|
2846
|
+
/* --------------- Main UI -------------- */
|
|
2847
|
+
/*----------------------------------------*/
|
|
2848
|
+
// Generate list of time options
|
|
2849
|
+
const times = [];
|
|
2850
|
+
for (let time = 0; time < 24 * 60; time += intervalMin) {
|
|
2851
|
+
times.push(formatTime(time));
|
|
2852
|
+
}
|
|
2853
|
+
// Currently selected time in minutes since midnight
|
|
2854
|
+
const selectedTimeMin = hour * 60 + minute;
|
|
2855
|
+
// Create choice options
|
|
2856
|
+
const timeOptions = times.map((timeString, timeIndex) => {
|
|
2857
|
+
const numMinutesForChoice = timeIndex * intervalMin;
|
|
2858
|
+
// Render the option
|
|
2859
|
+
return (React__default.createElement("option", { key: numMinutesForChoice, value: numMinutesForChoice, "aria-label": `choose ${timeString}` }, timeString));
|
|
2860
|
+
});
|
|
2861
|
+
return (React__default.createElement("div", { className: "SimpleTimeChooser-container", "aria-label": `time chooser with selected time: ${formatTime(selectedTimeMin)}` },
|
|
2862
|
+
React__default.createElement("select", { "aria-label": `time for ${ariaLabel}`, className: "custom-select d-inline-block", style: { width: 'auto' }, id: `SimpleTimeChooser-${name}-time`, value: selectedTimeMin, onChange: (e) => {
|
|
2863
|
+
// Parse selector value (string)
|
|
2864
|
+
const newTime = Number.parseInt(e.target.value, 10);
|
|
2865
|
+
// Convert minutes since midnight to hour and minute
|
|
2866
|
+
const timeInfo = convertMinSinceMidnightToHoursAndMin(newTime);
|
|
2867
|
+
// Notify parent
|
|
2868
|
+
onChange(timeInfo.hours, timeInfo.minutes);
|
|
2869
|
+
} }, timeOptions)));
|
|
2870
|
+
};
|
|
2871
|
+
|
|
2734
2872
|
/**
|
|
2735
2873
|
* Drawer container
|
|
2736
2874
|
* @author Gabe Abrams
|
|
@@ -4825,14 +4963,14 @@ const LogReviewer = (props) => {
|
|
|
4825
4963
|
if (expandedFilterDrawer) {
|
|
4826
4964
|
if (expandedFilterDrawer === FilterDrawer.Date) {
|
|
4827
4965
|
filterDrawer = (React__default.createElement(TabBox, { title: "Date" },
|
|
4828
|
-
React__default.createElement(SimpleDateChooser, { ariaLabel: "filter start date", name: "filter-start-date", year: dateFilterState.startDate.year, month: dateFilterState.startDate.month, day: dateFilterState.startDate.day,
|
|
4966
|
+
React__default.createElement(SimpleDateChooser, { ariaLabel: "filter start date", name: "filter-start-date", year: dateFilterState.startDate.year, month: dateFilterState.startDate.month, day: dateFilterState.startDate.day, dontAllowFuture: true, numMonthsToShow: 36, onChange: (month, day, year) => {
|
|
4829
4967
|
dateFilterState.startDate = { month, day, year };
|
|
4830
4968
|
handleDateRangeUpdated(dateFilterState);
|
|
4831
4969
|
} }),
|
|
4832
4970
|
' ',
|
|
4833
4971
|
"to",
|
|
4834
4972
|
' ',
|
|
4835
|
-
React__default.createElement(SimpleDateChooser, { ariaLabel: "filter end date", name: "filter-end-date", year: dateFilterState.endDate.year, month: dateFilterState.endDate.month, day: dateFilterState.endDate.day,
|
|
4973
|
+
React__default.createElement(SimpleDateChooser, { ariaLabel: "filter end date", name: "filter-end-date", year: dateFilterState.endDate.year, month: dateFilterState.endDate.month, day: dateFilterState.endDate.day, dontAllowFuture: true, numMonthsToShow: 12, onChange: (month, day, year) => {
|
|
4836
4974
|
if (year < dateFilterState.startDate.year
|
|
4837
4975
|
|| (year === dateFilterState.startDate.year
|
|
4838
4976
|
&& month < dateFilterState.startDate.month)
|
|
@@ -15312,24 +15450,6 @@ const padDecimalZeros = (num, numDigits) => {
|
|
|
15312
15450
|
return out;
|
|
15313
15451
|
};
|
|
15314
15452
|
|
|
15315
|
-
/**
|
|
15316
|
-
* Pad a number with zeros on the left (e.g. 5 becomes 05 with 2 digit padding)
|
|
15317
|
-
* @author Gabe Abrams
|
|
15318
|
-
* @param num the number to pad
|
|
15319
|
-
* @param numDigits the minimum number of digits before the decimal
|
|
15320
|
-
* @returns padded number
|
|
15321
|
-
*/
|
|
15322
|
-
const padZerosLeft = (num, numDigits) => {
|
|
15323
|
-
// Convert to string
|
|
15324
|
-
let out = String(num);
|
|
15325
|
-
// Add zeros
|
|
15326
|
-
while (out.split('.')[0].length < numDigits) {
|
|
15327
|
-
out = `0${out}`;
|
|
15328
|
-
}
|
|
15329
|
-
// Return
|
|
15330
|
-
return out;
|
|
15331
|
-
};
|
|
15332
|
-
|
|
15333
15453
|
/**
|
|
15334
15454
|
* Stub a server endpoint response
|
|
15335
15455
|
* @author Gabe Abrams
|
|
@@ -16200,5 +16320,5 @@ var DayOfWeek;
|
|
|
16200
16320
|
})(DayOfWeek || (DayOfWeek = {}));
|
|
16201
16321
|
var DayOfWeek$1 = DayOfWeek;
|
|
16202
16322
|
|
|
16203
|
-
export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, Dropdown, DropdownItemType$1 as DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogLevel$1 as LogLevel, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, MultiSwitch, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addFatalErrorHandler, alert, avg, canReviewLogs, capitalize, ceilToNumDecimals, combineClassNames, compareArraysByProp, confirm, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, getWordCount, idify, initClient, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, prompt, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
|
|
16323
|
+
export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntryFieldType$1 as DBEntryFieldType, DBEntryManagerPanel, DayOfWeek$1 as DayOfWeek, Drawer, Dropdown, DropdownItemType$1 as DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, ItemPicker, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, LoadingSpinner, LogAction$1 as LogAction, LogBuiltInMetadata, LogLevel$1 as LogLevel, LogReviewer, LogSource$1 as LogSource, LogType$1 as LogType, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, MultiSwitch, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, SimpleTimeChooser, TabBox, ToggleSwitch, Tooltip, Variant$1 as Variant, abbreviate, addFatalErrorHandler, alert, avg, canReviewLogs, capitalize, ceilToNumDecimals, combineClassNames, compareArraysByProp, confirm, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, getWordCount, idify, initClient, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, prompt, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
|
|
16204
16324
|
//# sourceMappingURL=index.js.map
|