@privyid/persona 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (330) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +4 -0
  3. package/dist/components/app/App.vue +3 -2
  4. package/dist/components/aspect-ratio/index.d.ts +3 -0
  5. package/dist/components/aspect-ratio/index.mjs +21 -0
  6. package/dist/components/aspect-ratio/utils/calculate-ratio.d.ts +7 -0
  7. package/dist/components/aspect-ratio/utils/calculate-ratio.mjs +10 -0
  8. package/dist/components/aspect-ratio/utils/resize-observer.d.ts +1 -0
  9. package/dist/components/aspect-ratio/utils/resize-observer.mjs +22 -0
  10. package/dist/components/avatar/Avatar.vue +1 -1
  11. package/dist/components/avatar/Avatar.vue.d.ts +1 -2
  12. package/dist/components/avatar/index.d.ts +2 -0
  13. package/dist/components/avatar/index.mjs +0 -0
  14. package/dist/components/badge/Badge.vue +33 -58
  15. package/dist/components/badge/Badge.vue.d.ts +1 -2
  16. package/dist/components/badge/index.d.ts +2 -0
  17. package/dist/components/badge/index.mjs +0 -0
  18. package/dist/components/banner/Banner.vue +23 -9
  19. package/dist/components/banner/Banner.vue.d.ts +1 -1
  20. package/dist/components/banner/index.d.ts +1 -0
  21. package/dist/components/banner/index.mjs +0 -0
  22. package/dist/components/button/Button.vue +74 -77
  23. package/dist/components/button/Button.vue.d.ts +1 -3
  24. package/dist/components/button/index.d.ts +3 -0
  25. package/dist/components/button/index.mjs +0 -0
  26. package/dist/components/button-group/ButtonGroup.vue +126 -63
  27. package/dist/components/button-group/ButtonGroup.vue.d.ts +1 -0
  28. package/dist/components/calendar/Calendar.vue +31 -30
  29. package/dist/components/calendar/adapter/adapter.d.ts +7 -0
  30. package/dist/components/calendar/adapter/adapter.mjs +8 -0
  31. package/dist/components/calendar/adapter/date.mjs +6 -4
  32. package/dist/components/calendar/adapter/month.mjs +2 -3
  33. package/dist/components/camera/Camera.vue +383 -0
  34. package/dist/components/camera/Camera.vue.d.ts +94 -0
  35. package/dist/components/camera/adapter/adapter.d.ts +41 -0
  36. package/dist/components/camera/adapter/adapter.mjs +3 -0
  37. package/dist/components/camera/adapter/capture.d.ts +5 -0
  38. package/dist/components/camera/adapter/capture.mjs +12 -0
  39. package/dist/components/camera/adapter/liveness.d.ts +5 -0
  40. package/dist/components/camera/adapter/liveness.mjs +46 -0
  41. package/dist/components/camera/adapter/qr-code.d.ts +2 -0
  42. package/dist/components/camera/adapter/qr-code.mjs +19 -0
  43. package/dist/components/camera/assets/shutter.wav +0 -0
  44. package/dist/components/camera/utils/motion.d.ts +29 -0
  45. package/dist/components/camera/utils/motion.mjs +88 -0
  46. package/dist/components/camera/utils/take-picture.d.ts +1 -0
  47. package/dist/components/camera/utils/take-picture.mjs +14 -0
  48. package/dist/components/caption/Caption.vue +60 -7
  49. package/dist/components/caption/Caption.vue.d.ts +27 -7
  50. package/dist/components/card/Card.vue +14 -8
  51. package/dist/components/card/Card.vue.d.ts +10 -1
  52. package/dist/components/card/CardSection.vue +2 -1
  53. package/dist/components/card/index.d.ts +1 -0
  54. package/dist/components/card/index.mjs +0 -0
  55. package/dist/components/chart/Chart.vue +6 -3
  56. package/dist/components/chart/Chart.vue.d.ts +1 -2
  57. package/dist/components/chart/index.d.ts +2 -0
  58. package/dist/components/chart/index.mjs +0 -0
  59. package/dist/components/chart/{use-chart.d.ts → utils/use-chart.d.ts} +0 -0
  60. package/dist/components/chart/{use-chart.mjs → utils/use-chart.mjs} +0 -0
  61. package/dist/components/checkbox/Checkbox.vue +47 -14
  62. package/dist/components/checkbox/Checkbox.vue.d.ts +0 -4
  63. package/dist/components/checkbox/{use-checkbox.d.ts → index.d.ts} +1 -1
  64. package/dist/components/checkbox/{use-checkbox.mjs → index.mjs} +0 -0
  65. package/dist/components/collapse/Collapse.vue +88 -0
  66. package/dist/components/collapse/Collapse.vue.d.ts +29 -0
  67. package/dist/components/contextual-bar/ContextualBar.vue +292 -0
  68. package/dist/components/contextual-bar/ContextualBar.vue.d.ts +78 -0
  69. package/dist/components/contextual-bar/assets/images/img-background-contextualbar.svg +14 -0
  70. package/dist/components/contextual-bar/assets/images/img-bg-contextualbar.svg +19 -0
  71. package/dist/components/contextual-bar/index.d.ts +1 -0
  72. package/dist/components/contextual-bar/index.mjs +0 -0
  73. package/dist/components/cropper/Cropper.vue +423 -0
  74. package/dist/components/cropper/Cropper.vue.d.ts +149 -0
  75. package/dist/components/cropper/assets/ps-neutral.png +0 -0
  76. package/dist/components/cropper/assets/sample-1.jpg +0 -0
  77. package/dist/components/cropper/utils/crop-image.d.ts +44 -0
  78. package/dist/components/cropper/utils/crop-image.mjs +43 -0
  79. package/dist/components/cropper/utils/use-pinch.d.ts +8 -0
  80. package/dist/components/cropper/utils/use-pinch.mjs +42 -0
  81. package/dist/components/cropper/utils/use-ratio.d.ts +9 -0
  82. package/dist/components/cropper/utils/use-ratio.mjs +24 -0
  83. package/dist/components/datepicker/Datepicker.vue +14 -5
  84. package/dist/components/datepicker/Datepicker.vue.d.ts +9 -0
  85. package/dist/components/dialog/Dialog.vue +2 -0
  86. package/dist/components/dialog/Dialog.vue.d.ts +1 -1
  87. package/dist/components/dialog/DialogFooter.vue +4 -2
  88. package/dist/components/dialog/DialogFooter.vue.d.ts +2 -1
  89. package/dist/components/dialog/index.d.ts +31 -6
  90. package/dist/components/dialog/index.mjs +32 -5
  91. package/dist/components/divider/Divider.vue +22 -2
  92. package/dist/components/dot/Dot.vue +27 -20
  93. package/dist/components/dot/Dot.vue.d.ts +10 -1
  94. package/dist/components/dot/index.d.ts +2 -0
  95. package/dist/components/dot/index.mjs +0 -0
  96. package/dist/components/dropdown/Dropdown.vue +73 -21
  97. package/dist/components/dropdown/Dropdown.vue.d.ts +16 -12
  98. package/dist/components/dropdown/DropdownItem.vue +3 -3
  99. package/dist/components/dropdown/index.d.ts +9 -0
  100. package/dist/components/dropdown/index.mjs +1 -0
  101. package/dist/components/dropdown/utils/use-focus.d.ts +1 -1
  102. package/dist/components/dropdown/utils/use-focus.mjs +4 -2
  103. package/dist/components/dropdown-subitem/DropdownSubitem.vue +12 -12
  104. package/dist/components/dropdown-subitem/DropdownSubitem.vue.d.ts +1 -1
  105. package/dist/components/dropdown-subitem/{use-dropdown-subitem.d.ts → index.d.ts} +0 -0
  106. package/dist/components/dropdown-subitem/{use-dropdown-subitem.mjs → index.mjs} +0 -0
  107. package/dist/components/dropzone/Dropzone.vue +202 -0
  108. package/dist/components/dropzone/Dropzone.vue.d.ts +93 -0
  109. package/dist/components/dropzone/index.d.ts +4 -0
  110. package/dist/components/dropzone/index.mjs +0 -0
  111. package/dist/components/dropzone/utils/accept.d.ts +1 -0
  112. package/dist/components/dropzone/utils/accept.mjs +17 -0
  113. package/dist/components/filterbar/Filterbar.vue +7 -5
  114. package/dist/components/filterbar/Filterbar.vue.d.ts +1 -1
  115. package/dist/components/filterbar/{use-filterbar.d.ts → index.d.ts} +1 -1
  116. package/dist/components/filterbar/{use-filterbar.mjs → index.mjs} +0 -0
  117. package/dist/components/filterbar/pinned/Date.vue +9 -7
  118. package/dist/components/filterbar/pinned/Date.vue.d.ts +1 -1
  119. package/dist/components/filterbar/pinned/Multiselect.vue +16 -13
  120. package/dist/components/filterbar/pinned/Multiselect.vue.d.ts +2 -2
  121. package/dist/components/filterbar/pinned/Select.vue +11 -8
  122. package/dist/components/filterbar/pinned/Select.vue.d.ts +2 -2
  123. package/dist/components/filterbar/pinned/Toggle.vue +2 -1
  124. package/dist/components/filterbar/pinned/Toggle.vue.d.ts +1 -1
  125. package/dist/components/form-group/FormGroup.vue +103 -0
  126. package/dist/components/form-group/FormGroup.vue.d.ts +61 -0
  127. package/dist/components/global/context.d.ts +24 -0
  128. package/dist/components/global/context.mjs +18 -0
  129. package/dist/components/global/router.d.ts +23 -0
  130. package/dist/components/global/router.mjs +7 -0
  131. package/dist/components/global/use-singleton.d.ts +17 -2
  132. package/dist/components/global/use-singleton.mjs +18 -10
  133. package/dist/components/heading/Heading.vue +50 -0
  134. package/dist/components/heading/Heading.vue.d.ts +19 -1
  135. package/dist/components/heading/index.d.ts +3 -0
  136. package/dist/components/heading/index.mjs +0 -0
  137. package/dist/components/input/Input.vue +119 -24
  138. package/dist/components/input/Input.vue.d.ts +38 -2
  139. package/dist/components/input/{use-input.d.ts → index.d.ts} +0 -0
  140. package/dist/components/input/{use-input.mjs → index.mjs} +0 -0
  141. package/dist/components/input-file/InputFile.vue +171 -0
  142. package/dist/components/input-file/InputFile.vue.d.ts +120 -0
  143. package/dist/components/input-group/InputGroup.vue +131 -0
  144. package/dist/components/input-group/InputGroup.vue.d.ts +45 -0
  145. package/dist/components/input-group/InputGroupAddon.vue +43 -0
  146. package/dist/components/input-password/InputPassword.vue +62 -0
  147. package/dist/components/input-password/InputPassword.vue.d.ts +5 -0
  148. package/dist/components/input-password/index.d.ts +2 -0
  149. package/dist/components/input-password/index.mjs +17 -0
  150. package/dist/components/input-pin/InputPin.vue +145 -0
  151. package/dist/components/input-pin/InputPin.vue.d.ts +64 -0
  152. package/dist/components/input-range/InputRange.vue +274 -0
  153. package/dist/components/input-range/InputRange.vue.d.ts +108 -0
  154. package/dist/components/input-range/utils/use-drag.d.ts +3 -0
  155. package/dist/components/input-range/utils/use-drag.mjs +19 -0
  156. package/dist/components/label/Label.vue +29 -41
  157. package/dist/components/label/Label.vue.d.ts +1 -1
  158. package/dist/components/markdown/index.d.ts +20 -0
  159. package/dist/components/markdown/index.mjs +15 -0
  160. package/dist/components/modal/Modal.vue +71 -5
  161. package/dist/components/modal/Modal.vue.d.ts +30 -0
  162. package/dist/components/nav/Nav.vue +16 -14
  163. package/dist/components/nav/Nav.vue.d.ts +3 -4
  164. package/dist/components/nav/NavForm.vue +19 -0
  165. package/dist/components/nav/NavItem.vue +14 -4
  166. package/dist/components/nav/NavItem.vue.d.ts +3 -4
  167. package/dist/components/nav/NavItemDropdown.vue +5 -1
  168. package/dist/components/nav/NavItemDropdown.vue.d.ts +9 -0
  169. package/dist/components/nav/NavSubItem.vue +5 -5
  170. package/dist/components/nav/index.d.ts +2 -0
  171. package/dist/components/nav/index.mjs +0 -0
  172. package/dist/components/navbar/Navbar.vue +143 -0
  173. package/dist/components/navbar/Navbar.vue.d.ts +57 -0
  174. package/dist/components/navbar/NavbarBrand.vue +33 -0
  175. package/dist/components/navbar/NavbarBrand.vue.d.ts +14 -0
  176. package/dist/components/navbar/NavbarNav.vue +109 -0
  177. package/dist/components/navbar/NavbarNav.vue.d.ts +19 -0
  178. package/dist/components/navbar/NavbarToggle.vue +74 -0
  179. package/dist/components/navbar/NavbarToggle.vue.d.ts +6 -0
  180. package/dist/components/navbar/index.d.ts +10 -0
  181. package/dist/components/navbar/index.mjs +1 -0
  182. package/dist/components/navbar-menu/NavbarNavMenu.vue +62 -0
  183. package/dist/components/navbar-menu/NavbarNavMenu.vue.d.ts +16 -0
  184. package/dist/components/overlay/Overlay.vue +8 -3
  185. package/dist/components/overlay/Overlay.vue.d.ts +14 -3
  186. package/dist/components/overlay/{use-overlay.d.ts → index.d.ts} +0 -0
  187. package/dist/components/overlay/{use-overlay.mjs → index.mjs} +0 -0
  188. package/dist/components/progress/Progress.vue +200 -0
  189. package/dist/components/progress/Progress.vue.d.ts +42 -0
  190. package/dist/components/progress/ProgressItem.vue +50 -0
  191. package/dist/components/progress/ProgressItem.vue.d.ts +25 -0
  192. package/dist/components/radio/Radio.vue +88 -31
  193. package/dist/components/radio/Radio.vue.d.ts +6 -6
  194. package/dist/components/radio/{use-radio.d.ts → index.d.ts} +1 -1
  195. package/dist/components/radio/{use-radio.mjs → index.mjs} +0 -0
  196. package/dist/components/select/Select.vue +10 -4
  197. package/dist/components/select/Select.vue.d.ts +11 -2
  198. package/dist/components/select/adapter/adapter.d.ts +1 -1
  199. package/dist/components/select/adapter/async-adapter.d.ts +1 -1
  200. package/dist/components/select/{use-select.d.ts → index.d.ts} +0 -0
  201. package/dist/components/select/{use-select.mjs → index.mjs} +0 -0
  202. package/dist/components/sidebar/Sidebar.vue +3 -3
  203. package/dist/components/sidebar/Sidebar.vue.d.ts +4 -9
  204. package/dist/components/sidebar/SidebarNav.vue +11 -11
  205. package/dist/components/sidebar/SidebarNav.vue.d.ts +2 -2
  206. package/dist/components/sidebar/index.d.ts +9 -0
  207. package/dist/components/sidebar/index.mjs +1 -0
  208. package/dist/components/sidebar-menu/SidebarMenu.vue.d.ts +4 -2
  209. package/dist/components/sidebar-menu/{use-sidebar-menu.d.ts → index.d.ts} +2 -0
  210. package/dist/components/sidebar-menu/{use-sidebar-menu.mjs → index.mjs} +0 -0
  211. package/dist/components/signature-draw/SignatureDraw.vue +1 -1
  212. package/dist/components/signature-draw/SignatureDrawDesktop.vue +5 -5
  213. package/dist/components/signature-draw/SignatureDrawMobile.vue +17 -5
  214. package/dist/components/signature-draw/utils/canvas.d.ts +7 -1
  215. package/dist/components/signature-draw/utils/canvas.mjs +8 -2
  216. package/dist/components/signature-draw/utils/use-draw.mjs +6 -5
  217. package/dist/components/signature-text/SignatureText.vue +1 -1
  218. package/dist/components/signature-text/SignatureText.vue.d.ts +1 -1
  219. package/dist/components/signature-text/utils/formatter.mjs +1 -1
  220. package/dist/components/spinner/Spinner.vue +1 -0
  221. package/dist/components/spinner/SpinnerRing.vue +1 -0
  222. package/dist/components/spread/Spread.vue +55 -0
  223. package/dist/components/spread/Spread.vue.d.ts +14 -0
  224. package/dist/components/steps/Step.vue +55 -0
  225. package/dist/components/steps/Step.vue.d.ts +32 -0
  226. package/dist/components/steps/StepSlider.vue +39 -0
  227. package/dist/components/steps/StepSlider.vue.d.ts +25 -0
  228. package/dist/components/steps/Steps.vue +111 -0
  229. package/dist/components/steps/Steps.vue.d.ts +56 -0
  230. package/dist/components/steps/index.d.ts +26 -0
  231. package/dist/components/steps/index.mjs +52 -0
  232. package/dist/components/steps/utils/hook.d.ts +10 -0
  233. package/dist/components/steps/utils/hook.mjs +34 -0
  234. package/dist/components/strengthbar/Strengthbar.vue +96 -0
  235. package/dist/components/strengthbar/Strengthbar.vue.d.ts +45 -0
  236. package/dist/components/subheading/Subheading.vue +65 -20
  237. package/dist/components/subheading/Subheading.vue.d.ts +23 -5
  238. package/dist/components/subheading/index.d.ts +1 -0
  239. package/dist/components/subheading/index.mjs +0 -0
  240. package/dist/components/table/Table.vue +21 -9
  241. package/dist/components/table/Table.vue.d.ts +1 -1
  242. package/dist/components/table/{use-table.d.ts → index.d.ts} +0 -0
  243. package/dist/components/table/{use-table.mjs → index.mjs} +0 -0
  244. package/dist/components/tabs/TabContent.vue +2 -2
  245. package/dist/components/tabs/Tabs.vue +12 -9
  246. package/dist/components/tabs/Tabs.vue.d.ts +2 -1
  247. package/dist/components/textarea/Textarea.vue +27 -16
  248. package/dist/components/textarea/Textarea.vue.d.ts +10 -1
  249. package/dist/components/toast/Toast.vue +102 -72
  250. package/dist/components/toast/Toast.vue.d.ts +1 -1
  251. package/dist/components/toast/ToastContainer.vue +1 -1
  252. package/dist/components/toast/ToastContainer.vue.d.ts +3 -3
  253. package/dist/components/toast/{use-toast.d.ts → index.d.ts} +1 -1
  254. package/dist/components/toast/index.mjs +6 -0
  255. package/dist/components/toggle/Toggle.vue +17 -21
  256. package/dist/components/tooltip/Tooltip.vue +161 -0
  257. package/dist/components/tooltip/Tooltip.vue.d.ts +51 -0
  258. package/dist/components/tooltip/TooltipContainer.vue +66 -0
  259. package/dist/components/tooltip/TooltipContainer.vue.d.ts +11 -0
  260. package/dist/components/tooltip/index.d.ts +14 -0
  261. package/dist/components/tooltip/index.mjs +82 -0
  262. package/dist/components/tooltip/utils/create-handler.d.ts +9 -0
  263. package/dist/components/tooltip/utils/create-handler.mjs +16 -0
  264. package/dist/components/tooltip/utils/parse-bindings.d.ts +22 -0
  265. package/dist/components/tooltip/utils/parse-bindings.mjs +45 -0
  266. package/dist/components/tour/Tour.vue +105 -0
  267. package/dist/components/tour/Tour.vue.d.ts +11 -0
  268. package/dist/components/tour/TourDialog.vue +204 -0
  269. package/dist/components/tour/TourDialog.vue.d.ts +108 -0
  270. package/dist/components/tour/TourHighlight.vue +57 -0
  271. package/dist/components/tour/TourHighlight.vue.d.ts +15 -0
  272. package/dist/components/tour/core/base.d.ts +59 -0
  273. package/dist/components/tour/core/base.mjs +43 -0
  274. package/dist/components/tour/core/step/action.d.ts +15 -0
  275. package/dist/components/tour/core/step/action.mjs +14 -0
  276. package/dist/components/tour/core/step/conditional.d.ts +26 -0
  277. package/dist/components/tour/core/step/conditional.mjs +69 -0
  278. package/dist/components/tour/core/step/delay.d.ts +8 -0
  279. package/dist/components/tour/core/step/delay.mjs +9 -0
  280. package/dist/components/tour/core/step/dialog.d.ts +11 -0
  281. package/dist/components/tour/core/step/dialog.mjs +25 -0
  282. package/dist/components/tour/core/step/visit.d.ts +9 -0
  283. package/dist/components/tour/core/step/visit.mjs +18 -0
  284. package/dist/components/tour/core/step.d.ts +37 -0
  285. package/dist/components/tour/core/step.mjs +30 -0
  286. package/dist/components/tour/core/story.d.ts +130 -0
  287. package/dist/components/tour/core/story.mjs +85 -0
  288. package/dist/components/tour/core/tour.d.ts +120 -0
  289. package/dist/components/tour/core/tour.mjs +133 -0
  290. package/dist/components/tour/index.d.ts +3 -0
  291. package/dist/components/tour/index.mjs +4 -0
  292. package/dist/components/tour/utils/is-visible.d.ts +2 -0
  293. package/dist/components/tour/utils/is-visible.mjs +35 -0
  294. package/dist/components/tour/utils/use-selector.d.ts +3 -0
  295. package/dist/components/tour/utils/use-selector.mjs +25 -0
  296. package/dist/components/tour/utils/wait-element.d.ts +6 -0
  297. package/dist/components/tour/utils/wait-element.mjs +44 -0
  298. package/dist/components/utils/base64.d.ts +8 -0
  299. package/dist/components/utils/base64.mjs +29 -0
  300. package/dist/components/utils/color.d.ts +6 -1
  301. package/dist/components/utils/color.mjs +4 -0
  302. package/dist/components/utils/value.mjs +2 -1
  303. package/dist/components/utils/vnode.d.ts +14 -1
  304. package/dist/components/utils/vnode.mjs +5 -2
  305. package/dist/components/wizard/Wizard.vue +85 -0
  306. package/dist/components/wizard/Wizard.vue.d.ts +72 -0
  307. package/dist/components/wizard/WizardBody.vue +50 -0
  308. package/dist/components/wizard/WizardBody.vue.d.ts +23 -0
  309. package/dist/components/wizard/WizardHeader.vue +38 -0
  310. package/dist/components/wizard/WizardHeader.vue.d.ts +16 -0
  311. package/dist/components/wizard/WizardStep.vue +20 -0
  312. package/dist/components/wizard/WizardStep.vue.d.ts +34 -0
  313. package/dist/core/index.d.ts +16 -6
  314. package/dist/core/index.mjs +37 -6
  315. package/dist/directive/index.d.ts +3 -0
  316. package/dist/directive/index.mjs +12 -0
  317. package/dist/module.d.ts +9 -2
  318. package/dist/module.json +1 -1
  319. package/dist/module.mjs +1613 -4
  320. package/dist/runtime/plugin.d.ts +2 -0
  321. package/dist/runtime/plugin.mjs +14 -0
  322. package/dist/types.d.ts +5 -1
  323. package/package.json +46 -9
  324. package/dist/components/dialog/use-dialog.d.ts +0 -28
  325. package/dist/components/dialog/use-dialog.mjs +0 -31
  326. package/dist/components/dropdown/utils/use-popper.d.ts +0 -6
  327. package/dist/components/dropdown/utils/use-popper.mjs +0 -32
  328. package/dist/components/input/InputGroup.vue +0 -25
  329. package/dist/components/toast/use-toast.mjs +0 -5
  330. package/dist/core/index.cjs +0 -75
@@ -0,0 +1,59 @@
1
+ import { Hook } from '../../steps/utils/hook';
2
+ export declare type TourActionHook = (to: AbstractTour, from: AbstractTour) => boolean | Promise<boolean>;
3
+ export declare enum TourDirection {
4
+ FORWARD = 1,
5
+ BACKWARD = -1
6
+ }
7
+ export interface BaseTourOptions {
8
+ /**
9
+ * Uniq identifier, can be string or symbol
10
+ * use for edit and remove
11
+ */
12
+ name?: string | symbol;
13
+ /**
14
+ * on-before-prev hook
15
+ */
16
+ onBeforePrev?: TourActionHook;
17
+ /**
18
+ * on-before-next hook
19
+ */
20
+ onBeforeNext?: TourActionHook;
21
+ }
22
+ export declare abstract class AbstractTour<Options extends BaseTourOptions = BaseTourOptions> {
23
+ name?: string | symbol;
24
+ /**
25
+ * Step direction, 1 for forward (next), -1 for backward (prev)
26
+ */
27
+ protected direction: TourDirection;
28
+ protected parent?: AbstractTour;
29
+ protected options: Options;
30
+ protected onNextHooks: Hook<TourActionHook>;
31
+ protected onPrevHooks: Hook<TourActionHook>;
32
+ protected runOnPrevHooks: TourActionHook;
33
+ protected runOnNextHooks: TourActionHook;
34
+ constructor(options?: Options);
35
+ setParent(parent: AbstractTour): this;
36
+ /**
37
+ * Get options with parent options as fallback
38
+ */
39
+ getOptions(): Options;
40
+ /**
41
+ * Set tour direction
42
+ * @param direction 1 for forward (next) and -1 for backward (prev)
43
+ */
44
+ setDirection(direction: TourDirection): this;
45
+ /**
46
+ * Attach to parent
47
+ * @param parent Parent Instance
48
+ */
49
+ attach(parent: AbstractTour): this;
50
+ /**
51
+ * Deattach from parent
52
+ * @param parent Parent Instance
53
+ */
54
+ detach(parent: AbstractTour): this;
55
+ abstract start(): void | Promise<void>;
56
+ abstract stop(): void | Promise<void>;
57
+ abstract next(): void | Promise<void>;
58
+ abstract prev(): void | Promise<void>;
59
+ }
@@ -0,0 +1,43 @@
1
+ import defu from "defu";
2
+ import { Hook } from "../../steps/utils/hook.mjs";
3
+ export var TourDirection = /* @__PURE__ */ ((TourDirection2) => {
4
+ TourDirection2[TourDirection2["FORWARD"] = 1] = "FORWARD";
5
+ TourDirection2[TourDirection2["BACKWARD"] = -1] = "BACKWARD";
6
+ return TourDirection2;
7
+ })(TourDirection || {});
8
+ export class AbstractTour {
9
+ constructor(options) {
10
+ this.direction = 1 /* FORWARD */;
11
+ this.name = options?.name ?? Symbol("TourID");
12
+ this.options = options;
13
+ this.onPrevHooks = new Hook();
14
+ this.onNextHooks = new Hook();
15
+ if (typeof options?.onBeforePrev === "function")
16
+ this.onPrevHooks.add(options.onBeforePrev);
17
+ if (typeof options?.onBeforeNext === "function")
18
+ this.onNextHooks.add(options.onBeforeNext);
19
+ this.runOnPrevHooks = async (...args) => await this.onPrevHooks.run(...args);
20
+ this.runOnNextHooks = async (...args) => await this.onNextHooks.run(...args);
21
+ }
22
+ setParent(parent) {
23
+ this.parent = parent;
24
+ return this;
25
+ }
26
+ getOptions() {
27
+ return defu(this.options, this.parent?.getOptions());
28
+ }
29
+ setDirection(direction) {
30
+ this.direction = direction;
31
+ return this;
32
+ }
33
+ attach(parent) {
34
+ parent.onPrevHooks.add(this.runOnPrevHooks);
35
+ parent.onNextHooks.add(this.runOnNextHooks);
36
+ return this;
37
+ }
38
+ detach(parent) {
39
+ parent.onPrevHooks.remove(this.runOnPrevHooks);
40
+ parent.onNextHooks.remove(this.runOnNextHooks);
41
+ return this;
42
+ }
43
+ }
@@ -0,0 +1,15 @@
1
+ import userEvent from '@testing-library/user-event';
2
+ import { AbstractStep } from '../step';
3
+ declare type UserEvent = ReturnType<typeof userEvent['setup']>;
4
+ declare type ExtractParams<F> = F extends (T: Element, ...args: infer P) => Promise<void> ? P : unknown[];
5
+ export declare type EventType = 'click' | 'dblClick' | 'tripleClick' | 'type' | 'hover' | 'unhover' | 'clear';
6
+ export declare type ParamsOf<E extends EventType> = ExtractParams<UserEvent[E]>;
7
+ export interface ActionOptions<E extends EventType> {
8
+ target: string;
9
+ action: E;
10
+ params: ParamsOf<E>;
11
+ }
12
+ export default class StepAction<E extends EventType> extends AbstractStep<ActionOptions<E>> {
13
+ protected run(): Promise<void>;
14
+ }
15
+ export {};
@@ -0,0 +1,14 @@
1
+ import userEvent from "@testing-library/user-event";
2
+ import { AbstractStep } from "../step.mjs";
3
+ import { waitElement } from "../../utils/wait-element.mjs";
4
+ export default class StepAction extends AbstractStep {
5
+ async run() {
6
+ const options = this.getOptions();
7
+ const target = await waitElement(options.target, options.waitTimeout);
8
+ const user = userEvent.setup({ document });
9
+ const action = options.action;
10
+ const params = options.params ?? [];
11
+ await user[action].apply(void 0, [target, ...params]);
12
+ await this.ahead();
13
+ }
14
+ }
@@ -0,0 +1,26 @@
1
+ import { MaybeRef } from '@vueuse/shared';
2
+ import { AbstractStep } from '../step';
3
+ import { Tour } from '../tour';
4
+ export interface ConditionalOptions {
5
+ condition: MaybeRef<boolean | (() => boolean | Promise<boolean>)>;
6
+ tour: Tour;
7
+ }
8
+ export declare enum ConditionalType {
9
+ IF = 1,
10
+ ELSE_IF = 2,
11
+ ELSE = 3
12
+ }
13
+ interface Routine extends ConditionalOptions {
14
+ type: ConditionalType;
15
+ }
16
+ export default class StepCondition extends AbstractStep<ConditionalOptions> {
17
+ protected routines: Routine[];
18
+ constructor(options: ConditionalOptions);
19
+ protected checkCondition(): Promise<boolean>;
20
+ canChain(): boolean;
21
+ chain(routine: Routine): this;
22
+ getTotalChild(): number;
23
+ getRoutines(): Routine[];
24
+ protected run(): Promise<void>;
25
+ }
26
+ export {};
@@ -0,0 +1,69 @@
1
+ import { unref } from "vue-demi";
2
+ import { TourDirection } from "../base.mjs";
3
+ import { AbstractStep } from "../step.mjs";
4
+ export var ConditionalType = /* @__PURE__ */ ((ConditionalType2) => {
5
+ ConditionalType2[ConditionalType2["IF"] = 1] = "IF";
6
+ ConditionalType2[ConditionalType2["ELSE_IF"] = 2] = "ELSE_IF";
7
+ ConditionalType2[ConditionalType2["ELSE"] = 3] = "ELSE";
8
+ return ConditionalType2;
9
+ })(ConditionalType || {});
10
+ export default class StepCondition extends AbstractStep {
11
+ constructor(options) {
12
+ super(options);
13
+ this.routines = [
14
+ {
15
+ type: 1 /* IF */,
16
+ condition: options.condition,
17
+ tour: options.tour
18
+ }
19
+ ];
20
+ }
21
+ async checkCondition() {
22
+ try {
23
+ const options = this.getOptions();
24
+ const condition = unref(options.condition);
25
+ return typeof condition === "function" ? await condition() : condition;
26
+ } catch (error) {
27
+ if (import.meta.env.DEV)
28
+ console.warn(error);
29
+ return false;
30
+ }
31
+ }
32
+ canChain() {
33
+ return this.routines.at(-1).type !== 3 /* ELSE */;
34
+ }
35
+ chain(routine) {
36
+ this.routines.push(routine);
37
+ return this;
38
+ }
39
+ getTotalChild() {
40
+ return Math.max(...this.routines.map((routine) => routine.tour.getTotalChild()));
41
+ }
42
+ getRoutines() {
43
+ return this.routines;
44
+ }
45
+ async run() {
46
+ let result = false;
47
+ for (const routine of this.routines) {
48
+ const condition = unref(routine.condition);
49
+ try {
50
+ result = typeof condition === "function" ? await condition() : condition;
51
+ } catch (error) {
52
+ if (import.meta.env.DEV)
53
+ console.warn(error);
54
+ result = false;
55
+ }
56
+ if (result) {
57
+ const tour = routine.tour;
58
+ const index = this.direction === TourDirection.BACKWARD ? tour.getSteps().length - 1 : 0;
59
+ await tour.setParent(this.parent).start(index, this.direction);
60
+ this.onCleanup(async () => {
61
+ await tour.stop();
62
+ });
63
+ break;
64
+ }
65
+ }
66
+ if (!result)
67
+ await this.ahead();
68
+ }
69
+ }
@@ -0,0 +1,8 @@
1
+ import { AbstractStep } from '../step';
2
+ interface Options {
3
+ duration: number;
4
+ }
5
+ export default class StepDelay extends AbstractStep<Options> {
6
+ protected run(): Promise<void>;
7
+ }
8
+ export {};
@@ -0,0 +1,9 @@
1
+ import { delay } from "nanodelay";
2
+ import { AbstractStep } from "../step.mjs";
3
+ export default class StepDelay extends AbstractStep {
4
+ async run() {
5
+ const options = this.getOptions();
6
+ await delay(options.duration);
7
+ await this.ahead();
8
+ }
9
+ }
@@ -0,0 +1,11 @@
1
+ import { AbstractStep } from '../step';
2
+ export interface DialogOptions {
3
+ target: string;
4
+ title?: string;
5
+ text: string;
6
+ image?: string;
7
+ }
8
+ export default class StepDialog extends AbstractStep<DialogOptions> {
9
+ protected dismiss(): Promise<void>;
10
+ protected run(): Promise<void>;
11
+ }
@@ -0,0 +1,25 @@
1
+ import defu from "defu";
2
+ import { removeSingleton, useSingleton } from "../../../global/use-singleton.mjs";
3
+ import { AbstractStep } from "../step.mjs";
4
+ import { waitElement } from "../../utils/wait-element.mjs";
5
+ export default class StepDialog extends AbstractStep {
6
+ async dismiss() {
7
+ await this.parent.stop();
8
+ }
9
+ async run() {
10
+ const options = this.getOptions();
11
+ const { default: Tour } = await import("../../Tour.vue");
12
+ const tour = await useSingleton(Tour);
13
+ const target = await waitElement(options.target, options.waitTimeout);
14
+ tour.show(target, defu({
15
+ step: this.parent.getIndex() + 1,
16
+ totalStep: this.parent.getTotal(),
17
+ onNext: this.next.bind(this),
18
+ onPrev: this.prev.bind(this),
19
+ onDismiss: this.dismiss.bind(this)
20
+ }, options));
21
+ this.onCleanup(async () => {
22
+ await removeSingleton(Tour);
23
+ });
24
+ }
25
+ }
@@ -0,0 +1,9 @@
1
+ import { AbstractStep } from '../step';
2
+ export interface VisitOptions {
3
+ url: string;
4
+ backUrl?: string;
5
+ }
6
+ export default class StepVisit extends AbstractStep<VisitOptions> {
7
+ protected lastURL: string;
8
+ protected run(): Promise<void>;
9
+ }
@@ -0,0 +1,18 @@
1
+ import { useRouter } from "../../../global/router.mjs";
2
+ import { TourDirection } from "../base.mjs";
3
+ import { AbstractStep } from "../step.mjs";
4
+ export default class StepVisit extends AbstractStep {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.lastURL = "";
8
+ }
9
+ async run() {
10
+ const router = useRouter();
11
+ const options = this.getOptions();
12
+ const lastURL = this.lastURL;
13
+ const targetURL = this.direction === TourDirection.FORWARD ? options.url : options.backUrl ?? lastURL;
14
+ this.lastURL = router.getURL();
15
+ await router.toURL(targetURL);
16
+ await this.ahead();
17
+ }
18
+ }
@@ -0,0 +1,37 @@
1
+ import { AbstractTour } from './base';
2
+ import type { Tour, TourOptions } from './tour';
3
+ declare type Merge<A, B> = Omit<A, keyof B> & B;
4
+ declare type BaseOptions = Partial<Omit<TourOptions, 'onFinished'>>;
5
+ export declare type OnCleanup = (cleanupFn: () => unknown) => unknown;
6
+ export declare abstract class AbstractStep<Option> extends AbstractTour<Merge<BaseOptions, Option>> {
7
+ protected parent?: Tour;
8
+ protected cleanFns: Array<() => unknown>;
9
+ protected dispose(): Promise<PromiseSettledResult<unknown>[]>;
10
+ /**
11
+ * Run function before unmounted
12
+ * @param cleanFn clean function
13
+ */
14
+ protected onCleanup(cleanFn: () => unknown): void;
15
+ /**
16
+ * Start this step
17
+ */
18
+ start(): Promise<void>;
19
+ /**
20
+ * Stop this step
21
+ */
22
+ stop(): Promise<void>;
23
+ /**
24
+ * Trigger next to parent
25
+ */
26
+ next(): Promise<void>;
27
+ /**
28
+ * Trigger prev to parent
29
+ */
30
+ prev(): Promise<void>;
31
+ /**
32
+ * Trigger next or prev following the direction
33
+ */
34
+ ahead(): Promise<void>;
35
+ protected abstract run(): void | Promise<void>;
36
+ }
37
+ export {};
@@ -0,0 +1,30 @@
1
+ import { AbstractTour, TourDirection } from "./base.mjs";
2
+ export class AbstractStep extends AbstractTour {
3
+ constructor() {
4
+ super(...arguments);
5
+ this.cleanFns = [];
6
+ }
7
+ async dispose() {
8
+ return await Promise.allSettled(this.cleanFns.map((clean) => clean()));
9
+ }
10
+ onCleanup(cleanFn) {
11
+ this.cleanFns.push(cleanFn);
12
+ }
13
+ async start() {
14
+ this.attach(this.parent);
15
+ await this.run();
16
+ }
17
+ async stop() {
18
+ await this.dispose();
19
+ this.detach(this.parent);
20
+ }
21
+ async next() {
22
+ await this.parent.next();
23
+ }
24
+ async prev() {
25
+ await this.parent.prev();
26
+ }
27
+ async ahead() {
28
+ return await (this.direction === TourDirection.BACKWARD ? this.prev() : this.next());
29
+ }
30
+ }
@@ -0,0 +1,130 @@
1
+ import { Tour } from './tour';
2
+ import type { ConditionalOptions } from './step/conditional';
3
+ import type { DialogOptions } from './step/dialog';
4
+ import type { ActionOptions, EventType, ParamsOf } from './step/action';
5
+ declare type TourBuilderCallback = (tour: TourStory) => unknown;
6
+ /**
7
+ * Tour with additional function to build a tour stories
8
+ */
9
+ export declare class TourStory extends Tour {
10
+ /**
11
+ * Show tour guide dialog
12
+ * @param options options
13
+ */
14
+ dialog(options: DialogOptions): this;
15
+ /**
16
+ * Show tour guide dialog
17
+ * @param target target querySelector
18
+ * @param text body text
19
+ * @param title title text
20
+ * @param image url image
21
+ */
22
+ dialog(target: string, text: string, title?: string, image?: string): this;
23
+ /**
24
+ * Delay or Wait, setTimout equivalent
25
+ * @param duration duration in milliseconds
26
+ */
27
+ delay(duration: number): this;
28
+ /**
29
+ * Trigger action to target element
30
+ * @param options ActionOptions
31
+ */
32
+ action<E extends EventType>(options: ActionOptions<E>): this;
33
+ /**
34
+ * Trigger action to target element
35
+ * @param target Target querySelector
36
+ * @param action Action name, ex: 'click', 'type'
37
+ * @param params Action parameters
38
+ */
39
+ action<E extends EventType>(target: string, action: E, ...params: ParamsOf<E>): this;
40
+ /**
41
+ * Trigger click to target element
42
+ * @param target Target querySelector
43
+ */
44
+ click(target: string): this;
45
+ /**
46
+ * Trigger double click to target element
47
+ * @param target Target querySelector
48
+ */
49
+ dblClick(target: string): this;
50
+ /**
51
+ * Trigger triple click to target element
52
+ * @param target Target querySelector
53
+ */
54
+ tripleClick(target: string): this;
55
+ /**
56
+ * Trigger hover to target element
57
+ * @param target Target querySelector
58
+ */
59
+ hover(target: string): this;
60
+ /**
61
+ * Trigger unhover (blur) to target element
62
+ * @param target Target querySelector
63
+ */
64
+ unhover(target: string): this;
65
+ /**
66
+ * Trigger blur (unhover) to target element
67
+ * @param target Target querySelector
68
+ */
69
+ blur(target: string): this;
70
+ /**
71
+ * Remotely typing target input
72
+ * @param target Target querySelector
73
+ */
74
+ type(target: string, text: string): this;
75
+ /**
76
+ * Clear input text
77
+ * @param target Target querySelector
78
+ */
79
+ clear(target: string): this;
80
+ /**
81
+ * Redirect to url
82
+ * @param url target url
83
+ * @param backUrl target url when back button clicked
84
+ */
85
+ visit(url: string, backUrl?: string): this;
86
+ /**
87
+ * Run steps only when condition meet, skip if not
88
+ * @param condition Ref or Function to check
89
+ * @param buildTour
90
+ * @example
91
+ * tour.runIf(() => window.matchMedia("(max-width: 700px)").matches, (tour) => {
92
+ * return tour
93
+ * .click('#mobile-only')
94
+ * .dialog('#mobile-only', 'Hello World')
95
+ * })
96
+ */
97
+ runIf(condition: ConditionalOptions['condition'], buildTour: TourBuilderCallback): this;
98
+ /**
99
+ * Run else if, this must be used after runIf.
100
+ * @param condition
101
+ * @param buildTour
102
+ * @example
103
+ * tour.runIf(() => window.matchMedia("(max-width: 700px)").matches, (tour) => {
104
+ * return tour
105
+ * .click('#mobile-only')
106
+ * .dialog('#mobile-only', 'Hello World')
107
+ * }).runElseIf(() => window.matchMedia("(max-width: 1000px), (tour) => {
108
+ * return tour
109
+ * .click('#tablet-only')
110
+ * .dialog('#tablet-only', 'Hello World')*
111
+ * })
112
+ */
113
+ runElseIf(condition: ConditionalOptions['condition'], buildTour: TourBuilderCallback): this;
114
+ /**
115
+ * Run else condition, this must be used after runElse
116
+ * @param buildTour
117
+ * @example
118
+ * tour.runIf(() => window.matchMedia("(max-width: 700px)").matches, (tour) => {
119
+ * return tour
120
+ * .click('#mobile-only')
121
+ * .dialog('#mobile-only', 'Hello World')
122
+ * }).runElse((tour) => {
123
+ * return tour
124
+ * .click('#not-mobile')
125
+ * .dialog('#not-mobile', 'Hello World')*
126
+ * })
127
+ */
128
+ runElse(buildTour: TourBuilderCallback): this;
129
+ }
130
+ export {};
@@ -0,0 +1,85 @@
1
+ import { Tour } from "./tour.mjs";
2
+ import { isString } from "lodash-es";
3
+ import StepDialog from "./step/dialog.mjs";
4
+ import StepDelay from "./step/delay.mjs";
5
+ import StepAction from "./step/action.mjs";
6
+ import StepVisit from "./step/visit.mjs";
7
+ import StepCondition, { ConditionalType } from "./step/conditional.mjs";
8
+ export class TourStory extends Tour {
9
+ dialog(targetOrOption, text = "", title, image) {
10
+ return isString(targetOrOption) ? this.add(new StepDialog({
11
+ target: targetOrOption,
12
+ text,
13
+ title,
14
+ image
15
+ })) : this.add(new StepDialog(targetOrOption));
16
+ }
17
+ delay(duration) {
18
+ return this.add(new StepDelay({ duration }));
19
+ }
20
+ action(targetOrOption, action, ...params) {
21
+ return isString(targetOrOption) ? this.add(new StepAction({
22
+ target: targetOrOption,
23
+ action,
24
+ params
25
+ })) : this.add(new StepAction(targetOrOption));
26
+ }
27
+ click(target) {
28
+ return this.action(target, "click");
29
+ }
30
+ dblClick(target) {
31
+ return this.action(target, "dblClick");
32
+ }
33
+ tripleClick(target) {
34
+ return this.action(target, "tripleClick");
35
+ }
36
+ hover(target) {
37
+ return this.action(target, "hover");
38
+ }
39
+ unhover(target) {
40
+ return this.action(target, "unhover");
41
+ }
42
+ blur(target) {
43
+ return this.unhover(target);
44
+ }
45
+ type(target, text) {
46
+ return this.action(target, "type", text);
47
+ }
48
+ clear(target) {
49
+ return this.action(target, "clear");
50
+ }
51
+ visit(url, backUrl) {
52
+ return this.add(new StepVisit({ url, backUrl }));
53
+ }
54
+ runIf(condition, buildTour) {
55
+ const tour = new TourStory();
56
+ return this.add(new StepCondition({
57
+ condition,
58
+ tour: buildTour(tour) ?? tour
59
+ }));
60
+ }
61
+ runElseIf(condition, buildTour) {
62
+ const step = this.steps.at(-1);
63
+ if (!(step instanceof StepCondition) || !step.canChain())
64
+ throw new Error(".runElseIf only can be use after .runIf or .runElseIf");
65
+ const tour = new TourStory();
66
+ step.chain({
67
+ type: ConditionalType.ELSE_IF,
68
+ condition,
69
+ tour: buildTour(tour) ?? tour
70
+ });
71
+ return this;
72
+ }
73
+ runElse(buildTour) {
74
+ const step = this.steps.at(-1);
75
+ if (!(step instanceof StepCondition) || !step.canChain())
76
+ throw new Error(".runElse only can be use after .runIf or .runElseIf");
77
+ const tour = new TourStory();
78
+ step.chain({
79
+ type: ConditionalType.ELSE,
80
+ condition: true,
81
+ tour: buildTour(tour) ?? tour
82
+ });
83
+ return this;
84
+ }
85
+ }