dce-reactkit 3.0.40 → 3.0.43

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/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import React, { useState, useRef, useEffect } from 'react';
1
+ import React, { useState, useRef, useEffect, useReducer } from 'react';
2
2
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
3
- import { faExclamationTriangle, faCircle, faDotCircle, faCheckSquare } from '@fortawesome/free-solid-svg-icons';
3
+ import { faExclamationTriangle, faCircle, faDotCircle, faCheckSquare, faHourglass, faClipboard } from '@fortawesome/free-solid-svg-icons';
4
4
  import { faCircle as faCircle$1, faSquare } from '@fortawesome/free-regular-svg-icons';
5
5
 
6
6
  /******************************************************************************
@@ -271,7 +271,7 @@ const ModalButtonTypeToLabelAndVariant = {
271
271
  /*------------------------------------------------------------------------*/
272
272
  /* Style */
273
273
  /*------------------------------------------------------------------------*/
274
- const style$4 = `
274
+ const style$6 = `
275
275
  .Modal-backdrop {
276
276
  position: fixed;
277
277
  top: 0;
@@ -445,7 +445,7 @@ const Modal = (props) => {
445
445
  left: 0,
446
446
  right: 0,
447
447
  } },
448
- React.createElement("style", null, style$4),
448
+ React.createElement("style", null, style$6),
449
449
  React.createElement("div", { className: `Modal-backdrop ${backdropAnimationClass}`, style: {
450
450
  zIndex: 5000000003,
451
451
  }, onClick: () => __awaiter(void 0, void 0, void 0, function* () {
@@ -710,7 +710,7 @@ const AppWrapper = (props) => {
710
710
  /*------------------------------------------------------------------------*/
711
711
  /* Style */
712
712
  /*------------------------------------------------------------------------*/
713
- const style$3 = `
713
+ const style$5 = `
714
714
  /* Container fades in */
715
715
  .LoadingSpinner-container {
716
716
  animation-name: LoadingSpinner-container-fade-in;
@@ -788,7 +788,7 @@ const LoadingSpinner = () => {
788
788
  /*------------------------------------------------------------------------*/
789
789
  // Add all four blips to a container
790
790
  return (React.createElement("div", { className: "text-center LoadingSpinner LoadingSpinner-container" },
791
- React.createElement("style", null, style$3),
791
+ React.createElement("style", null, style$5),
792
792
  React.createElement(FontAwesomeIcon, { icon: faCircle, className: "LoadingSpinner-blip-1 me-1" }),
793
793
  React.createElement(FontAwesomeIcon, { icon: faCircle, className: "LoadingSpinner-blip-2 me-1" }),
794
794
  React.createElement(FontAwesomeIcon, { icon: faCircle, className: "LoadingSpinner-blip-3 me-1" }),
@@ -802,7 +802,7 @@ const LoadingSpinner = () => {
802
802
  /*------------------------------------------------------------------------*/
803
803
  /* Style */
804
804
  /*------------------------------------------------------------------------*/
805
- const style$2 = `
805
+ const style$4 = `
806
806
  /* Tab Box */
807
807
  .TabBox-box {
808
808
  /* Light Border */
@@ -882,7 +882,7 @@ const TabBox = (props) => {
882
882
  /*----------------------------------------*/
883
883
  // Full UI
884
884
  return (React.createElement("div", { className: `TabBox-container ${noBottomMargin ? '' : 'mb-2'}` },
885
- React.createElement("style", null, style$2),
885
+ React.createElement("style", null, style$4),
886
886
  React.createElement("div", { className: "TabBox-title-container" },
887
887
  React.createElement("div", { className: "TabBox-title" }, title)),
888
888
  React.createElement("div", { className: `TabBox-box ps-2 pt-2 pe-2 ${noBottomPadding ? '' : 'pb-2'}` },
@@ -1154,7 +1154,7 @@ const SimpleDateChooser = (props) => {
1154
1154
  /*------------------------------------------------------------------------*/
1155
1155
  /* Style */
1156
1156
  /*------------------------------------------------------------------------*/
1157
- const style$1 = `
1157
+ const style$3 = `
1158
1158
  .Drawer-container {
1159
1159
  margin-left: 1rem;
1160
1160
  margin-right: 1rem;
@@ -1186,7 +1186,7 @@ const Drawer = (props) => {
1186
1186
  /* Main UI */
1187
1187
  /*----------------------------------------*/
1188
1188
  return (React.createElement("div", { className: "Drawer-container" },
1189
- React.createElement("style", null, style$1),
1189
+ React.createElement("style", null, style$3),
1190
1190
  children));
1191
1191
  };
1192
1192
 
@@ -1197,7 +1197,7 @@ const Drawer = (props) => {
1197
1197
  /*------------------------------------------------------------------------*/
1198
1198
  /* Style */
1199
1199
  /*------------------------------------------------------------------------*/
1200
- const style = `
1200
+ const style$2 = `
1201
1201
  .PopSuccessMark-outer-container {
1202
1202
  position: relative;
1203
1203
  display: inline-block;
@@ -1302,7 +1302,7 @@ const PopSuccessMark = (props) => {
1302
1302
  width: `${sizeRem}rem`,
1303
1303
  height: `${sizeRem}rem`,
1304
1304
  }, "aria-label": "checkmark indicating success" },
1305
- React.createElement("style", null, style),
1305
+ React.createElement("style", null, style$2),
1306
1306
  React.createElement("div", { className: `PopSuccessMark-check-stroke-1 bg-${checkVariant}`, style: {
1307
1307
  borderRadius: `${sizeRem / 5}rem`,
1308
1308
  } }),
@@ -1311,6 +1311,336 @@ const PopSuccessMark = (props) => {
1311
1311
  } })));
1312
1312
  };
1313
1313
 
1314
+ /**
1315
+ * Failure x mark that pops into view
1316
+ * @author Gabe Abrams
1317
+ */
1318
+ /*------------------------------------------------------------------------*/
1319
+ /* Style */
1320
+ /*------------------------------------------------------------------------*/
1321
+ const style$1 = `
1322
+ .PopFailureMark-outer-container {
1323
+ position: relative;
1324
+ display: inline-block;
1325
+ border-radius: 50%;
1326
+
1327
+ animation-name: PopFailureMark-outer-container;
1328
+ animation-duration: 0.8s;
1329
+ animation-fill-mode: both;
1330
+ animation-iteration-count: 1;
1331
+ animation-timing-function: ease-out;
1332
+ }
1333
+ @keyframes PopFailureMark-outer-container {
1334
+ 0% {
1335
+ opacity: 0;
1336
+ transform: scale(1.5);
1337
+ filter: saturate(0);
1338
+ }
1339
+ 80.7% {
1340
+ opacity: 1;
1341
+ transform: scale(1);
1342
+ filter: saturate(0);
1343
+ }
1344
+ 100% {
1345
+ opacity: 1;
1346
+ transform: scale(1);
1347
+ filter: saturate(1);
1348
+ }
1349
+ }
1350
+
1351
+ .PopFailureMark-x-stroke-1 {
1352
+ position: absolute;
1353
+ left: 25%;
1354
+ top: 19%;
1355
+
1356
+ display: inline-block;
1357
+ height: 16%;
1358
+ width: 70%;
1359
+
1360
+ transform-origin: left;
1361
+
1362
+ animation-name: PopFailureMark-x-stroke-1;
1363
+ animation-duration: 0.3s;
1364
+ animation-delay: 0.3s;
1365
+ animation-fill-mode: both;
1366
+ animation-iteration-count: 1;
1367
+ animation-timing-function: ease-in;
1368
+ }
1369
+ @keyframes PopFailureMark-x-stroke-1 {
1370
+ 0% {
1371
+ transform: rotate(45deg) scaleX(0);
1372
+ }
1373
+ 100% {
1374
+ transform: rotate(45deg) scaleX(1);
1375
+ }
1376
+ }
1377
+
1378
+ .PopFailureMark-x-stroke-2 {
1379
+ position: absolute;
1380
+ left: 75%;
1381
+ top: 19%;
1382
+
1383
+ display: inline-block;
1384
+ height: 16%;
1385
+ width: 70%;
1386
+
1387
+ transform-origin: left;
1388
+
1389
+ animation-name: PopFailureMark-x-stroke-2;
1390
+ animation-duration: 0.3s;
1391
+ animation-delay: 0.6s;
1392
+ animation-fill-mode: both;
1393
+ animation-iteration-count: 1;
1394
+ animation-timing-function: ease-out;
1395
+ }
1396
+ @keyframes PopFailureMark-x-stroke-2 {
1397
+ 0% {
1398
+ transform: rotate(135deg) scaleX(0);
1399
+ }
1400
+ 100% {
1401
+ transform: rotate(135deg) scaleX(1);
1402
+ }
1403
+ }
1404
+ `;
1405
+ /*------------------------------------------------------------------------*/
1406
+ /* Component */
1407
+ /*------------------------------------------------------------------------*/
1408
+ const PopFailureMark = (props) => {
1409
+ /*------------------------------------------------------------------------*/
1410
+ /* Setup */
1411
+ /*------------------------------------------------------------------------*/
1412
+ /* -------------- Props ------------- */
1413
+ // Destructure all props
1414
+ const { sizeRem = 3, circleVariant = 'danger', xVariant = 'white', } = props;
1415
+ /*------------------------------------------------------------------------*/
1416
+ /* Render */
1417
+ /*------------------------------------------------------------------------*/
1418
+ /*----------------------------------------*/
1419
+ /* Main UI */
1420
+ /*----------------------------------------*/
1421
+ return (React.createElement("div", { className: `PopFailureMark-outer-container bg-${circleVariant}`, style: {
1422
+ width: `${sizeRem}rem`,
1423
+ height: `${sizeRem}rem`,
1424
+ }, "aria-label": "mark indicating failure" },
1425
+ React.createElement("style", null, style$1),
1426
+ React.createElement("div", { className: `PopFailureMark-x-stroke-1 bg-${xVariant}`, style: {
1427
+ borderRadius: `${sizeRem / 5}rem`,
1428
+ } }),
1429
+ React.createElement("div", { className: `PopFailureMark-x-stroke-2 bg-${xVariant}`, style: {
1430
+ borderRadius: `${sizeRem / 5}rem`,
1431
+ } })));
1432
+ };
1433
+
1434
+ /**
1435
+ * Failure pending that pops into view
1436
+ * @author Gabe Abrams
1437
+ */
1438
+ /*------------------------------------------------------------------------*/
1439
+ /* Style */
1440
+ /*------------------------------------------------------------------------*/
1441
+ const style = `
1442
+ .PopPendingMark-outer-container {
1443
+ position: relative;
1444
+ display: inline-block;
1445
+ border-radius: 50%;
1446
+
1447
+ animation-name: PopPendingMark-outer-container;
1448
+ animation-duration: 0.8s;
1449
+ animation-fill-mode: both;
1450
+ animation-iteration-count: 1;
1451
+ animation-timing-function: ease-out;
1452
+ }
1453
+ @keyframes PopPendingMark-outer-container {
1454
+ 0% {
1455
+ opacity: 0;
1456
+ transform: scale(1.5);
1457
+ filter: saturate(0);
1458
+ }
1459
+ 80.7% {
1460
+ opacity: 1;
1461
+ transform: scale(1);
1462
+ filter: saturate(0);
1463
+ }
1464
+ 100% {
1465
+ opacity: 1;
1466
+ transform: scale(1);
1467
+ filter: saturate(1);
1468
+ }
1469
+ }
1470
+
1471
+ .PopPendingMark-hourglass {
1472
+ position: absolute;
1473
+ left: 28%;
1474
+ top: 21%;
1475
+
1476
+ animation-name: PopPendingMark-pending;
1477
+ animation-duration: 0.3s;
1478
+ animation-delay: 0.3s;
1479
+ animation-fill-mode: both;
1480
+ animation-iteration-count: 1;
1481
+ animation-timing-function: ease-in;
1482
+ }
1483
+ @keyframes PopPendingMark-pending {
1484
+ 0% {
1485
+ transform: scale(0.7) rotate(30deg);
1486
+ opacity: 0;
1487
+ }
1488
+ 100% {
1489
+ transform: scale(1) rotate(0);
1490
+ opacity: 1;
1491
+ }
1492
+ }
1493
+ `;
1494
+ /*------------------------------------------------------------------------*/
1495
+ /* Component */
1496
+ /*------------------------------------------------------------------------*/
1497
+ const PopPendingMark = (props) => {
1498
+ /*------------------------------------------------------------------------*/
1499
+ /* Setup */
1500
+ /*------------------------------------------------------------------------*/
1501
+ /* -------------- Props ------------- */
1502
+ // Destructure all props
1503
+ const { sizeRem = 3, circleVariant = 'warning', hourglassVariant = 'white', } = props;
1504
+ /*------------------------------------------------------------------------*/
1505
+ /* Render */
1506
+ /*------------------------------------------------------------------------*/
1507
+ /*----------------------------------------*/
1508
+ /* Main UI */
1509
+ /*----------------------------------------*/
1510
+ return (React.createElement("div", { className: `PopPendingMark-outer-container bg-${circleVariant}`, style: {
1511
+ width: `${sizeRem}rem`,
1512
+ height: `${sizeRem}rem`,
1513
+ }, "aria-label": "mark indicating that the item is pending" },
1514
+ React.createElement("style", null, style),
1515
+ React.createElement("div", null,
1516
+ React.createElement(FontAwesomeIcon, { icon: faHourglass, className: `PopPendingMark-hourglass text-${hourglassVariant}`, style: {
1517
+ fontSize: `${sizeRem * 0.6}rem`,
1518
+ } }))));
1519
+ };
1520
+
1521
+ /**
1522
+ * Copiable text box
1523
+ * @author Gabe Abrams
1524
+ */
1525
+ /* ------------- Actions ------------ */
1526
+ // Types of actions
1527
+ var ActionType;
1528
+ (function (ActionType) {
1529
+ // Indicate that the text was recently copied
1530
+ ActionType["IndicateRecentlyCopied"] = "indicate-recently-copied";
1531
+ // Clear the status
1532
+ ActionType["ClearRecentlyCopiedStatus"] = "clear-recently-copied-status";
1533
+ })(ActionType || (ActionType = {}));
1534
+ /**
1535
+ * Reducer that executes actions
1536
+ * @author Gabe Abrams
1537
+ * @param state current state
1538
+ * @param action action to execute
1539
+ */
1540
+ const reducer = (state, action) => {
1541
+ switch (action.type) {
1542
+ case ActionType.IndicateRecentlyCopied: {
1543
+ return {
1544
+ recentlyCopied: true,
1545
+ };
1546
+ }
1547
+ case ActionType.ClearRecentlyCopiedStatus: {
1548
+ return {
1549
+ recentlyCopied: false,
1550
+ };
1551
+ }
1552
+ default: {
1553
+ return state;
1554
+ }
1555
+ }
1556
+ };
1557
+ /*------------------------------------------------------------------------*/
1558
+ /* Component */
1559
+ /*------------------------------------------------------------------------*/
1560
+ const CopiableBox = (props) => {
1561
+ /*------------------------------------------------------------------------*/
1562
+ /* Setup */
1563
+ /*------------------------------------------------------------------------*/
1564
+ /* -------------- Props ------------- */
1565
+ // Destructure all props
1566
+ const { name, text, label, labelIcon, minLabelWidthRem, multiline, numVisibleLines = 10, } = props;
1567
+ /* -------------- State ------------- */
1568
+ // Initial state
1569
+ const initialState = {
1570
+ recentlyCopied: false,
1571
+ };
1572
+ // Initialize state
1573
+ const [state, dispatch] = useReducer(reducer, initialState);
1574
+ // Destructure common state
1575
+ const { recentlyCopied, } = state;
1576
+ /*------------------------------------------------------------------------*/
1577
+ /* Component Functions */
1578
+ /*------------------------------------------------------------------------*/
1579
+ // Determine the id for the copiable text field
1580
+ const copiableFieldClassName = `CopiableBox-text-box-${name}`;
1581
+ /**
1582
+ * Perform a copy
1583
+ * @author Gabe Abrams
1584
+ */
1585
+ const performCopy = () => __awaiter(void 0, void 0, void 0, function* () {
1586
+ // Write to clipboard
1587
+ let copyFailed = false;
1588
+ try {
1589
+ yield navigator.clipboard.writeText(text);
1590
+ }
1591
+ catch (err) {
1592
+ copyFailed = true;
1593
+ }
1594
+ // Try copy again if it failed
1595
+ if (copyFailed) {
1596
+ try {
1597
+ const input = (document.getElementsByClassName(copiableFieldClassName)[0]);
1598
+ input.focus();
1599
+ input.select();
1600
+ document.execCommand('copy');
1601
+ input.blur();
1602
+ }
1603
+ catch (err) {
1604
+ return alert$1('Unable to copy', 'Oops! We couldn\'t copy that to the clipboard. Please copy the text manually.');
1605
+ }
1606
+ }
1607
+ // Show copied notice
1608
+ dispatch({
1609
+ type: ActionType.IndicateRecentlyCopied,
1610
+ });
1611
+ // Wait a moment
1612
+ yield waitMs(4000);
1613
+ // Hide copied notice
1614
+ dispatch({
1615
+ type: ActionType.ClearRecentlyCopiedStatus,
1616
+ });
1617
+ });
1618
+ /*------------------------------------------------------------------------*/
1619
+ /* Render */
1620
+ /*------------------------------------------------------------------------*/
1621
+ /*----------------------------------------*/
1622
+ /* Main UI */
1623
+ /*----------------------------------------*/
1624
+ return (React.createElement("div", { className: "input-group mb-2" },
1625
+ React.createElement("span", { className: "input-group-text", style: {
1626
+ minWidth: (minLabelWidthRem
1627
+ ? `${minLabelWidthRem}rem`
1628
+ : undefined),
1629
+ } },
1630
+ labelIcon && (React.createElement(FontAwesomeIcon, { icon: labelIcon, className: "me-1" })),
1631
+ label),
1632
+ multiline
1633
+ ? (React.createElement("textarea", { className: `${copiableFieldClassName} CopiableBox-text-multiline form-control bg-white text-dark`, value: text, "aria-label": `${label} text`, rows: numVisibleLines, readOnly: true }))
1634
+ : (React.createElement("input", { type: "text", className: `${copiableFieldClassName} CopiableBox-text-single-line form-control bg-white text-dark`, value: text, "aria-label": `${label} text`, readOnly: true })),
1635
+ React.createElement("button", { className: "btn btn-secondary", type: "button", "aria-label": `copy ${label} to the clipboard`, disabled: recentlyCopied, style: {
1636
+ minWidth: '5.2rem',
1637
+ }, onClick: performCopy }, recentlyCopied
1638
+ ? 'Copied!'
1639
+ : (React.createElement("span", null,
1640
+ React.createElement(FontAwesomeIcon, { icon: faClipboard, className: "me-1" }),
1641
+ "Copy")))));
1642
+ };
1643
+
1314
1644
  /**
1315
1645
  * One minute in ms
1316
1646
  * @author Gabe Abrams
@@ -2063,7 +2393,7 @@ const getHumanReadableDate = (dateOrTimestamp) => {
2063
2393
  const { month, day, year, } = getTimeInfoInET(dateOrTimestamp);
2064
2394
  const currYear = getTimeInfoInET().year;
2065
2395
  // Create start of description
2066
- let description = `${monthMap[month]} ${getOrdinal(day)}`;
2396
+ let description = `${monthMap[month]} ${day}${getOrdinal(day)}`;
2067
2397
  // Add on year if it's different
2068
2398
  if (year !== currYear) {
2069
2399
  description += ` ${year}`;
@@ -2072,5 +2402,5 @@ const getHumanReadableDate = (dateOrTimestamp) => {
2072
2402
  return description;
2073
2403
  };
2074
2404
 
2075
- export { AppWrapper, ButtonInputGroup, CheckboxButton, DAY_IN_MS, Drawer, ErrorBox, ErrorWithCode, HOUR_IN_MS, LoadingSpinner, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, ParamType$1 as ParamType, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, Variant$1 as Variant, abbreviate, alert$1 as alert, avg, ceilToNumDecimals, confirm, floorToNumDecimals, forceNumIntoBounds, genRouteHandler, getHumanReadableDate, getOrdinal, getTimeInfoInET, handleError, handleSuccess, initServer, padDecimalZeros, padZerosLeft, roundToNumDecimals, showFatalError, startMinWait, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
2405
+ export { AppWrapper, ButtonInputGroup, CheckboxButton, CopiableBox, DAY_IN_MS, Drawer, ErrorBox, ErrorWithCode, HOUR_IN_MS, LoadingSpinner, MINUTE_IN_MS, Modal, ModalButtonType$1 as ModalButtonType, ModalSize$1 as ModalSize, ModalType$1 as ModalType, ParamType$1 as ParamType, PopFailureMark, PopPendingMark, PopSuccessMark, RadioButton, ReactKitErrorCode$1 as ReactKitErrorCode, SimpleDateChooser, TabBox, Variant$1 as Variant, abbreviate, alert$1 as alert, avg, ceilToNumDecimals, confirm, floorToNumDecimals, forceNumIntoBounds, genRouteHandler, getHumanReadableDate, getOrdinal, getTimeInfoInET, handleError, handleSuccess, initServer, padDecimalZeros, padZerosLeft, roundToNumDecimals, showFatalError, startMinWait, stubServerEndpoint, sum, visitServerEndpoint, waitMs };
2076
2406
  //# sourceMappingURL=index.js.map