@bze/bze-ui-kit 0.3.0 → 0.3.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/index.d.mts CHANGED
@@ -366,7 +366,7 @@ declare function shortNumberFormat(amount: BigNumber): string;
366
366
  declare const intlDateFormat: Intl.DateTimeFormat;
367
367
  declare const formatDate: (date: Date) => string;
368
368
  declare const formatTimeRemaining: (targetDate: Date) => string;
369
- declare const formatTimeRemainingFromEpochs: (epochs: BigNumber) => string;
369
+ declare function formatTimeRemainingFromEpochs(endEpoch: bigint | number | BigNumber, currentEpoch?: bigint | number | BigNumber): string;
370
370
 
371
371
  declare function sleep(ms: number): Promise<void>;
372
372
  declare const openExternalLink: (url: string) => void;
package/dist/index.d.ts CHANGED
@@ -366,7 +366,7 @@ declare function shortNumberFormat(amount: BigNumber): string;
366
366
  declare const intlDateFormat: Intl.DateTimeFormat;
367
367
  declare const formatDate: (date: Date) => string;
368
368
  declare const formatTimeRemaining: (targetDate: Date) => string;
369
- declare const formatTimeRemainingFromEpochs: (epochs: BigNumber) => string;
369
+ declare function formatTimeRemainingFromEpochs(endEpoch: bigint | number | BigNumber, currentEpoch?: bigint | number | BigNumber): string;
370
370
 
371
371
  declare function sleep(ms: number): Promise<void>;
372
372
  declare const openExternalLink: (url: string) => void;
package/dist/index.js CHANGED
@@ -961,11 +961,28 @@ var formatTimeRemaining = (targetDate) => {
961
961
  if (minutes > 0) parts.push(`${minutes}m`);
962
962
  return parts.join(" ") || "Now";
963
963
  };
964
- var formatTimeRemainingFromEpochs = (epochs) => {
965
- if (epochs.lte(0)) {
964
+ function formatTimeRemainingFromEpochs(endEpoch, currentEpoch) {
965
+ let epochDiff;
966
+ if (currentEpoch !== void 0) {
967
+ const endBN = toBigNumber(endEpoch);
968
+ const currentBN = toBigNumber(currentEpoch);
969
+ epochDiff = endBN.minus(currentBN);
970
+ if (epochDiff.lte(0)) {
971
+ return "Ended";
972
+ }
973
+ const hoursRemaining = epochDiff.toNumber();
974
+ const daysRemaining = Math.floor(hoursRemaining / 24);
975
+ const hoursRemainder = hoursRemaining % 24;
976
+ if (daysRemaining > 0) {
977
+ return `${daysRemaining}d ${hoursRemainder}h`;
978
+ }
979
+ return `${hoursRemainder}h`;
980
+ }
981
+ epochDiff = toBigNumber(endEpoch);
982
+ if (epochDiff.lte(0)) {
966
983
  return "Now";
967
984
  }
968
- const totalSeconds = epochs.multipliedBy(60).toNumber();
985
+ const totalSeconds = epochDiff.multipliedBy(60).toNumber();
969
986
  const days = Math.floor(totalSeconds / (60 * 60 * 24));
970
987
  const hours = Math.floor(totalSeconds % (60 * 60 * 24) / (60 * 60));
971
988
  const minutes = Math.floor(totalSeconds % (60 * 60) / 60);
@@ -974,7 +991,7 @@ var formatTimeRemainingFromEpochs = (epochs) => {
974
991
  if (hours > 0) parts.push(`${hours}h`);
975
992
  if (minutes > 0) parts.push(`${minutes}m`);
976
993
  return parts.join(" ") || "Now";
977
- };
994
+ }
978
995
 
979
996
  // src/utils/functions.ts
980
997
  async function sleep(ms) {