revotech-ui-kit 0.0.0 → 0.0.2-beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (307) hide show
  1. package/.github/workflows/deploy-storybook.yml +107 -0
  2. package/.storybook/main.ts +3 -3
  3. package/assume_role.sh +18 -0
  4. package/dist/183c6c38.js +1 -0
  5. package/dist/f28fd4b1.js +1 -0
  6. package/dist/index.ts +1 -0
  7. package/dist/public/globals.css +2215 -0
  8. package/dist/public/tailwind-lib.css +115 -0
  9. package/dist/src/assets/icons/arrows.icon.js +20 -0
  10. package/dist/src/assets/icons/arrows.icon.js.map +1 -0
  11. package/dist/src/assets/icons/index.js +4 -0
  12. package/dist/src/assets/icons/index.js.map +1 -0
  13. package/dist/src/assets/icons/search.icon.js +19 -0
  14. package/dist/src/assets/icons/search.icon.js.map +1 -0
  15. package/dist/src/assets/icons/tick.icon.js +20 -0
  16. package/dist/src/assets/icons/tick.icon.js.map +1 -0
  17. package/dist/src/components/atoms/alert/alert-description.js +18 -0
  18. package/dist/src/components/atoms/alert/alert-description.js.map +1 -0
  19. package/dist/src/components/atoms/alert/alert-title.js +20 -0
  20. package/dist/src/components/atoms/alert/alert-title.js.map +1 -0
  21. package/dist/src/components/atoms/alert/alert.atom.js +55 -0
  22. package/dist/src/components/atoms/alert/alert.atom.js.map +1 -0
  23. package/dist/src/components/atoms/alert/alert.stories.js +62 -0
  24. package/dist/src/components/atoms/alert/alert.stories.js.map +1 -0
  25. package/dist/src/components/atoms/alert/alert.styles.js +21 -0
  26. package/dist/src/components/atoms/alert/alert.styles.js.map +1 -0
  27. package/dist/src/components/atoms/alert/alert.types.js +2 -0
  28. package/dist/src/components/atoms/alert/alert.types.js.map +1 -0
  29. package/dist/src/components/atoms/badge/badge.atom.js +43 -0
  30. package/dist/src/components/atoms/badge/badge.atom.js.map +1 -0
  31. package/dist/src/components/atoms/badge/badge.stories.js +110 -0
  32. package/dist/src/components/atoms/badge/badge.stories.js.map +1 -0
  33. package/dist/src/components/atoms/badge/badge.style.js +17 -0
  34. package/dist/src/components/atoms/badge/badge.style.js.map +1 -0
  35. package/dist/src/components/atoms/badge/badge.type.js +2 -0
  36. package/dist/src/components/atoms/badge/badge.type.js.map +1 -0
  37. package/dist/src/components/atoms/button/button.atom.js +67 -0
  38. package/dist/src/components/atoms/button/button.atom.js.map +1 -0
  39. package/dist/src/components/atoms/button/button.stories.js +204 -0
  40. package/dist/src/components/atoms/button/button.stories.js.map +1 -0
  41. package/dist/src/components/atoms/button/button.style.js +24 -0
  42. package/dist/src/components/atoms/button/button.style.js.map +1 -0
  43. package/dist/src/components/atoms/button/button.type.js +2 -0
  44. package/dist/src/components/atoms/button/button.type.js.map +1 -0
  45. package/dist/src/components/atoms/card/card-content.js +17 -0
  46. package/dist/src/components/atoms/card/card-content.js.map +1 -0
  47. package/dist/src/components/atoms/card/card-description.js +17 -0
  48. package/dist/src/components/atoms/card/card-description.js.map +1 -0
  49. package/dist/src/components/atoms/card/card-footer.js +17 -0
  50. package/dist/src/components/atoms/card/card-footer.js.map +1 -0
  51. package/dist/src/components/atoms/card/card-header.js +17 -0
  52. package/dist/src/components/atoms/card/card-header.js.map +1 -0
  53. package/dist/src/components/atoms/card/card-title.js +17 -0
  54. package/dist/src/components/atoms/card/card-title.js.map +1 -0
  55. package/dist/src/components/atoms/card/card.atom.js +25 -0
  56. package/dist/src/components/atoms/card/card.atom.js.map +1 -0
  57. package/dist/src/components/atoms/card/card.stories.js +136 -0
  58. package/dist/src/components/atoms/card/card.stories.js.map +1 -0
  59. package/dist/src/components/atoms/checkbox/checkbox.atom.js +87 -0
  60. package/dist/src/components/atoms/checkbox/checkbox.atom.js.map +1 -0
  61. package/dist/src/components/atoms/checkbox/checkbox.stories.js +244 -0
  62. package/dist/src/components/atoms/checkbox/checkbox.stories.js.map +1 -0
  63. package/dist/src/components/atoms/checkbox/checkbox.style.js +3 -0
  64. package/dist/src/components/atoms/checkbox/checkbox.style.js.map +1 -0
  65. package/dist/src/components/atoms/checkbox/checkbox.type.js +2 -0
  66. package/dist/src/components/atoms/checkbox/checkbox.type.js.map +1 -0
  67. package/dist/src/components/atoms/combo-box/combo-box-input.js +47 -0
  68. package/dist/src/components/atoms/combo-box/combo-box-input.js.map +1 -0
  69. package/dist/src/components/atoms/combo-box/combo-box-item.js +85 -0
  70. package/dist/src/components/atoms/combo-box/combo-box-item.js.map +1 -0
  71. package/dist/src/components/atoms/combo-box/combo-box-list.js +67 -0
  72. package/dist/src/components/atoms/combo-box/combo-box-list.js.map +1 -0
  73. package/dist/src/components/atoms/combo-box/combo-box.atom.js +199 -0
  74. package/dist/src/components/atoms/combo-box/combo-box.atom.js.map +1 -0
  75. package/dist/src/components/atoms/combo-box/combo-box.stories.js +86 -0
  76. package/dist/src/components/atoms/combo-box/combo-box.stories.js.map +1 -0
  77. package/dist/src/components/atoms/command-empty/command-empty.atom.js +54 -0
  78. package/dist/src/components/atoms/command-empty/command-empty.atom.js.map +1 -0
  79. package/dist/src/components/atoms/command-group/command-group.atom.js +71 -0
  80. package/dist/src/components/atoms/command-group/command-group.atom.js.map +1 -0
  81. package/dist/src/components/atoms/command-item/command-item.atom.js +80 -0
  82. package/dist/src/components/atoms/command-item/command-item.atom.js.map +1 -0
  83. package/dist/src/components/atoms/command-list/command-list.atom.js +36 -0
  84. package/dist/src/components/atoms/command-list/command-list.atom.js.map +1 -0
  85. package/dist/src/components/atoms/command-separator/command-separator.atom.js +52 -0
  86. package/dist/src/components/atoms/command-separator/command-separator.atom.js.map +1 -0
  87. package/dist/src/components/atoms/dialog/dialog-close.js +47 -0
  88. package/dist/src/components/atoms/dialog/dialog-close.js.map +1 -0
  89. package/dist/src/components/atoms/dialog/dialog-content.js +72 -0
  90. package/dist/src/components/atoms/dialog/dialog-content.js.map +1 -0
  91. package/dist/src/components/atoms/dialog/dialog-footer.js +22 -0
  92. package/dist/src/components/atoms/dialog/dialog-footer.js.map +1 -0
  93. package/dist/src/components/atoms/dialog/dialog-header.js +40 -0
  94. package/dist/src/components/atoms/dialog/dialog-header.js.map +1 -0
  95. package/dist/src/components/atoms/dialog/dialog-overly.js +20 -0
  96. package/dist/src/components/atoms/dialog/dialog-overly.js.map +1 -0
  97. package/dist/src/components/atoms/dialog/dialog-trigger.js +54 -0
  98. package/dist/src/components/atoms/dialog/dialog-trigger.js.map +1 -0
  99. package/dist/src/components/atoms/dialog/dialog.atom.js +79 -0
  100. package/dist/src/components/atoms/dialog/dialog.atom.js.map +1 -0
  101. package/dist/src/components/atoms/dialog/dialog.stories.js +88 -0
  102. package/dist/src/components/atoms/dialog/dialog.stories.js.map +1 -0
  103. package/dist/src/components/atoms/dropdownMenu/dropdown-menu-checkbox-Item.js +117 -0
  104. package/dist/src/components/atoms/dropdownMenu/dropdown-menu-checkbox-Item.js.map +1 -0
  105. package/dist/src/components/atoms/dropdownMenu/dropdown-menu-content.js +81 -0
  106. package/dist/src/components/atoms/dropdownMenu/dropdown-menu-content.js.map +1 -0
  107. package/dist/src/components/atoms/dropdownMenu/dropdown-menu-group.js +71 -0
  108. package/dist/src/components/atoms/dropdownMenu/dropdown-menu-group.js.map +1 -0
  109. package/dist/src/components/atoms/dropdownMenu/dropdown-menu-item.js +80 -0
  110. package/dist/src/components/atoms/dropdownMenu/dropdown-menu-item.js.map +1 -0
  111. package/dist/src/components/atoms/dropdownMenu/dropdown-menu-radio-item.js +118 -0
  112. package/dist/src/components/atoms/dropdownMenu/dropdown-menu-radio-item.js.map +1 -0
  113. package/dist/src/components/atoms/dropdownMenu/dropdown-menu-seperator.js +52 -0
  114. package/dist/src/components/atoms/dropdownMenu/dropdown-menu-seperator.js.map +1 -0
  115. package/dist/src/components/atoms/dropdownMenu/dropdown-menu-shortcut.js +20 -0
  116. package/dist/src/components/atoms/dropdownMenu/dropdown-menu-shortcut.js.map +1 -0
  117. package/dist/src/components/atoms/dropdownMenu/dropdown-menu.atom.js +79 -0
  118. package/dist/src/components/atoms/dropdownMenu/dropdown-menu.atom.js.map +1 -0
  119. package/dist/src/components/atoms/dropdownMenu/dropdownMenu.stories.js +211 -0
  120. package/dist/src/components/atoms/dropdownMenu/dropdownMenu.stories.js.map +1 -0
  121. package/dist/src/components/atoms/dropdownMenu/dropdownMenu.style.js +4 -0
  122. package/dist/src/components/atoms/dropdownMenu/dropdownMenu.style.js.map +1 -0
  123. package/dist/src/components/atoms/index.js +14 -0
  124. package/dist/src/components/atoms/index.js.map +1 -0
  125. package/dist/src/components/atoms/input/input.atom.js +93 -0
  126. package/dist/src/components/atoms/input/input.atom.js.map +1 -0
  127. package/dist/src/components/atoms/input/input.stories.js +382 -0
  128. package/dist/src/components/atoms/input/input.stories.js.map +1 -0
  129. package/dist/src/components/atoms/input/input.styles.js +2 -0
  130. package/dist/src/components/atoms/input/input.styles.js.map +1 -0
  131. package/dist/src/components/atoms/input/input.type.js +2 -0
  132. package/dist/src/components/atoms/input/input.type.js.map +1 -0
  133. package/dist/src/components/atoms/label/label.atom.js +68 -0
  134. package/dist/src/components/atoms/label/label.atom.js.map +1 -0
  135. package/dist/src/components/atoms/label/label.stories.js +85 -0
  136. package/dist/src/components/atoms/label/label.stories.js.map +1 -0
  137. package/dist/src/components/atoms/label/label.style.js +3 -0
  138. package/dist/src/components/atoms/label/label.style.js.map +1 -0
  139. package/dist/src/components/atoms/popover/popover-content.js +64 -0
  140. package/dist/src/components/atoms/popover/popover-content.js.map +1 -0
  141. package/dist/src/components/atoms/popover/popover-trigger.js +51 -0
  142. package/dist/src/components/atoms/popover/popover-trigger.js.map +1 -0
  143. package/dist/src/components/atoms/popover/popover.atom.js +40 -0
  144. package/dist/src/components/atoms/popover/popover.atom.js.map +1 -0
  145. package/dist/src/components/atoms/popover/popover.stories.js +69 -0
  146. package/dist/src/components/atoms/popover/popover.stories.js.map +1 -0
  147. package/dist/src/components/atoms/popover/popover.style.js +21 -0
  148. package/dist/src/components/atoms/popover/popover.style.js.map +1 -0
  149. package/dist/src/components/atoms/popover/popover.types.js +4 -0
  150. package/dist/src/components/atoms/popover/popover.types.js.map +1 -0
  151. package/dist/src/components/atoms/toggle/defs.js +30 -0
  152. package/dist/src/components/atoms/toggle/defs.js.map +1 -0
  153. package/dist/src/components/atoms/toggle/toggle.atom.js +72 -0
  154. package/dist/src/components/atoms/toggle/toggle.atom.js.map +1 -0
  155. package/dist/src/components/atoms/toggle/toggle.stories.js +189 -0
  156. package/dist/src/components/atoms/toggle/toggle.stories.js.map +1 -0
  157. package/dist/src/components/atoms/toggle/toggle.style.js +19 -0
  158. package/dist/src/components/atoms/toggle/toggle.style.js.map +1 -0
  159. package/dist/src/components/command/command.js +410 -0
  160. package/dist/src/components/command/command.js.map +1 -0
  161. package/dist/src/components/command/command.stories.js +153 -0
  162. package/dist/src/components/command/command.stories.js.map +1 -0
  163. package/dist/src/components/index.js +3 -0
  164. package/dist/src/components/index.js.map +1 -0
  165. package/dist/src/components/molecules/command/command.molecules.js +27 -0
  166. package/dist/src/components/molecules/command/command.molecules.js.map +1 -0
  167. package/dist/src/components/molecules/command-input/command-input.atom.js +127 -0
  168. package/dist/src/components/molecules/command-input/command-input.atom.js.map +1 -0
  169. package/dist/src/components/molecules/dropdownMenu/dropdownMenu.molecules.js +2 -0
  170. package/dist/src/components/molecules/dropdownMenu/dropdownMenu.molecules.js.map +1 -0
  171. package/dist/src/components/molecules/index.js +2 -0
  172. package/dist/src/components/molecules/index.js.map +1 -0
  173. package/dist/src/helpers/base-element.js +64 -0
  174. package/dist/src/helpers/base-element.js.map +1 -0
  175. package/dist/src/helpers/index.js +4 -0
  176. package/dist/src/helpers/index.js.map +1 -0
  177. package/dist/src/helpers/mouse-conroller.helper.js +33 -0
  178. package/dist/src/helpers/mouse-conroller.helper.js.map +1 -0
  179. package/dist/src/helpers/style.helpers.js +6 -0
  180. package/dist/src/helpers/style.helpers.js.map +1 -0
  181. package/dist/src/index.js +2 -0
  182. package/dist/src/index.js.map +1 -0
  183. package/dist/src/interfaces/actionable.interface.js +2 -0
  184. package/dist/src/interfaces/actionable.interface.js.map +1 -0
  185. package/dist/src/interfaces/atomic.interface.js +2 -0
  186. package/dist/src/interfaces/atomic.interface.js.map +1 -0
  187. package/dist/src/interfaces/changeable.interface.js +2 -0
  188. package/dist/src/interfaces/changeable.interface.js.map +1 -0
  189. package/dist/src/interfaces/child-support-atomic.interface.js +2 -0
  190. package/dist/src/interfaces/child-support-atomic.interface.js.map +1 -0
  191. package/dist/src/interfaces/index.js +7 -0
  192. package/dist/src/interfaces/index.js.map +1 -0
  193. package/dist/src/interfaces/intractable.interface.js +2 -0
  194. package/dist/src/interfaces/intractable.interface.js.map +1 -0
  195. package/dist/src/interfaces/variant.interface.js +2 -0
  196. package/dist/src/interfaces/variant.interface.js.map +1 -0
  197. package/dist/src/lib/index.js +2 -0
  198. package/dist/src/lib/index.js.map +1 -0
  199. package/dist/src/lib/next/next.lib.js +2 -0
  200. package/dist/src/lib/next/next.lib.js.map +1 -0
  201. package/dist/src/lib/react/react.lib.js +16 -0
  202. package/dist/src/lib/react/react.lib.js.map +1 -0
  203. package/dist/src/lib/tw-styles.js +1956 -0
  204. package/dist/src/lib/tw-styles.js.map +1 -0
  205. package/dist/src/styles/index.js +2 -0
  206. package/dist/src/styles/index.js.map +1 -0
  207. package/dist/src/styles/tw.styles.js +2218 -0
  208. package/dist/src/styles/tw.styles.js.map +1 -0
  209. package/dist/src/wc-ui-app.js +88 -0
  210. package/dist/src/wc-ui-app.js.map +1 -0
  211. package/dist/sw.js +2 -0
  212. package/dist/sw.js.map +1 -0
  213. package/dist/test/wc-ui-app.test.js +18 -0
  214. package/dist/test/wc-ui-app.test.js.map +1 -0
  215. package/dist/tsconfig.tsbuildinfo +1 -0
  216. package/dist/workbox-a523fd56.js +2 -0
  217. package/dist/workbox-a523fd56.js.map +1 -0
  218. package/index.html +18 -66
  219. package/package.json +41 -18
  220. package/rollup.config.js +25 -13
  221. package/src/assets/icons/arrows.icon.ts +20 -0
  222. package/src/assets/icons/index.ts +3 -0
  223. package/src/assets/icons/search.icon.ts +19 -0
  224. package/src/assets/icons/tick.icon.ts +20 -0
  225. package/src/chai-custom.d.ts +0 -0
  226. package/src/components/atoms/alert/alert-description.ts +15 -0
  227. package/src/components/atoms/alert/alert-title.ts +17 -0
  228. package/src/components/atoms/alert/alert.atom.ts +51 -0
  229. package/src/components/atoms/alert/alert.stories.ts +71 -0
  230. package/src/components/atoms/alert/alert.styles.ts +21 -0
  231. package/src/components/atoms/alert/alert.types.ts +1 -0
  232. package/src/components/atoms/badge/badge.atom.ts +40 -0
  233. package/src/components/atoms/badge/badge.stories.ts +118 -0
  234. package/src/components/atoms/badge/badge.style.ts +24 -0
  235. package/src/components/atoms/badge/badge.type.ts +7 -0
  236. package/src/components/atoms/button/button.atom.ts +22 -8
  237. package/src/components/atoms/button/button.stories.ts +177 -139
  238. package/src/components/atoms/card/card-content.ts +15 -0
  239. package/src/components/atoms/card/card-description.ts +15 -0
  240. package/src/components/atoms/card/card-footer.ts +15 -0
  241. package/src/components/atoms/card/card-header.ts +15 -0
  242. package/src/components/atoms/card/card-title.ts +15 -0
  243. package/src/components/atoms/card/card.atom.ts +31 -0
  244. package/src/components/atoms/card/card.stories.ts +149 -0
  245. package/src/components/atoms/checkbox/checkbox.atom.ts +30 -16
  246. package/src/components/atoms/checkbox/checkbox.stories.ts +292 -25
  247. package/src/components/atoms/checkbox/checkbox.style.ts +5 -0
  248. package/src/components/atoms/checkbox/checkbox.type.ts +24 -0
  249. package/src/components/atoms/combo-box/combo-box-input.ts +33 -0
  250. package/src/components/atoms/combo-box/combo-box-item.ts +59 -0
  251. package/src/components/atoms/combo-box/combo-box-list.ts +57 -0
  252. package/src/components/atoms/combo-box/combo-box.atom.ts +187 -0
  253. package/src/components/atoms/combo-box/combo-box.stories.ts +95 -0
  254. package/src/components/atoms/command-empty/command-empty.atom.ts +2 -2
  255. package/src/components/atoms/command-group/command-group.atom.ts +1 -1
  256. package/src/components/atoms/command-item/command-item.atom.ts +2 -2
  257. package/src/components/atoms/command-list/command-list.atom.ts +2 -2
  258. package/src/components/atoms/command-separator/command-separator.atom.ts +2 -2
  259. package/src/components/atoms/dialog/dialog-close.ts +50 -0
  260. package/src/components/atoms/dialog/dialog-content.ts +71 -0
  261. package/src/components/atoms/dialog/dialog-footer.ts +22 -0
  262. package/src/components/atoms/dialog/dialog-header.ts +36 -0
  263. package/src/components/atoms/dialog/dialog-overly.ts +20 -0
  264. package/src/components/atoms/dialog/dialog-trigger.ts +54 -0
  265. package/src/components/atoms/dialog/dialog.atom.ts +3 -226
  266. package/src/components/atoms/dialog/dialog.stories.ts +11 -4
  267. package/src/components/atoms/dropdownMenu/dropdown-menu-checkbox-Item.ts +106 -0
  268. package/src/components/atoms/dropdownMenu/dropdown-menu-content.ts +79 -0
  269. package/src/components/atoms/dropdownMenu/dropdown-menu-group.ts +60 -0
  270. package/src/components/atoms/dropdownMenu/dropdown-menu-item.ts +74 -0
  271. package/src/components/atoms/dropdownMenu/dropdown-menu-radio-item.ts +107 -0
  272. package/src/components/atoms/dropdownMenu/dropdown-menu-seperator.ts +44 -0
  273. package/src/components/atoms/dropdownMenu/dropdown-menu-shortcut.ts +17 -0
  274. package/src/components/atoms/dropdownMenu/dropdown-menu.atom.ts +84 -0
  275. package/src/components/atoms/dropdownMenu/dropdownMenu.stories.ts +220 -0
  276. package/src/components/atoms/dropdownMenu/dropdownMenu.style.ts +7 -0
  277. package/src/components/atoms/index.ts +3 -0
  278. package/src/components/atoms/input/input.atom.ts +64 -10
  279. package/src/components/atoms/input/input.stories.ts +426 -64
  280. package/src/components/atoms/input/input.styles.ts +2 -0
  281. package/src/components/atoms/input/input.type.ts +42 -8
  282. package/src/components/atoms/label/label.atom.ts +31 -7
  283. package/src/components/atoms/label/label.stories.ts +87 -3
  284. package/src/components/atoms/popover/popover-content.ts +58 -0
  285. package/src/components/atoms/popover/popover-trigger.ts +50 -0
  286. package/src/components/atoms/popover/popover.atom.ts +34 -0
  287. package/src/components/atoms/popover/popover.stories.ts +79 -0
  288. package/src/components/atoms/popover/popover.style.ts +25 -0
  289. package/src/components/atoms/popover/popover.types.ts +3 -0
  290. package/src/components/atoms/toggle/defs.ts +29 -0
  291. package/src/components/atoms/toggle/toggle.atom.ts +58 -0
  292. package/src/components/atoms/toggle/toggle.stories.ts +204 -0
  293. package/src/components/atoms/toggle/toggle.style.ts +22 -0
  294. package/src/components/molecules/command/command.molecules.ts +2 -2
  295. package/src/components/molecules/command-input/command-input.atom.ts +3 -3
  296. package/src/components/molecules/dropdownMenu/dropdownMenu.molecules.ts +0 -0
  297. package/src/globals.css +475 -66
  298. package/src/helpers/base-element.ts +79 -0
  299. package/src/helpers/index.ts +1 -0
  300. package/src/index.ts +0 -0
  301. package/src/lib/react/react.lib.ts +18 -0
  302. package/src/lib/tw-styles.ts +1957 -0
  303. package/src/styles/tw.styles.ts +2051 -1699
  304. package/src/tailwind-lib.css +26 -6
  305. package/tailwind.config.js +174 -38
  306. package/tsconfig.json +6 -1
  307. package/src/components/popover.ts +0 -247
@@ -0,0 +1,382 @@
1
+ import { html } from 'lit';
2
+ import './input.atom';
3
+ import '../label/label.atom';
4
+ import '../button/button.atom';
5
+ import { expect, within, waitFor, fn, userEvent } from '@storybook/test';
6
+ const validInputTypes = [
7
+ 'hidden',
8
+ 'text',
9
+ 'search',
10
+ 'tel',
11
+ 'url',
12
+ 'email',
13
+ 'password',
14
+ ];
15
+ const validInputSpeceficTypes = [
16
+ 'hidden',
17
+ 'date',
18
+ 'month',
19
+ 'week',
20
+ 'time',
21
+ 'datetime-local',
22
+ 'number',
23
+ 'range',
24
+ 'color',
25
+ 'file',
26
+ ];
27
+ export default {
28
+ component: 'components/input',
29
+ tags: ['autodocs'],
30
+ };
31
+ const testInputBehavior = async (args, canvasElement, mockHandler) => {
32
+ const canvas = within(canvasElement);
33
+ const input = await waitFor(() => canvas.getByTestId('input-id'));
34
+ if (input.shadowRoot) {
35
+ const innerInput = input.shadowRoot.querySelector('[data-testchild="children-id"]');
36
+ if (args.type !== 'file') {
37
+ if (innerInput instanceof HTMLInputElement) {
38
+ innerInput.value = args.defaultValue;
39
+ }
40
+ expect(innerInput).toHaveAttribute('placeholder', args.placeholder);
41
+ }
42
+ // 1. Test: Input should have the correct `disabled` state based on args
43
+ if (args.disabled) {
44
+ expect(innerInput).toBeDisabled();
45
+ }
46
+ else {
47
+ expect(innerInput).not.toBeDisabled();
48
+ }
49
+ // 2. Test: `type` should be a valid InputType
50
+ expect(validInputTypes).toContain(args.type);
51
+ // 3. Test: Input should have correct type attribute
52
+ expect(innerInput).toHaveAttribute('type', args.type);
53
+ // 4. Test: Label should have correct `for` attribute linking to the input
54
+ if (args.label) {
55
+ const label = await waitFor(() => canvas.getByTestId('label-id'));
56
+ expect(label).toBeInTheDocument();
57
+ }
58
+ // 5. Button should handle click events when not disabled
59
+ if (args.ButtonLabel) {
60
+ const button = await waitFor(() => canvas.getByTestId('button-id'));
61
+ expect(button).toBeInTheDocument();
62
+ const innerButton = button.querySelector('[data-testid="children-id"]');
63
+ if (!args.disabledButton && innerButton) {
64
+ await userEvent.click(innerButton);
65
+ if (mockHandler) {
66
+ expect(mockHandler).toHaveBeenCalled();
67
+ }
68
+ }
69
+ }
70
+ // 6. Test: Button should not handle click events when disabled
71
+ if (args.disabledButton) {
72
+ expect(mockHandler).not.toHaveBeenCalled();
73
+ }
74
+ }
75
+ };
76
+ const testInputSpecificBehavior = async (args, canvasElement, mockHandler) => {
77
+ const canvas = within(canvasElement);
78
+ const input = await waitFor(() => canvas.getByTestId('input-id'));
79
+ if (input.shadowRoot) {
80
+ const innerInput = input.shadowRoot.querySelector('[data-testchild="children-id"]');
81
+ // 1. Test: Input should have the correct `disabled` state based on args
82
+ if (args.disabled) {
83
+ expect(innerInput).toBeDisabled();
84
+ }
85
+ else {
86
+ expect(innerInput).not.toBeDisabled();
87
+ }
88
+ // 2. Test: `type` should be a valid InputType
89
+ expect(validInputSpeceficTypes).toContain(args.type);
90
+ // 3. Test: Input should have correct type attribute
91
+ expect(innerInput).toHaveAttribute('type', args.type);
92
+ // 4. Test: Label should have correct `for` attribute linking to the input
93
+ if (args.label) {
94
+ const label = await waitFor(() => canvas.getByTestId('label-id'));
95
+ expect(label).toBeInTheDocument();
96
+ }
97
+ // 5. Button should handle click events when not disabled
98
+ if (args.ButtonLabel) {
99
+ const button = await waitFor(() => canvas.getByTestId('button-id'));
100
+ expect(button).toBeInTheDocument();
101
+ const innerButton = button.querySelector('[data-testid="children-id"]');
102
+ if (!args.disabledButton && innerButton) {
103
+ await userEvent.click(innerButton);
104
+ if (mockHandler) {
105
+ expect(mockHandler).toHaveBeenCalled();
106
+ }
107
+ }
108
+ }
109
+ // 6. Test: Button should not handle click events when disabled
110
+ if (args.disabledButton) {
111
+ expect(mockHandler).not.toHaveBeenCalled();
112
+ }
113
+ }
114
+ };
115
+ const mockOnClickHandler = fn(event => {
116
+ alert('Hello!');
117
+ });
118
+ const Template = ({ label, ButtonLabel, id, type, placeholder, disabled, disabledButton, defaultValue, }) => {
119
+ const inputValue = type !== 'file' ? defaultValue : '';
120
+ if (ButtonLabel && !label) {
121
+ return html `
122
+ <div style="display:flex">
123
+ <rtg-input
124
+ data-testid="input-id"
125
+ data-testchild="children-id"
126
+ id=${id}
127
+ type=${type}
128
+ placeholder=${placeholder}
129
+ ?disabled=${disabled}
130
+ .value=${inputValue}
131
+ style="min-width:50%"
132
+ ></rtg-input>
133
+ <rtg-button
134
+ data-testid="button-id"
135
+ style="margin-inline-start:4px"
136
+ size="default"
137
+ ?disabled=${disabledButton}
138
+ .click=${mockOnClickHandler}
139
+ >${ButtonLabel}</rtg-button
140
+ >
141
+ </div>
142
+ `;
143
+ }
144
+ else if (label && !ButtonLabel) {
145
+ return html `
146
+ <div>
147
+ <rtg-label data-testid="label-id" for="picture">${label}</rtg-label>
148
+ <rtg-input
149
+ data-testid="input-id"
150
+ data-testchild="children-id"
151
+ type=${type}
152
+ ?disabled=${disabled}
153
+ placeholder=${placeholder}
154
+ .value=${inputValue}
155
+ style="min-width:50%"
156
+ ></rtg-input>
157
+ </div>
158
+ `;
159
+ }
160
+ else if (label && ButtonLabel) {
161
+ return html `
162
+ <div style="display: flex; flex-direction: column;">
163
+ <rtg-label data-testid="label-id" for="picture">${label}</rtg-label>
164
+ <div style="display:flex">
165
+ <rtg-input
166
+ data-testid="input-id"
167
+ data-testchild="children-id"
168
+ id=${id}
169
+ type=${type}
170
+ placeholder=${placeholder}
171
+ ?disabled=${disabled}
172
+ .value=${inputValue}
173
+ style="min-width:50%"
174
+ ></rtg-input>
175
+ <rtg-button
176
+ data-testid="button-id"
177
+ style="margin-inline-start:4px"
178
+ size="default"
179
+ ?disabled=${disabledButton}
180
+ .click=${mockOnClickHandler}
181
+ >${ButtonLabel}</rtg-button
182
+ >
183
+ </div>
184
+ </div>
185
+ `;
186
+ }
187
+ else {
188
+ return html `
189
+ <rtg-input
190
+ data-testid="input-id"
191
+ data-testchild="children-id"
192
+ type=${type}
193
+ ?disabled=${disabled}
194
+ placeholder=${placeholder}
195
+ .value=${inputValue}
196
+ style="min-width:50%"
197
+ ></rtg-input>
198
+ `;
199
+ }
200
+ };
201
+ const TemplateSpecific = ({ label, ButtonLabel, id, type, value, disabled, disabledButton, }) => {
202
+ if (ButtonLabel && !label) {
203
+ return html `
204
+ <div style="display:flex">
205
+ <rtg-input
206
+ data-testid="input-id"
207
+ data-testchild="children-id"
208
+ id=${id}
209
+ type=${type}
210
+ ?disabled=${disabled}
211
+ .value=${value}
212
+ style="min-width:50%"
213
+ ></rtg-input>
214
+ <rtg-button
215
+ data-testid="button-id"
216
+ style="margin-inline-start:4px"
217
+ size="default"
218
+ ?disabled=${disabledButton}
219
+ .click=${mockOnClickHandler}
220
+ >${ButtonLabel}</rtg-button
221
+ >
222
+ </div>
223
+ `;
224
+ }
225
+ else if (label && !ButtonLabel) {
226
+ return html `
227
+ <div>
228
+ <rtg-label data-testid="label-id" for="picture">${label}</rtg-label>
229
+ <rtg-input
230
+ data-testid="input-id"
231
+ data-testchild="children-id"
232
+ type=${type}
233
+ ?disabled=${disabled}
234
+ .value=${value}
235
+ style="min-width:50%"
236
+ ></rtg-input>
237
+ </div>
238
+ `;
239
+ }
240
+ else if (label && ButtonLabel) {
241
+ return html `
242
+ <div style="display: flex; flex-direction: column;">
243
+ <rtg-label data-testid="label-id" for="picture">${label}</rtg-label>
244
+ <div style="display:flex">
245
+ <rtg-input
246
+ data-testid="input-id"
247
+ data-testchild="children-id"
248
+ id=${id}
249
+ type=${type}
250
+ ?disabled=${disabled}
251
+ .value=${value}
252
+ style="min-width:50%"
253
+ ></rtg-input>
254
+ <rtg-button
255
+ data-testid="button-id"
256
+ style="margin-inline-start:4px"
257
+ size="default"
258
+ ?disabled=${disabledButton}
259
+ .click=${mockOnClickHandler}
260
+ >${ButtonLabel}</rtg-button
261
+ >
262
+ </div>
263
+ </div>
264
+ `;
265
+ }
266
+ else {
267
+ return html `
268
+ <rtg-input
269
+ data-testid="input-id"
270
+ data-testchild="children-id"
271
+ type=${type}
272
+ ?disabled=${disabled}
273
+ .value=${value}
274
+ style="min-width:50%"
275
+ ></rtg-input>
276
+ `;
277
+ }
278
+ };
279
+ export const Input = Template.bind({});
280
+ Input.args = {
281
+ disabled: false,
282
+ type: 'text',
283
+ placeholder: 'Enter text',
284
+ defaultValue: '',
285
+ label: '',
286
+ ButtonLabel: 'Subscribe',
287
+ disabledButton: false,
288
+ id: '',
289
+ };
290
+ Input.parameters = {
291
+ docs: {
292
+ source: {
293
+ transform: (code) => {
294
+ // Handling boolean attributes: if true, render without value, if false, omit the attribute
295
+ const updatedCode = code
296
+ .replace(/disabled=""/g, 'disabled=true')
297
+ .replace(/disabled="false"/g, '');
298
+ return updatedCode;
299
+ },
300
+ },
301
+ },
302
+ };
303
+ Input.argTypes = {
304
+ disabled: {
305
+ control: 'boolean',
306
+ description: 'Determines whether the input is disabled (unclickable).',
307
+ table: {
308
+ defaultValue: { summary: 'false' },
309
+ },
310
+ },
311
+ disabledButton: {
312
+ control: 'boolean',
313
+ description: 'Indicates whether the button should be disabled, preventing user interaction.',
314
+ table: {
315
+ defaultValue: { summary: 'false' },
316
+ },
317
+ },
318
+ type: {
319
+ control: { type: 'select' },
320
+ description: 'Specifies the type of the input, such as text, email, password, etc.',
321
+ options: validInputTypes,
322
+ },
323
+ placeholder: {
324
+ control: 'text',
325
+ description: 'Provides a short hint that describes the expected value of the input.',
326
+ if: { arg: 'type', neq: 'file' },
327
+ },
328
+ defaultValue: {
329
+ control: 'text',
330
+ description: 'Sets the initial value of the input field.',
331
+ if: { arg: 'type', neq: 'file' },
332
+ },
333
+ label: {
334
+ control: 'text',
335
+ description: 'Defines the label text for the input field.',
336
+ },
337
+ ButtonLabel: {
338
+ control: 'text',
339
+ description: 'Defines the label text for the associated button.',
340
+ },
341
+ id: {
342
+ control: 'text',
343
+ description: 'Unique identifier for the input element.',
344
+ },
345
+ };
346
+ Input.play = async ({ args, canvasElement }) => {
347
+ try {
348
+ await testInputBehavior(args, canvasElement, mockOnClickHandler);
349
+ }
350
+ catch (error) {
351
+ console.error('An error occurred during the play function:', error);
352
+ }
353
+ };
354
+ export const SpecificInput = TemplateSpecific.bind({});
355
+ SpecificInput.args = {
356
+ disabled: false,
357
+ type: 'file',
358
+ label: '',
359
+ ButtonLabel: 'Subscribe',
360
+ disabledButton: false,
361
+ id: '',
362
+ };
363
+ SpecificInput.argTypes = {
364
+ disabled: { control: 'boolean' },
365
+ disabledButton: { control: 'boolean' },
366
+ type: {
367
+ control: { type: 'select' },
368
+ options: validInputSpeceficTypes,
369
+ },
370
+ label: { control: 'text' },
371
+ ButtonLabel: { control: 'text' },
372
+ id: { control: 'text' },
373
+ };
374
+ SpecificInput.play = async ({ args, canvasElement }) => {
375
+ try {
376
+ await testInputSpecificBehavior(args, canvasElement, mockOnClickHandler);
377
+ }
378
+ catch (error) {
379
+ console.error('An error occurred during the play function:', error);
380
+ }
381
+ };
382
+ //# sourceMappingURL=input.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.stories.js","sourceRoot":"","sources":["../../../../../src/components/atoms/input/input.stories.ts"],"names":[],"mappings":"AA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,WAAW,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;IAChC,EAAE,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;CACxB,CAAC;AAEF,aAAa,CAAC,IAAI,GAAG,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE;IACrD,IAAI,CAAC;QACH,MAAM,yBAAyB,CAC7B,IAAyB,EACzB,aAAa,EACb,kBAAkB,CACnB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,6CAA6C,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;AACH,CAAC,CAAC","sourcesContent":["import { html } from 'lit';\nimport { Meta, StoryFn } from '@storybook/web-components';\nimport './input.atom';\nimport '../label/label.atom';\nimport '../button/button.atom';\nimport {\n InputNormalType,\n InputArgs,\n InputSpecificType,\n InputSpecificArgs,\n} from './input.type';\nimport { expect, within, waitFor, fn, userEvent } from '@storybook/test';\n\nconst validInputTypes: InputNormalType[] = [\n 'hidden',\n 'text',\n 'search',\n 'tel',\n 'url',\n 'email',\n 'password',\n];\n\nconst validInputSpeceficTypes: InputSpecificType[] = [\n 'hidden',\n 'date',\n 'month',\n 'week',\n 'time',\n 'datetime-local',\n 'number',\n 'range',\n 'color',\n 'file',\n];\n\nexport default {\n component: 'components/input',\n tags: ['autodocs'],\n} as Meta;\n\nconst testInputBehavior = async (\n args: InputArgs,\n canvasElement: HTMLElement,\n mockHandler: any\n) => {\n const canvas = within(canvasElement);\n const input = await waitFor(() => canvas.getByTestId('input-id'));\n\n if (input.shadowRoot) {\n const innerInput = input.shadowRoot.querySelector(\n '[data-testchild=\"children-id\"]'\n );\n\n if (args.type !== 'file') {\n if (innerInput instanceof HTMLInputElement) {\n innerInput.value = args.defaultValue;\n }\n expect(innerInput).toHaveAttribute('placeholder', args.placeholder);\n }\n\n // 1. Test: Input should have the correct `disabled` state based on args\n if (args.disabled) {\n expect(innerInput).toBeDisabled();\n } else {\n expect(innerInput).not.toBeDisabled();\n }\n\n // 2. Test: `type` should be a valid InputType\n expect(validInputTypes).toContain(args.type);\n\n // 3. Test: Input should have correct type attribute\n expect(innerInput).toHaveAttribute('type', args.type);\n\n // 4. Test: Label should have correct `for` attribute linking to the input\n if (args.label) {\n const label = await waitFor(() => canvas.getByTestId('label-id'));\n expect(label).toBeInTheDocument();\n }\n\n // 5. Button should handle click events when not disabled\n if (args.ButtonLabel) {\n const button = await waitFor(() => canvas.getByTestId('button-id'));\n expect(button).toBeInTheDocument();\n const innerButton = button.querySelector('[data-testid=\"children-id\"]');\n if (!args.disabledButton && innerButton) {\n await userEvent.click(innerButton);\n if (mockHandler) {\n expect(mockHandler).toHaveBeenCalled();\n }\n }\n }\n\n // 6. Test: Button should not handle click events when disabled\n if (args.disabledButton) {\n expect(mockHandler).not.toHaveBeenCalled();\n }\n }\n};\n\nconst testInputSpecificBehavior = async (\n args: InputSpecificArgs,\n canvasElement: HTMLElement,\n mockHandler: any\n) => {\n const canvas = within(canvasElement);\n const input = await waitFor(() => canvas.getByTestId('input-id'));\n\n if (input.shadowRoot) {\n const innerInput = input.shadowRoot.querySelector(\n '[data-testchild=\"children-id\"]'\n );\n\n // 1. Test: Input should have the correct `disabled` state based on args\n if (args.disabled) {\n expect(innerInput).toBeDisabled();\n } else {\n expect(innerInput).not.toBeDisabled();\n }\n\n // 2. Test: `type` should be a valid InputType\n expect(validInputSpeceficTypes).toContain(args.type);\n\n // 3. Test: Input should have correct type attribute\n expect(innerInput).toHaveAttribute('type', args.type);\n\n // 4. Test: Label should have correct `for` attribute linking to the input\n if (args.label) {\n const label = await waitFor(() => canvas.getByTestId('label-id'));\n expect(label).toBeInTheDocument();\n }\n\n // 5. Button should handle click events when not disabled\n if (args.ButtonLabel) {\n const button = await waitFor(() => canvas.getByTestId('button-id'));\n expect(button).toBeInTheDocument();\n const innerButton = button.querySelector('[data-testid=\"children-id\"]');\n if (!args.disabledButton && innerButton) {\n await userEvent.click(innerButton);\n if (mockHandler) {\n expect(mockHandler).toHaveBeenCalled();\n }\n }\n }\n\n // 6. Test: Button should not handle click events when disabled\n if (args.disabledButton) {\n expect(mockHandler).not.toHaveBeenCalled();\n }\n }\n};\n\nconst mockOnClickHandler = fn(event => {\n alert('Hello!');\n});\n\nconst Template: StoryFn = ({\n label,\n ButtonLabel,\n id,\n type,\n placeholder,\n disabled,\n disabledButton,\n defaultValue,\n}) => {\n const inputValue = type !== 'file' ? defaultValue : '';\n if (ButtonLabel && !label) {\n return html`\n <div style=\"display:flex\">\n <rtg-input\n data-testid=\"input-id\"\n data-testchild=\"children-id\"\n id=${id}\n type=${type}\n placeholder=${placeholder}\n ?disabled=${disabled}\n .value=${inputValue}\n style=\"min-width:50%\"\n ></rtg-input>\n <rtg-button\n data-testid=\"button-id\"\n style=\"margin-inline-start:4px\"\n size=\"default\"\n ?disabled=${disabledButton}\n .click=${mockOnClickHandler}\n >${ButtonLabel}</rtg-button\n >\n </div>\n `;\n } else if (label && !ButtonLabel) {\n return html`\n <div>\n <rtg-label data-testid=\"label-id\" for=\"picture\">${label}</rtg-label>\n <rtg-input\n data-testid=\"input-id\"\n data-testchild=\"children-id\"\n type=${type}\n ?disabled=${disabled}\n placeholder=${placeholder}\n .value=${inputValue}\n style=\"min-width:50%\"\n ></rtg-input>\n </div>\n `;\n } else if (label && ButtonLabel) {\n return html`\n <div style=\"display: flex; flex-direction: column;\">\n <rtg-label data-testid=\"label-id\" for=\"picture\">${label}</rtg-label>\n <div style=\"display:flex\">\n <rtg-input\n data-testid=\"input-id\"\n data-testchild=\"children-id\"\n id=${id}\n type=${type}\n placeholder=${placeholder}\n ?disabled=${disabled}\n .value=${inputValue}\n style=\"min-width:50%\"\n ></rtg-input>\n <rtg-button\n data-testid=\"button-id\"\n style=\"margin-inline-start:4px\"\n size=\"default\"\n ?disabled=${disabledButton}\n .click=${mockOnClickHandler}\n >${ButtonLabel}</rtg-button\n >\n </div>\n </div>\n `;\n } else {\n return html`\n <rtg-input\n data-testid=\"input-id\"\n data-testchild=\"children-id\"\n type=${type}\n ?disabled=${disabled}\n placeholder=${placeholder}\n .value=${inputValue}\n style=\"min-width:50%\"\n ></rtg-input>\n `;\n }\n};\n\nconst TemplateSpecific: StoryFn = ({\n label,\n ButtonLabel,\n id,\n type,\n value,\n disabled,\n disabledButton,\n}) => {\n if (ButtonLabel && !label) {\n return html`\n <div style=\"display:flex\">\n <rtg-input\n data-testid=\"input-id\"\n data-testchild=\"children-id\"\n id=${id}\n type=${type}\n ?disabled=${disabled}\n .value=${value}\n style=\"min-width:50%\"\n ></rtg-input>\n <rtg-button\n data-testid=\"button-id\"\n style=\"margin-inline-start:4px\"\n size=\"default\"\n ?disabled=${disabledButton}\n .click=${mockOnClickHandler}\n >${ButtonLabel}</rtg-button\n >\n </div>\n `;\n } else if (label && !ButtonLabel) {\n return html`\n <div>\n <rtg-label data-testid=\"label-id\" for=\"picture\">${label}</rtg-label>\n <rtg-input\n data-testid=\"input-id\"\n data-testchild=\"children-id\"\n type=${type}\n ?disabled=${disabled}\n .value=${value}\n style=\"min-width:50%\"\n ></rtg-input>\n </div>\n `;\n } else if (label && ButtonLabel) {\n return html`\n <div style=\"display: flex; flex-direction: column;\">\n <rtg-label data-testid=\"label-id\" for=\"picture\">${label}</rtg-label>\n <div style=\"display:flex\">\n <rtg-input\n data-testid=\"input-id\"\n data-testchild=\"children-id\"\n id=${id}\n type=${type}\n ?disabled=${disabled}\n .value=${value}\n style=\"min-width:50%\"\n ></rtg-input>\n <rtg-button\n data-testid=\"button-id\"\n style=\"margin-inline-start:4px\"\n size=\"default\"\n ?disabled=${disabledButton}\n .click=${mockOnClickHandler}\n >${ButtonLabel}</rtg-button\n >\n </div>\n </div>\n `;\n } else {\n return html`\n <rtg-input\n data-testid=\"input-id\"\n data-testchild=\"children-id\"\n type=${type}\n ?disabled=${disabled}\n .value=${value}\n style=\"min-width:50%\"\n ></rtg-input>\n `;\n }\n};\n\nexport const Input = Template.bind({});\n\nInput.args = {\n disabled: false,\n type: 'text',\n placeholder: 'Enter text',\n defaultValue: '',\n label: '',\n ButtonLabel: 'Subscribe',\n disabledButton: false,\n id: '',\n};\n\nInput.parameters = {\n docs: {\n source: {\n transform: (code: string) => {\n // Handling boolean attributes: if true, render without value, if false, omit the attribute\n const updatedCode = code\n .replace(/disabled=\"\"/g, 'disabled=true')\n .replace(/disabled=\"false\"/g, '');\n\n return updatedCode;\n },\n },\n },\n};\n\nInput.argTypes = {\n disabled: {\n control: 'boolean',\n description: 'Determines whether the input is disabled (unclickable).',\n table: {\n defaultValue: { summary: 'false' },\n },\n },\n disabledButton: {\n control: 'boolean',\n description:\n 'Indicates whether the button should be disabled, preventing user interaction.',\n table: {\n defaultValue: { summary: 'false' },\n },\n },\n type: {\n control: { type: 'select' },\n description:\n 'Specifies the type of the input, such as text, email, password, etc.',\n options: validInputTypes,\n },\n placeholder: {\n control: 'text',\n description:\n 'Provides a short hint that describes the expected value of the input.',\n if: { arg: 'type', neq: 'file' },\n },\n defaultValue: {\n control: 'text',\n description: 'Sets the initial value of the input field.',\n if: { arg: 'type', neq: 'file' },\n },\n label: {\n control: 'text',\n description: 'Defines the label text for the input field.',\n },\n ButtonLabel: {\n control: 'text',\n description: 'Defines the label text for the associated button.',\n },\n id: {\n control: 'text',\n description: 'Unique identifier for the input element.',\n },\n};\n\nInput.play = async ({ args, canvasElement }) => {\n try {\n await testInputBehavior(\n args as InputArgs,\n canvasElement,\n mockOnClickHandler\n );\n } catch (error) {\n console.error('An error occurred during the play function:', error);\n }\n};\n\nexport const SpecificInput = TemplateSpecific.bind({});\n\nSpecificInput.args = {\n disabled: false,\n type: 'file',\n label: '',\n ButtonLabel: 'Subscribe',\n disabledButton: false,\n id: '',\n};\n\nSpecificInput.argTypes = {\n disabled: { control: 'boolean' },\n disabledButton: { control: 'boolean' },\n type: {\n control: { type: 'select' },\n options: validInputSpeceficTypes,\n },\n label: { control: 'text' },\n ButtonLabel: { control: 'text' },\n id: { control: 'text' },\n};\n\nSpecificInput.play = async ({ args, canvasElement }) => {\n try {\n await testInputSpecificBehavior(\n args as InputSpecificArgs,\n canvasElement,\n mockOnClickHandler\n );\n } catch (error) {\n console.error('An error occurred during the play function:', error);\n }\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export const inputStyles = 'flex h-8 w-full rounded-sm border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-50 input-base';
2
+ //# sourceMappingURL=input.styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.styles.js","sourceRoot":"","sources":["../../../../../src/components/atoms/input/input.styles.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GACtB,sTAAsT,CAAC","sourcesContent":["export const inputStyles =\n 'flex h-8 w-full rounded-sm border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:opacity-50 input-base';\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=input.type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.type.js","sourceRoot":"","sources":["../../../../../src/components/atoms/input/input.type.ts"],"names":[],"mappings":"","sourcesContent":["export type InputType =\n | 'hidden'\n | 'text'\n | 'search'\n | 'tel'\n | 'url'\n | 'email'\n | 'password'\n | 'date'\n | 'month'\n | 'week'\n | 'time'\n | 'datetime-local'\n | 'number'\n | 'range'\n | 'color'\n | 'file';\n\nexport type InputNormalType =\n | 'hidden'\n | 'text'\n | 'search'\n | 'tel'\n | 'url'\n | 'email'\n | 'password';\n\nexport type InputSpecificType =\n | 'hidden'\n | 'date'\n | 'month'\n | 'week'\n | 'time'\n | 'datetime-local'\n | 'number'\n | 'range'\n | 'color'\n | 'file';\n\nexport type InputArgs = {\n disabled: boolean;\n disabledButton: boolean;\n type: InputType;\n placeholder: string;\n label: string;\n defaultValue: string;\n ButtonLabel: string;\n id: string;\n};\n\nexport type InputSpecificArgs = {\n disabled: boolean;\n disabledButton: boolean;\n type: InputSpecificType;\n label: string;\n ButtonLabel: string;\n id: string;\n};\n"]}
@@ -0,0 +1,68 @@
1
+ var Label_1;
2
+ import { __decorate } from "tslib";
3
+ import { html, css } from 'lit';
4
+ import { property, customElement } from 'lit/decorators.js';
5
+ import { BaseElement, cn } from '../../../helpers';
6
+ import { TWStyles } from '../../../styles';
7
+ import { labelStyle } from './label.style';
8
+ import { spread } from '@open-wc/lit-helpers';
9
+ let Label = Label_1 = class Label extends BaseElement {
10
+ constructor() {
11
+ super(...arguments);
12
+ this.for = '';
13
+ }
14
+ firstUpdated(_changedProperties) {
15
+ const variables = ['--label-text-color,--label-padding'];
16
+ this.applyCustomClass(variables, 'label', 'label-base');
17
+ }
18
+ _onClick(e) {
19
+ var _a;
20
+ if (e.defaultPrevented)
21
+ return;
22
+ const target = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById(this.for);
23
+ if (target) {
24
+ target.click();
25
+ }
26
+ }
27
+ getAttributesToExclude() {
28
+ return ['for', 'data-testid'];
29
+ }
30
+ render() {
31
+ const attributes = this.getFilteredAttributes();
32
+ return html `
33
+ <label
34
+ for="${this.for}"
35
+ @click="${this._onClick}"
36
+ @keydown="${this._onClick}"
37
+ class="${cn(Label_1.labelVariants({
38
+ className: this.className,
39
+ }))}"
40
+ ${spread(attributes)}
41
+ >
42
+ <slot></slot>
43
+ </label>
44
+ `;
45
+ }
46
+ };
47
+ Label.labelVariants = labelStyle;
48
+ Label.styles = [
49
+ css `
50
+ :root {
51
+ --label-text-color: inherit;
52
+ --label-padding: inherit;
53
+ }
54
+ .label-base {
55
+ color: var(--label-text-color) !important;
56
+ padding: var(--label-padding) !important;
57
+ }
58
+ `,
59
+ TWStyles,
60
+ ];
61
+ __decorate([
62
+ property({ type: String })
63
+ ], Label.prototype, "for", void 0);
64
+ Label = Label_1 = __decorate([
65
+ customElement('rtg-label')
66
+ ], Label);
67
+ export { Label };
68
+ //# sourceMappingURL=label.atom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label.atom.js","sourceRoot":"","sources":["../../../../../src/components/atoms/label/label.atom.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAc,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAGvC,IAAM,KAAK,aAAX,MAAM,KAAM,SAAQ,WAAW;IAA/B;;QAGuB,QAAG,GAAG,EAAE,CAAC;IAoDvC,CAAC;IApCW,YAAY,CAAC,kBAAkC;QACvD,MAAM,SAAS,GAAG,CAAC,oCAAoC,CAAC,CAAC;QACzD,IAAI,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC;IAC1D,CAAC;IAEO,QAAQ,CAAC,CAAQ;;QACvB,IAAI,CAAC,CAAC,gBAAgB;YAAE,OAAO;QAC/B,MAAM,MAAM,GAAG,MAAA,IAAI,CAAC,UAAU,0CAAE,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACzD,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;IACH,CAAC;IAES,sBAAsB;QAC9B,OAAO,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;IAChC,CAAC;IAED,MAAM;QACJ,MAAM,UAAU,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAC;QAEhD,OAAO,IAAI,CAAA;;eAEA,IAAI,CAAC,GAAG;kBACL,IAAI,CAAC,QAAQ;oBACX,IAAI,CAAC,QAAQ;iBAChB,EAAE,CACT,OAAK,CAAC,aAAa,CAAC;YAClB,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CACH;UACC,MAAM,CAAC,UAAU,CAAC;;;;KAIvB,CAAC;IACJ,CAAC;;AArDM,mBAAa,GAAG,UAAU,AAAb,CAAc;AAI3B,YAAM,GAAG;IACd,GAAG,CAAA;;;;;;;;;KASF;IACD,QAAQ;CACT,AAZY,CAYX;AAd0B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kCAAU;AAH1B,KAAK;IADjB,aAAa,CAAC,WAAW,CAAC;GACd,KAAK,CAuDjB","sourcesContent":["import { LitElement, html, css, PropertyValues } from 'lit';\nimport { property, customElement } from 'lit/decorators.js';\nimport { BaseElement, cn } from '../../../helpers';\nimport { TWStyles } from '../../../styles';\nimport { labelStyle } from './label.style';\nimport { spread } from '@open-wc/lit-helpers';\n\n@customElement('rtg-label')\nexport class Label extends BaseElement {\n static labelVariants = labelStyle;\n\n @property({ type: String }) for = '';\n\n static styles = [\n css`\n :root {\n --label-text-color: inherit;\n --label-padding: inherit;\n }\n .label-base {\n color: var(--label-text-color) !important;\n padding: var(--label-padding) !important;\n }\n `,\n TWStyles,\n ];\n\n protected firstUpdated(_changedProperties: PropertyValues): void {\n const variables = ['--label-text-color,--label-padding'];\n this.applyCustomClass(variables, 'label', 'label-base');\n }\n\n private _onClick(e: Event) {\n if (e.defaultPrevented) return;\n const target = this.shadowRoot?.getElementById(this.for);\n if (target) {\n target.click();\n }\n }\n\n protected getAttributesToExclude(): string[] {\n return ['for', 'data-testid'];\n }\n\n render() {\n const attributes = this.getFilteredAttributes();\n\n return html`\n <label\n for=\"${this.for}\"\n @click=\"${this._onClick}\"\n @keydown=\"${this._onClick}\"\n class=\"${cn(\n Label.labelVariants({\n className: this.className,\n })\n )}\"\n ${spread(attributes)}\n >\n <slot></slot>\n </label>\n `;\n }\n}\n"]}
@@ -0,0 +1,85 @@
1
+ import { html } from 'lit';
2
+ import './label.atom';
3
+ import { expect, within, fn, waitFor, userEvent } from '@storybook/test';
4
+ import { Label } from './label.atom';
5
+ // Label Test Behavior
6
+ const testLabelBehavior = async (args, canvasElement, mockHandler) => {
7
+ const canvas = within(canvasElement);
8
+ const label = await waitFor(() => canvas.getByTestId('label-id'));
9
+ if (label.shadowRoot) {
10
+ const innerLabel = label.shadowRoot.querySelector('label') || '';
11
+ // 1. Test: Label should have correct "for" attribute
12
+ expect(label).toHaveAttribute('for', args.for);
13
+ // 2. Test: Label should apply correct variant classes
14
+ const expectedClasses = Label.labelVariants({
15
+ className: '',
16
+ });
17
+ expect(innerLabel).toHaveClass(expectedClasses);
18
+ // 3. Test: Label should trigger associated input's click when clicked
19
+ if (!args.disabled) {
20
+ const targetInput = document.createElement('input');
21
+ targetInput.id = args.for;
22
+ label.shadowRoot.appendChild(targetInput);
23
+ targetInput.click = fn(); // Mock click behavior for test
24
+ await userEvent.click(innerLabel);
25
+ expect(targetInput.click).toHaveBeenCalled();
26
+ label.shadowRoot.removeChild(targetInput); // Clean up
27
+ }
28
+ // 4. Test: Ensure that label doesn't trigger input click when default is prevented
29
+ const event = new Event('click', { cancelable: true });
30
+ label.dispatchEvent(event);
31
+ if (!event.defaultPrevented) {
32
+ await userEvent.click(innerLabel);
33
+ expect(mockHandler).not.toHaveBeenCalled(); // should not trigger if default prevented
34
+ }
35
+ }
36
+ };
37
+ export default {
38
+ title: 'components/atoms/label',
39
+ tags: ['autodocs'],
40
+ argTypes: {
41
+ label: {
42
+ type: 'string',
43
+ description: 'The text to display on the label.',
44
+ table: {
45
+ defaultValue: { summary: '' },
46
+ },
47
+ },
48
+ for: {
49
+ type: 'string',
50
+ description: "The text that the label is describing. This is typically the ID of the input element it's labeling.",
51
+ table: {
52
+ defaultValue: { summary: '' },
53
+ },
54
+ },
55
+ },
56
+ };
57
+ const Template = (args) => html ` <rtg-label
58
+ data-testchild="children-id"
59
+ data-testid="label-id"
60
+ for=${args.for}
61
+ >${args.label}</rtg-label
62
+ >`;
63
+ const HtmlForTemplate = (args) => html ` <rtg-label
64
+ data-testchild="children-id"
65
+ data-testid="label-id"
66
+ for=${args.for}
67
+ >
68
+ ${args.label}
69
+ <input type="text" id=${args.for} />
70
+ </rtg-label>`;
71
+ export const Default = Template.bind({});
72
+ export const HtmlFor = HtmlForTemplate.bind({});
73
+ Default.args = {
74
+ for: 'id',
75
+ label: 'Email address',
76
+ };
77
+ HtmlFor.args = {
78
+ for: 'id',
79
+ label: 'Email address',
80
+ };
81
+ Default.play = async ({ args, canvasElement }) => {
82
+ const mockHandler = fn();
83
+ await testLabelBehavior(args, canvasElement, mockHandler);
84
+ };
85
+ //# sourceMappingURL=label.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label.stories.js","sourceRoot":"","sources":["../../../../../src/components/atoms/label/label.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,OAAO,cAAc,CAAC;AAEtB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,sBAAsB;AACtB,MAAM,iBAAiB,GAAG,KAAK,EAC7B,IAAS,EACT,aAAkB,EAClB,WAAgB,EAChB,EAAE;IACF,MAAM,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAAC;IAClE,IAAI,KAAK,CAAC,UAAU,EAAE,CAAC;QACrB,MAAM,UAAU,GACd,KAAK,CAAC,UAAU,CAAC,aAAa,CA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lit';\nimport { Meta, StoryFn } from '@storybook/web-components';\nimport './label.atom';\n\nimport { expect, within, fn, waitFor, userEvent } from '@storybook/test';\nimport { Label } from './label.atom';\n\n// Label Test Behavior\nconst testLabelBehavior = async (\n args: any,\n canvasElement: any,\n mockHandler: any\n) => {\n const canvas = within(canvasElement);\n const label = await waitFor(() => canvas.getByTestId('label-id'));\n if (label.shadowRoot) {\n const innerLabel =\n label.shadowRoot.querySelector('label') || ('' as unknown as Element);\n // 1. Test: Label should have correct \"for\" attribute\n expect(label).toHaveAttribute('for', args.for);\n\n // 2. Test: Label should apply correct variant classes\n const expectedClasses = Label.labelVariants({\n className: '',\n });\n expect(innerLabel).toHaveClass(expectedClasses);\n\n // 3. Test: Label should trigger associated input's click when clicked\n if (!args.disabled) {\n const targetInput = document.createElement('input');\n targetInput.id = args.for;\n label.shadowRoot.appendChild(targetInput);\n targetInput.click = fn(); // Mock click behavior for test\n await userEvent.click(innerLabel);\n expect(targetInput.click).toHaveBeenCalled();\n label.shadowRoot.removeChild(targetInput); // Clean up\n }\n\n // 4. Test: Ensure that label doesn't trigger input click when default is prevented\n const event = new Event('click', { cancelable: true });\n label.dispatchEvent(event);\n if (!event.defaultPrevented) {\n await userEvent.click(innerLabel);\n expect(mockHandler).not.toHaveBeenCalled(); // should not trigger if default prevented\n }\n }\n};\n\nexport default {\n title: 'components/atoms/label',\n tags: ['autodocs'],\n argTypes: {\n label: {\n type: 'string',\n description: 'The text to display on the label.',\n table: {\n defaultValue: { summary: '' },\n },\n },\n for: {\n type: 'string',\n description:\n \"The text that the label is describing. This is typically the ID of the input element it's labeling.\",\n table: {\n defaultValue: { summary: '' },\n },\n },\n },\n} as Meta;\n\nconst Template: StoryFn = (args: any) =>\n html` <rtg-label\n data-testchild=\"children-id\"\n data-testid=\"label-id\"\n for=${args.for}\n >${args.label}</rtg-label\n >`;\n\nconst HtmlForTemplate: StoryFn = (args: any) =>\n html` <rtg-label\n data-testchild=\"children-id\"\n data-testid=\"label-id\"\n for=${args.for}\n >\n ${args.label}\n <input type=\"text\" id=${args.for} />\n </rtg-label>`;\nexport const Default = Template.bind({});\nexport const HtmlFor = HtmlForTemplate.bind({});\n\nDefault.args = {\n for: 'id',\n label: 'Email address',\n};\nHtmlFor.args = {\n for: 'id',\n label: 'Email address',\n};\nDefault.play = async ({ args, canvasElement }) => {\n const mockHandler = fn();\n await testLabelBehavior(args, canvasElement, mockHandler);\n};\n"]}
@@ -0,0 +1,3 @@
1
+ import { cva } from 'class-variance-authority';
2
+ export const labelStyle = cva('text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70');
3
+ //# sourceMappingURL=label.style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"label.style.js","sourceRoot":"","sources":["../../../../../src/components/atoms/label/label.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE/C,MAAM,CAAC,MAAM,UAAU,GAAG,GAAG,CAC3B,4FAA4F,CAC7F,CAAC","sourcesContent":["import { cva } from 'class-variance-authority';\n\nexport const labelStyle = cva(\n 'text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70'\n);\n"]}