@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
@@ -0,0 +1 @@
1
+ export declare const wTextfieldStyles: import("lit").CSSResult;
@@ -0,0 +1,55 @@
1
+ import { css } from 'lit';
2
+ /* For some reason the pseudoselectors for webkit and moz must be separate blocks :shrug: */
3
+ export const wTextfieldStyles = css `
4
+ .w-textfield {
5
+ --_input-padding-top: 12px;
6
+ --_input-padding-left: 8px;
7
+ --_input-padding-right: 8px;
8
+ position: relative;
9
+ }
10
+
11
+ .w-textfield--has-prefix {
12
+ --_input-padding-left: 40px;
13
+ }
14
+
15
+ .w-textfield--has-suffix {
16
+ --_input-padding-right: var(--w-prefix-width, 40px);
17
+ }
18
+
19
+ .w-textfield__input-wrapper {
20
+ position: relative;
21
+ overflow: hidden;
22
+ }
23
+
24
+ .w-textfield__input-wrapper:focus-within .w-textfield__mask {
25
+ display: none;
26
+ }
27
+
28
+ /* Hide the native browser controls */
29
+ input[type="number"] {
30
+ -moz-appearance:textfield;
31
+ }
32
+
33
+ input[type="number"]::-webkit-inner-spin-button {
34
+ display: none;
35
+ }
36
+
37
+ /* Could also consider giving the input mask a background color instead of this */
38
+ .w-textfield__input-wrapper:has(.w-textfield__mask):not(:focus-within) input {
39
+ color: transparent;
40
+ }
41
+
42
+ .w-textfield__mask {
43
+ display: block;
44
+ border: 1px solid transparent;
45
+ top: var(--_input-padding-top);
46
+ left: var(--_input-padding-left);
47
+ right: var(--_input-padding-right);
48
+ position: absolute;
49
+ pointer-events: none;
50
+ white-space: nowrap;
51
+ overflow: hidden;
52
+ text-overflow: ellipsis;
53
+ z-index: 1;
54
+ }
55
+ `;
@@ -0,0 +1,2 @@
1
+ import { css } from 'lit';
2
+ export const styles = css `*,:before,:after{--w-rotate:0;--w-rotate-x:0;--w-rotate-y:0;--w-rotate-z:0;--w-scale-x:1;--w-scale-y:1;--w-scale-z:1;--w-skew-x:0;--w-skew-y:0;--w-translate-x:0;--w-translate-y:0;--w-translate-z:0}.focus\\:\\[--w-outline-offset\\:-2px\\]:focus{--w-outline-offset:-2px}.bg-transparent{background-color:#0000}.border-1{border-width:1px}.rounded-4{border-radius:4px}.caret-current{caret-color:currentColor}.block{display:block}.focusable:focus{outline:2px solid var(--w-s-color-border-focus);outline-offset:var(--w-outline-offset,1px)}.focusable:focus-visible{outline:2px solid var(--w-s-color-border-focus);outline-offset:var(--w-outline-offset,1px)}.focusable:not(:focus-visible){outline:none}.outline-\\[--w-s-color-border-negative\\]\\!{outline-color:var(--w-s-color-border-negative)!important}.relative{position:relative}.static{position:static}.s-bg{background-color:var(--w-s-color-background)}.s-bg-disabled-subtle{background-color:var(--w-s-color-background-disabled-subtle)}.s-text{color:var(--w-s-color-text)}.s-text-disabled{color:var(--w-s-color-text-disabled)}.s-text-negative{color:var(--w-s-color-text-negative)}.s-text-subtle{color:var(--w-s-color-text-subtle)}.placeholder\\:s-text-placeholder::placeholder{color:var(--w-s-color-text-placeholder)}.s-border-disabled{border-color:var(--w-s-color-border-disabled)}.s-border-negative{border-color:var(--w-s-color-border-negative)}.s-border-strong{border-color:var(--w-s-color-border-strong)}.hover\\:s-border-negative-hover:hover{border-color:var(--w-s-color-border-negative-hover)}.hover\\:s-border-strong-hover:hover{border-color:var(--w-s-color-border-strong-hover)}.active\\:s-border-selected:active{border-color:var(--w-s-color-border-selected)}.w-full{width:100%}.min-h-\\[42\\]{min-height:4.2rem}.mb-0{margin-bottom:0}.mt-4{margin-top:.4rem}.px-8{padding-left:.8rem;padding-right:.8rem}.py-12{padding-top:1.2rem;padding-bottom:1.2rem}.pb-4{padding-bottom:.4rem}.pl-0{padding-left:0}.pl-8{padding-left:.8rem}.pr-40{padding-right:4rem}.pl-\\[var\\(--w-prefix-width\\,_40px\\)\\]{padding-left:var(--w-prefix-width,40px)}.cursor-pointer{cursor:pointer}.antialiased{-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;font-smoothing:grayscale}.font-bold{font-weight:700}.font-normal{font-weight:400}.pointer-events-none{pointer-events:none}.sr-only{clip:rect(0,0,0,0);white-space:nowrap;border-width:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}.text-m{font-size:var(--w-font-size-m);line-height:var(--w-line-height-m)}.text-s{font-size:var(--w-font-size-s);line-height:var(--w-line-height-s)}.text-xs{font-size:var(--w-font-size-xs);line-height:var(--w-line-height-xs)}.leading-m{line-height:var(--w-line-height-m)}@media (min-width:480px){.sm\\:min-h-\\[45\\]{min-height:4.5rem}}`;
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { StoryObj } from '@storybook/react';
3
+ import { TextField } from './react';
4
+ declare const _default: {
5
+ title: string;
6
+ render(args: Omit<React.HTMLAttributes<import(".").WarpTextField>, "label" | "onblur" | "onchange" | "onfocus" | "oninput" | "onFocus" | "onBlur" | "onChange" | "onInput" | "render" | "renderOptions" | "connectedCallback" | "disconnectedCallback" | "renderRoot" | "isUpdatePending" | "hasUpdated" | "addController" | "removeController" | "attributeChangedCallback" | "requestUpdate" | "updateComplete" | "form" | "mask" | "pattern" | "disabled" | "name" | "type" | "value" | "updated" | "validationTarget" | "internals" | "showError" | "validationMessage" | "validity" | "validationComplete" | "checkValidity" | "formResetCallback" | "resetFormControl" | "valueChangedCallback" | "validityCallback" | "validationMessageCallback" | "setValue" | "shouldFormValueUpdate" | "invalid" | "readOnly" | "helpText" | "size" | "max" | "min" | "minLength" | "maxLength" | "placeholder" | "required" | "formatter" | "_hasPrefix" | "_hasSuffix" | "_inputstyles" | "_helptextstyles" | "_label" | "_helpId" | "_id" | "_error" | "handler" | "prefixSlotChange" | "suffixSlotChange"> & {
7
+ onBlur?: (e: Event) => void;
8
+ onblur?: (e: Event) => void;
9
+ onChange?: (e: Event) => void;
10
+ onchange?: (e: Event) => void;
11
+ onInput?: (e: Event) => void;
12
+ oninput?: (e: Event) => void;
13
+ onFocus?: (e: Event) => void;
14
+ onfocus?: (e: Event) => void;
15
+ } & Partial<Omit<import(".").WarpTextField, keyof HTMLElement>> & React.RefAttributes<import(".").WarpTextField>): React.JSX.Element;
16
+ component: import("@lit/react").ReactWebComponent<import(".").WarpTextField, {
17
+ onBlur: string;
18
+ onblur: string;
19
+ onChange: string;
20
+ onchange: string;
21
+ onInput: string;
22
+ oninput: string;
23
+ onFocus: string;
24
+ onfocus: string;
25
+ }>;
26
+ };
27
+ export default _default;
28
+ export type Story = StoryObj<typeof TextField>;
29
+ export declare const Default: Story;
30
+ export declare const WithPlaceholder: Story;
31
+ export declare const WithHelpText: Story;
32
+ export declare const Invalid: Story;
33
+ export declare const Disabled: Story;
34
+ export declare const ReadOnly: Story;
35
+ export declare const Required: Story;
36
+ export declare const WithAffix: Story;
37
+ export declare const Masking: Story;
@@ -0,0 +1,88 @@
1
+ import React from 'react';
2
+ import { Affix } from '../affix/react';
3
+ import { TextField } from './react';
4
+ const locale = 'nb';
5
+ const getNumberFormatter = (locale, opts = {}) => {
6
+ return (value) => new Intl.NumberFormat(locale, { maximumFractionDigits: 0, ...opts }).format(value);
7
+ };
8
+ export default {
9
+ title: 'Forms/Textfield',
10
+ render(args) {
11
+ return React.createElement(TextField, { ...args });
12
+ },
13
+ component: TextField,
14
+ };
15
+ export const Default = {
16
+ args: {
17
+ label: 'Email',
18
+ type: 'email',
19
+ },
20
+ };
21
+ export const WithPlaceholder = {
22
+ args: {
23
+ label: 'Email',
24
+ placeholder: 'user@example.com',
25
+ type: 'email',
26
+ },
27
+ };
28
+ export const WithHelpText = {
29
+ args: {
30
+ label: 'Password',
31
+ helpText: 'Must be at least 8 characters',
32
+ type: 'password',
33
+ },
34
+ };
35
+ export const Invalid = {
36
+ args: {
37
+ label: 'Email',
38
+ invalid: true,
39
+ helpText: 'Please enter a valid email address',
40
+ value: 'invalid-email',
41
+ type: 'email',
42
+ },
43
+ };
44
+ export const Disabled = {
45
+ args: {
46
+ label: 'Email',
47
+ disabled: true,
48
+ value: 'user@example.com',
49
+ type: 'email',
50
+ },
51
+ };
52
+ export const ReadOnly = {
53
+ args: {
54
+ label: 'Email',
55
+ readOnly: true,
56
+ value: 'user@example.com',
57
+ type: 'email',
58
+ },
59
+ };
60
+ export const Required = {
61
+ args: {
62
+ label: 'Email',
63
+ required: true,
64
+ type: 'email',
65
+ },
66
+ };
67
+ export const WithAffix = {
68
+ args: {
69
+ label: 'Price',
70
+ placeholder: '1 000 000',
71
+ type: 'text',
72
+ },
73
+ render(args) {
74
+ return (React.createElement(TextField, { ...args },
75
+ React.createElement(Affix, { slot: "suffix", label: "kr" })));
76
+ },
77
+ };
78
+ export const Masking = {
79
+ args: {
80
+ label: 'Price',
81
+ placeholder: '1 000 000',
82
+ type: 'text',
83
+ },
84
+ render({ ...args }) {
85
+ return (React.createElement(TextField, { ...args, formatter: getNumberFormatter(locale) },
86
+ React.createElement(Affix, { slot: "suffix", label: "kr" })));
87
+ },
88
+ };
@@ -15,3 +15,4 @@ export declare const Disabled: Story;
15
15
  export declare const ReadOnly: Story;
16
16
  export declare const Required: Story;
17
17
  export declare const WithAffix: Story;
18
+ export declare const Masking: Story;
@@ -0,0 +1,105 @@
1
+ import { spread } from '@open-wc/lit-helpers';
2
+ import { getStorybookHelpers } from '@wc-toolkit/storybook-helpers';
3
+ import { html } from 'lit';
4
+ import { prespread } from '../../.storybook/utilities.js';
5
+ import './index.js';
6
+ const { events, args, argTypes } = getStorybookHelpers('w-textfield');
7
+ const meta = {
8
+ title: 'Forms/Textfield',
9
+ render(args) {
10
+ return html `<w-textfield ${spread(prespread(args))}></w-textfield>`;
11
+ },
12
+ args,
13
+ argTypes,
14
+ parameters: {
15
+ actions: {
16
+ handles: events,
17
+ },
18
+ },
19
+ };
20
+ export default meta;
21
+ export const Default = {
22
+ args: {
23
+ label: 'Email',
24
+ type: 'email',
25
+ },
26
+ };
27
+ export const WithPlaceholder = {
28
+ args: {
29
+ label: 'Email',
30
+ placeholder: 'user@example.com',
31
+ type: 'email',
32
+ },
33
+ };
34
+ export const WithHelpText = {
35
+ args: {
36
+ label: 'Password',
37
+ 'help-text': 'Must be at least 8 characters',
38
+ type: 'password',
39
+ },
40
+ };
41
+ export const Invalid = {
42
+ args: {
43
+ label: 'Email',
44
+ invalid: true,
45
+ 'help-text': 'Please enter a valid email address',
46
+ value: 'invalid-email',
47
+ type: 'email',
48
+ },
49
+ };
50
+ export const Disabled = {
51
+ args: {
52
+ label: 'Email',
53
+ disabled: true,
54
+ value: 'user@example.com',
55
+ type: 'email',
56
+ },
57
+ };
58
+ export const ReadOnly = {
59
+ args: {
60
+ label: 'Email',
61
+ 'read-only': true,
62
+ value: 'user@example.com',
63
+ type: 'email',
64
+ },
65
+ };
66
+ export const Required = {
67
+ args: {
68
+ label: 'Email',
69
+ required: true,
70
+ type: 'email',
71
+ },
72
+ };
73
+ export const WithAffix = {
74
+ args: {
75
+ label: 'Price',
76
+ placeholder: '1 000 000',
77
+ type: 'text',
78
+ },
79
+ render(args) {
80
+ return html `
81
+ <w-textfield ${spread(prespread(args))}>
82
+ <w-affix slot="suffix" label="kr"></w-affix>
83
+ </w-textfield>
84
+ `;
85
+ },
86
+ };
87
+ export const Masking = {
88
+ args: {
89
+ label: 'Price',
90
+ placeholder: '1 000 000',
91
+ type: 'text',
92
+ locale: 'nb',
93
+ },
94
+ render({ locale, ...args }) {
95
+ return html `
96
+ <w-textfield ${spread(prespread(args))} data-testid="masking">
97
+ <w-affix slot="suffix" label="kr"></w-affix>
98
+ </w-textfield>
99
+ <script type="module">
100
+ const maskingTextfield = document.querySelector('w-textfield[data-testid="masking"]');
101
+ maskingTextfield.formatter = window.getNumberFormatter('${locale}').format;
102
+ </script>
103
+ `;
104
+ },
105
+ };
@@ -1 +1,2 @@
1
+ import '../affix/index.js';
1
2
  import './index.js';
@@ -0,0 +1,68 @@
1
+ import { userEvent } from '@vitest/browser/context';
2
+ import { html } from 'lit';
3
+ import { expect, test, vi } from 'vitest';
4
+ import { render } from 'vitest-browser-lit';
5
+ import '../affix/index.js';
6
+ import './index.js';
7
+ test('renders the textfield', async () => {
8
+ const component = html `<w-textfield label="Test label"></w-textfield>`;
9
+ const page = render(component);
10
+ await expect.element(page.getByText('Test label')).toBeVisible();
11
+ });
12
+ test('works as expected in forms', async () => {
13
+ const label = 'Test label';
14
+ const component = html `
15
+ <form data-testid="form">
16
+ <w-textfield label="${label}" name="message" value="Hola el Mundo"></w-textfield>
17
+ </form>
18
+ `;
19
+ const page = render(component);
20
+ await expect.element(page.getByLabelText(label)).toHaveValue('Hola el Mundo');
21
+ let formData = new FormData(page.getByTestId('form').element());
22
+ expect(formData.get('message')).toBe('Hola el Mundo');
23
+ const inputHandler = vi.fn();
24
+ const changeHandler = vi.fn();
25
+ page.getByLabelText(label).element().addEventListener('input', inputHandler);
26
+ page.getByLabelText(label).element().addEventListener('change', changeHandler);
27
+ await page.getByLabelText(label).fill('Hello, World');
28
+ expect(inputHandler).toHaveBeenCalled();
29
+ expect(changeHandler).not.toHaveBeenCalled();
30
+ await userEvent.tab(); // trigger a blur to fire the change event
31
+ expect(changeHandler).toHaveBeenCalled();
32
+ await expect.element(page.getByLabelText(label)).toHaveValue('Hello, World');
33
+ formData = new FormData(page.getByTestId('form').element());
34
+ expect(formData.get('message')).toBe('Hello, World');
35
+ });
36
+ test('renders help text if provided', async () => {
37
+ const component = html `<w-textfield label="Test label" help-text="Helpful help text"></w-textfield>`;
38
+ const page = render(component);
39
+ await expect.element(page.getByText('Helpful help text')).toBeVisible();
40
+ });
41
+ test('marks input field as aria-invalid if the invalid prop is true', async () => {
42
+ const component = html `<w-textfield label="Test label" invalid help-text="No, bad input!"></w-textfield>`;
43
+ const page = render(component);
44
+ await expect.element(page.getByLabelText('Test label')).toHaveAccessibleErrorMessage('No, bad input!');
45
+ });
46
+ test('marks input field as readonly if the read-only prop is true', async () => {
47
+ const component = html `<w-textfield label="Test label" read-only></w-textfield>`;
48
+ const page = render(component);
49
+ await expect.element(page.getByLabelText('Test label')).toHaveAttribute('readonly', '');
50
+ });
51
+ test('renders affix component in the prefix slot', async () => {
52
+ const component = html `
53
+ <w-textfield label="Test label">
54
+ <w-affix slot="prefix" label="kr"></w-affix>
55
+ </w-textfield>
56
+ `;
57
+ const page = render(component);
58
+ await expect.element(page.getByText('kr')).toBeVisible();
59
+ });
60
+ test('renders affix component in the suffix slot', async () => {
61
+ const component = html `
62
+ <w-textfield label="Test label">
63
+ <w-affix slot="suffix" label="kr"></w-affix>
64
+ </w-textfield>
65
+ `;
66
+ const page = render(component);
67
+ await expect.element(page.getByText('kr')).toBeVisible();
68
+ });
@@ -1,54 +1,13 @@
1
- /**
2
- * Toast helper function options
3
- * @typedef {Object} ToastOptions
4
- * @property {(number|string)} [id] Custom identifier
5
- * @property {('success'|'error'|'warning')} [type] Type of toast
6
- * @property {String} [text] The toast message. Only needed when updating text on existing toast
7
- * @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.
8
- * @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.
9
- */
1
+ import type { ToastInternal, ToastOptions } from './types';
10
2
  /**
11
3
  * Creates a new toast
12
- * @param {String} message Message
13
- * @param {ToastOptions?} options Toast options
14
- * @returns {ToastOptions} Toast details
15
4
  */
16
- export function toast(message: string, options: ToastOptions | null): ToastOptions;
5
+ export declare function toast(message: string, options?: ToastOptions): ToastOptions;
17
6
  /**
18
7
  * Remove an existing toast
19
- * @param {String|Number} id Toast identifier
20
- * @return {Promise<Boolean>} Resolves to true if deleted, false if not found
21
8
  */
22
- export function removeToast(id: string | number): Promise<boolean>;
9
+ export declare function removeToast(id: string | number): Promise<boolean> | undefined;
23
10
  /**
24
11
  * Update an existing toast
25
- * @param {String|Number} id Toast identifier
26
- * @param {ToastOptions?} options Toast options
27
- * @returns {WarpToastContainer} Toast details
28
- */
29
- export function updateToast(id: string | number, options: ToastOptions | null): WarpToastContainer;
30
- /**
31
- * Toast helper function options
32
12
  */
33
- export type ToastOptions = {
34
- /**
35
- * Custom identifier
36
- */
37
- id?: (number | string);
38
- /**
39
- * Type of toast
40
- */
41
- type?: ("success" | "error" | "warning");
42
- /**
43
- * The toast message. Only needed when updating text on existing toast
44
- */
45
- text?: string;
46
- /**
47
- * 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.
48
- */
49
- duration?: (number | string);
50
- /**
51
- * 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.
52
- */
53
- canclose?: boolean;
54
- };
13
+ export declare function updateToast(id: string | number, options?: ToastOptions): ToastInternal | undefined;
@@ -0,0 +1,41 @@
1
+ import { windowExists } from '../utils/window-exists';
2
+ function getToastContainer() {
3
+ const container = customElements.get('w-toast-container');
4
+ return container;
5
+ }
6
+ /**
7
+ * Creates a new toast
8
+ */
9
+ export function toast(message, options) {
10
+ if (!windowExists)
11
+ return;
12
+ const toast = getToastContainer().init();
13
+ const data = {
14
+ id: Date.now().toString(36) + Math.random().toString(36).slice(2, 5),
15
+ text: message,
16
+ duration: 5000,
17
+ type: 'success',
18
+ ...options,
19
+ };
20
+ toast.set(data);
21
+ return data;
22
+ }
23
+ /**
24
+ * Remove an existing toast
25
+ */
26
+ export function removeToast(id) {
27
+ if (!windowExists)
28
+ return;
29
+ const toast = getToastContainer().init();
30
+ return toast.del(id);
31
+ }
32
+ /**
33
+ * Update an existing toast
34
+ */
35
+ export function updateToast(id, options) {
36
+ if (!windowExists)
37
+ return;
38
+ const toast = getToastContainer().init();
39
+ toast.set({ ...toast.get(id), ...options });
40
+ return toast.get(id);
41
+ }
@@ -1,3 +1,3 @@
1
- export { WarpToast } from "./toast";
2
- export { WarpToastContainer } from "./toast-container";
3
- export { toast, updateToast, removeToast } from "./api";
1
+ export { removeToast, toast, updateToast } from './api';
2
+ export { WarpToast } from './toast';
3
+ export { WarpToastContainer } from './toast-container';