@bosonprotocol/react-kit 0.29.0-alpha.1 → 0.29.0-alpha.3
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/config/ConfigContext.d.ts +1 -1
- package/dist/cjs/components/config/ConfigContext.d.ts.map +1 -1
- package/dist/cjs/components/config/ConfigContext.js +3 -3
- package/dist/cjs/components/config/ConfigContext.js.map +1 -1
- package/dist/cjs/components/config/ConfigProvider.d.ts.map +1 -1
- package/dist/cjs/components/config/ConfigProvider.js +1 -1
- package/dist/cjs/components/config/ConfigProvider.js.map +1 -1
- package/dist/cjs/components/modal/components/Commit/DetailView/ExternalCommitDetailView.d.ts +1 -0
- package/dist/cjs/components/modal/components/Commit/DetailView/ExternalCommitDetailView.d.ts.map +1 -1
- package/dist/cjs/components/modal/components/Commit/DetailView/ExternalCommitDetailView.js +4 -1
- package/dist/cjs/components/modal/components/Commit/DetailView/ExternalCommitDetailView.js.map +1 -1
- package/dist/cjs/components/widgets/commit/CommitWidget.d.ts +1 -1
- package/dist/cjs/components/widgets/commit/CommitWidget.d.ts.map +1 -1
- package/dist/cjs/components/widgets/commit/CommitWidget.js +1 -1
- package/dist/cjs/components/widgets/commit/CommitWidget.js.map +1 -1
- package/dist/cjs/components/widgets/commit/CommitWidgetProviders.d.ts +6 -0
- package/dist/cjs/components/widgets/commit/CommitWidgetProviders.d.ts.map +1 -1
- package/dist/cjs/components/widgets/commit/CommitWidgetProviders.js +56 -5
- package/dist/cjs/components/widgets/commit/CommitWidgetProviders.js.map +1 -1
- package/dist/cjs/hooks/index.d.ts +1 -0
- package/dist/cjs/hooks/index.d.ts.map +1 -1
- package/dist/cjs/hooks/index.js +1 -0
- package/dist/cjs/hooks/index.js.map +1 -1
- package/dist/cjs/hooks/uniswap/useIsWindowVisible.d.ts +1 -1
- package/dist/cjs/hooks/uniswap/useIsWindowVisible.d.ts.map +1 -1
- package/dist/cjs/hooks/uniswap/useIsWindowVisible.js +2 -1
- package/dist/cjs/hooks/uniswap/useIsWindowVisible.js.map +1 -1
- package/dist/cjs/lib/config/config.d.ts.map +1 -1
- package/dist/cjs/lib/config/config.js +3 -4
- package/dist/cjs/lib/config/config.js.map +1 -1
- package/dist/cjs/state/hooks.d.ts.map +1 -1
- package/dist/cjs/state/hooks.js +5 -2
- package/dist/cjs/state/hooks.js.map +1 -1
- package/dist/cjs/state/lists/updater.d.ts +6 -1
- package/dist/cjs/state/lists/updater.d.ts.map +1 -1
- package/dist/cjs/state/lists/updater.js +1 -5
- package/dist/cjs/state/lists/updater.js.map +1 -1
- package/dist/cjs/state/reducer.js +2 -2
- package/dist/cjs/state/reducer.js.map +1 -1
- package/dist/cjs/state/reduxContext.d.ts +3 -0
- package/dist/cjs/state/reduxContext.d.ts.map +1 -0
- package/dist/cjs/state/reduxContext.js +9 -0
- package/dist/cjs/state/reduxContext.js.map +1 -0
- package/dist/cjs/state/updaters.d.ts +5 -3
- package/dist/cjs/state/updaters.d.ts.map +1 -1
- package/dist/cjs/state/updaters.js +14 -2
- package/dist/cjs/state/updaters.js.map +1 -1
- package/dist/esm/components/config/ConfigContext.d.ts +1 -1
- package/dist/esm/components/config/ConfigContext.d.ts.map +1 -1
- package/dist/esm/components/config/ConfigContext.js +2 -2
- package/dist/esm/components/config/ConfigContext.js.map +1 -1
- package/dist/esm/components/config/ConfigProvider.d.ts.map +1 -1
- package/dist/esm/components/config/ConfigProvider.js +2 -2
- package/dist/esm/components/config/ConfigProvider.js.map +1 -1
- package/dist/esm/components/modal/components/Commit/DetailView/ExternalCommitDetailView.d.ts +1 -0
- package/dist/esm/components/modal/components/Commit/DetailView/ExternalCommitDetailView.d.ts.map +1 -1
- package/dist/esm/components/modal/components/Commit/DetailView/ExternalCommitDetailView.js +1 -0
- package/dist/esm/components/modal/components/Commit/DetailView/ExternalCommitDetailView.js.map +1 -1
- package/dist/esm/components/widgets/commit/CommitWidget.d.ts +1 -1
- package/dist/esm/components/widgets/commit/CommitWidget.d.ts.map +1 -1
- package/dist/esm/components/widgets/commit/CommitWidget.js +1 -1
- package/dist/esm/components/widgets/commit/CommitWidget.js.map +1 -1
- package/dist/esm/components/widgets/commit/CommitWidgetProviders.d.ts +6 -0
- package/dist/esm/components/widgets/commit/CommitWidgetProviders.d.ts.map +1 -1
- package/dist/esm/components/widgets/commit/CommitWidgetProviders.js +29 -4
- package/dist/esm/components/widgets/commit/CommitWidgetProviders.js.map +1 -1
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/index.d.ts.map +1 -1
- package/dist/esm/hooks/index.js +1 -0
- package/dist/esm/hooks/index.js.map +1 -1
- package/dist/esm/hooks/uniswap/useIsWindowVisible.d.ts +1 -1
- package/dist/esm/hooks/uniswap/useIsWindowVisible.d.ts.map +1 -1
- package/dist/esm/hooks/uniswap/useIsWindowVisible.js +1 -1
- package/dist/esm/hooks/uniswap/useIsWindowVisible.js.map +1 -1
- package/dist/esm/lib/config/config.d.ts.map +1 -1
- package/dist/esm/lib/config/config.js +3 -4
- package/dist/esm/lib/config/config.js.map +1 -1
- package/dist/esm/state/hooks.d.ts.map +1 -1
- package/dist/esm/state/hooks.js +6 -3
- package/dist/esm/state/hooks.js.map +1 -1
- package/dist/esm/state/lists/updater.d.ts +6 -1
- package/dist/esm/state/lists/updater.d.ts.map +1 -1
- package/dist/esm/state/lists/updater.js +1 -5
- package/dist/esm/state/lists/updater.js.map +1 -1
- package/dist/esm/state/reducer.js +2 -2
- package/dist/esm/state/reducer.js.map +1 -1
- package/dist/esm/state/reduxContext.d.ts +3 -0
- package/dist/esm/state/reduxContext.d.ts.map +1 -0
- package/dist/esm/state/reduxContext.js +3 -0
- package/dist/esm/state/reduxContext.js.map +1 -0
- package/dist/esm/state/updaters.d.ts +5 -3
- package/dist/esm/state/updaters.d.ts.map +1 -1
- package/dist/esm/state/updaters.js +2 -2
- package/dist/esm/state/updaters.js.map +1 -1
- package/package.json +4 -4
- package/src/components/config/ConfigContext.ts +2 -2
- package/src/components/config/ConfigProvider.tsx +3 -3
- package/src/components/modal/components/Commit/DetailView/ExternalCommitDetailView.tsx +4 -1
- package/src/components/widgets/commit/CommitWidget.tsx +5 -2
- package/src/components/widgets/commit/CommitWidgetProviders.tsx +72 -6
- package/src/hooks/index.ts +1 -0
- package/src/hooks/uniswap/useIsWindowVisible.ts +1 -1
- package/src/lib/config/config.ts +3 -4
- package/src/state/hooks.ts +10 -3
- package/src/state/lists/updater.ts +9 -5
- package/src/state/reducer.ts +2 -2
- package/src/state/reduxContext.ts +3 -0
- package/src/state/updaters.tsx +4 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { ReactNode } from "react";
|
|
1
|
+
import React, { ReactNode, useCallback } from "react";
|
|
2
2
|
import { QueryClient, QueryClientProvider } from "react-query";
|
|
3
3
|
import { CONFIG } from "../../../lib/config/config";
|
|
4
4
|
import ChatProvider from "../../chat/ChatProvider/ChatProvider";
|
|
@@ -15,15 +15,19 @@ import WalletConnectionProvider, {
|
|
|
15
15
|
import ConvertionRateProvider, {
|
|
16
16
|
ConvertionRateProviderProps
|
|
17
17
|
} from "../finance/convertion-rate/ConvertionRateProvider";
|
|
18
|
-
import { Updaters } from "../../../state/updaters";
|
|
18
|
+
import { Updaters, UpdatersProps } from "../../../state/updaters";
|
|
19
19
|
import { Provider } from "react-redux";
|
|
20
20
|
import store from "../../../state";
|
|
21
|
+
import { ReduxCCDummyContext } from "../../../state/reduxContext";
|
|
22
|
+
import { useIsWindowVisible } from "../../../hooks/uniswap/useIsWindowVisible";
|
|
23
|
+
import { useProvider } from "../../../hooks/connection/connection";
|
|
21
24
|
|
|
22
25
|
export type CommitWidgetProvidersProps = IpfsProviderProps &
|
|
23
26
|
Omit<ConfigProviderProps, "magicLinkKey" | "infuraKey"> &
|
|
24
27
|
ConvertionRateProviderProps &
|
|
25
28
|
Omit<WalletConnectionProviderProps, "children" | "envName"> & {
|
|
26
29
|
children: ReactNode;
|
|
30
|
+
withReduxProvider: boolean;
|
|
27
31
|
};
|
|
28
32
|
|
|
29
33
|
const queryClient = new QueryClient({
|
|
@@ -34,13 +38,60 @@ const queryClient = new QueryClient({
|
|
|
34
38
|
}
|
|
35
39
|
});
|
|
36
40
|
const { infuraKey, magicLinkKey } = CONFIG;
|
|
41
|
+
export const CommitWidgetReduxProvider = ({
|
|
42
|
+
children
|
|
43
|
+
}: {
|
|
44
|
+
children: ReactNode;
|
|
45
|
+
}) => {
|
|
46
|
+
return (
|
|
47
|
+
// it doesnt matter what the initial value of the context is, hence the any cast
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
+
<Provider store={store} context={ReduxCCDummyContext as any}>
|
|
50
|
+
{children}
|
|
51
|
+
</Provider>
|
|
52
|
+
);
|
|
53
|
+
};
|
|
54
|
+
export const CommitWidgetReduxUpdaters = ({
|
|
55
|
+
children,
|
|
56
|
+
...rest
|
|
57
|
+
}: UpdatersProps) => {
|
|
58
|
+
return <Updaters {...rest}>{children}</Updaters>;
|
|
59
|
+
};
|
|
37
60
|
|
|
38
61
|
export const CommitWidgetProviders: React.FC<CommitWidgetProvidersProps> = ({
|
|
39
62
|
children,
|
|
63
|
+
withReduxProvider,
|
|
40
64
|
...props
|
|
41
65
|
}) => {
|
|
66
|
+
const isWindowVisible = useIsWindowVisible();
|
|
67
|
+
const WithReduxProvider = useCallback(
|
|
68
|
+
({ children: providersChildren }: { children: ReactNode }) => {
|
|
69
|
+
return withReduxProvider ? (
|
|
70
|
+
<CommitWidgetReduxProvider>
|
|
71
|
+
{providersChildren}
|
|
72
|
+
</CommitWidgetReduxProvider>
|
|
73
|
+
) : (
|
|
74
|
+
<>{providersChildren}</>
|
|
75
|
+
);
|
|
76
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
77
|
+
},
|
|
78
|
+
[withReduxProvider]
|
|
79
|
+
);
|
|
80
|
+
const WithUpdaters = useCallback(
|
|
81
|
+
({ children: updatersChildren }: { children: ReactNode }) => {
|
|
82
|
+
return withReduxProvider ? (
|
|
83
|
+
<UpdatersWrapper isWindowVisible={isWindowVisible}>
|
|
84
|
+
{updatersChildren}
|
|
85
|
+
</UpdatersWrapper>
|
|
86
|
+
) : (
|
|
87
|
+
<>{updatersChildren}</>
|
|
88
|
+
);
|
|
89
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
90
|
+
},
|
|
91
|
+
[withReduxProvider, isWindowVisible]
|
|
92
|
+
);
|
|
42
93
|
return (
|
|
43
|
-
<
|
|
94
|
+
<WithReduxProvider>
|
|
44
95
|
<ConfigProvider
|
|
45
96
|
magicLinkKey={magicLinkKey}
|
|
46
97
|
infuraKey={infuraKey}
|
|
@@ -51,7 +102,7 @@ export const CommitWidgetProviders: React.FC<CommitWidgetProvidersProps> = ({
|
|
|
51
102
|
<WalletConnectionProvider
|
|
52
103
|
walletConnectProjectId={props.walletConnectProjectId}
|
|
53
104
|
>
|
|
54
|
-
<
|
|
105
|
+
<WithUpdaters>
|
|
55
106
|
<ChatProvider>
|
|
56
107
|
<IpfsProvider {...props}>
|
|
57
108
|
<ConvertionRateProvider>
|
|
@@ -59,11 +110,26 @@ export const CommitWidgetProviders: React.FC<CommitWidgetProvidersProps> = ({
|
|
|
59
110
|
</ConvertionRateProvider>
|
|
60
111
|
</IpfsProvider>
|
|
61
112
|
</ChatProvider>
|
|
62
|
-
</
|
|
113
|
+
</WithUpdaters>
|
|
63
114
|
</WalletConnectionProvider>
|
|
64
115
|
</QueryClientProvider>
|
|
65
116
|
</MagicProvider>
|
|
66
117
|
</ConfigProvider>
|
|
67
|
-
</
|
|
118
|
+
</WithReduxProvider>
|
|
68
119
|
);
|
|
69
120
|
};
|
|
121
|
+
|
|
122
|
+
function UpdatersWrapper({
|
|
123
|
+
children,
|
|
124
|
+
isWindowVisible
|
|
125
|
+
}: {
|
|
126
|
+
children: ReactNode;
|
|
127
|
+
isWindowVisible: boolean;
|
|
128
|
+
}) {
|
|
129
|
+
const provider = useProvider();
|
|
130
|
+
return (
|
|
131
|
+
<Updaters isWindowVisible={isWindowVisible} provider={provider}>
|
|
132
|
+
{children}
|
|
133
|
+
</Updaters>
|
|
134
|
+
);
|
|
135
|
+
}
|
package/src/hooks/index.ts
CHANGED
|
@@ -11,7 +11,7 @@ function isWindowVisible() {
|
|
|
11
11
|
/**
|
|
12
12
|
* Returns whether the window is currently visible to the user.
|
|
13
13
|
*/
|
|
14
|
-
export
|
|
14
|
+
export function useIsWindowVisible(): boolean {
|
|
15
15
|
const [focused, setFocused] = useState<boolean>(false);
|
|
16
16
|
const listener = useCallback(() => {
|
|
17
17
|
setFocused(isWindowVisible());
|
package/src/lib/config/config.ts
CHANGED
|
@@ -9,12 +9,11 @@ if (!magicLinkKey) {
|
|
|
9
9
|
);
|
|
10
10
|
}
|
|
11
11
|
const infuraKey =
|
|
12
|
-
process.env.
|
|
13
|
-
process.env.
|
|
14
|
-
process.env.REACT_APP_INFURA_IPFS_PROJECT_SECRET;
|
|
12
|
+
process.env.STORYBOOK_REACT_APP_INFURA_KEY ||
|
|
13
|
+
process.env.REACT_APP_INFURA_KEY;
|
|
15
14
|
if (!infuraKey) {
|
|
16
15
|
throw new Error(
|
|
17
|
-
"
|
|
16
|
+
"STORYBOOK_REACT_APP_INFURA_KEY/REACT_APP_INFURA_KEY is not defined"
|
|
18
17
|
);
|
|
19
18
|
}
|
|
20
19
|
|
package/src/state/hooks.ts
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createDispatchHook,
|
|
3
|
+
createSelectorHook,
|
|
4
|
+
TypedUseSelectorHook
|
|
5
|
+
} from "react-redux";
|
|
2
6
|
|
|
3
7
|
import store from "./index";
|
|
8
|
+
import { ReduxCCDummyContext } from "./reduxContext";
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
const useDappDispatch = createDispatchHook(ReduxCCDummyContext as any);
|
|
11
|
+
export const useAppDispatch = () => useDappDispatch<typeof store.dispatch>();
|
|
12
|
+
const useDappSelector = createSelectorHook(ReduxCCDummyContext as any);
|
|
6
13
|
export const useAppSelector: TypedUseSelectorHook<
|
|
7
14
|
ReturnType<typeof store.getState>
|
|
8
|
-
> =
|
|
15
|
+
> = useDappSelector;
|
|
@@ -10,15 +10,19 @@ import { useAllLists } from "../../state/lists/hooks";
|
|
|
10
10
|
|
|
11
11
|
import { acceptListUpdate } from "./actions";
|
|
12
12
|
import { shouldAcceptVersionUpdate } from "./utils";
|
|
13
|
-
import { useProvider } from "../../hooks/connection/connection";
|
|
14
|
-
import useIsWindowVisible from "../../hooks/uniswap/useIsWindowVisible";
|
|
15
13
|
import { useInterval } from "../../hooks/uniswap/useInterval";
|
|
16
14
|
import { useFetchListCallback } from "../../hooks/uniswap/useFetchListCallback";
|
|
15
|
+
import { providers } from "ethers";
|
|
17
16
|
|
|
18
|
-
export
|
|
19
|
-
|
|
17
|
+
export type ListsUpdaterProps = {
|
|
18
|
+
isWindowVisible: boolean;
|
|
19
|
+
provider: providers.FallbackProvider | providers.JsonRpcProvider;
|
|
20
|
+
};
|
|
21
|
+
export function ListsUpdater({
|
|
22
|
+
isWindowVisible,
|
|
23
|
+
provider
|
|
24
|
+
}: ListsUpdaterProps): null {
|
|
20
25
|
const dispatch = useAppDispatch();
|
|
21
|
-
const isWindowVisible = useIsWindowVisible();
|
|
22
26
|
|
|
23
27
|
// get all loaded lists, and the active urls
|
|
24
28
|
const lists = useAllLists();
|
package/src/state/reducer.ts
CHANGED
|
@@ -16,10 +16,10 @@ const appReducer = combineReducers({
|
|
|
16
16
|
export type AppState = ReturnType<typeof appReducer>;
|
|
17
17
|
|
|
18
18
|
const persistConfig: PersistConfig<AppState> = {
|
|
19
|
-
key: "
|
|
19
|
+
key: "CC",
|
|
20
20
|
version: 0, // see migrations.ts for more details about this version
|
|
21
21
|
storage: localForage.createInstance({
|
|
22
|
-
name: "redux"
|
|
22
|
+
name: "redux-cc"
|
|
23
23
|
}),
|
|
24
24
|
migrate: customCreateMigrate(migrations, { debug: false }),
|
|
25
25
|
whitelist: Object.keys(persistedReducers),
|
package/src/state/updaters.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
|
-
import { ListsUpdater } from "./lists/updater";
|
|
2
|
+
import { ListsUpdater, ListsUpdaterProps } from "./lists/updater";
|
|
3
3
|
|
|
4
|
-
export
|
|
4
|
+
export type UpdatersProps = ListsUpdaterProps & { children?: ReactNode };
|
|
5
|
+
export const Updaters = ({ children, ...rest }: UpdatersProps) => {
|
|
5
6
|
return (
|
|
6
7
|
<>
|
|
7
|
-
<ListsUpdater />
|
|
8
|
+
<ListsUpdater {...rest} />
|
|
8
9
|
{children}
|
|
9
10
|
</>
|
|
10
11
|
);
|