dce-reactkit 3.6.8 → 3.6.9

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.
@@ -0,0 +1,24 @@
1
+ /**
2
+ * A switch with multiple options for selection
3
+ * @author Alessandra De Lucas
4
+ * @author Gabe Abrams
5
+ */
6
+ import React from 'react';
7
+ import { IconProp } from '@fortawesome/fontawesome-svg-core';
8
+ type Props = {
9
+ options: Option[];
10
+ selectedOptionId: string;
11
+ /**
12
+ * A handler to call when the switch is changed
13
+ * @param selectedOptionId Updated option when switch is changed
14
+ */
15
+ onChange: (selectedOptionId: string) => void;
16
+ heightRem?: number;
17
+ };
18
+ type Option = {
19
+ label: string;
20
+ icon: IconProp;
21
+ id: string;
22
+ };
23
+ declare const MultiSwitch: React.FC<Props>;
24
+ export default MultiSwitch;
@@ -20,6 +20,7 @@ import DBEntryManagerPanel from './components/DBEntryManagerPanel';
20
20
  import Tooltip from './components/Tooltip';
21
21
  import ToggleSwitch from './components/ToggleSwitch';
22
22
  import AutoscrollToBottomContainer from './components/AutoscrollToBottomContainer';
23
+ import MultiSwitch from './components/MultiSwitch';
23
24
  import ErrorWithCode from './errors/ErrorWithCode';
24
25
  import MINUTE_IN_MS from './constants/MINUTE_IN_MS';
25
26
  import HOUR_IN_MS from './constants/HOUR_IN_MS';
@@ -84,4 +85,4 @@ import PickableItem from './components/ItemPicker/types/PickableItem';
84
85
  import DBEntry from './components/DBEntryManagerPanel/types/DBEntry';
85
86
  import DBEntryField from './components/DBEntryManagerPanel/types/DBEntryField';
86
87
  import DBEntryFieldType from './components/DBEntryManagerPanel/types/DBEntryFieldType';
87
- export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, 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, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
88
+ export { AppWrapper, LoadingSpinner, ErrorBox, Modal, TabBox, RadioButton, CheckboxButton, ButtonInputGroup, SimpleDateChooser, Drawer, PopSuccessMark, PopFailureMark, PopPendingMark, CopiableBox, ItemPicker, LogReviewer, IntelliTable, CSVDownloadButton, DBEntryManagerPanel, Tooltip, ToggleSwitch, AutoscrollToBottomContainer, MultiSwitch, 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, extractProp, compareArraysByProp, genCommaList, validateEmail, validatePhoneNumber, validateString, getLocalTimeInfo, idify, makeLinksClickable, initClient, visitServerEndpoint, logClientEvent, addFatalErrorHandler, leaveToURL, initServer, genRouteHandler, handleError, handleSuccess, initLogCollection, addDBEditorEndpoints, ModalButtonType, ModalSize, ModalType, ReactKitErrorCode, Variant, DayOfWeek, Log, LogType, LogSource, LogAction, LogBuiltInMetadata, LogMetadataType, IntelliTableColumn, PickableItem, DBEntry, DBEntryField, DBEntryFieldType, ParamType, };
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.ReactNode;
29
29
  };
30
30
  /**
@@ -75,7 +75,7 @@ declare const showFatalError: (error: any, errorTitle?: string) => Promise<void>
75
75
  * @author Gabe Abrams
76
76
  */
77
77
  declare const addFatalErrorHandler: (handler: () => void) => void;
78
- declare const AppWrapper: React.FC<Props$k>;
78
+ declare const AppWrapper: React.FC<Props$l>;
79
79
 
80
80
  /**
81
81
  * Loading spinner/indicator
@@ -88,14 +88,14 @@ declare const LoadingSpinner: () => JSX.Element;
88
88
  * @author Gabe Abrams
89
89
  */
90
90
 
91
- type Props$j = {
91
+ type Props$k = {
92
92
  error: any;
93
93
  title?: string;
94
94
  onClose?: () => void;
95
95
  variant?: Variant;
96
96
  icon?: IconProp;
97
97
  };
98
- declare const ErrorBox: React.FC<Props$j>;
98
+ declare const ErrorBox: React.FC<Props$k>;
99
99
 
100
100
  /**
101
101
  * Types of buttons in the modal
@@ -146,7 +146,7 @@ declare enum ModalType {
146
146
  * @author Gabe Abrams
147
147
  */
148
148
 
149
- type Props$i = {
149
+ type Props$j = {
150
150
  type?: ModalType;
151
151
  size?: ModalSize;
152
152
  title?: React.ReactNode;
@@ -175,27 +175,27 @@ type Props$i = {
175
175
  confirmVariant?: Variant;
176
176
  onTopOfOtherModals?: boolean;
177
177
  };
178
- declare const Modal: React.FC<Props$i>;
178
+ declare const Modal: React.FC<Props$j>;
179
179
 
180
180
  /**
181
181
  * A box with a tab on the top that holds buttons and other content
182
182
  * @author Gabe Abrams
183
183
  */
184
184
 
185
- type Props$h = {
185
+ type Props$i = {
186
186
  title: React.ReactNode;
187
187
  children: React.ReactNode;
188
188
  noBottomMargin?: boolean;
189
189
  noBottomPadding?: boolean;
190
190
  };
191
- declare const TabBox: React.FC<Props$h>;
191
+ declare const TabBox: React.FC<Props$i>;
192
192
 
193
193
  /**
194
194
  * A radio selection button
195
195
  * @author Gabe Abrams
196
196
  */
197
197
 
198
- type Props$g = {
198
+ type Props$h = {
199
199
  text: string;
200
200
  onSelected: () => void;
201
201
  ariaLabel: string;
@@ -207,14 +207,14 @@ type Props$g = {
207
207
  unselectedVariant?: Variant;
208
208
  small?: boolean;
209
209
  };
210
- declare const RadioButton: React.FC<Props$g>;
210
+ declare const RadioButton: React.FC<Props$h>;
211
211
 
212
212
  /**
213
213
  * A checkbox button
214
214
  * @author Gabe Abrams
215
215
  */
216
216
 
217
- type Props$f = {
217
+ type Props$g = {
218
218
  text: string;
219
219
  onChanged: (checked: boolean) => void;
220
220
  ariaLabel: string;
@@ -228,28 +228,28 @@ type Props$f = {
228
228
  small?: boolean;
229
229
  dashed?: boolean;
230
230
  };
231
- declare const CheckboxButton: React.FC<Props$f>;
231
+ declare const CheckboxButton: React.FC<Props$g>;
232
232
 
233
233
  /**
234
234
  * Input group with a title and space for buttons
235
235
  * @author Gabe Abrams
236
236
  */
237
237
 
238
- type Props$e = {
238
+ type Props$f = {
239
239
  label: string;
240
240
  minLabelWidth?: string;
241
241
  children: React.ReactNode;
242
242
  className?: string;
243
243
  wrapButtonsAndAddGaps?: boolean;
244
244
  };
245
- declare const ButtonInputGroup: React.FC<Props$e>;
245
+ declare const ButtonInputGroup: React.FC<Props$f>;
246
246
 
247
247
  /**
248
248
  * A very simple, lightweight date chooser
249
249
  * @author Gabe Abrams
250
250
  */
251
251
 
252
- type Props$d = {
252
+ type Props$e = {
253
253
  ariaLabel: string;
254
254
  name: string;
255
255
  month: number;
@@ -265,61 +265,61 @@ type Props$d = {
265
265
  numMonthsToShow?: number;
266
266
  chooseFromPast?: boolean;
267
267
  };
268
- declare const SimpleDateChooser: React.FC<Props$d>;
268
+ declare const SimpleDateChooser: React.FC<Props$e>;
269
269
 
270
270
  /**
271
271
  * Drawer container
272
272
  * @author Gabe Abrams
273
273
  */
274
274
 
275
- type Props$c = {
275
+ type Props$d = {
276
276
  customBackgroundColor?: string;
277
277
  children: React.ReactNode;
278
278
  };
279
- declare const Drawer: React.FC<Props$c>;
279
+ declare const Drawer: React.FC<Props$d>;
280
280
 
281
281
  /**
282
282
  * Success checkmark that pops into view
283
283
  * @author Gabe Abrams
284
284
  */
285
285
 
286
- type Props$b = {
286
+ type Props$c = {
287
287
  sizeRem?: number;
288
288
  circleVariant?: string;
289
289
  checkVariant?: string;
290
290
  };
291
- declare const PopSuccessMark: React.FC<Props$b>;
291
+ declare const PopSuccessMark: React.FC<Props$c>;
292
292
 
293
293
  /**
294
294
  * Failure x mark that pops into view
295
295
  * @author Gabe Abrams
296
296
  */
297
297
 
298
- type Props$a = {
298
+ type Props$b = {
299
299
  sizeRem?: number;
300
300
  circleVariant?: string;
301
301
  xVariant?: string;
302
302
  };
303
- declare const PopFailureMark: React.FC<Props$a>;
303
+ declare const PopFailureMark: React.FC<Props$b>;
304
304
 
305
305
  /**
306
306
  * Failure pending that pops into view
307
307
  * @author Gabe Abrams
308
308
  */
309
309
 
310
- type Props$9 = {
310
+ type Props$a = {
311
311
  sizeRem?: number;
312
312
  circleVariant?: string;
313
313
  hourglassVariant?: string;
314
314
  };
315
- declare const PopPendingMark: React.FC<Props$9>;
315
+ declare const PopPendingMark: React.FC<Props$a>;
316
316
 
317
317
  /**
318
318
  * Copiable text box
319
319
  * @author Gabe Abrams
320
320
  */
321
321
 
322
- type Props$8 = {
322
+ type Props$9 = {
323
323
  text: string;
324
324
  maxTextWidthRem?: number;
325
325
  label?: string;
@@ -331,7 +331,7 @@ type Props$8 = {
331
331
  textAreaId?: string;
332
332
  copyButtonId?: string;
333
333
  };
334
- declare const CopiableBox: React.FC<Props$8>;
334
+ declare const CopiableBox: React.FC<Props$9>;
335
335
 
336
336
  /**
337
337
  * An item that can be chosen (for use within ItemPicker)
@@ -354,7 +354,7 @@ type PickableItem = ({
354
354
  * @author Yuen Ler Chow
355
355
  */
356
356
 
357
- type Props$7 = {
357
+ type Props$8 = {
358
358
  title: string;
359
359
  items: PickableItem[];
360
360
  /**
@@ -365,7 +365,7 @@ type Props$7 = {
365
365
  onChanged: (updatedItems: PickableItem[]) => void;
366
366
  noBottomMargin?: boolean;
367
367
  };
368
- declare const ItemPicker: React.FC<Props$7>;
368
+ declare const ItemPicker: React.FC<Props$8>;
369
369
 
370
370
  /**
371
371
  * Type of the context map in a LogMetadata file
@@ -410,11 +410,11 @@ type LogMetadataType = {
410
410
  * @author Gabe Abrams
411
411
  */
412
412
 
413
- type Props$6 = {
413
+ type Props$7 = {
414
414
  LogMetadata: LogMetadataType;
415
415
  onClose: () => void;
416
416
  };
417
- declare const LogReviewer: React.FC<Props$6>;
417
+ declare const LogReviewer: React.FC<Props$7>;
418
418
 
419
419
  /**
420
420
  * Server-side API param types
@@ -449,7 +449,7 @@ type IntelliTableColumn = {
449
449
  * @author Gabe Abrams
450
450
  */
451
451
 
452
- type Props$5 = {
452
+ type Props$6 = {
453
453
  title: string;
454
454
  id: string;
455
455
  data: {
@@ -459,14 +459,14 @@ type Props$5 = {
459
459
  columns: IntelliTableColumn[];
460
460
  csvName?: string;
461
461
  };
462
- declare const IntelliTable: React.FC<Props$5>;
462
+ declare const IntelliTable: React.FC<Props$6>;
463
463
 
464
464
  /**
465
465
  * Button for downloading a csv file
466
466
  * @author Gabe Abrams
467
467
  */
468
468
 
469
- type Props$4 = {
469
+ type Props$5 = {
470
470
  filename: string;
471
471
  csv: string;
472
472
  id?: string;
@@ -478,7 +478,7 @@ type Props$4 = {
478
478
  onClick?: () => void;
479
479
  children?: React.ReactNode;
480
480
  };
481
- declare const CSVDownloadButton: React.FC<Props$4>;
481
+ declare const CSVDownloadButton: React.FC<Props$5>;
482
482
 
483
483
  /**
484
484
  * Generic type for an object
@@ -554,7 +554,7 @@ type DBEntryField = ({
554
554
  * @author Gabe Abrams
555
555
  */
556
556
 
557
- type Props$3 = {
557
+ type Props$4 = {
558
558
  entryFields: DBEntryField[];
559
559
  idPropName: string;
560
560
  titlePropName: string;
@@ -580,14 +580,14 @@ type Props$3 = {
580
580
  [k: string]: any;
581
581
  };
582
582
  };
583
- declare const DBEntryManagerPanel: React.FC<Props$3>;
583
+ declare const DBEntryManagerPanel: React.FC<Props$4>;
584
584
 
585
585
  /**
586
586
  * Simple tooltip component
587
587
  * @author Gabe Abrams
588
588
  */
589
589
 
590
- type Props$2 = {
590
+ type Props$3 = {
591
591
  icon?: IconProp;
592
592
  text: string;
593
593
  children: React.ReactNode;
@@ -595,7 +595,7 @@ type Props$2 = {
595
595
  thin?: boolean;
596
596
  containerIsDisplayBlock?: boolean;
597
597
  };
598
- declare const Tooltip: React.FC<Props$2>;
598
+ declare const Tooltip: React.FC<Props$3>;
599
599
 
600
600
  /**
601
601
  * A toggle switch that toggles on or off
@@ -603,7 +603,7 @@ declare const Tooltip: React.FC<Props$2>;
603
603
  * @author Gabe Abrams
604
604
  */
605
605
 
606
- type Props$1 = {
606
+ type Props$2 = {
607
607
  isOn: boolean;
608
608
  /**
609
609
  * A handler to call when the switch is toggled
@@ -614,7 +614,7 @@ type Props$1 = {
614
614
  description: string;
615
615
  backgroundVariantWhenOn?: Variant;
616
616
  };
617
- declare const ToggleSwitch: React.FC<Props$1>;
617
+ declare const ToggleSwitch: React.FC<Props$2>;
618
618
 
619
619
  /**
620
620
  * Container that automatically scrolls when new items are added,
@@ -625,7 +625,7 @@ declare const ToggleSwitch: React.FC<Props$1>;
625
625
  * @author Gabe Abrams
626
626
  */
627
627
 
628
- type Props = {
628
+ type Props$1 = {
629
629
  itemsName?: string;
630
630
  items: AutoScrollItem[];
631
631
  jumpToBottomButtonVariant?: Variant;
@@ -636,7 +636,30 @@ type AutoScrollItem = {
636
636
  id: string | number;
637
637
  item: React.ReactNode;
638
638
  };
639
- declare const AutoscrollToBottomContainer: React.FC<Props>;
639
+ declare const AutoscrollToBottomContainer: React.FC<Props$1>;
640
+
641
+ /**
642
+ * A switch with multiple options for selection
643
+ * @author Alessandra De Lucas
644
+ * @author Gabe Abrams
645
+ */
646
+
647
+ type Props = {
648
+ options: Option[];
649
+ selectedOptionId: string;
650
+ /**
651
+ * A handler to call when the switch is changed
652
+ * @param selectedOptionId Updated option when switch is changed
653
+ */
654
+ onChange: (selectedOptionId: string) => void;
655
+ heightRem?: number;
656
+ };
657
+ type Option = {
658
+ label: string;
659
+ icon: IconProp;
660
+ id: string;
661
+ };
662
+ declare const MultiSwitch: React.FC<Props>;
640
663
 
641
664
  /**
642
665
  * An error with a code
@@ -1443,4 +1466,4 @@ declare const LogBuiltInMetadata: {
1443
1466
  };
1444
1467
  };
1445
1468
 
1446
- 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, LogMetadataType, LogReviewer, LogSource, LogType, MINUTE_IN_MS, Modal, ModalButtonType, ModalSize, ModalType, ParamType, PickableItem, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode, SimpleDateChooser, TabBox, ToggleSwitch, Tooltip, Variant, abbreviate, addDBEditorEndpoints, addFatalErrorHandler, alert, avg, canReviewLogs, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
1469
+ 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, 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, ceilToNumDecimals, compareArraysByProp, confirm, extractProp, floorToNumDecimals, forceNumIntoBounds, genCSV, genCommaList, genRouteHandler, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, handleError, handleSuccess, idify, initClient, initLogCollection, initServer, isMobileOrTablet, leaveToURL, logClientEvent, makeLinksClickable, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, roundToNumDecimals, showFatalError, startMinWait, stringsToHumanReadableList, stubServerEndpoint, sum, validateEmail, validatePhoneNumber, validateString, visitServerEndpoint, waitMs };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.6.8",
3
+ "version": "3.6.9",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",