@leaflink/stash 51.9.3 → 51.11.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 (375) hide show
  1. package/assets/icons/cloud-share.svg +1 -0
  2. package/assets/spritesheet.svg +1 -1
  3. package/dist/Accordion.js.map +1 -1
  4. package/dist/Accordion.vue.d.ts +7 -38
  5. package/dist/ActionsDropdown.js +2 -2
  6. package/dist/ActionsDropdown.js.map +1 -1
  7. package/dist/ActionsDropdown.vue.d.ts +0 -74
  8. package/dist/AddressSelect.js +56 -60
  9. package/dist/AddressSelect.js.map +1 -1
  10. package/dist/AddressSelect.vue.d.ts +8 -65
  11. package/dist/Alert.js.map +1 -1
  12. package/dist/Alert.vue.d.ts +4 -41
  13. package/dist/AppNavigationItem.js.map +1 -1
  14. package/dist/AppNavigationItem.vue.d.ts +5 -32
  15. package/dist/AppSidebar.js.map +1 -1
  16. package/dist/AppSidebar.vue.d.ts +8 -35
  17. package/dist/AppTopbar.js +1 -1
  18. package/dist/AppTopbar.js.map +1 -1
  19. package/dist/AppTopbar.vue.d.ts +4 -33
  20. package/dist/Avatar.js.map +1 -1
  21. package/dist/Avatar.vue.d.ts +5 -44
  22. package/dist/Backdrop.js.map +1 -1
  23. package/dist/Backdrop.vue.d.ts +1 -1
  24. package/dist/Badge.js.map +1 -1
  25. package/dist/Badge.vue.d.ts +6 -55
  26. package/dist/Box.vue.d.ts +3 -36
  27. package/dist/Box.vue_vue_type_script_setup_true_lang-rFnvwLVY.js.map +1 -1
  28. package/dist/Button.js.map +1 -1
  29. package/dist/Button.vue.d.ts +5 -50
  30. package/dist/ButtonGroup.js +33 -37
  31. package/dist/ButtonGroup.js.map +1 -1
  32. package/dist/ButtonGroup.vue.d.ts +6 -39
  33. package/dist/Card.js.map +1 -1
  34. package/dist/Card.vue.d.ts +5 -32
  35. package/dist/CardContent.js.map +1 -1
  36. package/dist/CardContent.vue.d.ts +1 -1
  37. package/dist/CardFooter.js.map +1 -1
  38. package/dist/CardFooter.vue.d.ts +1 -1
  39. package/dist/CardHeader.js.map +1 -1
  40. package/dist/CardHeader.vue.d.ts +2 -15
  41. package/dist/CardMedia.js.map +1 -1
  42. package/dist/CardMedia.vue.d.ts +2 -15
  43. package/dist/Carousel.js +66 -72
  44. package/dist/Carousel.js.map +1 -1
  45. package/dist/Carousel.vue.d.ts +10 -10
  46. package/dist/Checkbox.js.map +1 -1
  47. package/dist/Checkbox.vue.d.ts +8 -53
  48. package/dist/ChevronToggle.vue.d.ts +7 -34
  49. package/dist/ChevronToggle.vue_vue_type_script_setup_true_lang-Ce_qOXfR.js.map +1 -1
  50. package/dist/Chip.js.map +1 -1
  51. package/dist/Chip.vue.d.ts +10 -52
  52. package/dist/ConfirmationCodeInput.js +40 -44
  53. package/dist/ConfirmationCodeInput.js.map +1 -1
  54. package/dist/ConfirmationCodeInput.vue.d.ts +8 -43
  55. package/dist/ContextSwitcher.js.map +1 -1
  56. package/dist/ContextSwitcher.vue.d.ts +6 -41
  57. package/dist/Copy.js.map +1 -1
  58. package/dist/Copy.vue.d.ts +3 -34
  59. package/dist/CurrencyInput.js +20 -21
  60. package/dist/CurrencyInput.js.map +1 -1
  61. package/dist/CurrencyInput.vue.d.ts +125 -46
  62. package/dist/CustomRender.js.map +1 -1
  63. package/dist/DataView.js +94 -96
  64. package/dist/DataView.js.map +1 -1
  65. package/dist/DataView.keys-aSOnA4AD.js.map +1 -1
  66. package/dist/DataView.vue.d.ts +15 -57
  67. package/dist/DataViewFilters.js +127 -139
  68. package/dist/DataViewFilters.js.map +1 -1
  69. package/dist/DataViewFilters.keys-BLu07FiP.js.map +1 -1
  70. package/dist/DataViewFilters.vue.d.ts +9 -54
  71. package/dist/DataViewSortButton.js +2 -2
  72. package/dist/DataViewSortButton.js.map +1 -1
  73. package/dist/DataViewSortButton.vue.d.ts +3 -30
  74. package/dist/DataViewToolbar.js +146 -71
  75. package/dist/DataViewToolbar.js.map +1 -1
  76. package/dist/DataViewToolbar.vue.d.ts +106 -40
  77. package/dist/DatePicker.js +4524 -4636
  78. package/dist/DatePicker.js.map +1 -1
  79. package/dist/DatePicker.vue.d.ts +32 -81
  80. package/dist/DescriptionList.js.map +1 -1
  81. package/dist/DescriptionList.vue.d.ts +3 -32
  82. package/dist/DescriptionListDetail.js.map +1 -1
  83. package/dist/DescriptionListDetail.vue.d.ts +1 -1
  84. package/dist/DescriptionListGroup.js.map +1 -1
  85. package/dist/DescriptionListGroup.vue.d.ts +1 -1
  86. package/dist/DescriptionListTerm.js.map +1 -1
  87. package/dist/DescriptionListTerm.vue.d.ts +1 -1
  88. package/dist/Dialog.js.map +1 -1
  89. package/dist/Dialog.vue.d.ts +10 -53
  90. package/dist/Divider.js.map +1 -1
  91. package/dist/Dropdown.js +89 -95
  92. package/dist/Dropdown.js.map +1 -1
  93. package/dist/Dropdown.vue.d.ts +12 -48
  94. package/dist/EmptyState.js +1 -1
  95. package/dist/EmptyState.js.map +1 -1
  96. package/dist/EmptyState.vue.d.ts +5 -62
  97. package/dist/Expand.vue.d.ts +10 -40
  98. package/dist/Expand.vue_vue_type_script_setup_true_lang-CiONJfAp.js.map +1 -1
  99. package/dist/Field.vue.d.ts +4 -53
  100. package/dist/Field.vue_vue_type_script_setup_true_lang-DI6z3AE9.js.map +1 -1
  101. package/dist/FileUpload.js +72 -74
  102. package/dist/FileUpload.js.map +1 -1
  103. package/dist/FileUpload.vue.d.ts +10 -44
  104. package/dist/FilterChip.js.map +1 -1
  105. package/dist/FilterChip.vue.d.ts +6 -41
  106. package/dist/FilterDrawerItem.js +21 -21
  107. package/dist/FilterDrawerItem.js.map +1 -1
  108. package/dist/FilterDrawerItem.vue.d.ts +6 -23
  109. package/dist/FilterDropdown.js +63 -69
  110. package/dist/FilterDropdown.js.map +1 -1
  111. package/dist/FilterDropdown.vue.d.ts +122 -35
  112. package/dist/FilterSelect.js.map +1 -1
  113. package/dist/FilterSelect.vue.d.ts +4 -31
  114. package/dist/Filters.js +157 -164
  115. package/dist/Filters.js.map +1 -1
  116. package/dist/Filters.vue.d.ts +0 -2190
  117. package/dist/HttpError.js +7 -7
  118. package/dist/HttpError.js.map +1 -1
  119. package/dist/HttpError.vue.d.ts +4 -41
  120. package/dist/Icon.js +16 -15
  121. package/dist/Icon.js.map +1 -1
  122. package/dist/Icon.vue.d.ts +4 -37
  123. package/dist/IconLabel.js.map +1 -1
  124. package/dist/IconLabel.vue.d.ts +6 -41
  125. package/dist/Illustration.js +2 -2
  126. package/dist/Illustration.vue.d.ts +3 -42
  127. package/dist/{Illustration.vue_vue_type_script_setup_true_lang-BrqEF8xe.js → Illustration.vue_vue_type_script_setup_true_lang-BVzzNsRt.js} +11 -11
  128. package/dist/{Illustration.vue_vue_type_script_setup_true_lang-BrqEF8xe.js.map → Illustration.vue_vue_type_script_setup_true_lang-BVzzNsRt.js.map} +1 -1
  129. package/dist/Image.js +2 -2
  130. package/dist/Image.vue.d.ts +5 -40
  131. package/dist/{Image.vue_vue_type_script_setup_true_lang-D5u4av0_.js → Image.vue_vue_type_script_setup_true_lang-Dg2Zk2r2.js} +37 -41
  132. package/dist/{Image.vue_vue_type_script_setup_true_lang-D5u4av0_.js.map → Image.vue_vue_type_script_setup_true_lang-Dg2Zk2r2.js.map} +1 -1
  133. package/dist/InlineEdit.js.map +1 -1
  134. package/dist/InlineEdit.vue.d.ts +126 -47
  135. package/dist/Input.js.map +1 -1
  136. package/dist/Input.vue.d.ts +12 -45
  137. package/dist/InputOptions.js +66 -69
  138. package/dist/InputOptions.js.map +1 -1
  139. package/dist/InputOptions.vue.d.ts +10 -55
  140. package/dist/IntegrationIcon.js +7 -7
  141. package/dist/IntegrationIcon.js.map +1 -1
  142. package/dist/IntegrationIcon.vue.d.ts +3 -36
  143. package/dist/Label.vue.d.ts +3 -42
  144. package/dist/Label.vue_vue_type_script_setup_true_lang-CNquF3AP.js.map +1 -1
  145. package/dist/LicenseChip.js.map +1 -1
  146. package/dist/LicenseChip.vue.d.ts +3 -30
  147. package/dist/ListItem.js.map +1 -1
  148. package/dist/ListItem.vue.d.ts +0 -294
  149. package/dist/ListItemCell.js.map +1 -1
  150. package/dist/ListItemCell.vue.d.ts +0 -21
  151. package/dist/ListView.js +4 -7
  152. package/dist/ListView.js.map +1 -1
  153. package/dist/ListView.types.d.ts +0 -29
  154. package/dist/ListView.vue.d.ts +0 -5496
  155. package/dist/Loading.js +2 -2
  156. package/dist/Loading.js.map +1 -1
  157. package/dist/Loading.vue.d.ts +1 -1
  158. package/dist/Logo.js +1 -1
  159. package/dist/Logo.vue.d.ts +6 -41
  160. package/dist/{Logo.vue_vue_type_script_setup_true_lang-Dz8c98sc.js → Logo.vue_vue_type_script_setup_true_lang-Y3iE9utm.js} +17 -17
  161. package/dist/Logo.vue_vue_type_script_setup_true_lang-Y3iE9utm.js.map +1 -0
  162. package/dist/Menu.js.map +1 -1
  163. package/dist/Menu.vue.d.ts +1 -1
  164. package/dist/MenuItem.js.map +1 -1
  165. package/dist/MenuItem.vue.d.ts +1 -1
  166. package/dist/MenusPlugin-B4jpNe7x.js +12 -0
  167. package/dist/{MenusPlugin-Bk6UW6o9.js.map → MenusPlugin-B4jpNe7x.js.map} +1 -1
  168. package/dist/Metric.js.map +1 -1
  169. package/dist/Metric.vue.d.ts +3 -34
  170. package/dist/Modal.js +62 -64
  171. package/dist/Modal.js.map +1 -1
  172. package/dist/Modal.vue.d.ts +13 -60
  173. package/dist/Modals.js +17 -18
  174. package/dist/Modals.js.map +1 -1
  175. package/dist/ModalsPlugin.js +11 -11
  176. package/dist/ModalsPlugin.js.map +1 -1
  177. package/dist/Module.js.map +1 -1
  178. package/dist/Module.keys-CEsrW2f0.js.map +1 -1
  179. package/dist/Module.types-B1FfGGac.js.map +1 -1
  180. package/dist/Module.vue.d.ts +2 -29
  181. package/dist/ModuleContent.js.map +1 -1
  182. package/dist/ModuleContent.vue.d.ts +3 -3
  183. package/dist/ModuleFooter.js.map +1 -1
  184. package/dist/ModuleFooter.vue.d.ts +1 -1
  185. package/dist/ModuleHeader.js.map +1 -1
  186. package/dist/ModuleHeader.vue.d.ts +5 -39
  187. package/dist/MoreActions.js +489 -0
  188. package/dist/MoreActions.js.map +1 -0
  189. package/dist/MoreActions.vue.d.ts +203 -0
  190. package/dist/ObfuscateText.js.map +1 -1
  191. package/dist/ObfuscateText.vue.d.ts +3 -40
  192. package/dist/PageContent.js.map +1 -1
  193. package/dist/PageContent.vue.d.ts +3 -30
  194. package/dist/PageHeader.js.map +1 -1
  195. package/dist/PageHeader.vue.d.ts +6 -35
  196. package/dist/PageNavigation.js +50 -50
  197. package/dist/PageNavigation.js.map +1 -1
  198. package/dist/PageNavigation.vue.d.ts +7 -36
  199. package/dist/Paginate.js.map +1 -1
  200. package/dist/Paginate.vue.d.ts +5 -40
  201. package/dist/PlaidLink.js.map +1 -1
  202. package/dist/PlaidLink.vue.d.ts +12 -49
  203. package/dist/QuickAction.js.map +1 -1
  204. package/dist/QuickAction.vue.d.ts +3 -16
  205. package/dist/Radio.js.map +1 -1
  206. package/dist/Radio.vue.d.ts +0 -93
  207. package/dist/RadioGroup.js +94 -101
  208. package/dist/RadioGroup.js.map +1 -1
  209. package/dist/RadioGroup.vue.d.ts +116 -42
  210. package/dist/RadioNew.js +96 -99
  211. package/dist/RadioNew.js.map +1 -1
  212. package/dist/RadioNew.vue.d.ts +7 -48
  213. package/dist/RangeInput.js.map +1 -1
  214. package/dist/RangeInput.vue.d.ts +1 -1
  215. package/dist/SearchBar.js +38 -39
  216. package/dist/SearchBar.js.map +1 -1
  217. package/dist/SearchBar.vue.d.ts +127 -44
  218. package/dist/SectionHeader.js.map +1 -1
  219. package/dist/SectionHeader.vue.d.ts +6 -37
  220. package/dist/Select.js +171 -183
  221. package/dist/Select.js.map +1 -1
  222. package/dist/Select.vue.d.ts +23 -102
  223. package/dist/SelectStatus.js +38 -38
  224. package/dist/SelectStatus.js.map +1 -1
  225. package/dist/SelectStatus.vue.d.ts +227 -47
  226. package/dist/Skeleton.js.map +1 -1
  227. package/dist/Skeleton.vue.d.ts +3 -34
  228. package/dist/Step.js +44 -44
  229. package/dist/Step.js.map +1 -1
  230. package/dist/Step.vue.d.ts +4 -43
  231. package/dist/Stepper.js.map +1 -1
  232. package/dist/Stepper.vue.d.ts +9 -44
  233. package/dist/Switch.js.map +1 -1
  234. package/dist/Switch.vue.d.ts +8 -47
  235. package/dist/Tab.js +9 -9
  236. package/dist/Tab.js.map +1 -1
  237. package/dist/Tab.vue.d.ts +2 -15
  238. package/dist/TabPanel.js.map +1 -1
  239. package/dist/TabPanel.vue.d.ts +3 -30
  240. package/dist/Table.js +53 -59
  241. package/dist/Table.js.map +1 -1
  242. package/dist/Table.keys-LHQf6FEH.js.map +1 -1
  243. package/dist/Table.vue.d.ts +3 -50
  244. package/dist/TableCell.js +1 -1
  245. package/dist/TableCell.js.map +1 -1
  246. package/dist/TableCell.vue.d.ts +3 -32
  247. package/dist/TableHeaderCell.js +1 -1
  248. package/dist/TableHeaderCell.js.map +1 -1
  249. package/dist/TableHeaderCell.vue.d.ts +3 -30
  250. package/dist/TableHeaderRow.js +47 -45
  251. package/dist/TableHeaderRow.js.map +1 -1
  252. package/dist/TableHeaderRow.vue.d.ts +5 -34
  253. package/dist/TableRow.js +60 -61
  254. package/dist/TableRow.js.map +1 -1
  255. package/dist/TableRow.vue.d.ts +7 -48
  256. package/dist/Tabs.js +2 -2
  257. package/dist/Tabs.vue.d.ts +4 -31
  258. package/dist/Tabs.vue_vue_type_script_setup_true_lang-BlJVDr7o.js +78 -0
  259. package/dist/Tabs.vue_vue_type_script_setup_true_lang-BlJVDr7o.js.map +1 -0
  260. package/dist/TextEditor.js +2414 -2420
  261. package/dist/TextEditor.js.map +1 -1
  262. package/dist/TextEditor.vue.d.ts +9 -40
  263. package/dist/Textarea.js +69 -69
  264. package/dist/Textarea.js.map +1 -1
  265. package/dist/Textarea.vue.d.ts +9 -44
  266. package/dist/Thumbnail.js +1 -1
  267. package/dist/Thumbnail.js.map +1 -1
  268. package/dist/Thumbnail.vue.d.ts +4 -4
  269. package/dist/ThumbnailEmpty.js.map +1 -1
  270. package/dist/ThumbnailEmpty.vue.d.ts +1 -1
  271. package/dist/ThumbnailGroup.js.map +1 -1
  272. package/dist/ThumbnailGroup.keys-EJ4qFNhx.js.map +1 -1
  273. package/dist/ThumbnailGroup.vue.d.ts +26 -22
  274. package/dist/Timeline.js.map +1 -1
  275. package/dist/Timeline.vue.d.ts +3 -32
  276. package/dist/TimelineItem.js.map +1 -1
  277. package/dist/TimelineItem.vue.d.ts +1 -1
  278. package/dist/Toast.js.map +1 -1
  279. package/dist/Toast.vue.d.ts +3 -30
  280. package/dist/Toasts.js.map +1 -1
  281. package/dist/ToastsPlugin.js +11 -11
  282. package/dist/ToastsPlugin.js.map +1 -1
  283. package/dist/Tooltip.js +29 -30
  284. package/dist/Tooltip.js.map +1 -1
  285. package/dist/Tooltip.vue.d.ts +11 -43
  286. package/dist/colors-DDDVvqfQ.js.map +1 -1
  287. package/dist/components.css +1 -1
  288. package/dist/constants.js.map +1 -1
  289. package/dist/directives/autofocus.js.map +1 -1
  290. package/dist/directives/clickoutside.js.map +1 -1
  291. package/dist/directives/observe.js.map +1 -1
  292. package/dist/directives/sticky.js.map +1 -1
  293. package/dist/directives/tooltip.js +3 -3
  294. package/dist/directives/tooltip.js.map +1 -1
  295. package/dist/directives/viewable.js +39 -44
  296. package/dist/directives/viewable.js.map +1 -1
  297. package/dist/{floating-ui.vue-pzUuloyX.js → floating-ui.vue-CL01Y9ER.js} +2 -2
  298. package/dist/{floating-ui.vue-pzUuloyX.js.map → floating-ui.vue-CL01Y9ER.js.map} +1 -1
  299. package/dist/formatDateTime-DG7kBc2T.js +1414 -0
  300. package/dist/{formatDateTime-Dz8bXV0R.js.map → formatDateTime-DG7kBc2T.js.map} +1 -1
  301. package/dist/index-D6bxWkZ1.js.map +1 -1
  302. package/dist/index-XZqpB2_R.js +294 -0
  303. package/dist/{index-ConQ3o31.js.map → index-XZqpB2_R.js.map} +1 -1
  304. package/dist/index.js +99 -104
  305. package/dist/index.js.map +1 -1
  306. package/dist/isDefined-DzVx0B6k.js.map +1 -1
  307. package/dist/keys-BEdEsanp.js.map +1 -1
  308. package/dist/keys-C8Zfr_By.js.map +1 -1
  309. package/dist/locale.js.map +1 -1
  310. package/dist/misc-CHQs-G03.js.map +1 -1
  311. package/dist/obfuscateText.d.ts +1 -1
  312. package/dist/parseISO-wlfIB_QJ.js.map +1 -1
  313. package/dist/searchFuzzy-DBDE6jkd.js +408 -0
  314. package/dist/{searchFuzzy-DRasJ33G.js.map → searchFuzzy-DBDE6jkd.js.map} +1 -1
  315. package/dist/statusLevels-D8EgtE_L.js.map +1 -1
  316. package/dist/storage.js.map +1 -1
  317. package/dist/tailwind-base.d.ts +18 -0
  318. package/dist/tailwind-base.js +19 -9
  319. package/dist/tailwind-base.js.map +1 -1
  320. package/dist/toTimeZone-Coq1oPTt.js.map +1 -1
  321. package/dist/useConfirmBeforeClosing.js.map +1 -1
  322. package/dist/useDialog.d.ts +2 -2
  323. package/dist/useDialog.js +21 -25
  324. package/dist/useDialog.js.map +1 -1
  325. package/dist/useGoogleMaps.js +108 -110
  326. package/dist/useGoogleMaps.js.map +1 -1
  327. package/dist/useMediaQuery.d.ts +0 -6
  328. package/dist/useMediaQuery.js +11 -15
  329. package/dist/useMediaQuery.js.map +1 -1
  330. package/dist/useModals.d.ts +1 -1
  331. package/dist/useModals.js.map +1 -1
  332. package/dist/usePaginationStats-d_q39naC.js.map +1 -1
  333. package/dist/usePlaidLink.js +20 -27
  334. package/dist/usePlaidLink.js.map +1 -1
  335. package/dist/useScriptTag.js.map +1 -1
  336. package/dist/useSearch.js +13 -13
  337. package/dist/useSearch.js.map +1 -1
  338. package/dist/useSelection.js +56 -56
  339. package/dist/useSelection.js.map +1 -1
  340. package/dist/useSortable.js +54 -63
  341. package/dist/useSortable.js.map +1 -1
  342. package/dist/useStepper.d.ts +2 -2
  343. package/dist/useStepper.js +36 -40
  344. package/dist/useStepper.js.map +1 -1
  345. package/dist/useToasts.js +23 -23
  346. package/dist/useToasts.js.map +1 -1
  347. package/dist/useValidation.js +96 -100
  348. package/dist/useValidation.js.map +1 -1
  349. package/dist/utils/calculateElementOverflow.js +4 -4
  350. package/dist/utils/calculateElementOverflow.js.map +1 -1
  351. package/dist/utils/colorScheme.js +2 -2
  352. package/dist/utils/colorScheme.js.map +1 -1
  353. package/dist/utils/createQueryString.js.map +1 -1
  354. package/dist/utils/createValidDate.js.map +1 -1
  355. package/dist/utils/formatDateTime.js +1 -1
  356. package/dist/utils/getContrastingTextColor.js.map +1 -1
  357. package/dist/utils/helpers.js.map +1 -1
  358. package/dist/utils/i18n.js.map +1 -1
  359. package/dist/utils/normalizeDate.js.map +1 -1
  360. package/dist/utils/obfuscateText.js +6 -6
  361. package/dist/utils/obfuscateText.js.map +1 -1
  362. package/dist/utils/searchFuzzy.js +1 -1
  363. package/dist/utils/storage.js +23 -23
  364. package/dist/utils/storage.js.map +1 -1
  365. package/package.json +12 -13
  366. package/tailwind-base.ts +12 -1
  367. package/types/vite.d.ts +7 -0
  368. package/types/vitest.d.ts +7 -0
  369. package/dist/Logo.vue_vue_type_script_setup_true_lang-Dz8c98sc.js.map +0 -1
  370. package/dist/MenusPlugin-Bk6UW6o9.js +0 -12
  371. package/dist/Tabs.vue_vue_type_script_setup_true_lang-CmnBP4i1.js +0 -159
  372. package/dist/Tabs.vue_vue_type_script_setup_true_lang-CmnBP4i1.js.map +0 -1
  373. package/dist/formatDateTime-Dz8bXV0R.js +0 -1418
  374. package/dist/index-ConQ3o31.js +0 -128
  375. package/dist/searchFuzzy-DRasJ33G.js +0 -409
@@ -1,70 +1,66 @@
1
- import { ref as f, computed as p, readonly as w } from "vue";
2
- function E(v = {
1
+ import { ref as f, computed as p, readonly as A } from "vue";
2
+ function C(v = {
3
3
  linear: !1,
4
4
  activeStep: -1,
5
5
  activeSubstep: -1,
6
6
  steps: []
7
7
  }) {
8
- const a = f(v.steps ? v.steps : []), o = p(() => a.value.length), e = f(
8
+ const u = f(v.steps ? v.steps : []), n = p(() => u.value.length), e = f(
9
9
  v.activeStep !== null && v.activeStep !== void 0 ? v.activeStep : -1
10
10
  ), l = f(
11
11
  v.activeSubstep !== null && v.activeSubstep !== void 0 ? v.activeSubstep : -1
12
- ), S = p(() => {
13
- var u, t;
14
- return Array.from(((t = (u = v.ref) == null ? void 0 : u.value) == null ? void 0 : t.children) || []);
15
- }), m = p(() => S.value[e.value]);
16
- function s(u) {
17
- return !!a.value[u].substeps.length;
12
+ ), o = p(() => Array.from(v.ref?.value?.children || [])), S = p(() => o.value[e.value]);
13
+ function s(a) {
14
+ return !!u.value[a].substeps.length;
18
15
  }
19
- function b() {
20
- const u = e.value === -1, t = e.value === a.value.length - 1;
21
- if (u)
16
+ function m() {
17
+ const a = e.value === -1, t = e.value === u.value.length - 1;
18
+ if (a)
22
19
  e.value++, s(e.value) && l.value++;
23
20
  else if (t)
24
21
  if (s(e.value)) {
25
- const i = l.value === -1, c = l.value === a.value[e.value].substeps.length - 1;
26
- i ? l.value++ : c ? (a.value[e.value].substeps[l.value].completed = !0, l.value = -1, a.value[e.value].completed = !0, e.value = -1) : (a.value[e.value].substeps[l.value].completed = !0, l.value++);
22
+ const c = l.value === -1, r = l.value === u.value[e.value].substeps.length - 1;
23
+ c ? l.value++ : r ? (u.value[e.value].substeps[l.value].completed = !0, l.value = -1, u.value[e.value].completed = !0, e.value = -1) : (u.value[e.value].substeps[l.value].completed = !0, l.value++);
27
24
  } else
28
- a.value[e.value].completed = !0, e.value = -1;
25
+ u.value[e.value].completed = !0, e.value = -1;
29
26
  else if (s(e.value)) {
30
- const i = l.value === -1, c = l.value === a.value[e.value].substeps.length - 1;
31
- i ? l.value++ : c ? (a.value[e.value].substeps[l.value].completed = !0, l.value = -1, a.value[e.value].completed = !0, e.value++, s(e.value) && l.value === -1 && l.value++) : (a.value[e.value].substeps[l.value].completed = !0, l.value++);
27
+ const c = l.value === -1, r = l.value === u.value[e.value].substeps.length - 1;
28
+ c ? l.value++ : r ? (u.value[e.value].substeps[l.value].completed = !0, l.value = -1, u.value[e.value].completed = !0, e.value++, s(e.value) && l.value === -1 && l.value++) : (u.value[e.value].substeps[l.value].completed = !0, l.value++);
32
29
  } else
33
- a.value[e.value].completed = !0, e.value++, s(e.value) && l.value === -1 && l.value++;
30
+ u.value[e.value].completed = !0, e.value++, s(e.value) && l.value === -1 && l.value++;
34
31
  }
35
- function h() {
36
- e.value !== -1 && (s(e.value) ? l.value === 0 ? (e.value--, l.value--, e.value >= 0 && s(e.value) && (l.value = a.value[e.value].substeps.length - 1)) : l.value-- : (e.value--, e.value >= 0 && s(e.value) && (l.value = a.value[e.value].substeps.length - 1)));
32
+ function b() {
33
+ e.value !== -1 && (s(e.value) ? l.value === 0 ? (e.value--, l.value--, e.value >= 0 && s(e.value) && (l.value = u.value[e.value].substeps.length - 1)) : l.value-- : (e.value--, e.value >= 0 && s(e.value) && (l.value = u.value[e.value].substeps.length - 1)));
37
34
  }
38
- function g(u, t = -1) {
39
- v.linear ? (r(u - 1) || u === 0) && (s(u) && (t <= 0 ? l.value = 0 : r(u, t - 1) && (l.value = t)), e.value = u) : (e.value = u, s(u) && (t < 0 ? l.value = 0 : l.value = t));
35
+ function h(a, t = -1) {
36
+ v.linear ? (i(a - 1) || a === 0) && (s(a) && (t <= 0 ? l.value = 0 : i(a, t - 1) && (l.value = t)), e.value = a) : (e.value = a, s(a) && (t < 0 ? l.value = 0 : l.value = t));
40
37
  }
41
- function r(u, t = -1) {
42
- var i, c, n;
43
- return t >= 0 ? (c = (i = a.value[u]) == null ? void 0 : i.substeps[t]) == null ? void 0 : c.completed : (n = a.value[u]) == null ? void 0 : n.completed;
38
+ function i(a, t = -1) {
39
+ return t >= 0 ? u.value[a]?.substeps[t]?.completed : u.value[a]?.completed;
44
40
  }
45
- function d(u, t = -1) {
46
- return t >= 0 ? e.value === u && l.value === t : e.value === u;
41
+ function g(a, t = -1) {
42
+ return t >= 0 ? e.value === a && l.value === t : e.value === a;
47
43
  }
48
- function A(u = !1) {
49
- if (u && !a.value.length)
44
+ function d(a = !1) {
45
+ if (a && !u.value.length)
50
46
  throw new Error("Cannot register a substep without a parent step.");
51
- u ? a.value[a.value.length - 1].substeps.push({ completed: !1 }) : a.value.push({ completed: !1, substeps: [] });
47
+ a ? u.value[u.value.length - 1].substeps.push({ completed: !1 }) : u.value.push({ completed: !1, substeps: [] });
52
48
  }
53
49
  return {
54
- steps: w(a),
55
- stepCount: o,
56
- activeStepElement: m,
50
+ steps: A(u),
51
+ stepCount: n,
52
+ activeStepElement: S,
57
53
  activeStepIndex: e,
58
54
  activeSubstepIndex: l,
59
- registerStep: A,
60
- next: b,
61
- back: h,
62
- goTo: g,
63
- isStepActive: d,
64
- isStepCompleted: r
55
+ registerStep: d,
56
+ next: m,
57
+ back: b,
58
+ goTo: h,
59
+ isStepActive: g,
60
+ isStepCompleted: i
65
61
  };
66
62
  }
67
63
  export {
68
- E as default
64
+ C as default
69
65
  };
70
66
  //# sourceMappingURL=useStepper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useStepper.js","sources":["../src/composables/useStepper/useStepper.ts"],"sourcesContent":["import { computed, readonly, Ref, ref } from 'vue';\n\nexport interface StepDefinition {\n completed: boolean;\n substeps: Array<Omit<StepDefinition, 'substeps'>>;\n}\n\nexport interface StepperOptions {\n /**\n * If true, the stepper will prevent skipping steps\n */\n linear?: boolean;\n /**\n * The index of the active step\n */\n activeStep?: number;\n /**\n * The index of the active substep\n */\n activeSubstep?: number;\n /**\n * The stepper representation as an array of steps and substeps\n */\n steps?: Array<StepDefinition>;\n /**\n * A ref to the stepper element\n */\n ref?: Ref<HTMLUListElement | null>;\n}\n\nexport default function useStepper(\n options: StepperOptions = {\n linear: false,\n activeStep: -1,\n activeSubstep: -1,\n steps: [],\n },\n) {\n /**\n * The steps and substeps of the stepper, so we can keep track of their state.\n * Can be populated with the `steps` option, or via the `registerStep` function.\n */\n const steps = ref<Array<StepDefinition>>(options.steps ? options.steps : []);\n\n const stepCount = computed(() => steps.value.length);\n\n const activeStepIndex = ref(\n options.activeStep !== null && options.activeStep !== undefined ? options.activeStep : -1,\n );\n const activeSubstepIndex = ref(\n options.activeSubstep !== null && options.activeSubstep !== undefined ? options.activeSubstep : -1,\n );\n\n const stepElements = computed(() => {\n return Array.from((options.ref?.value?.children || []) as HTMLCollectionOf<HTMLLIElement>);\n });\n\n const activeStepElement = computed(() => stepElements.value[activeStepIndex.value]);\n\n /**\n * Returns true if the step at the given index has substeps\n * @param stepIndex The index of the step to check\n */\n function stepHasSubsteps(stepIndex: number): boolean {\n return !!steps.value[stepIndex].substeps.length;\n }\n\n /**\n * Goes to the next step or substep, while flagging the current one as completed.\n * If the current step has substeps, it will go to the next substep if there are any, or to the next substep.\n * And if the next step has substeps, automatically goes to the first substep\n */\n function next(): void {\n const hasNoActiveStep = activeStepIndex.value === -1;\n const isLastStep = activeStepIndex.value === steps.value.length - 1;\n\n // If there is no active step, we want to activate the first step\n if (hasNoActiveStep) {\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep\n if (stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value++;\n }\n } else if (isLastStep) {\n if (stepHasSubsteps(activeStepIndex.value)) {\n const hasNoActiveSubstep = activeSubstepIndex.value === -1;\n const isLastSubstep = activeSubstepIndex.value === steps.value[activeStepIndex.value].substeps.length - 1;\n\n // if there are no active substeps, we want to activate the first substep\n if (hasNoActiveSubstep) {\n activeSubstepIndex.value++;\n // if the active substep is the last one, we want to reset the step and substep to -1\n } else if (isLastSubstep) {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value = -1;\n\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value = -1;\n // if there are more substeps, we want to complete the current one and proceed to the next substep\n } else {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value++;\n }\n // If there are no substeps, we want to complete the current step and reset the step to -1\n } else {\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value = -1;\n }\n } else {\n if (stepHasSubsteps(activeStepIndex.value)) {\n const hasNoActiveSubstep = activeSubstepIndex.value === -1;\n const isLastSubstep = activeSubstepIndex.value === steps.value[activeStepIndex.value].substeps.length - 1;\n\n // if there are no active substeps, we want to activate the first substep\n if (hasNoActiveSubstep) {\n activeSubstepIndex.value++;\n // if the active substep is the last one, we want to go to the next step\n } else if (isLastSubstep) {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value = -1;\n\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep right away\n if (stepHasSubsteps(activeStepIndex.value) && activeSubstepIndex.value === -1) {\n activeSubstepIndex.value++;\n }\n // if there are more substeps, we want to complete the current one and proceed to the next substep\n } else {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value++;\n }\n } else {\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep right away\n if (stepHasSubsteps(activeStepIndex.value) && activeSubstepIndex.value === -1) {\n activeSubstepIndex.value++;\n }\n }\n }\n }\n\n function back(): void {\n // We don't want to go back if there is no active step\n if (activeStepIndex.value === -1) {\n return;\n }\n\n if (stepHasSubsteps(activeStepIndex.value)) {\n // If the active substep is the first one, we want to go back to the previous step\n if (activeSubstepIndex.value === 0) {\n activeStepIndex.value--;\n activeSubstepIndex.value--;\n\n // If the step that we just navigated to has substeps, we want to navigate to the last substep\n if (activeStepIndex.value >= 0 && stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value = steps.value[activeStepIndex.value].substeps.length - 1;\n }\n } else {\n activeSubstepIndex.value--;\n }\n } else {\n activeStepIndex.value--;\n\n // If the step that we just navigated to has substeps, we want to navigate to the last substep\n if (activeStepIndex.value >= 0 && stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value = steps.value[activeStepIndex.value].substeps.length - 1;\n }\n }\n }\n\n /**\n * Navigates to a specific step and substep.\n */\n function goTo(stepIndex: number, substepIndex = -1): void {\n // A linear stepper prevents navigation to incomplete steps\n if (options.linear) {\n if (isStepCompleted(stepIndex - 1) || stepIndex === 0) {\n if (stepHasSubsteps(stepIndex)) {\n if (substepIndex <= 0) {\n activeSubstepIndex.value = 0;\n } else if (isStepCompleted(stepIndex, substepIndex - 1)) {\n activeSubstepIndex.value = substepIndex;\n }\n }\n activeStepIndex.value = stepIndex;\n }\n } else {\n activeStepIndex.value = stepIndex;\n\n if (stepHasSubsteps(stepIndex)) {\n if (substepIndex < 0) {\n activeSubstepIndex.value = 0;\n } else {\n activeSubstepIndex.value = substepIndex;\n }\n }\n }\n }\n\n /**\n * Returns true if the step is completed.\n * if the substep index is provided, check if the substep is completed.\n */\n function isStepCompleted(stepIndex: number, substepIndex = -1): boolean {\n if (substepIndex >= 0) {\n return steps.value[stepIndex]?.substeps[substepIndex]?.completed;\n } else {\n return steps.value[stepIndex]?.completed;\n }\n }\n\n /**\n * Returns true if the step is active.\n * if the substep index is provided, check both if the step and the substep are active.\n */\n function isStepActive(stepIndex: number, substepIndex = -1): boolean {\n if (substepIndex >= 0) {\n return activeStepIndex.value === stepIndex && activeSubstepIndex.value === substepIndex;\n } else {\n return activeStepIndex.value === stepIndex;\n }\n }\n\n /**\n * Registers a new step or substep into the steps array\n */\n function registerStep(nested = false): void {\n if (nested && !steps.value.length) {\n throw new Error('Cannot register a substep without a parent step.');\n }\n\n if (nested) {\n steps.value[steps.value.length - 1].substeps.push({ completed: false });\n } else {\n steps.value.push({ completed: false, substeps: [] });\n }\n }\n\n return {\n steps: readonly(steps),\n stepCount,\n activeStepElement,\n activeStepIndex,\n activeSubstepIndex,\n registerStep,\n next,\n back,\n goTo,\n isStepActive,\n isStepCompleted,\n };\n}\n"],"names":["useStepper","options","steps","ref","stepCount","computed","activeStepIndex","activeSubstepIndex","stepElements","_b","_a","activeStepElement","stepHasSubsteps","stepIndex","next","hasNoActiveStep","isLastStep","hasNoActiveSubstep","isLastSubstep","back","goTo","substepIndex","isStepCompleted","_c","isStepActive","registerStep","nested","readonly"],"mappings":";AA8BA,SAAwBA,EACtBC,IAA0B;AAAA,EACxB,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,OAAO,CAAA;AACT,GACA;AAKA,QAAMC,IAAQC,EAA2BF,EAAQ,QAAQA,EAAQ,QAAQ,EAAE,GAErEG,IAAYC,EAAS,MAAMH,EAAM,MAAM,MAAM,GAE7CI,IAAkBH;AAAA,IACtBF,EAAQ,eAAe,QAAQA,EAAQ,eAAe,SAAYA,EAAQ,aAAa;AAAA,EACzF,GACMM,IAAqBJ;AAAA,IACzBF,EAAQ,kBAAkB,QAAQA,EAAQ,kBAAkB,SAAYA,EAAQ,gBAAgB;AAAA,EAClG,GAEMO,IAAeH,EAAS,MAAM;;AAClC,WAAO,MAAM,OAAMI,KAAAC,IAAAT,EAAQ,QAAR,gBAAAS,EAAa,UAAb,gBAAAD,EAAoB,aAAY,EAAsC;AAAA,EAAA,CAC1F,GAEKE,IAAoBN,EAAS,MAAMG,EAAa,MAAMF,EAAgB,KAAK,CAAC;AAMlF,WAASM,EAAgBC,GAA4B;AACnD,WAAO,CAAC,CAACX,EAAM,MAAMW,CAAS,EAAE,SAAS;AAAA,EAAA;AAQ3C,WAASC,IAAa;AACd,UAAAC,IAAkBT,EAAgB,UAAU,IAC5CU,IAAaV,EAAgB,UAAUJ,EAAM,MAAM,SAAS;AAGlE,QAAIa;AACc,MAAAT,EAAA,SAGZM,EAAgBN,EAAgB,KAAK,KACpBC,EAAA;AAAA,aAEZS;AACL,UAAAJ,EAAgBN,EAAgB,KAAK,GAAG;AACpC,cAAAW,IAAqBV,EAAmB,UAAU,IAClDW,IAAgBX,EAAmB,UAAUL,EAAM,MAAMI,EAAgB,KAAK,EAAE,SAAS,SAAS;AA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AA,IACrB,WAAAE;AAAA,IACA,mBAAAO;AAAA,IACA,iBAAAL;AAAA,IACA,oBAAAC;AAAA,IACA,cAAAkB;AAAA,IACA,MAAAX;AAAA,IACA,MAAAK;AAAA,IACA,MAAAC;AAAA,IACA,cAAAI;AAAA,IACA,iBAAAF;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"useStepper.js","sources":["../src/composables/useStepper/useStepper.ts"],"sourcesContent":["import { computed, readonly, Ref, ref } from 'vue';\n\nexport interface StepDefinition {\n completed: boolean;\n substeps: Array<Omit<StepDefinition, 'substeps'>>;\n}\n\nexport interface StepperOptions {\n /**\n * If true, the stepper will prevent skipping steps\n */\n linear?: boolean;\n /**\n * The index of the active step\n */\n activeStep?: number;\n /**\n * The index of the active substep\n */\n activeSubstep?: number;\n /**\n * The stepper representation as an array of steps and substeps\n */\n steps?: Array<StepDefinition>;\n /**\n * A ref to the stepper element\n */\n ref?: Ref<HTMLUListElement | null>;\n}\n\nexport default function useStepper(\n options: StepperOptions = {\n linear: false,\n activeStep: -1,\n activeSubstep: -1,\n steps: [],\n },\n) {\n /**\n * The steps and substeps of the stepper, so we can keep track of their state.\n * Can be populated with the `steps` option, or via the `registerStep` function.\n */\n const steps = ref<Array<StepDefinition>>(options.steps ? options.steps : []);\n\n const stepCount = computed(() => steps.value.length);\n\n const activeStepIndex = ref(\n options.activeStep !== null && options.activeStep !== undefined ? options.activeStep : -1,\n );\n const activeSubstepIndex = ref(\n options.activeSubstep !== null && options.activeSubstep !== undefined ? options.activeSubstep : -1,\n );\n\n const stepElements = computed(() => {\n return Array.from((options.ref?.value?.children || []) as HTMLCollectionOf<HTMLLIElement>);\n });\n\n const activeStepElement = computed(() => stepElements.value[activeStepIndex.value]);\n\n /**\n * Returns true if the step at the given index has substeps\n * @param stepIndex The index of the step to check\n */\n function stepHasSubsteps(stepIndex: number): boolean {\n return !!steps.value[stepIndex].substeps.length;\n }\n\n /**\n * Goes to the next step or substep, while flagging the current one as completed.\n * If the current step has substeps, it will go to the next substep if there are any, or to the next substep.\n * And if the next step has substeps, automatically goes to the first substep\n */\n function next(): void {\n const hasNoActiveStep = activeStepIndex.value === -1;\n const isLastStep = activeStepIndex.value === steps.value.length - 1;\n\n // If there is no active step, we want to activate the first step\n if (hasNoActiveStep) {\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep\n if (stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value++;\n }\n } else if (isLastStep) {\n if (stepHasSubsteps(activeStepIndex.value)) {\n const hasNoActiveSubstep = activeSubstepIndex.value === -1;\n const isLastSubstep = activeSubstepIndex.value === steps.value[activeStepIndex.value].substeps.length - 1;\n\n // if there are no active substeps, we want to activate the first substep\n if (hasNoActiveSubstep) {\n activeSubstepIndex.value++;\n // if the active substep is the last one, we want to reset the step and substep to -1\n } else if (isLastSubstep) {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value = -1;\n\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value = -1;\n // if there are more substeps, we want to complete the current one and proceed to the next substep\n } else {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value++;\n }\n // If there are no substeps, we want to complete the current step and reset the step to -1\n } else {\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value = -1;\n }\n } else {\n if (stepHasSubsteps(activeStepIndex.value)) {\n const hasNoActiveSubstep = activeSubstepIndex.value === -1;\n const isLastSubstep = activeSubstepIndex.value === steps.value[activeStepIndex.value].substeps.length - 1;\n\n // if there are no active substeps, we want to activate the first substep\n if (hasNoActiveSubstep) {\n activeSubstepIndex.value++;\n // if the active substep is the last one, we want to go to the next step\n } else if (isLastSubstep) {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value = -1;\n\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep right away\n if (stepHasSubsteps(activeStepIndex.value) && activeSubstepIndex.value === -1) {\n activeSubstepIndex.value++;\n }\n // if there are more substeps, we want to complete the current one and proceed to the next substep\n } else {\n steps.value[activeStepIndex.value].substeps[activeSubstepIndex.value].completed = true;\n activeSubstepIndex.value++;\n }\n } else {\n steps.value[activeStepIndex.value].completed = true;\n activeStepIndex.value++;\n\n // If the step we just navigated to has substeps, we want to activate the first substep right away\n if (stepHasSubsteps(activeStepIndex.value) && activeSubstepIndex.value === -1) {\n activeSubstepIndex.value++;\n }\n }\n }\n }\n\n function back(): void {\n // We don't want to go back if there is no active step\n if (activeStepIndex.value === -1) {\n return;\n }\n\n if (stepHasSubsteps(activeStepIndex.value)) {\n // If the active substep is the first one, we want to go back to the previous step\n if (activeSubstepIndex.value === 0) {\n activeStepIndex.value--;\n activeSubstepIndex.value--;\n\n // If the step that we just navigated to has substeps, we want to navigate to the last substep\n if (activeStepIndex.value >= 0 && stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value = steps.value[activeStepIndex.value].substeps.length - 1;\n }\n } else {\n activeSubstepIndex.value--;\n }\n } else {\n activeStepIndex.value--;\n\n // If the step that we just navigated to has substeps, we want to navigate to the last substep\n if (activeStepIndex.value >= 0 && stepHasSubsteps(activeStepIndex.value)) {\n activeSubstepIndex.value = steps.value[activeStepIndex.value].substeps.length - 1;\n }\n }\n }\n\n /**\n * Navigates to a specific step and substep.\n */\n function goTo(stepIndex: number, substepIndex = -1): void {\n // A linear stepper prevents navigation to incomplete steps\n if (options.linear) {\n if (isStepCompleted(stepIndex - 1) || stepIndex === 0) {\n if (stepHasSubsteps(stepIndex)) {\n if (substepIndex <= 0) {\n activeSubstepIndex.value = 0;\n } else if (isStepCompleted(stepIndex, substepIndex - 1)) {\n activeSubstepIndex.value = substepIndex;\n }\n }\n activeStepIndex.value = stepIndex;\n }\n } else {\n activeStepIndex.value = stepIndex;\n\n if (stepHasSubsteps(stepIndex)) {\n if (substepIndex < 0) {\n activeSubstepIndex.value = 0;\n } else {\n activeSubstepIndex.value = substepIndex;\n }\n }\n }\n }\n\n /**\n * Returns true if the step is completed.\n * if the substep index is provided, check if the substep is completed.\n */\n function isStepCompleted(stepIndex: number, substepIndex = -1): boolean {\n if (substepIndex >= 0) {\n return steps.value[stepIndex]?.substeps[substepIndex]?.completed;\n } else {\n return steps.value[stepIndex]?.completed;\n }\n }\n\n /**\n * Returns true if the step is active.\n * if the substep index is provided, check both if the step and the substep are active.\n */\n function isStepActive(stepIndex: number, substepIndex = -1): boolean {\n if (substepIndex >= 0) {\n return activeStepIndex.value === stepIndex && activeSubstepIndex.value === substepIndex;\n } else {\n return activeStepIndex.value === stepIndex;\n }\n }\n\n /**\n * Registers a new step or substep into the steps array\n */\n function registerStep(nested = false): void {\n if (nested && !steps.value.length) {\n throw new Error('Cannot register a substep without a parent step.');\n }\n\n if (nested) {\n steps.value[steps.value.length - 1].substeps.push({ completed: false });\n } else {\n steps.value.push({ completed: false, substeps: [] });\n }\n }\n\n return {\n steps: readonly(steps),\n stepCount,\n activeStepElement,\n activeStepIndex,\n activeSubstepIndex,\n registerStep,\n next,\n back,\n goTo,\n isStepActive,\n isStepCompleted,\n };\n}\n"],"names":["useStepper","options","steps","ref","stepCount","computed","activeStepIndex","activeSubstepIndex","stepElements","activeStepElement","stepHasSubsteps","stepIndex","next","hasNoActiveStep","isLastStep","hasNoActiveSubstep","isLastSubstep","back","goTo","substepIndex","isStepCompleted","isStepActive","registerStep","nested","readonly"],"mappings":";AA8BA,SAAwBA,EACtBC,IAA0B;AAAA,EACxB,QAAQ;AAAA,EACR,YAAY;AAAA,EACZ,eAAe;AAAA,EACf,OAAO,CAAA;AACT,GACA;AAKA,QAAMC,IAAQC,EAA2BF,EAAQ,QAAQA,EAAQ,QAAQ,EAAE,GAErEG,IAAYC,EAAS,MAAMH,EAAM,MAAM,MAAM,GAE7CI,IAAkBH;AAAA,IACtBF,EAAQ,eAAe,QAAQA,EAAQ,eAAe,SAAYA,EAAQ,aAAa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AQ,IAE3BA,EAAmB,QAAQY;AAAA,EAInC;AAMA,WAASC,EAAgBT,GAAmBQ,IAAe,IAAa;AACtE,WAAIA,KAAgB,IACXjB,EAAM,MAAMS,CAAS,GAAG,SAASQ,CAAY,GAAG,YAEhDjB,EAAM,MAAMS,CAAS,GAAG;AAAA,EAEnC;AAMA,WAASU,EAAaV,GAAmBQ,IAAe,IAAa;AACnE,WAAIA,KAAgB,IACXb,EAAgB,UAAUK,KAAaJ,EAAmB,UAAUY,IAEpEb,EAAgB,UAAUK;AAAA,EAErC;AAKA,WAASW,EAAaC,IAAS,IAAa;AAC1C,QAAIA,KAAU,CAACrB,EAAM,MAAM;AACzB,YAAM,IAAI,MAAM,kDAAkD;AAGpE,IAAIqB,IACFrB,EAAM,MAAMA,EAAM,MAAM,SAAS,CAAC,EAAE,SAAS,KAAK,EAAE,WAAW,GAAA,CAAO,IAEtEA,EAAM,MAAM,KAAK,EAAE,WAAW,IAAO,UAAU,CAAA,GAAI;AAAA,EAEvD;AAEA,SAAO;AAAA,IACL,OAAOsB,EAAStB,CAAK;AAAA,IACrB,WAAAE;AAAA,IACA,mBAAAK;AAAA,IACA,iBAAAH;AAAA,IACA,oBAAAC;AAAA,IACA,cAAAe;AAAA,IACA,MAAAV;AAAA,IACA,MAAAK;AAAA,IACA,MAAAC;AAAA,IACA,cAAAG;AAAA,IACA,iBAAAD;AAAA,EAAA;AAEJ;"}
package/dist/useToasts.js CHANGED
@@ -2,38 +2,38 @@ import l from "lodash-es/merge";
2
2
  import T from "lodash-es/uniqueId";
3
3
  import { ref as h, reactive as y, readonly as b } from "vue";
4
4
  const w = 5e3, n = h([]);
5
- function M(s = { timeout: w }) {
6
- function c(e) {
7
- const o = typeof e == "string" ? e : void 0, { group: i = void 0, status: t = void 0 } = typeof e == "object" ? e : {};
8
- if (!o && (!i || !t))
5
+ function M(c = { timeout: w }) {
6
+ function s(o) {
7
+ const e = typeof o == "string" ? o : void 0, { group: i = void 0, status: t = void 0 } = typeof o == "object" ? o : {};
8
+ if (!e && (!i || !t))
9
9
  throw new Error("Must provide either a toast ID or both group and type");
10
- const r = i && t ? `toast-${t}-${i}` : String(o), f = n.value.findIndex(({ id: g }) => g === r);
10
+ const r = i && t ? `toast-${t}-${i}` : String(e), f = n.value.findIndex(({ id: g }) => g === r);
11
11
  f !== -1 && n.value.splice(f, 1);
12
12
  }
13
- function u(e, o, i) {
14
- const t = l({}, s, i), r = t != null && t.group ? `toast-${o}-${t.group}` : T("toast-");
15
- if (!(t != null && t.group && n.value.some(({ id: f }) => f === r)))
13
+ function u(o, e, i) {
14
+ const t = l({}, c, i), r = t?.group ? `toast-${e}-${t.group}` : T("toast-");
15
+ if (!(t?.group && n.value.some(({ id: f }) => f === r)))
16
16
  return n.value.push({
17
- text: e,
17
+ text: o,
18
18
  id: r,
19
- status: o,
19
+ status: e,
20
20
  offsetTop: t.offsetTop
21
- }), typeof t.timeout == "number" && setTimeout(() => c(r), Math.abs(t.timeout)), r;
21
+ }), typeof t.timeout == "number" && setTimeout(() => s(r), Math.abs(t.timeout)), r;
22
22
  }
23
23
  function a() {
24
24
  n.value = [];
25
25
  }
26
- function m(e, o) {
27
- return u(e, "error", o);
26
+ function m(o, e) {
27
+ return u(o, "error", e);
28
28
  }
29
- function v(e, o) {
30
- return u(e, "info", o);
29
+ function p(o, e) {
30
+ return u(o, "info", e);
31
31
  }
32
- function d(e, o) {
33
- return u(e, "success", o);
32
+ function v(o, e) {
33
+ return u(o, "success", e);
34
34
  }
35
- function p(e, o) {
36
- return u(e, "warning", o);
35
+ function d(o, e) {
36
+ return u(o, "warning", e);
37
37
  }
38
38
  return y({
39
39
  /**
@@ -43,7 +43,7 @@ function M(s = { timeout: w }) {
43
43
  /**
44
44
  * Removes an active/visible toast by id or by group and type.
45
45
  */
46
- remove: c,
46
+ remove: s,
47
47
  /**
48
48
  * Creates a new toast and makes it active/visible.
49
49
  */
@@ -59,15 +59,15 @@ function M(s = { timeout: w }) {
59
59
  /**
60
60
  * Creates a new "info" toast.
61
61
  */
62
- info: v,
62
+ info: p,
63
63
  /**
64
64
  * Creates a new "success" toast.
65
65
  */
66
- success: d,
66
+ success: v,
67
67
  /**
68
68
  * Creates a new "warning" toast.
69
69
  */
70
- warning: p
70
+ warning: d
71
71
  });
72
72
  }
73
73
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"useToasts.js","sources":["../src/composables/useToasts/useToasts.ts"],"sourcesContent":["import merge from 'lodash-es/merge';\nimport uniqueId from 'lodash-es/uniqueId';\nimport { reactive, readonly, ref, RenderFunction } from 'vue';\n\nimport { StatusSeverity } from '../../../types/statusLevels';\n\nexport const DEFAULT_TIMEOUT = 5000;\n\nexport type Toast = {\n id: string;\n text: string | RenderFunction;\n status: StatusSeverity;\n offsetTop?: string;\n};\n\nexport interface ToastOptions {\n /**\n * The timeout in milliseconds before the toast is automatically dismissed. If set to `false`, the toast will persist until the user clicks on it.\n * @default DEFAULT_TIMEOUT\n */\n timeout?: number | boolean;\n /**\n * A group name ensures only one toast with the same group and status is visible at any given time.\n * Toasts with the same group but different statuses will be treated as separate and will display concurrently.\n */\n group?: string;\n /**\n * The container distance from the top of the viewport.\n */\n offsetTop?: string;\n}\n\ntype ToastIdOrUndefined<O extends ToastOptions | undefined> = O extends { id: string }\n ? Toast['id'] | undefined\n : Toast['id'];\n\nconst active = ref<Toast[]>([]);\n\nexport default function useToasts(globalOptions: Omit<ToastOptions, 'group'> = { timeout: DEFAULT_TIMEOUT }) {\n // method overloads\n function remove(toastId: Toast['id']): void;\n function remove(options: { group: string; status: StatusSeverity }): void;\n function remove(toastIdOrOptions: Toast['id'] | { group: string; status: StatusSeverity }) {\n const toastId = typeof toastIdOrOptions === 'string' ? toastIdOrOptions : undefined;\n const { group = undefined, status = undefined } = typeof toastIdOrOptions === 'object' ? toastIdOrOptions : {};\n\n if (!toastId && (!group || !status)) {\n throw new Error('Must provide either a toast ID or both group and type');\n }\n\n const idToRemove = group && status ? `toast-${status}-${group}` : String(toastId);\n const index = active.value.findIndex(({ id }) => id === idToRemove);\n if (index === -1) {\n return;\n }\n\n active.value.splice(index, 1);\n }\n\n // method overloads\n function create(text: Toast['text'], status: StatusSeverity, options?: Omit<ToastOptions, 'group'>): Toast['id'];\n function create(\n text: Toast['text'],\n status: StatusSeverity,\n options: ToastOptions & { id: string },\n ): Toast['id'] | undefined;\n function create(text: Toast['text'], status: StatusSeverity, localOptions?: ToastOptions): Toast['id'] | undefined {\n const options = merge({}, globalOptions, localOptions);\n\n const id = options?.group ? `toast-${status}-${options.group}` : uniqueId('toast-');\n if (options?.group && active.value.some(({ id: existingId }) => existingId === id)) {\n return;\n }\n\n active.value.push({\n text,\n id,\n status,\n offsetTop: options.offsetTop,\n });\n\n if (typeof options.timeout === 'number') {\n setTimeout(() => remove(id), Math.abs(options.timeout));\n }\n\n return id;\n }\n\n function removeAll() {\n active.value = [];\n }\n\n function error<O extends ToastOptions>(text: Toast['text'], options?: O): ToastIdOrUndefined<O> {\n return create(text, 'error', options);\n }\n\n function info<O extends ToastOptions>(text: Toast['text'], options?: O): ToastIdOrUndefined<O> {\n return create(text, 'info', options);\n }\n\n function success<O extends ToastOptions>(text: Toast['text'], options?: O): ToastIdOrUndefined<O> {\n return create(text, 'success', options);\n }\n\n function warning<O extends ToastOptions>(text: Toast['text'], options?: O): ToastIdOrUndefined<O> {\n return create(text, 'warning', options);\n }\n\n return reactive({\n /**\n * The list of toasts that are currently visible.\n */\n active: readonly(active),\n\n /**\n * Removes an active/visible toast by id or by group and type.\n */\n remove,\n\n /**\n * Creates a new toast and makes it active/visible.\n */\n create,\n\n /**\n * Removes all active/visible toasts.\n */\n removeAll,\n\n /**\n * Creates a new \"error\" toast.\n */\n error,\n\n /**\n * Creates a new \"info\" toast.\n */\n info,\n\n /**\n * Creates a new \"success\" toast.\n */\n success,\n\n /**\n * Creates a new \"warning\" toast.\n */\n warning,\n });\n}\n"],"names":["DEFAULT_TIMEOUT","active","ref","useToasts","globalOptions","remove","toastIdOrOptions","toastId","group","status","idToRemove","index","id","create","text","localOptions","options","merge","uniqueId","existingId","removeAll","error","info","success","warning","reactive","readonly"],"mappings":";;;AAMO,MAAMA,IAAkB,KA8BzBC,IAASC,EAAa,EAAE;AAE9B,SAAwBC,EAAUC,IAA6C,EAAE,SAASJ,KAAmB;AAI3G,WAASK,EAAOC,GAA2E;AACzF,UAAMC,IAAU,OAAOD,KAAqB,WAAWA,IAAmB,QACpE,EAAE,OAAAE,IAAQ,QAAW,QAAAC,IAAS,WAAc,OAAOH,KAAqB,WAAWA,IAAmB,CAAC;AAE7G,QAAI,CAACC,MAAY,CAACC,KAAS,CAACC;AACpB,YAAA,IAAI,MAAM,uDAAuD;AAGnE,UAAAC,IAAaF,KAASC,IAAS,SAASA,CAAM,IAAID,CAAK,KAAK,OAAOD,CAAO,GAC1EI,IAAQV,EAAO,MAAM,UAAU,CAAC,EAAE,IAAAW,EAAA,MAASA,MAAOF,CAAU;AAClE,IAAIC,MAAU,MAIPV,EAAA,MAAM,OAAOU,GAAO,CAAC;AAAA,EAAA;AAUrB,WAAAE,EAAOC,GAAqBL,GAAwBM,GAAsD;AACjH,UAAMC,IAAUC,EAAM,IAAIb,GAAeW,CAAY,GAE/CH,IAAKI,KAAA,QAAAA,EAAS,QAAQ,SAASP,CAAM,IAAIO,EAAQ,KAAK,KAAKE,EAAS,QAAQ;AAClF,QAAI,EAAAF,KAAA,QAAAA,EAAS,SAASf,EAAO,MAAM,KAAK,CAAC,EAAE,IAAIkB,EAAW,MAAMA,MAAeP,CAAE;AAIjF,aAAAX,EAAO,MAAM,KAAK;AAAA,QAChB,MAAAa;AAAA,QACA,IAAAF;AAAA,QACA,QAAAH;AAAA,QACA,WAAWO,EAAQ;AAAA,MAAA,CACpB,GAEG,OAAOA,EAAQ,WAAY,YAClB,WAAA,MAAMX,EAAOO,CAAE,GAAG,KAAK,IAAII,EAAQ,OAAO,CAAC,GAGjDJ;AAAA,EAAA;AAGT,WAASQ,IAAY;AACnB,IAAAnB,EAAO,QAAQ,CAAC;AAAA,EAAA;AAGT,WAAAoB,EAA8BP,GAAqBE,GAAoC;AACvF,WAAAH,EAAOC,GAAM,SAASE,CAAO;AAAA,EAAA;AAG7B,WAAAM,EAA6BR,GAAqBE,GAAoC;AACtF,WAAAH,EAAOC,GAAM,QAAQE,CAAO;AAAA,EAAA;AAG5B,WAAAO,EAAgCT,GAAqBE,GAAoC;AACzF,WAAAH,EAAOC,GAAM,WAAWE,CAAO;AAAA,EAAA;AAG/B,WAAAQ,EAAgCV,GAAqBE,GAAoC;AACzF,WAAAH,EAAOC,GAAM,WAAWE,CAAO;AAAA,EAAA;AAGxC,SAAOS,EAAS;AAAA;AAAA;AAAA;AAAA,IAId,QAAQC,EAASzB,CAAM;AAAA;AAAA;AAAA;AAAA,IAKvB,QAAAI;AAAA;AAAA;AAAA;AAAA,IAKA,QAAAQ;AAAA;AAAA;AAAA;AAAA,IAKA,WAAAO;AAAA;AAAA;AAAA;AAAA,IAKA,OAAAC;AAAA;AAAA;AAAA;AAAA,IAKA,MAAAC;AAAA;AAAA;AAAA;AAAA,IAKA,SAAAC;AAAA;AAAA;AAAA;AAAA,IAKA,SAAAC;AAAA,EAAA,CACD;AACH;"}
1
+ {"version":3,"file":"useToasts.js","sources":["../src/composables/useToasts/useToasts.ts"],"sourcesContent":["import merge from 'lodash-es/merge';\nimport uniqueId from 'lodash-es/uniqueId';\nimport { reactive, readonly, ref, RenderFunction } from 'vue';\n\nimport { StatusSeverity } from '../../../types/statusLevels';\n\nexport const DEFAULT_TIMEOUT = 5000;\n\nexport type Toast = {\n id: string;\n text: string | RenderFunction;\n status: StatusSeverity;\n offsetTop?: string;\n};\n\nexport interface ToastOptions {\n /**\n * The timeout in milliseconds before the toast is automatically dismissed. If set to `false`, the toast will persist until the user clicks on it.\n * @default DEFAULT_TIMEOUT\n */\n timeout?: number | boolean;\n /**\n * A group name ensures only one toast with the same group and status is visible at any given time.\n * Toasts with the same group but different statuses will be treated as separate and will display concurrently.\n */\n group?: string;\n /**\n * The container distance from the top of the viewport.\n */\n offsetTop?: string;\n}\n\ntype ToastIdOrUndefined<O extends ToastOptions | undefined> = O extends { id: string }\n ? Toast['id'] | undefined\n : Toast['id'];\n\nconst active = ref<Toast[]>([]);\n\nexport default function useToasts(globalOptions: Omit<ToastOptions, 'group'> = { timeout: DEFAULT_TIMEOUT }) {\n // method overloads\n function remove(toastId: Toast['id']): void;\n function remove(options: { group: string; status: StatusSeverity }): void;\n function remove(toastIdOrOptions: Toast['id'] | { group: string; status: StatusSeverity }) {\n const toastId = typeof toastIdOrOptions === 'string' ? toastIdOrOptions : undefined;\n const { group = undefined, status = undefined } = typeof toastIdOrOptions === 'object' ? toastIdOrOptions : {};\n\n if (!toastId && (!group || !status)) {\n throw new Error('Must provide either a toast ID or both group and type');\n }\n\n const idToRemove = group && status ? `toast-${status}-${group}` : String(toastId);\n const index = active.value.findIndex(({ id }) => id === idToRemove);\n if (index === -1) {\n return;\n }\n\n active.value.splice(index, 1);\n }\n\n // method overloads\n function create(text: Toast['text'], status: StatusSeverity, options?: Omit<ToastOptions, 'group'>): Toast['id'];\n function create(\n text: Toast['text'],\n status: StatusSeverity,\n options: ToastOptions & { id: string },\n ): Toast['id'] | undefined;\n function create(text: Toast['text'], status: StatusSeverity, localOptions?: ToastOptions): Toast['id'] | undefined {\n const options = merge({}, globalOptions, localOptions);\n\n const id = options?.group ? `toast-${status}-${options.group}` : uniqueId('toast-');\n if (options?.group && active.value.some(({ id: existingId }) => existingId === id)) {\n return;\n }\n\n active.value.push({\n text,\n id,\n status,\n offsetTop: options.offsetTop,\n });\n\n if (typeof options.timeout === 'number') {\n setTimeout(() => remove(id), Math.abs(options.timeout));\n }\n\n return id;\n }\n\n function removeAll() {\n active.value = [];\n }\n\n function error<O extends ToastOptions>(text: Toast['text'], options?: O): ToastIdOrUndefined<O> {\n return create(text, 'error', options);\n }\n\n function info<O extends ToastOptions>(text: Toast['text'], options?: O): ToastIdOrUndefined<O> {\n return create(text, 'info', options);\n }\n\n function success<O extends ToastOptions>(text: Toast['text'], options?: O): ToastIdOrUndefined<O> {\n return create(text, 'success', options);\n }\n\n function warning<O extends ToastOptions>(text: Toast['text'], options?: O): ToastIdOrUndefined<O> {\n return create(text, 'warning', options);\n }\n\n return reactive({\n /**\n * The list of toasts that are currently visible.\n */\n active: readonly(active),\n\n /**\n * Removes an active/visible toast by id or by group and type.\n */\n remove,\n\n /**\n * Creates a new toast and makes it active/visible.\n */\n create,\n\n /**\n * Removes all active/visible toasts.\n */\n removeAll,\n\n /**\n * Creates a new \"error\" toast.\n */\n error,\n\n /**\n * Creates a new \"info\" toast.\n */\n info,\n\n /**\n * Creates a new \"success\" toast.\n */\n success,\n\n /**\n * Creates a new \"warning\" toast.\n */\n warning,\n });\n}\n"],"names":["DEFAULT_TIMEOUT","active","ref","useToasts","globalOptions","remove","toastIdOrOptions","toastId","group","status","idToRemove","index","id","create","text","localOptions","options","merge","uniqueId","existingId","removeAll","error","info","success","warning","reactive","readonly"],"mappings":";;;AAMO,MAAMA,IAAkB,KA8BzBC,IAASC,EAAa,EAAE;AAE9B,SAAwBC,EAAUC,IAA6C,EAAE,SAASJ,KAAmB;AAI3G,WAASK,EAAOC,GAA2E;AACzF,UAAMC,IAAU,OAAOD,KAAqB,WAAWA,IAAmB,QACpE,EAAE,OAAAE,IAAQ,QAAW,QAAAC,IAAS,OAAA,IAAc,OAAOH,KAAqB,WAAWA,IAAmB,CAAA;AAE5G,QAAI,CAACC,MAAY,CAACC,KAAS,CAACC;AAC1B,YAAM,IAAI,MAAM,uDAAuD;AAGzE,UAAMC,IAAaF,KAASC,IAAS,SAASA,CAAM,IAAID,CAAK,KAAK,OAAOD,CAAO,GAC1EI,IAAQV,EAAO,MAAM,UAAU,CAAC,EAAE,IAAAW,EAAA,MAASA,MAAOF,CAAU;AAClE,IAAIC,MAAU,MAIdV,EAAO,MAAM,OAAOU,GAAO,CAAC;AAAA,EAC9B;AASA,WAASE,EAAOC,GAAqBL,GAAwBM,G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;AAAA,EAAA,CACD;AACH;"}
@@ -1,30 +1,30 @@
1
1
  import O from "lodash-es/debounce";
2
- import V from "lodash-es/get";
3
- import { toValue as u, computed as c, ref as N, watch as L, reactive as I, nextTick as w, readonly as E } from "vue";
4
- import { DECIMAL_PRECISION as A, DEBOUNCE as q } from "./constants.js";
2
+ import E from "lodash-es/get";
3
+ import { toValue as u, computed as c, ref as V, watch as F, reactive as I, nextTick as w, readonly as S } from "vue";
4
+ import { DECIMAL_PRECISION as L, DEBOUNCE as A } from "./constants.js";
5
5
  import { t as f } from "./locale.js";
6
6
  import { i as l } from "./isDefined-DzVx0B6k.js";
7
- import D from "lodash-es/round";
8
- function j(e) {
7
+ import q from "lodash-es/round";
8
+ function D(e) {
9
9
  return e && e.constructor && typeof e.constructor.isBuffer == "function" && e.constructor.isBuffer(e);
10
10
  }
11
- function C(e) {
11
+ function j(e) {
12
12
  return e;
13
13
  }
14
- function F(e, t) {
14
+ function C(e, t) {
15
15
  t = t || {};
16
- const i = t.delimiter || ".", o = t.maxDepth, s = t.transformKey || C, m = {};
17
- function v(h, y, g) {
18
- g = g || 1, Object.keys(h).forEach(function(p) {
19
- const r = h[p], x = t.safe && Array.isArray(r), n = Object.prototype.toString.call(r), a = j(r), b = n === "[object Object]" || n === "[object Array]", d = y ? y + i + s(p) : s(p);
20
- if (!x && !a && b && Object.keys(r).length && (!t.maxDepth || g < o))
21
- return v(r, d, g + 1);
22
- m[d] = r;
16
+ const i = t.delimiter || ".", s = t.maxDepth, a = t.transformKey || j, m = {};
17
+ function h(v, y, g) {
18
+ g = g || 1, Object.keys(v).forEach(function(p) {
19
+ const n = v[p], N = t.safe && Array.isArray(n), r = Object.prototype.toString.call(n), o = D(n), b = r === "[object Object]" || r === "[object Array]", d = y ? y + i + a(p) : a(p);
20
+ if (!N && !o && b && Object.keys(n).length && (!t.maxDepth || g < s))
21
+ return h(n, d, g + 1);
22
+ m[d] = n;
23
23
  });
24
24
  }
25
- return v(e), m;
25
+ return h(e), m;
26
26
  }
27
- function Y(e = {}) {
27
+ function P(e = {}) {
28
28
  return {
29
29
  name: "email",
30
30
  validator(t) {
@@ -33,20 +33,20 @@ function Y(e = {}) {
33
33
  message: e.message || f("ll.validation.email")
34
34
  };
35
35
  }
36
- function _(e) {
36
+ function Y(e) {
37
37
  return {
38
38
  name: "maxLength",
39
39
  validator(t) {
40
- const i = u(e.max), o = u(t);
41
- if (!l(o))
40
+ const i = u(e.max), s = u(t);
41
+ if (!l(s))
42
42
  return !0;
43
- let s = String(o);
44
- return e.trim && (s = s.trim()), s.length <= i;
43
+ let a = String(s);
44
+ return e.trim && (a = a.trim()), a.length <= i;
45
45
  },
46
46
  message: e.message || (() => f("ll.validation.maxLength", { max: String(u(e.max)) }))
47
47
  };
48
48
  }
49
- function z(e) {
49
+ function _(e) {
50
50
  return {
51
51
  name: "maxValue",
52
52
  validator(t) {
@@ -56,20 +56,20 @@ function z(e) {
56
56
  message: e.message || (() => f("ll.validation.maxValue", { max: String(u(e.max)) }))
57
57
  };
58
58
  }
59
- function G(e) {
59
+ function z(e) {
60
60
  return {
61
61
  name: "minLength",
62
62
  validator(t) {
63
- const i = u(e.min), o = u(t);
64
- if (!l(o))
63
+ const i = u(e.min), s = u(t);
64
+ if (!l(s))
65
65
  return !0;
66
- let s = String(o);
67
- return e.trim && (s = s.trim()), s.length >= i;
66
+ let a = String(s);
67
+ return e.trim && (a = a.trim()), a.length >= i;
68
68
  },
69
69
  message: e.message || (() => f("ll.validation.minLength", { min: String(u(e.min)) }))
70
70
  };
71
71
  }
72
- function H(e) {
72
+ function G(e) {
73
73
  return {
74
74
  name: "minValue",
75
75
  validator(t) {
@@ -79,7 +79,7 @@ function H(e) {
79
79
  message: e.message || (() => f("ll.validation.minValue", { min: String(u(e.min)) }))
80
80
  };
81
81
  }
82
- function J(e) {
82
+ function H(e) {
83
83
  return {
84
84
  name: "pattern",
85
85
  validator(t) {
@@ -95,7 +95,7 @@ function J(e) {
95
95
  }
96
96
  };
97
97
  }
98
- function Q(e = {}) {
98
+ function J(e = {}) {
99
99
  return {
100
100
  name: "positiveNumber",
101
101
  validator(t) {
@@ -104,17 +104,17 @@ function Q(e = {}) {
104
104
  message: e.message || f("ll.validation.positiveNumber")
105
105
  };
106
106
  }
107
- function X(e = {}) {
107
+ function Q(e = {}) {
108
108
  return {
109
109
  name: "price",
110
110
  validator(t) {
111
111
  const i = Number(t);
112
- return !l(t) || i !== 1 / 0 && i >= 0 && i === D(i, A.CURRENCY);
112
+ return !l(t) || i !== 1 / 0 && i >= 0 && i === q(i, L.CURRENCY);
113
113
  },
114
114
  message: e.message || f("ll.validation.price")
115
115
  };
116
116
  }
117
- function Z(e = {}) {
117
+ function X(e = {}) {
118
118
  return {
119
119
  name: "required",
120
120
  validator(t) {
@@ -123,7 +123,7 @@ function Z(e = {}) {
123
123
  message: e.message || f("ll.validation.required")
124
124
  };
125
125
  }
126
- function W(e = {}) {
126
+ function Z(e = {}) {
127
127
  return {
128
128
  name: "wholeNumber",
129
129
  validator(t) {
@@ -136,97 +136,93 @@ function ee({
136
136
  rules: e,
137
137
  values: t
138
138
  }) {
139
- const o = c(() => Object.keys(F(e, { safe: !0 }))).value.reduce(
140
- (n, a) => {
141
- const b = N(V(u(t), a)), d = (T) => {
142
- b.value = V(u(t), T);
143
- }, S = O(() => {
144
- d(a);
145
- }, q.FAST);
146
- return L(
147
- () => V(u(t), a),
139
+ const s = c(() => Object.keys(C(e, { safe: !0 }))).value.reduce(
140
+ (r, o) => {
141
+ const b = V(E(u(t), o)), d = (T) => {
142
+ b.value = E(u(t), T);
143
+ }, x = O(() => {
144
+ d(o);
145
+ }, A.FAST);
146
+ return F(
147
+ () => E(u(t), o),
148
148
  () => {
149
- S();
149
+ x();
150
150
  }
151
- ), n[a] = B({
152
- fieldName: a,
151
+ ), r[o] = B({
152
+ fieldName: o,
153
153
  fieldValue: b,
154
154
  flush: () => {
155
- S.cancel(), d(a);
155
+ x.cancel(), d(o);
156
156
  },
157
- rules: V(e, a)
158
- }), n;
157
+ rules: E(e, o)
158
+ }), r;
159
159
  },
160
160
  {}
161
- ), s = c(() => Object.values(o)), m = c(() => s.value.some((n) => n.errors.length > 0)), v = c(() => s.value.some((n) => n.isTouched)), h = c(() => s.value.filter((n) => n.isDirty));
161
+ ), a = c(() => Object.values(s)), m = c(() => a.value.some((r) => r.errors.length > 0)), h = c(() => a.value.some((r) => r.isTouched)), v = c(() => a.value.filter((r) => r.isDirty));
162
162
  return I({
163
- validate: async function({ preventScroll: n } = {}) {
164
- if (s.value.forEach((a) => {
165
- a.setTouched(!1), a.setTouched(!0);
166
- }), await w(), m.value && !n) {
167
- const a = Object.entries(o).find(([, S]) => S.errorMessage), b = (a == null ? void 0 : a[0]) || "", d = document == null ? void 0 : document.querySelector(`[name=${b}]`);
163
+ validate: async function({ preventScroll: r } = {}) {
164
+ if (a.value.forEach((o) => {
165
+ o.setTouched(!1), o.setTouched(!0);
166
+ }), await w(), m.value && !r) {
167
+ const b = Object.entries(s).find(([, x]) => x.errorMessage)?.[0] || "", d = document?.querySelector(`[name=${b}]`);
168
168
  d && d.scrollIntoView({ behavior: "smooth" });
169
169
  }
170
170
  return !m.value;
171
171
  },
172
- getError: function(n) {
173
- var a;
174
- return ((a = o[n]) == null ? void 0 : a.errorMessage) || "";
172
+ getError: function(r) {
173
+ return s[r]?.errorMessage || "";
175
174
  },
176
- touch: function(n) {
177
- if (!o[n])
178
- throw new Error(`In touch: fieldName "${n}" does not exist in the validation fields.`);
179
- o[n].setTouched();
175
+ touch: function(r) {
176
+ if (!s[r])
177
+ throw new Error(`In touch: fieldName "${r}" does not exist in the validation fields.`);
178
+ s[r].setTouched();
180
179
  },
181
180
  setAllUntouched: async function() {
182
- await w(), s.value.forEach((n) => {
183
- n.setTouched(!1);
181
+ await w(), a.value.forEach((r) => {
182
+ r.setTouched(!1);
184
183
  });
185
184
  },
186
- setInitialValues: function(n) {
187
- s.value.forEach((a) => {
188
- a.setInitialValue(n[a.name]);
185
+ setInitialValues: function(r) {
186
+ a.value.forEach((o) => {
187
+ o.setInitialValue(r[o.name]);
189
188
  });
190
189
  },
191
- fields: o,
192
- dirtyFields: h,
190
+ fields: s,
191
+ dirtyFields: v,
193
192
  hasErrors: m,
194
- someTouched: v
193
+ someTouched: h
195
194
  });
196
195
  }
197
196
  function B({
198
197
  fieldName: e,
199
198
  fieldValue: t,
200
199
  rules: i,
201
- flush: o
200
+ flush: s
202
201
  }) {
203
- const s = N(t.value), m = N(!1), v = c(() => (t.value ?? "") !== (s.value ?? "")), h = c(() => m.value ? i.map((r) => ({
202
+ const a = V(t.value), m = V(!1), h = c(() => (t.value ?? "") !== (a.value ?? "")), v = c(() => m.value ? i.map((n) => ({
204
203
  fieldName: e,
205
- ruleName: r.name,
206
- isValid: r.validator(t.value),
207
- message: typeof r.message == "function" ? r.message(t.value) : r.message
204
+ ruleName: n.name,
205
+ isValid: n.validator(t.value),
206
+ message: typeof n.message == "function" ? n.message(t.value) : n.message
208
207
  })) : []), y = c(
209
- () => h.value.filter((r) => !r.isValid).map((r) => ({
210
- ruleName: r.ruleName,
211
- message: r.message
208
+ () => v.value.filter((n) => !n.isValid).map((n) => ({
209
+ ruleName: n.ruleName,
210
+ message: n.message
212
211
  }))
213
212
  );
214
- function g(r = !0) {
215
- o(), m.value = r;
213
+ function g(n = !0) {
214
+ s(), m.value = n;
216
215
  }
217
- function p(r) {
218
- s.value = r;
216
+ function p(n) {
217
+ a.value = n;
219
218
  }
220
219
  return I({
221
220
  name: e,
222
- currentValue: E(t),
223
- initialValue: E(s),
224
- isTouched: E(m),
225
- isDirty: E(v),
226
- errorMessage: c(() => {
227
- var r, x;
228
- return ((x = (r = y.value) == null ? void 0 : r[0]) == null ? void 0 : x.message) || "";
229
- }),
221
+ currentValue: S(t),
222
+ initialValue: S(a),
223
+ isTouched: S(m),
224
+ isDirty: S(h),
225
+ errorMessage: c(() => y.value?.[0]?.message || ""),
230
226
  errors: y,
231
227
  setInitialValue: p,
232
228
  setTouched: g
@@ -234,16 +230,16 @@ function B({
234
230
  }
235
231
  export {
236
232
  ee as default,
237
- Y as email,
233
+ P as email,
238
234
  l as isDefined,
239
- _ as maxLength,
240
- z as maxValue,
241
- G as minLength,
242
- H as minValue,
243
- J as pattern,
244
- Q as positiveNumber,
245
- X as price,
246
- Z as required,
247
- W as wholeNumber
235
+ Y as maxLength,
236
+ _ as maxValue,
237
+ z as minLength,
238
+ G as minValue,
239
+ H as pattern,
240
+ J as positiveNumber,
241
+ Q as price,
242
+ X as required,
243
+ Z as wholeNumber
248
244
  };
249
245
  //# sourceMappingURL=useValidation.js.map