dce-reactkit 4.3.3 → 4.3.5-beta-progress-size.2

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.
@@ -3,7 +3,6 @@
3
3
  * @author Allison Zhang
4
4
  */
5
5
  declare enum ProgressBarSize {
6
- Small = "Small",
7
6
  Medium = "Medium",
8
7
  Large = "Large"
9
8
  }
package/dist/esm/index.js CHANGED
@@ -396,7 +396,7 @@ function requireReactDom_production () {
396
396
  reactDom_production.useFormStatus = function () {
397
397
  return ReactSharedInternals.H.useHostTransitionStatus();
398
398
  };
399
- reactDom_production.version = "19.0.0";
399
+ reactDom_production.version = "19.2.1";
400
400
  return reactDom_production;
401
401
  }
402
402
 
@@ -824,7 +824,7 @@ function requireReactDom_development () {
824
824
  reactDom_development.useFormStatus = function () {
825
825
  return resolveDispatcher().useHostTransitionStatus();
826
826
  };
827
- reactDom_development.version = "19.0.0";
827
+ reactDom_development.version = "19.2.1";
828
828
  "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
829
829
  "function" ===
830
830
  typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
@@ -2824,7 +2824,7 @@ const SimpleDateChooser = (props) => {
2824
2824
  */
2825
2825
  const askToEditInvalidDate = () => __awaiter(void 0, void 0, void 0, function* () {
2826
2826
  // Ask the user if they want to edit the date
2827
- const confirmed = yield confirm('Are you sure?', 'The current date is outside the normal range. If you edit it, you\'ll need to choose a new date in the normal range.', {
2827
+ const confirmed = yield confirm('Are you sure?', `The current date is outside the ${numMonthsToShow} month range. If you edit it, you'll need to choose a new date in the normal range.`, {
2828
2828
  confirmButtonText: 'Edit Date',
2829
2829
  });
2830
2830
  // Check if user confirmed
@@ -15305,12 +15305,38 @@ const Dropdown = (props) => {
15305
15305
  */
15306
15306
  var ProgressBarSize;
15307
15307
  (function (ProgressBarSize) {
15308
- ProgressBarSize["Small"] = "Small";
15309
15308
  ProgressBarSize["Medium"] = "Medium";
15310
15309
  ProgressBarSize["Large"] = "Large";
15311
15310
  })(ProgressBarSize || (ProgressBarSize = {}));
15312
15311
  var ProgressBarSize$1 = ProgressBarSize;
15313
15312
 
15313
+ /**
15314
+ * Pad a number's decimal with zeros on the right
15315
+ * (e.g. 5.2 becomes 5.20 with 2 digit padding)
15316
+ * @author Gabe Abrams
15317
+ * @param num the number to pad
15318
+ * @param numDigits the minimum number of digits after the decimal
15319
+ * @returns padded number
15320
+ */
15321
+ const padDecimalZeros = (num, numDigits) => {
15322
+ // Skip if nothing to do
15323
+ if (numDigits < 1) {
15324
+ return String(num);
15325
+ }
15326
+ // Convert to string
15327
+ let out = String(num);
15328
+ // Add a decimal point if there isn't one
15329
+ if (!out.includes('.')) {
15330
+ out += '.';
15331
+ }
15332
+ // Add zeros
15333
+ while (out.split('.')[1].length < numDigits) {
15334
+ out = `${out}0`;
15335
+ }
15336
+ // Return
15337
+ return out;
15338
+ };
15339
+
15314
15340
  /**
15315
15341
  * Customizable Progress Bar component using Bootstrap styles
15316
15342
  * @author Allison Zhang
@@ -15321,7 +15347,7 @@ var ProgressBarSize$1 = ProgressBarSize;
15321
15347
  // Multiplier for calculating width of number of items
15322
15348
  const ITEM_WIDTH_MULTIPLIER = 1.3;
15323
15349
  // Constant for percent width
15324
- const PERCENT_WIDTH = 3;
15350
+ const PERCENT_WIDTH = 2.7;
15325
15351
  // Constant for item width
15326
15352
  const ITEM_WIDTH = 2;
15327
15353
  /*------------------------------------------------------------------------*/
@@ -15331,11 +15357,9 @@ const ITEM_WIDTH = 2;
15331
15357
  let style = `
15332
15358
  .ProgressBar-number-of,
15333
15359
  .ProgressBar-percent {
15334
- flex: 0 0 auto;
15335
15360
  white-space: nowrap;
15336
- padding-right: 0.5em;
15337
- padding-left: 0.25em;
15338
- text-align: right;
15361
+ padding-right: 0.3em;
15362
+ text-align: left;
15339
15363
  transition: width .25s ease;
15340
15364
  }
15341
15365
 
@@ -15355,7 +15379,7 @@ const ProgressBar = (props) => {
15355
15379
  /*------------------------------------------------------------------------*/
15356
15380
  /* -------------------------------- Setup ------------------------------- */
15357
15381
  /*------------------------------------------------------------------------*/
15358
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
15382
+ var _a, _b, _c, _d;
15359
15383
  /* -------------- Props ------------- */
15360
15384
  // Destructure props
15361
15385
  const { striped, variant = Variant$1.Warning, bgVariant = Variant$1.Secondary, showOutline, size = ProgressBarSize$1.Medium, } = props;
@@ -15387,10 +15411,19 @@ const ProgressBar = (props) => {
15387
15411
  /*----------------------------------------*/
15388
15412
  /* ---------------- Sizes --------------- */
15389
15413
  /*----------------------------------------*/
15414
+ // Add dynamic general style
15415
+ style += `
15416
+ .ProgressBar-percent {
15417
+ min-width: ${(status.usePercent ? (_a = status.numDecimalPlaces) !== null && _a !== void 0 ? _a : 0 : 0) + PERCENT_WIDTH}em;
15418
+ }
15419
+ .ProgressBar-number-of {
15420
+ min-width: ${((!status.usePercent ? String((_b = status.total) !== null && _b !== void 0 ? _b : 0).length || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
15421
+ }
15422
+ `;
15390
15423
  // Size styles
15391
15424
  switch (size) {
15392
- case ProgressBarSize$1.Small:
15393
- // Small size
15425
+ case ProgressBarSize$1.Medium:
15426
+ // Medium size
15394
15427
  style += `
15395
15428
  .ProgressBar-container .ProgressBar-number-of, .ProgressBar-container .ProgressBar-percent {
15396
15429
  font-size: 1em;
@@ -15403,18 +15436,10 @@ const ProgressBar = (props) => {
15403
15436
  height: 1.5em;
15404
15437
  border-radius: 0.5em;
15405
15438
  }
15406
- .ProgressBar-percent {
15407
- min-width: ${((status.usePercent ? (_a = status.numDecimalPlaces) !== null && _a !== void 0 ? _a : 0 : 0) * 1) + PERCENT_WIDTH}em;
15408
- max-width: ${((status.usePercent ? (_b = status.numDecimalPlaces) !== null && _b !== void 0 ? _b : 0 : 0) * 1) + PERCENT_WIDTH}em;
15409
- }
15410
- .ProgressBar-number-of {
15411
- min-width: ${((!status.usePercent ? ((_c = status.total) === null || _c === void 0 ? void 0 : _c.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
15412
- max-width: ${((!status.usePercent ? ((_d = status.total) === null || _d === void 0 ? void 0 : _d.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
15413
- }
15414
15439
  `;
15415
15440
  break;
15416
- case ProgressBarSize$1.Medium:
15417
- // Medium size
15441
+ case ProgressBarSize$1.Large:
15442
+ // Large size
15418
15443
  style += `
15419
15444
  .ProgressBar-container .ProgressBar-number-of, .ProgressBar-container .ProgressBar-percent {
15420
15445
  font-size: 1.5em;
@@ -15427,47 +15452,14 @@ const ProgressBar = (props) => {
15427
15452
  height: 2em;
15428
15453
  border-radius: 0.7em;
15429
15454
  }
15430
- .ProgressBar-percent {
15431
- min-width: ${((status.usePercent ? (_e = status.numDecimalPlaces) !== null && _e !== void 0 ? _e : 0 : 0) * 1) + PERCENT_WIDTH}em;
15432
- max-width: ${((status.usePercent ? (_f = status.numDecimalPlaces) !== null && _f !== void 0 ? _f : 0 : 0) * 1) + PERCENT_WIDTH}em;
15433
- }
15434
- .ProgressBar-number-of {
15435
- min-width: ${((!status.usePercent ? ((_g = status.total) === null || _g === void 0 ? void 0 : _g.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
15436
- max-width: ${((!status.usePercent ? ((_h = status.total) === null || _h === void 0 ? void 0 : _h.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
15437
- }
15438
- `;
15439
- break;
15440
- case ProgressBarSize$1.Large:
15441
- // Large size
15442
- style += `
15443
- .ProgressBar-container .ProgressBar-number-of, .ProgressBar-container .ProgressBar-percent {
15444
- font-size: 2em;
15445
- }
15446
- .ProgressBar-container .ProgressBar-background {
15447
- height: 3em;
15448
- border-radius: 1em;
15449
- }
15450
- .ProgressBar-container .ProgressBar-bar {
15451
- height: 3em;
15452
- border-radius: 1em;
15453
- }
15454
- .ProgressBar-percent {
15455
- min-width: ${((status.usePercent ? (_j = status.numDecimalPlaces) !== null && _j !== void 0 ? _j : 0 : 0) * 1) + PERCENT_WIDTH}em;
15456
- max-width: ${((status.usePercent ? (_k = status.numDecimalPlaces) !== null && _k !== void 0 ? _k : 0 : 0) * 1) + PERCENT_WIDTH}em;
15457
- }
15458
- .ProgressBar-number-of {
15459
- min-width: ${((!status.usePercent ? ((_l = status.total) === null || _l === void 0 ? void 0 : _l.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
15460
- max-width: ${((!status.usePercent ? ((_m = status.total) === null || _m === void 0 ? void 0 : _m.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
15461
- }
15462
15455
  `;
15463
15456
  break;
15464
15457
  }
15465
15458
  // Get the width of the outline based on size
15466
15459
  const outlineWidth = (() => {
15467
15460
  switch (size) {
15468
- case ProgressBarSize$1.Small: return '0.05em';
15469
- case ProgressBarSize$1.Medium: return '0.08em';
15470
- case ProgressBarSize$1.Large: return '0.1em';
15461
+ case ProgressBarSize$1.Medium: return '0.05em';
15462
+ case ProgressBarSize$1.Large: return '0.08em';
15471
15463
  default: return '0.05em';
15472
15464
  }
15473
15465
  })();
@@ -15492,33 +15484,46 @@ const ProgressBar = (props) => {
15492
15484
  }
15493
15485
  `;
15494
15486
  // Stripes for striped effect
15495
- const stripes = (React__default.createElement("div", null,
15496
- React__default.createElement("style", null, stripesStyle),
15497
- React__default.createElement("div", { className: "ProgressBar-stripes position-absolute ", style: {
15498
- width: '200%',
15499
- height: '100%',
15500
- } }, "\u00A0")));
15487
+ let stripes = null;
15488
+ if (striped) {
15489
+ stripes = (React__default.createElement("div", null,
15490
+ React__default.createElement("style", null, stripesStyle),
15491
+ React__default.createElement("div", { className: "ProgressBar-stripes position-absolute", style: {
15492
+ width: '200%',
15493
+ height: '100%',
15494
+ } }, "\u00A0")));
15495
+ }
15501
15496
  /*----------------------------------------*/
15502
15497
  /* --------------- Main UI -------------- */
15503
15498
  /*----------------------------------------*/
15499
+ // Calculate the width of the progress bar
15500
+ let progressBarWidthPercent = 0;
15501
+ if (status.usePercent) {
15502
+ // Use percent progress directly
15503
+ progressBarWidthPercent = status.percentProgress;
15504
+ }
15505
+ else if (status.total > 0) {
15506
+ // Calculate percent progress from items
15507
+ progressBarWidthPercent = (status.numComplete / status.total) * 100;
15508
+ }
15504
15509
  // Render the progress bar
15505
15510
  return (React__default.createElement("div", { className: "ProgressBar-container d-flex align-items-center" },
15506
15511
  React__default.createElement("style", null, style),
15507
- !status.usePercent && status.numComplete && (React__default.createElement("span", { className: "ProgressBar-number-of pe-2 align-self-center" },
15512
+ !status.usePercent && status.numComplete && (React__default.createElement("span", { className: "ProgressBar-number-of" },
15508
15513
  status.numComplete,
15509
15514
  "\u00A0of\u00A0",
15510
15515
  status.total)),
15511
- status.usePercent && status.percentProgress && (React__default.createElement("span", { className: "ProgressBar-percent pe-2 align-self-center" },
15512
- status.percentProgress.toFixed((_o = status === null || status === void 0 ? void 0 : status.numDecimalPlaces) !== null && _o !== void 0 ? _o : 0),
15516
+ status.usePercent && status.percentProgress && (React__default.createElement("span", { className: "ProgressBar-percent" },
15517
+ padDecimalZeros(roundToNumDecimals(status.percentProgress, (_c = status === null || status === void 0 ? void 0 : status.numDecimalPlaces) !== null && _c !== void 0 ? _c : 0), (_d = status === null || status === void 0 ? void 0 : status.numDecimalPlaces) !== null && _d !== void 0 ? _d : 0),
15513
15518
  "%")),
15514
- React__default.createElement("div", { className: `ProgressBar-background bg-${bgVariant} w-100`, style: {
15519
+ React__default.createElement("div", { className: `ProgressBar-background bg-${bgVariant} flex-grow-1`, style: {
15515
15520
  boxShadow: `0 0 0 ${outlineWidth} ${showOutline ? '#000' : '#DEE2E6'}`,
15516
15521
  }, "aria-valuenow": status.usePercent ? status.percentProgress : status.numComplete, "aria-valuemin": 0, "aria-valuemax": status.usePercent ? 100 : status.total },
15517
15522
  React__default.createElement("div", { className: `ProgressBar-bar bg-${variant} text-start position-relative`, style: {
15518
- width: `${(status.usePercent ? status.percentProgress : (status.numComplete / status.total) * 100)}%`,
15523
+ width: `${progressBarWidthPercent}%`,
15519
15524
  overflow: 'hidden',
15520
15525
  } },
15521
- striped && stripes,
15526
+ stripes,
15522
15527
  "\u00A0"))));
15523
15528
  };
15524
15529
 
@@ -15699,33 +15704,6 @@ const forceNumIntoBounds = (num, min, max) => {
15699
15704
  return Math.max(min, Math.min(max, num));
15700
15705
  };
15701
15706
 
15702
- /**
15703
- * Pad a number's decimal with zeros on the right
15704
- * (e.g. 5.2 becomes 5.20 with 2 digit padding)
15705
- * @author Gabe Abrams
15706
- * @param num the number to pad
15707
- * @param numDigits the minimum number of digits after the decimal
15708
- * @returns padded number
15709
- */
15710
- const padDecimalZeros = (num, numDigits) => {
15711
- // Skip if nothing to do
15712
- if (numDigits < 1) {
15713
- return String(num);
15714
- }
15715
- // Convert to string
15716
- let out = String(num);
15717
- // Add a decimal point if there isn't one
15718
- if (!out.includes('.')) {
15719
- out += '.';
15720
- }
15721
- // Add zeros
15722
- while (out.split('.')[1].length < numDigits) {
15723
- out = `${out}0`;
15724
- }
15725
- // Return
15726
- return out;
15727
- };
15728
-
15729
15707
  /**
15730
15708
  * Stub a server endpoint response
15731
15709
  * @author Gabe Abrams
@@ -15841,8 +15819,9 @@ const onlyKeepLetters = (str) => {
15841
15819
  */
15842
15820
  const parallelLimit = (taskFunctions, limit) => __awaiter(void 0, void 0, void 0, function* () {
15843
15821
  const results = [];
15822
+ let exited = false;
15844
15823
  // Wait until finished with all tasks
15845
- yield new Promise((resolve) => {
15824
+ yield new Promise((resolve, reject) => {
15846
15825
  /* ------------- Helpers ------------ */
15847
15826
  let nextTaskIndex = 0;
15848
15827
  let numFinishedTasks = 0;
@@ -15857,16 +15836,28 @@ const parallelLimit = (taskFunctions, limit) => __awaiter(void 0, void 0, void 0
15857
15836
  if (!taskFunction) {
15858
15837
  return;
15859
15838
  }
15860
- // Execute task
15861
- const result = yield taskFunction();
15862
- // Add results
15863
- results[taskIndex] = result;
15864
- // Tally and finish
15865
- if (++numFinishedTasks === taskFunctions.length) {
15866
- return resolve();
15839
+ try {
15840
+ // Execute task
15841
+ const result = yield taskFunction();
15842
+ // Add results
15843
+ results[taskIndex] = result;
15844
+ // Tally and finish
15845
+ if (++numFinishedTasks === taskFunctions.length) {
15846
+ exited = true;
15847
+ return resolve();
15848
+ }
15849
+ if (!exited) {
15850
+ // Not finished! Start another task
15851
+ startTask();
15852
+ }
15853
+ }
15854
+ catch (err) {
15855
+ // Reject only once
15856
+ if (!exited) {
15857
+ exited = true;
15858
+ return reject(err);
15859
+ }
15867
15860
  }
15868
- // Not finished! Start another task
15869
- startTask();
15870
15861
  });
15871
15862
  /* ----------- Start Tasks ---------- */
15872
15863
  // If no limit, start all tasks. At least start 1 task