@autoafleveren/ui 1.3.2 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (320) hide show
  1. package/dist/config/tailwind/config.cjs +1 -0
  2. package/dist/icons.cjs +17 -17
  3. package/dist/icons.js +1710 -1644
  4. package/dist/types/components/AppActionBar/AppActionBarItem.vue.d.ts +4 -0
  5. package/dist/types/composables/index.d.ts +2 -1
  6. package/dist/types/composables/useActionBar/index.d.ts +3 -3
  7. package/dist/types/composables/useFocusTrap/index.d.ts +10 -0
  8. package/dist/ui-storybook.css +1 -1
  9. package/dist/ui.cjs +47 -40
  10. package/dist/ui.js +12385 -11552
  11. package/package.json +5 -2
  12. package/src/App.vue +15 -0
  13. package/src/Playground.vue.example +9 -0
  14. package/src/config/eslint.cjs +199 -0
  15. package/src/config/tailwind/config.cjs +229 -0
  16. package/src/config/tailwind/screens.json +9 -0
  17. package/src/css/build.css +52 -0
  18. package/src/css/main.css +4 -0
  19. package/src/css/theme.css +208 -0
  20. package/src/css/tinymce.css +58 -0
  21. package/src/main.ts +34 -0
  22. package/src/modules/components/AppActionBar/AppActionBar.vue +96 -0
  23. package/src/modules/components/AppActionBar/AppActionBarItem.vue +149 -0
  24. package/src/modules/components/AppActionBar/AppActionBarSubMenu.vue +89 -0
  25. package/src/modules/components/AppActionBar/Components/Error.vue +11 -0
  26. package/src/modules/components/AppActionBar/Components/Loading.vue +9 -0
  27. package/src/modules/components/AppActionBar/Components/MultiSelect.vue +102 -0
  28. package/src/modules/components/AppActionBar/Components/__tests__/multi-select.spec.ts +74 -0
  29. package/src/modules/components/AppActionBar/__mocks__/index.ts +36 -0
  30. package/src/modules/components/AppActionBar/__tests__/app-action-bar-item.spec.ts +134 -0
  31. package/src/modules/components/AppActionBar/__tests__/app-action-bar-sub-menu.spec.ts +45 -0
  32. package/src/modules/components/AppActionBar/__tests__/app-action-bar.spec.ts +92 -0
  33. package/src/modules/components/AppActionBar/index.d.ts +29 -0
  34. package/src/modules/components/AppActionBar/index.ts +18 -0
  35. package/src/modules/components/AppAlert/AppAlert.vue +69 -0
  36. package/src/modules/components/AppAlert/__tests__/app-alert.spec.ts +67 -0
  37. package/src/modules/components/AppAlert/index.d.ts +3 -0
  38. package/src/modules/components/AppAlert/index.ts +18 -0
  39. package/src/modules/components/AppAvatar/AppAvatar.vue +30 -0
  40. package/src/modules/components/AppAvatar/DefaultAvatar.vue +187 -0
  41. package/src/modules/components/AppAvatar/__tests__/app-avatar.spec.ts +70 -0
  42. package/src/modules/components/AppAvatar/index.d.ts +9 -0
  43. package/src/modules/components/AppAvatar/index.ts +9 -0
  44. package/src/modules/components/AppBackButton/AppBackButton.vue +51 -0
  45. package/src/modules/components/AppBackButton/__tests__/app-back-button.spec.ts +70 -0
  46. package/src/modules/components/AppBadge/AppBadge.vue +65 -0
  47. package/src/modules/components/AppBadge/__tests__/app-badge.spec.ts +64 -0
  48. package/src/modules/components/AppBadge/index.d.ts +13 -0
  49. package/src/modules/components/AppBadge/index.ts +29 -0
  50. package/src/modules/components/AppButton/AppButton.vue +53 -0
  51. package/src/modules/components/AppButton/ButtonIconSlot.vue +26 -0
  52. package/src/modules/components/AppButton/__tests__/app-button.spec.ts +145 -0
  53. package/src/modules/components/AppButton/__tests__/button-icon-slot.spec.ts +30 -0
  54. package/src/modules/components/AppButton/index.d.ts +16 -0
  55. package/src/modules/components/AppButton/index.ts +57 -0
  56. package/src/modules/components/AppCard/AppCard.vue +88 -0
  57. package/src/modules/components/AppCard/CardAction.vue +101 -0
  58. package/src/modules/components/AppCard/CardIconSlot.vue +65 -0
  59. package/src/modules/components/AppCard/__tests__/app-card.spec.ts +109 -0
  60. package/src/modules/components/AppCard/__tests__/card-action.spec.ts +55 -0
  61. package/src/modules/components/AppCard/__tests__/card-icon-slot.spec.ts +27 -0
  62. package/src/modules/components/AppCard/index.d.ts +12 -0
  63. package/src/modules/components/AppCard/index.ts +5 -0
  64. package/src/modules/components/AppColor/AppColor.vue +74 -0
  65. package/src/modules/components/AppColor/__tests__/app-color.spec.ts +53 -0
  66. package/src/modules/components/AppColor/index.d.ts +10 -0
  67. package/src/modules/components/AppColorCard/AppColorCard.vue +41 -0
  68. package/src/modules/components/AppColorCard/__tests__/app-color-card.spec.ts +55 -0
  69. package/src/modules/components/AppConfirm/AppConfirm.vue +237 -0
  70. package/src/modules/components/AppConfirm/__tests__/app-confirm.spec.ts +366 -0
  71. package/src/modules/components/AppConfirm/index.d.ts +31 -0
  72. package/src/modules/components/AppConfirm/index.ts +1 -0
  73. package/src/modules/components/AppContextMenu/AppContextMenu.vue +109 -0
  74. package/src/modules/components/AppContextMenu/ShortcutItem.vue +38 -0
  75. package/src/modules/components/AppContextMenu/__mocks__/index.ts +25 -0
  76. package/src/modules/components/AppContextMenu/__tests__/app-context-menu.spec.ts +71 -0
  77. package/src/modules/components/AppContextMenu/__tests__/shortcut-item.spec.ts +29 -0
  78. package/src/modules/components/AppContextMenu/index.d.ts +23 -0
  79. package/src/modules/components/AppDataTable/AppDataTable.vue +323 -0
  80. package/src/modules/components/AppDataTable/AppDataTableFooter.vue +91 -0
  81. package/src/modules/components/AppDataTable/__mocks__/index.ts +71 -0
  82. package/src/modules/components/AppDataTable/__tests__/app-data-table-footer.spec.ts +107 -0
  83. package/src/modules/components/AppDataTable/__tests__/app-data-table.spec.ts +153 -0
  84. package/src/modules/components/AppDataTable/index.d.ts +29 -0
  85. package/src/modules/components/AppDefinitionList/AppDefinitionItem.vue +57 -0
  86. package/src/modules/components/AppDefinitionList/AppDefinitionList.vue +32 -0
  87. package/src/modules/components/AppDefinitionList/__mocks__/index.ts +31 -0
  88. package/src/modules/components/AppDefinitionList/__tests__/app-definition-item.spec.ts +93 -0
  89. package/src/modules/components/AppDefinitionList/__tests__/app-definition-list.spec.ts +35 -0
  90. package/src/modules/components/AppDefinitionList/index.d.ts +8 -0
  91. package/src/modules/components/AppDisclosure/AppDisclosure.vue +19 -0
  92. package/src/modules/components/AppDisclosure/AppDisclosureButton.vue +43 -0
  93. package/src/modules/components/AppDisclosure/AppDisclosurePanel.vue +31 -0
  94. package/src/modules/components/AppDisclosure/__tests__/app-disclosure-button.spec.ts +70 -0
  95. package/src/modules/components/AppDisclosure/__tests__/app-disclosure-panel.spec.ts +64 -0
  96. package/src/modules/components/AppDisclosure/__tests__/app-disclosure.spec.ts +41 -0
  97. package/src/modules/components/AppDrawer/AppDrawer.vue +149 -0
  98. package/src/modules/components/AppDrawer/__tests__/app-drawer.spec.ts +120 -0
  99. package/src/modules/components/AppDrawer/index.d.ts +27 -0
  100. package/src/modules/components/AppDropdownButton/AppDropdownButton.vue +82 -0
  101. package/src/modules/components/AppDropdownButton/AppDropdownItem.vue +67 -0
  102. package/src/modules/components/AppDropdownButton/__mocks__/index.ts +25 -0
  103. package/src/modules/components/AppDropdownButton/__tests__/app-dropdown-button.spec.ts +81 -0
  104. package/src/modules/components/AppDropdownButton/__tests__/app-dropdown-item.spec.ts +108 -0
  105. package/src/modules/components/AppDropdownButton/index.d.ts +26 -0
  106. package/src/modules/components/AppDropdownButton/index.ts +8 -0
  107. package/src/modules/components/AppError/AppError.vue +233 -0
  108. package/src/modules/components/AppError/__tests__/app-error.spec.ts +366 -0
  109. package/src/modules/components/AppError/index.d.ts +30 -0
  110. package/src/modules/components/AppError/index.ts +1 -0
  111. package/src/modules/components/AppImageDropzone/AppImageDropzone.vue +130 -0
  112. package/src/modules/components/AppImageDropzone/__tests__/app-image-dropzone.spec.ts +92 -0
  113. package/src/modules/components/AppImageDropzone/index.d.ts +8 -0
  114. package/src/modules/components/AppInput/AppInput.vue +247 -0
  115. package/src/modules/components/AppInput/FileInput.vue +58 -0
  116. package/src/modules/components/AppInput/Input.vue +141 -0
  117. package/src/modules/components/AppInput/InputIconSlot.vue +27 -0
  118. package/src/modules/components/AppInput/LocationInput.vue +150 -0
  119. package/src/modules/components/AppInput/__mocks__/location.ts +13 -0
  120. package/src/modules/components/AppInput/__tests__/app-input.spec.ts +255 -0
  121. package/src/modules/components/AppInput/__tests__/file-input.spec.ts +48 -0
  122. package/src/modules/components/AppInput/__tests__/input-icon-slot.spec.ts +27 -0
  123. package/src/modules/components/AppInput/__tests__/input.spec.ts +260 -0
  124. package/src/modules/components/AppInput/__tests__/location-input.spec.ts +159 -0
  125. package/src/modules/components/AppInput/choice.ts +24 -0
  126. package/src/modules/components/AppInput/datepicker.ts +62 -0
  127. package/src/modules/components/AppInput/index.d.ts +68 -0
  128. package/src/modules/components/AppInput/index.ts +133 -0
  129. package/src/modules/components/AppInput/location.ts +8 -0
  130. package/src/modules/components/AppInput/richText.ts +45 -0
  131. package/src/modules/components/AppInputLabel/AppInputLabel.vue +15 -0
  132. package/src/modules/components/AppInputLabel/__tests__/app-input-label.spec.ts +38 -0
  133. package/src/modules/components/AppInputLabel/index.d.ts +6 -0
  134. package/src/modules/components/AppLicensePlate/AppLicensePlate.vue +34 -0
  135. package/src/modules/components/AppLicensePlate/__tests__/app-license-plate.spec.ts +46 -0
  136. package/src/modules/components/AppLicensePlate/index.d.ts +1 -0
  137. package/src/modules/components/AppLoader/AppLoader.vue +37 -0
  138. package/src/modules/components/AppLoader/index.d.ts +1 -0
  139. package/src/modules/components/AppLoader/index.ts +8 -0
  140. package/src/modules/components/AppMaps/AppMaps.vue +105 -0
  141. package/src/modules/components/AppMaps/index.ts +44 -0
  142. package/src/modules/components/AppMenu/AppMenu.vue +79 -0
  143. package/src/modules/components/AppMenu/AppMenuItem.vue +40 -0
  144. package/src/modules/components/AppMenu/__mocks__/index.ts +23 -0
  145. package/src/modules/components/AppMenu/__tests__/app-menu-item.spec.ts +47 -0
  146. package/src/modules/components/AppMenu/__tests__/app-menu.spec.ts +53 -0
  147. package/src/modules/components/AppMenu/index.d.ts +15 -0
  148. package/src/modules/components/AppModal/AppModal.vue +261 -0
  149. package/src/modules/components/AppModal/__tests__/app-modal.spec.ts +282 -0
  150. package/src/modules/components/AppModal/index.d.ts +36 -0
  151. package/src/modules/components/AppNavigationMenu/AppNavigationMenu.vue +95 -0
  152. package/src/modules/components/AppNavigationMenu/Mobile.vue +126 -0
  153. package/src/modules/components/AppNavigationMenu/NavigationItem.vue +82 -0
  154. package/src/modules/components/AppNavigationMenu/SupportItem.vue +29 -0
  155. package/src/modules/components/AppNavigationMenu/__tests__/app-navigation-menu.spec.ts +104 -0
  156. package/src/modules/components/AppNavigationMenu/__tests__/mobile.spec.ts +155 -0
  157. package/src/modules/components/AppNavigationMenu/__tests__/navigation-item.spec.ts +91 -0
  158. package/src/modules/components/AppNavigationMenu/__tests__/support-item.spec.ts +48 -0
  159. package/src/modules/components/AppPagination/AppPagination.vue +133 -0
  160. package/src/modules/components/AppPagination/AppPaginationItem.vue +28 -0
  161. package/src/modules/components/AppPagination/__mocks__/index.ts +20 -0
  162. package/src/modules/components/AppPagination/__tests__/app-pagination.spec.ts +143 -0
  163. package/src/modules/components/AppPagination/index.d.ts +24 -0
  164. package/src/modules/components/AppProgressBar/AppProgressBar.vue +93 -0
  165. package/src/modules/components/AppProgressBar/AppProgressBarStep.vue +5 -0
  166. package/src/modules/components/AppProgressBar/__mocks__/index.ts +17 -0
  167. package/src/modules/components/AppProgressBar/__tests__/app-progress-bar-step.spec.ts +18 -0
  168. package/src/modules/components/AppProgressBar/__tests__/app-progress-bar.spec.ts +77 -0
  169. package/src/modules/components/AppProgressBar/index.d.ts +21 -0
  170. package/src/modules/components/AppRating/AppRating.vue +42 -0
  171. package/src/modules/components/AppRating/VueStarRating/Star.vue +215 -0
  172. package/src/modules/components/AppRating/VueStarRating/StarRating.vue +231 -0
  173. package/src/modules/components/AppRating/VueStarRating/classes/AlphaColor.ts +68 -0
  174. package/src/modules/components/AppRating/VueStarRating/readme.md +279 -0
  175. package/src/modules/components/AppRating/__tests__/app-rating.spec.ts +36 -0
  176. package/src/modules/components/AppSection/AppSection.vue +35 -0
  177. package/src/modules/components/AppSection/__tests__/app-section.spec.ts +53 -0
  178. package/src/modules/components/AppSelect/AppSelect.vue +176 -0
  179. package/src/modules/components/AppSelect/__mocks__/index.ts +24 -0
  180. package/src/modules/components/AppSelect/__tests__/app-select.spec.ts +73 -0
  181. package/src/modules/components/AppSelect/index.d.ts +43 -0
  182. package/src/modules/components/AppSelect/index.ts +69 -0
  183. package/src/modules/components/AppStepper/AppStepper.vue +79 -0
  184. package/src/modules/components/AppStepper/__tests__/app-stepper.spec.ts +59 -0
  185. package/src/modules/components/AppTable/AppTable.vue +40 -0
  186. package/src/modules/components/AppTimeline/AppTimeline.vue +22 -0
  187. package/src/modules/components/AppTimeline/AppTimelineItem.vue +97 -0
  188. package/src/modules/components/AppTimeline/AppTimelineItemIcon.vue +55 -0
  189. package/src/modules/components/AppTimeline/__mocks__/timeline.ts +29 -0
  190. package/src/modules/components/AppTimeline/__tests__/app-timeline-item-Icon.spec.ts +35 -0
  191. package/src/modules/components/AppTimeline/__tests__/app-timeline-item.spec.ts +121 -0
  192. package/src/modules/components/AppTimeline/__tests__/app-timeline.spec.ts +55 -0
  193. package/src/modules/components/AppTimeline/index.d.ts +30 -0
  194. package/src/modules/components/AppTimeline/index.ts +13 -0
  195. package/src/modules/components/AppToggle/AppToggle.vue +36 -0
  196. package/src/modules/components/AppToggle/__tests__/app-toggle.spec.ts +54 -0
  197. package/src/modules/components/AppToggle/index.d.ts +3 -0
  198. package/src/modules/components/AppToggleCard/AppToggleCard.vue +45 -0
  199. package/src/modules/components/AppToggleCard/__tests__/app-toggle-card.spec.ts +55 -0
  200. package/src/modules/components/index.ts +43 -0
  201. package/src/modules/composables/index.ts +14 -0
  202. package/src/modules/composables/useActionBar/__mocks__/index.ts +17 -0
  203. package/src/modules/composables/useActionBar/__tests__/index.spec.ts +62 -0
  204. package/src/modules/composables/useActionBar/index.d.ts +1 -0
  205. package/src/modules/composables/useActionBar/index.ts +67 -0
  206. package/src/modules/composables/useComputedPosition/index.d.ts +16 -0
  207. package/src/modules/composables/useComputedPosition/index.ts +199 -0
  208. package/src/modules/composables/useConfirm/__tests__/index.spec.ts +29 -0
  209. package/src/modules/composables/useConfirm/index.ts +63 -0
  210. package/src/modules/composables/useContextMenu/index.ts +127 -0
  211. package/src/modules/composables/useDrawer/__tests__/index.spec.ts +34 -0
  212. package/src/modules/composables/useDrawer/index.ts +136 -0
  213. package/src/modules/composables/useEcho/index.ts +167 -0
  214. package/src/modules/composables/useError/__tests__/index.spec.ts +29 -0
  215. package/src/modules/composables/useError/index.ts +61 -0
  216. package/src/modules/composables/useFocusTrap/index.d.ts +3 -0
  217. package/src/modules/composables/useFocusTrap/index.ts +98 -0
  218. package/src/modules/composables/useGoogleApi/__tests__/index.spec.ts +39 -0
  219. package/src/modules/composables/useGoogleApi/index.ts +26 -0
  220. package/src/modules/composables/useLayout/__tests__/index.spec.ts +34 -0
  221. package/src/modules/composables/useLayout/index.d.ts +1 -0
  222. package/src/modules/composables/useLayout/index.ts +68 -0
  223. package/src/modules/composables/useModal/__tests__/index.spec.ts +34 -0
  224. package/src/modules/composables/useModal/index.ts +97 -0
  225. package/src/modules/composables/useNavigation/__mocks__/navigation.ts +22 -0
  226. package/src/modules/composables/useNavigation/__tests__/index.spec.ts +88 -0
  227. package/src/modules/composables/useNavigation/index.d.ts +17 -0
  228. package/src/modules/composables/useNavigation/index.ts +97 -0
  229. package/src/modules/icons/BuildingCircleCheck.vue +32 -0
  230. package/src/modules/icons/BuildingCircleXmark.vue +20 -0
  231. package/src/modules/icons/CarsIcon.vue +29 -0
  232. package/src/modules/icons/ChatPersonRoundedIcon.vue +184 -0
  233. package/src/modules/icons/CompanyIcon.vue +18 -0
  234. package/src/modules/icons/HeroGirlIcon.vue +246 -0
  235. package/src/modules/icons/HeroPersonIcon.vue +402 -0
  236. package/src/modules/icons/HeroPersonRoundedIcon.vue +412 -0
  237. package/src/modules/icons/HeroPersonWithBgIcon.vue +4503 -0
  238. package/src/modules/icons/LocationMarkerIcon.vue +33 -0
  239. package/src/modules/icons/PartyPopperIcon.vue +146 -0
  240. package/src/modules/icons/index.ts +32 -0
  241. package/src/modules/icons/status/ErrorIcon.vue +24 -0
  242. package/src/modules/icons/status/SuccessIcon.vue +24 -0
  243. package/src/modules/icons/status/WarningIcon.vue +27 -0
  244. package/src/modules/icons/status/index.ts +3 -0
  245. package/src/modules/index.ts +8 -0
  246. package/src/modules/layouts/Auth/Auth.vue +36 -0
  247. package/src/modules/layouts/Auth/__tests__/auth.spec.ts +63 -0
  248. package/src/modules/layouts/Base/Base.vue +69 -0
  249. package/src/modules/layouts/Base/__tests__/base.spec.ts +56 -0
  250. package/src/modules/layouts/Platform/Platform.vue +96 -0
  251. package/src/modules/layouts/Platform/__tests__/platform.spec.ts +56 -0
  252. package/src/modules/layouts/index.ts +9 -0
  253. package/src/modules/plugins/Sentry/index.d.ts +16 -0
  254. package/src/modules/plugins/Sentry/index.ts +65 -0
  255. package/src/modules/plugins/Sentry/language/nl.ts +13 -0
  256. package/src/modules/plugins/TinyMCE/lang/nl.js +430 -0
  257. package/src/modules/plugins/Toast/Toast.vue +58 -0
  258. package/src/modules/plugins/Toast/__tests__/toast.spec.ts +90 -0
  259. package/src/modules/plugins/Toast/index.ts +36 -0
  260. package/src/modules/plugins/Toast/types.d.ts +265 -0
  261. package/src/modules/plugins/index.ts +63 -0
  262. package/src/stories/Introduction.mdx +4 -0
  263. package/src/stories/assets/code-brackets.svg +1 -0
  264. package/src/stories/assets/colors.svg +1 -0
  265. package/src/stories/assets/comments.svg +1 -0
  266. package/src/stories/assets/direction.svg +1 -0
  267. package/src/stories/assets/flow.svg +1 -0
  268. package/src/stories/assets/images/logo.png +0 -0
  269. package/src/stories/assets/images/road.png +0 -0
  270. package/src/stories/assets/plugin.svg +1 -0
  271. package/src/stories/assets/repo.svg +1 -0
  272. package/src/stories/assets/stackalt.svg +1 -0
  273. package/src/stories/components/ActionBar/ActionBar.stories.ts +67 -0
  274. package/src/stories/components/Alert/Alert.stories.ts +53 -0
  275. package/src/stories/components/Avatar/Avatar.stories.ts +44 -0
  276. package/src/stories/components/BackButton/BackButton.stories.ts +39 -0
  277. package/src/stories/components/Badge/Badge.stories.ts +42 -0
  278. package/src/stories/components/Button/Button.stories.ts +132 -0
  279. package/src/stories/components/Card/Card.stories.ts +70 -0
  280. package/src/stories/components/Color/Color.stories.ts +41 -0
  281. package/src/stories/components/ColorCard/ColorCard.stories.ts +43 -0
  282. package/src/stories/components/Confirm/Confirm.stories.ts +110 -0
  283. package/src/stories/components/ContextMenu/ContextMenu.stories.ts +85 -0
  284. package/src/stories/components/DefinitionList/DefinitionList.stories.ts +32 -0
  285. package/src/stories/components/Disclosure/Disclosure.stories.ts +61 -0
  286. package/src/stories/components/DropdownButton/DropdownButton.stories.ts +121 -0
  287. package/src/stories/components/Error/Error.stories.ts +106 -0
  288. package/src/stories/components/ImageDropzone/ImageDropzone.stories.ts +41 -0
  289. package/src/stories/components/Input/Input.stories.ts +180 -0
  290. package/src/stories/components/Input/LocationInput.stories.ts +77 -0
  291. package/src/stories/components/LicensePlate/LicensePlate.stories.ts +39 -0
  292. package/src/stories/components/Maps/Maps.stories.ts +36 -0
  293. package/src/stories/components/Menu/Menu.stories.ts +41 -0
  294. package/src/stories/components/Modal/Modal.stories.ts +68 -0
  295. package/src/stories/components/Navigation/Navigation.stories.ts +62 -0
  296. package/src/stories/components/Pagination/Pagination.stories.ts +62 -0
  297. package/src/stories/components/ProgressBar/ProgressBar.stories.ts +48 -0
  298. package/src/stories/components/Rating/Rating.stories.ts +38 -0
  299. package/src/stories/components/Section/Section.stories.ts +44 -0
  300. package/src/stories/components/Select/Select.stories.ts +90 -0
  301. package/src/stories/components/Stepper/Stepper.stories.ts +38 -0
  302. package/src/stories/components/Table/DataTable.stories.ts +96 -0
  303. package/src/stories/components/Table/Table.stories.ts +45 -0
  304. package/src/stories/components/Timeline/Timeline.stories.ts +46 -0
  305. package/src/stories/components/Toast/Toast.stories.ts +47 -0
  306. package/src/stories/components/Toggle/Toggle.stories.ts +41 -0
  307. package/src/stories/components/ToggleCard/ToggleCard.stories.ts +43 -0
  308. package/src/stories/layouts/Auth.stories.ts +43 -0
  309. package/src/stories/layouts/Base.stories.ts +70 -0
  310. package/src/tests/mocks/resize-observer.ts +13 -0
  311. package/src/tests/stubs/AppSelect.ts +89 -0
  312. package/src/tests/stubs/HeadlessUiDialogStub.ts +24 -0
  313. package/src/tests/stubs/HeadlessUiTransitionChildStub.ts +20 -0
  314. package/src/tests/stubs/HeadlessUiTransitionRootStub.ts +25 -0
  315. package/src/tests/stubs/IconStub.ts +9 -0
  316. package/src/tests/stubs/Vue3EasyDataTableStub.ts +53 -0
  317. package/src/typings/plugin.d.ts +5 -0
  318. package/src/typings/shims-vue.d.ts +13 -0
  319. package/src/typings/utilities.d.ts +4 -0
  320. package/src/typings/vite-environment.d.ts +12 -0
@@ -0,0 +1,366 @@
1
+ import {
2
+ describe,
3
+ it,
4
+ expect,
5
+ vi,
6
+ } from 'vitest';
7
+ import { flushPromises, shallowMount } from '@vue/test-utils';
8
+ import {
9
+ Dialog,
10
+ DialogTitle,
11
+ TransitionChild,
12
+ TransitionRoot,
13
+ } from '@headlessui/vue';
14
+ import Confirm from '../AppConfirm.vue';
15
+ import { AppButton } from '~components';
16
+ import HeadlessUiTransitionRootStub from '~/tests/stubs/HeadlessUiTransitionRootStub';
17
+ import HeadlessUiDialogStub from '~/tests/stubs/HeadlessUiDialogStub';
18
+ import HeadlessUiTransitionChildStub from '~/tests/stubs/HeadlessUiTransitionChildStub';
19
+
20
+ import type { ConfirmProps } from '../index.d';
21
+
22
+ function createWrapper(props: ConfirmProps) {
23
+ return shallowMount(Confirm, {
24
+ props,
25
+ global: {
26
+ stubs: {
27
+ Dialog: HeadlessUiDialogStub,
28
+ TransitionRoot: HeadlessUiTransitionRootStub,
29
+ TransitionChild: HeadlessUiTransitionChildStub,
30
+ },
31
+ },
32
+ });
33
+ }
34
+
35
+ describe('generic AppConfirm component', () => {
36
+ it('should display a confirm when title is set', () => {
37
+ const wrapper = createWrapper({ title: 'title' });
38
+
39
+ const transitionWrapper = wrapper.findComponent(TransitionRoot)
40
+ .findComponent(Dialog)
41
+ .findAllComponents(TransitionChild)[1];
42
+
43
+ expect(transitionWrapper.exists()).toBe(true);
44
+ expect(transitionWrapper.isVisible()).toBe(true);
45
+ });
46
+
47
+ it('should set the right title', () => {
48
+ const title = 'This is a test';
49
+
50
+ const wrapper = createWrapper({
51
+ title,
52
+ content: 'Bla',
53
+ });
54
+
55
+ const dialogTitleWrapper = wrapper.findComponent(TransitionRoot)
56
+ .findComponent(Dialog)
57
+ .findAllComponents(TransitionChild)[1]
58
+ .findComponent(DialogTitle);
59
+
60
+ expect(dialogTitleWrapper.text()).toStrictEqual(title);
61
+ });
62
+
63
+ it('should set the right content', () => {
64
+ const content = 'This is test content';
65
+
66
+ const wrapper = createWrapper({
67
+ title: 'This is a test',
68
+ content,
69
+ });
70
+
71
+ const dialogContent = wrapper.findComponent(TransitionRoot)
72
+ .findComponent(Dialog)
73
+ .findAllComponents(TransitionChild)[1]
74
+ .find('[data-test-confirm-content]');
75
+
76
+ expect(dialogContent.text()).toStrictEqual(content);
77
+ });
78
+
79
+ it('should render the content as text by default', () => {
80
+ const content = '<p>This is test content</p>';
81
+ const wrapper = createWrapper({
82
+ title: 'This is a test',
83
+ content,
84
+ });
85
+
86
+ const dialogContent = wrapper.findComponent(TransitionRoot)
87
+ .findComponent(Dialog)
88
+ .findAllComponents(TransitionChild)[1]
89
+ .find('[data-test-confirm-content]');
90
+
91
+ expect(dialogContent.text()).toBe(content);
92
+ });
93
+
94
+ it('should render the content as html when html is enabled', () => {
95
+ const content = '<p>This is test content</p>';
96
+
97
+ const wrapper = createWrapper({
98
+ title: 'This is a test',
99
+ content,
100
+ html: true,
101
+ });
102
+
103
+ const dialogContent = wrapper.findComponent(TransitionRoot)
104
+ .findComponent(Dialog)
105
+ .findAllComponents(TransitionChild)[1]
106
+ .find('[data-test-confirm-content]');
107
+
108
+ expect(dialogContent.text()).toBe('This is test content');
109
+ expect(dialogContent.find('.app-confirm-html-content').find('p').exists()).toBe(true);
110
+ expect(dialogContent.find('.app-confirm-html-content').find('p').text()).toBe('This is test content');
111
+ });
112
+
113
+ it('should be able to set a custom text in confirm button', () => {
114
+ const confirmButtonText = 'huts';
115
+
116
+ const wrapper = createWrapper({
117
+ title: 'This is a test',
118
+ content: 'Bla',
119
+ confirmButtonText,
120
+ cancelButtonText: 'cancel button',
121
+ });
122
+
123
+ const confirmButton = wrapper.findComponent(TransitionRoot)
124
+ .findComponent(Dialog)
125
+ .findAllComponents(TransitionChild)[1]
126
+ .findAllComponents(AppButton)[0];
127
+
128
+ expect(confirmButton.exists()).toBe(true);
129
+ expect(confirmButton.text()).toStrictEqual(confirmButtonText);
130
+ });
131
+
132
+ it('should be able to set a custom text in cancel button', () => {
133
+ const cancelButtonText = 'huts';
134
+
135
+ const wrapper = createWrapper({
136
+ title: 'This is a test',
137
+ content: 'Bla',
138
+ confirmButtonText: 'confirm button',
139
+ cancelButtonText,
140
+ });
141
+
142
+ const cancelButton = wrapper.findComponent(TransitionRoot)
143
+ .findComponent(Dialog)
144
+ .findAllComponents(TransitionChild)[1]
145
+ .findAllComponents(AppButton)[1];
146
+
147
+ expect(cancelButton.exists()).toBe(true);
148
+ expect(cancelButton.text()).toStrictEqual(cancelButtonText);
149
+ });
150
+
151
+ it('should not have a default icon', () => {
152
+ const wrapper = createWrapper({
153
+ title: 'This is a test',
154
+ content: 'Bla',
155
+ });
156
+
157
+ const appIconWrapper = wrapper.findComponent(TransitionRoot)
158
+ .findComponent(Dialog)
159
+ .findAllComponents(TransitionChild)[1]
160
+ .find('[data-test-confirm-icon]');
161
+
162
+ expect(appIconWrapper.exists()).toBe(false);
163
+ });
164
+
165
+ it('should have a default icon for type "success"', () => {
166
+ const wrapper = createWrapper({
167
+ type: 'success',
168
+ title: 'This is a test',
169
+ content: 'Bla',
170
+ });
171
+
172
+ const appIconWrapper = wrapper.findComponent(TransitionRoot)
173
+ .findComponent(Dialog)
174
+ .findAllComponents(TransitionChild)[1]
175
+ .find('[data-test-confirm-icon]');
176
+
177
+ expect(appIconWrapper.isVisible()).toBe(true);
178
+ });
179
+
180
+ it('should emit a close when confirm button is pressed', async () => {
181
+ expect.assertions(2);
182
+
183
+ const wrapper = createWrapper({
184
+ title: 'This is a test',
185
+ content: 'Bla',
186
+ confirmButtonText: 'confirm',
187
+ });
188
+
189
+ const confirmButton = wrapper.findComponent(TransitionRoot)
190
+ .findComponent(Dialog)
191
+ .findAllComponents(TransitionChild)[1]
192
+ .findAllComponents(AppButton)[0];
193
+
194
+ await confirmButton.trigger('click');
195
+
196
+ const emitted = wrapper.emitted<Event[]>();
197
+
198
+ expect(emitted).toHaveProperty('close');
199
+ expect(emitted.close[0][0]).toBe(true);
200
+ });
201
+
202
+ it('should emit a close when cancel button is pressed', async () => {
203
+ expect.assertions(2);
204
+
205
+ const wrapper = createWrapper({
206
+ title: 'This is a test',
207
+ content: 'Bla',
208
+ cancelButtonText: 'confirm',
209
+ });
210
+
211
+ const confirmButton = wrapper.findComponent(TransitionRoot)
212
+ .findComponent(Dialog)
213
+ .findAllComponents(TransitionChild)[1]
214
+ .findAllComponents(AppButton)[0];
215
+
216
+ await confirmButton.trigger('click');
217
+
218
+ const emitted = wrapper.emitted<Event[]>();
219
+
220
+ expect(emitted).toHaveProperty('close');
221
+ expect(emitted.close[0][0]).toBe(false);
222
+ });
223
+
224
+ it('should process promise when onConfirm is function', async () => {
225
+ expect.assertions(3);
226
+
227
+ const onConfirm = vi.fn();
228
+
229
+ const wrapper = createWrapper({
230
+ title: 'This is a test',
231
+ content: 'Bla',
232
+ confirmButtonText: 'confirm',
233
+ onConfirm,
234
+ });
235
+
236
+ const confirmButton = wrapper.findComponent(TransitionRoot)
237
+ .findComponent(Dialog)
238
+ .findAllComponents(TransitionChild)[1]
239
+ .findAllComponents(AppButton)[0];
240
+
241
+ await confirmButton.trigger('click');
242
+
243
+ const emitted = wrapper.emitted<Event[]>();
244
+
245
+ expect(emitted).toHaveProperty('close');
246
+ expect(emitted.close[0][0]).toBe(true);
247
+
248
+ expect(onConfirm).toHaveBeenCalledTimes(1);
249
+ });
250
+
251
+ it('should process promise when onCancel is function', async () => {
252
+ expect.assertions(3);
253
+
254
+ const onCancel = vi.fn();
255
+
256
+ const wrapper = createWrapper({
257
+ title: 'This is a test',
258
+ content: 'Bla',
259
+ cancelButtonText: 'confirm',
260
+ onCancel,
261
+ });
262
+
263
+ const cancelButton = wrapper.findComponent(TransitionRoot)
264
+ .findComponent(Dialog)
265
+ .findAllComponents(TransitionChild)[1]
266
+ .findAllComponents(AppButton)[0];
267
+
268
+ await cancelButton.trigger('click');
269
+
270
+ const emitted = wrapper.emitted<Event[]>();
271
+
272
+ expect(emitted).toHaveProperty('close');
273
+ expect(emitted.close[0][0]).toBe(false);
274
+
275
+ expect(onCancel).toHaveBeenCalledTimes(1);
276
+ });
277
+
278
+ it('should show spinner when confirming', async () => {
279
+ expect.assertions(2);
280
+
281
+ const wrapper = createWrapper({
282
+ title: 'This is a test',
283
+ content: 'Bla',
284
+ confirmButtonText: 'confirm',
285
+ cancelButtonText: 'confirm',
286
+ });
287
+
288
+ // @ts-expect-error setting data on wrapper works in this case but not according to Typescript
289
+ wrapper.vm.confirmLoading = true;
290
+ // @ts-expect-error setting data on wrapper works in this case but not according to Typescript
291
+ wrapper.vm.cancelLoading = true;
292
+
293
+ await flushPromises();
294
+
295
+ const buttons = wrapper.findComponent(TransitionRoot)
296
+ .findComponent(Dialog)
297
+ .findAllComponents(TransitionChild)[1]
298
+ .findAllComponents(AppButton);
299
+
300
+ expect(buttons[0].props('loading')).toBe(true);
301
+ expect(buttons[1].props('loading')).toBe(true);
302
+ });
303
+
304
+ it('should close confirm when backdrop is clicked and preventBackdropClose is "false"', async () => {
305
+ expect.assertions(3);
306
+
307
+ const wrapper = createWrapper({
308
+ title: 'This is a test',
309
+ content: 'BlaBlaBla',
310
+ preventBackdropClose: false,
311
+ });
312
+
313
+ const dialog = wrapper.findComponent(Dialog);
314
+ expect(dialog.exists()).toBe(true);
315
+
316
+ dialog.vm.$emit('close');
317
+
318
+ await flushPromises();
319
+
320
+ const closeConfirmEmit = wrapper.emitted<Event[]>('close');
321
+
322
+ expect(closeConfirmEmit).toBeDefined();
323
+ expect(closeConfirmEmit).toHaveLength(1);
324
+ });
325
+
326
+ it('should not close confirm when backdrop is clicked', async () => {
327
+ expect.assertions(2);
328
+
329
+ const wrapper = createWrapper({
330
+ title: 'This is a test',
331
+ content: 'BlaBlaBla',
332
+ });
333
+
334
+ const dialog = wrapper.findComponent(Dialog);
335
+ expect(dialog.exists()).toBe(true);
336
+
337
+ dialog.vm.$emit('close');
338
+
339
+ await flushPromises();
340
+
341
+ const closeConfirmEmit = wrapper.emitted<Event[]>('close');
342
+
343
+ expect(closeConfirmEmit).toBeUndefined();
344
+ });
345
+
346
+ it('shouldn\'t close confirm when backdrop is clicked with prevent prop', async () => {
347
+ expect.assertions(2);
348
+
349
+ const wrapper = createWrapper({
350
+ title: 'This is a test',
351
+ content: 'BlaBlaBla',
352
+ });
353
+
354
+ await wrapper.setProps({ preventBackdropClose: true });
355
+
356
+ const dialog = wrapper.findComponent(Dialog);
357
+ expect(dialog.exists()).toBe(true);
358
+
359
+ dialog.vm.$emit('close');
360
+ await flushPromises();
361
+
362
+ const closeConfirmEmit = wrapper.emitted<Event[]>('close');
363
+
364
+ expect(closeConfirmEmit).toBeUndefined();
365
+ });
366
+ });
@@ -0,0 +1,31 @@
1
+ import type { Component } from 'vue';
2
+
3
+ export type Confirm = (options: ConfirmProps) => Promise<void>;
4
+ export type ConfirmType = 'default' | 'success' | 'error';
5
+ export type OnConfirm = () => unknown;
6
+ export type OnCancel = () => unknown;
7
+
8
+ export interface ConfirmProps {
9
+ title: string;
10
+ type?: ConfirmType;
11
+ content?: string;
12
+ confirmButtonText?: string;
13
+ confirmButtonTrailingIcon?: Component;
14
+ confirmButtonLeadingIcon?: Component;
15
+ cancelButtonText?: string;
16
+ cancelButtonTrailingIcon?: Component;
17
+ cancelButtonLeadingIcon?: Component;
18
+ withBackdrop?: boolean;
19
+ preventBackdropClose?: boolean;
20
+ icon?: string | Component;
21
+ html?: boolean;
22
+ animate?: boolean;
23
+ extendedIconDomClasses?: string;
24
+ onConfirm?: OnConfirm;
25
+ onCancel?: OnCancel;
26
+ }
27
+
28
+ export interface ConfirmInstance {
29
+ instance: App;
30
+ element: HTMLDivElement;
31
+ }
@@ -0,0 +1 @@
1
+ export const types = ['default', 'success', 'error'] as const;
@@ -0,0 +1,109 @@
1
+ <script lang="ts" setup>
2
+ import { computed, nextTick, onUnmounted, ref } from 'vue';
3
+ import { onClickOutside } from '@vueuse/core';
4
+ import { useActionBar, useClientPoint, useContextMenu, useFocusTrap } from '~composables';
5
+ import AppActionBarItem from '~components/AppActionBar/AppActionBarItem.vue';
6
+ import ShortcutItem from './ShortcutItem.vue';
7
+
8
+ import type { Props, Action } from './index.d';
9
+
10
+ const props = defineProps<Props>();
11
+
12
+ const emit = defineEmits<{
13
+ (event: 'actionClicked', action: Action): void;
14
+ (event: 'close'): void;
15
+ (event: 'open'): void;
16
+ (event: 'cancel'): void;
17
+ }>();
18
+
19
+ const isOpen = ref(true);
20
+ const isLoading = ref(false);
21
+ const actionbar = useActionBar();
22
+ const contextMenu = useContextMenu();
23
+ const contextMenuElement = ref<HTMLDivElement>();
24
+ const clientComputedPosition = useClientPoint(contextMenuElement);
25
+ const { activate, deactivate, onEscape } = useFocusTrap(contextMenuElement);
26
+
27
+ const actionsWithFallback = computed((): Action[] => props.actions ?? actionbar.actions.value);
28
+
29
+ onUnmounted(deactivate);
30
+
31
+ async function open(): Promise<void> {
32
+ isOpen.value = true;
33
+
34
+ emit('open');
35
+
36
+ document.querySelector('#app')?.classList.add('context-menu-open');
37
+
38
+ clientComputedPosition.setPosition(props.event.x, props.event.y);
39
+
40
+ await nextTick();
41
+
42
+ activate();
43
+ }
44
+
45
+ async function close(): Promise<void> {
46
+ isOpen.value = false;
47
+
48
+ deactivate();
49
+
50
+ emit('close');
51
+
52
+ document.querySelector('#app')?.classList.remove('context-menu-open');
53
+ }
54
+
55
+ async function submit(action: Action): Promise<void> {
56
+ emit('actionClicked', action);
57
+
58
+ isOpen.value = false;
59
+
60
+ setTimeout(() => {
61
+ isLoading.value = false;
62
+ }, 300);
63
+ }
64
+
65
+ defineExpose({ isOpen, open, close, submit });
66
+ onClickOutside(contextMenuElement, close);
67
+ onEscape(close);
68
+ </script>
69
+
70
+ <template>
71
+ <div
72
+ v-if="isOpen && (actionsWithFallback.length > 0 || contextMenu.shortcuts.value.length > 0)"
73
+ ref="contextMenuElement"
74
+ :style="`left: ${event.x}px; top: ${event.y}px;`"
75
+ class="app-context-menu fixed z-50 flex w-64 flex-col rounded-lg bg-secondary p-2 drop-shadow-card empty:hidden"
76
+ data-test-context-menu
77
+ >
78
+ <div
79
+ v-if="contextMenu.shortcuts.value.length > 0"
80
+ :class="{ 'mb-2': actionsWithFallback.length > 0 }"
81
+ class="flex justify-between divide-x divide-zinc-600 rounded-md border border-zinc-600"
82
+ >
83
+ <ShortcutItem
84
+ v-for="shortcut in contextMenu.shortcuts.value"
85
+ :key="shortcut.name"
86
+ :shortcut="shortcut"
87
+ :item="item"
88
+ @close="close"
89
+ />
90
+ </div>
91
+
92
+ <AppActionBarItem
93
+ v-for="(action, index) in actionsWithFallback"
94
+ :key="`action-item-${index}`"
95
+ :action="action"
96
+ :context="true"
97
+ :item="item"
98
+ :confirmed="confirmed && confirmed === action.key"
99
+ :tabindex="`100${index}`"
100
+ class="flex h-10 items-center space-x-2 first:rounded-t-lg last:rounded-b-lg focus:outline-none"
101
+ @confirm="deactivate"
102
+ @confirmed="activate"
103
+ @close="close"
104
+ @mouseover="($event) => ($event.target as HTMLDivElement | undefined)?.focus()"
105
+ >
106
+ <span class="text-base">{{ action.name }}</span>
107
+ </AppActionBarItem>
108
+ </div>
109
+ </template>
@@ -0,0 +1,38 @@
1
+ <script lang="ts" setup>
2
+ import { ref } from 'vue';
3
+
4
+ import type { Shortcut } from './index.d';
5
+
6
+ const props = defineProps<{ shortcut: Shortcut; item: unknown }>();
7
+
8
+ const emit = defineEmits<{ (event: 'close'): void }>();
9
+
10
+ const name = ref(props.shortcut.name);
11
+
12
+ async function click(event): Promise<void> {
13
+ const closeOnComplete = await props.shortcut.click(props.shortcut, props.item, event);
14
+
15
+ if (props.shortcut.copied) {
16
+ name.value = 'Gekopieërd';
17
+
18
+ setTimeout(() => {
19
+ name.value = props.shortcut.name;
20
+ }, 1500);
21
+ }
22
+
23
+ if (closeOnComplete === true) {
24
+ emit('close');
25
+ }
26
+ }
27
+ </script>
28
+
29
+ <template>
30
+ <button
31
+ type="button"
32
+ tabindex="-1"
33
+ class="w-full p-1.5 text-xxs text-white cursor-pointer hover:bg-zinc-600 focus:outline-0"
34
+ @click="click"
35
+ >
36
+ {{ shortcut.copied ? name : shortcut.name }}
37
+ </button>
38
+ </template>
@@ -0,0 +1,25 @@
1
+ import { PencilIcon } from '~icons';
2
+
3
+ import type { Shortcut } from '~components/AppContextMenu/index.d';
4
+ import type { Action } from '~components/AppActionBar/index.d';
5
+
6
+ export const shortcutItem: Shortcut = {
7
+ name: 'shortcut',
8
+ click: () => {},
9
+ };
10
+
11
+ export const defaultAction: Action = {
12
+ name: 'Action #1',
13
+ icon: PencilIcon,
14
+ confirm: false,
15
+ type: 'default',
16
+ };
17
+
18
+ export const confirmableAction: Action = {
19
+ name: 'Action confirm',
20
+ icon: PencilIcon,
21
+ confirm: true,
22
+ type: 'danger',
23
+ };
24
+
25
+ export const actions = [defaultAction, confirmableAction];
@@ -0,0 +1,71 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { shallowMount } from '@vue/test-utils';
3
+ import { useContextMenu } from '~composables';
4
+ import { actions as actionsMock, shortcutItem as shortcutItemMock } from '../__mocks__';
5
+ import AppActionBarItem from '~components/AppActionBar/AppActionBarItem.vue';
6
+ import AppContextMenu from '../AppContextMenu.vue';
7
+ import ShortcutItem from '../ShortcutItem.vue';
8
+
9
+ import type { Action } from '~components/AppActionBar/index.d';
10
+
11
+ class MockPointerEvent {}
12
+ const contextMenu = useContextMenu();
13
+
14
+ function createWrapper(actions: Action[] = actionsMock) {
15
+ return shallowMount(AppContextMenu, { props: {
16
+ actions,
17
+ event: new MockPointerEvent() as PointerEvent,
18
+ item: {},
19
+ } });
20
+ }
21
+
22
+ describe('the AppContextMenu ShortcutItem component', () => {
23
+ it('should display the context menu', () => {
24
+ const wrapper = createWrapper();
25
+
26
+ const menu = wrapper.find('[data-test-context-menu]');
27
+ expect(menu.exists()).toBe(true);
28
+ });
29
+
30
+ it('should render the shortcut items when exists', async () => {
31
+ expect.assertions(3);
32
+
33
+ const wrapper = createWrapper();
34
+
35
+ let shortcutItems = wrapper.findAllComponents(ShortcutItem);
36
+ expect(shortcutItems).toHaveLength(0);
37
+
38
+ contextMenu.setShortcuts([shortcutItemMock, shortcutItemMock]);
39
+
40
+ await wrapper.vm.$nextTick();
41
+
42
+ shortcutItems = wrapper.findAllComponents(ShortcutItem);
43
+ expect(shortcutItems).toHaveLength(2);
44
+ expect(shortcutItems[0].props('shortcut')).toStrictEqual(shortcutItemMock);
45
+ });
46
+
47
+ it('should render the actionbar items', () => {
48
+ expect.assertions(5);
49
+
50
+ const wrapper = createWrapper();
51
+
52
+ const actionBarItems = wrapper.findAllComponents(AppActionBarItem);
53
+ expect(actionBarItems).toHaveLength(2);
54
+ expect(actionBarItems[0].props('action')).toStrictEqual(actionsMock[0]);
55
+ expect(actionBarItems[1].props('action')).toStrictEqual(actionsMock[1]);
56
+ expect(actionBarItems[1].props('context')).toBe(true);
57
+ expect(actionBarItems[1].text()).toBe(actionsMock[1].name);
58
+ });
59
+
60
+ it('should emit when action bar items emits close', () => {
61
+ expect.assertions(1);
62
+
63
+ const wrapper = createWrapper();
64
+
65
+ const actionBarItem = wrapper.findComponent(AppActionBarItem);
66
+
67
+ actionBarItem.vm.$emit('close');
68
+
69
+ expect(wrapper.emitted()).toHaveProperty('close');
70
+ });
71
+ });
@@ -0,0 +1,29 @@
1
+ import { describe, it, expect, vi } from 'vitest';
2
+ import { shallowMount } from '@vue/test-utils';
3
+ import { shortcutItem as shortcutItemMock } from '../__mocks__';
4
+ import ShortcutItem from '../ShortcutItem.vue';
5
+
6
+ import type { Shortcut } from '~components/AppContextMenu';
7
+
8
+ function createWrapper(shortcut: Shortcut = shortcutItemMock) {
9
+ return shallowMount(ShortcutItem, { props: { shortcut, item: {} } });
10
+ }
11
+
12
+ describe('the AppContextMenu ShortcutItem component', () => {
13
+ it('should display the name', () => {
14
+ const wrapper = createWrapper();
15
+
16
+ expect(wrapper.text()).toBe(shortcutItemMock.name);
17
+ });
18
+
19
+ it('should execute click event', async () => {
20
+ expect.assertions(1);
21
+
22
+ const clickSpy = vi.fn();
23
+ const wrapper = createWrapper({ ...shortcutItemMock, click: clickSpy });
24
+
25
+ await wrapper.trigger('click');
26
+
27
+ expect(clickSpy).toHaveBeenCalledTimes(1);
28
+ });
29
+ });
@@ -0,0 +1,23 @@
1
+ import type { App } from 'vue';
2
+ import type AppContextMenu from './AppContextMenu.vue';
3
+
4
+ export type { Action } from '~components/AppActionBar/index.d';
5
+
6
+ export interface Props {
7
+ item: unknown;
8
+ event: PointerEvent | MouseEvent;
9
+ actions?: Action[];
10
+ confirmed?: Action['key'];
11
+ }
12
+
13
+ export interface ContextMenuInstance {
14
+ ref: AppContextMenu;
15
+ instance: App;
16
+ element: HTMLDivElement;
17
+ }
18
+
19
+ export interface Shortcut {
20
+ name: string;
21
+ click: (shortcut: Shortcut, item: unknown, event: MouseEvent | PointerEvent) => boolean | void;
22
+ copied?: boolean;
23
+ }