bitboss-ui 0.2.31 → 0.2.32

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 (326) hide show
  1. package/dist/components/BaseButton/BaseButton.vue.d.ts +6 -6
  2. package/dist/components/BaseCheckbox/BaseCheckbox.vue.d.ts +16 -16
  3. package/dist/components/BaseCheckboxGroup/BaseCheckboxGroup.vue.d.ts +36 -36
  4. package/dist/components/BaseDatePicker/BaseDatePicker.vue.d.ts +20 -20
  5. package/dist/components/BaseDatePickerInput/BaseDatePickerInput.vue.d.ts +21 -21
  6. package/dist/components/BaseDialog/BaseDialog.vue.d.ts +8 -8
  7. package/dist/components/BaseInputContainer/BaseInputContainer.vue.d.ts +6 -6
  8. package/dist/components/BaseNumberInput/BaseNumberInput.vue.d.ts +20 -20
  9. package/dist/components/BaseRadio/BaseRadio.vue.d.ts +20 -20
  10. package/dist/components/BaseRadioGroup/BaseRadioGroup.vue.d.ts +36 -36
  11. package/dist/components/BaseRating/BaseRating.vue.d.ts +17 -17
  12. package/dist/components/BaseSelect/BaseSelect.vue.d.ts +23 -23
  13. package/dist/components/BaseSlider/BaseSlider.vue.d.ts +15 -15
  14. package/dist/components/BaseSwitch/BaseSwitch.vue.d.ts +1 -1
  15. package/dist/components/BaseSwitchGroup/BaseSwitchGroup.vue.d.ts +20 -20
  16. package/dist/components/BaseTag/BaseTag.vue.d.ts +20 -20
  17. package/dist/components/BaseTextInput/BaseTextInput.vue.d.ts +19 -19
  18. package/dist/components/BaseTextarea/BaseTextarea.vue.d.ts +18 -18
  19. package/dist/components/BbAccordion/BbAccordion.vue.d.ts +3 -3
  20. package/dist/components/BbAlert/BbAlert.vue.d.ts +3 -3
  21. package/dist/components/BbAvatar/BbAvatar.vue.d.ts +8 -8
  22. package/dist/components/BbBadge/BbBadge.vue.d.ts +1 -1
  23. package/dist/components/BbBreadcrumbs/BbBreadcrumbs.vue.d.ts +6 -6
  24. package/dist/components/BbButton/BbButton.vue.d.ts +1 -1
  25. package/dist/components/BbCheckbox/BbCheckbox.vue.d.ts +11 -11
  26. package/dist/components/BbCheckboxGroup/BbCheckboxGroup.vue.d.ts +27 -27
  27. package/dist/components/BbChip/BbChip.vue.d.ts +2 -2
  28. package/dist/components/BbConfirm/BbConfirm.vue.d.ts +4 -4
  29. package/dist/components/BbDatePickerInput/BbDatePickerInput.vue.d.ts +16 -24
  30. package/dist/components/BbDialog/BbDialog.vue.d.ts +2 -2
  31. package/dist/components/BbDropdown/BbDropdown.vue.d.ts +11 -11
  32. package/dist/components/BbDropdownButton/BbDropdownButton.vue.d.ts +14 -14
  33. package/dist/components/BbDropzone/BbDropzone.vue.d.ts +4 -4
  34. package/dist/components/BbIntersection/BbIntersection.vue.d.ts +3 -3
  35. package/dist/components/BbNumberInput/BbNumberInput.vue.d.ts +10 -10
  36. package/dist/components/BbOffCanvas/BbOffCanvas.vue.d.ts +9 -9
  37. package/dist/components/BbPagination/BbPagination.vue.d.ts +1 -1
  38. package/dist/components/BbPopover/BbPopover.vue.d.ts +8 -8
  39. package/dist/components/BbRadio/BbRadio.vue.d.ts +10 -10
  40. package/dist/components/BbRadioGroup/BbRadioGroup.vue.d.ts +27 -27
  41. package/dist/components/BbRating/BbRating.vue.d.ts +10 -10
  42. package/dist/components/BbSelect/BbSelect.vue.d.ts +19 -19
  43. package/dist/components/BbSlider/BbSlider.vue.d.ts +8 -8
  44. package/dist/components/BbSmoothHeight/BbSmoothHeight.vue.d.ts +1 -1
  45. package/dist/components/BbSpinner/BbSpinner.vue.d.ts +2 -2
  46. package/dist/components/BbSwitch/BbSwitch.vue.d.ts +2 -2
  47. package/dist/components/BbSwitchGroup/BbSwitchGroup.vue.d.ts +20 -20
  48. package/dist/components/BbTab/BbTab.vue.d.ts +5 -5
  49. package/dist/components/BbTable/BbTable.vue.d.ts +11 -11
  50. package/dist/components/BbTable/types.d.ts +107 -107
  51. package/dist/components/BbTag/BbTag.vue.d.ts +13 -13
  52. package/dist/components/BbTextInput/BbTextInput.vue.d.ts +11 -11
  53. package/dist/components/BbTextarea/BbTextarea.vue.d.ts +10 -10
  54. package/dist/components/BbToast/BbToast.vue.d.ts +1 -1
  55. package/dist/components/BbToast/BbToastMessage.vue.d.ts +1 -1
  56. package/dist/components/BbTooltip/BbTooltip.vue.d.ts +3 -3
  57. package/dist/components/BbTree/BbTree.vue.d.ts +1 -1
  58. package/dist/composables/useConfirm.d.ts +10 -10
  59. package/dist/composables/useOptions.d.ts +2 -2
  60. package/dist/composables/useRoute.d.ts +2 -2
  61. package/dist/composables/useRouter.d.ts +1 -1
  62. package/dist/composables/useToast.d.ts +5 -5
  63. package/dist/composables/useWizard.d.ts +1 -1
  64. package/dist/index.d.ts +126 -126
  65. package/dist/index101.js +32 -37
  66. package/dist/index101.js.map +1 -1
  67. package/dist/index103.js +19 -19
  68. package/dist/index103.js.map +1 -1
  69. package/dist/index105.js +16 -16
  70. package/dist/index105.js.map +1 -1
  71. package/dist/index107.js +15 -15
  72. package/dist/index107.js.map +1 -1
  73. package/dist/index109.js.map +1 -1
  74. package/dist/index11.js +7 -7
  75. package/dist/index11.js.map +1 -1
  76. package/dist/index111.js +16 -16
  77. package/dist/index111.js.map +1 -1
  78. package/dist/index113.js +3 -3
  79. package/dist/index113.js.map +1 -1
  80. package/dist/index115.js +6 -6
  81. package/dist/index115.js.map +1 -1
  82. package/dist/index116.js +1 -1
  83. package/dist/index116.js.map +1 -1
  84. package/dist/index117.js +1 -1
  85. package/dist/index117.js.map +1 -1
  86. package/dist/index118.js +4 -4
  87. package/dist/index118.js.map +1 -1
  88. package/dist/index119.js +5 -5
  89. package/dist/index119.js.map +1 -1
  90. package/dist/index120.js.map +1 -1
  91. package/dist/index121.js.map +1 -1
  92. package/dist/index122.js.map +1 -1
  93. package/dist/index124.js.map +1 -1
  94. package/dist/index125.js +4 -4
  95. package/dist/index125.js.map +1 -1
  96. package/dist/index126.js +1 -1
  97. package/dist/index126.js.map +1 -1
  98. package/dist/index127.js +1 -1
  99. package/dist/index128.js +4 -1
  100. package/dist/index128.js.map +1 -1
  101. package/dist/index129.js.map +1 -1
  102. package/dist/index13.js +11 -11
  103. package/dist/index13.js.map +1 -1
  104. package/dist/index130.js.map +1 -1
  105. package/dist/index131.js +2 -2
  106. package/dist/index15.js +226 -224
  107. package/dist/index15.js.map +1 -1
  108. package/dist/index17.js +61 -62
  109. package/dist/index17.js.map +1 -1
  110. package/dist/index19.js +22 -22
  111. package/dist/index19.js.map +1 -1
  112. package/dist/index196.js.map +1 -1
  113. package/dist/index197.js +2 -5
  114. package/dist/index197.js.map +1 -1
  115. package/dist/index198.js +4 -16
  116. package/dist/index198.js.map +1 -1
  117. package/dist/index199.js +293 -14
  118. package/dist/index199.js.map +1 -1
  119. package/dist/index2.js +23 -23
  120. package/dist/index2.js.map +1 -1
  121. package/dist/index200.js +15 -18
  122. package/dist/index200.js.map +1 -1
  123. package/dist/index201.js +13 -17
  124. package/dist/index201.js.map +1 -1
  125. package/dist/index202.js +18 -28
  126. package/dist/index202.js.map +1 -1
  127. package/dist/index203.js +20 -8
  128. package/dist/index203.js.map +1 -1
  129. package/dist/index204.js +29 -2
  130. package/dist/index204.js.map +1 -1
  131. package/dist/index205.js +8 -378
  132. package/dist/index205.js.map +1 -1
  133. package/dist/index206.js +2 -134
  134. package/dist/index206.js.map +1 -1
  135. package/dist/index207.js +235 -2
  136. package/dist/index207.js.map +1 -1
  137. package/dist/index208.js +3 -174
  138. package/dist/index208.js.map +1 -1
  139. package/dist/index209.js +35 -23
  140. package/dist/index209.js.map +1 -1
  141. package/dist/index21.js +4 -4
  142. package/dist/index21.js.map +1 -1
  143. package/dist/index210.js +6 -373
  144. package/dist/index210.js.map +1 -1
  145. package/dist/index211.js +10 -2
  146. package/dist/index211.js.map +1 -1
  147. package/dist/index212.js +378 -4
  148. package/dist/index212.js.map +1 -1
  149. package/dist/index213.js +134 -3
  150. package/dist/index213.js.map +1 -1
  151. package/dist/index214.js +2 -3
  152. package/dist/index214.js.map +1 -1
  153. package/dist/index215.js +172 -8
  154. package/dist/index215.js.map +1 -1
  155. package/dist/index216.js +23 -3
  156. package/dist/index216.js.map +1 -1
  157. package/dist/index217.js +369 -31
  158. package/dist/index217.js.map +1 -1
  159. package/dist/index218.js +3 -6
  160. package/dist/index218.js.map +1 -1
  161. package/dist/index219.js +3 -2
  162. package/dist/index219.js.map +1 -1
  163. package/dist/index220.js.map +1 -1
  164. package/dist/index221.js +26 -233
  165. package/dist/index221.js.map +1 -1
  166. package/dist/index222.js +16 -8
  167. package/dist/index222.js.map +1 -1
  168. package/dist/index223.js +2 -121
  169. package/dist/index223.js.map +1 -1
  170. package/dist/index224.js +8 -27
  171. package/dist/index224.js.map +1 -1
  172. package/dist/index225.js +120 -12
  173. package/dist/index225.js.map +1 -1
  174. package/dist/index226.js +1 -1
  175. package/dist/index227.js +4 -295
  176. package/dist/index227.js.map +1 -1
  177. package/dist/index228.js +2 -6
  178. package/dist/index228.js.map +1 -1
  179. package/dist/index229.js +6 -2
  180. package/dist/index229.js.map +1 -1
  181. package/dist/index23.js +14 -16
  182. package/dist/index23.js.map +1 -1
  183. package/dist/index230.js +2 -2
  184. package/dist/index235.js +2 -2
  185. package/dist/index236.js +428 -110
  186. package/dist/index236.js.map +1 -1
  187. package/dist/index237.js +88 -105
  188. package/dist/index237.js.map +1 -1
  189. package/dist/index238.js +199 -3
  190. package/dist/index238.js.map +1 -1
  191. package/dist/index239.js +1 -1
  192. package/dist/index240.js +1 -1
  193. package/dist/index241.js +2 -435
  194. package/dist/index241.js.map +1 -1
  195. package/dist/index242.js +115 -87
  196. package/dist/index242.js.map +1 -1
  197. package/dist/index243.js +104 -198
  198. package/dist/index243.js.map +1 -1
  199. package/dist/index244.js +160 -2
  200. package/dist/index244.js.map +1 -1
  201. package/dist/index245.js +2 -2
  202. package/dist/index245.js.map +1 -1
  203. package/dist/index246.js +9 -9
  204. package/dist/index246.js.map +1 -1
  205. package/dist/index247.js +5 -162
  206. package/dist/index247.js.map +1 -1
  207. package/dist/index248.js +1 -1
  208. package/dist/index249.js +37 -14
  209. package/dist/index249.js.map +1 -1
  210. package/dist/index25.js +4 -4
  211. package/dist/index25.js.map +1 -1
  212. package/dist/index250.js +2 -38
  213. package/dist/index250.js.map +1 -1
  214. package/dist/index251.js +2 -2
  215. package/dist/index251.js.map +1 -1
  216. package/dist/index252.js +15 -2
  217. package/dist/index252.js.map +1 -1
  218. package/dist/index253.js +3 -2
  219. package/dist/index253.js.map +1 -1
  220. package/dist/index255.js +2 -3
  221. package/dist/index255.js.map +1 -1
  222. package/dist/index27.js +7 -7
  223. package/dist/index27.js.map +1 -1
  224. package/dist/index29.js +15 -15
  225. package/dist/index29.js.map +1 -1
  226. package/dist/index3.js +2 -1
  227. package/dist/index3.js.map +1 -1
  228. package/dist/index31.js +28 -28
  229. package/dist/index31.js.map +1 -1
  230. package/dist/index33.js +10 -11
  231. package/dist/index33.js.map +1 -1
  232. package/dist/index35.js +2 -2
  233. package/dist/index35.js.map +1 -1
  234. package/dist/index37.js +12 -12
  235. package/dist/index37.js.map +1 -1
  236. package/dist/index39.js +5 -7
  237. package/dist/index39.js.map +1 -1
  238. package/dist/index4.js.map +1 -1
  239. package/dist/index41.js +5 -5
  240. package/dist/index41.js.map +1 -1
  241. package/dist/index43.js +19 -16
  242. package/dist/index43.js.map +1 -1
  243. package/dist/index45.js +9 -9
  244. package/dist/index45.js.map +1 -1
  245. package/dist/index47.js +4 -4
  246. package/dist/index47.js.map +1 -1
  247. package/dist/index49.js +1 -1
  248. package/dist/index49.js.map +1 -1
  249. package/dist/index5.js +7 -6
  250. package/dist/index5.js.map +1 -1
  251. package/dist/index51.js +6 -6
  252. package/dist/index51.js.map +1 -1
  253. package/dist/index53.js.map +1 -1
  254. package/dist/index55.js +20 -20
  255. package/dist/index55.js.map +1 -1
  256. package/dist/index57.js +35 -35
  257. package/dist/index57.js.map +1 -1
  258. package/dist/index59.js +8 -8
  259. package/dist/index59.js.map +1 -1
  260. package/dist/index6.js +38 -38
  261. package/dist/index6.js.map +1 -1
  262. package/dist/index61.js +27 -27
  263. package/dist/index61.js.map +1 -1
  264. package/dist/index63.js +4 -4
  265. package/dist/index63.js.map +1 -1
  266. package/dist/index65.js +20 -20
  267. package/dist/index65.js.map +1 -1
  268. package/dist/index67.js +26 -26
  269. package/dist/index67.js.map +1 -1
  270. package/dist/index69.js +21 -19
  271. package/dist/index69.js.map +1 -1
  272. package/dist/index7.js.map +1 -1
  273. package/dist/index71.js +2 -2
  274. package/dist/index71.js.map +1 -1
  275. package/dist/index72.js +3 -3
  276. package/dist/index72.js.map +1 -1
  277. package/dist/index73.js +14 -14
  278. package/dist/index73.js.map +1 -1
  279. package/dist/index75.js +18 -18
  280. package/dist/index75.js.map +1 -1
  281. package/dist/index77.js +11 -11
  282. package/dist/index77.js.map +1 -1
  283. package/dist/index79.js +15 -15
  284. package/dist/index79.js.map +1 -1
  285. package/dist/index8.js +10 -7
  286. package/dist/index8.js.map +1 -1
  287. package/dist/index81.js.map +1 -1
  288. package/dist/index83.js +20 -20
  289. package/dist/index83.js.map +1 -1
  290. package/dist/index85.js +34 -34
  291. package/dist/index85.js.map +1 -1
  292. package/dist/index87.js +18 -18
  293. package/dist/index87.js.map +1 -1
  294. package/dist/index89.js.map +1 -1
  295. package/dist/index9.js.map +1 -1
  296. package/dist/index91.js +53 -53
  297. package/dist/index91.js.map +1 -1
  298. package/dist/index93.js +16 -16
  299. package/dist/index93.js.map +1 -1
  300. package/dist/index95.js +21 -21
  301. package/dist/index95.js.map +1 -1
  302. package/dist/index97.js +37 -37
  303. package/dist/index97.js.map +1 -1
  304. package/dist/index99.js +18 -18
  305. package/dist/index99.js.map +1 -1
  306. package/dist/style.css +1 -1
  307. package/dist/types/CommonProps.d.ts +18 -18
  308. package/dist/types/ExtractGenericFromComputedRef.d.ts +1 -1
  309. package/dist/types/ExtractGenericFromRef.d.ts +1 -1
  310. package/dist/types/VoidHtmlElements.d.ts +1 -1
  311. package/dist/utilities/functions/cloneDeep.d.ts +1 -1
  312. package/dist/utilities/functions/debounce.d.ts +1 -1
  313. package/dist/utilities/functions/flow.d.ts +1 -1
  314. package/dist/utilities/functions/get.d.ts +1 -1
  315. package/dist/utilities/functions/isNotNil.d.ts +1 -1
  316. package/dist/utilities/functions/mapValues.d.ts +1 -1
  317. package/dist/utilities/functions/merge.d.ts +1 -1
  318. package/dist/utilities/functions/millisecondsTo.d.ts +1 -1
  319. package/dist/utilities/functions/overEvery.d.ts +1 -1
  320. package/dist/utilities/functions/percentage.d.ts +4 -4
  321. package/dist/utilities/functions/pick.d.ts +1 -1
  322. package/dist/utilities/functions/pickBy.d.ts +1 -1
  323. package/dist/utilities/functions/roundToTheNearest.d.ts +1 -1
  324. package/package.json +93 -77
  325. package/dist/index256.js +0 -5
  326. package/dist/index256.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"index75.js","sources":["../src/components/BbOffCanvas/BbOffCanvas.vue?vue&type=script&setup=true&lang.ts"],"sourcesContent":["import { defineComponent as _defineComponent } from 'vue'\nimport { renderSlot as _renderSlot, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, mergeProps as _mergeProps, Teleport as _Teleport, createBlock as _createBlock } from \"vue\"\n\nconst _hoisted_1 = { class: \"bb-offcanvas-close\" }\nconst _hoisted_2 = { class: \"bb-offcanvas-close__content\" }\nconst _hoisted_3 = { class: \"bb-offcanvas-close__label\" }\nconst _hoisted_4 = /*#__PURE__*/_createElementVNode(\"span\", { class: \"bb-offcanvas-close__icon\" }, [\n /*#__PURE__*/_createElementVNode(\"svg\", {\n viewBox: \"0 0 24 24\",\n fill: \"none\",\n xmlns: \"http://www.w3.org/2000/svg\"\n }, [\n /*#__PURE__*/_createElementVNode(\"path\", {\n d: \"M23 23L1 1M23 1L1 23\",\n stroke: \"currentColor\",\n \"stroke-width\": \"2\",\n \"stroke-linecap\": \"round\"\n })\n ])\n], -1)\nconst _hoisted_5 = /*#__PURE__*/_createElementVNode(\"div\", { style: {\"flex\":\"10000 10000 0%\"} }, null, -1)\n\nimport { computed, nextTick, onBeforeUnmount, onMounted, ref, useAttrs, watch } from \"vue\";\nimport { useFocusTrap } from \"@vueuse/integrations/useFocusTrap\";\nimport { useId } from \"@/composables/useId\";\nimport { wait } from \"@/utilities/functions/wait\";\nimport type { CommonProps, Size } from \"@/types/CommonProps\";\n\nexport type Sizes = {\n sm: number;\n md: number;\n lg: number;\n};\n\nexport type BbOffCanvasProps = Pick<\n CommonProps,\n | \"closeLabel\"\n | \"compact\"\n | \"disabled\"\n | \"eager\"\n | \"panelClasses\"\n | \"overlayClasses\"\n | \"persistent\"\n | \"showClose\"\n | \"title\"\n | \"transition\"\n | \"transitionDuration\"\n> &\n Size<Sizes> & {\n /**\n * Description of the content of the modal. Extremely useful for accessibility reasons.\n */\n description?: string;\n /**\n * Displays the modala as fulscreen with no margin to the page\n */\n fullscreen?: boolean;\n /**\n * Defines the state open / closed of the modal.\n */\n modelValue?: boolean | null;\n /**\n * Defines the direction the offcanvas should appear from\n */\n direction?: \"left\" | \"top\" | \"right\" | \"bottom\";\n };\n\nexport type BbOffCanvasEvents = {\n (e: \"shown\"): void;\n (e: \"hidden\"): void;\n (e: \"update:modelValue\", value: boolean): void;\n};\n\nexport type BbOffCanvasSlots = {\n header?: (props: {\n titleId: typeof titleId;\n close: typeof onCloseClick;\n title: BbOffCanvasProps[\"title\"];\n }) => any;\n title?: (props: { text: BbOffCanvasProps[\"title\"] }) => any;\n close?: (props: { text: BbOffCanvasProps[\"closeLabel\"] }) => any;\n description?: (props: {\n descriptionId: typeof descriptionId;\n text: BbOffCanvasProps[\"description\"];\n }) => any;\n default?: (props: {}) => any;\n content?: (props: { close: typeof onCloseClick }) => any;\n footer?: (props: {}) => any;\n};\n\n\nexport default /*#__PURE__*/_defineComponent({\n __name: 'BbOffCanvas',\n props: {\n closeLabel: { default: \"Chiudi\" },\n compact: { type: Boolean },\n disabled: { type: Boolean },\n eager: { type: Boolean },\n panelClasses: { default: () => [] },\n overlayClasses: { default: () => [] },\n persistent: { type: Boolean },\n showClose: { type: Boolean, default: true },\n title: {},\n transition: { default: \"fade\" },\n transitionDuration: { default: 350 },\n size: { default: \"sm\" },\n description: {},\n fullscreen: { type: Boolean },\n modelValue: { type: [Boolean, null] },\n direction: { default: \"left\" }\n },\n emits: [\"shown\", \"hidden\", \"update:modelValue\"],\n setup(__props: any, { emit: __emit }) {\n\nconst props = __props;\n\nconst emit = __emit;\n\n\n\nconst titleId = `title_${useId().id.value}`;\nconst descriptionId = `description_${useId().id.value}`;\n\nconst overlay = ref<HTMLElement | null>(null);\nconst panel = ref<HTMLElement | null>(null);\nconst content = ref<HTMLElement | null>(null);\nconst header = ref<HTMLElement | null>(null);\nconst body = ref<HTMLElement | null>(null);\nconst footer = ref<HTMLElement | null>(null);\nconst attrs = useAttrs();\n\nconst { activate, deactivate } = useFocusTrap(panel, {\n clickOutsideDeactivates: true,\n /* On esc deactivate the trap, return focus and then close the modal */\n escapeDeactivates: () => {\n nextTick(() => {\n emit(\"update:modelValue\", false);\n });\n return true;\n },\n});\n\nconst closeLabel = computed(() => props.closeLabel);\n\nconst open = ref(false);\nconst opening = ref(false);\nconst closed = ref(true);\nconst closing = ref(false);\nconst hasRenderedAtLeastOnce = ref(props.eager || props.modelValue);\nconst lastFocusedElement = ref<Element | null>(null);\n\nconst busy = computed(() => opening.value || closing.value);\n\nonMounted(() => {\n /**\n * Do not realign if open or opening\n */\n if (props.modelValue && !(open.value || opening.value)) {\n alignToModelValue();\n }\n});\n\n/**\n * Every time modelValue changes align the display to it\n */\nwatch(\n () => props.modelValue,\n () => {\n alignToModelValue();\n }\n);\nonBeforeUnmount(() => {\n if (props.modelValue) {\n let currentlyOpenCanvases = Number(\n document.body.dataset[\"openCanvases\"] ?? \"0\"\n );\n // This prevents overscroll chaining (additional scrolling to the body when the modal has been completely scrolled)\n currentlyOpenCanvases--;\n document.body.dataset[\"openCanvases\"] = currentlyOpenCanvases.toString();\n if (!currentlyOpenCanvases) {\n document.body.style.overflow = \"auto\";\n document.body.style.paddingRight = \"0px\";\n }\n }\n});\n\n/**\n * When modelValue becomes true if the component wasn't rendered render it\n * and wait for it to be on the page (or transitions would not work).\n * Stash the latest focused element so we can return it later when it closes.\n * Focus on the panel upon opening.\n * ---\n * Notice all interactions update modelValue and then this function aligns the display to it\n */\nconst alignToModelValue = async () => {\n if (props.modelValue) {\n if (!hasRenderedAtLeastOnce.value) {\n hasRenderedAtLeastOnce.value = true;\n }\n if (document.activeElement) {\n lastFocusedElement.value = document.activeElement;\n }\n\n closed.value = false;\n closing.value = false;\n opening.value = true;\n\n // This prevents overscroll chaining (additional scrolling to the body when the modal has been completely scrolled)\n\n let currentlyOpenCanvases = Number(\n document.body.dataset[\"openCanvases\"] ?? \"0\"\n );\n currentlyOpenCanvases++;\n document.body.dataset[\"openCanvases\"] = currentlyOpenCanvases.toString();\n const scrollBarWidth =\n window.innerWidth - document.documentElement.clientWidth;\n document.body.style.overflow = \"hidden\";\n document.body.style.paddingRight = `${scrollBarWidth}px`;\n\n await wait(props.transitionDuration);\n\n opening.value = false;\n open.value = true;\n emit(\"shown\");\n activate();\n } else {\n deactivate();\n opening.value = false;\n open.value = false;\n closing.value = true;\n\n await wait(props.transitionDuration);\n\n let currentlyOpenCanvases = Number(\n document.body.dataset[\"openCanvases\"] ?? \"0\"\n );\n // This prevents overscroll chaining (additional scrolling to the body when the modal has been completely scrolled)\n currentlyOpenCanvases--;\n document.body.dataset[\"openCanvases\"] = currentlyOpenCanvases.toString();\n if (!currentlyOpenCanvases) {\n document.body.style.overflow = \"auto\";\n document.body.style.paddingRight = \"0px\";\n }\n closing.value = false;\n closed.value = true;\n emit(\"hidden\");\n if (lastFocusedElement.value instanceof HTMLElement) {\n lastFocusedElement.value.focus();\n }\n }\n};\n\n/**\n * Disable scrolling\n */\nconst onOverlayScroll = (event: UIEvent) => {\n if (event.target === overlay.value) {\n event.preventDefault();\n }\n};\n\n/**\n * Close the modal on overlay click if not persistent\n */\nconst onOverlayClick = (event: MouseEvent) => {\n if (props.disabled || busy.value) return;\n if (overlay.value) {\n if (event.target === overlay.value) {\n if (!props.persistent) {\n emit(\"update:modelValue\", false);\n }\n }\n }\n};\n\n/**\n * On click on the X button\n */\nconst onCloseClick = () => {\n if (props.disabled) return;\n emit(\"update:modelValue\", false);\n};\n\nconst overlayAttributes = computed(() => {\n const classes = [\n {\n \"bb-offcanvas bb-offcanvas__overlay\": true,\n \"bb-offcanvas--fullscreen\": props.fullscreen,\n \"bb-offcanvas--open\": open.value,\n \"bb-offcanvas--opening\": opening.value,\n \"bb-offcanvas--closed\": closed.value,\n \"bb-offcanvas--closing\": closing.value,\n [`bb-offcanvas--transition-${props.transition}`]: true,\n [`bb-offcanvas--${props.direction}`]: true,\n },\n props.overlayClasses,\n ].flat();\n const eventListeners = {\n onClick: onOverlayClick,\n onScroll: onOverlayScroll,\n onTouchmove: onOverlayScroll,\n onWheel: onOverlayScroll,\n onKeydown: onOverlayScroll,\n };\n\n const style = {\n transitionDuration: props.transitionDuration / 1000 + \"s\",\n };\n return {\n class: classes,\n style,\n ...eventListeners,\n ...attrs,\n };\n});\n\nconst panelAttributes = computed(() => {\n const classes = [\n {\n \"bb-offcanvas__panel\": true,\n \"bb-offcanvas__panel--compact\": props.compact,\n },\n props.panelClasses,\n ].flat();\n\n const accessibilityAttrs: {\n [key: string]: string | boolean;\n } = {\n role: \"dialog\",\n \"aria-modal\": true,\n };\n\n if (hasRenderedAtLeastOnce.value) {\n accessibilityAttrs[\"aria-labelledby\"] = titleId;\n\n if (props.description)\n accessibilityAttrs[\"aria-describedby\"] = descriptionId;\n }\n\n let maxWidth;\n let maxHeight;\n let height;\n const sizes: Sizes = {\n sm: 384,\n md: 652,\n lg: 896,\n };\n if (props.direction === \"left\" || props.direction === \"right\") {\n if (props.fullscreen) maxWidth = \"100%\";\n else if (typeof props.size === \"number\") maxWidth = props.size + \"px\";\n else if (props.size in sizes)\n maxWidth = sizes[props.size as keyof Sizes] + \"px\";\n else maxWidth = props.size + \"px\";\n } else {\n if (props.fullscreen) height = \"100%\";\n else if (typeof props.size === \"number\") height = props.size + \"px\";\n else if (props.size in sizes)\n height = sizes[props.size as keyof Sizes] + \"px\";\n else if (!Number.isNaN(Number(props.size))) height = props.size + \"px\";\n else if (props.size === \"auto\") height = \"auto\";\n }\n\n const style = {\n maxWidth,\n maxHeight,\n height,\n transitionDuration: props.transitionDuration / 1000 + \"s\",\n };\n\n return {\n class: classes,\n style,\n ...accessibilityAttrs,\n };\n});\n\nreturn (_ctx: any,_cache: any) => {\n return (_openBlock(), _createBlock(_Teleport, { to: \"body\" }, [\n _createElementVNode(\"div\", _mergeProps(overlayAttributes.value, {\n ref_key: \"overlay\",\n ref: overlay\n }), [\n _createElementVNode(\"div\", _mergeProps(panelAttributes.value, {\n ref_key: \"panel\",\n ref: panel\n }), [\n (hasRenderedAtLeastOnce.value)\n ? (_openBlock(), _createElementBlock(\"div\", {\n key: 0,\n class: \"bb-offcanvas__content\",\n ref_key: \"content\",\n ref: content\n }, [\n _renderSlot(_ctx.$slots, \"content\", { close: onCloseClick }, () => [\n _createElementVNode(\"div\", {\n class: \"bb-offcanvas__header\",\n ref_key: \"header\",\n ref: header\n }, [\n _renderSlot(_ctx.$slots, \"header\", {\n titleId: titleId,\n close: onCloseClick,\n title: _ctx.title\n }, () => [\n _createElementVNode(\"span\", {\n class: \"bb-offcanvas__title\",\n id: titleId\n }, [\n _renderSlot(_ctx.$slots, \"title\", { text: _ctx.title }, () => [\n _createTextVNode(_toDisplayString(_ctx.title), 1)\n ])\n ]),\n _createElementVNode(\"span\", _hoisted_1, [\n (_ctx.showClose)\n ? (_openBlock(), _createElementBlock(\"button\", {\n key: 0,\n onClick: onCloseClick,\n type: \"button\"\n }, [\n _renderSlot(_ctx.$slots, \"close\", { text: closeLabel.value }, () => [\n _createElementVNode(\"span\", _hoisted_2, [\n _createElementVNode(\"span\", _hoisted_3, _toDisplayString(closeLabel.value), 1),\n _hoisted_4\n ])\n ])\n ]))\n : _createCommentVNode(\"\", true)\n ])\n ])\n ], 512),\n _createElementVNode(\"div\", {\n class: \"bb-offcanvas__body\",\n ref_key: \"body\",\n ref: body\n }, [\n _renderSlot(_ctx.$slots, \"description\", {\n descriptionId: descriptionId,\n text: _ctx.description\n }, () => [\n (_ctx.description)\n ? (_openBlock(), _createElementBlock(\"div\", {\n key: 0,\n id: descriptionId,\n class: \"bb-offcanvas__description\"\n }, _toDisplayString(_ctx.description), 1))\n : _createCommentVNode(\"\", true)\n ]),\n _renderSlot(_ctx.$slots, \"default\")\n ], 512),\n _hoisted_5,\n _createElementVNode(\"div\", {\n class: \"bb-offcanvas__footer\",\n ref_key: \"footer\",\n ref: footer\n }, [\n _renderSlot(_ctx.$slots, \"footer\")\n ], 512)\n ])\n ], 512))\n : _createCommentVNode(\"\", true)\n ], 16)\n ], 16)\n ]))\n}\n}\n\n})"],"names":["_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_createElementVNode","_hoisted_5","_sfc_main","_defineComponent","__props","__emit","props","emit","titleId","useId","descriptionId","overlay","ref","panel","content","header","body","footer","attrs","useAttrs","activate","deactivate","useFocusTrap","nextTick","closeLabel","computed","open","opening","closed","closing","hasRenderedAtLeastOnce","lastFocusedElement","busy","onMounted","alignToModelValue","watch","onBeforeUnmount","currentlyOpenCanvases","scrollBarWidth","wait","onOverlayScroll","event","onOverlayClick","onCloseClick","overlayAttributes","classes","eventListeners","style","panelAttributes","accessibilityAttrs","maxWidth","maxHeight","height","sizes","_ctx","_cache","_openBlock","_createBlock","_Teleport","_mergeProps","_createElementBlock","_renderSlot","_createTextVNode","_toDisplayString","_createCommentVNode"],"mappings":";;;;AAGA,MAAMA,KAAa,EAAE,OAAO,wBACtBC,KAAa,EAAE,OAAO,iCACtBC,KAAa,EAAE,OAAO,+BACtBC,KAA8CC,gBAAAA,EAAA,QAAQ,EAAE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U,EAAoB,IAAI,EAAI;AAAA,gBAAA,CACjC;AAAA,gBACDH,EAAYP,EAAK,QAAQ,SAAS;AAAA,iBACjC,GAAG;AAAA,cACNrD;AAAA,cACAD,EAAoB,OAAO;AAAA,gBACzB,OAAO;AAAA,gBACP,SAAS;AAAA,gBACT,KAAKiB;AAAA,cAAA,GACJ;AAAA,gBACD4C,EAAYP,EAAK,QAAQ,QAAQ;AAAA,iBAChC,GAAG;AAAA,YAAA,CACP;AAAA,UACA,GAAA,GAAG,KACNU,EAAoB,IAAI,EAAI;AAAA,WAC/B,EAAE;AAAA,SACJ,EAAE;AAAA,IAAA,CACN;AAAA,EAEH;AAEA,CAAC;"}
1
+ {"version":3,"file":"index75.js","sources":["../src/components/BbOffCanvas/BbOffCanvas.vue?vue&type=script&setup=true&lang.ts"],"sourcesContent":["import { defineComponent as _defineComponent } from 'vue'\nimport { renderSlot as _renderSlot, toDisplayString as _toDisplayString, createTextVNode as _createTextVNode, createElementVNode as _createElementVNode, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, mergeProps as _mergeProps, Teleport as _Teleport, createBlock as _createBlock } from \"vue\"\n\nconst _hoisted_1 = { class: \"bb-offcanvas-close\" }\nconst _hoisted_2 = { class: \"bb-offcanvas-close__content\" }\nconst _hoisted_3 = { class: \"bb-offcanvas-close__label\" }\nconst _hoisted_4 = /*#__PURE__*/_createElementVNode(\"span\", { class: \"bb-offcanvas-close__icon\" }, [\n /*#__PURE__*/_createElementVNode(\"svg\", {\n fill: \"none\",\n viewBox: \"0 0 24 24\",\n xmlns: \"http://www.w3.org/2000/svg\"\n }, [\n /*#__PURE__*/_createElementVNode(\"path\", {\n d: \"M23 23L1 1M23 1L1 23\",\n stroke: \"currentColor\",\n \"stroke-linecap\": \"round\",\n \"stroke-width\": \"2\"\n })\n ])\n], -1)\nconst _hoisted_5 = /*#__PURE__*/_createElementVNode(\"div\", { style: {\"flex\":\"10000 10000 0%\"} }, null, -1)\n\nimport {\n\tcomputed,\n\tnextTick,\n\tonBeforeUnmount,\n\tonMounted,\n\tref,\n\tuseAttrs,\n\twatch,\n} from 'vue';\nimport { useFocusTrap } from '@vueuse/integrations/useFocusTrap';\nimport { useId } from '@/composables/useId';\nimport { wait } from '@/utilities/functions/wait';\nimport type { CommonProps, Size } from '@/types/CommonProps';\n\nexport type Sizes = {\n\tsm: number;\n\tmd: number;\n\tlg: number;\n};\n\nexport type BbOffCanvasProps = Pick<\n\tCommonProps,\n\t| 'closeLabel'\n\t| 'compact'\n\t| 'disabled'\n\t| 'eager'\n\t| 'panelClasses'\n\t| 'overlayClasses'\n\t| 'persistent'\n\t| 'showClose'\n\t| 'title'\n\t| 'transition'\n\t| 'transitionDuration'\n> &\n\tSize<Sizes> & {\n\t\t/**\n\t\t * Description of the content of the modal. Extremely useful for accessibility reasons.\n\t\t */\n\t\tdescription?: string;\n\t\t/**\n\t\t * Displays the modala as fulscreen with no margin to the page\n\t\t */\n\t\tfullscreen?: boolean;\n\t\t/**\n\t\t * Defines the state open / closed of the modal.\n\t\t */\n\t\tmodelValue?: boolean | null;\n\t\t/**\n\t\t * Defines the direction the offcanvas should appear from\n\t\t */\n\t\tdirection?: 'left' | 'top' | 'right' | 'bottom';\n\t};\n\nexport type BbOffCanvasEvents = {\n\t(e: 'shown'): void;\n\t(e: 'hidden'): void;\n\t(e: 'update:modelValue', value: boolean): void;\n};\n\nexport type BbOffCanvasSlots = {\n\theader?: (props: {\n\t\ttitleId: typeof titleId;\n\t\tclose: typeof onCloseClick;\n\t\ttitle: BbOffCanvasProps['title'];\n\t}) => any;\n\ttitle?: (props: { text: BbOffCanvasProps['title'] }) => any;\n\tclose?: (props: { text: BbOffCanvasProps['closeLabel'] }) => any;\n\tdescription?: (props: {\n\t\tdescriptionId: typeof descriptionId;\n\t\ttext: BbOffCanvasProps['description'];\n\t}) => any;\n\tdefault?: (props: {}) => any;\n\tcontent?: (props: { close: typeof onCloseClick }) => any;\n\tfooter?: (props: {}) => any;\n};\n\n\nexport default /*#__PURE__*/_defineComponent({\n __name: 'BbOffCanvas',\n props: {\n closeLabel: { default: 'Chiudi' },\n compact: { type: Boolean },\n disabled: { type: Boolean },\n eager: { type: Boolean },\n panelClasses: { default: () => [] },\n overlayClasses: { default: () => [] },\n persistent: { type: Boolean },\n showClose: { type: Boolean, default: true },\n title: {},\n transition: { default: 'fade' },\n transitionDuration: { default: 350 },\n size: { default: 'sm' },\n description: {},\n fullscreen: { type: Boolean },\n modelValue: { type: [Boolean, null] },\n direction: { default: 'left' }\n },\n emits: [\"shown\", \"hidden\", \"update:modelValue\"],\n setup(__props: any, { emit: __emit }) {\n\nconst props = __props;\n\nconst emit = __emit;\n\n\n\nconst titleId = `title_${useId().id.value}`;\nconst descriptionId = `description_${useId().id.value}`;\n\nconst overlay = ref<HTMLElement | null>(null);\nconst panel = ref<HTMLElement | null>(null);\nconst content = ref<HTMLElement | null>(null);\nconst header = ref<HTMLElement | null>(null);\nconst body = ref<HTMLElement | null>(null);\nconst footer = ref<HTMLElement | null>(null);\nconst attrs = useAttrs();\n\nconst { activate, deactivate } = useFocusTrap(panel, {\n\tclickOutsideDeactivates: true,\n\t/* On esc deactivate the trap, return focus and then close the modal */\n\tescapeDeactivates: () => {\n\t\tnextTick(() => {\n\t\t\temit('update:modelValue', false);\n\t\t});\n\t\treturn true;\n\t},\n});\n\nconst closeLabel = computed(() => props.closeLabel);\n\nconst open = ref(false);\nconst opening = ref(false);\nconst closed = ref(true);\nconst closing = ref(false);\nconst hasRenderedAtLeastOnce = ref(props.eager || props.modelValue);\nconst lastFocusedElement = ref<Element | null>(null);\n\nconst busy = computed(() => opening.value || closing.value);\n\nonMounted(() => {\n\t/**\n\t * Do not realign if open or opening\n\t */\n\tif (props.modelValue && !(open.value || opening.value)) {\n\t\talignToModelValue();\n\t}\n});\n\n/**\n * Every time modelValue changes align the display to it\n */\nwatch(\n\t() => props.modelValue,\n\t() => {\n\t\talignToModelValue();\n\t}\n);\nonBeforeUnmount(() => {\n\tif (props.modelValue) {\n\t\tlet currentlyOpenCanvases = Number(\n\t\t\tdocument.body.dataset['openCanvases'] ?? '0'\n\t\t);\n\t\t// This prevents overscroll chaining (additional scrolling to the body when the modal has been completely scrolled)\n\t\tcurrentlyOpenCanvases--;\n\t\tdocument.body.dataset['openCanvases'] = currentlyOpenCanvases.toString();\n\t\tif (!currentlyOpenCanvases) {\n\t\t\tdocument.body.style.overflow = 'auto';\n\t\t\tdocument.body.style.paddingRight = '0px';\n\t\t}\n\t}\n});\n\n/**\n * When modelValue becomes true if the component wasn't rendered render it\n * and wait for it to be on the page (or transitions would not work).\n * Stash the latest focused element so we can return it later when it closes.\n * Focus on the panel upon opening.\n * ---\n * Notice all interactions update modelValue and then this function aligns the display to it\n */\nconst alignToModelValue = async () => {\n\tif (props.modelValue) {\n\t\tif (!hasRenderedAtLeastOnce.value) {\n\t\t\thasRenderedAtLeastOnce.value = true;\n\t\t}\n\t\tif (document.activeElement) {\n\t\t\tlastFocusedElement.value = document.activeElement;\n\t\t}\n\n\t\tclosed.value = false;\n\t\tclosing.value = false;\n\t\topening.value = true;\n\n\t\t// This prevents overscroll chaining (additional scrolling to the body when the modal has been completely scrolled)\n\n\t\tlet currentlyOpenCanvases = Number(\n\t\t\tdocument.body.dataset['openCanvases'] ?? '0'\n\t\t);\n\t\tcurrentlyOpenCanvases++;\n\t\tdocument.body.dataset['openCanvases'] = currentlyOpenCanvases.toString();\n\t\tconst scrollBarWidth =\n\t\t\twindow.innerWidth - document.documentElement.clientWidth;\n\t\tdocument.body.style.overflow = 'hidden';\n\t\tdocument.body.style.paddingRight = `${scrollBarWidth}px`;\n\n\t\tawait wait(props.transitionDuration);\n\n\t\topening.value = false;\n\t\topen.value = true;\n\t\temit('shown');\n\t\tactivate();\n\t} else {\n\t\tdeactivate();\n\t\topening.value = false;\n\t\topen.value = false;\n\t\tclosing.value = true;\n\n\t\tawait wait(props.transitionDuration);\n\n\t\tlet currentlyOpenCanvases = Number(\n\t\t\tdocument.body.dataset['openCanvases'] ?? '0'\n\t\t);\n\t\t// This prevents overscroll chaining (additional scrolling to the body when the modal has been completely scrolled)\n\t\tcurrentlyOpenCanvases--;\n\t\tdocument.body.dataset['openCanvases'] = currentlyOpenCanvases.toString();\n\t\tif (!currentlyOpenCanvases) {\n\t\t\tdocument.body.style.overflow = 'auto';\n\t\t\tdocument.body.style.paddingRight = '0px';\n\t\t}\n\t\tclosing.value = false;\n\t\tclosed.value = true;\n\t\temit('hidden');\n\t\tif (lastFocusedElement.value instanceof HTMLElement) {\n\t\t\tlastFocusedElement.value.focus();\n\t\t}\n\t}\n};\n\n/**\n * Disable scrolling\n */\nconst onOverlayScroll = (event: UIEvent) => {\n\tif (event.target === overlay.value) {\n\t\tevent.preventDefault();\n\t}\n};\n\n/**\n * Close the modal on overlay click if not persistent\n */\nconst onOverlayClick = (event: MouseEvent) => {\n\tif (props.disabled || busy.value) return;\n\tif (overlay.value) {\n\t\tif (event.target === overlay.value) {\n\t\t\tif (!props.persistent) {\n\t\t\t\temit('update:modelValue', false);\n\t\t\t}\n\t\t}\n\t}\n};\n\n/**\n * On click on the X button\n */\nconst onCloseClick = () => {\n\tif (props.disabled) return;\n\temit('update:modelValue', false);\n};\n\nconst overlayAttributes = computed(() => {\n\tconst classes = [\n\t\t{\n\t\t\t'bb-offcanvas bb-offcanvas__overlay': true,\n\t\t\t'bb-offcanvas--fullscreen': props.fullscreen,\n\t\t\t'bb-offcanvas--open': open.value,\n\t\t\t'bb-offcanvas--opening': opening.value,\n\t\t\t'bb-offcanvas--closed': closed.value,\n\t\t\t'bb-offcanvas--closing': closing.value,\n\t\t\t[`bb-offcanvas--transition-${props.transition}`]: true,\n\t\t\t[`bb-offcanvas--${props.direction}`]: true,\n\t\t},\n\t\tprops.overlayClasses,\n\t].flat();\n\tconst eventListeners = {\n\t\tonClick: onOverlayClick,\n\t\tonScroll: onOverlayScroll,\n\t\tonTouchmove: onOverlayScroll,\n\t\tonWheel: onOverlayScroll,\n\t\tonKeydown: onOverlayScroll,\n\t};\n\n\tconst style = {\n\t\ttransitionDuration: props.transitionDuration / 1000 + 's',\n\t};\n\treturn {\n\t\tclass: classes,\n\t\tstyle,\n\t\t...eventListeners,\n\t\t...attrs,\n\t};\n});\n\nconst panelAttributes = computed(() => {\n\tconst classes = [\n\t\t{\n\t\t\t'bb-offcanvas__panel': true,\n\t\t\t'bb-offcanvas__panel--compact': props.compact,\n\t\t},\n\t\tprops.panelClasses,\n\t].flat();\n\n\tconst accessibilityAttrs: {\n\t\t[key: string]: string | boolean;\n\t} = {\n\t\trole: 'dialog',\n\t\t'aria-modal': true,\n\t};\n\n\tif (hasRenderedAtLeastOnce.value) {\n\t\taccessibilityAttrs['aria-labelledby'] = titleId;\n\n\t\tif (props.description)\n\t\t\taccessibilityAttrs['aria-describedby'] = descriptionId;\n\t}\n\n\tlet maxWidth;\n\tlet maxHeight;\n\tlet height;\n\tconst sizes: Sizes = {\n\t\tsm: 384,\n\t\tmd: 652,\n\t\tlg: 896,\n\t};\n\tif (props.direction === 'left' || props.direction === 'right') {\n\t\tif (props.fullscreen) maxWidth = '100%';\n\t\telse if (typeof props.size === 'number') maxWidth = props.size + 'px';\n\t\telse if (props.size in sizes)\n\t\t\tmaxWidth = sizes[props.size as keyof Sizes] + 'px';\n\t\telse maxWidth = props.size + 'px';\n\t} else {\n\t\tif (props.fullscreen) height = '100%';\n\t\telse if (typeof props.size === 'number') height = props.size + 'px';\n\t\telse if (props.size in sizes)\n\t\t\theight = sizes[props.size as keyof Sizes] + 'px';\n\t\telse if (!Number.isNaN(Number(props.size))) height = props.size + 'px';\n\t\telse if (props.size === 'auto') height = 'auto';\n\t}\n\n\tconst style = {\n\t\tmaxWidth,\n\t\tmaxHeight,\n\t\theight,\n\t\ttransitionDuration: props.transitionDuration / 1000 + 's',\n\t};\n\n\treturn {\n\t\tclass: classes,\n\t\tstyle,\n\t\t...accessibilityAttrs,\n\t};\n});\n\nreturn (_ctx: any,_cache: any) => {\n return (_openBlock(), _createBlock(_Teleport, { to: \"body\" }, [\n _createElementVNode(\"div\", _mergeProps(overlayAttributes.value, {\n ref_key: \"overlay\",\n ref: overlay\n }), [\n _createElementVNode(\"div\", _mergeProps(panelAttributes.value, {\n ref_key: \"panel\",\n ref: panel\n }), [\n (hasRenderedAtLeastOnce.value)\n ? (_openBlock(), _createElementBlock(\"div\", {\n key: 0,\n ref_key: \"content\",\n ref: content,\n class: \"bb-offcanvas__content\"\n }, [\n _renderSlot(_ctx.$slots, \"content\", { close: onCloseClick }, () => [\n _createElementVNode(\"div\", {\n ref_key: \"header\",\n ref: header,\n class: \"bb-offcanvas__header\"\n }, [\n _renderSlot(_ctx.$slots, \"header\", {\n close: onCloseClick,\n title: _ctx.title,\n titleId: titleId\n }, () => [\n _createElementVNode(\"span\", {\n id: titleId,\n class: \"bb-offcanvas__title\"\n }, [\n _renderSlot(_ctx.$slots, \"title\", { text: _ctx.title }, () => [\n _createTextVNode(_toDisplayString(_ctx.title), 1)\n ])\n ]),\n _createElementVNode(\"span\", _hoisted_1, [\n (_ctx.showClose)\n ? (_openBlock(), _createElementBlock(\"button\", {\n key: 0,\n type: \"button\",\n onClick: onCloseClick\n }, [\n _renderSlot(_ctx.$slots, \"close\", { text: closeLabel.value }, () => [\n _createElementVNode(\"span\", _hoisted_2, [\n _createElementVNode(\"span\", _hoisted_3, _toDisplayString(closeLabel.value), 1),\n _hoisted_4\n ])\n ])\n ]))\n : _createCommentVNode(\"\", true)\n ])\n ])\n ], 512),\n _createElementVNode(\"div\", {\n ref_key: \"body\",\n ref: body,\n class: \"bb-offcanvas__body\"\n }, [\n _renderSlot(_ctx.$slots, \"description\", {\n descriptionId: descriptionId,\n text: _ctx.description\n }, () => [\n (_ctx.description)\n ? (_openBlock(), _createElementBlock(\"div\", {\n key: 0,\n id: descriptionId,\n class: \"bb-offcanvas__description\"\n }, _toDisplayString(_ctx.description), 1))\n : _createCommentVNode(\"\", true)\n ]),\n _renderSlot(_ctx.$slots, \"default\")\n ], 512),\n _hoisted_5,\n _createElementVNode(\"div\", {\n ref_key: \"footer\",\n ref: footer,\n class: \"bb-offcanvas__footer\"\n }, [\n _renderSlot(_ctx.$slots, \"footer\")\n ], 512)\n ])\n ], 512))\n : _createCommentVNode(\"\", true)\n ], 16)\n ], 16)\n ]))\n}\n}\n\n})"],"names":["_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_createElementVNode","_hoisted_5","_sfc_main","_defineComponent","__props","__emit","props","emit","titleId","useId","descriptionId","overlay","ref","panel","content","header","body","footer","attrs","useAttrs","activate","deactivate","useFocusTrap","nextTick","closeLabel","computed","open","opening","closed","closing","hasRenderedAtLeastOnce","lastFocusedElement","busy","onMounted","alignToModelValue","watch","onBeforeUnmount","currentlyOpenCanvases","scrollBarWidth","wait","onOverlayScroll","event","onOverlayClick","onCloseClick","overlayAttributes","classes","eventListeners","style","panelAttributes","accessibilityAttrs","maxWidth","maxHeight","height","sizes","_ctx","_cache","_openBlock","_createBlock","_Teleport","_mergeProps","_createElementBlock","_renderSlot","_createTextVNode","_toDisplayString","_createCommentVNode"],"mappings":";;;;AAGA,MAAMA,KAAa,EAAE,OAAO,wBACtBC,KAAa,EAAE,OAAO,iCACtBC,KAAa,EAAE,OAAO,+BACtBC,KAA8CC,gBAAAA,EAAA,QAAQ,EAAE,OAAO,8BAA8B;AAAA,oBAChE,OAAO;AAAA,IACtC,MAAM;AAAA,IACN,SAAS;AAAA,IACT,OAAO;AAAA,EAAA,GACN;AAAA,sBACgC,QAAQ;AAAA,MACvC,GAAG;AAAA,MACH,QAAQ;AAAA,MACR,kBAAkB;AAAA,MAClB,gBAAgB;AAAA,IAAA,CACjB;AAAA,EAAA,CACF;AACH,GAAG,EAAE,GACCC,KAA8CD,gBAAAA,EAAA,OAAO,EAAE,OAAO,EAAC,MAAO,mBAAqB,GAAA,MAAM,EAAE,GA+E7EE,KAAiBC,gBAAAA,EAAA;AAAA,EAC3C,QAAQ;AAAA,EACR,OAAO;AAAA,IACL,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package/dist/index77.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { defineComponent as x, computed as y, ref as p, onMounted as A, onBeforeUnmount as B, openBlock as V, createElementBlock as k, createElementVNode as u, renderSlot as g, createTextVNode as b, Fragment as E, renderList as P, normalizeClass as W, toDisplayString as h, nextTick as z } from "vue";
2
2
  import R from "./index226.js";
3
- const T = { "aria-label": "Navigazione" }, F = ["disabled"], L = ["onClick", "disabled"], D = ["disabled"], O = /* @__PURE__ */ x({
3
+ const T = { "aria-label": "Navigazione" }, F = ["disabled"], L = ["disabled", "onClick"], D = ["disabled"], O = /* @__PURE__ */ x({
4
4
  __name: "BbPagination",
5
5
  props: {
6
6
  disabled: { type: Boolean },
@@ -78,21 +78,21 @@ const T = { "aria-label": "Navigazione" }, F = ["disabled"], L = ["onClick", "di
78
78
  disabled: !!a.disabled || +a.totalPages < 2 || a.loading
79
79
  })), c = (e, t = 0) => Array.from({ length: e }, (l, v) => t + v);
80
80
  return (e, t) => (V(), k("div", {
81
- class: "bb-pagination",
82
81
  ref_key: "outercontainer",
83
- ref: o
82
+ ref: o,
83
+ class: "bb-pagination"
84
84
  }, [
85
85
  u("nav", T, [
86
86
  u("ul", {
87
- class: "bb-pagination__pages",
88
87
  ref_key: "innercontainer",
89
- ref: d
88
+ ref: d,
89
+ class: "bb-pagination__pages"
90
90
  }, [
91
91
  u("li", null, [
92
92
  u("button", {
93
93
  class: "bb-pagination__page bb-pagination__page--previous",
94
- onClick: t[0] || (t[0] = (l) => m("update:modelValue", a.modelValue - 1)),
95
- disabled: a.modelValue <= 1 || e.loading || e.disabled
94
+ disabled: a.modelValue <= 1 || e.loading || e.disabled,
95
+ onClick: t[0] || (t[0] = (l) => m("update:modelValue", a.modelValue - 1))
96
96
  }, [
97
97
  g(e.$slots, "previous", {}, () => [
98
98
  b("Precedente")
@@ -105,8 +105,8 @@ const T = { "aria-label": "Navigazione" }, F = ["disabled"], L = ["onClick", "di
105
105
  "bb-pagination__page--active": l.active,
106
106
  "bb-pagination__page--ellipsis": l.ellipsis
107
107
  }]),
108
- onClick: (v) => m("update:modelValue", l.key),
109
- disabled: l.disabled
108
+ disabled: l.disabled,
109
+ onClick: (v) => m("update:modelValue", l.key)
110
110
  }, [
111
111
  l.ellipsis === !0 ? g(e.$slots, "ellipsis", { key: 0 }, () => [
112
112
  b(h(a.ellipsis), 1)
@@ -123,8 +123,8 @@ const T = { "aria-label": "Navigazione" }, F = ["disabled"], L = ["onClick", "di
123
123
  u("li", null, [
124
124
  u("button", {
125
125
  class: "bb-pagination__page bb-pagination__page--next",
126
- onClick: t[1] || (t[1] = (l) => m("update:modelValue", a.modelValue + 1)),
127
- disabled: a.modelValue >= +i.value || e.loading || e.disabled
126
+ disabled: a.modelValue >= +i.value || e.loading || e.disabled,
127
+ onClick: t[1] || (t[1] = (l) => m("update:modelValue", a.modelValue + 1))
128
128
  }, [
129
129
  g(e.$slots, "next", {}, () => [
130
130
  b("Successivi")
@@ -1 +1 @@
1
- {"version":3,"file":"index77.js","sources":["../src/components/BbPagination/BbPagination.vue?vue&type=script&setup=true&lang.ts"],"sourcesContent":["import { defineComponent as _defineComponent } from 'vue'\nimport { renderSlot as _renderSlot, createTextVNode as _createTextVNode, createElementVNode as _createElementVNode, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, toDisplayString as _toDisplayString, createCommentVNode as _createCommentVNode, normalizeClass as _normalizeClass } from \"vue\"\n\nconst _hoisted_1 = { \"aria-label\": \"Navigazione\" }\nconst _hoisted_2 = [\"disabled\"]\nconst _hoisted_3 = [\"onClick\", \"disabled\"]\nconst _hoisted_4 = [\"disabled\"]\n\nimport { computed, nextTick, onBeforeUnmount, onMounted, ref } from \"vue\";\nimport { debounce } from \"@/utilities/functions/debounce\";\nimport type { CommonProps } from \"@/types/CommonProps\";\n\nexport type BbPaginationProps = Pick<CommonProps, \n'disabled' | 'loading'\n> & {\n /**\n * String of text displayed in place of hidden pages\n */\n ellipsis?: string;\n /**\n * Maximum number of clickable pages displayed at all times. \n * This has a tolerance of +/- 1 for odd / even numbering.\n * It does not include ellipses.\n */\n maxSize?: number | string;\n /**\n * Used by v-model. Indicates the current page.\n */\n modelValue: number;\n /**\n * Total number of pages there is.\n */\n totalPages?: number | string;\n}\n\nexport type BbPaginationEvents = {\n (e: \"update:modelValue\", value: number): void;\n};\n\ntype Item = {\n active: boolean;\n key: string;\n page: string;\n ellipsis: true;\n disabled: boolean;\n} | {\n active: boolean;\n key: number;\n page: number;\n ellipsis: false;\n disabled: boolean;\n}\n\n\nexport default /*#__PURE__*/_defineComponent({\n __name: 'BbPagination',\n props: {\n disabled: { type: Boolean },\n loading: { type: Boolean },\n ellipsis: { default: \"...\" },\n maxSize: { default: 5 },\n modelValue: { default: 1 },\n totalPages: { default: 1 }\n },\n emits: [\"update:modelValue\"],\n setup(__props: any, { emit: __emit }) {\n\nconst props = __props;\n\nconst emit = __emit;\n\n\n\nconst totalPages = computed(() => +props.totalPages);\nconst start = ref(1);\nconst maxSize = ref(+props.maxSize);\n\nconst outercontainer = ref<HTMLElement>();\nconst innercontainer = ref<HTMLElement>();\n\nconst buttonFootprint = ref<number>(Infinity);\n\n/**\n * Adjusts how many buttons to show.\n * if current buttons can't fit subtract maxSize until they do or until minimum is reached\n * if more buttons could fit add buttons until the don't\n * If minimum or maximum is reached just quit until next resize\n */\nconst adjustMaxElements = () => {\n if (outercontainer.value && innercontainer.value) {\n /* If some buttons do not fit */\n if (outercontainer.value.clientWidth < innercontainer.value.clientWidth) {\n if (maxSize.value - 1 > 3) {\n maxSize.value--;\n nextTick(adjustMaxElements);\n } else {\n maxSize.value = 3;\n }\n /* If all current buttons do fit */\n } else {\n /* If some buttons have been hidden */\n if (maxSize.value < +props.maxSize) {\n if (\n /* If there is enough space to fit one */\n outercontainer.value.clientWidth - innercontainer.value.clientWidth >\n buttonFootprint.value\n ) {\n maxSize.value = Math.min(maxSize.value + 1, +props.maxSize);\n nextTick(adjustMaxElements);\n }\n }\n }\n }\n};\nif (globalThis.ResizeObserver) {\n const observer = new ResizeObserver(debounce(adjustMaxElements, 200));\n onMounted(() => {\n if (outercontainer.value && innercontainer.value) {\n const button = outercontainer.value.querySelectorAll(\n \".bb-pagination__page\"\n )[1];\n if (button) {\n /* Compute the footprint necessary to render a new button */\n const gapString = getComputedStyle(innercontainer.value).columnGap;\n const numberAsString = gapString.replaceAll(/\\D/g, \"\");\n const gap = Number(numberAsString);\n buttonFootprint.value = button.clientWidth + gap;\n }\n observer.observe(outercontainer.value);\n }\n });\n onBeforeUnmount(() => {\n observer.disconnect();\n });\n}\n\nconst range = computed(() => {\n if (\n totalPages.value <= 0 ||\n isNaN(totalPages.value) ||\n totalPages.value > Number.MAX_SAFE_INTEGER\n )\n return [];\n\n if (maxSize.value <= 1) return [props.modelValue];\n\n if (totalPages.value <= maxSize.value) {\n return createRange(totalPages.value, start.value);\n }\n\n const even = maxSize.value % 2 === 0;\n const middle = even ? maxSize.value / 2 : Math.floor(maxSize.value / 2);\n const left = even ? middle : middle + 1;\n const right = totalPages.value - middle;\n\n if (left - props.modelValue >= 0) {\n return [\n ...createRange(Math.max(1, maxSize.value - 1), start.value),\n props.ellipsis,\n totalPages.value,\n ];\n } else if (props.modelValue - right >= (even ? 1 : 0)) {\n const rangeLength = maxSize.value - 1;\n const rangeStart = totalPages.value - rangeLength + start.value;\n return [\n start.value,\n props.ellipsis,\n ...createRange(rangeLength, rangeStart),\n ];\n } else {\n const rangeLength = Math.max(1, maxSize.value - 3);\n const rangeStart =\n rangeLength === 1\n ? props.modelValue\n : props.modelValue - Math.ceil(rangeLength / 2) + start.value;\n return [\n start.value,\n props.ellipsis,\n ...createRange(rangeLength, rangeStart),\n props.ellipsis,\n totalPages.value,\n ];\n }\n});\n\nconst items = computed<Item[]>(() => {\n return range.value.map((item, index) => {\n if (typeof item === \"string\") {\n return {\n active: false,\n key: `ellipsis-${index}`,\n page: item,\n ellipsis: true,\n disabled: true,\n };\n } else {\n const active = item === props.modelValue;\n return {\n active,\n key: item,\n page: item,\n ellipsis: false,\n disabled: !!props.disabled || +props.totalPages < 2 || props.loading,\n };\n }\n });\n});\n\nconst createRange = (length: number, start = 0): number[] => {\n return Array.from({ length }, (_, k) => start + k);\n};\n\nreturn (_ctx: any,_cache: any) => {\n return (_openBlock(), _createElementBlock(\"div\", {\n class: \"bb-pagination\",\n ref_key: \"outercontainer\",\n ref: outercontainer\n }, [\n _createElementVNode(\"nav\", _hoisted_1, [\n _createElementVNode(\"ul\", {\n class: \"bb-pagination__pages\",\n ref_key: \"innercontainer\",\n ref: innercontainer\n }, [\n _createElementVNode(\"li\", null, [\n _createElementVNode(\"button\", {\n class: \"bb-pagination__page bb-pagination__page--previous\",\n onClick: _cache[0] || (_cache[0] = ($event: any) => (emit('update:modelValue', props.modelValue - 1))),\n disabled: props.modelValue <= 1 || _ctx.loading || _ctx.disabled\n }, [\n _renderSlot(_ctx.$slots, \"previous\", {}, () => [\n _createTextVNode(\"Precedente\")\n ])\n ], 8, _hoisted_2)\n ]),\n (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items.value, (item) => {\n return (_openBlock(), _createElementBlock(\"li\", null, [\n _createElementVNode(\"button\", {\n class: _normalizeClass([\"bb-pagination__page\", {\n 'bb-pagination__page--active': item.active,\n 'bb-pagination__page--ellipsis': item.ellipsis,\n }]),\n onClick: ($event: any) => (emit('update:modelValue', item.key)),\n disabled: item.disabled\n }, [\n (item.ellipsis === true)\n ? _renderSlot(_ctx.$slots, \"ellipsis\", { key: 0 }, () => [\n _createTextVNode(_toDisplayString(props.ellipsis), 1)\n ])\n : _renderSlot(_ctx.$slots, \"item\", {\n key: 1,\n active: item.active,\n disabled: item.disabled,\n item: item.key\n }, () => [\n _createTextVNode(_toDisplayString(item.key), 1)\n ])\n ], 10, _hoisted_3)\n ]))\n }), 256)),\n _createElementVNode(\"li\", null, [\n _createElementVNode(\"button\", {\n class: \"bb-pagination__page bb-pagination__page--next\",\n onClick: _cache[1] || (_cache[1] = ($event: any) => (emit('update:modelValue', props.modelValue + 1))),\n disabled: props.modelValue >= +totalPages.value || _ctx.loading || _ctx.disabled\n }, [\n _renderSlot(_ctx.$slots, \"next\", {}, () => [\n _createTextVNode(\"Successivi\")\n ])\n ], 8, _hoisted_4)\n ])\n ], 512)\n ])\n ], 512))\n}\n}\n\n})"],"names":["_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_sfc_main","_defineComponent","__props","__emit","props","emit","totalPages","computed","start","ref","maxSize","outercontainer","innercontainer","buttonFootprint","adjustMaxElements","nextTick","observer","debounce","onMounted","button","numberAsString","gap","onBeforeUnmount","range","createRange","even","middle","left","right","rangeLength","rangeStart","items","item","index","length","_","k","_ctx","_cache","_openBlock","_createElementBlock","_createElementVNode","$event","_renderSlot","_createTextVNode","_Fragment","_renderList","_normalizeClass","_toDisplayString"],"mappings":";;AAGA,MAAMA,IAAa,EAAE,cAAc,iBAC7BC,IAAa,CAAC,UAAU,GACxBC,IAAa,CAAC,WAAW,UAAU,GACnCC,IAAa,CAAC,UAAU,GAgDFC,IAAiBC,gBAAAA,EAAA;AAAA,EAC3C,QAAQ;AAAA,EACR,OAAO;AAAA,IACL,UAAU,EAAE,MAAM,QAAQ;AAAA,IAC1B,SAAS,EAAE,MAAM,QAAQ;AAAA,IACzB,UAAU,EAAE,SAAS,MAAM;AAAA,IAC3B,SAAS,EAAE,SAAS,EAAE;AAAA,IACtB,YAAY,EAAE,SAAS,EAAE;AAAA,IACzB,YAAY,EAAE,SAAS,EAAE;AAAA,EAC3B;AAAA,EACA,OAAO,CAAC,mBAAmB;AAAA,EAC3B,MAAMC,GAAc,EAAE,MAAMC,KAAU;AAExC,UAAMC,IAAQF,GAERG,IAAOF,GAIPG,IAAaC,EAAS,MAAM,CAACH,EAAM,UAAU,GAC7CI,IAAQC,EAAI,CAAC,GACbC,IAAUD,EAAI,CAACL,EAAM,OAAO,GAE5BO,IAAiBF,KACjBG,IAAiBH,KAEjBI,IAAkBJ,EAAY,KAAQ,GAQtC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,YAAY,EAAE,KAAK,EAAE,GAAG,MAAM;AAAA,gBACrDO,EAAiBI,EAAiB5C,EAAM,QAAQ,GAAG,CAAC;AAAA,cACrD,CAAA,IACDuC,EAAYN,EAAK,QAAQ,QAAQ;AAAA,gBAC/B,KAAK;AAAA,gBACL,QAAQL,EAAK;AAAA,gBACb,UAAUA,EAAK;AAAA,gBACf,MAAMA,EAAK;AAAA,cAAA,GACV,MAAM;AAAA,gBACPY,EAAiBI,EAAiBhB,EAAK,GAAG,GAAG,CAAC;AAAA,cAAA,CAC/C;AAAA,YAAA,GACJ,IAAIlC,CAAU;AAAA,UAAA,CAClB,EACF,GAAG,GAAG;AAAA,UACP2C,EAAoB,MAAM,MAAM;AAAA,YAC9BA,EAAoB,UAAU;AAAA,cAC5B,OAAO;AAAA,cACP,SAASH,EAAO,CAAC,MAAMA,EAAO,CAAC,IAAI,CAACI,MAAiBrC,EAAK,qBAAqBD,EAAM,aAAa,CAAC;AAAA,cACnG,UAAUA,EAAM,cAAc,CAACE,EAAW,SAAS+B,EAAK,WAAWA,EAAK;AAAA,YAAA,GACvE;AAAA,cACDM,EAAYN,EAAK,QAAQ,QAAQ,IAAI,MAAM;AAAA,gBACzCO,EAAiB,YAAY;AAAA,cAAA,CAC9B;AAAA,YAAA,GACA,GAAG7C,CAAU;AAAA,UAAA,CACjB;AAAA,WACA,GAAG;AAAA,MAAA,CACP;AAAA,OACA,GAAG;AAAA,EAER;AAEA,CAAC;"}
1
+ {"version":3,"file":"index77.js","sources":["../src/components/BbPagination/BbPagination.vue?vue&type=script&setup=true&lang.ts"],"sourcesContent":["import { defineComponent as _defineComponent } from 'vue'\nimport { renderSlot as _renderSlot, createTextVNode as _createTextVNode, createElementVNode as _createElementVNode, renderList as _renderList, Fragment as _Fragment, openBlock as _openBlock, createElementBlock as _createElementBlock, toDisplayString as _toDisplayString, createCommentVNode as _createCommentVNode, normalizeClass as _normalizeClass } from \"vue\"\n\nconst _hoisted_1 = { \"aria-label\": \"Navigazione\" }\nconst _hoisted_2 = [\"disabled\"]\nconst _hoisted_3 = [\"disabled\", \"onClick\"]\nconst _hoisted_4 = [\"disabled\"]\n\nimport { computed, nextTick, onBeforeUnmount, onMounted, ref } from 'vue';\nimport { debounce } from '@/utilities/functions/debounce';\nimport type { CommonProps } from '@/types/CommonProps';\n\nexport type BbPaginationProps = Pick<CommonProps, 'disabled' | 'loading'> & {\n\t/**\n\t * String of text displayed in place of hidden pages\n\t */\n\tellipsis?: string;\n\t/**\n\t * Maximum number of clickable pages displayed at all times.\n\t * This has a tolerance of +/- 1 for odd / even numbering.\n\t * It does not include ellipses.\n\t */\n\tmaxSize?: number | string;\n\t/**\n\t * Used by v-model. Indicates the current page.\n\t */\n\tmodelValue: number;\n\t/**\n\t * Total number of pages there is.\n\t */\n\ttotalPages?: number | string;\n};\n\nexport type BbPaginationEvents = {\n\t(e: 'update:modelValue', value: number): void;\n};\n\ntype Item =\n\t| {\n\t\t\tactive: boolean;\n\t\t\tkey: string;\n\t\t\tpage: string;\n\t\t\tellipsis: true;\n\t\t\tdisabled: boolean;\n\t }\n\t| {\n\t\t\tactive: boolean;\n\t\t\tkey: number;\n\t\t\tpage: number;\n\t\t\tellipsis: false;\n\t\t\tdisabled: boolean;\n\t };\n\n\nexport default /*#__PURE__*/_defineComponent({\n __name: 'BbPagination',\n props: {\n disabled: { type: Boolean },\n loading: { type: Boolean },\n ellipsis: { default: '...' },\n maxSize: { default: 5 },\n modelValue: { default: 1 },\n totalPages: { default: 1 }\n },\n emits: ['update:modelValue'],\n setup(__props: any, { emit: __emit }) {\n\nconst props = __props;\n\nconst emit = __emit;\n\n\n\nconst totalPages = computed(() => +props.totalPages);\nconst start = ref(1);\nconst maxSize = ref(+props.maxSize);\n\nconst outercontainer = ref<HTMLElement>();\nconst innercontainer = ref<HTMLElement>();\n\nconst buttonFootprint = ref<number>(Infinity);\n\n/**\n * Adjusts how many buttons to show.\n * if current buttons can't fit subtract maxSize until they do or until minimum is reached\n * if more buttons could fit add buttons until the don't\n * If minimum or maximum is reached just quit until next resize\n */\nconst adjustMaxElements = () => {\n\tif (outercontainer.value && innercontainer.value) {\n\t\t/* If some buttons do not fit */\n\t\tif (outercontainer.value.clientWidth < innercontainer.value.clientWidth) {\n\t\t\tif (maxSize.value - 1 > 3) {\n\t\t\t\tmaxSize.value--;\n\t\t\t\tnextTick(adjustMaxElements);\n\t\t\t} else {\n\t\t\t\tmaxSize.value = 3;\n\t\t\t}\n\t\t\t/* If all current buttons do fit */\n\t\t} else {\n\t\t\t/* If some buttons have been hidden */\n\t\t\tif (maxSize.value < +props.maxSize) {\n\t\t\t\tif (\n\t\t\t\t\t/* If there is enough space to fit one */\n\t\t\t\t\toutercontainer.value.clientWidth - innercontainer.value.clientWidth >\n\t\t\t\t\tbuttonFootprint.value\n\t\t\t\t) {\n\t\t\t\t\tmaxSize.value = Math.min(maxSize.value + 1, +props.maxSize);\n\t\t\t\t\tnextTick(adjustMaxElements);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};\nif (globalThis.ResizeObserver) {\n\tconst observer = new ResizeObserver(debounce(adjustMaxElements, 200));\n\tonMounted(() => {\n\t\tif (outercontainer.value && innercontainer.value) {\n\t\t\tconst button = outercontainer.value.querySelectorAll(\n\t\t\t\t'.bb-pagination__page'\n\t\t\t)[1];\n\t\t\tif (button) {\n\t\t\t\t/* Compute the footprint necessary to render a new button */\n\t\t\t\tconst gapString = getComputedStyle(innercontainer.value).columnGap;\n\t\t\t\tconst numberAsString = gapString.replaceAll(/\\D/g, '');\n\t\t\t\tconst gap = Number(numberAsString);\n\t\t\t\tbuttonFootprint.value = button.clientWidth + gap;\n\t\t\t}\n\t\t\tobserver.observe(outercontainer.value);\n\t\t}\n\t});\n\tonBeforeUnmount(() => {\n\t\tobserver.disconnect();\n\t});\n}\n\nconst range = computed(() => {\n\tif (\n\t\ttotalPages.value <= 0 ||\n\t\tisNaN(totalPages.value) ||\n\t\ttotalPages.value > Number.MAX_SAFE_INTEGER\n\t)\n\t\treturn [];\n\n\tif (maxSize.value <= 1) return [props.modelValue];\n\n\tif (totalPages.value <= maxSize.value) {\n\t\treturn createRange(totalPages.value, start.value);\n\t}\n\n\tconst even = maxSize.value % 2 === 0;\n\tconst middle = even ? maxSize.value / 2 : Math.floor(maxSize.value / 2);\n\tconst left = even ? middle : middle + 1;\n\tconst right = totalPages.value - middle;\n\n\tif (left - props.modelValue >= 0) {\n\t\treturn [\n\t\t\t...createRange(Math.max(1, maxSize.value - 1), start.value),\n\t\t\tprops.ellipsis,\n\t\t\ttotalPages.value,\n\t\t];\n\t} else if (props.modelValue - right >= (even ? 1 : 0)) {\n\t\tconst rangeLength = maxSize.value - 1;\n\t\tconst rangeStart = totalPages.value - rangeLength + start.value;\n\t\treturn [\n\t\t\tstart.value,\n\t\t\tprops.ellipsis,\n\t\t\t...createRange(rangeLength, rangeStart),\n\t\t];\n\t} else {\n\t\tconst rangeLength = Math.max(1, maxSize.value - 3);\n\t\tconst rangeStart =\n\t\t\trangeLength === 1\n\t\t\t\t? props.modelValue\n\t\t\t\t: props.modelValue - Math.ceil(rangeLength / 2) + start.value;\n\t\treturn [\n\t\t\tstart.value,\n\t\t\tprops.ellipsis,\n\t\t\t...createRange(rangeLength, rangeStart),\n\t\t\tprops.ellipsis,\n\t\t\ttotalPages.value,\n\t\t];\n\t}\n});\n\nconst items = computed<Item[]>(() => {\n\treturn range.value.map((item, index) => {\n\t\tif (typeof item === 'string') {\n\t\t\treturn {\n\t\t\t\tactive: false,\n\t\t\t\tkey: `ellipsis-${index}`,\n\t\t\t\tpage: item,\n\t\t\t\tellipsis: true,\n\t\t\t\tdisabled: true,\n\t\t\t};\n\t\t} else {\n\t\t\tconst active = item === props.modelValue;\n\t\t\treturn {\n\t\t\t\tactive,\n\t\t\t\tkey: item,\n\t\t\t\tpage: item,\n\t\t\t\tellipsis: false,\n\t\t\t\tdisabled: !!props.disabled || +props.totalPages < 2 || props.loading,\n\t\t\t};\n\t\t}\n\t});\n});\n\nconst createRange = (length: number, start = 0): number[] => {\n\treturn Array.from({ length }, (_, k) => start + k);\n};\n\nreturn (_ctx: any,_cache: any) => {\n return (_openBlock(), _createElementBlock(\"div\", {\n ref_key: \"outercontainer\",\n ref: outercontainer,\n class: \"bb-pagination\"\n }, [\n _createElementVNode(\"nav\", _hoisted_1, [\n _createElementVNode(\"ul\", {\n ref_key: \"innercontainer\",\n ref: innercontainer,\n class: \"bb-pagination__pages\"\n }, [\n _createElementVNode(\"li\", null, [\n _createElementVNode(\"button\", {\n class: \"bb-pagination__page bb-pagination__page--previous\",\n disabled: props.modelValue <= 1 || _ctx.loading || _ctx.disabled,\n onClick: _cache[0] || (_cache[0] = ($event: any) => (emit('update:modelValue', props.modelValue - 1)))\n }, [\n _renderSlot(_ctx.$slots, \"previous\", {}, () => [\n _createTextVNode(\"Precedente\")\n ])\n ], 8, _hoisted_2)\n ]),\n (_openBlock(true), _createElementBlock(_Fragment, null, _renderList(items.value, (item) => {\n return (_openBlock(), _createElementBlock(\"li\", null, [\n _createElementVNode(\"button\", {\n class: _normalizeClass([\"bb-pagination__page\", {\n\t\t\t\t\t\t\t'bb-pagination__page--active': item.active,\n\t\t\t\t\t\t\t'bb-pagination__page--ellipsis': item.ellipsis,\n\t\t\t\t\t\t}]),\n disabled: item.disabled,\n onClick: ($event: any) => (emit('update:modelValue', item.key))\n }, [\n (item.ellipsis === true)\n ? _renderSlot(_ctx.$slots, \"ellipsis\", { key: 0 }, () => [\n _createTextVNode(_toDisplayString(props.ellipsis), 1)\n ])\n : _renderSlot(_ctx.$slots, \"item\", {\n key: 1,\n active: item.active,\n disabled: item.disabled,\n item: item.key\n }, () => [\n _createTextVNode(_toDisplayString(item.key), 1)\n ])\n ], 10, _hoisted_3)\n ]))\n }), 256)),\n _createElementVNode(\"li\", null, [\n _createElementVNode(\"button\", {\n class: \"bb-pagination__page bb-pagination__page--next\",\n disabled: props.modelValue >= +totalPages.value || _ctx.loading || _ctx.disabled,\n onClick: _cache[1] || (_cache[1] = ($event: any) => (emit('update:modelValue', props.modelValue + 1)))\n }, [\n _renderSlot(_ctx.$slots, \"next\", {}, () => [\n _createTextVNode(\"Successivi\")\n ])\n ], 8, _hoisted_4)\n ])\n ], 512)\n ])\n ], 512))\n}\n}\n\n})"],"names":["_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_sfc_main","_defineComponent","__props","__emit","props","emit","totalPages","computed","start","ref","maxSize","outercontainer","innercontainer","buttonFootprint","adjustMaxElements","nextTick","observer","debounce","onMounted","button","numberAsString","gap","onBeforeUnmount","range","createRange","even","middle","left","right","rangeLength","rangeStart","items","item","index","length","_","k","_ctx","_cache","_openBlock","_createElementBlock","_createElementVNode","$event","_renderSlot","_createTextVNode","_Fragment","_renderList","_normalizeClass","_toDisplayString"],"mappings":";;AAGA,MAAMA,IAAa,EAAE,cAAc,iBAC7BC,IAAa,CAAC,UAAU,GACxBC,IAAa,CAAC,YAAY,SAAS,GACnCC,IAAa,CAAC,UAAU,GAgDFC,IAAiBC,gBAAAA,EAAA;AAAA,EAC3C,QAAQ;AAAA,EACR,OAAO;AAAA,IACL,UAAU,EAAE,MAAM,QAAQ;AAAA,IAC1B,SAAS,EAAE,MAAM,QAAQ;AAAA,IACzB,UAAU,EAAE,SAAS,MAAM;AAAA,IAC3B,SAAS,EAAE,SAAS,EAAE;AAAA,IACtB,YAAY,EAAE,SAAS,EAAE;AAAA,IACzB,YAAY,EAAE,SAAS,EAAE;AAAA,EAC3B;AAAA,EACA,OAAO,CAAC,mBAAmB;AAAA,EAC3B,MAAMC,GAAc,EAAE,MAAMC,KAAU;AAExC,UAAMC,IAAQF,GAERG,IAAOF,GAIPG,IAAaC,EAAS,MAAM,CAACH,EAAM,UAAU,GAC7CI,IAAQC,EAAI,CAAC,GACbC,IAAUD,EAAI,CAACL,EAAM,OAAO,GAE5BO,IAAiBF,KACjBG,IAAiBH,KAEjBI,IAAkBJ,EAAY,KAAQ,GAQtCK,IAAoB,MAAM;AAC3B,MAAAH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AG,MAAM;AAAA,gBACrDO,EAAiBI,EAAiB5C,EAAM,QAAQ,GAAG,CAAC;AAAA,cACrD,CAAA,IACDuC,EAAYN,EAAK,QAAQ,QAAQ;AAAA,gBAC/B,KAAK;AAAA,gBACL,QAAQL,EAAK;AAAA,gBACb,UAAUA,EAAK;AAAA,gBACf,MAAMA,EAAK;AAAA,cAAA,GACV,MAAM;AAAA,gBACPY,EAAiBI,EAAiBhB,EAAK,GAAG,GAAG,CAAC;AAAA,cAAA,CAC/C;AAAA,YAAA,GACJ,IAAIlC,CAAU;AAAA,UAAA,CAClB,EACF,GAAG,GAAG;AAAA,UACP2C,EAAoB,MAAM,MAAM;AAAA,YAC9BA,EAAoB,UAAU;AAAA,cAC5B,OAAO;AAAA,cACP,UAAUrC,EAAM,cAAc,CAACE,EAAW,SAAS+B,EAAK,WAAWA,EAAK;AAAA,cACxE,SAASC,EAAO,CAAC,MAAMA,EAAO,CAAC,IAAI,CAACI,MAAiBrC,EAAK,qBAAqBD,EAAM,aAAa,CAAC;AAAA,YAAA,GAClG;AAAA,cACDuC,EAAYN,EAAK,QAAQ,QAAQ,IAAI,MAAM;AAAA,gBACzCO,EAAiB,YAAY;AAAA,cAAA,CAC9B;AAAA,YAAA,GACA,GAAG7C,CAAU;AAAA,UAAA,CACjB;AAAA,WACA,GAAG;AAAA,MAAA,CACP;AAAA,OACA,GAAG;AAAA,EAER;AAEA,CAAC;"}
package/dist/index79.js CHANGED
@@ -1,25 +1,25 @@
1
1
  import { defineComponent as V, ref as a, computed as _, openBlock as p, createElementBlock as h, mergeProps as B, createElementVNode as d, renderSlot as P, normalizeProps as I, guardReactiveProps as R, unref as g, createBlock as D, Teleport as U, normalizeClass as W, normalizeStyle as j, createCommentVNode as y, withCtx as G, nextTick as J } from "vue";
2
- import { useFloating as K, arrow as Q } from "./index223.js";
3
- import { useFocusTrap as X } from "./index217.js";
2
+ import { useFloating as K, arrow as Q } from "./index225.js";
3
+ import { useFocusTrap as X } from "./index209.js";
4
4
  import { useId as Y } from "./index7.js";
5
5
  import { wait as E } from "./index122.js";
6
6
  import Z from "./index9.js";
7
7
  import "./index10.js";
8
- import { autoUpdate as ee, flip as oe, shift as te } from "./index205.js";
9
- import { offset as ae } from "./index210.js";
8
+ import { autoUpdate as ee, flip as oe, shift as te } from "./index212.js";
9
+ import { offset as ae } from "./index217.js";
10
10
  const re = ["id"], ne = {
11
11
  key: 1,
12
12
  class: "bb-popover__bubble"
13
13
  }, se = /* @__PURE__ */ d("span", { class: "bb-popover__close-label" }, "Chiudi", -1), le = /* @__PURE__ */ d("svg", {
14
- viewBox: "0 0 24 24",
15
14
  fill: "none",
15
+ viewBox: "0 0 24 24",
16
16
  xmlns: "http://www.w3.org/2000/svg"
17
17
  }, [
18
18
  /* @__PURE__ */ d("path", {
19
19
  d: "M23 23L1 1M23 1L1 23",
20
20
  stroke: "currentColor",
21
- "stroke-width": "2",
22
- "stroke-linecap": "round"
21
+ "stroke-linecap": "round",
22
+ "stroke-width": "2"
23
23
  })
24
24
  ], -1), we = /* @__PURE__ */ V({
25
25
  __name: "BbPopover",
@@ -140,9 +140,9 @@ const re = ["id"], ne = {
140
140
  };
141
141
  return (e, t) => (p(), h("span", B({ class: "bb-popover" }, F.value), [
142
142
  d("span", {
143
- class: "bb-popover__wrapper",
144
143
  ref_key: "wrapper",
145
- ref: s
144
+ ref: s,
145
+ class: "bb-popover__wrapper"
146
146
  }, [
147
147
  P(e.$slots, "activator", I(R({
148
148
  props: {
@@ -162,6 +162,9 @@ const re = ["id"], ne = {
162
162
  ], 512),
163
163
  (p(), D(U, { to: "body" }, [
164
164
  d("span", {
165
+ id: `popover_${b}`,
166
+ ref_key: "content",
167
+ ref: u,
165
168
  class: W(["bb-popover__bubble-container", {
166
169
  [`bb-popover__bubble-container--${g(v)}`]: !0,
167
170
  [`bb-popover__bubble-container--${e.theme}`]: e.theme,
@@ -170,16 +173,13 @@ const re = ["id"], ne = {
170
173
  "bb-popover__bubble-container--opening": r.value,
171
174
  "bb-popover__bubble-container--open": n.value
172
175
  }]),
173
- ref_key: "content",
174
- ref: u,
175
- style: j(q.value),
176
- id: `popover_${b}`
176
+ style: j(q.value)
177
177
  }, [
178
178
  m.value || e.eager ? (p(), h("span", B({
179
179
  key: 0,
180
- class: "bb-popover__arrow",
181
180
  ref_key: "bubblearrow",
182
- ref: k
181
+ ref: k,
182
+ class: "bb-popover__arrow"
183
183
  }, H.value), null, 16)) : y("", !0),
184
184
  m.value || e.eager ? (p(), h("span", ne, [
185
185
  e.showClose ? (p(), D(Z, {
@@ -1 +1 @@
1
- {"version":3,"file":"index79.js","sources":["../src/components/BbPopover/BbPopover.vue?vue&type=script&setup=true&lang.ts"],"sourcesContent":["import { defineComponent as _defineComponent } from 'vue'\nimport { unref as _unref, normalizeProps as _normalizeProps, guardReactiveProps as _guardReactiveProps, renderSlot as _renderSlot, createElementVNode as _createElementVNode, mergeProps as _mergeProps, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, withCtx as _withCtx, createBlock as _createBlock, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, Teleport as _Teleport } from \"vue\"\n\nconst _hoisted_1 = [\"id\"]\nconst _hoisted_2 = {\n key: 1,\n class: \"bb-popover__bubble\"\n}\nconst _hoisted_3 = /*#__PURE__*/_createElementVNode(\"span\", { class: \"bb-popover__close-label\" }, \"Chiudi\", -1)\nconst _hoisted_4 = /*#__PURE__*/_createElementVNode(\"svg\", {\n viewBox: \"0 0 24 24\",\n fill: \"none\",\n xmlns: \"http://www.w3.org/2000/svg\"\n}, [\n /*#__PURE__*/_createElementVNode(\"path\", {\n d: \"M23 23L1 1M23 1L1 23\",\n stroke: \"currentColor\",\n \"stroke-width\": \"2\",\n \"stroke-linecap\": \"round\"\n })\n], -1)\n\nimport { computed, nextTick, ref } from \"vue\";\nimport {\n useFloating,\n autoUpdate,\n flip,\n shift,\n offset,\n arrow,\n} from \"@floating-ui/vue\";\nimport { useFocusTrap } from \"@vueuse/integrations/useFocusTrap\";\nimport { useId } from \"@/composables/useId\";\nimport { wait } from \"@/utilities/functions/wait\";\nimport BaseButton from \"../BaseButton/BaseButton.vue\";\nimport type { CommonProps } from \"@/types/CommonProps\";\nimport type { Placement } from \"@floating-ui/vue\";\n\nexport type BbPopoverProps = Pick<\n CommonProps,\n | \"arrowPadding\"\n | \"block\"\n | \"disabled\"\n | \"eager\"\n | \"offset\"\n | \"padding\"\n | \"placement\"\n | \"showClose\"\n | \"theme\"\n | \"transitionDuration\"\n> & {\n /**\n * Elements that obtains focus immediately after opening the popover.\n * By default it's the first tabbable item.\n */\n focusTarget?: string;\n /**\n * Width of the dropdown in pixels.\n */\n width?: number | string;\n};\n\nexport type BbPopoverEvents = {\n (e: \"shown\"): void;\n (e: \"hidden\"): void;\n};\n\n\nexport default /*#__PURE__*/_defineComponent({\n __name: 'BbPopover',\n props: {\n arrowPadding: { default: 10 },\n block: { type: Boolean },\n disabled: { type: Boolean },\n eager: { type: Boolean },\n offset: { default: 3 },\n padding: { default: 10 },\n placement: { default: \"bottom\" },\n showClose: { type: Boolean, default: true },\n theme: { default: \"default\" },\n transitionDuration: { default: 150 },\n focusTarget: {},\n width: {}\n },\n emits: [\"shown\", \"hidden\"],\n setup(__props: any, { emit: __emit }) {\n\nconst props = __props;\n\nconst emit = __emit;\n\n\n\nconst { id: _id } = useId();\nconst id = `bbp_${_id.value}`;\n\nconst wrapper = ref<HTMLElement>();\nconst content = ref<HTMLElement>();\nconst bubblearrow = ref<HTMLElement>();\n\nconst { activate, deactivate } = useFocusTrap(content, {\n /**\n * This traps all clicks outside so we are pressing\n * the trigger we just allow and process that in its\n * own click handler.\n * If we are pressing anything random on the page\n * close the popover and be done\n */\n clickOutsideDeactivates: (event) => {\n const target = event.target;\n if (target instanceof HTMLElement) {\n if (wrapper.value?.contains(target)) {\n return true;\n }\n }\n closePopover();\n emit(\"hidden\");\n return true;\n },\n escapeDeactivates: () => {\n nextTick(async () => {\n await closePopover();\n focusTrigger();\n emit(\"hidden\");\n });\n return true;\n },\n /* We don't return focus so that when\n * we press a button on tyhe page we can focus\n * THAT button and not the current trigger\n */\n returnFocusOnDeactivate: false,\n});\n\nconst { floatingStyles, placement, middlewareData } = useFloating(\n wrapper,\n content,\n {\n placement: props.placement,\n whileElementsMounted: autoUpdate,\n middleware: [\n flip(),\n offset(props.offset),\n shift({ padding: props.padding }),\n arrow({\n element: bubblearrow,\n padding: props.arrowPadding,\n }),\n ],\n }\n);\n\nconst attributes = computed(() => {\n const classes = {\n \"bb-popover--block\": props.block,\n [`bb-popover--theme-${props.theme}`]: props.theme,\n };\n return {\n class: classes,\n };\n});\n\nconst opening = ref(false);\nconst open = ref(false);\nconst closing = ref(false);\nconst closed = ref(true);\n\nconst arrowAttributes = computed(() => {\n if (middlewareData.value.arrow) {\n const { x, y } = middlewareData.value.arrow;\n return {\n style: {\n left: `${x}px`,\n top: `${y}px`,\n },\n };\n }\n});\n\nconst containerStyle = computed(() => {\n const base: Record<string, any> = {\n ...floatingStyles.value,\n transitionDuration: `${props.transitionDuration}ms`,\n };\n if (props.width) {\n let width: string;\n // If the width is a css unit string use it, if it is a number or number string add px\n if (typeof props.width === \"string\" && Number.isNaN(Number(props.width))) {\n if (props.width.includes(\"%\")) {\n if (!wrapper.value) return;\n width = `${\n wrapper.value.clientWidth * (+props.width.replace(\"%\", \"\") / 100)\n }px`;\n } else {\n width = props.width;\n }\n } else {\n width = `${props.width}px`;\n }\n base.width = width;\n }\n return base;\n});\n\nconst openPopover = async () => {\n closed.value = false;\n closing.value = false;\n opening.value = true;\n await wait(50);\n open.value = true;\n opening.value = false;\n};\n\nconst closePopover = async () => {\n open.value = false;\n opening.value = false;\n closing.value = true;\n await wait(props.transitionDuration);\n closing.value = false;\n closed.value = true;\n};\nconst hasOpenedOnce = ref(false);\nconst onTriggerClick = async () => {\n if (open.value) {\n await closePopover();\n focusTrigger();\n emit(\"hidden\");\n return;\n }\n if (opening.value || props.disabled) return;\n hasOpenedOnce.value = true;\n await openPopover();\n let focusTarget = props.focusTarget ?? \".bb-popover__close\";\n\n activate({\n onPostActivate: () => {\n if (content.value) {\n const target = content.value.querySelector(focusTarget);\n if (target instanceof HTMLElement) {\n target.focus();\n emit(\"shown\");\n }\n }\n },\n });\n};\n\nconst focusTrigger = () => {\n const trigger = wrapper.value?.querySelector(`[aria-controls=popover_${id}]`);\n if (trigger instanceof HTMLElement) {\n trigger.focus();\n }\n};\n\nconst onClickClose = async () => {\n deactivate();\n await closePopover();\n focusTrigger();\n emit(\"hidden\");\n};\n\nreturn (_ctx: any,_cache: any) => {\n return (_openBlock(), _createElementBlock(\"span\", _mergeProps({ class: \"bb-popover\" }, attributes.value), [\n _createElementVNode(\"span\", {\n class: \"bb-popover__wrapper\",\n ref_key: \"wrapper\",\n ref: wrapper\n }, [\n _renderSlot(_ctx.$slots, \"activator\", _normalizeProps(_guardReactiveProps({\n props: {\n 'aria-controls': `popover_${id}`,\n 'aria-expanded': open.value,\n onClick: onTriggerClick,\n id: id,\n disabled: !!_ctx.disabled,\n },\n closed: closed.value,\n closing: closing.value,\n disabled: !!_ctx.disabled,\n open: open.value,\n opening: opening.value,\n placement: _unref(placement),\n })))\n ], 512),\n (_openBlock(), _createBlock(_Teleport, { to: \"body\" }, [\n _createElementVNode(\"span\", {\n class: _normalizeClass([\"bb-popover__bubble-container\", {\n [`bb-popover__bubble-container--${_unref(placement)}`]: true,\n [`bb-popover__bubble-container--${_ctx.theme}`]: _ctx.theme,\n 'bb-popover__bubble-container--hidden': closed.value,\n 'bb-popover__bubble-container--closing': closing.value,\n 'bb-popover__bubble-container--opening': opening.value,\n 'bb-popover__bubble-container--open': open.value,\n }]),\n ref_key: \"content\",\n ref: content,\n style: _normalizeStyle(containerStyle.value),\n id: `popover_${id}`\n }, [\n (hasOpenedOnce.value || _ctx.eager)\n ? (_openBlock(), _createElementBlock(\"span\", _mergeProps({\n key: 0,\n class: \"bb-popover__arrow\",\n ref_key: \"bubblearrow\",\n ref: bubblearrow\n }, arrowAttributes.value), null, 16))\n : _createCommentVNode(\"\", true),\n (hasOpenedOnce.value || _ctx.eager)\n ? (_openBlock(), _createElementBlock(\"span\", _hoisted_2, [\n (_ctx.showClose)\n ? (_openBlock(), _createBlock(BaseButton, {\n key: 0,\n class: \"bb-popover__close\",\n onClick: onClickClose\n }, {\n default: _withCtx(() => [\n _hoisted_3,\n _hoisted_4\n ]),\n _: 1\n }))\n : _createCommentVNode(\"\", true),\n _renderSlot(_ctx.$slots, \"default\", {\n close: onClickClose,\n closed: closed.value,\n closing: closing.value,\n disabled: !!_ctx.disabled,\n open: open.value,\n opening: opening.value,\n placement: _unref(placement)\n })\n ]))\n : _createCommentVNode(\"\", true)\n ], 14, _hoisted_1)\n ]))\n ], 16))\n}\n}\n\n})"],"names":["_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_sfc_main","_defineComponent","__props","__emit","props","emit","_id","useId","id","wrapper","ref","content","bubblearrow","activate","deactivate","useFocusTrap","event","target","_a","closePopover","nextTick","focusTrigger","floatingStyles","placement","middlewareData","useFloating","autoUpdate","flip","offset","shift","arrow","attributes","computed","opening","open","closing","closed","arrowAttributes","x","y","containerStyle","base","width","openPopover","wait","hasOpenedOnce","onTriggerClick","focusTarget","trigger","onClickClose","_ctx","_cache","_openBlock","_createElementBlock","_mergeProps","_createElementVNode","_renderSlot","_normalizeProps","_guardReactiveProps","_unref","_createBlock","_Teleport","_normalizeClass","_normalizeStyle","_createCommentVNode","BaseButton","_withCtx"],"mappings":";;;;;;;;;AAGA,MAAMA,KAAa,CAAC,IAAI,GAClBC,KAAa;AAAA,EACjB,KAAK;AAAA,EACL,OAAO;AACT,GACMC,uBAA8C,QAAQ,EAAE,OAAO,6BAA6B,UAAU,EAAE,GACxGC,uBAA8C,OAAO;AAAA,EACzD,SAAS;AAAA,EACT,MAAM;AAAA,EACN,OAAO;AACT,GAAG;AAAA,oBACgC,QAAQ;AAAA,IACvC,GAAG;AAAA,IACH,QAAQ;AAAA,IACR,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EAAe,KAAK;AAAA,UAC3C,IAAI,WAAWhC,CAAE;AAAA,QAAA,GAChB;AAAA,UACAqC,EAAc,SAASK,EAAK,SACxBE,KAAcC,EAAoB,QAAQC,EAAY;AAAA,YACrD,KAAK;AAAA,YACL,OAAO;AAAA,YACP,SAAS;AAAA,YACT,KAAK1C;AAAA,UAAA,GACJyB,EAAgB,KAAK,GAAG,MAAM,EAAE,KACnC2B,EAAoB,IAAI,EAAI;AAAA,UAC/BnB,EAAc,SAASK,EAAK,SACxBE,KAAcC,EAAoB,QAAQxD,IAAY;AAAA,YACpDqD,EAAK,aACDE,KAAcQ,EAAaK,GAAY;AAAA,cACtC,KAAK;AAAA,cACL,OAAO;AAAA,cACP,SAAShB;AAAA,YAAA,GACR;AAAA,cACD,SAASiB,EAAS,MAAM;AAAA,gBACtBpE;AAAA,gBACAC;AAAA,cAAA,CACD;AAAA,cACD,GAAG;AAAA,YAAA,CACJ,KACDiE,EAAoB,IAAI,EAAI;AAAA,YAChCR,EAAYN,EAAK,QAAQ,WAAW;AAAA,cAClC,OAAOD;AAAA,cACP,QAAQb,EAAO;AAAA,cACf,SAASD,EAAQ;AAAA,cACjB,UAAU,CAAC,CAACe,EAAK;AAAA,cACjB,MAAMhB,EAAK;AAAA,cACX,SAASD,EAAQ;AAAA,cACjB,WAAW0B,EAAOpC,CAAS;AAAA,YAAA,CAC5B;AAAA,UAAA,CACF,KACDyC,EAAoB,IAAI,EAAI;AAAA,QAAA,GAC/B,IAAIpE,EAAU;AAAA,MAAA,CAClB;AAAA,OACA,EAAE;AAAA,EAEP;AAEA,CAAC;"}
1
+ {"version":3,"file":"index79.js","sources":["../src/components/BbPopover/BbPopover.vue?vue&type=script&setup=true&lang.ts"],"sourcesContent":["import { defineComponent as _defineComponent } from 'vue'\nimport { unref as _unref, normalizeProps as _normalizeProps, guardReactiveProps as _guardReactiveProps, renderSlot as _renderSlot, createElementVNode as _createElementVNode, mergeProps as _mergeProps, openBlock as _openBlock, createElementBlock as _createElementBlock, createCommentVNode as _createCommentVNode, withCtx as _withCtx, createBlock as _createBlock, normalizeClass as _normalizeClass, normalizeStyle as _normalizeStyle, Teleport as _Teleport } from \"vue\"\n\nconst _hoisted_1 = [\"id\"]\nconst _hoisted_2 = {\n key: 1,\n class: \"bb-popover__bubble\"\n}\nconst _hoisted_3 = /*#__PURE__*/_createElementVNode(\"span\", { class: \"bb-popover__close-label\" }, \"Chiudi\", -1)\nconst _hoisted_4 = /*#__PURE__*/_createElementVNode(\"svg\", {\n fill: \"none\",\n viewBox: \"0 0 24 24\",\n xmlns: \"http://www.w3.org/2000/svg\"\n}, [\n /*#__PURE__*/_createElementVNode(\"path\", {\n d: \"M23 23L1 1M23 1L1 23\",\n stroke: \"currentColor\",\n \"stroke-linecap\": \"round\",\n \"stroke-width\": \"2\"\n })\n], -1)\n\nimport { computed, nextTick, ref } from 'vue';\nimport {\n\tuseFloating,\n\tautoUpdate,\n\tflip,\n\tshift,\n\toffset,\n\tarrow,\n} from '@floating-ui/vue';\nimport { useFocusTrap } from '@vueuse/integrations/useFocusTrap';\nimport { useId } from '@/composables/useId';\nimport { wait } from '@/utilities/functions/wait';\nimport BaseButton from '../BaseButton/BaseButton.vue';\nimport type { CommonProps } from '@/types/CommonProps';\nimport type { Placement } from '@floating-ui/vue';\n\nexport type BbPopoverProps = Pick<\n\tCommonProps,\n\t| 'arrowPadding'\n\t| 'block'\n\t| 'disabled'\n\t| 'eager'\n\t| 'offset'\n\t| 'padding'\n\t| 'placement'\n\t| 'showClose'\n\t| 'theme'\n\t| 'transitionDuration'\n> & {\n\t/**\n\t * Elements that obtains focus immediately after opening the popover.\n\t * By default it's the first tabbable item.\n\t */\n\tfocusTarget?: string;\n\t/**\n\t * Width of the dropdown in pixels.\n\t */\n\twidth?: number | string;\n};\n\nexport type BbPopoverEvents = {\n\t(e: 'shown'): void;\n\t(e: 'hidden'): void;\n};\n\n\nexport default /*#__PURE__*/_defineComponent({\n __name: 'BbPopover',\n props: {\n arrowPadding: { default: 10 },\n block: { type: Boolean },\n disabled: { type: Boolean },\n eager: { type: Boolean },\n offset: { default: 3 },\n padding: { default: 10 },\n placement: { default: 'bottom' },\n showClose: { type: Boolean, default: true },\n theme: { default: 'default' },\n transitionDuration: { default: 150 },\n focusTarget: {},\n width: {}\n },\n emits: [\"shown\", \"hidden\"],\n setup(__props: any, { emit: __emit }) {\n\nconst props = __props;\n\nconst emit = __emit;\n\n\n\nconst { id: _id } = useId();\nconst id = `bbp_${_id.value}`;\n\nconst wrapper = ref<HTMLElement>();\nconst content = ref<HTMLElement>();\nconst bubblearrow = ref<HTMLElement>();\n\nconst { activate, deactivate } = useFocusTrap(content, {\n\t/**\n\t * This traps all clicks outside so we are pressing\n\t * the trigger we just allow and process that in its\n\t * own click handler.\n\t * If we are pressing anything random on the page\n\t * close the popover and be done\n\t */\n\tclickOutsideDeactivates: (event) => {\n\t\tconst target = event.target;\n\t\tif (target instanceof HTMLElement) {\n\t\t\tif (wrapper.value?.contains(target)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\t\tclosePopover();\n\t\temit('hidden');\n\t\treturn true;\n\t},\n\tescapeDeactivates: () => {\n\t\tnextTick(async () => {\n\t\t\tawait closePopover();\n\t\t\tfocusTrigger();\n\t\t\temit('hidden');\n\t\t});\n\t\treturn true;\n\t},\n\t/* We don't return focus so that when\n\t * we press a button on tyhe page we can focus\n\t * THAT button and not the current trigger\n\t */\n\treturnFocusOnDeactivate: false,\n});\n\nconst { floatingStyles, placement, middlewareData } = useFloating(\n\twrapper,\n\tcontent,\n\t{\n\t\tplacement: props.placement,\n\t\twhileElementsMounted: autoUpdate,\n\t\tmiddleware: [\n\t\t\tflip(),\n\t\t\toffset(props.offset),\n\t\t\tshift({ padding: props.padding }),\n\t\t\tarrow({\n\t\t\t\telement: bubblearrow,\n\t\t\t\tpadding: props.arrowPadding,\n\t\t\t}),\n\t\t],\n\t}\n);\n\nconst attributes = computed(() => {\n\tconst classes = {\n\t\t'bb-popover--block': props.block,\n\t\t[`bb-popover--theme-${props.theme}`]: props.theme,\n\t};\n\treturn {\n\t\tclass: classes,\n\t};\n});\n\nconst opening = ref(false);\nconst open = ref(false);\nconst closing = ref(false);\nconst closed = ref(true);\n\nconst arrowAttributes = computed(() => {\n\tif (middlewareData.value.arrow) {\n\t\tconst { x, y } = middlewareData.value.arrow;\n\t\treturn {\n\t\t\tstyle: {\n\t\t\t\tleft: `${x}px`,\n\t\t\t\ttop: `${y}px`,\n\t\t\t},\n\t\t};\n\t}\n});\n\nconst containerStyle = computed(() => {\n\tconst base: Record<string, any> = {\n\t\t...floatingStyles.value,\n\t\ttransitionDuration: `${props.transitionDuration}ms`,\n\t};\n\tif (props.width) {\n\t\tlet width: string;\n\t\t// If the width is a css unit string use it, if it is a number or number string add px\n\t\tif (typeof props.width === 'string' && Number.isNaN(Number(props.width))) {\n\t\t\tif (props.width.includes('%')) {\n\t\t\t\tif (!wrapper.value) return;\n\t\t\t\twidth = `${\n\t\t\t\t\twrapper.value.clientWidth * (+props.width.replace('%', '') / 100)\n\t\t\t\t}px`;\n\t\t\t} else {\n\t\t\t\twidth = props.width;\n\t\t\t}\n\t\t} else {\n\t\t\twidth = `${props.width}px`;\n\t\t}\n\t\tbase.width = width;\n\t}\n\treturn base;\n});\n\nconst openPopover = async () => {\n\tclosed.value = false;\n\tclosing.value = false;\n\topening.value = true;\n\tawait wait(50);\n\topen.value = true;\n\topening.value = false;\n};\n\nconst closePopover = async () => {\n\topen.value = false;\n\topening.value = false;\n\tclosing.value = true;\n\tawait wait(props.transitionDuration);\n\tclosing.value = false;\n\tclosed.value = true;\n};\nconst hasOpenedOnce = ref(false);\nconst onTriggerClick = async () => {\n\tif (open.value) {\n\t\tawait closePopover();\n\t\tfocusTrigger();\n\t\temit('hidden');\n\t\treturn;\n\t}\n\tif (opening.value || props.disabled) return;\n\thasOpenedOnce.value = true;\n\tawait openPopover();\n\tlet focusTarget = props.focusTarget ?? '.bb-popover__close';\n\n\tactivate({\n\t\tonPostActivate: () => {\n\t\t\tif (content.value) {\n\t\t\t\tconst target = content.value.querySelector(focusTarget);\n\t\t\t\tif (target instanceof HTMLElement) {\n\t\t\t\t\ttarget.focus();\n\t\t\t\t\temit('shown');\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t});\n};\n\nconst focusTrigger = () => {\n\tconst trigger = wrapper.value?.querySelector(`[aria-controls=popover_${id}]`);\n\tif (trigger instanceof HTMLElement) {\n\t\ttrigger.focus();\n\t}\n};\n\nconst onClickClose = async () => {\n\tdeactivate();\n\tawait closePopover();\n\tfocusTrigger();\n\temit('hidden');\n};\n\nreturn (_ctx: any,_cache: any) => {\n return (_openBlock(), _createElementBlock(\"span\", _mergeProps({ class: \"bb-popover\" }, attributes.value), [\n _createElementVNode(\"span\", {\n ref_key: \"wrapper\",\n ref: wrapper,\n class: \"bb-popover__wrapper\"\n }, [\n _renderSlot(_ctx.$slots, \"activator\", _normalizeProps(_guardReactiveProps({\n\t\t\t\t\tprops: {\n\t\t\t\t\t\t'aria-controls': `popover_${id}`,\n\t\t\t\t\t\t'aria-expanded': open.value,\n\t\t\t\t\t\tonClick: onTriggerClick,\n\t\t\t\t\t\tid: id,\n\t\t\t\t\t\tdisabled: !!_ctx.disabled,\n\t\t\t\t\t},\n\t\t\t\t\tclosed: closed.value,\n\t\t\t\t\tclosing: closing.value,\n\t\t\t\t\tdisabled: !!_ctx.disabled,\n\t\t\t\t\topen: open.value,\n\t\t\t\t\topening: opening.value,\n\t\t\t\t\tplacement: _unref(placement),\n\t\t\t\t})))\n ], 512),\n (_openBlock(), _createBlock(_Teleport, { to: \"body\" }, [\n _createElementVNode(\"span\", {\n id: `popover_${id}`,\n ref_key: \"content\",\n ref: content,\n class: _normalizeClass([\"bb-popover__bubble-container\", {\n\t\t\t\t\t[`bb-popover__bubble-container--${_unref(placement)}`]: true,\n\t\t\t\t\t[`bb-popover__bubble-container--${_ctx.theme}`]: _ctx.theme,\n\t\t\t\t\t'bb-popover__bubble-container--hidden': closed.value,\n\t\t\t\t\t'bb-popover__bubble-container--closing': closing.value,\n\t\t\t\t\t'bb-popover__bubble-container--opening': opening.value,\n\t\t\t\t\t'bb-popover__bubble-container--open': open.value,\n\t\t\t\t}]),\n style: _normalizeStyle(containerStyle.value)\n }, [\n (hasOpenedOnce.value || _ctx.eager)\n ? (_openBlock(), _createElementBlock(\"span\", _mergeProps({\n key: 0,\n ref_key: \"bubblearrow\",\n ref: bubblearrow,\n class: \"bb-popover__arrow\"\n }, arrowAttributes.value), null, 16))\n : _createCommentVNode(\"\", true),\n (hasOpenedOnce.value || _ctx.eager)\n ? (_openBlock(), _createElementBlock(\"span\", _hoisted_2, [\n (_ctx.showClose)\n ? (_openBlock(), _createBlock(BaseButton, {\n key: 0,\n class: \"bb-popover__close\",\n onClick: onClickClose\n }, {\n default: _withCtx(() => [\n _hoisted_3,\n _hoisted_4\n ]),\n _: 1\n }))\n : _createCommentVNode(\"\", true),\n _renderSlot(_ctx.$slots, \"default\", {\n close: onClickClose,\n closed: closed.value,\n closing: closing.value,\n disabled: !!_ctx.disabled,\n open: open.value,\n opening: opening.value,\n placement: _unref(placement)\n })\n ]))\n : _createCommentVNode(\"\", true)\n ], 14, _hoisted_1)\n ]))\n ], 16))\n}\n}\n\n})"],"names":["_hoisted_1","_hoisted_2","_hoisted_3","_hoisted_4","_sfc_main","_defineComponent","__props","__emit","props","emit","_id","useId","id","wrapper","ref","content","bubblearrow","activate","deactivate","useFocusTrap","event","target","_a","closePopover","nextTick","focusTrigger","floatingStyles","placement","middlewareData","useFloating","autoUpdate","flip","offset","shift","arrow","attributes","computed","opening","open","closing","closed","arrowAttributes","x","y","containerStyle","base","width","openPopover","wait","hasOpenedOnce","onTriggerClick","focusTarget","trigger","onClickClose","_ctx","_cache","_openBlock","_createElementBlock","_mergeProps","_createElementVNode","_renderSlot","_normalizeProps","_guardReactiveProps","_unref","_createBlock","_Teleport","_normalizeClass","_normalizeStyle","_createCommentVNode","BaseButton","_withCtx"],"mappings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AA,CAClB;AAAA,OACA,EAAE;AAAA,EAEP;AAEA,CAAC;"}
package/dist/index8.js CHANGED
@@ -34,13 +34,16 @@ const te = Symbol(), x = /((step\/)(?<step>[\s\S]+?)(?=[/?]))|((step\/)(?<step2>
34
34
  {}
35
35
  )
36
36
  ), m = g(
37
- () => X(o.value, (t) => typeof t.isValid == "function" ? {
38
- ...t,
39
- isValid: t.isValid(l)
40
- } : {
41
- ...t,
42
- isValid: t.isValid ?? !0
43
- })
37
+ () => X(
38
+ o.value,
39
+ (t) => typeof t.isValid == "function" ? {
40
+ ...t,
41
+ isValid: t.isValid(l)
42
+ } : {
43
+ ...t,
44
+ isValid: t.isValid ?? !0
45
+ }
46
+ )
44
47
  );
45
48
  let p = null;
46
49
  if (u && a(e.value)) {
@@ -1 +1 @@
1
- {"version":3,"file":"index8.js","sources":["../src/composables/useWizard.ts"],"sourcesContent":["import { cloneDeep } from \"@/utilities/functions/cloneDeep\";\nimport { computed, provide, reactive, watch, toValue } from \"vue\";\nimport { isNotNil } from \"@/utilities/functions/isNotNil\";\nimport { mapValues } from \"@/utilities/functions/mapValues\";\nimport { useRoute } from \"./useRoute\";\nimport { useRouter } from \"./useRouter\";\nimport { useStepper } from \"@vueuse/core\";\nimport type { ComputedRef, MaybeRef } from \"vue\";\n\nexport const wizardInjectionKey = Symbol();\nexport type Step<U> = {\n /**\n * Function that accepts a state object and returns a boolean.\n * When step are accessed at the end of the pipeline the result\n * is provided so you don't have to run the function yourself.\n * It determines if the validation has passed for the step.\n */\n isValid?: (state: U) => boolean | boolean;\n /**\n * Function that accepts a state object and returns a boolean.\n * When step are accessed at the end of the pipeline the result\n * is provided so you don't have to run the function yourself.\n * Steps that do not pass the condition are removed.\n */\n condition?: (state: U) => boolean;\n [key: string]: any;\n};\nexport type WizardState<T extends Record<string, any>> = ReturnType<typeof useWizard<T>>\n\nconst regexMatchStep =\n /((step\\/)(?<step>[\\s\\S]+?)(?=[/?]))|((step\\/)(?<step2>[\\s\\S]+))/;\n/**\n * With a url that follows the rule xyz.com/anything/step/:nameofthestep[/?query]\n * will match the :nameofthestep substring\n */\nconst extractStepFromUrl = (url: string) => {\n const match = url.match(regexMatchStep);\n return match?.groups?.step ?? match?.groups?.step2 ?? null;\n};\nexport const useWizard = <T extends object>(params: {\n /**\n * The steps definition for the wizard\n */\n steps: MaybeRef<Record<string, Step<T>>>;\n /**\n * Name of the wizard used to persist state\n */\n name: string;\n /**\n * Initial set of data to be made available throughout\n */\n initialState: T;\n /**\n * When navogation is enabled, to whether use the query parameters or an entire substring of the URL like xyz/steps/....\n * The latter useful with nuxt so you can leverage the automatic import of components based on the URL.\n */\n navigationMode?: \"query\" | \"route\";\n /**\n * Whether to use navigation at all. When disabled no query or URL is changed.\n */\n useNavigation?: boolean;\n /**\n *\n */\n persist?: boolean;\n}) => {\n if (!params.name) {\n throw new Error(\n \"You need to provide a unique name for the current wizard instance to be used to save data\"\n );\n }\n const route = useRoute();\n const router = useRouter();\n\n const useNavigation = params.useNavigation ?? true;\n const navigationMode = params.navigationMode ?? \"query\";\n const persist = params.persist ?? true;\n\n if (useNavigation && (!route.value || !router)) {\n throw new Error(\n \"Navigation is enabled but could not retrieve the router instance in useWizard.\"\n );\n }\n\n const initialStateCopy = cloneDeep(params.initialState);\n /**\n * Initial state is either read from session storage or the one provided\n */\n const innerState = reactive<typeof params.initialState>(\n persist && sessionStorage.getItem(params.name)\n ? {\n ...initialStateCopy,\n ...JSON.parse(sessionStorage.getItem(params.name)!),\n }\n : initialStateCopy\n );\n\n if (persist) {\n /**\n * Every time the state changes save it to sessionStorage\n */\n watch(innerState, () => {\n sessionStorage.setItem(params.name, JSON.stringify(innerState));\n });\n }\n\n /**\n * Steps can be passed as ref so we need to unwrap them\n */\n const unwrappedSteps = toValue(params.steps);\n const filteredSteps = computed(() =>\n Object.entries(unwrappedSteps).reduce(\n (acc: typeof unwrappedSteps, [key, step]) => {\n if (step.condition) {\n if (!step.condition(innerState as T)) {\n return acc;\n }\n }\n acc[key] = { ...step, key };\n return acc;\n },\n {}\n )\n );\n\n /**\n * Steps can have a isValid function that receives the current state\n * but we don't want to have to call it every single time so we call it once here\n */\n const mappedSteps = computed(() =>\n mapValues(filteredSteps.value, (step): Omit<Step<T>, 'isValid'> & { isValid: boolean } => {\n if(typeof step.isValid === 'function') {\n return {\n ...step,\n isValid: step.isValid(innerState as T)\n }\n }\n return {\n ...step,\n isValid: step.isValid ?? true\n };\n })\n );\n\n /**\n * Get the initial step from the query.\n * If it exists check that every step before it is also valid\n * so user cannot manually jump by changing the URL\n */\n let initialStep = null;\n if (useNavigation && isNotNil(route.value)) {\n let step: string | null = null;\n if (navigationMode === \"query\") {\n if (route.value.query.step) {\n step = route.value.query.step as string;\n }\n } else {\n const stepFromUrl = extractStepFromUrl(route.value.fullPath);\n if (stepFromUrl) {\n step = stepFromUrl;\n }\n }\n initialStep = step;\n }\n\n if (initialStep) {\n for (const stepName in filteredSteps.value) {\n if (stepName === initialStep) break;\n const current = mappedSteps.value[stepName];\n if (!current || !current.isValid) {\n initialStep = null;\n break;\n }\n }\n }\n\n /**\n * Define the state of the wizard\n * A few data come from useStepper\n */\n const {\n steps,\n current,\n goToNext,\n goToPrevious,\n goTo,\n index,\n at,\n get,\n goBackTo,\n isAfter,\n isBefore,\n isCurrent,\n isFirst,\n isLast,\n isNext,\n isPrevious,\n next,\n previous,\n stepNames,\n } = useStepper(\n mappedSteps,\n initialStep || Object.values(filteredSteps.value)[0].key\n );\n\n const key = computed(() => Object.keys(filteredSteps.value)[index.value]);\n\n /**\n * Complete state object\n */\n const state = {\n at,\n current: current as ComputedRef<Step<T> & { isValid: boolean }>,\n data: innerState,\n get,\n goBackTo,\n goTo,\n goToNext,\n goToPrevious,\n isAfter,\n isBefore,\n isCurrent,\n isFirst,\n isLast,\n isNext,\n isPrevious,\n key,\n next,\n previous,\n stepNames,\n steps,\n };\n\n provide(wizardInjectionKey, state);\n\n if (useNavigation) {\n if (navigationMode === \"query\") {\n /**\n * Every time the current step changes update route\n */\n watch(\n key,\n () => {\n if (isNotNil(router) && isNotNil(route.value)) {\n router.push({\n ...route,\n query: { ...route.value.query, step: key.value ?? null },\n });\n }\n },\n { immediate: true }\n );\n\n /**\n * Every time the route changes align the current step to the route\n */\n watch(\n () => route.value?.query.step,\n (value) => {\n if (value) {\n const stepAsString = value as string;\n if (stepAsString in filteredSteps.value) {\n const stepAsKey = stepAsString;\n const stepKeys = Object.keys(filteredSteps.value);\n const stepsPriorToTarget = stepKeys.slice(\n 0,\n stepKeys.indexOf(stepAsKey)\n );\n const allValid = stepsPriorToTarget.every(\n (key) => mappedSteps.value[key]?.isValid\n );\n if (allValid) {\n goTo(stepAsKey);\n }\n }\n } else {\n const key = Object.keys(steps)[0];\n goTo(key);\n }\n }\n );\n } else {\n const stepFromUrl = computed(() => {\n if (isNotNil(route.value)) {\n return extractStepFromUrl(route.value.fullPath);\n }\n });\n\n /**\n * Every time the current step changes update route\n */\n watch(\n key,\n (value) => {\n if (isNotNil(route.value) && isNotNil(router)) {\n if (route.value.path.includes(\"step\")) {\n router.push({\n query: route.value.query,\n path: route.value.path.replace(regexMatchStep, `step/${value}`),\n });\n } else {\n router.push({\n query: route.value.query,\n // Normalizes paths with / and without\n path: (route.value.path + `/step/${value}`).replace(\"//\", \"/\"),\n replace: true,\n });\n }\n }\n },\n { immediate: true, flush: \"post\" }\n );\n\n /**\n * Every time the route changes align the current step to the route\n */\n watch(\n () => stepFromUrl.value,\n (value) => {\n if (value && value !== key.value) {\n const stepAsString = value as string;\n if (stepAsString in filteredSteps.value) {\n const stepAsKey = stepAsString;\n const stepKeys = Object.keys(filteredSteps.value);\n const stepsPriorToTarget = stepKeys.slice(\n 0,\n stepKeys.indexOf(stepAsKey)\n );\n const allValid = stepsPriorToTarget.every(\n (key) => filteredSteps.value[key]?.isValid\n );\n if (allValid) {\n goTo(stepAsKey);\n }\n }\n }\n }\n );\n }\n }\n\n return state;\n};\n"],"names":["wizardInjectionKey","regexMatchStep","extractStepFromUrl","url","match","_a","_b","useWizard","params","route","useRoute","router","useRouter","useNavigation","navigationMode","persist","initialStateCopy","cloneDeep","innerState","reactive","watch","unwrappedSteps","toValue","filteredSteps","computed","acc","key","step","mappedSteps","mapValues","initialStep","isNotNil","stepFromUrl","stepName","current","steps","goToNext","goToPrevious","goTo","index","at","get","goBackTo","isAfter","isBefore","isCurrent","isFirst","isLast","isNext","isPrevious","next","previous","stepNames","useStepper","state","provide","value","stepAsString","stepAsKey","stepKeys"],"mappings":";;;;;;;AASO,MAAMA,KAAqB,OAAO,GAoBnCC,IACJ,mEAKIC,IAAqB,CAACC,MAAgB;;AACpC,QAAAC,IAAQD,EAAI,MAAMF,CAAc;AACtC,WAAOI,IAAAD,KAAA,gBAAAA,EAAO,WAAP,gBAAAC,EAAe,WAAQC,IAAAF,KAAA,gBAAAA,EAAO,WAAP,gBAAAE,EAAe,UAAS;AACxD,GACaC,KAAY,CAAmBC,MA0BtC;AACA,MAAA,CAACA,EAAO;AACV,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAGJ,QAAMC,IAAQC,KACRC,IAASC,KAETC,IAAgBL,EAAO,iBAAiB,IACxCM,IAAiBN,EAAO,kBAAkB,SAC1CO,IAAUP,EAAO,WAAW;AAElC,MAAIK,MAAkB,CAACJ,EAAM,SAAS,CAACE;AACrC,UAAM,IAAI;AAAA,MACR;AAAA,IAAA;AAIE,QAAAK,IAAmBC,EAAUT,EAAO,YAAY,GAIhDU,IAAaC;AAAA,IACjBJ,KAAW,eAAe,QAAQP,EAAO,IAAI,IACzC;AAAA,MACE,GAAGQ;AAAA,MACH,GAAG,KAAK,MAAM,eAAe,QAAQR,EAAO,IAAI,CAAE;AAAA,IAAA,IAEpDQ;AAAA,EAAA;AAGN,EAAID,KAIFK,EAAMF,GAAY,MAAM;AACtB,mBAAe,QAAQV,EAAO,MAAM,KAAK,UAAUU,CAAU,CAAC;AAAA,EAAA,CAC/D;AAMG,QAAAG,IAAiBC,EAAQd,EAAO,KAAK,GACr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BlC,EAAc,OAAO;AACvC,oBAAMmC,IAAYD,GACZE,IAAW,OAAO,KAAKpC,EAAc,KAAK;AAQhD,cAP2BoC,EAAS;AAAA,gBAClC;AAAA,gBACAA,EAAS,QAAQD,CAAS;AAAA,cAAA,EAEQ;AAAA,gBAClC,CAAChC,MAAAA;;AAAQ,0BAAArB,IAAAkB,EAAc,MAAMG,CAAG,MAAvB,gBAAArB,EAA0B;AAAA;AAAA,cAAA,KAGnCiC,EAAKoB,CAAS;AAAA,YAElB;AAAA,UACF;AAAA,QACF;AAAA,MAAA;AAAA,IAEJ;AAGK,SAAAJ;AACT;"}
1
+ {"version":3,"file":"index8.js","sources":["../src/composables/useWizard.ts"],"sourcesContent":["import { cloneDeep } from '@/utilities/functions/cloneDeep';\nimport { computed, provide, reactive, watch, toValue } from 'vue';\nimport { isNotNil } from '@/utilities/functions/isNotNil';\nimport { mapValues } from '@/utilities/functions/mapValues';\nimport { useRoute } from './useRoute';\nimport { useRouter } from './useRouter';\nimport { useStepper } from '@vueuse/core';\nimport type { ComputedRef, MaybeRef } from 'vue';\n\nexport const wizardInjectionKey = Symbol();\nexport type Step<U> = {\n\t/**\n\t * Function that accepts a state object and returns a boolean.\n\t * When step are accessed at the end of the pipeline the result\n\t * is provided so you don't have to run the function yourself.\n\t * It determines if the validation has passed for the step.\n\t */\n\tisValid?: (state: U) => boolean | boolean;\n\t/**\n\t * Function that accepts a state object and returns a boolean.\n\t * When step are accessed at the end of the pipeline the result\n\t * is provided so you don't have to run the function yourself.\n\t * Steps that do not pass the condition are removed.\n\t */\n\tcondition?: (state: U) => boolean;\n\t[key: string]: any;\n};\nexport type WizardState<T extends Record<string, any>> = ReturnType<\n\ttypeof useWizard<T>\n>;\n\nconst regexMatchStep =\n\t/((step\\/)(?<step>[\\s\\S]+?)(?=[/?]))|((step\\/)(?<step2>[\\s\\S]+))/;\n/**\n * With a url that follows the rule xyz.com/anything/step/:nameofthestep[/?query]\n * will match the :nameofthestep substring\n */\nconst extractStepFromUrl = (url: string) => {\n\tconst match = url.match(regexMatchStep);\n\treturn match?.groups?.step ?? match?.groups?.step2 ?? null;\n};\nexport const useWizard = <T extends object>(params: {\n\t/**\n\t * The steps definition for the wizard\n\t */\n\tsteps: MaybeRef<Record<string, Step<T>>>;\n\t/**\n\t * Name of the wizard used to persist state\n\t */\n\tname: string;\n\t/**\n\t * Initial set of data to be made available throughout\n\t */\n\tinitialState: T;\n\t/**\n\t * When navogation is enabled, to whether use the query parameters or an entire substring of the URL like xyz/steps/....\n\t * The latter useful with nuxt so you can leverage the automatic import of components based on the URL.\n\t */\n\tnavigationMode?: 'query' | 'route';\n\t/**\n\t * Whether to use navigation at all. When disabled no query or URL is changed.\n\t */\n\tuseNavigation?: boolean;\n\t/**\n\t *\n\t */\n\tpersist?: boolean;\n}) => {\n\tif (!params.name) {\n\t\tthrow new Error(\n\t\t\t'You need to provide a unique name for the current wizard instance to be used to save data'\n\t\t);\n\t}\n\tconst route = useRoute();\n\tconst router = useRouter();\n\n\tconst useNavigation = params.useNavigation ?? true;\n\tconst navigationMode = params.navigationMode ?? 'query';\n\tconst persist = params.persist ?? true;\n\n\tif (useNavigation && (!route.value || !router)) {\n\t\tthrow new Error(\n\t\t\t'Navigation is enabled but could not retrieve the router instance in useWizard.'\n\t\t);\n\t}\n\n\tconst initialStateCopy = cloneDeep(params.initialState);\n\t/**\n\t * Initial state is either read from session storage or the one provided\n\t */\n\tconst innerState = reactive<typeof params.initialState>(\n\t\tpersist && sessionStorage.getItem(params.name)\n\t\t\t? {\n\t\t\t\t\t...initialStateCopy,\n\t\t\t\t\t...JSON.parse(sessionStorage.getItem(params.name)!),\n\t\t\t\t}\n\t\t\t: initialStateCopy\n\t);\n\n\tif (persist) {\n\t\t/**\n\t\t * Every time the state changes save it to sessionStorage\n\t\t */\n\t\twatch(innerState, () => {\n\t\t\tsessionStorage.setItem(params.name, JSON.stringify(innerState));\n\t\t});\n\t}\n\n\t/**\n\t * Steps can be passed as ref so we need to unwrap them\n\t */\n\tconst unwrappedSteps = toValue(params.steps);\n\tconst filteredSteps = computed(() =>\n\t\tObject.entries(unwrappedSteps).reduce(\n\t\t\t(acc: typeof unwrappedSteps, [key, step]) => {\n\t\t\t\tif (step.condition) {\n\t\t\t\t\tif (!step.condition(innerState as T)) {\n\t\t\t\t\t\treturn acc;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tacc[key] = { ...step, key };\n\t\t\t\treturn acc;\n\t\t\t},\n\t\t\t{}\n\t\t)\n\t);\n\n\t/**\n\t * Steps can have a isValid function that receives the current state\n\t * but we don't want to have to call it every single time so we call it once here\n\t */\n\tconst mappedSteps = computed(() =>\n\t\tmapValues(\n\t\t\tfilteredSteps.value,\n\t\t\t(step): Omit<Step<T>, 'isValid'> & { isValid: boolean } => {\n\t\t\t\tif (typeof step.isValid === 'function') {\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...step,\n\t\t\t\t\t\tisValid: step.isValid(innerState as T),\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\t...step,\n\t\t\t\t\tisValid: step.isValid ?? true,\n\t\t\t\t};\n\t\t\t}\n\t\t)\n\t);\n\n\t/**\n\t * Get the initial step from the query.\n\t * If it exists check that every step before it is also valid\n\t * so user cannot manually jump by changing the URL\n\t */\n\tlet initialStep = null;\n\tif (useNavigation && isNotNil(route.value)) {\n\t\tlet step: string | null = null;\n\t\tif (navigationMode === 'query') {\n\t\t\tif (route.value.query.step) {\n\t\t\t\tstep = route.value.query.step as string;\n\t\t\t}\n\t\t} else {\n\t\t\tconst stepFromUrl = extractStepFromUrl(route.value.fullPath);\n\t\t\tif (stepFromUrl) {\n\t\t\t\tstep = stepFromUrl;\n\t\t\t}\n\t\t}\n\t\tinitialStep = step;\n\t}\n\n\tif (initialStep) {\n\t\tfor (const stepName in filteredSteps.value) {\n\t\t\tif (stepName === initialStep) break;\n\t\t\tconst current = mappedSteps.value[stepName];\n\t\t\tif (!current || !current.isValid) {\n\t\t\t\tinitialStep = null;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\n\t/**\n\t * Define the state of the wizard\n\t * A few data come from useStepper\n\t */\n\tconst {\n\t\tsteps,\n\t\tcurrent,\n\t\tgoToNext,\n\t\tgoToPrevious,\n\t\tgoTo,\n\t\tindex,\n\t\tat,\n\t\tget,\n\t\tgoBackTo,\n\t\tisAfter,\n\t\tisBefore,\n\t\tisCurrent,\n\t\tisFirst,\n\t\tisLast,\n\t\tisNext,\n\t\tisPrevious,\n\t\tnext,\n\t\tprevious,\n\t\tstepNames,\n\t} = useStepper(\n\t\tmappedSteps,\n\t\tinitialStep || Object.values(filteredSteps.value)[0].key\n\t);\n\n\tconst key = computed(() => Object.keys(filteredSteps.value)[index.value]);\n\n\t/**\n\t * Complete state object\n\t */\n\tconst state = {\n\t\tat,\n\t\tcurrent: current as ComputedRef<Step<T> & { isValid: boolean }>,\n\t\tdata: innerState,\n\t\tget,\n\t\tgoBackTo,\n\t\tgoTo,\n\t\tgoToNext,\n\t\tgoToPrevious,\n\t\tisAfter,\n\t\tisBefore,\n\t\tisCurrent,\n\t\tisFirst,\n\t\tisLast,\n\t\tisNext,\n\t\tisPrevious,\n\t\tkey,\n\t\tnext,\n\t\tprevious,\n\t\tstepNames,\n\t\tsteps,\n\t};\n\n\tprovide(wizardInjectionKey, state);\n\n\tif (useNavigation) {\n\t\tif (navigationMode === 'query') {\n\t\t\t/**\n\t\t\t * Every time the current step changes update route\n\t\t\t */\n\t\t\twatch(\n\t\t\t\tkey,\n\t\t\t\t() => {\n\t\t\t\t\tif (isNotNil(router) && isNotNil(route.value)) {\n\t\t\t\t\t\trouter.push({\n\t\t\t\t\t\t\t...route,\n\t\t\t\t\t\t\tquery: { ...route.value.query, step: key.value ?? null },\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{ immediate: true }\n\t\t\t);\n\n\t\t\t/**\n\t\t\t * Every time the route changes align the current step to the route\n\t\t\t */\n\t\t\twatch(\n\t\t\t\t() => route.value?.query.step,\n\t\t\t\t(value) => {\n\t\t\t\t\tif (value) {\n\t\t\t\t\t\tconst stepAsString = value as string;\n\t\t\t\t\t\tif (stepAsString in filteredSteps.value) {\n\t\t\t\t\t\t\tconst stepAsKey = stepAsString;\n\t\t\t\t\t\t\tconst stepKeys = Object.keys(filteredSteps.value);\n\t\t\t\t\t\t\tconst stepsPriorToTarget = stepKeys.slice(\n\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\tstepKeys.indexOf(stepAsKey)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst allValid = stepsPriorToTarget.every(\n\t\t\t\t\t\t\t\t(key) => mappedSteps.value[key]?.isValid\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (allValid) {\n\t\t\t\t\t\t\t\tgoTo(stepAsKey);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst key = Object.keys(steps)[0];\n\t\t\t\t\t\tgoTo(key);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t} else {\n\t\t\tconst stepFromUrl = computed(() => {\n\t\t\t\tif (isNotNil(route.value)) {\n\t\t\t\t\treturn extractStepFromUrl(route.value.fullPath);\n\t\t\t\t}\n\t\t\t\treturn undefined;\n\t\t\t});\n\n\t\t\t/**\n\t\t\t * Every time the current step changes update route\n\t\t\t */\n\t\t\twatch(\n\t\t\t\tkey,\n\t\t\t\t(value) => {\n\t\t\t\t\tif (isNotNil(route.value) && isNotNil(router)) {\n\t\t\t\t\t\tif (route.value.path.includes('step')) {\n\t\t\t\t\t\t\trouter.push({\n\t\t\t\t\t\t\t\tquery: route.value.query,\n\t\t\t\t\t\t\t\tpath: route.value.path.replace(regexMatchStep, `step/${value}`),\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\trouter.push({\n\t\t\t\t\t\t\t\tquery: route.value.query,\n\t\t\t\t\t\t\t\t// Normalizes paths with / and without\n\t\t\t\t\t\t\t\tpath: (route.value.path + `/step/${value}`).replace('//', '/'),\n\t\t\t\t\t\t\t\treplace: true,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{ immediate: true, flush: 'post' }\n\t\t\t);\n\n\t\t\t/**\n\t\t\t * Every time the route changes align the current step to the route\n\t\t\t */\n\t\t\twatch(\n\t\t\t\t() => stepFromUrl.value,\n\t\t\t\t(value) => {\n\t\t\t\t\tif (value && value !== key.value) {\n\t\t\t\t\t\tconst stepAsString = value as string;\n\t\t\t\t\t\tif (stepAsString in filteredSteps.value) {\n\t\t\t\t\t\t\tconst stepAsKey = stepAsString;\n\t\t\t\t\t\t\tconst stepKeys = Object.keys(filteredSteps.value);\n\t\t\t\t\t\t\tconst stepsPriorToTarget = stepKeys.slice(\n\t\t\t\t\t\t\t\t0,\n\t\t\t\t\t\t\t\tstepKeys.indexOf(stepAsKey)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tconst allValid = stepsPriorToTarget.every(\n\t\t\t\t\t\t\t\t(key) => filteredSteps.value[key]?.isValid\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif (allValid) {\n\t\t\t\t\t\t\t\tgoTo(stepAsKey);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\n\t\t}\n\t}\n\n\treturn state;\n};\n"],"names":["wizardInjectionKey","regexMatchStep","extractStepFromUrl","url","match","_a","_b","useWizard","params","route","useRoute","router","useRouter","useNavigation","navigationMode","persist","initialStateCopy","cloneDeep","innerState","reactive","watch","unwrappedSteps","toValue","filteredSteps","computed","acc","key","step","mappedSteps","mapValues","initialStep","isNotNil","stepFromUrl","stepName","current","steps","goToNext","goToPrevious","goTo","index","at","get","goBackTo","isAfter","isBefore","isCurrent","isFirst","isLast","isNext","isPrevious","next","previ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BAAArB,EAA0B;AAAA;AAAA,cAAA,KAGnCiC,EAAKoB,CAAS;AAAA,YAEhB;AAAA,UACD;AAAA,QACD;AAAA,MAAA;AAAA,IAEF;AAGM,SAAAJ;AACR;"}
@@ -1 +1 @@
1
- {"version":3,"file":"index81.js","sources":["../src/components/BbProgress/BbProgress.vue?vue&type=script&setup=true&lang.ts"],"sourcesContent":["import { defineComponent as _defineComponent } from 'vue'\nimport { normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nimport { clamp } from \"@/utilities/functions/clamp\";\nimport { getAsPercentageBetween } from \"@/utilities/functions/percentage\";\nimport { computed } from \"vue\";\n\nexport type BbProgressProps = {\n /**\n * Used by v-model. It'a number contained between `min` and `max` that corresponds to the current value.\n */\n modelValue?: number | null;\n /**\n * Minimum value. Lower cap.\n */\n min?: number;\n /**\n * Maximum value. Upper cap.\n */\n max?: number;\n /**\n * Displays the component as vertical.\n */\n vertical?: boolean;\n}\n\n/**\n * You can get percentage between 250 and 370 and have it compute it automatically\n */\n\nexport default /*#__PURE__*/_defineComponent({\n __name: 'BbProgress',\n props: {\n modelValue: { default: 0 },\n min: { default: 0 },\n max: { default: 100 },\n vertical: { type: Boolean }\n },\n setup(__props: any) {\n\nconst props = __props;\n\nconst width = computed(() =>\n clamp(\n getAsPercentageBetween(props.modelValue || props.min, props.min, props.max),\n 0,\n 100\n )\n);\n\nreturn (_ctx: any,_cache: any) => {\n return (_openBlock(), _createElementBlock(\"div\", {\n class: _normalizeClass([\"bb-progress\", {\n 'bb-progress--vertical': _ctx.vertical,\n 'bb-progress--horizontal': !_ctx.vertical,\n }])\n }, [\n _createElementVNode(\"div\", {\n class: \"bb-progress-bar\",\n style: _normalizeStyle({ [_ctx.vertical ? 'height' : 'width']: width.value + '%' })\n }, null, 4)\n ], 2))\n}\n}\n\n})"],"names":["_sfc_main","_defineComponent","__props","props","width","computed","clamp","getAsPercentageBetween","_ctx","_cache","_openBlock","_createElementBlock","_normalizeClass","_createElementVNode","_normalizeStyle"],"mappings":";;;AA8BA,MAA4BA,IAAiBC,gBAAAA,EAAA;AAAA,EAC3C,QAAQ;AAAA,EACR,OAAO;AAAA,IACL,YAAY,EAAE,SAAS,EAAE;AAAA,IACzB,KAAK,EAAE,SAAS,EAAE;AAAA,IAClB,KAAK,EAAE,SAAS,IAAI;AAAA,IACpB,UAAU,EAAE,MAAM,QAAQ;AAAA,EAC5B;AAAA,EACA,MAAMC,GAAc;AAEtB,UAAMC,IAAQD,GAERE,IAAQC;AAAA,MAAS,MACrBC;AAAA,QACEC,EAAuBJ,EAAM,cAAcA,EAAM,KAAKA,EAAM,KAAKA,EAAM,GAAG;AAAA,QAC1E;AAAA,QACA;AAAA,MACF;AAAA,IAAA;AAGK,WAAA,CAACK,GAAUC,OACRC,EAAA,GAAcC,EAAoB,OAAO;AAAA,MAC/C,OAAOC,EAAgB,CAAC,eAAe;AAAA,QACrC,yBAAyBJ,EAAK;AAAA,QAC9B,2BAA2B,CAACA,EAAK;AAAA,MAAA,CAClC,CAAC;AAAA,IAAA,GACD;AAAA,MACDK,EAAoB,OAAO;AAAA,QACzB,OAAO;AAAA,QACP,OAAOC,EAAgB,EAAE,CAACN,EAAK,WAAW,WAAW,OAAO,GAAGJ,EAAM,QAAQ,KAAK;AAAA,MAAA,GACjF,MAAM,CAAC;AAAA,OACT,CAAC;AAAA,EAEN;AAEA,CAAC;"}
1
+ {"version":3,"file":"index81.js","sources":["../src/components/BbProgress/BbProgress.vue?vue&type=script&setup=true&lang.ts"],"sourcesContent":["import { defineComponent as _defineComponent } from 'vue'\nimport { normalizeStyle as _normalizeStyle, createElementVNode as _createElementVNode, normalizeClass as _normalizeClass, openBlock as _openBlock, createElementBlock as _createElementBlock } from \"vue\"\n\nimport { clamp } from '@/utilities/functions/clamp';\nimport { getAsPercentageBetween } from '@/utilities/functions/percentage';\nimport { computed } from 'vue';\n\nexport type BbProgressProps = {\n\t/**\n\t * Used by v-model. It'a number contained between `min` and `max` that corresponds to the current value.\n\t */\n\tmodelValue?: number | null;\n\t/**\n\t * Minimum value. Lower cap.\n\t */\n\tmin?: number;\n\t/**\n\t * Maximum value. Upper cap.\n\t */\n\tmax?: number;\n\t/**\n\t * Displays the component as vertical.\n\t */\n\tvertical?: boolean;\n};\n\n/**\n * You can get percentage between 250 and 370 and have it compute it automatically\n */\n\nexport default /*#__PURE__*/_defineComponent({\n __name: 'BbProgress',\n props: {\n modelValue: { default: 0 },\n min: { default: 0 },\n max: { default: 100 },\n vertical: { type: Boolean }\n },\n setup(__props: any) {\n\nconst props = __props;\n\nconst width = computed(() =>\n\tclamp(\n\t\tgetAsPercentageBetween(props.modelValue || props.min, props.min, props.max),\n\t\t0,\n\t\t100\n\t)\n);\n\nreturn (_ctx: any,_cache: any) => {\n return (_openBlock(), _createElementBlock(\"div\", {\n class: _normalizeClass([\"bb-progress\", {\n\t\t\t'bb-progress--vertical': _ctx.vertical,\n\t\t\t'bb-progress--horizontal': !_ctx.vertical,\n\t\t}])\n }, [\n _createElementVNode(\"div\", {\n class: \"bb-progress-bar\",\n style: _normalizeStyle({ [_ctx.vertical ? 'height' : 'width']: width.value + '%' })\n }, null, 4)\n ], 2))\n}\n}\n\n})"],"names":["_sfc_main","_defineComponent","__props","props","width","computed","clamp","getAsPercentageBetween","_ctx","_cache","_openBlock","_createElementBlock","_normalizeClass","_createElementVNode","_normalizeStyle"],"mappings":";;;AA8BA,MAA4BA,IAAiBC,gBAAAA,EAAA;AAAA,EAC3C,QAAQ;AAAA,EACR,OAAO;AAAA,IACL,YAAY,EAAE,SAAS,EAAE;AAAA,IACzB,KAAK,EAAE,SAAS,EAAE;AAAA,IAClB,KAAK,EAAE,SAAS,IAAI;AAAA,IACpB,UAAU,EAAE,MAAM,QAAQ;AAAA,EAC5B;AAAA,EACA,MAAMC,GAAc;AAEtB,UAAMC,IAAQD,GAERE,IAAQC;AAAA,MAAS,MACtBC;AAAA,QACCC,EAAuBJ,EAAM,cAAcA,EAAM,KAAKA,EAAM,KAAKA,EAAM,GAAG;AAAA,QAC1E;AAAA,QACA;AAAA,MACD;AAAA,IAAA;AAGM,WAAA,CAACK,GAAUC,OACRC,EAAA,GAAcC,EAAoB,OAAO;AAAA,MAC/C,OAAOC,EAAgB,CAAC,eAAe;AAAA,QACxC,yBAAyBJ,EAAK;AAAA,QAC9B,2BAA2B,CAACA,EAAK;AAAA,MAAA,CACjC,CAAC;AAAA,IAAA,GACC;AAAA,MACDK,EAAoB,OAAO;AAAA,QACzB,OAAO;AAAA,QACP,OAAOC,EAAgB,EAAE,CAACN,EAAK,WAAW,WAAW,OAAO,GAAGJ,EAAM,QAAQ,KAAK;AAAA,MAAA,GACjF,MAAM,CAAC;AAAA,OACT,CAAC;AAAA,EAEN;AAEA,CAAC;"}