@witchcraft/ui 0.0.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 (315) hide show
  1. package/README.md +236 -0
  2. package/dist/module.cjs +5 -0
  3. package/dist/module.d.mts +34 -0
  4. package/dist/module.d.ts +34 -0
  5. package/dist/module.json +9 -0
  6. package/dist/module.mjs +124 -0
  7. package/dist/runtime/assets/base.css +1 -0
  8. package/dist/runtime/assets/locales/en.json +33 -0
  9. package/dist/runtime/assets/style.css +1 -0
  10. package/dist/runtime/assets/tailwind.css +1 -0
  11. package/dist/runtime/assets/theme.css +1 -0
  12. package/dist/runtime/build/WitchcraftUiResolver.d.ts +5 -0
  13. package/dist/runtime/build/WitchcraftUiResolver.js +17 -0
  14. package/dist/runtime/build/generateTheme.d.ts +1 -0
  15. package/dist/runtime/build/generateTheme.js +14 -0
  16. package/dist/runtime/build/unpluginIconViteOptions.d.ts +2 -0
  17. package/dist/runtime/build/unpluginIconViteOptions.js +10 -0
  18. package/dist/runtime/components/Aria/Aria.vue +18 -0
  19. package/dist/runtime/components/Focus.stories.d.ts +11 -0
  20. package/dist/runtime/components/Focus.stories.js +53 -0
  21. package/dist/runtime/components/Icon/Icon.vue +39 -0
  22. package/dist/runtime/components/LibButton/LibButton.stories.d.ts +12 -0
  23. package/dist/runtime/components/LibButton/LibButton.stories.js +94 -0
  24. package/dist/runtime/components/LibButton/LibButton.vue +247 -0
  25. package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.d.ts +14 -0
  26. package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.js +29 -0
  27. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +132 -0
  28. package/dist/runtime/components/LibColorInput/LibColorInput.stories.d.ts +7 -0
  29. package/dist/runtime/components/LibColorInput/LibColorInput.stories.js +58 -0
  30. package/dist/runtime/components/LibColorInput/LibColorInput.vue +125 -0
  31. package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.d.ts +7 -0
  32. package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +51 -0
  33. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +448 -0
  34. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.d.ts +7 -0
  35. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.js +36 -0
  36. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +95 -0
  37. package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.d.ts +11 -0
  38. package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.js +98 -0
  39. package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +67 -0
  40. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +370 -0
  41. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +314 -0
  42. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +27 -0
  43. package/dist/runtime/components/LibDatePicker/helpers.d.ts +25 -0
  44. package/dist/runtime/components/LibDatePicker/helpers.js +28 -0
  45. package/dist/runtime/components/LibDebug/LibDebug.stories.d.ts +9 -0
  46. package/dist/runtime/components/LibDebug/LibDebug.stories.js +46 -0
  47. package/dist/runtime/components/LibDebug/LibDebug.vue +91 -0
  48. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +53 -0
  49. package/dist/runtime/components/LibFileInput/LibFileInput.stories.d.ts +10 -0
  50. package/dist/runtime/components/LibFileInput/LibFileInput.stories.js +63 -0
  51. package/dist/runtime/components/LibFileInput/LibFileInput.vue +273 -0
  52. package/dist/runtime/components/LibInput/LibInput.stories.d.ts +33 -0
  53. package/dist/runtime/components/LibInput/LibInput.stories.js +339 -0
  54. package/dist/runtime/components/LibInput/LibInput.vue +372 -0
  55. package/dist/runtime/components/LibLabel/LibLabel.stories.d.ts +6 -0
  56. package/dist/runtime/components/LibLabel/LibLabel.stories.js +25 -0
  57. package/dist/runtime/components/LibLabel/LibLabel.vue +66 -0
  58. package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.d.ts +23 -0
  59. package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.js +60 -0
  60. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +127 -0
  61. package/dist/runtime/components/LibNotifications/LibNotification.stories.d.ts +15 -0
  62. package/dist/runtime/components/LibNotifications/LibNotification.stories.js +126 -0
  63. package/dist/runtime/components/LibNotifications/LibNotification.vue +121 -0
  64. package/dist/runtime/components/LibNotifications/LibNotifications.stories.d.ts +6 -0
  65. package/dist/runtime/components/LibNotifications/LibNotifications.stories.js +109 -0
  66. package/dist/runtime/components/LibNotifications/LibNotifications.vue +133 -0
  67. package/dist/runtime/components/LibPagination/LibPagination.stories.d.ts +6 -0
  68. package/dist/runtime/components/LibPagination/LibPagination.stories.js +40 -0
  69. package/dist/runtime/components/LibPagination/LibPagination.vue +261 -0
  70. package/dist/runtime/components/LibPalette/LibPalette.stories.d.ts +6 -0
  71. package/dist/runtime/components/LibPalette/LibPalette.stories.js +20 -0
  72. package/dist/runtime/components/LibPalette/LibPalette.vue +49 -0
  73. package/dist/runtime/components/LibPopup/LibPopup.stories.d.ts +14 -0
  74. package/dist/runtime/components/LibPopup/LibPopup.stories.js +147 -0
  75. package/dist/runtime/components/LibPopup/LibPopup.vue +441 -0
  76. package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.d.ts +10 -0
  77. package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.js +81 -0
  78. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +192 -0
  79. package/dist/runtime/components/LibRecorder/LibRecorder.stories.d.ts +19 -0
  80. package/dist/runtime/components/LibRecorder/LibRecorder.stories.js +63 -0
  81. package/dist/runtime/components/LibRecorder/LibRecorder.vue +243 -0
  82. package/dist/runtime/components/LibRoot/LibRoot.vue +126 -0
  83. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.d.ts +26 -0
  84. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.js +78 -0
  85. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +148 -0
  86. package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.d.ts +27 -0
  87. package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.js +112 -0
  88. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +198 -0
  89. package/dist/runtime/components/LibTable/LibTable.stories.d.ts +16 -0
  90. package/dist/runtime/components/LibTable/LibTable.stories.js +156 -0
  91. package/dist/runtime/components/LibTable/LibTable.vue +177 -0
  92. package/dist/runtime/components/Template/NAME.vue +49 -0
  93. package/dist/runtime/components/Template/TemplateStory.d.ts +7 -0
  94. package/dist/runtime/components/Template/TemplateStory.js +22 -0
  95. package/dist/runtime/components/TestControls/TestControls.vue +19 -0
  96. package/dist/runtime/components/index.d.ts +19 -0
  97. package/dist/runtime/components/index.js +19 -0
  98. package/dist/runtime/components/reset.stories.d.ts +5 -0
  99. package/dist/runtime/components/reset.stories.js +19 -0
  100. package/dist/runtime/components/shared/props.d.ts +135 -0
  101. package/dist/runtime/components/shared/props.js +14 -0
  102. package/dist/runtime/components/shared/storyHelpers/playInput.d.ts +8 -0
  103. package/dist/runtime/components/shared/storyHelpers/playInput.js +26 -0
  104. package/dist/runtime/components/shared/storyHelpers/playSuggestions.d.ts +12 -0
  105. package/dist/runtime/components/shared/storyHelpers/playSuggestions.js +83 -0
  106. package/dist/runtime/composables/index.d.ts +11 -0
  107. package/dist/runtime/composables/index.js +11 -0
  108. package/dist/runtime/composables/useAccesibilityOutline.d.ts +41 -0
  109. package/dist/runtime/composables/useAccesibilityOutline.js +58 -0
  110. package/dist/runtime/composables/useAriaLabel.d.ts +6 -0
  111. package/dist/runtime/composables/useAriaLabel.js +15 -0
  112. package/dist/runtime/composables/useDarkMode.d.ts +38 -0
  113. package/dist/runtime/composables/useDarkMode.js +79 -0
  114. package/dist/runtime/composables/useDivideAttrs.d.ts +27 -0
  115. package/dist/runtime/composables/useDivideAttrs.js +26 -0
  116. package/dist/runtime/composables/useGlobalResizeObserver.d.ts +3 -0
  117. package/dist/runtime/composables/useGlobalResizeObserver.js +28 -0
  118. package/dist/runtime/composables/useInjectedDarkMode.d.ts +2 -0
  119. package/dist/runtime/composables/useInjectedDarkMode.js +13 -0
  120. package/dist/runtime/composables/useInjectedI18n.d.ts +2 -0
  121. package/dist/runtime/composables/useInjectedI18n.js +7 -0
  122. package/dist/runtime/composables/useInjectedLocale.d.ts +2 -0
  123. package/dist/runtime/composables/useInjectedLocale.js +21 -0
  124. package/dist/runtime/composables/useNotificationHandler.d.ts +4 -0
  125. package/dist/runtime/composables/useNotificationHandler.js +21 -0
  126. package/dist/runtime/composables/useScrollNearContainerEdges.d.ts +68 -0
  127. package/dist/runtime/composables/useScrollNearContainerEdges.js +116 -0
  128. package/dist/runtime/composables/useScrollNearContainerEdges.stories.d.ts +7 -0
  129. package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +85 -0
  130. package/dist/runtime/composables/useSetupDarkMode.d.ts +12 -0
  131. package/dist/runtime/composables/useSetupDarkMode.js +4 -0
  132. package/dist/runtime/composables/useSetupI18n.d.ts +20 -0
  133. package/dist/runtime/composables/useSetupI18n.js +50 -0
  134. package/dist/runtime/composables/useSetupLocale.d.ts +9 -0
  135. package/dist/runtime/composables/useSetupLocale.js +21 -0
  136. package/dist/runtime/composables/useShowDevOnlyKey.d.ts +7 -0
  137. package/dist/runtime/composables/useShowDevOnlyKey.js +20 -0
  138. package/dist/runtime/composables/useSuggestions.d.ts +38 -0
  139. package/dist/runtime/composables/useSuggestions.js +226 -0
  140. package/dist/runtime/directives/index.d.ts +4 -0
  141. package/dist/runtime/directives/index.js +4 -0
  142. package/dist/runtime/directives/vDetectFlex.d.ts +2 -0
  143. package/dist/runtime/directives/vDetectFlex.js +109 -0
  144. package/dist/runtime/directives/vExtractRootEl.d.ts +22 -0
  145. package/dist/runtime/directives/vExtractRootEl.js +13 -0
  146. package/dist/runtime/directives/vResizableCols.d.ts +60 -0
  147. package/dist/runtime/directives/vResizableCols.js +252 -0
  148. package/dist/runtime/directives/vResizeObserver.d.ts +2 -0
  149. package/dist/runtime/directives/vResizeObserver.js +34 -0
  150. package/dist/runtime/globalResizeObserver.d.ts +5 -0
  151. package/dist/runtime/globalResizeObserver.js +5 -0
  152. package/dist/runtime/helpers/NotificationHandler.d.ts +48 -0
  153. package/dist/runtime/helpers/NotificationHandler.js +162 -0
  154. package/dist/runtime/helpers/addValue.d.ts +1 -0
  155. package/dist/runtime/helpers/addValue.js +8 -0
  156. package/dist/runtime/helpers/base64ToImg.d.ts +1 -0
  157. package/dist/runtime/helpers/base64ToImg.js +11 -0
  158. package/dist/runtime/helpers/copy.d.ts +1 -0
  159. package/dist/runtime/helpers/copy.js +10 -0
  160. package/dist/runtime/helpers/createNoonUtcDate.d.ts +7 -0
  161. package/dist/runtime/helpers/createNoonUtcDate.js +14 -0
  162. package/dist/runtime/helpers/defaultTranslationFunction.d.ts +16 -0
  163. package/dist/runtime/helpers/defaultTranslationFunction.js +14 -0
  164. package/dist/runtime/helpers/getTimeZoneList.d.ts +1 -0
  165. package/dist/runtime/helpers/getTimeZoneList.js +3 -0
  166. package/dist/runtime/helpers/hasModifiers.d.ts +1 -0
  167. package/dist/runtime/helpers/hasModifiers.js +1 -0
  168. package/dist/runtime/helpers/index.d.ts +8 -0
  169. package/dist/runtime/helpers/index.js +8 -0
  170. package/dist/runtime/helpers/readFile.d.ts +1 -0
  171. package/dist/runtime/helpers/readFile.js +13 -0
  172. package/dist/runtime/helpers/resizeObserverWrapper.d.ts +8 -0
  173. package/dist/runtime/helpers/resizeObserverWrapper.js +37 -0
  174. package/dist/runtime/helpers/storybook.d.ts +7 -0
  175. package/dist/runtime/helpers/storybook.js +42 -0
  176. package/dist/runtime/main.lib.d.ts +26 -0
  177. package/dist/runtime/main.lib.js +8 -0
  178. package/dist/runtime/nuxt/plugins/vue-plugin.d.ts +2 -0
  179. package/dist/runtime/nuxt/plugins/vue-plugin.js +12 -0
  180. package/dist/runtime/tailwind/index.d.ts +1 -0
  181. package/dist/runtime/tailwind/index.js +1 -0
  182. package/dist/runtime/tailwind/themeConvertionOpts.d.ts +2 -0
  183. package/dist/runtime/tailwind/themeConvertionOpts.js +12 -0
  184. package/dist/runtime/theme.d.ts +2 -0
  185. package/dist/runtime/theme.js +2 -0
  186. package/dist/runtime/types/index.d.ts +119 -0
  187. package/dist/runtime/types/index.js +0 -0
  188. package/dist/runtime/utils/twMerge.d.ts +10 -0
  189. package/dist/runtime/utils/twMerge.js +10 -0
  190. package/dist/runtime/vue/VueComponentsPlugin.d.ts +2 -0
  191. package/dist/runtime/vue/VueComponentsPlugin.js +10 -0
  192. package/dist/runtime/vue/registerComponents.d.ts +19 -0
  193. package/dist/runtime/vue/registerComponents.js +10 -0
  194. package/dist/runtime/vue/registerDirectives.d.ts +3 -0
  195. package/dist/runtime/vue/registerDirectives.js +9 -0
  196. package/dist/types.d.mts +7 -0
  197. package/dist/types.d.ts +7 -0
  198. package/package.json +207 -0
  199. package/src/module.ts +176 -0
  200. package/src/runtime/assets/base.css +67 -0
  201. package/src/runtime/assets/locales/en.json +33 -0
  202. package/src/runtime/assets/style.css +144 -0
  203. package/src/runtime/assets/tailwind.css +5 -0
  204. package/src/runtime/assets/theme.css +65 -0
  205. package/src/runtime/build/WitchcraftUiResolver.ts +27 -0
  206. package/src/runtime/build/generateTheme.ts +16 -0
  207. package/src/runtime/build/unpluginIconViteOptions.ts +11 -0
  208. package/src/runtime/components/Aria/Aria.vue +27 -0
  209. package/src/runtime/components/Focus.stories.ts +67 -0
  210. package/src/runtime/components/Icon/Icon.vue +39 -0
  211. package/src/runtime/components/LibButton/LibButton.stories.ts +107 -0
  212. package/src/runtime/components/LibButton/LibButton.vue +247 -0
  213. package/src/runtime/components/LibCheckbox/LibCheckbox.stories.ts +41 -0
  214. package/src/runtime/components/LibCheckbox/LibCheckbox.vue +132 -0
  215. package/src/runtime/components/LibColorInput/LibColorInput.stories.ts +69 -0
  216. package/src/runtime/components/LibColorInput/LibColorInput.vue +125 -0
  217. package/src/runtime/components/LibColorPicker/LibColorPicker.stories.ts +60 -0
  218. package/src/runtime/components/LibColorPicker/LibColorPicker.vue +448 -0
  219. package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts +51 -0
  220. package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +95 -0
  221. package/src/runtime/components/LibDatePicker/LibDatePicker.stories.ts +114 -0
  222. package/src/runtime/components/LibDatePicker/LibDatePicker.vue +67 -0
  223. package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +370 -0
  224. package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +314 -0
  225. package/src/runtime/components/LibDatePicker/LibTimeZonePicker.vue +27 -0
  226. package/src/runtime/components/LibDatePicker/helpers.ts +55 -0
  227. package/src/runtime/components/LibDebug/LibDebug.stories.ts +58 -0
  228. package/src/runtime/components/LibDebug/LibDebug.vue +91 -0
  229. package/src/runtime/components/LibDevOnly/LibDevOnly.vue +53 -0
  230. package/src/runtime/components/LibFileInput/LibFileInput.stories.ts +79 -0
  231. package/src/runtime/components/LibFileInput/LibFileInput.vue +273 -0
  232. package/src/runtime/components/LibInput/LibInput.stories.ts +367 -0
  233. package/src/runtime/components/LibInput/LibInput.vue +372 -0
  234. package/src/runtime/components/LibLabel/LibLabel.stories.ts +37 -0
  235. package/src/runtime/components/LibLabel/LibLabel.vue +66 -0
  236. package/src/runtime/components/LibMultiValues/LibMultiValues.stories.ts +83 -0
  237. package/src/runtime/components/LibMultiValues/LibMultiValues.vue +127 -0
  238. package/src/runtime/components/LibNotifications/LibNotification.stories.ts +142 -0
  239. package/src/runtime/components/LibNotifications/LibNotification.vue +121 -0
  240. package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +124 -0
  241. package/src/runtime/components/LibNotifications/LibNotifications.vue +133 -0
  242. package/src/runtime/components/LibPagination/LibPagination.stories.ts +53 -0
  243. package/src/runtime/components/LibPagination/LibPagination.vue +261 -0
  244. package/src/runtime/components/LibPalette/LibPalette.stories.ts +32 -0
  245. package/src/runtime/components/LibPalette/LibPalette.vue +49 -0
  246. package/src/runtime/components/LibPopup/LibPopup.stories.ts +157 -0
  247. package/src/runtime/components/LibPopup/LibPopup.vue +441 -0
  248. package/src/runtime/components/LibProgressBar/LibProgressBar.stories.ts +94 -0
  249. package/src/runtime/components/LibProgressBar/LibProgressBar.vue +192 -0
  250. package/src/runtime/components/LibRecorder/LibRecorder.stories.ts +81 -0
  251. package/src/runtime/components/LibRecorder/LibRecorder.vue +243 -0
  252. package/src/runtime/components/LibRoot/LibRoot.vue +126 -0
  253. package/src/runtime/components/LibSimpleInput/LibSimpleInput.stories.ts +98 -0
  254. package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +148 -0
  255. package/src/runtime/components/LibSuggestions/LibSuggestions.stories.ts +137 -0
  256. package/src/runtime/components/LibSuggestions/LibSuggestions.vue +198 -0
  257. package/src/runtime/components/LibTable/LibTable.stories.ts +170 -0
  258. package/src/runtime/components/LibTable/LibTable.vue +177 -0
  259. package/src/runtime/components/Template/NAME.vue +49 -0
  260. package/src/runtime/components/Template/TemplateStory.ts +38 -0
  261. package/src/runtime/components/TestControls/TestControls.vue +19 -0
  262. package/src/runtime/components/index.ts +22 -0
  263. package/src/runtime/components/reset.stories.ts +32 -0
  264. package/src/runtime/components/shared/props.ts +142 -0
  265. package/src/runtime/components/shared/storyHelpers/playInput.ts +35 -0
  266. package/src/runtime/components/shared/storyHelpers/playSuggestions.ts +105 -0
  267. package/src/runtime/composables/index.ts +13 -0
  268. package/src/runtime/composables/useAccesibilityOutline.ts +104 -0
  269. package/src/runtime/composables/useAriaLabel.ts +23 -0
  270. package/src/runtime/composables/useDarkMode.ts +146 -0
  271. package/src/runtime/composables/useDivideAttrs.ts +52 -0
  272. package/src/runtime/composables/useGlobalResizeObserver.ts +33 -0
  273. package/src/runtime/composables/useInjectedDarkMode.ts +15 -0
  274. package/src/runtime/composables/useInjectedI18n.ts +10 -0
  275. package/src/runtime/composables/useInjectedLocale.ts +24 -0
  276. package/src/runtime/composables/useNotificationHandler.ts +32 -0
  277. package/src/runtime/composables/useScrollNearContainerEdges.stories.ts +93 -0
  278. package/src/runtime/composables/useScrollNearContainerEdges.ts +205 -0
  279. package/src/runtime/composables/useSetupDarkMode.ts +14 -0
  280. package/src/runtime/composables/useSetupI18n.ts +77 -0
  281. package/src/runtime/composables/useSetupLocale.ts +32 -0
  282. package/src/runtime/composables/useShowDevOnlyKey.ts +28 -0
  283. package/src/runtime/composables/useSuggestions.ts +297 -0
  284. package/src/runtime/directives/index.ts +6 -0
  285. package/src/runtime/directives/vDetectFlex.ts +159 -0
  286. package/src/runtime/directives/vExtractRootEl.ts +38 -0
  287. package/src/runtime/directives/vResizableCols.ts +378 -0
  288. package/src/runtime/directives/vResizeObserver.ts +45 -0
  289. package/src/runtime/globalResizeObserver.ts +12 -0
  290. package/src/runtime/helpers/NotificationHandler.ts +227 -0
  291. package/src/runtime/helpers/addValue.ts +10 -0
  292. package/src/runtime/helpers/base64ToImg.ts +14 -0
  293. package/src/runtime/helpers/copy.ts +11 -0
  294. package/src/runtime/helpers/createNoonUtcDate.ts +21 -0
  295. package/src/runtime/helpers/defaultTranslationFunction.ts +33 -0
  296. package/src/runtime/helpers/getTimeZoneList.ts +4 -0
  297. package/src/runtime/helpers/hasModifiers.ts +1 -0
  298. package/src/runtime/helpers/index.ts +10 -0
  299. package/src/runtime/helpers/readFile.ts +22 -0
  300. package/src/runtime/helpers/resizeObserverWrapper.ts +45 -0
  301. package/src/runtime/helpers/storybook.ts +52 -0
  302. package/src/runtime/main.lib.ts +31 -0
  303. package/src/runtime/nuxt/plugins/vue-plugin.ts +19 -0
  304. package/src/runtime/tailwind/index.ts +3 -0
  305. package/src/runtime/tailwind/themeConvertionOpts.ts +15 -0
  306. package/src/runtime/theme.ts +5 -0
  307. package/src/runtime/types/index.ts +116 -0
  308. package/src/runtime/utils/twMerge.ts +13 -0
  309. package/src/runtime/vue/VueComponentsPlugin.ts +16 -0
  310. package/src/runtime/vue/registerComponents.ts +31 -0
  311. package/src/runtime/vue/registerDirectives.ts +12 -0
  312. package/types/components.d.ts +27 -0
  313. package/types/global.d.ts +16 -0
  314. package/types/index.d.ts +5 -0
  315. package/types/vite.d.ts +2 -0
@@ -0,0 +1,78 @@
1
+ import * as components from "../index.js";
2
+ const meta = {
3
+ component: components.LibSimpleInput,
4
+ title: "Components/SimpleInput",
5
+ args: {
6
+ modelValue: "Value",
7
+ placeholder: "Placeholder"
8
+ }
9
+ };
10
+ export default meta;
11
+ export const Primary = {
12
+ args: {
13
+ modelValue: "some value"
14
+ },
15
+ render: (args) => ({
16
+ components,
17
+ // eslint-disable-next-line no-console
18
+ setup: () => ({ args, test: () => console.log("Enter") }),
19
+ template: `
20
+ <lib-simple-input
21
+ @keydown="test"
22
+ class="m-2" v-bind="args" v-model="args.modelValue" ></lib-simple-input>
23
+ <lib-simple-input class="m-2" v-bind="{...args, modelValue:''}" ></lib-simple-input>
24
+ `
25
+ })
26
+ };
27
+ export const InsideAFlexbox = {
28
+ render: (args) => ({
29
+ components,
30
+ setup: () => ({ args }),
31
+ template: `
32
+ Inside a flexbox:
33
+ <div class="flex flex-wrap">
34
+ <lib-simple-input v-bind="args" v-model="args.modelValue"></lib-simple-input>
35
+ <div class="border-1 border-danger-500 flex-1 whitespace-nowrap">Flex Grow: 1</div>
36
+ </div>
37
+ `
38
+ }),
39
+ args: {
40
+ stretch: true
41
+ }
42
+ };
43
+ export const Disabled = {
44
+ ...Primary,
45
+ args: {
46
+ disabled: true
47
+ }
48
+ };
49
+ export const Readonly = {
50
+ ...Primary,
51
+ args: {
52
+ readonly: true
53
+ }
54
+ };
55
+ export const Invalid = {
56
+ ...Primary,
57
+ args: {
58
+ valid: false
59
+ }
60
+ };
61
+ export const Borderless = {
62
+ ...Primary,
63
+ args: {
64
+ border: false
65
+ }
66
+ };
67
+ export const Numerical = {
68
+ ...Primary,
69
+ args: {
70
+ type: "number"
71
+ }
72
+ };
73
+ export const NumericalInsideAFlexbox = {
74
+ ...InsideAFlexbox,
75
+ args: {
76
+ type: "number"
77
+ }
78
+ };
@@ -0,0 +1,148 @@
1
+ <template>
2
+ <input
3
+ :id="id ?? fallbackId"
4
+ :class="twMerge(`
5
+ input
6
+ flex-1
7
+ grow-[999999]
8
+ rounded-sm
9
+ px-1
10
+ focus-outline
11
+ min-w-[2rem]
12
+ bg-inherit
13
+ placeholder:text-neutral-400
14
+ placeholder:focus:text-accent-300
15
+ read-only:bg-neutral-50
16
+ read-only:text-neutral-800
17
+ read-only:placeholder:select-none
18
+ read-only:placeholder:text-opacity-0
19
+ read-only:focus:placeholder:text-opacity-0
20
+ disabled:placeholder:text-nuetral-400
21
+ disabled:cursor-unset
22
+ disabled:bg-neutral-50
23
+ disabled:text-neutral-400
24
+ dark:read-only:bg-neutral-950
25
+ dark:read-only:text-neutral-200
26
+ dark:disabled:placeholder:text-nuetral-600
27
+ dark:disabled:bg-neutral-950
28
+ dark:disabled:text-neutral-500
29
+ `,
30
+ type === `text` && `
31
+ min-w-[10ch]
32
+ w-full
33
+ `,
34
+ type === `number` && `
35
+ w-12
36
+ placeholder:text-transparent
37
+ appearance-none
38
+ pr-0
39
+ `,
40
+ border && `
41
+ border
42
+ border-neutral-500
43
+ focus:border-accent-500
44
+ disabled:border-neutral-400
45
+ dark:disabled:border-neutral-600
46
+ `,
47
+ !valid && `
48
+ placeholder:text-danger-700
49
+ border-danger-700
50
+ focus:border-danger-700
51
+ outlined:!ring-danger-700
52
+ text-danger-800
53
+ dark:text-danger-400
54
+ dark:placeholder:text-danger-700
55
+ dark:border-danger-600
56
+ `,
57
+ ($attrs as any)?.class
58
+ )"
59
+ :data-border="border"
60
+ :data-invalid="!valid"
61
+ :type="type"
62
+ :placeholder="placeholder"
63
+ :disabled="disabled"
64
+ :readonly="readonly"
65
+ v-model="modelValue"
66
+ v-bind="{...$attrs, class:undefined, ...ariaLabel}"
67
+ @keydown="handleKeydown"
68
+ @input="emit('input', $event as InputEvent)"
69
+ >
70
+ </template>
71
+
72
+
73
+ <script lang="ts" setup generic="T">
74
+ import { keys } from "@alanscodelog/utils/keys.js"
75
+ import { pick } from "@alanscodelog/utils/pick.js"
76
+ import type { MakeRequired } from "@alanscodelog/utils/types"
77
+ import { castType } from "@alanscodelog/utils/utils"
78
+ import { getCurrentInstance, type InputHTMLAttributes, type InputTypeHTMLAttribute,toRef,useAttrs } from "vue"
79
+
80
+ import { useAriaLabel } from "../../composables/useAriaLabel.js"
81
+ import { hasModifiers } from "../../helpers/hasModifiers.js"
82
+ import { twMerge } from "../../utils/twMerge.js"
83
+ import { type BaseInteractiveProps, baseInteractivePropsDefaults, getFallbackId,type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
84
+
85
+
86
+ defineOptions({
87
+ name: "lib-simple-input",
88
+ inheritAttrs: false,
89
+ })
90
+
91
+ const fallbackId = getFallbackId()
92
+
93
+ // eslint-disable-next-line no-use-before-define
94
+ const props = withDefaults(defineProps<Props>(), {
95
+ id: "",
96
+ placeholder: "",
97
+ valid: true,
98
+ label: "",
99
+ type: undefined,
100
+ ...baseInteractivePropsDefaults
101
+ })
102
+
103
+ const modelValue = defineModel<T>({ required: true })
104
+
105
+ const emit = defineEmits<{
106
+ /* User presses enter.*/
107
+ (e: "submit", val: T): void
108
+ (e: "input", val: InputEvent): void
109
+ }>()
110
+ const $attrs = useAttrs()
111
+ const ariaLabel = useAriaLabel(props, fallbackId)
112
+
113
+ function handleKeydown(e: KeyboardEvent) {
114
+ if (e.key === "Enter" && !hasModifiers(e)) {
115
+ emit("submit", modelValue.value)
116
+ }
117
+ }
118
+
119
+ </script>
120
+
121
+ <script lang="ts">
122
+
123
+ type RealProps =
124
+ & LinkableByIdProps
125
+ & LabelProps
126
+ & BaseInteractiveProps
127
+ & {
128
+ placeholder?: InputHTMLAttributes["placeholder"]
129
+ disabled?: InputHTMLAttributes["disabled"]
130
+ id?: InputHTMLAttributes["id"]
131
+ type?: InputHTMLAttributes["type"]
132
+ valid?: boolean
133
+ }
134
+
135
+ interface Props
136
+ extends
137
+ /** @vue-ignore */
138
+ Partial<Omit<
139
+ InputHTMLAttributes,
140
+ | "class"
141
+ | "readonly"
142
+ | "disabled"
143
+ | "onSubmit"
144
+ | "onInput"
145
+ > & TailwindClassProp>,
146
+ RealProps
147
+ {}
148
+ </script>
@@ -0,0 +1,27 @@
1
+ import type { StoryObj } from "@storybook/vue3";
2
+ import LibSuggestions from "./LibSuggestions.vue.js";
3
+ declare const meta: {
4
+ component: any;
5
+ title: string;
6
+ args: {
7
+ id: string;
8
+ modelValue: string;
9
+ label: string;
10
+ border: boolean;
11
+ suggestions: string[];
12
+ };
13
+ };
14
+ export default meta;
15
+ type Story = StoryObj<typeof LibSuggestions>;
16
+ /**
17
+ * The suggestions component is just the dropdown part.
18
+ *
19
+ * Here it is decoupled from the input.
20
+ *
21
+ * More examples can be found in the input component.
22
+ */
23
+ export declare const Primary: Story;
24
+ export declare const RestrictToSuggestions: Story;
25
+ export declare const AlwaysShowAllSuggestions: any;
26
+ export declare const AlwaysShowAllSuggestionsAndNoRestrictToSuggestions: any;
27
+ export declare const CustomSuggestionsObject: any;
@@ -0,0 +1,112 @@
1
+ import { computed, onMounted, ref } from "vue";
2
+ import LibSuggestions from "./LibSuggestions.vue";
3
+ import * as components from "../index.js";
4
+ const meta = {
5
+ component: LibSuggestions,
6
+ title: "Components/Suggestions",
7
+ args: {
8
+ id: "some-id",
9
+ modelValue: "",
10
+ label: "Some Label",
11
+ border: true,
12
+ suggestions: ["A", "AB", "ABC", "B", "BC", "C", "ABCDEFGHIJKLMNOPQRSTUVWXYZ"]
13
+ }
14
+ };
15
+ export default meta;
16
+ export const Primary = {
17
+ render: (args) => ({
18
+ components: { ...components, LibSuggestions },
19
+ setup: () => {
20
+ const inputValue = ref(args.modelValue);
21
+ const modelValue = ref(args.modelValue);
22
+ const drawer = ref(null);
23
+ const keydownHandler = (e) => {
24
+ drawer.value?.inputKeydownHandler(e);
25
+ };
26
+ const suggestions = computed(() => drawer.value?.suggestions);
27
+ const blurHandler = (e) => {
28
+ drawer.value?.inputBlurHandler(e);
29
+ };
30
+ onMounted(() => {
31
+ drawer.value?.suggestions.open();
32
+ });
33
+ return {
34
+ args,
35
+ inputValue,
36
+ modelValue,
37
+ isOpen: ref(false),
38
+ suggestions,
39
+ drawer,
40
+ keydownHandler,
41
+ blurHandler
42
+ };
43
+ },
44
+ template: `
45
+ <div class="flex flex-col gap-3">
46
+ Temporary Value: {{inputValue}}
47
+ <br/>
48
+ Model Value (Final Value): <span class="inline-block" data-testid="model-value">{{modelValue}}</span>
49
+
50
+
51
+ <br/>
52
+ Selected: {{suggestions?.filtered[suggestions.active]}}
53
+ <label>Some Label</label>
54
+ <lib-simple-input
55
+ :class="isOpen ? 'open' : ''"
56
+ v-model="inputValue"
57
+ @focus="suggestions.open()"
58
+ @blur="blurHandler"
59
+ @keydown="keydownHandler"
60
+ ></lib-simple-input>
61
+ <lib-suggestions
62
+ ref="drawer"
63
+ v-bind="{...args}"
64
+ @update:isOpen="isOpen = $event"
65
+ v-model="modelValue"
66
+ v-model:inputValue="inputValue"
67
+ >
68
+ <template #item={item}>
69
+ {{item}}
70
+ </template>
71
+ </lib-suggestions>
72
+ </div>
73
+ `
74
+ })
75
+ };
76
+ export const RestrictToSuggestions = {
77
+ ...Primary,
78
+ args: {
79
+ ...Primary.args,
80
+ restrictToSuggestions: true
81
+ }
82
+ };
83
+ export const AlwaysShowAllSuggestions = {
84
+ ...Primary,
85
+ args: {
86
+ ...Primary.args,
87
+ restrictToSuggestions: true,
88
+ suggestionsFilter: (_input, items) => items
89
+ }
90
+ };
91
+ export const AlwaysShowAllSuggestionsAndNoRestrictToSuggestions = {
92
+ ...Primary,
93
+ args: {
94
+ ...Primary.args,
95
+ restrictToSuggestions: false,
96
+ suggestionsFilter: (_input, items) => items
97
+ }
98
+ };
99
+ export const CustomSuggestionsObject = {
100
+ ...Primary,
101
+ args: {
102
+ ...Primary.args,
103
+ restrictToSuggestions: true,
104
+ suggestions: [
105
+ { label: "A", other: "some data A" },
106
+ { label: "AB", other: "some data AB" },
107
+ { label: "ABC", other: "some data ABC" },
108
+ { label: "ABCDEFGHIJKLMNOPQRSTUVWXYZ", other: "some data ABCDEFGHIJKLMNOPQRSTUVWXYZ" }
109
+ ],
110
+ suggestionLabel: (item) => item.label
111
+ }
112
+ };
@@ -0,0 +1,198 @@
1
+ <template>
2
+ <div
3
+ v-if="suggestions.isOpen"
4
+ :id="`suggestions-${id ?? fallbackId}`"
5
+ :class="twMerge(`
6
+ suggestions
7
+ bg-bg
8
+ dark:bg-fg
9
+ `,
10
+ ($.attrs as any)?.class
11
+ )"
12
+ :data-open="suggestions.isOpen"
13
+ role="listbox"
14
+ ref="el"
15
+ v-bind="{...$.attrs, class:undefined}"
16
+ >
17
+ <!-- Click event is just in case, it should not really be triggered. We can do click selections via the blur handler. -->
18
+ <div :id="`suggestion-${id ?? fallbackId}-${index}`"
19
+ role="option"
20
+ :class="twMerge(`
21
+ px-1
22
+ user-select-none
23
+ cursor-pointer
24
+ px-2
25
+ `,
26
+ index=== suggestions.active && `bg-accent-200 dark:bg-accent-800`,
27
+ ($.itemAttrs as any)?.class
28
+ )"
29
+ v-bind="{...$.itemAttrs, class:undefined}"
30
+ :aria-selected="index === suggestions.active ? true : false"
31
+ :aria-label="suggestions.getLabel(item)"
32
+ v-for="(item, index) in suggestions.filtered"
33
+ :key="item"
34
+ @mouseover="suggestions.active = index"
35
+ @mousedown.prevent
36
+ @mouseup="suggestions.enterSuggestion(index)"
37
+ >
38
+ <slot name="item" :item="item" :index="index">
39
+ {{ item }}
40
+ </slot>
41
+ </div>
42
+ </div>
43
+ </template>
44
+
45
+
46
+ <script setup lang="ts" generic="TSuggestion extends string | object">
47
+
48
+ import { type HTMLAttributes,reactive, ref } from "vue"
49
+
50
+ import { useDivideAttrs } from "../../composables/useDivideAttrs.js"
51
+ import { useSuggestions } from "../../composables/useSuggestions.js"
52
+ import { hasModifiers } from "../../helpers/hasModifiers.js"
53
+ import { twMerge } from "../../utils/twMerge.js"
54
+ import { type BaseInteractiveProps, baseInteractivePropsDefaults, getFallbackId,type LabelProps, type LinkableByIdProps, type MultiValueProps, type SuggestionsEmits, type SuggestionsProps, type WrapperProps } from "../shared/props.js"
55
+
56
+ defineOptions({
57
+ name: "lib-suggestions",
58
+ inheritAttrs: false,
59
+ })
60
+
61
+ const $ = useDivideAttrs(["item"] as const)
62
+
63
+ const emits = defineEmits<SuggestionsEmits>()
64
+
65
+ const fallbackId = getFallbackId()
66
+ // eslint-disable-next-line no-use-before-define
67
+ const props = withDefaults(defineProps<Props & SuggestionsProps<TSuggestion>>(), {
68
+ isValid: true,
69
+ canOpen: true,
70
+ values: undefined,
71
+ filterKeydown: undefined,
72
+ ...baseInteractivePropsDefaults
73
+ })
74
+
75
+ /**
76
+ * 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.
77
+ *
78
+ * If suggestions are objects, this will be the string returned by the `suggestionLabel` prop.
79
+ */
80
+ const $modelValue = defineModel<string>("modelValue", { required: true })
81
+ /**
82
+ * If the element is bound to an input, this is the value that the input should be sharing.
83
+ *
84
+ * 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.
85
+ */
86
+ const $inputValue = defineModel<string >("inputValue", { default: "" })
87
+
88
+
89
+ if (typeof props.suggestions?.[0] === "object" && !props.suggestionLabel && !props.suggestionsFilter) {
90
+ throw new Error("`suggestionLabel` or `suggestionsFilter` must be passed if suggestions are objects.")
91
+ }
92
+
93
+ const el = ref<HTMLElement | null>(null)
94
+ const mousedown = ref(false)
95
+
96
+ const suggestions = reactive(useSuggestions(
97
+ $inputValue,
98
+ $modelValue,
99
+ emits,
100
+ props
101
+ ))
102
+
103
+ const inputKeydownHandler = (e: KeyboardEvent): void => {
104
+ if (props.filterKeydown?.(e)) return
105
+ if (hasModifiers(e)) return
106
+ if (e.key === "Enter") {
107
+ suggestions.enterSelected()
108
+ e.preventDefault()
109
+ } else if (e.key === "Escape") {
110
+ suggestions.cancel()
111
+ e.preventDefault()
112
+ } else if (!suggestions.isOpen && ["ArrowDown", "ArrowUp", "PageUp", "PageDown"].includes(e.key) && suggestions.available) {
113
+ suggestions.open()
114
+ e.preventDefault()
115
+ if (e.key === "PageUp") {
116
+ suggestions.first()
117
+ } else if (e.key === "PageDown") {
118
+ suggestions.last()
119
+ }
120
+ } else if (e.key === "ArrowUp") {
121
+ suggestions.prev()
122
+ e.preventDefault()
123
+ } else if (e.key === "ArrowDown") {
124
+ suggestions.next()
125
+ e.preventDefault()
126
+ } else if (e.key === "PageUp") {
127
+ suggestions.first()
128
+ e.preventDefault()
129
+ } else if (e.key === "PageDown") {
130
+ suggestions.last()
131
+ e.preventDefault()
132
+ }
133
+ }
134
+ const inputBlurHandler = (e: MouseEvent): void => {
135
+ if (props.filterBlur?.(e)) return
136
+
137
+ if (!suggestions.isOpen) return
138
+
139
+ if (props.restrictToSuggestions) {
140
+ suggestions.cancel()
141
+ } else {
142
+ $modelValue.value = $inputValue.value
143
+ }
144
+ if (suggestions.isOpen) {
145
+ suggestions.close()
146
+ }
147
+ }
148
+ const inputFocusHandler = (e: FocusEvent): void => {
149
+ if (props.filterFocus?.(e)) return
150
+ suggestions.open()
151
+ }
152
+
153
+ defineExpose({
154
+ suggestions,
155
+ el,
156
+ /** A simple keydown handler that can be passed to an input to control the component while still focused inside it. */
157
+ inputKeydownHandler,
158
+ /** 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. */
159
+ inputBlurHandler,
160
+ /** A focus handler for the input that controls the component. */
161
+ inputFocusHandler,
162
+ })
163
+
164
+ </script>
165
+
166
+ <script lang="ts">
167
+ type WrapperTypes = Partial<WrapperProps<"item",HTMLAttributes, {
168
+ /** Tailwind classes. */
169
+ class?: string
170
+ }>>
171
+
172
+ type RealProps =
173
+ & LinkableByIdProps
174
+ & LabelProps
175
+ & BaseInteractiveProps
176
+ & MultiValueProps
177
+ & {
178
+ /** Return true to prevent the keydown event from being handled. */
179
+ filterKeydown?: (e: KeyboardEvent) => boolean
180
+ /** Return true to prevent the blur event from being handled. */
181
+ filterBlur?: (e: MouseEvent) => boolean
182
+ /** Return true to prevent the focus event from being handled. */
183
+ filterFocus?: (e: FocusEvent) => boolean
184
+ }
185
+
186
+ interface Props
187
+ extends
188
+ /** @vue-ignore */
189
+ Partial<Omit<HTMLAttributes,"class" | "onSubmit"> & {
190
+ /** Tailwind classes. */
191
+ class?: string
192
+ }>,
193
+ /** @vue-ignore */
194
+ WrapperTypes,
195
+ RealProps
196
+ {}
197
+
198
+ </script>
@@ -0,0 +1,16 @@
1
+ import type { Meta, StoryObj } from "@storybook/vue3";
2
+ import LibTable from "./LibTable.vue.js";
3
+ declare const meta: Meta<typeof LibTable>;
4
+ export default meta;
5
+ type Story = StoryObj<typeof LibTable>;
6
+ export declare const Primary: Story;
7
+ export declare const NoCellBorders: Story;
8
+ export declare const NoBorders: Story;
9
+ export declare const NoCellBordersNoBorders: Story;
10
+ export declare const SquareBorders: Story;
11
+ export declare const NoHeader: Story;
12
+ export declare const NoHeaderNoBorders: Story;
13
+ export declare const NoHeaderNoCellBorders: Story;
14
+ export declare const FitWidthFalse: Story;
15
+ export declare const ThreeColSomeColsNotResizable: Story;
16
+ export declare const FourColSomeColsNotResizable: Story;