@faststore/core 3.0.89 → 3.0.93
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +22 -22
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- package/.next/cache/eslint/.cache_1gneedd +1 -1
- package/.next/cache/webpack/client-production/0.pack +0 -0
- package/.next/cache/webpack/client-production/index.pack +0 -0
- package/.next/cache/webpack/server-production/0.pack +0 -0
- package/.next/cache/webpack/server-production/index.pack +0 -0
- package/.next/next-server.js.nft.json +1 -1
- package/.next/prerender-manifest.js +1 -1
- package/.next/prerender-manifest.json +1 -1
- package/.next/react-loadable-manifest.json +1 -1
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/646.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/en-US/404.html +2 -2
- package/.next/server/pages/en-US/404.json +1 -1
- package/.next/server/pages/en-US/500.html +2 -2
- package/.next/server/pages/en-US/500.json +1 -1
- package/.next/server/pages/en-US/account.html +2 -2
- package/.next/server/pages/en-US/account.json +1 -1
- package/.next/server/pages/en-US/checkout.html +2 -2
- package/.next/server/pages/en-US/checkout.json +1 -1
- package/.next/server/pages/en-US/login.html +2 -2
- package/.next/server/pages/en-US/login.json +1 -1
- package/.next/server/pages/en-US/s.html +2 -2
- package/.next/server/pages/en-US/s.json +1 -1
- package/.next/server/pages/en-US.html +2 -2
- package/.next/server/pages/en-US.json +1 -1
- package/.next/server/pages-manifest.json +1 -1
- package/.next/static/{0b6ZzLjb0ZPtd21YGWfui → _36OHYNSFRCrMGC98GYLg}/_buildManifest.js +1 -1
- package/.next/static/chunks/104-9e38d52de0573dbb.js +1 -0
- package/.next/static/chunks/{65.da22595d53beae76.js → 65.78da4e775f896fbd.js} +1 -1
- package/.next/static/chunks/{webpack-63df43b7e99450a0.js → webpack-91a2417668848fcd.js} +1 -1
- package/.next/trace +95 -95
- package/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-test.log +4 -4
- package/package.json +2 -2
- package/src/components/cms/SectionBoundary.tsx +16 -3
- package/src/components/common/Footer/Footer.tsx +8 -3
- package/src/components/navigation/Navbar/Navbar.tsx +2 -2
- package/src/components/navigation/NavbarSlider/NavbarSlider.tsx +3 -2
- package/src/components/search/SearchDropdown/SearchDropdown.tsx +8 -3
- package/src/components/search/SearchInput/SearchInput.tsx +2 -1
- package/src/components/search/Sort/Sort.tsx +9 -4
- package/src/components/sections/Navbar/DefaultComponents.ts +3 -0
- package/src/components/templates/LandingPage/LandingPage.tsx +1 -1
- package/src/components/templates/ProductListingPage/ProductListing.tsx +1 -1
- package/src/components/ui/Image/loader.ts +6 -1
- package/src/components/ui/ImageGallery/ImageGallery.tsx +7 -1
- package/src/components/ui/Newsletter/NewsletterAddendum.tsx +2 -0
- package/src/customizations/src/dynamicContent/index.ts +1 -1
- package/src/experimental/index.ts +1 -0
- package/src/pages/[slug]/p.tsx +1 -1
- package/src/sdk/analytics/index.tsx +1 -1
- package/src/sdk/error/ErrorBoundary/ErrorBoundary.tsx +14 -2
- package/src/sdk/overrides/overrides.ts +37 -27
- package/src/sdk/product/useProductGalleryQuery.ts +9 -1
- package/src/typings/overrides.ts +9 -8
- package/test/utils/multipleTemplates.test.ts +1 -1
- package/tsconfig.json +3 -2
- package/.next/static/chunks/104-e3f9b47f4ac2de68.js +0 -1
- /package/.next/static/{0b6ZzLjb0ZPtd21YGWfui → _36OHYNSFRCrMGC98GYLg}/_ssgManifest.js +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -75,7 +75,7 @@ Route (pages) Size First Load JS
|
|
|
75
75
|
├ chunks/framework-8e279965036b6169.js 45.4 kB
|
|
76
76
|
├ chunks/main-6f63f6746cc029db.js 33.1 kB
|
|
77
77
|
├ chunks/pages/_app-c25fabc2435c8961.js 12.6 kB
|
|
78
|
-
├ chunks/webpack-
|
|
78
|
+
├ chunks/webpack-91a2417668848fcd.js 2.45 kB
|
|
79
79
|
└ css/ee0556daedda6306.css 3.07 kB
|
|
80
80
|
|
|
81
81
|
λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
|
package/.turbo/turbo-test.log
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
$ jest
|
|
2
|
-
PASS test/utils/multipleTemplates.test.ts (31.
|
|
3
|
-
PASS test/server/cms/index.test.ts (
|
|
4
|
-
PASS test/server/index.test.ts (
|
|
2
|
+
PASS test/utils/multipleTemplates.test.ts (31.495 s)
|
|
3
|
+
PASS test/server/cms/index.test.ts (31.977 s)
|
|
4
|
+
PASS test/server/index.test.ts (33.746 s)
|
|
5
5
|
|
|
6
6
|
Test Suites: 3 passed, 3 total
|
|
7
7
|
Tests: 19 passed, 19 total
|
|
8
8
|
Snapshots: 0 total
|
|
9
|
-
Time:
|
|
9
|
+
Time: 34.811 s
|
|
10
10
|
Ran all test suites.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.93",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"repository": "vtex/faststore",
|
|
6
6
|
"browserslist": "supports es6-module and not dead",
|
|
@@ -130,5 +130,5 @@
|
|
|
130
130
|
"node": "18.19.0",
|
|
131
131
|
"yarn": "1.19.1"
|
|
132
132
|
},
|
|
133
|
-
"gitHead": "
|
|
133
|
+
"gitHead": "32c36b739087214e8abb6a78da4623033143ec97"
|
|
134
134
|
}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
import { Component } from 'react'
|
|
2
2
|
import type { ErrorInfo, ReactNode } from 'react'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
interface ErrorBoundaryProps {
|
|
5
5
|
children: ReactNode
|
|
6
6
|
name: string
|
|
7
|
-
}
|
|
8
|
-
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface ErrorBoundaryState {
|
|
10
|
+
hasError: Boolean
|
|
11
|
+
error: Error | null
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
class SectionBoundary extends Component<
|
|
15
|
+
ErrorBoundaryProps,
|
|
16
|
+
ErrorBoundaryState
|
|
17
|
+
> {
|
|
18
|
+
public state: ErrorBoundaryState = {
|
|
19
|
+
hasError: false,
|
|
20
|
+
error: null,
|
|
21
|
+
}
|
|
9
22
|
|
|
10
23
|
public static getDerivedStateFromError(error: Error) {
|
|
11
24
|
return {
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
+
import { ReactNode } from 'react'
|
|
1
2
|
import { mark } from 'src/sdk/tests/mark'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
interface FooterProps {
|
|
5
|
+
children: ReactNode
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function FooterInfo({ children }: FooterProps) {
|
|
4
9
|
return <div data-fs-footer-info>{children}</div>
|
|
5
10
|
}
|
|
6
11
|
|
|
7
|
-
export function FooterNavigation({ children }) {
|
|
12
|
+
export function FooterNavigation({ children }: FooterProps) {
|
|
8
13
|
return <div data-fs-footer-navigation>{children}</div>
|
|
9
14
|
}
|
|
10
15
|
|
|
11
|
-
export function Footer({ children }) {
|
|
16
|
+
export function Footer({ children }: FooterProps) {
|
|
12
17
|
return (
|
|
13
18
|
<footer
|
|
14
19
|
data-fs-footer
|
|
@@ -11,7 +11,6 @@ import NavbarSlider from 'src/components/navigation/NavbarSlider'
|
|
|
11
11
|
import CartToggle from 'src/components/cart/CartToggle'
|
|
12
12
|
import Logo from 'src/components/ui/Logo'
|
|
13
13
|
import Link from 'src/components/ui/Link'
|
|
14
|
-
import { ButtonSignIn } from 'src/components/ui/Button'
|
|
15
14
|
import { useOverrideComponents } from 'src/sdk/overrides/OverrideContext'
|
|
16
15
|
|
|
17
16
|
import type { NavbarProps as SectionNavbarProps } from '../../sections/Navbar'
|
|
@@ -77,6 +76,7 @@ function Navbar({
|
|
|
77
76
|
NavbarRow,
|
|
78
77
|
NavbarButtons,
|
|
79
78
|
IconButton,
|
|
79
|
+
_experimentalButtonSignIn: ButtonSignIn,
|
|
80
80
|
} = useOverrideComponents<'Navbar'>()
|
|
81
81
|
const scrollDirection = useScrollDirection()
|
|
82
82
|
const { openNavbar, navbar: displayNavbar } = useUI()
|
|
@@ -152,7 +152,7 @@ function Navbar({
|
|
|
152
152
|
aria-hidden={!searchExpanded}
|
|
153
153
|
/>
|
|
154
154
|
|
|
155
|
-
<ButtonSignIn {...signInButton} />
|
|
155
|
+
<ButtonSignIn.Component {...signInButton} />
|
|
156
156
|
|
|
157
157
|
<CartToggle {...cart} />
|
|
158
158
|
</NavbarButtons.Component>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useFadeEffect, useUI } from '@faststore/ui'
|
|
2
2
|
import { Suspense } from 'react'
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import { ButtonSignInFallback } from 'src/components/ui/Button'
|
|
5
5
|
import Link from 'src/components/ui/Link'
|
|
6
6
|
import NavbarLinks from 'src/components/navigation/NavbarLinks'
|
|
7
7
|
import Logo from 'src/components/ui/Logo'
|
|
@@ -32,6 +32,7 @@ function NavbarSlider({
|
|
|
32
32
|
NavbarSliderHeader,
|
|
33
33
|
NavbarSliderContent,
|
|
34
34
|
NavbarSliderFooter,
|
|
35
|
+
_experimentalButtonSignIn: ButtonSignIn,
|
|
35
36
|
} = useOverrideComponents<'Navbar'>()
|
|
36
37
|
|
|
37
38
|
const { closeNavbar } = useUI()
|
|
@@ -65,7 +66,7 @@ function NavbarSlider({
|
|
|
65
66
|
</NavbarSliderContent.Component>
|
|
66
67
|
<NavbarSliderFooter.Component {...NavbarSliderFooter.props}>
|
|
67
68
|
<Suspense fallback={<ButtonSignInFallback />}>
|
|
68
|
-
<ButtonSignIn {...signInButton} />
|
|
69
|
+
<ButtonSignIn.Component {...signInButton} />
|
|
69
70
|
</Suspense>
|
|
70
71
|
</NavbarSliderFooter.Component>
|
|
71
72
|
</NavbarSliderWrapper.Component>
|
|
@@ -14,7 +14,12 @@ import { ProductSummary_ProductFragment } from '@generated/graphql'
|
|
|
14
14
|
import SearchProductItem from 'src/components/search/SearchProductItem'
|
|
15
15
|
import { formatSearchPath } from 'src/sdk/search/formatSearchPath'
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
interface SearchDropdownProps {
|
|
18
|
+
sort: SearchState['sort']
|
|
19
|
+
[key: string]: any
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function SearchDropdown({ sort, ...otherProps }: SearchDropdownProps) {
|
|
18
23
|
const {
|
|
19
24
|
values: { onSearchSelection, products, term, terms },
|
|
20
25
|
} = useSearch()
|
|
@@ -32,14 +37,14 @@ function SearchDropdown({ sort, ...otherProps }) {
|
|
|
32
37
|
linkProps={{
|
|
33
38
|
href: formatSearchPath({
|
|
34
39
|
term: suggestion,
|
|
35
|
-
sort
|
|
40
|
+
sort,
|
|
36
41
|
}),
|
|
37
42
|
onClick: () =>
|
|
38
43
|
onSearchSelection?.(
|
|
39
44
|
suggestion,
|
|
40
45
|
formatSearchPath({
|
|
41
46
|
term: suggestion,
|
|
42
|
-
sort
|
|
47
|
+
sort,
|
|
43
48
|
})
|
|
44
49
|
),
|
|
45
50
|
}}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { SearchEvent, SearchState } from '@faststore/sdk'
|
|
2
2
|
import { sendAnalyticsEvent } from '@faststore/sdk'
|
|
3
|
+
|
|
3
4
|
import type {
|
|
4
5
|
SearchInputFieldProps as UISearchInputFieldProps,
|
|
5
6
|
SearchInputFieldRef as UISearchInputFieldRef,
|
|
@@ -133,7 +134,7 @@ const SearchInput = forwardRef<SearchInputRef, SearchInputProps>(
|
|
|
133
134
|
|
|
134
135
|
{searchDropdownVisible && (
|
|
135
136
|
<Suspense fallback={null}>
|
|
136
|
-
<SearchDropdown sort={sort} />
|
|
137
|
+
<SearchDropdown sort={sort as SearchState['sort']} />
|
|
137
138
|
</Suspense>
|
|
138
139
|
)}
|
|
139
140
|
</UISearchInput>
|
|
@@ -27,13 +27,18 @@ export interface SortProps {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
type SortOptionKeys = keyof SortProps['options']
|
|
31
|
+
|
|
30
32
|
function Sort({ label = 'Sort by', options = OptionsMap }: SortProps) {
|
|
31
33
|
const { state, setState } = useSearch()
|
|
32
34
|
|
|
33
|
-
const optionsMap = Object.keys(options).reduce(
|
|
34
|
-
acc
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
const optionsMap = Object.keys(options).reduce(
|
|
36
|
+
(acc, currentKey: SortOptionKeys) => {
|
|
37
|
+
acc[currentKey] = options[currentKey] ?? OptionsMap[currentKey]
|
|
38
|
+
return acc
|
|
39
|
+
},
|
|
40
|
+
{} as Record<SortOptionKeys, string>
|
|
41
|
+
)
|
|
37
42
|
|
|
38
43
|
return (
|
|
39
44
|
<SelectField
|
|
@@ -12,6 +12,8 @@ import {
|
|
|
12
12
|
IconButton as UIIconButton,
|
|
13
13
|
} from '@faststore/ui'
|
|
14
14
|
|
|
15
|
+
import { ButtonSignIn } from 'src/components/ui/Button'
|
|
16
|
+
|
|
15
17
|
export const NavbarDefaultComponents = {
|
|
16
18
|
Navbar: UINavbar,
|
|
17
19
|
NavbarLinks: UINavbarLinks,
|
|
@@ -24,4 +26,5 @@ export const NavbarDefaultComponents = {
|
|
|
24
26
|
NavbarRow: UINavbarRow,
|
|
25
27
|
NavbarButtons: UINavbarButtons,
|
|
26
28
|
IconButton: UIIconButton,
|
|
29
|
+
_experimentalButtonSignIn: ButtonSignIn,
|
|
27
30
|
} as const
|
|
@@ -100,7 +100,7 @@ export const getLandingPageBySlug = async (
|
|
|
100
100
|
try {
|
|
101
101
|
if (storeConfig.cms.data) {
|
|
102
102
|
const cmsData = JSON.parse(storeConfig.cms.data)
|
|
103
|
-
const pageBySlug = cmsData['landingPage'].find((page) => {
|
|
103
|
+
const pageBySlug = cmsData['landingPage'].find((page: any) => {
|
|
104
104
|
slug === page.settings?.seo?.slug
|
|
105
105
|
})
|
|
106
106
|
|
|
@@ -47,7 +47,7 @@ const COMPONENTS: Record<string, ComponentType<any>> = {
|
|
|
47
47
|
|
|
48
48
|
// Array merging strategy from deepmerge that makes client arrays overwrite server array
|
|
49
49
|
// https://www.npmjs.com/package/deepmerge
|
|
50
|
-
const overwriteMerge = (_, sourceArray) => sourceArray
|
|
50
|
+
const overwriteMerge = (_: any[], sourceArray: any[]) => sourceArray
|
|
51
51
|
|
|
52
52
|
export default function ProductListing({
|
|
53
53
|
page: { sections, settings },
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import storeConfig from 'faststore.config'
|
|
2
|
+
import { ImageLoaderProps } from 'next/image'
|
|
2
3
|
const THUMBOR_SERVER = `https://${storeConfig.api.storeId}.vtexassets.com`
|
|
3
4
|
|
|
4
|
-
export default function customImageLoader({
|
|
5
|
+
export default function customImageLoader({
|
|
6
|
+
src,
|
|
7
|
+
width,
|
|
8
|
+
quality,
|
|
9
|
+
}: ImageLoaderProps) {
|
|
5
10
|
const preSizeComponents = [THUMBOR_SERVER, 'unsafe']
|
|
6
11
|
|
|
7
12
|
// proportional to the width, enter a height of 0,
|
|
@@ -5,7 +5,13 @@ import { useRouter } from 'next/router'
|
|
|
5
5
|
import type { ImageGalleryProps as UIImageGalleryProps } from '@faststore/ui'
|
|
6
6
|
import { useOverrideComponents } from 'src/sdk/overrides/OverrideContext'
|
|
7
7
|
|
|
8
|
-
const ImageComponent = ({
|
|
8
|
+
const ImageComponent = ({
|
|
9
|
+
url,
|
|
10
|
+
alternateName,
|
|
11
|
+
}: {
|
|
12
|
+
url: string
|
|
13
|
+
alternateName?: string
|
|
14
|
+
}) => {
|
|
9
15
|
const { __experimentalImageGalleryImage: Image } =
|
|
10
16
|
useOverrideComponents<'ProductDetails'>()
|
|
11
17
|
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
*
|
|
14
14
|
* This is a limitation not only for this component, but for every native & custom component that makes use of Rich Text.
|
|
15
15
|
*/
|
|
16
|
+
|
|
17
|
+
// @ts-ignore motivation: cannot find the draftjs-to-html package types.
|
|
16
18
|
import draftToHtml from 'draftjs-to-html'
|
|
17
19
|
import { NewsletterAddendum as UINewsletterAddendum } from '@faststore/ui'
|
|
18
20
|
import type { NewsletterAddendumProps as UINewsletterAddendumProps } from '@faststore/ui'
|
|
@@ -38,3 +38,4 @@ export { useShippingSimulation as useShippingSimulation_unstable } from '../../s
|
|
|
38
38
|
export { Image as Image_unstable } from '../../src/components/ui/Image'
|
|
39
39
|
export { ProfileChallenge as ProfileChallenge_unstable } from '../../src/components/auth/ProfileChallenge'
|
|
40
40
|
export { default as Selectors_unstable } from '../../src/components/ui/SkuSelector'
|
|
41
|
+
export { ButtonSignIn as ButtonSignIn_unstable } from '../../src/components/ui/Button'
|
package/src/pages/[slug]/p.tsx
CHANGED
|
@@ -63,7 +63,7 @@ type Props = PDPContentType & {
|
|
|
63
63
|
|
|
64
64
|
// Array merging strategy from deepmerge that makes client arrays overwrite server array
|
|
65
65
|
// https://www.npmjs.com/package/deepmerge
|
|
66
|
-
const overwriteMerge = (_, sourceArray) => sourceArray
|
|
66
|
+
const overwriteMerge = (_: any[], sourceArray: any[]) => sourceArray
|
|
67
67
|
|
|
68
68
|
function Page({ data: server, sections, globalSections, offers, meta }: Props) {
|
|
69
69
|
const { product } = server
|
|
@@ -11,7 +11,7 @@ if (typeof window !== 'undefined') {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
const AnalyticsHandler = () => {
|
|
14
|
+
const AnalyticsHandler = (): null => {
|
|
15
15
|
useAnalyticsEvent((event: AnalyticsEvent) => {
|
|
16
16
|
// Cleans the ecommerce object before pushing a new one
|
|
17
17
|
// This prevents the new data from getting merged with the previous one
|
|
@@ -15,8 +15,20 @@ if (typeof window !== 'undefined') {
|
|
|
15
15
|
window.setInterval(() => setReloads(0), 30e3)
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
interface ErrorBoundaryProps {
|
|
19
|
+
children: ReactNode
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface ErrorBoundaryState {
|
|
23
|
+
hasError: Boolean
|
|
24
|
+
error: Error | null
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryState> {
|
|
28
|
+
public state: ErrorBoundaryState = {
|
|
29
|
+
hasError: false,
|
|
30
|
+
error: null,
|
|
31
|
+
}
|
|
20
32
|
|
|
21
33
|
public static getDerivedStateFromError(error: Error) {
|
|
22
34
|
return {
|
|
@@ -7,6 +7,9 @@ import type {
|
|
|
7
7
|
|
|
8
8
|
import type { SectionsOverrides } from '../../typings/overrides'
|
|
9
9
|
|
|
10
|
+
/* TODO: Fix typescript errors. It is necessary to further investigate the typing
|
|
11
|
+
issues of this file. Error lines have been marked with the @ts-ignore comment*/
|
|
12
|
+
|
|
10
13
|
export function getSectionOverrides<
|
|
11
14
|
SectionName extends keyof SectionsOverrides
|
|
12
15
|
>(
|
|
@@ -15,38 +18,45 @@ export function getSectionOverrides<
|
|
|
15
18
|
): OverriddenComponents<SectionName> {
|
|
16
19
|
const overriddenComponents = {} as OverriddenComponents<SectionName>
|
|
17
20
|
|
|
18
|
-
Object.entries(defaultComponents).forEach(
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
21
|
+
Object.entries<React.ComponentType>(defaultComponents).forEach(
|
|
22
|
+
([key, value]) => {
|
|
23
|
+
const componentOverride:
|
|
24
|
+
| ComponentOverrideDefinition<React.ComponentType, unknown>
|
|
25
|
+
| undefined =
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
override.components?.[key]
|
|
28
|
+
|
|
29
|
+
if (!componentOverride) {
|
|
30
|
+
// @ts-ignore
|
|
31
|
+
overriddenComponents[key] = {
|
|
32
|
+
Component: value,
|
|
33
|
+
props: {},
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return
|
|
27
37
|
}
|
|
28
38
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
console.warn(
|
|
34
|
-
`Mixed use of Component and props overrides detected. Defaulting to Component override: component ${key} in the ${override.section} section.`
|
|
35
|
-
)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (componentOverride.Component) {
|
|
39
|
-
overriddenComponents[key] = {
|
|
40
|
-
Component: componentOverride.Component,
|
|
41
|
-
props: {},
|
|
39
|
+
if (componentOverride.Component && componentOverride.props) {
|
|
40
|
+
console.warn(
|
|
41
|
+
`Mixed use of Component and props overrides detected. Defaulting to Component override: component ${key} in the ${override.section} section.`
|
|
42
|
+
)
|
|
42
43
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
|
|
45
|
+
if (componentOverride.Component) {
|
|
46
|
+
// @ts-ignore
|
|
47
|
+
overriddenComponents[key] = {
|
|
48
|
+
Component: componentOverride.Component,
|
|
49
|
+
props: {},
|
|
50
|
+
}
|
|
51
|
+
} else {
|
|
52
|
+
// @ts-ignore
|
|
53
|
+
overriddenComponents[key] = {
|
|
54
|
+
Component: value,
|
|
55
|
+
props: componentOverride.props ?? {},
|
|
56
|
+
}
|
|
47
57
|
}
|
|
48
58
|
}
|
|
49
|
-
|
|
59
|
+
)
|
|
50
60
|
|
|
51
61
|
return overriddenComponents
|
|
52
62
|
}
|
|
@@ -7,6 +7,7 @@ import { useLocalizedVariables } from './useLocalizedVariables'
|
|
|
7
7
|
import { useSession } from 'src/sdk/session'
|
|
8
8
|
|
|
9
9
|
import type {
|
|
10
|
+
ClientManyProductsQueryQueryVariables,
|
|
10
11
|
ClientProductGalleryQueryQuery as Query,
|
|
11
12
|
ClientProductGalleryQueryQueryVariables as Variables,
|
|
12
13
|
} from '@generated/graphql'
|
|
@@ -61,12 +62,19 @@ export const fragment = gql(`
|
|
|
61
62
|
}
|
|
62
63
|
`)
|
|
63
64
|
|
|
65
|
+
type ProductGalleryQueryOptions = {
|
|
66
|
+
itemsPerPage: number
|
|
67
|
+
selectedFacets: Facet[]
|
|
68
|
+
sort: ClientManyProductsQueryQueryVariables['sort']
|
|
69
|
+
term: ClientManyProductsQueryQueryVariables['term']
|
|
70
|
+
}
|
|
71
|
+
|
|
64
72
|
export const useProductGalleryQuery = ({
|
|
65
73
|
term,
|
|
66
74
|
sort,
|
|
67
75
|
selectedFacets,
|
|
68
76
|
itemsPerPage,
|
|
69
|
-
}) => {
|
|
77
|
+
}: ProductGalleryQueryOptions) => {
|
|
70
78
|
const { locale } = useSession()
|
|
71
79
|
const { state, setState } = useSearch()
|
|
72
80
|
|
package/src/typings/overrides.ts
CHANGED
|
@@ -81,19 +81,19 @@ export type SectionOverride = {
|
|
|
81
81
|
export type OverrideComponentsForSection<
|
|
82
82
|
Section extends SectionsOverrides[keyof SectionsOverrides]['Section']
|
|
83
83
|
> = {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
84
|
+
// The first 'extends' condition is used to filter out sections that don't have overrides (typed 'never')
|
|
85
|
+
[K in keyof SectionsOverrides as SectionsOverrides[K] extends {
|
|
86
|
+
Section: never
|
|
87
|
+
}
|
|
88
88
|
? never
|
|
89
89
|
: // In the second 'extends' condition, we check if the section matches the one we're looking for
|
|
90
90
|
SectionsOverrides[K] extends {
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
Section: Section
|
|
92
|
+
}
|
|
93
93
|
? // If it does, we return the components. Otherwise, we return 'never', which is filtered out
|
|
94
|
-
|
|
94
|
+
K
|
|
95
95
|
: never]: SectionsOverrides[K]['components']
|
|
96
|
-
}
|
|
96
|
+
}
|
|
97
97
|
|
|
98
98
|
// This type is used to extract only the list of components from the section override
|
|
99
99
|
export type ComponentsFromSection<
|
|
@@ -195,6 +195,7 @@ export type SectionsOverrides = {
|
|
|
195
195
|
IconButtonProps,
|
|
196
196
|
Omit<IconButtonProps, 'onClick'>
|
|
197
197
|
>
|
|
198
|
+
_experimentalButtonSignIn: ComponentOverrideDefinition<any, any>
|
|
198
199
|
}
|
|
199
200
|
}
|
|
200
201
|
Newsletter: {
|
|
@@ -61,7 +61,7 @@ describe('Multiple page templates', () => {
|
|
|
61
61
|
})
|
|
62
62
|
|
|
63
63
|
it('should return false when the rewrites is empty array', () => {
|
|
64
|
-
const rewritesArr = []
|
|
64
|
+
const rewritesArr: Rewrite[] = []
|
|
65
65
|
const result = hasRewritesConfigForSlug({
|
|
66
66
|
rewrites: rewritesArr,
|
|
67
67
|
templateValue: '/test/my-office',
|
package/tsconfig.json
CHANGED
|
@@ -22,13 +22,14 @@
|
|
|
22
22
|
]
|
|
23
23
|
},
|
|
24
24
|
"forceConsistentCasingInFileNames": true,
|
|
25
|
-
"
|
|
25
|
+
"noImplicitAny": true,
|
|
26
26
|
"incremental": true,
|
|
27
27
|
"isolatedModules": true,
|
|
28
28
|
"target": "es5",
|
|
29
29
|
"lib": ["dom", "dom.iterable", "esnext"],
|
|
30
30
|
"skipLibCheck": true,
|
|
31
|
-
"esModuleInterop": true
|
|
31
|
+
"esModuleInterop": true,
|
|
32
|
+
"strict": false
|
|
32
33
|
},
|
|
33
34
|
"include": ["*.d.ts", "src/**/*.ts", "src/**/*.tsx", "@generated/**/*.ts"],
|
|
34
35
|
"exclude": ["node_modules", "public"]
|