@warp-ds/elements 2.2.0-next.8 → 2.2.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 (330) hide show
  1. package/README.md +188 -26
  2. package/dist/.storybook/utilities.js +52 -0
  3. package/dist/api.js +1 -1
  4. package/dist/api.js.map +4 -4
  5. package/dist/custom-elements.json +1517 -2876
  6. package/dist/index.d.ts +942 -25
  7. package/dist/packages/affix/affix.react.stories.d.ts +9 -0
  8. package/dist/packages/affix/affix.react.stories.js +10 -0
  9. package/dist/packages/affix/affix.stories.js +25 -0
  10. package/dist/packages/affix/affix.test.js +9 -0
  11. package/dist/packages/affix/index.d.ts +0 -17
  12. package/dist/packages/affix/index.js +5 -5
  13. package/dist/packages/affix/index.js.map +4 -4
  14. package/dist/packages/affix/react.d.ts +1 -1
  15. package/dist/packages/affix/react.js +15 -2482
  16. package/dist/packages/affix/styles.js +2 -0
  17. package/dist/packages/alert/alert.react.stories.d.ts +13 -0
  18. package/dist/packages/alert/alert.react.stories.js +44 -0
  19. package/dist/packages/alert/alert.stories.js +68 -0
  20. package/dist/packages/alert/alert.test.js +18 -0
  21. package/dist/packages/alert/index.d.ts +1 -6
  22. package/dist/packages/alert/index.js +4 -4
  23. package/dist/packages/alert/index.js.map +4 -4
  24. package/dist/packages/alert/react.d.ts +1 -1
  25. package/dist/packages/alert/react.js +11 -2492
  26. package/dist/packages/alert/styles.js +2 -0
  27. package/dist/packages/attention/attention.react.stories.d.ts +15 -0
  28. package/dist/packages/attention/attention.react.stories.js +92 -0
  29. package/dist/packages/attention/attention.stories.d.ts +6 -0
  30. package/dist/packages/attention/attention.stories.js +180 -0
  31. package/dist/packages/attention/attention.test.js +11 -0
  32. package/dist/packages/attention/index.d.ts +24 -91
  33. package/dist/packages/attention/index.js +3585 -17
  34. package/dist/packages/attention/index.js.map +4 -4
  35. package/dist/packages/attention/layout-styles.js +905 -0
  36. package/dist/packages/attention/locales/da/messages.mjs +1 -0
  37. package/dist/packages/attention/locales/en/messages.mjs +1 -0
  38. package/dist/packages/attention/locales/fi/messages.mjs +1 -0
  39. package/dist/packages/attention/locales/nb/messages.mjs +1 -0
  40. package/dist/packages/attention/locales/sv/messages.mjs +1 -0
  41. package/dist/packages/attention/react.d.ts +15 -0
  42. package/dist/packages/attention/react.js +17 -0
  43. package/dist/packages/attention/styles.js +2 -0
  44. package/dist/packages/badge/badge.react.stories.d.ts +18 -0
  45. package/dist/packages/badge/badge.react.stories.js +60 -0
  46. package/dist/packages/badge/badge.stories.js +68 -0
  47. package/dist/packages/badge/badge.test.js +9 -0
  48. package/dist/packages/badge/index.d.ts +0 -5
  49. package/dist/packages/badge/index.js +1 -1
  50. package/dist/packages/badge/index.js.map +4 -4
  51. package/dist/packages/badge/react.d.ts +1 -1
  52. package/dist/packages/badge/react.js +11 -2465
  53. package/dist/packages/badge/styles.js +2 -0
  54. package/dist/packages/box/box.react.stories.d.ts +15 -0
  55. package/dist/packages/box/box.react.stories.js +45 -0
  56. package/dist/packages/box/box.stories.js +59 -0
  57. package/dist/packages/box/box.test.js +9 -0
  58. package/dist/packages/box/index.d.ts +0 -5
  59. package/dist/packages/box/index.js +11 -4
  60. package/dist/packages/box/index.js.map +4 -4
  61. package/dist/packages/box/react.d.ts +1 -1
  62. package/dist/packages/box/react.js +11 -2465
  63. package/dist/packages/box/slot.test.js +9 -0
  64. package/dist/packages/box/styles.js +2 -0
  65. package/dist/packages/breadcrumbs/breadcrumbs.react.stories.d.ts +13 -0
  66. package/dist/packages/breadcrumbs/breadcrumbs.react.stories.js +40 -0
  67. package/dist/packages/breadcrumbs/breadcrumbs.stories.js +60 -0
  68. package/dist/packages/breadcrumbs/breadcrumbs.test.js +16 -0
  69. package/dist/packages/breadcrumbs/index.d.ts +0 -12
  70. package/dist/packages/breadcrumbs/index.js +6 -6
  71. package/dist/packages/breadcrumbs/index.js.map +4 -4
  72. package/dist/packages/breadcrumbs/locales/da/messages.mjs +1 -0
  73. package/dist/packages/breadcrumbs/locales/en/messages.mjs +1 -0
  74. package/dist/packages/breadcrumbs/locales/fi/messages.mjs +1 -0
  75. package/dist/packages/breadcrumbs/locales/nb/messages.mjs +1 -0
  76. package/dist/packages/breadcrumbs/locales/sv/messages.mjs +1 -0
  77. package/dist/packages/breadcrumbs/react.d.ts +1 -1
  78. package/dist/packages/breadcrumbs/react.js +11 -2475
  79. package/dist/packages/breadcrumbs/styles.js +2 -0
  80. package/dist/packages/button/button.react.stories.d.ts +22 -0
  81. package/dist/packages/button/button.react.stories.js +102 -0
  82. package/dist/packages/button/button.stories.d.ts +4 -0
  83. package/dist/packages/button/button.stories.js +151 -0
  84. package/dist/packages/button/button.test.js +25 -0
  85. package/dist/packages/button/index.d.ts +0 -66
  86. package/dist/packages/button/index.js +17 -11
  87. package/dist/packages/button/index.js.map +4 -4
  88. package/dist/packages/button/locales/da/messages.mjs +1 -0
  89. package/dist/packages/button/locales/en/messages.mjs +1 -0
  90. package/dist/packages/button/locales/fi/messages.mjs +1 -0
  91. package/dist/packages/button/locales/nb/messages.mjs +1 -0
  92. package/dist/packages/button/locales/sv/messages.mjs +1 -0
  93. package/dist/packages/button/react.d.ts +1 -1
  94. package/dist/packages/button/react.js +10 -2684
  95. package/dist/packages/button/styles.js +2 -0
  96. package/dist/packages/card/card.react.stories.d.ts +16 -0
  97. package/dist/packages/card/card.react.stories.js +63 -0
  98. package/dist/packages/card/card.stories.js +82 -0
  99. package/dist/packages/card/card.test.js +9 -0
  100. package/dist/packages/card/index.d.ts +1 -18
  101. package/dist/packages/card/index.js +4 -4
  102. package/dist/packages/card/index.js.map +4 -4
  103. package/dist/packages/card/locales/da/messages.mjs +1 -0
  104. package/dist/packages/card/locales/en/messages.mjs +1 -0
  105. package/dist/packages/card/locales/fi/messages.mjs +1 -0
  106. package/dist/packages/card/locales/nb/messages.mjs +1 -0
  107. package/dist/packages/card/locales/sv/messages.mjs +1 -0
  108. package/dist/packages/card/react.d.ts +1 -1
  109. package/dist/packages/card/react.js +11 -2487
  110. package/dist/packages/card/styles.js +2 -0
  111. package/dist/packages/expandable/expandable.react.stories.d.ts +18 -0
  112. package/dist/packages/expandable/expandable.react.stories.js +103 -0
  113. package/dist/packages/expandable/expandable.stories.js +132 -0
  114. package/dist/packages/expandable/expandable.test.js +24 -0
  115. package/dist/packages/expandable/index.d.ts +2 -33
  116. package/dist/packages/expandable/index.js +20 -11
  117. package/dist/packages/expandable/index.js.map +4 -4
  118. package/dist/packages/expandable/react.d.ts +1 -1
  119. package/dist/packages/expandable/react.js +11 -2495
  120. package/dist/packages/expandable/styles.js +2 -0
  121. package/dist/packages/i18n.js +45 -0
  122. package/dist/packages/link/index.d.ts +0 -5
  123. package/dist/packages/link/index.js +93 -2640
  124. package/dist/packages/link/styles.js +200 -0
  125. package/dist/packages/modal/index.js +24 -41
  126. package/dist/packages/modal/index.js.map +4 -4
  127. package/dist/packages/modal/locales/da/messages.mjs +1 -0
  128. package/dist/packages/modal/locales/en/messages.mjs +1 -0
  129. package/dist/packages/modal/locales/fi/messages.mjs +1 -0
  130. package/dist/packages/modal/locales/nb/messages.mjs +1 -0
  131. package/dist/packages/modal/locales/sv/messages.mjs +1 -0
  132. package/dist/packages/modal/modal-footer.d.ts +0 -5
  133. package/dist/packages/{dead-toggle/index.js → modal/modal-footer.js} +20 -47
  134. package/dist/packages/modal/modal-footer.js.map +7 -0
  135. package/dist/packages/modal/modal-header.d.ts +0 -5
  136. package/dist/packages/{steps/index.js → modal/modal-header.js} +122 -20
  137. package/dist/packages/modal/modal-header.js.map +7 -0
  138. package/dist/packages/modal/modal-main.d.ts +0 -5
  139. package/dist/packages/{dead-toggle/react.js → modal/modal-main.js} +124 -59
  140. package/dist/packages/{box/react.js.map → modal/modal-main.js.map} +4 -4
  141. package/dist/packages/modal/modal.react.stories.d.ts +14 -0
  142. package/dist/packages/modal/modal.react.stories.js +27 -0
  143. package/dist/packages/modal/modal.stories.d.ts +3 -3
  144. package/dist/packages/modal/modal.stories.js +254 -0
  145. package/dist/packages/modal/react.d.ts +11 -3
  146. package/dist/packages/modal/react.js +31 -2754
  147. package/dist/packages/modal/util.js +21 -0
  148. package/dist/packages/pill/index.d.ts +0 -17
  149. package/dist/packages/pill/index.js +5 -5
  150. package/dist/packages/pill/index.js.map +2 -2
  151. package/dist/packages/pill/locales/da/messages.mjs +1 -0
  152. package/dist/packages/pill/locales/en/messages.mjs +1 -0
  153. package/dist/packages/pill/locales/fi/messages.mjs +1 -0
  154. package/dist/packages/pill/locales/nb/messages.mjs +1 -0
  155. package/dist/packages/pill/locales/sv/messages.mjs +1 -0
  156. package/dist/packages/pill/pill.react.stories.d.ts +23 -0
  157. package/dist/packages/pill/pill.react.stories.js +22 -0
  158. package/dist/packages/pill/pill.stories.js +33 -0
  159. package/dist/packages/pill/pill.test.js +25 -0
  160. package/dist/packages/pill/react.d.ts +7 -0
  161. package/dist/packages/pill/react.js +17 -0
  162. package/dist/packages/pill/styles.js +2 -0
  163. package/dist/packages/select/index.d.ts +4 -29
  164. package/dist/packages/select/index.js +25 -18
  165. package/dist/packages/select/index.js.map +3 -3
  166. package/dist/packages/select/locales/da/messages.mjs +1 -0
  167. package/dist/packages/select/locales/en/messages.mjs +1 -0
  168. package/dist/packages/select/locales/fi/messages.mjs +1 -0
  169. package/dist/packages/select/locales/nb/messages.mjs +1 -0
  170. package/dist/packages/select/locales/sv/messages.mjs +1 -0
  171. package/dist/packages/select/react.d.ts +6 -2
  172. package/dist/packages/select/react.js +20 -2494
  173. package/dist/packages/select/select.react.stories.d.ts +18 -0
  174. package/dist/packages/select/select.react.stories.js +28 -0
  175. package/dist/packages/select/select.stories.d.ts +7 -0
  176. package/dist/packages/select/select.stories.js +100 -0
  177. package/dist/packages/select/select.test.js +31 -0
  178. package/dist/packages/select/styles.js +2 -0
  179. package/dist/packages/{switch/index.js → styles.js} +5 -18
  180. package/dist/packages/textfield/index.d.ts +12 -26
  181. package/dist/packages/textfield/index.js +86 -28
  182. package/dist/packages/textfield/index.js.map +4 -4
  183. package/dist/packages/textfield/react.d.ts +11 -2
  184. package/dist/packages/textfield/react.js +21 -2490
  185. package/dist/packages/textfield/styles/w-textfield.styles.d.ts +1 -0
  186. package/dist/packages/textfield/styles/w-textfield.styles.js +55 -0
  187. package/dist/packages/textfield/styles.js +2 -0
  188. package/dist/packages/textfield/textfield.react.stories.d.ts +37 -0
  189. package/dist/packages/textfield/textfield.react.stories.js +88 -0
  190. package/dist/packages/textfield/textfield.stories.d.ts +1 -0
  191. package/dist/packages/textfield/textfield.stories.js +105 -0
  192. package/dist/packages/textfield/textfield.test.d.ts +1 -0
  193. package/dist/packages/textfield/textfield.test.js +68 -0
  194. package/dist/packages/toast/api.d.ts +4 -45
  195. package/dist/packages/toast/api.js +41 -0
  196. package/dist/packages/toast/index.d.ts +3 -3
  197. package/dist/packages/toast/index.js +2463 -24
  198. package/dist/packages/toast/index.js.map +4 -4
  199. package/dist/packages/toast/locales/da/messages.mjs +1 -0
  200. package/dist/packages/toast/locales/en/messages.mjs +1 -0
  201. package/dist/packages/toast/locales/fi/messages.mjs +1 -0
  202. package/dist/packages/toast/locales/nb/messages.mjs +1 -0
  203. package/dist/packages/toast/locales/sv/messages.mjs +1 -0
  204. package/dist/packages/toast/styles.js +2 -0
  205. package/dist/packages/toast/toast-container.d.ts +12 -78
  206. package/dist/packages/{switch/react.js → toast/toast-container.js} +21 -38
  207. package/dist/packages/toast/toast-container.js.map +7 -0
  208. package/dist/packages/toast/toast.d.ts +16 -29
  209. package/dist/packages/{pagination/index.js → toast/toast.js} +21 -49
  210. package/dist/packages/toast/toast.js.map +7 -0
  211. package/dist/packages/toast/toast.stories.js +50 -0
  212. package/dist/packages/toast/types.d.ts +15 -0
  213. package/dist/packages/toast/types.js +1 -0
  214. package/dist/packages/utils/expand-transition.d.ts +3 -3
  215. package/dist/packages/utils/expand-transition.js +59 -0
  216. package/dist/packages/utils/index.js +37 -0
  217. package/dist/packages/utils/unstyled-heading.d.ts +2 -3
  218. package/dist/packages/utils/unstyled-heading.js +22 -0
  219. package/dist/packages/utils/window-exists.js +1 -0
  220. package/dist/setup-tests.js +1 -0
  221. package/dist/web-types.json +225 -510
  222. package/package.json +39 -32
  223. package/dist/index.css +0 -2
  224. package/dist/index.css.map +0 -7
  225. package/dist/index.js +0 -3386
  226. package/dist/index.js.map +0 -7
  227. package/dist/packages/affix/react.js.map +0 -7
  228. package/dist/packages/alert/react.js.map +0 -7
  229. package/dist/packages/badge/react.js.map +0 -7
  230. package/dist/packages/breadcrumbs/react.js.map +0 -7
  231. package/dist/packages/button/react.js.map +0 -7
  232. package/dist/packages/card/react.js.map +0 -7
  233. package/dist/packages/datepicker/DatePicker.test.d.ts +0 -1
  234. package/dist/packages/datepicker/datepicker.d.ts +0 -107
  235. package/dist/packages/datepicker/datepicker.stories.d.ts +0 -11
  236. package/dist/packages/datepicker/datepicker.test.d.ts +0 -2
  237. package/dist/packages/datepicker/index.d.ts +0 -1
  238. package/dist/packages/datepicker/index.js +0 -2785
  239. package/dist/packages/datepicker/index.js.map +0 -7
  240. package/dist/packages/datepicker/locales/da/messages.d.mts +0 -1
  241. package/dist/packages/datepicker/locales/en/messages.d.mts +0 -1
  242. package/dist/packages/datepicker/locales/fi/messages.d.mts +0 -1
  243. package/dist/packages/datepicker/locales/nb/messages.d.mts +0 -1
  244. package/dist/packages/datepicker/locales/sv/messages.d.mts +0 -1
  245. package/dist/packages/datepicker/react.d.ts +0 -2
  246. package/dist/packages/datepicker/react.js +0 -2805
  247. package/dist/packages/datepicker/react.js.map +0 -7
  248. package/dist/packages/datepicker/styles/w-datepicker-calendar.styles.d.ts +0 -1
  249. package/dist/packages/datepicker/styles/w-datepicker-day.styles.d.ts +0 -1
  250. package/dist/packages/datepicker/styles/w-datepicker-month.styles.d.ts +0 -1
  251. package/dist/packages/datepicker/styles/w-datepicker.styles.d.ts +0 -1
  252. package/dist/packages/datepicker/utils.d.ts +0 -13
  253. package/dist/packages/dead-toggle/dead-toggle.stories.d.ts +0 -10
  254. package/dist/packages/dead-toggle/index.d.ts +0 -21
  255. package/dist/packages/dead-toggle/index.js.map +0 -7
  256. package/dist/packages/dead-toggle/react.d.ts +0 -2
  257. package/dist/packages/dead-toggle/react.js.map +0 -7
  258. package/dist/packages/expandable/react.js.map +0 -7
  259. package/dist/packages/link/index.js.map +0 -7
  260. package/dist/packages/link/link.stories.d.ts +0 -20
  261. package/dist/packages/link/link.test.d.ts +0 -1
  262. package/dist/packages/link/react.d.ts +0 -2
  263. package/dist/packages/link/react.js +0 -2666
  264. package/dist/packages/link/react.js.map +0 -7
  265. package/dist/packages/modal/react.js.map +0 -7
  266. package/dist/packages/pageindicator/index.d.ts +0 -14
  267. package/dist/packages/pageindicator/index.js +0 -32
  268. package/dist/packages/pageindicator/index.js.map +0 -7
  269. package/dist/packages/pageindicator/pageindicator.stories.d.ts +0 -32
  270. package/dist/packages/pageindicator/react.d.ts +0 -2
  271. package/dist/packages/pageindicator/react.js +0 -52
  272. package/dist/packages/pageindicator/react.js.map +0 -7
  273. package/dist/packages/pagination/index.d.ts +0 -37
  274. package/dist/packages/pagination/index.js.map +0 -7
  275. package/dist/packages/pagination/locales/da/messages.d.mts +0 -1
  276. package/dist/packages/pagination/locales/en/messages.d.mts +0 -1
  277. package/dist/packages/pagination/locales/fi/messages.d.mts +0 -1
  278. package/dist/packages/pagination/locales/nb/messages.d.mts +0 -1
  279. package/dist/packages/pagination/locales/sv/messages.d.mts +0 -1
  280. package/dist/packages/pagination/pagination.stories.d.ts +0 -14
  281. package/dist/packages/pagination/pagination.test.d.ts +0 -1
  282. package/dist/packages/pagination/react.d.ts +0 -2
  283. package/dist/packages/pagination/react.js +0 -2514
  284. package/dist/packages/pagination/react.js.map +0 -7
  285. package/dist/packages/rip-and-tear-checkbox/checkbox.d.ts +0 -64
  286. package/dist/packages/rip-and-tear-checkbox/index.css +0 -2
  287. package/dist/packages/rip-and-tear-checkbox/index.css.map +0 -7
  288. package/dist/packages/rip-and-tear-checkbox/index.d.ts +0 -6
  289. package/dist/packages/rip-and-tear-checkbox/index.js +0 -36
  290. package/dist/packages/rip-and-tear-checkbox/index.js.map +0 -7
  291. package/dist/packages/rip-and-tear-radio/base-element.d.ts +0 -46
  292. package/dist/packages/rip-and-tear-radio/custom-error-validator.d.ts +0 -6
  293. package/dist/packages/rip-and-tear-radio/form-associated-element.d.ts +0 -103
  294. package/dist/packages/rip-and-tear-radio/index.css +0 -2
  295. package/dist/packages/rip-and-tear-radio/index.css.map +0 -7
  296. package/dist/packages/rip-and-tear-radio/index.d.ts +0 -8
  297. package/dist/packages/rip-and-tear-radio/index.js +0 -34
  298. package/dist/packages/rip-and-tear-radio/index.js.map +0 -7
  299. package/dist/packages/rip-and-tear-radio/invalid.d.ts +0 -8
  300. package/dist/packages/rip-and-tear-radio/math.d.ts +0 -1
  301. package/dist/packages/rip-and-tear-radio/radio-group.d.ts +0 -72
  302. package/dist/packages/rip-and-tear-radio/radio.d.ts +0 -38
  303. package/dist/packages/rip-and-tear-radio/required-validator.d.ts +0 -11
  304. package/dist/packages/rip-and-tear-radio/slot.d.ts +0 -20
  305. package/dist/packages/rip-and-tear-radio/watch.d.ts +0 -26
  306. package/dist/packages/select/react.js.map +0 -7
  307. package/dist/packages/steps/index.d.ts +0 -43
  308. package/dist/packages/steps/index.js.map +0 -7
  309. package/dist/packages/steps/locales/da/messages.d.mts +0 -1
  310. package/dist/packages/steps/locales/en/messages.d.mts +0 -1
  311. package/dist/packages/steps/locales/fi/messages.d.mts +0 -1
  312. package/dist/packages/steps/locales/nb/messages.d.mts +0 -1
  313. package/dist/packages/steps/locales/sv/messages.d.mts +0 -1
  314. package/dist/packages/steps/react.d.ts +0 -3
  315. package/dist/packages/steps/react.js +0 -2485
  316. package/dist/packages/steps/react.js.map +0 -7
  317. package/dist/packages/steps/steps.stories.d.ts +0 -12
  318. package/dist/packages/switch/index.d.ts +0 -20
  319. package/dist/packages/switch/index.js.map +0 -7
  320. package/dist/packages/switch/react.d.ts +0 -2
  321. package/dist/packages/switch/react.js.map +0 -7
  322. package/dist/packages/switch/styles.d.ts +0 -1
  323. package/dist/packages/switch/switch.stories.d.ts +0 -9
  324. package/dist/packages/textfield/react.js.map +0 -7
  325. package/dist/vscode.css-custom-data.json +0 -6
  326. package/dist/vscode.html-custom-data.json +0 -418
  327. /package/dist/packages/{dead-toggle/dead-toggle.test.d.ts → attention/attention.test.d.ts} +0 -0
  328. /package/dist/packages/{pageindicator/style.d.ts → attention/layout-styles.d.ts} +0 -0
  329. /package/dist/packages/{pagination → attention}/styles.d.ts +0 -0
  330. /package/dist/packages/{steps → toast}/styles.d.ts +0 -0
package/README.md CHANGED
@@ -14,35 +14,103 @@ start by reviewing the [contributing guidelines](CONTRIBUTING.md).
14
14
 
15
15
  ### Installation
16
16
 
17
- Install by using npm/pnpm or by adding a script link:
17
+ Warp custom elements are supplied by the Eik CDN.
18
+ In addition, you can install the `@warp-ds/elements` package to get intellisense
19
+ in your editor.
18
20
 
19
- #### Install using npm
21
+ #### Step 1.
20
22
 
21
- ```sh
22
- npm install @warp-ds/elements
23
+ Add the following script and style to the very top of your document head to ensure performant loading
24
+
25
+ ```html
26
+ <link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/elements/2.2.0-next.13/styles.css" crossorigin />
27
+ <script src="https://assets.finn.no/pkg/@warp-ds/elements/2.2.0-next.13/index.js" type="module"></script>
23
28
  ```
24
29
 
25
- #### Install using pnpm
30
+ #### Step 2.
26
31
 
27
- ```sh
28
- pnpm add @warp-ds/elements
32
+ Be sure to preload whichever brand fonts you need for a page and load the correct font file:
33
+
34
+ ```html
35
+ <!-- Finn example -->
36
+ <link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/FINNTypeAlleTegn-Light.woff2" as="font" type="font/woff2" crossorigin>
37
+ <link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/FINNTypeAlleTegn-Medium.woff2" as="font" type="font/woff2" crossorigin>
38
+ <link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/finn-no.css" crossorigin>
29
39
  ```
30
40
 
31
- #### Using a direct link to Eik
41
+ ```html
42
+ <!-- Tori example -->
43
+ <link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/ToriSans-Regular.woff2" as="font" type="font/woff2" crossorigin>
44
+ <link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/ToriSans-Bold.woff2" as="font" type="font/woff2" crossorigin>
45
+ <link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/ToriSans-Italic.woff2" as="font" type="font/woff2" crossorigin>
46
+ <link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/tori-fi.css" crossorigin>
47
+ ```
32
48
 
33
49
  ```html
34
- <script src="https://assets.finn.no/pkg/@warp-ds/elements/v1"></script>
50
+ <!-- DBA example -->
51
+ <link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/ProximaNova-Regular.woff2" as="font" type="font/woff2" crossorigin>
52
+ <link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/ProximaNova-Bold.woff2" as="font" type="font/woff2" crossorigin>
53
+ <link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/dba-dk.css" crossorigin>
35
54
  ```
36
- ### Import components
37
- This project builds both the whole Elements package and separate component packages that are published to EIK, making it possible for the user to choose to either import all of the components:
38
- ```js
39
- import '@warp-ds/elements';
55
+
56
+ ```html
57
+ <!-- Blocket example -->
58
+ <link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/BlocketSans-Regular.woff2" as="font" type="font/woff2" crossorigin>
59
+ <link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/BlocketSans-Bold.woff2" as="font" type="font/woff2" crossorigin>
60
+ <link rel="preload" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/BlocketSans-Medium.woff2" as="font" type="font/woff2" crossorigin>
61
+ <link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/fonts/v1/blocket-se.css" crossorigin>
40
62
  ```
41
- or a specific component:
42
- ```js
43
- import '@warp-ds/elements/components/toast';
63
+
64
+ #### Step 3.
65
+
66
+ You'll also want to load Warp tokens and resets CSS files to ensure consistent and correct styling for the brand.
67
+
68
+ ```html
69
+ <!-- Finn example -->
70
+ <link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/css/v2/tokens/finn-no.css" crossorigin>
71
+ <link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/css/v2/resets.css" crossorigin>
72
+ ```
73
+
74
+ ```html
75
+ <!-- Tori example -->
76
+ <link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/css/v2/tokens/tori-fi.css" crossorigin>
77
+ <link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/css/v2/resets.css" crossorigin>
78
+ ```
79
+
80
+ ```html
81
+ <!-- DBA example -->
82
+ <link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/css/v2/tokens/dba-dk.css" crossorigin>
83
+ <link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/css/v2/resets.css" crossorigin>
84
+ ```
85
+
86
+ ```html
87
+ <!-- Blocket example -->
88
+ <link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/css/v2/tokens/blocket-se.css" crossorigin>
89
+ <link rel="stylesheet" href="https://assets.finn.no/pkg/@warp-ds/css/v2/resets.css" crossorigin>
44
90
  ```
45
91
 
92
+ #### Step 4.
93
+
94
+ Next, to add intellisense to your editor install `@warp-ds/elements` by using npm/pnpm. See the Editor integration below.
95
+
96
+ ##### Install using npm
97
+
98
+ ```sh
99
+ npm install @warp-ds/elements
100
+ ```
101
+
102
+ ##### Install using pnpm
103
+
104
+ ```sh
105
+ pnpm add @warp-ds/elements
106
+ ```
107
+
108
+ And then head on down to the editor configuration section below to complete setup.
109
+
110
+ ### Using Warp elements with Borealis
111
+
112
+ If you are using Borealis modules from the Web Platform Team (and you should be) and keeping your app dependencies up to date (and you should be), then steps 2 and 3 are already taken care of for you, you just need to do steps 1 and 4.
113
+
46
114
  ### Documentation
47
115
 
48
116
  For information on the components available in the package and how to use them,
@@ -50,33 +118,127 @@ see the [Warp Design System documentation](https://warp-ds.github.io/tech-docs/)
50
118
 
51
119
  ### Editor integration
52
120
 
53
- #### Visual Studio Code
121
+ #### Typescript
54
122
 
55
- This module includes [Custom HTML and CSS data for Visual Studio Code](https://code.visualstudio.com/blogs/2020/02/24/custom-data-format).
123
+ Install the `@warp-ds/elements` package
56
124
 
57
- Add this to your `settings.json` and restart VS Code to get IntelliSense and inline documentation for Warp elements.
125
+ ```
126
+ npm install @warp-ds/elements
127
+ ```
128
+
129
+ Add `@warp-ds/elements` to tsconfig types in compilerOptions.
58
130
 
59
131
  ```json
60
132
  {
61
- "html.customData": [
62
- "./node_modules/@warp-ds/elements/dist/vscode.html-custom-data.json"
63
- ],
64
- "css.customData": [
65
- "./node_modules/@warp-ds/elements/dist/vscode.css-custom-data.json"
66
- ]
133
+ "compilerOptions": {
134
+ "types": ["react", "react-dom", "@warp-ds/elements"]
135
+ }
67
136
  }
68
137
  ```
69
138
 
139
+ #### Visual Studio Code
140
+
141
+ Install the [Web Components Language Server](https://wc-toolkit.com/integrations/web-components-language-server/) extension. The extension automatically picks up the [Custom Element Manifest](https://wc-toolkit.com/getting-started/) that we ship with `@warp-ds/elements`.
142
+
143
+ ##### Using Warp Elements in a plain HTML page
144
+
145
+ Install Warp Elements locally using npm:
146
+
147
+ ```
148
+ npm install @warp-ds/elements
149
+ ```
150
+
151
+ Install the [Web Components Language Server](https://wc-toolkit.com/integrations/web-components-language-server/) extension.
152
+
153
+ Now, inside any `.html` files, you will get IntelliSense when using Warp Elements:
154
+
155
+ ```html
156
+ <w-button variant=""><w-button>
157
+ ```
158
+
159
+ ##### Using Warp Elements in JavaScript template literals
160
+
161
+ IntelliSense in JavaScript strings is not supported without additional plugins and syntax, such as comment hints (`/* html */`) or a tagged template literal similar to Lit.
162
+
163
+ ##### Using Warp Elements in Lit html tagged template literals
164
+
165
+ Install Warp Elements locally using npm:
166
+
167
+ ```
168
+ npm install @warp-ds/elements
169
+ ```
170
+
171
+ Install the [Web Components Language Server](https://wc-toolkit.com/integrations/web-components-language-server/) extension.
172
+
173
+ Install the [lit-plugin](https://marketplace.visualstudio.com/items?itemName=runem.lit-plugin) extension.
174
+
175
+ Now, inside any html`` tagged template literals, you will get intellisense when using Warp Elements.
176
+
177
+ ```html
178
+ <w-button variant=""><w-button>
179
+ ```
180
+
181
+ ##### Using Warp Elements in a React app, v19 or later
182
+
183
+ ```
184
+ npm install @warp-ds/elements
185
+ ```
186
+
187
+ Now, inside your react components, you will get intellisense when using Warp Elements.
188
+
189
+ ```html
190
+ <w-button variant=""><w-button>
191
+ ```
192
+
193
+ ##### Using Warp Elements in a React app, v18 or earlier
194
+
195
+ React 18 and earlier do not support custom elements.
196
+
197
+ If you are on React 18 or early, we strongly urge you to please consider upgrading to React v19.
198
+
199
+ If you cannot upgrade right away, Warp supplies custom element wrappers to add backwards compatibility. Use them like so:
200
+
201
+ ```
202
+ npm install @warp-ds/elements
203
+ ```
204
+
205
+ Wherever you need to use a component in your app, import the appropriate element from the React namespace
206
+
207
+ ```js
208
+ import { Button } from "@warp-ds/elements/react/button";
209
+ ```
210
+
211
+ and use the component
212
+
213
+ ```js
214
+ <Button variant="primary"></Button>
215
+ ```
216
+
217
+ you should get intellisense when using Warp Elements.
218
+
70
219
  #### JetBrains products
71
220
 
72
221
  We ship `web-types.json` which should get picked up automatically by JetBrains IDEA and similar products.
73
222
 
74
223
  You should see code completions and inline docs for Warp elements when writing HTML.
75
224
 
225
+ ### Ensure elements are ready (and avoid CLS and FOUCE)
226
+
227
+ To avoid issues like CLS (cumulative layout shift) and FOUCE (flash of unstyled custom elements), its important that Warp Elements is loaded before the page is rendered. For this reason, elements should not be bundled into the rest of your client side application and code and should be loaded in the document head, as early as possible (see installation above). When this is done correctly, elements will be loaded and ready about the same time as the rest of the page styles and wont cause delays in page load times. However, due to the way browsers work, a page render will occur without the components and an immediate re-render will occur with the components. This causes things to jump around on the page which in turn impacts lighthouse and other performance scores. Warp elements ships with a tool to prevent the initial render without components and only do the second, with components, render. This tool is called Warp Cloak and its usage is described below.
228
+
229
+ #### The Warp cloaking device
230
+
231
+ To use the Warp cloaking device to avoid CLS and FOUCE, simply add the warp-cloak class to your pages body, html or a wrapper div that contains all the pages visible elements (including the header and footer)
232
+
233
+ ```html
234
+ <body class="warp-cloak">
235
+ ```
236
+
237
+ That's it, your components should render just 1x, fully ready with no CLS and FOUCE.
76
238
 
77
239
  ## Releases
78
240
 
79
- This project is continuously published to [NPM](https://www.npmjs.com/package/@warp-ds/elements) and [Eik](https://assets.finn.no/pkg/@warp-ds/elements) using a `next` tag (e.g. `1.1.0-next.1`).
241
+ This project is continuously published to [NPM](https://www.npmjs.com/package/@warp-ds/elements) and [Eik](https://assets.finn.no/pkg/@warp-ds/elements) using a `next` tag (e.g. `2.2.0-next.13`).
80
242
  Anyone needing to use the latest changes of this package can point to the `next` version while waiting for the stable release.
81
243
 
82
244
  ## Changelog
@@ -0,0 +1,52 @@
1
+ /**
2
+ * Massages storybook args before being spread to HTML attributes.
3
+ *
4
+ * - Empty strings are treated as not set.
5
+ * - Boolean false don't get set.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * import { html } from 'lit';
10
+ * import { spread } from '@open-wc/lit-helpers';
11
+ * import { prespread } from '../../.storybook/utilities.js';
12
+ *
13
+ * type Args = {
14
+ * required: boolean;
15
+ * };
16
+ *
17
+ * const meta: Meta<Args> = {
18
+ * component: 'w-component',
19
+ * render(args) {
20
+ * return html`<w-component ${spread(prespread(args))}></w-component>`;
21
+ * },
22
+ * argTypes: {
23
+ * required: { type: 'boolean' },
24
+ * },
25
+ * };
26
+ * ```
27
+ */
28
+ export function prespread(args) {
29
+ const newArgs = {
30
+ ...args,
31
+ };
32
+ for (const field of Object.keys(newArgs)) {
33
+ const value = args[field];
34
+ // Add Lit syntax for boolean attributes
35
+ if (typeof value === 'boolean') {
36
+ newArgs[`?${field}`] = value;
37
+ delete newArgs[field];
38
+ }
39
+ // Add Lit syntax for complex properties
40
+ if (typeof value === 'object') {
41
+ newArgs[`.${field}`] = value;
42
+ delete newArgs[field];
43
+ }
44
+ // The manifest has a bunch of default empty strings (which we should probably investigate)
45
+ // that turn on features that should be off in Storybook canvases.
46
+ // Remove the empty strings.
47
+ if (newArgs[field] === '') {
48
+ delete newArgs[field];
49
+ }
50
+ }
51
+ return newArgs;
52
+ }
package/dist/api.js CHANGED
@@ -1,2 +1,2 @@
1
- var e=typeof window!="undefined";function a(t,n){if(!e)return;let o=customElements.get("w-toast-container").init(),s={id:Date.now().toString(36)+Math.random().toString(36).slice(2,5),text:t,duration:5e3,type:"success",...n};return o.set(s),s}function c(t){return e?customElements.get("w-toast-container").init().del(t):void 0}function u(t,n){if(!e)return;let o=customElements.get("w-toast-container").init();return o.set({...o.get(t),...n}),o.get(t)}export{c as removeToast,a as toast,u as updateToast};
1
+ var e=typeof window!="undefined";function r(){return customElements.get("w-toast-container")}function p(t,o){if(!e)return;let n=r().init(),s={id:Date.now().toString(36)+Math.random().toString(36).slice(2,5),text:t,duration:5e3,type:"success",...o};return n.set(s),s}function u(t){return e?r().init().del(t):void 0}function c(t,o){if(!e)return;let n=r().init();return n.set({...n.get(t),...o}),n.get(t)}export{u as removeToast,p as toast,c as updateToast};
2
2
  //# sourceMappingURL=api.js.map
package/dist/api.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../packages/utils/window-exists.js", "../packages/toast/api.js"],
4
- "sourcesContent": ["export const windowExists = typeof window !== 'undefined';\n", "import { windowExists } from '../utils/window-exists';\n\n/**\n * Toast helper function options\n * @typedef {Object} ToastOptions\n * @property {(number|string)} [id] Custom identifier\n * @property {('success'|'error'|'warning')} [type] Type of toast\n * @property {String} [text] The toast message. Only needed when updating text on existing toast\n * @property {(number|string)} [duration] Duration of toast in milliseconds. Defaults to 5000. For accessibility reasons, toasts should never be interactive and therefore need to auto remove. If you must disable auto remove, set duration to Number.POSITIVE_INFINITY.\n * @property {Boolean} [canclose] Whether the toast can be dismissed. Defaults to false. WARNING! For accessibility reasons, toasts should not be interactive and canclose should always be false. If the toast absolutely must be dismissable, set this to true.\n */\n\n/**\n * Creates a new toast\n * @param {String} message Message\n * @param {ToastOptions?} options Toast options\n * @returns {ToastOptions} Toast details\n */\nexport function toast(message, options) {\n if (!windowExists) return;\n const toast = customElements.get('w-toast-container').init();\n\n const data = {\n id: Date.now().toString(36) + Math.random().toString(36).slice(2, 5),\n text: message,\n duration: 5000,\n type: 'success',\n ...options,\n };\n\n toast.set(data);\n return data;\n}\n\n/**\n * Remove an existing toast\n * @param {String|Number} id Toast identifier\n * @return {Promise<Boolean>} Resolves to true if deleted, false if not found\n */\nexport function removeToast(id) {\n if (!windowExists) return;\n const toast = customElements.get('w-toast-container').init();\n return toast.del(id);\n}\n\n/**\n * Update an existing toast\n * @param {String|Number} id Toast identifier\n * @param {ToastOptions?} options Toast options\n * @returns {WarpToastContainer} Toast details\n */\nexport function updateToast(id, options) {\n if (!windowExists) return;\n const toast = customElements.get('w-toast-container').init();\n toast.set({ ...toast.get(id), ...options });\n return toast.get(id);\n}\n"],
5
- "mappings": "AAAO,IAAMA,EAAe,OAAO,QAAW,YCkBvC,SAASC,EAAMC,EAASC,EAAS,CACtC,GAAI,CAACC,EAAc,OACnB,IAAMH,EAAQ,eAAe,IAAI,mBAAmB,EAAE,KAAK,EAErDI,EAAO,CACX,GAAI,KAAK,IAAI,EAAE,SAAS,EAAE,EAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAG,CAAC,EACnE,KAAMH,EACN,SAAU,IACV,KAAM,UACN,GAAGC,CACL,EAEA,OAAAF,EAAM,IAAII,CAAI,EACPA,CACT,CAOO,SAASC,EAAYC,EAAI,CAC9B,OAAKH,EACS,eAAe,IAAI,mBAAmB,EAAE,KAAK,EAC9C,IAAIG,CAAE,EAFA,MAGrB,CAQO,SAASC,EAAYD,EAAIJ,EAAS,CACvC,GAAI,CAACC,EAAc,OACnB,IAAMH,EAAQ,eAAe,IAAI,mBAAmB,EAAE,KAAK,EAC3D,OAAAA,EAAM,IAAI,CAAE,GAAGA,EAAM,IAAIM,CAAE,EAAG,GAAGJ,CAAQ,CAAC,EACnCF,EAAM,IAAIM,CAAE,CACrB",
6
- "names": ["windowExists", "toast", "message", "options", "windowExists", "data", "removeToast", "id", "updateToast"]
3
+ "sources": ["../packages/utils/window-exists.js", "../packages/toast/api.ts"],
4
+ "sourcesContent": ["export const windowExists = typeof window !== 'undefined';\n", "import { windowExists } from '../utils/window-exists';\n\nimport { WarpToastContainer } from './toast-container';\nimport type { ToastInternal, ToastOptions } from './types';\n\nfunction getToastContainer() {\n const container = customElements.get('w-toast-container');\n return container as typeof WarpToastContainer;\n}\n\n/**\n * Creates a new toast\n */\nexport function toast(message: string, options?: ToastOptions) {\n if (!windowExists) return;\n\n const toast = getToastContainer().init() as WarpToastContainer;\n\n const data: ToastOptions = {\n id: Date.now().toString(36) + Math.random().toString(36).slice(2, 5),\n text: message,\n duration: 5000,\n type: 'success',\n ...options,\n };\n\n toast.set(data);\n return data;\n}\n\n/**\n * Remove an existing toast\n */\nexport function removeToast(id: string | number): Promise<boolean> | undefined {\n if (!windowExists) return;\n\n const toast = getToastContainer().init() as WarpToastContainer;\n return toast.del(id);\n}\n\n/**\n * Update an existing toast\n */\nexport function updateToast(id: string | number, options?: ToastOptions): ToastInternal | undefined {\n if (!windowExists) return;\n\n const toast = getToastContainer().init() as WarpToastContainer;\n toast.set({ ...toast.get(id), ...options });\n return toast.get(id);\n}\n"],
5
+ "mappings": "AAAO,IAAMA,EAAe,OAAO,QAAW,YCK9C,SAASC,GAAoB,CAE3B,OADkB,eAAe,IAAI,mBAAmB,CAE1D,CAKO,SAASC,EAAMC,EAAiBC,EAAwB,CAC7D,GAAI,CAACC,EAAc,OAEnB,IAAMH,EAAQD,EAAkB,EAAE,KAAK,EAEjCK,EAAqB,CACzB,GAAI,KAAK,IAAI,EAAE,SAAS,EAAE,EAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,EAAG,CAAC,EACnE,KAAMH,EACN,SAAU,IACV,KAAM,UACN,GAAGC,CACL,EAEA,OAAAF,EAAM,IAAII,CAAI,EACPA,CACT,CAKO,SAASC,EAAYC,EAAmD,CAC7E,OAAKH,EAESJ,EAAkB,EAAE,KAAK,EAC1B,IAAIO,CAAE,EAHA,MAIrB,CAKO,SAASC,EAAYD,EAAqBJ,EAAmD,CAClG,GAAI,CAACC,EAAc,OAEnB,IAAMH,EAAQD,EAAkB,EAAE,KAAK,EACvC,OAAAC,EAAM,IAAI,CAAE,GAAGA,EAAM,IAAIM,CAAE,EAAG,GAAGJ,CAAQ,CAAC,EACnCF,EAAM,IAAIM,CAAE,CACrB",
6
+ "names": ["windowExists", "getToastContainer", "toast", "message", "options", "windowExists", "data", "removeToast", "id", "updateToast"]
7
7
  }