@witchcraft/ui 0.4.0 → 0.4.1

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
@@ -1,134 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import type { StoryObj } from "@storybook/vue3"
3
- import { computed, onMounted, ref } from "vue"
4
- import type { ComponentExposed } from "vue-component-type-helpers"
5
-
6
- import LibSuggestions from "./LibSuggestions.vue"
7
-
8
- import * as components from "../index.js"
9
-
10
- const meta = {
11
- component: LibSuggestions,
12
- title: "Components/Suggestions",
13
- args: {
14
- id: "some-id",
15
- modelValue: "",
16
- label: "Some Label",
17
- border: true,
18
- suggestions: ["A", "AB", "ABC", "B", "BC", "C", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
19
- }
20
- } // satisfies Meta<typeof LibSuggestions> & Meta<{ custom: string }>
21
-
22
- export default meta
23
- type Story = StoryObj<typeof LibSuggestions> // & StoryObj<typeof extraArgs>
24
-
25
- /**
26
- * The suggestions component is just the dropdown part.
27
- *
28
- * Here it is decoupled from the input.
29
- *
30
- * More examples can be found in the input component.
31
- */
32
- export const Primary: Story = {
33
- render: args => ({
34
- components: { ...components, LibSuggestions },
35
-
36
- setup: () => {
37
- const inputValue = ref(args.modelValue)
38
- const modelValue = ref(args.modelValue)
39
- const drawer = ref<ComponentExposed<typeof LibSuggestions> | null>(null)
40
- const keydownHandler = (e: KeyboardEvent): void => {
41
- drawer.value?.inputKeydownHandler(e)
42
- }
43
- const suggestions = computed(() => drawer.value?.suggestions)
44
- const blurHandler = (e: MouseEvent) => {
45
- drawer.value?.inputBlurHandler(e)
46
- }
47
- onMounted(() => {
48
- drawer.value?.suggestions.open()
49
- })
50
- return {
51
- args,
52
- inputValue,
53
- modelValue,
54
- isOpen: ref(false),
55
- suggestions,
56
- drawer,
57
- keydownHandler,
58
- blurHandler
59
- }
60
- },
61
-
62
- template: `
63
- <div class="flex flex-col gap-3">
64
- Temporary Value: {{inputValue}}
65
- <br/>
66
- Model Value (Final Value): <span class="inline-block" data-testid="model-value">{{modelValue}}</span>\n
67
-
68
- <br/>
69
- Selected: {{suggestions?.filtered[suggestions.active]}}
70
- <label>Some Label</label>
71
- <lib-simple-input
72
- :class="isOpen ? 'open' : ''"
73
- v-model="inputValue"
74
- @focus="suggestions.open()"
75
- @blur="blurHandler"
76
- @keydown="keydownHandler"
77
- ></lib-simple-input>
78
- <lib-suggestions
79
- ref="drawer"
80
- v-bind="{...args}"
81
- @update:isOpen="isOpen = $event"
82
- v-model="modelValue"
83
- v-model:inputValue="inputValue"
84
- >
85
- <template #item={item}>
86
- {{item}}
87
- </template>
88
- </lib-suggestions>
89
- </div>
90
- `
91
- })
92
- }
93
-
94
- export const RestrictToSuggestions: Story = {
95
- ...Primary,
96
- args: {
97
- ...Primary.args,
98
- restrictToSuggestions: true
99
- }
100
-
101
- }
102
- export const AlwaysShowAllSuggestions = {
103
- ...Primary,
104
- args: {
105
- ...Primary.args,
106
- restrictToSuggestions: true,
107
- suggestionsFilter: (_input: string, items: string[]) => items
108
- }
109
-
110
- }
111
- export const AlwaysShowAllSuggestionsAndNoRestrictToSuggestions = {
112
- ...Primary,
113
- args: {
114
- ...Primary.args,
115
- restrictToSuggestions: false,
116
- suggestionsFilter: (_input: string, items: string[]) => items
117
- }
118
-
119
- }
120
- export const CustomSuggestionsObject = {
121
- ...Primary,
122
- args: {
123
- ...Primary.args,
124
- restrictToSuggestions: true,
125
- suggestions: [
126
- { label: "A", other: "some data A" },
127
- { label: "AB", other: "some data AB" },
128
- { label: "ABC", other: "some data ABC" },
129
- { label: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", other: "some data ABCDEFGHIJKLMNOPQRSTUVWXYZ" }
130
- ],
131
- suggestionLabel: (item: any) => item.label
132
- }
133
-
134
- }
@@ -1,212 +0,0 @@
1
- <template>
2
- <div
3
- v-if="$open"
4
- :id="`suggestions-${id ?? fallbackId}`"
5
- :class="twMerge(`
6
- suggestions
7
- bg-bg
8
- dark:bg-fg
9
- dark:text-bg
10
- `,
11
- ($.attrs as any)?.class
12
- )"
13
- :data-open="$open"
14
- role="listbox"
15
- ref="el"
16
- v-bind="{ ...$.attrs, class: undefined }"
17
- >
18
- <!-- Click event is just in case, it should not really be triggered. We can do click selections via the blur handler. -->
19
- <div
20
- :id="`suggestion-${id ?? fallbackId}-${index}`"
21
- role="option"
22
- :class="twMerge(`
23
- suggestions--item
24
- user-select-none
25
- cursor-pointer
26
- px-2
27
- `,
28
- index=== suggestions.active && `
29
- bg-accent-200
30
- dark:bg-accent-800/70
31
- `,
32
- ($.itemAttrs as any)?.class
33
- )"
34
- v-bind="{ ...$.itemAttrs, class: undefined }"
35
- :aria-selected="index === suggestions.active ? true : false"
36
- :aria-label="suggestions.getLabel(item)"
37
- v-for="(item, index) in suggestions.filtered"
38
- :key="item"
39
- @mouseover="suggestions.active = index"
40
- @mousedown.prevent
41
- @mouseup="suggestions.enterIndex(index, !Array.isArray($modelValue))"
42
- >
43
- <slot
44
- name="item"
45
- :item="item"
46
- :index="index"
47
- :is-selected="Array.isArray($modelValue) ? $modelValue.includes(item) : $modelValue === item"
48
- >
49
- <div class="flex gap-2 nowrap">
50
- <lib-checkbox
51
- v-if="Array.isArray($modelValue) && showSelectedValues"
52
- :model-value="$modelValue.includes(item)"
53
- @mousedown.prevent
54
- />
55
- <div> {{ item }} </div>
56
- </div>
57
- </slot>
58
- </div>
59
- </div>
60
- </template>
61
-
62
- <script setup lang="ts" generic="TSuggestion extends string | object, TValue extends string|string[]">
63
- import { type HTMLAttributes, reactive, ref } from "vue"
64
-
65
- import { useDivideAttrs } from "../../composables/useDivideAttrs.js"
66
- import { useSuggestions } from "../../composables/useSuggestions.js"
67
- import { hasModifiers } from "../../helpers/hasModifiers.js"
68
- import { twMerge } from "../../utils/twMerge.js"
69
- import LibCheckbox from "../LibCheckbox/LibCheckbox.vue"
70
- import { type BaseInteractiveProps, getFallbackId, type LabelProps, type LinkableByIdProps, type SuggestionsEmits, type SuggestionsProps, type WrapperProps } from "../shared/props.js"
71
-
72
- defineOptions({
73
- name: "LibSuggestions",
74
- inheritAttrs: false
75
- })
76
-
77
- const $ = useDivideAttrs(["item"] as const)
78
-
79
- const emits = defineEmits<SuggestionsEmits>()
80
-
81
- const fallbackId = getFallbackId()
82
- const props = withDefaults(defineProps<Props & SuggestionsProps<TSuggestion>>(), {
83
- isValid: true,
84
- canOpen: true,
85
- canClose: true,
86
- filterKeydown: undefined,
87
- unstyle: false, disabled: false, readonly: false, border: true
88
- })
89
- /**
90
- * The final valid value. This is *not* the value you want to share with the input. If `restrictToSuggestions` is true this will not update on any invalid values that `inputValue` might be set to.
91
- *
92
- * If suggestions are objects, this will be the string returned by the `suggestionLabel` prop.
93
- */
94
- const $modelValue = defineModel<TValue>("modelValue", { required: true })
95
- /**
96
- * If the element is bound to an input, this is the value that the input should be sharing.
97
- *
98
- * It allows the component to read even invalid output, and also to reset that invalid output when either modelValue is set to a new value, or when the component is closed via cancel.
99
- */
100
- const $inputValue = defineModel<string>("inputValue", { default: "" })
101
-
102
- const $open = defineModel<boolean>("open", { default: false })
103
-
104
- if (typeof props.suggestions?.[0] === "object" && !props.suggestionLabel && !props.suggestionsFilter) {
105
- throw new Error("`suggestionLabel` or `suggestionsFilter` must be passed if suggestions are objects.")
106
- }
107
-
108
- const el = ref<HTMLElement | null>(null)
109
-
110
- const suggestions = reactive(useSuggestions<TSuggestion, TValue extends string[] ? true : false>(
111
- $inputValue,
112
- $modelValue as any,
113
- $open,
114
- emits,
115
- props
116
- ))
117
-
118
- const inputKeydownHandler = (e: KeyboardEvent): void => {
119
- if (props.filterKeydown?.(e)) return
120
- if (hasModifiers(e)) return
121
- if (e.key === "Enter") {
122
- suggestions.enterSelected(!Array.isArray($modelValue))
123
- e.preventDefault()
124
- } else if (e.key === "Escape") {
125
- suggestions.cancel()
126
- e.preventDefault()
127
- } else if (!$open.value && ["ArrowDown", "ArrowUp", "PageUp", "PageDown"].includes(e.key) && suggestions.available) {
128
- suggestions.open()
129
- e.preventDefault()
130
- if (e.key === "PageUp") {
131
- suggestions.first()
132
- } else if (e.key === "PageDown") {
133
- suggestions.last()
134
- }
135
- } else if (e.key === "ArrowUp") {
136
- suggestions.prev()
137
- e.preventDefault()
138
- } else if (e.key === "ArrowDown") {
139
- suggestions.next()
140
- e.preventDefault()
141
- } else if (e.key === "PageUp") {
142
- suggestions.first()
143
- e.preventDefault()
144
- } else if (e.key === "PageDown") {
145
- suggestions.last()
146
- e.preventDefault()
147
- }
148
- }
149
- const inputBlurHandler = (e: MouseEvent): void => {
150
- if (props.filterBlur?.(e)) return
151
-
152
- if (!$open.value) return
153
-
154
- if (props.restrictToSuggestions) {
155
- suggestions.cancel()
156
- } else {
157
- if (!Array.isArray($modelValue.value)) {
158
- $modelValue.value = $inputValue.value as any
159
- }
160
- }
161
- if ($open.value) {
162
- suggestions.close()
163
- }
164
- }
165
- const inputFocusHandler = (e: FocusEvent): void => {
166
- if (props.filterFocus?.(e)) return
167
- suggestions.open()
168
- }
169
-
170
- defineExpose({
171
- suggestions,
172
- el,
173
- /** A simple keydown handler that can be passed to an input to control the component while still focused inside it. */
174
- inputKeydownHandler,
175
- /** A blur handler for the input that controls the component. This also takes care of making clicking on a suggestion work, since otherwise if canOpen is set to false in the blur handler, no click event will fire. */
176
- inputBlurHandler,
177
- /** A focus handler for the input that controls the component. */
178
- inputFocusHandler
179
- })
180
- </script>
181
-
182
- <script lang="ts">
183
- type WrapperTypes = Partial<WrapperProps<"item", HTMLAttributes, {
184
- /** Tailwind classes. */
185
- class?: string
186
- }>>
187
-
188
- type RealProps
189
- = & LinkableByIdProps
190
- & LabelProps
191
- & BaseInteractiveProps
192
- & {
193
- /** Return true to prevent the keydown event from being handled. */
194
- filterKeydown?: (e: KeyboardEvent) => boolean
195
- /** Return true to prevent the blur event from being handled. */
196
- filterBlur?: (e: MouseEvent) => boolean
197
- /** Return true to prevent the focus event from being handled. */
198
- filterFocus?: (e: FocusEvent) => boolean
199
- }
200
-
201
- interface Props
202
- extends
203
- /** @vue-ignore */
204
- Partial<Omit<HTMLAttributes, "class" | "onSubmit"> & {
205
- /** Tailwind classes. */
206
- class?: string
207
- }>,
208
- /** @vue-ignore */
209
- WrapperTypes,
210
- RealProps
211
- {}
212
- </script>
@@ -1,167 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import type { Meta, StoryObj } from "@storybook/vue3"
3
-
4
- import LibTable from "./LibTable.vue"
5
-
6
- // todo
7
- import * as components from "../index.js"
8
-
9
- const meta: Meta<typeof LibTable> = {
10
- component: LibTable,
11
- title: "Components/Table"
12
- }
13
-
14
- export default meta
15
- type Story = StoryObj<typeof LibTable>
16
- export const Primary: Story = {
17
- render: args => ({
18
- components,
19
- setup: () => ({ args }),
20
- template: `
21
- <div class="overflow-x-scroll scrollbar-hidden">
22
- <lib-table
23
- v-bind="args"
24
- >
25
- </lib-table>
26
- </div>
27
- `
28
- }),
29
- args: {
30
- cols: ["prop1", "prop2", "prop3"],
31
- values: [
32
- { prop1: "Item1 Prop 1", prop2: "Item1 Prop 2", prop3: "Item1 Prop 3" },
33
- { prop1: "Item2 Prop 1", prop2: "Item2 Prop 2", prop3: "Item2 Prop 3" },
34
- { prop1: "Item3 Prop 1", prop2: "Item3 Prop 2", prop3: "Item3 Prop 3" }
35
- ],
36
- colConfig: { prop1: { name: "Header 1" }, prop2: { name: "Header 2" } },
37
- itemKey: "prop1"
38
- }
39
- }
40
-
41
- export const NoCellBorders: Story = {
42
- ...Primary,
43
- args: {
44
- ...Primary.args,
45
- cellBorder: false
46
- }
47
- }
48
- export const NoBorders: Story = {
49
- ...Primary,
50
- args: {
51
- ...Primary.args,
52
- border: false
53
- }
54
- }
55
- export const NoCellBordersNoBorders: Story = {
56
- ...Primary,
57
- args: {
58
- ...Primary.args,
59
- cellBorder: false,
60
- border: false
61
- }
62
- }
63
-
64
- export const SquareBorders: Story = {
65
- ...Primary,
66
- args: {
67
- ...Primary.args,
68
- rounded: false
69
- }
70
- }
71
- export const NoHeader: Story = {
72
- ...Primary,
73
- args: {
74
- ...Primary.args,
75
- header: false
76
- }
77
- }
78
- export const NoHeaderNoBorders: Story = {
79
- ...Primary,
80
- args: {
81
- ...Primary.args,
82
- header: false,
83
- border: false
84
- }
85
- }
86
- export const NoHeaderNoCellBorders: Story = {
87
- ...Primary,
88
- args: {
89
- ...Primary.args,
90
- header: false,
91
- cellBorder: false
92
- }
93
- }
94
- export const FitWidthFalse: Story = {
95
- ...Primary,
96
- args: {
97
- ...Primary.args,
98
- resizable: {
99
- fitWidth: false
100
- }
101
- }
102
- }
103
-
104
- export const ThreeColSomeColsNotResizable: Story = {
105
- render: args => ({
106
- components,
107
- setup: () => ({ args }),
108
- template: `
109
- <lib-table
110
- v-bind="args"
111
- >
112
- </lib-table>
113
- <br>
114
- <lib-table
115
- v-bind="{...args, colConfig:args.colConfig2}"
116
- >
117
- </lib-table>
118
- <br>
119
- <lib-table
120
- v-bind="{...args, colConfig:args.colConfig3}"
121
- >
122
- </lib-table>
123
- `
124
- }),
125
- args: {
126
- cols: ["prop1", "prop2", "prop3"],
127
- itemKey: "prop1",
128
- values: [
129
- { prop1: "Prop 1", prop2: "Prop 2", prop3: "Prop 3" }
130
- ],
131
- colConfig: { prop1: { name: "No Resize", resizable: false } },
132
- colConfig2: { prop2: { name: "No Resize", resizable: false } },
133
- colConfig3: { prop3: { name: "No Resize", resizable: false } }
134
- } as any
135
- }
136
- export const FourColSomeColsNotResizable: Story = {
137
- render: args => ({
138
- components,
139
- setup: () => ({ args }),
140
- template: `
141
- <lib-table
142
- v-bind="args"
143
- >
144
- </lib-table>
145
- <br>
146
- <lib-table
147
- v-bind="{...args, colConfig:args.colConfig2}"
148
- >
149
- </lib-table>
150
- <br>
151
- <lib-table
152
- v-bind="{...args, colConfig:args.colConfig3}"
153
- >
154
- </lib-table>
155
- `
156
- }),
157
- args: {
158
- cols: ["prop1", "prop2", "prop3", "prop4"],
159
- values: [
160
- { prop1: "Prop 1", prop2: "Prop 2", prop3: "Prop 3", prop4: "Prop 4" }
161
- ],
162
- itemKey: "prop1",
163
- colConfig: { prop1: { name: "No Resize", resizable: false }, prop3: { name: "No Resize", resizable: false } },
164
- colConfig2: { prop2: { name: "No Resize", resizable: false }, prop3: { name: "No Resize", resizable: false } },
165
- colConfig3: { prop1: { name: "No Resize", resizable: false }, prop4: { name: "No Resize", resizable: false } }
166
- } as any
167
- }
@@ -1,190 +0,0 @@
1
- <template>
2
- <!-- Assumes no scrollbars on children -->
3
- <table
4
- :class="twMerge(`table
5
- table-fixed
6
- border-separate
7
- border-spacing-0
8
- overflow-x-scroll
9
- scrollbar-hidden
10
- [&_.grip]:w-[5px]
11
- relative
12
- w-full
13
- box-content
14
- [&_thead]:font-bold
15
- [&_td]:p-1
16
- [&_td]:overflow-x-hidden
17
- [&.resizable-cols-error]:cursor-not-allowed
18
- [&.resizable-cols-error]:user-select-none
19
- `,
20
- cellBorder && `
21
- [&_td]:border-neutral-500
22
- [&_td:not(.last-row)]:border-b
23
- [&_td:not(.first-col)]:border-l
24
- `,
25
- border && `
26
- [&_thead_td]:bg-neutral-200
27
- [&_td]:border-neutral-500
28
- dark:[&_thead_td]:bg-neutral-800
29
- dark:[&_td]:border-neutral-500
30
- [&_td.first-row]:border-t
31
- [&_td.last-row]:border-b
32
- [&_td.last-col]:border-r
33
- [&_td.first-col]:border-l
34
- `,
35
- rounded &&`
36
- [&_td.br]:rounded-br-sm
37
- [&_td.bl]:rounded-bl-sm
38
- [&_td.tr]:rounded-tr-sm
39
- [&_td.tl]:rounded-tl-sm
40
- `,
41
- ($attrs as any).class)"
42
- v-resizable-cols="resizableOptions"
43
- >
44
- <thead
45
- v-if="header"
46
- class="table--header"
47
- >
48
- <tr class="table--row">
49
- <template
50
- v-for="col, i of cols"
51
- :key="col"
52
- >
53
- <slot
54
- :name="`header-${col.toString()}`"
55
- :class="[
56
- extraClasses[`-1-${i}`],
57
- 'cell table--header-cell',
58
- (colConfig as any)[col]?.resizable === false
59
- ? 'no-resize'
60
- : ''
61
- ].join(' ')"
62
- :style="`width:${widths.length > 0 ? widths[i] : ``}; `"
63
- :col-key="col"
64
- >
65
- <td
66
- :class="[
67
- extraClasses[`-1-${i}`],
68
- 'cell table--header-cell',
69
- (colConfig as any)[col]?.resizable === false
70
- ? 'no-resize'
71
- : ''
72
- ].join(' ')"
73
- :style="`width:${widths.length > 0 ? widths[i] : ``}; `"
74
- >
75
- {{ (colConfig as any)[col]?.name ?? col }}
76
- </td>
77
- </slot>
78
- </template>
79
- </tr>
80
- </thead>
81
- <tbody class="table--body">
82
- <template
83
- v-for="item, i of values"
84
- :key="typeof itemKey === 'function' ? itemKey(item) : item[itemKey]"
85
- >
86
- <tr class="table--row">
87
- <template
88
- v-for="col, j of cols"
89
- :key="(typeof itemKey === 'function' ? itemKey(item) : item[itemKey]) + col.toString()"
90
- >
91
- <slot
92
- :name="col"
93
- :item="item"
94
- :value="item[col]"
95
- :class="extraClasses[`${i}-${j}`] + 'table--cell cell'"
96
- >
97
- <td :class="extraClasses[`${i}-${j}`] + 'table--cell cell'">
98
- {{ item[col] }}
99
- </td>
100
- </slot>
101
- </template>
102
- </tr>
103
- </template>
104
- </tbody>
105
- </table>
106
- </template>
107
-
108
- <!-- generic="T extends Record<string, any> -->"
109
- <script setup lang="ts" generic="T">
110
- import type { MakeRequired } from "@alanscodelog/utils"
111
- import { keys } from "@alanscodelog/utils/keys"
112
- import { computed, ref, type TableHTMLAttributes } from "vue"
113
-
114
- import { vResizableCols } from "../../directives/vResizableCols.js"
115
- import type { ResizableOptions, TableColConfig } from "../../types/index.js"
116
- import { twMerge } from "../../utils/twMerge.js"
117
- import type { TailwindClassProp } from "../shared/props.js"
118
-
119
- defineOptions({
120
- name: "LibTable"
121
- })
122
-
123
- const props = withDefaults(defineProps<Props>(), {
124
- resizable: () => ({}),
125
- values: () => [] as T[],
126
- itemKey: "",
127
- cols: () => [] as (keyof T)[],
128
- rounded: true,
129
- border: true,
130
- cellBorder: true,
131
- header: true,
132
- colConfig: () => ({})
133
- })
134
-
135
- const widths = ref([])
136
- const resizableOptions = computed<MakeRequired<Partial<ResizableOptions>, "colCount" | "widths">>(() => ({
137
- colCount: props.cols.length,
138
- widths,
139
- selector: ".cell",
140
- ...props.resizable
141
- }))
142
-
143
- /* props.values.length instead of `props.values.length - 1` because we're creating an artificial first row for the header */
144
- const getExtraClasses = (row: number, col: number, isHeader: boolean): string[] => {
145
- const res = {
146
- bl: !isHeader && row === props.values.length - 1 && col === 0,
147
- br: !isHeader && row === props.values.length - 1 && col === props.cols.length - 1,
148
- tr: (isHeader || !props.header) && row === 0 && col === props.cols.length - 1,
149
- tl: (isHeader || !props.header) && row === 0 && col === 0,
150
- "first-row": (isHeader || !props.header) && row === 0,
151
- "last-row": row === props.values.length - 1,
152
- "first-col": col === 0,
153
- "last-col": col === props.cols.length - 1
154
- }
155
- return keys(res).filter(key => res[key])
156
- }
157
-
158
- const extraClasses = computed(() => Object.fromEntries([...Array(props.values.length + 1).keys()]
159
- .map(row => [...Array(props.cols.length).keys()]
160
- .map(col =>
161
- [
162
- `${row - 1}-${col}`,
163
- getExtraClasses(row <= 0 ? 0 : row - 1, col, row === 0).join(" ")
164
- ]))
165
- .flat()
166
- ))
167
- </script>
168
-
169
- <script lang="ts">
170
- // generic isn't working here :/
171
- type T = any
172
-
173
- type RealProps = {
174
- resizable?: Partial<ResizableOptions>
175
- values?: T[]
176
- itemKey?: keyof T | ((item: T) => string)
177
- /** Let's the table know the shape of the data since values might be empty. */
178
- cols?: (keyof T)[]
179
- rounded?: boolean
180
- border?: boolean
181
- cellBorder?: boolean
182
- header?: boolean
183
- colConfig?: TableColConfig<T>
184
- }
185
- interface Props
186
- extends
187
- /** @vue-ignore */
188
- Partial<Omit<TableHTMLAttributes, "class" | "readonly" | "disabled"> & TailwindClassProp>,
189
- RealProps { }
190
- </script>