@bosonprotocol/react-kit 0.34.0-alpha.1 → 0.34.0-alpha.11
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/connection/utils.d.ts.map +1 -1
- package/dist/cjs/components/connection/utils.js +0 -1
- package/dist/cjs/components/connection/utils.js.map +1 -1
- package/dist/cjs/components/queryClient/withQueryClientProvider.d.ts +0 -4
- package/dist/cjs/components/queryClient/withQueryClientProvider.d.ts.map +1 -1
- package/dist/cjs/components/queryClient/withQueryClientProvider.js +3 -26
- package/dist/cjs/components/queryClient/withQueryClientProvider.js.map +1 -1
- package/dist/cjs/components/wallet/wallet-connection.d.ts +9559 -9559
- package/dist/cjs/components/wallet2/selector/ChainSelector.d.ts +4 -1
- package/dist/cjs/components/wallet2/selector/ChainSelector.d.ts.map +1 -1
- package/dist/cjs/components/wallet2/selector/ChainSelector.js +2 -4
- package/dist/cjs/components/wallet2/selector/ChainSelector.js.map +1 -1
- package/dist/cjs/components/wallet2/walletModal/Option.d.ts +5 -1
- package/dist/cjs/components/wallet2/walletModal/Option.d.ts.map +1 -1
- package/dist/cjs/components/wallet2/walletModal/Option.js +5 -2
- package/dist/cjs/components/wallet2/walletModal/Option.js.map +1 -1
- package/dist/cjs/components/wallet2/walletModal/index.d.ts +1 -1
- package/dist/cjs/components/wallet2/walletModal/index.d.ts.map +1 -1
- package/dist/cjs/components/wallet2/walletModal/index.js.map +1 -1
- package/dist/cjs/components/wallet2/web3Status/index.d.ts +14 -2
- package/dist/cjs/components/wallet2/web3Status/index.d.ts.map +1 -1
- package/dist/cjs/components/wallet2/web3Status/index.js +13 -5
- package/dist/cjs/components/wallet2/web3Status/index.js.map +1 -1
- package/dist/cjs/hooks/index.d.ts +5 -0
- package/dist/cjs/hooks/index.d.ts.map +1 -1
- package/dist/cjs/hooks/index.js +11 -1
- package/dist/cjs/hooks/index.js.map +1 -1
- package/dist/cjs/hooks/useCtaClickHandler.d.ts +1 -1
- package/dist/cjs/hooks/useCtaClickHandler.d.ts.map +1 -1
- package/dist/cjs/hooks/useCtaClickHandler.js.map +1 -1
- package/dist/cjs/hooks/useMetaTx.d.ts +1 -1
- package/dist/cjs/hooks/useMetaTx.d.ts.map +1 -1
- package/dist/cjs/hooks/useMetaTx.js.map +1 -1
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/components/connection/utils.d.ts.map +1 -1
- package/dist/esm/components/connection/utils.js +0 -1
- package/dist/esm/components/connection/utils.js.map +1 -1
- package/dist/esm/components/queryClient/withQueryClientProvider.d.ts +0 -4
- package/dist/esm/components/queryClient/withQueryClientProvider.d.ts.map +1 -1
- package/dist/esm/components/queryClient/withQueryClientProvider.js +1 -11
- package/dist/esm/components/queryClient/withQueryClientProvider.js.map +1 -1
- package/dist/esm/components/wallet/wallet-connection.d.ts +9559 -9559
- package/dist/esm/components/wallet2/selector/ChainSelector.d.ts +4 -1
- package/dist/esm/components/wallet2/selector/ChainSelector.d.ts.map +1 -1
- package/dist/esm/components/wallet2/selector/ChainSelector.js +3 -5
- package/dist/esm/components/wallet2/selector/ChainSelector.js.map +1 -1
- package/dist/esm/components/wallet2/walletModal/Option.d.ts +5 -1
- package/dist/esm/components/wallet2/walletModal/Option.d.ts.map +1 -1
- package/dist/esm/components/wallet2/walletModal/Option.js +5 -2
- package/dist/esm/components/wallet2/walletModal/Option.js.map +1 -1
- package/dist/esm/components/wallet2/walletModal/index.d.ts +1 -1
- package/dist/esm/components/wallet2/walletModal/index.d.ts.map +1 -1
- package/dist/esm/components/wallet2/walletModal/index.js.map +1 -1
- package/dist/esm/components/wallet2/web3Status/index.d.ts +14 -2
- package/dist/esm/components/wallet2/web3Status/index.d.ts.map +1 -1
- package/dist/esm/components/wallet2/web3Status/index.js +14 -6
- package/dist/esm/components/wallet2/web3Status/index.js.map +1 -1
- package/dist/esm/hooks/index.d.ts +5 -0
- package/dist/esm/hooks/index.d.ts.map +1 -1
- package/dist/esm/hooks/index.js +5 -0
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/useCtaClickHandler.d.ts +1 -1
- package/dist/esm/hooks/useCtaClickHandler.d.ts.map +1 -1
- package/dist/esm/hooks/useCtaClickHandler.js.map +1 -1
- package/dist/esm/hooks/useMetaTx.d.ts +1 -1
- package/dist/esm/hooks/useMetaTx.d.ts.map +1 -1
- package/dist/esm/hooks/useMetaTx.js.map +1 -1
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/connection/utils.ts +0 -1
- package/src/components/queryClient/withQueryClientProvider.tsx +1 -26
- package/src/components/wallet2/selector/ChainSelector.tsx +25 -13
- package/src/components/wallet2/walletModal/Option.tsx +9 -2
- package/src/components/wallet2/walletModal/index.tsx +1 -0
- package/src/components/wallet2/web3Status/index.tsx +43 -15
- package/src/hooks/index.ts +10 -0
- package/src/hooks/useCtaClickHandler.ts +4 -1
- package/src/hooks/useMetaTx.ts +3 -1
- package/src/index.tsx +4 -0
- package/src/stories/ConnectWallet.stories.tsx +29 -5
- package/src/stories/buttons/Upload.stories.tsx +1 -3
|
@@ -110,6 +110,9 @@ export interface OptionProps {
|
|
|
110
110
|
hoverColor: CSSProperties["color"];
|
|
111
111
|
backgroundColor: CSSProperties["backgroundColor"];
|
|
112
112
|
borderRadius: CSSProperties["borderRadius"];
|
|
113
|
+
onOptionClick?: (arg0: {
|
|
114
|
+
activationState: ReturnType<typeof useActivationState>["activationState"];
|
|
115
|
+
}) => void;
|
|
113
116
|
}
|
|
114
117
|
export function Option({
|
|
115
118
|
connection,
|
|
@@ -117,7 +120,8 @@ export function Option({
|
|
|
117
120
|
hoverFocusBackgroundColor,
|
|
118
121
|
hoverColor,
|
|
119
122
|
backgroundColor,
|
|
120
|
-
borderRadius
|
|
123
|
+
borderRadius,
|
|
124
|
+
onOptionClick
|
|
121
125
|
}: OptionProps) {
|
|
122
126
|
const { activationState, tryActivation } = useActivationState();
|
|
123
127
|
const toggleAccountDrawer = useToggleAccountDrawer();
|
|
@@ -139,7 +143,10 @@ export function Option({
|
|
|
139
143
|
>
|
|
140
144
|
<OptionCardClickable
|
|
141
145
|
disabled={isSomeOptionPending}
|
|
142
|
-
onClick={
|
|
146
|
+
onClick={() => {
|
|
147
|
+
activate();
|
|
148
|
+
onOptionClick?.({ activationState });
|
|
149
|
+
}}
|
|
143
150
|
selected={isCurrentOptionPending}
|
|
144
151
|
data-testid={`wallet-option-${connection.type}`}
|
|
145
152
|
>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useWeb3React } from "@web3-react/core";
|
|
2
|
-
import React, { memo, useCallback, useEffect, useRef } from "react";
|
|
2
|
+
import React, { ReactNode, memo, useCallback, useEffect, useRef } from "react";
|
|
3
3
|
import styled from "styled-components";
|
|
4
4
|
|
|
5
5
|
import { useIsMagicLoggedIn } from "../../../hooks";
|
|
@@ -64,7 +64,17 @@ const getCommonWalletButtonProps = (isXXS: boolean) =>
|
|
|
64
64
|
function Web3StatusInner({
|
|
65
65
|
showOnlyIcon,
|
|
66
66
|
errorButtonTheme,
|
|
67
|
-
|
|
67
|
+
connectedButtonTheme,
|
|
68
|
+
connectWalletButtonTheme,
|
|
69
|
+
connectWalletChild = <>Connect Wallet</>,
|
|
70
|
+
showStatusIcon = true,
|
|
71
|
+
wrongNetworkChild = <>Wrong network</>,
|
|
72
|
+
leftConnectWalletChild,
|
|
73
|
+
leftConnectedChild,
|
|
74
|
+
leftWrongNetworkChild,
|
|
75
|
+
rightConnectWalletChild,
|
|
76
|
+
rightConnectedChild,
|
|
77
|
+
rightWrongNetworkChild
|
|
68
78
|
}: ConnectWalletProps) {
|
|
69
79
|
const switchingChain = useAppSelector(
|
|
70
80
|
(state) => state.wallets.switchingChain
|
|
@@ -121,18 +131,21 @@ function Web3StatusInner({
|
|
|
121
131
|
disabled={Boolean(switchingChain)}
|
|
122
132
|
data-testid="web3-status-connected"
|
|
123
133
|
onClick={handleWalletDropdownClick}
|
|
124
|
-
theme={
|
|
134
|
+
theme={connectedButtonTheme}
|
|
125
135
|
>
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
136
|
+
{showStatusIcon && (
|
|
137
|
+
<StatusIcon
|
|
138
|
+
account={account}
|
|
139
|
+
size={24}
|
|
140
|
+
connection={connection}
|
|
141
|
+
showMiniIcons={showOnlyIcon}
|
|
142
|
+
/>
|
|
143
|
+
)}
|
|
144
|
+
{leftConnectedChild}
|
|
133
145
|
<AddressAndChevronContainer>
|
|
134
146
|
<Text>{ENSName || formatAddress(account)}</Text>
|
|
135
147
|
</AddressAndChevronContainer>
|
|
148
|
+
{rightConnectedChild}
|
|
136
149
|
</BaseButton>
|
|
137
150
|
);
|
|
138
151
|
}
|
|
@@ -163,7 +176,9 @@ function Web3StatusInner({
|
|
|
163
176
|
onClick={handleWalletDropdownClick}
|
|
164
177
|
theme={errorButtonTheme}
|
|
165
178
|
>
|
|
166
|
-
|
|
179
|
+
{leftWrongNetworkChild}
|
|
180
|
+
{wrongNetworkChild}
|
|
181
|
+
{rightWrongNetworkChild}
|
|
167
182
|
</BaseButton>
|
|
168
183
|
</Tooltip>
|
|
169
184
|
) : (
|
|
@@ -171,23 +186,36 @@ function Web3StatusInner({
|
|
|
171
186
|
onClick={handleWalletDropdownClick}
|
|
172
187
|
data-testid="navbar-connect-wallet"
|
|
173
188
|
{...getCommonWalletButtonProps(isXXS)}
|
|
174
|
-
theme={
|
|
189
|
+
theme={connectWalletButtonTheme}
|
|
175
190
|
style={{
|
|
176
191
|
...getCommonWalletButtonProps(isXXS).style
|
|
177
192
|
}}
|
|
178
193
|
>
|
|
179
|
-
|
|
194
|
+
{leftConnectWalletChild}
|
|
195
|
+
{connectWalletChild}
|
|
196
|
+
{rightConnectWalletChild}
|
|
180
197
|
</BaseButton>
|
|
181
198
|
)}
|
|
182
199
|
</Grid>
|
|
183
200
|
);
|
|
184
201
|
}
|
|
202
|
+
type SuccessButtonTheme = Omit<BaseButtonTheme, "color" | "background"> &
|
|
203
|
+
Required<Pick<BaseButtonTheme, "color" | "background">>;
|
|
185
204
|
|
|
186
205
|
export type ConnectWalletProps = {
|
|
187
206
|
showOnlyIcon?: boolean;
|
|
188
207
|
errorButtonTheme: BaseButtonTheme;
|
|
189
|
-
|
|
190
|
-
|
|
208
|
+
connectedButtonTheme: SuccessButtonTheme;
|
|
209
|
+
connectWalletButtonTheme: SuccessButtonTheme;
|
|
210
|
+
connectWalletChild?: ReactNode;
|
|
211
|
+
wrongNetworkChild?: ReactNode;
|
|
212
|
+
showStatusIcon?: boolean;
|
|
213
|
+
leftConnectedChild?: ReactNode;
|
|
214
|
+
rightConnectedChild?: ReactNode;
|
|
215
|
+
leftWrongNetworkChild?: ReactNode;
|
|
216
|
+
rightWrongNetworkChild?: ReactNode;
|
|
217
|
+
leftConnectWalletChild?: ReactNode;
|
|
218
|
+
rightConnectWalletChild?: ReactNode;
|
|
191
219
|
};
|
|
192
220
|
export const ConnectWallet = memo(function Web3Status(
|
|
193
221
|
props: ConnectWalletProps
|
package/src/hooks/index.ts
CHANGED
|
@@ -25,3 +25,13 @@ export * from "./ipfs/useIpfsStorage";
|
|
|
25
25
|
export * from "./location/buildUseSearchParams";
|
|
26
26
|
export * from "./form/useForm";
|
|
27
27
|
export * from "./useBreakpoints";
|
|
28
|
+
export * from "./useSignerAddress";
|
|
29
|
+
export * from "./useMetaTx";
|
|
30
|
+
export { useCtaClickHandler } from "./useCtaClickHandler";
|
|
31
|
+
export {
|
|
32
|
+
useToggleAccountDrawer,
|
|
33
|
+
useAccountDrawer,
|
|
34
|
+
useCloseAccountDrawer,
|
|
35
|
+
useOpenAccountDrawer
|
|
36
|
+
} from "../components/wallet2/accountDrawer/index";
|
|
37
|
+
export * from "./usePrevious";
|
|
@@ -20,7 +20,10 @@ export function useCtaClickHandler<T>({
|
|
|
20
20
|
successPayload
|
|
21
21
|
}: {
|
|
22
22
|
waitBlocks: number;
|
|
23
|
-
coreSdk:
|
|
23
|
+
coreSdk: Pick<
|
|
24
|
+
CoreSDK,
|
|
25
|
+
"relayNativeMetaTransaction" | "relayMetaTransaction" | "parseError"
|
|
26
|
+
>;
|
|
24
27
|
useMetaTx: boolean;
|
|
25
28
|
actions: Action[];
|
|
26
29
|
successPayload: T | ((receipt: providers.TransactionReceipt) => T);
|
package/src/hooks/useMetaTx.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { CoreSDK } from "@bosonprotocol/core-sdk";
|
|
2
2
|
import { useSignerAddress } from "./useSignerAddress";
|
|
3
3
|
|
|
4
|
-
export function useMetaTx(
|
|
4
|
+
export function useMetaTx(
|
|
5
|
+
coreSdk: Pick<CoreSDK, "isMetaTxConfigSet" | "web3Lib"> | undefined
|
|
6
|
+
) {
|
|
5
7
|
const { signerAddress, signerContract } = useSignerAddress(coreSdk?.web3Lib);
|
|
6
8
|
const isMetaTx = coreSdk
|
|
7
9
|
? Boolean(coreSdk.isMetaTxConfigSet && signerAddress && !signerContract)
|
package/src/index.tsx
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./components/buttons/BurgerButton";
|
|
|
3
3
|
export * from "./components/buttons/Button";
|
|
4
4
|
export * from "./components/buttons/CommitButtonView";
|
|
5
5
|
export * from "./components/config/ConfigProvider";
|
|
6
|
+
export * from "./components/cta/common/types";
|
|
6
7
|
export * from "./components/cta/dispute/DecideDisputeButton";
|
|
7
8
|
export * from "./components/cta/dispute/EscalateDisputeButton";
|
|
8
9
|
export * from "./components/cta/dispute/ExpireDisputeButton";
|
|
@@ -45,6 +46,8 @@ export * from "./components/modal/components/Redeem/DetailView/ExternalExchangeD
|
|
|
45
46
|
export * from "./components/portal/Portal";
|
|
46
47
|
export * from "./components/productCard/const";
|
|
47
48
|
export * from "./components/productCard/ProductCard";
|
|
49
|
+
export * from "./components/queryClient/withQueryClientProvider";
|
|
50
|
+
export * from "./components/queryClient/QueryClientProviderCustom";
|
|
48
51
|
export * from "./components/scroll/ScrollToID";
|
|
49
52
|
export * from "./components/scroll/ScrollToTop";
|
|
50
53
|
export * from "./components/searchBar/SearchBar";
|
|
@@ -85,6 +88,7 @@ export * from "./lib/magicLink/logout";
|
|
|
85
88
|
export * from "./lib/magicLink/provider";
|
|
86
89
|
export * from "./lib/offer/filter";
|
|
87
90
|
export * from "./lib/offer/getIsOfferExpired";
|
|
91
|
+
export * from "./lib/opensea/getOpenSeaUrl";
|
|
88
92
|
export * from "./lib/promises/promises";
|
|
89
93
|
export * from "./lib/url/url";
|
|
90
94
|
export * from "./theme";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fn } from "@storybook/test";
|
|
2
|
-
import React from "react";
|
|
2
|
+
import React, { ReactNode } from "react";
|
|
3
3
|
import { Meta } from "@storybook/react";
|
|
4
4
|
import {
|
|
5
5
|
ChainSelector,
|
|
@@ -17,8 +17,9 @@ import {
|
|
|
17
17
|
import { HashRouter, Route, Routes } from "react-router-dom";
|
|
18
18
|
import { bosonButtonThemeKeys } from "../components/ui/ThemedButton";
|
|
19
19
|
import { CSSProperties, createGlobalStyle } from "styled-components";
|
|
20
|
+
import { Wallet } from "phosphor-react";
|
|
20
21
|
const colors = theme.colors.light;
|
|
21
|
-
const successButtonTheme: ConnectWalletProps["
|
|
22
|
+
const successButtonTheme: ConnectWalletProps["connectWalletButtonTheme"] = {
|
|
22
23
|
...bosonButtonThemes({ withBosonStyle: false })["primary"],
|
|
23
24
|
color: "inherit",
|
|
24
25
|
background: "var(--buttonBgColor)"
|
|
@@ -30,13 +31,17 @@ const errorButtonTheme = bosonButtonThemes({ withBosonStyle: false })[
|
|
|
30
31
|
const envName =
|
|
31
32
|
(process.env.STORYBOOK_DATA_ENV_NAME as EnvironmentType) || "testing";
|
|
32
33
|
const envConfig = getEnvConfigs(envName);
|
|
33
|
-
const
|
|
34
|
+
const config = envConfig[0];
|
|
35
|
+
const configId = config.configId;
|
|
34
36
|
const ColorGlobalStyle = createGlobalStyle<{ color: CSSProperties["color"] }>`
|
|
35
37
|
html, body{
|
|
36
38
|
color: ${({ color }) => color};
|
|
37
39
|
}
|
|
38
40
|
`;
|
|
39
41
|
const Component = ({
|
|
42
|
+
showStatusIcon,
|
|
43
|
+
rightConnectedChild,
|
|
44
|
+
connectWalletChild,
|
|
40
45
|
textColor,
|
|
41
46
|
chainSelectorBackgroundColor,
|
|
42
47
|
connectWalletBorderRadius,
|
|
@@ -58,7 +63,10 @@ const Component = ({
|
|
|
58
63
|
magicLoginButtonBorderRadiusPx,
|
|
59
64
|
onUserDisconnect
|
|
60
65
|
}: {
|
|
66
|
+
showStatusIcon: boolean;
|
|
67
|
+
rightConnectedChild?: ReactNode;
|
|
61
68
|
textColor: string;
|
|
69
|
+
connectWalletChild: string;
|
|
62
70
|
chainSelectorBackgroundColor: string | undefined;
|
|
63
71
|
connectWalletBorderRadius: string | undefined;
|
|
64
72
|
connectWalletSuccessButtonThemeKey: string | undefined;
|
|
@@ -114,9 +122,22 @@ const Component = ({
|
|
|
114
122
|
<ChainSelector
|
|
115
123
|
leftAlign={true}
|
|
116
124
|
backgroundColor={chainSelectorBackgroundColor}
|
|
125
|
+
config={config}
|
|
117
126
|
/>
|
|
118
127
|
<ConnectWallet
|
|
119
|
-
|
|
128
|
+
showStatusIcon={showStatusIcon}
|
|
129
|
+
connectWalletChild={connectWalletChild}
|
|
130
|
+
rightConnectedChild={rightConnectedChild}
|
|
131
|
+
connectWalletButtonTheme={{
|
|
132
|
+
...(connectWalletSuccessButtonThemeKey
|
|
133
|
+
? bosonButtonThemes({ withBosonStyle: false })[
|
|
134
|
+
connectWalletSuccessButtonThemeKey
|
|
135
|
+
]
|
|
136
|
+
: successButtonTheme),
|
|
137
|
+
borderRadius: connectWalletBorderRadius,
|
|
138
|
+
gap: "2px"
|
|
139
|
+
}}
|
|
140
|
+
connectedButtonTheme={{
|
|
120
141
|
...(connectWalletSuccessButtonThemeKey
|
|
121
142
|
? bosonButtonThemes({ withBosonStyle: false })[
|
|
122
143
|
connectWalletSuccessButtonThemeKey
|
|
@@ -283,6 +304,9 @@ export const CustomTheme = {
|
|
|
283
304
|
walletHoverFocusBackgroundColor: "#e89f0e",
|
|
284
305
|
walletHoverColor: "#ff0000",
|
|
285
306
|
magicLoginButtonThemeKey: "orangeInverse",
|
|
286
|
-
magicLoginButtonBorderRadiusPx: "50"
|
|
307
|
+
magicLoginButtonBorderRadiusPx: "50",
|
|
308
|
+
showStatusIcon: false,
|
|
309
|
+
connectWalletChild: <>Connect</>,
|
|
310
|
+
rightConnectedChild: <Wallet />
|
|
287
311
|
}
|
|
288
312
|
};
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { fn } from "@storybook/test";
|
|
2
1
|
import React from "react";
|
|
3
2
|
import { Meta } from "@storybook/react";
|
|
4
|
-
import { Upload } from "../..";
|
|
3
|
+
import { QueryClientProviderCustom, Upload } from "../..";
|
|
5
4
|
import { EnvironmentProvider } from "../../components/environment/EnvironmentProvider";
|
|
6
5
|
import { IpfsProvider } from "../../components/ipfs/IpfsProvider";
|
|
7
6
|
import { Formik } from "formik";
|
|
8
|
-
import { QueryClientProviderCustom } from "../../components/queryClient/withQueryClientProvider";
|
|
9
7
|
import {
|
|
10
8
|
bosonButtonThemeKeys,
|
|
11
9
|
bosonButtonThemes
|