@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,192 @@
1
+ <template>
2
+ <Transition>
3
+ <div v-if="!hide"
4
+ :id="id ?? fallbackId"
5
+ :class="twMerge(`
6
+ w-[200px]
7
+ whitespace-nowrap
8
+ overflow-x-scroll
9
+ scrollbar-hidden
10
+ rounded-sm
11
+ flex
12
+ text-fg
13
+ relative
14
+ before:content-['']
15
+ text-sm
16
+ min-w-[50px]
17
+ after:shadow-inner
18
+ after:shadow-black/50
19
+ after:content-['']
20
+ after:absolute
21
+ after:inset-0
22
+ after:pointer-events-none
23
+ after:z-2
24
+ after:transition-all
25
+ before:shadow-inner
26
+ before:shadow-black/50
27
+ before:rounded-sm
28
+ before:bg-bars-gradient
29
+ before:animate-[slide_10s_linear_infinite]
30
+ before:[background-size:15px_15px]
31
+ before:absolute
32
+ before:w-[var(--progress)]
33
+ before:top-0 before:bottom-0 before:left-0
34
+ before:transition-all
35
+ before:z-1
36
+ before:duration-500
37
+ `,psuedoHide && `
38
+ after:opacity-0
39
+ before:opacity-0
40
+ `, ($attrs as any).class)"
41
+ :data-value="progress"
42
+ :title="label"
43
+ role="progressbar"
44
+ :aria-valuenow="clampVal(progress, clamp[0] ?? 0, clamp[1] ?? 100)"
45
+ :aria-valuemin="clamp[0] ?? 0"
46
+ :aria-valuemax="clamp[1] ?? 100"
47
+ v-bind="{...$attrs, class:undefined}"
48
+ :style="`--progress: ${clampVal(progress, clamp[0] ?? 0, clamp[1] ?? 100)}%;`"
49
+ >
50
+ <div class="label-wrapper relative flex-1">
51
+ <span class="before:content-vertical-holder"/>
52
+ <Transition>
53
+ <slot>
54
+ <label v-if="!psuedoHide"
55
+ :for="id"
56
+ class="
57
+ text-bg
58
+ absolute inset-0 flex
59
+ justify-center
60
+ "
61
+ >
62
+ <div class="truncate">
63
+ {{ label ?? "" }}
64
+ </div>
65
+ </label>
66
+ </slot>
67
+ </Transition>
68
+
69
+ <Transition>
70
+ <slot>
71
+ <label
72
+ v-if="!psuedoHide"
73
+ class="
74
+ contrast-label
75
+ pointer-events-none
76
+ absolute
77
+ inset-0
78
+ flex justify-center transition-all
79
+ duration-500
80
+ [clip-path:inset(0_0_0_var(--progress))]
81
+ dark:hidden
82
+ "
83
+ >
84
+ <div class="truncate">
85
+ {{ label ?? "" }}
86
+ </div>
87
+ </label>
88
+ </slot>
89
+ </Transition>
90
+ </div>
91
+ </div>
92
+ </Transition>
93
+ </template>
94
+ <script setup lang="ts">
95
+ import { type HTMLAttributes,type PropType, ref, watch } from "vue"
96
+
97
+ import { twMerge } from "../../utils/twMerge.js"
98
+ import { type BaseInteractiveProps, baseInteractivePropsDefaults,getFallbackId,type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
99
+
100
+ // TODO move to utils
101
+ const clampVal = (n: number, min: number, max: number) => Math.min(Math.max(n, min), max)
102
+
103
+ defineOptions({
104
+ name: "lib-progress-bar",
105
+ inheritAttrs: false,
106
+ })
107
+ const fallbackId = getFallbackId()
108
+ // eslint-disable-next-line no-use-before-define
109
+ const props = withDefaults(defineProps<Props>(), {
110
+ autohideOnComplete: -1,
111
+ keepSpaceWhenHidden: false,
112
+ clamp: () => [0, 100],
113
+ ...baseInteractivePropsDefaults
114
+ })
115
+ const hide = ref<boolean>(false)
116
+ const psuedoHide = ref<boolean>(false)
117
+ let timeout: number
118
+ let type: number
119
+ if (props.autohideOnComplete > -1 && (props.progress >= 100 || props.progress < 0)) {
120
+ if (props.keepSpaceWhenHidden) {
121
+ hide.value = false
122
+ psuedoHide.value = true
123
+ } else {
124
+ hide.value = true
125
+ psuedoHide.value = false
126
+ }
127
+ }
128
+
129
+ watch([
130
+ () => props.progress,
131
+ () => props.keepSpaceWhenHidden,
132
+ () => props.autohideOnComplete,
133
+ ], () => {
134
+ if (props.autohideOnComplete > -1 && (props.progress >= 100 || props.progress < 0)) {
135
+ if (props.keepSpaceWhenHidden) {
136
+ if (type === 1) return
137
+ clearTimeout(timeout)
138
+ type = 1
139
+ timeout = setTimeout(() => {
140
+ type = 0
141
+ hide.value = false
142
+ psuedoHide.value = true
143
+ }, props.autohideOnComplete) as any
144
+ } else {
145
+ if (type === 2) return
146
+ clearTimeout(timeout)
147
+ type = 2
148
+ timeout = setTimeout(() => {
149
+ type = 0
150
+ hide.value = true
151
+ psuedoHide.value = false
152
+ }, props.autohideOnComplete) as any
153
+ }
154
+ } else {
155
+ clearTimeout(timeout)
156
+ hide.value = false
157
+ psuedoHide.value = false
158
+ }
159
+ }, { immediate: false })
160
+
161
+ </script>
162
+ <script lang="ts">
163
+
164
+ type RealProps =
165
+ & LinkableByIdProps
166
+ & BaseInteractiveProps
167
+ & LabelProps
168
+ & {
169
+ progress: number
170
+ /** Will auto hide after this given time if progress is 100% or more or less than 0% until progress is set to something else. Disabled (-1) by default. */
171
+ autohideOnComplete?: number
172
+ /**
173
+ * Do not actually hide the element, just leave an unstyled div,
174
+ * so the whole layout doesn't change on completion when autohideOnComplete is set.
175
+ */
176
+ keepSpaceWhenHidden?: boolean
177
+ /**
178
+ * By default the progress bar is visually clamped to 0-100, even if the value might be something else.
179
+ * You can change what it's clamped to here, to for example,
180
+ * show at least a small sliver of the progress bar when it's still 0.
181
+ */
182
+ clamp?: [start:number, end:number]
183
+ }
184
+
185
+ interface Props
186
+ extends
187
+ /** @vue-ignore */
188
+ Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
189
+ RealProps
190
+ { }
191
+
192
+ </script>
@@ -0,0 +1,81 @@
1
+ /* eslint-disable @typescript-eslint/naming-convention */
2
+ import type { Meta, StoryObj } from "@storybook/vue3"
3
+ import { ref, watchEffect } from "vue"
4
+
5
+ import { createRecorderHandler, createRecorderWatchEffect } from "../../helpers/storybook.js"
6
+ // eslint-disable-next-line @typescript-eslint/no-restricted-imports
7
+ import * as components from "../index.js"
8
+ /**
9
+ * This is a special input component designed to record any type of event.
10
+ *
11
+ * It requires additional setup to actually work since what and how anything is recorded is up to the needs of the application.
12
+ *
13
+ * This basic implementation just lists the keys. Enter accepts the recording, escape cancels back to the initial value.
14
+ */
15
+ const meta: Meta<typeof components.LibRecorder> = {
16
+ component: components.LibRecorder,
17
+ title: "Components/Recorder",
18
+ args: {
19
+ label: "Some Label",
20
+ recordingTitle: "Recording. Press enter or click away to accept. Press escape to cancel.",
21
+ modelValue: "K E Y S",
22
+ },
23
+ }
24
+
25
+ export default meta
26
+ type Story = StoryObj<typeof components.LibRecorder>
27
+
28
+ export const Primary: Story = {
29
+ render: args => ({
30
+ components,
31
+ setup: () => {
32
+ const recording = ref(false)
33
+ const recordingValue = ref("")
34
+ const modelValue = ref(args.modelValue)
35
+ const recorderEl = ref(null)
36
+ const recorder = createRecorderHandler(recordingValue, recording, modelValue, recorderEl)
37
+ watchEffect(createRecorderWatchEffect(recordingValue, recording, modelValue))
38
+ return {
39
+ args,
40
+ modelValue,
41
+ recorder,
42
+ recording,
43
+ recordingValue,
44
+ recorderEl,
45
+ }
46
+ },
47
+ template: `
48
+ <lib-recorder
49
+ v-bind="args"
50
+ v-extract-root-el="_ => recorderEl = _"
51
+ :recordingValue="recordingValue"
52
+ :recorder="recorder"
53
+ v-model:recording="recording"
54
+ v-model="modelValue"
55
+ @recorder:click="recording = !recording"
56
+ />
57
+ `,
58
+ }),
59
+ }
60
+
61
+ /** Should not be tabbable or recordable. */
62
+ export const Disabled: Story = {
63
+ ...Primary,
64
+ args: {
65
+ disabled: true,
66
+ },
67
+ }
68
+ /** *Should* be tabbable but not recordable. */
69
+ export const Readonly: Story = {
70
+ ...Primary,
71
+ args: {
72
+ readonly: true,
73
+ },
74
+ }
75
+ /** Height should not shrink. */
76
+ export const EmptyInitialValue: Story = {
77
+ ...Primary,
78
+ args: {
79
+ modelValue: "",
80
+ },
81
+ }
@@ -0,0 +1,243 @@
1
+ <template>
2
+ <!--
3
+ We use a custom element for the recorder so we don't have to deal with the input event.
4
+ contenteditable=false is because of storybook, it's shortcuts interfere when not using real input elements
5
+ -->
6
+ <div
7
+ :id="id?? fallbackId"
8
+ :class="twMerge(`recorder
9
+ flex items-center
10
+ gap-2
11
+ px-2
12
+ grow-[999999]
13
+ focus-outline-no-offset
14
+ rounded-sm
15
+ `,
16
+ border &&`
17
+ border
18
+ border-neutral-500
19
+ focus:border-accent-500
20
+ `,
21
+
22
+ (disabled || readonly) && `
23
+ text-neutral-400
24
+ dark:text-neutral-600
25
+ `,
26
+ (disabled || readonly) && border && `
27
+ bg-neutral-50
28
+ dark:bg-neutral-950
29
+ border-neutral-400
30
+ dark:border-neutral-600
31
+ `
32
+ , ($attrs as any).class)"
33
+ :aria-disabled="disabled"
34
+ :aria-readonly="readonly"
35
+ :tabindex="disabled ? -1 : 0"
36
+ :title="recording ? recordingTitle : tempValue"
37
+ contenteditable="false"
38
+ ref="recorderEl"
39
+ v-bind="{...ariaLabel, ...$attrs, class:undefined}"
40
+ @blur="handleBlurRecorder($event)"
41
+ @click="handleClickRecorder($event)"
42
+ @keydown.space.prevent="handleClickRecorder($event, true)"
43
+ >
44
+ <!-- :aria-description="recording ? recordingTitle : ''" -->
45
+ <div
46
+ :class="twMerge(`recorder-indicator
47
+ inline-block
48
+ bg-red-700
49
+ rounded-full
50
+ w-[1em]
51
+ h-[1em]
52
+ shrink-0
53
+ hover:bg-red-500
54
+ `,
55
+ recording && `
56
+ animate-[blink_1s_infinite]
57
+ bg-red-500
58
+ `,
59
+ (disabled || readonly) && `
60
+ bg-neutral-500
61
+ `
62
+ )"
63
+ ref="recorderIndicatorEl"
64
+ />
65
+ <div class="recorder-value before:content-vertical-holder truncate">
66
+ {{ recording
67
+ ? recordingValue ?? t("recorder.recording")
68
+ : tempValue }}
69
+ </div>
70
+ </div>
71
+ </template>
72
+ <script setup lang="ts">
73
+ import { keys } from "@alanscodelog/utils/keys.js"
74
+ import { computed, type HTMLAttributes ,onBeforeUnmount, onMounted, type PropType, ref, watch, watchPostEffect } from "vue"
75
+
76
+ import { useAriaLabel } from "../../composables/useAriaLabel.js"
77
+ import { useInjectedI18n } from "../../composables/useInjectedI18n.js"
78
+ import { twMerge } from "../../utils/twMerge.js"
79
+ import { type BaseInteractiveProps, baseInteractivePropsDefaults, getFallbackId, type LabelProps, type LinkableByIdProps,type TailwindClassProp } from "../shared/props.js"
80
+
81
+ defineOptions({
82
+ name: "lib-recorder",
83
+ inheritAttrs: false,
84
+ })
85
+ const t = useInjectedI18n()
86
+
87
+ const emits = defineEmits<{
88
+ /** Recorder is blurred */
89
+ (e: "recorder:blur", $event: FocusEvent): void
90
+ /** Recorder is clicked. The component's indicator and recorder elements are passed to help filter out those clicks. */
91
+ (e: "recorder:click", { event, indicator, input }: { event: MouseEvent | KeyboardEvent, indicator: HTMLElement, input: HTMLInputElement }): void
92
+ /* User presses enter. Not emitted when multiple values are used. */
93
+ (e: "focus:parent"): void
94
+ }>()
95
+ const fallbackId = getFallbackId()
96
+ // eslint-disable-next-line no-use-before-define
97
+ const props = withDefaults(defineProps<Props>(), {
98
+ recordingTitle: "",
99
+ id: undefined,
100
+ binders: undefined,
101
+ recorder: undefined,
102
+ ...baseInteractivePropsDefaults
103
+ })
104
+ /**
105
+ * Puts the element into recording mode if true. See {@link props.recorder}.
106
+ */
107
+ const recording = defineModel<boolean>("recording", { required: false, default: false })
108
+
109
+ /** The final value of the recorder. For intermediate values while recording, pass a recorder and set an appropriate recording value. */
110
+ const modelValue = defineModel<string>({ required: true })
111
+
112
+
113
+ const recorderEl = ref<HTMLInputElement | null>(null)
114
+ const recorderIndicatorEl = ref<HTMLElement | null>(null)
115
+ const canEdit = computed(() => !props.disabled && !props.readonly)
116
+ const tempValue = ref(modelValue.value)
117
+
118
+ watch([() => props.binders, () => props.binders], () => {
119
+ if (recording.value) {
120
+ throw new Error("Component was not designed to allow swapping out of binders/recorders while recording")
121
+ }
122
+ })
123
+
124
+ watch(modelValue, () => {
125
+ tempValue.value = modelValue.value
126
+ })
127
+ const ariaLabel = useAriaLabel(props)
128
+
129
+ const boundListeners: Record<string, any> = {}
130
+ let isBound = false
131
+
132
+ const unbindListeners = (): void => {
133
+ if (!isBound) return
134
+ isBound = false
135
+ if (props.recorder) {
136
+ for (const key of keys(boundListeners)) {
137
+ recorderEl.value?.removeEventListener(key, boundListeners[key])
138
+ delete boundListeners[key]
139
+ }
140
+ }
141
+ if (props.binders && recorderEl.value) {
142
+ props.binders.unbind(recorderEl.value as HTMLInputElement)
143
+ }
144
+ }
145
+ const bindListeners = (): void => {
146
+ if (!props.recorder && !props.binders) {
147
+ throw new Error("Record is true but no recorder or binders props was passed")
148
+ }
149
+ if (props.recorder && props.binders) {
150
+ throw new Error("Recording is true and was passed both a recorder and a binders prop. Both cannot be used at the same time.")
151
+ }
152
+ isBound = true
153
+ if (props.recorder) {
154
+ for (const key of keys(props.recorder)) {
155
+ recorderEl.value?.addEventListener(key, props.recorder[key], { passive: false })
156
+ boundListeners[key] = props.recorder[key]
157
+ }
158
+ }
159
+ if (props.binders && recorderEl.value) {
160
+ props.binders.bind(recorderEl.value as HTMLInputElement)
161
+ }
162
+ }
163
+
164
+ watchPostEffect(() => {
165
+ if (!canEdit.value) {
166
+ unbindListeners()
167
+ recording.value = false
168
+ return
169
+ }
170
+ if (recording.value) {
171
+ bindListeners()
172
+ } else {
173
+ if ((props.recorder || props.binders) && isBound) {
174
+ unbindListeners()
175
+ // if we just blur the input then we can't shift+tab backwards
176
+ // this way we can go forwards or backwards without actually focusing since parentEl is not focusable
177
+ // parentEl.value?.focus()
178
+ emits("focus:parent")
179
+ }
180
+ }
181
+ })
182
+
183
+ onBeforeUnmount(() => {
184
+ unbindListeners()
185
+ })
186
+ onMounted(() => {
187
+ if (recording.value) {
188
+ bindListeners()
189
+ }
190
+ })
191
+
192
+ const handleBlurRecorder = (e: FocusEvent): void => {
193
+ if (!canEdit.value) return
194
+ if (props.recorder || props.binders) {
195
+ emits("recorder:blur", e)
196
+ }
197
+ }
198
+
199
+ const handleClickRecorder = (e: MouseEvent | KeyboardEvent, isSpaceKey: boolean = false): void => {
200
+ if (!canEdit.value) return
201
+ if (!recording.value) {
202
+ recorderEl.value?.focus()
203
+ }
204
+ // toggle if clicking on the recording indicator, otherwise only allow starting recording, so if needed, clicks can be recorded
205
+ if (props.recorder || props.binders) {
206
+ if (isSpaceKey) { return }
207
+ emits("recorder:click", { event: e as MouseEvent, indicator: recorderIndicatorEl.value! as HTMLElement, input: recorderEl.value! as HTMLInputElement })
208
+ }
209
+ }
210
+
211
+ </script>
212
+ <script lang="ts">
213
+ type RealProps =
214
+ & LinkableByIdProps
215
+ & BaseInteractiveProps
216
+ & LabelProps
217
+ & {
218
+ border?: boolean
219
+ /** A value to display while recording, if none given the i18n `recorder.recording` key is used. */
220
+ recordingValue?: string
221
+ /** A title to display on the input div while recording. Is also used as the aria-description. */
222
+ recordingTitle?: string
223
+ /**
224
+ * The recorder object is a series of event listeners to attach to the input div while recording is started. If you need to bind directly to the element, see the `binders` prop.
225
+ *
226
+ * The listeners are then unbound when recording is set to false again.
227
+ *
228
+ * Note that the component does not handle the setting of `recording` (unless the component is disabled), `modelValue`, or `recordingValue` at all and has no mechanism for cancelling a recording. It is left to the recorder listeners and any `recorder:*` handlers to determine what to do.
229
+ */
230
+ recorder?: undefined | Record<string, any>
231
+ /** This provides a way to manually attach/remove event listeners to/from the element. It is an alternative to the `recorder` prop, see it for more details. Both cannot be specified at the same time.*/
232
+ binders?: undefined | { bind: (el: HTMLElement) => void, unbind: (el: HTMLElement) => void }
233
+ /** The id of the element. If not provided, the id will be generated automatically. */
234
+ id?: string
235
+ }
236
+
237
+ interface Props
238
+ extends
239
+ /** @vue-ignore */
240
+ Partial<Omit<HTMLAttributes,"class"> & TailwindClassProp>,
241
+ RealProps
242
+ { }
243
+ </script>
@@ -0,0 +1,126 @@
1
+ <template>
2
+ <div :id="id"
3
+ tabindex="-1"
4
+ :class="twMerge(
5
+ (showOutline ? 'group outlined outlined-visible' : '[&_*]:outline-hidden'),
6
+ darkMode && ' dark',
7
+ ($attrs['wrapperAttrs'] as any)?.class
8
+ )"
9
+ v-bind="{ ...($attrs['wrapperAttrs']), attrs:undefined, class: undefined }"
10
+ :ref="handleRef"
11
+ >
12
+ <!-- id root is useful for teleports, so they are at the topmost level where they can still be styled -->
13
+ <!-- See TestControls for why the margins here -->
14
+ <div
15
+ id="root"
16
+ v-bind="{ ...$attrs.attrs, class: undefined, wrapperAttrs: undefined }"
17
+ :class="twMerge( `
18
+ dark:bg-fg
19
+ dark:text-bg
20
+ bg-bg
21
+ text-fg
22
+ `,
23
+ testWrapperMode && `
24
+ px-10
25
+ pb-10
26
+ `,
27
+ !testWrapperMode && `
28
+ min-h-dvh
29
+ flex
30
+ flex-col
31
+ `,
32
+ ($attrs as any).attrs?.class)"
33
+ >
34
+ <TestControls v-if="testWrapperMode" :show-outline="showOutline"/>
35
+ <slot/>
36
+ </div>
37
+ </div>
38
+ </template>
39
+
40
+ <script setup lang="ts">
41
+ import { unreachable } from "@alanscodelog/utils/unreachable.js"
42
+ import { type Theme } from "metamorphosis"
43
+ import { type ComponentPublicInstance, computed, onBeforeUnmount, onMounted, ref, toRaw } from "vue"
44
+
45
+ import { useAccesibilityOutline } from "../../composables/useAccesibilityOutline.js"
46
+ import { useDivideAttrs } from "../../composables/useDivideAttrs.js"
47
+ import { useSetupDarkMode } from "../../composables/useSetupDarkMode.js"
48
+ import { useSetupI18n } from "../../composables/useSetupI18n.js"
49
+ import { useSetupLocale } from "../../composables/useSetupLocale.js"
50
+ import { useShowDevOnlyKey } from "../../composables/useShowDevOnlyKey.js"
51
+ import { theme as defaultTheme } from "../../theme.js"
52
+ import { twMerge } from "../../utils/twMerge.js"
53
+ import TestControls from "../TestControls/TestControls.vue"
54
+
55
+ const $attrs = useDivideAttrs(["wrapper"])
56
+
57
+ defineOptions({ name: "root", inheritAttrs: false, suspensible: false })
58
+ const props = withDefaults(defineProps<{
59
+ theme?: Theme
60
+ outline?: boolean
61
+ forceOutline?: boolean
62
+ testWrapperMode?: boolean
63
+ id?: string
64
+ /** You can set a ref to the root element by passing :getRef="_ => el = _" */
65
+ getRef?: (el: HTMLElement | null) => void
66
+ /** True by default, should be passed import.meta.client if using nuxt, or false when running server side. */
67
+ isClientSide?: boolean
68
+ useBuiltinTranslations?: boolean
69
+ }>(), {
70
+ theme: undefined,
71
+ testWrapperMode: false,
72
+ outline: true,
73
+ forceOutline: false,
74
+ id: "app",
75
+ getRef: undefined,
76
+ isClientSide: true,
77
+ useBuiltinTranslations: true
78
+ })
79
+
80
+ const el = ref<HTMLElement | null>(null)
81
+
82
+ function handleRef(_: Element | ComponentPublicInstance | null): void {
83
+ if (_ !== null && !(_ instanceof HTMLElement)) unreachable()
84
+ el.value = _
85
+ props.getRef?.(_)
86
+ }
87
+
88
+ const autoOutline = useAccesibilityOutline(el).outline
89
+
90
+ const showOutline = computed(() => (props.outline && autoOutline.value) || props.forceOutline)
91
+
92
+ const theme = computed(() => props.theme ?? defaultTheme)
93
+ const themeCb = (): void => {
94
+ toRaw(theme.value).attach(el.value!)
95
+ }
96
+ if (props.isClientSide) {
97
+ onMounted(() => {
98
+ toRaw(theme.value).on("change", themeCb)
99
+ themeCb()
100
+ })
101
+ onBeforeUnmount(() => {
102
+ toRaw(theme.value).off("change", themeCb)
103
+ })
104
+ }
105
+
106
+ const darkModeSetup = useSetupDarkMode({ isClientSide: props.isClientSide })
107
+
108
+ const darkMode = darkModeSetup.darkMode
109
+
110
+ useShowDevOnlyKey()
111
+
112
+ defineExpose({
113
+ darkMode: darkModeSetup,
114
+ })
115
+
116
+ if (props.useBuiltinTranslations) {
117
+ const { languageLocale } = useSetupLocale()
118
+ void useSetupI18n({
119
+ locale: languageLocale,
120
+ useBuiltinTranslations: true,
121
+ useDummyMessageSetWhileLoading: true,
122
+ })
123
+ }
124
+
125
+ </script>
126
+