@faststore/core 2.0.165-alpha.0 → 2.0.168-alpha.0

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.
Files changed (166) hide show
  1. package/.turbo/turbo-build.log +10 -10
  2. package/CHANGELOG.md +12 -0
  3. package/cms/faststore/sections.json +226 -0
  4. package/package.json +3 -3
  5. package/src/Layout.tsx +1 -25
  6. package/src/components/cart/CartSidebar/CartSidebar.tsx +97 -54
  7. package/src/components/cms/GlobalSections.tsx +11 -9
  8. package/src/components/region/RegionBar/RegionBar.tsx +35 -3
  9. package/src/components/region/RegionModal/RegionModal.tsx +81 -19
  10. package/src/components/sections/RegionBar/RegionBar.tsx +41 -0
  11. package/.next/BUILD_ID +0 -1
  12. package/.next/build-manifest.json +0 -132
  13. package/.next/cache/.tsbuildinfo +0 -1
  14. package/.next/cache/config.json +0 -7
  15. package/.next/cache/eslint/.cache_1gneedd +0 -1
  16. package/.next/cache/next-server.js.nft.json +0 -1
  17. package/.next/cache/webpack/client-production/0.pack +0 -0
  18. package/.next/cache/webpack/client-production/index.pack +0 -0
  19. package/.next/cache/webpack/server-production/0.pack +0 -0
  20. package/.next/cache/webpack/server-production/index.pack +0 -0
  21. package/.next/export-marker.json +0 -1
  22. package/.next/images-manifest.json +0 -1
  23. package/.next/next-server.js.nft.json +0 -1
  24. package/.next/package.json +0 -1
  25. package/.next/prerender-manifest.json +0 -1
  26. package/.next/react-loadable-manifest.json +0 -48
  27. package/.next/required-server-files.json +0 -1
  28. package/.next/routes-manifest.json +0 -1
  29. package/.next/server/chunks/123.js +0 -58
  30. package/.next/server/chunks/143.js +0 -106
  31. package/.next/server/chunks/183.js +0 -90
  32. package/.next/server/chunks/205.js +0 -692
  33. package/.next/server/chunks/247.js +0 -61
  34. package/.next/server/chunks/280.js +0 -324
  35. package/.next/server/chunks/287.js +0 -58
  36. package/.next/server/chunks/289.js +0 -229
  37. package/.next/server/chunks/312.js +0 -697
  38. package/.next/server/chunks/336.js +0 -821
  39. package/.next/server/chunks/350.js +0 -143
  40. package/.next/server/chunks/368.js +0 -253
  41. package/.next/server/chunks/487.js +0 -9142
  42. package/.next/server/chunks/502.js +0 -600
  43. package/.next/server/chunks/576.js +0 -90
  44. package/.next/server/chunks/597.js +0 -169
  45. package/.next/server/chunks/608.js +0 -644
  46. package/.next/server/chunks/644.js +0 -235
  47. package/.next/server/chunks/650.js +0 -9142
  48. package/.next/server/chunks/664.js +0 -3401
  49. package/.next/server/chunks/676.js +0 -32
  50. package/.next/server/chunks/701.js +0 -87
  51. package/.next/server/chunks/74.js +0 -2710
  52. package/.next/server/chunks/82.js +0 -371
  53. package/.next/server/chunks/854.js +0 -72
  54. package/.next/server/chunks/859.js +0 -959
  55. package/.next/server/chunks/874.js +0 -487
  56. package/.next/server/chunks/886.js +0 -120
  57. package/.next/server/chunks/907.js +0 -1803
  58. package/.next/server/chunks/970.js +0 -200
  59. package/.next/server/chunks/98.js +0 -124
  60. package/.next/server/chunks/font-manifest.json +0 -1
  61. package/.next/server/font-manifest.json +0 -1
  62. package/.next/server/middleware-build-manifest.js +0 -1
  63. package/.next/server/middleware-manifest.json +0 -6
  64. package/.next/server/middleware-react-loadable-manifest.js +0 -1
  65. package/.next/server/pages/404.js +0 -393
  66. package/.next/server/pages/404.js.nft.json +0 -1
  67. package/.next/server/pages/500.js +0 -395
  68. package/.next/server/pages/500.js.nft.json +0 -1
  69. package/.next/server/pages/[...slug].js +0 -786
  70. package/.next/server/pages/[...slug].js.nft.json +0 -1
  71. package/.next/server/pages/[slug]/p.js +0 -2532
  72. package/.next/server/pages/[slug]/p.js.nft.json +0 -1
  73. package/.next/server/pages/_app.js +0 -368
  74. package/.next/server/pages/_app.js.nft.json +0 -1
  75. package/.next/server/pages/_document.js +0 -304
  76. package/.next/server/pages/_document.js.nft.json +0 -1
  77. package/.next/server/pages/_error.js +0 -164
  78. package/.next/server/pages/_error.js.nft.json +0 -1
  79. package/.next/server/pages/account.js +0 -370
  80. package/.next/server/pages/account.js.nft.json +0 -1
  81. package/.next/server/pages/api/graphql.js +0 -365
  82. package/.next/server/pages/api/graphql.js.nft.json +0 -1
  83. package/.next/server/pages/api/preview.js +0 -119
  84. package/.next/server/pages/api/preview.js.nft.json +0 -1
  85. package/.next/server/pages/checkout.js +0 -370
  86. package/.next/server/pages/checkout.js.nft.json +0 -1
  87. package/.next/server/pages/en-US/404.html +0 -81
  88. package/.next/server/pages/en-US/404.json +0 -1
  89. package/.next/server/pages/en-US/500.html +0 -81
  90. package/.next/server/pages/en-US/500.json +0 -1
  91. package/.next/server/pages/en-US/account.html +0 -81
  92. package/.next/server/pages/en-US/account.json +0 -1
  93. package/.next/server/pages/en-US/checkout.html +0 -81
  94. package/.next/server/pages/en-US/checkout.json +0 -1
  95. package/.next/server/pages/en-US/login.html +0 -81
  96. package/.next/server/pages/en-US/login.json +0 -1
  97. package/.next/server/pages/en-US/s.html +0 -81
  98. package/.next/server/pages/en-US/s.json +0 -1
  99. package/.next/server/pages/en-US.html +0 -81
  100. package/.next/server/pages/en-US.json +0 -1
  101. package/.next/server/pages/index.js +0 -966
  102. package/.next/server/pages/index.js.nft.json +0 -1
  103. package/.next/server/pages/login.js +0 -375
  104. package/.next/server/pages/login.js.nft.json +0 -1
  105. package/.next/server/pages/s.js +0 -473
  106. package/.next/server/pages/s.js.nft.json +0 -1
  107. package/.next/server/pages-manifest.json +0 -16
  108. package/.next/server/webpack-api-runtime.js +0 -229
  109. package/.next/server/webpack-runtime.js +0 -229
  110. package/.next/static/chunks/0-82274e07cb857231.js +0 -1
  111. package/.next/static/chunks/143.dd8a556e6957baa1.js +0 -1
  112. package/.next/static/chunks/226.b57e10ad9932f88c.js +0 -1
  113. package/.next/static/chunks/240-8e66b2892f9d8c40.js +0 -1
  114. package/.next/static/chunks/336.0846f48eccce57e4.js +0 -1
  115. package/.next/static/chunks/377-891ff95d759cb061.js +0 -1
  116. package/.next/static/chunks/391-47b923ef44945418.js +0 -1
  117. package/.next/static/chunks/495.0ecd099878b2a36d.js +0 -1
  118. package/.next/static/chunks/502.eeca300cb9a355fb.js +0 -1
  119. package/.next/static/chunks/545-1d3d08edfd2ee4c6.js +0 -1
  120. package/.next/static/chunks/597.57a8984b6a1071ae.js +0 -1
  121. package/.next/static/chunks/64.ebbe1d2b40f980c7.js +0 -1
  122. package/.next/static/chunks/651.7142f31ce1e052b3.js +0 -1
  123. package/.next/static/chunks/741.52f7fb873418346f.js +0 -1
  124. package/.next/static/chunks/98.97381d2021f86cd9.js +0 -1
  125. package/.next/static/chunks/framework-dfd14d7ce6600b03.js +0 -1
  126. package/.next/static/chunks/main-fd466221927468fd.js +0 -1
  127. package/.next/static/chunks/pages/404-459452495a0df278.js +0 -1
  128. package/.next/static/chunks/pages/500-008e30c48eceebed.js +0 -1
  129. package/.next/static/chunks/pages/[...slug]-e9d8386ff5e56d85.js +0 -1
  130. package/.next/static/chunks/pages/[slug]/p-8346514a688bf869.js +0 -1
  131. package/.next/static/chunks/pages/_app-78846ca9151cf266.js +0 -1
  132. package/.next/static/chunks/pages/_error-a7a0c1d9bfbb4f38.js +0 -1
  133. package/.next/static/chunks/pages/account-46263f0c100c3eae.js +0 -1
  134. package/.next/static/chunks/pages/checkout-20bb3710b24df3b6.js +0 -1
  135. package/.next/static/chunks/pages/index-2006be8f08ad057f.js +0 -1
  136. package/.next/static/chunks/pages/login-f9d316d261fcc062.js +0 -1
  137. package/.next/static/chunks/pages/s-1cbe740b5b781d28.js +0 -1
  138. package/.next/static/chunks/polyfills-c67a75d1b6f99dc8.js +0 -1
  139. package/.next/static/chunks/webpack-e9bf82a67cc08d0f.js +0 -1
  140. package/.next/static/css/13a4da555ff5e3be.css +0 -1
  141. package/.next/static/css/287f5ba239375052.css +0 -1
  142. package/.next/static/css/28d7d73e13e2bc1d.css +0 -1
  143. package/.next/static/css/2e00f7ba49c754b3.css +0 -1
  144. package/.next/static/css/47d82dcec9a7dbc2.css +0 -1
  145. package/.next/static/css/6e41f1b6078c14c1.css +0 -1
  146. package/.next/static/css/7d822a137c54a781.css +0 -1
  147. package/.next/static/css/c6f97f692b2efad9.css +0 -1
  148. package/.next/static/css/d4a0d9df8c6df555.css +0 -1
  149. package/.next/static/css/e02cdad8fc000339.css +0 -1
  150. package/.next/static/zYvKRrlOU3r6IZCy0a0eY/_buildManifest.js +0 -1
  151. package/.next/static/zYvKRrlOU3r6IZCy0a0eY/_ssgManifest.js +0 -1
  152. package/.next/trace +0 -70
  153. package/public/~partytown/debug/partytown-atomics.js +0 -556
  154. package/public/~partytown/debug/partytown-media.js +0 -374
  155. package/public/~partytown/debug/partytown-sandbox-sw.js +0 -543
  156. package/public/~partytown/debug/partytown-sw.js +0 -59
  157. package/public/~partytown/debug/partytown-ww-atomics.js +0 -1789
  158. package/public/~partytown/debug/partytown-ww-sw.js +0 -1781
  159. package/public/~partytown/debug/partytown.js +0 -72
  160. package/public/~partytown/partytown-atomics.js +0 -2
  161. package/public/~partytown/partytown-media.js +0 -2
  162. package/public/~partytown/partytown-sw.js +0 -2
  163. package/public/~partytown/partytown.js +0 -2
  164. package/src/components/common/RegionBar/RegionBar.tsx +0 -17
  165. /package/src/components/{common → sections}/RegionBar/index.ts +0 -0
  166. /package/src/components/{common → sections}/RegionBar/section.module.scss +0 -0
@@ -22,26 +22,26 @@ info - Generating static pages (7/7)
22
22
  info - Finalizing page optimization...
23
23
 
24
24
  Route (pages) Size First Load JS
25
- ┌ ● / 3.1 kB 126 kB
25
+ ┌ ● / 3.1 kB 125 kB
26
26
  ├ └ css/13a4da555ff5e3be.css 7.19 kB
27
- ├ /_app 0 B 78 kB
27
+ ├ /_app 0 B 77.8 kB
28
28
  ├ ● /[...slug] 10.1 kB 133 kB
29
29
  ├ └ css/6e41f1b6078c14c1.css 7.9 kB
30
- ├ ● /[slug]/p 11.7 kB 135 kB
30
+ ├ ● /[slug]/p 11.7 kB 134 kB
31
31
  ├ └ css/c6f97f692b2efad9.css 11 kB
32
32
  ├ ○ /404 1.09 kB 113 kB
33
33
  ├ ● /500 1.11 kB 113 kB
34
- ├ ● /account 672 B 113 kB
35
- ├ λ /api/graphql 0 B 78 kB
36
- ├ λ /api/preview 0 B 78 kB
37
- ├ ● /checkout 659 B 113 kB
34
+ ├ ● /account 669 B 112 kB
35
+ ├ λ /api/graphql 0 B 77.8 kB
36
+ ├ λ /api/preview 0 B 77.8 kB
37
+ ├ ● /checkout 657 B 112 kB
38
38
  ├ ● /login 1.01 kB 113 kB
39
39
  └ ● /s 1.11 kB 124 kB
40
- + First Load JS shared by all 80.7 kB
40
+ + First Load JS shared by all 80.6 kB
41
41
  ├ chunks/framework-dfd14d7ce6600b03.js 45.3 kB
42
42
  ├ chunks/main-fd466221927468fd.js 23.9 kB
43
- ├ chunks/pages/_app-78846ca9151cf266.js 6.49 kB
44
- ├ chunks/webpack-e9bf82a67cc08d0f.js 2.27 kB
43
+ ├ chunks/pages/_app-79d333aa6001a806.js 6.38 kB
44
+ ├ chunks/webpack-79982595c94ff0e7.js 2.21 kB
45
45
  └ css/47d82dcec9a7dbc2.css 2.78 kB
46
46
 
47
47
  λ (Server) server-side renders at runtime (uses getInitialProps or getServerSideProps)
package/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [2.0.168-alpha.0](https://github.com/vtex/faststore/compare/v2.0.167-alpha.0...v2.0.168-alpha.0) (2023-05-29)
7
+
8
+ ### Features
9
+
10
+ - Adds `RegionBar` and `RegionModal` Sections ([#1798](https://github.com/vtex/faststore/issues/1798)) ([627fa25](https://github.com/vtex/faststore/commit/627fa25832a7a41a1feebe07bef43b67e5edf13a))
11
+
12
+ ## [2.0.166-alpha.0](https://github.com/vtex/faststore/compare/v2.0.165-alpha.0...v2.0.166-alpha.0) (2023-05-29)
13
+
14
+ ### Features
15
+
16
+ - Adds `CartSidebar` Section ([#1795](https://github.com/vtex/faststore/issues/1795)) ([c544c45](https://github.com/vtex/faststore/commit/c544c4571b1419ad421b4df57a51de7a0f9e0e2b))
17
+
6
18
  ## [2.0.165-alpha.0](https://github.com/vtex/faststore/compare/v2.0.164-alpha.0...v2.0.165-alpha.0) (2023-05-26)
7
19
 
8
20
  **Note:** Version bump only for package @faststore/core
@@ -1422,5 +1422,231 @@
1422
1422
  }
1423
1423
  }
1424
1424
  }
1425
+ },
1426
+ {
1427
+ "name": "CartSidebar",
1428
+ "schema": {
1429
+ "title": "Cart Sidebar",
1430
+ "type": "object",
1431
+ "description": "Cart Sidebar configuration",
1432
+ "properties": {
1433
+ "title": {
1434
+ "title": "Title text",
1435
+ "type": "string",
1436
+ "default": "Your Cart"
1437
+ },
1438
+ "alert": {
1439
+ "title": "Alert",
1440
+ "type": "object",
1441
+ "properties": {
1442
+ "icon": {
1443
+ "title": "Icon",
1444
+ "type": "object",
1445
+ "required": ["icon", "alt"],
1446
+ "properties": {
1447
+ "icon": {
1448
+ "title": "Icon",
1449
+ "type": "string",
1450
+ "enumNames": [
1451
+ "Bell",
1452
+ "BellRinging",
1453
+ "Checked",
1454
+ "Info",
1455
+ "Truck",
1456
+ "User"
1457
+ ],
1458
+ "enum": [
1459
+ "Bell",
1460
+ "BellRinging",
1461
+ "Checked",
1462
+ "Info",
1463
+ "Truck",
1464
+ "User"
1465
+ ],
1466
+ "default": "Truck"
1467
+ },
1468
+ "alt": {
1469
+ "title": "Alternative label",
1470
+ "type": "string",
1471
+ "default": "Arrow Right icon"
1472
+ }
1473
+ }
1474
+ },
1475
+ "text": {
1476
+ "type": "string",
1477
+ "title": "Text",
1478
+ "default": "Free shipping starts at $300"
1479
+ }
1480
+ }
1481
+ },
1482
+ "checkoutButton": {
1483
+ "title": "Checkout button",
1484
+ "type": "object",
1485
+ "required": ["label", "loadingLabel", "icon"],
1486
+ "properties": {
1487
+ "label": {
1488
+ "title": "Label",
1489
+ "type": "string",
1490
+ "default": "Checkout"
1491
+ },
1492
+ "loadingLabel": {
1493
+ "title": "Loading label",
1494
+ "type": "string",
1495
+ "default": "Loading..."
1496
+ },
1497
+ "icon": {
1498
+ "title": "Icon",
1499
+ "type": "object",
1500
+ "required": ["icon", "alt"],
1501
+ "properties": {
1502
+ "icon": {
1503
+ "title": "Icon",
1504
+ "type": "string",
1505
+ "enumNames": ["ArrowRight"],
1506
+ "enum": ["ArrowRight"],
1507
+ "default": "ArrowRight"
1508
+ },
1509
+ "alt": {
1510
+ "title": "Alternative label",
1511
+ "type": "string",
1512
+ "default": "Arrow Right icon"
1513
+ }
1514
+ }
1515
+ }
1516
+ }
1517
+ }
1518
+ }
1519
+ }
1520
+ },
1521
+ {
1522
+ "name": "RegionBar",
1523
+ "schema": {
1524
+ "title": "Region Bar",
1525
+ "type": "object",
1526
+ "description": "Region Bar configuration",
1527
+ "required": ["label"],
1528
+ "properties": {
1529
+ "icon": {
1530
+ "title": "Location Icon",
1531
+ "type": "object",
1532
+ "properties": {
1533
+ "icon": {
1534
+ "title": "Icon",
1535
+ "type": "string",
1536
+ "enumNames": ["Map Pin"],
1537
+ "enum": ["MapPin"],
1538
+ "default": "MapPin"
1539
+ },
1540
+ "alt": {
1541
+ "title": "Alternative Label",
1542
+ "type": "string",
1543
+ "default": "Map Pin icon"
1544
+ }
1545
+ }
1546
+ },
1547
+ "label": {
1548
+ "title": "Location label",
1549
+ "type": "string",
1550
+ "default": "Set your location"
1551
+ },
1552
+ "editLabel": {
1553
+ "title": "Location edit label",
1554
+ "type": "string",
1555
+ "default": "Edit"
1556
+ },
1557
+ "buttonIcon": {
1558
+ "title": "Button Icon",
1559
+ "type": "object",
1560
+ "properties": {
1561
+ "icon": {
1562
+ "title": "Icon",
1563
+ "type": "string",
1564
+ "enumNames": ["Caret Right"],
1565
+ "enum": ["CaretRight"],
1566
+ "default": "CaretRight"
1567
+ },
1568
+ "alt": {
1569
+ "title": "Alternative Label",
1570
+ "type": "string",
1571
+ "default": "Caret Right icon"
1572
+ }
1573
+ }
1574
+ }
1575
+ }
1576
+ }
1577
+ },
1578
+ {
1579
+ "name": "RegionModal",
1580
+ "schema": {
1581
+ "title": "Region Modal",
1582
+ "type": "object",
1583
+ "description": "Region Modal configuration",
1584
+ "properties": {
1585
+ "title": {
1586
+ "title": "Title",
1587
+ "type": "string",
1588
+ "default": "Set your location"
1589
+ },
1590
+ "description": {
1591
+ "title": "Description",
1592
+ "type": "string",
1593
+ "default": "Prices, offers and availability may vary according to your location."
1594
+ },
1595
+ "closeButtonAriaLabel": {
1596
+ "title": "Close modal aria-label",
1597
+ "type": "string",
1598
+ "default": "Close Region Modal"
1599
+ },
1600
+ "inputField": {
1601
+ "title": "Input Field",
1602
+ "type": "object",
1603
+ "properties": {
1604
+ "label": {
1605
+ "title": "Input field label",
1606
+ "type": "string",
1607
+ "default": "Postal Code"
1608
+ },
1609
+ "errorMessage": {
1610
+ "title": "Input field error message",
1611
+ "type": "string",
1612
+ "default": "You entered an invalid Postal Code"
1613
+ }
1614
+ }
1615
+ },
1616
+ "idkPostalCodeLink": {
1617
+ "title": "I don't know my postal code link",
1618
+ "type": "object",
1619
+ "properties": {
1620
+ "text": {
1621
+ "type": "string",
1622
+ "title": "Link Text",
1623
+ "default": "I don't know my Postal Code"
1624
+ },
1625
+ "to": {
1626
+ "type": "string",
1627
+ "title": "Action link"
1628
+ },
1629
+ "icon": {
1630
+ "title": "Icon",
1631
+ "type": "object",
1632
+ "properties": {
1633
+ "icon": {
1634
+ "title": "Icon",
1635
+ "type": "string",
1636
+ "enumNames": ["Arrow Square Out"],
1637
+ "enum": ["ArrowSquareOut"],
1638
+ "default": "ArrowSquareOut"
1639
+ },
1640
+ "alt": {
1641
+ "title": "Alternative Label",
1642
+ "type": "string",
1643
+ "default": "Arrow Square Out icon"
1644
+ }
1645
+ }
1646
+ }
1647
+ }
1648
+ }
1649
+ }
1650
+ }
1425
1651
  }
1426
1652
  ]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faststore/core",
3
- "version": "2.0.165-alpha.0",
3
+ "version": "2.0.168-alpha.0",
4
4
  "license": "MIT",
5
5
  "browserslist": "supports es6-module and not dead",
6
6
  "scripts": {
@@ -30,7 +30,7 @@
30
30
  "@envelop/parser-cache": "^2.2.0",
31
31
  "@envelop/validation-cache": "^2.2.0",
32
32
  "@faststore/api": "^2.0.165-alpha.0",
33
- "@faststore/components": "^2.0.160-alpha.0",
33
+ "@faststore/components": "^2.0.168-alpha.0",
34
34
  "@faststore/graphql-utils": "^2.0.3-alpha.0",
35
35
  "@faststore/sdk": "^2.0.162-alpha.0",
36
36
  "@faststore/ui": "^2.0.160-alpha.0",
@@ -108,5 +108,5 @@
108
108
  "msw": {
109
109
  "workerDirectory": "public"
110
110
  },
111
- "gitHead": "21ad4389f70c01d68d1d9722acb5d68eb13ec30c"
111
+ "gitHead": "83716a775545aa6ed10a478113408de4a094f792"
112
112
  }
package/src/Layout.tsx CHANGED
@@ -1,31 +1,7 @@
1
1
  import type { PropsWithChildren } from 'react'
2
- import { lazy, Suspense } from 'react'
3
-
4
- import { useUI } from '@faststore/ui'
5
-
6
- const CartSidebar = lazy(() => import('src/components/cart/CartSidebar'))
7
- const RegionModal = lazy(() => import('src/components/region/RegionModal'))
8
2
 
9
3
  function Layout({ children }: PropsWithChildren) {
10
- const { cart: displayCart, modal: displayModal } = useUI()
11
-
12
- return (
13
- <>
14
- {children}
15
-
16
- {displayCart && (
17
- <Suspense fallback={null}>
18
- <CartSidebar />
19
- </Suspense>
20
- )}
21
-
22
- {displayModal && (
23
- <Suspense fallback={null}>
24
- <RegionModal />
25
- </Suspense>
26
- )}
27
- </>
28
- )
4
+ return <>{children}</>
29
5
  }
30
6
 
31
7
  export default Layout
@@ -6,10 +6,11 @@ import {
6
6
  CartSidebarList as UICartSidebarList,
7
7
  } from '@faststore/ui'
8
8
 
9
- import type { CurrencyCode, ViewCartEvent } from '@faststore/sdk'
10
- import { useEffect } from 'react'
9
+ import type { CartSidebarProps as UICartSidebarProps } from '@faststore/ui'
11
10
 
11
+ import type { CurrencyCode, ViewCartEvent } from '@faststore/sdk'
12
12
  import { Icon, useFadeEffect, useUI } from '@faststore/ui'
13
+ import { Suspense, useEffect } from 'react'
13
14
  import { useCart } from 'src/sdk/cart'
14
15
  import { useCheckoutButton } from 'src/sdk/cart/useCheckoutButton'
15
16
  import { useSession } from 'src/sdk/session'
@@ -20,11 +21,41 @@ import EmptyCart from '../EmptyCart'
20
21
  import OrderSummary from '../OrderSummary'
21
22
  import styles from './section.module.scss'
22
23
 
23
- function CartSidebar() {
24
+ export interface CartSidebarProps {
25
+ title: UICartSidebarProps['title']
26
+ alert?: {
27
+ icon?: {
28
+ icon: string
29
+ alt: string
30
+ }
31
+ text: UICartSidebarProps['alertText']
32
+ }
33
+ checkoutButton: {
34
+ label: string
35
+ loadingLabel: string
36
+ icon?: {
37
+ icon: string
38
+ alt: string
39
+ }
40
+ }
41
+ }
42
+
43
+ function CartSidebar({
44
+ title,
45
+ alert: {
46
+ icon: { icon: alertIcon, alt: alertIconAlt },
47
+ text: alertText,
48
+ },
49
+ checkoutButton: {
50
+ label: checkoutLabel,
51
+ loadingLabel: checkoutLoadingLabel,
52
+ icon: { icon: checkoutButtonIcon, alt: checkoutButtonIconAlt },
53
+ },
54
+ }: CartSidebarProps) {
24
55
  const { currency } = useSession()
25
56
  const btnProps = useCheckoutButton()
26
57
  const cart = useCart()
27
- const { closeCart } = useUI()
58
+ const { cart: displayCart, closeCart } = useUI()
28
59
  const { fadeOut } = useFadeEffect()
29
60
 
30
61
  const { items, gifts, totalItems, isValidating, subTotal, total } = cart
@@ -55,60 +86,72 @@ function CartSidebar() {
55
86
  }, [])
56
87
 
57
88
  return (
58
- <UICartSidebar
59
- overlayProps={{
60
- className: `section ${styles.section} section-cart-sidebar`,
61
- }}
62
- totalItems={totalItems}
63
- alertIcon={<Icon name="Truck" />}
64
- alertText="Free shipping starts at $300"
65
- onClose={fadeOut}
66
- >
67
- {isEmpty ? (
68
- <EmptyCart onDismiss={closeCart} />
69
- ) : (
70
- <>
71
- <UICartSidebarList>
72
- {items.map((item) => (
73
- <li key={item.id}>
74
- <CartItem item={item} />
75
- </li>
76
- ))}
77
- {gifts.length > 0 && (
89
+ <>
90
+ {displayCart && (
91
+ <Suspense fallback={null}>
92
+ <UICartSidebar
93
+ overlayProps={{
94
+ className: `section ${styles.section} section-cart-sidebar`,
95
+ }}
96
+ title={title}
97
+ totalItems={totalItems}
98
+ alertIcon={<Icon name={alertIcon} aria-label={alertIconAlt} />}
99
+ alertText={alertText}
100
+ onClose={fadeOut}
101
+ >
102
+ {isEmpty ? (
103
+ <EmptyCart onDismiss={closeCart} />
104
+ ) : (
78
105
  <>
79
- {gifts.map((item) => (
80
- <li key={item.id}>
81
- <Gift item={item} />
82
- </li>
83
- ))}
106
+ <UICartSidebarList>
107
+ {items.map((item) => (
108
+ <li key={item.id}>
109
+ <CartItem item={item} />
110
+ </li>
111
+ ))}
112
+ {gifts.length > 0 && (
113
+ <>
114
+ {gifts.map((item) => (
115
+ <li key={item.id}>
116
+ <Gift item={item} />
117
+ </li>
118
+ ))}
119
+ </>
120
+ )}
121
+ </UICartSidebarList>
122
+
123
+ <UICartSidebarFooter>
124
+ <OrderSummary
125
+ subTotal={subTotal}
126
+ total={total}
127
+ numberOfItems={totalItems}
128
+ checkoutButton={
129
+ <UIButton
130
+ variant="primary"
131
+ icon={
132
+ !isValidating && (
133
+ <Icon
134
+ name={checkoutButtonIcon}
135
+ aria-label={checkoutButtonIconAlt}
136
+ width={18}
137
+ height={18}
138
+ />
139
+ )
140
+ }
141
+ iconPosition="right"
142
+ {...btnProps}
143
+ >
144
+ {isValidating ? checkoutLoadingLabel : checkoutLabel}
145
+ </UIButton>
146
+ }
147
+ />
148
+ </UICartSidebarFooter>
84
149
  </>
85
150
  )}
86
- </UICartSidebarList>
87
-
88
- <UICartSidebarFooter>
89
- <OrderSummary
90
- subTotal={subTotal}
91
- total={total}
92
- numberOfItems={totalItems}
93
- checkoutButton={
94
- <UIButton
95
- variant="primary"
96
- icon={
97
- !isValidating && (
98
- <Icon name="ArrowRight" width={18} height={18} />
99
- )
100
- }
101
- iconPosition="right"
102
- {...btnProps}
103
- >
104
- {isValidating ? 'Loading...' : 'Checkout'}
105
- </UIButton>
106
- }
107
- />
108
- </UICartSidebarFooter>
109
- </>
151
+ </UICartSidebar>
152
+ </Suspense>
110
153
  )}
111
- </UICartSidebar>
154
+ </>
112
155
  )
113
156
  }
114
157
 
@@ -1,17 +1,19 @@
1
- import { PropsWithChildren, useMemo } from 'react'
2
-
3
1
  import { Locator, Section } from '@vtex/client-cms'
4
2
  import type { ComponentType } from 'react'
3
+ import { PropsWithChildren, lazy } from 'react'
5
4
  import CUSTOM_COMPONENTS from 'src/customizations/components'
6
5
  import { PageContentType, getPage } from 'src/server/cms'
7
6
 
8
- import RegionBar from 'src/components/common/RegionBar'
9
7
  import Toast from 'src/components/common/Toast'
10
8
  import RenderSections from './RenderSections'
11
9
 
12
10
  import Alert from 'src/components/sections/Alert'
13
- import Navbar from 'src/components/sections/Navbar'
14
11
  import Footer from 'src/components/sections/Footer'
12
+ import Navbar from 'src/components/sections/Navbar'
13
+ import RegionBar from 'src/components/sections/RegionBar'
14
+
15
+ const RegionModal = lazy(() => import('src/components/region/RegionModal'))
16
+ const CartSidebar = lazy(() => import('src/components/cart/CartSidebar'))
15
17
 
16
18
  export const GLOBAL_SECTIONS_CONTENT_TYPE = 'globalSections'
17
19
 
@@ -22,8 +24,11 @@ export type GlobalSectionsData = {
22
24
  /* A list of components that can be used in the CMS. */
23
25
  const COMPONENTS: Record<string, ComponentType<any>> = {
24
26
  Alert,
25
- Footer,
26
27
  Navbar,
28
+ RegionBar,
29
+ RegionModal,
30
+ CartSidebar,
31
+ Footer,
27
32
  ...CUSTOM_COMPONENTS,
28
33
  }
29
34
 
@@ -35,10 +40,7 @@ function GlobalSections({
35
40
  <RenderSections components={COMPONENTS} {...otherProps}>
36
41
  <Toast />
37
42
 
38
- <main>
39
- <RegionBar className="display-mobile" />
40
- {children}
41
- </main>
43
+ <main>{children}</main>
42
44
  </RenderSections>
43
45
  )
44
46
  }
@@ -1,9 +1,39 @@
1
- import { RegionBar as UIRegionBar } from '@faststore/ui'
1
+ import type { RegionBarProps as UIRegionBarProps } from '@faststore/ui'
2
+ import { Icon, RegionBar as UIRegionBar } from '@faststore/ui'
2
3
 
3
- import { useSession } from 'src/sdk/session'
4
4
  import { useUI } from '@faststore/ui'
5
+ import { useSession } from 'src/sdk/session'
6
+
7
+ export interface RegionBarProps {
8
+ /**
9
+ * A React component that will be rendered as an icon.
10
+ */
11
+ icon?: {
12
+ icon: string
13
+ alt: string
14
+ }
15
+ /**
16
+ * Specifies a label for the location text.
17
+ */
18
+ label: UIRegionBarProps['label']
19
+ /**
20
+ * Specifies a label for the edit text.
21
+ */
22
+ editLabel?: UIRegionBarProps['editLabel']
23
+ /**
24
+ * A React component that will be rendered as an icon.
25
+ */
26
+ buttonIcon?: {
27
+ icon: string
28
+ alt: string
29
+ }
30
+ }
5
31
 
6
- function RegionBar({ ...otherProps }) {
32
+ function RegionBar({
33
+ icon: { icon: locationIcon, alt: locationIconAlt },
34
+ buttonIcon: { icon: buttonIcon, alt: buttonIconAlt },
35
+ ...otherProps
36
+ }: RegionBarProps) {
7
37
  const { openModal } = useUI()
8
38
  const { postalCode } = useSession()
9
39
 
@@ -11,6 +41,8 @@ function RegionBar({ ...otherProps }) {
11
41
  <UIRegionBar
12
42
  onButtonClick={openModal}
13
43
  postalCode={postalCode}
44
+ icon={<Icon name={locationIcon} aria-label={locationIconAlt} />}
45
+ buttonIcon={<Icon name={buttonIcon} aria-label={buttonIconAlt} />}
14
46
  {...otherProps}
15
47
  />
16
48
  )