@postnord/pn-marketweb-components 1.0.4 → 1.0.8

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 (229) hide show
  1. package/cjs/convert-57b3dd5e.js +1730 -0
  2. package/cjs/{index-0f43b450.js → index-b58d2618.js} +82 -0
  3. package/cjs/index-f472d191.js +181 -0
  4. package/cjs/loader.cjs.js +2 -2
  5. package/cjs/pn-choice-button_2.cjs.entry.js +78 -0
  6. package/cjs/pn-find-service-and-price-store-56d8b760.js +23 -0
  7. package/cjs/pn-find-service-and-price.cjs.entry.js +263 -0
  8. package/cjs/pn-language-selector_9.cjs.entry.js +646 -0
  9. package/cjs/pn-mainnav-link.cjs.entry.js +45 -0
  10. package/cjs/pn-mainnav-store-dda9827f.js +18 -0
  11. package/cjs/pn-market-web-components.cjs.js +2 -2
  12. package/cjs/pn-marketweb-sitefooter.cjs.entry.js +145 -0
  13. package/cjs/{pn-siteheader.cjs.entry.js → pn-marketweb-siteheader.cjs.entry.js} +8 -8
  14. package/cjs/pn-product-pricelist-result.cjs.entry.js +45 -0
  15. package/cjs/pn-product-pricelist-store-e4f8503b.js +20 -0
  16. package/cjs/pn-product-pricelist.cjs.entry.js +219 -0
  17. package/cjs/pn-product-tile_3.cjs.entry.js +49 -0
  18. package/cjs/pn-site-footer_2.cjs.entry.js +36 -0
  19. package/collection/collection-manifest.json +22 -3
  20. package/collection/components/input/pn-choice-button/choice-button.stories.js +34 -0
  21. package/collection/components/input/pn-choice-button/pn-choice-button.css +66 -0
  22. package/collection/components/input/pn-choice-button/pn-choice-button.js +170 -0
  23. package/collection/components/layout-components/pn-marketweb-sitefooter/pn-marketweb-sitefooter-types.js +10 -0
  24. package/collection/components/layout-components/pn-marketweb-sitefooter/pn-marketweb-sitefooter.css +0 -0
  25. package/collection/components/layout-components/pn-marketweb-sitefooter/pn-marketweb-sitefooter.js +166 -0
  26. package/collection/components/layout-components/pn-marketweb-sitefooter/pn-marketweb-sitefooter.stories.js +54 -0
  27. package/collection/components/layout-components/{pn-siteheader → pn-marketweb-sitefooter}/translations.js +0 -0
  28. package/collection/components/layout-components/pn-marketweb-siteheader/pn-marketweb-siteheader-login.css +34 -0
  29. package/collection/components/layout-components/{pn-siteheader/pn-siteheader-login.js → pn-marketweb-siteheader/pn-marketweb-siteheader-login.js} +6 -6
  30. package/collection/components/layout-components/{pn-siteheader/pn-siteheader-loginmanager.js → pn-marketweb-siteheader/pn-marketweb-siteheader-loginmanager.js} +0 -0
  31. package/collection/components/layout-components/{pn-siteheader/pn-siteheader-search.css → pn-marketweb-siteheader/pn-marketweb-siteheader-search.css} +0 -0
  32. package/collection/components/layout-components/{pn-siteheader/pn-siteheader-search.js → pn-marketweb-siteheader/pn-marketweb-siteheader-search.js} +5 -6
  33. package/collection/components/layout-components/{pn-siteheader/pn-siteheader-types.js → pn-marketweb-siteheader/pn-marketweb-siteheader-types.js} +0 -0
  34. package/collection/components/layout-components/{pn-siteheader/pn-siteheader.css → pn-marketweb-siteheader/pn-marketweb-siteheader.css} +21 -21
  35. package/collection/components/layout-components/{pn-siteheader/pn-siteheader.js → pn-marketweb-siteheader/pn-marketweb-siteheader.js} +7 -7
  36. package/collection/components/layout-components/{pn-siteheader/pn-siteheader.stories.js → pn-marketweb-siteheader/pn-marketweb-siteheader.stories.js} +2 -2
  37. package/collection/components/layout-components/pn-marketweb-siteheader/translations.js +47 -0
  38. package/collection/components/navigation/pn-language-selector/language-selector.stories.js +43 -0
  39. package/collection/components/navigation/pn-language-selector/pn-language-selector-option.css +74 -0
  40. package/collection/components/navigation/pn-language-selector/pn-language-selector-option.js +148 -0
  41. package/collection/components/navigation/pn-language-selector/pn-language-selector-types.js +1 -0
  42. package/collection/components/navigation/pn-language-selector/pn-language-selector.css +32 -0
  43. package/collection/components/navigation/pn-language-selector/pn-language-selector.js +92 -0
  44. package/collection/components/navigation/pn-language-selector/translations.js +17 -0
  45. package/collection/components/navigation/pn-mainnav/main-nav.stories.js +92 -0
  46. package/collection/components/navigation/pn-mainnav/pn-main-nav-mockdata.js +5851 -0
  47. package/collection/components/navigation/pn-mainnav/pn-mainnav-level.css +139 -0
  48. package/collection/components/navigation/pn-mainnav/pn-mainnav-level.js +93 -0
  49. package/collection/components/navigation/pn-mainnav/pn-mainnav-link.css +221 -0
  50. package/collection/components/navigation/pn-mainnav/pn-mainnav-link.js +126 -0
  51. package/collection/components/navigation/pn-mainnav/pn-mainnav-list.css +51 -0
  52. package/collection/components/navigation/pn-mainnav/pn-mainnav-list.js +46 -0
  53. package/collection/components/navigation/pn-mainnav/pn-mainnav-store.js +14 -0
  54. package/collection/components/navigation/pn-mainnav/pn-mainnav.css +100 -0
  55. package/collection/components/navigation/pn-mainnav/pn-mainnav.js +200 -0
  56. package/collection/components/navigation/pn-mainnav/translations.js +32 -0
  57. package/collection/components/navigation/pn-mainnav/types.js +1 -0
  58. package/collection/components/navigation/pn-site-footer/pn-site-footer-col.css +20 -0
  59. package/collection/components/navigation/pn-site-footer/pn-site-footer-col.js +14 -0
  60. package/collection/components/navigation/pn-site-footer/pn-site-footer.css +72 -0
  61. package/collection/components/navigation/pn-site-footer/pn-site-footer.js +50 -0
  62. package/collection/components/navigation/pn-site-footer/site-footer.stories.js +87 -0
  63. package/collection/components/navigation/pn-site-selector/pn-site-selector-i18n.js +18 -0
  64. package/collection/components/navigation/pn-site-selector/pn-site-selector-item.css +62 -0
  65. package/collection/components/navigation/pn-site-selector/pn-site-selector-item.js +103 -0
  66. package/collection/components/navigation/pn-site-selector/pn-site-selector-types.js +1 -0
  67. package/collection/components/navigation/pn-site-selector/pn-site-selector.css +29 -0
  68. package/collection/components/navigation/pn-site-selector/pn-site-selector.js +96 -0
  69. package/collection/components/navigation/pn-site-selector/site-selector.stories.js +35 -0
  70. package/collection/components/widgets/pn-find-service-and-price/data.js +53 -0
  71. package/collection/components/widgets/pn-find-service-and-price/find-service-and-price.stories.js +27 -0
  72. package/collection/components/widgets/pn-find-service-and-price/libs/convertnode.js +58 -0
  73. package/collection/components/widgets/pn-find-service-and-price/pn-find-service-and-price-result.css +0 -0
  74. package/collection/components/widgets/pn-find-service-and-price/pn-find-service-and-price-result.js +101 -0
  75. package/collection/components/widgets/pn-find-service-and-price/pn-find-service-and-price-store.js +20 -0
  76. package/collection/components/widgets/pn-find-service-and-price/pn-find-service-and-price-translations.js +71 -0
  77. package/collection/components/widgets/pn-find-service-and-price/pn-find-service-and-price-types.js +1 -0
  78. package/collection/components/widgets/pn-find-service-and-price/pn-find-service-and-price.css +56 -0
  79. package/collection/components/widgets/pn-find-service-and-price/pn-find-service-and-price.js +236 -0
  80. package/collection/components/widgets/pn-find-service-and-price/runconvert.js +2 -0
  81. package/collection/components/widgets/pn-product-pricelist/data.js +53 -0
  82. package/collection/components/widgets/pn-product-pricelist/libs/convert.js +43 -0
  83. package/collection/components/widgets/pn-product-pricelist/libs/convertnode.js +58 -0
  84. package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist-result.css +0 -0
  85. package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist-result.js +101 -0
  86. package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist-store.js +17 -0
  87. package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist-translations.js +56 -0
  88. package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist-types.js +1 -0
  89. package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist.css +55 -0
  90. package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist.js +231 -0
  91. package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist.stories.js +35 -0
  92. package/collection/components/widgets/pn-product-pricelist/runconvert.js +2 -0
  93. package/collection/components/widgets/pn-product-tile/pn-product-tile-info.css +3 -0
  94. package/collection/components/widgets/pn-product-tile/pn-product-tile-info.js +70 -0
  95. package/collection/components/widgets/pn-product-tile/pn-product-tile-price.css +23 -0
  96. package/collection/components/widgets/pn-product-tile/pn-product-tile-price.js +94 -0
  97. package/collection/components/widgets/pn-product-tile/pn-product-tile.css +48 -0
  98. package/collection/components/widgets/pn-product-tile/pn-product-tile.js +21 -0
  99. package/collection/components/widgets/pn-product-tile/product-tile.stories.js +50 -0
  100. package/collection/globals/shared/productprice/convert.js +43 -0
  101. package/collection/globals/shared/productprice/product-price-types.js +1 -0
  102. package/custom-elements/index.d.ts +126 -12
  103. package/custom-elements/index.js +3179 -24
  104. package/esm/convert-b49a0857.js +1728 -0
  105. package/esm/{index-1e3839a0.js → index-52dc19ca.js} +79 -1
  106. package/esm/index-7c277874.js +179 -0
  107. package/esm/loader.js +2 -2
  108. package/esm/pn-choice-button_2.entry.js +73 -0
  109. package/esm/pn-find-service-and-price-store-d02cbfe1.js +21 -0
  110. package/esm/pn-find-service-and-price.entry.js +259 -0
  111. package/esm/pn-language-selector_9.entry.js +634 -0
  112. package/esm/pn-mainnav-link.entry.js +41 -0
  113. package/esm/pn-mainnav-store-a0726338.js +15 -0
  114. package/esm/pn-market-web-components.js +2 -2
  115. package/esm/pn-marketweb-sitefooter.entry.js +141 -0
  116. package/esm/{pn-siteheader.entry.js → pn-marketweb-siteheader.entry.js} +8 -8
  117. package/esm/pn-product-pricelist-result.entry.js +41 -0
  118. package/esm/pn-product-pricelist-store-6259b354.js +18 -0
  119. package/esm/pn-product-pricelist.entry.js +215 -0
  120. package/esm/pn-product-tile_3.entry.js +43 -0
  121. package/esm/pn-site-footer_2.entry.js +31 -0
  122. package/esm-es5/convert-b49a0857.js +13 -0
  123. package/esm-es5/index-52dc19ca.js +1 -0
  124. package/esm-es5/index-7c277874.js +1 -0
  125. package/esm-es5/loader.js +1 -1
  126. package/esm-es5/pn-choice-button_2.entry.js +1 -0
  127. package/esm-es5/pn-find-service-and-price-store-d02cbfe1.js +1 -0
  128. package/esm-es5/pn-find-service-and-price.entry.js +1 -0
  129. package/esm-es5/pn-language-selector_9.entry.js +1 -0
  130. package/esm-es5/pn-mainnav-link.entry.js +1 -0
  131. package/esm-es5/pn-mainnav-store-a0726338.js +1 -0
  132. package/esm-es5/pn-market-web-components.js +1 -1
  133. package/esm-es5/pn-marketweb-sitefooter.entry.js +1 -0
  134. package/esm-es5/pn-marketweb-siteheader.entry.js +1 -0
  135. package/esm-es5/pn-product-pricelist-result.entry.js +1 -0
  136. package/esm-es5/pn-product-pricelist-store-6259b354.js +1 -0
  137. package/esm-es5/pn-product-pricelist.entry.js +1 -0
  138. package/esm-es5/pn-product-tile_3.entry.js +1 -0
  139. package/esm-es5/pn-site-footer_2.entry.js +1 -0
  140. package/package.json +6 -3
  141. package/pn-market-web-components/p-05d06f7f.system.js +1 -0
  142. package/pn-market-web-components/p-0a756d7d.system.entry.js +1 -0
  143. package/pn-market-web-components/p-21e0e386.js +13 -0
  144. package/pn-market-web-components/p-27502f43.system.entry.js +1 -0
  145. package/pn-market-web-components/p-3ae134bf.system.entry.js +1 -0
  146. package/pn-market-web-components/p-3ae74105.system.entry.js +1 -0
  147. package/pn-market-web-components/p-43bb8707.system.js +1 -0
  148. package/pn-market-web-components/p-46018354.system.js +1 -0
  149. package/pn-market-web-components/p-4b4ee8d5.system.entry.js +1 -0
  150. package/pn-market-web-components/p-4bf9a9ff.js +1 -0
  151. package/pn-market-web-components/p-57a1db89.system.entry.js +1 -0
  152. package/pn-market-web-components/p-5f1ad0b7.entry.js +1 -0
  153. package/pn-market-web-components/p-62700d6e.system.js +1 -0
  154. package/pn-market-web-components/p-7331d3bb.system.js +1 -0
  155. package/pn-market-web-components/p-80fd4dd9.system.entry.js +1 -0
  156. package/pn-market-web-components/p-91624bd5.system.js +13 -0
  157. package/pn-market-web-components/p-926fc962.js +1 -0
  158. package/pn-market-web-components/p-986d3894.entry.js +1 -0
  159. package/pn-market-web-components/p-a04d0ba4.entry.js +1 -0
  160. package/pn-market-web-components/p-a5179982.system.entry.js +1 -0
  161. package/pn-market-web-components/p-af861bb5.js +1 -0
  162. package/pn-market-web-components/p-b129cc27.system.js +1 -0
  163. package/pn-market-web-components/p-b4904bdb.system.entry.js +1 -0
  164. package/pn-market-web-components/p-ba704cbf.entry.js +1 -0
  165. package/pn-market-web-components/p-ba8e9dfe.entry.js +1 -0
  166. package/pn-market-web-components/p-be245b29.entry.js +1 -0
  167. package/pn-market-web-components/p-bfc523fc.js +1 -0
  168. package/pn-market-web-components/p-ce136600.js +1 -0
  169. package/pn-market-web-components/p-d3590589.entry.js +1 -0
  170. package/pn-market-web-components/p-e367b055.system.entry.js +1 -0
  171. package/pn-market-web-components/p-e377410f.entry.js +1 -0
  172. package/pn-market-web-components/p-ec95bda3.entry.js +1 -0
  173. package/pn-market-web-components/p-fee1d1c9.entry.js +1 -0
  174. package/pn-market-web-components/pn-market-web-components.esm.js +1 -1
  175. package/pn-market-web-components/pn-market-web-components.js +1 -1
  176. package/types/components/input/pn-choice-button/pn-choice-button.d.ts +20 -0
  177. package/types/components/layout-components/pn-marketweb-sitefooter/pn-marketweb-sitefooter-types.d.ts +21 -0
  178. package/types/components/layout-components/pn-marketweb-sitefooter/pn-marketweb-sitefooter.d.ts +23 -0
  179. package/types/components/layout-components/{pn-siteheader → pn-marketweb-sitefooter}/translations.d.ts +0 -0
  180. package/types/components/layout-components/{pn-siteheader/pn-siteheader-login.d.ts → pn-marketweb-siteheader/pn-marketweb-siteheader-login.d.ts} +3 -3
  181. package/types/components/layout-components/{pn-siteheader/pn-siteheader-loginmanager.d.ts → pn-marketweb-siteheader/pn-marketweb-siteheader-loginmanager.d.ts} +0 -0
  182. package/types/components/layout-components/{pn-siteheader/pn-siteheader-search.d.ts → pn-marketweb-siteheader/pn-marketweb-siteheader-search.d.ts} +2 -2
  183. package/types/components/layout-components/{pn-siteheader/pn-siteheader-types.d.ts → pn-marketweb-siteheader/pn-marketweb-siteheader-types.d.ts} +0 -0
  184. package/types/components/layout-components/{pn-siteheader/pn-siteheader.d.ts → pn-marketweb-siteheader/pn-marketweb-siteheader.d.ts} +2 -2
  185. package/types/components/layout-components/pn-marketweb-siteheader/translations.d.ts +47 -0
  186. package/types/components/navigation/pn-language-selector/pn-language-selector-option.d.ts +12 -0
  187. package/types/components/navigation/pn-language-selector/pn-language-selector-types.d.ts +9 -0
  188. package/types/components/navigation/pn-language-selector/pn-language-selector.d.ts +15 -0
  189. package/types/components/navigation/pn-language-selector/translations.d.ts +17 -0
  190. package/types/components/navigation/pn-mainnav/pn-mainnav-level.d.ts +15 -0
  191. package/types/components/navigation/pn-mainnav/pn-mainnav-link.d.ts +19 -0
  192. package/types/components/navigation/pn-mainnav/pn-mainnav-list.d.ts +7 -0
  193. package/types/components/navigation/pn-mainnav/pn-mainnav-store.d.ts +21 -0
  194. package/types/components/navigation/pn-mainnav/pn-mainnav.d.ts +24 -0
  195. package/types/components/navigation/pn-mainnav/translations.d.ts +32 -0
  196. package/types/components/navigation/pn-mainnav/types.d.ts +6 -0
  197. package/types/components/navigation/pn-site-footer/pn-site-footer-col.d.ts +3 -0
  198. package/types/components/navigation/pn-site-footer/pn-site-footer.d.ts +6 -0
  199. package/types/components/navigation/pn-site-selector/pn-site-selector-item.d.ts +7 -0
  200. package/types/components/navigation/pn-site-selector/pn-site-selector-types.d.ts +3 -0
  201. package/types/components/navigation/pn-site-selector/pn-site-selector.d.ts +12 -0
  202. package/types/components/widgets/pn-find-service-and-price/pn-find-service-and-price-result.d.ts +9 -0
  203. package/types/components/widgets/pn-find-service-and-price/pn-find-service-and-price-store.d.ts +33 -0
  204. package/types/components/widgets/pn-find-service-and-price/pn-find-service-and-price-translations.d.ts +71 -0
  205. package/types/components/widgets/pn-find-service-and-price/pn-find-service-and-price-types.d.ts +29 -0
  206. package/types/components/widgets/pn-find-service-and-price/pn-find-service-and-price.d.ts +18 -0
  207. package/types/components/widgets/pn-product-pricelist/pn-product-pricelist-result.d.ts +9 -0
  208. package/types/components/widgets/pn-product-pricelist/pn-product-pricelist-store.d.ts +27 -0
  209. package/types/components/widgets/pn-product-pricelist/pn-product-pricelist-translations.d.ts +56 -0
  210. package/types/components/widgets/pn-product-pricelist/pn-product-pricelist-types.d.ts +16 -0
  211. package/types/components/widgets/pn-product-pricelist/pn-product-pricelist.d.ts +20 -0
  212. package/types/components/widgets/pn-product-tile/pn-product-tile-info.d.ts +6 -0
  213. package/types/components/widgets/pn-product-tile/pn-product-tile-price.d.ts +7 -0
  214. package/types/components/widgets/pn-product-tile/pn-product-tile.d.ts +3 -0
  215. package/types/components.d.ts +486 -28
  216. package/types/globals/shared/productprice/product-price-types.d.ts +19 -0
  217. package/cjs/pn-siteheader-login_2.cjs.entry.js +0 -295
  218. package/collection/components/layout-components/pn-siteheader/pn-siteheader-login.css +0 -34
  219. package/esm/pn-siteheader-login_2.entry.js +0 -290
  220. package/esm-es5/index-1e3839a0.js +0 -1
  221. package/esm-es5/pn-siteheader-login_2.entry.js +0 -1
  222. package/esm-es5/pn-siteheader.entry.js +0 -1
  223. package/pn-market-web-components/p-0e743863.system.js +0 -1
  224. package/pn-market-web-components/p-1e159db8.js +0 -1
  225. package/pn-market-web-components/p-2e901469.system.entry.js +0 -1
  226. package/pn-market-web-components/p-4d08fcb9.entry.js +0 -1
  227. package/pn-market-web-components/p-530b52d0.system.js +0 -1
  228. package/pn-market-web-components/p-9a654a14.system.entry.js +0 -1
  229. package/pn-market-web-components/p-a1045531.entry.js +0 -1
@@ -0,0 +1,231 @@
1
+ import { Component, h, Prop, State, Host, Watch } from "@stencil/core";
2
+ import { translations, markets } from "./pn-product-pricelist-translations";
3
+ import { weights } from "./data.js";
4
+ import { convertFileFromStream } from "../../../globals/shared/productprice/convert.js";
5
+ import { state } from "./pn-product-pricelist-store";
6
+ export class PnFindProductPricelist {
7
+ constructor() {
8
+ this.source = "https://com-integration.postnord.com/globalassets/global/prices/sv-se-findprice.xlsx";
9
+ this.language = "sv";
10
+ this.market = "se";
11
+ this.productid = "";
12
+ this.filteredItems = [];
13
+ this.sourceData = { types: [], data: [] };
14
+ this.gotData = false;
15
+ this.loading = false;
16
+ this.postagetype = { value: "" };
17
+ this.weight = { value: 0, name: "" };
18
+ this.weightvalue = 0;
19
+ }
20
+ componentWillLoad() {
21
+ this.setState();
22
+ this.getDataSource().then(() => { });
23
+ }
24
+ setState() {
25
+ if (this.market) {
26
+ state.market = markets[this.market];
27
+ }
28
+ if (this.language && translations[this.language]) {
29
+ state.i18n = translations[this.language];
30
+ }
31
+ }
32
+ async getDataSource() {
33
+ if (!this.productid) {
34
+ return;
35
+ }
36
+ this.loading = true;
37
+ const req = await fetch(this.source);
38
+ const reqbody = await req.blob();
39
+ try {
40
+ const convertedData = await convertFileFromStream(reqbody);
41
+ this.sourceData = convertedData;
42
+ this.filterItems();
43
+ }
44
+ catch (e) {
45
+ this.loading = false;
46
+ console.warn('Unable to parse data');
47
+ }
48
+ }
49
+ filterItems() {
50
+ var _a;
51
+ if (!((_a = this.sourceData) === null || _a === void 0 ? void 0 : _a.data)) {
52
+ console.info('Data has not yet been loaded');
53
+ return;
54
+ }
55
+ this.loading = false;
56
+ const productIdItems = this.sourceData.data.filter(x => x.id === this.productid);
57
+ if (productIdItems.length === 0) {
58
+ return;
59
+ }
60
+ this.postagetype.value = productIdItems[0].what;
61
+ if (!weights[this.postagetype.value] || weights[this.postagetype.value].length === 0) {
62
+ return;
63
+ }
64
+ if (this.weightvalue === 0) {
65
+ this.weight = weights[this.postagetype.value][0];
66
+ this.weightvalue = this.weight.value;
67
+ }
68
+ // For letters we use grams. Otherwise we use KG
69
+ const comparisonWeight = (this.weight.abbreviation.toLocaleLowerCase() === "kg" && this.postagetype.value === 'letter') ? this.weight.value * 1000 : this.weight.value;
70
+ let weightFilteredData = productIdItems.filter(x => x.maxweight === comparisonWeight);
71
+ // In parcels the maxwidths don't necessarily start at 1kg so we fetch any type below the user selected value
72
+ if (weightFilteredData.length === 0) {
73
+ weightFilteredData = productIdItems.filter(x => x.maxweight >= comparisonWeight);
74
+ if (weightFilteredData.length > 0) {
75
+ // We reverse the result array since the map will take the last unique item instead of the first
76
+ const uniqueWeightOptions = [...new Map(weightFilteredData.reverse().map(item => [item["id"], item])).values()];
77
+ if (uniqueWeightOptions.length > 0) {
78
+ weightFilteredData = uniqueWeightOptions;
79
+ }
80
+ }
81
+ }
82
+ this.filteredItems = weightFilteredData;
83
+ this.gotData = this.filteredItems.length > 0;
84
+ }
85
+ render() {
86
+ return (h(Host, null,
87
+ h("div", { class: "content" },
88
+ h("slot", null)),
89
+ this.loading ? (h("pn-spinner", null)) : null,
90
+ (this.postagetype.value && weights[this.postagetype.value]) ? (h("div", { class: "weightselection" },
91
+ (state.i18n.sizeheading) ? (h("div", { class: "heading" }, state.i18n.sizeheading)) : null,
92
+ h("div", { class: "weightoption" },
93
+ h("div", { class: "weightoption-input" },
94
+ h("pn-input", { inputid: "weightvalue", name: "weightvalue", type: "number", label: state.i18n.weightlabel, value: this.weightvalue, onChange: (e) => {
95
+ if (e && e.target && e.target.value) {
96
+ const weightNum = parseInt(e.target.value, 10);
97
+ if (!isNaN(weightNum)) {
98
+ let matchingWeights = weights[this.postagetype.value].filter((x) => {
99
+ let weightInGrams = (x.abbreviation === "kg") ? x.value * 1000 : x.value;
100
+ return weightInGrams >= weightNum;
101
+ });
102
+ if (matchingWeights && matchingWeights.length > 0) {
103
+ this.weight = matchingWeights[0];
104
+ this.weightvalue = this.weight.value;
105
+ }
106
+ }
107
+ }
108
+ } }),
109
+ h("span", { class: "weightoption-input-abbreviation" }, this.weight.abbreviation)),
110
+ h("div", { class: "weightoption-range" },
111
+ h("input", { type: "range", id: "weightrange", name: "weightrange", list: "weightlist", value: (!this.weight.value) ? 0 : weights[this.postagetype.value].findIndex((x) => x.value === this.weightvalue), onChange: (e) => {
112
+ const value = e.target.value;
113
+ this.weight = weights[this.postagetype.value][value];
114
+ this.weightvalue = this.weight.value;
115
+ }, min: "0",
116
+ // max={ weights[this.postagetype.value][weights[this.postagetype.value].length - 1].value }
117
+ max: weights[this.postagetype.value].length - 1 }),
118
+ h("datalist", { id: "weightlist" }, weights[this.postagetype.value].map((weight, weightindex) => {
119
+ let labelText = weight.name;
120
+ if (weights[this.postagetype.value].length > 6) {
121
+ labelText = (weightindex % 5 === 0 || weightindex === 0 || weightindex === weights[this.postagetype.value].length - 1) ? weight.name : '';
122
+ }
123
+ return (h("option", Object.assign({ value: weightindex }, (labelText ? { label: labelText } : {}))));
124
+ })))))) : null,
125
+ h("div", { class: "resultlist", "data-list-count": this.filteredItems.length }, this.filteredItems.map((item) => (h("div", null,
126
+ h("pn-product-pricelist-result", { item: item })))))));
127
+ }
128
+ static get is() { return "pn-product-pricelist"; }
129
+ static get originalStyleUrls() { return {
130
+ "$": ["pn-product-pricelist.scss"]
131
+ }; }
132
+ static get styleUrls() { return {
133
+ "$": ["pn-product-pricelist.css"]
134
+ }; }
135
+ static get properties() { return {
136
+ "source": {
137
+ "type": "string",
138
+ "mutable": false,
139
+ "complexType": {
140
+ "original": "string",
141
+ "resolved": "string",
142
+ "references": {}
143
+ },
144
+ "required": false,
145
+ "optional": false,
146
+ "docs": {
147
+ "tags": [],
148
+ "text": ""
149
+ },
150
+ "attribute": "source",
151
+ "reflect": false,
152
+ "defaultValue": "\"https://com-integration.postnord.com/globalassets/global/prices/sv-se-findprice.xlsx\""
153
+ },
154
+ "language": {
155
+ "type": "string",
156
+ "mutable": true,
157
+ "complexType": {
158
+ "original": "string",
159
+ "resolved": "string",
160
+ "references": {}
161
+ },
162
+ "required": false,
163
+ "optional": false,
164
+ "docs": {
165
+ "tags": [],
166
+ "text": ""
167
+ },
168
+ "attribute": "language",
169
+ "reflect": false,
170
+ "defaultValue": "\"sv\""
171
+ },
172
+ "market": {
173
+ "type": "string",
174
+ "mutable": true,
175
+ "complexType": {
176
+ "original": "string",
177
+ "resolved": "string",
178
+ "references": {}
179
+ },
180
+ "required": false,
181
+ "optional": false,
182
+ "docs": {
183
+ "tags": [],
184
+ "text": ""
185
+ },
186
+ "attribute": "market",
187
+ "reflect": false,
188
+ "defaultValue": "\"se\""
189
+ },
190
+ "productid": {
191
+ "type": "string",
192
+ "mutable": false,
193
+ "complexType": {
194
+ "original": "string",
195
+ "resolved": "string",
196
+ "references": {}
197
+ },
198
+ "required": false,
199
+ "optional": false,
200
+ "docs": {
201
+ "tags": [],
202
+ "text": ""
203
+ },
204
+ "attribute": "productid",
205
+ "reflect": false,
206
+ "defaultValue": "\"\""
207
+ }
208
+ }; }
209
+ static get states() { return {
210
+ "filteredItems": {},
211
+ "sourceData": {},
212
+ "gotData": {},
213
+ "loading": {},
214
+ "postagetype": {},
215
+ "weight": {},
216
+ "weightvalue": {}
217
+ }; }
218
+ static get watchers() { return [{
219
+ "propName": "market",
220
+ "methodName": "setState"
221
+ }, {
222
+ "propName": "language",
223
+ "methodName": "setState"
224
+ }, {
225
+ "propName": "postagetype",
226
+ "methodName": "filterItems"
227
+ }, {
228
+ "propName": "weightvalue",
229
+ "methodName": "filterItems"
230
+ }]; }
231
+ }
@@ -0,0 +1,35 @@
1
+ import readme from "./readme.md";
2
+
3
+ export default {
4
+ title: "Widgets/Product price list",
5
+ parameters: {
6
+ notes: readme
7
+ }
8
+ };
9
+
10
+
11
+
12
+ const Template = ({ ...args }) => {
13
+ return `
14
+ <div style="max-width: 100%; margin:1em auto 0;">
15
+ <pn-product-pricelist
16
+ source="${args.source}"
17
+ market="${args.market}"
18
+ language="${args.language}"
19
+ productid="${args.productid}">
20
+ <h2>${args.heading}</h2>
21
+ <p>${args.description}</p>
22
+ </pn-product-pricelist>
23
+ </div>
24
+ `;
25
+ };
26
+
27
+ export const Primary = Template.bind({});
28
+ Primary.args = {
29
+ heading: '1:a-klassbrev inrikes',
30
+ description: '1:a-klassbrev kan väga upp till 2 kg och delas normalt ut första alternativt andra dagen dagen efter att det lämnats. För att skicka ett 1:a-klassbrev behöver du vara avtalskund hos oss.',
31
+ source: 'https://com-integration.postnord.com/globalassets/global/prices/sv-se-findprice.xlsx',
32
+ language: 'sv',
33
+ market: 'se',
34
+ productid: 'expressletter'
35
+ };
@@ -0,0 +1,2 @@
1
+ const convert = require("./libs/convertnode.js");
2
+ convert();
@@ -0,0 +1,3 @@
1
+ pn-product-tile-info {
2
+ align-self: center;
3
+ }
@@ -0,0 +1,70 @@
1
+ import { Component, h, Prop, Host } from "@stencil/core";
2
+ export class PnProductTileInfo {
3
+ render() {
4
+ return (h(Host, null,
5
+ (this.label) ? (h("p", null,
6
+ h("small", null, this.label))) : null,
7
+ (this.text) ? (h("h3", null, this.text)) : null));
8
+ }
9
+ static get is() { return "pn-product-tile-info"; }
10
+ static get originalStyleUrls() { return {
11
+ "$": ["pn-product-tile-info.scss"]
12
+ }; }
13
+ static get styleUrls() { return {
14
+ "$": ["pn-product-tile-info.css"]
15
+ }; }
16
+ static get properties() { return {
17
+ "label": {
18
+ "type": "string",
19
+ "mutable": false,
20
+ "complexType": {
21
+ "original": "string",
22
+ "resolved": "string",
23
+ "references": {}
24
+ },
25
+ "required": false,
26
+ "optional": false,
27
+ "docs": {
28
+ "tags": [],
29
+ "text": ""
30
+ },
31
+ "attribute": "label",
32
+ "reflect": false
33
+ },
34
+ "text": {
35
+ "type": "string",
36
+ "mutable": false,
37
+ "complexType": {
38
+ "original": "string",
39
+ "resolved": "string",
40
+ "references": {}
41
+ },
42
+ "required": false,
43
+ "optional": false,
44
+ "docs": {
45
+ "tags": [],
46
+ "text": ""
47
+ },
48
+ "attribute": "text",
49
+ "reflect": false
50
+ },
51
+ "icon": {
52
+ "type": "string",
53
+ "mutable": false,
54
+ "complexType": {
55
+ "original": "string",
56
+ "resolved": "string",
57
+ "references": {}
58
+ },
59
+ "required": false,
60
+ "optional": false,
61
+ "docs": {
62
+ "tags": [],
63
+ "text": ""
64
+ },
65
+ "attribute": "icon",
66
+ "reflect": false
67
+ }
68
+ }; }
69
+ }
70
+ h("pn-icon", { symbol: "align-center", small: "false", color: "black" });
@@ -0,0 +1,23 @@
1
+ pn-product-tile-price {
2
+ margin-top: 1em;
3
+ white-space: nowrap;
4
+ text-align: right;
5
+ }
6
+ pn-product-tile-price span:last-child {
7
+ display: inline-block;
8
+ margin-left: 0.2em;
9
+ }
10
+ pn-product-tile-price + pn-product-tile-price {
11
+ margin-left: 1.5em;
12
+ }
13
+ pn-product-tile-price pn-icon {
14
+ display: inline-block;
15
+ align-self: center;
16
+ }
17
+ pn-product-tile-price a {
18
+ text-decoration: none;
19
+ color: #005D92;
20
+ }
21
+ pn-product-tile-price a h3 {
22
+ text-decoration: underline;
23
+ }
@@ -0,0 +1,94 @@
1
+ import { Component, h, Prop, Host } from "@stencil/core";
2
+ export class PnProductTilePrice {
3
+ render() {
4
+ if (!this.amount) {
5
+ return;
6
+ }
7
+ return (this.url) ? (h(Host, null,
8
+ h("h3", null,
9
+ (this.amount) ? (h("span", { class: "pn-2xl" }, this.amount)) : null,
10
+ (this.currency) ? (h("span", { class: "pn-2xl" }, this.currency)) : null),
11
+ (this.label) ? (h("a", { href: this.url },
12
+ h("pn-button", { small: "true", icon: "arrow-right" }, this.label))) : null)) : (h(Host, null,
13
+ h("h3", null,
14
+ (this.amount) ? (h("span", { class: "pn-2xl" }, this.amount)) : null,
15
+ (this.currency) ? (h("span", { class: "pn-2xl" }, this.currency)) : null)));
16
+ }
17
+ static get is() { return "pn-product-tile-price"; }
18
+ static get originalStyleUrls() { return {
19
+ "$": ["pn-product-tile-price.scss"]
20
+ }; }
21
+ static get styleUrls() { return {
22
+ "$": ["pn-product-tile-price.css"]
23
+ }; }
24
+ static get properties() { return {
25
+ "label": {
26
+ "type": "string",
27
+ "mutable": false,
28
+ "complexType": {
29
+ "original": "string",
30
+ "resolved": "string",
31
+ "references": {}
32
+ },
33
+ "required": false,
34
+ "optional": false,
35
+ "docs": {
36
+ "tags": [],
37
+ "text": ""
38
+ },
39
+ "attribute": "label",
40
+ "reflect": false
41
+ },
42
+ "amount": {
43
+ "type": "string",
44
+ "mutable": false,
45
+ "complexType": {
46
+ "original": "string",
47
+ "resolved": "string",
48
+ "references": {}
49
+ },
50
+ "required": false,
51
+ "optional": false,
52
+ "docs": {
53
+ "tags": [],
54
+ "text": ""
55
+ },
56
+ "attribute": "amount",
57
+ "reflect": false
58
+ },
59
+ "currency": {
60
+ "type": "string",
61
+ "mutable": false,
62
+ "complexType": {
63
+ "original": "string",
64
+ "resolved": "string",
65
+ "references": {}
66
+ },
67
+ "required": false,
68
+ "optional": false,
69
+ "docs": {
70
+ "tags": [],
71
+ "text": ""
72
+ },
73
+ "attribute": "currency",
74
+ "reflect": false
75
+ },
76
+ "url": {
77
+ "type": "string",
78
+ "mutable": false,
79
+ "complexType": {
80
+ "original": "string",
81
+ "resolved": "string",
82
+ "references": {}
83
+ },
84
+ "required": false,
85
+ "optional": false,
86
+ "docs": {
87
+ "tags": [],
88
+ "text": ""
89
+ },
90
+ "attribute": "url",
91
+ "reflect": false
92
+ }
93
+ }; }
94
+ }
@@ -0,0 +1,48 @@
1
+ pn-product-tile {
2
+ margin-bottom: 1em;
3
+ border: 0.1rem solid #D3CECB;
4
+ outline: none;
5
+ background: white;
6
+ box-shadow: 0px 0.6px 1.8px rgba(0, 0, 0, 0.1), 0px 3.2px 7.2px rgba(0, 0, 0, 0.13);
7
+ display: flex;
8
+ padding: 1.5em;
9
+ word-break: break-word;
10
+ text-decoration: none;
11
+ border-radius: 0.8rem;
12
+ }
13
+ pn-product-tile [slot=content] h3 {
14
+ display: flex;
15
+ width: 100%;
16
+ justify-content: space-between;
17
+ margin-bottom: 0.5em;
18
+ }
19
+ pn-product-tile > pn-illustration {
20
+ min-width: 8rem;
21
+ width: 8rem;
22
+ height: 8rem;
23
+ margin-right: 3rem;
24
+ align-self: center;
25
+ }
26
+ pn-product-tile .tilecontent {
27
+ display: flex;
28
+ flex-direction: row;
29
+ justify-content: center;
30
+ flex-grow: 1;
31
+ }
32
+ pn-product-tile .details {
33
+ display: flex;
34
+ flex-direction: column;
35
+ justify-content: space-between;
36
+ width: 100%;
37
+ }
38
+ pn-product-tile .info {
39
+ display: flex;
40
+ justify-content: space-between;
41
+ flex-grow: 1;
42
+ max-width: calc((100% / 3) * 2);
43
+ flex-flow: wrap;
44
+ }
45
+ pn-product-tile .info > * {
46
+ min-width: 6em;
47
+ margin: 0.2em 1em 0.2em 0;
48
+ }
@@ -0,0 +1,21 @@
1
+ import { Component, h, Host } from "@stencil/core";
2
+ export class PnProductTile {
3
+ render() {
4
+ return (h(Host, null,
5
+ h("slot", { name: "illustration" }),
6
+ h("div", { class: "tilecontent" },
7
+ h("div", { class: "details" },
8
+ h("slot", { name: "content" }),
9
+ h("div", { class: "info" },
10
+ h("slot", null)),
11
+ h("slot", { name: "note" })),
12
+ h("slot", { name: "price" }))));
13
+ }
14
+ static get is() { return "pn-product-tile"; }
15
+ static get originalStyleUrls() { return {
16
+ "$": ["pn-product-tile.scss"]
17
+ }; }
18
+ static get styleUrls() { return {
19
+ "$": ["pn-product-tile.css"]
20
+ }; }
21
+ }
@@ -0,0 +1,50 @@
1
+ import readme from "./readme.md";
2
+
3
+ export default {
4
+ title: "Widgets/Product Tile",
5
+ parameters: {
6
+ notes: readme
7
+ }
8
+ };
9
+
10
+ const Template = ({ ...args }) => {
11
+ return `
12
+ <div style="max-width: 30em; margin:1em auto 0;">
13
+ <pn-product-tile>
14
+ <div slot="content">
15
+ <h3>${args.heading}</h3>
16
+ <p>${args.description}</p>
17
+ </div>
18
+ <pn-product-tile-info label="${args.info1label}" text="${args.info1value}"></pn-product-tile-info>
19
+ <pn-product-tile-info label="${args.info2label}" text="${args.info2value}"></pn-product-tile-info>
20
+ <pn-product-tile-price slot="price" label="${args.pricelabel}" amount="${args.priceamount}" currency="${args.pricecurrency}"></pn-product-tile-price>
21
+ </pn-product-tile>
22
+ </div>
23
+ `;
24
+ };
25
+
26
+ export const Primary = Template.bind({});
27
+ Primary.args = {
28
+ heading: "Skicka hem",
29
+ description: "Lorem ipsum dolor sit amet",
30
+ info1label: "Maxvikt",
31
+ info1value: "250g",
32
+ info2label: "Max längd + bredd + höjd",
33
+ info2value: "90cm",
34
+ pricelabel: "Skicka direkt",
35
+ priceamount: "52",
36
+ pricecurrency: "kr"
37
+ };
38
+
39
+ export const Secondary = Template.bind({});
40
+ Secondary.args = {
41
+ heading: "",
42
+ description: "",
43
+ info1label: "Maxvikt",
44
+ info1value: "250g",
45
+ info2label: "Max längd + bredd + höjd",
46
+ info2value: "90cm",
47
+ pricelabel: "Skicka direkt",
48
+ priceamount: "52",
49
+ pricecurrency: "kr"
50
+ };
@@ -0,0 +1,43 @@
1
+ import readXlsxFile from 'read-excel-file';
2
+
3
+ async function convertFileFromStream(stream, filterColumnNames = ["what", "deliveryscope"]) {
4
+ const toFilterValue = (x) => x.toLowerCase().replace(/\s+/g, '');
5
+ const sheets = await readXlsxFile(stream, { getSheets: true })
6
+ let dataRows = [];
7
+ let sheetsData = await Promise.all(sheets.map(async (sheet) => { return await readXlsxFile(stream, { sheet: sheet.name }) }));
8
+
9
+ let types = {};
10
+ sheetsData.forEach(sheetData => {
11
+ const firstRow = sheetData.shift().map(x => toFilterValue(x));
12
+ // Set up column for adding options
13
+ firstRow.forEach((col, i) => {
14
+ if (typeof types[col] === "undefined" && filterColumnNames.includes(col)) {
15
+ types[col] = [];
16
+ }
17
+ });
18
+ sheetData.forEach((row, rowindex) => {
19
+ const dataRow = {};
20
+ firstRow.forEach(async (col, i) => {
21
+ const rowVal = row[i];
22
+ dataRow[col] = rowVal;
23
+ // Add to types options
24
+ if (filterColumnNames.includes(col)) {
25
+ const filterVal = toFilterValue(rowVal);
26
+ dataRow[col] = filterVal;
27
+ if (!types[col].includes(filterVal)) {
28
+ types[col].push(filterVal);
29
+ }
30
+ }
31
+ });
32
+ dataRows.push(dataRow);
33
+ });
34
+ });
35
+
36
+ const fileData = {
37
+ "types": types,
38
+ "data": dataRows
39
+ };
40
+ return fileData;
41
+ }
42
+
43
+ export { convertFileFromStream };