@faststore/core 2.1.93 → 2.1.95
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 +33 -33
- 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/routes-manifest.json +1 -1
- package/.next/server/chunks/350.js +1 -1
- package/.next/server/chunks/574.js +42 -23
- package/.next/server/chunks/71.js +0 -2
- package/.next/server/chunks/74.js +31 -9
- package/.next/server/chunks/907.js +25 -3
- package/.next/server/chunks/933.js +7 -3
- package/.next/server/chunks/98.js +42 -23
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/[slug]/p.js +28 -14
- package/.next/server/pages/api/graphql.js +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-manifest.json +4 -4
- package/.next/static/chunks/238-2ad31f382e7c6f14.js +1 -0
- package/.next/static/chunks/243-8c394e91ccf75fdb.js +1 -0
- package/.next/static/chunks/{574.d13dd0afe15cd635.js → 574.70612be06fd1365f.js} +1 -1
- package/.next/static/chunks/{603-d1c069aa8a349c86.js → 603-be78b9dfb8fa6c49.js} +1 -1
- package/.next/static/chunks/98.40c7e17d9de4eb8f.js +1 -0
- package/.next/static/chunks/pages/[slug]/{p-9e2aae53cf59dd99.js → p-3383e9b97bffafdd.js} +1 -1
- package/.next/static/chunks/pages/s-1f885639c2605ace.js +1 -0
- package/.next/static/chunks/{webpack-8e4905e5f03f2234.js → webpack-6580be4a27ecdd75.js} +1 -1
- package/.next/static/css/{20e4a3a45cdd65f4.css → 373ae96b742c3694.css} +1 -1
- package/.next/static/css/{3f6300dff11030c5.css → 7ca374e5534a3f68.css} +1 -1
- package/.next/static/{CLTJdyHdlxA10PF9e-xnr → ziUh67NXJKKH4lkHTrbrJ}/_buildManifest.js +1 -1
- package/.next/trace +80 -80
- package/.turbo/turbo-build.log +5 -5
- package/@generated/graphql/index.ts +8 -0
- package/@generated/graphql/persisted.json +3 -3
- package/package.json +4 -4
- package/src/components/sections/ProductGallery/useGalleryQuery.ts +31 -2
- package/src/components/ui/ProductDetails/ProductDetailsSettings.tsx +42 -23
- package/src/sdk/analytics/platform/vtex/search.ts +53 -21
- package/src/sdk/analytics/types.ts +14 -0
- package/src/sdk/search/useSuggestions.ts +41 -7
- package/.next/static/chunks/238-e5e4b2094f0e1df8.js +0 -1
- package/.next/static/chunks/243-df6d1b248f7b4d3c.js +0 -1
- package/.next/static/chunks/98.1632997dfd4d3a52.js +0 -1
- package/.next/static/chunks/pages/s-0e516ab36bb49c99.js +0 -1
- /package/.next/static/{CLTJdyHdlxA10PF9e-xnr → ziUh67NXJKKH4lkHTrbrJ}/_ssgManifest.js +0 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -23,10 +23,10 @@ info - Finalizing page optimization...
|
|
|
23
23
|
Route (pages) Size First Load JS
|
|
24
24
|
┌ ● / 3.16 kB 197 kB
|
|
25
25
|
├ /_app 0 B 77.9 kB
|
|
26
|
-
├ ● /[...slug] 4.06 kB
|
|
26
|
+
├ ● /[...slug] 4.06 kB 209 kB
|
|
27
27
|
├ └ css/527e334fa69cf40a.css 1.85 kB
|
|
28
|
-
├ ● /[slug]/p 10.5 kB
|
|
29
|
-
├ └ css/
|
|
28
|
+
├ ● /[slug]/p 10.5 kB 205 kB
|
|
29
|
+
├ └ css/7ca374e5534a3f68.css 11.3 kB
|
|
30
30
|
├ ○ /404 1.19 kB 114 kB
|
|
31
31
|
├ ● /500 1.21 kB 114 kB
|
|
32
32
|
├ ● /account 670 B 113 kB
|
|
@@ -36,12 +36,12 @@ Route (pages) Size First Load JS
|
|
|
36
36
|
├ λ /api/preview 0 B 77.9 kB
|
|
37
37
|
├ ● /checkout 657 B 113 kB
|
|
38
38
|
├ ● /login 1.09 kB 114 kB
|
|
39
|
-
└ ● /s 4.
|
|
39
|
+
└ ● /s 4.6 kB 128 kB
|
|
40
40
|
+ First Load JS shared by all 81 kB
|
|
41
41
|
├ chunks/framework-dfd14d7ce6600b03.js 45.3 kB
|
|
42
42
|
├ chunks/main-fd466221927468fd.js 23.9 kB
|
|
43
43
|
├ chunks/pages/_app-6d0e6ab9a4dd8106.js 6.45 kB
|
|
44
|
-
├ chunks/webpack-
|
|
44
|
+
├ chunks/webpack-6580be4a27ecdd75.js 2.29 kB
|
|
45
45
|
└ css/9e76fef1c9ca89af.css 3.06 kB
|
|
46
46
|
|
|
47
47
|
λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
|
|
@@ -1058,6 +1058,11 @@ export type ProductDetailsFragment_ProductFragment = {
|
|
|
1058
1058
|
}>
|
|
1059
1059
|
}
|
|
1060
1060
|
|
|
1061
|
+
export type SearchEvent_MetadataFragment = {
|
|
1062
|
+
isTermMisspelled: boolean
|
|
1063
|
+
logicalOperator: string
|
|
1064
|
+
}
|
|
1065
|
+
|
|
1061
1066
|
export type ProductGalleryQueryQueryVariables = Exact<{
|
|
1062
1067
|
first: Scalars['Int']
|
|
1063
1068
|
after: Scalars['String']
|
|
@@ -1089,6 +1094,7 @@ export type ProductGalleryQueryQuery = {
|
|
|
1089
1094
|
max: { selected: number; absolute: number }
|
|
1090
1095
|
}
|
|
1091
1096
|
>
|
|
1097
|
+
metadata: { isTermMisspelled: boolean; logicalOperator: string } | null
|
|
1092
1098
|
}
|
|
1093
1099
|
}
|
|
1094
1100
|
|
|
@@ -1371,6 +1377,8 @@ export type SearchSuggestionsQueryQuery = {
|
|
|
1371
1377
|
}
|
|
1372
1378
|
}>
|
|
1373
1379
|
}
|
|
1380
|
+
products: { pageInfo: { totalCount: number } }
|
|
1381
|
+
metadata: { isTermMisspelled: boolean; logicalOperator: string } | null
|
|
1374
1382
|
}
|
|
1375
1383
|
}
|
|
1376
1384
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"ProductGalleryQuery": "query ProductGalleryQuery($first: Int!, $after: String!, $sort: StoreSort!, $term: String!, $selectedFacets: [IStoreSelectedFacet!]!) {\n search(\n first: $first\n after: $after\n sort: $sort\n term: $term\n selectedFacets: $selectedFacets\n ) {\n products {\n pageInfo {\n totalCount\n }\n }\n facets {\n ... on StoreFacetRange {\n key\n label\n min {\n selected\n absolute\n }\n max {\n selected\n absolute\n }\n __typename\n }\n ... on StoreFacetBoolean {\n key\n label\n values {\n label\n value\n selected\n quantity\n }\n __typename\n }\n }\n }\n}\n",
|
|
2
|
+
"ProductGalleryQuery": "query ProductGalleryQuery($first: Int!, $after: String!, $sort: StoreSort!, $term: String!, $selectedFacets: [IStoreSelectedFacet!]!) {\n search(\n first: $first\n after: $after\n sort: $sort\n term: $term\n selectedFacets: $selectedFacets\n ) {\n products {\n pageInfo {\n totalCount\n }\n }\n facets {\n ... on StoreFacetRange {\n key\n label\n min {\n selected\n absolute\n }\n max {\n selected\n absolute\n }\n __typename\n }\n ... on StoreFacetBoolean {\n key\n label\n values {\n label\n value\n selected\n quantity\n }\n __typename\n }\n }\n metadata {\n isTermMisspelled\n logicalOperator\n }\n }\n}\n",
|
|
3
3
|
"ServerCollectionPageQuery": "query ServerCollectionPageQuery($slug: String!) {\n collection(slug: $slug) {\n seo {\n title\n description\n }\n breadcrumbList {\n itemListElement {\n item\n name\n position\n }\n }\n meta {\n selectedFacets {\n key\n value\n }\n }\n }\n}\n",
|
|
4
4
|
"ServerProductPageQuery": "query ServerProductPageQuery($slug: String!) {\n product(locator: [{key: \"slug\", value: $slug}]) {\n id: productID\n seo {\n title\n description\n canonical\n }\n brand {\n name\n }\n sku\n gtin\n name\n description\n releaseDate\n breadcrumbList {\n itemListElement {\n item\n name\n position\n }\n }\n image {\n url\n alternateName\n }\n offers {\n lowPrice\n highPrice\n priceCurrency\n offers {\n availability\n price\n priceValidUntil\n priceCurrency\n itemCondition\n seller {\n identifier\n }\n listPrice\n }\n }\n isVariantOf {\n productGroupID\n name\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n}\n",
|
|
5
5
|
"ValidateCartMutation": "mutation ValidateCartMutation($cart: IStoreCart!, $session: IStoreSession!) {\n validateCart(cart: $cart, session: $session) {\n order {\n orderNumber\n acceptedOffer {\n seller {\n identifier\n }\n quantity\n price\n listPrice\n itemOffered {\n sku\n name\n image {\n url\n alternateName\n }\n brand {\n name\n }\n isVariantOf {\n productGroupID\n name\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n gtin\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n }\n }\n messages {\n text\n status\n }\n }\n}\n",
|
|
6
6
|
"SubscribeToNewsletter": "mutation SubscribeToNewsletter($data: IPersonNewsletter!) {\n subscribeToNewsletter(data: $data) {\n id\n }\n}\n",
|
|
7
|
-
"BrowserProductQuery": "query BrowserProductQuery($locator: [IStoreSelectedFacet!]!) {\n product(locator: $locator) {\n id: productID\n sku\n name\n gtin\n description\n isVariantOf {\n name\n productGroupID\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n image {\n url\n alternateName\n }\n brand {\n name\n }\n offers {\n lowPrice\n offers {\n availability\n price\n listPrice\n seller {\n identifier\n }\n }\n }\n
|
|
7
|
+
"BrowserProductQuery": "query BrowserProductQuery($locator: [IStoreSelectedFacet!]!) {\n product(locator: $locator) {\n id: productID\n sku\n name\n gtin\n description\n isVariantOf {\n name\n productGroupID\n skuVariants {\n activeVariations\n slugsMap\n availableVariations\n }\n }\n image {\n url\n alternateName\n }\n brand {\n name\n }\n offers {\n lowPrice\n offers {\n availability\n price\n listPrice\n seller {\n identifier\n }\n }\n }\n additionalProperty {\n propertyID\n name\n value\n valueReference\n }\n }\n}\n",
|
|
8
8
|
"ProductsQuery": "query ProductsQuery($first: Int!, $after: String, $sort: StoreSort!, $term: String!, $selectedFacets: [IStoreSelectedFacet!]!) {\n search(\n first: $first\n after: $after\n sort: $sort\n term: $term\n selectedFacets: $selectedFacets\n ) {\n products {\n pageInfo {\n totalCount\n }\n edges {\n node {\n id: productID\n slug\n sku\n brand {\n brandName: name\n name\n }\n name\n gtin\n isVariantOf {\n productGroupID\n name\n }\n image {\n url\n alternateName\n }\n offers {\n lowPrice\n offers {\n availability\n price\n listPrice\n quantity\n seller {\n identifier\n }\n }\n }\n }\n }\n }\n }\n}\n",
|
|
9
|
-
"SearchSuggestionsQuery": "query SearchSuggestionsQuery($term: String!, $selectedFacets: [IStoreSelectedFacet!]) {\n search(first: 5, term: $term, selectedFacets: $selectedFacets) {\n suggestions {\n terms {\n value\n }\n products {\n id: productID\n slug\n sku\n brand {\n brandName: name\n name\n }\n name\n gtin\n isVariantOf {\n productGroupID\n name\n }\n image {\n url\n alternateName\n }\n offers {\n lowPrice\n offers {\n availability\n price\n listPrice\n quantity\n seller {\n identifier\n }\n }\n }\n }\n }\n }\n}\n",
|
|
9
|
+
"SearchSuggestionsQuery": "query SearchSuggestionsQuery($term: String!, $selectedFacets: [IStoreSelectedFacet!]) {\n search(first: 5, term: $term, selectedFacets: $selectedFacets) {\n suggestions {\n terms {\n value\n }\n products {\n id: productID\n slug\n sku\n brand {\n brandName: name\n name\n }\n name\n gtin\n isVariantOf {\n productGroupID\n name\n }\n image {\n url\n alternateName\n }\n offers {\n lowPrice\n offers {\n availability\n price\n listPrice\n quantity\n seller {\n identifier\n }\n }\n }\n }\n }\n products {\n pageInfo {\n totalCount\n }\n }\n metadata {\n isTermMisspelled\n logicalOperator\n }\n }\n}\n",
|
|
10
10
|
"TopSearchSuggestionsQuery": "query TopSearchSuggestionsQuery($term: String!, $selectedFacets: [IStoreSelectedFacet!]) {\n search(first: 5, term: $term, selectedFacets: $selectedFacets) {\n suggestions {\n terms {\n value\n }\n }\n }\n}\n",
|
|
11
11
|
"ValidateSession": "mutation ValidateSession($session: IStoreSession!, $search: String!) {\n validateSession(session: $session, search: $search) {\n locale\n channel\n country\n addressType\n postalCode\n deliveryMode {\n deliveryChannel\n deliveryMethod\n deliveryWindow {\n startDate\n endDate\n }\n }\n geoCoordinates {\n latitude\n longitude\n }\n currency {\n code\n symbol\n }\n person {\n id\n email\n givenName\n familyName\n }\n }\n}\n",
|
|
12
12
|
"ShippingSimulationQuery": "query ShippingSimulationQuery($postalCode: String!, $country: String!, $items: [IShippingItem!]!) {\n shipping(items: $items, postalCode: $postalCode, country: $country) {\n logisticsInfo {\n slas {\n carrier\n price\n availableDeliveryWindows {\n startDateUtc\n endDateUtc\n price\n listPrice\n }\n shippingEstimate\n localizedEstimates\n }\n }\n address {\n city\n neighborhood\n }\n }\n}\n"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faststore/core",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.95",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"browserslist": "supports es6-module and not dead",
|
|
6
6
|
"scripts": {
|
|
@@ -30,10 +30,10 @@
|
|
|
30
30
|
"@envelop/parser-cache": "^2.2.0",
|
|
31
31
|
"@envelop/validation-cache": "^2.2.0",
|
|
32
32
|
"@faststore/api": "^2.1.90",
|
|
33
|
-
"@faststore/components": "^2.1.
|
|
33
|
+
"@faststore/components": "^2.1.94",
|
|
34
34
|
"@faststore/graphql-utils": "^2.1.82",
|
|
35
35
|
"@faststore/sdk": "^2.1.82",
|
|
36
|
-
"@faststore/ui": "^2.1.
|
|
36
|
+
"@faststore/ui": "^2.1.94",
|
|
37
37
|
"@types/react": "^18.0.14",
|
|
38
38
|
"@vtex/client-cms": "^0.2.12",
|
|
39
39
|
"autoprefixer": "^10.4.0",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"msw": {
|
|
111
111
|
"workerDirectory": "public"
|
|
112
112
|
},
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "9447859539b322b297c940c7a8a4769c5097f2ac"
|
|
114
114
|
}
|
|
@@ -1,19 +1,27 @@
|
|
|
1
|
-
import { useSearch } from '@faststore/sdk'
|
|
1
|
+
import { sendAnalyticsEvent, useSearch } from '@faststore/sdk'
|
|
2
2
|
import { gql } from '@faststore/graphql-utils'
|
|
3
3
|
|
|
4
4
|
import { useQuery } from 'src/sdk/graphql/useQuery'
|
|
5
|
+
|
|
5
6
|
import type {
|
|
6
7
|
ProductGalleryQueryQuery as Query,
|
|
7
8
|
ProductGalleryQueryQueryVariables as Variables,
|
|
8
9
|
} from '@generated/graphql'
|
|
10
|
+
import type { IntelligentSearchQueryEvent } from 'src/sdk/analytics/types'
|
|
9
11
|
|
|
10
12
|
import { useLocalizedVariables } from '../../../sdk/product/useProductsQuery'
|
|
13
|
+
import { useSession } from 'src/sdk/session'
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* This query is run on the browser and contains
|
|
14
17
|
* the current search state of the user
|
|
15
18
|
*/
|
|
16
19
|
export const query = gql`
|
|
20
|
+
fragment SearchEvent_metadata on SearchMetadata {
|
|
21
|
+
isTermMisspelled
|
|
22
|
+
logicalOperator
|
|
23
|
+
}
|
|
24
|
+
|
|
17
25
|
query ProductGalleryQuery(
|
|
18
26
|
$first: Int!
|
|
19
27
|
$after: String!
|
|
@@ -36,6 +44,9 @@ export const query = gql`
|
|
|
36
44
|
facets {
|
|
37
45
|
...Filter_facets
|
|
38
46
|
}
|
|
47
|
+
metadata {
|
|
48
|
+
...SearchEvent_metadata
|
|
49
|
+
}
|
|
39
50
|
}
|
|
40
51
|
}
|
|
41
52
|
`
|
|
@@ -46,6 +57,8 @@ export const useGalleryQuery = () => {
|
|
|
46
57
|
itemsPerPage,
|
|
47
58
|
} = useSearch()
|
|
48
59
|
|
|
60
|
+
const { locale } = useSession()
|
|
61
|
+
|
|
49
62
|
const localizedVariables = useLocalizedVariables({
|
|
50
63
|
first: itemsPerPage,
|
|
51
64
|
after: '0',
|
|
@@ -54,5 +67,21 @@ export const useGalleryQuery = () => {
|
|
|
54
67
|
selectedFacets,
|
|
55
68
|
})
|
|
56
69
|
|
|
57
|
-
return useQuery<Query, Variables>(query, localizedVariables
|
|
70
|
+
return useQuery<Query, Variables>(query, localizedVariables, {
|
|
71
|
+
onSuccess: (data) => {
|
|
72
|
+
if (data && term) {
|
|
73
|
+
sendAnalyticsEvent<IntelligentSearchQueryEvent>({
|
|
74
|
+
name: 'intelligent_search_query',
|
|
75
|
+
params: {
|
|
76
|
+
locale,
|
|
77
|
+
term,
|
|
78
|
+
url: window.location.href,
|
|
79
|
+
logicalOperator: data.search.metadata?.logicalOperator ?? 'and',
|
|
80
|
+
isTermMisspelled: data.search.metadata?.isTermMisspelled ?? false,
|
|
81
|
+
totalCount: data.search.products.pageInfo.totalCount,
|
|
82
|
+
},
|
|
83
|
+
})
|
|
84
|
+
}
|
|
85
|
+
},
|
|
86
|
+
})
|
|
58
87
|
}
|
|
@@ -73,33 +73,52 @@ function ProductDetailsSettings({
|
|
|
73
73
|
},
|
|
74
74
|
})
|
|
75
75
|
|
|
76
|
+
const shouldShowDiscountedPrice = lowPrice !== listPrice
|
|
77
|
+
|
|
76
78
|
return (
|
|
77
79
|
<>
|
|
78
80
|
<section data-fs-product-details-values>
|
|
79
81
|
<div data-fs-product-details-prices>
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
82
|
+
{shouldShowDiscountedPrice ? (
|
|
83
|
+
<>
|
|
84
|
+
<Price.Component
|
|
85
|
+
formatter={useFormattedPrice}
|
|
86
|
+
testId="list-price"
|
|
87
|
+
variant="listing"
|
|
88
|
+
SRText="Original price:"
|
|
89
|
+
{...Price.props}
|
|
90
|
+
// Dynamic props shouldn't be overridable
|
|
91
|
+
// This decision can be reviewed later if needed
|
|
92
|
+
value={listPrice}
|
|
93
|
+
data-value={listPrice}
|
|
94
|
+
/>
|
|
95
|
+
<Price.Component
|
|
96
|
+
formatter={useFormattedPrice}
|
|
97
|
+
testId="price"
|
|
98
|
+
variant="spot"
|
|
99
|
+
className="text__lead"
|
|
100
|
+
SRText="Sale Price:"
|
|
101
|
+
{...Price.props}
|
|
102
|
+
// Dynamic props shouldn't be overridable
|
|
103
|
+
// This decision can be reviewed later if needed
|
|
104
|
+
value={lowPrice}
|
|
105
|
+
data-value={lowPrice}
|
|
106
|
+
/>
|
|
107
|
+
</>
|
|
108
|
+
) : (
|
|
109
|
+
<Price.Component
|
|
110
|
+
formatter={useFormattedPrice}
|
|
111
|
+
testId="list-price"
|
|
112
|
+
variant="spot"
|
|
113
|
+
className="text__lead"
|
|
114
|
+
SRText="Original price:"
|
|
115
|
+
{...Price.props}
|
|
116
|
+
// Dynamic props shouldn't be overridable
|
|
117
|
+
// This decision can be reviewed later if needed
|
|
118
|
+
value={lowPrice}
|
|
119
|
+
data-value={lowPrice}
|
|
120
|
+
/>
|
|
121
|
+
)}
|
|
103
122
|
</div>
|
|
104
123
|
<QuantitySelector.Component
|
|
105
124
|
min={1}
|
|
@@ -2,7 +2,10 @@
|
|
|
2
2
|
* More info at: https://www.notion.so/vtexhandbook/Event-API-Documentation-48eee26730cf4d7f80f8fd7262231f84
|
|
3
3
|
*/
|
|
4
4
|
import type { AnalyticsEvent } from '@faststore/sdk'
|
|
5
|
-
import type {
|
|
5
|
+
import type {
|
|
6
|
+
IntelligentSearchQueryEvent,
|
|
7
|
+
SearchSelectItemEvent,
|
|
8
|
+
} from '../../types'
|
|
6
9
|
|
|
7
10
|
import config from '../../../../../faststore.config'
|
|
8
11
|
import { getCookie } from '../../../../utils/getCookie'
|
|
@@ -52,6 +55,15 @@ type SearchEvent =
|
|
|
52
55
|
url: string
|
|
53
56
|
type: 'search.click'
|
|
54
57
|
}
|
|
58
|
+
| {
|
|
59
|
+
text: string
|
|
60
|
+
misspelled: boolean
|
|
61
|
+
match: number
|
|
62
|
+
operator: string
|
|
63
|
+
locale: string
|
|
64
|
+
url: string
|
|
65
|
+
type: 'search.query'
|
|
66
|
+
}
|
|
55
67
|
|
|
56
68
|
const sendEvent = (options: SearchEvent & { url?: string }) =>
|
|
57
69
|
fetch(`https://sp.vtex.com/event-api/v1/${config.api.storeId}/event`, {
|
|
@@ -71,30 +83,50 @@ const isFullTextSearch = (url: URL) =>
|
|
|
71
83
|
typeof url.searchParams.get('q') === 'string' &&
|
|
72
84
|
/^\/s(\/)?$/g.test(url.pathname)
|
|
73
85
|
|
|
74
|
-
const handleEvent = (
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
const handleEvent = (
|
|
87
|
+
event: AnalyticsEvent | SearchSelectItemEvent | IntelligentSearchQueryEvent
|
|
88
|
+
) => {
|
|
89
|
+
switch (event.name) {
|
|
90
|
+
case 'search_select_item': {
|
|
91
|
+
const url = new URL(event.params.url)
|
|
92
|
+
|
|
93
|
+
if (!isFullTextSearch(url)) {
|
|
94
|
+
return
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
for (const item of event.params.items ?? []) {
|
|
98
|
+
const productId = item.item_id ?? item.item_variant
|
|
99
|
+
const position = item.index
|
|
100
|
+
|
|
101
|
+
if (productId && position) {
|
|
102
|
+
sendEvent({
|
|
103
|
+
type: 'search.click',
|
|
104
|
+
productId,
|
|
105
|
+
position,
|
|
106
|
+
url: url.href,
|
|
107
|
+
text: url.searchParams.get('q') ?? '<empty>',
|
|
108
|
+
})
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
break
|
|
113
|
+
}
|
|
88
114
|
|
|
89
|
-
|
|
115
|
+
case 'intelligent_search_query': {
|
|
90
116
|
sendEvent({
|
|
91
|
-
type: 'search.
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
117
|
+
type: 'search.query',
|
|
118
|
+
url: event.params.url,
|
|
119
|
+
text: event.params.term,
|
|
120
|
+
misspelled: event.params.isTermMisspelled,
|
|
121
|
+
match: event.params.totalCount,
|
|
122
|
+
operator: event.params.logicalOperator,
|
|
123
|
+
locale: event.params.locale,
|
|
96
124
|
})
|
|
125
|
+
|
|
126
|
+
break
|
|
97
127
|
}
|
|
128
|
+
|
|
129
|
+
default:
|
|
98
130
|
}
|
|
99
131
|
}
|
|
100
132
|
|
|
@@ -20,3 +20,17 @@ export interface SearchSelectItemEvent {
|
|
|
20
20
|
name: 'search_select_item'
|
|
21
21
|
params: SearchSelectItemParams
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
export interface IntelligentSearchQueryParams {
|
|
25
|
+
url: string
|
|
26
|
+
locale: string
|
|
27
|
+
term: string
|
|
28
|
+
logicalOperator: string
|
|
29
|
+
isTermMisspelled: boolean
|
|
30
|
+
totalCount: number
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface IntelligentSearchQueryEvent {
|
|
34
|
+
name: 'intelligent_search_query'
|
|
35
|
+
params: IntelligentSearchQueryParams
|
|
36
|
+
}
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo } from 'react'
|
|
2
2
|
|
|
3
|
+
import { sendAnalyticsEvent } from '@faststore/sdk'
|
|
4
|
+
import { gql } from '@faststore/graphql-utils'
|
|
3
5
|
import { useQuery } from 'src/sdk/graphql/useQuery'
|
|
6
|
+
|
|
4
7
|
import type {
|
|
5
8
|
SearchSuggestionsQueryQuery as Query,
|
|
6
9
|
SearchSuggestionsQueryQueryVariables as Variables,
|
|
7
10
|
} from '@generated/graphql'
|
|
11
|
+
import type { IntelligentSearchQueryEvent } from '../analytics/types'
|
|
8
12
|
|
|
9
13
|
import { useSession } from '../session'
|
|
10
14
|
|
|
@@ -24,6 +28,14 @@ const query = gql`
|
|
|
24
28
|
...ProductSummary_product
|
|
25
29
|
}
|
|
26
30
|
}
|
|
31
|
+
products {
|
|
32
|
+
pageInfo {
|
|
33
|
+
totalCount
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
metadata {
|
|
37
|
+
...SearchEvent_metadata
|
|
38
|
+
}
|
|
27
39
|
}
|
|
28
40
|
}
|
|
29
41
|
`
|
|
@@ -31,12 +43,34 @@ const query = gql`
|
|
|
31
43
|
function useSuggestions(term: string, limit: number = MAX_SUGGESTIONS) {
|
|
32
44
|
const { channel, locale } = useSession()
|
|
33
45
|
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
const variables = useMemo(
|
|
47
|
+
() => ({
|
|
48
|
+
term,
|
|
49
|
+
selectedFacets: [
|
|
50
|
+
{ key: 'channel', value: channel ?? '' },
|
|
51
|
+
{ key: 'locale', value: locale },
|
|
52
|
+
],
|
|
53
|
+
}),
|
|
54
|
+
[term, locale, channel]
|
|
55
|
+
)
|
|
56
|
+
const { data, error } = useQuery<Query, Variables>(query, variables, {
|
|
57
|
+
onSuccess: (callbackData) => {
|
|
58
|
+
if (callbackData && term) {
|
|
59
|
+
sendAnalyticsEvent<IntelligentSearchQueryEvent>({
|
|
60
|
+
name: 'intelligent_search_query',
|
|
61
|
+
params: {
|
|
62
|
+
locale,
|
|
63
|
+
term,
|
|
64
|
+
url: window.location.href,
|
|
65
|
+
logicalOperator:
|
|
66
|
+
callbackData.search.metadata?.logicalOperator ?? 'and',
|
|
67
|
+
isTermMisspelled:
|
|
68
|
+
callbackData.search.metadata?.isTermMisspelled ?? false,
|
|
69
|
+
totalCount: callbackData.search.products.pageInfo.totalCount,
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
}
|
|
73
|
+
},
|
|
40
74
|
})
|
|
41
75
|
|
|
42
76
|
return {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[238],{1953:function(e,t,r){"use strict";var n=r(2784);const a=(0,n.forwardRef)((function({testId:e="fs-label",children:t,...r},a){return n.createElement("label",{ref:a,"data-fs-label":!0,"data-testid":e,...r},t)}));t.Z=a},9767:function(e,t,r){"use strict";var n=r(2784),a=r(5450);const i=(0,n.forwardRef)((function({value:e,as:t="span",variant:r="selling",testId:i="fs-price",formatter:o=(e=>e),SRText:s,...c},l){const d=o(e,r);return n.createElement(t,{ref:l,"data-fs-price":!0,"data-fs-price-variant":r,"data-testid":i,...c},s&&n.createElement(a.Z,{text:s}),d)}));t.Z=i},792:function(e,t,r){"use strict";var n=r(2784);const a=(0,n.forwardRef)((function({testId:e="fs-skeleton",loading:t=!0,shimmer:r=!0,children:a,size:i,border:o,borderRadius:s,...c},l){const d={width:i.width,height:i.height};return t?n.createElement("div",{ref:l,"data-fs-skeleton":!0,"data-testid":e,"data-fs-skeleton-border":o||null,style:s?{...d,borderRadius:s}:d,...c},r&&n.createElement("div",{"data-fs-skeleton-shimmer":!0})):n.createElement(n.Fragment,null,a)}));t.Z=a},2946:function(e,t,r){"use strict";r.d(t,{Z:function(){return i}});var n=r(2784),a=r(276);var i=({listPrice:e,spotPrice:t,thresholdLow:r=15,thresholdHigh:i=40,size:o,testId:s="fs-discount-badge"})=>{const c=((e,t)=>(0,n.useMemo)((()=>{const r=100*(e-t)/e;return Math.round(r)}),[t,e]))(e,t);if(0===c)return n.createElement(n.Fragment,null);const l=c<=r?"low":c<=i?"medium":"high";return n.createElement(a.Z,{"data-fs-discount-badge":!0,"data-fs-discount-badge-variant":l,size:o,"data-testid":s},c,"% off")}},3779:function(e,t,r){"use strict";var n=r(2784),a=r(5170),i=r(1953),o=r(7041),s=r(2614),c=r(3339);t.Z=({id:e,label:t,type:r="text",error:l,displayClearButton:d,actionable:u,buttonActionText:f="Apply",onSubmit:p,onClear:m,placeholder:v=" ",inputRef:b,disabled:h,value:g,testId:y="fs-input-field",...P})=>{const w=!h&&l&&""!==l,O=u&&!h&&""!==g;return n.createElement("div",{"data-fs-input-field":!0,"data-fs-input-field-actionable":u,"data-fs-input-field-error":l&&""!==l,"data-testid":y},n.createElement(a.Z,{id:e,type:r,value:g,ref:b,disabled:h,placeholder:v,...P}),n.createElement(i.Z,{htmlFor:e},t),O&&(d||l?n.createElement(o.Z,{size:"small","aria-label":"Clear Field",icon:n.createElement(s.Z,{name:"XCircle"}),onClick:()=>{m?.(),b?.current?.focus()}}):n.createElement(c.Z,{variant:"tertiary",size:"small",onClick:p},f)),w&&n.createElement("span",{"data-fs-input-field-error-message":!0},l))}},6546:function(e,t,r){"use strict";var n=r(2784),a=r(2614),i=r(7041),o=r(4564);const s=(0,n.forwardRef)((function({children:e,testId:t="fs-rating",length:r=5,value:s=0,icon:c,onChange:l,...d},u){const[f,p]=(0,n.useState)(0),m={"data-fs-rating-icon-outline":!0},v=n.isValidElement(c)?c:n.createElement(a.Z,{name:"Star"});return n.createElement(o.Z,{ref:u,"data-fs-rating":!0,"data-fs-rating-actionable":"function"===typeof l,"data-testid":t,...d},Array.from({length:r}).map(((e,r)=>{const o=r+1;return n.createElement("li",{key:`rating-${r}`,"data-fs-rating-item":o<=(f||s)?"full":o-s>0&&o-s<1?"partial":"empty","data-testid":`${t}-item`},l?n.createElement(i.Z,{"data-fs-rating-button":!0,icon:v,size:"small","aria-label":"rate",onClick:()=>{l(o)},onMouseEnter:()=>p(o),onMouseLeave:()=>p(s)}):n.createElement(n.Fragment,null,n.createElement("div",{"data-fs-rating-icon-wrapper":!0},v),n.isValidElement(c)?n.cloneElement(c,m):n.createElement(a.Z,{name:"Star","data-fs-rating-icon-outline":!0})))})))}));t.Z=s},8091:function(e,t,r){"use strict";r.d(t,{Z:function(){return k}});var n=r(9499),a=r(4730),i=r(2784);var o=(0,i.forwardRef)((function({testId:e="fs-product-card",variant:t="default",bordered:r=!1,outOfStock:n,children:a,...o},s){return i.createElement("article",{ref:s,"data-fs-product-card":n?"out-of-stock":"","data-fs-product-card-variant":t,"data-fs-product-card-bordered":r,"data-testid":e,...o},a)}));var s=(0,i.forwardRef)((function({testId:e="fs-product-card-image",aspectRatio:t=1,children:r,...n},a){return i.createElement("div",{ref:a,"data-fs-product-card-image":!0,"data-testid":e,style:{"--fs-product-card-image-aspect-ratio":t},...n},r)})),c=r(4272),l=r(9767),d=r(6546),u=r(2614),f=r(2946),p=r(276),m=r(3339);var v=(0,i.forwardRef)((function({testId:e="fs-product-card-content",title:t,linkProps:r,price:n,outOfStock:a,outOfStockLabel:o="Out of stock",ratingValue:s,showDiscountBadge:v,buttonLabel:b="Add",onButtonClick:h,children:g,...y},P){return i.createElement("section",{ref:P,"data-fs-product-card-content":!0,"data-fs-product-card-badge":v,"data-testid":e,...y},i.createElement("div",{"data-fs-product-card-heading":!0},i.createElement("h3",{"data-fs-product-card-title":!0},i.createElement(c.Z,{...r,title:t},i.createElement("span",null,t))),!a&&i.createElement("div",{"data-fs-product-card-prices":!0},i.createElement(l.Z,{value:n?.listPrice?n.listPrice:0,formatter:n?.formatter,testId:"list-price","data-value":n?.listPrice,variant:"listing",SRText:"Original price:"}),i.createElement(l.Z,{value:n?.value?n.value:0,formatter:n?.formatter,testId:"price","data-value":n?.value,variant:"spot",SRText:"Sale Price:"})),s&&i.createElement(d.Z,{value:s,icon:i.createElement(u.Z,{name:"Star"})})),v&&!a&&i.createElement(f.Z,{listPrice:n?.listPrice?n.listPrice:0,spotPrice:n?.value?n.value:0}),a&&i.createElement(p.Z,null,o),h&&!a&&i.createElement("div",{"data-fs-product-card-actions":!0},i.createElement(m.Z,{variant:"primary",icon:i.createElement(u.Z,{name:"ShoppingCart"}),iconPosition:"left",size:"small",onClick:h},b)))})),b=r(1664),h=r.n(b),g=r(9266),y=r(5346),P=r(9854),w=r(2322),O=["product","index","bordered","variant","aspectRatio","imgProps","ratingValue","buttonLabel","onButtonClick","showDiscountBadge"];function x(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function E(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?x(Object(r),!0).forEach((function(t){(0,n.Z)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):x(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function j(e){var t,r,{product:n,index:c,bordered:l=!0,variant:d="default",aspectRatio:u=1,imgProps:f,ratingValue:p,buttonLabel:m="Add",onButtonClick:b,showDiscountBadge:x=!0}=e,j=(0,a.Z)(e,O),{sku:k,isVariantOf:{name:I},image:[_],offers:{lowPrice:S,offers:[{listPrice:Z,availability:C}]}}=n,R=E(E({},(0,P.w)({product:n,selectedOffer:0,index:c})),{},{as:h(),passHref:!0,legacyBehavior:!1,prefetch:!1}),D=(0,i.useMemo)((()=>"https://schema.org/InStock"!==C),[C]);return(0,w.jsxs)(o,E(E({outOfStock:D,bordered:l,variant:d,"data-fs-product-card-sku":k},j),{},{children:[(0,w.jsx)(s,{aspectRatio:u,children:(0,w.jsx)(g.E,{src:_.url,alt:_.alternateName,sizes:"".concat(null!==(t=null===f||void 0===f?void 0:f.sizes)&&void 0!==t?t:"(max-width: 768px) 40vw, 30vw"),width:null!==(r=null===f||void 0===f?void 0:f.width)&&void 0!==r?r:360,height:Math.round((Number(null===f||void 0===f?void 0:f.height)||360)/u),loading:null===f||void 0===f?void 0:f.loading})}),(0,w.jsx)(v,{title:I,price:{value:S,listPrice:Z,formatter:y.P},ratingValue:p,outOfStock:D,onButtonClick:b,linkProps:R,showDiscountBadge:x})]}))}var k=(0,i.memo)(j)},8463:function(e,t,r){"use strict";r.d(t,{Z:function(){return y}});var n=r(9499),a=r(2784);const i=(0,a.createContext)(void 0);var o=(0,a.forwardRef)((function({children:e,testId:t="fs-banner-text",variant:r="primary",colorVariant:n="main",...o},s){const c={variant:r,colorVariant:n};return a.createElement(i.Provider,{value:c},a.createElement("article",{ref:s,"data-fs-banner-text":!0,"data-fs-banner-text-variant":r,"data-fs-banner-text-color-variant":n,"data-testid":t,...o},e))})),s=r(3922);var c=(0,a.forwardRef)((function({testId:e="fs-banner-text-content",title:t,caption:r,link:n,linkText:o,...c},l){const{variant:d,colorVariant:u}=function(){const e=(0,a.useContext)(i);if(void 0===e)throw new Error("Do not use BannerText components outside the BannerText context.");return e}();return a.createElement("header",{ref:l,"data-fs-banner-text-content":!0,"data-fs-content":"banner-text","data-testid":e,...c},a.createElement("div",{"data-fs-banner-text-heading":!0,"data-fs-banner-text-color-variant":u},a.createElement("h2",null,t),"secondary"===d&&r&&a.createElement("p",null,r)),a.createElement(s.Z,{"data-fs-banner-text-link":!0,href:n,variant:d,inverse:"main"===u,"aria-label":o},o))})),l=r(9104),d={section:"BannerText"},{BannerText:u,BannerTextContent:f}=(0,l.f)({BannerText:o,BannerTextContent:c},d),p=r(7067),m=r(23),v=r.n(m),b=r(2322);function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function g(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?h(Object(r),!0).forEach((function(t){(0,n.Z)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):h(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var y=function(e){var t,r,{title:n,caption:a,link:{url:i=f.props.link,text:o=f.props.linkText},variant:s=(null!==(t=u.props.variant)&&void 0!==t?t:"primary"),colorVariant:c=(null!==(r=u.props.colorVariant)&&void 0!==r?r:"main")}=e;return(0,b.jsx)(p.Z,{className:"".concat(v().section," section-banner layout__section"),children:(0,b.jsx)("div",{className:"layout__content",children:(0,b.jsx)(u.Component,g(g({},u.props),{},{variant:s,colorVariant:c,children:(0,b.jsx)(f.Component,g(g({},f.props),{},{title:n,caption:a,link:i,linkText:o}))}))})})}},5168:function(e,t,r){"use strict";r.d(t,{Z:function(){return L}});var n=r(9499),a=r(4730),i=r(2784),o=r(1503),s=r(4262),c=r(6652),l=r(29),d=r(9857),u=r(180),f=r(7732),p=(e,t,r)=>{var n=(0,d.ZP)((0,f.km)(e,t),(()=>null),f.WN),a=function(){var t=(0,l.Z)((function*(t){var a=yield(0,u.W)(e,t,r);n.mutate(a,!1)}));return function(e){return t.apply(this,arguments)}}();return[a,n]},m=r(2614),v=r(3779),b=r(3339),h=r(9104),g={section:"Newsletter"},{ToastIconSuccess:y,ToastIconError:P,HeaderIcon:w,InputFieldName:O,InputFieldEmail:x,Button:E}=(0,h.f)({ToastIconSuccess:m.Z,ToastIconError:m.Z,HeaderIcon:m.Z,InputFieldName:v.Z,InputFieldEmail:v.Z,Button:b.Z},g),j=r(2322);function k(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function I(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?k(Object(r),!0).forEach((function(t){(0,n.Z)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):k(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var _=e=>{if(!e)return"";var t=JSON.parse(e);return(0,s.E)((0,o.convertFromRaw)(t),{entityStyleFn:e=>{if("link"===e.get("type").toLowerCase())return{element:"a",attributes:{"data-fs-link":"true","data-fs-link-variant":"inline","data-fs-link-inverse":"true","data-fs-link-size":"regular","data-testid":"fs-link",href:e.getData().url}}}})},S=(0,i.forwardRef)((function(e,t){var r,{icon:n,title:a,description:o,privacyPolicy:s,emailInputLabel:l,displayNameInput:d,nameInputLabel:u,subscribeButtonLabel:f,subscribeButtonLoadingLabel:m,card:v,toastSubscribe:b,toastSubscribeError:h}=e,{subscribeUser:g,loading:k,data:S}=(()=>{var[e,{data:t,error:r,isValidating:n}]=p("SubscribeToNewsletter",{data:{name:"",email:""}});return{subscribeUser:e,data:t,error:r,loading:n}})(),Z=(0,i.useRef)(null),C=(0,i.useRef)(null),{pushToast:R}=((0,i.useMemo)((()=>k?m:f),[k,f,m]),(0,c.l)());return(0,j.jsx)("div",{"data-fs-newsletter":v?"card":"",children:(0,j.jsxs)("form",{ref:t,"data-fs-newsletter-form":!0,"data-fs-content":"newsletter",onSubmit:e=>{var t,r,n,a,i,o,s;(e.preventDefault(),g({data:{name:null!==(t=null===(r=Z.current)||void 0===r?void 0:r.value)&&void 0!==t?t:"",email:null!==(n=null===(a=C.current)||void 0===a?void 0:a.value)&&void 0!==n?n:""}}),null!==S&&void 0!==S&&null!==(i=S.subscribeToNewsletter)&&void 0!==i&&i.id)?R(I(I({},b),{},{status:"INFO",icon:(0,j.jsx)(y.Component,I(I({width:30,height:30},y.props),{},{name:null!==(o=b.icon)&&void 0!==o?o:y.props.name}))})):R(I(I({},h),{},{status:"ERROR",icon:(0,j.jsx)(P.Component,I(I({width:30,height:30},P.props),{},{name:null!==(s=b.icon)&&void 0!==s?s:P.props.name}))}));e.currentTarget.reset()},children:[(0,j.jsxs)("header",{"data-fs-newsletter-header":!0,children:[(0,j.jsxs)("h3",{children:[(0,j.jsx)(w.Component,I(I({width:32,height:32},w.props),{},{name:null!==(r=null===n||void 0===n?void 0:n.icon)&&void 0!==r?r:w.props.name})),a]}),o&&(0,j.jsxs)("span",{children:[" ",o]})]}),(0,j.jsx)("div",{"data-fs-newsletter-controls":!0,children:(0,j.jsxs)(j.Fragment,{children:[d?(0,j.jsx)(O.Component,I(I({id:"newsletter-name",required:!0},O.props),{},{label:null!==u&&void 0!==u?u:O.props.label,inputRef:Z})):null,(0,j.jsx)(x.Component,I(I({id:"newsletter-email",type:"email",required:!0},x.props),{},{label:null!==l&&void 0!==l?l:x.props.label,inputRef:C})),(0,j.jsx)("span",{"data-fs-newsletter-addendum":!0,dangerouslySetInnerHTML:{__html:_(s)}}),(0,j.jsx)(E.Component,I(I({variant:"secondary",inverse:!0,type:"submit"},E.props),{},{children:k?m:f}))]})})]})})})),Z=r(7067),C=r(1778),R=r.n(C),D=["icon","title","description","privacyPolicy","emailInputLabel","displayNameInput","nameInputLabel","subscribeButtonLabel","card","toastSubscribe","toastSubscribeError"];function T(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function B(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?T(Object(r),!0).forEach((function(t){(0,n.Z)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):T(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var L=function(e){var{icon:t,title:r,description:n,privacyPolicy:i,emailInputLabel:o,displayNameInput:s,nameInputLabel:c,subscribeButtonLabel:l,card:d,toastSubscribe:u,toastSubscribeError:f}=e,p=(0,a.Z)(e,D);return(0,j.jsx)(Z.Z,{className:"".concat(R().section," section-newsletter"),children:(0,j.jsx)(S,B({icon:t,title:r,description:n,privacyPolicy:i,emailInputLabel:o,displayNameInput:s,nameInputLabel:c,subscribeButtonLabel:l,toastSubscribe:u,toastSubscribeError:f,card:d},p))})}},3288:function(e,t,r){"use strict";r.d(t,{Z:function(){return i}});var n=r(792),a=r(2322);var i=function(e){var{bordered:t,sectioned:r,displayButton:i,aspectRatio:o=1,variant:s="default"}=e;return(0,a.jsxs)("div",{"data-fs-product-card-skeleton":!0,"data-fs-product-card-skeleton-variant":s,"data-fs-product-card-skeleton-bordered":t,"data-fs-product-card-skeleton-sectioned":r,children:[(0,a.jsx)("div",{"data-fs-product-card-skeleton-image":!0,style:{"--fs-product-card-skeleton-image-aspect-ratio":o},children:(0,a.jsx)(n.Z,{size:{width:"100%",height:"100%"}})}),(0,a.jsxs)("div",{"data-fs-product-card-skeleton-content":!0,children:[(0,a.jsx)(n.Z,{"data-fs-product-card-skeleton-text":!0,size:{width:"90%",height:"1.5rem"}}),(0,a.jsx)(n.Z,{"data-fs-product-card-skeleton-text":!0,size:{width:"70%",height:"1.5rem"}}),(0,a.jsx)(n.Z,{"data-fs-product-card-skeleton-badge":!0,size:{width:"6rem",height:"2rem"},border:"pill"}),i&&(0,a.jsx)(n.Z,{"data-fs-product-card-skeleton-button":!0,size:{width:"6rem",height:"2rem"},style:{columnGap:".75rem"}})]})]})}},1309:function(e,t,r){"use strict";r.d(t,{Z:function(){return L}});var n=r(9499),a=r(4730),i=r(2784);var o=(0,i.forwardRef)((function({testId:e="fs-product-shelf",children:t,...r},n){return i.createElement("div",{ref:n,"data-fs-product-shelf":!0,"data-fs-content":"product-shelf","data-testid":e,...r},t)}));var s=(0,i.forwardRef)((function({testId:e="fs-product-shelf-items",children:t,...r},n){return i.createElement("ul",{role:"list",ref:n,"data-fs-product-shelf-items":!0,"data-fs-content":"product-shelf","data-testid":e,...r},t)}));var c=(0,i.forwardRef)((function({testId:e="fs-product-shelf-item",children:t,...r},n){return i.createElement("li",{role:"listitem",ref:n,"data-fs-product-shelf-item":!0,"data-testid":e,...r},t)})),l=r(8459),d=r(3288),u=r(2322);var f=function(e){var{children:t,aspectRatio:r,loading:n=!0}=e;return n?(0,u.jsx)(o,{"data-fs-product-shelf-skeleton":!0,children:(0,u.jsx)(s,{children:Array.from({length:l.K},((e,t)=>(0,u.jsx)(c,{children:(0,u.jsx)(d.Z,{aspectRatio:r,sectioned:!0,bordered:!0})},String(t))))})}):(0,u.jsx)(u.Fragment,{children:t})},p=r(5184),m=r(737);var v=r(8091),b=r(7041),h=r(2614),g=r(5724);function y(e,t){switch(t.type){case"NEXT_PAGE":{const t=e.infinite?e.totalPages+1:e.totalPages,r=(e.currentPage+1)%t,n=r%t*e.itemsPerPage;return{...e,sliding:!0,slideDirection:"next",currentItem:n,currentPage:r}}case"PREVIOUS_PAGE":{const t=e.infinite?e.totalPages+1:e.totalPages,r=e.infinite&&0===e.currentPage?-1:((e,t)=>(t-(t-e+1)%t)%t)(e.currentPage,e.totalPages);return{...e,sliding:!0,slideDirection:"previous",currentItem:r%t*e.itemsPerPage,currentPage:r}}case"GO_TO_PAGE":return t.payload.pageIndex===e.currentPage?e:{...e,sliding:t.payload.shouldSlide,slideDirection:t.payload.pageIndex>e.currentPage?"next":"previous",currentItem:t.payload.pageIndex%e.totalPages*e.itemsPerPage,currentPage:t.payload.pageIndex};case"STOP_SLIDE":return{...e,sliding:!1};default:return e}}const P=(e,t)=>{"next"===e&&t({type:"NEXT_PAGE"}),"previous"===e&&t({type:"PREVIOUS_PAGE"}),"number"===typeof e&&t({type:"GO_TO_PAGE",payload:{pageIndex:e,shouldSlide:!0}})},w=({totalItems:e,itemsPerPage:t=1,infiniteMode:r=!1,shouldSlideOnSwipe:n=!0,...a})=>{const[o,s]=(0,i.useReducer)(y,void 0,(()=>((e,t,r)=>({currentItem:0,currentPage:0,sliding:!1,slideDirection:"next",totalItems:e,itemsPerPage:t,totalPages:Math.ceil(e/t),infinite:r}))(e,t,r)));return{handlers:(0,g.QS)({onSwipedRight:()=>n&&P("previous",s),onSwipedLeft:()=>n&&P("next",s),trackMouse:!0,...a}),slide:P,sliderState:o,sliderDispatch:s}};var O=r(3339);const x=(e,t,r)=>r?`Current page from ${e}`:`Go to page ${t+1} from ${e}`;var E=(0,i.forwardRef)((function({id:e,totalQuantity:t,activeBullet:r,onClick:n,testId:a="fs-carousel-bullets",ariaLabelGenerator:o=x,ariaControlsGenerator:s,...c},l){const d=(0,i.useMemo)((()=>Array(t).fill(0)),[t]);return i.createElement("div",{ref:l,"data-fs-carousel-bullets":!0,"data-testid":a,role:"tablist",...c},d.map(((t,c)=>{const l=r===c;return i.createElement(O.Z,{key:`${e}-${c}`,role:"tab",tabIndex:-1,"data-fs-carousel-bullet":!0,testId:`${a}-bullet`,onClick:e=>n(e,c),"aria-label":o(e,c,l),"aria-controls":s?.(c),"aria-selected":l,variant:"tertiary"})})))}));var j=function({id:e,index:t,state:r,children:n,totalItems:a,infiniteMode:o,isScrollCarousel:s}){const{isItemVisible:c,shouldRenderItem:l}=(({currentSlide:e,itemsPerPage:t,totalItems:r})=>{const n=(0,i.useRef)(new Set);(0,i.useEffect)((()=>{for(let r=0;r<t;r++)n.current.add(e+r)}),[e,t]);const a=n=>function({itemsPerPage:e,currentSlide:t,slideIdx:r,totalItems:n}){return t<0||t>=n||r>=t&&r<t+e}({slideIdx:n,currentSlide:e,itemsPerPage:t,totalItems:r});return{shouldRenderItem:e=>n.current.has(e)||a(e),isItemVisible:a}})({totalItems:a,currentSlide:r.currentItem,itemsPerPage:r.itemsPerPage}),d=!s&&{width:"100%"}||s&&{maxWidth:"60%",display:"inline-block"},u=s||l(t-Number(o));return i.createElement("li",{style:d,id:`${e}-carousel-item-${t}`,"data-fs-carousel-item":!0,"data-fs-carousel-item-visible":c(t-Number(o))||void 0},u?n:null)};var k=function({children:e,className:t,"aria-label":r,infiniteMode:n=!0,controls:a="complete",testId:o="fs-carousel",transition:s={duration:400,property:"transform"},id:c="fs-carousel",variant:l="slide",itemsPerPage:d=1,navigationIcons:u,...f}){const p=(0,i.useRef)(null),m="slide"===l,v="scroll"===l,g=i.Children.toArray(e),y=g.length,P=n?y+2:y,O=`${s.property} ${s.duration}ms ${s.timing??""} ${s.delay??""}`,{handlers:x,slide:k,sliderState:I,sliderDispatch:_}=w({itemsPerPage:d,infiniteMode:n,totalItems:y,shouldSlideOnSwipe:m,...f}),S=Math.ceil(y/I.itemsPerPage),Z=1!==S&&("complete"===a||"navigationArrows"===a),C=1!==S&&("complete"===a||"paginationBullets"===a),R=(0,i.useMemo)((()=>((e,t)=>{const r={},n=100/t;for(let a=0;a<t;++a){const t=-n*a;r[e?a-1:a]=t}return r})(n,P)),[P,n]),D=n&&e?g.slice(0,1):[],T=(n&&e?g.slice(y-1):[]).concat(e??[],D),B=(0,i.useMemo)((()=>({display:"flex",width:100*P+"%",transition:I.sliding?O:void 0,transform:`translate3d(${R[I.currentPage]}%, 0, 0)`})),[P,R,O,I.sliding,I.currentPage]),L=(0,i.useMemo)((()=>({width:"100%",display:"block",overflowX:"scroll",whiteSpace:"nowrap"})),[]),N=m&&B||v&&L,V=()=>{I.sliding||!n&&0===I.currentPage||k("previous",_)},M=()=>{I.sliding||!n&&I.currentPage===y-1||k("next",_)},A=async(e,t)=>{if("previous"===t&&0===I.currentPage)return;if("next"===t&&I.currentPage===I.totalPages-1)return;let r;const n=Number(p.current?.firstElementChild?.clientWidth);r=d>1?e*n*d:e*n-.125*n,p.current?.scrollTo({left:r,behavior:"smooth"}),k(e,_)};return i.createElement("section",{id:c,"data-fs-carousel":!0,className:t,"data-testid":o,"aria-label":r},i.createElement("div",{"data-fs-carousel-track-container":!0,style:{width:"100%",overflow:"hidden",display:v?"block":void 0},...x},i.createElement("ul",{"aria-live":"polite",ref:p,style:N,"data-fs-carousel-track":!0,onScroll:e=>{if(m||d>1)return;const t=Number(e.currentTarget.firstElementChild?.scrollWidth),r=e.currentTarget?.scrollLeft,n=(r>t/2?Math.round:Math.floor)(r/t);k(n,_)},onTransitionEnd:()=>{_({type:"STOP_SLIDE"}),n&&I.currentItem>=y&&_({type:"GO_TO_PAGE",payload:{pageIndex:0,shouldSlide:!1}}),n&&I.currentItem<0&&_({type:"GO_TO_PAGE",payload:{pageIndex:I.totalPages-1,shouldSlide:!1}})}},T.map(((e,t)=>i.createElement(j,{id:c,index:t,key:String(t),state:I,totalItems:y,infiniteMode:n,isScrollCarousel:v},e))))),Z&&i.createElement("div",{"data-fs-carousel-controls":!0},i.createElement(b.Z,{"data-fs-carousel-control":"left","aria-controls":c,"aria-label":"previous",icon:u?.left??i.createElement(h.Z,{name:"ArrowLeft",width:20,height:20,weight:"bold"}),onClick:()=>{m&&V(),v&&A(I.currentPage-1,"previous")}}),i.createElement(b.Z,{"data-fs-carousel-control":"right","aria-controls":c,"aria-label":"next",icon:u?.right??i.createElement(h.Z,{name:"ArrowRight",width:20,height:20,weight:"bold"}),onClick:()=>{m&&M(),v&&A(I.currentPage+1,"next")}})),C&&i.createElement(E,{id:c,tabIndex:0,activeBullet:I.currentPage,totalQuantity:S,onKeyDown:e=>{switch(e.key){case"ArrowLeft":m&&V(),v&&A(I.currentPage-1,"previous");break;case"ArrowRight":m&&M(),v&&A(I.currentPage+1,"next");break;case"Home":k(0,_);break;case"End":k(y-1,_)}},onClick:async(e,t)=>{m&&!I.sliding&&k(t,_),v&&A(t)},onFocus:e=>e.currentTarget.focus(),ariaControlsGenerator:e=>`${c}-carousel-item-${e}`}))};var I=function(e){var{id:t,testId:r,children:n,itemsPerPage:a=5}=e,i=window.innerWidth<=768;return(0,u.jsx)(k,{id:t,testId:r,variant:"scroll",infiniteMode:!1,itemsPerPage:i?1:a,children:n})},_=r(9104),S={section:"ProductShelf"},{ProductShelf:Z,__experimentalCarousel:C,__experimentalProductCard:R}=(0,_.f)({ProductShelf:o,__experimentalCarousel:I,__experimentalProductCard:v.Z},S),D=["title","inView","productCardConfiguration"];function T(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function B(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?T(Object(r),!0).forEach((function(t){(0,n.Z)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):T(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var L=function(e){var t,{title:r,inView:n,productCardConfiguration:{bordered:o=R.props.bordered,showDiscountBadge:s=R.props.showDiscountBadge}={}}=e,c=(0,a.Z)(e,D),l=function(e){var t,r=e.replace(/[^\w\s]/gi,"-");return null!==(t=r=(r=r.replace(/\s+/g,"-")).toLowerCase())&&void 0!==t?t:""}(r),d=(0,i.useId)(),v=(0,i.useRef)(!1),b=(0,m.kN)(c),h=null!==(t=null===b||void 0===b?void 0:b.edges)&&void 0!==t?t:[],{sendViewItemListEvent:g}=(0,p.m)({products:h,title:r,page:0,pageSize:0});return(0,i.useEffect)((()=>{n&&!v.current&&h.length&&(g(),v.current=!0)}),[n,h.length,g]),0===(null===b||void 0===b?void 0:b.edges.length)?null:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("h2",{className:"text__title-section layout__content",children:r}),(0,u.jsx)(f,{aspectRatio:1,loading:void 0===b,children:(0,u.jsx)(Z.Component,B(B({},Z.props),{},{children:(0,u.jsx)(C.Component,B(B({id:l||d},C.props),{},{children:h.map(((e,t)=>(0,i.createElement)(R.Component,B(B({aspectRatio:1,imgProps:{width:216,height:216,sizes:"(max-width: 768px) 42vw, 30vw"}},R.props),{},{bordered:o,showDiscountBadge:s,key:"".concat(e.node.id),product:e.node,index:t+1}))))}))}))})]})}},8459:function(e,t,r){"use strict";r.d(t,{K:function(){return a},g:function(){return n}});var n=12,a=5},5184:function(e,t,r){"use strict";r.d(t,{m:function(){return o}});var n=r(1072),a=r(2784),i=r(7295),o=e=>{var{products:t,title:r,page:o,pageSize:s}=e,{currency:{code:c}}=(0,i.kP)();return{sendViewItemListEvent:(0,a.useCallback)((()=>{(0,n._)({name:"view_item_list",params:{item_list_name:r,item_list_id:r,items:t.map(((e,t)=>{var{node:r}=e;return{item_id:r.isVariantOf.productGroupID,item_name:r.isVariantOf.name,item_brand:r.brand.name,item_variant:r.sku,price:r.offers.offers[0].price,index:o*s+t+1,discount:r.offers.offers[0].listPrice-r.offers.offers[0].price,currency:c,item_variant_name:r.name,product_reference_id:r.gtin}}))}})}),[c,t,r,o,s])}}},5346:function(e,t,r){"use strict";r.d(t,{P:function(){return i}});var n=r(2784),a=r(7295),i=e=>{var t=function(){var{decimals:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{currency:t,locale:r}=(0,a.kP)();return(0,n.useCallback)((n=>Intl.NumberFormat(r,{style:"currency",currency:t.code,minimumFractionDigits:e?2:0}).format(n)),[t.code,r,e])}();return(0,n.useMemo)((()=>t(e)),[t,e])}},9854:function(e,t,r){"use strict";r.d(t,{w:function(){return o}});var n=r(1072),a=r(2784),i=r(7295),o=e=>{var{index:t,product:r,selectedOffer:o}=e,{slug:s}=r,{currency:{code:c}}=(0,i.kP)(),l=(0,a.useCallback)((()=>{(0,n._)({name:"select_item",params:{items:[{item_id:r.isVariantOf.productGroupID,item_name:r.isVariantOf.name,item_brand:r.brand.name,item_variant:r.sku,index:t,price:r.offers.offers[o].price,discount:r.offers.offers[o].listPrice-r.offers.offers[o].price,currency:c,item_variant_name:r.name,product_reference_id:r.gtin}]}}),(0,n._)({name:"search_select_item",params:{url:window.location.href,items:[{item_id:r.isVariantOf.productGroupID,item_variant:r.sku,index:t}]}})}),[c,r,t,o]);return{href:"/".concat(s,"/p"),onClick:l,"data-testid":"product-link"}}},737:function(e,t,r){"use strict";r.d(t,{yb:function(){return v},kN:function(){return b},BG:function(){return h}});var n=r(9499),a=r(2784),i=r(9857),o=r(8459),s=r(4730),c=r(180),l=r(7732),d=["cache"],u=r(7295);function f(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function p(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?f(Object(r),!0).forEach((function(t){(0,n.Z)(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):f(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var m="ProductsQuery",v=e=>{var{first:t,after:r,sort:n,term:i,selectedFacets:s}=e,{channel:c,locale:l}=(0,u.kP)();return(0,a.useMemo)((()=>{var e,a=(e=s,Array.isArray(e)?e:e?[e]:[]);return{first:null!==t&&void 0!==t?t:o.K,after:null!==r&&void 0!==r?r:"0",sort:null!==n&&void 0!==n?n:"score_desc",term:null!==i&&void 0!==i?i:"",selectedFacets:[...a,{key:"channel",value:null!==c&&void 0!==c?c:""},{key:"locale",value:l}]}}),[s,t,r,n,i,c,l])},b=(e,t)=>{var r,n=v(e),{data:a}=(0,l.aM)(m,n,p({fallbackData:null,suspense:!0},t));return null===a||void 0===a||null===(r=a.search)||void 0===r?void 0:r.products},h=(e,t)=>{var r=v(e),{cache:n}=(0,i.kY)();return(0,a.useCallback)((()=>((e,t,r)=>{var{cache:n}=r,a=(0,s.Z)(r,d),o=(0,l.km)(e,t);n.get(o)||(0,i.JG)(o,(0,c.W)(e,t,a))})(m,r,p({cache:n},t))),[r,n,t])}},23:function(e){e.exports={section:"section_section__ivuGF"}},1778:function(e){e.exports={section:"section_section__kRRBW"}},3262:function(e){e.exports={section:"section_section__C1DoH",loading:"section_loading__k5bCF"}}}]);
|