@deframe-sdk/components 0.1.69 → 0.1.71

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.mjs CHANGED
@@ -4,7 +4,7 @@ import { HiXMark, HiChevronUp, HiChevronDown, HiChevronLeft, HiOutlineClock, HiA
4
4
  import * as React6 from 'react';
5
5
  import React6__default, { useMemo, useState, useEffect, useRef, useCallback } from 'react';
6
6
  import { motion, AnimatePresence } from 'framer-motion';
7
- import { MdClose, MdOutlineSearch, MdOutlineSearchOff, MdOutlineSwapHoriz, MdHistory, MdOutlineSwapVert, MdArrowRight, MdArrowDropDown, MdOutlineArrowBack, MdOutlineArrowDropDown, MdOutlineClose, MdContentCopy, MdOutlineExpandMore, MdQrCodeScanner, MdOutlineArrowUpward, MdOutlineArrowDownward, MdCheckCircleOutline, MdErrorOutline, MdWarningAmber, MdInfoOutline, MdArrowUpward, MdArrowDownward } from 'react-icons/md';
7
+ import { MdClose, MdOutlineSearch, MdOutlineSearchOff, MdOutlineSwapHoriz, MdHistory, MdOutlineSwapVert, MdArrowRight, MdArrowDropDown, MdOutlineArrowBack, MdOutlineArrowDropDown, MdOutlineClose, MdContentCopy, MdOutlineExpandMore, MdQrCodeScanner, MdOutlineArrowUpward, MdOutlineArrowDownward, MdCheckCircleOutline, MdErrorOutline, MdWarningAmber, MdInfoOutline, MdAccessTime, MdArrowUpward, MdArrowDownward } from 'react-icons/md';
8
8
  import { IoAlertCircleOutline, IoTimeOutline, IoCheckmarkOutline } from 'react-icons/io5';
9
9
  import { PiClockCountdownBold } from 'react-icons/pi';
10
10
  import QRCode from 'react-qr-code';
@@ -4822,6 +4822,28 @@ function SkeletonCard({ testId, symbol, network, amount, usd, balance }) {
4822
4822
  }
4823
4823
  );
4824
4824
  }
4825
+ function useBackgroundConfirmationTransition({
4826
+ enabled,
4827
+ started,
4828
+ slowAfterMs = 5e3,
4829
+ dismissAfterSlowMs = 3e3,
4830
+ onDismiss
4831
+ }) {
4832
+ const [phase, setPhase] = useState("initial");
4833
+ useEffect(() => {
4834
+ if (!enabled || !started) return;
4835
+ if (phase !== "initial") return;
4836
+ const id = window.setTimeout(() => setPhase("background-confirmation"), slowAfterMs);
4837
+ return () => window.clearTimeout(id);
4838
+ }, [enabled, started, phase, slowAfterMs]);
4839
+ useEffect(() => {
4840
+ if (phase !== "background-confirmation") return;
4841
+ if (!onDismiss) return;
4842
+ const id = window.setTimeout(() => onDismiss(), dismissAfterSlowMs);
4843
+ return () => window.clearTimeout(id);
4844
+ }, [phase, dismissAfterSlowMs, onDismiss]);
4845
+ return { phase };
4846
+ }
4825
4847
  function LoadingIcon() {
4826
4848
  const green = "var(--deframe-widget-color-brand-primary)";
4827
4849
  const trackColor = "color-mix(in srgb, var(--deframe-widget-color-brand-primary) 12%, transparent)";
@@ -4882,10 +4904,42 @@ function LoadingIcon() {
4882
4904
  }
4883
4905
  );
4884
4906
  }
4907
+ function SlowIcon() {
4908
+ return /* @__PURE__ */ jsx(
4909
+ motion.div,
4910
+ {
4911
+ "data-test-id": "swap-processing-simple-background-confirmation-icon",
4912
+ initial: { scale: 0.7, opacity: 0 },
4913
+ animate: { scale: 1, opacity: 1 },
4914
+ transition: { type: "spring", stiffness: 280, damping: 22 },
4915
+ className: "flex items-center justify-center shrink-0 w-[56px] h-[56px]",
4916
+ "aria-hidden": "true",
4917
+ children: /* @__PURE__ */ jsx(
4918
+ MdAccessTime,
4919
+ {
4920
+ size: 56,
4921
+ color: "var(--deframe-widget-color-brand-primary)"
4922
+ }
4923
+ )
4924
+ }
4925
+ );
4926
+ }
4885
4927
  var SwapProcessingViewSimple = ({
4886
4928
  titleText,
4887
- descriptionPrefix
4929
+ descriptionPrefix,
4930
+ allowBackgroundConfirmation = false,
4931
+ backgroundConfirmationStarted = false,
4932
+ backgroundConfirmationLabels,
4933
+ onBackgroundConfirmationDismiss
4888
4934
  }) => {
4935
+ const { phase } = useBackgroundConfirmationTransition({
4936
+ enabled: allowBackgroundConfirmation,
4937
+ started: backgroundConfirmationStarted,
4938
+ onDismiss: onBackgroundConfirmationDismiss
4939
+ });
4940
+ const isBackgroundConfirmation = phase === "background-confirmation" && backgroundConfirmationLabels !== void 0;
4941
+ const renderedTitle = isBackgroundConfirmation ? backgroundConfirmationLabels.title : titleText;
4942
+ const renderedSubtitle = isBackgroundConfirmation ? backgroundConfirmationLabels.subtitle : descriptionPrefix;
4889
4943
  return /* @__PURE__ */ jsxs(
4890
4944
  "div",
4891
4945
  {
@@ -4915,7 +4969,7 @@ var SwapProcessingViewSimple = ({
4915
4969
  "bg-[color-mix(in_srgb,var(--deframe-widget-color-bg-secondary)_88%,transparent)]"
4916
4970
  ),
4917
4971
  children: [
4918
- /* @__PURE__ */ jsx(LoadingIcon, {}),
4972
+ isBackgroundConfirmation ? /* @__PURE__ */ jsx(SlowIcon, {}) : /* @__PURE__ */ jsx(LoadingIcon, {}),
4919
4973
  /* @__PURE__ */ jsxs(
4920
4974
  "div",
4921
4975
  {
@@ -4925,20 +4979,20 @@ var SwapProcessingViewSimple = ({
4925
4979
  /* @__PURE__ */ jsx(
4926
4980
  "span",
4927
4981
  {
4928
- "data-test-id": "swap-processing-simple-title",
4982
+ "data-test-id": isBackgroundConfirmation ? "swap-processing-simple-background-confirmation-title" : "swap-processing-simple-title",
4929
4983
  className: twMerge(
4930
4984
  "[font-size:12px] [line-height:1.25] [letter-spacing:0.10em] uppercase",
4931
4985
  "[font-weight:var(--deframe-widget-font-weight-semibold)]",
4932
4986
  "font-[var(--deframe-widget-font-family)]",
4933
4987
  "text-[color:var(--deframe-widget-color-brand-primary)]"
4934
4988
  ),
4935
- children: titleText
4989
+ children: renderedTitle
4936
4990
  }
4937
4991
  ),
4938
4992
  /* @__PURE__ */ jsx(
4939
4993
  "span",
4940
4994
  {
4941
- "data-test-id": "swap-processing-simple-subtitle",
4995
+ "data-test-id": isBackgroundConfirmation ? "swap-processing-simple-background-confirmation-subtitle" : "swap-processing-simple-subtitle",
4942
4996
  className: twMerge(
4943
4997
  "[font-size:var(--deframe-widget-font-size-md)] [line-height:1.6]",
4944
4998
  "[font-weight:var(--deframe-widget-font-weight-regular)]",
@@ -4946,7 +5000,7 @@ var SwapProcessingViewSimple = ({
4946
5000
  "text-[color:var(--deframe-widget-color-text-secondary)]",
4947
5001
  "max-w-[260px]"
4948
5002
  ),
4949
- children: descriptionPrefix
5003
+ children: renderedSubtitle
4950
5004
  }
4951
5005
  )
4952
5006
  ]
@@ -5062,12 +5116,20 @@ var SwapCrossChainProcessingView = ({
5062
5116
  };
5063
5117
  var SwapCrossChainProcessingViewSimple = ({
5064
5118
  title,
5065
- description
5119
+ description,
5120
+ allowBackgroundConfirmation,
5121
+ backgroundConfirmationStarted,
5122
+ backgroundConfirmationLabels,
5123
+ onBackgroundConfirmationDismiss
5066
5124
  }) => /* @__PURE__ */ jsx(
5067
5125
  SwapProcessingViewSimple,
5068
5126
  {
5069
5127
  titleText: title,
5070
- descriptionPrefix: description
5128
+ descriptionPrefix: description,
5129
+ allowBackgroundConfirmation,
5130
+ backgroundConfirmationStarted,
5131
+ backgroundConfirmationLabels,
5132
+ onBackgroundConfirmationDismiss
5071
5133
  }
5072
5134
  );
5073
5135
  var InvestmentCrossChainProcessingView = ({
@@ -5260,9 +5322,14 @@ function EarnFeedbackOverlaySimpleView({
5260
5322
  variant,
5261
5323
  title,
5262
5324
  subtitle,
5263
- formData
5325
+ formData,
5326
+ phase = "initial",
5327
+ backgroundConfirmationLabels
5264
5328
  }) {
5265
- const isLoading = variant === "loading";
5329
+ const isBackgroundConfirmation = phase === "background-confirmation" && variant === "loading" && backgroundConfirmationLabels !== void 0;
5330
+ const renderedTitle = isBackgroundConfirmation ? backgroundConfirmationLabels.title : title;
5331
+ const renderedSubtitle = isBackgroundConfirmation ? backgroundConfirmationLabels.subtitle : subtitle;
5332
+ const isLoading = variant === "loading" && !isBackgroundConfirmation;
5266
5333
  const wrapperClasses = twMerge(
5267
5334
  "relative flex flex-col overflow-hidden w-[420px]",
5268
5335
  "rounded-[var(--deframe-widget-size-radius-md)]",
@@ -5283,7 +5350,7 @@ function EarnFeedbackOverlaySimpleView({
5283
5350
  "gap-[var(--deframe-widget-size-gap-sm)] text-center"
5284
5351
  );
5285
5352
  const titleClasses2 = twMerge(
5286
- isLoading ? "[font-size:12px] [line-height:1.25] [letter-spacing:0.10em] uppercase [font-weight:var(--deframe-widget-font-weight-semibold)] font-[var(--deframe-widget-font-family)] text-[color:var(--deframe-widget-color-brand-primary)]" : "text-[22px] font-bold text-[color:var(--deframe-widget-color-text-primary)] leading-[1.25]"
5353
+ isLoading || isBackgroundConfirmation ? "[font-size:12px] [line-height:1.25] [letter-spacing:0.10em] uppercase [font-weight:var(--deframe-widget-font-weight-semibold)] font-[var(--deframe-widget-font-family)] text-[color:var(--deframe-widget-color-brand-primary)]" : "text-[22px] font-bold text-[color:var(--deframe-widget-color-text-primary)] leading-[1.25]"
5287
5354
  );
5288
5355
  const subtitleClasses = twMerge(
5289
5356
  "[font-size:var(--deframe-widget-font-size-md)] [line-height:1.6]",
@@ -5311,6 +5378,7 @@ function EarnFeedbackOverlaySimpleView({
5311
5378
  transition: { duration: 0.2 },
5312
5379
  className: overlayClasses,
5313
5380
  children: [
5381
+ isBackgroundConfirmation && /* @__PURE__ */ jsx(SlowIcon2, {}),
5314
5382
  isLoading && /* @__PURE__ */ jsx(LoadingIcon2, {}),
5315
5383
  variant === "success" && /* @__PURE__ */ jsx(SuccessIcon, {}),
5316
5384
  variant === "warning" && /* @__PURE__ */ jsx(WarningIcon, {}),
@@ -5325,19 +5393,19 @@ function EarnFeedbackOverlaySimpleView({
5325
5393
  /* @__PURE__ */ jsx(
5326
5394
  "span",
5327
5395
  {
5328
- "data-test-id": "earn-feedback-title",
5396
+ "data-test-id": isBackgroundConfirmation ? "earn-feedback-background-confirmation-title" : "earn-feedback-title",
5329
5397
  "data-slot": "earn-feedback-title",
5330
5398
  className: titleClasses2,
5331
- children: title
5399
+ children: renderedTitle
5332
5400
  }
5333
5401
  ),
5334
- subtitle && /* @__PURE__ */ jsx(
5402
+ renderedSubtitle && /* @__PURE__ */ jsx(
5335
5403
  "span",
5336
5404
  {
5337
- "data-test-id": "earn-feedback-subtitle",
5405
+ "data-test-id": isBackgroundConfirmation ? "earn-feedback-background-confirmation-subtitle" : "earn-feedback-subtitle",
5338
5406
  "data-slot": "earn-feedback-subtitle",
5339
5407
  className: subtitleClasses,
5340
- children: subtitle
5408
+ children: renderedSubtitle
5341
5409
  }
5342
5410
  )
5343
5411
  ]
@@ -5351,6 +5419,27 @@ function EarnFeedbackOverlaySimpleView({
5351
5419
  }
5352
5420
  );
5353
5421
  }
5422
+ function SlowIcon2() {
5423
+ return /* @__PURE__ */ jsx(
5424
+ motion.div,
5425
+ {
5426
+ "data-test-id": "earn-feedback-background-confirmation-icon",
5427
+ "data-slot": "earn-feedback-background-confirmation-icon",
5428
+ initial: { scale: 0.7, opacity: 0 },
5429
+ animate: { scale: 1, opacity: 1 },
5430
+ transition: { type: "spring", stiffness: 280, damping: 22 },
5431
+ className: "flex items-center justify-center shrink-0 w-[56px] h-[56px]",
5432
+ "aria-hidden": "true",
5433
+ children: /* @__PURE__ */ jsx(
5434
+ MdAccessTime,
5435
+ {
5436
+ size: 56,
5437
+ color: "var(--deframe-widget-color-brand-primary)"
5438
+ }
5439
+ )
5440
+ }
5441
+ );
5442
+ }
5354
5443
  function LoadingIcon2() {
5355
5444
  const green = "var(--deframe-widget-color-brand-primary)";
5356
5445
  const trackColor = "color-mix(in srgb, var(--deframe-widget-color-brand-primary) 12%, transparent)";
@@ -5589,14 +5678,25 @@ var InvestmentCrossChainProcessingSimpleView = ({
5589
5678
  strategyName,
5590
5679
  strategyIcon,
5591
5680
  amountToken,
5592
- amountUSD
5681
+ amountUSD,
5682
+ allowBackgroundConfirmation = false,
5683
+ backgroundConfirmationStarted = false,
5684
+ backgroundConfirmationLabels,
5685
+ onBackgroundConfirmationDismiss
5593
5686
  }) => {
5687
+ const { phase } = useBackgroundConfirmationTransition({
5688
+ enabled: allowBackgroundConfirmation,
5689
+ started: backgroundConfirmationStarted,
5690
+ onDismiss: onBackgroundConfirmationDismiss
5691
+ });
5594
5692
  return /* @__PURE__ */ jsx("div", { "data-test-id": "investment-crosschain-processing-simple-view", children: /* @__PURE__ */ jsx(
5595
5693
  EarnFeedbackOverlaySimpleView,
5596
5694
  {
5597
5695
  variant: "loading",
5598
5696
  title,
5599
5697
  subtitle: description,
5698
+ phase,
5699
+ backgroundConfirmationLabels,
5600
5700
  formData: {
5601
5701
  headerTitle: title,
5602
5702
  tokenSymbol: strategyName,
@@ -13600,14 +13700,25 @@ var EarnDepositProcessingSimpleView = ({
13600
13700
  amountToken,
13601
13701
  amountUSD,
13602
13702
  iconSrc,
13603
- strategyName
13703
+ strategyName,
13704
+ allowBackgroundConfirmation = false,
13705
+ backgroundConfirmationStarted = false,
13706
+ backgroundConfirmationLabels,
13707
+ onBackgroundConfirmationDismiss
13604
13708
  }) => {
13709
+ const { phase } = useBackgroundConfirmationTransition({
13710
+ enabled: allowBackgroundConfirmation,
13711
+ started: backgroundConfirmationStarted,
13712
+ onDismiss: onBackgroundConfirmationDismiss
13713
+ });
13605
13714
  return /* @__PURE__ */ jsx("div", { "data-test-id": "earn-deposit-processing-simple-view", children: /* @__PURE__ */ jsx(
13606
13715
  EarnFeedbackOverlaySimpleView,
13607
13716
  {
13608
13717
  variant: "loading",
13609
13718
  title,
13610
13719
  subtitle: descriptionPrefix,
13720
+ phase,
13721
+ backgroundConfirmationLabels,
13611
13722
  formData: {
13612
13723
  headerTitle: title,
13613
13724
  tokenSymbol: strategyName,
@@ -13975,14 +14086,25 @@ var EarnWithdrawProcessingSimpleView = ({
13975
14086
  amountToken,
13976
14087
  amountUSD,
13977
14088
  iconSrc,
13978
- strategyName
14089
+ strategyName,
14090
+ allowBackgroundConfirmation = false,
14091
+ backgroundConfirmationStarted = false,
14092
+ backgroundConfirmationLabels,
14093
+ onBackgroundConfirmationDismiss
13979
14094
  }) => {
14095
+ const { phase } = useBackgroundConfirmationTransition({
14096
+ enabled: allowBackgroundConfirmation,
14097
+ started: backgroundConfirmationStarted,
14098
+ onDismiss: onBackgroundConfirmationDismiss
14099
+ });
13980
14100
  return /* @__PURE__ */ jsx("div", { "data-test-id": "earn-withdraw-processing-simple-view", children: /* @__PURE__ */ jsx(
13981
14101
  EarnFeedbackOverlaySimpleView,
13982
14102
  {
13983
14103
  variant: "loading",
13984
14104
  title,
13985
14105
  subtitle: descriptionPrefix,
14106
+ phase,
14107
+ backgroundConfirmationLabels,
13986
14108
  formData: {
13987
14109
  headerTitle: title,
13988
14110
  tokenSymbol: strategyName,
@@ -16059,14 +16181,25 @@ var OnchainWithdrawFailedSimpleView = ({
16059
16181
  ) });
16060
16182
  var OnchainWithdrawProcessingSimpleView = ({
16061
16183
  onClose: _onClose,
16062
- formData
16184
+ formData,
16185
+ allowBackgroundConfirmation = false,
16186
+ backgroundConfirmationStarted = false,
16187
+ backgroundConfirmationLabels,
16188
+ onBackgroundConfirmationDismiss
16063
16189
  }) => {
16190
+ const { phase } = useBackgroundConfirmationTransition({
16191
+ enabled: allowBackgroundConfirmation,
16192
+ started: backgroundConfirmationStarted,
16193
+ onDismiss: onBackgroundConfirmationDismiss
16194
+ });
16064
16195
  return /* @__PURE__ */ jsx("div", { "data-test-id": "onchain-withdraw-processing-simple-view", children: /* @__PURE__ */ jsx(
16065
16196
  EarnFeedbackOverlaySimpleView,
16066
16197
  {
16067
16198
  variant: "loading",
16068
16199
  title: "PROCESSANDO SAQUE...",
16069
16200
  subtitle: "Aguarde enquanto sua transa\xE7\xE3o \xE9 confirmada.",
16201
+ phase,
16202
+ backgroundConfirmationLabels,
16070
16203
  formData
16071
16204
  }
16072
16205
  ) });
@@ -18150,13 +18283,25 @@ function OfframpProcessingView({
18150
18283
  }
18151
18284
  );
18152
18285
  }
18153
- var OfframpProcessingSimpleView = () => {
18286
+ var OfframpProcessingSimpleView = ({
18287
+ allowBackgroundConfirmation = false,
18288
+ backgroundConfirmationStarted = false,
18289
+ backgroundConfirmationLabels,
18290
+ onBackgroundConfirmationDismiss
18291
+ }) => {
18292
+ const { phase } = useBackgroundConfirmationTransition({
18293
+ enabled: allowBackgroundConfirmation,
18294
+ started: backgroundConfirmationStarted,
18295
+ onDismiss: onBackgroundConfirmationDismiss
18296
+ });
18154
18297
  return /* @__PURE__ */ jsx("div", { "data-test-id": "offramp-processing-simple-view", children: /* @__PURE__ */ jsx(
18155
18298
  EarnFeedbackOverlaySimpleView,
18156
18299
  {
18157
18300
  variant: "loading",
18158
18301
  title: "PROCESSANDO SAQUE...",
18159
- subtitle: "Seu PIX est\xE1 sendo enviado. Aguarde alguns instantes."
18302
+ subtitle: "Seu PIX est\xE1 sendo enviado. Aguarde alguns instantes.",
18303
+ phase,
18304
+ backgroundConfirmationLabels
18160
18305
  }
18161
18306
  ) });
18162
18307
  };