@bosonprotocol/react-kit 0.31.1 → 0.32.0-alpha.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.
Files changed (185) hide show
  1. package/dist/cjs/components/buttons/BaseButton.d.ts +27 -0
  2. package/dist/cjs/components/buttons/BaseButton.d.ts.map +1 -0
  3. package/dist/cjs/components/buttons/BaseButton.js +154 -0
  4. package/dist/cjs/components/buttons/BaseButton.js.map +1 -0
  5. package/dist/cjs/components/form/BaseInput.d.ts +17 -0
  6. package/dist/cjs/components/form/BaseInput.d.ts.map +1 -0
  7. package/dist/cjs/components/form/BaseInput.js +88 -0
  8. package/dist/cjs/components/form/BaseInput.js.map +1 -0
  9. package/dist/cjs/components/form/BaseTagsInput.d.ts +8 -0
  10. package/dist/cjs/components/form/BaseTagsInput.d.ts.map +1 -0
  11. package/dist/cjs/components/form/{TagsInput.js → BaseTagsInput.js} +24 -16
  12. package/dist/cjs/components/form/BaseTagsInput.js.map +1 -0
  13. package/dist/cjs/components/form/ClearButton.d.ts +14 -0
  14. package/dist/cjs/components/form/ClearButton.d.ts.map +1 -0
  15. package/dist/cjs/components/form/ClearButton.js +28 -0
  16. package/dist/cjs/components/form/ClearButton.js.map +1 -0
  17. package/dist/cjs/components/form/Field.styles.d.ts +45 -7
  18. package/dist/cjs/components/form/Field.styles.d.ts.map +1 -1
  19. package/dist/cjs/components/form/Field.styles.js +44 -36
  20. package/dist/cjs/components/form/Field.styles.js.map +1 -1
  21. package/dist/cjs/components/form/Input.d.ts +3 -2
  22. package/dist/cjs/components/form/Input.d.ts.map +1 -1
  23. package/dist/cjs/components/form/Input.js +37 -24
  24. package/dist/cjs/components/form/Input.js.map +1 -1
  25. package/dist/cjs/components/form/Phone.js +1 -1
  26. package/dist/cjs/components/form/Phone.js.map +1 -1
  27. package/dist/cjs/components/form/index.d.ts +3 -2
  28. package/dist/cjs/components/form/index.d.ts.map +1 -1
  29. package/dist/cjs/components/form/index.js +17 -3
  30. package/dist/cjs/components/form/index.js.map +1 -1
  31. package/dist/cjs/components/form/styles/{TagsInput.styles.d.ts → BaseTagsInput.styles.d.ts} +6 -2
  32. package/dist/cjs/components/form/styles/BaseTagsInput.styles.d.ts.map +1 -0
  33. package/dist/cjs/components/form/styles/BaseTagsInput.styles.js +76 -0
  34. package/dist/cjs/components/form/styles/BaseTagsInput.styles.js.map +1 -0
  35. package/dist/cjs/components/modal/components/Redeem/RedeemNonModal.js +7 -3
  36. package/dist/cjs/components/modal/components/Redeem/RedeemNonModal.js.map +1 -1
  37. package/dist/cjs/components/styles/GlobalStyle.d.ts +1 -14
  38. package/dist/cjs/components/styles/GlobalStyle.d.ts.map +1 -1
  39. package/dist/cjs/components/styles/GlobalStyle.js +14 -41
  40. package/dist/cjs/components/styles/GlobalStyle.js.map +1 -1
  41. package/dist/cjs/components/ui/ThemedButton.d.ts.map +1 -1
  42. package/dist/cjs/components/ui/ThemedButton.js +3 -97
  43. package/dist/cjs/components/ui/ThemedButton.js.map +1 -1
  44. package/dist/cjs/components/ui/styles.d.ts.map +1 -1
  45. package/dist/cjs/components/ui/styles.js +5 -2
  46. package/dist/cjs/components/ui/styles.js.map +1 -1
  47. package/dist/cjs/components/widgets/finance/convertion-rate/ConvertionRateContext.d.ts.map +1 -1
  48. package/dist/cjs/components/widgets/finance/convertion-rate/ConvertionRateContext.js +5 -1
  49. package/dist/cjs/components/widgets/finance/convertion-rate/ConvertionRateContext.js.map +1 -1
  50. package/dist/cjs/components/widgets/finance/convertion-rate/useUniswapPools.d.ts.map +1 -1
  51. package/dist/cjs/components/widgets/finance/convertion-rate/useUniswapPools.js +7 -3
  52. package/dist/cjs/components/widgets/finance/convertion-rate/useUniswapPools.js.map +1 -1
  53. package/dist/cjs/hooks/tokenGated/useCheckTokenGatedOffer.d.ts.map +1 -1
  54. package/dist/cjs/hooks/tokenGated/useCheckTokenGatedOffer.js +3 -2
  55. package/dist/cjs/hooks/tokenGated/useCheckTokenGatedOffer.js.map +1 -1
  56. package/dist/cjs/hooks/useCurrentSellers.js.map +1 -1
  57. package/dist/cjs/index.d.ts +2 -0
  58. package/dist/cjs/index.d.ts.map +1 -1
  59. package/dist/cjs/index.js +2 -0
  60. package/dist/cjs/index.js.map +1 -1
  61. package/dist/cjs/lib/config/config.d.ts +2 -2
  62. package/dist/cjs/lib/config/config.d.ts.map +1 -1
  63. package/dist/cjs/lib/config/config.js +15 -2
  64. package/dist/cjs/lib/config/config.js.map +1 -1
  65. package/dist/cjs/lib/const/networks.d.ts.map +1 -1
  66. package/dist/cjs/lib/const/networks.js +1 -0
  67. package/dist/cjs/lib/const/networks.js.map +1 -1
  68. package/dist/cjs/lib/uniswap/validateTokenList.d.ts.map +1 -1
  69. package/dist/cjs/lib/uniswap/validateTokenList.js +10 -9
  70. package/dist/cjs/lib/uniswap/validateTokenList.js.map +1 -1
  71. package/dist/esm/components/buttons/BaseButton.d.ts +27 -0
  72. package/dist/esm/components/buttons/BaseButton.d.ts.map +1 -0
  73. package/dist/esm/components/buttons/BaseButton.js +107 -0
  74. package/dist/esm/components/buttons/BaseButton.js.map +1 -0
  75. package/dist/esm/components/form/BaseInput.d.ts +17 -0
  76. package/dist/esm/components/form/BaseInput.d.ts.map +1 -0
  77. package/dist/esm/components/form/BaseInput.js +47 -0
  78. package/dist/esm/components/form/BaseInput.js.map +1 -0
  79. package/dist/esm/components/form/BaseTagsInput.d.ts +8 -0
  80. package/dist/esm/components/form/BaseTagsInput.d.ts.map +1 -0
  81. package/dist/esm/components/form/{TagsInput.js → BaseTagsInput.js} +22 -17
  82. package/dist/esm/components/form/BaseTagsInput.js.map +1 -0
  83. package/dist/esm/components/form/ClearButton.d.ts +14 -0
  84. package/dist/esm/components/form/ClearButton.d.ts.map +1 -0
  85. package/dist/esm/components/form/ClearButton.js +22 -0
  86. package/dist/esm/components/form/ClearButton.js.map +1 -0
  87. package/dist/esm/components/form/Field.styles.d.ts +45 -7
  88. package/dist/esm/components/form/Field.styles.d.ts.map +1 -1
  89. package/dist/esm/components/form/Field.styles.js +44 -36
  90. package/dist/esm/components/form/Field.styles.js.map +1 -1
  91. package/dist/esm/components/form/Input.d.ts +3 -2
  92. package/dist/esm/components/form/Input.d.ts.map +1 -1
  93. package/dist/esm/components/form/Input.js +37 -12
  94. package/dist/esm/components/form/Input.js.map +1 -1
  95. package/dist/esm/components/form/Phone.js +1 -1
  96. package/dist/esm/components/form/Phone.js.map +1 -1
  97. package/dist/esm/components/form/index.d.ts +3 -2
  98. package/dist/esm/components/form/index.d.ts.map +1 -1
  99. package/dist/esm/components/form/index.js +2 -1
  100. package/dist/esm/components/form/index.js.map +1 -1
  101. package/dist/esm/components/form/styles/{TagsInput.styles.d.ts → BaseTagsInput.styles.d.ts} +6 -2
  102. package/dist/esm/components/form/styles/BaseTagsInput.styles.d.ts.map +1 -0
  103. package/dist/esm/components/form/styles/{TagsInput.styles.js → BaseTagsInput.styles.js} +14 -4
  104. package/dist/esm/components/form/styles/BaseTagsInput.styles.js.map +1 -0
  105. package/dist/esm/components/modal/components/Redeem/RedeemNonModal.js +5 -2
  106. package/dist/esm/components/modal/components/Redeem/RedeemNonModal.js.map +1 -1
  107. package/dist/esm/components/styles/GlobalStyle.d.ts +1 -14
  108. package/dist/esm/components/styles/GlobalStyle.d.ts.map +1 -1
  109. package/dist/esm/components/styles/GlobalStyle.js +14 -41
  110. package/dist/esm/components/styles/GlobalStyle.js.map +1 -1
  111. package/dist/esm/components/ui/ThemedButton.d.ts.map +1 -1
  112. package/dist/esm/components/ui/ThemedButton.js +4 -98
  113. package/dist/esm/components/ui/ThemedButton.js.map +1 -1
  114. package/dist/esm/components/ui/styles.d.ts.map +1 -1
  115. package/dist/esm/components/ui/styles.js +5 -2
  116. package/dist/esm/components/ui/styles.js.map +1 -1
  117. package/dist/esm/components/widgets/finance/convertion-rate/ConvertionRateContext.d.ts.map +1 -1
  118. package/dist/esm/components/widgets/finance/convertion-rate/ConvertionRateContext.js +3 -1
  119. package/dist/esm/components/widgets/finance/convertion-rate/ConvertionRateContext.js.map +1 -1
  120. package/dist/esm/components/widgets/finance/convertion-rate/useUniswapPools.d.ts.map +1 -1
  121. package/dist/esm/components/widgets/finance/convertion-rate/useUniswapPools.js +3 -1
  122. package/dist/esm/components/widgets/finance/convertion-rate/useUniswapPools.js.map +1 -1
  123. package/dist/esm/hooks/tokenGated/useCheckTokenGatedOffer.d.ts.map +1 -1
  124. package/dist/esm/hooks/tokenGated/useCheckTokenGatedOffer.js +3 -2
  125. package/dist/esm/hooks/tokenGated/useCheckTokenGatedOffer.js.map +1 -1
  126. package/dist/esm/hooks/useCurrentSellers.js.map +1 -1
  127. package/dist/esm/index.d.ts +2 -0
  128. package/dist/esm/index.d.ts.map +1 -1
  129. package/dist/esm/index.js +2 -0
  130. package/dist/esm/index.js.map +1 -1
  131. package/dist/esm/lib/config/config.d.ts +2 -2
  132. package/dist/esm/lib/config/config.d.ts.map +1 -1
  133. package/dist/esm/lib/config/config.js +10 -2
  134. package/dist/esm/lib/config/config.js.map +1 -1
  135. package/dist/esm/lib/const/networks.d.ts.map +1 -1
  136. package/dist/esm/lib/const/networks.js +1 -0
  137. package/dist/esm/lib/const/networks.js.map +1 -1
  138. package/dist/esm/lib/uniswap/validateTokenList.d.ts.map +1 -1
  139. package/dist/esm/lib/uniswap/validateTokenList.js +10 -6
  140. package/dist/esm/lib/uniswap/validateTokenList.js.map +1 -1
  141. package/package.json +2 -2
  142. package/src/components/buttons/BaseButton.tsx +181 -0
  143. package/src/components/form/BaseInput.tsx +88 -0
  144. package/src/components/form/{TagsInput.tsx → BaseTagsInput.tsx} +46 -24
  145. package/src/components/form/ClearButton.tsx +39 -0
  146. package/src/components/form/Field.styles.ts +83 -40
  147. package/src/components/form/Input.tsx +42 -21
  148. package/src/components/form/Phone.tsx +1 -1
  149. package/src/components/form/index.ts +3 -2
  150. package/src/components/form/styles/{TagsInput.styles.ts → BaseTagsInput.styles.ts} +18 -4
  151. package/src/components/modal/components/Redeem/RedeemNonModal.tsx +6 -2
  152. package/src/components/styles/GlobalStyle.tsx +15 -71
  153. package/src/components/ui/ThemedButton.tsx +8 -145
  154. package/src/components/ui/styles.ts +5 -2
  155. package/src/components/widgets/finance/convertion-rate/ConvertionRateContext.tsx +3 -1
  156. package/src/components/widgets/finance/convertion-rate/useUniswapPools.ts +4 -1
  157. package/src/hooks/tokenGated/useCheckTokenGatedOffer.ts +5 -5
  158. package/src/hooks/useCurrentSellers.ts +8 -8
  159. package/src/index.tsx +2 -0
  160. package/src/lib/config/config.ts +10 -2
  161. package/src/lib/const/networks.ts +2 -1
  162. package/src/lib/uniswap/validateTokenList.ts +10 -6
  163. package/src/stories/buttons/button.stories.tsx +84 -62
  164. package/src/stories/form/Input.stories.tsx +67 -0
  165. package/src/stories/ui/ThemedButton.stories.tsx +79 -52
  166. package/dist/cjs/components/form/TagsInput.d.ts +0 -4
  167. package/dist/cjs/components/form/TagsInput.d.ts.map +0 -1
  168. package/dist/cjs/components/form/TagsInput.js.map +0 -1
  169. package/dist/cjs/components/form/styles/TagsInput.styles.d.ts.map +0 -1
  170. package/dist/cjs/components/form/styles/TagsInput.styles.js +0 -46
  171. package/dist/cjs/components/form/styles/TagsInput.styles.js.map +0 -1
  172. package/dist/cjs/global.d.ts +0 -5
  173. package/dist/cjs/global.d.ts.map +0 -1
  174. package/dist/cjs/global.js +0 -44
  175. package/dist/cjs/global.js.map +0 -1
  176. package/dist/esm/components/form/TagsInput.d.ts +0 -4
  177. package/dist/esm/components/form/TagsInput.d.ts.map +0 -1
  178. package/dist/esm/components/form/TagsInput.js.map +0 -1
  179. package/dist/esm/components/form/styles/TagsInput.styles.d.ts.map +0 -1
  180. package/dist/esm/components/form/styles/TagsInput.styles.js.map +0 -1
  181. package/dist/esm/global.d.ts +0 -5
  182. package/dist/esm/global.d.ts.map +0 -1
  183. package/dist/esm/global.js +0 -41
  184. package/dist/esm/global.js.map +0 -1
  185. package/src/global.ts +0 -42
@@ -1,104 +1,11 @@
1
- import React, { ButtonHTMLAttributes, forwardRef, Fragment } from "react";
2
- import styled, { css, ThemeProvider } from "styled-components";
1
+ import React, { ButtonHTMLAttributes, forwardRef } from "react";
3
2
 
4
- import { zIndex } from "./zIndex";
5
- import { Tooltip } from "../tooltip/Tooltip";
6
- import * as Styles from "./styles";
7
- import { Typography } from "./Typography";
8
3
  import { theme } from "../../theme";
9
- import { Loading } from "../Loading";
4
+ import { BaseButton } from "../buttons/BaseButton";
10
5
  import { ButtonSize } from "./buttonSize";
11
6
 
12
7
  const colors = theme.colors.light;
13
8
 
14
- const BaseButton = styled.button<{
15
- size: IButton["size"];
16
- fill: IButton["fill"];
17
- }>`
18
- ${() => Styles.button};
19
- ${(props) => Styles[props.size as keyof typeof Styles]}
20
- border-style: solid;
21
- border-color: ${(props) => props.theme.borderColor || "transparent"};
22
- border-width: ${(props) => props.theme.borderWidth || 0}px;
23
- color: ${(props) => props.theme.color || "#000000"};
24
- background-color: ${(props) => props.theme.background || "transparent"};
25
- svg {
26
- stroke: ${(props) => props.theme.color || "#000000"};
27
- }
28
- ${(props) =>
29
- props.fill
30
- ? css`
31
- width: 100%;
32
- `
33
- : ""};
34
- ${(props) =>
35
- props.theme.hover &&
36
- css`
37
- &:hover:not(:disabled) {
38
- background-color: ${props.theme.hover.background};
39
- ${props.theme.hover.color &&
40
- css`
41
- color: ${props.theme.hover.color} !important;
42
- svg {
43
- fill: ${props.theme.hover.color} !important;
44
- line {
45
- stroke: ${props.theme.hover.color} !important;
46
- }
47
- polyline {
48
- stroke: ${props.theme.hover.color} !important;
49
- }
50
- path {
51
- stroke: ${props.theme.hover.color} !important;
52
- }
53
- }
54
- `};
55
- ${props.theme.hover.borderColor &&
56
- css`
57
- border-color: ${props.theme.hover.borderColor};
58
- `};
59
- }
60
- `}
61
- ${(props) =>
62
- props.theme.padding
63
- ? css`
64
- padding: ${props.theme.padding} !important;
65
- `
66
- : ""}
67
-
68
- ${(props) =>
69
- props.theme.disabled
70
- ? css`
71
- &:disabled {
72
- background-color: ${props.theme.disabled.background ||
73
- "transparent"};
74
- color: ${props.theme.disabled.color || colors.darkGrey};
75
- border-color: transparent;
76
- cursor: not-allowed;
77
- opacity: 0.5;
78
- }
79
- `
80
- : css`
81
- &:disabled {
82
- background-color: ${colors.lightGrey};
83
- color: ${colors.darkGrey};
84
- border-color: transparent;
85
- cursor: not-allowed;
86
- opacity: 0.5;
87
- }
88
- `};
89
- `;
90
-
91
- const ChildWrapperButton = styled.div`
92
- display: flex;
93
- align-items: center;
94
- justify-content: center;
95
- gap: 12px;
96
- position: relative;
97
- z-index: ${zIndex.Button};
98
-
99
- ${() => Styles.buttonText};
100
- `;
101
-
102
9
  const allThemes = ({ withBosonStyle }: { withBosonStyle?: boolean }) => {
103
10
  return {
104
11
  primary: {
@@ -325,57 +232,13 @@ export type IButton = ButtonHTMLAttributes<HTMLButtonElement> & {
325
232
  };
326
233
 
327
234
  const ThemedButton = forwardRef<HTMLButtonElement, IButton>(
328
- (
329
- {
330
- children,
331
- onClick,
332
- size = "regular",
333
- themeVal = "primary",
334
- type = "button",
335
- step = 0,
336
- fill = false,
337
- isLoading = false,
338
- tooltip = "",
339
- withBosonStyle = false,
340
- ...rest
341
- },
342
- ref
343
- ) => {
344
- const Wrapper = tooltip !== "" && rest?.disabled ? Tooltip : Fragment;
345
- const wrapperParams =
346
- tooltip !== "" && rest?.disabled ? { wrap: false, content: tooltip } : {};
235
+ ({ themeVal = "primary", withBosonStyle = false, ...rest }, ref) => {
347
236
  return (
348
- <>
349
- {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
350
- {/* @ts-ignore */}
351
- <ThemeProvider theme={allThemes({ withBosonStyle })[themeVal]}>
352
- {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
353
- {/* @ts-ignore */}
354
- <Wrapper {...wrapperParams}>
355
- <BaseButton
356
- onClick={onClick}
357
- type={type}
358
- size={size}
359
- fill={fill ? fill : undefined}
360
- {...rest}
361
- ref={ref}
362
- >
363
- {isLoading ? (
364
- <Loading />
365
- ) : (
366
- <ChildWrapperButton data-child-wrapper-button>
367
- {children}
368
- {step !== 0 && (
369
- <Typography>
370
- <small>Step {step}</small>
371
- </Typography>
372
- )}
373
- </ChildWrapperButton>
374
- )}
375
- </BaseButton>
376
- </Wrapper>
377
- </ThemeProvider>
378
- </>
237
+ <BaseButton
238
+ {...rest}
239
+ ref={ref}
240
+ theme={allThemes({ withBosonStyle })[themeVal]}
241
+ />
379
242
  );
380
243
  }
381
244
  );
@@ -33,8 +33,11 @@ export const clamp = css`
33
33
  -webkit-box-orient: vertical;
34
34
  `;
35
35
  export const boxShadow = css`
36
- box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.05), 0px 0px 8px rgba(0, 0, 0, 0.05),
37
- 0px 0px 16px rgba(0, 0, 0, 0.05), 0px 0px 32px rgba(0, 0, 0, 0.05);
36
+ box-shadow:
37
+ 0px 0px 4px rgba(0, 0, 0, 0.05),
38
+ 0px 0px 8px rgba(0, 0, 0, 0.05),
39
+ 0px 0px 16px rgba(0, 0, 0, 0.05),
40
+ 0px 0px 32px rgba(0, 0, 0, 0.05);
38
41
  `;
39
42
 
40
43
  export const text = css`
@@ -36,7 +36,9 @@ export const initalState: ConvertionRateContextType = {
36
36
  type: null,
37
37
  tokens: null,
38
38
  rates:
39
- process.env.NODE_ENV === "development"
39
+ process.env.NODE_ENV === "development" ||
40
+ // @ts-expect-error import.meta.env only exists in vite environments
41
+ import.meta?.env?.DEV
40
42
  ? MOCK_RATES
41
43
  : getItemFromStorage("convertionRates", null),
42
44
  fixed: 20,
@@ -100,7 +100,10 @@ export interface IPool {
100
100
 
101
101
  export function useUniswapPools({ tokens }: Props) {
102
102
  const tokensWithoutBoson = tokens?.filter((t) => t.symbol !== "BOSON") || [];
103
- const isDev = process.env.NODE_ENV === "development";
103
+ const isDev =
104
+ process.env.NODE_ENV === "development" ||
105
+ // @ts-expect-error import.meta.env only exists in vite environments
106
+ import.meta?.env?.DEV;
104
107
  const queries = generateQuery(tokensWithoutBoson, false);
105
108
  const swapQueries = generateQuery(tokensWithoutBoson, true);
106
109
 
@@ -3,8 +3,9 @@ import { utils } from "ethers";
3
3
  import { useEffect, useState } from "react";
4
4
  import { Offer } from "../../types/offer";
5
5
  import { useCoreSDKWithContext } from "../core-sdk/useCoreSdkWithContext";
6
- import { BosonSnapshotGate__factory } from "./BosonSnapshotGate/typechain";
6
+ // import { BosonSnapshotGate__factory } from "./BosonSnapshotGate/typechain";
7
7
  import { useAccount, useSigner } from "../connection/connection";
8
+ const importedTypechain = import("./BosonSnapshotGate/typechain");
8
9
 
9
10
  interface Props {
10
11
  commitProxyAddress?: string | undefined;
@@ -32,10 +33,9 @@ export default function useCheckTokenGatedOffer({
32
33
  }
33
34
 
34
35
  try {
35
- const proxyContract = BosonSnapshotGate__factory.connect(
36
- commitProxyAddress,
37
- signer
38
- );
36
+ const proxyContract = (
37
+ await importedTypechain
38
+ ).BosonSnapshotGate__factory.connect(commitProxyAddress, signer);
39
39
  const [owned, used] = await proxyContract.checkSnapshot(
40
40
  condition.minTokenId,
41
41
  utils.getAddress(address)
@@ -259,15 +259,15 @@ export function useCurrentSellers(
259
259
  const sellerType: string[] | string[][] = resultById?.data
260
260
  ? resultById.data.map((d) => Object.keys(d))
261
261
  : resultByLensId?.data
262
- ? Object.keys(resultByLensId.data)
263
- : resultByAddress?.data?.sellerType || [];
262
+ ? Object.keys(resultByLensId.data)
263
+ : resultByAddress?.data?.sellerType || [];
264
264
 
265
265
  const sellerIdsToQuery: string[] =
266
266
  sellerAddressType === "SELLER_IDS"
267
267
  ? (sellerAddress as string[])
268
268
  : sellerAddressType === "LENS_TOKEN_ID" && resultByLensId?.data?.sellerId
269
- ? [resultByLensId?.data.sellerId]
270
- : [];
269
+ ? [resultByLensId?.data.sellerId]
270
+ : [];
271
271
  const enableSellerById = !!sellerIdsToQuery?.length;
272
272
  const { data: sellers2, refetch: refetchFetchSellers } = fetchSellers(
273
273
  sellerIdsToQuery,
@@ -360,10 +360,10 @@ export function useCurrentSellers(
360
360
  resultByAddress.data
361
361
  ? resultByAddress.data.sellers.map((seller) => seller.id)
362
362
  : sellerAddressType === "SELLER_IDS"
363
- ? Array.isArray(sellerAddress)
364
- ? sellerAddress
365
- : [sellerAddress]
366
- : []
363
+ ? Array.isArray(sellerAddress)
364
+ ? sellerAddress
365
+ : [sellerAddress]
366
+ : []
367
367
  ).filter((sellerId) => !!sellerId) as string[];
368
368
  }, [resultByAddress.data, sellerAddress, sellerAddressType]);
369
369
  return {
package/src/index.tsx CHANGED
@@ -6,6 +6,7 @@ export { default as ThemedButton, IButton } from "./components/ui/ThemedButton";
6
6
  export * from "./components/ui/zIndex";
7
7
  export * from "./components/ui/buttonSize";
8
8
  export * from "./components/buttons/Button";
9
+ export * from "./components/buttons/BaseButton";
9
10
  export * from "./components/buttons/CommitButtonView";
10
11
  export * from "./components/cta/exchange/BatchCompleteButton";
11
12
  export * from "./components/cta/exchange/CancelButton";
@@ -58,6 +59,7 @@ export * from "./components/ui/Grid";
58
59
  export * from "./components/ui/GridContainer";
59
60
  export * from "./components/ui/Typography";
60
61
  export * from "./components/ui/MuteButton";
62
+ export * from "./components/form";
61
63
  export * from "./lib/magicLink/logout";
62
64
  export * from "./lib/magicLink/provider";
63
65
  export * from "./lib/const/networks";
@@ -2,7 +2,11 @@ import { getRpcUrls } from "../const/networks";
2
2
 
3
3
  const magicLinkKey =
4
4
  process.env.STORYBOOK_REACT_APP_MAGIC_API_KEY ||
5
- process.env.REACT_APP_MAGIC_API_KEY;
5
+ process.env.REACT_APP_MAGIC_API_KEY ||
6
+ // @ts-expect-error import.meta.env only exists in vite environments
7
+ import.meta?.env.STORYBOOK_REACT_APP_MAGIC_API_KEY ||
8
+ // @ts-expect-error import.meta.env only exists in vite environments
9
+ import.meta?.env.REACT_APP_MAGIC_API_KEY;
6
10
  if (!magicLinkKey) {
7
11
  throw new Error(
8
12
  "STORYBOOK_REACT_APP_MAGIC_API_KEY/REACT_APP_MAGIC_API_KEY is not defined"
@@ -10,7 +14,11 @@ if (!magicLinkKey) {
10
14
  }
11
15
  const infuraKey =
12
16
  process.env.STORYBOOK_REACT_APP_INFURA_KEY ||
13
- process.env.REACT_APP_INFURA_KEY;
17
+ process.env.REACT_APP_INFURA_KEY ||
18
+ // @ts-expect-error import.meta.env only exists in vite environments
19
+ import.meta?.env.STORYBOOK_REACT_APP_INFURA_KEY ||
20
+ // @ts-expect-error import.meta.env only exists in vite environments
21
+ import.meta?.env.REACT_APP_INFURA_KEY;
14
22
  if (!infuraKey) {
15
23
  throw new Error(
16
24
  "STORYBOOK_REACT_APP_INFURA_KEY/REACT_APP_INFURA_KEY is not defined"
@@ -179,7 +179,8 @@ export const getRpcUrls = (infuraKey: string) => ({
179
179
  `https://polygon-mumbai.infura.io/v3/${infuraKey}`,
180
180
  ...FALLBACK_URLS[ChainId.POLYGON_MUMBAI]
181
181
  ],
182
- 80002: [ // AMOY
182
+ 80002: [
183
+ // AMOY
183
184
  `https://polygon-amoy.infura.io/v3/${infuraKey}`,
184
185
  ...FALLBACK_URLS[80002]
185
186
  ],
@@ -1,7 +1,9 @@
1
1
  import type { TokenList } from "@uniswap/token-lists";
2
2
  import type { ValidateFunction } from "ajv";
3
- import validatorImportList from "./__generated__/validateTokenList";
4
- import validateTokens from "./__generated__/validateTokens";
3
+ // import validateTokens from "./__generated__/validateTokens";
4
+ const importValidateTokens = import("./__generated__/validateTokens");
5
+ // import validatorImportList from "./__generated__/validateTokenList";
6
+ const importValidatorImportList = import("./__generated__/validateTokenList");
5
7
 
6
8
  enum ValidationSchema {
7
9
  LIST = "list",
@@ -30,13 +32,15 @@ async function validate(
30
32
  // validatorImport = await import(
31
33
  // "lib/uniswap/__generated__/validateTokenList"
32
34
  // );
33
- validatorImport = validatorImportList;
35
+ // validatorImport = validatorImportList;
36
+ validatorImport = await importValidatorImportList;
34
37
  break;
35
38
  case ValidationSchema.TOKENS:
36
39
  // validatorImport = await import(
37
40
  // "lib/uniswap/__generated__/validateTokens"
38
41
  // );
39
- validatorImport = validateTokens;
42
+ // validatorImport = validateTokens;
43
+ validatorImport = await importValidateTokens;
40
44
  break;
41
45
  default:
42
46
  throw new Error("No validation function specified for token list schema");
@@ -45,8 +49,8 @@ async function validate(
45
49
  import("ajv")
46
50
  // validatorImport
47
51
  ]);
48
- // const validator = validatorModule.default as ValidateFunction;
49
- const validator = validatorImport as ValidateFunction;
52
+ const validator = validatorImport.default as ValidateFunction;
53
+ // const validator = validatorImport as ValidateFunction;
50
54
  if (validator?.(data)) {
51
55
  return data;
52
56
  }
@@ -1,88 +1,110 @@
1
- import React from "react";
2
- import { ComponentStory, ComponentMeta } from "@storybook/react";
3
-
1
+ import { fn } from "@storybook/test";
4
2
  import { Button } from "../../components/buttons/Button";
3
+ import React from "react";
4
+ import { Meta } from "@storybook/react";
5
5
 
6
6
  // More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
7
7
  export default {
8
8
  title: "Visual Components/Buttons/Button",
9
- component: Button
10
- } as ComponentMeta<typeof Button>;
9
+ component: Button,
10
+ parameters: {
11
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
12
+ layout: "centered"
13
+ },
14
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
15
+ tags: ["autodocs"],
16
+ args: { onClick: fn() },
17
+ argTypes: {
18
+ disabled: { control: "boolean" },
19
+ size: {
20
+ control: "select",
21
+ options: ["small", "regular", "large"]
22
+ },
23
+ children: { control: "text" },
24
+ tooltip: { control: "text" }
25
+ },
26
+ decorators: [
27
+ (Story) => {
28
+ return <Story />;
29
+ }
30
+ ]
31
+ } satisfies Meta<typeof Button>;
11
32
 
12
33
  const BASE_ARGS = {
13
34
  children: "Button Text",
14
- // eslint-disable-next-line @typescript-eslint/no-empty-function
15
- onClick: () => {},
16
- size: "regular"
35
+ size: "regular",
36
+ tooltip: "tooltip shown when disabled only"
17
37
  } as const;
18
- // More on component templates: https://storybook.js.org/docs/react/writing-stories/introduction#using-args
19
- const Template: ComponentStory<typeof Button> = (args) => (
20
- <Button {...BASE_ARGS} {...args} />
21
- );
22
-
23
- export const PrimaryFill: ComponentStory<typeof Button> = Template.bind({});
24
-
25
- export const PrimaryInverted: ComponentStory<typeof Button> = Template.bind({});
26
-
27
- export const SecondaryFill: ComponentStory<typeof Button> = Template.bind({});
28
-
29
- export const SecondaryInverted: ComponentStory<typeof Button> = Template.bind(
30
- {}
31
- );
32
-
33
- export const AccentFill: ComponentStory<typeof Button> = Template.bind({});
34
-
35
- export const AccentInverted: ComponentStory<typeof Button> = Template.bind({});
36
-
37
- export const Disabled: ComponentStory<typeof Button> = Template.bind({});
38
-
39
- export const Loading: ComponentStory<typeof Button> = Template.bind({});
40
38
 
41
39
  // More on args: https://storybook.js.org/docs/react/writing-stories/args
42
- PrimaryFill.args = {
43
- disabled: false,
44
- loading: false,
45
- variant: "primaryFill"
40
+ export const PrimaryFill = {
41
+ args: {
42
+ ...BASE_ARGS,
43
+ disabled: false,
44
+ loading: false,
45
+ variant: "primaryFill"
46
+ }
46
47
  };
47
48
 
48
- PrimaryInverted.args = {
49
- disabled: false,
50
- loading: false,
51
- variant: "primaryInverted"
49
+ export const PrimaryInverted = {
50
+ args: {
51
+ ...BASE_ARGS,
52
+ disabled: false,
53
+ loading: false,
54
+ variant: "primaryInverted"
55
+ }
52
56
  };
53
57
 
54
- SecondaryFill.args = {
55
- disabled: false,
56
- loading: false,
57
- variant: "secondaryFill"
58
+ export const SecondaryFill = {
59
+ args: {
60
+ ...BASE_ARGS,
61
+ disabled: false,
62
+ loading: false,
63
+ variant: "secondaryFill"
64
+ }
58
65
  };
59
66
 
60
- SecondaryInverted.args = {
61
- disabled: false,
62
- loading: false,
63
- variant: "secondaryInverted"
67
+ export const SecondaryInverted = {
68
+ args: {
69
+ ...BASE_ARGS,
70
+ disabled: false,
71
+ loading: false,
72
+ variant: "secondaryInverted"
73
+ }
64
74
  };
65
75
 
66
- AccentFill.args = {
67
- disabled: false,
68
- loading: false,
69
- variant: "accentFill"
76
+ export const AccentFill = {
77
+ args: {
78
+ ...BASE_ARGS,
79
+ disabled: false,
80
+ loading: false,
81
+ variant: "accentFill"
82
+ }
70
83
  };
71
84
 
72
- AccentInverted.args = {
73
- disabled: false,
74
- loading: false,
75
- variant: "accentInverted"
85
+ export const AccentInverted = {
86
+ args: {
87
+ ...BASE_ARGS,
88
+ disabled: false,
89
+ loading: false,
90
+ variant: "accentInverted"
91
+ }
76
92
  };
77
93
 
78
- Disabled.args = {
79
- disabled: true,
80
- loading: false,
81
- variant: "primaryFill"
94
+ export const Disabled = {
95
+ args: {
96
+ ...BASE_ARGS,
97
+ disabled: true,
98
+ loading: false,
99
+ variant: "primaryFill"
100
+ }
82
101
  };
83
102
 
84
- Loading.args = {
85
- disabled: false,
86
- loading: true,
87
- variant: "primaryFill"
103
+ export const Loading = {
104
+ args: {
105
+ ...BASE_ARGS,
106
+ disabled: false,
107
+ loading: true,
108
+ variant: "primaryFill"
109
+ }
88
110
  };
@@ -0,0 +1,67 @@
1
+ import React from "react";
2
+ import { Input } from "../../components/form";
3
+ import { Formik } from "formik";
4
+ import type { Meta } from "@storybook/react";
5
+ import { fn } from "@storybook/test";
6
+ const inputWithErrors = "With error";
7
+ const defaultHeightSize = "regular";
8
+ const inputName = "test";
9
+ // More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
10
+ export default {
11
+ title: "Visual Components/Inputs/Input",
12
+ component: Input,
13
+ parameters: {
14
+ // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
15
+ layout: "centered"
16
+ },
17
+ // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
18
+ tags: ["autodocs"],
19
+ // More on argTypes: https://storybook.js.org/docs/api/argtypes
20
+ argTypes: {
21
+ disabled: { control: "boolean" },
22
+ heightSize: {
23
+ control: "select",
24
+ options: ["small", "regular", "large"]
25
+ },
26
+ isClearable: { control: "boolean" }
27
+ },
28
+ // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
29
+ args: { onClick: fn() },
30
+ decorators: [
31
+ (Story, { name }) => {
32
+ return (
33
+ <Formik<{ [inputName]: unknown }>
34
+ onSubmit={() => {
35
+ //
36
+ }}
37
+ initialErrors={
38
+ name === inputWithErrors
39
+ ? { [inputName]: "Input error before typing!" }
40
+ : {}
41
+ }
42
+ initialValues={{ [inputName]: "" }}
43
+ initialTouched={{ [inputName]: true }}
44
+ >
45
+ <Story />
46
+ </Formik>
47
+ );
48
+ }
49
+ ] satisfies Meta<typeof Input>["decorators"]
50
+ } satisfies Meta<typeof Input>;
51
+
52
+ export const Simple = {
53
+ args: {
54
+ name: inputName,
55
+ placeholder: "this is a placeholder",
56
+ heightSize: defaultHeightSize
57
+ }
58
+ };
59
+
60
+ export const InputWithError = {
61
+ name: "With error",
62
+ args: {
63
+ name: inputName,
64
+ placeholder: "this is a placeholder",
65
+ heightSize: defaultHeightSize
66
+ }
67
+ };