dce-reactkit 3.2.4 → 3.2.6

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.
@@ -8,6 +8,7 @@ declare type Props = {
8
8
  minLabelWidth?: string;
9
9
  children: React.ReactNode;
10
10
  className?: string;
11
+ wrapButtonsAndAddGaps?: boolean;
11
12
  };
12
13
  declare const ButtonInputGroup: React.FC<Props>;
13
14
  export default ButtonInputGroup;
package/dist/index.d.ts CHANGED
@@ -243,6 +243,7 @@ declare type Props$a = {
243
243
  minLabelWidth?: string;
244
244
  children: React.ReactNode;
245
245
  className?: string;
246
+ wrapButtonsAndAddGaps?: boolean;
246
247
  };
247
248
  declare const ButtonInputGroup: React.FC<Props$a>;
248
249
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dce-reactkit",
3
- "version": "3.2.4",
3
+ "version": "3.2.6",
4
4
  "description": "Shared components for Harvard DCE apps",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -20,6 +20,8 @@ type Props = {
20
20
  children: React.ReactNode,
21
21
  // Additional class names to add to the outer container
22
22
  className?: string,
23
+ // If true, wrap buttons and create gaps
24
+ wrapButtonsAndAddGaps?: boolean,
23
25
  };
24
26
 
25
27
  /*------------------------------------------------------------------------*/
@@ -39,6 +41,7 @@ const ButtonInputGroup: React.FC<Props> = (props) => {
39
41
  minLabelWidth,
40
42
  children,
41
43
  className,
44
+ wrapButtonsAndAddGaps,
42
45
  } = props;
43
46
 
44
47
  /*------------------------------------------------------------------------*/
@@ -77,7 +80,15 @@ const ButtonInputGroup: React.FC<Props> = (props) => {
77
80
  borderLeftWidth: 0,
78
81
  }}
79
82
  >
80
- {children}
83
+ {
84
+ wrapButtonsAndAddGaps
85
+ ? (
86
+ <div className="d-flex gap-1 flex-wrap">
87
+ {children}
88
+ </div>
89
+ )
90
+ : children
91
+ }
81
92
  </span>
82
93
  </div>
83
94
  </div>
@@ -467,7 +467,7 @@ const columns: IntelliTableColumn[] = [
467
467
  */
468
468
  const genHumanReadableName = (machineReadableName: string) => {
469
469
  let humanReadableName = '';
470
-
470
+
471
471
  // Add chars and spaces
472
472
  const chars = machineReadableName.split('');
473
473
  chars.forEach((char) => {
@@ -477,9 +477,49 @@ const genHumanReadableName = (machineReadableName: string) => {
477
477
  }
478
478
  humanReadableName += char;
479
479
  });
480
+ const words = (
481
+ humanReadableName
482
+ .trim()
483
+ // Split into words
484
+ .split(' ')
485
+ // Filter out whitespace
486
+ .filter((word) => {
487
+ return (word.length > 0);
488
+ })
489
+ // Capitalize first letter
490
+ .map((word) => {
491
+ if (word.length <= 1) {
492
+ return word;
493
+ }
494
+ return `${word.substring(0, 1).toUpperCase()}${word.substring(1)}`;
495
+ })
496
+ );
480
497
 
481
- // Trim and return
482
- return humanReadableName.trim();
498
+ // Handle acronyms by piling words together
499
+ const consolidatedWords: string[] = [];
500
+ let acronym = '';
501
+ words.forEach((word) => {
502
+ if (word.length === 1) {
503
+ // Add on to acronym
504
+ acronym += word;
505
+ } else {
506
+ // Wrap up acronym
507
+ if (acronym.length > 0) {
508
+ consolidatedWords.push(acronym);
509
+ acronym = '';
510
+ }
511
+
512
+ // Full word. Just add it
513
+ consolidatedWords.push(word);
514
+ }
515
+ });
516
+ // Add trailing acronym
517
+ if (acronym.length > 0) {
518
+ consolidatedWords.push(acronym);
519
+ }
520
+
521
+ // Return
522
+ return consolidatedWords.join(' ');
483
523
  };
484
524
 
485
525
  /*------------------------------------------------------------------------*/
@@ -1373,61 +1413,61 @@ const LogReviewer: React.FC<Props> = (props) => {
1373
1413
  <ButtonInputGroup
1374
1414
  label="Action"
1375
1415
  className="mb-2"
1416
+ wrapButtonsAndAddGaps
1376
1417
  >
1377
- <div className="d-flex gap-1 flex-wrap">
1378
- {
1379
- Object.keys(LogAction)
1380
- .map((action) => {
1381
- const description = genHumanReadableName(action);
1382
- return (
1383
- <CheckboxButton
1384
- key={action}
1385
- id={`LogReviewer-action-${action}-checkbox`}
1386
- text={description}
1387
- ariaLabel={`include logs with action type "${description}" in results`}
1388
- noMarginOnRight
1389
- checked={actionErrorFilterState.action[action]}
1390
- onChanged={(checked) => {
1391
- actionErrorFilterState.action[action] = checked;
1392
- dispatch({
1393
- type: ActionType.UpdateActionErrorFilterState,
1394
- actionErrorFilterState,
1395
- });
1396
- }}
1397
- />
1398
- );
1399
- })
1400
- }
1401
- </div>
1418
+ {
1419
+ Object.keys(LogAction)
1420
+ .map((action) => {
1421
+ const description = genHumanReadableName(action);
1422
+ return (
1423
+ <CheckboxButton
1424
+ key={action}
1425
+ id={`LogReviewer-action-${action}-checkbox`}
1426
+ text={description}
1427
+ ariaLabel={`include logs with action type "${description}" in results`}
1428
+ noMarginOnRight
1429
+ checked={actionErrorFilterState.action[action]}
1430
+ onChanged={(checked) => {
1431
+ actionErrorFilterState.action[action] = checked;
1432
+ dispatch({
1433
+ type: ActionType.UpdateActionErrorFilterState,
1434
+ actionErrorFilterState,
1435
+ });
1436
+ }}
1437
+ />
1438
+ );
1439
+ })
1440
+ }
1402
1441
  </ButtonInputGroup>
1403
1442
  {/* Target */}
1404
- <ButtonInputGroup label="Target">
1443
+ <ButtonInputGroup
1444
+ label="Target"
1445
+ wrapButtonsAndAddGaps
1446
+ >
1405
1447
  {/* List of targets */}
1406
- <div className="d-flex gap-1 flex-wrap">
1407
- {
1408
- Object.keys(targetMap)
1409
- .map((target) => {
1410
- const description = genHumanReadableName(target);
1411
- return (
1412
- <CheckboxButton
1413
- key={target}
1414
- id={`LogReviewer-target-${target}-checkbox`}
1415
- text={description}
1416
- ariaLabel={`include logs with target "${description}" in results`}
1417
- checked={actionErrorFilterState.target[target]}
1418
- noMarginOnRight
1419
- onChanged={(checked) => {
1420
- actionErrorFilterState.target[target] = checked;
1421
- dispatch({
1422
- type: ActionType.UpdateActionErrorFilterState,
1423
- actionErrorFilterState,
1424
- });
1425
- }}
1426
- />
1427
- );
1428
- })
1429
- }
1430
- </div>
1448
+ {
1449
+ Object.keys(targetMap)
1450
+ .map((target) => {
1451
+ const description = genHumanReadableName(target);
1452
+ return (
1453
+ <CheckboxButton
1454
+ key={target}
1455
+ id={`LogReviewer-target-${target}-checkbox`}
1456
+ text={description}
1457
+ ariaLabel={`include logs with target "${description}" in results`}
1458
+ checked={actionErrorFilterState.target[target]}
1459
+ noMarginOnRight
1460
+ onChanged={(checked) => {
1461
+ actionErrorFilterState.target[target] = checked;
1462
+ dispatch({
1463
+ type: ActionType.UpdateActionErrorFilterState,
1464
+ actionErrorFilterState,
1465
+ });
1466
+ }}
1467
+ />
1468
+ );
1469
+ })
1470
+ }
1431
1471
  </ButtonInputGroup>
1432
1472
  </TabBox>
1433
1473
  )