dce-reactkit 3.4.0-beta.8 → 3.4.0

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 (128) hide show
  1. package/.eslintrc.js +0 -2
  2. package/dist/cjs/index.js +190 -36371
  3. package/dist/cjs/index.js.map +1 -1
  4. package/dist/cjs/types/helpers/abbreviate.test.d.ts +5 -0
  5. package/dist/cjs/types/helpers/avg.test.d.ts +5 -0
  6. package/dist/cjs/types/helpers/canReviewLogs.d.ts +5 -0
  7. package/dist/cjs/types/helpers/canReviewLogs.test.d.ts +5 -0
  8. package/dist/cjs/types/helpers/ceilToNumDecimals.test.d.ts +5 -0
  9. package/dist/cjs/types/helpers/compareArraysByProp.test.d.ts +5 -0
  10. package/dist/cjs/types/helpers/extractProp.test.d.ts +5 -0
  11. package/dist/cjs/types/helpers/floorToNumDecimals.test.d.ts +5 -0
  12. package/dist/cjs/types/helpers/forceNumIntoBounds.test.d.ts +5 -0
  13. package/dist/cjs/types/helpers/genCSV.test.d.ts +5 -0
  14. package/dist/cjs/types/helpers/genCommaList.d.ts +12 -0
  15. package/dist/cjs/types/helpers/genCommaList.test.d.ts +1 -0
  16. package/dist/cjs/types/helpers/getHumanReadableDate.test.d.ts +5 -0
  17. package/dist/cjs/types/helpers/getLocalTimeInfo.test.d.ts +6 -0
  18. package/dist/cjs/types/helpers/getMonthName.test.d.ts +5 -0
  19. package/dist/cjs/types/helpers/getOrdinal.test.d.ts +5 -0
  20. package/dist/cjs/types/helpers/getPartOfDay.test.d.ts +5 -0
  21. package/dist/cjs/types/helpers/getTimeInfoInET.test.d.ts +5 -0
  22. package/dist/cjs/types/helpers/validators/shared/constants/ERROR_MESSAGES.d.ts +10 -0
  23. package/dist/cjs/types/helpers/validators/shared/helpers/validateRegex.d.ts +19 -0
  24. package/dist/cjs/types/helpers/validators/shared/types/ValidationResult.d.ts +12 -0
  25. package/dist/cjs/types/helpers/validators/validateEmail.d.ts +11 -0
  26. package/dist/cjs/types/helpers/validators/validateEmail.test.d.ts +1 -0
  27. package/dist/cjs/types/helpers/validators/validatePhoneNumber.d.ts +11 -0
  28. package/dist/cjs/types/helpers/validators/validatePhoneNumber.test.d.ts +1 -0
  29. package/dist/cjs/types/helpers/validators/validateString.d.ts +22 -0
  30. package/dist/cjs/types/helpers/validators/validateString.test.d.ts +1 -0
  31. package/dist/cjs/types/index.d.ts +1 -6
  32. package/dist/esm/index.js +419 -36579
  33. package/dist/esm/index.js.map +1 -1
  34. package/dist/esm/types/helpers/abbreviate.test.d.ts +5 -0
  35. package/dist/esm/types/helpers/avg.test.d.ts +5 -0
  36. package/dist/esm/types/helpers/canReviewLogs.d.ts +5 -0
  37. package/dist/esm/types/helpers/canReviewLogs.test.d.ts +5 -0
  38. package/dist/esm/types/helpers/ceilToNumDecimals.test.d.ts +5 -0
  39. package/dist/esm/types/helpers/compareArraysByProp.test.d.ts +5 -0
  40. package/dist/esm/types/helpers/extractProp.test.d.ts +5 -0
  41. package/dist/esm/types/helpers/floorToNumDecimals.test.d.ts +5 -0
  42. package/dist/esm/types/helpers/forceNumIntoBounds.test.d.ts +5 -0
  43. package/dist/esm/types/helpers/genCSV.test.d.ts +5 -0
  44. package/dist/esm/types/helpers/genCommaList.d.ts +12 -0
  45. package/dist/esm/types/helpers/genCommaList.test.d.ts +1 -0
  46. package/dist/esm/types/helpers/getHumanReadableDate.test.d.ts +5 -0
  47. package/dist/esm/types/helpers/getLocalTimeInfo.test.d.ts +6 -0
  48. package/dist/esm/types/helpers/getMonthName.test.d.ts +5 -0
  49. package/dist/esm/types/helpers/getOrdinal.test.d.ts +5 -0
  50. package/dist/esm/types/helpers/getPartOfDay.test.d.ts +5 -0
  51. package/dist/esm/types/helpers/getTimeInfoInET.test.d.ts +5 -0
  52. package/dist/esm/types/helpers/validators/shared/constants/ERROR_MESSAGES.d.ts +10 -0
  53. package/dist/esm/types/helpers/validators/shared/helpers/validateRegex.d.ts +19 -0
  54. package/dist/esm/types/helpers/validators/shared/types/ValidationResult.d.ts +12 -0
  55. package/dist/esm/types/helpers/validators/validateEmail.d.ts +11 -0
  56. package/dist/esm/types/helpers/validators/validateEmail.test.d.ts +1 -0
  57. package/dist/esm/types/helpers/validators/validatePhoneNumber.d.ts +11 -0
  58. package/dist/esm/types/helpers/validators/validatePhoneNumber.test.d.ts +1 -0
  59. package/dist/esm/types/helpers/validators/validateString.d.ts +22 -0
  60. package/dist/esm/types/helpers/validators/validateString.test.d.ts +1 -0
  61. package/dist/esm/types/index.d.ts +1 -6
  62. package/dist/index.d.ts +35 -166
  63. package/package.json +13 -17
  64. package/src/client/initClient.tsx +20 -12
  65. package/src/components/AppWrapper.tsx +1 -1
  66. package/src/components/ItemPicker/index.test.tsx +10 -10
  67. package/src/helpers/abbreviate.test.ts +26 -0
  68. package/src/helpers/avg.test.ts +24 -0
  69. package/src/helpers/canReviewLogs.test.ts +67 -0
  70. package/src/helpers/canReviewLogs.ts +20 -0
  71. package/src/helpers/ceilToNumDecimals.test.ts +39 -0
  72. package/src/helpers/compareArraysByProp.test.ts +102 -0
  73. package/src/helpers/extractProp.test.ts +34 -0
  74. package/src/helpers/floorToNumDecimals.test.ts +39 -0
  75. package/src/helpers/forceNumIntoBounds.test.ts +34 -0
  76. package/src/helpers/genCSV.test.ts +61 -0
  77. package/src/helpers/genCSV.ts +5 -2
  78. package/src/helpers/genCommaList.test.ts +57 -0
  79. package/src/helpers/genCommaList.ts +21 -0
  80. package/src/helpers/getHumanReadableDate.test.ts +29 -0
  81. package/src/helpers/getLocalTimeInfo.test.ts +48 -0
  82. package/src/helpers/getMonthName.test.ts +79 -0
  83. package/src/helpers/getOrdinal.test.ts +84 -0
  84. package/src/helpers/{getOrdinal.tsx → getOrdinal.ts} +1 -0
  85. package/src/helpers/getPartOfDay.test.ts +56 -0
  86. package/src/helpers/getTimeInfoInET.test.ts +72 -0
  87. package/src/helpers/validators/shared/constants/ERROR_MESSAGES.ts +18 -0
  88. package/src/helpers/validators/shared/helpers/validateRegex.ts +47 -0
  89. package/src/helpers/validators/shared/types/ValidationResult.ts +20 -0
  90. package/src/helpers/validators/validateEmail.test.ts +110 -0
  91. package/src/helpers/validators/validateEmail.ts +47 -0
  92. package/src/helpers/validators/validatePhoneNumber.test.ts +94 -0
  93. package/src/helpers/validators/validatePhoneNumber.ts +49 -0
  94. package/src/helpers/validators/validateString.test.ts +175 -0
  95. package/src/helpers/validators/validateString.ts +171 -0
  96. package/src/index.ts +10 -12
  97. package/tsconfig.json +6 -2
  98. package/dist/cjs/types/components/DBEntryManagerPanel/AddOrEditDBEntry/CreatableMultiselect.d.ts +0 -10
  99. package/dist/cjs/types/components/DBEntryManagerPanel/AddOrEditDBEntry/index.d.ts +0 -34
  100. package/dist/cjs/types/components/DBEntryManagerPanel/helpers/generateEndpointPath.d.ts +0 -9
  101. package/dist/cjs/types/components/DBEntryManagerPanel/index.d.ts +0 -25
  102. package/dist/cjs/types/components/DBEntryManagerPanel/types/DBEntry.d.ts +0 -8
  103. package/dist/cjs/types/components/DBEntryManagerPanel/types/DBEntryField.d.ts +0 -49
  104. package/dist/cjs/types/components/DBEntryManagerPanel/types/DBEntryFieldType.d.ts +0 -12
  105. package/dist/cjs/types/helpers/addDBEditorEndpoints.d.ts +0 -40
  106. package/dist/esm/types/components/DBEntryManagerPanel/AddOrEditDBEntry/CreatableMultiselect.d.ts +0 -10
  107. package/dist/esm/types/components/DBEntryManagerPanel/AddOrEditDBEntry/index.d.ts +0 -34
  108. package/dist/esm/types/components/DBEntryManagerPanel/helpers/generateEndpointPath.d.ts +0 -9
  109. package/dist/esm/types/components/DBEntryManagerPanel/index.d.ts +0 -25
  110. package/dist/esm/types/components/DBEntryManagerPanel/types/DBEntry.d.ts +0 -8
  111. package/dist/esm/types/components/DBEntryManagerPanel/types/DBEntryField.d.ts +0 -49
  112. package/dist/esm/types/components/DBEntryManagerPanel/types/DBEntryFieldType.d.ts +0 -12
  113. package/dist/esm/types/helpers/addDBEditorEndpoints.d.ts +0 -40
  114. package/src/components/DBEntryManagerPanel/AddOrEditDBEntry/CreatableMultiselect.tsx +0 -286
  115. package/src/components/DBEntryManagerPanel/AddOrEditDBEntry/index.tsx +0 -722
  116. package/src/components/DBEntryManagerPanel/helpers/generateEndpointPath.ts +0 -15
  117. package/src/components/DBEntryManagerPanel/index.tsx +0 -511
  118. package/src/components/DBEntryManagerPanel/types/DBEntry.ts +0 -7
  119. package/src/components/DBEntryManagerPanel/types/DBEntryField.ts +0 -94
  120. package/src/components/DBEntryManagerPanel/types/DBEntryFieldType.ts +0 -18
  121. package/src/helpers/addDBEditorEndpoints.ts +0 -124
  122. /package/src/helpers/{abbreviate.tsx → abbreviate.ts} +0 -0
  123. /package/src/helpers/{avg.tsx → avg.ts} +0 -0
  124. /package/src/helpers/{ceilToNumDecimals.tsx → ceilToNumDecimals.ts} +0 -0
  125. /package/src/helpers/{floorToNumDecimals.tsx → floorToNumDecimals.ts} +0 -0
  126. /package/src/helpers/{forceNumIntoBounds.tsx → forceNumIntoBounds.ts} +0 -0
  127. /package/src/helpers/{getLocalTimeInfo.tsx → getLocalTimeInfo.ts} +0 -0
  128. /package/src/helpers/{getTimeInfoInET.tsx → getTimeInfoInET.ts} +0 -0
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import React from 'react';
3
- import express from 'express';
4
3
 
5
4
  /**
6
5
  * Bootstrap variants
@@ -23,7 +22,7 @@ declare enum Variant {
23
22
  * @author Gabe Abrams
24
23
  */
25
24
 
26
- declare type Props$h = {
25
+ declare type Props$g = {
27
26
  children: React.ReactNode;
28
27
  dark?: boolean;
29
28
  };
@@ -62,7 +61,7 @@ declare const confirm: (title: string, text: string, opts?: {
62
61
  * @param [errorTitle] title of the error box
63
62
  */
64
63
  declare const showFatalError: (error: any, errorTitle?: string) => undefined;
65
- declare const AppWrapper: React.FC<Props$h>;
64
+ declare const AppWrapper: React.FC<Props$g>;
66
65
 
67
66
  /**
68
67
  * Loading spinner/indicator
@@ -75,12 +74,12 @@ declare const LoadingSpinner: () => JSX.Element;
75
74
  * @author Gabe Abrams
76
75
  */
77
76
 
78
- declare type Props$g = {
77
+ declare type Props$f = {
79
78
  error: any;
80
79
  title?: string;
81
80
  onClose?: () => void;
82
81
  };
83
- declare const ErrorBox: React.FC<Props$g>;
82
+ declare const ErrorBox: React.FC<Props$f>;
84
83
 
85
84
  /**
86
85
  * Types of buttons in the modal
@@ -131,7 +130,7 @@ declare enum ModalType {
131
130
  * @author Gabe Abrams
132
131
  */
133
132
 
134
- declare type Props$f = {
133
+ declare type Props$e = {
135
134
  type?: ModalType;
136
135
  size?: ModalSize;
137
136
  title?: React.ReactNode;
@@ -160,27 +159,27 @@ declare type Props$f = {
160
159
  confirmVariant?: Variant;
161
160
  onTopOfOtherModals?: boolean;
162
161
  };
163
- declare const Modal: React.FC<Props$f>;
162
+ declare const Modal: React.FC<Props$e>;
164
163
 
165
164
  /**
166
165
  * A box with a tab on the top that holds buttons and other content
167
166
  * @author Gabe Abrams
168
167
  */
169
168
 
170
- declare type Props$e = {
169
+ declare type Props$d = {
171
170
  title: React.ReactNode;
172
171
  children: React.ReactNode;
173
172
  noBottomMargin?: boolean;
174
173
  noBottomPadding?: boolean;
175
174
  };
176
- declare const TabBox: React.FC<Props$e>;
175
+ declare const TabBox: React.FC<Props$d>;
177
176
 
178
177
  /**
179
178
  * A radio selection button
180
179
  * @author Gabe Abrams
181
180
  */
182
181
 
183
- declare type Props$d = {
182
+ declare type Props$c = {
184
183
  text: string;
185
184
  onSelected: () => void;
186
185
  ariaLabel: string;
@@ -192,14 +191,14 @@ declare type Props$d = {
192
191
  unselectedVariant?: Variant;
193
192
  small?: boolean;
194
193
  };
195
- declare const RadioButton: React.FC<Props$d>;
194
+ declare const RadioButton: React.FC<Props$c>;
196
195
 
197
196
  /**
198
197
  * A checkbox button
199
198
  * @author Gabe Abrams
200
199
  */
201
200
 
202
- declare type Props$c = {
201
+ declare type Props$b = {
203
202
  text: string;
204
203
  onChanged: (checked: boolean) => void;
205
204
  ariaLabel: string;
@@ -213,28 +212,28 @@ declare type Props$c = {
213
212
  small?: boolean;
214
213
  dashed?: boolean;
215
214
  };
216
- declare const CheckboxButton: React.FC<Props$c>;
215
+ declare const CheckboxButton: React.FC<Props$b>;
217
216
 
218
217
  /**
219
218
  * Input group with a title and space for buttons
220
219
  * @author Gabe Abrams
221
220
  */
222
221
 
223
- declare type Props$b = {
222
+ declare type Props$a = {
224
223
  label: string;
225
224
  minLabelWidth?: string;
226
225
  children: React.ReactNode;
227
226
  className?: string;
228
227
  wrapButtonsAndAddGaps?: boolean;
229
228
  };
230
- declare const ButtonInputGroup: React.FC<Props$b>;
229
+ declare const ButtonInputGroup: React.FC<Props$a>;
231
230
 
232
231
  /**
233
232
  * A very simple, lightweight date chooser
234
233
  * @author Gabe Abrams
235
234
  */
236
235
 
237
- declare type Props$a = {
236
+ declare type Props$9 = {
238
237
  ariaLabel: string;
239
238
  name: string;
240
239
  month: number;
@@ -250,61 +249,61 @@ declare type Props$a = {
250
249
  numMonthsToShow?: number;
251
250
  chooseFromPast?: boolean;
252
251
  };
253
- declare const SimpleDateChooser: React.FC<Props$a>;
252
+ declare const SimpleDateChooser: React.FC<Props$9>;
254
253
 
255
254
  /**
256
255
  * Drawer container
257
256
  * @author Gabe Abrams
258
257
  */
259
258
 
260
- declare type Props$9 = {
259
+ declare type Props$8 = {
261
260
  customBackgroundColor?: string;
262
261
  children: React.ReactNode;
263
262
  };
264
- declare const Drawer: React.FC<Props$9>;
263
+ declare const Drawer: React.FC<Props$8>;
265
264
 
266
265
  /**
267
266
  * Success checkmark that pops into view
268
267
  * @author Gabe Abrams
269
268
  */
270
269
 
271
- declare type Props$8 = {
270
+ declare type Props$7 = {
272
271
  sizeRem?: number;
273
272
  circleVariant?: string;
274
273
  checkVariant?: string;
275
274
  };
276
- declare const PopSuccessMark: React.FC<Props$8>;
275
+ declare const PopSuccessMark: React.FC<Props$7>;
277
276
 
278
277
  /**
279
278
  * Failure x mark that pops into view
280
279
  * @author Gabe Abrams
281
280
  */
282
281
 
283
- declare type Props$7 = {
282
+ declare type Props$6 = {
284
283
  sizeRem?: number;
285
284
  circleVariant?: string;
286
285
  xVariant?: string;
287
286
  };
288
- declare const PopFailureMark: React.FC<Props$7>;
287
+ declare const PopFailureMark: React.FC<Props$6>;
289
288
 
290
289
  /**
291
290
  * Failure pending that pops into view
292
291
  * @author Gabe Abrams
293
292
  */
294
293
 
295
- declare type Props$6 = {
294
+ declare type Props$5 = {
296
295
  sizeRem?: number;
297
296
  circleVariant?: string;
298
297
  hourglassVariant?: string;
299
298
  };
300
- declare const PopPendingMark: React.FC<Props$6>;
299
+ declare const PopPendingMark: React.FC<Props$5>;
301
300
 
302
301
  /**
303
302
  * Copiable text box
304
303
  * @author Gabe Abrams
305
304
  */
306
305
 
307
- declare type Props$5 = {
306
+ declare type Props$4 = {
308
307
  text: string;
309
308
  maxTextWidthRem?: number;
310
309
  label?: string;
@@ -316,7 +315,7 @@ declare type Props$5 = {
316
315
  textAreaId?: string;
317
316
  copyButtonId?: string;
318
317
  };
319
- declare const CopiableBox: React.FC<Props$5>;
318
+ declare const CopiableBox: React.FC<Props$4>;
320
319
 
321
320
  /**
322
321
  * An item that can be chosen (for use within ItemPicker)
@@ -339,7 +338,7 @@ declare type PickableItem = ({
339
338
  * @author Yuen Ler Chow
340
339
  */
341
340
 
342
- declare type Props$4 = {
341
+ declare type Props$3 = {
343
342
  title: string;
344
343
  items: PickableItem[];
345
344
  /**
@@ -350,7 +349,7 @@ declare type Props$4 = {
350
349
  onChanged: (updatedItems: PickableItem[]) => void;
351
350
  noBottomMargin?: boolean;
352
351
  };
353
- declare const ItemPicker: React.FC<Props$4>;
352
+ declare const ItemPicker: React.FC<Props$3>;
354
353
 
355
354
  /**
356
355
  * Type of the context map in a LogMetadata file
@@ -395,11 +394,11 @@ declare type LogMetadataType = {
395
394
  * @author Gabe Abrams
396
395
  */
397
396
 
398
- declare type Props$3 = {
397
+ declare type Props$2 = {
399
398
  LogMetadata: LogMetadataType;
400
399
  onClose: () => void;
401
400
  };
402
- declare const LogReviewer: React.FC<Props$3>;
401
+ declare const LogReviewer: React.FC<Props$2>;
403
402
 
404
403
  /**
405
404
  * Server-side API param types
@@ -434,7 +433,7 @@ declare type IntelliTableColumn = {
434
433
  * @author Gabe Abrams
435
434
  */
436
435
 
437
- declare type Props$2 = {
436
+ declare type Props$1 = {
438
437
  title: string;
439
438
  id: string;
440
439
  data: {
@@ -444,14 +443,14 @@ declare type Props$2 = {
444
443
  columns: IntelliTableColumn[];
445
444
  csvName?: string;
446
445
  };
447
- declare const IntelliTable: React.FC<Props$2>;
446
+ declare const IntelliTable: React.FC<Props$1>;
448
447
 
449
448
  /**
450
449
  * Button for downloading a csv file
451
450
  * @author Gabe Abrams
452
451
  */
453
452
 
454
- declare type Props$1 = {
453
+ declare type Props = {
455
454
  filename: string;
456
455
  csv: string;
457
456
  id?: string;
@@ -463,98 +462,7 @@ declare type Props$1 = {
463
462
  onClick?: () => void;
464
463
  children?: React.ReactNode;
465
464
  };
466
- declare const CSVDownloadButton: React.FC<Props$1>;
467
-
468
- /**
469
- * Generic type for an object
470
- * @author Yuen Ler Chow
471
- */
472
- declare type DBEntry = {
473
- [k: string]: any;
474
- };
475
-
476
- /**
477
- * Options for field types
478
- * @author Yuen Ler Chow
479
- */
480
- declare enum DBEntryFieldType {
481
- String = "String",
482
- Number = "Number",
483
- Object = "Object",
484
- StringArray = "StringArray",
485
- NumberArray = "NumberArray"
486
- }
487
-
488
- /**
489
- * A database entry input field
490
- * @author Yuen Ler Chow
491
- */
492
- declare type DBEntryField = ({
493
- label: string;
494
- objectKey: string;
495
- placeholder: string;
496
- lockAfterCreation?: boolean;
497
- required?: boolean;
498
- } & ({
499
- type: DBEntryFieldType.String;
500
- minNumChars?: number;
501
- maxNumChars?: number;
502
- defaultValue?: string;
503
- choices?: {
504
- title: string;
505
- value: string;
506
- }[];
507
- } | {
508
- type: DBEntryFieldType.Number;
509
- minNumber?: number;
510
- maxNumber?: number;
511
- defaultValue?: number;
512
- } | {
513
- type: DBEntryFieldType.StringArray;
514
- minNumElements?: number;
515
- maxNumElements?: number;
516
- defaultValue?: string[];
517
- choices?: {
518
- title: string;
519
- value: string;
520
- }[];
521
- } | {
522
- type: DBEntryFieldType.NumberArray;
523
- minNumElements?: number;
524
- maxNumElements?: number;
525
- minNumber?: number;
526
- maxNumber?: number;
527
- defaultValue?: number[];
528
- } | {
529
- type: DBEntryFieldType.Object;
530
- defaultValue?: {
531
- [k: string]: any;
532
- };
533
- subfields: DBEntryField[];
534
- }));
535
-
536
- /**
537
- * DB Entry Manager Panel
538
- * @author Yuen Ler Chow
539
- */
540
-
541
- declare type Props = {
542
- entryFields: DBEntryField[];
543
- idPropName: string;
544
- titlePropName: string;
545
- descriptionPropName: string;
546
- itemListTitle: string;
547
- itemName: string;
548
- validateEntry?: (dbEntry: DBEntry) => Promise<void>;
549
- modifyEntry?: (dbEntry: DBEntry) => Promise<DBEntry>;
550
- disableEdit?: boolean;
551
- collectionName: string;
552
- adminsOnly?: boolean;
553
- filterQuery?: {
554
- [k: string]: any;
555
- };
556
- };
557
- declare const DBEntryManagerPanel: React.FC<Props>;
465
+ declare const CSVDownloadButton: React.FC<Props>;
558
466
 
559
467
  /**
560
468
  * An error with a code
@@ -1177,45 +1085,6 @@ declare const getLocalTimeInfo: (dateOrTimestamp?: number | Date | undefined) =>
1177
1085
  isPM: boolean;
1178
1086
  };
1179
1087
 
1180
- /**
1181
- * Interface for a collection in the database
1182
- * @author Yuen Ler Chow
1183
- */
1184
- interface Collection {
1185
- /**
1186
- * Find all items in the collection that match the filter query
1187
- * @param filterQuery
1188
- * @returns list of items that match the filter query
1189
- */
1190
- find: (filterQuery: any) => Promise<any[]>;
1191
- /**
1192
- * Insert an item into the collection
1193
- * @param item the item to insert
1194
- */
1195
- insert: (item: any) => Promise<void>;
1196
- /**
1197
- * Delete an item in the collection
1198
- * @param id the id of the item to delete
1199
- */
1200
- delete: (filterQuery: {
1201
- id: string;
1202
- }) => Promise<void>;
1203
- }
1204
- /**
1205
- * Add all routes for the DBEditor
1206
- * @author Yuen Ler Chow
1207
- * @param opts object containing all arguments
1208
- * @param opts.app express app to add routes too
1209
- * @param opts.collectionName the name of the collection
1210
- * @param opts.adminsOnly true if the endpoint is for admins only
1211
- */
1212
- declare const addDBEditorEndpoints: (opts: {
1213
- app: express.Application;
1214
- collectionName: string;
1215
- adminsOnly: boolean;
1216
- collection: Collection;
1217
- }) => void;
1218
-
1219
1088
  /**
1220
1089
  * List of error codes built into the react kit
1221
1090
  * @author Gabe Abrams
@@ -1266,4 +1135,4 @@ declare const LogBuiltInMetadata: {
1266
1135
  };
1267
1136
  };
1268
1137
 
1269
- export { AppWrapper, 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, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, Variant, abbreviate, addDBEditorEndpoints, alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initClient, initLogCollection, initServer, isMobileOrTablet, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
1138
+ 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, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, initClient, initLogCollection, initServer, isMobileOrTablet, logClientEvent, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.4.0-beta.8",
3
+ "version": "3.4.0",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "scripts": {
9
9
  "build": "rm -rf dist && rollup -c",
10
- "test": "jest"
10
+ "test": "jest --runInBand"
11
11
  },
12
12
  "jest": {
13
13
  "preset": "ts-jest",
@@ -28,26 +28,25 @@
28
28
  "@fortawesome/free-solid-svg-icons": "^x.x.x",
29
29
  "@fortawesome/react-fontawesome": "^x.x.x",
30
30
  "bootstrap": "^5.x.x",
31
- "react": "^x.x.x",
32
- "express": "^x.x.x"
31
+ "react": "^x.x.x"
33
32
  },
34
33
  "devDependencies": {
35
34
  "@rollup/plugin-commonjs": "^22.0.0",
36
35
  "@rollup/plugin-json": "^4.1.0",
37
36
  "@rollup/plugin-node-resolve": "^13.2.1",
38
37
  "@rollup/plugin-typescript": "^8.3.2",
39
- "@types/express": "^4.17.17",
40
38
  "@types/jest": "^28.1.7",
39
+ "@types/node": "^20.2.5",
41
40
  "@types/react": "^17.0.7",
42
- "@typescript-eslint/eslint-plugin": "^5.21.0",
43
- "@typescript-eslint/parser": "^5.21.0",
44
- "eslint": "^8.14.0",
41
+ "@typescript-eslint/eslint-plugin": "^5.59.9",
42
+ "@typescript-eslint/parser": "^5.59.9",
43
+ "eslint": "^8.42.0",
45
44
  "eslint-config-airbnb": "^19.0.4",
46
45
  "eslint-config-airbnb-typescript": "^17.0.0",
47
- "eslint-plugin-import": "^2.26.0",
48
- "eslint-plugin-jsx-a11y": "^6.5.1",
49
- "eslint-plugin-react": "^7.29.4",
50
- "eslint-plugin-react-hooks": "^4.4.0",
46
+ "eslint-plugin-import": "^2.27.5",
47
+ "eslint-plugin-jsx-a11y": "^6.7.1",
48
+ "eslint-plugin-react": "^7.32.2",
49
+ "eslint-plugin-react-hooks": "^4.6.0",
51
50
  "jest": "^28.1.3",
52
51
  "jest-environment-jsdom": "^28.1.3",
53
52
  "raixa": "^1.0.19",
@@ -55,9 +54,6 @@
55
54
  "rollup-plugin-dts": "^4.2.1",
56
55
  "rollup-plugin-sourcemaps": "^0.6.3",
57
56
  "ts-jest": "^28.0.8",
58
- "typescript": "^4.6.3"
59
- },
60
- "dependencies": {
61
- "react-select": "^5.7.3"
57
+ "typescript": "^4.9.5"
62
58
  }
63
- }
59
+ }
@@ -56,24 +56,32 @@ let storedSendRequest: SendRequestFunction;
56
56
  * @returns sendRequest function
57
57
  */
58
58
  export const getSendRequest = async () => {
59
- // Show timeout error if too much time passes
60
- let successful = false;
59
+ // Track timeout
60
+ let timedOut = false;
61
61
  (async () => {
62
62
  await waitMs(5000);
63
-
64
- if (!successful) {
65
- showFatalError(
66
- new ErrorWithCode(
67
- 'Could not send a request because the request needed to be sent before dce-reactkit was properly initialized. Perhaps dce-reactkit was not initialized with initClient.',
68
- ReactKitErrorCode.NoCACCLSendRequestFunction,
69
- ),
70
- );
71
- }
63
+ timedOut = true;
72
64
  })(),
73
65
 
74
66
  // Wait for initialization
75
67
  await initialized;
76
- successful = true;
68
+
69
+ // Error if no send request function
70
+ if (timedOut) {
71
+ showFatalError(
72
+ new ErrorWithCode(
73
+ 'Could not send a request because the request needed to be sent before dce-reactkit was properly initialized. Perhaps dce-reactkit was not initialized with initClient.',
74
+ ReactKitErrorCode.NoCACCLSendRequestFunction,
75
+ ),
76
+ );
77
+
78
+ // Return dummy function that never resolves
79
+ return (
80
+ () => {
81
+ return new Promise(() => {});
82
+ }
83
+ ) as SendRequestFunction;
84
+ }
77
85
 
78
86
  // Return
79
87
  return storedSendRequest;
@@ -434,4 +434,4 @@ const AppWrapper: React.FC<Props> = (props: Props): React.ReactElement => {
434
434
  /*------------------------------------------------------------------------*/
435
435
 
436
436
  // Export component
437
- export default AppWrapper;
437
+ export default AppWrapper;
@@ -512,7 +512,7 @@ const assertExpectedItemsAreChecked = (
512
512
  }
513
513
  };
514
514
 
515
- test(
515
+ test.skip(
516
516
  'All Checkboxes appear when initially rendered',
517
517
  async () => {
518
518
  Raixa.render(
@@ -530,7 +530,7 @@ test(
530
530
  },
531
531
  );
532
532
 
533
- test(
533
+ test.skip(
534
534
  'Collapsing item 3 results in only the first 3 items and item 24 showing',
535
535
  async () => {
536
536
  Raixa.render(
@@ -555,7 +555,7 @@ test(
555
555
  },
556
556
  );
557
557
 
558
- test(
558
+ test.skip(
559
559
  'Collapsing item 15 results hides items 16 through 21',
560
560
  async () => {
561
561
  Raixa.render(
@@ -580,7 +580,7 @@ test(
580
580
  },
581
581
  );
582
582
 
583
- test(
583
+ test.skip(
584
584
  'Collapsing item 10 results hides items 11 through 21',
585
585
  async () => {
586
586
  Raixa.render(
@@ -605,7 +605,7 @@ test(
605
605
  },
606
606
  );
607
607
 
608
- test(
608
+ test.skip(
609
609
  'All Checkboxes are unchecked when initially rendered',
610
610
  async () => {
611
611
  Raixa.render(
@@ -626,7 +626,7 @@ test(
626
626
  },
627
627
  );
628
628
 
629
- test(
629
+ test.skip(
630
630
  'Checking item 1 checks items 1',
631
631
  async () => {
632
632
  let updatedItems: PickableItem[] = [];
@@ -654,7 +654,7 @@ test(
654
654
  },
655
655
  );
656
656
 
657
- test(
657
+ test.skip(
658
658
  'Clicking item 1 unchecks items 1',
659
659
  async () => {
660
660
  let updatedItems: PickableItem[] = [];
@@ -686,7 +686,7 @@ test(
686
686
  },
687
687
  );
688
688
 
689
- test(
689
+ test.skip(
690
690
  'Checking item 3 checks items 3 through 23',
691
691
  async () => {
692
692
  let updatedItems: PickableItem[] = [];
@@ -720,7 +720,7 @@ test(
720
720
  },
721
721
  );
722
722
 
723
- test(
723
+ test.skip(
724
724
  'Clicking folder 3 checks unchecks 3 through 23',
725
725
  async () => {
726
726
  let updatedItems: PickableItem[] = [];
@@ -750,7 +750,7 @@ test(
750
750
  },
751
751
  );
752
752
 
753
- test(
753
+ test.skip(
754
754
  'Clicking dashed folder 3 checks 3 through 23',
755
755
  async () => {
756
756
  let updatedItems: PickableItem[] = [];
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Unit tests for abbreviate helper
3
+ * @author Gabe Abrams
4
+ */
5
+
6
+ import abbreviate from './abbreviate';
7
+
8
+ describe('helpers > abbreviate', () => {
9
+ it('should return the original text if it is shorter than the maxChars parameter', () => {
10
+ const text = 'Hello, world!';
11
+ const maxChars = 20;
12
+ expect(abbreviate(text, maxChars)).toEqual(text);
13
+ });
14
+
15
+ it('should abbreviate the text if it is longer than the maxChars parameter', () => {
16
+ const text = 'This is a really long string that needs to be abbreviated';
17
+ const maxChars = 20;
18
+ expect(abbreviate(text, maxChars)).toEqual('This is a really...');
19
+ });
20
+
21
+ it('should handle leading/trailing whitespace', () => {
22
+ const text = ' This is a string with leading/trailing whitespace ';
23
+ const maxChars = 20;
24
+ expect(abbreviate(text, maxChars)).toEqual('This is a string...');
25
+ });
26
+ });
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Unit tests for avg helper
3
+ * @author Gabe Abrams
4
+ */
5
+
6
+ import avg from './avg';
7
+
8
+ describe('helpers > avg', () => {
9
+ it('should return 0 for an empty array', () => {
10
+ expect(avg([])).toEqual(0);
11
+ });
12
+
13
+ it('should return the correct average for an array of numbers', () => {
14
+ expect(avg([1, 2, 3, 4, 5])).toEqual(3);
15
+ });
16
+
17
+ it('should handle negative numbers', () => {
18
+ expect(avg([-1, 0, 1])).toEqual(0);
19
+ });
20
+
21
+ it('should handle decimal numbers', () => {
22
+ expect(avg([1.5, 2.5, 3.5])).toEqual(2.5);
23
+ });
24
+ });