@bosonprotocol/react-kit 0.33.0-alpha.1 → 0.33.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/buttons/BaseButton.d.ts +1 -0
- package/dist/cjs/components/buttons/BaseButton.d.ts.map +1 -1
- package/dist/cjs/components/buttons/BaseButton.js +1 -0
- package/dist/cjs/components/buttons/BaseButton.js.map +1 -1
- package/dist/cjs/components/form/Select.d.ts +2 -1
- package/dist/cjs/components/form/Select.d.ts.map +1 -1
- package/dist/cjs/components/form/Select.js +18 -15
- package/dist/cjs/components/form/Select.js.map +1 -1
- package/dist/cjs/components/form/index.d.ts +1 -1
- package/dist/cjs/components/form/index.d.ts.map +1 -1
- package/dist/cjs/components/form/index.js.map +1 -1
- package/dist/cjs/components/form/types.d.ts +33 -0
- package/dist/cjs/components/form/types.d.ts.map +1 -1
- package/dist/cjs/components/image/Image.js +2 -2
- package/dist/cjs/components/image/Image.js.map +1 -1
- package/dist/cjs/components/image/Image.styles.d.ts +2 -1
- package/dist/cjs/components/image/Image.styles.d.ts.map +1 -1
- package/dist/cjs/components/image/Image.styles.js +2 -2
- package/dist/cjs/components/image/Image.styles.js.map +1 -1
- package/dist/cjs/components/modal/components/Commit/DetailView/InnerCommitDetailView.js +3 -3
- package/dist/cjs/components/modal/components/Commit/DetailView/InnerCommitDetailView.js.map +1 -1
- package/dist/cjs/components/modal/components/Redeem/ExchangeView/RedeemSuccess.js +3 -3
- package/dist/cjs/components/modal/components/Redeem/ExchangeView/RedeemSuccess.js.map +1 -1
- package/dist/cjs/components/modal/components/common/OfferFullDescription/DigitalProductData.js +2 -2
- package/dist/cjs/components/modal/components/common/OfferFullDescription/DigitalProductData.js.map +1 -1
- package/dist/cjs/components/modal/components/common/detail/DetailSlider.js +2 -2
- package/dist/cjs/components/modal/components/common/detail/DetailSlider.js.map +1 -1
- package/dist/cjs/components/modal/components/common/detail/PhygitalProduct.js +2 -2
- package/dist/cjs/components/modal/components/common/detail/PhygitalProduct.js.map +1 -1
- package/dist/cjs/components/modal/components/common/detail/SlickSlider.js +2 -2
- package/dist/cjs/components/modal/components/common/detail/SlickSlider.js.map +1 -1
- package/dist/cjs/components/ui/CardCTA.d.ts +21 -0
- package/dist/cjs/components/ui/CardCTA.d.ts.map +1 -0
- package/dist/cjs/components/ui/CardCTA.js +77 -0
- package/dist/cjs/components/ui/CardCTA.js.map +1 -0
- package/dist/cjs/components/ui/Grid.d.ts.map +1 -1
- package/dist/cjs/components/ui/Grid.js +22 -21
- package/dist/cjs/components/ui/Grid.js.map +1 -1
- package/dist/cjs/components/ui/IpfsImage.d.ts +2 -2
- package/dist/cjs/components/ui/IpfsImage.d.ts.map +1 -1
- package/dist/cjs/components/ui/IpfsImage.js +2 -1
- package/dist/cjs/components/ui/IpfsImage.js.map +1 -1
- package/dist/cjs/components/ui/Typography.d.ts.map +1 -1
- package/dist/cjs/components/ui/Typography.js +29 -28
- package/dist/cjs/components/ui/Typography.js.map +1 -1
- package/dist/cjs/components/ui/Video.d.ts.map +1 -1
- package/dist/cjs/components/ui/Video.js +22 -12
- package/dist/cjs/components/ui/Video.js.map +1 -1
- package/dist/cjs/components/ui/common.d.ts +2 -0
- package/dist/cjs/components/ui/common.d.ts.map +1 -0
- package/dist/cjs/components/ui/common.js +6 -0
- package/dist/cjs/components/ui/common.js.map +1 -0
- package/dist/cjs/components/wallet/ConnectButton.js +2 -2
- package/dist/cjs/components/wallet/ConnectButton.js.map +1 -1
- package/dist/cjs/components/widgets/finance/convertion-rate/ConvertionRateContext.js +2 -2
- package/dist/cjs/components/widgets/finance/convertion-rate/ConvertionRateContext.js.map +1 -1
- package/dist/cjs/components/widgets/finance/convertion-rate/ConvertionRateProvider.js +2 -2
- package/dist/cjs/components/widgets/finance/convertion-rate/ConvertionRateProvider.js.map +1 -1
- package/dist/cjs/components/widgets/finance/useOffersBacked.js +1 -1
- package/dist/cjs/components/widgets/finance/useOffersBacked.js.map +1 -1
- package/dist/cjs/hooks/connection/connection.d.ts +2 -2
- package/dist/cjs/hooks/connection/connection.d.ts.map +1 -1
- package/dist/cjs/hooks/connection/connection.js +15 -6
- package/dist/cjs/hooks/connection/connection.js.map +1 -1
- package/dist/cjs/hooks/core-sdk/useCoreSdk.d.ts.map +1 -1
- package/dist/cjs/hooks/core-sdk/useCoreSdk.js +2 -2
- package/dist/cjs/hooks/core-sdk/useCoreSdk.js.map +1 -1
- package/dist/cjs/hooks/form/useForm.d.ts +55 -0
- package/dist/cjs/hooks/form/useForm.d.ts.map +1 -0
- package/dist/cjs/hooks/form/useForm.js +11 -0
- package/dist/cjs/hooks/form/useForm.js.map +1 -0
- package/dist/cjs/hooks/index.d.ts +6 -0
- package/dist/cjs/hooks/index.d.ts.map +1 -1
- package/dist/cjs/hooks/index.js +8 -1
- package/dist/cjs/hooks/index.js.map +1 -1
- package/dist/cjs/hooks/ipfs/useIpfsStorage.d.ts +2 -0
- package/dist/cjs/hooks/ipfs/useIpfsStorage.d.ts.map +1 -0
- package/dist/cjs/hooks/ipfs/useIpfsStorage.js +14 -0
- package/dist/cjs/hooks/ipfs/useIpfsStorage.js.map +1 -0
- package/dist/cjs/hooks/location/buildUseSearchParams.d.ts +12 -0
- package/dist/cjs/hooks/location/buildUseSearchParams.d.ts.map +1 -0
- package/dist/cjs/hooks/location/buildUseSearchParams.js +36 -0
- package/dist/cjs/hooks/location/buildUseSearchParams.js.map +1 -0
- package/dist/cjs/{components/widgets/finance/storage/useLocalStorage.d.ts → hooks/storage/useBosonLocalStorage.d.ts} +3 -3
- package/dist/cjs/hooks/storage/useBosonLocalStorage.d.ts.map +1 -0
- package/dist/cjs/hooks/storage/useBosonLocalStorage.js +22 -0
- package/dist/cjs/hooks/storage/useBosonLocalStorage.js.map +1 -0
- package/dist/cjs/hooks/storage/useLocalStorage.d.ts +6 -0
- package/dist/cjs/hooks/storage/useLocalStorage.d.ts.map +1 -0
- package/dist/cjs/hooks/storage/useLocalStorage.js.map +1 -0
- package/dist/cjs/hooks/useIpfsMetadataStorage.d.ts.map +1 -1
- package/dist/cjs/hooks/useIpfsMetadataStorage.js +1 -1
- package/dist/cjs/hooks/useIpfsMetadataStorage.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/cjs/lib/url/url.d.ts +1 -0
- package/dist/cjs/lib/url/url.d.ts.map +1 -1
- package/dist/cjs/lib/url/url.js +2 -1
- package/dist/cjs/lib/url/url.js.map +1 -1
- package/dist/cjs/types/helpers.d.ts +3 -0
- package/dist/cjs/types/helpers.d.ts.map +1 -1
- package/dist/cjs/types/helpers.js.map +1 -1
- package/dist/esm/components/buttons/BaseButton.d.ts +1 -0
- package/dist/esm/components/buttons/BaseButton.d.ts.map +1 -1
- package/dist/esm/components/buttons/BaseButton.js +1 -0
- package/dist/esm/components/buttons/BaseButton.js.map +1 -1
- package/dist/esm/components/form/Select.d.ts +2 -1
- package/dist/esm/components/form/Select.d.ts.map +1 -1
- package/dist/esm/components/form/Select.js +19 -15
- package/dist/esm/components/form/Select.js.map +1 -1
- package/dist/esm/components/form/index.d.ts +1 -1
- package/dist/esm/components/form/index.d.ts.map +1 -1
- package/dist/esm/components/form/index.js.map +1 -1
- package/dist/esm/components/form/types.d.ts +33 -0
- package/dist/esm/components/form/types.d.ts.map +1 -1
- package/dist/esm/components/image/Image.js +2 -2
- package/dist/esm/components/image/Image.js.map +1 -1
- package/dist/esm/components/image/Image.styles.d.ts +2 -1
- package/dist/esm/components/image/Image.styles.d.ts.map +1 -1
- package/dist/esm/components/image/Image.styles.js +2 -2
- package/dist/esm/components/image/Image.styles.js.map +1 -1
- package/dist/esm/components/modal/components/Commit/DetailView/InnerCommitDetailView.js +1 -1
- package/dist/esm/components/modal/components/Commit/DetailView/InnerCommitDetailView.js.map +1 -1
- package/dist/esm/components/modal/components/Redeem/ExchangeView/RedeemSuccess.js +1 -1
- package/dist/esm/components/modal/components/Redeem/ExchangeView/RedeemSuccess.js.map +1 -1
- package/dist/esm/components/modal/components/common/OfferFullDescription/DigitalProductData.js +1 -1
- package/dist/esm/components/modal/components/common/OfferFullDescription/DigitalProductData.js.map +1 -1
- package/dist/esm/components/modal/components/common/detail/DetailSlider.js +1 -1
- package/dist/esm/components/modal/components/common/detail/DetailSlider.js.map +1 -1
- package/dist/esm/components/modal/components/common/detail/PhygitalProduct.js +1 -1
- package/dist/esm/components/modal/components/common/detail/PhygitalProduct.js.map +1 -1
- package/dist/esm/components/modal/components/common/detail/SlickSlider.js +1 -1
- package/dist/esm/components/modal/components/common/detail/SlickSlider.js.map +1 -1
- package/dist/esm/components/ui/CardCTA.d.ts +21 -0
- package/dist/esm/components/ui/CardCTA.d.ts.map +1 -0
- package/dist/esm/components/ui/CardCTA.js +35 -0
- package/dist/esm/components/ui/CardCTA.js.map +1 -0
- package/dist/esm/components/ui/Grid.d.ts.map +1 -1
- package/dist/esm/components/ui/Grid.js +22 -21
- package/dist/esm/components/ui/Grid.js.map +1 -1
- package/dist/esm/components/ui/IpfsImage.d.ts +2 -2
- package/dist/esm/components/ui/IpfsImage.d.ts.map +1 -1
- package/dist/esm/components/ui/IpfsImage.js +1 -2
- package/dist/esm/components/ui/IpfsImage.js.map +1 -1
- package/dist/esm/components/ui/Typography.d.ts.map +1 -1
- package/dist/esm/components/ui/Typography.js +29 -28
- package/dist/esm/components/ui/Typography.js.map +1 -1
- package/dist/esm/components/ui/Video.d.ts.map +1 -1
- package/dist/esm/components/ui/Video.js +22 -12
- package/dist/esm/components/ui/Video.js.map +1 -1
- package/dist/esm/components/ui/common.d.ts +2 -0
- package/dist/esm/components/ui/common.d.ts.map +1 -0
- package/dist/esm/components/ui/common.js +2 -0
- package/dist/esm/components/ui/common.js.map +1 -0
- package/dist/esm/components/wallet/ConnectButton.js +1 -1
- package/dist/esm/components/wallet/ConnectButton.js.map +1 -1
- package/dist/esm/components/widgets/finance/convertion-rate/ConvertionRateContext.js +1 -1
- package/dist/esm/components/widgets/finance/convertion-rate/ConvertionRateContext.js.map +1 -1
- package/dist/esm/components/widgets/finance/convertion-rate/ConvertionRateProvider.js +1 -1
- package/dist/esm/components/widgets/finance/convertion-rate/ConvertionRateProvider.js.map +1 -1
- package/dist/esm/components/widgets/finance/useOffersBacked.js +1 -1
- package/dist/esm/components/widgets/finance/useOffersBacked.js.map +1 -1
- package/dist/esm/hooks/connection/connection.d.ts +2 -2
- package/dist/esm/hooks/connection/connection.d.ts.map +1 -1
- package/dist/esm/hooks/connection/connection.js +14 -6
- package/dist/esm/hooks/connection/connection.js.map +1 -1
- package/dist/esm/hooks/core-sdk/useCoreSdk.d.ts.map +1 -1
- package/dist/esm/hooks/core-sdk/useCoreSdk.js +3 -3
- package/dist/esm/hooks/core-sdk/useCoreSdk.js.map +1 -1
- package/dist/esm/hooks/form/useForm.d.ts +55 -0
- package/dist/esm/hooks/form/useForm.d.ts.map +1 -0
- package/dist/esm/hooks/form/useForm.js +10 -0
- package/dist/esm/hooks/form/useForm.js.map +1 -0
- package/dist/esm/hooks/index.d.ts +6 -0
- package/dist/esm/hooks/index.d.ts.map +1 -1
- package/dist/esm/hooks/index.js +6 -0
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/ipfs/useIpfsStorage.d.ts +2 -0
- package/dist/esm/hooks/ipfs/useIpfsStorage.d.ts.map +1 -0
- package/dist/esm/hooks/ipfs/useIpfsStorage.js +10 -0
- package/dist/esm/hooks/ipfs/useIpfsStorage.js.map +1 -0
- package/dist/esm/hooks/location/buildUseSearchParams.d.ts +12 -0
- package/dist/esm/hooks/location/buildUseSearchParams.d.ts.map +1 -0
- package/dist/esm/hooks/location/buildUseSearchParams.js +32 -0
- package/dist/esm/hooks/location/buildUseSearchParams.js.map +1 -0
- package/dist/esm/{components/widgets/finance/storage/useLocalStorage.d.ts → hooks/storage/useBosonLocalStorage.d.ts} +3 -3
- package/dist/esm/hooks/storage/useBosonLocalStorage.d.ts.map +1 -0
- package/dist/esm/hooks/storage/useBosonLocalStorage.js +15 -0
- package/dist/esm/hooks/storage/useBosonLocalStorage.js.map +1 -0
- package/dist/esm/hooks/storage/useLocalStorage.d.ts +6 -0
- package/dist/esm/hooks/storage/useLocalStorage.d.ts.map +1 -0
- package/dist/esm/hooks/storage/useLocalStorage.js.map +1 -0
- package/dist/esm/hooks/useIpfsMetadataStorage.d.ts.map +1 -1
- package/dist/esm/hooks/useIpfsMetadataStorage.js +2 -2
- package/dist/esm/hooks/useIpfsMetadataStorage.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/dist/esm/lib/url/url.d.ts +1 -0
- package/dist/esm/lib/url/url.d.ts.map +1 -1
- package/dist/esm/lib/url/url.js +1 -0
- package/dist/esm/lib/url/url.js.map +1 -1
- package/dist/esm/types/helpers.d.ts +3 -0
- package/dist/esm/types/helpers.d.ts.map +1 -1
- package/dist/esm/types/helpers.js.map +1 -1
- package/package.json +5 -5
- package/src/components/buttons/BaseButton.tsx +4 -0
- package/src/components/form/Select.tsx +20 -14
- package/src/components/form/index.ts +1 -1
- package/src/components/form/types.ts +33 -0
- package/src/components/image/Image.styles.ts +7 -5
- package/src/components/image/Image.tsx +2 -2
- package/src/components/modal/components/Commit/DetailView/InnerCommitDetailView.tsx +1 -1
- package/src/components/modal/components/Redeem/ExchangeView/RedeemSuccess.tsx +1 -1
- package/src/components/modal/components/common/OfferFullDescription/DigitalProductData.tsx +1 -1
- package/src/components/modal/components/common/detail/DetailSlider.tsx +1 -1
- package/src/components/modal/components/common/detail/PhygitalProduct.tsx +1 -1
- package/src/components/modal/components/common/detail/SlickSlider.tsx +1 -1
- package/src/components/ui/CardCTA.tsx +77 -0
- package/src/components/ui/Grid.tsx +33 -21
- package/src/components/ui/IpfsImage.tsx +3 -3
- package/src/components/ui/Typography.tsx +39 -29
- package/src/components/ui/Video.tsx +28 -14
- package/src/components/ui/common.ts +2 -0
- package/src/components/wallet/ConnectButton.tsx +1 -1
- package/src/components/widgets/finance/convertion-rate/ConvertionRateContext.tsx +1 -1
- package/src/components/widgets/finance/convertion-rate/ConvertionRateProvider.tsx +1 -1
- package/src/components/widgets/finance/useOffersBacked.ts +1 -1
- package/src/hooks/connection/connection.ts +18 -8
- package/src/hooks/core-sdk/useCoreSdk.tsx +4 -3
- package/src/hooks/form/useForm.ts +12 -0
- package/src/hooks/index.ts +6 -0
- package/src/hooks/ipfs/useIpfsStorage.ts +16 -0
- package/src/hooks/location/buildUseSearchParams.tsx +45 -0
- package/src/hooks/storage/useBosonLocalStorage.ts +40 -0
- package/src/{components/widgets/finance → hooks}/storage/useLocalStorage.ts +5 -17
- package/src/hooks/useIpfsMetadataStorage.tsx +6 -2
- package/src/index.tsx +4 -0
- package/src/lib/url/url.ts +3 -0
- package/src/stories/selects/Select.stories.tsx +117 -0
- package/src/types/helpers.ts +4 -0
- package/dist/cjs/components/widgets/finance/storage/useLocalStorage.d.ts.map +0 -1
- package/dist/cjs/components/widgets/finance/storage/useLocalStorage.js.map +0 -1
- package/dist/esm/components/widgets/finance/storage/useLocalStorage.d.ts.map +0 -1
- package/dist/esm/components/widgets/finance/storage/useLocalStorage.js.map +0 -1
- /package/dist/cjs/{components/widgets/finance → hooks}/storage/useLocalStorage.js +0 -0
- /package/dist/esm/{components/widgets/finance → hooks}/storage/useLocalStorage.js +0 -0
|
@@ -9,7 +9,7 @@ import React, {
|
|
|
9
9
|
useRef,
|
|
10
10
|
useState
|
|
11
11
|
} from "react";
|
|
12
|
-
import styled, { css } from "styled-components";
|
|
12
|
+
import styled, { CSSProperties, css } from "styled-components";
|
|
13
13
|
import { useIpfsStorage } from "../../hooks/useIpfsStorage";
|
|
14
14
|
import { fetchIpfsBase64Media } from "../../lib/base64/base64";
|
|
15
15
|
import { theme } from "../../theme";
|
|
@@ -24,6 +24,7 @@ const StyledMuteButton = styled(MuteButton)`
|
|
|
24
24
|
position: absolute;
|
|
25
25
|
top: 1rem;
|
|
26
26
|
right: 1rem;
|
|
27
|
+
z-index: 1;
|
|
27
28
|
`;
|
|
28
29
|
const VideoWrapper = styled.div<{ $hasOnClick?: boolean }>`
|
|
29
30
|
overflow: hidden;
|
|
@@ -68,8 +69,15 @@ const VideoHtml = styled.video`
|
|
|
68
69
|
object-fit: contain;
|
|
69
70
|
`;
|
|
70
71
|
|
|
71
|
-
const VideoPlaceholder = styled.div
|
|
72
|
-
position
|
|
72
|
+
const VideoPlaceholder = styled.div<{ $position?: CSSProperties["position"] }>`
|
|
73
|
+
${({ $position }) =>
|
|
74
|
+
$position
|
|
75
|
+
? css`
|
|
76
|
+
position: ${$position};
|
|
77
|
+
`
|
|
78
|
+
: css`
|
|
79
|
+
position: absolute;
|
|
80
|
+
`}
|
|
73
81
|
top: 0;
|
|
74
82
|
height: 100%;
|
|
75
83
|
width: 100%;
|
|
@@ -125,6 +133,8 @@ const Video: React.FC<IVideo & React.HTMLAttributes<HTMLDivElement>> = ({
|
|
|
125
133
|
ipfsMetadataStorage
|
|
126
134
|
);
|
|
127
135
|
setVideoSrc(base64str as string);
|
|
136
|
+
setIsLoaded(true);
|
|
137
|
+
setIsError(false);
|
|
128
138
|
} catch (error) {
|
|
129
139
|
console.error("error in Video", error);
|
|
130
140
|
setIsLoaded(true);
|
|
@@ -136,8 +146,13 @@ const Video: React.FC<IVideo & React.HTMLAttributes<HTMLDivElement>> = ({
|
|
|
136
146
|
}
|
|
137
147
|
}
|
|
138
148
|
if (!isLoaded && videoSrc === null) {
|
|
139
|
-
if (
|
|
140
|
-
|
|
149
|
+
if (
|
|
150
|
+
src?.startsWith("ipfs://") ||
|
|
151
|
+
src?.startsWith("https://bosonprotocol.infura-ipfs.io/ipfs/")
|
|
152
|
+
) {
|
|
153
|
+
const newString = src?.startsWith("ipfs://")
|
|
154
|
+
? src.split("//")
|
|
155
|
+
: src.split("https://bosonprotocol.infura-ipfs.io/ipfs/");
|
|
141
156
|
const CID = newString[newString.length - 1];
|
|
142
157
|
fetchData(`ipfs://${CID}`);
|
|
143
158
|
} else if (src?.startsWith("undefined") && src?.length > 9) {
|
|
@@ -149,12 +164,6 @@ const Video: React.FC<IVideo & React.HTMLAttributes<HTMLDivElement>> = ({
|
|
|
149
164
|
}
|
|
150
165
|
}, []); // eslint-disable-line
|
|
151
166
|
|
|
152
|
-
useEffect(() => {
|
|
153
|
-
if (videoSrc !== null) {
|
|
154
|
-
setTimeout(() => setIsLoaded(true), 100);
|
|
155
|
-
}
|
|
156
|
-
}, [videoSrc]);
|
|
157
|
-
|
|
158
167
|
const mp4Src = useMemo(() => {
|
|
159
168
|
const octetSrc =
|
|
160
169
|
videoSrc?.startsWith("data:application/octet-stream;base64,") || false;
|
|
@@ -183,13 +192,14 @@ const Video: React.FC<IVideo & React.HTMLAttributes<HTMLDivElement>> = ({
|
|
|
183
192
|
videoRef.current.play();
|
|
184
193
|
}
|
|
185
194
|
}, [muted]);
|
|
195
|
+
|
|
186
196
|
if (!isLoaded && !isError) {
|
|
187
197
|
if (ComponentWhileLoading) {
|
|
188
198
|
return <ComponentWhileLoading />;
|
|
189
199
|
}
|
|
190
200
|
return (
|
|
191
201
|
<VideoWrapper {...rest}>
|
|
192
|
-
<VideoPlaceholder>
|
|
202
|
+
<VideoPlaceholder $position="static">
|
|
193
203
|
<Typography tag="div">
|
|
194
204
|
<Loading />
|
|
195
205
|
</Typography>
|
|
@@ -200,8 +210,8 @@ const Video: React.FC<IVideo & React.HTMLAttributes<HTMLDivElement>> = ({
|
|
|
200
210
|
|
|
201
211
|
if (isLoaded && isError) {
|
|
202
212
|
return (
|
|
203
|
-
<VideoWrapper {...rest}>
|
|
204
|
-
<VideoPlaceholder data-video-placeholder>
|
|
213
|
+
<VideoWrapper {...rest} className="video-container">
|
|
214
|
+
<VideoPlaceholder data-video-placeholder $position="static">
|
|
205
215
|
{showPlaceholderText ? (
|
|
206
216
|
<VideoIcon size={50} color={colors.white} />
|
|
207
217
|
) : (
|
|
@@ -235,6 +245,10 @@ const Video: React.FC<IVideo & React.HTMLAttributes<HTMLDivElement>> = ({
|
|
|
235
245
|
data-testid={dataTestId}
|
|
236
246
|
{...videoProps}
|
|
237
247
|
src={mp4Src || ""}
|
|
248
|
+
onError={() => {
|
|
249
|
+
setIsLoaded(true);
|
|
250
|
+
setIsError(true);
|
|
251
|
+
}}
|
|
238
252
|
/>
|
|
239
253
|
</>
|
|
240
254
|
)}
|
|
@@ -8,7 +8,7 @@ import FallbackAvatar from "../avatar/fallback-avatar";
|
|
|
8
8
|
import { Button } from "../buttons/Button";
|
|
9
9
|
import ThemedButton, { bosonButtonThemes } from "../ui/ThemedButton";
|
|
10
10
|
import { useBreakpoints } from "../../hooks/useBreakpoints";
|
|
11
|
-
import { saveItemInStorage } from "
|
|
11
|
+
import { saveItemInStorage } from "../../hooks/storage/useBosonLocalStorage";
|
|
12
12
|
import { SignOut, Wallet } from "phosphor-react";
|
|
13
13
|
import { useIsMagicLoggedIn } from "../../hooks";
|
|
14
14
|
import { useAccount, useChainId } from "../../hooks/connection/connection";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint @typescript-eslint/no-empty-function: "off" */
|
|
2
2
|
/* eslint @typescript-eslint/no-explicit-any: "off" */
|
|
3
3
|
import { createContext } from "react";
|
|
4
|
-
import { getItemFromStorage } from "
|
|
4
|
+
import { getItemFromStorage } from "../../../../hooks/storage/useBosonLocalStorage";
|
|
5
5
|
|
|
6
6
|
export type Token = {
|
|
7
7
|
symbol: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { useTokens } from "../exchange-tokens/useTokens";
|
|
4
|
-
import { saveItemInStorage } from "
|
|
4
|
+
import { saveItemInStorage } from "../../../../hooks/storage/useBosonLocalStorage";
|
|
5
5
|
import ConvertionRateContext, {
|
|
6
6
|
ConvertionRateContextType,
|
|
7
7
|
initalState,
|
|
@@ -5,7 +5,7 @@ import groupBy from "lodash/groupBy";
|
|
|
5
5
|
import { useCallback, useMemo } from "react";
|
|
6
6
|
|
|
7
7
|
import { Props } from "./Finance";
|
|
8
|
-
import { saveItemInStorage } from "
|
|
8
|
+
import { saveItemInStorage } from "../../../hooks/storage/useLocalStorage";
|
|
9
9
|
import { SellerExchangeProps } from "./useSellerDeposit";
|
|
10
10
|
import { subgraph } from "@bosonprotocol/core-sdk";
|
|
11
11
|
import { Offer } from "../../../types/offer";
|
|
@@ -16,7 +16,7 @@ import { useSignerAddress } from "../useSignerAddress";
|
|
|
16
16
|
import { useEthersProvider } from "../ethers/useEthersProvider";
|
|
17
17
|
import { useQuery } from "react-query";
|
|
18
18
|
import { useExternalSignerChainId } from "../../lib/signer/externalSigner";
|
|
19
|
-
import { Signer } from "ethers";
|
|
19
|
+
import { Signer, providers } from "ethers";
|
|
20
20
|
import { useWeb3ReactWrapper } from "../web3React/useWeb3ReactWrapper";
|
|
21
21
|
|
|
22
22
|
export function useAccount() {
|
|
@@ -105,8 +105,11 @@ export function useIsConnectedToWrongChain(): boolean {
|
|
|
105
105
|
return connectedToWrongChain;
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
export function useProvider()
|
|
109
|
-
|
|
108
|
+
export function useProvider():
|
|
109
|
+
| providers.JsonRpcProvider
|
|
110
|
+
| providers.FallbackProvider {
|
|
111
|
+
const { withExternalConnectionProps, withWeb3React } = useConfigContext();
|
|
112
|
+
const { provider: web3Provider } = useWeb3ReactWrapper() || {};
|
|
110
113
|
let provider;
|
|
111
114
|
let error: unknown;
|
|
112
115
|
try {
|
|
@@ -116,12 +119,14 @@ export function useProvider() {
|
|
|
116
119
|
}
|
|
117
120
|
const magicProvider = useMagicProvider();
|
|
118
121
|
const isMagicLoggedIn = useIsMagicLoggedIn();
|
|
119
|
-
if (!withExternalConnectionProps && error) {
|
|
122
|
+
if (!withExternalConnectionProps && error && !withWeb3React) {
|
|
120
123
|
throw error;
|
|
121
124
|
}
|
|
122
125
|
return isMagicLoggedIn
|
|
123
|
-
? magicProvider ?? provider
|
|
124
|
-
:
|
|
126
|
+
? magicProvider ?? web3Provider ?? provider
|
|
127
|
+
: withWeb3React
|
|
128
|
+
? web3Provider ?? magicProvider ?? provider
|
|
129
|
+
: provider ?? magicProvider ?? web3Provider;
|
|
125
130
|
}
|
|
126
131
|
|
|
127
132
|
export function useSigner(): Signer | undefined {
|
|
@@ -140,6 +145,7 @@ export function useSigner(): Signer | undefined {
|
|
|
140
145
|
const { externalSigner } = useExternalSigner() ?? {};
|
|
141
146
|
const magicProvider = useMagicProvider();
|
|
142
147
|
const isMagicLoggedIn = useIsMagicLoggedIn();
|
|
148
|
+
const { provider: web3Provider } = useWeb3ReactWrapper() || {};
|
|
143
149
|
|
|
144
150
|
const signer = useMemo(() => {
|
|
145
151
|
return externalConnectedSigner
|
|
@@ -148,13 +154,17 @@ export function useSigner(): Signer | undefined {
|
|
|
148
154
|
? externalSigner
|
|
149
155
|
: isMagicLoggedIn
|
|
150
156
|
? magicProvider?.getSigner()
|
|
151
|
-
:
|
|
157
|
+
: withWeb3React
|
|
158
|
+
? web3Provider?.getSigner()
|
|
159
|
+
: wagmiSigner;
|
|
152
160
|
}, [
|
|
153
161
|
externalConnectedSigner,
|
|
154
162
|
externalSigner,
|
|
155
163
|
wagmiSigner,
|
|
156
164
|
magicProvider,
|
|
157
|
-
isMagicLoggedIn
|
|
165
|
+
isMagicLoggedIn,
|
|
166
|
+
web3Provider,
|
|
167
|
+
withWeb3React
|
|
158
168
|
]);
|
|
159
169
|
if (!withExternalConnectionProps && error && !withWeb3React) {
|
|
160
170
|
throw error;
|
|
@@ -4,7 +4,8 @@ import {
|
|
|
4
4
|
getEnvConfigById,
|
|
5
5
|
ConfigId,
|
|
6
6
|
EnvironmentType,
|
|
7
|
-
MetaTxConfig
|
|
7
|
+
MetaTxConfig,
|
|
8
|
+
validateMetadata
|
|
8
9
|
} from "@bosonprotocol/core-sdk";
|
|
9
10
|
import { EthersAdapter, Provider } from "@bosonprotocol/ethers-sdk";
|
|
10
11
|
import { IpfsMetadataStorage } from "@bosonprotocol/ipfs-storage";
|
|
@@ -108,7 +109,7 @@ function initCoreSdk(config: CoreSdkConfig, overrides?: CoreSdkOverrides) {
|
|
|
108
109
|
protocolDiamond:
|
|
109
110
|
config.protocolDiamond || defaultConfig.contracts.protocolDiamond,
|
|
110
111
|
subgraphUrl: config.subgraphUrl || defaultConfig.subgraphUrl,
|
|
111
|
-
theGraphStorage: new IpfsMetadataStorage({
|
|
112
|
+
theGraphStorage: new IpfsMetadataStorage(validateMetadata, {
|
|
112
113
|
url: theGraphStorageUrl,
|
|
113
114
|
headers:
|
|
114
115
|
config.theGraphIpfsStorageHeaders ||
|
|
@@ -116,7 +117,7 @@ function initCoreSdk(config: CoreSdkConfig, overrides?: CoreSdkOverrides) {
|
|
|
116
117
|
? config.ipfsMetadataStorageHeaders
|
|
117
118
|
: undefined
|
|
118
119
|
}),
|
|
119
|
-
metadataStorage: new IpfsMetadataStorage({
|
|
120
|
+
metadataStorage: new IpfsMetadataStorage(validateMetadata, {
|
|
120
121
|
url: metadataStorageUrl,
|
|
121
122
|
headers: config.ipfsMetadataStorageHeaders
|
|
122
123
|
}),
|
package/src/hooks/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { useCoreSdk } from "./core-sdk/useCoreSdk";
|
|
2
2
|
export { useIpfsMetadataStorage } from "./useIpfsMetadataStorage";
|
|
3
|
+
export { useIpfsContext } from "../components/ipfs/IpfsContext";
|
|
3
4
|
export * from "./magic";
|
|
4
5
|
export * from "../lib/signer/externalSigner";
|
|
5
6
|
export * from "../lib/signer/useCallSignerFromIframe";
|
|
@@ -19,3 +20,8 @@ export * from "./contracts/erc1155/useErc1155Uris";
|
|
|
19
20
|
export * from "./uniswap/useIsWindowVisible";
|
|
20
21
|
export * from "./connection/connection";
|
|
21
22
|
export { useConfigContext } from "../components/config/ConfigContext";
|
|
23
|
+
export * from "./storage/useLocalStorage";
|
|
24
|
+
export * from "./ipfs/useIpfsStorage";
|
|
25
|
+
export * from "./location/buildUseSearchParams";
|
|
26
|
+
export * from "./form/useForm";
|
|
27
|
+
export * from "./useBreakpoints";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { useConfigContext } from "../../components/config/ConfigContext";
|
|
2
|
+
import { useIpfsContext } from "../../components/ipfs/IpfsContext";
|
|
3
|
+
import { useIpfsMetadataStorage } from "../useIpfsMetadataStorage";
|
|
4
|
+
|
|
5
|
+
export function useIpfsStorage() {
|
|
6
|
+
const { config } = useConfigContext();
|
|
7
|
+
const { ipfsMetadataStorageHeaders, ipfsMetadataStorageUrl } =
|
|
8
|
+
useIpfsContext();
|
|
9
|
+
const storage = useIpfsMetadataStorage(
|
|
10
|
+
config.envName,
|
|
11
|
+
config.configId,
|
|
12
|
+
ipfsMetadataStorageUrl,
|
|
13
|
+
ipfsMetadataStorageHeaders
|
|
14
|
+
);
|
|
15
|
+
return storage;
|
|
16
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import qs from "query-string";
|
|
2
|
+
import { useCallback, useEffect, useState } from "react";
|
|
3
|
+
import { useLocation } from "react-router-dom";
|
|
4
|
+
|
|
5
|
+
export type BuildUseSearchParamsProps = {
|
|
6
|
+
useNavigate: () => (arg0: { pathname: string; search: string }) => unknown;
|
|
7
|
+
};
|
|
8
|
+
export function buildUseSearchParams({
|
|
9
|
+
useNavigate
|
|
10
|
+
}: BuildUseSearchParamsProps) {
|
|
11
|
+
return () => {
|
|
12
|
+
const navigate = useNavigate();
|
|
13
|
+
const location = useLocation();
|
|
14
|
+
const [params, setParams] = useState(qs.parse(location.search));
|
|
15
|
+
|
|
16
|
+
const handleChange = useCallback(
|
|
17
|
+
(name: string, value: string) => {
|
|
18
|
+
const oldParams = qs.parse(location.search);
|
|
19
|
+
|
|
20
|
+
const newParams = {
|
|
21
|
+
...oldParams,
|
|
22
|
+
[name]: value
|
|
23
|
+
};
|
|
24
|
+
setParams(newParams);
|
|
25
|
+
},
|
|
26
|
+
[location.search]
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
navigate({
|
|
31
|
+
pathname: location.pathname,
|
|
32
|
+
search: qs.stringify(params)
|
|
33
|
+
});
|
|
34
|
+
}, [params]); // eslint-disable-line
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
setParams(qs.parse(location.search));
|
|
38
|
+
}, [location.search]); // eslint-disable-line
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
params,
|
|
42
|
+
handleChange
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getItemFromStorage as baseGetItemFromStorage,
|
|
3
|
+
saveItemInStorage as baseSaveItemInStorage,
|
|
4
|
+
removeItemInStorage as baseRemoveItemInStorage,
|
|
5
|
+
clearLocalStorage as baseClearLocalStorage,
|
|
6
|
+
useLocalStorage as useBaseLocalStorage
|
|
7
|
+
} from "./useLocalStorage";
|
|
8
|
+
|
|
9
|
+
export type GetItemFromStorageKey =
|
|
10
|
+
| "wagmi.store"
|
|
11
|
+
| "isChainUnsupported"
|
|
12
|
+
| "tracing-url"
|
|
13
|
+
| "isConnectWalletFromCommit"
|
|
14
|
+
| "convertionRates"
|
|
15
|
+
| "google-jwt"
|
|
16
|
+
| "showCookies";
|
|
17
|
+
|
|
18
|
+
export function getItemFromStorage<T>(
|
|
19
|
+
key: GetItemFromStorageKey,
|
|
20
|
+
initialValue: T
|
|
21
|
+
) {
|
|
22
|
+
return baseGetItemFromStorage(key, initialValue);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function saveItemInStorage<T>(key: GetItemFromStorageKey, value: T) {
|
|
26
|
+
return baseSaveItemInStorage(key, value);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function removeItemInStorage(key: GetItemFromStorageKey) {
|
|
30
|
+
return baseRemoveItemInStorage(key);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export const clearLocalStorage = baseClearLocalStorage;
|
|
34
|
+
|
|
35
|
+
export function useLocalStorage<T>(
|
|
36
|
+
key: GetItemFromStorageKey,
|
|
37
|
+
initialValue: T
|
|
38
|
+
) {
|
|
39
|
+
return useBaseLocalStorage(key, initialValue);
|
|
40
|
+
}
|
|
@@ -1,17 +1,8 @@
|
|
|
1
1
|
// extracted from https://usehooks.com/useLocalStorage/
|
|
2
2
|
import { useCallback, useState } from "react";
|
|
3
3
|
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
| "isChainUnsupported"
|
|
7
|
-
| "tracing-url"
|
|
8
|
-
| "isConnectWalletFromCommit"
|
|
9
|
-
| "convertionRates"
|
|
10
|
-
| "google-jwt"
|
|
11
|
-
| "showCookies";
|
|
12
|
-
|
|
13
|
-
export function getItemFromStorage<T>(
|
|
14
|
-
key: GetItemFromStorageKey,
|
|
4
|
+
export function getItemFromStorage<K extends string, T>(
|
|
5
|
+
key: K,
|
|
15
6
|
initialValue: T
|
|
16
7
|
) {
|
|
17
8
|
if (typeof window === "undefined") {
|
|
@@ -26,7 +17,7 @@ export function getItemFromStorage<T>(
|
|
|
26
17
|
}
|
|
27
18
|
}
|
|
28
19
|
|
|
29
|
-
export function saveItemInStorage<T>(key:
|
|
20
|
+
export function saveItemInStorage<K extends string, T>(key: K, value: T) {
|
|
30
21
|
if (typeof window !== "undefined") {
|
|
31
22
|
try {
|
|
32
23
|
window.localStorage.setItem(key, JSON.stringify(value));
|
|
@@ -36,7 +27,7 @@ export function saveItemInStorage<T>(key: string, value: T) {
|
|
|
36
27
|
}
|
|
37
28
|
}
|
|
38
29
|
|
|
39
|
-
export function removeItemInStorage(key:
|
|
30
|
+
export function removeItemInStorage<K extends string>(key: K) {
|
|
40
31
|
if (typeof window !== "undefined") {
|
|
41
32
|
try {
|
|
42
33
|
Object.keys(localStorage)
|
|
@@ -58,10 +49,7 @@ export const clearLocalStorage = () => {
|
|
|
58
49
|
}
|
|
59
50
|
};
|
|
60
51
|
|
|
61
|
-
export function useLocalStorage<T>(
|
|
62
|
-
key: GetItemFromStorageKey,
|
|
63
|
-
initialValue: T
|
|
64
|
-
) {
|
|
52
|
+
export function useLocalStorage<K extends string, T>(key: K, initialValue: T) {
|
|
65
53
|
const [storedValue, setStoredValue] = useState<T>(() =>
|
|
66
54
|
getItemFromStorage(key, initialValue)
|
|
67
55
|
);
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { useEffect, useState } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
getEnvConfigById,
|
|
4
|
+
ConfigId,
|
|
5
|
+
validateMetadata
|
|
6
|
+
} from "@bosonprotocol/core-sdk";
|
|
3
7
|
import { IpfsMetadataStorage } from "@bosonprotocol/ipfs-storage";
|
|
4
8
|
import { EnvironmentType } from "@bosonprotocol/common/src/types";
|
|
5
9
|
|
|
@@ -37,7 +41,7 @@ function initIpfsMetadataStorage(
|
|
|
37
41
|
url?: string,
|
|
38
42
|
headers?: Headers | Record<string, string>
|
|
39
43
|
) {
|
|
40
|
-
return new IpfsMetadataStorage({
|
|
44
|
+
return new IpfsMetadataStorage(validateMetadata, {
|
|
41
45
|
url: url || getEnvConfigById(envName, configId).ipfsMetadataUrl,
|
|
42
46
|
headers
|
|
43
47
|
});
|
package/src/index.tsx
CHANGED
|
@@ -32,6 +32,7 @@ export * from "./components/cta/funds/WithdrawAllFundsButton";
|
|
|
32
32
|
export * from "./components/currencyDisplay/CurrencyDisplay";
|
|
33
33
|
export * from "./components/exchangeCard/ExchangeCard";
|
|
34
34
|
export * from "./components/image/Image";
|
|
35
|
+
export * from "./components/ui/IpfsImage";
|
|
35
36
|
export * from "./components/ui/loading/Loading";
|
|
36
37
|
export * from "./components/productCard/ProductCard";
|
|
37
38
|
export * from "./components/productCard/const";
|
|
@@ -67,6 +68,7 @@ export * from "./components/ui/Grid";
|
|
|
67
68
|
export * from "./components/ui/GridContainer";
|
|
68
69
|
export * from "./components/ui/Typography";
|
|
69
70
|
export * from "./components/ui/MuteButton";
|
|
71
|
+
export * from "./components/ui/CardCTA";
|
|
70
72
|
export * from "./components/form";
|
|
71
73
|
export * from "./lib/magicLink/logout";
|
|
72
74
|
export * from "./lib/magicLink/provider";
|
|
@@ -86,3 +88,5 @@ export * from "./components/error/SimpleError";
|
|
|
86
88
|
export * from "./components/step/MultiSteps";
|
|
87
89
|
export * from "./components/ipfs/IpfsProvider";
|
|
88
90
|
export * from "./types/helpers";
|
|
91
|
+
export * from "./lib/url/url";
|
|
92
|
+
export * from "./lib/promises/promises";
|
package/src/lib/url/url.ts
CHANGED
|
@@ -5,6 +5,9 @@ const SAFE_URL_PATTERN =
|
|
|
5
5
|
const DATA_URL_PATTERN =
|
|
6
6
|
/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+\\/]+=*$/i;
|
|
7
7
|
|
|
8
|
+
export const websitePattern =
|
|
9
|
+
"^(http://|https://)?(www.)?([a-zA-Z0-9]+).[a-zA-Z0-9]*.[a-z]{1}.([-a-z-A-Z-0-9:_+.?/@#%&=]+)?$";
|
|
10
|
+
|
|
8
11
|
function _sanitizeUrl(url: string): string {
|
|
9
12
|
url = String(url);
|
|
10
13
|
if (url === "null" || url.length === 0 || url === "about:blank")
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { fn } from "@storybook/test";
|
|
2
|
+
import { Select, SelectProps, theme } from "../../index";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Meta } from "@storybook/react";
|
|
5
|
+
import { Formik } from "formik";
|
|
6
|
+
|
|
7
|
+
const inputWithErrors = "With error";
|
|
8
|
+
const inputName = "test";
|
|
9
|
+
|
|
10
|
+
const colors = theme.colors.light;
|
|
11
|
+
// More on default export: https://storybook.js.org/docs/react/writing-stories/introduction#default-export
|
|
12
|
+
export default {
|
|
13
|
+
title: "Visual Components/Selects/Select",
|
|
14
|
+
component: Select,
|
|
15
|
+
parameters: {
|
|
16
|
+
// Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
|
|
17
|
+
layout: "centered"
|
|
18
|
+
},
|
|
19
|
+
// This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
|
|
20
|
+
tags: ["autodocs"],
|
|
21
|
+
args: { onChange: fn() },
|
|
22
|
+
argTypes: {
|
|
23
|
+
name: {
|
|
24
|
+
table: {
|
|
25
|
+
disable: true // remove name input in controls
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
theme: {
|
|
29
|
+
table: {
|
|
30
|
+
disable: true // remove name input in controls
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
disabled: { control: "boolean" },
|
|
34
|
+
placeholder: { control: "text" }
|
|
35
|
+
},
|
|
36
|
+
decorators: [
|
|
37
|
+
(Story, { args, name }) => {
|
|
38
|
+
return (
|
|
39
|
+
<Formik<{ [inputName]: unknown }>
|
|
40
|
+
onSubmit={() => {
|
|
41
|
+
//
|
|
42
|
+
}}
|
|
43
|
+
initialErrors={
|
|
44
|
+
name === inputWithErrors
|
|
45
|
+
? { [inputName]: "There has been an error!" }
|
|
46
|
+
: {}
|
|
47
|
+
}
|
|
48
|
+
initialValues={{ [inputName]: "" }}
|
|
49
|
+
initialTouched={{ [inputName]: true }}
|
|
50
|
+
>
|
|
51
|
+
<Story args={{ ...args, name: inputName }} />
|
|
52
|
+
</Formik>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
]
|
|
56
|
+
} satisfies Meta<typeof Select>;
|
|
57
|
+
|
|
58
|
+
const BASE_ARGS = {
|
|
59
|
+
name: inputName,
|
|
60
|
+
options: [
|
|
61
|
+
{ label: "first option", value: "1" },
|
|
62
|
+
{ label: "second option", value: "2" },
|
|
63
|
+
{ label: "third option", value: "3" }
|
|
64
|
+
]
|
|
65
|
+
} as SelectProps;
|
|
66
|
+
|
|
67
|
+
// More on args: https://storybook.js.org/docs/react/writing-stories/args
|
|
68
|
+
export const Base = {
|
|
69
|
+
args: { ...BASE_ARGS } satisfies SelectProps
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export const CustomTheme = {
|
|
73
|
+
args: {
|
|
74
|
+
...BASE_ARGS,
|
|
75
|
+
theme: {
|
|
76
|
+
control: {
|
|
77
|
+
background: colors.arsenic,
|
|
78
|
+
borderRadius: "16px",
|
|
79
|
+
padding: "3px",
|
|
80
|
+
boxShadow: "1px 2px 3px 4px blue",
|
|
81
|
+
borderWidth: undefined,
|
|
82
|
+
border: "1px solid green",
|
|
83
|
+
focus: {
|
|
84
|
+
border: "1px solid red"
|
|
85
|
+
},
|
|
86
|
+
hover: {
|
|
87
|
+
borderColor: undefined,
|
|
88
|
+
borderWidth: undefined,
|
|
89
|
+
border: "1px solid purple"
|
|
90
|
+
},
|
|
91
|
+
error: {
|
|
92
|
+
border: "1px solid orange"
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
option: {
|
|
96
|
+
opacity: "1",
|
|
97
|
+
background: "pink",
|
|
98
|
+
color: "brown",
|
|
99
|
+
selected: {
|
|
100
|
+
background: "yellow",
|
|
101
|
+
color: "cyan"
|
|
102
|
+
},
|
|
103
|
+
disabled: {
|
|
104
|
+
opacity: "0.8"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
} satisfies SelectProps
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const WithError = {
|
|
112
|
+
name: inputWithErrors,
|
|
113
|
+
args: {
|
|
114
|
+
...BASE_ARGS,
|
|
115
|
+
placeholder: "this is a placeholder"
|
|
116
|
+
} satisfies SelectProps
|
|
117
|
+
};
|
package/src/types/helpers.ts
CHANGED
|
@@ -5,6 +5,10 @@ export type DeepReadonly<T> = {
|
|
|
5
5
|
};
|
|
6
6
|
export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
|
|
7
7
|
|
|
8
|
+
export type Prettify<T> = {
|
|
9
|
+
[K in keyof T]: T[K];
|
|
10
|
+
} & {};
|
|
11
|
+
|
|
8
12
|
type Falsy = false | 0 | "" | null | undefined;
|
|
9
13
|
|
|
10
14
|
export const isTruthy = <T>(x: T | Falsy): x is T => !!x;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalStorage.d.ts","sourceRoot":"","sources":["../../../../../../src/components/widgets/finance/storage/useLocalStorage.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,qBAAqB,GAC7B,aAAa,GACb,oBAAoB,GACpB,aAAa,GACb,2BAA2B,GAC3B,iBAAiB,GACjB,YAAY,GACZ,aAAa,CAAC;AAElB,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,GAAG,EAAE,qBAAqB,EAC1B,YAAY,EAAE,CAAC,OAYhB;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,QAQzD;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,QAU9C;AAED,eAAO,MAAM,iBAAiB,YAQ7B,CAAC;AAEF,wBAAgB,eAAe,CAAC,CAAC,EAC/B,GAAG,EAAE,qBAAqB,EAC1B,YAAY,EAAE,CAAC,mCAOM,CAAC,KAAK,CAAC,wBAiB7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalStorage.js","sourceRoot":"","sources":["../../../../../../src/components/widgets/finance/storage/useLocalStorage.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalStorage.d.ts","sourceRoot":"","sources":["../../../../../../src/components/widgets/finance/storage/useLocalStorage.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,qBAAqB,GAC7B,aAAa,GACb,oBAAoB,GACpB,aAAa,GACb,2BAA2B,GAC3B,iBAAiB,GACjB,YAAY,GACZ,aAAa,CAAC;AAElB,wBAAgB,kBAAkB,CAAC,CAAC,EAClC,GAAG,EAAE,qBAAqB,EAC1B,YAAY,EAAE,CAAC,OAYhB;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,QAQzD;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,QAU9C;AAED,eAAO,MAAM,iBAAiB,YAQ7B,CAAC;AAEF,wBAAgB,eAAe,CAAC,CAAC,EAC/B,GAAG,EAAE,qBAAqB,EAC1B,YAAY,EAAE,CAAC,mCAOM,CAAC,KAAK,CAAC,wBAiB7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useLocalStorage.js","sourceRoot":"","sources":["../../../../../../src/components/widgets/finance/storage/useLocalStorage.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAW9C,MAAM,UAAU,kBAAkB,CAChC,GAA0B,EAC1B,YAAe;IAEf,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,OAAO,YAAY,CAAC;KACrB;IACD,IAAI;QACF,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC9C,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;KAC/C;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,YAAY,CAAC;KACrB;AACH,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAI,GAAW,EAAE,KAAQ;IACxD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,IAAI;YACF,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC;SACzD;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACtB;KACF;AACH,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,IAAI;YACF,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC;iBACtB,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC;iBAC/C,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,YAAY,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC;SACzD;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACtB;KACF;AACH,CAAC;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,EAAE;IACpC,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;QACjC,IAAI;YACF,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;SAC7B;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACtB;KACF;AACH,CAAC,CAAC;AAEF,MAAM,UAAU,eAAe,CAC7B,GAA0B,EAC1B,YAAe;IAEf,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAI,GAAG,EAAE,CACrD,kBAAkB,CAAC,GAAG,EAAE,YAAY,CAAC,CACtC,CAAC;IAEF,MAAM,QAAQ,GAAG,WAAW,CAC1B,CAAC,KAA0B,EAAE,EAAE;QAC7B,IAAI;YACF,MAAM,YAAY,GAChB,KAAK,YAAY,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YACzD,cAAc,CAAC,YAAY,CAAC,CAAC;YAC7B,iBAAiB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;SACtC;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;SACtB;IACH,CAAC,EACD,CAAC,GAAG,EAAE,WAAW,CAAC,CACnB,CAAC;IACF,MAAM,iBAAiB,GAAG,WAAW,CAAC,GAAG,EAAE;QACzC,mBAAmB,CAAC,GAAG,CAAC,CAAC;QACzB,cAAc,CAAC,YAAY,CAAC,CAAC;IAC/B,CAAC,EAAE,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC;IACxB,OAAO,CAAC,WAAW,EAAE,QAAQ,EAAE,iBAAiB,CAAU,CAAC;AAC7D,CAAC"}
|
|
File without changes
|
|
File without changes
|