dce-reactkit 3.9.0-beta-loading-modal.2 → 3.9.0-beta-loading-modal.3

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 (62) hide show
  1. package/dist/cjs/index.js +783 -201
  2. package/dist/cjs/index.js.map +1 -1
  3. package/dist/cjs/types/client/initClient.d.ts +16 -2
  4. package/dist/cjs/types/components/AppWrapper.d.ts +32 -0
  5. package/dist/cjs/types/components/CheckboxButton.d.ts +1 -0
  6. package/dist/cjs/types/components/Dropdown.d.ts +32 -0
  7. package/dist/cjs/types/components/RadioButton.d.ts +2 -0
  8. package/dist/cjs/types/helpers/genRouteHandler.d.ts +8 -0
  9. package/dist/cjs/types/helpers/validators/ChicagoTitleCase.d.ts +9 -0
  10. package/dist/cjs/types/helpers/validators/validURL.d.ts +8 -0
  11. package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/index.d.ts +24 -0
  12. package/dist/cjs/types/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +33 -0
  13. package/dist/cjs/types/index.d.ts +5 -2
  14. package/dist/cjs/types/types/DropdownItemType.d.ts +6 -0
  15. package/dist/cjs/types/types/ModalType.d.ts +1 -0
  16. package/dist/cjs/types/types/ReactKitErrorCode.d.ts +6 -1
  17. package/dist/esm/index.js +779 -202
  18. package/dist/esm/index.js.map +1 -1
  19. package/dist/esm/types/client/initClient.d.ts +16 -2
  20. package/dist/esm/types/components/AppWrapper.d.ts +32 -0
  21. package/dist/esm/types/components/CheckboxButton.d.ts +1 -0
  22. package/dist/esm/types/components/Dropdown.d.ts +32 -0
  23. package/dist/esm/types/components/RadioButton.d.ts +2 -0
  24. package/dist/esm/types/helpers/genRouteHandler.d.ts +8 -0
  25. package/dist/esm/types/helpers/validators/ChicagoTitleCase.d.ts +9 -0
  26. package/dist/esm/types/helpers/validators/validURL.d.ts +8 -0
  27. package/dist/esm/types/helpers/visitEndpointOnAnotherServer/index.d.ts +24 -0
  28. package/dist/esm/types/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.d.ts +33 -0
  29. package/dist/esm/types/index.d.ts +5 -2
  30. package/dist/esm/types/types/DropdownItemType.d.ts +6 -0
  31. package/dist/esm/types/types/ModalType.d.ts +1 -0
  32. package/dist/esm/types/types/ReactKitErrorCode.d.ts +6 -1
  33. package/dist/index.d.ts +163 -46
  34. package/package.json +2 -1
  35. package/src/client/initClient.tsx +49 -11
  36. package/src/components/AppWrapper.tsx +258 -2
  37. package/src/components/CheckboxButton.tsx +24 -6
  38. package/src/components/Dropdown.tsx +317 -0
  39. package/src/components/IntelliTable.tsx +1 -1
  40. package/src/components/ItemPicker/NestableItemList.tsx +1 -0
  41. package/src/components/LogReviewer.tsx +17 -4
  42. package/src/components/Modal/index.tsx +4 -1
  43. package/src/components/MultiSwitch.tsx +1 -1
  44. package/src/components/RadioButton.tsx +33 -6
  45. package/src/components/SimpleDateChooser.tsx +8 -2
  46. package/src/helpers/genRouteHandler.ts +116 -17
  47. package/src/helpers/logClientEvent.tsx +8 -0
  48. package/src/helpers/validators/ChicagoTitleCase.test.ts +85 -0
  49. package/src/helpers/validators/ChicagoTitleCase.ts +32 -0
  50. package/src/helpers/validators/findURL.test.ts +83 -0
  51. package/src/helpers/validators/findURL.ts +43 -0
  52. package/src/helpers/validators/validURL.test.ts +90 -0
  53. package/src/helpers/validators/validURL.ts +18 -0
  54. package/src/helpers/visitEndpointOnAnotherServer/index.ts +93 -0
  55. package/src/helpers/visitEndpointOnAnotherServer/sendServerToServerRequest.ts +164 -0
  56. package/src/helpers/visitServerEndpoint.tsx +1 -0
  57. package/src/index.ts +8 -0
  58. package/src/server/initLogCollection.ts +5 -0
  59. package/src/server/initServer.ts +11 -5
  60. package/src/types/DropdownItemType.ts +11 -0
  61. package/src/types/ModalType.tsx +1 -0
  62. package/src/types/ReactKitErrorCode.tsx +8 -1
package/dist/index.d.ts CHANGED
@@ -24,7 +24,7 @@ declare enum Variant {
24
24
  * @author Gabe Abrams
25
25
  */
26
26
 
27
- type Props$k = {
27
+ type Props$l = {
28
28
  children: React$1.ReactNode;
29
29
  };
30
30
  /**
@@ -63,6 +63,38 @@ declare const confirm: (title: string, text: string, opts?: {
63
63
  cancelButtonText?: string;
64
64
  cancelButtonVariant?: Variant;
65
65
  }) => Promise<boolean>;
66
+ /**
67
+ * Show a prompt modal asking the user for input
68
+ * @author Yuen Ler Chow
69
+ * @param title the title text to display at the top of the prompt
70
+ * @param [opts={}] additional options for the prompt dialog
71
+ * @param [opts.textAboveInputField] the text to display in the prompt
72
+ * @param [opts.defaultText] the default text for the input field
73
+ * @param [opts.placeholder] the placeholder text for the input field
74
+ * @param [opts.confirmButtonText=Okay] the text of the confirm button
75
+ * @param [opts.confirmButtonVariant=Variant.Dark] the variant of the confirm button
76
+ * @param [opts.cancelButtonText=Cancel] the text of the cancel button
77
+ * @param [opts.cancelButtonVariant=Variant.Secondary] the variant of the cancel button
78
+ * @param [opts.minNumChars] the minimum number of characters required for
79
+ * the input to be valid
80
+ * @param [opts.findValidationError] a function that takes the input text and
81
+ * returns an error message if the input is invalid, returns undefined if the
82
+ * input is valid
83
+ * @param [opts.ariaLabel] the aria label for the input field
84
+ * @returns Promise that resolves with the input string or null if canceled
85
+ */
86
+ declare const prompt: (title: string, opts?: {
87
+ textAboveInputField?: string | undefined;
88
+ defaultText?: string | undefined;
89
+ placeholder?: string | undefined;
90
+ confirmButtonText?: string | undefined;
91
+ confirmButtonVariant?: Variant | undefined;
92
+ cancelButtonText?: string | undefined;
93
+ cancelButtonVariant?: Variant | undefined;
94
+ minNumChars?: number | undefined;
95
+ findValidationError?: ((text: string) => string | undefined) | undefined;
96
+ ariaLabel?: string | undefined;
97
+ } | undefined) => Promise<string | null>;
66
98
  /**
67
99
  * Show a fatal error message
68
100
  * @author Gabe Abrams
@@ -75,7 +107,7 @@ declare const showFatalError: (error: any, errorTitle?: string) => Promise<void>
75
107
  * @author Gabe Abrams
76
108
  */
77
109
  declare const addFatalErrorHandler: (handler: () => void) => void;
78
- declare const AppWrapper: React$1.FC<Props$k>;
110
+ declare const AppWrapper: React$1.FC<Props$l>;
79
111
 
80
112
  /**
81
113
  * Loading spinner/indicator
@@ -88,14 +120,14 @@ declare const LoadingSpinner: () => JSX.Element;
88
120
  * @author Gabe Abrams
89
121
  */
90
122
 
91
- type Props$j = {
123
+ type Props$k = {
92
124
  error: any;
93
125
  title?: string;
94
126
  onClose?: () => void;
95
127
  variant?: Variant;
96
128
  icon?: IconProp;
97
129
  };
98
- declare const ErrorBox: React$1.FC<Props$j>;
130
+ declare const ErrorBox: React$1.FC<Props$k>;
99
131
 
100
132
  /**
101
133
  * Types of buttons in the modal
@@ -131,6 +163,7 @@ declare enum ModalSize {
131
163
  */
132
164
  declare enum ModalType {
133
165
  Okay = "okay",
166
+ Cancel = "cancel",
134
167
  OkayCancel = "okay-cancel",
135
168
  YesNo = "yes-no",
136
169
  YesNoCancel = "yes-no-cancel",
@@ -193,39 +226,41 @@ declare const Modal: React$1.FC<ModalProps>;
193
226
  * @author Gabe Abrams
194
227
  */
195
228
 
196
- type Props$i = {
229
+ type Props$j = {
197
230
  title: React$1.ReactNode;
198
231
  children: React$1.ReactNode;
199
232
  noBottomMargin?: boolean;
200
233
  noBottomPadding?: boolean;
201
234
  };
202
- declare const TabBox: React$1.FC<Props$i>;
235
+ declare const TabBox: React$1.FC<Props$j>;
203
236
 
204
237
  /**
205
238
  * A radio selection button
206
239
  * @author Gabe Abrams
207
240
  */
208
241
 
209
- type Props$h = {
242
+ type Props$i = {
210
243
  text: React$1.ReactNode;
211
244
  onSelected: () => void;
212
245
  ariaLabel: string;
213
246
  title?: string;
214
247
  selected?: boolean;
215
248
  id?: string;
249
+ className?: string;
216
250
  noMarginOnRight?: boolean;
217
251
  selectedVariant?: Variant;
218
252
  unselectedVariant?: Variant;
219
253
  small?: boolean;
254
+ useComplexFormatting?: boolean;
220
255
  };
221
- declare const RadioButton: React$1.FC<Props$h>;
256
+ declare const RadioButton: React$1.FC<Props$i>;
222
257
 
223
258
  /**
224
259
  * A checkbox button
225
260
  * @author Gabe Abrams
226
261
  */
227
262
 
228
- type Props$g = {
263
+ type Props$h = {
229
264
  text: React$1.ReactNode;
230
265
  onChanged: (checked: boolean) => void;
231
266
  ariaLabel: string;
@@ -238,15 +273,16 @@ type Props$g = {
238
273
  uncheckedVariant?: Variant;
239
274
  small?: boolean;
240
275
  dashed?: boolean;
276
+ useComplexFormatting?: boolean;
241
277
  };
242
- declare const CheckboxButton: React$1.FC<Props$g>;
278
+ declare const CheckboxButton: React$1.FC<Props$h>;
243
279
 
244
280
  /**
245
281
  * Input group with a title and space for buttons
246
282
  * @author Gabe Abrams
247
283
  */
248
284
 
249
- type Props$f = {
285
+ type Props$g = {
250
286
  label: React$1.ReactNode;
251
287
  minLabelWidth?: string;
252
288
  children: React$1.ReactNode;
@@ -255,14 +291,14 @@ type Props$f = {
255
291
  isAdminFeature?: boolean;
256
292
  noMarginOnBottom?: boolean;
257
293
  };
258
- declare const ButtonInputGroup: React$1.FC<Props$f>;
294
+ declare const ButtonInputGroup: React$1.FC<Props$g>;
259
295
 
260
296
  /**
261
297
  * A very simple, lightweight date chooser
262
298
  * @author Gabe Abrams
263
299
  */
264
300
 
265
- type Props$e = {
301
+ type Props$f = {
266
302
  ariaLabel: string;
267
303
  name: string;
268
304
  month: number;
@@ -278,62 +314,62 @@ type Props$e = {
278
314
  numMonthsToShow?: number;
279
315
  chooseFromPast?: boolean;
280
316
  };
281
- declare const SimpleDateChooser: React$1.FC<Props$e>;
317
+ declare const SimpleDateChooser: React$1.FC<Props$f>;
282
318
 
283
319
  /**
284
320
  * Drawer container
285
321
  * @author Gabe Abrams
286
322
  */
287
323
 
288
- type Props$d = {
324
+ type Props$e = {
289
325
  grayBackground?: boolean;
290
326
  customBackgroundColor?: string;
291
327
  children: React$1.ReactNode;
292
328
  };
293
- declare const Drawer: React$1.FC<Props$d>;
329
+ declare const Drawer: React$1.FC<Props$e>;
294
330
 
295
331
  /**
296
332
  * Success checkmark that pops into view
297
333
  * @author Gabe Abrams
298
334
  */
299
335
 
300
- type Props$c = {
336
+ type Props$d = {
301
337
  sizeRem?: number;
302
338
  circleVariant?: string;
303
339
  checkVariant?: string;
304
340
  };
305
- declare const PopSuccessMark: React$1.FC<Props$c>;
341
+ declare const PopSuccessMark: React$1.FC<Props$d>;
306
342
 
307
343
  /**
308
344
  * Failure x mark that pops into view
309
345
  * @author Gabe Abrams
310
346
  */
311
347
 
312
- type Props$b = {
348
+ type Props$c = {
313
349
  sizeRem?: number;
314
350
  circleVariant?: string;
315
351
  xVariant?: string;
316
352
  };
317
- declare const PopFailureMark: React$1.FC<Props$b>;
353
+ declare const PopFailureMark: React$1.FC<Props$c>;
318
354
 
319
355
  /**
320
356
  * Failure pending that pops into view
321
357
  * @author Gabe Abrams
322
358
  */
323
359
 
324
- type Props$a = {
360
+ type Props$b = {
325
361
  sizeRem?: number;
326
362
  circleVariant?: string;
327
363
  hourglassVariant?: string;
328
364
  };
329
- declare const PopPendingMark: React$1.FC<Props$a>;
365
+ declare const PopPendingMark: React$1.FC<Props$b>;
330
366
 
331
367
  /**
332
368
  * Copiable text box
333
369
  * @author Gabe Abrams
334
370
  */
335
371
 
336
- type Props$9 = {
372
+ type Props$a = {
337
373
  text: string;
338
374
  maxTextWidthRem?: number;
339
375
  label?: string;
@@ -345,7 +381,7 @@ type Props$9 = {
345
381
  textAreaId?: string;
346
382
  copyButtonId?: string;
347
383
  };
348
- declare const CopiableBox: React$1.FC<Props$9>;
384
+ declare const CopiableBox: React$1.FC<Props$a>;
349
385
 
350
386
  /**
351
387
  * An item that can be chosen (for use within ItemPicker)
@@ -368,7 +404,7 @@ type PickableItem = ({
368
404
  * @author Yuen Ler Chow
369
405
  */
370
406
 
371
- type Props$8 = {
407
+ type Props$9 = {
372
408
  title: string;
373
409
  items: PickableItem[];
374
410
  /**
@@ -379,7 +415,7 @@ type Props$8 = {
379
415
  onChanged: (updatedItems: PickableItem[]) => void;
380
416
  noBottomMargin?: boolean;
381
417
  };
382
- declare const ItemPicker: React$1.FC<Props$8>;
418
+ declare const ItemPicker: React$1.FC<Props$9>;
383
419
 
384
420
  /**
385
421
  * Type of the context map in a LogMetadata file
@@ -424,11 +460,11 @@ type LogMetadataType = {
424
460
  * @author Gabe Abrams
425
461
  */
426
462
 
427
- type Props$7 = {
463
+ type Props$8 = {
428
464
  LogMetadata: LogMetadataType;
429
465
  onClose: () => void;
430
466
  };
431
- declare const LogReviewer: React$1.FC<Props$7>;
467
+ declare const LogReviewer: React$1.FC<Props$8>;
432
468
 
433
469
  /**
434
470
  * Server-side API param types
@@ -463,7 +499,7 @@ type IntelliTableColumn = {
463
499
  * @author Gabe Abrams
464
500
  */
465
501
 
466
- type Props$6 = {
502
+ type Props$7 = {
467
503
  title: string;
468
504
  id: string;
469
505
  data: {
@@ -473,14 +509,14 @@ type Props$6 = {
473
509
  columns: IntelliTableColumn[];
474
510
  csvName?: string;
475
511
  };
476
- declare const IntelliTable: React$1.FC<Props$6>;
512
+ declare const IntelliTable: React$1.FC<Props$7>;
477
513
 
478
514
  /**
479
515
  * Button for downloading a csv file
480
516
  * @author Gabe Abrams
481
517
  */
482
518
 
483
- type Props$5 = {
519
+ type Props$6 = {
484
520
  filename: string;
485
521
  csv: string;
486
522
  id?: string;
@@ -492,7 +528,7 @@ type Props$5 = {
492
528
  onClick?: () => void;
493
529
  children?: React$1.ReactNode;
494
530
  };
495
- declare const CSVDownloadButton: React$1.FC<Props$5>;
531
+ declare const CSVDownloadButton: React$1.FC<Props$6>;
496
532
 
497
533
  /**
498
534
  * Generic type for an object
@@ -568,7 +604,7 @@ type DBEntryField = ({
568
604
  * @author Gabe Abrams
569
605
  */
570
606
 
571
- type Props$4 = {
607
+ type Props$5 = {
572
608
  entryFields: DBEntryField[];
573
609
  idPropName: string;
574
610
  titlePropName: string;
@@ -594,18 +630,18 @@ type Props$4 = {
594
630
  [k: string]: any;
595
631
  };
596
632
  };
597
- declare const DBEntryManagerPanel: React$1.FC<Props$4>;
633
+ declare const DBEntryManagerPanel: React$1.FC<Props$5>;
598
634
 
599
635
  /**
600
636
  * Simple tooltip component
601
637
  * @author Gabe Abrams
602
638
  */
603
639
 
604
- type Props$3 = {
640
+ type Props$4 = {
605
641
  text: string;
606
642
  children: JSX.Element;
607
643
  };
608
- declare const Tooltip: React$1.FC<Props$3>;
644
+ declare const Tooltip: React$1.FC<Props$4>;
609
645
 
610
646
  /**
611
647
  * A toggle switch that toggles on or off
@@ -613,7 +649,7 @@ declare const Tooltip: React$1.FC<Props$3>;
613
649
  * @author Gabe Abrams
614
650
  */
615
651
 
616
- type Props$2 = {
652
+ type Props$3 = {
617
653
  isOn: boolean;
618
654
  /**
619
655
  * A handler to call when the switch is toggled
@@ -625,7 +661,7 @@ type Props$2 = {
625
661
  description: string;
626
662
  backgroundVariantWhenOn?: Variant;
627
663
  };
628
- declare const ToggleSwitch: React$1.FC<Props$2>;
664
+ declare const ToggleSwitch: React$1.FC<Props$3>;
629
665
 
630
666
  /**
631
667
  * Container that automatically scrolls when new items are added,
@@ -636,7 +672,7 @@ declare const ToggleSwitch: React$1.FC<Props$2>;
636
672
  * @author Gabe Abrams
637
673
  */
638
674
 
639
- type Props$1 = {
675
+ type Props$2 = {
640
676
  itemsName?: string;
641
677
  items: AutoScrollItem[];
642
678
  jumpToBottomButtonVariant?: Variant;
@@ -647,7 +683,7 @@ type AutoScrollItem = {
647
683
  id: string | number;
648
684
  item: React$1.ReactNode;
649
685
  };
650
- declare const AutoscrollToBottomContainer: React$1.FC<Props$1>;
686
+ declare const AutoscrollToBottomContainer: React$1.FC<Props$2>;
651
687
 
652
688
  /**
653
689
  * A switch with multiple options for selection
@@ -656,7 +692,7 @@ declare const AutoscrollToBottomContainer: React$1.FC<Props$1>;
656
692
  * @author Austen Money
657
693
  */
658
694
 
659
- type Props = {
695
+ type Props$1 = {
660
696
  options: Option[];
661
697
  selectedOptionId: string;
662
698
  /**
@@ -671,7 +707,43 @@ type Option = {
671
707
  icon: IconProp;
672
708
  id: string;
673
709
  };
674
- declare const MultiSwitch: React$1.FC<Props>;
710
+ declare const MultiSwitch: React$1.FC<Props$1>;
711
+
712
+ declare enum DropdownItemType {
713
+ Header = "Header",
714
+ Divider = "Divider",
715
+ Item = "Item"
716
+ }
717
+
718
+ /**
719
+ * A simple dropdown menu
720
+ * @author Alessandra De Lucas
721
+ * @author Yuen Ler Chow
722
+ * @author Gabe Abrams
723
+ */
724
+
725
+ type Props = {
726
+ items: DropdownItem[];
727
+ dropdownButton: {
728
+ ariaLabel: string;
729
+ id: string;
730
+ content?: React$1.ReactNode;
731
+ variant?: Variant;
732
+ };
733
+ };
734
+ type DropdownItem = ({
735
+ type: DropdownItemType.Header;
736
+ content: React$1.ReactNode;
737
+ } | {
738
+ type: DropdownItemType.Divider;
739
+ } | {
740
+ type: DropdownItemType.Item;
741
+ content: React$1.ReactNode;
742
+ ariaLabel: string;
743
+ id: string;
744
+ onClick: () => void;
745
+ });
746
+ declare const Dropdown: React$1.FC<Props>;
675
747
 
676
748
  /**
677
749
  * An error with a code
@@ -740,12 +812,20 @@ type SendRequestFunction = (opts: {
740
812
  * @param opts object containing all arguments
741
813
  * @param opts.sendRequest caccl send request functions
742
814
  * @param [opts.sessionExpiredMessage] a custom session expired message
815
+ * @param [opts.darkModeOn] if true, dark mode is enabled
816
+ * @param [opts.noServer] if true, there is no server for this app
743
817
  */
744
- declare const initClient: (opts: {
818
+ declare const initClient: (opts: ({
745
819
  sendRequest: SendRequestFunction;
746
820
  sessionExpiredMessage?: string;
747
821
  darkModeOn?: boolean;
748
- }) => void;
822
+ noServer?: false;
823
+ } | {
824
+ darkModeOn?: boolean;
825
+ noServer: true;
826
+ sendRequest?: undefined;
827
+ sessionExpiredMessage?: undefined;
828
+ })) => void;
749
829
 
750
830
  /**
751
831
  * Shorten text so it fits into a certain number of chars
@@ -1010,6 +1090,12 @@ type LogFunction = (opts: ({
1010
1090
  * @param opts.handler function that processes the request
1011
1091
  * @param [opts.skipSessionCheck] if true, skip the session check (allow users
1012
1092
  * to not be logged in and launched via LTI)
1093
+ * @param [opts.allowedHosts] if included, only allow requests from these hosts
1094
+ * (start a hostname with a "*" to only check the end of the hostname)
1095
+ * you can include just one string instead of an array
1096
+ * @param [opts.bannedHosts] if included, do not allow requests from these hosts
1097
+ * (start a hostname with a "*" to only check the end of the hostname)
1098
+ * you can include just one string instead of an array
1013
1099
  * @param [opts.unhandledErrorMessagePrefix] if included, when an error that
1014
1100
  * is not of type ErrorWithCode is thrown, the client will receive an error
1015
1101
  * where the error message is prefixed with this string. For example,
@@ -1064,6 +1150,8 @@ declare const genRouteHandler: (opts: {
1064
1150
  logServerEvent: LogFunction;
1065
1151
  }) => any;
1066
1152
  skipSessionCheck?: boolean | undefined;
1153
+ allowedHosts?: string | string[] | undefined;
1154
+ bannedHosts?: string | string[] | undefined;
1067
1155
  unhandledErrorMessagePrefix?: string | undefined;
1068
1156
  }) => (req: any, res: any, next: () => void) => Promise<undefined>;
1069
1157
 
@@ -1569,6 +1657,30 @@ declare const capitalize: (str: string) => string;
1569
1657
  */
1570
1658
  declare const shuffleArray: <T>(arr: T[]) => T[];
1571
1659
 
1660
+ /**
1661
+ * Send a server-to-server request from this sever to another server that uses
1662
+ * dce-reactkit [for server only]
1663
+ * @author Gabe Abrams
1664
+ * @param opts object containing all arguments
1665
+ * @param opts.host - the host of the other server
1666
+ * @param opts.path - the path of the other server's endpoint
1667
+ * @param [opts.method=GET] - the method of the endpoint
1668
+ * @param [opts.params] - query/body parameters to include
1669
+ * @param [opts.headers] - headers to include
1670
+ * @returns response from server
1671
+ */
1672
+ declare const visitEndpointOnAnotherServer: (opts: {
1673
+ host: string;
1674
+ path: string;
1675
+ method?: "GET" | "POST" | "DELETE" | "PUT" | undefined;
1676
+ params?: {
1677
+ [x: string]: any;
1678
+ } | undefined;
1679
+ headers?: {
1680
+ [x: string]: any;
1681
+ } | undefined;
1682
+ }) => Promise<any>;
1683
+
1572
1684
  /**
1573
1685
  * List of error codes built into the react kit
1574
1686
  * @author Gabe Abrams
@@ -1579,6 +1691,8 @@ declare enum ReactKitErrorCode {
1579
1691
  SessionExpired = "DRK3",
1580
1692
  MissingParameter = "DRK4",
1581
1693
  InvalidParameter = "DRK5",
1694
+ HostNotAllowed = "DRK17",
1695
+ HostBanned = "DRK18",
1582
1696
  WrongCourse = "DRK6",
1583
1697
  NoCACCLSendRequestFunction = "DRK7",
1584
1698
  NoCACCLGetLaunchInfoFunction = "DRK8",
@@ -1586,7 +1700,10 @@ declare enum ReactKitErrorCode {
1586
1700
  NotAdmin = "DRK10",
1587
1701
  NotAllowedToReviewLogs = "DRK11",
1588
1702
  ThemeCheckedBeforeReactKitReady = "DRK12",
1589
- SessionExpiredMessageGottenBeforeReactKitReady = "DRK13"
1703
+ SessionExpiredMessageGottenBeforeReactKitReady = "DRK13",
1704
+ NotConnected = "DRK14",
1705
+ SelfSigned = "DRK15",
1706
+ ResponseParseError = "DRK16"
1590
1707
  }
1591
1708
 
1592
1709
  /**
@@ -1619,4 +1736,4 @@ declare const LogBuiltInMetadata: {
1619
1736
  };
1620
1737
  };
1621
1738
 
1622
- export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, DayOfWeek, Drawer, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogFunction, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, MultiSwitch, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert, avg, canReviewLogs, capitalize, ceilToNumDecimals, combineClassNames, compareArraysByProp, confirm, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
1739
+ export { AppWrapper, AutoscrollToBottomContainer, ButtonInputGroup, CSVDownloadButton, CheckboxButton, CopiableBox, DAY_IN_MS, DBEntry, DBEntryField, DBEntryFieldType, DBEntryManagerPanel, DayOfWeek, Drawer, Dropdown, DropdownItemType, DynamicWord, ErrorBox, ErrorWithCode, HOUR_IN_MS, IntelliTable, IntelliTableColumn, ItemPicker, LoadingSpinner, Log, LogAction, LogBuiltInMetadata, LogFunction, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, MultiSwitch, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert, avg, canReviewLogs, capitalize, ceilToNumDecimals, combineClassNames, compareArraysByProp, confirm, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, prompt, roundToNumDecimals, setClientEventMetadataPopulator, showFatalError, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, useForceRender, validateEmail, validatePhoneNumber, validateString, visitEndpointOnAnotherServer, visitServerEndpoint, waitMs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.9.0-beta-loading-modal.2",
3
+ "version": "3.9.0-beta-loading-modal.3",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -24,6 +24,7 @@
24
24
  },
25
25
  "homepage": "https://github.com/harvard-edtech/dce-reactkit#readme",
26
26
  "dependencies": {
27
+ "qs": "^6.x.x",
27
28
  "react-select": "^5.7.3"
28
29
  },
29
30
  "peerDependencies": {
@@ -47,6 +47,18 @@ const initialized = new Promise((resolve) => {
47
47
  onInitialized = resolve;
48
48
  });
49
49
 
50
+ /* ------------ No Server ----------- */
51
+
52
+ let noServer = false;
53
+
54
+ /**
55
+ * Check if there is no server for this app
56
+ * @author Gabe Abrams
57
+ */
58
+ export const appHasNoServer = () => {
59
+ return noServer;
60
+ };
61
+
50
62
  /* ---------- Send Request ---------- */
51
63
 
52
64
  let storedSendRequest: SendRequestFunction;
@@ -119,20 +131,46 @@ export const isDarkModeOn = () => {
119
131
  * @param opts object containing all arguments
120
132
  * @param opts.sendRequest caccl send request functions
121
133
  * @param [opts.sessionExpiredMessage] a custom session expired message
134
+ * @param [opts.darkModeOn] if true, dark mode is enabled
135
+ * @param [opts.noServer] if true, there is no server for this app
122
136
  */
123
137
  const initClient = (
124
- opts: {
125
- // Copy of CACCL's send request function
126
- sendRequest: SendRequestFunction,
127
- // Custom session expired message
128
- sessionExpiredMessage?: string,
129
- // If true, dark mode is enabled
130
- darkModeOn?: boolean,
131
- },
138
+ opts: (
139
+ | {
140
+ // Copy of CACCL's send request function
141
+ sendRequest: SendRequestFunction,
142
+ // Custom session expired message
143
+ sessionExpiredMessage?: string,
144
+ // If true, dark mode is enabled
145
+ darkModeOn?: boolean,
146
+ // If true, there is no server for this app
147
+ noServer?: false,
148
+ }
149
+ | {
150
+ // If true, dark mode is enabled
151
+ darkModeOn?: boolean,
152
+ // If true, there is no server for this app
153
+ noServer: true
154
+ // Copy of CACCL's send request function
155
+ sendRequest?: undefined,
156
+ // Custom session expired message
157
+ sessionExpiredMessage?: undefined,
158
+ }
159
+ ),
132
160
  ) => {
133
- // Store values
134
- storedSendRequest = opts.sendRequest;
135
- sessionExpiredMessage = opts.sessionExpiredMessage;
161
+ // Handle separately if there is no server
162
+ if (opts.noServer) {
163
+ // Store values
164
+ storedSendRequest = async () => {
165
+ throw new Error('Cannot send requests because there is no server');
166
+ };
167
+ } else {
168
+ // Store values
169
+ storedSendRequest = opts.sendRequest;
170
+ sessionExpiredMessage = opts.sessionExpiredMessage;
171
+ }
172
+
173
+ // Handle universal parts
136
174
  darkModeOn = !!opts.darkModeOn;
137
175
 
138
176
  // Mark as initialized