dce-reactkit 3.2.2-beta.9 → 3.2.4

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 (50) hide show
  1. package/dist/cjs/index.js +742 -435
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/components/Drawer.d.ts +1 -0
  4. package/dist/cjs/types/components/IntelliTable.d.ts +1 -0
  5. package/dist/cjs/types/components/ItemPicker/NestableItemList.d.ts +1 -0
  6. package/dist/cjs/types/dynamicConstants/DynamicWord.d.ts +13 -0
  7. package/dist/cjs/types/helpers/isMobileOrTablet.d.ts +7 -0
  8. package/dist/cjs/types/index.d.ts +3 -1
  9. package/dist/cjs/types/types/LogAction.d.ts +16 -16
  10. package/dist/cjs/types/types/LogBuiltInMetadata.d.ts +1 -1
  11. package/dist/cjs/types/types/LogMetadataContextMap.d.ts +11 -0
  12. package/dist/cjs/types/types/LogMetadataTagMap.d.ts +8 -0
  13. package/dist/cjs/types/types/LogMetadataTargetMap.d.ts +8 -0
  14. package/dist/cjs/types/types/LogMetadataType.d.ts +6 -12
  15. package/dist/esm/index.js +742 -437
  16. package/dist/esm/index.js.map +1 -1
  17. package/dist/esm/types/components/Drawer.d.ts +1 -0
  18. package/dist/esm/types/components/IntelliTable.d.ts +1 -0
  19. package/dist/esm/types/components/ItemPicker/NestableItemList.d.ts +1 -0
  20. package/dist/esm/types/dynamicConstants/DynamicWord.d.ts +13 -0
  21. package/dist/esm/types/helpers/isMobileOrTablet.d.ts +7 -0
  22. package/dist/esm/types/index.d.ts +3 -1
  23. package/dist/esm/types/types/LogAction.d.ts +16 -16
  24. package/dist/esm/types/types/LogBuiltInMetadata.d.ts +1 -1
  25. package/dist/esm/types/types/LogMetadataContextMap.d.ts +11 -0
  26. package/dist/esm/types/types/LogMetadataTagMap.d.ts +8 -0
  27. package/dist/esm/types/types/LogMetadataTargetMap.d.ts +8 -0
  28. package/dist/esm/types/types/LogMetadataType.d.ts +6 -12
  29. package/dist/index.d.ts +70 -30
  30. package/package.json +1 -1
  31. package/src/components/ButtonInputGroup.tsx +1 -1
  32. package/src/components/CSVDownloadButton.tsx +2 -2
  33. package/src/components/Drawer.tsx +9 -1
  34. package/src/components/IntelliTable.tsx +178 -23
  35. package/src/components/ItemPicker/NestableItemList.tsx +32 -14
  36. package/src/components/LogReviewer.tsx +584 -424
  37. package/src/components/SimpleDateChooser.tsx +30 -25
  38. package/src/dynamicConstants/DynamicWord.tsx +44 -0
  39. package/src/helpers/genCSV.ts +22 -4
  40. package/src/helpers/genRouteHandler.ts +2 -2
  41. package/src/helpers/isMobileOrTablet.tsx +26 -0
  42. package/src/helpers/logClientEvent.tsx +1 -1
  43. package/src/index.ts +7 -0
  44. package/src/server/initServer.ts +10 -3
  45. package/src/types/LogAction.ts +16 -16
  46. package/src/types/LogBuiltInMetadata.ts +5 -5
  47. package/src/types/LogMetadataContextMap.ts +15 -0
  48. package/src/types/LogMetadataTagMap.ts +9 -0
  49. package/src/types/LogMetadataTargetMap.ts +9 -0
  50. package/src/types/LogMetadataType.ts +8 -15
@@ -4,6 +4,7 @@
4
4
  */
5
5
  import React from 'react';
6
6
  declare type Props = {
7
+ customBackgroundColor?: string;
7
8
  children: React.ReactNode;
8
9
  };
9
10
  declare const Drawer: React.FC<Props>;
@@ -12,6 +12,7 @@ declare type Props = {
12
12
  [k: string]: any;
13
13
  }[];
14
14
  columns: IntelliTableColumn[];
15
+ csvName?: string;
15
16
  };
16
17
  declare const IntelliTable: React.FC<Props>;
17
18
  export default IntelliTable;
@@ -1,6 +1,7 @@
1
1
  /**
2
2
  * Reusable nested item picker
3
3
  * @author Yuen Ler Chow
4
+ * @author Gabe Abrams
4
5
  */
5
6
  import React from 'react';
6
7
  import PickableItem from './types/PickableItem';
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Dynamic words determined by the user's platform
3
+ * @author Gabe Abrams
4
+ */
5
+ declare const DynamicWord: {
6
+ Click: string;
7
+ ClickCapitalized: string;
8
+ App: string;
9
+ AppCapitalized: string;
10
+ Device: string;
11
+ DeviceCapitalized: string;
12
+ };
13
+ export default DynamicWord;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Check if the user is on a mobile device or tablet
3
+ * from https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser
4
+ * @returns true if user is on a mobile device
5
+ */
6
+ declare const isMobileOrTablet: () => boolean;
7
+ export default isMobileOrTablet;
@@ -20,6 +20,7 @@ import ErrorWithCode from './errors/ErrorWithCode';
20
20
  import MINUTE_IN_MS from './constants/MINUTE_IN_MS';
21
21
  import HOUR_IN_MS from './constants/HOUR_IN_MS';
22
22
  import DAY_IN_MS from './constants/DAY_IN_MS';
23
+ import DynamicWord from './dynamicConstants/DynamicWord';
23
24
  import abbreviate from './helpers/abbreviate';
24
25
  import avg from './helpers/avg';
25
26
  import ceilToNumDecimals from './helpers/ceilToNumDecimals';
@@ -49,6 +50,7 @@ import initLogCollection from './server/initLogCollection';
49
50
  import getMonthName from './helpers/getMonthName';
50
51
  import genCSV from './helpers/genCSV';
51
52
  import canReviewLogs from './helpers/canReviewLogs';
53
+ import isMobileOrTablet from './helpers/isMobileOrTablet';
52
54
  import ModalButtonType from './types/ModalButtonType';
53
55
  import ModalSize from './types/ModalSize';
54
56
  import ModalType from './types/ModalType';
@@ -64,4 +66,4 @@ import LogBuiltInMetadata from './types/LogBuiltInMetadata';
64
66
  import LogMetadataType from './types/LogMetadataType';
65
67
  import IntelliTableColumn from './types/IntelliTableColumn';
66
68
  import PickableItem from './components/ItemPicker/types/PickableItem';
67
- export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, visitServerEndpoint, logClientEvent, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, ParamType, };
69
+ export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, alert, confirm, showFatalError, ErrorWithCode, MINUTE_IN_MS, HOUR_IN_MS, DAY_IN_MS, DynamicWord, abbreviate, avg, ceilToNumDecimals, floorToNumDecimals, forceNumIntoBounds, padDecimalZeros, padZerosLeft, roundToNumDecimals, sum, waitMs, getOrdinal, getTimeInfoInET, stubServerEndpoint, startMinWait, getHumanReadableDate, getPartOfDay, stringsToHumanReadableList, onlyKeepLetters, parallelLimit, getMonthName, genCSV, canReviewLogs, isMobileOrTablet, visitServerEndpoint, logClientEvent, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, ParamType, };
@@ -3,21 +3,21 @@
3
3
  * @author Gabe Abrams
4
4
  */
5
5
  declare enum LogAction {
6
- Open = "open",
7
- Close = "close",
8
- Cancel = "cancel",
9
- Expand = "expand",
10
- Collapse = "collapse",
11
- View = "view",
12
- Interrupt = "interrupt",
13
- Create = "create",
14
- Edit = "edit",
15
- Delete = "delete",
16
- Add = "add",
17
- Remove = "remove",
18
- Activate = "activate",
19
- Deactivate = "deactivate",
20
- Peek = "peek",
21
- Unknown = "unknown"
6
+ Open = "Open",
7
+ Close = "Close",
8
+ Cancel = "Cancel",
9
+ Expand = "Expand",
10
+ Collapse = "Collapse",
11
+ View = "View",
12
+ Interrupt = "Interrupt",
13
+ Create = "Create",
14
+ Edit = "Edit",
15
+ Delete = "Delete",
16
+ Add = "Add",
17
+ Remove = "Remove",
18
+ Activate = "Activate",
19
+ Deactivate = "Deactivate",
20
+ Peek = "Peek",
21
+ Unknown = "Unknown"
22
22
  }
23
23
  export default LogAction;
@@ -10,7 +10,7 @@ declare const LogBuiltInMetadata: {
10
10
  ClientFatalError: string;
11
11
  };
12
12
  Target: {
13
- NoSpecificTarget: string;
13
+ NoTarget: string;
14
14
  };
15
15
  };
16
16
  export default LogBuiltInMetadata;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Type of the context map in a LogMetadata file
3
+ * @author Gabe Abrams
4
+ */
5
+ declare type LogMetadataContextMap = {
6
+ [k: string]: (string | {
7
+ _: string;
8
+ [k: string]: string;
9
+ });
10
+ };
11
+ export default LogMetadataContextMap;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Type of the tag map inside a LogMetadata file
3
+ * @author Gabe Abrams
4
+ */
5
+ declare type LogMetadataTagMap = {
6
+ [k: string]: string;
7
+ };
8
+ export default LogMetadataTagMap;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Type of the target map inside a LogMetadata file
3
+ * @author Gabe Abrams
4
+ */
5
+ declare type LogMetadataTargetMap = {
6
+ [k: string]: string;
7
+ };
8
+ export default LogMetadataTargetMap;
@@ -1,19 +1,13 @@
1
+ import LogMetadataContextMap from './LogMetadataContextMap';
2
+ import LogMetadataTagMap from './LogMetadataTagMap';
3
+ import LogMetadataTargetMap from './LogMetadataTargetMap';
1
4
  /**
2
5
  * Type of a LogMetadata file
3
6
  * @author Gabe Abrams
4
7
  */
5
8
  declare type LogMetadataType = {
6
- Context?: {
7
- [k: string]: (string | {
8
- _: string;
9
- [k: string]: string;
10
- });
11
- };
12
- Tag?: {
13
- [k: string]: string;
14
- };
15
- Target?: {
16
- [k: string]: string;
17
- };
9
+ Context?: LogMetadataContextMap;
10
+ Tag?: LogMetadataTagMap;
11
+ Target?: LogMetadataTargetMap;
18
12
  };
19
13
  export default LogMetadataType;
package/dist/index.d.ts CHANGED
@@ -275,6 +275,7 @@ declare const SimpleDateChooser: React.FC<Props$9>;
275
275
  */
276
276
 
277
277
  declare type Props$8 = {
278
+ customBackgroundColor?: string;
278
279
  children: React.ReactNode;
279
280
  };
280
281
  declare const Drawer: React.FC<Props$8>;
@@ -368,23 +369,41 @@ declare type Props$3 = {
368
369
  };
369
370
  declare const ItemPicker: React.FC<Props$3>;
370
371
 
372
+ /**
373
+ * Type of the context map in a LogMetadata file
374
+ * @author Gabe Abrams
375
+ */
376
+ declare type LogMetadataContextMap = {
377
+ [k: string]: (string | {
378
+ _: string;
379
+ [k: string]: string;
380
+ });
381
+ };
382
+
383
+ /**
384
+ * Type of the tag map inside a LogMetadata file
385
+ * @author Gabe Abrams
386
+ */
387
+ declare type LogMetadataTagMap = {
388
+ [k: string]: string;
389
+ };
390
+
391
+ /**
392
+ * Type of the target map inside a LogMetadata file
393
+ * @author Gabe Abrams
394
+ */
395
+ declare type LogMetadataTargetMap = {
396
+ [k: string]: string;
397
+ };
398
+
371
399
  /**
372
400
  * Type of a LogMetadata file
373
401
  * @author Gabe Abrams
374
402
  */
375
403
  declare type LogMetadataType = {
376
- Context?: {
377
- [k: string]: (string | {
378
- _: string;
379
- [k: string]: string;
380
- });
381
- };
382
- Tag?: {
383
- [k: string]: string;
384
- };
385
- Target?: {
386
- [k: string]: string;
387
- };
404
+ Context?: LogMetadataContextMap;
405
+ Tag?: LogMetadataTagMap;
406
+ Target?: LogMetadataTargetMap;
388
407
  };
389
408
 
390
409
  /**
@@ -440,6 +459,7 @@ declare type Props$1 = {
440
459
  [k: string]: any;
441
460
  }[];
442
461
  columns: IntelliTableColumn[];
462
+ csvName?: string;
443
463
  };
444
464
  declare const IntelliTable: React.FC<Props$1>;
445
465
 
@@ -489,6 +509,19 @@ declare const HOUR_IN_MS = 3600000;
489
509
  */
490
510
  declare const DAY_IN_MS = 86400000;
491
511
 
512
+ /**
513
+ * Dynamic words determined by the user's platform
514
+ * @author Gabe Abrams
515
+ */
516
+ declare const DynamicWord: {
517
+ Click: string;
518
+ ClickCapitalized: string;
519
+ App: string;
520
+ AppCapitalized: string;
521
+ Device: string;
522
+ DeviceCapitalized: string;
523
+ };
524
+
492
525
  /**
493
526
  * Shorten text so it fits into a certain number of chars
494
527
  * @author Gabe Abrams
@@ -669,22 +702,22 @@ declare type LogSourceSpecificInfo = ({
669
702
  * @author Gabe Abrams
670
703
  */
671
704
  declare enum LogAction {
672
- Open = "open",
673
- Close = "close",
674
- Cancel = "cancel",
675
- Expand = "expand",
676
- Collapse = "collapse",
677
- View = "view",
678
- Interrupt = "interrupt",
679
- Create = "create",
680
- Edit = "edit",
681
- Delete = "delete",
682
- Add = "add",
683
- Remove = "remove",
684
- Activate = "activate",
685
- Deactivate = "deactivate",
686
- Peek = "peek",
687
- Unknown = "unknown"
705
+ Open = "Open",
706
+ Close = "Close",
707
+ Cancel = "Cancel",
708
+ Expand = "Expand",
709
+ Collapse = "Collapse",
710
+ View = "View",
711
+ Interrupt = "Interrupt",
712
+ Create = "Create",
713
+ Edit = "Edit",
714
+ Delete = "Delete",
715
+ Add = "Add",
716
+ Remove = "Remove",
717
+ Activate = "Activate",
718
+ Deactivate = "Deactivate",
719
+ Peek = "Peek",
720
+ Unknown = "Unknown"
688
721
  }
689
722
 
690
723
  /**
@@ -984,6 +1017,13 @@ declare const genCSV: (data: {
984
1017
  */
985
1018
  declare const canReviewLogs: () => Promise<boolean>;
986
1019
 
1020
+ /**
1021
+ * Check if the user is on a mobile device or tablet
1022
+ * from https://stackoverflow.com/questions/11381673/detecting-a-mobile-browser
1023
+ * @returns true if user is on a mobile device
1024
+ */
1025
+ declare const isMobileOrTablet: () => boolean;
1026
+
987
1027
  /**
988
1028
  * List of error codes built into the react kit
989
1029
  * @author Gabe Abrams
@@ -1028,8 +1068,8 @@ declare const LogBuiltInMetadata: {
1028
1068
  ClientFatalError: string;
1029
1069
  };
1030
1070
  Target: {
1031
- NoSpecificTarget: string;
1071
+ NoTarget: string;
1032
1072
  };
1033
1073
  };
1034
1074
 
1035
- export { AppWrapper, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DayOfWeek, Drawer, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, Variant, abbreviate, alert, avg, canReviewLogs, ceilToNumDecimals, confirm, floorToNumDecimals, forceNumIntoBounds, genCSV, genRouteHandler, getHumanReadableDate, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initLogCollection, initServer, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
1075
+ export { AppWrapper, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, Variant, abbreviate, alert, avg, canReviewLogs, ceilToNumDecimals, confirm, floorToNumDecimals, forceNumIntoBounds, genCSV, genRouteHandler, getHumanReadableDate, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initLogCollection, initServer, isMobileOrTablet, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.2.2-beta.9",
3
+ "version": "3.2.4",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -69,7 +69,7 @@ const ButtonInputGroup: React.FC<Props> = (props) => {
69
69
 
70
70
  {/* Contents */}
71
71
  <span
72
- className="input-group-text flex-grow-1 rounded-right"
72
+ className="input-group-text flex-grow-1 rounded-right d-flex flex-wrap"
73
73
  style={{
74
74
  backgroundColor: 'white',
75
75
  borderTopLeftRadius: 0,
@@ -70,7 +70,7 @@ const CSVDownloadButton: React.FC<Props> = (props) => {
70
70
  <a
71
71
  id={id}
72
72
  download={filename}
73
- href={`data:application/octet-stream,${csv}`}
73
+ href={`data:application/octet-stream,${encodeURIComponent(csv)}`}
74
74
  className={`CSVDownloadButton-button ${className ?? 'btn btn-secondary'}`}
75
75
  aria-label={(
76
76
  ariaLabel
@@ -84,8 +84,8 @@ const CSVDownloadButton: React.FC<Props> = (props) => {
84
84
  <>
85
85
  <FontAwesomeIcon
86
86
  icon={faCloudDownloadAlt}
87
- className="mr-2"
88
87
  />
88
+ {' '}
89
89
  Download CSV
90
90
  </>
91
91
  )}
@@ -12,6 +12,8 @@ import React from 'react';
12
12
 
13
13
  // Props definition
14
14
  type Props = {
15
+ // Custom background color
16
+ customBackgroundColor?: string,
15
17
  // Children to display
16
18
  children: React.ReactNode,
17
19
  };
@@ -49,6 +51,7 @@ const Drawer: React.FC<Props> = (props) => {
49
51
 
50
52
  // Destructure all props
51
53
  const {
54
+ customBackgroundColor,
52
55
  children,
53
56
  } = props;
54
57
 
@@ -61,7 +64,12 @@ const Drawer: React.FC<Props> = (props) => {
61
64
  /*----------------------------------------*/
62
65
 
63
66
  return (
64
- <div className="Drawer-container">
67
+ <div
68
+ className="Drawer-container"
69
+ style={{
70
+ backgroundColor: (customBackgroundColor ?? undefined),
71
+ }}
72
+ >
65
73
  <style>{style}</style>
66
74
  {children}
67
75
  </div>