dce-reactkit 3.7.37 → 3.8.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.7.37",
3
+ "version": "3.8.0",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -255,6 +255,9 @@ const Modal: React.FC<ModalProps> = (props) => {
255
255
  onTopOfOtherModals,
256
256
  } = props;
257
257
 
258
+ // Determine if no header either
259
+ const noHeader = (!title && type === ModalType.NoButtons);
260
+
258
261
  /* -------------- State ------------- */
259
262
 
260
263
  // True if animation is in use
@@ -457,59 +460,61 @@ const Modal: React.FC<ModalProps> = (props) => {
457
460
  ),
458
461
  }}
459
462
  >
460
- <div
461
- className="modal-header"
462
- style={{
463
- color: (
464
- isDarkModeOn()
465
- ? 'white'
466
- : undefined
467
- ),
468
- backgroundColor: (
469
- isDarkModeOn()
470
- ? '#444'
471
- : undefined
472
- ),
473
- borderBottom: (
474
- isDarkModeOn()
475
- ? '0.1rem solid gray'
476
- : undefined
477
- ),
478
- }}
479
- >
480
- <h5
481
- className="modal-title"
463
+ {!noHeader && (
464
+ <div
465
+ className="modal-header"
482
466
  style={{
483
- fontWeight: 'bold',
484
- fontSize: (
485
- largeTitle
486
- ? '1.6rem'
467
+ color: (
468
+ isDarkModeOn()
469
+ ? 'white'
470
+ : undefined
471
+ ),
472
+ backgroundColor: (
473
+ isDarkModeOn()
474
+ ? '#444'
475
+ : undefined
476
+ ),
477
+ borderBottom: (
478
+ isDarkModeOn()
479
+ ? '0.1rem solid gray'
487
480
  : undefined
488
481
  ),
489
482
  }}
490
483
  >
491
- {title}
492
- </h5>
493
-
494
- {(onClose && !dontShowXButton) && (
495
- <button
496
- type="button"
497
- className="Modal-x-button btn-close"
498
- aria-label="Close"
484
+ <h5
485
+ className="modal-title"
499
486
  style={{
500
- backgroundColor: (
501
- isDarkModeOn()
502
- ? 'white'
487
+ fontWeight: 'bold',
488
+ fontSize: (
489
+ largeTitle
490
+ ? '1.6rem'
503
491
  : undefined
504
492
  ),
505
493
  }}
506
- onClick={() => {
507
- // Handle close
508
- handleClose(ModalButtonType.Cancel);
509
- }}
510
- />
511
- )}
512
- </div>
494
+ >
495
+ {title}
496
+ </h5>
497
+
498
+ {(onClose && !dontShowXButton) && (
499
+ <button
500
+ type="button"
501
+ className="Modal-x-button btn-close"
502
+ aria-label="Close"
503
+ style={{
504
+ backgroundColor: (
505
+ isDarkModeOn()
506
+ ? 'white'
507
+ : undefined
508
+ ),
509
+ }}
510
+ onClick={() => {
511
+ // Handle close
512
+ handleClose(ModalButtonType.Cancel);
513
+ }}
514
+ />
515
+ )}
516
+ </div>
517
+ )}
513
518
  {children && (
514
519
  <div
515
520
  className="modal-body"
@@ -129,12 +129,26 @@ const visitServerEndpoint = async (
129
129
  params = Object.fromEntries(
130
130
  Object
131
131
  .entries(opts.params)
132
- .filter(([key, value]) => {
132
+ .filter(([, value]) => {
133
133
  return value !== undefined;
134
134
  }),
135
135
  );
136
136
  }
137
137
 
138
+ // Automatically JSONify arrays and objects
139
+ if (params) {
140
+ params = Object.fromEntries(
141
+ Object
142
+ .entries(params)
143
+ .map(([key, value]) => {
144
+ if (Array.isArray(value) || typeof value === 'object') {
145
+ return [key, JSON.stringify(value)];
146
+ }
147
+ return [key, value];
148
+ }),
149
+ );
150
+ }
151
+
138
152
  // Send the request
139
153
  const sendRequest = await getSendRequest();
140
154
  const response = await sendRequest({