@witchcraft/ui 0.4.0 → 0.4.2

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 (316) hide show
  1. package/README.md +56 -61
  2. package/dist/module.d.mts +1 -1
  3. package/dist/module.json +1 -1
  4. package/dist/module.mjs +13 -9
  5. package/dist/runtime/assets/animations.css +1 -1
  6. package/dist/runtime/assets/locales/en.json +2 -0
  7. package/dist/runtime/assets/utils.css +1 -1
  8. package/dist/runtime/build/WitchcraftUiResolver.js +1 -2
  9. package/dist/runtime/components/TestControls/TestControls.d.vue.ts +2 -1
  10. package/dist/runtime/components/TestControls/TestControls.vue +3 -3
  11. package/dist/runtime/components/TestControls/TestControls.vue.d.ts +2 -1
  12. package/dist/runtime/components/WButton/WButton.d.vue.ts +34 -0
  13. package/dist/runtime/components/{LibButton/LibButton.vue → WButton/WButton.vue} +26 -38
  14. package/dist/runtime/components/WButton/WButton.vue.d.ts +34 -0
  15. package/dist/runtime/components/WCheckbox/WCheckbox.d.vue.ts +33 -0
  16. package/dist/runtime/components/WCheckbox/WCheckbox.vue +110 -0
  17. package/dist/runtime/components/WCheckbox/WCheckbox.vue.d.ts +33 -0
  18. package/dist/runtime/components/{LibColorInput/LibColorInput.d.vue.ts → WColorInput/WColorInput.d.vue.ts} +18 -36
  19. package/dist/runtime/components/WColorInput/WColorInput.vue +85 -0
  20. package/dist/runtime/components/{LibColorInput/LibColorInput.vue.d.ts → WColorInput/WColorInput.vue.d.ts} +18 -36
  21. package/dist/runtime/components/WColorInput/WColorSwatchButton.d.vue.ts +28 -0
  22. package/dist/runtime/components/WColorInput/WColorSwatchButton.vue +86 -0
  23. package/dist/runtime/components/WColorInput/WColorSwatchButton.vue.d.ts +28 -0
  24. package/dist/runtime/components/{LibColorPicker/LibColorPicker.d.vue.ts → WColorPicker/WColorPicker.d.vue.ts} +12 -9
  25. package/dist/runtime/components/{LibColorPicker/LibColorPicker.vue → WColorPicker/WColorPicker.vue} +41 -29
  26. package/dist/runtime/components/{LibColorPicker/LibColorPicker.vue.d.ts → WColorPicker/WColorPicker.vue.d.ts} +12 -9
  27. package/dist/runtime/components/WCombobox/WCombobox.d.vue.ts +111 -0
  28. package/dist/runtime/components/WCombobox/WCombobox.vue +405 -0
  29. package/dist/runtime/components/WCombobox/WCombobox.vue.d.ts +111 -0
  30. package/dist/runtime/components/WCombobox/storyPlays.d.ts +18 -0
  31. package/dist/runtime/components/WCombobox/storyPlays.js +68 -0
  32. package/dist/runtime/components/{LibDarkModeSwitcher/LibDarkModeSwitcher.d.vue.ts → WDarkModeSwitcher/WDarkModeSwitcher.d.vue.ts} +9 -13
  33. package/dist/runtime/components/{LibDarkModeSwitcher/LibDarkModeSwitcher.vue → WDarkModeSwitcher/WDarkModeSwitcher.vue} +11 -14
  34. package/dist/runtime/components/{LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts → WDarkModeSwitcher/WDarkModeSwitcher.vue.d.ts} +9 -13
  35. package/dist/runtime/components/{LibDatePicker/LibDatePicker.d.vue.ts → WDatePicker/WDatePicker.d.vue.ts} +7 -7
  36. package/dist/runtime/components/{LibDatePicker/LibDatePicker.vue → WDatePicker/WDatePicker.vue} +3 -7
  37. package/dist/runtime/components/{LibDatePicker/LibDatePicker.vue.d.ts → WDatePicker/WDatePicker.vue.d.ts} +7 -7
  38. package/dist/runtime/components/WDatePicker/WRangeDatePicker.d.vue.ts +182 -0
  39. package/dist/runtime/components/{LibDatePicker/LibRangeDatePicker.vue → WDatePicker/WRangeDatePicker.vue} +29 -25
  40. package/dist/runtime/components/WDatePicker/WRangeDatePicker.vue.d.ts +182 -0
  41. package/dist/runtime/components/{LibDatePicker/LibSingleDatePicker.d.vue.ts → WDatePicker/WSingleDatePicker.d.vue.ts} +7 -5
  42. package/dist/runtime/components/{LibDatePicker/LibSingleDatePicker.vue → WDatePicker/WSingleDatePicker.vue} +21 -21
  43. package/dist/runtime/components/{LibDatePicker/LibSingleDatePicker.vue.d.ts → WDatePicker/WSingleDatePicker.vue.d.ts} +7 -5
  44. package/dist/runtime/components/WDatePicker/WTimeZonePicker.d.vue.ts +13 -0
  45. package/dist/runtime/components/{LibDatePicker/LibTimeZonePicker.vue → WDatePicker/WTimeZonePicker.vue} +5 -12
  46. package/dist/runtime/components/WDatePicker/WTimeZonePicker.vue.d.ts +13 -0
  47. package/dist/runtime/components/{LibDebug/LibDebug.d.vue.ts → WDebug/WDebug.d.vue.ts} +3 -2
  48. package/dist/runtime/components/{LibDebug/LibDebug.vue → WDebug/WDebug.vue} +10 -12
  49. package/dist/runtime/components/{LibDebug/LibDebug.vue.d.ts → WDebug/WDebug.vue.d.ts} +3 -2
  50. package/dist/runtime/components/{LibDevOnly/LibDevOnly.d.vue.ts → WDevOnly/WDevOnly.d.vue.ts} +3 -5
  51. package/dist/runtime/components/{LibDevOnly/LibDevOnly.vue.d.ts → WDevOnly/WDevOnly.vue.d.ts} +3 -5
  52. package/dist/runtime/components/WFileInput/WFileInput.d.vue.ts +58 -0
  53. package/dist/runtime/components/WFileInput/WFileInput.vue +348 -0
  54. package/dist/runtime/components/WFileInput/WFileInput.vue.d.ts +58 -0
  55. package/dist/runtime/components/WIcon/WIcon.d.vue.ts +18 -0
  56. package/dist/runtime/components/{Icon/Icon.vue → WIcon/WIcon.vue} +1 -1
  57. package/dist/runtime/components/WIcon/WIcon.vue.d.ts +18 -0
  58. package/dist/runtime/components/WMultiValues/WMultiValues.d.vue.ts +28 -0
  59. package/dist/runtime/components/WMultiValues/WMultiValues.vue +150 -0
  60. package/dist/runtime/components/WMultiValues/WMultiValues.vue.d.ts +28 -0
  61. package/dist/runtime/components/WNotifications/WNotification.d.vue.ts +37 -0
  62. package/dist/runtime/components/{LibNotifications/LibNotification.vue → WNotifications/WNotification.vue} +61 -35
  63. package/dist/runtime/components/WNotifications/WNotification.vue.d.ts +37 -0
  64. package/dist/runtime/components/WNotifications/WNotificationTestMessageComponent.d.vue.ts +7 -0
  65. package/dist/runtime/components/WNotifications/WNotificationTestMessageComponent.vue +29 -0
  66. package/dist/runtime/components/WNotifications/WNotificationTestMessageComponent.vue.d.ts +7 -0
  67. package/dist/runtime/components/WNotifications/WNotifications.d.vue.ts +11 -0
  68. package/dist/runtime/components/{LibNotifications/LibNotifications.vue → WNotifications/WNotifications.vue} +72 -36
  69. package/dist/runtime/components/WNotifications/WNotifications.vue.d.ts +11 -0
  70. package/dist/runtime/components/WNotifications/calculateNotificationProgress.d.ts +2 -0
  71. package/dist/runtime/components/WNotifications/calculateNotificationProgress.js +4 -0
  72. package/dist/runtime/components/WNumberInput/WNumberInput.d.vue.ts +27 -0
  73. package/dist/runtime/components/WNumberInput/WNumberInput.vue +96 -0
  74. package/dist/runtime/components/WNumberInput/WNumberInput.vue.d.ts +27 -0
  75. package/dist/runtime/components/WPagination/WPagination.d.vue.ts +59 -0
  76. package/dist/runtime/components/WPagination/WPagination.vue +182 -0
  77. package/dist/runtime/components/WPagination/WPagination.vue.d.ts +59 -0
  78. package/dist/runtime/components/WPalette/WPalette.d.vue.ts +11 -0
  79. package/dist/runtime/components/{LibPalette/LibPalette.vue → WPalette/WPalette.vue} +3 -8
  80. package/dist/runtime/components/WPalette/WPalette.vue.d.ts +11 -0
  81. package/dist/runtime/components/WPopover/WPopover.d.vue.ts +45 -0
  82. package/dist/runtime/components/WPopover/WPopover.vue +144 -0
  83. package/dist/runtime/components/WPopover/WPopover.vue.d.ts +45 -0
  84. package/dist/runtime/components/WPopup/WPopup.d.vue.ts +51 -0
  85. package/dist/runtime/components/WPopup/WPopup.vue +115 -0
  86. package/dist/runtime/components/WPopup/WPopup.vue.d.ts +51 -0
  87. package/dist/runtime/components/{LibProgressBar/LibProgressBar.d.vue.ts → WProgressBar/WProgressBar.d.vue.ts} +13 -16
  88. package/dist/runtime/components/WProgressBar/WProgressBar.vue +150 -0
  89. package/dist/runtime/components/{LibProgressBar/LibProgressBar.vue.d.ts → WProgressBar/WProgressBar.vue.d.ts} +13 -16
  90. package/dist/runtime/components/{LibRecorder/LibRecorder.d.vue.ts → WRecorder/WRecorder.d.vue.ts} +13 -27
  91. package/dist/runtime/components/{LibRecorder/LibRecorder.vue → WRecorder/WRecorder.vue} +37 -36
  92. package/dist/runtime/components/{LibRecorder/LibRecorder.vue.d.ts → WRecorder/WRecorder.vue.d.ts} +13 -27
  93. package/dist/runtime/components/{LibRoot/LibRoot.d.vue.ts → WRoot/WRoot.d.vue.ts} +11 -9
  94. package/dist/runtime/components/{LibRoot/LibRoot.vue → WRoot/WRoot.vue} +17 -15
  95. package/dist/runtime/components/{LibRoot/LibRoot.vue.d.ts → WRoot/WRoot.vue.d.ts} +11 -9
  96. package/dist/runtime/components/WSimpleInput/WSimpleInput.d.vue.ts +34 -0
  97. package/dist/runtime/components/{LibSimpleInput/LibSimpleInput.vue → WSimpleInput/WSimpleInput.vue} +14 -24
  98. package/dist/runtime/components/WSimpleInput/WSimpleInput.vue.d.ts +34 -0
  99. package/dist/runtime/components/WTable/WTable.d.vue.ts +102 -0
  100. package/dist/runtime/components/WTable/WTable.vue +370 -0
  101. package/dist/runtime/components/WTable/WTable.vue.d.ts +102 -0
  102. package/dist/runtime/components/WTooltip/WTooltip.d.vue.ts +40 -0
  103. package/dist/runtime/components/WTooltip/WTooltip.vue +112 -0
  104. package/dist/runtime/components/WTooltip/WTooltip.vue.d.ts +40 -0
  105. package/dist/runtime/components/index.d.ts +20 -20
  106. package/dist/runtime/components/index.js +20 -20
  107. package/dist/runtime/composables/index.d.ts +4 -4
  108. package/dist/runtime/composables/index.js +4 -4
  109. package/dist/runtime/composables/useDelayedLoadingIndicator.d.ts +9 -0
  110. package/dist/runtime/composables/useDelayedLoadingIndicator.js +18 -0
  111. package/dist/runtime/composables/useDisplayForReka.d.ts +25 -0
  112. package/dist/runtime/composables/useDisplayForReka.js +16 -0
  113. package/dist/runtime/composables/useFallbackId.d.ts +3 -0
  114. package/dist/runtime/composables/useFallbackId.js +5 -0
  115. package/dist/runtime/composables/useInjectedDarkMode.d.ts +1 -1
  116. package/dist/runtime/composables/usePopupConstrainToStyle.d.ts +8 -0
  117. package/dist/runtime/composables/usePopupConstrainToStyle.js +8 -0
  118. package/dist/runtime/composables/useSetupDarkMode.d.ts +2 -3
  119. package/dist/runtime/composables/useSetupDarkMode.js +90 -4
  120. package/dist/runtime/composables/useTimeConditionally.d.ts +16 -0
  121. package/dist/runtime/composables/useTimeConditionally.js +27 -0
  122. package/dist/runtime/directives/vResizableCols.js +101 -34
  123. package/dist/runtime/helpers/NotificationHandler.d.ts +28 -3
  124. package/dist/runtime/helpers/NotificationHandler.js +7 -10
  125. package/dist/runtime/injectionKeys.d.ts +1 -5
  126. package/dist/runtime/injectionKeys.js +0 -2
  127. package/dist/runtime/types/index.d.ts +97 -31
  128. package/dist/runtime/types/index.js +1 -0
  129. package/dist/runtime/utils/notifyIfError.d.ts +3 -1
  130. package/dist/runtime/utils/notifyIfError.js +4 -2
  131. package/dist/runtime/utils/twMerge.d.ts +1 -0
  132. package/dist/runtime/utils/twMerge.js +2 -1
  133. package/package.json +59 -56
  134. package/src/module.ts +16 -8
  135. package/src/runtime/assets/animations.css +53 -6
  136. package/src/runtime/assets/locales/en.json +2 -0
  137. package/src/runtime/assets/tailwind.css +1 -1
  138. package/src/runtime/assets/utils.css +52 -4
  139. package/src/runtime/build/WitchcraftUiResolver.ts +1 -2
  140. package/src/runtime/components/TestControls/TestControls.vue +3 -3
  141. package/src/runtime/components/WButton/WButton.stories.ts +112 -0
  142. package/src/runtime/components/{LibButton/LibButton.vue → WButton/WButton.vue} +34 -50
  143. package/src/runtime/components/{LibCheckbox/LibCheckbox.stories.ts → WCheckbox/WCheckbox.stories.ts} +5 -5
  144. package/src/runtime/components/WCheckbox/WCheckbox.vue +125 -0
  145. package/src/runtime/components/{LibColorInput/LibColorInput.stories.ts → WColorInput/WColorInput.stories.ts} +8 -8
  146. package/src/runtime/components/WColorInput/WColorInput.vue +112 -0
  147. package/src/runtime/components/WColorInput/WColorSwatchButton.vue +102 -0
  148. package/src/runtime/components/{LibColorPicker/LibColorPicker.stories.ts → WColorPicker/WColorPicker.stories.ts} +12 -12
  149. package/src/runtime/components/{LibColorPicker/LibColorPicker.vue → WColorPicker/WColorPicker.vue} +44 -31
  150. package/src/runtime/components/WCombobox/WCombobox.stories.ts +209 -0
  151. package/src/runtime/components/WCombobox/WCombobox.vue +450 -0
  152. package/src/runtime/components/WCombobox/storyPlays.ts +92 -0
  153. package/src/runtime/components/{LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts → WDarkModeSwitcher/WDarkModeSwitcher.stories.ts} +6 -6
  154. package/src/runtime/components/{LibDarkModeSwitcher/LibDarkModeSwitcher.vue → WDarkModeSwitcher/WDarkModeSwitcher.vue} +19 -30
  155. package/src/runtime/components/{LibDatePicker/LibDatePicker.stories.ts → WDatePicker/WDatePicker.stories.ts} +42 -34
  156. package/src/runtime/components/{LibDatePicker/LibDatePicker.vue → WDatePicker/WDatePicker.vue} +3 -7
  157. package/src/runtime/components/{LibDatePicker/LibRangeDatePicker.vue → WDatePicker/WRangeDatePicker.vue} +29 -25
  158. package/src/runtime/components/{LibDatePicker/LibSingleDatePicker.vue → WDatePicker/WSingleDatePicker.vue} +21 -21
  159. package/src/runtime/components/{LibDatePicker/LibTimeZonePicker.vue → WDatePicker/WTimeZonePicker.vue} +5 -12
  160. package/src/runtime/components/{LibDebug/LibDebug.stories.ts → WDebug/WDebug.stories.ts} +5 -5
  161. package/src/runtime/components/{LibDebug/LibDebug.vue → WDebug/WDebug.vue} +9 -10
  162. package/src/runtime/components/{LibDevOnly/LibDevOnly.vue → WDevOnly/WDevOnly.vue} +0 -4
  163. package/src/runtime/components/{LibFileInput/LibFileInput.stories.ts → WFileInput/WFileInput.stories.ts} +20 -10
  164. package/src/runtime/components/WFileInput/WFileInput.vue +392 -0
  165. package/src/runtime/components/{Icon/Icon.vue → WIcon/WIcon.vue} +5 -8
  166. package/src/runtime/components/{LibMultiValues/LibMultiValues.stories.ts → WMultiValues/WMultiValues.stories.ts} +9 -9
  167. package/src/runtime/components/WMultiValues/WMultiValues.vue +163 -0
  168. package/src/runtime/components/{LibNotifications/LibNotification.stories.ts → WNotifications/WNotification.stories.ts} +42 -6
  169. package/src/runtime/components/{LibNotifications/LibNotification.vue → WNotifications/WNotification.vue} +72 -45
  170. package/src/runtime/components/WNotifications/WNotificationTestMessageComponent.vue +27 -0
  171. package/src/runtime/components/WNotifications/WNotifications.stories.ts +139 -0
  172. package/src/runtime/components/{LibNotifications/LibNotifications.vue → WNotifications/WNotifications.vue} +87 -47
  173. package/src/runtime/components/WNotifications/calculateNotificationProgress.ts +8 -0
  174. package/src/runtime/components/WNumberInput/WNumberInput.vue +109 -0
  175. package/src/runtime/components/WPagination/WPagination.stories.ts +51 -0
  176. package/src/runtime/components/WPagination/WPagination.vue +207 -0
  177. package/src/runtime/components/{LibPalette/LibPalette.stories.ts → WPalette/WPalette.stories.ts} +6 -6
  178. package/src/runtime/components/{LibPalette/LibPalette.vue → WPalette/WPalette.vue} +3 -8
  179. package/src/runtime/components/WPopover/WPopover.stories.ts +218 -0
  180. package/src/runtime/components/WPopover/WPopover.vue +168 -0
  181. package/src/runtime/components/WPopup/WPopup.stories.ts +104 -0
  182. package/src/runtime/components/WPopup/WPopup.vue +134 -0
  183. package/src/runtime/components/WProgressBar/WProgressBar.stories.ts +119 -0
  184. package/src/runtime/components/WProgressBar/WProgressBar.vue +185 -0
  185. package/src/runtime/components/{LibRecorder/LibRecorder.stories.ts → WRecorder/WRecorder.stories.ts} +9 -6
  186. package/src/runtime/components/{LibRecorder/LibRecorder.vue → WRecorder/WRecorder.vue} +69 -68
  187. package/src/runtime/components/{LibRoot/LibRoot.vue → WRoot/WRoot.vue} +18 -15
  188. package/src/runtime/components/{LibSimpleInput/LibSimpleInput.stories.ts → WSimpleInput/WSimpleInput.stories.ts} +11 -12
  189. package/src/runtime/components/{LibSimpleInput/LibSimpleInput.vue → WSimpleInput/WSimpleInput.vue} +28 -42
  190. package/src/runtime/components/WTable/WTable.stories.ts +334 -0
  191. package/src/runtime/components/WTable/WTable.vue +471 -0
  192. package/src/runtime/components/WTooltip/WTooltip.stories.ts +82 -0
  193. package/src/runtime/components/WTooltip/WTooltip.vue +128 -0
  194. package/src/runtime/components/index.ts +20 -20
  195. package/src/runtime/composables/index.ts +4 -4
  196. package/src/runtime/composables/useDelayedLoadingIndicator.ts +30 -0
  197. package/src/runtime/composables/useDisplayForReka.ts +37 -0
  198. package/src/runtime/composables/useFallbackId.ts +6 -0
  199. package/src/runtime/composables/useInjectedDarkMode.ts +1 -2
  200. package/src/runtime/composables/usePopupConstrainToStyle.ts +29 -0
  201. package/src/runtime/composables/useSetupDarkMode.ts +122 -4
  202. package/src/runtime/composables/useTimeConditionally.ts +51 -0
  203. package/src/runtime/directives/vResizableCols.ts +121 -38
  204. package/src/runtime/helpers/NotificationHandler.ts +30 -11
  205. package/src/runtime/injectionKeys.ts +1 -7
  206. package/src/runtime/types/index.ts +118 -36
  207. package/src/runtime/utils/notifyIfError.ts +6 -2
  208. package/src/runtime/utils/twMerge.ts +2 -1
  209. package/types/components.d.ts +14 -15
  210. package/dist/runtime/components/Aria/Aria.d.vue.ts +0 -5
  211. package/dist/runtime/components/Aria/Aria.vue +0 -16
  212. package/dist/runtime/components/Aria/Aria.vue.d.ts +0 -5
  213. package/dist/runtime/components/Icon/Icon.d.vue.ts +0 -21
  214. package/dist/runtime/components/Icon/Icon.vue.d.ts +0 -21
  215. package/dist/runtime/components/LibButton/LibButton.d.vue.ts +0 -36
  216. package/dist/runtime/components/LibButton/LibButton.vue.d.ts +0 -36
  217. package/dist/runtime/components/LibCheckbox/LibCheckbox.d.vue.ts +0 -42
  218. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +0 -103
  219. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +0 -42
  220. package/dist/runtime/components/LibColorInput/LibColorInput.vue +0 -162
  221. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.d.vue.ts +0 -34
  222. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +0 -34
  223. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.d.vue.ts +0 -22
  224. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +0 -22
  225. package/dist/runtime/components/LibFileInput/LibFileInput.d.vue.ts +0 -43
  226. package/dist/runtime/components/LibFileInput/LibFileInput.vue +0 -274
  227. package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +0 -43
  228. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.d.vue.ts +0 -165
  229. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +0 -387
  230. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +0 -165
  231. package/dist/runtime/components/LibLabel/LibLabel.d.vue.ts +0 -26
  232. package/dist/runtime/components/LibLabel/LibLabel.vue +0 -45
  233. package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +0 -26
  234. package/dist/runtime/components/LibMultiValues/LibMultiValues.d.vue.ts +0 -29
  235. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +0 -109
  236. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +0 -29
  237. package/dist/runtime/components/LibNotifications/LibNotification.d.vue.ts +0 -30
  238. package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +0 -30
  239. package/dist/runtime/components/LibNotifications/LibNotifications.d.vue.ts +0 -13
  240. package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +0 -13
  241. package/dist/runtime/components/LibPagination/LibPagination.d.vue.ts +0 -104
  242. package/dist/runtime/components/LibPagination/LibPagination.vue +0 -229
  243. package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +0 -104
  244. package/dist/runtime/components/LibPalette/LibPalette.d.vue.ts +0 -14
  245. package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +0 -14
  246. package/dist/runtime/components/LibPopup/LibPopup.d.vue.ts +0 -46
  247. package/dist/runtime/components/LibPopup/LibPopup.vue +0 -365
  248. package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +0 -46
  249. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +0 -169
  250. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.d.vue.ts +0 -35
  251. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +0 -35
  252. package/dist/runtime/components/LibSuggestions/LibSuggestions.d.vue.ts +0 -94
  253. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +0 -178
  254. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +0 -94
  255. package/dist/runtime/components/LibTable/LibTable.d.vue.ts +0 -45
  256. package/dist/runtime/components/LibTable/LibTable.vue +0 -155
  257. package/dist/runtime/components/LibTable/LibTable.vue.d.ts +0 -45
  258. package/dist/runtime/components/Template/NAME.d.vue.ts +0 -17
  259. package/dist/runtime/components/Template/NAME.vue +0 -27
  260. package/dist/runtime/components/Template/NAME.vue.d.ts +0 -17
  261. package/dist/runtime/components/Template/TemplateStory.d.ts +0 -7
  262. package/dist/runtime/components/Template/TemplateStory.js +0 -22
  263. package/dist/runtime/components/shared/props.d.ts +0 -171
  264. package/dist/runtime/components/shared/props.js +0 -2
  265. package/dist/runtime/composables/useAriaLabel.d.ts +0 -6
  266. package/dist/runtime/composables/useAriaLabel.js +0 -15
  267. package/dist/runtime/composables/useDarkMode.d.ts +0 -77
  268. package/dist/runtime/composables/useDarkMode.js +0 -89
  269. package/dist/runtime/composables/useDivideAttrs.d.ts +0 -27
  270. package/dist/runtime/composables/useDivideAttrs.js +0 -27
  271. package/dist/runtime/composables/useSuggestions.d.ts +0 -40
  272. package/dist/runtime/composables/useSuggestions.js +0 -263
  273. package/src/runtime/components/Aria/Aria.vue +0 -26
  274. package/src/runtime/components/LibButton/LibButton.stories.ts +0 -106
  275. package/src/runtime/components/LibCheckbox/LibCheckbox.vue +0 -129
  276. package/src/runtime/components/LibColorInput/LibColorInput.vue +0 -203
  277. package/src/runtime/components/LibFileInput/LibFileInput.vue +0 -320
  278. package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.ts +0 -405
  279. package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +0 -414
  280. package/src/runtime/components/LibLabel/LibLabel.stories.ts +0 -33
  281. package/src/runtime/components/LibLabel/LibLabel.vue +0 -65
  282. package/src/runtime/components/LibMultiValues/LibMultiValues.vue +0 -123
  283. package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +0 -120
  284. package/src/runtime/components/LibPagination/LibPagination.stories.ts +0 -49
  285. package/src/runtime/components/LibPagination/LibPagination.vue +0 -274
  286. package/src/runtime/components/LibPopup/LibPopup.stories.ts +0 -153
  287. package/src/runtime/components/LibPopup/LibPopup.vue +0 -396
  288. package/src/runtime/components/LibProgressBar/LibProgressBar.stories.ts +0 -90
  289. package/src/runtime/components/LibProgressBar/LibProgressBar.vue +0 -197
  290. package/src/runtime/components/LibSuggestions/LibSuggestions.stories.ts +0 -134
  291. package/src/runtime/components/LibSuggestions/LibSuggestions.vue +0 -212
  292. package/src/runtime/components/LibTable/LibTable.stories.ts +0 -167
  293. package/src/runtime/components/LibTable/LibTable.vue +0 -190
  294. package/src/runtime/components/Template/NAME.vue +0 -49
  295. package/src/runtime/components/Template/TemplateStory.ts +0 -37
  296. package/src/runtime/components/shared/props.ts +0 -199
  297. package/src/runtime/composables/useAriaLabel.ts +0 -23
  298. package/src/runtime/composables/useDarkMode.ts +0 -199
  299. package/src/runtime/composables/useDivideAttrs.ts +0 -53
  300. package/src/runtime/composables/useSuggestions.ts +0 -339
  301. /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToHsva.d.ts +0 -0
  302. /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToHsva.js +0 -0
  303. /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToRgba.d.ts +0 -0
  304. /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToRgba.js +0 -0
  305. /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/toLowPrecisionRgbaString.d.ts +0 -0
  306. /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/toLowPrecisionRgbaString.js +0 -0
  307. /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/truncate.d.ts +0 -0
  308. /package/dist/runtime/components/{LibColorPicker → WColorPicker}/utils/truncate.js +0 -0
  309. /package/dist/runtime/components/{LibDatePicker → WDatePicker}/helpers.d.ts +0 -0
  310. /package/dist/runtime/components/{LibDatePicker → WDatePicker}/helpers.js +0 -0
  311. /package/dist/runtime/components/{LibDevOnly/LibDevOnly.vue → WDevOnly/WDevOnly.vue} +0 -0
  312. /package/src/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToHsva.ts +0 -0
  313. /package/src/runtime/components/{LibColorPicker → WColorPicker}/utils/safeConvertToRgba.ts +0 -0
  314. /package/src/runtime/components/{LibColorPicker → WColorPicker}/utils/toLowPrecisionRgbaString.ts +0 -0
  315. /package/src/runtime/components/{LibColorPicker → WColorPicker}/utils/truncate.ts +0 -0
  316. /package/src/runtime/components/{LibDatePicker → WDatePicker}/helpers.ts +0 -0
@@ -0,0 +1,392 @@
1
+ <template>
2
+ <div
3
+ :class="twMerge(`
4
+ file-input
5
+ justify-center
6
+ border-2
7
+ border-dashed
8
+ border-accent-500/80
9
+ focus-outline-within
10
+ transition-[border-color,box-shadow]
11
+ ease-out
12
+ hover:bg-accent-500/10
13
+ outlined-focus-within
14
+ `,
15
+ compact && `rounded-sm`,
16
+ !compact && `
17
+ flex
18
+ w-full
19
+ flex-col
20
+ items-stretch
21
+ gap-2
22
+ rounded-xl
23
+ p-2
24
+ `,
25
+ isHovered && `bg-accent-500/10`,
26
+ errors.length > 0 && isErrored && `errored border-red-400 hover:border-red-500`,
27
+ wrapperAttrs?.class
28
+ )"
29
+ v-bind="{ ...wrapperAttrs, class: undefined }"
30
+ @drop="onDrop"
31
+ @dragover.prevent="isHovered = true"
32
+ @dragleave="isHovered = false"
33
+ >
34
+ <div
35
+ :class="twMerge(`
36
+ file-input--wrapper
37
+ relative
38
+ justify-center
39
+ @container
40
+ `,
41
+ compact && `flex gap-2`,
42
+ !compact && `
43
+ file-input
44
+ flex
45
+ flex-col
46
+ items-center
47
+ `
48
+ )"
49
+ >
50
+ <label
51
+ :for="finalId"
52
+ :class="twMerge(`
53
+ file-input--label
54
+ pointer-events-none
55
+ flex
56
+ gap-1
57
+ items-center
58
+ justify-center
59
+ whitespace-nowrap
60
+ max-w-full
61
+ `)"
62
+ >
63
+ <slot
64
+ v-if="compact || multiple || files.length === 0"
65
+ name="icon"
66
+ >
67
+ <WIcon><i-lucide-upload/></WIcon>
68
+ </slot>
69
+ <slot name="label">
70
+ <div class="text-ellipsis overflow-hidden shrink-1 hidden @min-[15ch]:block">
71
+ {{
72
+ (compact
73
+ ? multiple
74
+ ? t("file-input.compact-choose-file-plural")
75
+ : t("file-input.compact-choose-file")
76
+ : multiple
77
+ ? t("file-input.non-compact-choose-file-plural")
78
+ : t("file-input.non-compact-choose-file")
79
+ )
80
+ }}
81
+ </div>
82
+ </slot>
83
+ <div
84
+ v-if="compact && multiple"
85
+ class="file-input--label-count"
86
+ >
87
+ {{ ` (${files.length})` }}
88
+ </div>
89
+ <div
90
+ v-if="compact && !multiple && files.length > 0"
91
+ class="file-input--label-name text-ellipsis overflow-hidden shrink-9999 hidden @3xs:block"
92
+ >
93
+ {{ ` (${files[0]?.file.name})` }}
94
+ </div>
95
+ <div
96
+ v-if="compact && !multiple && files.length > 0"
97
+ class="file-input--label-name text-ellipsis overflow-hidden shrink-9999 @3xs:hidden"
98
+ >
99
+ {{ ` (...)` }}
100
+ </div>
101
+ </label>
102
+ <label
103
+ v-if="!compact && formats?.length > 0"
104
+ class="file-input--formats-label flex-col items-center text-sm max-w-full hidden @min-[15ch]:flex"
105
+ >
106
+ <slot name="formats"><div class="text-ellipsis overflow-hidden max-w-full">{{ t("file-input.accepted-formats") }}:</div> </slot>
107
+ <div class="file-input--formats-list overflow-hidden text-ellipsis max-w-full">
108
+ {{ extensions.join(", ") }}
109
+ </div>
110
+ </label>
111
+ <input
112
+ :id="finalId"
113
+ :class="twMerge(`
114
+ file-input--input
115
+ absolute
116
+ inset-[calc(var(--spacing)*-2)]
117
+ cursor-pointer
118
+ z-0
119
+ text-[0]
120
+ opacity-0
121
+ `,
122
+ inputAttrs?.class
123
+ )"
124
+ type="file"
125
+ :accept="formats.join(', ')"
126
+ :multiple="multiple"
127
+ v-bind="{ ...inputAttrs, class: undefined }"
128
+ :aria-invalid="errors.length > 0"
129
+ :aria-errormessage="errors.map(_ => _.message).join(', ')"
130
+ ref="el"
131
+ @input="(inputFile as any)"
132
+ @click="($event.target! as any).value = null"
133
+ >
134
+ <!-- click event allows event to fire even if the user picks the same file -->
135
+ </div>
136
+ <div
137
+ v-if="!compact && files.length > 0"
138
+ :class="twMerge(`file-input--previews
139
+ flex items-stretch justify-center gap-4 flex-wrap
140
+ `,
141
+ multiple && `
142
+ w-full
143
+ `
144
+ )"
145
+ >
146
+ <div
147
+ class="
148
+ file-input--preview-wrapper
149
+ z-1
150
+ relative
151
+ flex
152
+ min-w-0
153
+ max-w-[150px]
154
+ flex-initial
155
+ flex-col
156
+ items-center
157
+ gap-1
158
+ p-1
159
+ rounded-sm
160
+ border
161
+ border-neutral-300
162
+ dark:border-neutral-800
163
+ shadow-md
164
+ shadow-neutral-800/30
165
+ bg-neutral-100
166
+ dark:bg-neutral-900
167
+ [&:hover_.file-input--remove-button]:opacity-100
168
+ "
169
+ v-for="entry of files"
170
+ :key="entry.file.name"
171
+ >
172
+ <div class="flex flex-initial basis-full justify-start items-center max-w-full gap-2 px-1">
173
+ <WButton
174
+ :border="false"
175
+ class="file-input--remove-button rounded-full p-0"
176
+ :aria-label="`Remove file ${entry.file.name}`"
177
+ @click="removeFile(entry)"
178
+ >
179
+ <WIcon><i-lucide-x/></WIcon>
180
+ </Wbutton>
181
+ <div
182
+ class="file-input--preview-filename min-w-0 flex-1 basis-0 truncate break-all rounded-sm text-sm"
183
+ :title="entry.file.name"
184
+ >
185
+ {{ entry.file.name }}
186
+ </div>
187
+ </div>
188
+
189
+ <div class="file-input--preview flex flex-initial basis-full justify-center">
190
+ <div
191
+ v-if="entry.isImg"
192
+ class="file-input--preview-image
193
+ bg-transparency-squares flex
194
+ h-[80px] flex-wrap items-center
195
+ justify-center
196
+ "
197
+ >
198
+ <img
199
+ class="max-h-full w-auto"
200
+ :src="entry.previewUrl"
201
+ >
202
+ </div>
203
+ <div
204
+ v-if="!entry.isImg"
205
+ class="file-input--preview-no-image
206
+ flex h-[80px]
207
+ flex-1 basis-full flex-wrap items-center justify-center
208
+ "
209
+ >
210
+ <WIcon><i-lucide-file class="text-4xl opacity-50"/></WIcon>
211
+ </div>
212
+ </div>
213
+ </div>
214
+ </div>
215
+ <div
216
+ v-if="!compact && errors.length > 0"
217
+ class="file-input--errors flex flex-col gap-2 text-sm text-red-600 dark:text-red-400 items-center px-2"
218
+ >
219
+ <div
220
+ class="file-input--error text-center"
221
+ v-for="error of errors"
222
+ :key="error.message"
223
+ >
224
+ {{ error.message }}
225
+ </div>
226
+ </div>
227
+ </div>
228
+ </template>
229
+
230
+ <script setup lang="ts">
231
+ import type { HTMLAttributes, InputHTMLAttributes } from "vue"
232
+ import { computed, onBeforeUnmount, ref, shallowReactive, watch } from "vue"
233
+
234
+ import ILucideFile from "~icons/lucide/file"
235
+ import ILucideUpload from "~icons/lucide/upload"
236
+ import ILucideX from "~icons/lucide/x"
237
+
238
+ import { useFallbackId } from "../../composables/useFallbackId.js"
239
+ import { useInjectedI18n } from "../../composables/useInjectedI18n.js"
240
+ import type { FileInputError, TailwindClassProp } from "../../types/index.js"
241
+ import { twMerge } from "../../utils/twMerge.js"
242
+ import WButton from "../WButton/WButton.vue"
243
+ import WIcon from "../WIcon/WIcon.vue"
244
+
245
+ const t = useInjectedI18n()
246
+ const el = ref<null | HTMLInputElement>(null)
247
+
248
+
249
+ const props = withDefaults(defineProps<
250
+ & {
251
+ id?: string
252
+ multiple?: boolean
253
+ /**
254
+ * A list of extensions or mime types to add to the input's accept. Basic validations are done so that files match an extension and mimeType, but note that a file could still be lying, all files should be validated server side.
255
+ *
256
+ * Pass an empty array to allow any filetype.
257
+ */
258
+ formats?: string[]
259
+ compact?: boolean
260
+ inputAttrs?: Omit<InputHTMLAttributes, "class"> & TailwindClassProp
261
+ wrapperAttrs?: Omit<HTMLAttributes, "class"> & TailwindClassProp
262
+ }
263
+ >(), {
264
+ multiple: false,
265
+ formats: () => ["image/*", ".jpeg", ".jpg", ".png"],
266
+ compact: false
267
+ })
268
+ const finalId = useFallbackId(props)
269
+
270
+ const emits = defineEmits<{
271
+ (e: "input", val: File[], clearFiles: () => void): void
272
+ (e: "errors", val: FileInputError[], clearErrors: () => void): void
273
+ }>()
274
+
275
+ type Entry = { file: File } & ({ isImg: true, previewUrl: string } | { isImg: false, previewUrl: undefined })
276
+
277
+ const files = shallowReactive<(Entry)[]>([])
278
+ const errors = shallowReactive<(FileInputError)[]>([])
279
+ const isErrored = ref(false)
280
+ const isHovered = ref(false)
281
+
282
+ function clearFiles() {
283
+ if (el.value) {
284
+ // not sure why sometimes el.value is undefined but it can be
285
+ el.value.value = ""
286
+ }
287
+ for (const entry of files) {
288
+ if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl)
289
+ }
290
+ files.splice(0, files.length)
291
+ }
292
+
293
+ watch(files, () => {
294
+ emits("input", files.map(entry => entry.file), clearFiles)
295
+ })
296
+ watch(errors, () => {
297
+ if (errors.length > 0) {
298
+ isErrored.value = true
299
+ emits("errors", [...errors], clearErrors)
300
+ }
301
+ })
302
+
303
+ function clearErrors() {
304
+ isErrored.value = false
305
+ errors.splice(0, errors.length)
306
+ }
307
+
308
+ defineOptions({
309
+ name: "WFileInput",
310
+ inheritAttrs: false
311
+ })
312
+
313
+ const mimeTypes = computed(() => props.formats?.filter(_ => !_.startsWith(".")) ?? [])
314
+ const extensions = computed(() => props.formats?.filter(_ => _.startsWith(".")) ?? [])
315
+
316
+
317
+ onBeforeUnmount(() => {
318
+ for (const entry of files) {
319
+ if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl)
320
+ }
321
+ })
322
+
323
+ function removeFile(entry: Entry) {
324
+ if (entry.previewUrl) URL.revokeObjectURL(entry.previewUrl)
325
+ const index = files.indexOf(entry)
326
+ if (index > -1) files.splice(index, 1)
327
+ }
328
+
329
+ const extensionsList = computed(() => extensions.value.join(", "))
330
+
331
+ function onDrop(e: DragEvent) {
332
+ if ("dataTransfer" in e && e.dataTransfer && e.dataTransfer.files && e.dataTransfer.files.length > 0) {
333
+ el.value!.files = e.dataTransfer.files
334
+ e.preventDefault()
335
+ isHovered.value = false
336
+ return updateFiles(el.value!.files)
337
+ }
338
+ return undefined
339
+ }
340
+ async function inputFile(e: InputEvent): Promise<undefined | boolean> {
341
+ e.preventDefault()
342
+ if (el.value!.files) {
343
+ return updateFiles(el.value!.files)
344
+ }
345
+ return undefined
346
+ }
347
+
348
+ function updateFiles(filesList: FileList): boolean | undefined {
349
+ const errs = []
350
+ for (const file of filesList) {
351
+ const isImg = file.type.startsWith("image")
352
+
353
+ const byPassValidation = props.formats.length === 0
354
+ const isValidMimeType = mimeTypes.value.find(_ => _.endsWith("/*") ? file.type.startsWith(_.slice(0, -2)) : _ === file.type) !== undefined
355
+ const isValidExtension = extensions.value.find(_ => file.name.endsWith(_)) !== undefined
356
+ if (!byPassValidation && (!isValidMimeType || !isValidExtension)) {
357
+ const extension = file.name.match(/.*(\..*)/)?.[1] ?? "Unknown"
358
+ const type = file.type === "" ? "" : ` (${file.type})`
359
+ const message = `File type ${extension}${type} is not allowed. Allowed file types are: ${extensionsList.value}.`
360
+ const err = new Error(message) as FileInputError
361
+ err.file = file
362
+ err.isValidExtension = isValidExtension
363
+ err.isValidMimeType = isValidMimeType
364
+ errs.push(err)
365
+ continue
366
+ }
367
+ const previewUrl = isImg ? URL.createObjectURL(file) : undefined
368
+ if (errs.length > 0) continue
369
+ if (!files.find(_ => _.file === file)) {
370
+ if ((props.multiple || files.length < 1)
371
+ ) {
372
+ files.push({ file, isImg, previewUrl: previewUrl as any })
373
+ } else {
374
+ files.splice(0, files.length, { file, isImg, previewUrl: previewUrl as any })
375
+ }
376
+ }
377
+ }
378
+ if (errs.length > 0) {
379
+ errors.splice(0, errors.length, ...errs)
380
+ return false
381
+ } else if (errors.length > 0) {
382
+ clearErrors()
383
+ }
384
+ return undefined
385
+ }
386
+
387
+ defineExpose({
388
+ clearFiles,
389
+ clearErrors
390
+ })
391
+ </script>
392
+
@@ -19,7 +19,9 @@ defineOptions({
19
19
 
20
20
  const $attrs = useAttrs() as any
21
21
 
22
- /* const props = */defineProps<Props>()
22
+ defineProps<
23
+ & /** @vue-ignore */ Omit<HTMLAttributes, "class">
24
+ >()
23
25
  </script>
24
26
 
25
27
  <script lang="ts">
@@ -27,13 +29,8 @@ const $attrs = useAttrs() as any
27
29
  * Just a very simple wrapper for wrapping unplugin-icons in an inline-block div so the icon in the slot take's up a normal line height when it's alone.
28
30
  *
29
31
  * ```vue
30
- * <icon><i-...></icon>
32
+ * <WIcon><i-...></WIcon>
31
33
  * ``
32
34
  */
33
-
34
- interface Props
35
- extends
36
- /** @vue-ignore */
37
- Partial<Omit<HTMLAttributes, "class">
38
- > { }
35
+ export default { name: "Icon" }
39
36
  </script>
@@ -2,22 +2,22 @@
2
2
  import type { Meta, StoryObj } from "@storybook/vue3"
3
3
  import { ref } from "vue"
4
4
 
5
- import LibMultiValues from "./LibMultiValues.vue"
5
+ import WMultiValues from "./WMultiValues.vue"
6
6
 
7
7
  import * as components from "../index.js"
8
8
 
9
9
  const meta = {
10
- component: LibMultiValues as any,
10
+ component: WMultiValues as any,
11
11
  title: "Components/MultiValues",
12
12
  args: {
13
13
  modelValue: ["A", "B", "C"],
14
14
  border: true
15
15
  },
16
16
  tags: ["!test"]
17
- } satisfies Meta<typeof LibMultiValues> & Meta<{ custom: string }>
17
+ } satisfies Meta<typeof WMultiValues>
18
18
 
19
19
  export default meta
20
- type Story = StoryObj<typeof LibMultiValues> // & StoryObj<typeof extraArgs>
20
+ type Story = StoryObj<typeof WMultiValues>
21
21
 
22
22
  /**
23
23
  * The multi-value component is just the values part beneath the input.
@@ -28,10 +28,10 @@ type Story = StoryObj<typeof LibMultiValues> // & StoryObj<typeof extraArgs>
28
28
  */
29
29
  export const Primary: Story = {
30
30
  render: args => ({
31
- components: { ...components, LibMultiValues },
31
+ components: { ...components, WMultiValues },
32
32
  setup: () => {
33
33
  const inputValue = ref("B")
34
- const multiValueEl = ref<typeof LibMultiValues | null>(null)
34
+ const multiValueEl = ref<typeof WMultiValues | null>(null)
35
35
  const onKeydownEnter = (e: KeyboardEvent): void => {
36
36
  if (e.key === "Enter") (args.modelValue!).push(inputValue.value)
37
37
  }
@@ -47,14 +47,14 @@ export const Primary: Story = {
47
47
  <p>Simple Input connected to multi-value.</p>
48
48
  <p>Note: You will be able to add values, including duplicates, even to the disabled/readonly version in this test, see the Input component for a properly connected approach.</p>
49
49
  <p> Press enter to add value :</p>
50
- <lib-simple-input
50
+ <WSimpleInput
51
51
  v-model="inputValue"
52
52
  @keydown="onKeydownEnter"
53
53
  >
54
- </lib-simple-input>
54
+ </WSimpleInput>
55
55
  <p>Multi-value component: </p>
56
56
  <div class="flex justify-start">
57
- <lib-multi-values
57
+ <WMultiValues
58
58
  ref="multiValueEl"
59
59
  v-bind="args"
60
60
  v-model="args.modelValue"
@@ -0,0 +1,163 @@
1
+ <template>
2
+ <div
3
+ v-if="$modelValue && $modelValue?.length > 0"
4
+ role="list"
5
+ :class="twMerge(`
6
+ multivalues
7
+ group
8
+ flex
9
+ flex-initial
10
+ items-center
11
+ justify-center
12
+ gap-1
13
+ overflow-x-scroll
14
+ scrollbar-hidden
15
+ `,
16
+ ($attrs as any)?.class)
17
+ "
18
+ :data-disabled="disabled"
19
+ :data-read-only="readonly"
20
+ :aria-label="label ? `Values for ${label}` : undefined"
21
+ v-bind="{ ...$attrs, class: undefined }"
22
+ @keydown="handleKeydown"
23
+ >
24
+ <div
25
+ role="listitem"
26
+ :data-border="border"
27
+ :class="twMerge(`
28
+ multivalues--item
29
+ flex-basis-0
30
+ min-w-2
31
+ flex
32
+ max-w-fit
33
+ flex-1
34
+ items-center
35
+ gap-0.5
36
+ overflow-hidden
37
+ px-1
38
+ text-xs
39
+ leading-none
40
+ focus-outline
41
+ outlined:outline-offset-0
42
+ `,
43
+ !(disabled || readonly) && `
44
+ group-focus:text-accent-500
45
+ focus:text-accent-500`,
46
+ border && `
47
+ rounded-sm
48
+ border-neutral-400
49
+ border
50
+ focus:border-accent-400
51
+ `,
52
+ border && (disabled || readonly) && `
53
+ border-neutral-200
54
+ focus:border-neutral-200
55
+ dark:border-neutral-800
56
+ dark:focus:border-neutral-800
57
+ `,
58
+ itemAttrs?.class
59
+ )"
60
+ :tabindex="canEdit ? (activeIndex === index ? 0 : -1) : undefined"
61
+ v-for="(value, index) of $modelValue"
62
+ :key="value"
63
+ ref="itemRefs"
64
+ @keydown.ctrl.c.prevent="copy(value.toString())"
65
+ @focus="activeIndex = index"
66
+ >
67
+ <span class="multivalues--label truncate">{{ value }}</span>
68
+ <WButton
69
+ class="multivalues--remove-button !p-0 text-sm !leading-none"
70
+ :aria-label="`Remove ${value}`"
71
+ :border="false"
72
+ :disabled="disabled || readonly"
73
+ tabindex="-1"
74
+ @click="removeVal(value)"
75
+ >
76
+ <WIcon><i-lucide-x/></WIcon>
77
+ </Wbutton>
78
+ </div>
79
+ </div>
80
+ </template>
81
+
82
+ <script setup lang="ts" generic="T extends string | number">
83
+ import { removeIfIn } from "@alanscodelog/utils/removeIfIn"
84
+ import { computed, type HTMLAttributes, nextTick, ref, useAttrs } from "vue"
85
+
86
+ import ILucideX from "~icons/lucide/x"
87
+
88
+ import { copy } from "../../helpers/copy.js"
89
+ import type { BaseInteractiveProps, TailwindClassProp } from "../../types/index.js"
90
+ import { twMerge } from "../../utils/twMerge.js"
91
+ import WButton from "../WButton/WButton.vue"
92
+ import WIcon from "../WIcon/WIcon.vue"
93
+
94
+ defineOptions({
95
+ name: "WMultiValues",
96
+ inheritAttrs: false
97
+ })
98
+
99
+ const $attrs = useAttrs()
100
+ const props = withDefaults(defineProps<
101
+ & BaseInteractiveProps
102
+ & {
103
+ label?: string
104
+ border?: boolean
105
+ itemAttrs?: Omit<HTMLAttributes, "class"> & TailwindClassProp
106
+ }
107
+ & /** @vue-ignore */ Omit<HTMLAttributes, "class">
108
+ & /** @vue-ignore */ TailwindClassProp
109
+ >(), {
110
+ border: true
111
+ })
112
+
113
+ const canEdit = computed(() => !props.disabled && !props.readonly)
114
+ const $modelValue = defineModel<T[]>({ default: () => [] })
115
+ const itemRefs = ref<HTMLElement[]>([])
116
+ const activeIndex = ref(0)
117
+
118
+
119
+ function removeVal(value: T) {
120
+ if (!canEdit.value) return
121
+ removeIfIn($modelValue.value, value)
122
+
123
+ if ($modelValue.value.length > 0) {
124
+ if (activeIndex.value >= $modelValue.value.length) {
125
+ activeIndex.value = $modelValue.value.length - 1
126
+ }
127
+ nextTick(() => {
128
+ itemRefs.value[activeIndex.value]?.focus()
129
+ })
130
+ }
131
+ }
132
+
133
+ function handleKeydown(e: KeyboardEvent) {
134
+ if (props.disabled) return
135
+
136
+ const len = $modelValue.value.length
137
+ if (len === 0) return
138
+
139
+ if (e.key === "ArrowRight") {
140
+ activeIndex.value = (activeIndex.value + 1) % len
141
+ itemRefs.value[activeIndex.value]?.focus()
142
+ e.preventDefault()
143
+ } else if (e.key === "ArrowLeft") {
144
+ activeIndex.value = (activeIndex.value - 1 + len) % len
145
+ itemRefs.value[activeIndex.value]?.focus()
146
+ e.preventDefault()
147
+ } else if (e.key === "Delete" || e.key === "Backspace") {
148
+ if (canEdit.value) {
149
+ removeVal($modelValue.value[activeIndex.value]!)
150
+ e.preventDefault()
151
+ }
152
+ } else if (e.key === "Home") {
153
+ activeIndex.value = 0
154
+ itemRefs.value[activeIndex.value]?.focus()
155
+ e.preventDefault()
156
+ } else if (e.key === "End") {
157
+ activeIndex.value = len - 1
158
+ itemRefs.value[activeIndex.value]?.focus()
159
+ e.preventDefault()
160
+ }
161
+ }
162
+ </script>
163
+