@wf-financing/ui 1.4.1 → 1.4.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/CHANGELOG.md +12 -0
- package/dist/ConsentModal-vhnjWxOz.mjs +161 -0
- package/dist/index-Gn-_ZM3g.mjs +75671 -0
- package/dist/index.es.js +1 -95278
- package/package.json +3 -3
- package/src/components/banner/ProceedFundingButton.tsx +8 -5
- package/src/components/modal/ConsentModal.snapshot.stories.tsx +2 -2
- package/src/components/modal/ConsentModal.tsx +3 -1
- package/src/components/modal/ModalFooter.tsx +2 -1
- package/src/config/fontParameters.ts +12 -8
- package/src/config/index.ts +3 -2
- package/src/utils/applyFont.ts +2 -5
- package/src/utils/loadFont.ts +13 -8
- package/vite.config.ts +3 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wf-financing/ui",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.3",
|
|
4
4
|
"exports": {
|
|
5
5
|
".": {
|
|
6
6
|
"import": "./dist/index.es.js",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@tanstack/react-query": "5.81.5",
|
|
35
|
-
"@wayflyer/flyui-icons": "1.
|
|
35
|
+
"@wayflyer/flyui-icons": "1.6.0",
|
|
36
36
|
"framer-motion": "^12.23.0",
|
|
37
37
|
"react-aria": "^3.41.1",
|
|
38
38
|
"react-intl": "^6.2.5",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@wf-financing/embedded-types": "0.3.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@wayflyer/flyui": "
|
|
43
|
+
"@wayflyer/flyui": "204.4.1"
|
|
44
44
|
},
|
|
45
45
|
"publishConfig": {
|
|
46
46
|
"access": "public"
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { Button } from '@wayflyer/flyui';
|
|
2
2
|
import {
|
|
3
|
+
ContinueHostedApplicationResponseType,
|
|
3
4
|
CtaContinueFundingType,
|
|
4
5
|
CtaGenericOfferType,
|
|
5
6
|
CtaIndicativeOfferType,
|
|
6
7
|
CtaStateType,
|
|
7
|
-
ContinueHostedApplicationResponseType,
|
|
8
8
|
} from '@wf-financing/embedded-types';
|
|
9
|
-
import { useState } from 'react';
|
|
9
|
+
import { lazy, Suspense, useState } from 'react';
|
|
10
|
+
|
|
11
|
+
import { useContinueHostedApplication, useCtaBanner } from '../../hooks';
|
|
10
12
|
|
|
11
|
-
|
|
12
|
-
import { ConsentModal } from '../modal/ConsentModal';
|
|
13
|
+
const ConsentModal = lazy(() => import('../modal/ConsentModal'));
|
|
13
14
|
|
|
14
15
|
type CtaResponseType = CtaGenericOfferType | CtaIndicativeOfferType | CtaContinueFundingType;
|
|
15
16
|
|
|
@@ -50,7 +51,9 @@ export const ProceedFundingButton = () => {
|
|
|
50
51
|
<Button variant="Primary" fullWidth onClick={handleContinueHostedApplication}>
|
|
51
52
|
{config?.button_label}
|
|
52
53
|
</Button>
|
|
53
|
-
<
|
|
54
|
+
<Suspense>
|
|
55
|
+
<ConsentModal isModalOpen={isModalOpen} setIsModalOpen={setIsModalOpen} />
|
|
56
|
+
</Suspense>
|
|
54
57
|
</>
|
|
55
58
|
);
|
|
56
59
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
2
|
|
|
3
|
-
import { ConsentModal } from './ConsentModal';
|
|
4
|
-
import { PartnerContext } from '../../utils';
|
|
5
3
|
import { Themes } from '@wayflyer/flyui';
|
|
4
|
+
import { PartnerContext } from '../../utils';
|
|
5
|
+
import ConsentModal from './ConsentModal';
|
|
6
6
|
|
|
7
7
|
const portalContainer = document.createElement('div');
|
|
8
8
|
document.body.append(portalContainer);
|
|
@@ -17,7 +17,7 @@ const ImageContainer = styled(Image)`
|
|
|
17
17
|
max-width: none;
|
|
18
18
|
`;
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
const ConsentModal = ({ isModalOpen, setIsModalOpen }: ConsentModalProps) => {
|
|
21
21
|
const { formatMessage } = useIntl();
|
|
22
22
|
const isSmallScreen = useDetectSmallScreen();
|
|
23
23
|
const { isMobile } = useDetectDeviceSize();
|
|
@@ -39,3 +39,5 @@ export const ConsentModal = ({ isModalOpen, setIsModalOpen }: ConsentModalProps)
|
|
|
39
39
|
</Modal>
|
|
40
40
|
);
|
|
41
41
|
};
|
|
42
|
+
|
|
43
|
+
export default ConsentModal;
|
|
@@ -3,7 +3,7 @@ import { IconArrowOnSquareUpRight16Line } from '@wayflyer/flyui-icons/16/line';
|
|
|
3
3
|
import { StartHostedApplicationResponseType } from '@wf-financing/embedded-types';
|
|
4
4
|
import { FormattedMessage } from 'react-intl';
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { useDetectSmallScreen, useStartHostedApplication } from '../../hooks';
|
|
7
7
|
|
|
8
8
|
type ModalFooterType = {
|
|
9
9
|
setOpen: (isOpen: boolean) => void;
|
|
@@ -18,6 +18,7 @@ export const ModalFooter = ({ setOpen }: ModalFooterType) => {
|
|
|
18
18
|
startHostedAppMutation.mutate(undefined, {
|
|
19
19
|
onSuccess: (nextUrl: StartHostedApplicationResponseType) => {
|
|
20
20
|
const { next } = nextUrl;
|
|
21
|
+
setOpen(false);
|
|
21
22
|
window.open(next);
|
|
22
23
|
},
|
|
23
24
|
onError: (error) => {
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
+
export type FontParamsType = {
|
|
2
|
+
fontFamily: string;
|
|
3
|
+
fontUrl: string;
|
|
4
|
+
fallbackFontUrl: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
1
7
|
const dmSansParams = {
|
|
2
8
|
fontFamily: 'DM Sans',
|
|
3
|
-
fontUrl: 'https://
|
|
4
|
-
|
|
5
|
-
const sourceSansParams = {
|
|
6
|
-
fontFamily: 'Source Sans Pro',
|
|
7
|
-
fontUrl: 'https://app.wayflyer.com/flyui-assets/fonts/source-sans/SourceSans3-VariableFont_wght.ttf',
|
|
9
|
+
fontUrl: 'https://static.wayflyer.com/flyui-assets/fonts/dm-sans/DMSans-VariableFont_opsz,wght.ttf',
|
|
10
|
+
fallbackFontUrl: 'https://app.wayflyer.com/flyui-assets/fonts/dm-sans/DMSans-VariableFont_opsz,wght.ttf',
|
|
8
11
|
};
|
|
12
|
+
|
|
9
13
|
const merrionSansParams = {
|
|
10
14
|
fontFamily: 'Merrion Sans',
|
|
11
|
-
fontUrl: 'https://
|
|
15
|
+
fontUrl: 'https://static.wayflyer.com/flyui-assets/fonts/merrion-sans/Merrion_Sans-Medium.woff2',
|
|
16
|
+
fallbackFontUrl: 'https://app.wayflyer.com/flyui-assets/fonts/merrion-sans/Merrion_Sans-Medium.woff2',
|
|
12
17
|
};
|
|
13
18
|
|
|
14
|
-
export const FONT_PARAMS = {
|
|
19
|
+
export const FONT_PARAMS: Record<string, FontParamsType> = {
|
|
15
20
|
dmSansParams,
|
|
16
|
-
sourceSansParams,
|
|
17
21
|
merrionSansParams,
|
|
18
22
|
};
|
package/src/config/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
export { FONT_PARAMS } from './fontParameters';
|
|
2
|
+
export type { FontParamsType } from './fontParameters';
|
|
3
|
+
export { ROOTS_CONFIG } from './rootsParameters';
|
|
1
4
|
export { WAYFLYER_HEADLESS_SDK_ID } from './scriptId';
|
|
2
5
|
export { HEADLESS_SDK_URL } from './url';
|
|
3
|
-
export { ROOTS_CONFIG } from './rootsParameters';
|
|
4
|
-
export { FONT_PARAMS } from './fontParameters';
|
package/src/utils/applyFont.ts
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
import type { Themes } from '@wayflyer/flyui';
|
|
2
2
|
|
|
3
|
-
import { loadFont } from './loadFont';
|
|
4
3
|
import { FONT_PARAMS } from '../config';
|
|
4
|
+
import { loadFont } from './loadFont';
|
|
5
5
|
|
|
6
6
|
type ApplyFontsType = (shadow: ShadowRoot, partnerDesignId: Themes) => Promise<void>;
|
|
7
7
|
|
|
8
8
|
export const applyFont: ApplyFontsType = async (shadow, partnerDesignId) => {
|
|
9
|
-
const { dmSansParams,
|
|
9
|
+
const { dmSansParams, merrionSansParams } = FONT_PARAMS;
|
|
10
10
|
|
|
11
11
|
switch (partnerDesignId) {
|
|
12
12
|
case 'whiteLabel':
|
|
13
13
|
await loadFont(shadow, dmSansParams);
|
|
14
14
|
break;
|
|
15
|
-
case 'bigCommerce':
|
|
16
|
-
await loadFont(shadow, sourceSansParams);
|
|
17
|
-
break;
|
|
18
15
|
case 'wayflyer':
|
|
19
16
|
case 'staff':
|
|
20
17
|
case 'defaultTheme':
|
package/src/utils/loadFont.ts
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
fontFamily: string;
|
|
3
|
-
fontUrl: string;
|
|
4
|
-
};
|
|
1
|
+
import { FontParamsType } from 'src/config';
|
|
5
2
|
|
|
6
3
|
type LoadFontType = (shadow: ShadowRoot, fontParams: FontParamsType) => Promise<void>;
|
|
7
4
|
|
|
8
5
|
export const loadFont: LoadFontType = async (shadow, fontParams) => {
|
|
9
|
-
const { fontFamily, fontUrl } = fontParams;
|
|
6
|
+
const { fontFamily, fontUrl, fallbackFontUrl } = fontParams;
|
|
10
7
|
const fontStylesId = 'font-styles';
|
|
11
8
|
|
|
12
|
-
|
|
9
|
+
let font: FontFace;
|
|
13
10
|
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
try {
|
|
12
|
+
font = new FontFace(fontFamily, `url(${fontUrl})`);
|
|
13
|
+
await font.load();
|
|
14
|
+
} catch {
|
|
15
|
+
font = new FontFace(fontFamily, `url(${fallbackFontUrl})`);
|
|
16
|
+
await font.load();
|
|
17
|
+
} finally {
|
|
18
|
+
document.fonts.add(font!);
|
|
19
|
+
}
|
|
16
20
|
|
|
17
21
|
let fontStyles = shadow.getElementById(fontStylesId);
|
|
22
|
+
|
|
18
23
|
if (!fontStyles) {
|
|
19
24
|
fontStyles = document.createElement('style');
|
|
20
25
|
fontStyles.id = fontStylesId;
|
package/vite.config.ts
CHANGED
|
@@ -3,10 +3,10 @@ import react from '@vitejs/plugin-react';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { defineConfig } from 'vite';
|
|
5
5
|
|
|
6
|
-
export default defineConfig({
|
|
6
|
+
export default defineConfig(({ mode }) => ({
|
|
7
7
|
plugins: [react()],
|
|
8
8
|
define: {
|
|
9
|
-
'process.env':
|
|
9
|
+
'process.env.NODE_ENV': JSON.stringify(mode === 'production' ? 'production' : 'development'),
|
|
10
10
|
},
|
|
11
11
|
server: {
|
|
12
12
|
host: true,
|
|
@@ -20,8 +20,5 @@ export default defineConfig({
|
|
|
20
20
|
fileName: (format) => `index.${format}.js`,
|
|
21
21
|
formats: ['es'],
|
|
22
22
|
},
|
|
23
|
-
rollupOptions: {
|
|
24
|
-
external: [],
|
|
25
|
-
},
|
|
26
23
|
},
|
|
27
|
-
});
|
|
24
|
+
}));
|