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.
@@ -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
@@ -1,4 +1,4 @@
1
- import { CommonKitErrorCode, waitMs, ErrorWithCode, LOG_ROUTE_PATH, LogBuiltInMetadata, LogLevel, getOrdinal, getMonthName, getTimeInfoInET, padZerosLeft, ParamType, roundToNumDecimals, genCSV, LogAction, cloneDeep, LogType, LogSource, getHumanReadableDate, LOG_REVIEW_GET_LOGS_ROUTE, idify, LOG_REVIEW_STATUS_ROUTE, SELECT_ADMIN_CHECK_ROUTE } from 'dce-commonkit';
1
+ import { CommonKitErrorCode, waitMs, ErrorWithCode, LOG_ROUTE_PATH, LogBuiltInMetadata, LogLevel, getOrdinal, getMonthName, getTimeInfoInET, padZerosLeft, ParamType, roundToNumDecimals, genCSV, LogAction, cloneDeep, LogType, LogSource, getHumanReadableDate, LOG_REVIEW_GET_LOGS_ROUTE, idify, padDecimalZeros, LOG_REVIEW_STATUS_ROUTE, SELECT_ADMIN_CHECK_ROUTE } from 'dce-commonkit';
2
2
  export { CommonKitErrorCode, DAY_IN_MS, DayOfWeek, ErrorWithCode, HOUR_IN_MS, LOG_REVIEW_GET_LOGS_ROUTE, LOG_REVIEW_ROUTE_PATH_PREFIX, LOG_REVIEW_STATUS_ROUTE, LOG_ROUTE_PATH, LogAction, LogBuiltInMetadata, LogLevel, LogSource, LogType, MINUTE_IN_MS, ParamType, SELECT_ADMIN_CHECK_ROUTE, abbreviate, avg, capitalize, ceilToNumDecimals, cloneDeep, compareArraysByProp, everyAsync, extractProp, filterAsync, floorToNumDecimals, forEachAsync, forceNumIntoBounds, genCSV, genCommaList, getHumanReadableDate, getLocalTimeInfo, getMonthName, getOrdinal, getPartOfDay, getTimeInfoInET, getTimestampFromTimeInfoInET, getWordCount, idify, mapAsync, onlyKeepLetters, padDecimalZeros, padZerosLeft, parallelLimit, prefixWithAOrAn, roundToNumDecimals, shuffleArray, someAsync, startMinWait, stringsToHumanReadableList, sum, validateEmail, validatePhoneNumber, validateString, waitMs } from 'dce-commonkit';
3
3
  import * as React from 'react';
4
4
  import React__default, { useState, useRef, useEffect, useReducer, forwardRef, useContext, useLayoutEffect, createContext, useMemo, useCallback, Component, Fragment } from 'react';
@@ -14168,7 +14168,6 @@ const Dropdown = (props) => {
14168
14168
  */
14169
14169
  var ProgressBarSize;
14170
14170
  (function (ProgressBarSize) {
14171
- ProgressBarSize["Small"] = "Small";
14172
14171
  ProgressBarSize["Medium"] = "Medium";
14173
14172
  ProgressBarSize["Large"] = "Large";
14174
14173
  })(ProgressBarSize || (ProgressBarSize = {}));
@@ -14184,7 +14183,7 @@ var ProgressBarSize$1 = ProgressBarSize;
14184
14183
  // Multiplier for calculating width of number of items
14185
14184
  const ITEM_WIDTH_MULTIPLIER = 1.3;
14186
14185
  // Constant for percent width
14187
- const PERCENT_WIDTH = 3;
14186
+ const PERCENT_WIDTH = 2.7;
14188
14187
  // Constant for item width
14189
14188
  const ITEM_WIDTH = 2;
14190
14189
  /*------------------------------------------------------------------------*/
@@ -14194,11 +14193,9 @@ const ITEM_WIDTH = 2;
14194
14193
  let style = `
14195
14194
  .ProgressBar-number-of,
14196
14195
  .ProgressBar-percent {
14197
- flex: 0 0 auto;
14198
14196
  white-space: nowrap;
14199
- padding-right: 0.5em;
14200
- padding-left: 0.25em;
14201
- text-align: right;
14197
+ padding-right: 0.3em;
14198
+ text-align: left;
14202
14199
  transition: width .25s ease;
14203
14200
  }
14204
14201
 
@@ -14218,7 +14215,7 @@ const ProgressBar = (props) => {
14218
14215
  /*------------------------------------------------------------------------*/
14219
14216
  /* -------------------------------- Setup ------------------------------- */
14220
14217
  /*------------------------------------------------------------------------*/
14221
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
14218
+ var _a, _b, _c, _d, _e;
14222
14219
  /* -------------- Props ------------- */
14223
14220
  // Destructure props
14224
14221
  const { striped, variant = Variant$1.Warning, bgVariant = Variant$1.Secondary, showOutline, size = ProgressBarSize$1.Medium, } = props;
@@ -14250,10 +14247,19 @@ const ProgressBar = (props) => {
14250
14247
  /*----------------------------------------*/
14251
14248
  /* ---------------- Sizes --------------- */
14252
14249
  /*----------------------------------------*/
14250
+ // Add dynamic general style
14251
+ style += `
14252
+ .ProgressBar-percent {
14253
+ min-width: ${(status.usePercent ? (_a = status.numDecimalPlaces) !== null && _a !== void 0 ? _a : 0 : 0) + PERCENT_WIDTH}em;
14254
+ }
14255
+ .ProgressBar-number-of {
14256
+ min-width: ${((!status.usePercent ? String((_b = status.total) !== null && _b !== void 0 ? _b : 0).length || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
14257
+ }
14258
+ `;
14253
14259
  // Size styles
14254
14260
  switch (size) {
14255
- case ProgressBarSize$1.Small:
14256
- // Small size
14261
+ case ProgressBarSize$1.Medium:
14262
+ // Medium size
14257
14263
  style += `
14258
14264
  .ProgressBar-container .ProgressBar-number-of, .ProgressBar-container .ProgressBar-percent {
14259
14265
  font-size: 1em;
@@ -14266,18 +14272,10 @@ const ProgressBar = (props) => {
14266
14272
  height: 1.5em;
14267
14273
  border-radius: 0.5em;
14268
14274
  }
14269
- .ProgressBar-percent {
14270
- min-width: ${((status.usePercent ? (_a = status.numDecimalPlaces) !== null && _a !== void 0 ? _a : 0 : 0) * 1) + PERCENT_WIDTH}em;
14271
- max-width: ${((status.usePercent ? (_b = status.numDecimalPlaces) !== null && _b !== void 0 ? _b : 0 : 0) * 1) + PERCENT_WIDTH}em;
14272
- }
14273
- .ProgressBar-number-of {
14274
- min-width: ${((!status.usePercent ? ((_c = status.total) === null || _c === void 0 ? void 0 : _c.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
14275
- max-width: ${((!status.usePercent ? ((_d = status.total) === null || _d === void 0 ? void 0 : _d.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
14276
- }
14277
14275
  `;
14278
14276
  break;
14279
- case ProgressBarSize$1.Medium:
14280
- // Medium size
14277
+ case ProgressBarSize$1.Large:
14278
+ // Large size
14281
14279
  style += `
14282
14280
  .ProgressBar-container .ProgressBar-number-of, .ProgressBar-container .ProgressBar-percent {
14283
14281
  font-size: 1.5em;
@@ -14290,47 +14288,14 @@ const ProgressBar = (props) => {
14290
14288
  height: 2em;
14291
14289
  border-radius: 0.7em;
14292
14290
  }
14293
- .ProgressBar-percent {
14294
- min-width: ${((status.usePercent ? (_e = status.numDecimalPlaces) !== null && _e !== void 0 ? _e : 0 : 0) * 1) + PERCENT_WIDTH}em;
14295
- max-width: ${((status.usePercent ? (_f = status.numDecimalPlaces) !== null && _f !== void 0 ? _f : 0 : 0) * 1) + PERCENT_WIDTH}em;
14296
- }
14297
- .ProgressBar-number-of {
14298
- min-width: ${((!status.usePercent ? ((_g = status.total) === null || _g === void 0 ? void 0 : _g.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
14299
- max-width: ${((!status.usePercent ? ((_h = status.total) === null || _h === void 0 ? void 0 : _h.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
14300
- }
14301
- `;
14302
- break;
14303
- case ProgressBarSize$1.Large:
14304
- // Large size
14305
- style += `
14306
- .ProgressBar-container .ProgressBar-number-of, .ProgressBar-container .ProgressBar-percent {
14307
- font-size: 2em;
14308
- }
14309
- .ProgressBar-container .ProgressBar-background {
14310
- height: 3em;
14311
- border-radius: 1em;
14312
- }
14313
- .ProgressBar-container .ProgressBar-bar {
14314
- height: 3em;
14315
- border-radius: 1em;
14316
- }
14317
- .ProgressBar-percent {
14318
- min-width: ${((status.usePercent ? (_j = status.numDecimalPlaces) !== null && _j !== void 0 ? _j : 0 : 0) * 1) + PERCENT_WIDTH}em;
14319
- max-width: ${((status.usePercent ? (_k = status.numDecimalPlaces) !== null && _k !== void 0 ? _k : 0 : 0) * 1) + PERCENT_WIDTH}em;
14320
- }
14321
- .ProgressBar-number-of {
14322
- min-width: ${((!status.usePercent ? ((_l = status.total) === null || _l === void 0 ? void 0 : _l.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
14323
- max-width: ${((!status.usePercent ? ((_m = status.total) === null || _m === void 0 ? void 0 : _m.toString().length) || 1 : 0) * ITEM_WIDTH_MULTIPLIER) + ITEM_WIDTH}em;
14324
- }
14325
14291
  `;
14326
14292
  break;
14327
14293
  }
14328
14294
  // Get the width of the outline based on size
14329
14295
  const outlineWidth = (() => {
14330
14296
  switch (size) {
14331
- case ProgressBarSize$1.Small: return '0.05em';
14332
- case ProgressBarSize$1.Medium: return '0.08em';
14333
- case ProgressBarSize$1.Large: return '0.1em';
14297
+ case ProgressBarSize$1.Medium: return '0.05em';
14298
+ case ProgressBarSize$1.Large: return '0.08em';
14334
14299
  default: return '0.05em';
14335
14300
  }
14336
14301
  })();
@@ -14355,33 +14320,46 @@ const ProgressBar = (props) => {
14355
14320
  }
14356
14321
  `;
14357
14322
  // Stripes for striped effect
14358
- const stripes = (React__default.createElement("div", null,
14359
- React__default.createElement("style", null, stripesStyle),
14360
- React__default.createElement("div", { className: "ProgressBar-stripes position-absolute ", style: {
14361
- width: '200%',
14362
- height: '100%',
14363
- } }, "\u00A0")));
14323
+ let stripes = null;
14324
+ if (striped) {
14325
+ stripes = (React__default.createElement("div", null,
14326
+ React__default.createElement("style", null, stripesStyle),
14327
+ React__default.createElement("div", { className: "ProgressBar-stripes position-absolute", style: {
14328
+ width: '200%',
14329
+ height: '100%',
14330
+ } }, "\u00A0")));
14331
+ }
14364
14332
  /*----------------------------------------*/
14365
14333
  /* --------------- Main UI -------------- */
14366
14334
  /*----------------------------------------*/
14335
+ // Calculate the width of the progress bar
14336
+ let progressBarWidthPercent = 0;
14337
+ if (status.usePercent) {
14338
+ // Use percent progress directly
14339
+ progressBarWidthPercent = status.percentProgress;
14340
+ }
14341
+ else if (status.total > 0) {
14342
+ // Calculate percent progress from items
14343
+ progressBarWidthPercent = (status.numComplete / status.total) * 100;
14344
+ }
14367
14345
  // Render the progress bar
14368
14346
  return (React__default.createElement("div", { className: "ProgressBar-container d-flex align-items-center" },
14369
14347
  React__default.createElement("style", null, style),
14370
- !status.usePercent && status.numComplete && (React__default.createElement("span", { className: "ProgressBar-number-of pe-2 align-self-center" },
14348
+ !status.usePercent && status.numComplete && (React__default.createElement("span", { className: "ProgressBar-number-of" },
14371
14349
  status.numComplete,
14372
14350
  "\u00A0of\u00A0",
14373
14351
  status.total)),
14374
- status.usePercent && status.percentProgress && (React__default.createElement("span", { className: "ProgressBar-percent pe-2 align-self-center" },
14375
- status.percentProgress.toFixed((_o = status === null || status === void 0 ? void 0 : status.numDecimalPlaces) !== null && _o !== void 0 ? _o : 0),
14352
+ status.usePercent && (React__default.createElement("span", { className: "ProgressBar-percent" },
14353
+ padDecimalZeros(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),
14376
14354
  "%")),
14377
- React__default.createElement("div", { className: `ProgressBar-background bg-${bgVariant} w-100`, style: {
14355
+ React__default.createElement("div", { className: `ProgressBar-background bg-${bgVariant} flex-grow-1`, style: {
14378
14356
  boxShadow: `0 0 0 ${outlineWidth} ${showOutline ? '#000' : '#DEE2E6'}`,
14379
14357
  }, "aria-valuenow": status.usePercent ? status.percentProgress : status.numComplete, "aria-valuemin": 0, "aria-valuemax": status.usePercent ? 100 : status.total },
14380
14358
  React__default.createElement("div", { className: `ProgressBar-bar bg-${variant} text-start position-relative`, style: {
14381
- width: `${(status.usePercent ? status.percentProgress : (status.numComplete / status.total) * 100)}%`,
14359
+ width: `${progressBarWidthPercent}%`,
14382
14360
  overflow: 'hidden',
14383
14361
  } },
14384
- striped && stripes,
14362
+ stripes,
14385
14363
  "\u00A0"))));
14386
14364
  };
14387
14365