@warp-ds/elements 2.2.0-next.3 → 2.2.0-next.31

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 (265) hide show
  1. package/README.md +200 -28
  2. package/dist/.storybook/utilities.d.ts +28 -0
  3. package/dist/.storybook/utilities.js +52 -0
  4. package/dist/api.js +1 -49
  5. package/dist/api.js.map +4 -4
  6. package/dist/custom-elements.json +3059 -0
  7. package/dist/index.d.ts +942 -18
  8. package/dist/packages/affix/affix.react.stories.d.ts +9 -0
  9. package/dist/packages/affix/affix.react.stories.js +10 -0
  10. package/dist/packages/affix/affix.stories.d.ts +10 -0
  11. package/dist/packages/affix/affix.stories.js +25 -0
  12. package/dist/packages/affix/affix.test.d.ts +1 -0
  13. package/dist/packages/affix/affix.test.js +9 -0
  14. package/dist/packages/affix/index.d.ts +47 -24
  15. package/dist/packages/affix/index.js +2448 -2240
  16. package/dist/packages/affix/index.js.map +4 -4
  17. package/dist/packages/affix/react.d.ts +2 -0
  18. package/dist/packages/affix/react.js +15 -0
  19. package/dist/packages/affix/styles.d.ts +1 -0
  20. package/dist/packages/affix/styles.js +2 -0
  21. package/dist/packages/alert/alert.react.stories.d.ts +13 -0
  22. package/dist/packages/alert/alert.react.stories.js +44 -0
  23. package/dist/packages/alert/alert.stories.d.ts +15 -0
  24. package/dist/packages/alert/alert.stories.js +68 -0
  25. package/dist/packages/alert/alert.test.d.ts +1 -0
  26. package/dist/packages/alert/alert.test.js +18 -0
  27. package/dist/packages/alert/index.d.ts +23 -17
  28. package/dist/packages/alert/index.js +2452 -2446
  29. package/dist/packages/alert/index.js.map +4 -4
  30. package/dist/packages/alert/react.d.ts +2 -0
  31. package/dist/packages/alert/react.js +11 -0
  32. package/dist/packages/alert/styles.d.ts +1 -0
  33. package/dist/packages/alert/styles.js +2 -0
  34. package/dist/packages/attention/attention.react.stories.d.ts +15 -0
  35. package/dist/packages/attention/attention.react.stories.js +92 -0
  36. package/dist/packages/attention/attention.stories.d.ts +16 -0
  37. package/dist/packages/attention/attention.stories.js +180 -0
  38. package/dist/packages/attention/attention.test.d.ts +1 -0
  39. package/dist/packages/attention/attention.test.js +11 -0
  40. package/dist/packages/attention/index.d.ts +61 -89
  41. package/dist/packages/attention/index.js +3530 -3924
  42. package/dist/packages/attention/index.js.map +4 -4
  43. package/dist/packages/attention/layout-styles.d.ts +1 -0
  44. package/dist/packages/attention/layout-styles.js +905 -0
  45. package/dist/packages/attention/locales/da/messages.mjs +1 -0
  46. package/dist/packages/attention/locales/en/messages.mjs +1 -0
  47. package/dist/packages/attention/locales/fi/messages.mjs +1 -0
  48. package/dist/packages/attention/locales/nb/messages.mjs +1 -0
  49. package/dist/packages/attention/locales/sv/messages.mjs +1 -0
  50. package/dist/packages/attention/react.d.ts +15 -0
  51. package/dist/packages/attention/react.js +17 -0
  52. package/dist/packages/attention/styles.d.ts +1 -0
  53. package/dist/packages/attention/styles.js +2 -0
  54. package/dist/packages/badge/badge.react.stories.d.ts +18 -0
  55. package/dist/packages/badge/badge.react.stories.js +60 -0
  56. package/dist/packages/badge/badge.stories.d.ts +17 -0
  57. package/dist/packages/badge/badge.stories.js +68 -0
  58. package/dist/packages/badge/badge.test.d.ts +1 -0
  59. package/dist/packages/badge/badge.test.js +9 -0
  60. package/dist/packages/badge/index.d.ts +12 -12
  61. package/dist/packages/badge/index.js +2441 -300
  62. package/dist/packages/badge/index.js.map +4 -4
  63. package/dist/packages/badge/react.d.ts +2 -0
  64. package/dist/packages/badge/react.js +11 -0
  65. package/dist/packages/badge/styles.d.ts +1 -0
  66. package/dist/packages/badge/styles.js +2 -0
  67. package/dist/packages/box/box.react.stories.d.ts +15 -0
  68. package/dist/packages/box/box.react.stories.js +45 -0
  69. package/dist/packages/box/box.stories.d.ts +14 -0
  70. package/dist/packages/box/box.stories.js +59 -0
  71. package/dist/packages/box/box.test.d.ts +1 -0
  72. package/dist/packages/box/box.test.js +9 -0
  73. package/dist/packages/box/index.d.ts +16 -21
  74. package/dist/packages/box/index.js +2443 -299
  75. package/dist/packages/box/index.js.map +4 -4
  76. package/dist/packages/box/react.d.ts +2 -0
  77. package/dist/packages/box/react.js +11 -0
  78. package/dist/packages/box/slot.test.d.ts +1 -0
  79. package/dist/packages/box/slot.test.js +9 -0
  80. package/dist/packages/box/styles.d.ts +1 -0
  81. package/dist/packages/box/styles.js +2 -0
  82. package/dist/packages/breadcrumbs/breadcrumbs.react.stories.d.ts +13 -0
  83. package/dist/packages/breadcrumbs/breadcrumbs.react.stories.js +40 -0
  84. package/dist/packages/breadcrumbs/breadcrumbs.stories.d.ts +12 -0
  85. package/dist/packages/breadcrumbs/breadcrumbs.stories.js +60 -0
  86. package/dist/packages/breadcrumbs/breadcrumbs.test.d.ts +1 -0
  87. package/dist/packages/breadcrumbs/breadcrumbs.test.js +16 -0
  88. package/dist/packages/breadcrumbs/index.d.ts +19 -16
  89. package/dist/packages/breadcrumbs/index.js +2402 -2051
  90. package/dist/packages/breadcrumbs/index.js.map +4 -4
  91. package/dist/packages/breadcrumbs/locales/da/messages.mjs +1 -0
  92. package/dist/packages/breadcrumbs/locales/en/messages.mjs +1 -0
  93. package/dist/packages/breadcrumbs/locales/fi/messages.mjs +1 -0
  94. package/dist/packages/breadcrumbs/locales/nb/messages.mjs +1 -0
  95. package/dist/packages/breadcrumbs/locales/sv/messages.mjs +1 -0
  96. package/dist/packages/breadcrumbs/react.d.ts +2 -0
  97. package/dist/packages/breadcrumbs/react.js +11 -0
  98. package/dist/packages/breadcrumbs/styles.d.ts +1 -0
  99. package/dist/packages/breadcrumbs/styles.js +2 -0
  100. package/dist/packages/button/button.react.stories.d.ts +22 -0
  101. package/dist/packages/button/button.react.stories.js +102 -0
  102. package/dist/packages/button/button.stories.d.ts +25 -0
  103. package/dist/packages/button/button.stories.js +151 -0
  104. package/dist/packages/button/button.test.d.ts +1 -1
  105. package/dist/packages/button/button.test.js +25 -0
  106. package/dist/packages/button/index.d.ts +83 -9
  107. package/dist/packages/button/index.js +2614 -2422
  108. package/dist/packages/button/index.js.map +4 -4
  109. package/dist/packages/button/locales/da/messages.mjs +1 -0
  110. package/dist/packages/button/locales/en/messages.mjs +1 -0
  111. package/dist/packages/button/locales/fi/messages.mjs +1 -0
  112. package/dist/packages/button/locales/nb/messages.mjs +1 -0
  113. package/dist/packages/button/locales/sv/messages.mjs +1 -0
  114. package/dist/packages/button/react.d.ts +2 -0
  115. package/dist/packages/button/react.js +11 -0
  116. package/dist/packages/button/styles.d.ts +1 -0
  117. package/dist/packages/button/styles.js +2 -0
  118. package/dist/packages/card/card.react.stories.d.ts +16 -0
  119. package/dist/packages/card/card.react.stories.js +63 -0
  120. package/dist/packages/card/card.stories.d.ts +15 -0
  121. package/dist/packages/card/card.stories.js +82 -0
  122. package/dist/packages/card/card.test.d.ts +1 -0
  123. package/dist/packages/card/card.test.js +9 -0
  124. package/dist/packages/card/index.d.ts +27 -16
  125. package/dist/packages/card/index.js +2403 -2067
  126. package/dist/packages/card/index.js.map +4 -4
  127. package/dist/packages/card/locales/da/messages.mjs +1 -0
  128. package/dist/packages/card/locales/en/messages.mjs +1 -0
  129. package/dist/packages/card/locales/fi/messages.mjs +1 -0
  130. package/dist/packages/card/locales/nb/messages.mjs +1 -0
  131. package/dist/packages/card/locales/sv/messages.mjs +1 -0
  132. package/dist/packages/card/react.d.ts +2 -0
  133. package/dist/packages/card/react.js +11 -0
  134. package/dist/packages/card/styles.d.ts +1 -0
  135. package/dist/packages/card/styles.js +2 -0
  136. package/dist/packages/expandable/expandable.react.stories.d.ts +18 -0
  137. package/dist/packages/expandable/expandable.react.stories.js +103 -0
  138. package/dist/packages/expandable/expandable.stories.d.ts +19 -0
  139. package/dist/packages/expandable/expandable.stories.js +132 -0
  140. package/dist/packages/expandable/expandable.test.d.ts +1 -0
  141. package/dist/packages/expandable/expandable.test.js +24 -0
  142. package/dist/packages/expandable/index.d.ts +52 -50
  143. package/dist/packages/expandable/index.js +2424 -2286
  144. package/dist/packages/expandable/index.js.map +4 -4
  145. package/dist/packages/expandable/react.d.ts +2 -0
  146. package/dist/packages/expandable/react.js +11 -0
  147. package/dist/packages/expandable/styles.d.ts +1 -0
  148. package/dist/packages/expandable/styles.js +2 -0
  149. package/dist/packages/i18n.js +45 -0
  150. package/dist/packages/link/index.d.ts +34 -0
  151. package/dist/packages/link/index.js +99 -0
  152. package/dist/packages/link/styles.d.ts +1 -0
  153. package/dist/packages/link/styles.js +200 -0
  154. package/dist/packages/modal/index.d.ts +5 -6
  155. package/dist/packages/modal/index.js +5 -2611
  156. package/dist/packages/modal/locales/da/messages.mjs +1 -0
  157. package/dist/packages/modal/locales/en/messages.mjs +1 -0
  158. package/dist/packages/modal/locales/fi/messages.mjs +1 -0
  159. package/dist/packages/modal/locales/nb/messages.mjs +1 -0
  160. package/dist/packages/modal/locales/sv/messages.mjs +1 -0
  161. package/dist/packages/modal/modal-footer.d.ts +12 -10
  162. package/dist/packages/modal/modal-footer.js +2460 -0
  163. package/dist/packages/modal/modal-footer.js.map +7 -0
  164. package/dist/packages/modal/modal-header.d.ts +15 -13
  165. package/dist/packages/modal/modal-header.js +2567 -0
  166. package/dist/packages/modal/modal-header.js.map +7 -0
  167. package/dist/packages/modal/modal-main.d.ts +14 -8
  168. package/dist/packages/modal/modal-main.js +2572 -0
  169. package/dist/packages/modal/modal-main.js.map +7 -0
  170. package/dist/packages/modal/modal.react.stories.d.ts +14 -0
  171. package/dist/packages/modal/modal.react.stories.js +27 -0
  172. package/dist/packages/modal/modal.stories.d.ts +19 -0
  173. package/dist/packages/modal/modal.stories.js +254 -0
  174. package/dist/packages/modal/react.d.ts +12 -0
  175. package/dist/packages/modal/react.js +31 -0
  176. package/dist/packages/modal/util.d.ts +7 -17
  177. package/dist/packages/modal/util.js +21 -0
  178. package/dist/packages/pill/index.d.ts +39 -23
  179. package/dist/packages/pill/index.js +2408 -2175
  180. package/dist/packages/pill/index.js.map +4 -4
  181. package/dist/packages/pill/locales/da/messages.mjs +1 -0
  182. package/dist/packages/pill/locales/en/messages.mjs +1 -0
  183. package/dist/packages/pill/locales/fi/messages.mjs +1 -0
  184. package/dist/packages/pill/locales/nb/messages.mjs +1 -0
  185. package/dist/packages/pill/locales/sv/messages.mjs +1 -0
  186. package/dist/packages/pill/pill.react.stories.d.ts +23 -0
  187. package/dist/packages/pill/pill.react.stories.js +22 -0
  188. package/dist/packages/pill/pill.stories.d.ts +12 -0
  189. package/dist/packages/pill/pill.stories.js +33 -0
  190. package/dist/packages/pill/pill.test.d.ts +1 -0
  191. package/dist/packages/pill/pill.test.js +25 -0
  192. package/dist/packages/pill/react.d.ts +7 -0
  193. package/dist/packages/pill/react.js +17 -0
  194. package/dist/packages/pill/styles.d.ts +1 -0
  195. package/dist/packages/pill/styles.js +2 -0
  196. package/dist/packages/select/index.d.ts +56 -60
  197. package/dist/packages/select/index.js +2428 -2533
  198. package/dist/packages/select/index.js.map +4 -4
  199. package/dist/packages/select/locales/da/messages.mjs +1 -0
  200. package/dist/packages/select/locales/en/messages.mjs +1 -0
  201. package/dist/packages/select/locales/fi/messages.mjs +1 -0
  202. package/dist/packages/select/locales/nb/messages.mjs +1 -0
  203. package/dist/packages/select/locales/sv/messages.mjs +1 -0
  204. package/dist/packages/select/react.d.ts +6 -0
  205. package/dist/packages/select/react.js +20 -0
  206. package/dist/packages/select/select.react.stories.d.ts +18 -0
  207. package/dist/packages/select/select.react.stories.js +28 -0
  208. package/dist/packages/select/select.stories.d.ts +17 -0
  209. package/dist/packages/select/select.stories.js +100 -0
  210. package/dist/packages/select/select.test.d.ts +1 -0
  211. package/dist/packages/select/select.test.js +31 -0
  212. package/dist/packages/select/styles.d.ts +1 -0
  213. package/dist/packages/select/styles.js +2 -0
  214. package/dist/packages/styles.js +2442 -0
  215. package/dist/packages/textfield/index.d.ts +78 -74
  216. package/dist/packages/textfield/index.js +2522 -707
  217. package/dist/packages/textfield/index.js.map +4 -4
  218. package/dist/packages/textfield/react.d.ts +11 -0
  219. package/dist/packages/textfield/react.js +21 -0
  220. package/dist/packages/textfield/styles/w-textfield.styles.d.ts +1 -0
  221. package/dist/packages/textfield/styles/w-textfield.styles.js +55 -0
  222. package/dist/packages/textfield/styles.d.ts +1 -0
  223. package/dist/packages/textfield/styles.js +2 -0
  224. package/dist/packages/textfield/textfield.react.stories.d.ts +37 -0
  225. package/dist/packages/textfield/textfield.react.stories.js +88 -0
  226. package/dist/packages/textfield/textfield.stories.d.ts +18 -0
  227. package/dist/packages/textfield/textfield.stories.js +105 -0
  228. package/dist/packages/textfield/textfield.test.d.ts +2 -0
  229. package/dist/packages/textfield/textfield.test.js +68 -0
  230. package/dist/packages/toast/api.d.ts +4 -45
  231. package/dist/packages/toast/api.js +41 -0
  232. package/dist/packages/toast/index.d.ts +3 -3
  233. package/dist/packages/toast/index.js +3 -2804
  234. package/dist/packages/toast/locales/da/messages.mjs +1 -0
  235. package/dist/packages/toast/locales/en/messages.mjs +1 -0
  236. package/dist/packages/toast/locales/fi/messages.mjs +1 -0
  237. package/dist/packages/toast/locales/nb/messages.mjs +1 -0
  238. package/dist/packages/toast/locales/sv/messages.mjs +1 -0
  239. package/dist/packages/toast/styles.d.ts +1 -0
  240. package/dist/packages/toast/styles.js +2 -0
  241. package/dist/packages/toast/toast-container.d.ts +13 -63
  242. package/dist/packages/toast/toast-container.js +2458 -0
  243. package/dist/packages/toast/toast-container.js.map +7 -0
  244. package/dist/packages/toast/toast.d.ts +36 -29
  245. package/dist/packages/toast/toast.js +2466 -0
  246. package/dist/packages/toast/toast.js.map +7 -0
  247. package/dist/packages/toast/toast.stories.d.ts +12 -0
  248. package/dist/packages/toast/toast.stories.js +50 -0
  249. package/dist/packages/toast/types.d.ts +15 -0
  250. package/dist/packages/toast/types.js +1 -0
  251. package/dist/packages/utils/expand-transition.d.ts +3 -3
  252. package/dist/packages/utils/expand-transition.js +59 -0
  253. package/dist/packages/utils/index.d.ts +1 -1
  254. package/dist/packages/utils/index.js +37 -0
  255. package/dist/packages/utils/unstyled-heading.d.ts +3 -4
  256. package/dist/packages/utils/unstyled-heading.js +22 -0
  257. package/dist/packages/utils/window-exists.js +1 -0
  258. package/dist/setup-tests.d.ts +1 -0
  259. package/dist/setup-tests.js +1 -0
  260. package/dist/web-types.json +661 -0
  261. package/package.json +89 -36
  262. package/dist/index.js +0 -9820
  263. package/dist/index.js.map +0 -7
  264. package/dist/packages/modal/index.js.map +0 -7
  265. package/dist/packages/toast/index.js.map +0 -7
package/README.md CHANGED
@@ -14,64 +14,236 @@ 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.
22
+
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>
28
+ ```
29
+
30
+ #### Step 2.
31
+
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>
39
+ ```
40
+
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
+ ```
48
+
49
+ ```html
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>
54
+ ```
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>
62
+ ```
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>
90
+ ```
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
20
97
 
21
98
  ```sh
22
99
  npm install @warp-ds/elements
23
100
  ```
24
101
 
25
- #### Install using pnpm
102
+ ##### Install using pnpm
26
103
 
27
104
  ```sh
28
105
  pnpm add @warp-ds/elements
29
106
  ```
30
107
 
31
- #### Using a direct link to Eik
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
+
114
+ ### Documentation
115
+
116
+ For information on the components available in the package and how to use them,
117
+ see the [Warp Design System documentation](https://warp-ds.github.io/tech-docs/).
118
+
119
+ ### Editor integration
120
+
121
+ #### Typescript
122
+
123
+ Install the `@warp-ds/elements` package
124
+
125
+ ```
126
+ npm install @warp-ds/elements
127
+ ```
128
+
129
+ Add `@warp-ds/elements` to tsconfig types in compilerOptions.
130
+
131
+ ```json
132
+ {
133
+ "compilerOptions": {
134
+ "types": ["react", "react-dom", "@warp-ds/elements"]
135
+ }
136
+ }
137
+ ```
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.
32
188
 
33
189
  ```html
34
- <script src="https://assets.finn.no/pkg/@warp-ds/elements/v1"></script>
190
+ <w-button variant=""><w-button>
35
191
  ```
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:
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
+
38
207
  ```js
39
- import '@warp-ds/elements';
208
+ import { Button } from "@warp-ds/elements/react/button";
40
209
  ```
41
- or a specific component:
210
+
211
+ and use the component
212
+
42
213
  ```js
43
- import '@warp-ds/elements/components/toast';
214
+ <Button variant="primary"></Button>
44
215
  ```
45
216
 
46
- ### Documentation
217
+ you should get intellisense when using Warp Elements.
47
218
 
48
- For information on the components available in the package and how to use them,
49
- see the [Warp Design System documentation](https://warp-ds.github.io/tech-docs/).
219
+ #### JetBrains products
50
220
 
51
- ## Releases
221
+ We ship `web-types.json` which should get picked up automatically by JetBrains IDEA and similar products.
52
222
 
53
- 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`).
54
- Anyone needing to use the latest changes of this package can point to the `next` version while waiting for the stable release.
223
+ You should see code completions and inline docs for Warp elements when writing HTML.
55
224
 
56
- ## Changelog
225
+ ### Ensure elements are ready (and avoid CLS and FOUCE)
57
226
 
58
- Detailed changes for each release can be found in the [CHANGELOG](CHANGELOG.md) file.
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.
59
228
 
60
- ## How to test component-classes locally
229
+ #### The Warp cloaking device
61
230
 
62
- It is possible to test changes that have been made to component-classes from the [@warp-ds/css](https://github.com/warp-ds/css) package but that has not yet been published to Eik. You simply need to link the `@warp-ds/css` package in this repository and add `@unocss-placeholder` inside the static styles of the component that you want to test:
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)
63
232
 
64
- ```js
65
- static styles = [
66
- css`
67
- @unocss-placeholder
68
- `,
69
- ]
233
+ ```html
234
+ <body class="warp-cloak">
70
235
  ```
71
236
 
72
- Run `pnpm dev` to see the linked styles in action.
237
+ That's it, your components should render just 1x, fully ready with no CLS and FOUCE.
73
238
 
74
- Once you have tested it locally, make sure to remove the `@unocss-placeholder` from the static styles before pushing any changes to the repository.
239
+ ## Releases
240
+
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`).
242
+ Anyone needing to use the latest changes of this package can point to the `next` version while waiting for the stable release.
243
+
244
+ ## Changelog
245
+
246
+ Detailed changes for each release can be found in the [CHANGELOG](CHANGELOG.md) file.
75
247
 
76
248
  ## License
77
249
 
@@ -0,0 +1,28 @@
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 declare function prespread(args: Record<string, unknown>): Record<string, unknown>;
@@ -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,50 +1,2 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
3
- var __hasOwnProp = Object.prototype.hasOwnProperty;
4
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
5
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
6
- var __spreadValues = (a, b) => {
7
- for (var prop in b || (b = {}))
8
- if (__hasOwnProp.call(b, prop))
9
- __defNormalProp(a, prop, b[prop]);
10
- if (__getOwnPropSymbols)
11
- for (var prop of __getOwnPropSymbols(b)) {
12
- if (__propIsEnum.call(b, prop))
13
- __defNormalProp(a, prop, b[prop]);
14
- }
15
- return a;
16
- };
17
-
18
- // packages/utils/window-exists.js
19
- var windowExists = typeof window !== "undefined";
20
-
21
- // packages/toast/api.js
22
- function toast(message, options) {
23
- if (!windowExists) return;
24
- const toast2 = customElements.get("w-toast-container").init();
25
- const data = __spreadValues({
26
- id: Date.now().toString(36) + Math.random().toString(36).slice(2, 5),
27
- text: message,
28
- duration: 5e3,
29
- type: "success"
30
- }, options);
31
- toast2.set(data);
32
- return data;
33
- }
34
- function removeToast(id) {
35
- if (!windowExists) return;
36
- const toast2 = customElements.get("w-toast-container").init();
37
- return toast2.del(id);
38
- }
39
- function updateToast(id, options) {
40
- if (!windowExists) return;
41
- const toast2 = customElements.get("w-toast-container").init();
42
- toast2.set(__spreadValues(__spreadValues({}, toast2.get(id)), options));
43
- return toast2.get(id);
44
- }
45
- export {
46
- removeToast,
47
- toast,
48
- updateToast
49
- };
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};
50
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,IAAM,eAAe,OAAO,WAAW;;;ACkBvC,SAAS,MAAM,SAAS,SAAS;AACtC,MAAI,CAAC,aAAc;AACnB,QAAMA,SAAQ,eAAe,IAAI,mBAAmB,EAAE,KAAK;AAE3D,QAAM,OAAO;AAAA,IACX,IAAI,KAAK,IAAI,EAAE,SAAS,EAAE,IAAI,KAAK,OAAO,EAAE,SAAS,EAAE,EAAE,MAAM,GAAG,CAAC;AAAA,IACnE,MAAM;AAAA,IACN,UAAU;AAAA,IACV,MAAM;AAAA,KACH;AAGL,EAAAA,OAAM,IAAI,IAAI;AACd,SAAO;AACT;AAOO,SAAS,YAAY,IAAI;AAC9B,MAAI,CAAC,aAAc;AACnB,QAAMA,SAAQ,eAAe,IAAI,mBAAmB,EAAE,KAAK;AAC3D,SAAOA,OAAM,IAAI,EAAE;AACrB;AAQO,SAAS,YAAY,IAAI,SAAS;AACvC,MAAI,CAAC,aAAc;AACnB,QAAMA,SAAQ,eAAe,IAAI,mBAAmB,EAAE,KAAK;AAC3D,EAAAA,OAAM,IAAI,kCAAKA,OAAM,IAAI,EAAE,IAAM,QAAS;AAC1C,SAAOA,OAAM,IAAI,EAAE;AACrB;",
6
- "names": ["toast"]
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
  }