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.
- package/dist/cjs/index.js +97 -106
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/types/ProgressBarSize.d.ts +0 -1
- package/dist/esm/index.js +97 -106
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/types/ProgressBarSize.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/package.json +1 -1
- package/src/components/ProgressBar.tsx +61 -75
- package/src/helpers/parallelLimit.ts +25 -12
- package/src/types/ProgressBarSize.ts +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -423,7 +423,7 @@ function requireReactDom_production () {
|
|
|
423
423
|
reactDom_production.useFormStatus = function () {
|
|
424
424
|
return ReactSharedInternals.H.useHostTransitionStatus();
|
|
425
425
|
};
|
|
426
|
-
reactDom_production.version = "19.
|
|
426
|
+
reactDom_production.version = "19.2.1";
|
|
427
427
|
return reactDom_production;
|
|
428
428
|
}
|
|
429
429
|
|
|
@@ -851,7 +851,7 @@ function requireReactDom_development () {
|
|
|
851
851
|
reactDom_development.useFormStatus = function () {
|
|
852
852
|
return resolveDispatcher().useHostTransitionStatus();
|
|
853
853
|
};
|
|
854
|
-
reactDom_development.version = "19.
|
|
854
|
+
reactDom_development.version = "19.2.1";
|
|
855
855
|
"undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ &&
|
|
856
856
|
"function" ===
|
|
857
857
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop &&
|
|
@@ -2851,7 +2851,7 @@ const SimpleDateChooser = (props) => {
|
|
|
2851
2851
|
*/
|
|
2852
2852
|
const askToEditInvalidDate = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2853
2853
|
// Ask the user if they want to edit the date
|
|
2854
|
-
const confirmed = yield confirm('Are you sure?',
|
|
2854
|
+
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.`, {
|
|
2855
2855
|
confirmButtonText: 'Edit Date',
|
|
2856
2856
|
});
|
|
2857
2857
|
// Check if user confirmed
|
|
@@ -15332,12 +15332,38 @@ const Dropdown = (props) => {
|
|
|
15332
15332
|
*/
|
|
15333
15333
|
var ProgressBarSize;
|
|
15334
15334
|
(function (ProgressBarSize) {
|
|
15335
|
-
ProgressBarSize["Small"] = "Small";
|
|
15336
15335
|
ProgressBarSize["Medium"] = "Medium";
|
|
15337
15336
|
ProgressBarSize["Large"] = "Large";
|
|
15338
15337
|
})(ProgressBarSize || (ProgressBarSize = {}));
|
|
15339
15338
|
var ProgressBarSize$1 = ProgressBarSize;
|
|
15340
15339
|
|
|
15340
|
+
/**
|
|
15341
|
+
* Pad a number's decimal with zeros on the right
|
|
15342
|
+
* (e.g. 5.2 becomes 5.20 with 2 digit padding)
|
|
15343
|
+
* @author Gabe Abrams
|
|
15344
|
+
* @param num the number to pad
|
|
15345
|
+
* @param numDigits the minimum number of digits after the decimal
|
|
15346
|
+
* @returns padded number
|
|
15347
|
+
*/
|
|
15348
|
+
const padDecimalZeros = (num, numDigits) => {
|
|
15349
|
+
// Skip if nothing to do
|
|
15350
|
+
if (numDigits < 1) {
|
|
15351
|
+
return String(num);
|
|
15352
|
+
}
|
|
15353
|
+
// Convert to string
|
|
15354
|
+
let out = String(num);
|
|
15355
|
+
// Add a decimal point if there isn't one
|
|
15356
|
+
if (!out.includes('.')) {
|
|
15357
|
+
out += '.';
|
|
15358
|
+
}
|
|
15359
|
+
// Add zeros
|
|
15360
|
+
while (out.split('.')[1].length < numDigits) {
|
|
15361
|
+
out = `${out}0`;
|
|
15362
|
+
}
|
|
15363
|
+
// Return
|
|
15364
|
+
return out;
|
|
15365
|
+
};
|
|
15366
|
+
|
|
15341
15367
|
/**
|
|
15342
15368
|
* Customizable Progress Bar component using Bootstrap styles
|
|
15343
15369
|
* @author Allison Zhang
|
|
@@ -15348,7 +15374,7 @@ var ProgressBarSize$1 = ProgressBarSize;
|
|
|
15348
15374
|
// Multiplier for calculating width of number of items
|
|
15349
15375
|
const ITEM_WIDTH_MULTIPLIER = 1.3;
|
|
15350
15376
|
// Constant for percent width
|
|
15351
|
-
const PERCENT_WIDTH =
|
|
15377
|
+
const PERCENT_WIDTH = 2.7;
|
|
15352
15378
|
// Constant for item width
|
|
15353
15379
|
const ITEM_WIDTH = 2;
|
|
15354
15380
|
/*------------------------------------------------------------------------*/
|
|
@@ -15358,11 +15384,9 @@ const ITEM_WIDTH = 2;
|
|
|
15358
15384
|
let style = `
|
|
15359
15385
|
.ProgressBar-number-of,
|
|
15360
15386
|
.ProgressBar-percent {
|
|
15361
|
-
flex: 0 0 auto;
|
|
15362
15387
|
white-space: nowrap;
|
|
15363
|
-
padding-right: 0.
|
|
15364
|
-
|
|
15365
|
-
text-align: right;
|
|
15388
|
+
padding-right: 0.3em;
|
|
15389
|
+
text-align: left;
|
|
15366
15390
|
transition: width .25s ease;
|
|
15367
15391
|
}
|
|
15368
15392
|
|
|
@@ -15382,7 +15406,7 @@ const ProgressBar = (props) => {
|
|
|
15382
15406
|
/*------------------------------------------------------------------------*/
|
|
15383
15407
|
/* -------------------------------- Setup ------------------------------- */
|
|
15384
15408
|
/*------------------------------------------------------------------------*/
|
|
15385
|
-
var _a, _b, _c, _d
|
|
15409
|
+
var _a, _b, _c, _d;
|
|
15386
15410
|
/* -------------- Props ------------- */
|
|
15387
15411
|
// Destructure props
|
|
15388
15412
|
const { striped, variant = Variant$1.Warning, bgVariant = Variant$1.Secondary, showOutline, size = ProgressBarSize$1.Medium, } = props;
|
|
@@ -15414,10 +15438,19 @@ const ProgressBar = (props) => {
|
|
|
15414
15438
|
/*----------------------------------------*/
|
|
15415
15439
|
/* ---------------- Sizes --------------- */
|
|
15416
15440
|
/*----------------------------------------*/
|
|
15441
|
+
// Add dynamic general style
|
|
15442
|
+
style += `
|
|
15443
|
+
.ProgressBar-percent {
|
|
15444
|
+
min-width: ${(status.usePercent ? (_a = status.numDecimalPlaces) !== null && _a !== void 0 ? _a : 0 : 0) + PERCENT_WIDTH}em;
|
|
15445
|
+
}
|
|
15446
|
+
.ProgressBar-number-of {
|
|
15447
|
+
min-width: ${((!status.usePercent ? String((_b = status.total) !== null && _b !== void 0 ? _b : 0).length || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
|
|
15448
|
+
}
|
|
15449
|
+
`;
|
|
15417
15450
|
// Size styles
|
|
15418
15451
|
switch (size) {
|
|
15419
|
-
case ProgressBarSize$1.
|
|
15420
|
-
//
|
|
15452
|
+
case ProgressBarSize$1.Medium:
|
|
15453
|
+
// Medium size
|
|
15421
15454
|
style += `
|
|
15422
15455
|
.ProgressBar-container .ProgressBar-number-of, .ProgressBar-container .ProgressBar-percent {
|
|
15423
15456
|
font-size: 1em;
|
|
@@ -15430,18 +15463,10 @@ const ProgressBar = (props) => {
|
|
|
15430
15463
|
height: 1.5em;
|
|
15431
15464
|
border-radius: 0.5em;
|
|
15432
15465
|
}
|
|
15433
|
-
.ProgressBar-percent {
|
|
15434
|
-
min-width: ${((status.usePercent ? (_a = status.numDecimalPlaces) !== null && _a !== void 0 ? _a : 0 : 0) * 1) + PERCENT_WIDTH}em;
|
|
15435
|
-
max-width: ${((status.usePercent ? (_b = status.numDecimalPlaces) !== null && _b !== void 0 ? _b : 0 : 0) * 1) + PERCENT_WIDTH}em;
|
|
15436
|
-
}
|
|
15437
|
-
.ProgressBar-number-of {
|
|
15438
|
-
min-width: ${((!status.usePercent ? ((_c = status.total) === null || _c === void 0 ? void 0 : _c.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
|
|
15439
|
-
max-width: ${((!status.usePercent ? ((_d = status.total) === null || _d === void 0 ? void 0 : _d.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
|
|
15440
|
-
}
|
|
15441
15466
|
`;
|
|
15442
15467
|
break;
|
|
15443
|
-
case ProgressBarSize$1.
|
|
15444
|
-
//
|
|
15468
|
+
case ProgressBarSize$1.Large:
|
|
15469
|
+
// Large size
|
|
15445
15470
|
style += `
|
|
15446
15471
|
.ProgressBar-container .ProgressBar-number-of, .ProgressBar-container .ProgressBar-percent {
|
|
15447
15472
|
font-size: 1.5em;
|
|
@@ -15454,47 +15479,14 @@ const ProgressBar = (props) => {
|
|
|
15454
15479
|
height: 2em;
|
|
15455
15480
|
border-radius: 0.7em;
|
|
15456
15481
|
}
|
|
15457
|
-
.ProgressBar-percent {
|
|
15458
|
-
min-width: ${((status.usePercent ? (_e = status.numDecimalPlaces) !== null && _e !== void 0 ? _e : 0 : 0) * 1) + PERCENT_WIDTH}em;
|
|
15459
|
-
max-width: ${((status.usePercent ? (_f = status.numDecimalPlaces) !== null && _f !== void 0 ? _f : 0 : 0) * 1) + PERCENT_WIDTH}em;
|
|
15460
|
-
}
|
|
15461
|
-
.ProgressBar-number-of {
|
|
15462
|
-
min-width: ${((!status.usePercent ? ((_g = status.total) === null || _g === void 0 ? void 0 : _g.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
|
|
15463
|
-
max-width: ${((!status.usePercent ? ((_h = status.total) === null || _h === void 0 ? void 0 : _h.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
|
|
15464
|
-
}
|
|
15465
|
-
`;
|
|
15466
|
-
break;
|
|
15467
|
-
case ProgressBarSize$1.Large:
|
|
15468
|
-
// Large size
|
|
15469
|
-
style += `
|
|
15470
|
-
.ProgressBar-container .ProgressBar-number-of, .ProgressBar-container .ProgressBar-percent {
|
|
15471
|
-
font-size: 2em;
|
|
15472
|
-
}
|
|
15473
|
-
.ProgressBar-container .ProgressBar-background {
|
|
15474
|
-
height: 3em;
|
|
15475
|
-
border-radius: 1em;
|
|
15476
|
-
}
|
|
15477
|
-
.ProgressBar-container .ProgressBar-bar {
|
|
15478
|
-
height: 3em;
|
|
15479
|
-
border-radius: 1em;
|
|
15480
|
-
}
|
|
15481
|
-
.ProgressBar-percent {
|
|
15482
|
-
min-width: ${((status.usePercent ? (_j = status.numDecimalPlaces) !== null && _j !== void 0 ? _j : 0 : 0) * 1) + PERCENT_WIDTH}em;
|
|
15483
|
-
max-width: ${((status.usePercent ? (_k = status.numDecimalPlaces) !== null && _k !== void 0 ? _k : 0 : 0) * 1) + PERCENT_WIDTH}em;
|
|
15484
|
-
}
|
|
15485
|
-
.ProgressBar-number-of {
|
|
15486
|
-
min-width: ${((!status.usePercent ? ((_l = status.total) === null || _l === void 0 ? void 0 : _l.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
|
|
15487
|
-
max-width: ${((!status.usePercent ? ((_m = status.total) === null || _m === void 0 ? void 0 : _m.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
|
|
15488
|
-
}
|
|
15489
15482
|
`;
|
|
15490
15483
|
break;
|
|
15491
15484
|
}
|
|
15492
15485
|
// Get the width of the outline based on size
|
|
15493
15486
|
const outlineWidth = (() => {
|
|
15494
15487
|
switch (size) {
|
|
15495
|
-
case ProgressBarSize$1.
|
|
15496
|
-
case ProgressBarSize$1.
|
|
15497
|
-
case ProgressBarSize$1.Large: return '0.1em';
|
|
15488
|
+
case ProgressBarSize$1.Medium: return '0.05em';
|
|
15489
|
+
case ProgressBarSize$1.Large: return '0.08em';
|
|
15498
15490
|
default: return '0.05em';
|
|
15499
15491
|
}
|
|
15500
15492
|
})();
|
|
@@ -15519,33 +15511,46 @@ const ProgressBar = (props) => {
|
|
|
15519
15511
|
}
|
|
15520
15512
|
`;
|
|
15521
15513
|
// Stripes for striped effect
|
|
15522
|
-
|
|
15523
|
-
|
|
15524
|
-
React__default["default"].createElement("div",
|
|
15525
|
-
|
|
15526
|
-
|
|
15527
|
-
|
|
15514
|
+
let stripes = null;
|
|
15515
|
+
if (striped) {
|
|
15516
|
+
stripes = (React__default["default"].createElement("div", null,
|
|
15517
|
+
React__default["default"].createElement("style", null, stripesStyle),
|
|
15518
|
+
React__default["default"].createElement("div", { className: "ProgressBar-stripes position-absolute", style: {
|
|
15519
|
+
width: '200%',
|
|
15520
|
+
height: '100%',
|
|
15521
|
+
} }, "\u00A0")));
|
|
15522
|
+
}
|
|
15528
15523
|
/*----------------------------------------*/
|
|
15529
15524
|
/* --------------- Main UI -------------- */
|
|
15530
15525
|
/*----------------------------------------*/
|
|
15526
|
+
// Calculate the width of the progress bar
|
|
15527
|
+
let progressBarWidthPercent = 0;
|
|
15528
|
+
if (status.usePercent) {
|
|
15529
|
+
// Use percent progress directly
|
|
15530
|
+
progressBarWidthPercent = status.percentProgress;
|
|
15531
|
+
}
|
|
15532
|
+
else if (status.total > 0) {
|
|
15533
|
+
// Calculate percent progress from items
|
|
15534
|
+
progressBarWidthPercent = (status.numComplete / status.total) * 100;
|
|
15535
|
+
}
|
|
15531
15536
|
// Render the progress bar
|
|
15532
15537
|
return (React__default["default"].createElement("div", { className: "ProgressBar-container d-flex align-items-center" },
|
|
15533
15538
|
React__default["default"].createElement("style", null, style),
|
|
15534
|
-
!status.usePercent && status.numComplete && (React__default["default"].createElement("span", { className: "ProgressBar-number-of
|
|
15539
|
+
!status.usePercent && status.numComplete && (React__default["default"].createElement("span", { className: "ProgressBar-number-of" },
|
|
15535
15540
|
status.numComplete,
|
|
15536
15541
|
"\u00A0of\u00A0",
|
|
15537
15542
|
status.total)),
|
|
15538
|
-
status.usePercent && status.percentProgress && (React__default["default"].createElement("span", { className: "ProgressBar-percent
|
|
15539
|
-
status.percentProgress.
|
|
15543
|
+
status.usePercent && status.percentProgress && (React__default["default"].createElement("span", { className: "ProgressBar-percent" },
|
|
15544
|
+
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),
|
|
15540
15545
|
"%")),
|
|
15541
|
-
React__default["default"].createElement("div", { className: `ProgressBar-background bg-${bgVariant}
|
|
15546
|
+
React__default["default"].createElement("div", { className: `ProgressBar-background bg-${bgVariant} flex-grow-1`, style: {
|
|
15542
15547
|
boxShadow: `0 0 0 ${outlineWidth} ${showOutline ? '#000' : '#DEE2E6'}`,
|
|
15543
15548
|
}, "aria-valuenow": status.usePercent ? status.percentProgress : status.numComplete, "aria-valuemin": 0, "aria-valuemax": status.usePercent ? 100 : status.total },
|
|
15544
15549
|
React__default["default"].createElement("div", { className: `ProgressBar-bar bg-${variant} text-start position-relative`, style: {
|
|
15545
|
-
width: `${
|
|
15550
|
+
width: `${progressBarWidthPercent}%`,
|
|
15546
15551
|
overflow: 'hidden',
|
|
15547
15552
|
} },
|
|
15548
|
-
|
|
15553
|
+
stripes,
|
|
15549
15554
|
"\u00A0"))));
|
|
15550
15555
|
};
|
|
15551
15556
|
|
|
@@ -15726,33 +15731,6 @@ const forceNumIntoBounds = (num, min, max) => {
|
|
|
15726
15731
|
return Math.max(min, Math.min(max, num));
|
|
15727
15732
|
};
|
|
15728
15733
|
|
|
15729
|
-
/**
|
|
15730
|
-
* Pad a number's decimal with zeros on the right
|
|
15731
|
-
* (e.g. 5.2 becomes 5.20 with 2 digit padding)
|
|
15732
|
-
* @author Gabe Abrams
|
|
15733
|
-
* @param num the number to pad
|
|
15734
|
-
* @param numDigits the minimum number of digits after the decimal
|
|
15735
|
-
* @returns padded number
|
|
15736
|
-
*/
|
|
15737
|
-
const padDecimalZeros = (num, numDigits) => {
|
|
15738
|
-
// Skip if nothing to do
|
|
15739
|
-
if (numDigits < 1) {
|
|
15740
|
-
return String(num);
|
|
15741
|
-
}
|
|
15742
|
-
// Convert to string
|
|
15743
|
-
let out = String(num);
|
|
15744
|
-
// Add a decimal point if there isn't one
|
|
15745
|
-
if (!out.includes('.')) {
|
|
15746
|
-
out += '.';
|
|
15747
|
-
}
|
|
15748
|
-
// Add zeros
|
|
15749
|
-
while (out.split('.')[1].length < numDigits) {
|
|
15750
|
-
out = `${out}0`;
|
|
15751
|
-
}
|
|
15752
|
-
// Return
|
|
15753
|
-
return out;
|
|
15754
|
-
};
|
|
15755
|
-
|
|
15756
15734
|
/**
|
|
15757
15735
|
* Stub a server endpoint response
|
|
15758
15736
|
* @author Gabe Abrams
|
|
@@ -15868,8 +15846,9 @@ const onlyKeepLetters = (str) => {
|
|
|
15868
15846
|
*/
|
|
15869
15847
|
const parallelLimit = (taskFunctions, limit) => __awaiter(void 0, void 0, void 0, function* () {
|
|
15870
15848
|
const results = [];
|
|
15849
|
+
let exited = false;
|
|
15871
15850
|
// Wait until finished with all tasks
|
|
15872
|
-
yield new Promise((resolve) => {
|
|
15851
|
+
yield new Promise((resolve, reject) => {
|
|
15873
15852
|
/* ------------- Helpers ------------ */
|
|
15874
15853
|
let nextTaskIndex = 0;
|
|
15875
15854
|
let numFinishedTasks = 0;
|
|
@@ -15884,16 +15863,28 @@ const parallelLimit = (taskFunctions, limit) => __awaiter(void 0, void 0, void 0
|
|
|
15884
15863
|
if (!taskFunction) {
|
|
15885
15864
|
return;
|
|
15886
15865
|
}
|
|
15887
|
-
|
|
15888
|
-
|
|
15889
|
-
|
|
15890
|
-
|
|
15891
|
-
|
|
15892
|
-
|
|
15893
|
-
|
|
15866
|
+
try {
|
|
15867
|
+
// Execute task
|
|
15868
|
+
const result = yield taskFunction();
|
|
15869
|
+
// Add results
|
|
15870
|
+
results[taskIndex] = result;
|
|
15871
|
+
// Tally and finish
|
|
15872
|
+
if (++numFinishedTasks === taskFunctions.length) {
|
|
15873
|
+
exited = true;
|
|
15874
|
+
return resolve();
|
|
15875
|
+
}
|
|
15876
|
+
if (!exited) {
|
|
15877
|
+
// Not finished! Start another task
|
|
15878
|
+
startTask();
|
|
15879
|
+
}
|
|
15880
|
+
}
|
|
15881
|
+
catch (err) {
|
|
15882
|
+
// Reject only once
|
|
15883
|
+
if (!exited) {
|
|
15884
|
+
exited = true;
|
|
15885
|
+
return reject(err);
|
|
15886
|
+
}
|
|
15894
15887
|
}
|
|
15895
|
-
// Not finished! Start another task
|
|
15896
|
-
startTask();
|
|
15897
15888
|
});
|
|
15898
15889
|
/* ----------- Start Tasks ---------- */
|
|
15899
15890
|
// If no limit, start all tasks. At least start 1 task
|