@wf-financing/ui 1.3.1 → 1.4.0
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/CHANGELOG.md +17 -0
- package/dist/index.es.js +22447 -22467
- package/package.json +2 -2
- package/src/api/dismissCta.ts +11 -0
- package/src/api/index.ts +4 -0
- package/src/components/banner/CloseButton.tsx +12 -2
- package/src/config/fontParameters.ts +3 -3
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useContinueHostedApplication.ts +1 -1
- package/src/hooks/useCtaBanner.ts +1 -1
- package/src/hooks/useDismissCta.ts +12 -0
- package/src/hooks/useStartHostedApplication.ts +1 -1
- package/src/main.tsx +6 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wf-financing/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"import": "./dist/index.es.js",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"react-aria": "^3.41.1",
|
|
38
38
|
"react-intl": "^6.2.5",
|
|
39
39
|
"styled-components": "^6.1.19",
|
|
40
|
-
"@wf-financing/embedded-types": "0.
|
|
40
|
+
"@wf-financing/embedded-types": "0.3.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@wayflyer/flyui": "202.1.0"
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MockedModeType } from '@wf-financing/embedded-types';
|
|
2
|
+
|
|
3
|
+
import { getHeadlessSdkInstance } from './getHeadlessSdkInstance';
|
|
4
|
+
|
|
5
|
+
export const dismissCta = async (companyToken: string, mockedMode?: MockedModeType) => {
|
|
6
|
+
const sdk = await getHeadlessSdkInstance(companyToken, mockedMode);
|
|
7
|
+
|
|
8
|
+
if (!mockedMode) {
|
|
9
|
+
await sdk.dismissCta();
|
|
10
|
+
}
|
|
11
|
+
};
|
package/src/api/index.ts
ADDED
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import { Button, Flex } from '@wayflyer/flyui';
|
|
2
2
|
import { IconX16Line } from '@wayflyer/flyui-icons/16/line';
|
|
3
3
|
|
|
4
|
-
import { usePartnerContext } from '../../hooks';
|
|
4
|
+
import { usePartnerContext, useDismissCta } from '../../hooks';
|
|
5
5
|
|
|
6
6
|
export const CloseButton = () => {
|
|
7
7
|
const { onWidgetClose: closeWidget } = usePartnerContext();
|
|
8
|
+
const dismissCta = useDismissCta();
|
|
9
|
+
|
|
10
|
+
const handleCloseWidget = () => {
|
|
11
|
+
closeWidget();
|
|
12
|
+
dismissCta.mutate(undefined, {
|
|
13
|
+
onError: (error) => {
|
|
14
|
+
console.error('Failed to dismiss CTA', error);
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
};
|
|
8
18
|
|
|
9
19
|
return (
|
|
10
|
-
<Button onClick={
|
|
20
|
+
<Button onClick={handleCloseWidget} variant="Tertiary">
|
|
11
21
|
<Flex padding="2">
|
|
12
22
|
<IconX16Line />
|
|
13
23
|
</Flex>
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
const dmSansParams = {
|
|
2
2
|
fontFamily: 'DM Sans',
|
|
3
|
-
fontUrl: 'https://
|
|
3
|
+
fontUrl: 'https://app.wayflyer.com/flyui-assets/fonts/dm-sans/DMSans-VariableFont_opsz,wght.ttf',
|
|
4
4
|
};
|
|
5
5
|
const sourceSansParams = {
|
|
6
6
|
fontFamily: 'Source Sans Pro',
|
|
7
|
-
fontUrl: 'https://
|
|
7
|
+
fontUrl: 'https://app.wayflyer.com/flyui-assets/fonts/source-sans/SourceSans3-VariableFont_wght.ttf',
|
|
8
8
|
};
|
|
9
9
|
const merrionSansParams = {
|
|
10
10
|
fontFamily: 'Merrion Sans',
|
|
11
|
-
fontUrl: 'https://
|
|
11
|
+
fontUrl: 'https://app.wayflyer.com/flyui-assets/fonts/merrion-sans/Merrion_Sans-Medium.woff2',
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
export const FONT_PARAMS = {
|
package/src/hooks/index.ts
CHANGED
|
@@ -3,4 +3,5 @@ export { useCtaBanner } from './useCtaBanner';
|
|
|
3
3
|
export { useStartHostedApplication } from './useStartHostedApplication';
|
|
4
4
|
export { useDetectSmallScreen } from './useDetectSmallScreen';
|
|
5
5
|
export { useContinueHostedApplication } from './useContinueHostedApplication';
|
|
6
|
+
export { useDismissCta } from './useDismissCta';
|
|
6
7
|
export { useRemoveInerted } from './useRemoveInerted';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMutation } from '@tanstack/react-query';
|
|
2
2
|
|
|
3
|
-
import { continueHostedApplication } from '../api
|
|
3
|
+
import { continueHostedApplication } from '../api';
|
|
4
4
|
import { usePartnerContext } from './usePartnerContext';
|
|
5
5
|
|
|
6
6
|
export const useContinueHostedApplication = () => {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { useMutation } from '@tanstack/react-query';
|
|
2
|
+
|
|
3
|
+
import { dismissCta } from '../api';
|
|
4
|
+
import { usePartnerContext } from './usePartnerContext';
|
|
5
|
+
|
|
6
|
+
export const useDismissCta = () => {
|
|
7
|
+
const { companyToken, mockedMode } = usePartnerContext();
|
|
8
|
+
|
|
9
|
+
return useMutation({
|
|
10
|
+
mutationFn: () => dismissCta(companyToken, mockedMode),
|
|
11
|
+
});
|
|
12
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMutation } from '@tanstack/react-query';
|
|
2
2
|
|
|
3
|
-
import { startHostedApplication } from '../api
|
|
3
|
+
import { startHostedApplication } from '../api';
|
|
4
4
|
import { usePartnerContext } from './usePartnerContext';
|
|
5
5
|
|
|
6
6
|
export const useStartHostedApplication = () => {
|
package/src/main.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import ReactDOM from 'react-dom/client';
|
|
|
4
4
|
import { StyleSheetManager } from 'styled-components';
|
|
5
5
|
|
|
6
6
|
import { App } from './App';
|
|
7
|
-
import { createRoots } from './utils';
|
|
7
|
+
import { createRoots, applyFont } from './utils';
|
|
8
8
|
|
|
9
9
|
let root: ReactDOM.Root | undefined = undefined;
|
|
10
10
|
|
|
@@ -20,8 +20,11 @@ export const mountToTarget = async (
|
|
|
20
20
|
|
|
21
21
|
const shadow = hostEl.shadowRoot ?? hostEl.attachShadow({ mode: 'open' });
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
try {
|
|
24
|
+
await applyFont(shadow, partnerDesignId);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error(error);
|
|
27
|
+
}
|
|
25
28
|
|
|
26
29
|
const { styledComponentsStyleRoot, portalRoot, bannerRoot } = createRoots(shadow);
|
|
27
30
|
|