@dropins/storefront-product-discovery 2.1.0 → 3.0.0-alpha2
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/LICENSE.md +24 -24
- package/chunks/acdlEvents.js +1 -1
- package/chunks/search.js +3 -3
- package/chunks/search.js.map +1 -1
- package/containers/Pagination.js +1 -1
- package/containers/Pagination.js.map +1 -1
- package/containers/SearchResults/ComplexProductPrice.d.ts +6 -0
- package/containers/SearchResults/SimpleProductPrice.d.ts +6 -0
- package/containers/SearchResults.js +1 -1
- package/containers/SearchResults.js.map +1 -1
- package/package.json +1 -1
- package/render.js +1 -1
package/LICENSE.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
Last Updated:
|
|
1
|
+
Last Updated: 8 December 2025
|
|
2
2
|
|
|
3
|
-
ADOBE COMMERCE DROP-IN LICENSE AGREEMENT
|
|
3
|
+
**ADOBE COMMERCE DROP-IN LICENSE AGREEMENT**
|
|
4
4
|
|
|
5
|
-
applicable to Adobe Commerce Customers
|
|
5
|
+
applicable to Adobe Commerce as a Cloud Service and Adobe Commerce Optimizer Customers
|
|
6
6
|
|
|
7
7
|
**Effective Date:** first date you download or use the Drop-in
|
|
8
8
|
|
|
9
|
-
NOTICE TO USER: The Adobe Commerce Drop-in (
|
|
9
|
+
NOTICE TO USER: The Adobe Commerce Drop-ins are licensed only for use with Adobe Commerce as a Cloud Service and Adobe Commerce Optimizer. The Adobe Commerce Drop-in ("Drop-in") is licensed to you subject to the terms and conditions below which form a binding agreement between you and Adobe. **By downloading, installing, or making use of any portion of the Drop-in, you are agreeing to the following terms and conditions. If you do not agree to the terms and conditions below, do not use the Drop-in**. If you agree to be bound by this agreement on behalf of your employer or other entity, you must have the legal authority to do so. If you are not authorized to so bind your employer or such entity, do not download and do not use the Drop-in.
|
|
10
10
|
|
|
11
11
|
Your access to and use of the Drop-in is governed by the Adobe Enterprise Licensing Terms previously agreed to by you and Adobe or an authorized Adobe Reseller in a separate agreement. If you have not previously agreed to licensing terms then your installation and use of the Drop-in is subject to the current applicable Adobe Enterprise Licensing Terms available at <http://www.adobe.com/legal/terms/enterprise-licensing.html>. You agree that this agreement will have the same effect as any written negotiated agreement signed by you.
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ By downloading, installing or making use of any portion of the Drop-in, you acce
|
|
|
14
14
|
|
|
15
15
|
This agreement is enforceable against any person or entity that installs and uses the Drop-in and any person or entity (e.g., system integrator, consultant or contractor) that installs or uses the drop-in on another person's or entity's behalf (e.g., Adobe Customer).
|
|
16
16
|
|
|
17
|
-
Notice to U.S. Government End Users: Products and services are
|
|
17
|
+
Notice to U.S. Government End Users: Products and services are "Commercial Product(s)," and "Commercial Service(s)" as those terms are defined at 48 C.F.R. section 2.101, consisting of "Commercial Computer Software" and "Commercial Computer Software Documentation," as the terms are used in 48 C.F.R. section 12.212 or 48 C.F.R. section 227.7202, as applicable. Customer agrees, consistent with 48 C.F.R. section 12.212 or 48 C.F.R. sections 227.7202-1 through 227.72024, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are being licensed to U.S. Government end users (A) only as Commercial Products and Services; and (B) with only those rights as are granted to all other end users pursuant to the terms and conditions herein. Unpublished rights are reserved under the copyright laws of the United States.
|
|
18
18
|
|
|
19
19
|
**ADOBE COMMERCE DROP-IN LICENSE AGREEMENT**
|
|
20
20
|
|
|
@@ -22,21 +22,21 @@ applicable to Developers
|
|
|
22
22
|
|
|
23
23
|
**Effective Date:** first date you download or use the Drop-in
|
|
24
24
|
|
|
25
|
-
The Adobe Commerce Drop-in (
|
|
25
|
+
The Adobe Commerce Drop-ins are licensed only for use with Adobe Commerce as a Cloud Service and Adobe Commerce Optimizer. The Adobe Commerce Drop-in ("Drop-in") is licensed to you subject to the terms and conditions below which form a binding agreement between you and Adobe. **By downloading, installing, or making use of any portion of the Drop-in, you are agreeing to the following terms and conditions. If you do not agree to the terms and conditions below, do not use the Drop-in**. If you agree to be bound by this agreement on behalf of your employer or other entity, you must have the legal authority to do so. If you are not authorized to so bind your employer or such entity, do not download and do not use the Drop-in.
|
|
26
26
|
|
|
27
27
|
**AGREED TERMS AND CONDITIONS**
|
|
28
28
|
|
|
29
29
|
1. **DEFINITIONS**.
|
|
30
30
|
|
|
31
|
-
1.1
|
|
31
|
+
1.1 "**Adobe**" means collectively, Adobe Inc., a company incorporated in Delaware, U.S.A., having a place of business at 345 Park Avenue, San Jose, California USA 95110-2704, U.S.A. ("**Adobe US**") and Adobe Systems Software Ireland, company incorporated in Ireland, having a place of business 4-6 Riverwalk, City West Business Campus, Saggart, Dublin 24, Ireland ("**Adobe Ireland**").
|
|
32
32
|
|
|
33
|
-
1.2
|
|
33
|
+
1.2 "**Adobe Product(s)**" means software applications, programs and other technologies not included in or with the Drop-in which are or may be made available by Adobe for licensing to the general public. This agreement does not govern use of Adobe Products. See the end user license agreement accompanying an Adobe Product for terms governing its use.
|
|
34
34
|
|
|
35
|
-
1.3
|
|
35
|
+
1.3 "**Developer Product(s)**" means any software application(s), program(s) and other technolog(y/ies) you develop with use of the Drop-in to function or interoperate with Adobe Products.
|
|
36
36
|
|
|
37
|
-
1.4
|
|
37
|
+
1.4 "**Intellectual Property Rights**" means copyright, moral rights, trademark, trade dress, patent, trade secret, unfair competition, and any other intellectual and proprietary rights.
|
|
38
38
|
|
|
39
|
-
1.5
|
|
39
|
+
1.5 "**Adobe Commerce Drop-in**" or "Drop-in" means all items comprising the application and all associated materials licensed to you by Adobe as part of the Drop-in, including all Drop-in system files, tools, programs and utilities, as well as any plug-ins or other application programming interfaces, header or JAR files ("**API**"), sample images, sounds, or similar assets ("**Content** **Files**"), software code samples, runtimes and libraries, including any portion(s) that is modified by you, or merged or incorporated with your Developer Products ("**Sample Code**"), and any related documentation, technical specifications, notes and explanatory materials, as well any modifications, updates, upgrades, or copies of, any of the foregoing items, that may be made available by Adobe, whether online or recorded on media, or manually downloaded by you.
|
|
40
40
|
|
|
41
41
|
2. **LICENSES GRANTED TO YOU**.
|
|
42
42
|
|
|
@@ -50,23 +50,23 @@ The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the ter
|
|
|
50
50
|
|
|
51
51
|
3. **SCOPE OF LICENSE; LIMITATIONS AND RESTRICTIONS**
|
|
52
52
|
|
|
53
|
-
3.1 You may not distribute the Drop-ins or any of its component parts to interoperate with or to run on a platform other than
|
|
53
|
+
3.1 You may not distribute the Drop-ins or any of its component parts to interoperate with or to run on a platform other than Adobe Commerce as a Cloud Service and Adobe Commerce Optimizer.
|
|
54
54
|
|
|
55
55
|
3.2 Third-Party Software. The Drop-ins may contain third-party software, subject to additional terms and conditions, available at <http://www.adobe.com/go/thirdparty>; and
|
|
56
56
|
|
|
57
57
|
3.3 You may not modify, port, adapt, creative derivate works, redistribute, or translate any portion of this Drop-in; or add or delete any Drop-in program files that would in any way result in modifying the functionality or appearance of any element of the Adobe Products.
|
|
58
58
|
|
|
59
|
-
3.4 You may not reverse engineer, decompile, disassemble, or otherwise attempt to discover the source code of, any portion of the Drop-in, except and only to the extent that applicable laws of the jurisdiction where you are located grant you the right to decompile the Drop-in in order to obtain information necessary to render the Drop-in interoperable with other software; in which case you must first request the information from Adobe in writing and Adobe may, in its discretion, either provide such information to you or impose reasonable conditions, including reasonable fees, on your use of the Drop-in to ensure that Adobe
|
|
59
|
+
3.4 You may not reverse engineer, decompile, disassemble, or otherwise attempt to discover the source code of, any portion of the Drop-in, except and only to the extent that applicable laws of the jurisdiction where you are located grant you the right to decompile the Drop-in in order to obtain information necessary to render the Drop-in interoperable with other software; in which case you must first request the information from Adobe in writing and Adobe may, in its discretion, either provide such information to you or impose reasonable conditions, including reasonable fees, on your use of the Drop-in to ensure that Adobe's and its licensors' Intellectual Proprietary Rights in the Drop-in are protected.
|
|
60
60
|
|
|
61
|
-
3.5 You may not unbundle, repackage, distribute, rent, lease, offer, sell, resale, sublicense, assign or transfer all, or any component parts of the Drop-in, or any of your rights in the Drop-in, nor authorize any portion of the Drop-in to be copied onto another
|
|
61
|
+
3.5 You may not unbundle, repackage, distribute, rent, lease, offer, sell, resale, sublicense, assign or transfer all, or any component parts of the Drop-in, or any of your rights in the Drop-in, nor authorize any portion of the Drop-in to be copied onto another's device, computer or platform, including on a service bureau basis to other providers (i.e., volume printing, banking, payroll service providers, etc) who provide you free or fee-based business services.
|
|
62
62
|
|
|
63
63
|
4. **VIRAL OPEN SOURCE SOFTWARE AND SERVICES**
|
|
64
64
|
|
|
65
|
-
You are not license to (and you agree that you will not) merge, integrate or use the Drop-in with any Viral Open Source Software or Viral Service, or otherwise take any action that could require disclosure, distribution, or licensing of all or any part of the Drop-in in source code form for any purpose whatsoever. For purposes of this Section,
|
|
65
|
+
You are not license to (and you agree that you will not) merge, integrate or use the Drop-in with any Viral Open Source Software or Viral Service, or otherwise take any action that could require disclosure, distribution, or licensing of all or any part of the Drop-in in source code form for any purpose whatsoever. For purposes of this Section, "**Viral Open Source Software**" means software licensed under the GNU General Public License, the GNU Affero General Public License (AGPL), the GNU Lesser General Public License (LGPL), or any other license terms that would require, or condition your use, modification, or distribution of such licensed software on the disclosure, distribution, or licensing of any other software in source code form, for the purpose of making derivative works, or at no charge, and "**Viral Service**" means any service that contains any viruses, Trojan horses, worms, time bombs, cancelbots or other computer programming routines that are intended to damage, detrimentally interfere with, surreptitiously intercept, expropriate or deprive owners' possession of any system, data or personal information, or that in any way violates any law, statute, ordinance, regulation or rights (including any law, regulations or rights respecting intellectual property, computer spyware, privacy, export control, unfair competition, antidiscrimination or false advertising), or otherwise interferes with the operability of Adobe Products or third-party programs or software.
|
|
66
66
|
|
|
67
67
|
5. **NON-BLOCKING OF ADOBE DEVELOPMENT**
|
|
68
68
|
|
|
69
|
-
You acknowledge that Adobe is currently developing or may develop technologies and Adobe Products in the future that have, or may have, design or functionality similar to Developer Products that you may develop based on the license granted to you in this agreement. Nothing in this agreement will impair, limit or curtail Adobe
|
|
69
|
+
You acknowledge that Adobe is currently developing or may develop technologies and Adobe Products in the future that have, or may have, design or functionality similar to Developer Products that you may develop based on the license granted to you in this agreement. Nothing in this agreement will impair, limit or curtail Adobe's right to continue with its development, maintenance or distribution of Adobe Products. You agree that you will not assert in any way any patent owned by you arising out of or in connection with your use of the Drop-in, or any Drop-in modifications made by you, against Adobe, its customers, subsidiaries or affiliates, or any of their customers, direct or indirect, agents and contractors for the manufacture, use, import, license, offer for sale, or sale of any Adobe Products.
|
|
70
70
|
|
|
71
71
|
6. **OWNERSHIP; INTELLECTUAL PROPERTY RIGHTS**
|
|
72
72
|
|
|
@@ -74,13 +74,13 @@ The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the ter
|
|
|
74
74
|
|
|
75
75
|
6.2 The Drop-in, or any of its component parts, may be supplied to you with certain accompanying proprietary notices, including patent, copyright and trademark notices. You agree to protect all copyright and other ownership interests of Adobe and its licensors in the Drop-in supplied to you under this agreement; to preserve exactly (and not remove or alter) all proprietary notices displayed in or on the Drop-in; to reproduce the same proprietary notices in all copies you make of any portion of the Drop-in.
|
|
76
76
|
|
|
77
|
-
6.3 You agree to include in your Developer Products Adobe
|
|
77
|
+
6.3 You agree to include in your Developer Products Adobe's copyright notices, wherever such notices are customarily posted, in substantially the following form: _Portions of software used to develop this product copyrighted by Adobe and its licensors. All Rights Reserved_.
|
|
78
78
|
|
|
79
79
|
6.4 Nothing in this agreement gives you a right to use the name, logo or trademarks of Adobe or its licensors to market your Developer Products.
|
|
80
80
|
|
|
81
81
|
7. **CONFIDENTIAL INFORMATION**
|
|
82
82
|
|
|
83
|
-
With respect to the API, and any portion, included in the Drop-in (for purposes of this Section,
|
|
83
|
+
With respect to the API, and any portion, included in the Drop-in (for purposes of this Section, "**Adobe Confidential Information**"), you will treat the Adobe Confidential Information, and exercise the same degree of care to protect it, as you afford to your own confidential information. Your obligations under this Section will terminate when you can document that (a) the Adobe Confidential Information was in the public domain at or subsequent to the time Adobe communicated or provided it to you with no fault of your own; (b) your employees or agents developed independently without reference to any Adobe Confidential Information Adobe communicated or provided to you; or (c) your communication of Adobe Confidential Information was in response to a valid order by a court or other governmental body, was otherwise required by law, or was necessary to establish the rights of a party under this agreement.
|
|
84
84
|
|
|
85
85
|
8. **TERM; TERMINATION**
|
|
86
86
|
|
|
@@ -90,13 +90,13 @@ The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the ter
|
|
|
90
90
|
|
|
91
91
|
You expressly understand and agree that, to the maximum extent permitted by applicable law:
|
|
92
92
|
|
|
93
|
-
9.1 **Use OF THE DROP-IN is entirely at your own risk. The Drop-in is provided by Adobe
|
|
93
|
+
9.1 **Use OF THE DROP-IN is entirely at your own risk. The Drop-in is provided by Adobe "AS-IS" and with all faults. Adobe and its licensors are not liable to you or anyone else for any special, incidental, indirect, consequential, or punitive damages whatsoever (even if Adobe has been advised of the possibility of such damages), including (a) damages resulting from loss of use, data, or profits, whether or not foreseeable, (b) damages based on any theory of liability, including breach of contract or warranty, negligence or other tortious action, or (c) damages arising from any other claim arising out of or in connection with your use of the Drop-in.**
|
|
94
94
|
|
|
95
|
-
9.2 **Adobe
|
|
95
|
+
9.2 **Adobe's total liability in any matter arising out of or related to these terms is limited to US $100. This limitation will apply even if Adobe has been advised of the possibility of such damages and regardless of any failure of the essential purpose of any limited remedy.**
|
|
96
96
|
|
|
97
97
|
10. **INDEMNIFICATION**
|
|
98
98
|
|
|
99
|
-
To the maximum extent permitted by law, you agree to indemnify Adobe, its subsidiaries, affiliates, officers, agents, employees, partners, licensors, or suppliers from any claim or demand, including reasonable attorneys
|
|
99
|
+
To the maximum extent permitted by law, you agree to indemnify Adobe, its subsidiaries, affiliates, officers, agents, employees, partners, licensors, or suppliers from any claim or demand, including reasonable attorneys' fees, that arise from the use and distribution of your Developer Products that contain or are based upon any portion of the Drop-in, or from your violation of the terms of this agreement.
|
|
100
100
|
|
|
101
101
|
11. **DISPUTE RESOLUTION**
|
|
102
102
|
|
|
@@ -104,7 +104,7 @@ The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the ter
|
|
|
104
104
|
|
|
105
105
|
11.2 **Venue.** You agree that any claim or dispute you may have against Adobe must be resolved by a court located in Santa Clara County, California, United States of America. You agree to submit to the personal jurisdiction of the courts located in Santa Clara County, California, United States of America when the laws of California apply, and the courts of Dublin, Ireland, when the laws of Ireland applies, for the purpose of litigating such claims or disputes. The parties specifically disclaim the U.N. Convention on Contracts for the International Sale of Goods.
|
|
106
106
|
|
|
107
|
-
11.3 **Injunctive Relief.** Notwithstanding the foregoing, in the event of your or others
|
|
107
|
+
11.3 **Injunctive Relief.** Notwithstanding the foregoing, in the event of your or others' unauthorized access to or use of the Drop-in in violation of this Agreement, you agree that Adobe is entitled to apply for injunctive remedies (or an equivalent type of urgent legal relief) in any jurisdiction.
|
|
108
108
|
|
|
109
109
|
12. **EXPORT RULES**
|
|
110
110
|
|
|
@@ -112,7 +112,7 @@ The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the ter
|
|
|
112
112
|
|
|
113
113
|
13. **NOTICE TO U.S. GOVERNMENT END USERS**
|
|
114
114
|
|
|
115
|
-
Products and services are
|
|
115
|
+
Products and services are "Commercial Product(s)," and "Commercial Service(s)" as those terms are defined at 48 C.F.R. section 2.101, consisting of "Commercial Computer Software" and "Commercial Computer Software Documentation," as the terms are used in 48 C.F.R. section 12.212 or 48 C.F.R. section 227.7202, as applicable. Customer agrees, consistent with 48 C.F.R. section 12.212 or 48 C.F.R. sections 227.7202-1 through 227.72024, as applicable, the Commercial Computer Software and Commercial Computer Software Documentation are being licensed to U.S. Government end users (A) only as Commercial Products and Services; and (B) with only those rights as are granted to all other end users pursuant to the terms and conditions herein. Unpublished rights are reserved under the copyright laws of the United States.
|
|
116
116
|
|
|
117
117
|
14. **GENERAL PROVISIONS**
|
|
118
118
|
|
|
@@ -124,4 +124,4 @@ The Adobe Commerce Drop-in (“Drop-in”) is licensed to you subject to the ter
|
|
|
124
124
|
|
|
125
125
|
14.4 **Entire Agreement.** This Agreement is the entire agreement, superseding any prior written or oral agreements, between you and Adobe relating to the Drop-in.
|
|
126
126
|
|
|
127
|
-
Adobe Commerce Drop-in License Agreement_en_US-
|
|
127
|
+
Adobe Commerce Drop-in License Agreement_en_US-20251208_v1
|
package/chunks/acdlEvents.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
const f="searchInputContext",C="searchResultsContext",w="livesearch-plp",N="livesearch-popover",_="search-product-click",I="search-request-sent",b="search-response-received",T="search-results-view",i="category-results-view",y="channelContext";function g(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function R(s){const t=g();return t.getState?t.getState(s):{}}function S(s,t){const n=g();n.push({[s]:null}),n.push({[s]:t})}function x(){return{_id:"https://ns.adobe.com/xdm/channels/web",_type:"https://ns.adobe.com/xdm/channel-types/web"}}function l(){S(y,x())}function h(s,t){g().push(c=>{const e=c.getState?c.getState():{};c.push({event:s,eventInfo:{...e,...t}})})}const v=s=>{l(),h(I,{searchUnitId:s})},P=s=>{l(),h(b,{searchUnitId:s})},A=s=>{h(i,{searchUnitId:s})},k=s=>{h(T,{searchUnitId:s})},H=(s,t)=>{h(_,{sku:s,searchUnitId:t})},O=(s,t,n,c,e,o,r)=>{if(!g)return;const a=R(f)||{};a!=null&&a.units||(a.units=[]);const u={searchUnitId:s,searchRequestId:t,queryTypes:["products","suggestions"],phrase:n,pageSize:e,currentPage:o,filter:c,sort:r},d=a.units.findIndex(E=>E.searchUnitId===s);d<0?a.units.push(u):a.units[d]=u,S(f,a)},V=(s,t,n)=>{var p,a;if(!g)return;const e=R(C)||{};e!=null&&e.units||(e.units=[]);const o=e.units.findIndex(u=>u.searchUnitId===s),r={searchUnitId:s,searchRequestId:t,products:L(n.items),categories:[],suggestions:D(n.suggestions),page:((p=n==null?void 0:n.pageInfo)==null?void 0:p.currentPage)||1,perPage:((a=n==null?void 0:n.pageInfo)==null?void 0:a.pageSize)||20,facets:U(n.facets)};o<0?e.units.push(r):e.units[o]=r,S(C,e)},L=s=>s?s.map((n,c)=>{var e,o,r,p,a,u,d,E;return{name:n==null?void 0:n.name,sku:n==null?void 0:n.sku,url:(n==null?void 0:n.url)??"",imageUrl:((e=n==null?void 0:n.images[0])==null?void 0:e.url)??"",price:((p=(r=(o=n==null?void 0:n.price)==null?void 0:o.final)==null?void 0:r.amount)==null?void 0:p.value)??((E=(d=(u=(a=n==null?void 0:n.priceRange)==null?void 0:a.minimum)==null?void 0:u.regular)==null?void 0:d.amount)==null?void 0:E.value),rank:c}}):[],D=s=>s?s.map((n,c)=>({suggestion:n,rank:c})):[],U=s=>s?s.map(n=>({attribute:n==null?void 0:n.attribute,title:n==null?void 0:n.title,type:(n==null?void 0:n.type)||"PINNED",buckets:n==null?void 0:n.buckets.map(c=>c)})):[];export{w as P,N as S,
|
|
3
|
+
const f="searchInputContext",C="searchResultsContext",w="livesearch-plp",N="livesearch-popover",_="search-product-click",I="search-request-sent",b="search-response-received",T="search-results-view",i="category-results-view",y="channelContext";function g(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function R(s){const t=g();return t.getState?t.getState(s):{}}function S(s,t){const n=g();n.push({[s]:null}),n.push({[s]:t})}function x(){return{_id:"https://ns.adobe.com/xdm/channels/web",_type:"https://ns.adobe.com/xdm/channel-types/web"}}function l(){S(y,x())}function h(s,t){g().push(c=>{const e=c.getState?c.getState():{};c.push({event:s,eventInfo:{...e,...t}})})}const v=s=>{l(),h(I,{searchUnitId:s})},P=s=>{l(),h(b,{searchUnitId:s})},A=s=>{h(i,{searchUnitId:s})},k=s=>{h(T,{searchUnitId:s})},H=(s,t)=>{h(_,{sku:s,searchUnitId:t})},O=(s,t,n,c,e,o,r)=>{if(!g)return;const a=R(f)||{};a!=null&&a.units||(a.units=[]);const u={searchUnitId:s,searchRequestId:t,queryTypes:["products","suggestions"],phrase:n,pageSize:e,currentPage:o,filter:c,sort:r},d=a.units.findIndex(E=>E.searchUnitId===s);d<0?a.units.push(u):a.units[d]=u,S(f,a)},V=(s,t,n)=>{var p,a;if(!g)return;const e=R(C)||{};e!=null&&e.units||(e.units=[]);const o=e.units.findIndex(u=>u.searchUnitId===s),r={searchUnitId:s,searchRequestId:t,products:L(n.items),categories:[],suggestions:D(n.suggestions),page:((p=n==null?void 0:n.pageInfo)==null?void 0:p.currentPage)||1,perPage:((a=n==null?void 0:n.pageInfo)==null?void 0:a.pageSize)||20,facets:U(n.facets)};o<0?e.units.push(r):e.units[o]=r,S(C,e)},L=s=>s?s.map((n,c)=>{var e,o,r,p,a,u,d,E;return{name:n==null?void 0:n.name,sku:n==null?void 0:n.sku,url:(n==null?void 0:n.url)??"",imageUrl:((e=n==null?void 0:n.images[0])==null?void 0:e.url)??"",price:((p=(r=(o=n==null?void 0:n.price)==null?void 0:o.final)==null?void 0:r.amount)==null?void 0:p.value)??((E=(d=(u=(a=n==null?void 0:n.priceRange)==null?void 0:a.minimum)==null?void 0:u.regular)==null?void 0:d.amount)==null?void 0:E.value),rank:c}}):[],D=s=>s?s.map((n,c)=>({suggestion:n,rank:c})):[],U=s=>s?s.map(n=>({attribute:n==null?void 0:n.attribute,title:n==null?void 0:n.title,type:(n==null?void 0:n.type)||"PINNED",buckets:n==null?void 0:n.buckets.map(c=>c)})):[];export{w as P,N as S,V as a,P as b,k as c,A as d,H as e,v as s,O as u};
|
|
4
4
|
//# sourceMappingURL=acdlEvents.js.map
|
package/chunks/search.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{merge as
|
|
3
|
+
import{merge as re}from"@dropins/tools/lib.js";import{c as ne}from"./initialize.js";import{events as _}from"@dropins/tools/event-bus.js";import{ProductView as ie,Facet as oe}from"../fragments.js";import{S as se,P as te,u as le,s as ue,a as ce,b as me}from"./acdlEvents.js";import{FetchGraphQL as pe}from"@dropins/tools/fetch-graphql.js";const{setEndpoint:be,setFetchGraphQlHeader:xe,removeFetchGraphQlHeader:$e,setFetchGraphQlHeaders:De,getFetchGraphQlHeader:Fe,fetchGraphQl:ge,getConfig:Ae}=new pe().getMethods(),C=e=>!e||!Intl.supportedValuesOf("currency").includes(e)?"USD":e,fe=e=>{var r,s,n,l,u,f,h,p,y,c,P,g,I,R,i,m,t,v,w,x,$,D,F,A,T,U,E,k,z,Q,G,H,K,O,M,L,N,j,Y,B,J,W,X,Z,V,q,a,S,d;if(!e)return{id:"",name:"",sku:"",shortDescription:"",url:"",urlKey:"",metaTitle:"",metaKeywords:"",metaDescription:"",lowStock:!1,links:[],images:[],description:"",externalId:"",inputOptions:[],addToCartAllowed:!1,price:void 0,priceRange:void 0,inStock:!1,typename:""};const o={id:(e==null?void 0:e.id)||"",name:(e==null?void 0:e.name)||"",sku:(e==null?void 0:e.sku)||"",shortDescription:(e==null?void 0:e.shortDescription)||"",url:(e==null?void 0:e.url)||"",urlKey:(e==null?void 0:e.urlKey)||"",metaTitle:(e==null?void 0:e.metaTitle)||"",metaKeywords:(e==null?void 0:e.metaKeywords)||"",metaDescription:(e==null?void 0:e.metaDescription)||"",lowStock:(e==null?void 0:e.lowStock)||!1,links:(e==null?void 0:e.links)||[],images:((r=e==null?void 0:e.images)==null?void 0:r.map(b=>{var ee;return{label:b.label||"",roles:b.roles||[],url:((ee=b.url)==null?void 0:ee.replace(/^https?:\/\//,"//"))||""}}))||[],description:(e==null?void 0:e.description)||"",externalId:(e==null?void 0:e.externalId)||"",inputOptions:(e==null?void 0:e.inputOptions)||[],addToCartAllowed:(e==null?void 0:e.addToCartAllowed)||!1,price:e.price?{final:{amount:{value:((l=(n=(s=e==null?void 0:e.price)==null?void 0:s.final)==null?void 0:n.amount)==null?void 0:l.value)||0,currency:C((h=(f=(u=e==null?void 0:e.price)==null?void 0:u.final)==null?void 0:f.amount)==null?void 0:h.currency)}},regular:{amount:{value:((c=(y=(p=e==null?void 0:e.price)==null?void 0:p.regular)==null?void 0:y.amount)==null?void 0:c.value)||0,currency:C((I=(g=(P=e==null?void 0:e.price)==null?void 0:P.regular)==null?void 0:g.amount)==null?void 0:I.currency)}},roles:((R=e==null?void 0:e.price)==null?void 0:R.roles)||[]}:void 0,priceRange:e!=null&&e.priceRange?{minimum:{final:{amount:{value:((v=(t=(m=(i=e==null?void 0:e.priceRange)==null?void 0:i.minimum)==null?void 0:m.final)==null?void 0:t.amount)==null?void 0:v.value)||0,currency:C((D=($=(x=(w=e==null?void 0:e.priceRange)==null?void 0:w.minimum)==null?void 0:x.final)==null?void 0:$.amount)==null?void 0:D.currency)}},regular:{amount:{value:((U=(T=(A=(F=e==null?void 0:e.priceRange)==null?void 0:F.minimum)==null?void 0:A.regular)==null?void 0:T.amount)==null?void 0:U.value)||0,currency:C((Q=(z=(k=(E=e==null?void 0:e.priceRange)==null?void 0:E.minimum)==null?void 0:k.regular)==null?void 0:z.amount)==null?void 0:Q.currency)}}},maximum:{final:{amount:{value:((O=(K=(H=(G=e==null?void 0:e.priceRange)==null?void 0:G.maximum)==null?void 0:H.final)==null?void 0:K.amount)==null?void 0:O.value)||0,currency:C((j=(N=(L=(M=e==null?void 0:e.priceRange)==null?void 0:M.maximum)==null?void 0:L.final)==null?void 0:N.amount)==null?void 0:j.currency)}},regular:{amount:{value:((W=(J=(B=(Y=e==null?void 0:e.priceRange)==null?void 0:Y.maximum)==null?void 0:B.regular)==null?void 0:J.amount)==null?void 0:W.value)||0,currency:C((q=(V=(Z=(X=e==null?void 0:e.priceRange)==null?void 0:X.maximum)==null?void 0:Z.regular)==null?void 0:V.amount)==null?void 0:q.currency)}}}}:void 0,inStock:(e==null?void 0:e.inStock)||!1,typename:(e==null?void 0:e.__typename)||""};return re(o,(d=(S=(a=ne.getConfig().models)==null?void 0:a.Product)==null?void 0:S.transformer)==null?void 0:d.call(S,e))};function he(e,o){var n,l,u,f,h,p,y,c,P;const r=e==null?void 0:e.productSearch,s={facets:Pe((r==null?void 0:r.facets)||[],o),items:(r==null?void 0:r.items.map(g=>fe(g==null?void 0:g.productView)))||[],pageInfo:{currentPage:((n=r==null?void 0:r.page_info)==null?void 0:n.current_page)||1,totalPages:((l=r==null?void 0:r.page_info)==null?void 0:l.total_pages)||1,totalItems:((u=r==null?void 0:r.page_info)==null?void 0:u.total_items)||0,pageSize:((f=r==null?void 0:r.page_info)==null?void 0:f.page_size)||10},totalCount:(r==null?void 0:r.total_count)||0,metadata:{filterableAttributes:((h=e==null?void 0:e.attributeMetadata)==null?void 0:h.filterableInSearch)||[],sortableAttributes:ye(((p=e==null?void 0:e.attributeMetadata)==null?void 0:p.sortable)||[],o)}};return re(s,(P=(c=(y=ne.getConfig().models)==null?void 0:y.ProductSearchResult)==null?void 0:c.transformer)==null?void 0:P.call(c,e))}function ye(e=[],o){return!e||e.length===0?[]:e.filter(r=>{var s;return r.attribute==="position"?(s=o==null?void 0:o.filter)==null?void 0:s.some(l=>l.attribute==="categoryPath"):!0}).map(r=>({...r,bidirectional:r.attribute==="price"}))}function Pe(e=[],o){var s;return!e||e.length===0?[]:((s=o==null?void 0:o.filter)==null?void 0:s.some(n=>n.attribute==="categoryPath"))?e.filter(n=>n.attribute!=="categories"):e}const ve=`
|
|
4
4
|
query productSearch(
|
|
5
5
|
$phrase: String!
|
|
6
6
|
$pageSize: Int
|
|
@@ -44,7 +44,7 @@ import{merge as ee}from"@dropins/tools/lib.js";import{c as re}from"./initialize.
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
${ne}
|
|
48
47
|
${ie}
|
|
49
|
-
|
|
48
|
+
${oe}
|
|
49
|
+
`,Te=async(e,o={})=>{const r=o.scope==="search"?void 0:o.scope,s={request:e||{},result:{facets:[],pageInfo:{currentPage:0,totalPages:0,totalItems:0,pageSize:0},items:[],totalCount:0,suggestions:[],metadata:{filterableAttributes:[],sortableAttributes:[]}}};if(e===null)return _.emit("search/result",s,{scope:r}),s.result;_.emit("search/loading",!0,{scope:r});try{const n=r==="popover"?se:te,l=window.crypto.randomUUID(),u=new URLSearchParams(window.location.search),f=Number(u.get("page"))||1,h=u.get("q")??void 0,p=u.get("sort"),y=p?p.split(",").map(i=>{let m=i,t="ASC";if(i.includes(":"))[m,t]=i.split(":");else if(i.includes("_")){const[v,w]=i.split("_");m=v,t=w==="DESC"?"DESC":"ASC"}return{attribute:m,direction:t}}):void 0,c=u.get("filter"),P=c?Object.entries(decodeURIComponent(c).split(",").reduce((i,m)=>{const[t,v]=m.split(":");return t&&(i[t]??(i[t]=[]),v&&i[t].push(v.trim())),i},{})).map(([i,m])=>({attribute:i,eq:m.join(",")})):void 0;e={...e,sort:y??e.sort,filter:P??e.filter,phrase:h??e.phrase,currentPage:f},le(n,l,e.phrase||"",e.filter||[],e.pageSize||0,e.currentPage||0,e.sort||[]),ue(n);const{errors:g,data:I}=await ge(ve,{method:"GET",variables:{...e}});if(g&&!I)throw new Error("Error fetching product search");const R=he(I,e);return ce(n,l,R),me(n),_.emit("search/result",{request:e,result:R},{scope:r}),R}catch(n){throw _.emit("search/error",n.message,{scope:r}),_.emit("search/result",s,{scope:r}),n}finally{_.emit("search/loading",!1,{scope:r})}};export{xe as a,De as b,Ae as c,Te as d,ge as f,Fe as g,$e as r,be as s};
|
|
50
50
|
//# sourceMappingURL=search.js.map
|
package/chunks/search.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"search.js","sources":["/@dropins/storefront-product-discovery/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-product-discovery/src/data/transforms/product.ts","/@dropins/storefront-product-discovery/src/data/transforms/api.ts","/@dropins/storefront-product-discovery/src/api/search/graphql/search.graphql.ts","/@dropins/storefront-product-discovery/src/api/search/search.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n getFetchGraphQlHeader,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\nimport { merge } from '@adobe-commerce/elsie/lib';\nimport { config } from '@/plp/api/initialize/initialize';\nimport { Product } from '../models/product';\n\nexport const transformProduct = (data: any): Product | null => {\n // check if data is null or undefined, and if so return an empty object\n if (!data) {\n return {\n id: '',\n name: '',\n sku: '',\n shortDescription: '',\n url: '',\n urlKey: '',\n metaTitle: '',\n metaKeywords: '',\n metaDescription: '',\n lowStock: false,\n links: [],\n images: [],\n description: '',\n externalId: '',\n inputOptions: [],\n addToCartAllowed: false,\n price: undefined,\n priceRange: undefined,\n inStock: false,\n typename: '',\n };\n }\n\n const transformedProduct = {\n id: data?.id || '',\n name: data?.name || '',\n sku: data?.sku || '',\n shortDescription: data?.shortDescription || '',\n url: data?.url || '',\n urlKey: data?.urlKey || '',\n metaTitle: data?.metaTitle || '',\n metaKeywords: data?.metaKeywords || '',\n metaDescription: data?.metaDescription || '',\n lowStock: data?.lowStock || false,\n links: data?.links || [],\n images:\n data?.images?.map((image: any) => ({\n label: image.label || '',\n roles: image.roles || [],\n url: image.url?.replace(/^https?:\\/\\//, '//') || '',\n })) || [],\n description: data?.description || '',\n externalId: data?.externalId || '',\n inputOptions: data?.inputOptions || [],\n addToCartAllowed: data?.addToCartAllowed || false,\n price: data.price\n ? {\n final: {\n amount: {\n value: data?.price?.final?.amount?.value || 0,\n currency: data?.price?.final?.amount?.currency || '',\n },\n },\n regular: {\n amount: {\n value: data?.price?.regular?.amount?.value || 0,\n currency: data?.price?.regular?.amount?.currency || '',\n },\n },\n roles: data?.price?.roles || [],\n }\n : undefined,\n priceRange: data?.priceRange\n ? {\n minimum: {\n final: {\n amount: {\n value: data?.priceRange?.minimum?.final?.amount?.value || 0,\n currency: data?.priceRange?.minimum?.final?.amount?.currency || '',\n },\n },\n regular: {\n amount: {\n value: data?.priceRange?.minimum?.regular?.amount?.value || 0,\n currency: data?.priceRange?.minimum?.regular?.amount?.currency || '',\n },\n },\n },\n maximum: {\n final: {\n amount: {\n value: data?.priceRange?.maximum?.final?.amount?.value || 0,\n currency: data?.priceRange?.maximum?.final?.amount?.currency || '',\n },\n },\n regular: {\n amount: {\n value: data?.priceRange?.maximum?.regular?.amount?.value || 0,\n currency: data?.priceRange?.maximum?.regular?.amount?.currency || '',\n },\n },\n },\n }\n : undefined,\n inStock: data?.inStock || false,\n typename: data?.__typename || '',\n };\n\n return merge(\n transformedProduct, // default transformer\n config.getConfig().models?.Product?.transformer?.(data), // custom transformer\n )\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\nimport { merge } from '@adobe-commerce/elsie/lib';\nimport { config } from '@/plp/api/initialize/initialize';\nimport { ProductSearchResult, SearchVariables } from '@/plp/data/models';\nimport { Product } from '@/plp/data/models/product';\n\nimport { transformProduct } from './product';\n\n\nexport function transformProductSearchResponse(data: any, searchVariables?: SearchVariables): ProductSearchResult {\n const productSearch = data?.productSearch;\n\n const transformedResponse: ProductSearchResult = {\n facets: transformFacets(productSearch?.facets || [], searchVariables),\n items: productSearch?.items.map((product: any) => transformProduct(product?.productView)) || [],\n pageInfo: {\n currentPage: productSearch?.page_info?.current_page || 1,\n totalPages: productSearch?.page_info?.total_pages || 1,\n totalItems: productSearch?.page_info?.total_items || 0,\n pageSize: productSearch?.page_info?.page_size || 10, //replace with default constant\n },\n totalCount: productSearch?.total_count || 0,\n metadata: {\n filterableAttributes: data?.attributeMetadata?.filterableInSearch || [],\n sortableAttributes: transformSortAttributes(data?.attributeMetadata?.sortable || [], searchVariables),\n }\n };\n return merge(\n transformedResponse, // default transformer\n config.getConfig().models?.ProductSearchResult?.transformer?.(data), // custom transformer\n );\n}\n\nexport const transformSearchResultProducts = (searchResponse: { productSearch: { items: any[] } }): Product[] =>\n searchResponse?.productSearch?.items?.reduce<Product[]>((returnedProductList, productItem) => {\n if (!productItem?.productView) return returnedProductList; // Skip if no productView and product is null\n\n const transformed = transformProduct(productItem.productView);\n if (transformed) {\n returnedProductList.push(transformed);\n }\n\n return returnedProductList;\n }, []) || [];\n\nfunction transformSortAttributes(sortableAttributes: any[] = [], searchVariables?: SearchVariables): any[] {\n if (!sortableAttributes || sortableAttributes.length === 0) {\n return [];\n }\n\n return sortableAttributes\n .filter((option) => {\n // Only include position attribute if there's a category filter\n if (option.attribute === 'position') {\n const hasCategoryFilter = searchVariables?.filter?.some(\n (filter) => filter.attribute === 'categoryPath'\n );\n return hasCategoryFilter;\n }\n\n // Include all other attributes\n return true;\n })\n .map((option) => ({\n ...option,\n bidirectional: option.attribute === 'price',\n }));\n}\n\nfunction transformFacets(facets: any[] = [], searchVariables?: SearchVariables): any[] {\n if (!facets || facets.length === 0) {\n return [];\n }\n\n const hasCategoryPathFilter = searchVariables?.filter?.some(\n (filter) => filter.attribute === 'categoryPath'\n );\n\n // if hasCategoryPathFilter, then we need to remove facets with attribute 'categories'\n if (hasCategoryPathFilter) {\n return facets.filter((facet) => facet.attribute !== 'categories');\n }\n\n return facets;\n}\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { Facet, ProductView } from '../../graphql/fragments.graphql';\n\nconst PRODUCT_SEARCH_QUERY = /* GraphQL */ `\n query productSearch(\n $phrase: String!\n $pageSize: Int\n $currentPage: Int = 1\n $filter: [SearchClauseInput!]\n $sort: [ProductSearchSortInput!]\n $context: QueryContextInput\n ) {\n attributeMetadata {\n sortable {\n label\n attribute\n numeric\n }\n filterableInSearch {\n label\n attribute\n numeric\n }\n }\n\n productSearch(\n phrase: $phrase\n page_size: $pageSize\n current_page: $currentPage\n filter: $filter\n sort: $sort\n context: $context\n ) {\n total_count\n items {\n ...ProductView\n }\n facets {\n ...Facet\n }\n page_info {\n current_page\n page_size\n total_pages\n }\n }\n }\n ${ProductView}\n ${Facet}\n`;\n\nexport { PRODUCT_SEARCH_QUERY };\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { ProductSearchResult, Scope, SearchVariables } from '@/plp/data/models';\nimport { fetchGraphQl } from '@/plp/api';\nimport { transformProductSearchResponse } from '@/plp/data/transforms';\nimport { events } from '@adobe-commerce/event-bus';\nimport { PRODUCT_SEARCH_QUERY } from './graphql/search.graphql';\nimport { \n searchRequestSent, \n searchResponseReceived, \n updateSearchInputCtx,\n updateSearchResultsCtx,\n SEARCH_UNIT_ID, \n PLP_UNIT_ID,\n} from '@/plp/utils/acdlEvents';\n\ntype SearchOptions = {\n scope?: Scope;\n}\n\nexport const search = async (request: SearchVariables | null, options: SearchOptions = {}): Promise<ProductSearchResult> => {\n const scope = options.scope === 'search' ? undefined : options.scope;\n\n // empty result\n const emptyResult = {\n request: request || {} ,\n result: {\n facets: [],\n pageInfo: { currentPage: 0, totalPages: 0, totalItems: 0, pageSize: 0 },\n items: [],\n totalCount: 0,\n suggestions: [],\n metadata: {\n filterableAttributes: [],\n sortableAttributes: []\n }\n }\n };\n\n // clear search results if no request are provided\n if (request === null) {\n events.emit('search/result', emptyResult, { scope });\n return emptyResult.result;\n }\n\n\n // Emit loading state\n events.emit('search/loading', true, { scope });\n\n try {\n const acdlUnitId = scope === 'popover' ? SEARCH_UNIT_ID : PLP_UNIT_ID;\n const searchRequestId = window.crypto.randomUUID();\n\n // Update search input context in ACDL\n updateSearchInputCtx(\n acdlUnitId,\n searchRequestId,\n request.phrase || '',\n request.filter || [],\n request.pageSize || 0,\n request.currentPage || 0,\n request.sort || [],\n );\n\n // Publish search request event to ACDL\n searchRequestSent(acdlUnitId);\n\n // Execute search with validated request\n const { errors, data } = await fetchGraphQl(PRODUCT_SEARCH_QUERY, {\n method: 'GET',\n variables: { ...request },\n });\n\n if (errors && !data) {\n throw new Error('Error fetching product search');\n }\n\n const result = transformProductSearchResponse(data, request);\n\n // Update search results context in ACDL\n updateSearchResultsCtx(acdlUnitId, searchRequestId, result);\n\n // Publish search response event to ACDL\n searchResponseReceived(acdlUnitId)\n\n // Emit single event with result and metadata\n events.emit('search/result', { request, result }, { scope });\n\n return result;\n\n } catch (error) {\n // Emit error event\n events.emit('search/error', (error as Error).message, { scope });\n\n // Emit result event with empty result\n events.emit('search/result', emptyResult, { scope });\n\n throw error;\n } finally {\n // Reset loading state\n events.emit('search/loading', false, { scope });\n }\n};"],"names":["setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","getFetchGraphQlHeader","fetchGraphQl","getConfig","FetchGraphQL","transformProduct","data","transformedProduct","_a","image","_d","_c","_b","_g","_f","_e","_j","_i","_h","_m","_l","_k","_n","_r","_q","_p","_o","_v","_u","_t","_s","_z","_y","_x","_w","_D","_C","_B","_A","_H","_G","_F","_E","_L","_K","_J","_I","_P","_O","_N","_M","_T","_S","_R","_Q","merge","_W","_V","_U","config","transformProductSearchResponse","searchVariables","productSearch","transformedResponse","transformFacets","product","transformSortAttributes","sortableAttributes","option","filter","facets","facet","PRODUCT_SEARCH_QUERY","ProductView","Facet","search","request","options","scope","emptyResult","events","acdlUnitId","SEARCH_UNIT_ID","PLP_UNIT_ID","searchRequestId","updateSearchInputCtx","searchRequestSent","errors","result","updateSearchResultsCtx","searchResponseReceived","error"],"mappings":"iVAWO,KAAM,CACX,YAAAA,GACA,sBAAAC,GACA,yBAAAC,GACA,uBAAAC,GACA,sBAAAC,GACA,aAAAC,GACA,UAAA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AAA,CAAC,EAInBU,GAAkBL,CAAU,EAG5B,KAAM,CAAE,OAAAM,EAAQ,KAAAjF,CAAA,EAAS,MAAMJ,GAAasE,GAAsB,CAChE,OAAQ,MACR,UAAW,CAAE,GAAGI,CAAA,CAAQ,CACzB,EAED,GAAIW,GAAU,CAACjF,EACb,MAAM,IAAI,MAAM,+BAA+B,EAGjD,MAAMkF,EAAS5B,GAA+BtD,EAAMsE,CAAO,EAG3D,OAAAa,GAAuBR,EAAYG,EAAiBI,CAAM,EAG1DE,GAAuBT,CAAU,EAGjCD,EAAO,KAAK,gBAAiB,CAAE,QAAAJ,EAAS,OAAAY,GAAU,CAAE,MAAAV,EAAO,EAEpDU,CAET,OAASG,EAAO,CAEd,MAAAX,EAAO,KAAK,eAAiBW,EAAgB,QAAS,CAAE,MAAAb,EAAO,EAG/DE,EAAO,KAAK,gBAAiBD,EAAa,CAAE,MAAAD,EAAO,EAE7Ca,CACR,QAAA,CAEEX,EAAO,KAAK,iBAAkB,GAAO,CAAE,MAAAF,EAAO,CAChD,CACF"}
|
|
1
|
+
{"version":3,"file":"search.js","sources":["/@dropins/storefront-product-discovery/src/api/fetch-graphql/fetch-graphql.ts","/@dropins/storefront-product-discovery/src/data/transforms/product.ts","/@dropins/storefront-product-discovery/src/data/transforms/api.ts","/@dropins/storefront-product-discovery/src/api/search/graphql/search.graphql.ts","/@dropins/storefront-product-discovery/src/api/search/search.ts"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { FetchGraphQL } from '@adobe-commerce/fetch-graphql';\n\nexport const {\n setEndpoint,\n setFetchGraphQlHeader,\n removeFetchGraphQlHeader,\n setFetchGraphQlHeaders,\n getFetchGraphQlHeader,\n fetchGraphQl,\n getConfig,\n} = new FetchGraphQL().getMethods();\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\nimport { merge } from '@adobe-commerce/elsie/lib';\nimport { config } from '@/plp/api/initialize/initialize';\nimport { Product } from '../models/product';\n\nconst getCurrency = (currency?: string) => {\n if (!currency || !Intl.supportedValuesOf(\"currency\").includes(currency)) {\n return 'USD';\n }\n return currency;\n};\n\nexport const transformProduct = (data: any): Product | null => {\n // check if data is null or undefined, and if so return an empty object\n if (!data) {\n return {\n id: '',\n name: '',\n sku: '',\n shortDescription: '',\n url: '',\n urlKey: '',\n metaTitle: '',\n metaKeywords: '',\n metaDescription: '',\n lowStock: false,\n links: [],\n images: [],\n description: '',\n externalId: '',\n inputOptions: [],\n addToCartAllowed: false,\n price: undefined,\n priceRange: undefined,\n inStock: false,\n typename: '',\n };\n }\n\n const transformedProduct = {\n id: data?.id || '',\n name: data?.name || '',\n sku: data?.sku || '',\n shortDescription: data?.shortDescription || '',\n url: data?.url || '',\n urlKey: data?.urlKey || '',\n metaTitle: data?.metaTitle || '',\n metaKeywords: data?.metaKeywords || '',\n metaDescription: data?.metaDescription || '',\n lowStock: data?.lowStock || false,\n links: data?.links || [],\n images:\n data?.images?.map((image: any) => ({\n label: image.label || '',\n roles: image.roles || [],\n url: image.url?.replace(/^https?:\\/\\//, '//') || '',\n })) || [],\n description: data?.description || '',\n externalId: data?.externalId || '',\n inputOptions: data?.inputOptions || [],\n addToCartAllowed: data?.addToCartAllowed || false,\n price: data.price\n ? {\n final: {\n amount: {\n value: data?.price?.final?.amount?.value || 0,\n currency: getCurrency(data?.price?.final?.amount?.currency),\n },\n },\n regular: {\n amount: {\n value: data?.price?.regular?.amount?.value || 0,\n currency: getCurrency(data?.price?.regular?.amount?.currency),\n },\n },\n roles: data?.price?.roles || [],\n }\n : undefined,\n priceRange: data?.priceRange\n ? {\n minimum: {\n final: {\n amount: {\n value: data?.priceRange?.minimum?.final?.amount?.value || 0,\n currency: getCurrency(data?.priceRange?.minimum?.final?.amount?.currency),\n },\n },\n regular: {\n amount: {\n value: data?.priceRange?.minimum?.regular?.amount?.value || 0,\n currency: getCurrency(data?.priceRange?.minimum?.regular?.amount?.currency),\n },\n },\n },\n maximum: {\n final: {\n amount: {\n value: data?.priceRange?.maximum?.final?.amount?.value || 0,\n currency: getCurrency(data?.priceRange?.maximum?.final?.amount?.currency),\n },\n },\n regular: {\n amount: {\n value: data?.priceRange?.maximum?.regular?.amount?.value || 0,\n currency: getCurrency(data?.priceRange?.maximum?.regular?.amount?.currency),\n },\n },\n },\n }\n : undefined,\n inStock: data?.inStock || false,\n typename: data?.__typename || '',\n };\n\n return merge(\n transformedProduct, // default transformer\n config.getConfig().models?.Product?.transformer?.(data), // custom transformer\n )\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\nimport { merge } from '@adobe-commerce/elsie/lib';\nimport { config } from '@/plp/api/initialize/initialize';\nimport { ProductSearchResult, SearchVariables } from '@/plp/data/models';\nimport { Product } from '@/plp/data/models/product';\n\nimport { transformProduct } from './product';\n\n\nexport function transformProductSearchResponse(data: any, searchVariables?: SearchVariables): ProductSearchResult {\n const productSearch = data?.productSearch;\n\n const transformedResponse: ProductSearchResult = {\n facets: transformFacets(productSearch?.facets || [], searchVariables),\n items: productSearch?.items.map((product: any) => transformProduct(product?.productView)) || [],\n pageInfo: {\n currentPage: productSearch?.page_info?.current_page || 1,\n totalPages: productSearch?.page_info?.total_pages || 1,\n totalItems: productSearch?.page_info?.total_items || 0,\n pageSize: productSearch?.page_info?.page_size || 10, //replace with default constant\n },\n totalCount: productSearch?.total_count || 0,\n metadata: {\n filterableAttributes: data?.attributeMetadata?.filterableInSearch || [],\n sortableAttributes: transformSortAttributes(data?.attributeMetadata?.sortable || [], searchVariables),\n }\n };\n return merge(\n transformedResponse, // default transformer\n config.getConfig().models?.ProductSearchResult?.transformer?.(data), // custom transformer\n );\n}\n\nexport const transformSearchResultProducts = (searchResponse: { productSearch: { items: any[] } }): Product[] =>\n searchResponse?.productSearch?.items?.reduce<Product[]>((returnedProductList, productItem) => {\n if (!productItem?.productView) return returnedProductList; // Skip if no productView and product is null\n\n const transformed = transformProduct(productItem.productView);\n if (transformed) {\n returnedProductList.push(transformed);\n }\n\n return returnedProductList;\n }, []) || [];\n\nfunction transformSortAttributes(sortableAttributes: any[] = [], searchVariables?: SearchVariables): any[] {\n if (!sortableAttributes || sortableAttributes.length === 0) {\n return [];\n }\n\n return sortableAttributes\n .filter((option) => {\n // Only include position attribute if there's a category filter\n if (option.attribute === 'position') {\n const hasCategoryFilter = searchVariables?.filter?.some(\n (filter) => filter.attribute === 'categoryPath'\n );\n return hasCategoryFilter;\n }\n\n // Include all other attributes\n return true;\n })\n .map((option) => ({\n ...option,\n bidirectional: option.attribute === 'price',\n }));\n}\n\nfunction transformFacets(facets: any[] = [], searchVariables?: SearchVariables): any[] {\n if (!facets || facets.length === 0) {\n return [];\n }\n\n const hasCategoryPathFilter = searchVariables?.filter?.some(\n (filter) => filter.attribute === 'categoryPath'\n );\n\n // if hasCategoryPathFilter, then we need to remove facets with attribute 'categories'\n if (hasCategoryPathFilter) {\n return facets.filter((facet) => facet.attribute !== 'categories');\n }\n\n return facets;\n}\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { Facet, ProductView } from '../../graphql/fragments.graphql';\n\nconst PRODUCT_SEARCH_QUERY = /* GraphQL */ `\n query productSearch(\n $phrase: String!\n $pageSize: Int\n $currentPage: Int = 1\n $filter: [SearchClauseInput!]\n $sort: [ProductSearchSortInput!]\n $context: QueryContextInput\n ) {\n attributeMetadata {\n sortable {\n label\n attribute\n numeric\n }\n filterableInSearch {\n label\n attribute\n numeric\n }\n }\n\n productSearch(\n phrase: $phrase\n page_size: $pageSize\n current_page: $currentPage\n filter: $filter\n sort: $sort\n context: $context\n ) {\n total_count\n items {\n ...ProductView\n }\n facets {\n ...Facet\n }\n page_info {\n current_page\n page_size\n total_pages\n }\n }\n }\n ${ProductView}\n ${Facet}\n`;\n\nexport { PRODUCT_SEARCH_QUERY };\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { ProductSearchResult, Scope, SearchVariables, SortOrder, SearchFilter } from '@/plp/data/models';\nimport { fetchGraphQl } from '@/plp/api';\nimport { transformProductSearchResponse } from '@/plp/data/transforms';\nimport { events } from '@adobe-commerce/event-bus';\nimport { PRODUCT_SEARCH_QUERY } from './graphql/search.graphql';\nimport { \n searchRequestSent, \n searchResponseReceived, \n updateSearchInputCtx,\n updateSearchResultsCtx,\n SEARCH_UNIT_ID, \n PLP_UNIT_ID,\n} from '@/plp/utils/acdlEvents';\n\ntype SearchOptions = {\n scope?: Scope;\n}\n\nexport const search = async (request: SearchVariables | null, options: SearchOptions = {}): Promise<ProductSearchResult> => {\n const scope = options.scope === 'search' ? undefined : options.scope;\n\n // empty result\n const emptyResult = {\n request: request || {} ,\n result: {\n facets: [],\n pageInfo: { currentPage: 0, totalPages: 0, totalItems: 0, pageSize: 0 },\n items: [],\n totalCount: 0,\n suggestions: [],\n metadata: {\n filterableAttributes: [],\n sortableAttributes: []\n }\n }\n };\n\n // clear search results if no request are provided\n if (request === null) {\n events.emit('search/result', emptyResult, { scope });\n return emptyResult.result;\n }\n\n\n // Emit loading state\n events.emit('search/loading', true, { scope });\n\n try {\n const acdlUnitId = scope === 'popover' ? SEARCH_UNIT_ID : PLP_UNIT_ID;\n const searchRequestId = window.crypto.randomUUID();\n const params = new URLSearchParams(window.location.search);\n \n const currentPage = Number(params.get('page')) || 1;\n const phrase = params.get('q') ?? undefined;\n const sortParam = params.get('sort');\n \n const sort: SortOrder[] | undefined = sortParam\n ? sortParam.split(',').map((token) => {\n let attribute = token;\n let direction: 'ASC' | 'DESC' = 'ASC';\n \n if (token.includes(':')) {\n [attribute, direction] = token.split(':') as [string, 'ASC' | 'DESC'];\n } else if (token.includes('_')) {\n const [attr, dir] = token.split('_');\n attribute = attr;\n direction = dir === 'DESC' ? 'DESC' : 'ASC';\n }\n \n return { attribute, direction };\n })\n : undefined;\n \n const filterParam = params.get('filter');\n \n const filter: SearchFilter[] | undefined = filterParam\n ? Object.entries(\n decodeURIComponent(filterParam)\n .split(',')\n .reduce<Record<string, string[]>>((acc, part) => {\n const [attr, value] = part.split(':');\n if (!attr) return acc;\n acc[attr] ??= [];\n if (value) acc[attr].push(value.trim());\n return acc;\n }, {})\n ).map(([attribute, values]) => ({\n attribute,\n eq: values.join(','),\n }))\n : undefined;\n \n request = {\n ...request,\n sort: sort ?? request.sort,\n filter: filter ?? request.filter,\n phrase: phrase ?? request.phrase,\n currentPage\n };\n \n // Update search input context in ACDL\n updateSearchInputCtx(\n acdlUnitId,\n searchRequestId,\n request.phrase || '',\n request.filter || [],\n request.pageSize || 0,\n request.currentPage || 0,\n request.sort || [],\n );\n\n // Publish search request event to ACDL\n searchRequestSent(acdlUnitId);\n\n // Execute search with validated request\n const { errors, data } = await fetchGraphQl(PRODUCT_SEARCH_QUERY, {\n method: 'GET',\n variables: { ...request },\n });\n\n if (errors && !data) {\n throw new Error('Error fetching product search');\n }\n\n const result = transformProductSearchResponse(data, request);\n\n // Update search results context in ACDL\n updateSearchResultsCtx(acdlUnitId, searchRequestId, result);\n\n // Publish search response event to ACDL\n searchResponseReceived(acdlUnitId)\n\n // Emit single event with result and metadata\n events.emit('search/result', { request, result }, { scope });\n\n return result;\n\n } catch (error) {\n // Emit error event\n events.emit('search/error', (error as Error).message, { scope });\n\n // Emit result event with empty result\n events.emit('search/result', emptyResult, { scope });\n\n throw error;\n } finally {\n // Reset loading state\n events.emit('search/loading', false, { scope });\n }\n};"],"names":["setEndpoint","setFetchGraphQlHeader","removeFetchGraphQlHeader","setFetchGraphQlHeaders","getFetchGraphQlHeader","fetchGraphQl","getConfig","FetchGraphQL","getCurrency","currency","transformProduct","data","transformedProduct","_a","image","_d","_c","_b","_g","_f","_e","_j","_i","_h","_m","_l","_k","_n","_r","_q","_p","_o","_v","_u","_t","_s","_z","_y","_x","_w","_D","_C","_B","_A","_H","_G","_F","_E","_L","_K","_J","_I","_P","_O","_N","_M","_T","_S","_R","_Q","merge","_W","_V","_U","config","transformProductSearchResponse","searchVariables","productSearch","transformedResponse","transformFacets","product","transformSortAttributes","sortableAttributes","option","filter","facets","facet","PRODUCT_SEARCH_QUERY","ProductView","Facet","search","request","options","scope","emptyResult","events","acdlUnitId","SEARCH_UNIT_ID","PLP_UNIT_ID","searchRequestId","params","currentPage","phrase","sortParam","sort","token","attribute","direction","attr","dir","filterParam","acc","part","value","values","updateSearchInputCtx","searchRequestSent","errors","result","updateSearchResultsCtx","searchResponseReceived","error"],"mappings":"iVAWO,KAAM,CACX,YAAAA,GACA,sBAAAC,GACA,yBAAAC,GACA,uBAAAC,GACA,sBAAAC,GACA,aAAAC,GACA,UAAAC,EACF,EAAI,IAAIC,GAAA,EAAe,WAAA,ECPjBC,EAAeC,GACf,CAACA,GAAY,CAAC,KAAK,kBAAkB,UAAU,EAAE,SAASA,CAAQ,EAC7D,MAEFA,EAGIC,GAAoBC,GAA8B,uGAE7D,GAAI,CAACA,EACH,MAAO,CACL,GAAI,GACJ,KAAM,GACN,IAAK,GACL,iBAAkB,GAClB,IAAK,GACL,OAAQ,GACR,UAAW,GACX,aAAc,GACd,gBAAiB,GACjB,SAAU,GACV,MAAO,CAAA,EACP,OAAQ,CAAA,EACR,YAAa,GACb,WAAY,GACZ,aAAc,CAAA,EACd,iBAAkB,GAClB,MAAO,OACP,WAAY,OACZ,QAAS,GACT,SAAU,EAAA,EAId,MAAMC,EAA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AU,CAAE,MAAAzB,EAAO,EAEpDyB,CAET,OAASG,EAAO,CAEd,MAAA1B,EAAO,KAAK,eAAiB0B,EAAgB,QAAS,CAAE,MAAA5B,EAAO,EAG/DE,EAAO,KAAK,gBAAiBD,EAAa,CAAE,MAAAD,EAAO,EAE7C4B,CACR,QAAA,CAEE1B,EAAO,KAAK,iBAAkB,GAAO,CAAE,MAAAF,EAAO,CAChD,CACF"}
|
package/containers/Pagination.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsx as
|
|
3
|
+
import{jsx as h}from"@dropins/tools/preact-jsx-runtime.js";import{useState as o,useEffect as w}from"@dropins/tools/preact-compat.js";import{Pagination as S}from"@dropins/tools/components.js";import{events as d}from"@dropins/tools/event-bus.js";import{d as $}from"../chunks/search.js";import"@dropins/tools/lib.js";import"../chunks/initialize.js";import"../fragments.js";import"../chunks/acdlEvents.js";import"@dropins/tools/fetch-graphql.js";const k=({scope:a,onPageChange:e})=>{const[s,f]=o(),[n,l]=o(),[p,g]=o({});w(()=>{const t=d.on("search/result",r=>{var i,c,u,m;g(r.request),f((c=(i=r.result)==null?void 0:i.pageInfo)==null?void 0:c.currentPage),l((m=(u=r.result)==null?void 0:u.pageInfo)==null?void 0:m.totalPages)},{eager:!0,scope:a});return()=>{t==null||t.off()}},[]);const P=async t=>{const r=new URLSearchParams(window.location.search);r.set("page",String(t)),window.history.pushState({},"",`${window.location.pathname}?${r.toString()}`),e==null||e(t),$({...p,currentPage:t},{scope:a})};return!s||!n?null:h(S,{currentPage:s,totalPages:n,onChange:P})};export{k as Pagination,k as default};
|
|
4
4
|
//# sourceMappingURL=Pagination.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pagination.js","sources":["/@dropins/storefront-product-discovery/src/containers/Pagination/Pagination.tsx"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n \nimport { HTMLAttributes, useState, useEffect } from 'preact/compat';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { Pagination as PaginationComponent } from '@adobe-commerce/elsie/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport { Scope, SearchVariables } from '@/plp/data/models';\nimport { search } from '@/plp/api';\n\nexport interface PaginationProps extends HTMLAttributes<HTMLDivElement> {\n scope?: Scope;\n onPageChange?: (page: number) => void;\n }\n \nexport const Pagination: Container<PaginationProps> = ({ scope, onPageChange }) => {\n const [currentPage, setCurrentPage] = useState<number>();\n const [totalPages, setTotalPages] = useState<number>();\n const [currentSearchVariables, setCurrentSearchVariables] = useState<SearchVariables>({});\n\n useEffect(() => {\n const searchEvent = events.on('search/result', (payload) => {\n setCurrentSearchVariables(payload.request);\n setCurrentPage(payload.result?.pageInfo?.currentPage);\n setTotalPages(payload.result?.pageInfo?.totalPages);\n }, { eager: true, scope });\n\n return () => {\n searchEvent?.off();\n };\n }, []);\n\n const handlePageChange = async (page: number): Promise<void> => {\n onPageChange?.(page);\n\n search({ ...currentSearchVariables, currentPage: page }
|
|
1
|
+
{"version":3,"file":"Pagination.js","sources":["/@dropins/storefront-product-discovery/src/containers/Pagination/Pagination.tsx"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n \nimport { HTMLAttributes, useState, useEffect } from 'preact/compat';\nimport { Container } from '@adobe-commerce/elsie/lib';\nimport { Pagination as PaginationComponent } from '@adobe-commerce/elsie/components';\nimport { events } from '@adobe-commerce/event-bus';\nimport { Scope, SearchVariables } from '@/plp/data/models';\nimport { search } from '@/plp/api';\n\nexport interface PaginationProps extends HTMLAttributes<HTMLDivElement> {\n scope?: Scope;\n onPageChange?: (page: number) => void;\n }\n \nexport const Pagination: Container<PaginationProps> = ({ scope, onPageChange }) => {\n const [currentPage, setCurrentPage] = useState<number>();\n const [totalPages, setTotalPages] = useState<number>();\n const [currentSearchVariables, setCurrentSearchVariables] = useState<SearchVariables>({});\n\n useEffect(() => {\n const searchEvent = events.on('search/result', (payload) => {\n setCurrentSearchVariables(payload.request);\n setCurrentPage(payload.result?.pageInfo?.currentPage);\n setTotalPages(payload.result?.pageInfo?.totalPages);\n }, { eager: true, scope });\n\n return () => {\n searchEvent?.off();\n };\n }, []);\n\n const handlePageChange = async (page: number): Promise<void> => {\n // Update URL\n const params = new URLSearchParams(window.location.search);\n params.set('page', String(page));\n \n window.history.pushState(\n {},\n '',\n `${window.location.pathname}?${params.toString()}`\n );\n \n onPageChange?.(page);\n \n search(\n { ...currentSearchVariables, currentPage: page },\n { scope }\n );\n };\n \n\n // Don't render if we don't have the variables\n if (!currentPage || !totalPages) {\n return null;\n }\n\n return (\n <PaginationComponent \n currentPage={currentPage}\n totalPages={totalPages}\n onChange={handlePageChange}\n />\n );\n};"],"names":["Pagination","scope","onPageChange","currentPage","setCurrentPage","useState","totalPages","setTotalPages","currentSearchVariables","setCurrentSearchVariables","useEffect","searchEvent","events","payload","_b","_a","_d","_c","handlePageChange","page","params","search","jsx","PaginationComponent"],"mappings":"0bAqBO,MAAMA,EAAyC,CAAC,CAAE,MAAAC,EAAO,aAAAC,KAAmB,CACjF,KAAM,CAACC,EAAaC,CAAc,EAAIC,EAAA,EAChC,CAACC,EAAYC,CAAa,EAAIF,EAAA,EAC9B,CAACG,EAAwBC,CAAyB,EAAIJ,EAA0B,CAAA,CAAE,EAExFK,EAAU,IAAM,CACd,MAAMC,EAAcC,EAAO,GAAG,gBAAkBC,GAAY,aAC1DJ,EAA0BI,EAAQ,OAAO,EACzCT,GAAeU,GAAAC,EAAAF,EAAQ,SAAR,YAAAE,EAAgB,WAAhB,YAAAD,EAA0B,WAAW,EACpDP,GAAcS,GAAAC,EAAAJ,EAAQ,SAAR,YAAAI,EAAgB,WAAhB,YAAAD,EAA0B,UAAU,CACpD,EAAG,CAAE,MAAO,GAAM,MAAAf,EAAO,EAEzB,MAAO,IAAM,CACXU,GAAA,MAAAA,EAAa,KACf,CACF,EAAG,CAAA,CAAE,EAEL,MAAMO,EAAmB,MAAOC,GAAgC,CAE9D,MAAMC,EAAS,IAAI,gBAAgB,OAAO,SAAS,MAAM,EACzDA,EAAO,IAAI,OAAQ,OAAOD,CAAI,CAAC,EAE/B,OAAO,QAAQ,UACb,CAAA,EACA,GACA,GAAG,OAAO,SAAS,QAAQ,IAAIC,EAAO,UAAU,EAAA,EAGlDlB,GAAA,MAAAA,EAAeiB,GAEfE,EACE,CAAE,GAAGb,EAAwB,YAAaW,CAAA,EAC1C,CAAE,MAAAlB,CAAA,CAAM,CAEZ,EAIA,MAAI,CAACE,GAAe,CAACG,EACZ,KAIPgB,EAACC,EAAA,CACC,YAAApB,EACA,WAAAG,EACA,SAAUY,CAAA,CAAA,CAGhB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
import{jsxs as
|
|
3
|
+
import{jsxs as U,jsx as e}from"@dropins/tools/preact-jsx-runtime.js";import*as w from"@dropins/tools/preact-compat.js";import{useState as E,useEffect as q}from"@dropins/tools/preact-compat.js";import{VComponent as G,classes as J,Slot as y}from"@dropins/tools/lib.js";import{events as C}from"@dropins/tools/event-bus.js";import{PriceRange as R,InLineAlert as K,Icon as Q,ProductItemCard as H,Image as W}from"@dropins/tools/components.js";/* empty css */import{c as X,d as Y,e as $,S as ee,P as re}from"../chunks/acdlEvents.js";import{useText as ne}from"@dropins/tools/i18n.js";const F=t=>new DOMParser().parseFromString(t,"text/html").documentElement.textContent,M=({productList:t,header:a,footer:n,imageWidth:i,imageHeight:l})=>U("div",{className:"product-discovery-product-list",style:{"--imageWidth":i,"--imageHeight":l},children:[a&&e("div",{className:"product-discovery-product-list__header",children:a}),e("div",{className:"product-discovery-product-list__grid",children:t&&e(G,{node:t})}),n&&e("div",{className:"product-discovery-product-list__footer",children:n})]}),te=({product:t})=>{var h,v,u,p,o,P,d,x,_;let a=((u=(v=(h=t.price)==null?void 0:h.regular)==null?void 0:v.amount)==null?void 0:u.currency)??"USD";Intl.supportedValuesOf("currency").includes(a)||(a="USD");const n=(P=(o=(p=t.price)==null?void 0:p.final)==null?void 0:o.amount)==null?void 0:P.value,i=(_=(x=(d=t.price)==null?void 0:d.regular)==null?void 0:x.amount)==null?void 0:_.value;return n!==void 0&&i!==void 0&&n<i?U("div",{class:"product-price",children:[e("span",{class:"regular-price-normal",children:e(R,{amount:n,currency:a})}),e("span",{class:"special-price-crossed",children:e(R,{amount:i,currency:a})})]}):e(R,{amount:i,currency:a})},ae=({product:t})=>{var u,p,o,P,d,x,_,L,S,A,N,k;let a=((P=(o=(p=(u=t.priceRange)==null?void 0:u.minimum)==null?void 0:p.regular)==null?void 0:o.amount)==null?void 0:P.currency)??"USD";Intl.supportedValuesOf("currency").includes(a)||(a="USD");const n=(x=(d=t.priceRange)==null?void 0:d.minimum)==null?void 0:x.final.amount.value,i=(L=(_=t.priceRange)==null?void 0:_.minimum)==null?void 0:L.regular.amount.value,l=(A=(S=t.priceRange)==null?void 0:S.maximum)==null?void 0:A.final.amount.value,h=(k=(N=t.priceRange)==null?void 0:N.maximum)==null?void 0:k.regular.amount.value;return n<i||l<h?U("div",{class:"product-price",children:[e("span",{class:"regular-price-normal",children:e(R,{display:"from to",minimumAmount:n,maximumAmount:l,currency:a})}),e("span",{class:"special-price-crossed",children:e(R,{display:"from to",minimumAmount:i,maximumAmount:h,currency:a})})]}):e(R,{display:"from to",minimumAmount:i,maximumAmount:h,currency:a})},ce=t=>w.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},w.createElement("g",{clipPath:"url(#clip0_841_1324)"},w.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),w.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"})),w.createElement("defs",null,w.createElement("clipPath",{id:"clip0_841_1324"},w.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),ie=({alertMessage:t=""})=>e("div",{className:J(["product-discovery-search-alert-message__wrapper"]),children:e("div",{className:"product-discovery-search-alert-message__content",children:e(K,{heading:t,type:"warning",icon:e(Q,{source:ce,size:"24"}),onDismiss:void 0})})}),fe=({routeProduct:t,scope:a,slots:n,imageWidth:i=400,imageHeight:l=450,skeletonCount:h=8,onSearchResult:v})=>{const u=a==="popover"?ee:re,p=ne({noResults:"Search.PLP.noResults",searchError:"Search.PLP.searchError"}),[o,P]=E(null),[d,x]=E([]),[_,L]=E(!1),[S,A]=E(null);q(()=>{const r=C.on("search/loading",L,{eager:!0,scope:a}),c=C.on("search/error",()=>{A(p.searchError)},{eager:!0,scope:a}),s=C.on("search/result",m=>{var g,f,I;A(((g=m.result)==null?void 0:g.items.length)<1?p.noResults:null),P(m.request),x((f=m.result)==null?void 0:f.items),v==null||v((I=m.result)==null?void 0:I.items),m.request.phrase?X(u):Y(u)},{eager:!0,scope:a});return()=>{r==null||r.off(),c==null||c.off(),s==null||s.off()}},[]);const N=(r,c)=>{var f;const s=(f=r.target)==null?void 0:f.closest("a");if(!s||!t)return;const m=new URL(s.href),g=new URL(t(c),window.location.origin);m.pathname===g.pathname&&m.hostname===g.hostname&&$(c.sku,u)},k=(r,c)=>{var f,I,V,D;const s={loading:c<8?"eager":"lazy",src:((I=(f=r.images)==null?void 0:f[0])==null?void 0:I.url)||"",alt:((D=(V=r.images)==null?void 0:V[0])==null?void 0:D.label)||"",width:i,height:l,params:{width:i}},m=r.name!==null?F(r.name):r.sku,g=e(W,{class:"product-discovery-product-item__image",...s,"aria-label":m||""});return e(y,{name:"ProductImage",slot:n==null?void 0:n.ProductImage,context:{product:r,defaultImageProps:s,variables:o},children:t?e("a",{href:t(r),children:g}):g})},b=r=>{const c=r.name!==null?F(r.name):"";return e(y,{name:"ProductName",slot:n==null?void 0:n.ProductName,context:{product:r,variables:o},children:t?e("a",{href:t(r),children:c}):c})},j=r=>{const c=r.typename==="ComplexProductView"?e(ae,{product:r}):e(te,{product:r});return e(y,{name:"ProductPrice",slot:n==null?void 0:n.ProductPrice,context:{product:r,variables:o},children:t?e("a",{href:t(r),children:c}):c})},z=r=>e(y,{name:"ProductActions",slot:n==null?void 0:n.ProductActions,context:{product:r,variables:o}}),B=()=>e(y,{name:"NoResults",slot:n==null?void 0:n.NoResults,context:{error:S,variables:o},children:S&&e(ie,{alertMessage:S})}),O=()=>e(M,{imageWidth:i,imageHeight:l,productList:Array.from({length:h}).map((r,c)=>e(H,{initialized:!1},c))}),T=()=>e(y,{name:"Header",slot:n==null?void 0:n.Header,context:{products:d,variables:o}}),Z=()=>e(y,{name:"Footer",slot:n==null?void 0:n.Footer,context:{products:d,variables:o}});return e("div",{children:_?O():S?B():e(M,{header:T(),footer:Z(),imageWidth:i,imageHeight:l,productList:d.map((r,c)=>e(H,{image:k(r,c),titleNode:b(r),price:j(r),actionButton:n!=null&&n.ProductActions?z(r):void 0,onClick:s=>N(s,r),initialized:!0},r.id||r.sku||c))})})};export{fe as SearchResults,fe as default};
|
|
4
4
|
//# sourceMappingURL=SearchResults.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchResults.js","sources":["/@dropins/storefront-product-discovery/src/utils/htmlStringDecode.ts","/@dropins/storefront-product-discovery/src/components/ProductList/ProductList.tsx","../../node_modules/@adobe-commerce/elsie/src/icons/Warning.svg","/@dropins/storefront-product-discovery/src/components/SearchAlertMessage/SearchAlertMessage.tsx","/@dropins/storefront-product-discovery/src/containers/SearchResults/SearchResults.tsx"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nconst htmlStringDecode = (input: string): string | null => {\n const doc = new DOMParser().parseFromString(input, 'text/html');\n return doc.documentElement.textContent;\n};\n\nexport { htmlStringDecode };\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { VComponent } from '@adobe-commerce/elsie/lib';\nimport '@/plp/components/ProductList/ProductList.css';\n\nexport interface ProductListProps extends HTMLAttributes<HTMLDivElement> {\n productList?: VNode[];\n header?: VNode;\n footer?: VNode;\n imageWidth?: number;\n imageHeight?: number;\n}\n\nexport const ProductList: FunctionComponent<ProductListProps> = ({ productList, header, footer, imageWidth, imageHeight }) => {\n return (\n <div className={'product-discovery-product-list'} style={{ '--imageWidth': imageWidth, '--imageHeight': imageHeight }}>\n {header && <div className=\"product-discovery-product-list__header\">{header}</div>}\n <div className=\"product-discovery-product-list__grid\">{productList && <VComponent node={productList} />}</div>\n {footer && <div className=\"product-discovery-product-list__footer\">{footer}</div>}\n </div>\n );\n};\n","import * as React from \"react\";\nconst SvgWarning = (props) => /* @__PURE__ */ React.createElement(\"svg\", { id: \"Icon_Warning_Base\", width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"g\", { clipPath: \"url(#clip0_841_1324)\" }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z\", stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z\", stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\" })), /* @__PURE__ */ React.createElement(\"defs\", null, /* @__PURE__ */ React.createElement(\"clipPath\", { id: \"clip0_841_1324\" }, /* @__PURE__ */ React.createElement(\"rect\", { width: 24, height: 21, fill: \"white\", transform: \"translate(0 1.5)\" }))));\nexport default SvgWarning;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport '@/plp/components/SearchAlertMessage/SearchAlertMessage.css';\nimport { Icon, InLineAlert } from '@adobe-commerce/elsie/components';\nimport { Warning } from '@adobe-commerce/elsie/icons';\n\nexport interface SearchAlertMessageProps extends HTMLAttributes<HTMLDivElement> {\n alertMessage?: string;\n}\n\nexport const SearchAlertMessage: FunctionComponent<SearchAlertMessageProps> = ({ alertMessage = '' }) => {\n return (\n <div className={classes(['product-discovery-search-alert-message__wrapper'])}>\n <div className=\"product-discovery-search-alert-message__content\">\n <InLineAlert\n heading={alertMessage}\n type={'warning'}\n icon={<Icon source={Warning} size=\"24\" />}\n onDismiss={undefined}\n />\n </div>\n </div>\n );\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ImageProps, Image, ProductItemCard, PriceRange } from '@adobe-commerce/elsie/components';\nimport { htmlStringDecode } from '@/plp/utils/htmlStringDecode';\nimport { Scope, SearchVariables } from '@/plp/data/models';\nimport { Product } from '@/plp/data/models/product';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { ProductList, SearchAlertMessage } from '@/plp/components'\nimport {\n searchProductClick,\n searchResultsView,\n categoryResultsView,\n PLP_UNIT_ID,\n SEARCH_UNIT_ID\n} from '@/plp/utils/acdlEvents';\n\ntype SlotDefaultContext = {\n product: Product;\n variables: SearchVariables | null;\n}\n\nexport interface SearchResultsProps extends HTMLAttributes<HTMLDivElement> {\n routeProduct?: (product: Product) => string;\n scope?: Scope;\n imageWidth?: number;\n imageHeight?: number;\n skeletonCount?: number;\n onSearchResult?: (payload: Product[]) => void;\n slots?: {\n ProductActions?: SlotProps<SlotDefaultContext>;\n ProductPrice?: SlotProps<SlotDefaultContext>;\n ProductName?: SlotProps<SlotDefaultContext>;\n ProductImage?: SlotProps<SlotDefaultContext & { defaultImageProps: ImageProps }>;\n NoResults?: SlotProps<{ error: string | null; variables: SearchVariables | null }>;\n Header?: SlotProps<{ products: Product[]; variables: SearchVariables | null }>;\n Footer?: SlotProps<{ products: Product[]; variables: SearchVariables | null }>;\n },\n}\n\nexport const SearchResults: Container<SearchResultsProps> = ({\n routeProduct,\n scope,\n slots,\n imageWidth = 400,\n imageHeight = 450,\n skeletonCount = 8,\n onSearchResult,\n}) => {\n const acdlUnitId = scope === 'popover' ? SEARCH_UNIT_ID : PLP_UNIT_ID;\n\n const labels = useText({\n noResults: 'Search.PLP.noResults',\n searchError: 'Search.PLP.searchError',\n });\n\n const [variables, setVariables] = useState<SearchVariables | null>(null);\n const [items, setItems] = useState<any[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n const loadingEvent = events.on('search/loading', setLoading, { eager: true, scope });\n\n const errorEvent = events.on('search/error', () => {\n setError(labels.searchError!);\n }, { eager: true, scope });\n\n const searchEvent = events.on('search/result', (payload) => {\n setError(payload.result?.items.length < 1 ? labels.noResults! : null);\n\n setVariables(payload.request);\n setItems(payload.result?.items);\n onSearchResult?.(payload.result?.items);\n\n // Publish search results view event to ACDL\n if (payload.request.phrase) {\n searchResultsView(acdlUnitId);\n } else {\n categoryResultsView(acdlUnitId);\n }\n }, { eager: true, scope });\n\n return () => {\n loadingEvent?.off();\n errorEvent?.off();\n searchEvent?.off();\n };\n }, []);\n\n const handleProductClick = (event: MouseEvent, product: Product): void => {\n const anchor = (event.target as HTMLElement)?.closest('a');\n\n if (!anchor || !routeProduct) return;\n\n const anchorUrl = new URL(anchor.href);\n const routeUrl = new URL(routeProduct(product), window.location.origin);\n\n // Compare both pathname and hostname to ensure same path under same host\n if (anchorUrl.pathname === routeUrl.pathname && anchorUrl.hostname === routeUrl.hostname) { \n searchProductClick(product.sku, acdlUnitId);\n }\n };\n\n const renderProductImageSlot = (product: Product, index: number) => {\n const defaultImageProps: ImageProps = {\n loading: index < 8 ? 'eager' : 'lazy',\n src: product.images?.[0]?.url || '',\n alt: product.images?.[0]?.label || '',\n width: imageWidth,\n height: imageHeight,\n params: { width: imageWidth },\n };\n const productName = product.name !== null ? htmlStringDecode(product.name) : product.sku;\n const imageComponent = (\n <Image class=\"product-discovery-product-item__image\" {...defaultImageProps} aria-label={productName || ''} />\n );\n\n return (\n <Slot name=\"ProductImage\" slot={slots?.ProductImage} context={{ product, defaultImageProps, variables }}>\n {routeProduct ? (\n <a href={routeProduct(product)}>\n {imageComponent}\n </a>\n ) : (\n imageComponent\n )}\n </Slot>\n );\n };\n\n const renderProductNameSlot = (product: Product) => {\n const productName = product.name !== null ? htmlStringDecode(product.name) : '';\n return (\n <Slot name=\"ProductName\" slot={slots?.ProductName} context={{ product, variables }}>\n {routeProduct ? (\n <a href={routeProduct(product)}>\n {productName}\n </a>\n ) : (\n productName\n )}\n </Slot>\n );\n };\n\n const renderProductPriceSlot = (product: Product) => {\n let productCurrency =\n product.typename === 'ComplexProductView'\n ? product.priceRange?.minimum.regular.amount.currency\n : product.price?.regular.amount.currency;\n if (Intl.supportedValuesOf('currency').indexOf(productCurrency || '') === -1) {\n productCurrency = 'USD'; // Fallback to USD if the currency is not supported\n }\n const productPrice =\n product.typename === 'ComplexProductView' ? (\n <PriceRange\n display=\"from to\"\n minimumAmount={product.priceRange?.minimum.regular.amount.value}\n maximumAmount={product.priceRange?.maximum.regular.amount.value}\n currency={productCurrency}\n />\n ) : (\n <PriceRange amount={product.price?.regular.amount.value} currency={productCurrency} />\n );\n return (\n <Slot name=\"ProductPrice\" slot={slots?.ProductPrice} context={{ product, variables }}>\n {routeProduct ? (\n <a href={routeProduct(product)}>\n {productPrice}\n </a>\n ) : (\n productPrice\n )}\n </Slot>\n );\n };\n\n const renderActionsSlot = (product: Product) => {\n return <Slot name=\"ProductActions\" slot={slots?.ProductActions} context={{ product, variables }} />;\n };\n\n const renderAlertSlot = () => {\n return <Slot name=\"NoResults\" slot={slots?.NoResults} context={{ error, variables }}>\n {error && <SearchAlertMessage alertMessage={error} />}\n </Slot>;\n }\n\n const renderSkeleton = () => {\n return <ProductList\n imageWidth={imageWidth}\n imageHeight={imageHeight}\n productList={Array.from({ length: skeletonCount }).map((_, index) => (\n <ProductItemCard key={index} initialized={false} />\n ))}\n />\n }\n\n const renderHeader = () => {\n return <Slot name=\"Header\" slot={slots?.Header} context={{ products: items, variables }} />;\n }\n\n const renderFooter = () => {\n return <Slot name=\"Footer\" slot={slots?.Footer} context={{ products: items, variables }} />;\n }\n\n const renderResults = () => {\n if (error) return renderAlertSlot();\n\n return <ProductList\n header={renderHeader()}\n footer={renderFooter()}\n imageWidth={imageWidth}\n imageHeight={imageHeight}\n productList={items.map((product, index) => (\n <ProductItemCard key={product.id || product.sku || index}\n image={renderProductImageSlot(product, index)}\n titleNode={renderProductNameSlot(product)}\n price={renderProductPriceSlot(product)}\n actionButton={slots?.ProductActions ? renderActionsSlot(product) : undefined}\n onClick={(event) => handleProductClick(event, product)}\n initialized\n />\n ))}\n />\n }\n\n return (\n <div>\n {loading ? renderSkeleton() : renderResults()}\n </div>\n );\n};\n"],"names":["htmlStringDecode","input","ProductList","productList","header","footer","imageWidth","imageHeight","jsxs","jsx","VComponent","SvgWarning","props","React","SearchAlertMessage","alertMessage","classes","InLineAlert","Icon","Warning","SearchResults","routeProduct","scope","slots","skeletonCount","onSearchResult","acdlUnitId","SEARCH_UNIT_ID","PLP_UNIT_ID","labels","useText","variables","setVariables","useState","items","setItems","loading","setLoading","error","setError","useEffect","loadingEvent","events","errorEvent","searchEvent","payload","_a","_b","_c","searchResultsView","categoryResultsView","handleProductClick","event","product","anchor","anchorUrl","routeUrl","searchProductClick","renderProductImageSlot","index","defaultImageProps","_d","productName","imageComponent","Image","Slot","renderProductNameSlot","renderProductPriceSlot","productCurrency","productPrice","PriceRange","_e","renderActionsSlot","renderAlertSlot","renderSkeleton","_","ProductItemCard","renderHeader","renderFooter"],"mappings":"glBASA,MAAMA,EAAoBC,GACZ,IAAI,UAAA,EAAY,gBAAgBA,EAAO,WAAW,EACnD,gBAAgB,YCWhBC,EAAmD,CAAC,CAAE,YAAAC,EAAa,OAAAC,EAAQ,OAAAC,EAAQ,WAAAC,EAAY,YAAAC,KAExGC,EAAC,MAAA,CAAI,UAAW,iCAAkC,MAAO,CAAE,eAAgBF,EAAY,gBAAiBC,CAAA,EACrG,SAAA,CAAAH,GAAUK,EAAC,MAAA,CAAI,UAAU,yCAA0C,SAAAL,EAAO,EAC3EK,EAAC,OAAI,UAAU,uCAAwC,YAAeA,EAACC,EAAA,CAAW,KAAMP,CAAA,CAAa,CAAA,CAAG,EACvGE,GAAUI,EAAC,MAAA,CAAI,UAAU,yCAA0C,SAAAJ,CAAA,CA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AAAA,EAAO,OAAQ,QAAS,CAAE,SAAUW,EAAO,UAAAH,CAAA,CAAU,CAAG,EAwB3F,SACG,MAAA,CACE,SAAAK,EAAUsC,EAAA,EAtBTpC,EAAcmC,EAAA,EAEXhE,EAACP,EAAA,CACN,OAAQ2E,EAAA,EACR,OAAQC,EAAA,EACR,WAAAxE,EACA,YAAAC,EACA,YAAa2B,EAAM,IAAI,CAACmB,EAASM,IAC/BlD,EAACmE,EAAA,CACC,MAAOlB,EAAuBL,EAASM,CAAK,EAC5C,UAAWO,EAAsBb,CAAO,EACxC,MAAOc,EAAuBd,CAAO,EACrC,aAAc9B,GAAA,MAAAA,EAAO,eAAiBiD,EAAkBnB,CAAO,EAAI,OACnE,QAAUD,GAAUD,EAAmBC,EAAOC,CAAO,EACrD,YAAW,EAAA,EANSA,EAAQ,IAAMA,EAAQ,KAAOM,CAAA,CAQpD,CAAA,CAAA,EAOH,CAEJ","x_google_ignoreList":[2]}
|
|
1
|
+
{"version":3,"file":"SearchResults.js","sources":["/@dropins/storefront-product-discovery/src/utils/htmlStringDecode.ts","/@dropins/storefront-product-discovery/src/components/ProductList/ProductList.tsx","/@dropins/storefront-product-discovery/src/containers/SearchResults/SimpleProductPrice.tsx","/@dropins/storefront-product-discovery/src/containers/SearchResults/ComplexProductPrice.tsx","../../node_modules/@adobe-commerce/elsie/src/icons/Warning.svg","/@dropins/storefront-product-discovery/src/components/SearchAlertMessage/SearchAlertMessage.tsx","/@dropins/storefront-product-discovery/src/containers/SearchResults/SearchResults.tsx"],"sourcesContent":["/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nconst htmlStringDecode = (input: string): string | null => {\n const doc = new DOMParser().parseFromString(input, 'text/html');\n return doc.documentElement.textContent;\n};\n\nexport { htmlStringDecode };\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { FunctionComponent, VNode } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { VComponent } from '@adobe-commerce/elsie/lib';\nimport '@/plp/components/ProductList/ProductList.css';\n\nexport interface ProductListProps extends HTMLAttributes<HTMLDivElement> {\n productList?: VNode[];\n header?: VNode;\n footer?: VNode;\n imageWidth?: number;\n imageHeight?: number;\n}\n\nexport const ProductList: FunctionComponent<ProductListProps> = ({ productList, header, footer, imageWidth, imageHeight }) => {\n return (\n <div className={'product-discovery-product-list'} style={{ '--imageWidth': imageWidth, '--imageHeight': imageHeight }}>\n {header && <div className=\"product-discovery-product-list__header\">{header}</div>}\n <div className=\"product-discovery-product-list__grid\">{productList && <VComponent node={productList} />}</div>\n {footer && <div className=\"product-discovery-product-list__footer\">{footer}</div>}\n </div>\n );\n};\n","import { PriceRange } from \"@adobe-commerce/elsie/components\";\nimport { Product } from \"@/plp/data/models/product\";\nimport '@/plp/components/ProductList/ProductList';\n\nexport const SimpleProductPrice = ({ product }: { product: Product }) => {\n let currency = product.price?.regular?.amount?.currency ?? \"USD\";\n\n if (!Intl.supportedValuesOf(\"currency\").includes(currency)) {\n currency = \"USD\";\n }\n\n\n const finalAmount = product.price?.final?.amount?.value;\n const regularAmount = product.price?.regular?.amount?.value;\n\n const hasSpecial =\n finalAmount !== undefined &&\n regularAmount !== undefined &&\n finalAmount < regularAmount;\n\n if (!hasSpecial) {\n return <PriceRange amount={regularAmount} currency={currency} />;\n }\n\n return (\n <div class=\"product-price\">\n <span class=\"regular-price-normal\">\n <PriceRange amount={finalAmount} currency={currency} />\n </span>\n <span class=\"special-price-crossed\">\n <PriceRange amount={regularAmount} currency={currency} />\n </span>\n </div>\n );\n};\n","import { PriceRange } from \"@adobe-commerce/elsie/components\";\nimport { Product } from \"@/plp/data/models/product\";\n\nexport const ComplexProductPrice = ({ product }: { product: Product }) => {\n let currency =\n product.priceRange?.minimum?.regular?.amount?.currency ?? \"USD\";\n\n if (!Intl.supportedValuesOf(\"currency\").includes(currency)) {\n currency = \"USD\";\n }\n\n const minFinal = product.priceRange?.minimum?.final.amount.value;\n const minRegular = product.priceRange?.minimum?.regular.amount.value;\n const maxFinal = product.priceRange?.maximum?.final.amount.value;\n const maxRegular = product.priceRange?.maximum?.regular.amount.value;\n\n const hasSpecial = minFinal < minRegular || maxFinal < maxRegular;\n\n if (!hasSpecial) {\n return (\n <PriceRange\n display=\"from to\"\n minimumAmount={minRegular}\n maximumAmount={maxRegular}\n currency={currency}\n />\n );\n }\n\n return (\n <div class=\"product-price\">\n <span class=\"regular-price-normal\">\n <PriceRange\n display=\"from to\"\n minimumAmount={minFinal}\n maximumAmount={maxFinal}\n currency={currency}\n />\n </span>\n\n <span class=\"special-price-crossed\">\n <PriceRange\n display=\"from to\"\n minimumAmount={minRegular}\n maximumAmount={maxRegular}\n currency={currency}\n />\n </span>\n </div>\n );\n};","import * as React from \"react\";\nconst SvgWarning = (props) => /* @__PURE__ */ React.createElement(\"svg\", { id: \"Icon_Warning_Base\", width: 24, height: 24, viewBox: \"0 0 24 24\", fill: \"none\", xmlns: \"http://www.w3.org/2000/svg\", ...props }, /* @__PURE__ */ React.createElement(\"g\", { clipPath: \"url(#clip0_841_1324)\" }, /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z\", stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\" }), /* @__PURE__ */ React.createElement(\"path\", { vectorEffect: \"non-scaling-stroke\", d: \"M12.4336 10.5504L12.3373 14.4766H11.6632L11.5669 10.5504V9.51273H12.4336V10.5504ZM11.5883 18.2636V17.2687H12.4229V18.2636H11.5883Z\", stroke: \"currentColor\", strokeLinecap: \"round\", strokeLinejoin: \"round\" })), /* @__PURE__ */ React.createElement(\"defs\", null, /* @__PURE__ */ React.createElement(\"clipPath\", { id: \"clip0_841_1324\" }, /* @__PURE__ */ React.createElement(\"rect\", { width: 24, height: 21, fill: \"white\", transform: \"translate(0 1.5)\" }))));\nexport default SvgWarning;\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this\n * file in accordance with the terms of the Adobe license agreement\n * accompanying it.\n *******************************************************************/\n\nimport { FunctionComponent } from 'preact';\nimport { HTMLAttributes } from 'preact/compat';\nimport { classes } from '@adobe-commerce/elsie/lib';\nimport '@/plp/components/SearchAlertMessage/SearchAlertMessage.css';\nimport { Icon, InLineAlert } from '@adobe-commerce/elsie/components';\nimport { Warning } from '@adobe-commerce/elsie/icons';\n\nexport interface SearchAlertMessageProps extends HTMLAttributes<HTMLDivElement> {\n alertMessage?: string;\n}\n\nexport const SearchAlertMessage: FunctionComponent<SearchAlertMessageProps> = ({ alertMessage = '' }) => {\n return (\n <div className={classes(['product-discovery-search-alert-message__wrapper'])}>\n <div className=\"product-discovery-search-alert-message__content\">\n <InLineAlert\n heading={alertMessage}\n type={'warning'}\n icon={<Icon source={Warning} size=\"24\" />}\n onDismiss={undefined}\n />\n </div>\n </div>\n );\n};\n","/********************************************************************\n * Copyright 2025 Adobe\n * All Rights Reserved.\n *\n * NOTICE: Adobe permits you to use, modify, and distribute this \n * file in accordance with the terms of the Adobe license agreement \n * accompanying it. \n *******************************************************************/\n\nimport { HTMLAttributes, useEffect, useState } from 'preact/compat';\nimport { Container, Slot, SlotProps } from '@adobe-commerce/elsie/lib';\nimport { events } from '@adobe-commerce/event-bus';\nimport { ImageProps, Image, ProductItemCard } from '@adobe-commerce/elsie/components';\nimport { htmlStringDecode } from '@/plp/utils/htmlStringDecode';\nimport { Scope, SearchVariables } from '@/plp/data/models';\nimport { Product } from '@/plp/data/models/product';\nimport { useText } from '@adobe-commerce/elsie/i18n';\nimport { SimpleProductPrice } from '@/plp/containers/SearchResults/SimpleProductPrice';\nimport { ComplexProductPrice } from \"@/plp/containers/SearchResults/ComplexProductPrice\";\nimport { ProductList, SearchAlertMessage } from '@/plp/components'\nimport {\n searchProductClick,\n searchResultsView,\n categoryResultsView,\n PLP_UNIT_ID,\n SEARCH_UNIT_ID\n} from '@/plp/utils/acdlEvents';\n\ntype SlotDefaultContext = {\n product: Product;\n variables: SearchVariables | null;\n}\n\nexport interface SearchResultsProps extends HTMLAttributes<HTMLDivElement> {\n routeProduct?: (product: Product) => string;\n scope?: Scope;\n imageWidth?: number;\n imageHeight?: number;\n skeletonCount?: number;\n onSearchResult?: (payload: Product[]) => void;\n slots?: {\n ProductActions?: SlotProps<SlotDefaultContext>;\n ProductPrice?: SlotProps<SlotDefaultContext>;\n ProductName?: SlotProps<SlotDefaultContext>;\n ProductImage?: SlotProps<SlotDefaultContext & { defaultImageProps: ImageProps }>;\n NoResults?: SlotProps<{ error: string | null; variables: SearchVariables | null }>;\n Header?: SlotProps<{ products: Product[]; variables: SearchVariables | null }>;\n Footer?: SlotProps<{ products: Product[]; variables: SearchVariables | null }>;\n },\n}\n\nexport const SearchResults: Container<SearchResultsProps> = ({\n routeProduct,\n scope,\n slots,\n imageWidth = 400,\n imageHeight = 450,\n skeletonCount = 8,\n onSearchResult,\n}) => {\n const acdlUnitId = scope === 'popover' ? SEARCH_UNIT_ID : PLP_UNIT_ID;\n\n const labels = useText({\n noResults: 'Search.PLP.noResults',\n searchError: 'Search.PLP.searchError',\n });\n\n const [variables, setVariables] = useState<SearchVariables | null>(null);\n const [items, setItems] = useState<any[]>([]);\n const [loading, setLoading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n useEffect(() => {\n const loadingEvent = events.on('search/loading', setLoading, { eager: true, scope });\n\n const errorEvent = events.on('search/error', () => {\n setError(labels.searchError!);\n }, { eager: true, scope });\n\n const searchEvent = events.on('search/result', (payload) => {\n setError(payload.result?.items.length < 1 ? labels.noResults! : null);\n\n setVariables(payload.request);\n setItems(payload.result?.items);\n onSearchResult?.(payload.result?.items);\n\n // Publish search results view event to ACDL\n if (payload.request.phrase) {\n searchResultsView(acdlUnitId);\n } else {\n categoryResultsView(acdlUnitId);\n }\n }, { eager: true, scope });\n\n return () => {\n loadingEvent?.off();\n errorEvent?.off();\n searchEvent?.off();\n };\n }, []);\n\n const handleProductClick = (event: MouseEvent, product: Product): void => {\n const anchor = (event.target as HTMLElement)?.closest('a');\n\n if (!anchor || !routeProduct) return;\n\n const anchorUrl = new URL(anchor.href);\n const routeUrl = new URL(routeProduct(product), window.location.origin);\n\n // Compare both pathname and hostname to ensure same path under same host\n if (anchorUrl.pathname === routeUrl.pathname && anchorUrl.hostname === routeUrl.hostname) { \n searchProductClick(product.sku, acdlUnitId);\n }\n };\n\n const renderProductImageSlot = (product: Product, index: number) => {\n const defaultImageProps: ImageProps = {\n loading: index < 8 ? 'eager' : 'lazy',\n src: product.images?.[0]?.url || '',\n alt: product.images?.[0]?.label || '',\n width: imageWidth,\n height: imageHeight,\n params: { width: imageWidth },\n };\n const productName = product.name !== null ? htmlStringDecode(product.name) : product.sku;\n const imageComponent = (\n <Image class=\"product-discovery-product-item__image\" {...defaultImageProps} aria-label={productName || ''} />\n );\n\n return (\n <Slot name=\"ProductImage\" slot={slots?.ProductImage} context={{ product, defaultImageProps, variables }}>\n {routeProduct ? (\n <a href={routeProduct(product)}>\n {imageComponent}\n </a>\n ) : (\n imageComponent\n )}\n </Slot>\n );\n };\n\n const renderProductNameSlot = (product: Product) => {\n const productName = product.name !== null ? htmlStringDecode(product.name) : '';\n return (\n <Slot name=\"ProductName\" slot={slots?.ProductName} context={{ product, variables }}>\n {routeProduct ? (\n <a href={routeProduct(product)}>\n {productName}\n </a>\n ) : (\n productName\n )}\n </Slot>\n );\n };\n\n const renderProductPriceSlot = (product: Product) => {\n const PriceNode =\n product.typename === \"ComplexProductView\" ? (\n <ComplexProductPrice product={product} />\n ) : (\n <SimpleProductPrice product={product} />\n );\n \n return (\n <Slot name=\"ProductPrice\" slot={slots?.ProductPrice} context={{ product, variables }}>\n {routeProduct ? (\n <a href={routeProduct(product)}>{PriceNode}</a>\n ) : (\n PriceNode\n )}\n </Slot>\n );\n }; \n \n const renderActionsSlot = (product: Product) => {\n return <Slot name=\"ProductActions\" slot={slots?.ProductActions} context={{ product, variables }} />;\n };\n\n const renderAlertSlot = () => {\n return <Slot name=\"NoResults\" slot={slots?.NoResults} context={{ error, variables }}>\n {error && <SearchAlertMessage alertMessage={error} />}\n </Slot>;\n }\n\n const renderSkeleton = () => {\n return <ProductList\n imageWidth={imageWidth}\n imageHeight={imageHeight}\n productList={Array.from({ length: skeletonCount }).map((_, index) => (\n <ProductItemCard key={index} initialized={false} />\n ))}\n />\n }\n\n const renderHeader = () => {\n return <Slot name=\"Header\" slot={slots?.Header} context={{ products: items, variables }} />;\n }\n\n const renderFooter = () => {\n return <Slot name=\"Footer\" slot={slots?.Footer} context={{ products: items, variables }} />;\n }\n\n const renderResults = () => {\n if (error) return renderAlertSlot();\n\n return <ProductList\n header={renderHeader()}\n footer={renderFooter()}\n imageWidth={imageWidth}\n imageHeight={imageHeight}\n productList={items.map((product, index) => (\n <ProductItemCard key={product.id || product.sku || index}\n image={renderProductImageSlot(product, index)}\n titleNode={renderProductNameSlot(product)}\n price={renderProductPriceSlot(product)}\n actionButton={slots?.ProductActions ? renderActionsSlot(product) : undefined}\n onClick={(event) => handleProductClick(event, product)}\n initialized\n />\n ))}\n />\n }\n\n return (\n <div>\n {loading ? renderSkeleton() : renderResults()}\n </div>\n );\n};\n"],"names":["htmlStringDecode","input","ProductList","productList","header","footer","imageWidth","imageHeight","jsxs","jsx","VComponent","SimpleProductPrice","product","currency","_c","_b","_a","finalAmount","_f","_e","_d","regularAmount","_i","_h","_g","PriceRange","ComplexProductPrice","minFinal","minRegular","maxFinal","_j","maxRegular","_l","_k","SvgWarning","props","React","SearchAlertMessage","alertMessage","classes","InLineAlert","Icon","Warning","SearchResults","routeProduct","scope","slots","skeletonCount","onSearchResult","acdlUnitId","SEARCH_UNIT_ID","PLP_UNIT_ID","labels","useText","variables","setVariables","useState","items","setItems","loading","setLoading","error","setError","useEffect","loadingEvent","events","errorEvent","searchEvent","payload","searchResultsView","categoryResultsView","handleProductClick","event","anchor","anchorUrl","routeUrl","searchProductClick","renderProductImageSlot","index","defaultImageProps","productName","imageComponent","Image","Slot","renderProductNameSlot","renderProductPriceSlot","PriceNode","renderActionsSlot","renderAlertSlot","renderSkeleton","_","ProductItemCard","renderHeader","renderFooter"],"mappings":"glBASA,MAAMA,EAAoBC,GACZ,IAAI,UAAA,EAAY,gBAAgBA,EAAO,WAAW,EACnD,gBAAgB,YCWhBC,EAAmD,CAAC,CAAE,YAAAC,EAAa,OAAAC,EAAQ,OAAAC,EAAQ,WAAAC,EAAY,YAAAC,KAExGC,EAAC,MAAA,CAAI,UAAW,iCAAkC,MAAO,CAAE,eAAgBF,EAAY,gBAAiBC,CAAA,EACrG,SAAA,CAAAH,GAAUK,EAAC,MAAA,CAAI,UAAU,yCAA0C,SAAAL,EAAO,EAC3EK,EAAC,OAAI,UAAU,uCAAwC,YAAeA,EAACC,EAAA,CAAW,KAAMP,CAAA,CAAa,CAAA,CAAG,EACvGE,GAAUI,EAAC,MAAA,CAAI,UAAU,yCAA0C,SAAAJ,CAAA,CAAO,CAAA,EAC7E,ECxBSM,GAAqB,CAAC,CAAE,QAAAC,KAAoC,uBACvE,IAAIC,IAAWC,GAAAC,GAAAC,EAAAJ,EAAQ,QAAR,YAAAI,EAAe,UAAf,YAAAD,EAAwB,SAAxB,YAAAD,EAAgC,WAAY,MAEtD,KAAK,kBAAkB,UAAU,EAAE,SAASD,CAAQ,IACvDA,EAAW,OAIb,MAAMI,GAAcC,GAAAC,GAAAC,EAAAR,EAAQ,QAAR,YAAAQ,EAAe,QAAf,YAAAD,EAAsB,SAAtB,YAAAD,EAA8B,MAC5CG,GAAgBC,GAAAC,GAAAC,EAAAZ,EAAQ,QAAR,YAAAY,EAAe,UAAf,YAAAD,EAAwB,SAAxB,YAAAD,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A,YAAAC,EACA,YAAakD,EAAM,IAAI,CAAC7C,EAASkE,IAC/BrE,EAACkF,EAAA,CACC,MAAOd,EAAuBjE,EAASkE,CAAK,EAC5C,UAAWM,EAAsBxE,CAAO,EACxC,MAAOyE,EAAuBzE,CAAO,EACrC,aAAckC,GAAA,MAAAA,EAAO,eAAiByC,EAAkB3E,CAAO,EAAI,OACnE,QAAU4D,GAAUD,EAAmBC,EAAO5D,CAAO,EACrD,YAAW,EAAA,EANSA,EAAQ,IAAMA,EAAQ,KAAOkE,CAAA,CAQpD,CAAA,CAAA,EAOH,CAEJ","x_google_ignoreList":[4]}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name": "@dropins/storefront-product-discovery", "version": "
|
|
1
|
+
{"name": "@dropins/storefront-product-discovery", "version": "3.0.0-alpha2", "@dropins/tools": "^1.4.0", "license": "SEE LICENSE IN LICENSE.md"}
|
package/render.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! Copyright 2025 Adobe
|
|
2
2
|
All Rights Reserved. */
|
|
3
|
-
(function(d,r){try{if(typeof document<"u"){const t=document.createElement("style"),o=r.styleId;for(const e in r.attributes)t.setAttribute(e,r.attributes[e]);t.setAttribute("data-dropin",o),t.appendChild(document.createTextNode(d));const i=document.querySelector('style[data-dropin="sdk"]');if(i)i.after(t);else{const e=document.querySelector('link[rel="stylesheet"], style');e?e.before(t):document.head.append(t)}}}catch(t){console.error("dropin-styles (injectCodeFunction)",t)}})(".product-discovery-product-list{container-type:inline-size;display:flex;flex-direction:column;width:100%}.product-discovery-product-list__container{display:flex;flex-direction:column;width:100%}.product-discovery-product-list__grid{display:grid;grid-template-columns:1fr;gap:var(--spacing-small)}.product-discovery-product-list__grid .dropin-product-item-card{margin:unset;width:100%}.product-discovery-product-list__grid .dropin-product-item-card img,.product-discovery-product-list__grid .dropin-product-item-card__skeleton__image{aspect-ratio:var(--imageWidth) / var(--imageHeight);max-height:unset;height:unset}@container (min-width: 600px){.product-discovery-product-list__grid{grid-template-columns:repeat(2,1fr)}}@container (min-width: 900px){.product-discovery-product-list__grid{grid-template-columns:repeat(3,1fr)}}@container (min-width: 1200px){.product-discovery-product-list__grid{grid-template-columns:repeat(4,1fr)}}.product-discovery-search-alert-message__wrapper{display:flex;flex-direction:column;justify-content:center;width:100%;min-height:300px}.product-discovery-search-alert-message__content{display:flex;justify-content:center}.product-discovery-facet{padding-block:var(--spacing-small)}.product-discovery-facet:not(.product-discovery-facet--last){border-bottom:1px solid var(--color-neutral-400)}.product-discovery-facet__header{display:block;margin-block-end:var(--spacing-xsmall)}.product-discovery-facet__bucket .dropin-price-range .dropin-price--small.dropin-price--bold{font:var(--type-body-2-default-font)}.product-discovery-facet__bucket .dropin-radio-button__label:before{margin-right:var(--spacing-xsmall)}.product-discovery-facet-list{display:flex;flex-direction:column;width:100%}.product-discovery-facet-list__selected-filters{display:flex;flex-direction:row;flex-wrap:wrap;row-gap:var(--spacing-xxsmall);padding:0 0 var(--spacing-xxsmall) 0}.product-discovery-facet-list__selected-filters button{padding:0 var(--spacing-xxsmall);margin:0 var(--spacing-xxsmall);border-radius:var(--shape-border-radius-2)}.product-discovery-facet-list__selected-filters .dropin-price-range .dropin-price--small.dropin-price--bold{font:var(--type-button-2-font)}.product-discovery-facet-list__facet-options{text-align:left}.product-discovery-facet-list__facet-options button{padding:0}.product-discovery-facet-list__facet-options .dropin-radio-button{padding:var(--spacing-xxsmall) 0}.product-discovery-facet-list__facet-options--hidden{display:none}.product-discovery-facet-list .dropin-divider{margin:var(--spacing-xsmall) 0 var(--spacing-xsmall) 0}",{styleId:"storefront-product-discovery"});
|
|
3
|
+
(function(d,r){try{if(typeof document<"u"){const t=document.createElement("style"),o=r.styleId;for(const e in r.attributes)t.setAttribute(e,r.attributes[e]);t.setAttribute("data-dropin",o),t.appendChild(document.createTextNode(d));const i=document.querySelector('style[data-dropin="sdk"]');if(i)i.after(t);else{const e=document.querySelector('link[rel="stylesheet"], style');e?e.before(t):document.head.append(t)}}}catch(t){console.error("dropin-styles (injectCodeFunction)",t)}})(".product-discovery-product-list{container-type:inline-size;display:flex;flex-direction:column;width:100%}.product-discovery-product-list__container{display:flex;flex-direction:column;width:100%}.product-discovery-product-list__grid{display:grid;grid-template-columns:1fr;gap:var(--spacing-small)}.product-discovery-product-list__grid .dropin-product-item-card{margin:unset;width:100%}.product-discovery-product-list__grid .dropin-product-item-card img,.product-discovery-product-list__grid .dropin-product-item-card__skeleton__image{aspect-ratio:var(--imageWidth) / var(--imageHeight);max-height:unset;height:unset}.product-discovery-product-list .product-price{display:flex;gap:8px}.product-discovery-product-list .special-price-crossed{text-decoration:line-through;opacity:.5}@container (min-width: 600px){.product-discovery-product-list__grid{grid-template-columns:repeat(2,1fr)}}@container (min-width: 900px){.product-discovery-product-list__grid{grid-template-columns:repeat(3,1fr)}}@container (min-width: 1200px){.product-discovery-product-list__grid{grid-template-columns:repeat(4,1fr)}}.product-discovery-search-alert-message__wrapper{display:flex;flex-direction:column;justify-content:center;width:100%;min-height:300px}.product-discovery-search-alert-message__content{display:flex;justify-content:center}.product-discovery-facet{padding-block:var(--spacing-small)}.product-discovery-facet:not(.product-discovery-facet--last){border-bottom:1px solid var(--color-neutral-400)}.product-discovery-facet__header{display:block;margin-block-end:var(--spacing-xsmall)}.product-discovery-facet__bucket .dropin-price-range .dropin-price--small.dropin-price--bold{font:var(--type-body-2-default-font)}.product-discovery-facet__bucket .dropin-radio-button__label:before{margin-right:var(--spacing-xsmall)}.product-discovery-facet-list{display:flex;flex-direction:column;width:100%}.product-discovery-facet-list__selected-filters{display:flex;flex-direction:row;flex-wrap:wrap;row-gap:var(--spacing-xxsmall);padding:0 0 var(--spacing-xxsmall) 0}.product-discovery-facet-list__selected-filters button{padding:0 var(--spacing-xxsmall);margin:0 var(--spacing-xxsmall);border-radius:var(--shape-border-radius-2)}.product-discovery-facet-list__selected-filters .dropin-price-range .dropin-price--small.dropin-price--bold{font:var(--type-button-2-font)}.product-discovery-facet-list__facet-options{text-align:left}.product-discovery-facet-list__facet-options button{padding:0}.product-discovery-facet-list__facet-options .dropin-radio-button{padding:var(--spacing-xxsmall) 0}.product-discovery-facet-list__facet-options--hidden{display:none}.product-discovery-facet-list .dropin-divider{margin:var(--spacing-xsmall) 0 var(--spacing-xsmall) 0}",{styleId:"storefront-product-discovery"});
|
|
4
4
|
import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{deepmerge as f,Render as l}from"@dropins/tools/lib.js";import{useState as g,useEffect as h}from"@dropins/tools/preact-hooks.js";import{UIProvider as m}from"@dropins/tools/components.js";import{events as u}from"@dropins/tools/event-bus.js";import{c as w}from"./chunks/initialize.js";const d={PLP:{noResults:"Your search returned no results.",searchError:"An error occurred while searching."},Facet:{showMore:"Show more",showLess:"Show less",clearAll:"Clear all"},SortBy:{title:"Sort by",lowToHigh:"Low to High",highToLow:"High to Low"}},S={Search:d},p={default:S},L=({children:n})=>{var e;const[t,s]=g("en_US"),i=(e=w.getConfig())==null?void 0:e.langDefinitions;h(()=>{const o=u.on("locale",a=>{s(a)},{eager:!0});return()=>{o==null||o.off()}},[]);const c=f(p,i??{});return r(m,{lang:t,langDefinitions:c,children:n})},y=new l(r(L,{}));export{y as render};
|
|
5
5
|
//# sourceMappingURL=render.js.map
|