dce-reactkit 4.0.0-beta-date-and-time.1 → 4.0.0-beta.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.
Files changed (43) hide show
  1. package/.vscode/settings.json +1 -3
  2. package/README.md +20 -0
  3. package/dist/cjs/index.js +1408 -2867
  4. package/dist/cjs/index.js.map +1 -1
  5. package/dist/cjs/types/components/ItemPicker/index.d.ts +0 -1
  6. package/dist/cjs/types/components/ItemPicker/index.test.d.ts +1 -0
  7. package/dist/cjs/types/components/LoadingSpinner.d.ts +2 -2
  8. package/dist/cjs/types/components/Modal/ModalProps.d.ts +0 -2
  9. package/dist/cjs/types/components/SimpleDateChooser.d.ts +1 -3
  10. package/dist/cjs/types/components/TabBox.d.ts +0 -1
  11. package/dist/cjs/types/components/Tooltip.d.ts +1 -1
  12. package/dist/cjs/types/index.d.ts +1 -6
  13. package/dist/cjs/types/types/ReactKitErrorCode.d.ts +1 -3
  14. package/dist/esm/index.js +1423 -2878
  15. package/dist/esm/index.js.map +1 -1
  16. package/dist/esm/types/components/ItemPicker/index.d.ts +0 -1
  17. package/dist/esm/types/components/ItemPicker/index.test.d.ts +1 -0
  18. package/dist/esm/types/components/LoadingSpinner.d.ts +2 -2
  19. package/dist/esm/types/components/Modal/ModalProps.d.ts +0 -2
  20. package/dist/esm/types/components/SimpleDateChooser.d.ts +1 -3
  21. package/dist/esm/types/components/TabBox.d.ts +0 -1
  22. package/dist/esm/types/components/Tooltip.d.ts +1 -1
  23. package/dist/esm/types/index.d.ts +1 -6
  24. package/dist/esm/types/types/ReactKitErrorCode.d.ts +1 -3
  25. package/dist/index.d.ts +19 -77
  26. package/package.json +10 -6
  27. package/src/components/IntelliTable.tsx +1 -1
  28. package/src/components/ItemPicker/NestableItemList.tsx +0 -1
  29. package/src/components/ItemPicker/index.tsx +0 -96
  30. package/src/components/LogReviewer.tsx +2 -2
  31. package/src/components/Modal/ModalProps.ts +0 -4
  32. package/src/components/Modal/index.tsx +20 -59
  33. package/src/components/SimpleDateChooser.tsx +26 -62
  34. package/src/components/TabBox.tsx +9 -27
  35. package/src/components/Tooltip.tsx +1 -1
  36. package/src/index.ts +0 -10
  37. package/src/types/ReactKitErrorCode.tsx +1 -3
  38. package/dist/cjs/types/components/SimpleTimeChooser.d.ts +0 -20
  39. package/dist/cjs/types/helpers/getWordCount.d.ts +0 -10
  40. package/dist/esm/types/components/SimpleTimeChooser.d.ts +0 -20
  41. package/dist/esm/types/helpers/getWordCount.d.ts +0 -10
  42. package/src/components/SimpleTimeChooser.tsx +0 -195
  43. package/src/helpers/getWordCount.ts +0 -26
@@ -14,9 +14,6 @@ import React, { useState, useEffect, useRef } from 'react';
14
14
  import ReactDOM from 'react-dom';
15
15
 
16
16
  // Import other components
17
- import LoadingSpinner from '../LoadingSpinner';
18
-
19
- // Import helpers
20
17
  import waitMs from '../../helpers/waitMs';
21
18
 
22
19
  // Import types
@@ -44,7 +41,6 @@ const BASE_Z_INDEX_ON_TOP = 2000000000;
44
41
 
45
42
  // Constants
46
43
  const MS_TO_ANIMATE = 200; // Animation duration
47
- const MS_TO_WAIT_BEFORE_SHOWING_LOADING_INDICATOR = 1000;
48
44
 
49
45
  // Modal type to list of buttons
50
46
  const modalTypeToModalButtonTypes: {
@@ -260,8 +256,6 @@ const Modal: React.FC<ModalProps> = (props) => {
260
256
  dontAllowBackdropExit,
261
257
  dontShowXButton,
262
258
  onTopOfOtherModals,
263
- isLoading,
264
- isLoadingCancelable,
265
259
  } = props;
266
260
 
267
261
  // Determine if no header either
@@ -272,7 +266,6 @@ const Modal: React.FC<ModalProps> = (props) => {
272
266
  // True if animation is in use
273
267
  const [animatingIn, setAnimatingIn] = useState(true);
274
268
  const [animatingPop, setAnimatingPop] = useState(false);
275
- const [showModal, setShowModal] = useState(false);
276
269
 
277
270
  /* -------------- Refs -------------- */
278
271
 
@@ -305,15 +298,6 @@ const Modal: React.FC<ModalProps> = (props) => {
305
298
  if (mounted.current) {
306
299
  setAnimatingIn(false);
307
300
  }
308
- if (isLoading) {
309
- // wait before showing modal
310
- await waitMs(MS_TO_WAIT_BEFORE_SHOWING_LOADING_INDICATOR);
311
- if (mounted.current) {
312
- setShowModal(true);
313
- }
314
- } else {
315
- setShowModal(true);
316
- }
317
301
  })();
318
302
 
319
303
  return () => {
@@ -416,17 +400,6 @@ const Modal: React.FC<ModalProps> = (props) => {
416
400
  animationClass = 'Modal-animating-pop';
417
401
  }
418
402
 
419
- // default to show close button when not loading and not show close button when loading
420
- // unless downShowXButton or isLoadingCancelable
421
- const showCloseButton = (
422
- // The modal must have an onClose function
423
- onClose
424
- // ...and the close button is allowed to be visible
425
- && !dontShowXButton
426
- // ...and should not be shown if the modal is loading and not cancelable
427
- && !(isLoading && !isLoadingCancelable)
428
- );
429
-
430
403
  // Render the modal
431
404
  const contentToRender = (
432
405
  <div
@@ -463,8 +436,6 @@ const Modal: React.FC<ModalProps> = (props) => {
463
436
  handleClose(ModalButtonType.Cancel);
464
437
  }}
465
438
  />
466
-
467
- {showModal && (
468
439
  <div
469
440
  className={`modal-dialog modal-${size} ${animationClass} modal-dialog-scrollable modal-dialog-centered`}
470
441
  style={{
@@ -527,7 +498,7 @@ const Modal: React.FC<ModalProps> = (props) => {
527
498
  {title}
528
499
  </h5>
529
500
 
530
- {showCloseButton && (
501
+ {(onClose && !dontShowXButton) && (
531
502
  <button
532
503
  type="button"
533
504
  className="Modal-x-button btn-close"
@@ -547,34 +518,25 @@ const Modal: React.FC<ModalProps> = (props) => {
547
518
  )}
548
519
  </div>
549
520
  )}
550
-
551
- <div
552
- className="modal-body"
553
- style={{
554
- color: (
555
- isDarkModeOn()
556
- ? 'white'
557
- : undefined
558
- ),
559
- backgroundColor: (
560
- isDarkModeOn()
561
- ? '#444'
562
- : undefined
563
- ),
564
- }}
565
- >
566
- {
567
- isLoading
568
- ? (
569
- <>
570
- <LoadingSpinner />
571
- <span className="sr-only">Content loading</span>
572
- </>
573
- )
574
- : children
575
- }
576
- </div>
577
-
521
+ {children && (
522
+ <div
523
+ className="modal-body"
524
+ style={{
525
+ color: (
526
+ isDarkModeOn()
527
+ ? 'white'
528
+ : undefined
529
+ ),
530
+ backgroundColor: (
531
+ isDarkModeOn()
532
+ ? '#444'
533
+ : undefined
534
+ ),
535
+ }}
536
+ >
537
+ {children}
538
+ </div>
539
+ )}
578
540
  {footer && (
579
541
  <div
580
542
  className="modal-footer pt-1 pb-1"
@@ -601,7 +563,6 @@ const Modal: React.FC<ModalProps> = (props) => {
601
563
  )}
602
564
  </div>
603
565
  </div>
604
- )}
605
566
  </div>
606
567
  );
607
568
 
@@ -1,23 +1,16 @@
1
1
  /**
2
2
  * A very simple, lightweight date chooser
3
3
  * @author Gabe Abrams
4
- * @author Gardeniu Liu
5
4
  */
6
5
 
7
6
  // Import React
8
7
  import React from 'react';
8
+ import getMonthName from '../helpers/getMonthName';
9
9
 
10
10
  // Import helpers
11
11
  import getOrdinal from '../helpers/getOrdinal';
12
- import getMonthName from '../helpers/getMonthName';
13
12
  import getTimeInfoInET from '../helpers/getTimeInfoInET';
14
13
 
15
- // Import classes
16
- import ErrorWithCode from '../errors/ErrorWithCode';
17
-
18
- // Import types
19
- import ReactKitErrorCode from '../types/ReactKitErrorCode';
20
-
21
14
  /*------------------------------------------------------------------------*/
22
15
  /* -------------------------------- Types ------------------------------- */
23
16
  /*------------------------------------------------------------------------*/
@@ -40,14 +33,12 @@ type Props = {
40
33
  * @param year new full year number
41
34
  */
42
35
  onChange: (month: number, day: number, year: number) => void,
43
- // Number of months in either the past or future to allow the user to choose from
44
- // If we aren't allowing the past or the future, we will throw an error
45
- // (max is 12, default is 6 in the past and 6 in the future)
36
+ // Number of months to allow the user to choose from
37
+ // (max is 12, default is 6)
46
38
  numMonthsToShow?: number,
47
- // If true, the user isn't allowed to select dates in the past
48
- dontAllowPast?: boolean,
49
- // If true, the user isn't allowed to select dates in the future
50
- dontAllowFuture?: boolean,
39
+ // If true, instead of showing numMonthsToShow months into the future,
40
+ // show numMonthsToShow months into the past
41
+ chooseFromPast?: boolean,
51
42
  };
52
43
 
53
44
  /*------------------------------------------------------------------------*/
@@ -65,9 +56,8 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
65
56
  ariaLabel,
66
57
  name,
67
58
  onChange,
59
+ chooseFromPast,
68
60
  numMonthsToShow = 6,
69
- dontAllowFuture,
70
- dontAllowPast,
71
61
  } = props;
72
62
 
73
63
  /*------------------------------------------------------------------------*/
@@ -86,41 +76,16 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
86
76
  days: number[],
87
77
  year: number,
88
78
  }[] = [];
89
-
90
79
  let startYear = today.year;
91
80
  let startMonth = today.month;
92
-
93
- // Don't allow past or future dates
94
- if (dontAllowPast && dontAllowFuture) {
95
- throw new ErrorWithCode(
96
- 'No past or future dates allowed',
97
- ReactKitErrorCode.SimpleDateChooserInvalidDateRange,
98
- );
99
- }
100
-
101
- // Require numMonthsToShow to be positive
102
- if (numMonthsToShow <= 0) {
103
- throw new ErrorWithCode(
104
- 'numMonthsToShow must be positive',
105
- ReactKitErrorCode.SimpleDateChooserInvalidNumMonths,
106
- );
107
- }
108
-
109
- // Recalculate startMonth and startYear when allowing past dates
110
- if (!dontAllowPast) {
81
+ if (chooseFromPast) {
111
82
  startMonth -= Math.max(0, numMonthsToShow - 1);
112
83
  while (startMonth <= 0) {
113
84
  startMonth += 12;
114
85
  startYear -= 1;
115
86
  }
116
87
  }
117
- // Calculate total number of months to show
118
- let totalMonthsToShow = numMonthsToShow;
119
- if (!dontAllowPast && !dontAllowFuture) {
120
- totalMonthsToShow = totalMonthsToShow * 2 - 1;
121
- }
122
-
123
- for (let i = 0; i < totalMonthsToShow; i++) {
88
+ for (let i = 0; i < numMonthsToShow; i++) {
124
89
  // Get month and year info
125
90
  const unmoddedMonth = (startMonth + i);
126
91
  let month = unmoddedMonth;
@@ -140,25 +105,24 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
140
105
  // Figure out which days are allowed
141
106
  const days = [];
142
107
  const numDaysInMonth = (new Date(year, month, 0)).getDate();
143
-
144
- // Current month
145
- if (month === today.month && year === today.year) {
146
- // Past selection: add all previous days of the month
147
- if (!dontAllowPast) {
148
- for (let day = 1; day < today.day; day++) {
149
- days.push(day);
150
- }
108
+ if (chooseFromPast) {
109
+ // Past selection
110
+ const numDaysToAdd = (
111
+ (month === today.month)
112
+ ? today.day // Current month, only add up to today
113
+ : numDaysInMonth // Past month, add all days
114
+ );
115
+ for (let day = 1; day <= numDaysToAdd; day++) {
116
+ days.push(day);
151
117
  }
152
- days.push(today.day); // Add current day
118
+ } else {
153
119
  // Future selection: add all remaining days of the month
154
- if (!dontAllowFuture) {
155
- for (let day = today.day + 1; day <= numDaysInMonth; day++) {
156
- days.push(day);
157
- }
158
- }
159
- } else { // Past or future month
160
- // Include all days in the month
161
- for (let day = 1; day <= numDaysInMonth; day++) {
120
+ const firstDay = (
121
+ month === today.month
122
+ ? today.day // Current month: start at current date
123
+ : 1 // Future month: start at beginning of month
124
+ );
125
+ for (let day = firstDay; day <= numDaysInMonth; day++) {
162
126
  days.push(day);
163
127
  }
164
128
  }
@@ -194,8 +158,8 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
194
158
  </option>,
195
159
  );
196
160
 
197
- // This is the currently selected month
198
161
  if (month === choice.month) {
162
+ // This is the currently selected month
199
163
  // Create day options
200
164
  choice.days.forEach((dayChoice) => {
201
165
  const ordinal = getOrdinal(dayChoice);
@@ -15,8 +15,6 @@ type Props = {
15
15
  title: React.ReactNode,
16
16
  // Children/contents inside the box
17
17
  children: React.ReactNode,
18
- // Children to display on the top right of the tab box
19
- topRightChildren?: React.ReactNode,
20
18
  // If true, don't add margin below the tab box
21
19
  noBottomMargin?: boolean,
22
20
  // If true, don't add padding to bottom of tab box
@@ -51,9 +49,7 @@ const style = `
51
49
 
52
50
  /* Container for Title */
53
51
  .TabBox-title-container {
54
- display: flex;
55
- justify-content: space-between;
56
- align-items: center;
52
+ /* Place on Left */
57
53
  position: relative;
58
54
  left: 0;
59
55
  text-align: left;
@@ -86,19 +82,6 @@ const style = `
86
82
  background: #fdfdfd;
87
83
  }
88
84
 
89
- .TabBox-title-right-container {
90
- display: flex;
91
- flex-direction: row;
92
- align-items: bottom;
93
- height: 2.4rem;
94
- overflow: visible;
95
- }
96
-
97
- .TabBox-title-right-contents {
98
- margin-right: 0.5rem;
99
- margin-bottom: 0.2rem;
100
- }
101
-
102
85
  /* Make the TabBox's Children Appear Above Title if Overlap Occurs */
103
86
  .TabBox-children {
104
87
  position: relative;
@@ -115,10 +98,11 @@ const TabBox: React.FC<Props> = (props) => {
115
98
  /* -------------------------------- Setup ------------------------------- */
116
99
  /*------------------------------------------------------------------------*/
117
100
 
101
+ /* -------------- Props ------------- */
102
+
118
103
  const {
119
104
  title,
120
105
  children,
121
- topRightChildren,
122
106
  noBottomPadding,
123
107
  noBottomMargin,
124
108
  } = props;
@@ -127,23 +111,21 @@ const TabBox: React.FC<Props> = (props) => {
127
111
  /* ------------------------------- Render ------------------------------- */
128
112
  /*------------------------------------------------------------------------*/
129
113
 
114
+ /*----------------------------------------*/
115
+ /* --------------- Main UI -------------- */
116
+ /*----------------------------------------*/
117
+
118
+ // Full UI
130
119
  return (
131
120
  <div className={`TabBox-container ${noBottomMargin ? '' : 'mb-2'}`}>
132
121
  {/* Style */}
133
122
  <style>{style}</style>
134
123
 
135
- {/* Title Row with Left and Right sections */}
124
+ {/* Title */}
136
125
  <div className="TabBox-title-container">
137
126
  <div className="TabBox-title">
138
127
  {title}
139
128
  </div>
140
- {topRightChildren && (
141
- <div className="TabBox-title-right-container">
142
- <div className="TabBox-title-right-contents">
143
- {topRightChildren}
144
- </div>
145
- </div>
146
- )}
147
129
  </div>
148
130
 
149
131
  {/* Contents */}
@@ -15,7 +15,7 @@ type Props = {
15
15
  // Text of the tooltip
16
16
  text: string,
17
17
  // Children to wrap in the tooltip
18
- children: any,
18
+ children: JSX.Element,
19
19
  };
20
20
 
21
21
  /*------------------------------------------------------------------------*/
package/src/index.ts CHANGED
@@ -15,7 +15,6 @@ import RadioButton from './components/RadioButton';
15
15
  import CheckboxButton from './components/CheckboxButton';
16
16
  import ButtonInputGroup from './components/ButtonInputGroup';
17
17
  import SimpleDateChooser from './components/SimpleDateChooser';
18
- import SimpleTimeChooser from './components/SimpleTimeChooser';
19
18
  import Drawer from './components/Drawer';
20
19
  import PopSuccessMark from './components/PopSuccessMark';
21
20
  import PopFailureMark from './components/PopFailureMark';
@@ -39,9 +38,6 @@ import ErrorWithCode from './errors/ErrorWithCode';
39
38
  import MINUTE_IN_MS from './constants/MINUTE_IN_MS';
40
39
  import HOUR_IN_MS from './constants/HOUR_IN_MS';
41
40
  import DAY_IN_MS from './constants/DAY_IN_MS';
42
- import LOG_REVIEW_ROUTE_PATH_PREFIX from './constants/LOG_REVIEW_ROUTE_PATH_PREFIX';
43
- import LOG_ROUTE_PATH from './constants/LOG_ROUTE_PATH';
44
- import LOG_REVIEW_STATUS_ROUTE from './constants/LOG_REVIEW_STATUS_ROUTE';
45
41
 
46
42
  // Import dynamic constants
47
43
  import DynamicWord from './dynamicConstants/DynamicWord';
@@ -92,7 +88,6 @@ import mapAsync from './helpers/asyncArrayFunctions/mapAsync';
92
88
  import someAsync from './helpers/asyncArrayFunctions/someAsync';
93
89
  import capitalize from './helpers/capitalize';
94
90
  import shuffleArray from './helpers/shuffleArray';
95
- import getWordCount from './helpers/getWordCount';
96
91
 
97
92
  // Import types
98
93
  import ParamType from './types/ParamType';
@@ -134,7 +129,6 @@ export {
134
129
  CheckboxButton,
135
130
  ButtonInputGroup,
136
131
  SimpleDateChooser,
137
- SimpleTimeChooser,
138
132
  Drawer,
139
133
  PopSuccessMark,
140
134
  PopFailureMark,
@@ -161,9 +155,6 @@ export {
161
155
  MINUTE_IN_MS,
162
156
  HOUR_IN_MS,
163
157
  DAY_IN_MS,
164
- LOG_REVIEW_ROUTE_PATH_PREFIX,
165
- LOG_ROUTE_PATH,
166
- LOG_REVIEW_STATUS_ROUTE,
167
158
  // Dynamic Constants
168
159
  DynamicWord,
169
160
  // Helpers
@@ -207,7 +198,6 @@ export {
207
198
  someAsync,
208
199
  capitalize,
209
200
  shuffleArray,
210
- getWordCount,
211
201
  // Client helpers
212
202
  initClient,
213
203
  visitServerEndpoint,
@@ -1,4 +1,4 @@
1
- // Highest error code = DRK36
1
+ // Highest error code = DRK34
2
2
 
3
3
  /**
4
4
  * List of error codes built into the react kit
@@ -9,8 +9,6 @@ enum ReactKitErrorCode {
9
9
  NoCode = 'DRK2',
10
10
  SessionExpired = 'DRK3',
11
11
  NoCACCLSendRequestFunction = 'DRK7',
12
- SimpleDateChooserInvalidDateRange = 'DRK35',
13
- SimpleDateChooserInvalidNumMonths = 'DRK36',
14
12
  }
15
13
 
16
14
  export default ReactKitErrorCode;
@@ -1,20 +0,0 @@
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;
@@ -1,10 +0,0 @@
1
- /**
2
- * Get number of words in string
3
- * @author Gardenia Liu
4
- * @author Allison Zhang
5
- * @author Gabe Abrams
6
- * @param text the string to check
7
- * @returns number of words in the string
8
- */
9
- declare const getWordCount: (text: string) => number;
10
- export default getWordCount;
@@ -1,20 +0,0 @@
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;
@@ -1,10 +0,0 @@
1
- /**
2
- * Get number of words in string
3
- * @author Gardenia Liu
4
- * @author Allison Zhang
5
- * @author Gabe Abrams
6
- * @param text the string to check
7
- * @returns number of words in the string
8
- */
9
- declare const getWordCount: (text: string) => number;
10
- export default getWordCount;