@postnord/pn-marketweb-components 1.0.3 → 1.0.7

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-7ced0e29.js +21 -0
  7. package/cjs/pn-find-service-and-price.cjs.entry.js +246 -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} +14 -11
  14. package/cjs/pn-product-pricelist-result.cjs.entry.js +34 -0
  15. package/cjs/pn-product-pricelist-store-ffd73312.js +16 -0
  16. package/cjs/pn-product-pricelist.cjs.entry.js +110 -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} +13 -10
  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 +18 -0
  76. package/collection/components/widgets/pn-find-service-and-price/pn-find-service-and-price-translations.js +61 -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 +52 -0
  79. package/collection/components/widgets/pn-find-service-and-price/pn-find-service-and-price.js +229 -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 +51 -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 +86 -0
  86. package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist-store.js +13 -0
  87. package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist-translations.js +36 -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 +6 -0
  90. package/collection/components/widgets/pn-product-pricelist/pn-product-pricelist.js +157 -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 +21 -0
  96. package/collection/components/widgets/pn-product-tile/pn-product-tile-price.js +99 -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 +3042 -27
  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-0c7083bd.js +19 -0
  110. package/esm/pn-find-service-and-price.entry.js +242 -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} +14 -11
  117. package/esm/pn-product-pricelist-result.entry.js +30 -0
  118. package/esm/pn-product-pricelist-store-82211c4a.js +14 -0
  119. package/esm/pn-product-pricelist.entry.js +106 -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-0c7083bd.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-82211c4a.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-1905c548.entry.js +1 -0
  144. package/pn-market-web-components/p-1fe6de09.entry.js +1 -0
  145. package/pn-market-web-components/p-21e0e386.js +13 -0
  146. package/pn-market-web-components/p-23743bec.system.entry.js +1 -0
  147. package/pn-market-web-components/p-23d34c82.system.entry.js +1 -0
  148. package/pn-market-web-components/p-27502f43.system.entry.js +1 -0
  149. package/pn-market-web-components/p-2fa246f1.system.js +1 -0
  150. package/pn-market-web-components/p-3ae74105.system.entry.js +1 -0
  151. package/pn-market-web-components/p-44f74289.system.entry.js +1 -0
  152. package/pn-market-web-components/p-46018354.system.js +1 -0
  153. package/pn-market-web-components/p-4bf9a9ff.js +1 -0
  154. package/pn-market-web-components/p-4f283190.js +1 -0
  155. package/pn-market-web-components/p-5f1ad0b7.entry.js +1 -0
  156. package/pn-market-web-components/p-62700d6e.system.js +1 -0
  157. package/pn-market-web-components/p-64a6c2fb.js +1 -0
  158. package/pn-market-web-components/p-7331d3bb.system.js +1 -0
  159. package/pn-market-web-components/p-91624bd5.system.js +13 -0
  160. package/pn-market-web-components/p-986d3894.entry.js +1 -0
  161. package/pn-market-web-components/p-a5179982.system.entry.js +1 -0
  162. package/pn-market-web-components/p-be245b29.entry.js +1 -0
  163. package/pn-market-web-components/p-bfc523fc.js +1 -0
  164. package/pn-market-web-components/p-c06b37c7.entry.js +1 -0
  165. package/pn-market-web-components/p-c9af6ced.entry.js +1 -0
  166. package/pn-market-web-components/p-ce136600.js +1 -0
  167. package/pn-market-web-components/p-d0e7e65c.system.js +1 -0
  168. package/pn-market-web-components/p-dc5ff15f.entry.js +1 -0
  169. package/pn-market-web-components/p-e367b055.system.entry.js +1 -0
  170. package/pn-market-web-components/p-ea9afb95.system.entry.js +1 -0
  171. package/pn-market-web-components/p-ec95bda3.entry.js +1 -0
  172. package/pn-market-web-components/p-f37be6ee.system.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} +1 -0
  184. package/types/components/layout-components/{pn-siteheader/pn-siteheader.d.ts → pn-marketweb-siteheader/pn-marketweb-siteheader.d.ts} +3 -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 +29 -0
  204. package/types/components/widgets/pn-find-service-and-price/pn-find-service-and-price-translations.d.ts +61 -0
  205. package/types/components/widgets/pn-find-service-and-price/pn-find-service-and-price-types.d.ts +27 -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 +7 -0
  208. package/types/components/widgets/pn-product-pricelist/pn-product-pricelist-store.d.ts +19 -0
  209. package/types/components/widgets/pn-product-pricelist/pn-product-pricelist-translations.d.ts +36 -0
  210. package/types/components/widgets/pn-product-pricelist/pn-product-pricelist-types.d.ts +7 -0
  211. package/types/components/widgets/pn-product-pricelist/pn-product-pricelist.d.ts +16 -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-50b6c2c1.system.entry.js +0 -1
  226. package/pn-market-web-components/p-530b52d0.system.js +0 -1
  227. package/pn-market-web-components/p-9a654a14.system.entry.js +0 -1
  228. package/pn-market-web-components/p-a1045531.entry.js +0 -1
  229. package/pn-market-web-components/p-fc344aee.entry.js +0 -1
@@ -0,0 +1,229 @@
1
+ import { Component, h, Prop, State, Watch } from "@stencil/core";
2
+ import { translations, markets } from "./pn-find-service-and-price-translations";
3
+ import { postagetypes, weights, deliveryscopes } from "./data.js";
4
+ import { convertFileFromStream } from "../../../globals/shared/productprice/convert.js";
5
+ import { state } from "./pn-find-service-and-price-store";
6
+ export class PnfindServiceAndPrice {
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.filteredItems = [];
12
+ this.postagetype = { value: "", name: "", icon: "" };
13
+ this.weight = { value: 0, name: "" };
14
+ this.weightvalue = 0;
15
+ this.deliveryscope = { value: "", name: "", icon: "" };
16
+ this.sourceData = { types: [], data: [] };
17
+ }
18
+ componentWillLoad() {
19
+ this.setState();
20
+ this.getDataSource();
21
+ window.setTimeout(() => {
22
+ this.postagetype = postagetypes[1];
23
+ this.deliveryscope = deliveryscopes[this.postagetype.value][0];
24
+ this.weight = weights[this.postagetype.value][0];
25
+ this.weightvalue = this.weight.value;
26
+ }, 500);
27
+ // this.filterItems();
28
+ }
29
+ async getDataSource() {
30
+ const req = await fetch(this.source);
31
+ const reqbody = await req.blob();
32
+ try {
33
+ const convertedData = await convertFileFromStream(reqbody);
34
+ this.sourceData = convertedData;
35
+ }
36
+ catch (e) {
37
+ console.log('Unable to parse data');
38
+ }
39
+ }
40
+ setState() {
41
+ if (this.market) {
42
+ state.market = markets[this.market];
43
+ }
44
+ if (this.language && translations[this.language]) {
45
+ state.i18n = translations[this.language];
46
+ }
47
+ }
48
+ filterItems() {
49
+ var _a;
50
+ // this.debug = `Postagetype: ${this.postagetype.value}. <br/>Weight: ${ this.weight.value }`;
51
+ if (!((_a = this.sourceData) === null || _a === void 0 ? void 0 : _a.data)) {
52
+ console.log('Data has not yet been loaded');
53
+ return;
54
+ }
55
+ if (!this.postagetype) {
56
+ return;
57
+ }
58
+ const typeData = this.sourceData.data.filter((x) => x.what === this.postagetype.value);
59
+ if (!this.deliveryscope) {
60
+ return;
61
+ }
62
+ const deliveryScopeData = typeData.filter((x) => x.deliveryscope === this.deliveryscope.value);
63
+ if (!this.weight || !this.weight.value) {
64
+ return;
65
+ }
66
+ // For letters we use grams. Otherwise we use KG
67
+ const comparisonWeight = (this.weight.abbreviation.toLocaleLowerCase() === "kg" && this.postagetype.value === 'letter') ? this.weight.value * 1000 : this.weight.value;
68
+ let weightData = deliveryScopeData.filter(x => x.maxweight === comparisonWeight);
69
+ // In parcels the maxwidths don't necessarily start at 1kg so we fetch any type below the user selected value
70
+ if (weightData.length === 0) {
71
+ weightData = deliveryScopeData.filter(x => x.maxweight >= comparisonWeight);
72
+ if (weightData.length > 0) {
73
+ // We reverse the result array since the map will take the last unique item instead of the first
74
+ const uniqueWeightOptions = [...new Map(weightData.reverse().map(item => [item["id"], item])).values()];
75
+ if (uniqueWeightOptions.length > 0) {
76
+ weightData = uniqueWeightOptions;
77
+ }
78
+ }
79
+ }
80
+ this.filteredItems = weightData;
81
+ }
82
+ render() {
83
+ return (h("div", null,
84
+ h("div", { class: "form" },
85
+ (state.i18n.componentheading) ? (h("h2", null, state.i18n.componentheading)) : null,
86
+ h("div", { class: "postagetypes" }, postagetypes.map((postagetype) => (h("pn-choice-button", { choiceid: postagetype.value, value: postagetype.value, name: "postagetype", type: "radio", checked: postagetype.value === this.postagetype.value, onChange: () => {
87
+ this.postagetype = postagetypes.filter(x => x.value === postagetype.value)[0];
88
+ this.weight = weights[this.postagetype.value][0];
89
+ this.weightvalue = this.weight.value;
90
+ } },
91
+ h("pn-illustration", { illustration: postagetype.illustration }),
92
+ " ",
93
+ postagetype.name)))),
94
+ this.postagetype.value && deliveryscopes[this.postagetype.value] ? (h("div", null,
95
+ (state.i18n.deliveryscopeheading) ? (h("div", { class: "heading" }, state.i18n.deliveryscopeheading)) : null,
96
+ h("div", { class: "deliveryscope" }, deliveryscopes[this.postagetype.value].map((deliveryscope) => (h("pn-choice-button", { choiceid: this.postagetype.value + deliveryscope.value, value: deliveryscope.value, name: "deliveryscope", type: "radio", checked: deliveryscope.value === this.deliveryscope.value, onChange: () => {
97
+ this.deliveryscope = deliveryscopes[this.postagetype.value].filter(x => x.value === deliveryscope.value)[0];
98
+ } },
99
+ h("pn-illustration", { illustration: deliveryscope.illustration }),
100
+ " ",
101
+ deliveryscope.name)))))) : null,
102
+ (this.postagetype.value && weights[this.postagetype.value] && this.deliveryscope.value) ? (h("div", null,
103
+ (state.i18n.sizeheading) ? (h("div", { class: "heading" }, state.i18n.sizeheading)) : null,
104
+ h("div", { class: "weightoption" },
105
+ h("div", { class: "weightoption-input" },
106
+ h("pn-input", { inputid: "weightvalue", name: "weightvalue", type: "number", label: state.i18n.weightlabel, value: this.weightvalue, onChange: (e) => {
107
+ if (e && e.target && e.target.value) {
108
+ const weightNum = parseInt(e.target.value, 10);
109
+ if (!isNaN(weightNum)) {
110
+ let matchingWeights = weights[this.postagetype.value].filter((x) => {
111
+ let weightInGrams = (x.abbreviation === "kg") ? x.value * 1000 : x.value;
112
+ return weightInGrams >= weightNum;
113
+ });
114
+ if (matchingWeights && matchingWeights.length > 0) {
115
+ this.weight = matchingWeights[0];
116
+ this.weightvalue = this.weight.value;
117
+ }
118
+ }
119
+ }
120
+ } }),
121
+ h("span", { class: "weightoption-input-abbreviation" }, this.weight.abbreviation)),
122
+ h("div", { class: "weightoption-range" },
123
+ 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) => {
124
+ const value = e.target.value;
125
+ this.weight = weights[this.postagetype.value][value];
126
+ this.weightvalue = this.weight.value;
127
+ }, min: "0",
128
+ // max={ weights[this.postagetype.value][weights[this.postagetype.value].length - 1].value }
129
+ max: weights[this.postagetype.value].length - 1 }),
130
+ h("datalist", { id: "weightlist" }, weights[this.postagetype.value].map((weight, weightindex) => {
131
+ let labelText = weight.name;
132
+ if (weights[this.postagetype.value].length > 6) {
133
+ labelText = (weightindex % 5 === 0 || weightindex === 0 || weightindex === weights[this.postagetype.value].length - 1) ? weight.name : '';
134
+ }
135
+ return (h("option", Object.assign({ value: weightindex }, (labelText ? { label: labelText } : {}))));
136
+ })))))) : null),
137
+ (this.filteredItems) ? (h("div", { class: "resultlist" },
138
+ (state.i18n.resultlistheading) ? (h("div", { class: "heading" }, state.i18n.resultlistheading)) : null,
139
+ this.filteredItems.map((item) => (h("div", null,
140
+ h("pn-find-service-and-price-result", { item: item })))))) : null));
141
+ }
142
+ static get is() { return "pn-find-service-and-price"; }
143
+ static get originalStyleUrls() { return {
144
+ "$": ["pn-find-service-and-price.scss"]
145
+ }; }
146
+ static get styleUrls() { return {
147
+ "$": ["pn-find-service-and-price.css"]
148
+ }; }
149
+ static get properties() { return {
150
+ "source": {
151
+ "type": "string",
152
+ "mutable": false,
153
+ "complexType": {
154
+ "original": "string",
155
+ "resolved": "string",
156
+ "references": {}
157
+ },
158
+ "required": false,
159
+ "optional": false,
160
+ "docs": {
161
+ "tags": [],
162
+ "text": ""
163
+ },
164
+ "attribute": "source",
165
+ "reflect": false,
166
+ "defaultValue": "\"https://com-integration.postnord.com/globalassets/global/prices/sv-se-findprice.xlsx\""
167
+ },
168
+ "language": {
169
+ "type": "string",
170
+ "mutable": true,
171
+ "complexType": {
172
+ "original": "string",
173
+ "resolved": "string",
174
+ "references": {}
175
+ },
176
+ "required": false,
177
+ "optional": false,
178
+ "docs": {
179
+ "tags": [],
180
+ "text": ""
181
+ },
182
+ "attribute": "language",
183
+ "reflect": false,
184
+ "defaultValue": "\"sv\""
185
+ },
186
+ "market": {
187
+ "type": "string",
188
+ "mutable": true,
189
+ "complexType": {
190
+ "original": "string",
191
+ "resolved": "string",
192
+ "references": {}
193
+ },
194
+ "required": false,
195
+ "optional": false,
196
+ "docs": {
197
+ "tags": [],
198
+ "text": ""
199
+ },
200
+ "attribute": "market",
201
+ "reflect": false,
202
+ "defaultValue": "\"se\""
203
+ }
204
+ }; }
205
+ static get states() { return {
206
+ "filteredItems": {},
207
+ "postagetype": {},
208
+ "weight": {},
209
+ "weightvalue": {},
210
+ "deliveryscope": {},
211
+ "sourceData": {}
212
+ }; }
213
+ static get watchers() { return [{
214
+ "propName": "market",
215
+ "methodName": "setState"
216
+ }, {
217
+ "propName": "language",
218
+ "methodName": "setState"
219
+ }, {
220
+ "propName": "postagetype",
221
+ "methodName": "filterItems"
222
+ }, {
223
+ "propName": "deliveryscope",
224
+ "methodName": "filterItems"
225
+ }, {
226
+ "propName": "weightvalue",
227
+ "methodName": "filterItems"
228
+ }]; }
229
+ }
@@ -0,0 +1,2 @@
1
+ const convert = require("./libs/convertnode.js");
2
+ convert();
@@ -0,0 +1,51 @@
1
+ const postagetypes = [
2
+ { name: "Brev", value: "letter", icon: "envelope" },
3
+ { name: "Paket", value: "parcel", icon: "box-label" }
4
+ ]
5
+
6
+ const weights = {
7
+ "letter": [
8
+ { name: "50g", abbreviation: 'g', value: 50 },
9
+ { name: "100g", abbreviation: 'g', value: 100 },
10
+ { name: "250g", abbreviation: 'g', value: 250 },
11
+ { name: "500g", abbreviation: 'g', value: 500 },
12
+ { name: "1kg", abbreviation: 'kg', value: 1 },
13
+ { name: "2kg", abbreviation: 'kg', value: 2 },
14
+ ],
15
+ "parcel": [
16
+ { name: "1kg", abbreviation: 'kg', value: 1 },
17
+ { name: "2kg", abbreviation: 'kg', value: 2 },
18
+ { name: "3kg", abbreviation: 'kg', value: 3 },
19
+ { name: "4kg", abbreviation: 'kg', value: 4 },
20
+ { name: "5kg", abbreviation: 'kg', value: 5 },
21
+ { name: "6kg", abbreviation: 'kg', value: 6 },
22
+ { name: "7Kg", abbreviation: 'kg', value: 7 },
23
+ { name: "8kg", abbreviation: 'kg', value: 8 },
24
+ { name: "9kg", abbreviation: 'kg', value: 9 },
25
+ { name: "10kg", abbreviation: 'kg', value: 10 },
26
+ { name: "11kg", abbreviation: 'kg', value: 11 },
27
+ { name: "12kg", abbreviation: 'kg', value: 12 },
28
+ { name: "13kg", abbreviation: 'kg', value: 13 },
29
+ { name: "14kg", abbreviation: 'kg', value: 14 },
30
+ { name: "15kg", abbreviation: 'kg', value: 15 },
31
+ { name: "16kg", abbreviation: 'kg', value: 16 },
32
+ { name: "17kg", abbreviation: 'kg', value: 17 },
33
+ { name: "18kg", abbreviation: 'kg', value: 18 },
34
+ { name: "20kg", abbreviation: 'kg', value: 20 },
35
+ ]
36
+ };
37
+
38
+ const deliveryscopes = {
39
+ "letter": [
40
+ { name: "Sweden", value: "sweden", icon: "home" },
41
+ { name: "Abroad", value: "abroad", icon: "globe" },
42
+
43
+ ],
44
+ "parcel": [
45
+ { name: "Sweden", value: "sweden", icon: "home" },
46
+ { name: "Within Europe", value:"withineurope", icon: "compass" },
47
+ { name: "Outside Europe", value:"outsideeurope", icon: "globe" },
48
+ ]
49
+ };
50
+
51
+ export { postagetypes, weights, deliveryscopes};
@@ -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 };
@@ -0,0 +1,58 @@
1
+ const fs = require("fs-extra");
2
+ const path = require("path");
3
+ const readXlsxFile = require('read-excel-file/node');
4
+
5
+ async function getFiles(dirpath = "./data") {
6
+ const allFiles = await fs.readdir(dirpath);
7
+ const xslxFiles = allFiles.filter(x => (x.indexOf('.xlsx') !== -1 && x.indexOf('~') !== 0));
8
+ return xslxFiles.map((file) => path.join(dirpath, file));
9
+ }
10
+
11
+ async function convertFile(filepath) {
12
+ const toFilterValue = (x) => x.toLowerCase().replace(/\s+/g, '');
13
+ const outputFilename = filepath.substring(0, filepath.lastIndexOf('.') + 1) + 'json';
14
+ console.log(`Reading file "${filepath}" and converting to "${outputFilename}"`);
15
+ const sheets = await readXlsxFile(filepath, { getSheets: true })
16
+ let dataRows = [];
17
+ let sheetsData = await Promise.all(sheets.map(async (sheet) => { return await readXlsxFile(filepath, { sheet: sheet.name }) })); //await readXlsxFile(filepath, { sheet: sheet.name });
18
+ const filterColumnNames = ["what", "deliveryscope"];
19
+ let types = {};
20
+ sheetsData.forEach(sheetData => {
21
+ const firstRow = sheetData.shift().map(x => toFilterValue(x));
22
+ // Set up column for adding options
23
+ firstRow.forEach(async (col, i) => {
24
+ if (typeof types[col] === "undefined" && filterColumnNames.includes(col)) {
25
+ types[col] = [];
26
+ }
27
+ });
28
+ sheetData.forEach((row, rowindex) => {
29
+ const dataRow = {};
30
+ firstRow.forEach(async (col, i) => {
31
+ const rowVal = row[i];
32
+ dataRow[col] = rowVal;
33
+ // Add to types options
34
+ if (filterColumnNames.includes(col)) {
35
+ const filterVal = toFilterValue(rowVal);
36
+ dataRow[col] = filterVal;
37
+ if (!types[col].includes(filterVal)) {
38
+ types[col].push(filterVal);
39
+ }
40
+ }
41
+ });
42
+ dataRows.push(dataRow);
43
+ });
44
+ });
45
+ const dataFile = filepath;
46
+ const fileData = {
47
+ "file": filepath,
48
+ "types": types,
49
+ "data": dataRows
50
+ };
51
+ console.log(`Stored ${dataRows.length} rows from ${sheetsData.length} sheets. ${Object.keys(types).length} filter types identified`)
52
+ fs.writeJsonSync(outputFilename, fileData)
53
+ }
54
+
55
+ async function convert(dirpath = "./data") {
56
+ const files = await getFiles(dirpath);
57
+ files.forEach(convertFile);
58
+ }
@@ -0,0 +1,86 @@
1
+ import { Component, h, Prop, Host } from "@stencil/core";
2
+ import { state } from "./pn-product-pricelist-store";
3
+ export class PnFindProductPricelistResult {
4
+ constructor() {
5
+ this.item = null;
6
+ this.shownitems = [];
7
+ }
8
+ componentWillLoad() {
9
+ if (this.item.pricestamps) {
10
+ this.shownitems.push(Object.assign(Object.assign({}, this.item), { priceagent: null, pricesenddirect: null }));
11
+ }
12
+ if (this.item.priceagent) {
13
+ this.shownitems.push(Object.assign(Object.assign({}, this.item), { pricestamps: null, pricesenddirect: null }));
14
+ }
15
+ if (this.item.pricesenddirect) {
16
+ this.shownitems.push(Object.assign(Object.assign({}, this.item), { pricestamps: null, priceagent: null }));
17
+ }
18
+ }
19
+ render() {
20
+ return (h(Host, null, this.shownitems.map((item) => (h("pn-product-tile", null,
21
+ h("pn-illustration", { slot: "illustration", illustration: item.illustration }),
22
+ h("div", { slot: "content" },
23
+ h("div", { class: "content" },
24
+ h("h3", null, item.name),
25
+ (item.description) ? (h("div", { class: "description" }, item.description)) : null,
26
+ (item.info) ? (h("div", { class: "description" }, item.info)) : null)),
27
+ item.maxweight ? (h("pn-product-tile-info", { label: state.i18n.maxweightlabel, text: item.maxweight + '' })) : null,
28
+ item.maximummeasurements ? (h("pn-product-tile-info", { label: state.i18n.maxmeasurementlabel, text: item.maximummeasurements })) : null,
29
+ item.pricestamps ? (h("pn-product-tile-price", { slot: "price", label: "With stamps", amount: item.pricestamps + '', currency: state.market.currency })) : null,
30
+ item.priceagent ? (h("pn-product-tile-price", { slot: "price", label: "Service point", amount: item.priceagent + '', currency: state.market.currency, url: "https://shop.postnord.se/ebutik/default.aspx" })) : null,
31
+ item.pricesenddirect ? (h("pn-product-tile-price", { slot: "price", label: "Send direct", amount: item.pricesenddirect + '', currency: state.market.currency, url: "https://portal.postnord.com/skickadirekt/" })) : null,
32
+ item.info ? (h("small", { slot: "note" },
33
+ h("p", null, item.note))) : null)))));
34
+ }
35
+ static get is() { return "pn-product-pricelist-result"; }
36
+ static get originalStyleUrls() { return {
37
+ "$": ["pn-product-pricelist-result.scss"]
38
+ }; }
39
+ static get styleUrls() { return {
40
+ "$": ["pn-product-pricelist-result.css"]
41
+ }; }
42
+ static get properties() { return {
43
+ "item": {
44
+ "type": "unknown",
45
+ "mutable": false,
46
+ "complexType": {
47
+ "original": "ProductPriceItem",
48
+ "resolved": "ProductPriceItem",
49
+ "references": {
50
+ "ProductPriceItem": {
51
+ "location": "import",
52
+ "path": "../../../globals/shared/productprice/product-price-types"
53
+ }
54
+ }
55
+ },
56
+ "required": false,
57
+ "optional": false,
58
+ "docs": {
59
+ "tags": [],
60
+ "text": ""
61
+ },
62
+ "defaultValue": "null"
63
+ },
64
+ "shownitems": {
65
+ "type": "unknown",
66
+ "mutable": false,
67
+ "complexType": {
68
+ "original": "ProductPriceItem[]",
69
+ "resolved": "ProductPriceItem[]",
70
+ "references": {
71
+ "ProductPriceItem": {
72
+ "location": "import",
73
+ "path": "../../../globals/shared/productprice/product-price-types"
74
+ }
75
+ }
76
+ },
77
+ "required": false,
78
+ "optional": false,
79
+ "docs": {
80
+ "tags": [],
81
+ "text": ""
82
+ },
83
+ "defaultValue": "[]"
84
+ }
85
+ }; }
86
+ }
@@ -0,0 +1,13 @@
1
+ import { createStore } from "@stencil/store";
2
+ // Read more about how stencil stores work here: https://stenciljs.com/docs/stencil-store
3
+ const { state, onChange } = createStore({
4
+ i18n: {
5
+ maxweightlabel: '',
6
+ maxmeasurementlabel: ''
7
+ },
8
+ market: {
9
+ currency: ""
10
+ }
11
+ });
12
+ export { state, onChange };
13
+ export default state;
@@ -0,0 +1,36 @@
1
+ export const translations = {
2
+ 'sv': {
3
+ 'maxweightlabel': 'Maxvikt',
4
+ 'maxmeasurementlabel': 'Maxvolym',
5
+ },
6
+ 'en': {
7
+ 'maxweightlabel': 'Max weight',
8
+ 'maxmeasurementlabel': 'Maximum measurement',
9
+ },
10
+ 'da': {
11
+ 'maxweightlabel': 'Max vægt',
12
+ 'maxmeasurementlabel': 'Maks. Volumen',
13
+ },
14
+ 'no': {
15
+ 'maxweightlabel': 'Maks vekt',
16
+ 'maxmeasurementlabel': 'Maks volum',
17
+ },
18
+ 'fi': {
19
+ 'maxweightlabel': 'Max paino',
20
+ 'maxmeasurementlabel': 'Max äänenvoimakkuus',
21
+ }
22
+ };
23
+ export const markets = {
24
+ 'se': {
25
+ "currency": "kr",
26
+ },
27
+ 'dk': {
28
+ "currency": "dk",
29
+ },
30
+ 'fi': {
31
+ "currency": " €",
32
+ },
33
+ 'no': {
34
+ "currency": "kr",
35
+ }
36
+ };
@@ -0,0 +1,6 @@
1
+ pn-product-pricelist pn-spinner {
2
+ margin: 1em auto;
3
+ }
4
+ pn-product-pricelist .resultlist:not([data-list-count="0"]) {
5
+ margin-top: 1.5em;
6
+ }