dce-reactkit 3.5.13 → 3.6.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 (34) hide show
  1. package/dist/cjs/index.js +355 -298
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/client/initClient.d.ts +7 -0
  4. package/dist/cjs/types/components/AppWrapper.d.ts +0 -1
  5. package/dist/cjs/types/helpers/makeLinksClickable.d.ts +4 -2
  6. package/dist/esm/index.js +355 -298
  7. package/dist/esm/index.js.map +1 -1
  8. package/dist/esm/types/client/initClient.d.ts +7 -0
  9. package/dist/esm/types/components/AppWrapper.d.ts +0 -1
  10. package/dist/esm/types/helpers/makeLinksClickable.d.ts +4 -2
  11. package/dist/index.d.ts +5 -3
  12. package/package.json +1 -1
  13. package/src/client/initClient.tsx +20 -4
  14. package/src/components/AppWrapper.tsx +8 -6
  15. package/src/components/ButtonInputGroup.tsx +6 -6
  16. package/src/components/CSVDownloadButton.tsx +6 -6
  17. package/src/components/CheckboxButton.tsx +19 -8
  18. package/src/components/CopiableBox.tsx +8 -8
  19. package/src/components/Drawer.tsx +7 -7
  20. package/src/components/ErrorBox.tsx +5 -5
  21. package/src/components/IntelliTable.tsx +135 -135
  22. package/src/components/ItemPicker/NestableItemList.tsx +7 -7
  23. package/src/components/ItemPicker/index.tsx +7 -7
  24. package/src/components/LoadingSpinner.tsx +4 -4
  25. package/src/components/LogReviewer.tsx +21 -22
  26. package/src/components/Modal.tsx +163 -75
  27. package/src/components/PopFailureMark.tsx +7 -7
  28. package/src/components/PopPendingMark.tsx +7 -7
  29. package/src/components/PopSuccessMark.tsx +7 -7
  30. package/src/components/RadioButton.tsx +17 -8
  31. package/src/components/SimpleDateChooser.tsx +14 -13
  32. package/src/components/TabBox.tsx +7 -7
  33. package/src/helpers/genRouteHandler.ts +45 -41
  34. package/src/helpers/makeLinksClickable.tsx +6 -4
@@ -7,7 +7,7 @@
7
7
  import React from 'react';
8
8
 
9
9
  /*------------------------------------------------------------------------*/
10
- /* Types */
10
+ /* -------------------------------- Types ------------------------------- */
11
11
  /*------------------------------------------------------------------------*/
12
12
 
13
13
  // Props definition
@@ -21,7 +21,7 @@ type Props = {
21
21
  };
22
22
 
23
23
  /*------------------------------------------------------------------------*/
24
- /* Style */
24
+ /* -------------------------------- Style ------------------------------- */
25
25
  /*------------------------------------------------------------------------*/
26
26
 
27
27
  const style = `
@@ -111,12 +111,12 @@ const style = `
111
111
  `;
112
112
 
113
113
  /*------------------------------------------------------------------------*/
114
- /* Component */
114
+ /* ------------------------------ Component ----------------------------- */
115
115
  /*------------------------------------------------------------------------*/
116
116
 
117
117
  const PopSuccessMark: React.FC<Props> = (props) => {
118
118
  /*------------------------------------------------------------------------*/
119
- /* Setup */
119
+ /* -------------------------------- Setup ------------------------------- */
120
120
  /*------------------------------------------------------------------------*/
121
121
 
122
122
  /* -------------- Props ------------- */
@@ -129,11 +129,11 @@ const PopSuccessMark: React.FC<Props> = (props) => {
129
129
  } = props;
130
130
 
131
131
  /*------------------------------------------------------------------------*/
132
- /* Render */
132
+ /* ------------------------------- Render ------------------------------- */
133
133
  /*------------------------------------------------------------------------*/
134
134
 
135
135
  /*----------------------------------------*/
136
- /* Main UI */
136
+ /* --------------- Main UI -------------- */
137
137
  /*----------------------------------------*/
138
138
 
139
139
  return (
@@ -165,7 +165,7 @@ const PopSuccessMark: React.FC<Props> = (props) => {
165
165
  };
166
166
 
167
167
  /*------------------------------------------------------------------------*/
168
- /* Wrap Up */
168
+ /* ------------------------------- Wrap Up ------------------------------ */
169
169
  /*------------------------------------------------------------------------*/
170
170
 
171
171
  // Export component
@@ -13,9 +13,10 @@ import { faCircle } from '@fortawesome/free-regular-svg-icons';
13
13
 
14
14
  // Import shared types
15
15
  import Variant from '../types/Variant';
16
+ import { isDarkModeOn } from '../client/initClient';
16
17
 
17
18
  /*------------------------------------------------------------------------*/
18
- /* Types */
19
+ /* -------------------------------- Types ------------------------------- */
19
20
  /*------------------------------------------------------------------------*/
20
21
 
21
22
  type Props = {
@@ -42,12 +43,12 @@ type Props = {
42
43
  };
43
44
 
44
45
  /*------------------------------------------------------------------------*/
45
- /* Component */
46
+ /* ------------------------------ Component ----------------------------- */
46
47
  /*------------------------------------------------------------------------*/
47
48
 
48
49
  const RadioButton: React.FC<Props> = (props) => {
49
50
  /*------------------------------------------------------------------------*/
50
- /* Setup */
51
+ /* -------------------------------- Setup ------------------------------- */
51
52
  /*------------------------------------------------------------------------*/
52
53
 
53
54
  /* -------------- Props ------------- */
@@ -60,17 +61,25 @@ const RadioButton: React.FC<Props> = (props) => {
60
61
  selected,
61
62
  id,
62
63
  noMarginOnRight,
63
- selectedVariant = Variant.Secondary,
64
- unselectedVariant = Variant.Light,
64
+ selectedVariant = (
65
+ isDarkModeOn()
66
+ ? Variant.Light
67
+ : Variant.Secondary
68
+ ),
69
+ unselectedVariant = (
70
+ isDarkModeOn()
71
+ ? Variant.Secondary
72
+ : Variant.Light
73
+ ),
65
74
  small,
66
75
  } = props;
67
76
 
68
77
  /*------------------------------------------------------------------------*/
69
- /* Render */
78
+ /* ------------------------------- Render ------------------------------- */
70
79
  /*------------------------------------------------------------------------*/
71
80
 
72
81
  /*----------------------------------------*/
73
- /* Main UI */
82
+ /* --------------- Main UI -------------- */
74
83
  /*----------------------------------------*/
75
84
 
76
85
  return (
@@ -96,7 +105,7 @@ const RadioButton: React.FC<Props> = (props) => {
96
105
  };
97
106
 
98
107
  /*------------------------------------------------------------------------*/
99
- /* Wrap up */
108
+ /* ------------------------------- Wrap Up ------------------------------ */
100
109
  /*------------------------------------------------------------------------*/
101
110
 
102
111
  export default RadioButton;
@@ -10,10 +10,9 @@ import getMonthName from '../helpers/getMonthName';
10
10
  // Import helpers
11
11
  import getOrdinal from '../helpers/getOrdinal';
12
12
  import getTimeInfoInET from '../helpers/getTimeInfoInET';
13
- import forceNumIntoBounds from '../helpers/forceNumIntoBounds';
14
13
 
15
14
  /*------------------------------------------------------------------------*/
16
- /* Types */
15
+ /* -------------------------------- Types ------------------------------- */
17
16
  /*------------------------------------------------------------------------*/
18
17
 
19
18
  type Props = {
@@ -43,12 +42,12 @@ type Props = {
43
42
  };
44
43
 
45
44
  /*------------------------------------------------------------------------*/
46
- /* Component */
45
+ /* ------------------------------ Component ----------------------------- */
47
46
  /*------------------------------------------------------------------------*/
48
47
 
49
48
  const SimpleDateChooser: React.FC<Props> = (props) => {
50
49
  /*------------------------------------------------------------------------*/
51
- /* Setup */
50
+ /* -------------------------------- Setup ------------------------------- */
52
51
  /*------------------------------------------------------------------------*/
53
52
 
54
53
  /* -------------- Props ------------- */
@@ -56,20 +55,17 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
56
55
  const {
57
56
  ariaLabel,
58
57
  name,
59
- month,
60
- day,
61
- year,
62
58
  onChange,
63
59
  chooseFromPast,
60
+ numMonthsToShow = 6,
64
61
  } = props;
65
- const numMonthsToShow = (props.numMonthsToShow ?? 6);
66
62
 
67
63
  /*------------------------------------------------------------------------*/
68
- /* Render */
64
+ /* ------------------------------- Render ------------------------------- */
69
65
  /*------------------------------------------------------------------------*/
70
66
 
71
67
  /*----------------------------------------*/
72
- /* Main UI */
68
+ /* --------------- Main UI -------------- */
73
69
  /*----------------------------------------*/
74
70
 
75
71
  // Determine the set of choices allowed
@@ -134,6 +130,11 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
134
130
  }
135
131
 
136
132
  // Create choice options
133
+ const {
134
+ month,
135
+ day,
136
+ year,
137
+ } = props;
137
138
  const monthOptions: React.ReactNode[] = [];
138
139
  const dayOptions: React.ReactNode[] = [];
139
140
  choices.forEach((choice) => {
@@ -148,7 +149,7 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
148
149
  }}
149
150
  >
150
151
  {choice.choiceName}
151
- </option>
152
+ </option>,
152
153
  );
153
154
 
154
155
  if (month === choice.month) {
@@ -164,7 +165,7 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
164
165
  >
165
166
  {dayChoice}
166
167
  {ordinal}
167
- </option>
168
+ </option>,
168
169
  );
169
170
  });
170
171
  }
@@ -219,7 +220,7 @@ const SimpleDateChooser: React.FC<Props> = (props) => {
219
220
  };
220
221
 
221
222
  /*------------------------------------------------------------------------*/
222
- /* Wrap Up */
223
+ /* ------------------------------- Wrap Up ------------------------------ */
223
224
  /*------------------------------------------------------------------------*/
224
225
 
225
226
  // Export component
@@ -7,7 +7,7 @@
7
7
  import React from 'react';
8
8
 
9
9
  /*------------------------------------------------------------------------*/
10
- /* Types */
10
+ /* -------------------------------- Types ------------------------------- */
11
11
  /*------------------------------------------------------------------------*/
12
12
 
13
13
  type Props = {
@@ -22,7 +22,7 @@ type Props = {
22
22
  };
23
23
 
24
24
  /*------------------------------------------------------------------------*/
25
- /* Style */
25
+ /* -------------------------------- Style ------------------------------- */
26
26
  /*------------------------------------------------------------------------*/
27
27
 
28
28
  const style = `
@@ -90,12 +90,12 @@ const style = `
90
90
  `;
91
91
 
92
92
  /*------------------------------------------------------------------------*/
93
- /* Component */
93
+ /* ------------------------------ Component ----------------------------- */
94
94
  /*------------------------------------------------------------------------*/
95
95
 
96
96
  const TabBox: React.FC<Props> = (props) => {
97
97
  /*------------------------------------------------------------------------*/
98
- /* Setup */
98
+ /* -------------------------------- Setup ------------------------------- */
99
99
  /*------------------------------------------------------------------------*/
100
100
 
101
101
  /* -------------- Props ------------- */
@@ -108,11 +108,11 @@ const TabBox: React.FC<Props> = (props) => {
108
108
  } = props;
109
109
 
110
110
  /*------------------------------------------------------------------------*/
111
- /* Render */
111
+ /* ------------------------------- Render ------------------------------- */
112
112
  /*------------------------------------------------------------------------*/
113
113
 
114
114
  /*----------------------------------------*/
115
- /* Main UI */
115
+ /* --------------- Main UI -------------- */
116
116
  /*----------------------------------------*/
117
117
 
118
118
  // Full UI
@@ -139,7 +139,7 @@ const TabBox: React.FC<Props> = (props) => {
139
139
  };
140
140
 
141
141
  /*------------------------------------------------------------------------*/
142
- /* Wrap Up */
142
+ /* ------------------------------- Wrap Up ------------------------------ */
143
143
  /*------------------------------------------------------------------------*/
144
144
 
145
145
  // Export component
@@ -1,4 +1,6 @@
1
1
  // Import caccl functions
2
+ // TODO: fix dependency cycle
3
+ // eslint-disable-next-line import/no-cycle
2
4
  import {
3
5
  cacclGetLaunchInfo,
4
6
  internalGetLogCollection,
@@ -84,7 +86,7 @@ const genRouteHandler = (
84
86
  const output: { [k in string]: any } = {};
85
87
 
86
88
  /*----------------------------------------*/
87
- /* Parse Params */
89
+ /* ------------ Parse Params ------------ */
88
90
  /*----------------------------------------*/
89
91
 
90
92
  // Process items one by one
@@ -271,7 +273,7 @@ const genRouteHandler = (
271
273
  }
272
274
 
273
275
  /*----------------------------------------*/
274
- /* Launch Info */
276
+ /* ------------- Launch Info ------------ */
275
277
  /*----------------------------------------*/
276
278
 
277
279
  // Get launch info
@@ -438,7 +440,7 @@ const genRouteHandler = (
438
440
  },
439
441
  );
440
442
  }
441
-
443
+
442
444
  // Add Admin endpoint security
443
445
  if (
444
446
  // This is an admin endpoint
@@ -467,7 +469,7 @@ const genRouteHandler = (
467
469
  * Log an event on the server
468
470
  * @author Gabe Abrams
469
471
  */
470
- const logServerEvent: LogFunction = async (opts) => {
472
+ const logServerEvent: LogFunction = async (logOpts) => {
471
473
  // NOTE: internally, we slip through an opts.overrideAsClientEvent boolean
472
474
  // that indicates that this is actually a client event, but we don't
473
475
  // include that in the LogFunction type because this is internal and
@@ -510,20 +512,20 @@ const genRouteHandler = (
510
512
  minute,
511
513
  timestamp,
512
514
  context: (
513
- typeof opts.context === 'string'
514
- ? opts.context
515
+ typeof logOpts.context === 'string'
516
+ ? logOpts.context
515
517
  : (
516
- ((opts.context as any) ?? {})._
518
+ ((logOpts.context as any) ?? {})._
517
519
  ?? LogBuiltInMetadata.Context.Uncategorized
518
520
  )
519
521
  ),
520
522
  subcontext: (
521
- opts.subcontext
523
+ logOpts.subcontext
522
524
  ?? LogBuiltInMetadata.Context.Uncategorized
523
525
  ),
524
- tags: (opts.tags ?? []),
525
- level: (opts.level ?? LogLevel.Info),
526
- metadata: (opts.metadata ?? {}),
526
+ tags: (logOpts.tags ?? []),
527
+ level: (logOpts.level ?? LogLevel.Info),
528
+ metadata: (logOpts.metadata ?? {}),
527
529
  };
528
530
 
529
531
  // Type-specific info
@@ -531,18 +533,18 @@ const genRouteHandler = (
531
533
  ('error' in opts && opts.error)
532
534
  ? {
533
535
  type: LogType.Error,
534
- errorMessage: opts.error.message ?? 'Unknown message',
535
- errorCode: opts.error.code ?? ReactKitErrorCode.NoCode,
536
- errorStack: opts.error.stack ?? 'No stack',
536
+ errorMessage: (logOpts as any).error.message ?? 'Unknown message',
537
+ errorCode: (logOpts as any).error.code ?? ReactKitErrorCode.NoCode,
538
+ errorStack: (logOpts as any).error.stack ?? 'No stack',
537
539
  }
538
540
  : {
539
541
  type: LogType.Action,
540
542
  target: (
541
- (opts as any).target
543
+ (logOpts as any).target
542
544
  ?? LogBuiltInMetadata.Target.NoTarget
543
545
  ),
544
546
  action: (
545
- (opts as any).action
547
+ (logOpts as any).action
546
548
  ?? LogAction.Unknown
547
549
  ),
548
550
  }
@@ -550,7 +552,7 @@ const genRouteHandler = (
550
552
 
551
553
  // Source-specific info
552
554
  const sourceSpecificInfo: LogSourceSpecificInfo = (
553
- (opts as any).overrideAsClientEvent
555
+ (logOpts as any).overrideAsClientEvent
554
556
  ? {
555
557
  source: LogSource.Client,
556
558
  }
@@ -573,21 +575,22 @@ const genRouteHandler = (
573
575
  if (logCollection) {
574
576
  // Store to the log collection
575
577
  await logCollection.insert(log);
576
- } else {
578
+ } else if (log.type === LogType.Error) {
577
579
  // Print to console
578
- if (log.type === LogType.Error) {
579
- console.error('dce-reactkit error log:', log);
580
- } else {
581
- console.log('dce-reactkit action log:', log);
582
- }
580
+ // eslint-disable-next-line no-console
581
+ console.error('dce-reactkit error log:', log);
582
+ } else {
583
+ // eslint-disable-next-line no-console
584
+ console.log('dce-reactkit action log:', log);
583
585
  }
584
586
 
585
587
  // Return log entry
586
588
  return log;
587
589
  } catch (err) {
588
590
  // Print because we cannot store the error
591
+ // eslint-disable-next-line no-console
589
592
  console.error('Could not log the following:', opts);
590
-
593
+
591
594
  // Create a dummy log to return
592
595
  const dummyMainInfo: LogMainInfo = {
593
596
  id: '-1',
@@ -620,7 +623,7 @@ const genRouteHandler = (
620
623
  context: LogBuiltInMetadata.Context.Uncategorized,
621
624
  subcontext: LogBuiltInMetadata.Context.Uncategorized,
622
625
  };
623
-
626
+
624
627
  const dummyTypeSpecificInfo: LogTypeSpecificInfo = {
625
628
  type: LogType.Error,
626
629
  errorMessage: 'Unknown',
@@ -675,17 +678,17 @@ const genRouteHandler = (
675
678
  /**
676
679
  * Render an error page
677
680
  * @author Gabe Abrams
678
- * @param opts object containing all arguments
679
- * @param [opts.title=An Error Occurred] title of the error box
680
- * @param [opts.description=An unknown server error occurred. Please contact support.]
681
+ * @param renderOpts object containing all arguments
682
+ * @param [renderOpts.title=An Error Occurred] title of the error box
683
+ * @param [renderOpts.description=An unknown server error occurred. Please contact support.]
681
684
  * a human-readable description of the error
682
- * @param [opts.code=ReactKitErrorCode.NoCode] error code to show
683
- * @param [opts.pageTitle=opts.title] title of the page/tab if it differs from
685
+ * @param [renderOpts.code=ReactKitErrorCode.NoCode] error code to show
686
+ * @param [renderOpts.pageTitle=renderOpts.title] title of the page/tab if it differs from
684
687
  * the title of the error
685
- * @param [opts.status=500] http status code
688
+ * @param [renderOpts.status=500] http status code
686
689
  */
687
690
  const renderErrorPage = (
688
- opts: {
691
+ renderOpts: {
689
692
  title?: string,
690
693
  description?: string,
691
694
  code?: string,
@@ -693,22 +696,22 @@ const genRouteHandler = (
693
696
  status?: number,
694
697
  } = {},
695
698
  ) => {
696
- const html = genErrorPage(opts);
697
- send(html, opts.status ?? 500);
699
+ const html = genErrorPage(renderOpts);
700
+ send(html, renderOpts.status ?? 500);
698
701
 
699
702
  // Log
700
703
  logServerEvent({
701
704
  context: LogBuiltInMetadata.Context.ServerRenderedErrorPage,
702
705
  error: {
703
- message: `${opts.title}: ${opts.description}`,
704
- code: opts.code,
706
+ message: `${renderOpts.title}: ${renderOpts.description}`,
707
+ code: renderOpts.code,
705
708
  },
706
709
  metadata: {
707
- title: opts.title,
708
- description: opts.description,
709
- code: opts.code,
710
- pageTitle: opts.pageTitle,
711
- status: opts.status ?? 500,
710
+ title: renderOpts.title,
711
+ description: renderOpts.description,
712
+ code: renderOpts.code,
713
+ pageTitle: renderOpts.pageTitle,
714
+ status: renderOpts.status ?? 500,
712
715
  },
713
716
  });
714
717
  };
@@ -747,6 +750,7 @@ const genRouteHandler = (
747
750
  }
748
751
 
749
752
  // Log error that was not responded with
753
+ // eslint-disable-next-line no-console
750
754
  console.log('Error occurred but could not be sent to client because a response was already sent:', err);
751
755
  }
752
756
  };
@@ -10,8 +10,9 @@ const urlRegex = /(https?:\/\/)?([a-z0-9-]+\.)+[a-z0-9]{2,6}(:[0-9]{1,5})?(\/\S*
10
10
  * @param text the text to process
11
11
  * @param [opts] options to customize behavior
12
12
  * @param [opts.newTab] if true, links will open in a new tab
13
- * @param [opts.preventPropagation] if true, clicks to link will prevent default
14
- * and propagation
13
+ * @param [opts.preventPropagation] if true, clicks to link will prevent
14
+ * propagation
15
+ * @param [opts.inheritColor] if true, inherit text color for links
15
16
  * @returns the processed text
16
17
  */
17
18
  const makeLinksClickable = (
@@ -19,6 +20,7 @@ const makeLinksClickable = (
19
20
  opts?: {
20
21
  newTab?: boolean,
21
22
  preventPropagation?: boolean,
23
+ inheritColor?: boolean,
22
24
  },
23
25
  ): React.ReactNode => {
24
26
  // Search text for links
@@ -61,11 +63,11 @@ const makeLinksClickable = (
61
63
  rel={newTab ? 'noopener noreferrer' : undefined}
62
64
  style={{
63
65
  textDecoration: 'underline',
66
+ color: opts?.inheritColor ? 'inherit' : undefined,
64
67
  }}
65
68
  onClick={(e) => {
66
- // Prevent default and propagation if requested
69
+ // Prevent propagation if requested
67
70
  if (opts?.preventPropagation) {
68
- e.preventDefault();
69
71
  e.stopPropagation();
70
72
  }
71
73
  }}