dce-reactkit 5.0.0 → 5.0.1

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 CHANGED
@@ -14194,7 +14194,6 @@ const Dropdown = (props) => {
14194
14194
  */
14195
14195
  var ProgressBarSize;
14196
14196
  (function (ProgressBarSize) {
14197
- ProgressBarSize["Small"] = "Small";
14198
14197
  ProgressBarSize["Medium"] = "Medium";
14199
14198
  ProgressBarSize["Large"] = "Large";
14200
14199
  })(ProgressBarSize || (ProgressBarSize = {}));
@@ -14210,7 +14209,7 @@ var ProgressBarSize$1 = ProgressBarSize;
14210
14209
  // Multiplier for calculating width of number of items
14211
14210
  const ITEM_WIDTH_MULTIPLIER = 1.3;
14212
14211
  // Constant for percent width
14213
- const PERCENT_WIDTH = 3;
14212
+ const PERCENT_WIDTH = 2.7;
14214
14213
  // Constant for item width
14215
14214
  const ITEM_WIDTH = 2;
14216
14215
  /*------------------------------------------------------------------------*/
@@ -14220,11 +14219,9 @@ const ITEM_WIDTH = 2;
14220
14219
  let style = `
14221
14220
  .ProgressBar-number-of,
14222
14221
  .ProgressBar-percent {
14223
- flex: 0 0 auto;
14224
14222
  white-space: nowrap;
14225
- padding-right: 0.5em;
14226
- padding-left: 0.25em;
14227
- text-align: right;
14223
+ padding-right: 0.3em;
14224
+ text-align: left;
14228
14225
  transition: width .25s ease;
14229
14226
  }
14230
14227
 
@@ -14244,7 +14241,7 @@ const ProgressBar = (props) => {
14244
14241
  /*------------------------------------------------------------------------*/
14245
14242
  /* -------------------------------- Setup ------------------------------- */
14246
14243
  /*------------------------------------------------------------------------*/
14247
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
14244
+ var _a, _b, _c, _d, _e;
14248
14245
  /* -------------- Props ------------- */
14249
14246
  // Destructure props
14250
14247
  const { striped, variant = Variant$1.Warning, bgVariant = Variant$1.Secondary, showOutline, size = ProgressBarSize$1.Medium, } = props;
@@ -14276,10 +14273,19 @@ const ProgressBar = (props) => {
14276
14273
  /*----------------------------------------*/
14277
14274
  /* ---------------- Sizes --------------- */
14278
14275
  /*----------------------------------------*/
14276
+ // Add dynamic general style
14277
+ style += `
14278
+ .ProgressBar-percent {
14279
+ min-width: ${(status.usePercent ? (_a = status.numDecimalPlaces) !== null && _a !== void 0 ? _a : 0 : 0) + PERCENT_WIDTH}em;
14280
+ }
14281
+ .ProgressBar-number-of {
14282
+ min-width: ${((!status.usePercent ? String((_b = status.total) !== null && _b !== void 0 ? _b : 0).length || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
14283
+ }
14284
+ `;
14279
14285
  // Size styles
14280
14286
  switch (size) {
14281
- case ProgressBarSize$1.Small:
14282
- // Small size
14287
+ case ProgressBarSize$1.Medium:
14288
+ // Medium size
14283
14289
  style += `
14284
14290
  .ProgressBar-container .ProgressBar-number-of, .ProgressBar-container .ProgressBar-percent {
14285
14291
  font-size: 1em;
@@ -14292,18 +14298,10 @@ const ProgressBar = (props) => {
14292
14298
  height: 1.5em;
14293
14299
  border-radius: 0.5em;
14294
14300
  }
14295
- .ProgressBar-percent {
14296
- min-width: ${((status.usePercent ? (_a = status.numDecimalPlaces) !== null && _a !== void 0 ? _a : 0 : 0) * 1) + PERCENT_WIDTH}em;
14297
- max-width: ${((status.usePercent ? (_b = status.numDecimalPlaces) !== null && _b !== void 0 ? _b : 0 : 0) * 1) + PERCENT_WIDTH}em;
14298
- }
14299
- .ProgressBar-number-of {
14300
- min-width: ${((!status.usePercent ? ((_c = status.total) === null || _c === void 0 ? void 0 : _c.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
14301
- max-width: ${((!status.usePercent ? ((_d = status.total) === null || _d === void 0 ? void 0 : _d.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
14302
- }
14303
14301
  `;
14304
14302
  break;
14305
- case ProgressBarSize$1.Medium:
14306
- // Medium size
14303
+ case ProgressBarSize$1.Large:
14304
+ // Large size
14307
14305
  style += `
14308
14306
  .ProgressBar-container .ProgressBar-number-of, .ProgressBar-container .ProgressBar-percent {
14309
14307
  font-size: 1.5em;
@@ -14316,47 +14314,14 @@ const ProgressBar = (props) => {
14316
14314
  height: 2em;
14317
14315
  border-radius: 0.7em;
14318
14316
  }
14319
- .ProgressBar-percent {
14320
- min-width: ${((status.usePercent ? (_e = status.numDecimalPlaces) !== null && _e !== void 0 ? _e : 0 : 0) * 1) + PERCENT_WIDTH}em;
14321
- max-width: ${((status.usePercent ? (_f = status.numDecimalPlaces) !== null && _f !== void 0 ? _f : 0 : 0) * 1) + PERCENT_WIDTH}em;
14322
- }
14323
- .ProgressBar-number-of {
14324
- min-width: ${((!status.usePercent ? ((_g = status.total) === null || _g === void 0 ? void 0 : _g.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
14325
- max-width: ${((!status.usePercent ? ((_h = status.total) === null || _h === void 0 ? void 0 : _h.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
14326
- }
14327
- `;
14328
- break;
14329
- case ProgressBarSize$1.Large:
14330
- // Large size
14331
- style += `
14332
- .ProgressBar-container .ProgressBar-number-of, .ProgressBar-container .ProgressBar-percent {
14333
- font-size: 2em;
14334
- }
14335
- .ProgressBar-container .ProgressBar-background {
14336
- height: 3em;
14337
- border-radius: 1em;
14338
- }
14339
- .ProgressBar-container .ProgressBar-bar {
14340
- height: 3em;
14341
- border-radius: 1em;
14342
- }
14343
- .ProgressBar-percent {
14344
- min-width: ${((status.usePercent ? (_j = status.numDecimalPlaces) !== null && _j !== void 0 ? _j : 0 : 0) * 1) + PERCENT_WIDTH}em;
14345
- max-width: ${((status.usePercent ? (_k = status.numDecimalPlaces) !== null && _k !== void 0 ? _k : 0 : 0) * 1) + PERCENT_WIDTH}em;
14346
- }
14347
- .ProgressBar-number-of {
14348
- min-width: ${((!status.usePercent ? ((_l = status.total) === null || _l === void 0 ? void 0 : _l.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
14349
- max-width: ${((!status.usePercent ? ((_m = status.total) === null || _m === void 0 ? void 0 : _m.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
14350
- }
14351
14317
  `;
14352
14318
  break;
14353
14319
  }
14354
14320
  // Get the width of the outline based on size
14355
14321
  const outlineWidth = (() => {
14356
14322
  switch (size) {
14357
- case ProgressBarSize$1.Small: return '0.05em';
14358
- case ProgressBarSize$1.Medium: return '0.08em';
14359
- case ProgressBarSize$1.Large: return '0.1em';
14323
+ case ProgressBarSize$1.Medium: return '0.05em';
14324
+ case ProgressBarSize$1.Large: return '0.08em';
14360
14325
  default: return '0.05em';
14361
14326
  }
14362
14327
  })();
@@ -14381,33 +14346,46 @@ const ProgressBar = (props) => {
14381
14346
  }
14382
14347
  `;
14383
14348
  // Stripes for striped effect
14384
- const stripes = (React__default["default"].createElement("div", null,
14385
- React__default["default"].createElement("style", null, stripesStyle),
14386
- React__default["default"].createElement("div", { className: "ProgressBar-stripes position-absolute ", style: {
14387
- width: '200%',
14388
- height: '100%',
14389
- } }, "\u00A0")));
14349
+ let stripes = null;
14350
+ if (striped) {
14351
+ stripes = (React__default["default"].createElement("div", null,
14352
+ React__default["default"].createElement("style", null, stripesStyle),
14353
+ React__default["default"].createElement("div", { className: "ProgressBar-stripes position-absolute", style: {
14354
+ width: '200%',
14355
+ height: '100%',
14356
+ } }, "\u00A0")));
14357
+ }
14390
14358
  /*----------------------------------------*/
14391
14359
  /* --------------- Main UI -------------- */
14392
14360
  /*----------------------------------------*/
14361
+ // Calculate the width of the progress bar
14362
+ let progressBarWidthPercent = 0;
14363
+ if (status.usePercent) {
14364
+ // Use percent progress directly
14365
+ progressBarWidthPercent = status.percentProgress;
14366
+ }
14367
+ else if (status.total > 0) {
14368
+ // Calculate percent progress from items
14369
+ progressBarWidthPercent = (status.numComplete / status.total) * 100;
14370
+ }
14393
14371
  // Render the progress bar
14394
14372
  return (React__default["default"].createElement("div", { className: "ProgressBar-container d-flex align-items-center" },
14395
14373
  React__default["default"].createElement("style", null, style),
14396
- !status.usePercent && status.numComplete && (React__default["default"].createElement("span", { className: "ProgressBar-number-of pe-2 align-self-center" },
14374
+ !status.usePercent && status.numComplete && (React__default["default"].createElement("span", { className: "ProgressBar-number-of" },
14397
14375
  status.numComplete,
14398
14376
  "\u00A0of\u00A0",
14399
14377
  status.total)),
14400
- status.usePercent && status.percentProgress && (React__default["default"].createElement("span", { className: "ProgressBar-percent pe-2 align-self-center" },
14401
- status.percentProgress.toFixed((_o = status === null || status === void 0 ? void 0 : status.numDecimalPlaces) !== null && _o !== void 0 ? _o : 0),
14378
+ status.usePercent && (React__default["default"].createElement("span", { className: "ProgressBar-percent" },
14379
+ dceCommonkit.padDecimalZeros(dceCommonkit.roundToNumDecimals((_c = status.percentProgress) !== null && _c !== void 0 ? _c : 0, (_d = status === null || status === void 0 ? void 0 : status.numDecimalPlaces) !== null && _d !== void 0 ? _d : 0), (_e = status === null || status === void 0 ? void 0 : status.numDecimalPlaces) !== null && _e !== void 0 ? _e : 0),
14402
14380
  "%")),
14403
- React__default["default"].createElement("div", { className: `ProgressBar-background bg-${bgVariant} w-100`, style: {
14381
+ React__default["default"].createElement("div", { className: `ProgressBar-background bg-${bgVariant} flex-grow-1`, style: {
14404
14382
  boxShadow: `0 0 0 ${outlineWidth} ${showOutline ? '#000' : '#DEE2E6'}`,
14405
14383
  }, "aria-valuenow": status.usePercent ? status.percentProgress : status.numComplete, "aria-valuemin": 0, "aria-valuemax": status.usePercent ? 100 : status.total },
14406
14384
  React__default["default"].createElement("div", { className: `ProgressBar-bar bg-${variant} text-start position-relative`, style: {
14407
- width: `${(status.usePercent ? status.percentProgress : (status.numComplete / status.total) * 100)}%`,
14385
+ width: `${progressBarWidthPercent}%`,
14408
14386
  overflow: 'hidden',
14409
14387
  } },
14410
- striped && stripes,
14388
+ stripes,
14411
14389
  "\u00A0"))));
14412
14390
  };
14413
14391