revotech-ui-kit 0.0.2 → 0.0.3-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 +1 -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,64 @@
1
+ import { __decorate } from "tslib";
2
+ import { LitElement, html, css } from 'lit';
3
+ import { customElement, property } from 'lit/decorators.js';
4
+ import { popoverContentStyle } from './popover.style'; // Import the cva styles
5
+ import { TWStyles } from '../../../styles';
6
+ import { Popover } from './popover.atom';
7
+ import { cn } from '../../../helpers';
8
+ let PopoverContent = class PopoverContent extends LitElement {
9
+ constructor() {
10
+ super(...arguments);
11
+ this.side = 'bottom';
12
+ }
13
+ get _popover() {
14
+ let parent = this.parentElement;
15
+ // Traverse up the DOM tree to find the parent `Popover`
16
+ while (parent && !(parent instanceof Popover)) {
17
+ parent = parent.parentElement;
18
+ }
19
+ return parent;
20
+ }
21
+ handleClickOutside(event) {
22
+ var _a, _b;
23
+ // Check if the click was outside the popover
24
+ const slot = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot');
25
+ if (slot) {
26
+ const assignedElements = slot.assignedElements({ flatten: true });
27
+ console.log(assignedElements[0]);
28
+ if (!((_b = assignedElements[0]) === null || _b === void 0 ? void 0 : _b.contains(event.target))) {
29
+ const popover = this._popover; // Get the parent popover
30
+ //@ts-ignore
31
+ popover.isOpen = false;
32
+ }
33
+ }
34
+ }
35
+ firstUpdated(_changedProperties) {
36
+ window.addEventListener('click', this.handleClickOutside.bind(this));
37
+ }
38
+ updated(_changedProperties) {
39
+ var _a;
40
+ if (!((_a = this._popover) === null || _a === void 0 ? void 0 : _a.isOpen)) {
41
+ window.removeEventListener('click', this.handleClickOutside.bind(this));
42
+ }
43
+ }
44
+ render() {
45
+ const classes = popoverContentStyle({
46
+ state: 'open',
47
+ side: this.side,
48
+ });
49
+ return html `
50
+ <div class="${cn(classes)}">
51
+ <slot></slot>
52
+ </div>
53
+ `;
54
+ }
55
+ };
56
+ PopoverContent.styles = [css ``, TWStyles];
57
+ __decorate([
58
+ property({ type: String })
59
+ ], PopoverContent.prototype, "side", void 0);
60
+ PopoverContent = __decorate([
61
+ customElement('rtg-popover-content')
62
+ ], PopoverContent);
63
+ export { PopoverContent };
64
+ //# sourceMappingURL=popover-content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover-content.js","sourceRoot":"","sources":["../../../../../src/components/atoms/popover/popover-content.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC,CAAC,wBAAwB;AAC/E,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAG/B,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAAvC;;QAWuB,SAAI,GAC9B,QAAQ,CAAC;IAqCb,CAAC;IA/CC,IAAI,QAAQ;QACV,IAAI,MAAM,GAAG,IAA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C,KAAK,EAAE,MAAM;YACb,IAAI,EAAE,IAAI,CAAC,IAAI;SAChB,CAAC,CAAC;QAEH,OAAO,IAAI,CAAA;oBACK,EAAE,CAAC,OAAO,CAAC;;;KAG1B,CAAC;IACJ,CAAC;;AA/CM,qBAAM,GAAG,CAAC,GAAG,CAAA,EAAE,EAAE,QAAQ,CAAC,AAApB,CAAqB;AAUN;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAChB;AAZA,cAAc;IAD1B,aAAa,CAAC,qBAAqB,CAAC;GACxB,cAAc,CAiD1B","sourcesContent":["import { LitElement, html, css, PropertyValues } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { popoverContentStyle } from './popover.style'; // Import the cva styles\nimport { TWStyles } from '../../../styles';\nimport { Popover } from './popover.atom';\nimport { cn } from '../../../helpers';\n\n@customElement('rtg-popover-content')\nexport class PopoverContent extends LitElement {\n static styles = [css``, TWStyles];\n get _popover(): Popover | null {\n let parent = this.parentElement;\n // Traverse up the DOM tree to find the parent `Popover`\n while (parent && !(parent instanceof Popover)) {\n parent = parent.parentElement;\n }\n return parent;\n }\n\n @property({ type: String }) side: 'bottom' | 'left' | 'right' | 'top' =\n 'bottom';\n private handleClickOutside(event: MouseEvent) {\n // Check if the click was outside the popover\n const slot = this.shadowRoot?.querySelector('slot');\n if (slot) {\n const assignedElements = slot.assignedElements({ flatten: true });\n console.log(assignedElements[0]);\n if (!assignedElements[0]?.contains(event.target as Node)) {\n const popover = this._popover; // Get the parent popover\n //@ts-ignore\n popover.isOpen = false;\n }\n }\n }\n\n protected firstUpdated(_changedProperties: PropertyValues): void {\n window.addEventListener('click', this.handleClickOutside.bind(this));\n }\n\n protected updated(_changedProperties: PropertyValues): void {\n if (!this._popover?.isOpen) {\n window.removeEventListener('click', this.handleClickOutside.bind(this));\n }\n }\n\n render() {\n const classes = popoverContentStyle({\n state: 'open',\n side: this.side,\n });\n\n return html`\n <div class=\"${cn(classes)}\">\n <slot></slot>\n </div>\n `;\n }\n}\n"]}
@@ -0,0 +1,51 @@
1
+ import { __decorate } from "tslib";
2
+ import { LitElement, html, css } from 'lit';
3
+ import { customElement } from 'lit/decorators.js';
4
+ import { TWStyles } from '../../../styles';
5
+ import { Popover } from './popover.atom'; // Import the correct parent component
6
+ let PopoverTrigger = class PopoverTrigger extends LitElement {
7
+ constructor() {
8
+ super(...arguments);
9
+ this.handleClick = () => {
10
+ const popover = this._popover; // Get the parent popover
11
+ if (popover) {
12
+ popover.isOpen = !popover.isOpen;
13
+ }
14
+ };
15
+ }
16
+ firstUpdated(_changedProperties) {
17
+ var _a, _b;
18
+ super.firstUpdated(_changedProperties);
19
+ const slots = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot[name="trigger-button"]');
20
+ const assignedElements = slots === null || slots === void 0 ? void 0 : slots.assignedElements({ flatten: true });
21
+ if (assignedElements && assignedElements.length > 0) {
22
+ //@ts-ignore
23
+ assignedElements[0].click = this.handleClick;
24
+ // assignedElements[0].addEventListener('click', this.handleClick);
25
+ }
26
+ (_b = this.shadowRoot) === null || _b === void 0 ? void 0 : _b.addEventListener('click', e => {
27
+ e.stopPropagation();
28
+ });
29
+ }
30
+ get _popover() {
31
+ let parent = this.parentElement;
32
+ // Traverse up the DOM tree to find the parent `Popover`
33
+ while (parent && !(parent instanceof Popover)) {
34
+ parent = parent.parentElement;
35
+ }
36
+ return parent;
37
+ }
38
+ render() {
39
+ return html `
40
+ <div style="width: fit-content;">
41
+ <slot name="trigger-button"></slot>
42
+ </div>
43
+ `;
44
+ }
45
+ };
46
+ PopoverTrigger.styles = [css ``, TWStyles];
47
+ PopoverTrigger = __decorate([
48
+ customElement('rtg-popover-trigger') // Rename the custom element tag to avoid conflict
49
+ ], PopoverTrigger);
50
+ export { PopoverTrigger };
51
+ //# sourceMappingURL=popover-trigger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover-trigger.js","sourceRoot":"","sources":["../../../../../src/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AG,IAAI,CAAC,aAAa,CAAC;QAChC,wDAAwD;QACxD,OAAO,MAAM,IAAI,CAAC,CAAC,MAAM,YAAY,OAAO,CAAC,EAAE,CAAC;YAC9C,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC;QAChC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;;;KAIV,CAAC;IACJ,CAAC;;AAzCM,qBAAM,GAAG,CAAC,GAAG,CAAA,EAAE,EAAE,QAAQ,CAAC,AAApB,CAAqB;AADvB,cAAc;IAD1B,aAAa,CAAC,qBAAqB,CAAC,CAAC,kDAAkD;GAC3E,cAAc,CA2C1B","sourcesContent":["import { LitElement, html, css, PropertyValues } from 'lit';\nimport { customElement } from 'lit/decorators.js';\nimport { TWStyles } from '../../../styles';\nimport { Popover } from './popover.atom'; // Import the correct parent component\n\n@customElement('rtg-popover-trigger') // Rename the custom element tag to avoid conflict\nexport class PopoverTrigger extends LitElement {\n static styles = [css``, TWStyles];\n\n handleClick = () => {\n const popover = this._popover; // Get the parent popover\n if (popover) {\n popover.isOpen = !popover.isOpen;\n }\n };\n\n protected firstUpdated(_changedProperties: PropertyValues): void {\n super.firstUpdated(_changedProperties);\n const slots = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger-button\"]'\n ) as HTMLSlotElement;\n const assignedElements = slots?.assignedElements({ flatten: true });\n if (assignedElements && assignedElements.length > 0) {\n //@ts-ignore\n assignedElements[0].click = this.handleClick;\n // assignedElements[0].addEventListener('click', this.handleClick);\n }\n\n this.shadowRoot?.addEventListener('click', e => {\n e.stopPropagation();\n });\n }\n\n get _popover(): Popover | null {\n let parent = this.parentElement;\n // Traverse up the DOM tree to find the parent `Popover`\n while (parent && !(parent instanceof Popover)) {\n parent = parent.parentElement;\n }\n return parent;\n }\n\n render() {\n return html`\n <div style=\"width: fit-content;\">\n <slot name=\"trigger-button\"></slot>\n </div>\n `;\n }\n}\n"]}
@@ -0,0 +1,40 @@
1
+ import { __decorate } from "tslib";
2
+ import { LitElement, html, css } from 'lit';
3
+ import { customElement, state } from 'lit/decorators.js';
4
+ import { TWStyles } from '../../../styles';
5
+ let Popover = class Popover extends LitElement {
6
+ constructor() {
7
+ super(...arguments);
8
+ this.isOpen = false;
9
+ }
10
+ firstUpdated(_changedProperties) {
11
+ super.firstUpdated(_changedProperties);
12
+ // Add event listener for clicks outside the popover
13
+ }
14
+ updated(_changedProperties) {
15
+ super.updated(_changedProperties);
16
+ // Remove event listener when the popover is closed
17
+ }
18
+ render() {
19
+ return html `
20
+ <div>
21
+ <slot
22
+ name="trigger"
23
+ @click="${() => (this.isOpen = !this.isOpen)}"
24
+ ></slot>
25
+ <div data-testid="popover-content-holder" ?hidden="${!this.isOpen}">
26
+ <slot name="content"></slot>
27
+ </div>
28
+ </div>
29
+ `;
30
+ }
31
+ };
32
+ Popover.styles = [css ``, TWStyles];
33
+ __decorate([
34
+ state()
35
+ ], Popover.prototype, "isOpen", void 0);
36
+ Popover = __decorate([
37
+ customElement('rtg-popover')
38
+ ], Popover);
39
+ export { Popover };
40
+ //# sourceMappingURL=popover.atom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover.atom.js","sourceRoot":"","sources":["../../../../../src/components/atoms/popover/popover.atom.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGpC,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,UAAU;IAAhC;;QAGI,WAAM,GAAY,KAAK,CAAC;IAyBnC,CAAC;IAvBW,YAAY,CAAC,kBAAkC;QACvD,KAAK,CAAC,YAAY,CAAC,kBAAkB,CAAC,CAAC;QACvC,oDAAoD;IACtD,CAAC;IAES,OAAO,CAAC,kBAAkC;QAClD,KAAK,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAClC,mDAAmD;IACrD,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA;;;;oBAIK,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC;;6DAEO,CAAC,IAAI,CAAC,MAAM;;;;KAIpE,CAAC;IACJ,CAAC;;AA1BM,cAAM,GAAG,CAAC,GAAG,CAAA,EAAE,EAAE,QAAQ,CAAC,AAApB,CAAqB;AAEzB;IAAR,KAAK,EAAE;uCAAyB;AAHtB,OAAO;IADnB,aAAa,CAAC,aAAa,CAAC;GAChB,OAAO,CA4BnB","sourcesContent":["import { LitElement, html, css, PropertyValues } from 'lit';\nimport { customElement, state } from 'lit/decorators.js';\nimport { TWStyles } from '../../../styles';\n\n@customElement('rtg-popover')\nexport class Popover extends LitElement {\n static styles = [css``, TWStyles];\n\n @state() isOpen: boolean = false;\n\n protected firstUpdated(_changedProperties: PropertyValues): void {\n super.firstUpdated(_changedProperties);\n // Add event listener for clicks outside the popover\n }\n\n protected updated(_changedProperties: PropertyValues): void {\n super.updated(_changedProperties);\n // Remove event listener when the popover is closed\n }\n\n render() {\n return html`\n <div>\n <slot\n name=\"trigger\"\n @click=\"${() => (this.isOpen = !this.isOpen)}\"\n ></slot>\n <div data-testid=\"popover-content-holder\" ?hidden=\"${!this.isOpen}\">\n <slot name=\"content\"></slot>\n </div>\n </div>\n `;\n }\n}\n"]}
@@ -0,0 +1,69 @@
1
+ import { html } from 'lit';
2
+ import './popover.atom';
3
+ import './popover-trigger';
4
+ import './popover-content';
5
+ import '../button/button.atom';
6
+ import '../label/label.atom';
7
+ import '../input/input.atom';
8
+ import { expect, within, userEvent } from '@storybook/test';
9
+ // Create a test to ensure the popover opens and closes correctly
10
+ const testPopoverBehavior = async (args, canvasElement) => {
11
+ const canvas = within(canvasElement);
12
+ // Click on the trigger button to open the popover
13
+ const trigger = await canvas.getByText(args.triggerLabel);
14
+ await userEvent.click(trigger);
15
+ // Ensure the popover content is visible
16
+ const popoverContent = await canvas.getByTestId('popover-content');
17
+ expect(popoverContent).toBeVisible();
18
+ // Click inside the popover content, it should remain open
19
+ await userEvent.click(popoverContent);
20
+ expect(popoverContent).toBeVisible();
21
+ // Click outside the popover, it should close
22
+ await userEvent.click(document.body); // Trigger a click outside
23
+ await new Promise(r => setTimeout(r, 100)); // Wait for state update
24
+ // Check if popover content is hidden
25
+ const hiddenPopoverContent = canvas.queryByTestId('popover-content-holder');
26
+ expect(hiddenPopoverContent).toBeNull();
27
+ };
28
+ export default {
29
+ title: 'components/atoms/popover',
30
+ component: 'rtg-popover',
31
+ tags: ['autodocs'],
32
+ argTypes: {
33
+ triggerLabel: { control: 'text', defaultValue: 'Click me' },
34
+ popoverContent: {
35
+ control: 'text',
36
+ defaultValue: 'This is the content inside the popover.',
37
+ },
38
+ },
39
+ };
40
+ const Template = (args) => html `
41
+ <rtg-popover>
42
+ <!-- Trigger to open/close the popover -->
43
+ <rtg-popover-trigger slot="trigger">
44
+ <rtg-button variant="outline" slot="trigger-button"
45
+ >${args.triggerLabel}</rtg-button
46
+ >
47
+ </rtg-popover-trigger>
48
+
49
+ <!-- Popover content that will be shown or hidden -->
50
+ <rtg-popover-content
51
+ data-side="bottom"
52
+ data-testid="popover-content"
53
+ slot="content"
54
+ >
55
+ <div>
56
+ <p>${args.popoverContent}</p>
57
+ </div>
58
+ </rtg-popover-content>
59
+ </rtg-popover>
60
+ `;
61
+ export const Default = Template.bind({});
62
+ Default.args = {
63
+ triggerLabel: 'Click me',
64
+ popoverContent: 'This is the content inside the popover.',
65
+ };
66
+ Default.play = async ({ canvasElement }) => {
67
+ await testPopoverBehavior(Default.args, canvasElement);
68
+ };
69
+ //# sourceMappingURL=popover.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover.stories.js","sourceRoot":"","sources":["../../../../../src/components/atoms/popover/popover.stories.ts"],"names":[],"mappings":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AEF,eAAe;IACb,KAAK,EAAE,0BAA0B;IACjC,SAAS,EAAE,aAAa;IACxB,IAAI,EAAE,CAAC,UAAU,CAAC;IAClB,QAAQ,EAAE;QACR,YAAY,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,UAAU,EAAE;QAC3D,cAAc,EAAE;YACd,OAAO,EAAE,MAAM;YACf,YAAY,EAAE,yCAAyC;SACxD;KACF;CACM,CAAC;AAEV,MAAM,QAAQ,GAAY,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAA;;;;;WAKlC,IAAI,CAAC,YAAY;;;;;;;;;;;aAWf,IAAI,CAAC,cAAc;;;;CAI/B,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACzC,OAAO,CAAC,IAAI,GAAG;IACb,YAAY,EAAE,UAAU;IACxB,cAAc,EAAE,yCAAyC;CAC1D,CAAC;AACF,OAAO,CAAC,IAAI,GAAG,KAAK,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE;IACzC,MAAM,mBAAmB,CAAC,OAAO,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;AACzD,CAAC,CAAC","sourcesContent":["import { html } from 'lit';\nimport { Meta, StoryFn } from '@storybook/web-components';\nimport './popover.atom';\nimport './popover-trigger';\nimport './popover-content';\nimport '../button/button.atom';\nimport '../label/label.atom';\nimport '../input/input.atom';\n\nimport { expect, within, userEvent } from '@storybook/test';\n\n// Create a test to ensure the popover opens and closes correctly\nconst testPopoverBehavior = async (args: any, canvasElement: any) => {\n const canvas = within(canvasElement);\n\n // Click on the trigger button to open the popover\n const trigger = await canvas.getByText(args.triggerLabel);\n await userEvent.click(trigger);\n\n // Ensure the popover content is visible\n const popoverContent = await canvas.getByTestId('popover-content');\n expect(popoverContent).toBeVisible();\n\n // Click inside the popover content, it should remain open\n await userEvent.click(popoverContent);\n expect(popoverContent).toBeVisible();\n\n // Click outside the popover, it should close\n await userEvent.click(document.body); // Trigger a click outside\n await new Promise(r => setTimeout(r, 100)); // Wait for state update\n\n // Check if popover content is hidden\n const hiddenPopoverContent = canvas.queryByTestId('popover-content-holder');\n expect(hiddenPopoverContent).toBeNull();\n};\n\nexport default {\n title: 'components/atoms/popover',\n component: 'rtg-popover',\n tags: ['autodocs'],\n argTypes: {\n triggerLabel: { control: 'text', defaultValue: 'Click me' },\n popoverContent: {\n control: 'text',\n defaultValue: 'This is the content inside the popover.',\n },\n },\n} as Meta;\n\nconst Template: StoryFn = (args: any) => html`\n <rtg-popover>\n <!-- Trigger to open/close the popover -->\n <rtg-popover-trigger slot=\"trigger\">\n <rtg-button variant=\"outline\" slot=\"trigger-button\"\n >${args.triggerLabel}</rtg-button\n >\n </rtg-popover-trigger>\n\n <!-- Popover content that will be shown or hidden -->\n <rtg-popover-content\n data-side=\"bottom\"\n data-testid=\"popover-content\"\n slot=\"content\"\n >\n <div>\n <p>${args.popoverContent}</p>\n </div>\n </rtg-popover-content>\n </rtg-popover>\n`;\n\nexport const Default = Template.bind({});\nDefault.args = {\n triggerLabel: 'Click me',\n popoverContent: 'This is the content inside the popover.',\n};\nDefault.play = async ({ canvasElement }) => {\n await testPopoverBehavior(Default.args, canvasElement);\n};\n"]}
@@ -0,0 +1,21 @@
1
+ import { cva } from 'class-variance-authority';
2
+ export const popoverRootStyle = cva('rtgpop-root');
3
+ export const popoverContentStyle = cva('z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none transition-transform transition-opacity', {
4
+ variants: {
5
+ state: {
6
+ open: 'opacity-100 scale-100 duration-500', // 0.5 seconds for the transition
7
+ closed: 'opacity-0 scale-95 duration-500', // 0.5 seconds for the transition
8
+ },
9
+ side: {
10
+ bottom: 'translate-y-0',
11
+ left: 'translate-x-0',
12
+ right: 'translate-x-0',
13
+ top: 'translate-y-0',
14
+ },
15
+ },
16
+ defaultVariants: {
17
+ state: 'closed',
18
+ side: 'bottom',
19
+ },
20
+ });
21
+ //# sourceMappingURL=popover.style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover.style.js","sourceRoot":"","sources":["../../../../../src/components/atoms/popover/popover.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,0BAA0B,CAAC;AAE/C,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC,aAAa,CAAC,CAAC;AAEnD,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CACpC,mIAAmI,EACnI;IACE,QAAQ,EAAE;QACR,KAAK,EAAE;YACL,IAAI,EAAE,oCAAoC,EAAE,iCAAiC;YAC7E,MAAM,EAAE,iCAAiC,EAAE,iCAAiC;SAC7E;QACD,IAAI,EAAE;YACJ,MAAM,EAAE,eAAe;YACvB,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE,eAAe;YACtB,GAAG,EAAE,eAAe;SACrB;KACF;IACD,eAAe,EAAE;QACf,KAAK,EAAE,QAAQ;QACf,IAAI,EAAE,QAAQ;KACf;CACF,CACF,CAAC","sourcesContent":["import { cva } from 'class-variance-authority';\n\nexport const popoverRootStyle = cva('rtgpop-root');\n\nexport const popoverContentStyle = cva(\n 'z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none transition-transform transition-opacity',\n {\n variants: {\n state: {\n open: 'opacity-100 scale-100 duration-500', // 0.5 seconds for the transition\n closed: 'opacity-0 scale-95 duration-500', // 0.5 seconds for the transition\n },\n side: {\n bottom: 'translate-y-0',\n left: 'translate-x-0',\n right: 'translate-x-0',\n top: 'translate-y-0',\n },\n },\n defaultVariants: {\n state: 'closed',\n side: 'bottom',\n },\n }\n);\n"]}
@@ -0,0 +1,4 @@
1
+ // popoverConstants.ts
2
+ export const STATE_OPEN = 'open';
3
+ export const STATE_CLOSED = 'closed';
4
+ //# sourceMappingURL=popover.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"popover.types.js","sourceRoot":"","sources":["../../../../../src/components/atoms/popover/popover.types.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC;AACjC,MAAM,CAAC,MAAM,YAAY,GAAG,QAAQ,CAAC","sourcesContent":["// popoverConstants.ts\nexport const STATE_OPEN = 'open';\nexport const STATE_CLOSED = 'closed';\n"]}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Toggle size.
3
+ */
4
+ export var TOGGLE_SIZE;
5
+ (function (TOGGLE_SIZE) {
6
+ /**
7
+ * Small size
8
+ */
9
+ TOGGLE_SIZE["SMALL"] = "sm";
10
+ /**
11
+ * medium size
12
+ */
13
+ TOGGLE_SIZE["MEDIUM"] = "md";
14
+ /**
15
+ * Large size
16
+ */
17
+ TOGGLE_SIZE["LARGE"] = "lg";
18
+ })(TOGGLE_SIZE || (TOGGLE_SIZE = {}));
19
+ export var TOGGLE_VARIANT;
20
+ (function (TOGGLE_VARIANT) {
21
+ /**
22
+ * Default variant
23
+ */
24
+ TOGGLE_VARIANT["DEFAULT"] = "default";
25
+ /**
26
+ * Outline variant
27
+ */
28
+ TOGGLE_VARIANT["OUTLINE"] = "outline";
29
+ })(TOGGLE_VARIANT || (TOGGLE_VARIANT = {}));
30
+ //# sourceMappingURL=defs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defs.js","sourceRoot":"","sources":["../../../../../src/components/atoms/toggle/defs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,CAAN,IAAY,WAaX;AAbD,WAAY,WAAW;IACrB;;OAEG;IACH,2BAAY,CAAA;IACZ;;OAEG;IACH,4BAAa,CAAA;IACb;;OAEG;IACH,2BAAY,CAAA;AACd,CAAC,EAbW,WAAW,KAAX,WAAW,QAatB;AAED,MAAM,CAAN,IAAY,cASX;AATD,WAAY,cAAc;IACxB;;OAEG;IACH,qCAAmB,CAAA;IACnB;;OAEG;IACH,qCAAmB,CAAA;AACrB,CAAC,EATW,cAAc,KAAd,cAAc,QASzB","sourcesContent":["/**\n * Toggle size.\n */\n\nexport enum TOGGLE_SIZE {\n /**\n * Small size\n */\n SMALL = 'sm',\n /**\n * medium size\n */\n MEDIUM = 'md',\n /**\n * Large size\n */\n LARGE = 'lg',\n}\n\nexport enum TOGGLE_VARIANT {\n /**\n * Default variant\n */\n DEFAULT = 'default',\n /**\n * Outline variant\n */\n OUTLINE = 'outline',\n}\n"]}
@@ -0,0 +1,72 @@
1
+ var Toggle_1;
2
+ import { __decorate } from "tslib";
3
+ import { html } from 'lit-element';
4
+ import { customElement, property } from 'lit/decorators.js';
5
+ import { TOGGLE_SIZE, TOGGLE_VARIANT } from './defs';
6
+ import { TWStyles } from '../../../styles';
7
+ import { toggleStyle } from './toggle.style';
8
+ import { BaseElement, cn } from '../../../helpers';
9
+ import { spread } from '@open-wc/lit-helpers';
10
+ export { TOGGLE_SIZE, TOGGLE_VARIANT };
11
+ let Toggle = Toggle_1 = class Toggle extends BaseElement {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.disabled = false;
15
+ this.checked = false;
16
+ this.required = false;
17
+ this.variant = TOGGLE_VARIANT.DEFAULT;
18
+ this.size = TOGGLE_SIZE.SMALL;
19
+ }
20
+ getAttributesToExclude() {
21
+ return ['disabled', 'checked', 'variant', 'size', 'required'];
22
+ }
23
+ toggle() {
24
+ if (!this.disabled) {
25
+ this.checked = !this.checked;
26
+ }
27
+ }
28
+ render() {
29
+ const attributes = this.getFilteredAttributes();
30
+ return html `
31
+ <button
32
+ type="button"
33
+ class="${cn(Toggle_1.toggleVariants({
34
+ variant: this.variant,
35
+ size: this.size,
36
+ className: this.className,
37
+ }))}"
38
+ aria-pressed=${this.checked}
39
+ data-state="${this.checked ? 'on' : 'off'}"
40
+ aria-label="Toggle bold"
41
+ @click=${this.toggle}
42
+ ?disabled=${this.disabled}
43
+ ?required=${this.required}
44
+ ${spread(attributes)}
45
+ >
46
+ <slot></slot>
47
+ </button>
48
+ `;
49
+ }
50
+ };
51
+ Toggle.styles = [TWStyles];
52
+ Toggle.toggleVariants = toggleStyle;
53
+ __decorate([
54
+ property({ attribute: true, type: Boolean, reflect: true })
55
+ ], Toggle.prototype, "disabled", void 0);
56
+ __decorate([
57
+ property({ attribute: true, type: Boolean, reflect: true })
58
+ ], Toggle.prototype, "checked", void 0);
59
+ __decorate([
60
+ property({ attribute: true, type: Boolean, reflect: true })
61
+ ], Toggle.prototype, "required", void 0);
62
+ __decorate([
63
+ property({ attribute: true, type: String })
64
+ ], Toggle.prototype, "variant", void 0);
65
+ __decorate([
66
+ property({ attribute: true, type: String })
67
+ ], Toggle.prototype, "size", void 0);
68
+ Toggle = Toggle_1 = __decorate([
69
+ customElement('rtg-toggle')
70
+ ], Toggle);
71
+ export { Toggle };
72
+ //# sourceMappingURL=toggle.atom.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toggle.atom.js","sourceRoot":"","sources":["../../../../../src/components/atoms/toggle/toggle.atom.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,CAAC;AAGvC,IAAM,MAAM,cAAZ,MAAM,MAAO,SAAQ,WAAW;IAAhC;;QAC+D,aAAQ,GAAG,KAAK,CAAC;QACjB,YAAO,GAAG,KAAK,CAAC;QAChB,aAAQ,GAAG,KAAK,CAAC;QACjC,YAAO,GAClD,cAAc,CAAC,OAAO,CAAC;QACoB,SA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,CAAC;wCAAkB;AACjC;IAA5C,QAAQ,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uCACnB;AACoB;IAA5C,QAAQ,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oCACxB;AAPhB,MAAM;IADX,aAAa,CAAC,YAAY,CAAC;GACtB,MAAM,CA4CX;AAED,OAAO,EAAE,MAAM,EAAE,CAAC","sourcesContent":["import { html } from 'lit-element';\nimport { customElement, property } from 'lit/decorators.js';\nimport { TOGGLE_SIZE, TOGGLE_VARIANT } from './defs';\nimport { TWStyles } from '../../../styles';\nimport { toggleStyle } from './toggle.style';\nimport { BaseElement, cn } from '../../../helpers';\nimport { spread } from '@open-wc/lit-helpers';\n\nexport { TOGGLE_SIZE, TOGGLE_VARIANT };\n\n@customElement('rtg-toggle')\nclass Toggle extends BaseElement {\n @property({ attribute: true, type: Boolean, reflect: true }) disabled = false;\n @property({ attribute: true, type: Boolean, reflect: true }) checked = false;\n @property({ attribute: true, type: Boolean, reflect: true }) required = false;\n @property({ attribute: true, type: String }) variant: TOGGLE_VARIANT =\n TOGGLE_VARIANT.DEFAULT;\n @property({ attribute: true, type: String }) size: TOGGLE_SIZE =\n TOGGLE_SIZE.SMALL;\n\n static styles = [TWStyles];\n static toggleVariants = toggleStyle;\n protected getAttributesToExclude(): string[] {\n return ['disabled', 'checked', 'variant', 'size', 'required'];\n }\n\n toggle() {\n if (!this.disabled) {\n this.checked = !this.checked;\n }\n }\n render() {\n const attributes = this.getFilteredAttributes();\n return html`\n <button\n type=\"button\"\n class=\"${cn(\n Toggle.toggleVariants({\n variant: this.variant,\n size: this.size,\n className: this.className,\n })\n )}\"\n aria-pressed=${this.checked}\n data-state=\"${this.checked ? 'on' : 'off'}\"\n aria-label=\"Toggle bold\"\n @click=${this.toggle}\n ?disabled=${this.disabled}\n ?required=${this.required}\n ${spread(attributes)}\n >\n <slot></slot>\n </button>\n `;\n }\n}\n\nexport { Toggle };\n"]}
@@ -0,0 +1,189 @@
1
+ import { html } from 'lit';
2
+ import { expect, within, waitFor, userEvent } from '@storybook/test';
3
+ import { Toggle, TOGGLE_SIZE, TOGGLE_VARIANT } from './toggle.atom';
4
+ // import '../button';
5
+ const meta = {
6
+ component: 'Toggle',
7
+ tags: ['autodocs'],
8
+ argTypes: {
9
+ variant: {
10
+ control: {
11
+ type: 'select',
12
+ },
13
+ options: Object.values(TOGGLE_VARIANT),
14
+ defaultValue: 'DEFAULT',
15
+ description: 'Choose the visual style of the toggle.',
16
+ table: {
17
+ defaultValue: { summary: 'DEFAULT' },
18
+ },
19
+ },
20
+ size: {
21
+ control: {
22
+ type: 'select',
23
+ },
24
+ options: Object.values(TOGGLE_SIZE),
25
+ description: 'Choose the size of the toggle.',
26
+ defaultValue: 'SMALL',
27
+ table: {
28
+ defaultValue: { summary: 'SMALL' },
29
+ },
30
+ },
31
+ disabled: {
32
+ control: 'boolean',
33
+ description: 'Disable the toggle to prevent interactions.',
34
+ table: {
35
+ defaultValue: { summary: 'false' },
36
+ },
37
+ },
38
+ checked: {
39
+ control: 'boolean',
40
+ description: 'Set the initial checked state of the toggle.',
41
+ table: {
42
+ defaultValue: { summary: 'false' },
43
+ },
44
+ },
45
+ required: {
46
+ control: 'boolean',
47
+ description: 'Mark the toggle as required.',
48
+ table: {
49
+ defaultValue: { summary: 'false' },
50
+ },
51
+ },
52
+ },
53
+ };
54
+ const testToggleBehavior = async (args, canvasElement, mockHandler) => {
55
+ const canvas = within(canvasElement);
56
+ const toggle = await waitFor(() => canvas.getByTestId('toggle-id'));
57
+ if (toggle.shadowRoot) {
58
+ const innerToggle = toggle.shadowRoot.querySelector('[data-testchild="children-id"]');
59
+ expect(innerToggle).toHaveAttribute('type', 'button');
60
+ // Test toggle state
61
+ if (args.checked) {
62
+ expect(innerToggle).toBeChecked();
63
+ }
64
+ else {
65
+ expect(innerToggle).not.toBeChecked();
66
+ }
67
+ // Test toggle click behavior
68
+ if (!args.disabled && innerToggle) {
69
+ await userEvent.click(innerToggle);
70
+ if (mockHandler) {
71
+ expect(mockHandler).toHaveBeenCalled();
72
+ }
73
+ }
74
+ // Test toggle disabled state
75
+ if (args.disabled) {
76
+ expect(innerToggle).toBeDisabled();
77
+ }
78
+ else {
79
+ expect(innerToggle).not.toBeDisabled();
80
+ }
81
+ // Test toggle variant classes
82
+ const expectedClasses = Toggle.toggleVariants({
83
+ variant: args.variant,
84
+ size: args.size,
85
+ className: '',
86
+ });
87
+ expect(innerToggle).toHaveClass(expectedClasses);
88
+ // Test toggle size classes
89
+ const expectedSizeClasses = Toggle.toggleVariants({
90
+ variant: args.variant,
91
+ size: args.size,
92
+ className: '',
93
+ });
94
+ expect(innerToggle).toHaveClass(expectedSizeClasses);
95
+ }
96
+ };
97
+ export default meta;
98
+ export const Toggles = {
99
+ args: {
100
+ variant: 'DEFAULT',
101
+ size: 'SMALL',
102
+ disabled: false,
103
+ checked: false,
104
+ required: false,
105
+ },
106
+ render: ({ variant, size, disabled, checked, required }) => html `
107
+ <rtg-toggle
108
+ ?disabled=${disabled}
109
+ ?checked=${checked}
110
+ ?required=${required}
111
+ .variant=${variant}
112
+ .size=${size}
113
+ data-testid="toggle-id"
114
+ data-testchild="children-id"
115
+ >
116
+ <svg
117
+ xmlns="http://www.w3.org/2000/svg"
118
+ width="24"
119
+ height="24"
120
+ viewBox="0 0 24 24"
121
+ fill="none"
122
+ stroke="currentColor"
123
+ stroke-width="2"
124
+ stroke-linecap="round"
125
+ stroke-linejoin="round"
126
+ class="lucide lucide-bold h-4 w-4"
127
+ >
128
+ <path d="M14 12a4 4 0 0 0 0-8H6v8"></path>
129
+ <path d="M15 20a4 4 0 0 0 0-8H6v8Z"></path>
130
+ </svg>
131
+ </rtg-toggle>
132
+ `,
133
+ play: async ({ args, canvasElement }) => {
134
+ await testToggleBehavior(args, canvasElement, null);
135
+ },
136
+ };
137
+ export const RequiredToggle = {
138
+ name: 'Required Toggle',
139
+ args: {
140
+ variant: 'DEFAULT',
141
+ size: 'SMALL',
142
+ disabled: false,
143
+ checked: false,
144
+ required: true,
145
+ },
146
+ render: ({ variant, size, disabled, checked, required }) => html `
147
+ <div>
148
+ <rtg-toggle
149
+ ?disabled=${disabled}
150
+ ?checked=${checked}
151
+ ?required=${required}
152
+ .variant=${variant}
153
+ .size=${size}
154
+ data-testid="toggle-id"
155
+ data-testchild="children-id"
156
+ @click=${(e) => {
157
+ const checkbox = e.target;
158
+ const button = document.querySelector('rtg-button');
159
+ if (button) {
160
+ button.disabled = required ? !checkbox.checked : false;
161
+ }
162
+ }}
163
+ >
164
+ <svg
165
+ xmlns="http://www.w3.org/2000/svg"
166
+ width="24"
167
+ height="24"
168
+ viewBox="0 0 24 24"
169
+ fill="none"
170
+ stroke="currentColor"
171
+ stroke-width="2"
172
+ stroke-linecap="round"
173
+ stroke-linejoin="round"
174
+ class="lucide lucide-italic h-4 w-4"
175
+ >
176
+ <line x1="19" x2="10" y1="4" y2="4"></line>
177
+ <line x1="14" x2="5" y1="20" y2="20"></line>
178
+ <line x1="15" x2="9" y1="4" y2="20"></line>
179
+ </svg>
180
+ </rtg-toggle>
181
+ </div>
182
+
183
+ <rtg-button ?disabled=${required && !checked}> send </rtg-button>
184
+ `,
185
+ play: async ({ args, canvasElement }) => {
186
+ await testToggleBehavior(args, canvasElement, null);
187
+ },
188
+ };
189
+ //# sourceMappingURL=toggle.stories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toggle.stories.js","sourceRoot":"","sources":["../../../../../src/components/atoms/toggle/toggle.stories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACrE,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpE,sBAAsB;AAEtB,MAA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AAG,CAAC,CAAC,MAA0B,CAAC;QAC9C,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CACnC,YAAY,CACQ,CAAC;QACvB,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC;QACzD,CAAC;IACH,CAAC;;;;;;;;;;;;;;;;;;;;;4BAqBmB,QAAQ,IAAI,CAAC,OAAO;GAC7C;IACD,IAAI,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,EAAE,EAAE;QACtC,MAAM,kBAAkB,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;CACF,CAAC","sourcesContent":["import { html } from 'lit';\nimport type { Meta, StoryObj } from '@storybook/web-components';\nimport { expect, within, waitFor, userEvent } from '@storybook/test';\nimport { Toggle, TOGGLE_SIZE, TOGGLE_VARIANT } from './toggle.atom';\n// import '../button';\n\nconst meta: Meta = {\n component: 'Toggle',\n tags: ['autodocs'],\n argTypes: {\n variant: {\n control: {\n type: 'select',\n },\n options: Object.values(TOGGLE_VARIANT),\n defaultValue: 'DEFAULT',\n description: 'Choose the visual style of the toggle.',\n table: {\n defaultValue: { summary: 'DEFAULT' },\n },\n },\n size: {\n control: {\n type: 'select',\n },\n options: Object.values(TOGGLE_SIZE),\n description: 'Choose the size of the toggle.',\n defaultValue: 'SMALL',\n table: {\n defaultValue: { summary: 'SMALL' },\n },\n },\n disabled: {\n control: 'boolean',\n description: 'Disable the toggle to prevent interactions.',\n table: {\n defaultValue: { summary: 'false' },\n },\n },\n checked: {\n control: 'boolean',\n description: 'Set the initial checked state of the toggle.',\n table: {\n defaultValue: { summary: 'false' },\n },\n },\n required: {\n control: 'boolean',\n description: 'Mark the toggle as required.',\n table: {\n defaultValue: { summary: 'false' },\n },\n },\n },\n};\n\nconst testToggleBehavior = async (\n args: any,\n canvasElement: any,\n mockHandler: any\n) => {\n const canvas = within(canvasElement);\n const toggle = await waitFor(() => canvas.getByTestId('toggle-id'));\n if (toggle.shadowRoot) {\n const innerToggle = toggle.shadowRoot.querySelector(\n '[data-testchild=\"children-id\"]'\n );\n expect(innerToggle).toHaveAttribute('type', 'button');\n // Test toggle state\n if (args.checked) {\n expect(innerToggle).toBeChecked();\n } else {\n expect(innerToggle).not.toBeChecked();\n }\n\n // Test toggle click behavior\n if (!args.disabled && innerToggle) {\n await userEvent.click(innerToggle);\n if (mockHandler) {\n expect(mockHandler).toHaveBeenCalled();\n }\n }\n\n // Test toggle disabled state\n if (args.disabled) {\n expect(innerToggle).toBeDisabled();\n } else {\n expect(innerToggle).not.toBeDisabled();\n }\n\n // Test toggle variant classes\n const expectedClasses = Toggle.toggleVariants({\n variant: args.variant,\n size: args.size,\n className: '',\n });\n expect(innerToggle).toHaveClass(expectedClasses);\n // Test toggle size classes\n const expectedSizeClasses = Toggle.toggleVariants({\n variant: args.variant,\n size: args.size,\n className: '',\n });\n expect(innerToggle).toHaveClass(expectedSizeClasses);\n }\n};\n\nexport default meta;\ntype Story = StoryObj;\n\nexport const Toggles: Story = {\n args: {\n variant: 'DEFAULT',\n size: 'SMALL',\n disabled: false,\n checked: false,\n required: false,\n },\n render: ({ variant, size, disabled, checked, required }) => html`\n <rtg-toggle\n ?disabled=${disabled}\n ?checked=${checked}\n ?required=${required}\n .variant=${variant}\n .size=${size}\n data-testid=\"toggle-id\"\n data-testchild=\"children-id\"\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-bold h-4 w-4\"\n >\n <path d=\"M14 12a4 4 0 0 0 0-8H6v8\"></path>\n <path d=\"M15 20a4 4 0 0 0 0-8H6v8Z\"></path>\n </svg>\n </rtg-toggle>\n `,\n play: async ({ args, canvasElement }) => {\n await testToggleBehavior(args, canvasElement, null);\n },\n};\n\nexport const RequiredToggle: Story = {\n name: 'Required Toggle',\n args: {\n variant: 'DEFAULT',\n size: 'SMALL',\n disabled: false,\n checked: false,\n required: true,\n },\n render: ({ variant, size, disabled, checked, required }) => html`\n <div>\n <rtg-toggle\n ?disabled=${disabled}\n ?checked=${checked}\n ?required=${required}\n .variant=${variant}\n .size=${size}\n data-testid=\"toggle-id\"\n data-testchild=\"children-id\"\n @click=${(e: Event) => {\n const checkbox = e.target as HTMLInputElement;\n const button = document.querySelector(\n 'rtg-button'\n ) as HTMLButtonElement;\n if (button) {\n button.disabled = required ? !checkbox.checked : false;\n }\n }}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"lucide lucide-italic h-4 w-4\"\n >\n <line x1=\"19\" x2=\"10\" y1=\"4\" y2=\"4\"></line>\n <line x1=\"14\" x2=\"5\" y1=\"20\" y2=\"20\"></line>\n <line x1=\"15\" x2=\"9\" y1=\"4\" y2=\"20\"></line>\n </svg>\n </rtg-toggle>\n </div>\n\n <rtg-button ?disabled=${required && !checked}> send </rtg-button>\n `,\n play: async ({ args, canvasElement }) => {\n await testToggleBehavior(args, canvasElement, null);\n },\n};\n"]}