@witchcraft/ui 0.3.26 → 0.4.0-beta.10

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 (287) hide show
  1. package/README.md +54 -61
  2. package/dist/module.json +1 -1
  3. package/dist/module.mjs +1 -1
  4. package/dist/runtime/assets/animations.css +1 -1
  5. package/dist/runtime/assets/locales/en.json +2 -0
  6. package/dist/runtime/build/WitchcraftUiResolver.js +2 -2
  7. package/dist/runtime/components/TestControls/TestControls.vue +3 -3
  8. package/dist/runtime/components/WButton/WButton.d.vue.ts +34 -0
  9. package/dist/runtime/components/{LibButton/LibButton.vue → WButton/WButton.vue} +26 -38
  10. package/dist/runtime/components/WButton/WButton.vue.d.ts +34 -0
  11. package/dist/runtime/components/WCheckbox/WCheckbox.d.vue.ts +33 -0
  12. package/dist/runtime/components/WCheckbox/WCheckbox.vue +110 -0
  13. package/dist/runtime/components/WCheckbox/WCheckbox.vue.d.ts +33 -0
  14. package/dist/runtime/components/WColorInput/WColorInput.d.vue.ts +45 -0
  15. package/dist/runtime/components/WColorInput/WColorInput.vue +85 -0
  16. package/dist/runtime/components/WColorInput/WColorInput.vue.d.ts +45 -0
  17. package/dist/runtime/components/WColorInput/WColorSwatchButton.d.vue.ts +28 -0
  18. package/dist/runtime/components/WColorInput/WColorSwatchButton.vue +86 -0
  19. package/dist/runtime/components/WColorInput/WColorSwatchButton.vue.d.ts +28 -0
  20. package/dist/runtime/components/{LibColorPicker/LibColorPicker.d.vue.ts → WColorPicker/WColorPicker.d.vue.ts} +7 -6
  21. package/dist/runtime/components/{LibColorPicker/LibColorPicker.vue → WColorPicker/WColorPicker.vue} +41 -29
  22. package/dist/runtime/components/{LibColorPicker/LibColorPicker.vue.d.ts → WColorPicker/WColorPicker.vue.d.ts} +7 -6
  23. package/dist/runtime/components/WCombobox/WCombobox.d.vue.ts +111 -0
  24. package/dist/runtime/components/WCombobox/WCombobox.vue +405 -0
  25. package/dist/runtime/components/WCombobox/WCombobox.vue.d.ts +111 -0
  26. package/dist/runtime/components/WCombobox/storyPlays.d.ts +18 -0
  27. package/dist/runtime/components/WCombobox/storyPlays.js +68 -0
  28. package/dist/runtime/components/{LibDarkModeSwitcher/LibDarkModeSwitcher.d.vue.ts → WDarkModeSwitcher/WDarkModeSwitcher.d.vue.ts} +8 -13
  29. package/dist/runtime/components/{LibDarkModeSwitcher/LibDarkModeSwitcher.vue → WDarkModeSwitcher/WDarkModeSwitcher.vue} +11 -14
  30. package/dist/runtime/components/{LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts → WDarkModeSwitcher/WDarkModeSwitcher.vue.d.ts} +8 -13
  31. package/dist/runtime/components/WDatePicker/WDatePicker.d.vue.ts +40 -0
  32. package/dist/runtime/components/{LibDatePicker/LibDatePicker.vue → WDatePicker/WDatePicker.vue} +3 -7
  33. package/dist/runtime/components/WDatePicker/WDatePicker.vue.d.ts +40 -0
  34. package/dist/runtime/components/{LibDatePicker/LibRangeDatePicker.vue → WDatePicker/WRangeDatePicker.vue} +21 -21
  35. package/dist/runtime/components/{LibDatePicker/LibSingleDatePicker.vue → WDatePicker/WSingleDatePicker.vue} +21 -21
  36. package/dist/runtime/components/{LibDatePicker/LibTimeZonePicker.d.vue.ts → WDatePicker/WTimeZonePicker.d.vue.ts} +1 -11
  37. package/dist/runtime/components/{LibDatePicker/LibTimeZonePicker.vue → WDatePicker/WTimeZonePicker.vue} +5 -12
  38. package/dist/runtime/components/{LibDatePicker/LibTimeZonePicker.vue.d.ts → WDatePicker/WTimeZonePicker.vue.d.ts} +1 -11
  39. package/dist/runtime/components/{LibDebug/LibDebug.vue → WDebug/WDebug.vue} +10 -12
  40. package/dist/runtime/components/{LibDevOnly/LibDevOnly.d.vue.ts → WDevOnly/WDevOnly.d.vue.ts} +0 -3
  41. package/dist/runtime/components/{LibDevOnly/LibDevOnly.vue.d.ts → WDevOnly/WDevOnly.vue.d.ts} +0 -3
  42. package/dist/runtime/components/WFileInput/WFileInput.d.vue.ts +58 -0
  43. package/dist/runtime/components/{LibFileInput/LibFileInput.vue → WFileInput/WFileInput.vue} +74 -57
  44. package/dist/runtime/components/WFileInput/WFileInput.vue.d.ts +58 -0
  45. package/dist/runtime/components/{Icon/Icon.vue.d.ts → WIcon/WIcon.d.vue.ts} +2 -6
  46. package/dist/runtime/components/{Icon/Icon.vue → WIcon/WIcon.vue} +1 -1
  47. package/dist/runtime/components/{Icon/Icon.d.vue.ts → WIcon/WIcon.vue.d.ts} +2 -6
  48. package/dist/runtime/components/{LibMultiValues/LibMultiValues.d.vue.ts → WMultiValues/WMultiValues.d.vue.ts} +8 -14
  49. package/dist/runtime/components/WMultiValues/WMultiValues.vue +150 -0
  50. package/dist/runtime/components/{LibMultiValues/LibMultiValues.vue.d.ts → WMultiValues/WMultiValues.vue.d.ts} +8 -14
  51. package/dist/runtime/components/WNotifications/WNotification.d.vue.ts +37 -0
  52. package/dist/runtime/components/{LibNotifications/LibNotification.vue → WNotifications/WNotification.vue} +34 -47
  53. package/dist/runtime/components/WNotifications/WNotification.vue.d.ts +37 -0
  54. package/dist/runtime/components/WNotifications/WNotifications.d.vue.ts +11 -0
  55. package/dist/runtime/components/{LibNotifications/LibNotifications.vue → WNotifications/WNotifications.vue} +35 -17
  56. package/dist/runtime/components/WNotifications/WNotifications.vue.d.ts +11 -0
  57. package/dist/runtime/components/WNumberInput/WNumberInput.d.vue.ts +27 -0
  58. package/dist/runtime/components/WNumberInput/WNumberInput.vue +96 -0
  59. package/dist/runtime/components/WNumberInput/WNumberInput.vue.d.ts +27 -0
  60. package/dist/runtime/components/WPagination/WPagination.d.vue.ts +59 -0
  61. package/dist/runtime/components/WPagination/WPagination.vue +182 -0
  62. package/dist/runtime/components/WPagination/WPagination.vue.d.ts +59 -0
  63. package/dist/runtime/components/WPalette/WPalette.d.vue.ts +11 -0
  64. package/dist/runtime/components/{LibPalette/LibPalette.vue → WPalette/WPalette.vue} +3 -8
  65. package/dist/runtime/components/WPalette/WPalette.vue.d.ts +11 -0
  66. package/dist/runtime/components/WPopover/WPopover.d.vue.ts +45 -0
  67. package/dist/runtime/components/WPopover/WPopover.vue +144 -0
  68. package/dist/runtime/components/WPopover/WPopover.vue.d.ts +45 -0
  69. package/dist/runtime/components/WPopup/WPopup.d.vue.ts +51 -0
  70. package/dist/runtime/components/WPopup/WPopup.vue +106 -0
  71. package/dist/runtime/components/WPopup/WPopup.vue.d.ts +51 -0
  72. package/dist/runtime/components/{LibProgressBar/LibProgressBar.d.vue.ts → WProgressBar/WProgressBar.d.vue.ts} +14 -18
  73. package/dist/runtime/components/WProgressBar/WProgressBar.vue +150 -0
  74. package/dist/runtime/components/{LibProgressBar/LibProgressBar.vue.d.ts → WProgressBar/WProgressBar.vue.d.ts} +14 -18
  75. package/dist/runtime/components/{LibRecorder/LibRecorder.d.vue.ts → WRecorder/WRecorder.d.vue.ts} +14 -29
  76. package/dist/runtime/components/{LibRecorder/LibRecorder.vue → WRecorder/WRecorder.vue} +37 -36
  77. package/dist/runtime/components/{LibRecorder/LibRecorder.vue.d.ts → WRecorder/WRecorder.vue.d.ts} +14 -29
  78. package/dist/runtime/components/{LibRoot/LibRoot.d.vue.ts → WRoot/WRoot.d.vue.ts} +6 -5
  79. package/dist/runtime/components/{LibRoot/LibRoot.vue → WRoot/WRoot.vue} +17 -15
  80. package/dist/runtime/components/{LibRoot/LibRoot.vue.d.ts → WRoot/WRoot.vue.d.ts} +6 -5
  81. package/dist/runtime/components/{LibSimpleInput/LibSimpleInput.d.vue.ts → WSimpleInput/WSimpleInput.d.vue.ts} +10 -16
  82. package/dist/runtime/components/{LibSimpleInput/LibSimpleInput.vue → WSimpleInput/WSimpleInput.vue} +14 -24
  83. package/dist/runtime/components/{LibSimpleInput/LibSimpleInput.vue.d.ts → WSimpleInput/WSimpleInput.vue.d.ts} +10 -16
  84. package/dist/runtime/components/WTable/WTable.d.vue.ts +102 -0
  85. package/dist/runtime/components/{LibTable/LibTable.vue → WTable/WTable.vue} +13 -14
  86. package/dist/runtime/components/WTable/WTable.vue.d.ts +102 -0
  87. package/dist/runtime/components/WTooltip/WTooltip.d.vue.ts +40 -0
  88. package/dist/runtime/components/WTooltip/WTooltip.vue +112 -0
  89. package/dist/runtime/components/WTooltip/WTooltip.vue.d.ts +40 -0
  90. package/dist/runtime/components/index.d.ts +20 -20
  91. package/dist/runtime/components/index.js +20 -20
  92. package/dist/runtime/composables/index.d.ts +4 -4
  93. package/dist/runtime/composables/index.js +4 -4
  94. package/dist/runtime/composables/useDelayedLoadingIndicator.d.ts +9 -0
  95. package/dist/runtime/composables/useDelayedLoadingIndicator.js +18 -0
  96. package/dist/runtime/composables/useDisplayForReka.d.ts +25 -0
  97. package/dist/runtime/composables/useDisplayForReka.js +16 -0
  98. package/dist/runtime/composables/useFallbackId.d.ts +3 -0
  99. package/dist/runtime/composables/useFallbackId.js +5 -0
  100. package/dist/runtime/composables/useInjectedDarkMode.d.ts +1 -1
  101. package/dist/runtime/composables/usePopupConstrainToStyle.d.ts +8 -0
  102. package/dist/runtime/composables/usePopupConstrainToStyle.js +8 -0
  103. package/dist/runtime/composables/useSetupDarkMode.d.ts +2 -3
  104. package/dist/runtime/composables/useSetupDarkMode.js +90 -4
  105. package/dist/runtime/helpers/NotificationHandler.d.ts +2 -2
  106. package/dist/runtime/injectionKeys.d.ts +1 -5
  107. package/dist/runtime/injectionKeys.js +0 -2
  108. package/dist/runtime/types/index.d.ts +85 -27
  109. package/dist/runtime/types/index.js +1 -0
  110. package/package.json +1 -1
  111. package/src/module.ts +1 -1
  112. package/src/runtime/assets/animations.css +3 -3
  113. package/src/runtime/assets/locales/en.json +2 -0
  114. package/src/runtime/build/WitchcraftUiResolver.ts +2 -2
  115. package/src/runtime/components/TestControls/TestControls.vue +3 -3
  116. package/src/runtime/components/WButton/WButton.stories.ts +112 -0
  117. package/src/runtime/components/{LibButton/LibButton.vue → WButton/WButton.vue} +34 -50
  118. package/src/runtime/components/{LibCheckbox/LibCheckbox.stories.ts → WCheckbox/WCheckbox.stories.ts} +5 -5
  119. package/src/runtime/components/WCheckbox/WCheckbox.vue +125 -0
  120. package/src/runtime/components/{LibColorInput/LibColorInput.stories.ts → WColorInput/WColorInput.stories.ts} +8 -8
  121. package/src/runtime/components/WColorInput/WColorInput.vue +112 -0
  122. package/src/runtime/components/WColorInput/WColorSwatchButton.vue +102 -0
  123. package/src/runtime/components/{LibColorPicker/LibColorPicker.stories.ts → WColorPicker/WColorPicker.stories.ts} +12 -12
  124. package/src/runtime/components/{LibColorPicker/LibColorPicker.vue → WColorPicker/WColorPicker.vue} +44 -31
  125. package/src/runtime/components/WCombobox/WCombobox.stories.ts +209 -0
  126. package/src/runtime/components/WCombobox/WCombobox.vue +450 -0
  127. package/src/runtime/components/WCombobox/storyPlays.ts +92 -0
  128. package/src/runtime/components/{LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts → WDarkModeSwitcher/WDarkModeSwitcher.stories.ts} +6 -6
  129. package/src/runtime/components/{LibDarkModeSwitcher/LibDarkModeSwitcher.vue → WDarkModeSwitcher/WDarkModeSwitcher.vue} +19 -30
  130. package/src/runtime/components/{LibDatePicker/LibDatePicker.stories.ts → WDatePicker/WDatePicker.stories.ts} +42 -34
  131. package/src/runtime/components/{LibDatePicker/LibDatePicker.vue → WDatePicker/WDatePicker.vue} +3 -7
  132. package/src/runtime/components/{LibDatePicker/LibRangeDatePicker.vue → WDatePicker/WRangeDatePicker.vue} +21 -21
  133. package/src/runtime/components/{LibDatePicker/LibSingleDatePicker.vue → WDatePicker/WSingleDatePicker.vue} +21 -21
  134. package/src/runtime/components/{LibDatePicker/LibTimeZonePicker.vue → WDatePicker/WTimeZonePicker.vue} +5 -12
  135. package/src/runtime/components/{LibDebug/LibDebug.stories.ts → WDebug/WDebug.stories.ts} +5 -5
  136. package/src/runtime/components/{LibDebug/LibDebug.vue → WDebug/WDebug.vue} +9 -10
  137. package/src/runtime/components/{LibDevOnly/LibDevOnly.vue → WDevOnly/WDevOnly.vue} +0 -4
  138. package/src/runtime/components/{LibFileInput/LibFileInput.stories.ts → WFileInput/WFileInput.stories.ts} +7 -7
  139. package/src/runtime/components/{LibFileInput/LibFileInput.vue → WFileInput/WFileInput.vue} +98 -97
  140. package/src/runtime/components/{Icon/Icon.vue → WIcon/WIcon.vue} +5 -8
  141. package/src/runtime/components/{LibMultiValues/LibMultiValues.stories.ts → WMultiValues/WMultiValues.stories.ts} +9 -9
  142. package/src/runtime/components/WMultiValues/WMultiValues.vue +163 -0
  143. package/src/runtime/components/{LibNotifications/LibNotification.stories.ts → WNotifications/WNotification.stories.ts} +9 -9
  144. package/src/runtime/components/{LibNotifications/LibNotification.vue → WNotifications/WNotification.vue} +45 -65
  145. package/src/runtime/components/WNotifications/WNotifications.stories.ts +139 -0
  146. package/src/runtime/components/{LibNotifications/LibNotifications.vue → WNotifications/WNotifications.vue} +51 -29
  147. package/src/runtime/components/WNumberInput/WNumberInput.vue +109 -0
  148. package/src/runtime/components/WPagination/WPagination.stories.ts +51 -0
  149. package/src/runtime/components/WPagination/WPagination.vue +207 -0
  150. package/src/runtime/components/{LibPalette/LibPalette.stories.ts → WPalette/WPalette.stories.ts} +6 -6
  151. package/src/runtime/components/{LibPalette/LibPalette.vue → WPalette/WPalette.vue} +3 -8
  152. package/src/runtime/components/WPopover/WPopover.stories.ts +218 -0
  153. package/src/runtime/components/WPopover/WPopover.vue +168 -0
  154. package/src/runtime/components/WPopup/WPopup.stories.ts +104 -0
  155. package/src/runtime/components/WPopup/WPopup.vue +125 -0
  156. package/src/runtime/components/WProgressBar/WProgressBar.stories.ts +119 -0
  157. package/src/runtime/components/WProgressBar/WProgressBar.vue +185 -0
  158. package/src/runtime/components/{LibRecorder/LibRecorder.stories.ts → WRecorder/WRecorder.stories.ts} +9 -6
  159. package/src/runtime/components/{LibRecorder/LibRecorder.vue → WRecorder/WRecorder.vue} +69 -68
  160. package/src/runtime/components/{LibRoot/LibRoot.vue → WRoot/WRoot.vue} +18 -15
  161. package/src/runtime/components/{LibSimpleInput/LibSimpleInput.stories.ts → WSimpleInput/WSimpleInput.stories.ts} +11 -12
  162. package/src/runtime/components/{LibSimpleInput/LibSimpleInput.vue → WSimpleInput/WSimpleInput.vue} +28 -44
  163. package/src/runtime/components/{LibTable/LibTable.stories.ts → WTable/WTable.stories.ts} +60 -52
  164. package/src/runtime/components/{LibTable/LibTable.vue → WTable/WTable.vue} +85 -88
  165. package/src/runtime/components/WTooltip/WTooltip.stories.ts +82 -0
  166. package/src/runtime/components/WTooltip/WTooltip.vue +128 -0
  167. package/src/runtime/components/index.ts +20 -20
  168. package/src/runtime/composables/index.ts +4 -4
  169. package/src/runtime/composables/useDelayedLoadingIndicator.ts +30 -0
  170. package/src/runtime/composables/useDisplayForReka.ts +37 -0
  171. package/src/runtime/composables/useFallbackId.ts +6 -0
  172. package/src/runtime/composables/useInjectedDarkMode.ts +1 -2
  173. package/src/runtime/composables/usePopupConstrainToStyle.ts +29 -0
  174. package/src/runtime/composables/useSetupDarkMode.ts +122 -4
  175. package/src/runtime/helpers/NotificationHandler.ts +2 -2
  176. package/src/runtime/injectionKeys.ts +1 -7
  177. package/src/runtime/types/index.ts +105 -32
  178. package/types/components.d.ts +14 -15
  179. package/dist/runtime/components/Aria/Aria.d.vue.ts +0 -6
  180. package/dist/runtime/components/Aria/Aria.vue +0 -16
  181. package/dist/runtime/components/Aria/Aria.vue.d.ts +0 -6
  182. package/dist/runtime/components/LibButton/LibButton.d.vue.ts +0 -37
  183. package/dist/runtime/components/LibButton/LibButton.vue.d.ts +0 -37
  184. package/dist/runtime/components/LibCheckbox/LibCheckbox.d.vue.ts +0 -41
  185. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +0 -103
  186. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +0 -41
  187. package/dist/runtime/components/LibColorInput/LibColorInput.d.vue.ts +0 -64
  188. package/dist/runtime/components/LibColorInput/LibColorInput.vue +0 -162
  189. package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +0 -64
  190. package/dist/runtime/components/LibDatePicker/LibDatePicker.d.vue.ts +0 -191
  191. package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +0 -191
  192. package/dist/runtime/components/LibFileInput/LibFileInput.d.vue.ts +0 -46
  193. package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +0 -46
  194. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.d.vue.ts +0 -256
  195. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +0 -387
  196. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +0 -256
  197. package/dist/runtime/components/LibLabel/LibLabel.d.vue.ts +0 -27
  198. package/dist/runtime/components/LibLabel/LibLabel.vue +0 -45
  199. package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +0 -27
  200. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +0 -109
  201. package/dist/runtime/components/LibNotifications/LibNotification.d.vue.ts +0 -45
  202. package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +0 -45
  203. package/dist/runtime/components/LibNotifications/LibNotifications.d.vue.ts +0 -15
  204. package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +0 -15
  205. package/dist/runtime/components/LibPagination/LibPagination.d.vue.ts +0 -105
  206. package/dist/runtime/components/LibPagination/LibPagination.vue +0 -229
  207. package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +0 -105
  208. package/dist/runtime/components/LibPalette/LibPalette.d.vue.ts +0 -15
  209. package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +0 -15
  210. package/dist/runtime/components/LibPopup/LibPopup.d.vue.ts +0 -52
  211. package/dist/runtime/components/LibPopup/LibPopup.vue +0 -365
  212. package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +0 -52
  213. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +0 -169
  214. package/dist/runtime/components/LibSuggestions/LibSuggestions.d.vue.ts +0 -99
  215. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +0 -178
  216. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +0 -99
  217. package/dist/runtime/components/LibTable/LibTable.d.vue.ts +0 -125
  218. package/dist/runtime/components/LibTable/LibTable.vue.d.ts +0 -125
  219. package/dist/runtime/components/Template/NAME.d.vue.ts +0 -18
  220. package/dist/runtime/components/Template/NAME.vue +0 -27
  221. package/dist/runtime/components/Template/NAME.vue.d.ts +0 -18
  222. package/dist/runtime/components/Template/TemplateStory.d.ts +0 -7
  223. package/dist/runtime/components/Template/TemplateStory.js +0 -22
  224. package/dist/runtime/components/shared/props.d.ts +0 -171
  225. package/dist/runtime/components/shared/props.js +0 -2
  226. package/dist/runtime/composables/useAriaLabel.d.ts +0 -6
  227. package/dist/runtime/composables/useAriaLabel.js +0 -15
  228. package/dist/runtime/composables/useDarkMode.d.ts +0 -77
  229. package/dist/runtime/composables/useDarkMode.js +0 -89
  230. package/dist/runtime/composables/useDivideAttrs.d.ts +0 -27
  231. package/dist/runtime/composables/useDivideAttrs.js +0 -27
  232. package/dist/runtime/composables/useSuggestions.d.ts +0 -40
  233. package/dist/runtime/composables/useSuggestions.js +0 -263
  234. package/src/runtime/components/Aria/Aria.vue +0 -26
  235. package/src/runtime/components/LibButton/LibButton.stories.ts +0 -106
  236. package/src/runtime/components/LibCheckbox/LibCheckbox.vue +0 -131
  237. package/src/runtime/components/LibColorInput/LibColorInput.vue +0 -203
  238. package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.ts +0 -405
  239. package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +0 -419
  240. package/src/runtime/components/LibLabel/LibLabel.stories.ts +0 -33
  241. package/src/runtime/components/LibLabel/LibLabel.vue +0 -65
  242. package/src/runtime/components/LibMultiValues/LibMultiValues.vue +0 -123
  243. package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +0 -131
  244. package/src/runtime/components/LibPagination/LibPagination.stories.ts +0 -49
  245. package/src/runtime/components/LibPagination/LibPagination.vue +0 -274
  246. package/src/runtime/components/LibPopup/LibPopup.stories.ts +0 -153
  247. package/src/runtime/components/LibPopup/LibPopup.vue +0 -396
  248. package/src/runtime/components/LibProgressBar/LibProgressBar.stories.ts +0 -90
  249. package/src/runtime/components/LibProgressBar/LibProgressBar.vue +0 -197
  250. package/src/runtime/components/LibSuggestions/LibSuggestions.stories.ts +0 -134
  251. package/src/runtime/components/LibSuggestions/LibSuggestions.vue +0 -212
  252. package/src/runtime/components/Template/NAME.vue +0 -49
  253. package/src/runtime/components/Template/TemplateStory.ts +0 -37
  254. package/src/runtime/components/shared/props.ts +0 -199
  255. package/src/runtime/composables/useAriaLabel.ts +0 -23
  256. package/src/runtime/composables/useDarkMode.ts +0 -199
  257. package/src/runtime/composables/useDivideAttrs.ts +0 -53
  258. package/src/runtime/composables/useSuggestions.ts +0 -339
  259. /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToHsva.d.ts +0 -0
  260. /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToHsva.js +0 -0
  261. /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToRgba.d.ts +0 -0
  262. /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToRgba.js +0 -0
  263. /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/toLowPrecisionRgbaString.d.ts +0 -0
  264. /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/toLowPrecisionRgbaString.js +0 -0
  265. /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/truncate.d.ts +0 -0
  266. /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/truncate.js +0 -0
  267. /package/dist/runtime/components/{LibDatePicker/LibRangeDatePicker.d.vue.ts → WDatePicker/WRangeDatePicker.d.vue.ts} +0 -0
  268. /package/dist/runtime/components/{LibDatePicker/LibRangeDatePicker.vue.d.ts → WDatePicker/WRangeDatePicker.vue.d.ts} +0 -0
  269. /package/dist/runtime/components/{LibDatePicker/LibSingleDatePicker.d.vue.ts → WDatePicker/WSingleDatePicker.d.vue.ts} +0 -0
  270. /package/dist/runtime/components/{LibDatePicker/LibSingleDatePicker.vue.d.ts → WDatePicker/WSingleDatePicker.vue.d.ts} +0 -0
  271. /package/dist/runtime/components/{LibDatePicker → WDatePicker}/helpers.d.ts +0 -0
  272. /package/dist/runtime/components/{LibDatePicker → WDatePicker}/helpers.js +0 -0
  273. /package/dist/runtime/components/{LibDebug/LibDebug.d.vue.ts → WDebug/WDebug.d.vue.ts} +0 -0
  274. /package/dist/runtime/components/{LibDebug/LibDebug.vue.d.ts → WDebug/WDebug.vue.d.ts} +0 -0
  275. /package/dist/runtime/components/{LibDevOnly/LibDevOnly.vue → WDevOnly/WDevOnly.vue} +0 -0
  276. /package/dist/runtime/components/{LibNotifications/LibNotificationTestMessageComponent.d.vue.ts → WNotifications/WNotificationTestMessageComponent.d.vue.ts} +0 -0
  277. /package/dist/runtime/components/{LibNotifications/LibNotificationTestMessageComponent.vue → WNotifications/WNotificationTestMessageComponent.vue} +0 -0
  278. /package/dist/runtime/components/{LibNotifications/LibNotificationTestMessageComponent.vue.d.ts → WNotifications/WNotificationTestMessageComponent.vue.d.ts} +0 -0
  279. /package/dist/runtime/components/{LibNotifications → WNotifications}/calculateNotificationProgress.d.ts +0 -0
  280. /package/dist/runtime/components/{LibNotifications → WNotifications}/calculateNotificationProgress.js +0 -0
  281. /package/src/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToHsva.ts +0 -0
  282. /package/src/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToRgba.ts +0 -0
  283. /package/src/runtime/components/{LibColorPicker → WColorPicker}/utils/toLowPrecisionRgbaString.ts +0 -0
  284. /package/src/runtime/components/{LibColorPicker → WColorPicker}/utils/truncate.ts +0 -0
  285. /package/src/runtime/components/{LibDatePicker → WDatePicker}/helpers.ts +0 -0
  286. /package/src/runtime/components/{LibNotifications/LibNotificationTestMessageComponent.vue → WNotifications/WNotificationTestMessageComponent.vue} +0 -0
  287. /package/src/runtime/components/{LibNotifications → WNotifications}/calculateNotificationProgress.ts +0 -0
@@ -1,199 +0,0 @@
1
- import { computed, nextTick, onMounted, provide, type Ref, ref, watch } from "vue"
2
-
3
- import { darkModeCommandsInjectionKey, darkModeStateInjectionKey, isDarkModeInjectionKey, manualDarkModeInjectionKey } from "../injectionKeys.js"
4
-
5
- const defaultLocalStorageKey = "prefersColorSchemeDark"
6
- const defaultOrder = ["system", "dark", "light"] as const
7
-
8
- /**
9
- * @deprecated Use `useSetupDarkMode` instead.
10
- *
11
- * A composable for setting up dark mode that automatically takes care of saving the user's preference.
12
- *
13
- * See the returned utilities for more details.
14
- *
15
- * It also provides injection keys with a ref so it can be accessed in deep nested components if needed. Alternatively you can use `useInjectedDarkMode` for ease of use.
16
- *
17
- * Note that this should only be called once at the root of the app.
18
- */
19
- export const useDarkMode = ({
20
- useLocalStorage = true,
21
- darkModeOrder = defaultOrder,
22
-
23
- isClientSide = true,
24
- useViewTransition = true
25
- }: DarkModeOptions = {}): DarkModeState & DarkModeCommands => {
26
- const systemDarkMode = ref(false)
27
- const manualDarkMode = ref<boolean | undefined>(undefined)
28
-
29
- if (useLocalStorage && isClientSide) {
30
- watch(manualDarkMode, () => {
31
- localStorage.setItem(defaultLocalStorageKey, manualDarkMode.value ? "true" : "false")
32
- })
33
- }
34
-
35
- const darkMode = computed(() => manualDarkMode.value ?? systemDarkMode.value)
36
- const darkModeState = computed(() =>
37
- manualDarkMode.value === undefined
38
- ? "system"
39
- : manualDarkMode.value
40
- ? "dark"
41
- : "light"
42
- )
43
- // todo move to useinjected
44
- function setDarkMode(value: "dark" | "light" | "system"): void {
45
- manualDarkMode.value
46
- = value === "dark"
47
- ? true
48
- : value === "light"
49
- ? false
50
- : undefined
51
- }
52
-
53
- function getNextValue(): "dark" | "light" | "system" {
54
- const index = darkModeOrder.indexOf(darkModeState.value)
55
-
56
- return index === 2
57
- ? darkModeOrder[0]!
58
- : darkModeOrder[index + 1]!
59
- }
60
-
61
- function _cycleDarkMode(): void {
62
- setDarkMode(getNextValue())
63
- }
64
-
65
- function cycleDarkMode(): void {
66
- if (!useViewTransition) {
67
- _cycleDarkMode()
68
- return
69
- }
70
- const nextValue = getNextValue()
71
- const index = darkModeOrder.indexOf(darkModeState.value)
72
- const systemDarkModeName = systemDarkMode.value ? "dark" : "light"
73
-
74
- if (nextValue === "system" && systemDarkModeName === darkModeOrder[index]) {
75
- // don't do view transitions if we're not really transitioning
76
- _cycleDarkMode()
77
- return
78
- }
79
- if (!document.startViewTransition) _cycleDarkMode()
80
- document.startViewTransition(async () => {
81
- _cycleDarkMode()
82
- await nextTick()
83
- })
84
- }
85
-
86
- onMounted(() => {
87
- window.matchMedia("(prefers-color-scheme: dark)")
88
- .addEventListener("change", ({ matches }) => {
89
- if (matches) {
90
- systemDarkMode.value = true
91
- } else {
92
- systemDarkMode.value = false
93
- }
94
- })
95
- if (useLocalStorage !== false) {
96
- const key = typeof useLocalStorage === "string" ? useLocalStorage : defaultLocalStorageKey
97
- const value = localStorage.getItem(key)
98
-
99
- if (value === "true") {
100
- manualDarkMode.value = true
101
- } else if (value === "false") {
102
- manualDarkMode.value = false
103
- }
104
- }
105
- })
106
- provide(isDarkModeInjectionKey, darkMode)
107
- provide(manualDarkModeInjectionKey, manualDarkMode)
108
-
109
- provide(darkModeStateInjectionKey, {
110
- darkMode,
111
- darkModeState,
112
- manualDarkMode,
113
- systemDarkMode
114
- })
115
- provide(darkModeCommandsInjectionKey, {
116
- setDarkMode,
117
- cycleDarkMode
118
- })
119
-
120
- return {
121
- darkMode,
122
- darkModeState,
123
- setDarkMode,
124
- cycleDarkMode,
125
- manualDarkMode,
126
- systemDarkMode
127
- }
128
- }
129
- export const defaultDarkModeOrder = defaultOrder
130
-
131
-
132
- export type DarkModeOptions = {
133
- /* Whether to save the manual dark mode to local storage. Uses the key "prefersColorSchemeDark" by default. You can pass a key instead of true to use that as the key instead. */
134
- useLocalStorage?: boolean | string
135
- /* The order of the string dark modes when using `cycleDarkMode`. Defaults to `["system", "dark", "light"]` */
136
- darkModeOrder?: readonly ("system" | "dark" | "light")[]
137
- /** True by default, should be passed import.meta.client if using nuxt, or false when running server side. */
138
- isClientSide?: boolean
139
- /**
140
- * Whether to use the view transition to animate the dark mode switch (you just need to add the css).
141
- *
142
- * Note that the transitition is NOT triggered if visually the mode does not change (e.g. system mode is dark and the user switches from system to dark, visually nothing changes so transitioning is skipped).
143
- *
144
- * There is an example in storybook. But basically:
145
- *
146
- * ```css
147
- *
148
- * #root { // the dark mode switcher works on the WRoot component not the html root
149
- * view-transition-name: wroot;
150
- * height: 100dvh;
151
- * padding: 0;
152
- * }
153
- *
154
- * ::view-transition-new(wroot) {
155
- * animation: grow var(--story-anim-length) ease-in-out;
156
- * animation-fill-mode: both;
157
- * z-index: 2;
158
- * mask: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40"><circle cx="20" cy="20" r="20" fill="white"/></svg>') center / 0 no-repeat;
159
- * }
160
- *
161
- * ::view-transition-old(wroot) {
162
- * animation: none;
163
- * animation-fill-mode: both;
164
- * z-index: 1;
165
- * }
166
- *
167
- * @keyframes grow {
168
- * from {
169
- * mask-size: 0dvw;
170
- * }
171
- * to {
172
- * mask-size: 300dvw;
173
- * }
174
- * }
175
- * ```
176
- *
177
- * See https://theme-toggle.rdsx.dev/ for more ideas.
178
- *
179
- * @default true
180
- */
181
- useViewTransition?: boolean
182
- }
183
-
184
- export interface DarkModeCommands {
185
- setDarkMode: (value: "dark" | "light" | "system") => void
186
- cycleDarkMode: () => void
187
- }
188
-
189
- export interface DarkModeState {
190
- /** Whether the dark mode should be enabled or not */
191
- darkMode: Ref<boolean>
192
- /** The current state of the darkMode but as a string (dark, light, system) */
193
- darkModeState: Ref<"dark" | "light" | "system">
194
- /** The value of the manuably controllable dark mode. You can set this to true/false or undefined to allow the systemDarkMode to take priority. Alternatively use setDarkMode instead. */
195
- manualDarkMode: Ref<boolean | undefined>
196
- /** The value of the system dark mode. This is automatically set depending on the user's `prefer-color-scheme` and should not be set directly. */
197
- systemDarkMode: Ref<boolean>
198
-
199
- }
@@ -1,53 +0,0 @@
1
- import { keys } from "@alanscodelog/utils/keys"
2
- import { computed, type Ref, useAttrs } from "vue"
3
-
4
- /**
5
- * Allows users to more easily pass attributes to different parts of a component. Suppose a component has an input and a wrapper and you want most attributes to go to the input, but any that start with `wrapper` to go to the wrapper.
6
- *
7
- * You can do:
8
- *
9
- * ```ts
10
- * const extraAttrs = useDivideAttrs(["wrapper"] as const)
11
- * ```
12
- * This will correctly remove the start of the key. So if the user passes:
13
- * ```vue
14
- * <your-component regular-attr wrapper-attr wrapperAttrs/>
15
- * ```
16
- * You will get a ref like:
17
- *
18
- * ```ts
19
- * extraAttrs.value = {
20
- * attrs: { regular-attr: true },
21
- * wrapperAttrs: { attr: true, Attrs: true },
22
- * }
23
- *
24
- * Additionally attributes are properly reactive, tough this is probably a bit expensive given they weren't meant to be reactive.
25
- *
26
- * Note that if using multi-word prefixes, like `inner-wrapper`, they will appear as the key `inner-wrapperAttrs` internally, but users will be able to correctly pass `inner-wrapper-prop`. Aditionally these can be passed down to deeper components, allowing easy wrapping.
27
- * ```
28
- */
29
- export const useDivideAttrs = <T extends readonly string[]>(divisionKeys: T): Ref<Record<`${T[number]}Attrs` | "attrs", Record<string, any>>> => computed(() => {
30
- const attrs: Record<string, any> = useAttrs()
31
- const res: any = { attrs: {} }
32
- const unseen = keys(attrs)
33
- for (const key of divisionKeys) {
34
- res[`${key}Attrs`] = {}
35
- for (let i = 0; i < unseen.length; i++) {
36
- const attrKey = unseen[i]
37
- if (!attrKey) continue
38
- if (attrKey.startsWith(`${key}-`)) {
39
- res[`${key}Attrs`][attrKey.slice(key.length + 1)] = attrs[attrKey]
40
- unseen.splice(i, 1)
41
- i--
42
- } else if (attrKey.startsWith(key)) {
43
- res[`${key}Attrs`][attrKey.slice(key.length)] = attrs[attrKey]
44
- unseen.splice(i, 1)
45
- i--
46
- }
47
- }
48
- }
49
- for (const attrKey of unseen) {
50
- res.attrs[attrKey] = attrs[attrKey]
51
- }
52
- return res
53
- })
@@ -1,339 +0,0 @@
1
- /* eslint-disable no-console */
2
- import type { AnyFunction } from "@alanscodelog/utils"
3
- import { isBlank } from "@alanscodelog/utils/isBlank"
4
- import { isObject } from "@alanscodelog/utils/isObject"
5
- import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn"
6
- import { removeIfIn } from "@alanscodelog/utils/removeIfIn"
7
- import { computed, type Ref, ref, toRaw, watch } from "vue"
8
-
9
- import type { SuggestionsEmits, SuggestionsOptions } from "../components/shared/props.js"
10
-
11
- /**
12
- * The logic for the suggestions component.
13
- *
14
- * Note that while object suggestions are supported, the `suggestionLabel` prop is required and $inputModel and $modelValue will still be string values (as returned by the suggestionLabel function).
15
- */
16
-
17
- export function useSuggestions<TSuggestion, TMultivalue extends boolean = false>(
18
- $inputValue: Ref<string>,
19
- $modelValue: Ref<TMultivalue extends true ? string[] : string>,
20
- $open: Ref<boolean>,
21
- emit: SuggestionsEmits,
22
- opts: SuggestionsOptions<TSuggestion>,
23
- debug: boolean = false
24
- ) {
25
- if (typeof opts.suggestions?.[0] === "object" && !opts.suggestionLabel && !opts.suggestionsFilter) {
26
- throw new Error("`suggestionLabel` or `suggestionsFilter` must be passed if suggestions are objects.")
27
- }
28
-
29
- const activeSuggestion = ref(-1)
30
- watch(activeSuggestion, val => { emit("update:activeSuggestion", val) })
31
- if (opts.suggestions) {
32
- for (const suggestion of opts.suggestions) {
33
- suggestionLabelGuard(suggestion, opts.suggestionLabel)
34
- }
35
- }
36
-
37
- const getSuggestionLabel = (item: any): string => {
38
- suggestionLabelGuard(item, opts.suggestionLabel)
39
- if (isObject<any>(item)) {
40
- return opts.suggestionLabel!(item)
41
- }
42
- return item
43
- }
44
-
45
- const defaultSuggestionsFilter = (input: string, items: TSuggestion[]): TSuggestion[] => input === ""
46
- ? [...items]
47
- : items.filter(item => {
48
- if (Array.isArray($modelValue.value)) {
49
- // always include selected values for unselecting
50
- if ($modelValue.value.includes(getSuggestionLabel(item))) return true
51
- }
52
- return getSuggestionLabel(item).toLowerCase().includes(input.toLowerCase())
53
- })
54
- const suggestionsFilter = computed(() => opts.suggestionsFilter ?? defaultSuggestionsFilter)
55
-
56
- const suggestionsList = computed(() => {
57
- if (opts.suggestions) {
58
- const suggestions = [...opts.suggestions]
59
- if (Array.isArray($modelValue.value) && !opts.showSelectedValues) {
60
- pushIfNotIn(suggestions, $modelValue.value)
61
- }
62
- const res = suggestionsFilter.value($inputValue.value, suggestions)
63
- return res
64
- }
65
- return undefined
66
- })
67
-
68
- const suggestionAvailable = computed<boolean>(() =>
69
- (suggestionsList.value?.length ?? 0) > 0)
70
-
71
- const moreThanOneSuggestionAvailable = computed<boolean>(() =>
72
- (suggestionsList.value?.length ?? 0) > 1)
73
-
74
- const exactlyMatchingSuggestion = computed(() =>
75
- opts.suggestions?.find(suggestion =>
76
- $inputValue.value === getSuggestionLabel(suggestion)))
77
-
78
- const isValidSuggestion = computed(() =>
79
- ((!opts.restrictToSuggestions && opts.isValid) || suggestionAvailable.value))
80
-
81
- const openable = computed(() =>
82
- opts.canOpen && (
83
- (isBlank($inputValue.value) && opts.allowOpenEmpty)
84
- || suggestionAvailable.value
85
-
86
- )
87
- )
88
-
89
- const filteredSuggestions = computed(() => {
90
- if (opts.suggestions) {
91
- const res = (suggestionAvailable.value
92
- ? suggestionsList.value!
93
- : opts.suggestions!)
94
-
95
- if (opts.restrictToSuggestions && !isValidSuggestion.value) return res
96
- return res
97
- }
98
- return undefined
99
- })
100
-
101
- // methods
102
- // returns true if the value was removed
103
- function setValue(val: string): boolean {
104
- if (Array.isArray($modelValue.value)) {
105
- // works like a toggle
106
- if ($modelValue.value.includes(val)) {
107
- removeIfIn($modelValue.value, val)
108
- return true
109
- } else {
110
- pushIfNotIn($modelValue.value, [val])
111
- }
112
- } else {
113
- ($modelValue.value as string) = val
114
- }
115
- return false
116
- }
117
-
118
- function closeSuggestions(): void {
119
- if (!opts.canClose) return
120
- if (debug) console.log("closeSuggestions")
121
- $open.value = false
122
- activeSuggestion.value = -1
123
- }
124
- function openSuggestions(): void {
125
- if (debug) console.log("openSuggestions", { openable: openable.value })
126
- if (!openable.value) return
127
- if (activeSuggestion.value === -1) {
128
- if (exactlyMatchingSuggestion.value) {
129
- activeSuggestion.value = suggestionsList.value?.indexOf(exactlyMatchingSuggestion.value) ?? -1
130
- } else {
131
- activeSuggestion.value = 0
132
- }
133
- }
134
- $open.value = true
135
- }
136
-
137
- function enterSuggestion(num: number, doClose: boolean = true): void {
138
- if (num < -1 || num > (filteredSuggestions.value?.length ?? 0)) return
139
- if (debug) console.log("enterSuggestion", num)
140
- if (filteredSuggestions.value === undefined) return
141
-
142
- const suggestion = filteredSuggestions.value[num]
143
- const val = getSuggestionLabel(suggestion)
144
- const wasRemoved = setValue(val)
145
- $inputValue.value = Array.isArray($modelValue.value) ? "" : getSuggestionLabel(suggestion)
146
- if (doClose) {
147
- closeSuggestions()
148
- }
149
- emit("submit", val, toRaw(suggestion), wasRemoved)
150
- }
151
-
152
- function enterSelected(doClose: boolean = true): void {
153
- if (activeSuggestion.value === -1) {
154
- if (!opts.restrictToSuggestions) {
155
- if (debug) console.log("enterSelected, unrestricted, emitting submit")
156
- emit("submit", $inputValue.value)
157
- } else {
158
- if (debug) console.log("enterSelected, no active suggestion, ignoring")
159
- }
160
- return
161
- }
162
- if (debug) console.log("enterSelected")
163
- enterSuggestion(activeSuggestion.value, doClose)
164
- }
165
-
166
- function selectSuggestion(num: number): void {
167
- if (debug) console.log("selectSuggestion", num)
168
- if (num >= -1) {
169
- activeSuggestion.value = num
170
- }
171
- if (num === Infinity && (filteredSuggestions.value?.length ?? 0) > 0) {
172
- activeSuggestion.value = filteredSuggestions.value!.length - 1
173
- }
174
- }
175
-
176
- function toggleSuggestions(): void {
177
- $open.value ? closeSuggestions() : openSuggestions()
178
- }
179
-
180
- function prevSuggestion(): void {
181
- if (!filteredSuggestions.value) return
182
- if (activeSuggestion.value > 0) {
183
- activeSuggestion.value--
184
- } else if (filteredSuggestions.value) {
185
- activeSuggestion.value = filteredSuggestions.value.length - 1
186
- }
187
- }
188
-
189
- function nextSuggestion(): void {
190
- if (!filteredSuggestions.value) return
191
- if (activeSuggestion.value >= filteredSuggestions.value.length - 1) {
192
- activeSuggestion.value = 0
193
- } else {
194
- activeSuggestion.value++
195
- }
196
- }
197
- function firstSuggestion(): void {
198
- selectSuggestion(0)
199
- }
200
- function lastSuggestion(): void {
201
- selectSuggestion(Infinity)
202
- }
203
-
204
- function cancel(): void {
205
- if (Array.isArray($modelValue.value)) {
206
- $inputValue.value = ""
207
- return
208
- }
209
- if (debug) console.log("cancel")
210
- $inputValue.value = getSuggestionLabel($modelValue.value)
211
- closeSuggestions()
212
- }
213
-
214
- watch(() => opts.canOpen, val => {
215
- if (!val) {
216
- if (debug) console.log("canOpen changed to false, closing suggestions")
217
- closeSuggestions()
218
- }
219
- })
220
-
221
- watch(openable, val => {
222
- if (!val) {
223
- if (debug) console.log("openable changed to false, closing suggestions")
224
- closeSuggestions()
225
- }
226
- })
227
-
228
- watch(isValidSuggestion, () => {
229
- if (!isValidSuggestion.value) {
230
- if (debug) console.log("isValidSuggestion changed to false, opening suggestions")
231
- openSuggestions()
232
- }
233
- })
234
-
235
- // sync vmodels and vmodel effects
236
-
237
- watch($modelValue, () => {
238
- if (Array.isArray($modelValue.value)) {
239
- $inputValue.value = ""
240
- } else {
241
- $inputValue.value = getSuggestionLabel($modelValue.value)
242
- }
243
- if (debug) console.log("modelValue changed")
244
- })
245
-
246
- function defaultSuggestionSelector(suggestions: TSuggestion[], input: string): number {
247
- if (input.length === 0) return 0
248
- let longestMatch
249
- let ii = -1
250
- for (let i = 0; i < suggestions.length; i++) {
251
- const suggestion = suggestions[i]
252
- const label = getSuggestionLabel(suggestion)
253
- const labelPart = label.slice(0, input.length)
254
- if (labelPart === input) {
255
- if (label.length > (longestMatch?.[0]?.length ?? 0)) {
256
- longestMatch = label
257
- ii = i
258
- }
259
- }
260
- }
261
- return ii
262
- }
263
-
264
- watch($inputValue, () => {
265
- if (debug) console.log("input changed:", $inputValue.value, "modelValue:", $modelValue.value)
266
- if (!Array.isArray($modelValue.value) && getSuggestionLabel($modelValue.value) === $inputValue.value) return
267
-
268
- if (suggestionAvailable.value) {
269
- if (debug) console.log("input changed, suggestion available, opening suggestions")
270
- openSuggestions()
271
- }
272
-
273
- if (!opts.restrictToSuggestions && !Array.isArray($modelValue.value)) {
274
- if (debug) console.log("input changed, unrestricted, setting modelValue")
275
- setValue($inputValue.value)
276
- }
277
- if (exactlyMatchingSuggestion.value && suggestionsList.value) {
278
- if (debug) console.log("input changed, exactly matching, setting activeSuggestion")
279
- selectSuggestion(suggestionsList.value.indexOf(exactlyMatchingSuggestion.value))
280
- } else {
281
- if (debug) console.log("input changed, not exactly matching, finding longest match")
282
-
283
- const i
284
- = opts.suggestionSelector?.(filteredSuggestions.value ?? [], $inputValue.value)
285
- ?? defaultSuggestionSelector(filteredSuggestions.value ?? [], $inputValue.value)
286
-
287
- selectSuggestion(i)
288
- }
289
- })
290
-
291
- return {
292
- list: suggestionsList,
293
- filtered: filteredSuggestions,
294
- active: activeSuggestion,
295
- available: suggestionAvailable,
296
- moreThanOneAvailable: moreThanOneSuggestionAvailable,
297
- hasExactlyMatching: exactlyMatchingSuggestion,
298
- /** Whether there is a valid suggestion that can be submitted. If `restrictToSuggestions` is true, this will be true if isValid is true, otherwise this is considered to be true if suggestions are available. */
299
- hasValidSuggestion: isValidSuggestion,
300
- openable,
301
- getLabel: getSuggestionLabel,
302
- $open,
303
- open: openSuggestions,
304
- close: closeSuggestions,
305
- enterSelected,
306
- enterIndex: enterSuggestion,
307
- toggle: toggleSuggestions,
308
- cancel,
309
- select: selectSuggestion,
310
- prev: prevSuggestion,
311
- next: nextSuggestion,
312
- first: firstSuggestion,
313
- last: lastSuggestion
314
-
315
- }
316
- }
317
-
318
- export function useSuggestionsInputAria(
319
- id: Ref<string>,
320
- $open: Ref<boolean>,
321
- activeSuggestion: Ref<number>,
322
- suggestions: Ref<any | undefined>
323
- ) {
324
- const ariaInputProps = computed(() => ({
325
- "aria-autocomplete": suggestions !== undefined ? "both" as const : undefined,
326
- "aria-controls": suggestions !== undefined ? `suggestions-${id.value}` : undefined,
327
- role: suggestions ? "combobox" : undefined,
328
- "aria-expanded": suggestions !== undefined ? $open.value : undefined,
329
- "aria-activedescendant": $open.value ? `suggestion-${id.value}-${activeSuggestion.value}` : undefined
330
- }))
331
- return ariaInputProps
332
- }
333
- export function suggestionLabelGuard<TFunction extends AnyFunction>(item: any, suggestionLabeler: TFunction | undefined): asserts suggestionLabeler is TFunction {
334
- if (isObject<any>(item)) {
335
- if (!suggestionLabeler) {
336
- throw new Error("`suggestionLabel` must be passed if suggestions are objects.")
337
- }
338
- }
339
- }