@faststore/core 2.2.69 → 2.2.71
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 +62 -52
- package/.next/cache/.tsbuildinfo +1 -1
- package/.next/cache/config.json +3 -3
- package/.next/cache/eslint/.cache_1gneedd +1 -1
- package/.next/cache/next-server.js.nft.json +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.json +1 -1
- package/.next/react-loadable-manifest.json +4 -4
- package/.next/routes-manifest.json +1 -1
- package/.next/server/chunks/117.js +427 -0
- package/.next/server/chunks/184.js +61 -0
- package/.next/server/chunks/350.js +2846 -35
- package/.next/server/chunks/585.js +22 -0
- package/.next/server/chunks/632.js +514 -0
- package/.next/server/chunks/661.js +1451 -0
- package/.next/server/chunks/693.js +58 -0
- package/.next/server/chunks/719.js +84 -0
- package/.next/server/chunks/74.js +987 -6854
- package/.next/server/chunks/779.js +58 -0
- package/.next/server/chunks/854.js +72 -0
- package/.next/server/chunks/863.js +22 -0
- package/.next/server/chunks/{520.js → 898.js} +250 -30
- package/.next/server/chunks/903.js +1926 -0
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/404.js +0 -21
- package/.next/server/pages/404.js.nft.json +1 -1
- package/.next/server/pages/500.js +0 -21
- package/.next/server/pages/500.js.nft.json +1 -1
- package/.next/server/pages/[...slug].js +9 -9
- package/.next/server/pages/[...slug].js.nft.json +1 -1
- package/.next/server/pages/[slug]/p.js +1373 -33
- package/.next/server/pages/[slug]/p.js.nft.json +1 -1
- package/.next/server/pages/_app.js.nft.json +1 -1
- package/.next/server/pages/account.js +0 -21
- package/.next/server/pages/account.js.nft.json +1 -1
- package/.next/server/pages/api/graphql.js +1 -1
- package/.next/server/pages/api/graphql.js.nft.json +1 -1
- package/.next/server/pages/checkout.js +0 -21
- package/.next/server/pages/checkout.js.nft.json +1 -1
- package/.next/server/pages/en-US/404.html +2 -2
- package/.next/server/pages/en-US/500.html +2 -2
- package/.next/server/pages/en-US/account.html +2 -2
- package/.next/server/pages/en-US/checkout.html +2 -2
- package/.next/server/pages/en-US/login.html +2 -2
- package/.next/server/pages/en-US/s.html +2 -2
- package/.next/server/pages/en-US.html +2 -2
- package/.next/server/pages/index.js +5 -5
- package/.next/server/pages/index.js.nft.json +1 -1
- package/.next/server/pages/login.js +0 -21
- package/.next/server/pages/login.js.nft.json +1 -1
- package/.next/server/pages/s.js +4 -58
- package/.next/server/pages/s.js.nft.json +1 -1
- package/.next/static/IDskqcKTB7kE5quFZAhgJ/_buildManifest.js +1 -0
- package/.next/static/chunks/223-cb77217cce52d45c.js +1 -0
- package/.next/static/chunks/251.11f5198fc8bef3a4.js +1 -0
- package/.next/static/chunks/397-0d3aada1012cd78b.js +1 -0
- package/.next/static/chunks/585.6561778b7763b79e.js +1 -0
- package/.next/static/chunks/675-479a97aecebead97.js +1 -0
- package/.next/static/chunks/800.5d92de2974baf641.js +1 -0
- package/.next/static/chunks/881-57643fb90f59e576.js +1 -0
- package/.next/static/chunks/988.afda042dd9ba11d1.js +1 -0
- package/.next/static/chunks/pages/404-e106cb9a78182f5f.js +1 -0
- package/.next/static/chunks/pages/500-d28aa4a8ce88bddd.js +1 -0
- package/.next/static/chunks/pages/[...slug]-cf872b9e9befd47c.js +1 -0
- package/.next/static/chunks/pages/[slug]/p-4a75b11857b82b5c.js +1 -0
- package/.next/static/chunks/pages/{account-1963c084b0b6e597.js → account-bf9c88a9cac80d8a.js} +1 -1
- package/.next/static/chunks/pages/{checkout-d66a352e910607dd.js → checkout-6ca76c1e88a28ac4.js} +1 -1
- package/.next/static/chunks/pages/index-629ba146ae5f0ecf.js +1 -0
- package/.next/static/chunks/pages/login-d2af0de13ea75848.js +1 -0
- package/.next/static/chunks/pages/s-d729254b91430d1c.js +1 -0
- package/.next/static/chunks/webpack-54ce04ec11860b0b.js +1 -0
- package/.next/static/css/021de9c7b050d301.css +1 -0
- package/.next/static/css/510895065f32ed2f.css +1 -0
- package/.next/static/css/7e897ebb936fac09.css +1 -0
- package/.next/static/css/938781cdc945862e.css +1 -0
- package/.next/static/css/9558da13053ac066.css +1 -0
- package/.next/static/css/def381bf7c69fa2e.css +1 -0
- package/.next/trace +82 -82
- package/.turbo/turbo-build.log +19 -19
- package/.turbo/turbo-test.log +10 -10
- package/index.ts +13 -0
- package/package.json +2 -2
- package/src/components/cms/GlobalSections.tsx +1 -1
- package/src/components/navigation/Navbar/Navbar.tsx +10 -10
- package/src/components/navigation/NavbarLinks/NavbarLinks.tsx +3 -5
- package/src/components/navigation/NavbarSlider/NavbarSlider.tsx +8 -7
- package/src/components/sections/Alert/Alert.tsx +11 -3
- package/src/components/sections/Alert/OverriddenDefaultAlert.ts +7 -4
- package/src/components/sections/BannerText/BannerText.tsx +10 -2
- package/src/components/sections/BannerText/OverriddenDefaultBannerText.ts +7 -4
- package/src/components/sections/Breadcrumb/Breadcrumb.tsx +9 -3
- package/src/components/sections/Breadcrumb/OverriddenDefaultBreadcrumb.ts +7 -4
- package/src/components/sections/CrossSellingShelf/CrossSellingShelf.tsx +8 -2
- package/src/components/sections/CrossSellingShelf/OverriddenDefaultCrossSellingShelf.ts +2 -1
- package/src/components/sections/EmptyState/Overrides.tsx +2 -2
- package/src/components/sections/Hero/Hero.tsx +11 -3
- package/src/components/sections/Hero/OverriddenDefaultHero.ts +7 -4
- package/src/components/sections/Navbar/DefaultComponents.ts +27 -0
- package/src/components/sections/Navbar/Navbar.tsx +10 -2
- package/src/components/sections/Navbar/OverriddenDefaultNavbar.ts +14 -0
- package/src/components/sections/Newsletter/Newsletter.tsx +10 -2
- package/src/components/sections/Newsletter/OverriddenDefaultNewsletter.ts +6 -4
- package/src/components/sections/ProductDetails/OverriddenDefaultProductDetails.ts +7 -4
- package/src/components/sections/ProductDetails/ProductDetails.tsx +16 -8
- package/src/components/sections/ProductGallery/OverriddenDefaultProductGallery.ts +6 -4
- package/src/components/sections/ProductGallery/ProductGallery.tsx +13 -5
- package/src/components/sections/ProductShelf/OverriddenDefaultProductShelf.ts +7 -4
- package/src/components/sections/ProductShelf/ProductShelf.tsx +12 -2
- package/src/components/sections/RegionBar/OverriddenDefaultRegionBar.ts +6 -4
- package/src/components/sections/RegionBar/RegionBar.tsx +11 -5
- package/src/sdk/overrides/getOverriddenSection.tsx +45 -44
- package/src/sdk/overrides/overrides.ts +2 -2
- package/src/typings/overrides.ts +265 -186
- package/src/typings/overridesDefinition.ts +20 -6
- package/.next/server/chunks/445.js +0 -167
- package/.next/server/chunks/829.js +0 -2938
- package/.next/server/chunks/934.js +0 -125
- package/.next/static/JNkl1RxkhVPSzLAsRUxC6/_buildManifest.js +0 -1
- package/.next/static/chunks/251.65e0bb7a2f58b3db.js +0 -1
- package/.next/static/chunks/557-4f8a963d7e07e582.js +0 -1
- package/.next/static/chunks/585.ee7478bead8853ae.js +0 -1
- package/.next/static/chunks/800.8f4f91b39aa47346.js +0 -1
- package/.next/static/chunks/846-c59a0f158089800c.js +0 -1
- package/.next/static/chunks/988.a57dac6501fb5184.js +0 -1
- package/.next/static/chunks/pages/404-e44d7103a9c6781f.js +0 -1
- package/.next/static/chunks/pages/500-2ddd76fa11c851e4.js +0 -1
- package/.next/static/chunks/pages/[...slug]-f7f47afa6dce5abf.js +0 -1
- package/.next/static/chunks/pages/[slug]/p-27a9a4ef5d07a4ce.js +0 -1
- package/.next/static/chunks/pages/index-9e98f2fc42dec7c1.js +0 -1
- package/.next/static/chunks/pages/login-349e1406a3a98968.js +0 -1
- package/.next/static/chunks/pages/s-9b771eb03d589ee6.js +0 -1
- package/.next/static/chunks/webpack-3beeb2f9a51fccf6.js +0 -1
- package/.next/static/css/0c844be3b8585e70.css +0 -1
- package/.next/static/css/280c254f1f559956.css +0 -1
- package/.next/static/css/a6bcc59f42b42f36.css +0 -1
- package/.next/static/css/ecdecb8d639a8311.css +0 -1
- package/src/components/sections/Navbar/Overrides.tsx +0 -60
- package/src/sdk/overrides/sections.tsx +0 -54
- /package/.next/static/{JNkl1RxkhVPSzLAsRUxC6 → IDskqcKTB7kE5quFZAhgJ}/_ssgManifest.js +0 -0
|
@@ -4,18 +4,20 @@ import { gql } from '@faststore/graphql-utils'
|
|
|
4
4
|
import type { CurrencyCode, ViewItemEvent } from '@faststore/sdk'
|
|
5
5
|
import { sendAnalyticsEvent } from '@faststore/sdk'
|
|
6
6
|
|
|
7
|
-
import type { AnalyticsItem } from '
|
|
8
|
-
import { useFormattedPrice } from '
|
|
9
|
-
import { useSession } from '
|
|
7
|
+
import type { AnalyticsItem } from '../../../sdk/analytics/types'
|
|
8
|
+
import { useFormattedPrice } from '../../../sdk/product/useFormattedPrice'
|
|
9
|
+
import { useSession } from '../../../sdk/session'
|
|
10
10
|
|
|
11
11
|
import Section from '../Section'
|
|
12
|
-
import ProductDescription from '
|
|
13
|
-
import { ProductDetailsSettings } from '
|
|
12
|
+
import ProductDescription from '../../../components/ui/ProductDescription'
|
|
13
|
+
import { ProductDetailsSettings } from '../../../components/ui/ProductDetails'
|
|
14
14
|
|
|
15
15
|
import styles from './section.module.scss'
|
|
16
16
|
|
|
17
|
-
import { usePDP } from '
|
|
18
|
-
import { useOverrideComponents } from '
|
|
17
|
+
import { usePDP } from '../../../sdk/overrides/PageProvider'
|
|
18
|
+
import { useOverrideComponents } from '../../../sdk/overrides/OverrideContext'
|
|
19
|
+
import { ProductDetailsDefaultComponents } from './DefaultComponents'
|
|
20
|
+
import { getOverridableSection } from '../../../sdk/overrides/getOverriddenSection'
|
|
19
21
|
|
|
20
22
|
export interface ProductDetailsProps {
|
|
21
23
|
productTitle: {
|
|
@@ -280,4 +282,10 @@ export const fragment = gql`
|
|
|
280
282
|
}
|
|
281
283
|
`
|
|
282
284
|
|
|
283
|
-
|
|
285
|
+
const OverridableProductDetails = getOverridableSection<typeof ProductDetails>(
|
|
286
|
+
'ProductDetails',
|
|
287
|
+
ProductDetails,
|
|
288
|
+
ProductDetailsDefaultComponents
|
|
289
|
+
)
|
|
290
|
+
|
|
291
|
+
export default OverridableProductDetails
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { override } from 'src/customizations/src/components/overrides/ProductGallery'
|
|
2
2
|
import { getOverriddenSection } from 'src/sdk/overrides/getOverriddenSection'
|
|
3
|
-
import type {
|
|
3
|
+
import type { SectionOverrideDefinitionV1 } from 'src/typings/overridesDefinition'
|
|
4
|
+
import ProductGallery from '.'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* This component exists to support overrides 1.0
|
|
7
8
|
*
|
|
8
9
|
* This allows users to override the default ProductGallery section present in the Headless CMS
|
|
9
10
|
*/
|
|
10
|
-
export const OverriddenDefaultProductGallery = getOverriddenSection(
|
|
11
|
-
override as
|
|
12
|
-
|
|
11
|
+
export const OverriddenDefaultProductGallery = getOverriddenSection({
|
|
12
|
+
...(override as SectionOverrideDefinitionV1<'ProductGallery'>),
|
|
13
|
+
Section: ProductGallery,
|
|
14
|
+
})
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { mark } from '
|
|
1
|
+
import { mark } from '../../../sdk/tests/mark'
|
|
2
2
|
|
|
3
3
|
import ProductGallery, {
|
|
4
4
|
ProductGalleryProps,
|
|
5
|
-
} from '
|
|
5
|
+
} from '../../ui/ProductGallery/ProductGallery'
|
|
6
6
|
import Section from '../Section'
|
|
7
7
|
import type { EmptyGalleryProps } from './EmptyGallery'
|
|
8
8
|
|
|
@@ -13,8 +13,10 @@ import {
|
|
|
13
13
|
isPLP,
|
|
14
14
|
isSearchPage,
|
|
15
15
|
usePage,
|
|
16
|
-
} from '
|
|
17
|
-
import { useOverrideComponents } from '
|
|
16
|
+
} from '../../../sdk/overrides/PageProvider'
|
|
17
|
+
import { useOverrideComponents } from '../../../sdk/overrides/OverrideContext'
|
|
18
|
+
import { getOverridableSection } from '../../../sdk/overrides/getOverriddenSection'
|
|
19
|
+
import { ProductGalleryDefaultComponents } from './DefaultComponents'
|
|
18
20
|
|
|
19
21
|
export interface ProductGallerySectionProps {
|
|
20
22
|
searchTermLabel?: ProductGalleryProps['searchTermLabel']
|
|
@@ -69,4 +71,10 @@ function ProductGallerySection({
|
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
ProductGallerySection.displayName = 'ProductGallery'
|
|
72
|
-
|
|
74
|
+
const MarkedProductGallery = mark(ProductGallerySection)
|
|
75
|
+
|
|
76
|
+
const OverridableProductGallery = getOverridableSection<
|
|
77
|
+
typeof MarkedProductGallery
|
|
78
|
+
>('ProductGallery', MarkedProductGallery, ProductGalleryDefaultComponents)
|
|
79
|
+
|
|
80
|
+
export default OverridableProductGallery
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { override } from 'src/customizations/src/components/overrides/ProductShelf'
|
|
2
2
|
import { getOverriddenSection } from 'src/sdk/overrides/getOverriddenSection'
|
|
3
|
-
import
|
|
3
|
+
import ProductShelf from '.'
|
|
4
|
+
|
|
5
|
+
import type { SectionOverrideDefinitionV1 } from 'src/typings/overridesDefinition'
|
|
4
6
|
|
|
5
7
|
/**
|
|
6
8
|
* This component exists to support overrides 1.0
|
|
7
9
|
*
|
|
8
10
|
* This allows users to override the default ProductShelf section present in the Headless CMS
|
|
9
11
|
*/
|
|
10
|
-
export const OverriddenDefaultProductShelf = getOverriddenSection(
|
|
11
|
-
override as
|
|
12
|
-
|
|
12
|
+
export const OverriddenDefaultProductShelf = getOverriddenSection({
|
|
13
|
+
...(override as SectionOverrideDefinitionV1<'ProductShelf'>),
|
|
14
|
+
Section: ProductShelf,
|
|
15
|
+
})
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { useInView } from 'react-intersection-observer'
|
|
2
2
|
import Section from '../Section'
|
|
3
3
|
|
|
4
|
-
import ProductShelf, {
|
|
4
|
+
import ProductShelf, {
|
|
5
|
+
ProductShelfProps,
|
|
6
|
+
} from '../../../components/ui/ProductShelf'
|
|
5
7
|
import styles from './section.module.scss'
|
|
8
|
+
import { ProductShelfDefaultComponents } from './DefaultComponents'
|
|
9
|
+
import { getOverridableSection } from '../../../sdk/overrides/getOverriddenSection'
|
|
6
10
|
|
|
7
11
|
function ProductShelfSection({
|
|
8
12
|
...otherProps
|
|
@@ -19,4 +23,10 @@ function ProductShelfSection({
|
|
|
19
23
|
)
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
|
|
26
|
+
const OverridableProductShelf = getOverridableSection<typeof ProductShelf>(
|
|
27
|
+
'ProductShelf',
|
|
28
|
+
ProductShelfSection,
|
|
29
|
+
ProductShelfDefaultComponents
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
export default OverridableProductShelf
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { override } from 'src/customizations/src/components/overrides/RegionBar'
|
|
2
2
|
import { getOverriddenSection } from 'src/sdk/overrides/getOverriddenSection'
|
|
3
|
-
import type {
|
|
3
|
+
import type { SectionOverrideDefinitionV1 } from 'src/typings/overridesDefinition'
|
|
4
|
+
import RegionBar from '.'
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* This component exists to support overrides 1.0
|
|
7
8
|
*
|
|
8
9
|
* This allows users to override the default RegionBar section present in the Headless CMS
|
|
9
10
|
*/
|
|
10
|
-
export const OverriddenDefaultRegionBar = getOverriddenSection(
|
|
11
|
-
override as
|
|
12
|
-
|
|
11
|
+
export const OverriddenDefaultRegionBar = getOverriddenSection({
|
|
12
|
+
...(override as SectionOverrideDefinitionV1<'RegionBar'>),
|
|
13
|
+
Section: RegionBar,
|
|
14
|
+
})
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import RegionBar, {
|
|
2
|
-
|
|
3
|
-
} from 'src/components/region/RegionBar/RegionBar'
|
|
4
|
-
import Section from 'src/components/sections/Section/Section'
|
|
1
|
+
import RegionBar, { RegionBarProps } from '../../region/RegionBar/RegionBar'
|
|
2
|
+
import Section from '../Section/Section'
|
|
5
3
|
import styles from './section.module.scss'
|
|
4
|
+
import { RegionBarDefaultComponents } from './DefaultComponents'
|
|
5
|
+
import { getOverridableSection } from '../../..//sdk/overrides/getOverriddenSection'
|
|
6
6
|
|
|
7
7
|
type RegionBarSectionProps = {
|
|
8
8
|
/**
|
|
@@ -38,4 +38,10 @@ function RegionBarSection({
|
|
|
38
38
|
)
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
const OverridableRegionBar = getOverridableSection<typeof RegionBarSection>(
|
|
42
|
+
'RegionBar',
|
|
43
|
+
RegionBarSection,
|
|
44
|
+
RegionBarDefaultComponents
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
export default OverridableRegionBar
|
|
@@ -1,44 +1,52 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { useMemo, type ComponentProps, type ComponentType } from 'react'
|
|
2
2
|
|
|
3
|
-
import { OverrideProvider } from './OverrideContext'
|
|
4
|
-
import { DefaultComponents, Sections } from './sections'
|
|
5
|
-
import { getSectionOverrides } from './overrides'
|
|
6
3
|
import type {
|
|
7
4
|
DefaultSectionComponentsDefinitions,
|
|
8
|
-
OverriddenComponents,
|
|
9
5
|
SectionOverrideDefinition,
|
|
6
|
+
SectionOverrideDefinitionV1,
|
|
10
7
|
} from '../../typings/overridesDefinition'
|
|
11
|
-
import type {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* This function adds OverrideContext to the tree. It is essential for the compatible sections
|
|
15
|
-
* to consume the components it provides.
|
|
16
|
-
*/
|
|
17
|
-
function createOverriddenSection<
|
|
18
|
-
SectionName extends keyof SupportedSectionsOverridesV2
|
|
19
|
-
>({
|
|
20
|
-
Section,
|
|
21
|
-
sectionOverrides,
|
|
22
|
-
className,
|
|
23
|
-
}: {
|
|
24
|
-
Section: (typeof Sections)[SectionName]
|
|
25
|
-
sectionOverrides: OverriddenComponents<SectionName>
|
|
26
|
-
className?: string
|
|
27
|
-
}) {
|
|
28
|
-
const overrideContextValue = { className, components: sectionOverrides }
|
|
8
|
+
import type { SectionsOverrides } from '../../typings/overrides'
|
|
9
|
+
import { getSectionOverrides } from './overrides'
|
|
10
|
+
import { OverrideProvider } from './OverrideContext'
|
|
29
11
|
|
|
30
|
-
|
|
31
|
-
|
|
12
|
+
export function getOverridableSection<
|
|
13
|
+
Section extends ComponentType,
|
|
14
|
+
SectionName extends keyof SectionsOverrides = keyof SectionsOverrides
|
|
15
|
+
>(
|
|
16
|
+
sectionName: SectionName,
|
|
17
|
+
Section: Section,
|
|
18
|
+
defaultComponents: DefaultSectionComponentsDefinitions<SectionName>
|
|
19
|
+
) {
|
|
20
|
+
function OverridableSection(
|
|
21
|
+
propsWithOverrides: ComponentProps<typeof Section> & {
|
|
22
|
+
__overrides?: Omit<SectionOverrideDefinitionV1<SectionName>, 'Section'>
|
|
23
|
+
}
|
|
32
24
|
) {
|
|
25
|
+
const { __overrides: overrides, ...props } = propsWithOverrides
|
|
26
|
+
|
|
27
|
+
const overrideContextValue = useMemo(
|
|
28
|
+
() => ({
|
|
29
|
+
...(overrides ?? {}),
|
|
30
|
+
components: getSectionOverrides<SectionName>(defaultComponents, {
|
|
31
|
+
...(overrides ?? {}),
|
|
32
|
+
section: sectionName,
|
|
33
|
+
}),
|
|
34
|
+
}),
|
|
35
|
+
[overrides]
|
|
36
|
+
)
|
|
37
|
+
|
|
33
38
|
/** This type wizardry is here because the props won't behave correctly if nothing is done */
|
|
34
|
-
const SectionComponent = Section as ComponentType<
|
|
39
|
+
const SectionComponent = Section as ComponentType<ComponentProps<Section>>
|
|
35
40
|
|
|
36
41
|
return (
|
|
37
42
|
<OverrideProvider value={overrideContextValue}>
|
|
38
|
-
<SectionComponent {...props} />
|
|
43
|
+
<SectionComponent {...(props as ComponentProps<typeof Section>)} />
|
|
39
44
|
</OverrideProvider>
|
|
40
45
|
)
|
|
41
46
|
}
|
|
47
|
+
|
|
48
|
+
// This type cast is here so the symbol prop doesn't show up in the type definition
|
|
49
|
+
return OverridableSection as Section
|
|
42
50
|
}
|
|
43
51
|
|
|
44
52
|
/**
|
|
@@ -50,23 +58,16 @@ function createOverriddenSection<
|
|
|
50
58
|
* @see https://www.faststore.dev/docs/building-sections/overriding-components-and-props
|
|
51
59
|
*/
|
|
52
60
|
export function getOverriddenSection<
|
|
53
|
-
|
|
54
|
-
>(override: SectionOverrideDefinition<
|
|
55
|
-
const
|
|
56
|
-
override.section
|
|
57
|
-
] as DefaultSectionComponentsDefinitions<SectionName>
|
|
61
|
+
Section extends SectionsOverrides[keyof SectionsOverrides]['Section']
|
|
62
|
+
>(override: SectionOverrideDefinition<Section>) {
|
|
63
|
+
const { Section, ...rest } = override
|
|
58
64
|
|
|
59
|
-
if
|
|
60
|
-
|
|
61
|
-
`Section ${override.section} does not exist. Please provide a valid section name to override.`
|
|
62
|
-
)
|
|
63
|
-
}
|
|
65
|
+
/** This type wizardry is here because the props won't behave correctly if nothing is done */
|
|
66
|
+
const OverridableSection = Section as ComponentType<ComponentProps<Section>>
|
|
64
67
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
className: override.className,
|
|
71
|
-
})
|
|
68
|
+
return function OverriddenSection(
|
|
69
|
+
props: ComponentProps<typeof OverridableSection>
|
|
70
|
+
) {
|
|
71
|
+
return <OverridableSection {...props} {...{ __overrides: rest }} />
|
|
72
|
+
}
|
|
72
73
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
DefaultSectionComponentsDefinitions,
|
|
3
3
|
ComponentOverrideDefinition,
|
|
4
|
-
SectionOverrideDefinition,
|
|
5
4
|
OverriddenComponents,
|
|
5
|
+
SectionOverrideDefinitionV1,
|
|
6
6
|
} from '../../typings/overridesDefinition'
|
|
7
7
|
|
|
8
8
|
import type { SectionsOverrides } from '../../typings/overrides'
|
|
@@ -11,7 +11,7 @@ export function getSectionOverrides<
|
|
|
11
11
|
SectionName extends keyof SectionsOverrides
|
|
12
12
|
>(
|
|
13
13
|
defaultComponents: DefaultSectionComponentsDefinitions<SectionName>,
|
|
14
|
-
override:
|
|
14
|
+
override: SectionOverrideDefinitionV1<SectionName>
|
|
15
15
|
): OverriddenComponents<SectionName> {
|
|
16
16
|
const overriddenComponents = {} as OverriddenComponents<SectionName>
|
|
17
17
|
|