@gearbox-protocol/ui-kit 4.0.0-next.8 → 4.0.0-next.9
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/components/composites/tx-preview/confirm/dialog/TransactionConfirmShell.cjs +1 -1
- package/dist/esm/components/composites/tx-preview/confirm/dialog/TransactionConfirmShell.js +44 -55
- package/dist/types/components/composites/tx-preview/confirm/dialog/transactionConfirmShellTypes.d.ts +8 -5
- package/package.json +1 -1
package/dist/cjs/components/composites/tx-preview/confirm/dialog/TransactionConfirmShell.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("../../../../client-adapters/styled-dialog-container/styled-dialog-container.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),j=require("../../../../client-adapters/styled-dialog-container/styled-dialog-container.cjs"),C=require("../../../../confirm-menu/confirm-menu.cjs"),q=require("../../../../error-message/error-line-message.cjs");require("react-intl");require("../../../../buttons/button/button.cjs");require("../../../../dialog/dialog-container.cjs");const x=require("../../../../typed-intl/index.cjs");require("react");require("@gearbox-protocol/sdk");const w=require("../../../../../utils/cn.cjs");require("sonner");require("@gearbox-protocol/sdk/common-utils");require("luxon");require("../../../../../utils/z-index.cjs");const S=require("../../../../modal/modal.cjs"),T=require("../../../../skeleton/skeleton-stack.cjs"),k=require("../../../../spinner/spinner.cjs"),y=require("../../../../typography/typography.cjs"),p=require("../../../../vspace/vspace.cjs"),P=require("../stepper/ProgressStepper.cjs"),M=require("./computeTransactionConfirmDialogLayout.cjs"),t=require("./constants.cjs");function D(n){const{mode:r,open:c=!0,phase:u="confirm",onClose:l,title:i,titleAddon:d,hideTitleAddonOnResult:s=!0,body:o,className:a,previewClassName:g,"data-testid":h,shellTestId:_}=n;if(r==="dialog"&&!c)return null;const m=o.kind==="ready"?u:"confirm",v=m!=="confirm"&&m!=="awaiting_receipt"&&s?void 0:d,f=e.jsx(j.StyledDialogContainer,{className:w.cn(t.transactionConfirmDialogShellVariants(),r==="dialog"?t.transactionConfirmModalContainerVariants():null,a),"data-testid":h,children:e.jsx(N,{body:o,phase:m,previewClassName:g,testId:_??t.TransactionConfirmDialogTest.root,header:e.jsx(C.ConfirmMenu,{title:i,titleAddon:v,onClose:l})})});return r==="page"?f:e.jsx(S.Modal,{show:!0,onClickOutside:l,zIndexLayer:"MODAL",children:f})}function N({body:n,phase:r,previewClassName:c,testId:u,header:l}){const i=n.kind==="ready"?n.stepper:void 0,d=!!(i&&i.length>0),s=M.computeTransactionConfirmDialogLayout(r,d),o=n.kind==="ready"?L(n,r):void 0,a=n.kind==="ready"?n.execution:void 0;return e.jsxs("div",{className:t.transactionConfirmShellContentVariants(),"data-testid":u,children:[e.jsx("div",{className:"shrink-0",children:l}),e.jsx(p.VSpace,{size:"sm"}),s.showResult&&o?e.jsx("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":t.TransactionConfirmDialogTest.result,children:o}):null,s.showResult?null:e.jsxs("div",{className:"flex min-h-0 flex-1 flex-col",children:[s.showPreview?e.jsx("div",{className:c??t.transactionConfirmPreviewScrollVariants(),children:e.jsx(I,{body:n})}):null,s.showPreview&&s.showExecution&&a?e.jsx(p.VSpace,{size:"md"}):null,s.showExecution&&a?e.jsx("div",{className:"min-w-0 w-full shrink-0","data-testid":t.TransactionConfirmDialogTest.execution,children:a}):null]}),s.showProgressStepper&&i?e.jsxs(e.Fragment,{children:[e.jsx(p.VSpace,{size:"md"}),e.jsx("div",{className:"shrink-0","data-testid":t.TransactionConfirmDialogTest.progress,children:e.jsx(P.ProgressStepper,{tone:"muted",steps:i})})]}):null]})}function I({body:n}){const r=x.useIntlTyped();return n.kind==="loading"?e.jsxs("div",{className:"flex flex-col items-center justify-center gap-3 py-8",children:[e.jsx(k.Spinner,{}),e.jsx(y.Typography,{variant:"bodySmall",color:"muted",as:"p",children:e.jsx(x.FormattedMessageTyped,{messageId:"components.transactionConfirm.previewLoading"})})]}):n.kind==="error"?e.jsx(q.ErrorLineMessage,{err:n.error,title:n.title??r.formatMessage({messageId:"components.transactionConfirm.previewErrorTitle"})}):n.previewLoading?e.jsx(T.SkeletonStack,{lines:3}):e.jsx(e.Fragment,{children:n.preview})}function L(n,r){if(n.result){if(r==="success")return n.result.success;if(r==="failure")return n.result.failure}}exports.TransactionConfirmShell=D;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as r, jsxs as
|
|
1
|
+
import { jsx as r, jsxs as l, Fragment as v } from "react/jsx-runtime";
|
|
2
2
|
import { StyledDialogContainer as S } from "../../../../client-adapters/styled-dialog-container/styled-dialog-container.js";
|
|
3
3
|
import { ConfirmMenu as k } from "../../../../confirm-menu/confirm-menu.js";
|
|
4
4
|
import { ErrorLineMessage as T } from "../../../../error-message/error-line-message.js";
|
|
@@ -13,121 +13,110 @@ import "sonner";
|
|
|
13
13
|
import "@gearbox-protocol/sdk/common-utils";
|
|
14
14
|
import "luxon";
|
|
15
15
|
import "../../../../../utils/z-index.js";
|
|
16
|
-
import { Modal as
|
|
17
|
-
import { SkeletonStack as
|
|
16
|
+
import { Modal as M } from "../../../../modal/modal.js";
|
|
17
|
+
import { SkeletonStack as L } from "../../../../skeleton/skeleton-stack.js";
|
|
18
18
|
import { Spinner as A } from "../../../../spinner/spinner.js";
|
|
19
19
|
import { Typography as D } from "../../../../typography/typography.js";
|
|
20
|
-
import { VSpace as
|
|
20
|
+
import { VSpace as f } from "../../../../vspace/vspace.js";
|
|
21
21
|
import { ProgressStepper as V } from "../stepper/ProgressStepper.js";
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
|
|
25
|
-
function ce(e) {
|
|
22
|
+
import { computeTransactionConfirmDialogLayout as z } from "./computeTransactionConfirmDialogLayout.js";
|
|
23
|
+
import { TransactionConfirmDialogTest as m, transactionConfirmModalContainerVariants as E, transactionConfirmDialogShellVariants as R, transactionConfirmShellContentVariants as j, transactionConfirmPreviewScrollVariants as y } from "./constants.js";
|
|
24
|
+
function me(e) {
|
|
26
25
|
const {
|
|
27
26
|
mode: t,
|
|
28
27
|
open: c = !0,
|
|
29
|
-
phase:
|
|
30
|
-
onClose:
|
|
28
|
+
phase: d = "confirm",
|
|
29
|
+
onClose: a,
|
|
31
30
|
title: n,
|
|
32
|
-
titleAddon:
|
|
31
|
+
titleAddon: p,
|
|
33
32
|
hideTitleAddonOnResult: i = !0,
|
|
34
33
|
body: o,
|
|
35
34
|
className: s,
|
|
36
|
-
previewClassName:
|
|
35
|
+
previewClassName: g,
|
|
37
36
|
"data-testid": w,
|
|
38
37
|
shellTestId: x
|
|
39
38
|
} = e;
|
|
40
39
|
if (t === "dialog" && !c) return null;
|
|
41
|
-
const
|
|
40
|
+
const u = o.kind === "ready" ? d : "confirm", C = u !== "confirm" && u !== "awaiting_receipt" && i ? void 0 : p, h = /* @__PURE__ */ r(
|
|
42
41
|
S,
|
|
43
42
|
{
|
|
44
43
|
className: I(
|
|
45
|
-
|
|
46
|
-
t === "dialog" ?
|
|
44
|
+
R(),
|
|
45
|
+
t === "dialog" ? E() : null,
|
|
47
46
|
s
|
|
48
47
|
),
|
|
49
48
|
"data-testid": w,
|
|
50
49
|
children: /* @__PURE__ */ r(
|
|
51
|
-
|
|
50
|
+
O,
|
|
52
51
|
{
|
|
53
52
|
body: o,
|
|
54
|
-
phase:
|
|
55
|
-
previewClassName:
|
|
56
|
-
testId: x ??
|
|
53
|
+
phase: u,
|
|
54
|
+
previewClassName: g,
|
|
55
|
+
testId: x ?? m.root,
|
|
57
56
|
header: /* @__PURE__ */ r(
|
|
58
57
|
k,
|
|
59
58
|
{
|
|
60
59
|
title: n,
|
|
61
60
|
titleAddon: C,
|
|
62
|
-
onClose:
|
|
61
|
+
onClose: a
|
|
63
62
|
}
|
|
64
63
|
)
|
|
65
64
|
}
|
|
66
65
|
)
|
|
67
66
|
}
|
|
68
67
|
);
|
|
69
|
-
return t === "page" ?
|
|
68
|
+
return t === "page" ? h : /* @__PURE__ */ r(M, { show: !0, onClickOutside: a, zIndexLayer: "MODAL", children: h });
|
|
70
69
|
}
|
|
71
|
-
function
|
|
70
|
+
function O({
|
|
72
71
|
body: e,
|
|
73
72
|
phase: t,
|
|
74
73
|
previewClassName: c,
|
|
75
|
-
testId:
|
|
76
|
-
header:
|
|
74
|
+
testId: d,
|
|
75
|
+
header: a
|
|
77
76
|
}) {
|
|
78
|
-
const n = e.kind === "ready" ? e.stepper : void 0,
|
|
79
|
-
return /* @__PURE__ */
|
|
77
|
+
const n = e.kind === "ready" ? e.stepper : void 0, p = !!(n && n.length > 0), i = z(t, p), o = e.kind === "ready" ? B(e, t) : void 0, s = e.kind === "ready" ? e.execution : void 0;
|
|
78
|
+
return /* @__PURE__ */ l(
|
|
80
79
|
"div",
|
|
81
80
|
{
|
|
82
|
-
className:
|
|
83
|
-
"data-testid":
|
|
81
|
+
className: j(),
|
|
82
|
+
"data-testid": d,
|
|
84
83
|
children: [
|
|
85
|
-
/* @__PURE__ */ r("div", { className: "shrink-0", children:
|
|
86
|
-
/* @__PURE__ */ r(
|
|
84
|
+
/* @__PURE__ */ r("div", { className: "shrink-0", children: a }),
|
|
85
|
+
/* @__PURE__ */ r(f, { size: "sm" }),
|
|
87
86
|
i.showResult && o ? /* @__PURE__ */ r(
|
|
88
87
|
"div",
|
|
89
88
|
{
|
|
90
89
|
className: "flex min-h-0 flex-1 flex-col",
|
|
91
|
-
"data-testid":
|
|
90
|
+
"data-testid": m.result,
|
|
92
91
|
children: o
|
|
93
92
|
}
|
|
94
93
|
) : null,
|
|
95
|
-
i.showResult ? null : /* @__PURE__ */
|
|
94
|
+
i.showResult ? null : /* @__PURE__ */ l("div", { className: "flex min-h-0 flex-1 flex-col", children: [
|
|
96
95
|
i.showPreview ? /* @__PURE__ */ r(
|
|
97
96
|
"div",
|
|
98
97
|
{
|
|
99
|
-
className: c ??
|
|
100
|
-
children: /* @__PURE__ */ r(
|
|
98
|
+
className: c ?? y(),
|
|
99
|
+
children: /* @__PURE__ */ r(F, { body: e })
|
|
101
100
|
}
|
|
102
101
|
) : null,
|
|
103
|
-
i.showPreview && i.showExecution && s ? /* @__PURE__ */ r(
|
|
102
|
+
i.showPreview && i.showExecution && s ? /* @__PURE__ */ r(f, { size: "md" }) : null,
|
|
104
103
|
i.showExecution && s ? /* @__PURE__ */ r(
|
|
105
104
|
"div",
|
|
106
105
|
{
|
|
107
106
|
className: "min-w-0 w-full shrink-0",
|
|
108
|
-
"data-testid":
|
|
107
|
+
"data-testid": m.execution,
|
|
109
108
|
children: s
|
|
110
109
|
}
|
|
111
110
|
) : null
|
|
112
111
|
] }),
|
|
113
|
-
i.showProgressStepper && n ? /* @__PURE__ */
|
|
114
|
-
/* @__PURE__ */ r(
|
|
112
|
+
i.showProgressStepper && n ? /* @__PURE__ */ l(v, { children: [
|
|
113
|
+
/* @__PURE__ */ r(f, { size: "md" }),
|
|
115
114
|
/* @__PURE__ */ r(
|
|
116
115
|
"div",
|
|
117
116
|
{
|
|
118
117
|
className: "shrink-0",
|
|
119
|
-
"data-testid":
|
|
120
|
-
children: /* @__PURE__ */ r(
|
|
121
|
-
V,
|
|
122
|
-
{
|
|
123
|
-
tone: "muted",
|
|
124
|
-
steps: n.steps.map((a) => ({
|
|
125
|
-
id: a.id,
|
|
126
|
-
status: a.status,
|
|
127
|
-
label: n.renderLabel(a)
|
|
128
|
-
}))
|
|
129
|
-
}
|
|
130
|
-
)
|
|
118
|
+
"data-testid": m.progress,
|
|
119
|
+
children: /* @__PURE__ */ r(V, { tone: "muted", steps: n })
|
|
131
120
|
}
|
|
132
121
|
)
|
|
133
122
|
] }) : null
|
|
@@ -135,11 +124,11 @@ function F({
|
|
|
135
124
|
}
|
|
136
125
|
);
|
|
137
126
|
}
|
|
138
|
-
function
|
|
127
|
+
function F({
|
|
139
128
|
body: e
|
|
140
129
|
}) {
|
|
141
130
|
const t = N();
|
|
142
|
-
return e.kind === "loading" ? /* @__PURE__ */
|
|
131
|
+
return e.kind === "loading" ? /* @__PURE__ */ l("div", { className: "flex flex-col items-center justify-center gap-3 py-8", children: [
|
|
143
132
|
/* @__PURE__ */ r(A, {}),
|
|
144
133
|
/* @__PURE__ */ r(D, { variant: "bodySmall", color: "muted", as: "p", children: /* @__PURE__ */ r(P, { messageId: "components.transactionConfirm.previewLoading" }) })
|
|
145
134
|
] }) : e.kind === "error" ? /* @__PURE__ */ r(
|
|
@@ -150,14 +139,14 @@ function B({
|
|
|
150
139
|
messageId: "components.transactionConfirm.previewErrorTitle"
|
|
151
140
|
})
|
|
152
141
|
}
|
|
153
|
-
) : e.previewLoading ? /* @__PURE__ */ r(
|
|
142
|
+
) : e.previewLoading ? /* @__PURE__ */ r(L, { lines: 3 }) : /* @__PURE__ */ r(v, { children: e.preview });
|
|
154
143
|
}
|
|
155
|
-
function
|
|
144
|
+
function B(e, t) {
|
|
156
145
|
if (e.result) {
|
|
157
146
|
if (t === "success") return e.result.success;
|
|
158
147
|
if (t === "failure") return e.result.failure;
|
|
159
148
|
}
|
|
160
149
|
}
|
|
161
150
|
export {
|
|
162
|
-
|
|
151
|
+
me as TransactionConfirmShell
|
|
163
152
|
};
|
package/dist/types/components/composites/tx-preview/confirm/dialog/transactionConfirmShellTypes.d.ts
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { ProgressStepperStep } from '../stepper/ProgressStepper';
|
|
3
3
|
import { TransactionConfirmPhase } from './transactionConfirmPhase';
|
|
4
4
|
/**
|
|
5
5
|
* How the card is framed. The body is identical in both: `page` drops the card
|
|
6
6
|
* into page flow, `dialog` puts the same card inside a modal.
|
|
7
7
|
*/
|
|
8
8
|
export type TransactionConfirmShellMode = "page" | "dialog";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Pre-labelled, ready-to-render steps. The slot no longer restricts step ids
|
|
11
|
+
* to the execution union: session-plan steppers (agreement/approve/confirm
|
|
12
|
+
* plus a delayed request/complete tail) carry their own ids and labels, and
|
|
13
|
+
* visibility is the caller's decision — omit the slot to hide the stepper.
|
|
14
|
+
*/
|
|
15
|
+
export type TransactionConfirmShellStepper = ReadonlyArray<ProgressStepperStep>;
|
|
13
16
|
/**
|
|
14
17
|
* Shown instead of preview and execution once the phase is terminal.
|
|
15
18
|
*
|