@witchcraft/ui 0.0.1 → 0.1.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 (224) hide show
  1. package/README.md +18 -28
  2. package/dist/module.d.mts +3 -1
  3. package/dist/module.json +3 -3
  4. package/dist/module.mjs +21 -12
  5. package/dist/runtime/assets/base.css +1 -1
  6. package/dist/runtime/assets/locales/en.json +2 -2
  7. package/dist/runtime/assets/tailwind.css +1 -1
  8. package/dist/runtime/assets/utils.css +1 -0
  9. package/dist/runtime/build/WitchcraftUiResolver.js +1 -1
  10. package/dist/runtime/components/Aria/Aria.vue +5 -9
  11. package/dist/runtime/components/Aria/Aria.vue.d.ts +5 -0
  12. package/dist/runtime/components/Icon/Icon.vue +12 -28
  13. package/dist/runtime/components/Icon/Icon.vue.d.ts +21 -0
  14. package/dist/runtime/components/LibButton/LibButton.vue +93 -117
  15. package/dist/runtime/components/LibButton/LibButton.vue.d.ts +36 -0
  16. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +53 -76
  17. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +42 -0
  18. package/dist/runtime/components/LibColorInput/LibColorInput.vue +131 -101
  19. package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +63 -0
  20. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +326 -296
  21. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +61 -0
  22. package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.d.ts +2 -0
  23. package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.js +18 -0
  24. package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.d.ts +2 -0
  25. package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.js +17 -0
  26. package/dist/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.d.ts +2 -0
  27. package/dist/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.js +8 -0
  28. package/dist/runtime/components/LibColorPicker/utils/truncate.d.ts +1 -0
  29. package/dist/runtime/components/LibColorPicker/utils/truncate.js +5 -0
  30. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +42 -64
  31. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +22 -0
  32. package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +20 -54
  33. package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +40 -0
  34. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +205 -173
  35. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +34 -0
  36. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +215 -164
  37. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +34 -0
  38. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +9 -10
  39. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +22 -0
  40. package/dist/runtime/components/LibDebug/LibDebug.vue +47 -65
  41. package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +32 -0
  42. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +19 -34
  43. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +22 -0
  44. package/dist/runtime/components/LibFileInput/LibFileInput.vue +155 -173
  45. package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +43 -0
  46. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +352 -0
  47. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue.d.ts +165 -0
  48. package/dist/runtime/components/LibLabel/LibLabel.vue +30 -46
  49. package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +27 -0
  50. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +50 -66
  51. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +29 -0
  52. package/dist/runtime/components/LibNotifications/LibNotification.vue +48 -56
  53. package/dist/runtime/components/LibNotifications/LibNotification.vue.d.ts +17 -0
  54. package/dist/runtime/components/LibNotifications/LibNotifications.vue +71 -83
  55. package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +13 -0
  56. package/dist/runtime/components/LibPagination/LibPagination.vue +86 -131
  57. package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +104 -0
  58. package/dist/runtime/components/LibPalette/LibPalette.vue +23 -26
  59. package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +14 -0
  60. package/dist/runtime/components/LibPopup/LibPopup.vue +326 -400
  61. package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +46 -0
  62. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +73 -93
  63. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +41 -0
  64. package/dist/runtime/components/LibRecorder/LibRecorder.vue +134 -179
  65. package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +77 -0
  66. package/dist/runtime/components/LibRoot/LibRoot.vue +75 -89
  67. package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +41 -0
  68. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +51 -82
  69. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +35 -0
  70. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +147 -164
  71. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +94 -0
  72. package/dist/runtime/components/LibTable/LibTable.vue +69 -106
  73. package/dist/runtime/components/LibTable/LibTable.vue.d.ts +45 -0
  74. package/dist/runtime/components/Template/NAME.vue +15 -36
  75. package/dist/runtime/components/Template/NAME.vue.d.ts +17 -0
  76. package/dist/runtime/components/TestControls/TestControls.vue +7 -10
  77. package/dist/runtime/components/TestControls/TestControls.vue.d.ts +5 -0
  78. package/dist/runtime/components/index.d.ts +12 -11
  79. package/dist/runtime/components/index.js +12 -11
  80. package/dist/runtime/components/shared/props.d.ts +81 -16
  81. package/dist/runtime/components/shared/storyHelpers/playInput.js +5 -5
  82. package/dist/runtime/components/shared/storyHelpers/playSuggestions.js +15 -11
  83. package/dist/runtime/composables/index.d.ts +5 -0
  84. package/dist/runtime/composables/index.js +5 -0
  85. package/dist/runtime/composables/useDivideAttrs.js +1 -0
  86. package/dist/runtime/composables/useDragWithThreshold.d.ts +71 -0
  87. package/dist/runtime/composables/useDragWithThreshold.js +40 -0
  88. package/dist/runtime/composables/usePreHydrationValue.d.ts +12 -0
  89. package/dist/runtime/composables/usePreHydrationValue.js +15 -0
  90. package/dist/runtime/composables/useSetupI18n.d.ts +2 -0
  91. package/dist/runtime/composables/useSetupI18n.js +5 -1
  92. package/dist/runtime/composables/useSuggestions.d.ts +7 -5
  93. package/dist/runtime/composables/useSuggestions.js +94 -57
  94. package/dist/runtime/directives/vResizableCols.js +92 -84
  95. package/dist/runtime/helpers/NotificationHandler.d.ts +5 -0
  96. package/dist/runtime/helpers/index.d.ts +3 -1
  97. package/dist/runtime/helpers/index.js +3 -1
  98. package/dist/runtime/types/index.d.ts +6 -0
  99. package/dist/runtime/utils/notifyIfError.d.ts +14 -0
  100. package/dist/runtime/utils/notifyIfError.js +29 -0
  101. package/dist/types.d.mts +2 -6
  102. package/package.json +27 -29
  103. package/src/module.ts +31 -12
  104. package/src/runtime/assets/base.css +10 -1
  105. package/src/runtime/assets/locales/en.json +2 -2
  106. package/src/runtime/assets/tailwind.css +1 -1
  107. package/src/runtime/assets/{style.css → utils.css} +86 -4
  108. package/src/runtime/build/WitchcraftUiResolver.ts +1 -1
  109. package/src/runtime/components/Focus.stories.ts +3 -2
  110. package/src/runtime/components/Icon/Icon.vue +10 -6
  111. package/src/runtime/components/LibButton/LibButton.vue +41 -47
  112. package/src/runtime/components/LibCheckbox/LibCheckbox.vue +7 -4
  113. package/src/runtime/components/LibColorInput/LibColorInput.vue +111 -37
  114. package/src/runtime/components/LibColorPicker/LibColorPicker.stories.ts +25 -4
  115. package/src/runtime/components/LibColorPicker/LibColorPicker.vue +242 -131
  116. package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +24 -0
  117. package/src/runtime/components/LibColorPicker/utils/safeConvertToRgba.ts +23 -0
  118. package/src/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.ts +13 -0
  119. package/src/runtime/components/LibColorPicker/utils/truncate.ts +6 -0
  120. package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts +1 -1
  121. package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +11 -9
  122. package/src/runtime/components/LibDatePicker/LibDatePicker.vue +4 -17
  123. package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +192 -131
  124. package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +183 -115
  125. package/src/runtime/components/LibDatePicker/LibTimeZonePicker.vue +3 -3
  126. package/src/runtime/components/LibDebug/LibDebug.vue +15 -5
  127. package/src/runtime/components/LibDevOnly/LibDevOnly.vue +1 -3
  128. package/src/runtime/components/LibFileInput/LibFileInput.vue +54 -29
  129. package/src/runtime/components/{LibInput/LibInput.stories.ts → LibInputDeprecated/LibInputDeprecated.stories.ts} +64 -19
  130. package/{dist/runtime/components/LibInput/LibInput.vue → src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue} +40 -34
  131. package/src/runtime/components/LibLabel/LibLabel.vue +2 -2
  132. package/src/runtime/components/LibMultiValues/LibMultiValues.stories.ts +5 -4
  133. package/src/runtime/components/LibMultiValues/LibMultiValues.vue +11 -13
  134. package/src/runtime/components/LibNotifications/LibNotification.vue +19 -11
  135. package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +2 -2
  136. package/src/runtime/components/LibNotifications/LibNotifications.vue +20 -12
  137. package/src/runtime/components/LibPagination/LibPagination.stories.ts +2 -2
  138. package/src/runtime/components/LibPagination/LibPagination.vue +19 -20
  139. package/src/runtime/components/LibPalette/LibPalette.vue +3 -3
  140. package/src/runtime/components/LibPopup/LibPopup.stories.ts +2 -2
  141. package/src/runtime/components/LibPopup/LibPopup.vue +30 -67
  142. package/src/runtime/components/LibProgressBar/LibProgressBar.vue +3 -2
  143. package/src/runtime/components/LibRecorder/LibRecorder.vue +2 -3
  144. package/src/runtime/components/LibRoot/LibRoot.vue +14 -1
  145. package/src/runtime/components/LibSimpleInput/LibSimpleInput.stories.ts +1 -1
  146. package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +5 -8
  147. package/src/runtime/components/LibSuggestions/LibSuggestions.vue +42 -26
  148. package/src/runtime/components/LibTable/LibTable.vue +8 -9
  149. package/src/runtime/components/Scrolling.stories.ts +58 -0
  150. package/src/runtime/components/Template/NAME.vue +1 -1
  151. package/src/runtime/components/TestControls/TestControls.vue +1 -1
  152. package/src/runtime/components/index.ts +12 -12
  153. package/src/runtime/components/shared/props.ts +82 -19
  154. package/src/runtime/components/shared/storyHelpers/playInput.ts +6 -5
  155. package/src/runtime/components/shared/storyHelpers/playSuggestions.ts +25 -11
  156. package/src/runtime/composables/index.ts +5 -0
  157. package/src/runtime/composables/useDarkMode.ts +2 -2
  158. package/src/runtime/composables/useDivideAttrs.ts +1 -0
  159. package/src/runtime/composables/useDragWithThreshold.ts +108 -0
  160. package/src/runtime/composables/usePreHydrationValue.ts +30 -0
  161. package/src/runtime/composables/useSetupI18n.ts +8 -2
  162. package/src/runtime/composables/useSuggestions.ts +92 -45
  163. package/src/runtime/directives/vResizableCols.ts +82 -74
  164. package/src/runtime/helpers/NotificationHandler.ts +5 -0
  165. package/src/runtime/helpers/index.ts +3 -1
  166. package/src/runtime/types/index.ts +5 -0
  167. package/src/runtime/utils/notifyIfError.ts +45 -0
  168. package/dist/module.cjs +0 -5
  169. package/dist/module.d.ts +0 -34
  170. package/dist/runtime/assets/style.css +0 -1
  171. package/dist/runtime/components/Focus.stories.d.ts +0 -11
  172. package/dist/runtime/components/Focus.stories.js +0 -53
  173. package/dist/runtime/components/LibButton/LibButton.stories.d.ts +0 -12
  174. package/dist/runtime/components/LibButton/LibButton.stories.js +0 -94
  175. package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.d.ts +0 -14
  176. package/dist/runtime/components/LibCheckbox/LibCheckbox.stories.js +0 -29
  177. package/dist/runtime/components/LibColorInput/LibColorInput.stories.d.ts +0 -7
  178. package/dist/runtime/components/LibColorInput/LibColorInput.stories.js +0 -58
  179. package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.d.ts +0 -7
  180. package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +0 -51
  181. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.d.ts +0 -7
  182. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.js +0 -36
  183. package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.d.ts +0 -11
  184. package/dist/runtime/components/LibDatePicker/LibDatePicker.stories.js +0 -98
  185. package/dist/runtime/components/LibDebug/LibDebug.stories.d.ts +0 -9
  186. package/dist/runtime/components/LibDebug/LibDebug.stories.js +0 -46
  187. package/dist/runtime/components/LibFileInput/LibFileInput.stories.d.ts +0 -10
  188. package/dist/runtime/components/LibFileInput/LibFileInput.stories.js +0 -63
  189. package/dist/runtime/components/LibInput/LibInput.stories.d.ts +0 -33
  190. package/dist/runtime/components/LibInput/LibInput.stories.js +0 -339
  191. package/dist/runtime/components/LibLabel/LibLabel.stories.d.ts +0 -6
  192. package/dist/runtime/components/LibLabel/LibLabel.stories.js +0 -25
  193. package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.d.ts +0 -23
  194. package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.js +0 -60
  195. package/dist/runtime/components/LibNotifications/LibNotification.stories.d.ts +0 -15
  196. package/dist/runtime/components/LibNotifications/LibNotification.stories.js +0 -126
  197. package/dist/runtime/components/LibNotifications/LibNotifications.stories.d.ts +0 -6
  198. package/dist/runtime/components/LibNotifications/LibNotifications.stories.js +0 -109
  199. package/dist/runtime/components/LibPagination/LibPagination.stories.d.ts +0 -6
  200. package/dist/runtime/components/LibPagination/LibPagination.stories.js +0 -40
  201. package/dist/runtime/components/LibPalette/LibPalette.stories.d.ts +0 -6
  202. package/dist/runtime/components/LibPalette/LibPalette.stories.js +0 -20
  203. package/dist/runtime/components/LibPopup/LibPopup.stories.d.ts +0 -14
  204. package/dist/runtime/components/LibPopup/LibPopup.stories.js +0 -147
  205. package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.d.ts +0 -10
  206. package/dist/runtime/components/LibProgressBar/LibProgressBar.stories.js +0 -81
  207. package/dist/runtime/components/LibRecorder/LibRecorder.stories.d.ts +0 -19
  208. package/dist/runtime/components/LibRecorder/LibRecorder.stories.js +0 -63
  209. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.d.ts +0 -26
  210. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.js +0 -78
  211. package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.d.ts +0 -27
  212. package/dist/runtime/components/LibSuggestions/LibSuggestions.stories.js +0 -112
  213. package/dist/runtime/components/LibTable/LibTable.stories.d.ts +0 -16
  214. package/dist/runtime/components/LibTable/LibTable.stories.js +0 -156
  215. package/dist/runtime/components/reset.stories.d.ts +0 -5
  216. package/dist/runtime/components/reset.stories.js +0 -19
  217. package/dist/runtime/composables/useScrollNearContainerEdges.stories.d.ts +0 -7
  218. package/dist/runtime/composables/useScrollNearContainerEdges.stories.js +0 -85
  219. package/dist/runtime/helpers/addValue.d.ts +0 -1
  220. package/dist/runtime/helpers/addValue.js +0 -8
  221. package/dist/types.d.ts +0 -7
  222. package/src/runtime/components/LibInput/LibInput.vue +0 -372
  223. package/src/runtime/helpers/addValue.ts +0 -10
  224. /package/src/runtime/components/{reset.stories.ts → Reset.stories.ts} +0 -0
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-use-before-define */
2
1
  import { castType } from "@alanscodelog/utils/castType.js"
3
2
  import { override } from "@alanscodelog/utils/override.js"
4
3
  import { throttle } from "@alanscodelog/utils/throttle.js"
@@ -137,7 +136,7 @@ export const vResizableCols: Directive = {
137
136
  }
138
137
 
139
138
 
140
- const setWidth = (col: HTMLElement, amountInPx: number, el: ResizableElement): void => {
139
+ function setWidth(col: HTMLElement, amountInPx: number, el: ResizableElement): void {
141
140
  const $el = getElInfo(el)
142
141
  const width = Math.max($el.margin, amountInPx)
143
142
 
@@ -150,13 +149,14 @@ const setWidth = (col: HTMLElement, amountInPx: number, el: ResizableElement): v
150
149
  }
151
150
 
152
151
 
153
- const getBox = (el: Element): { x: number, width: number } => {
152
+ function getBox(el: Element): { x: number, width: number } {
154
153
  const rect = el.getBoundingClientRect()
155
154
  // the numbers need to be rounded or else the columns will start to shift
156
155
  // rounding rect.width is bettwe than just using clientWidth which does not include the scrollbar
157
156
  return { x: Math.round(rect.x), width: Math.round(rect.width) }
158
157
  }
159
- const getCols = (el: ResizableElement): { col: HTMLElement | null, colNext: HTMLElement | null } => {
158
+
159
+ function getCols(el: ResizableElement): { col: HTMLElement | null, colNext: HTMLElement | null } {
160
160
  const $el = getElInfo(el)
161
161
  if (!$el.target) unreachable()
162
162
  let col = getColEls(el)[$el.grips.get($el.target!)!]
@@ -174,89 +174,95 @@ const getCols = (el: ResizableElement): { col: HTMLElement | null, colNext: HTML
174
174
  return { col, colNext }
175
175
  }
176
176
 
177
- const createPointerDownHandler = (el: ResizableElement) => (e: PointerEvent) => {
178
- const $el = getElInfo(el)
179
- if (!$el.isDragging) {
180
- castType<HTMLElement>(e.target)
181
- $el.target = e.target
182
- $el.isDragging = true
183
- e.preventDefault()
184
-
185
- // in case any errors happen, we want the pointer up to still be called
186
- document.addEventListener("pointerup", $el.pointerUpHandler)
187
-
188
- const { col, colNext } = getCols(el)
189
- if (col === null || colNext === null) {
190
- el.classList.add("resizable-cols-error")
191
- } else {
192
- document.addEventListener("pointermove", $el.pointerMoveHandler)
193
- const box = getBox(col!)
194
- if (box) {
195
- $el.offset = e.pageX - (box.x + box.width)
177
+ function createPointerDownHandler(el: ResizableElement) {
178
+ return (e: PointerEvent) => {
179
+ const $el = getElInfo(el)
180
+ if (!$el.isDragging) {
181
+ castType<HTMLElement>(e.target)
182
+ $el.target = e.target
183
+ $el.isDragging = true
184
+ e.preventDefault()
185
+
186
+ // in case any errors happen, we want the pointer up to still be called
187
+ document.addEventListener("pointerup", $el.pointerUpHandler)
188
+
189
+ const { col, colNext } = getCols(el)
190
+ if (col === null || colNext === null) {
191
+ el.classList.add("resizable-cols-error")
192
+ } else {
193
+ document.addEventListener("pointermove", $el.pointerMoveHandler)
194
+ const box = getBox(col!)
195
+ if (box) {
196
+ $el.offset = e.pageX - (box.x + box.width)
197
+ }
196
198
  }
197
199
  }
198
200
  }
199
201
  }
200
- const createPointerMoveHandler = (el: ResizableElement) => (e: PointerEvent) => {
201
- const $el = getElInfo(el)
202
- if ($el.isDragging) {
203
- e.preventDefault()
202
+ function createPointerMoveHandler(el: ResizableElement) {
203
+ return (e: PointerEvent) => {
204
+ const $el = getElInfo(el)
205
+ if ($el.isDragging) {
206
+ e.preventDefault()
204
207
 
205
- const { col, colNext } = getCols(el)
208
+ const { col, colNext } = getCols(el)
206
209
 
207
- if (col !== null) {
208
- const leftBox = getBox(col)
210
+ if (col !== null) {
211
+ const leftBox = getBox(col)
209
212
 
210
- const oldWidth = leftBox.width
211
- const leftBound = leftBox.x
212
- const rightBox = colNext ? getBox(colNext) : getBox(el)
213
+ const oldWidth = leftBox.width
214
+ const leftBound = leftBox.x
215
+ const rightBox = colNext ? getBox(colNext) : getBox(el)
213
216
 
214
- const rightBound = rightBox.x + rightBox.width
215
- const margin = $el.margin
216
- const pos = e.pageX - $el.offset!
217
+ const rightBound = rightBox.x + rightBox.width
218
+ const margin = $el.margin
219
+ const pos = e.pageX - $el.offset!
217
220
 
218
- if ($el.fitWidth) {
219
- if (pos > (leftBound + margin) && pos < (rightBound - margin)) {
220
- const newWidth = pos - leftBound
221
- const diff = oldWidth - newWidth
221
+ if ($el.fitWidth) {
222
+ if (pos > (leftBound + margin) && pos < (rightBound - margin)) {
223
+ const newWidth = pos - leftBound
224
+ const diff = oldWidth - newWidth
222
225
 
223
- if (rightBox.width + diff < margin) {
224
- el.classList.add("resizable-cols-error")
225
- return
226
- }
226
+ if (rightBox.width + diff < margin) {
227
+ el.classList.add("resizable-cols-error")
228
+ return
229
+ }
227
230
 
228
231
 
229
- setWidth(col, newWidth, el)
230
- setWidth(colNext!, rightBox.width + diff, el)
231
- }
232
- } else {
233
- if (pos > leftBound + margin) {
234
- const newWidth = pos - leftBound
235
- setWidth(col, newWidth, el)
232
+ setWidth(col, newWidth, el)
233
+ setWidth(colNext!, rightBox.width + diff, el)
234
+ }
235
+ } else {
236
+ if (pos > leftBound + margin) {
237
+ const newWidth = pos - leftBound
238
+ setWidth(col, newWidth, el)
239
+ }
236
240
  }
237
- }
238
241
 
239
- positionGrips(el)
242
+ positionGrips(el)
243
+ }
240
244
  }
241
245
  }
242
246
  }
243
247
 
244
- const createPointerUpHandler = (el: ResizableElement) => (e: PointerEvent) => {
245
- const $el = getElInfo(el)
246
- if ($el.isDragging) {
247
- e.preventDefault()
248
- $el.isDragging = false
249
- el.classList.remove("resizable-cols-error")
250
- $el.offset = 0
251
- delete $el.target
252
- document.removeEventListener("pointermove", $el.pointerMoveHandler)
253
- document.removeEventListener("pointerup", $el.pointerUpHandler)
254
- // unfortunately does not work with iframes in storybook but otherwise does work
255
- document.removeEventListener("pointerleave", $el.pointerLeaveHandler)
248
+ function createPointerUpHandler(el: ResizableElement) {
249
+ return (e: PointerEvent) => {
250
+ const $el = getElInfo(el)
251
+ if ($el.isDragging) {
252
+ e.preventDefault()
253
+ $el.isDragging = false
254
+ el.classList.remove("resizable-cols-error")
255
+ $el.offset = 0
256
+ delete $el.target
257
+ document.removeEventListener("pointermove", $el.pointerMoveHandler)
258
+ document.removeEventListener("pointerup", $el.pointerUpHandler)
259
+ // unfortunately does not work with iframes in storybook but otherwise does work
260
+ document.removeEventListener("pointerleave", $el.pointerLeaveHandler)
261
+ }
256
262
  }
257
263
  }
258
264
 
259
- const createGrip = (): HTMLElement => {
265
+ function createGrip(): HTMLElement {
260
266
  const grip = document.createElement("div")
261
267
  grip.style.position = "absolute"
262
268
  grip.style.cursor = "col-resize"
@@ -271,7 +277,7 @@ const removeGrips = (el: HTMLElement): void => {
271
277
  el.removeChild(grip)
272
278
  }
273
279
  }
274
- const getTestGripSize = (el: ResizableElement): number => {
280
+ function getTestGripSize(el: ResizableElement): number {
275
281
  const testGrip = createGrip()
276
282
  el.appendChild(testGrip)
277
283
  const dynamicMinWidth = getBox(testGrip).width * 3
@@ -279,18 +285,18 @@ const getTestGripSize = (el: ResizableElement): number => {
279
285
  return dynamicMinWidth
280
286
  }
281
287
 
282
- const getElInfo = (el: ResizableElement): Data => {
288
+ function getElInfo(el: ResizableElement): Data {
283
289
  const $el = elMap.get(el)
284
290
  if (!$el) unreachable("El went missing.")
285
291
  return $el
286
292
  }
287
- const getColEls = (el: ResizableElement): HTMLElement[] => {
293
+ function getColEls(el: ResizableElement): HTMLElement[] {
288
294
  const $el = elMap.get(el)
289
295
  if (!$el) unreachable("El went missing.")
290
296
  return [...el.querySelectorAll(`:scope ${$el.selector ? $el.selector : "tr > td"}`)] as any
291
297
  }
292
298
 
293
- const setupColumns = (el: ResizableElement, opts: ResizableOptions): void => {
299
+ function setupColumns(el: ResizableElement, opts: ResizableOptions): void {
294
300
  const gripWidth = getTestGripSize(el)
295
301
  const $el: Data = {
296
302
  grips: new Map(),
@@ -325,12 +331,14 @@ const setupColumns = (el: ResizableElement, opts: ResizableOptions): void => {
325
331
  el.classList.add("resizable-cols-setup")
326
332
  }
327
333
 
328
- const positionGrips = (el: ResizableElement): void => {
334
+ function positionGrips(el: ResizableElement): void {
329
335
  let xPos = 0
330
336
  const $el = getElInfo(el)
331
337
  for (const grip of $el.grips.keys()) {
332
338
  const col = $el.grips.get(grip)!
333
- const colBox = getBox(getColEls(el)[col])
339
+ const colEls = getColEls(el)[col]
340
+ if (!colEls) unreachable()
341
+ const colBox = getBox(colEls)
334
342
  const gripBox = getBox(grip)
335
343
 
336
344
  grip.style.left = `${xPos + colBox.width - (gripBox.width / 2)}px`
@@ -338,7 +346,7 @@ const positionGrips = (el: ResizableElement): void => {
338
346
  }
339
347
  }
340
348
 
341
- const setColWidths = (el: ResizableElement, children?: Element[]): void => {
349
+ function setColWidths(el: ResizableElement, children?: Element[]): void {
342
350
  const $el = getElInfo(el)
343
351
  const header = children ?? getColEls(el).slice(0, $el.colCount)
344
352
  const len = $el.colCount
@@ -363,7 +371,7 @@ const setColWidths = (el: ResizableElement, children?: Element[]): void => {
363
371
  }
364
372
  }
365
373
 
366
- const teardownColumns = (el: ResizableElement): void => {
374
+ function teardownColumns(el: ResizableElement): void {
367
375
  const $el = getElInfo(el)
368
376
 
369
377
  el.removeEventListener("pointerdown", $el.pointerDownHandler)
@@ -200,11 +200,16 @@ export type RawNotificationEntry<
200
200
  message: string
201
201
  title?: string
202
202
  code?: string
203
+ /** @default ["Ok", "Cancel"] */
203
204
  options?: TOptions
205
+ /** @default false */
204
206
  requiresAction?: boolean
205
207
  cancellable?: TCancellable
208
+ /** @default "Ok" */
206
209
  default?: TOptions[number]
210
+ /** @default [] */
207
211
  dangerous?: TOptions[number][]
212
+ /** @default false if cancellable, otherwise the default timeout */
208
213
  timeout?: number | boolean
209
214
  icon?: string
210
215
  }
@@ -1,9 +1,11 @@
1
1
  /* Autogenerated Index */
2
2
 
3
- export { addValue } from "./addValue.js"
4
3
  export { base64ToImg } from "./base64ToImg.js"
5
4
  export { copy } from "./copy.js"
5
+ export { createNoonUtcDate } from "./createNoonUtcDate.js"
6
6
  export { createRecorderHandler } from "./storybook.js"
7
+ export { defaultTranslationFunction } from "./defaultTranslationFunction.js"
8
+ export { getTimeZoneList } from "./getTimeZoneList.js"
7
9
  export { hasModifiers } from "./hasModifiers.js"
8
10
  export { NotificationHandler } from "./NotificationHandler.js"
9
11
  export { readFile } from "./readFile.js"
@@ -51,9 +51,14 @@ export type ResizeCallback = (_rect: DOMRectReadOnly, el: Element) => void
51
51
 
52
52
  export type FileInputError = ErrorW<{ file: File, isValidMimeType: boolean, isValidExtension: boolean }>
53
53
 
54
+
55
+ /** h 0-360+ (deg), s 0-100%, v 0-100%, a 0-1 */
54
56
  export type HsvaColor = { h: number, s: number, v: number, a?: number }
57
+ /** rgb 0-255, 0-1 for alpha */
55
58
  export type RgbaColor = { r: number, g: number, b: number, a?: number }
56
59
 
60
+ export type Point = { x: number, y: number }
61
+
57
62
  export type ScrollNearContainerEdgesOptions = {
58
63
  containerEl: Ref< HTMLElement | null>
59
64
  /** Margin inside contianer that allows scrolling. 10 by default. */
@@ -0,0 +1,45 @@
1
+ import { TypedError } from "@alanscodelog/utils/TypedError.js"
2
+
3
+ import { useNotificationHandler } from "../composables/useNotificationHandler.js"
4
+
5
+ /**
6
+ * Notifies the user if the given value is an error. Useful for making non-critical errors don't go unnoticed.
7
+ *
8
+ * Integrates with {@link TypedError} from `@alanscodelog/utils` to display the error code as well if it has one.
9
+ *
10
+ * If the value is not an error, it is returned.
11
+ */
12
+ export function notifyIfError<T>(
13
+ err: T, {
14
+ logger,
15
+ ns,
16
+ force = false,
17
+ }: {
18
+ logger?: { debug: (...args: any[]) => void }
19
+ /* Logger namespace. */
20
+ ns?: string
21
+ /* force interpret as error, for catch blocks */
22
+ force?: boolean
23
+ } = {}): T {
24
+ if (force || err instanceof Error) {
25
+ const errMessage = {
26
+ message: err instanceof Error ? err.message : `Unknown error ${err as any}`,
27
+ code: err instanceof TypedError ? err.code : undefined,
28
+ }
29
+ if (logger) {
30
+ logger.debug({
31
+ ns,
32
+ ...errMessage,
33
+ stack: err instanceof Error ? err.stack : undefined
34
+ })
35
+ }
36
+ void useNotificationHandler().notify({
37
+ title: "Error",
38
+ ...errMessage,
39
+ options: ["Ok"],
40
+ cancellable: "Ok",
41
+ timeout: true
42
+ })
43
+ }
44
+ return err
45
+ }
package/dist/module.cjs DELETED
@@ -1,5 +0,0 @@
1
- module.exports = function(...args) {
2
- return import('./module.mjs').then(m => m.default.call(this, ...args))
3
- }
4
- const _meta = module.exports.meta = require('./module.json')
5
- module.exports.getMeta = () => Promise.resolve(_meta)
package/dist/module.d.ts DELETED
@@ -1,34 +0,0 @@
1
- import * as _nuxt_schema from '@nuxt/schema';
2
-
3
- declare const knownDirectives: readonly ["vExtractRootEl", "vResizableCols", "vResizeObserver", "vResizableCols"];
4
- declare module "@nuxt/schema" {
5
- interface PublicRuntimeConfig {
6
- witchcraftUi: Pick<ModuleOptions, "directives">;
7
- }
8
- }
9
- interface ModuleOptions {
10
- /**
11
- * Whether to include the vite unplugin-icons plugins (pre-configured with the ui module's defaults.
12
- *
13
- * @default true
14
- */
15
- includeUnpluginIconsPlugins?: boolean;
16
- directives: (typeof knownDirectives[number])[];
17
- /**
18
- * Which components (without a prefix) to register for auto-importing globally.
19
- */
20
- globalComponents: string[];
21
- /**
22
- * @default "W"
23
- */
24
- componentPrefix: string;
25
- debug?: boolean;
26
- /**
27
- * @default "~/assets/css/tailwind.css"
28
- */
29
- mainCssFile?: string;
30
- }
31
- declare const _default: _nuxt_schema.NuxtModule<ModuleOptions, ModuleOptions, false>;
32
-
33
- export { _default as default };
34
- export type { ModuleOptions };
@@ -1 +0,0 @@
1
- @custom-variant dark (&:where(.dark, .dark *));@utility focus-outline-within{@apply outlined-within:outline-hidden outlined-within:ring-2 outlined-within:ring-accent-500 outlined-within:ring-offset-2}@utility focus-outline{@apply outlined:outline-hidden outlined:ring-2 outlined:ring-accent-500 outlined:ring-offset-2}@utility focus-outline-no-offset{@apply outlined:outline-hidden outlined:ring-2 outlined:ring-accent-500}@utility focus-outline-hidden{@apply outlined:outline-hidden}@utility bg-squares-gradient{--_square:var(--squareSize,5px);--_double_square:calc(var(--_square)*2);--_light_square:var(--lightSquare,var(--color-white));--_dark_square:var(--darkSquare,var(--color-black));background-color:var(--_light_square);background:repeating-conic-gradient(var(--_dark_square) 0 25%,var(--_light_square) 0 50%) 50% /var(--_double_square) var(--_double_square)}@utility square-light-*{--lightSquare:--value(--color- *)}@utility square-dark-*{--darkSquare:--value(--color- *)}@utility square-size-*{--squareSize:calc(--value(integer) * 1px)}@utility bg-bars-gradient{--_bg_color:var(--bars-bg-color,var(--color-accent-700));--_fg_color:var(--bars-fg-color,var(--color-accent-800));--_angle:var(--bars-angle,45deg);--_fg_width:var(--bars-fg-width,50%);--_bg_width:calc(100% - var(--_fg_width));background-color:var(--_bg_color);--_pos_1:calc(var(--_bg_width)/2);--_pos_2:calc(var(--_bg_width)/2 + var(--_fg_width)/2);--_pos_3:calc(var(--_bg_width) + var(--_fg_width)/2);background-image:repeating-linear-gradient(var(--_angle),var(--_bg_color),var(--_bg_color) var(--_pos_1),var(--_fg_color) var(--_pos_1),var(--_fg_color) var(--_pos_2),var(--_bg_color) var(--_pos_2),var(--_bg_color) var(--_pos_3),var(--_fg_color) var(--_pos_3),var(--_fg_color))}@utility bars-angle-*{--bars-angle:var(--value(integer) * 1deg)}@utility bars-fg-*{--bars-fg-color:--value(--color-*)}@utility bars-bg-*{--bars-bg-color:--value(--color-*)}@utility bars-w-*{--bars-fg-width:calc(--value(integer) * 1%, 50%)}@utility scrollbar-hidden{-ms-overflow-style:none;scrollbar-width:none;&::-webkit-scrollbar{display:none}}@utility content-vertical-holder{--tw-content:"\200b";content:var(--tw-content)}@utility no-touch-action{touch-action:none}@utility bg-transparency-squares{@apply bg-squares-gradient square-light-white square-dark-neutral-300 square-size-6}@utility link-like{@apply cursor-pointer hover:text-accent-500}
@@ -1,11 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/vue3";
2
- /**
3
- * For testing the focus styles. The (still WIP) idea is that normally the outlined class is set by whether the user is using the keyboard or not. When true, outlines generated by the focus-outline-* or outlined-* utilities are allowed (they might not always appear since most components have focus-visible styles), when false, they are not allowed, but components can still set custom focus styles that will always appear. Either or is usually not a good idea unless all components set custom focus styles. For something like a web app, focus-visible should be allowed. For an app, this setup allows that to be configurable.
4
- */
5
- declare const meta: Meta;
6
- export default meta;
7
- type Story = StoryObj<typeof NAME>;
8
- export declare const Primary: Story;
9
- export declare const OutlineForcedTrue: Story;
10
- export declare const OutlineFalse: Story;
11
- export declare const AlwaysAllowFocusVisible: Story;
@@ -1,53 +0,0 @@
1
- import { onMounted, ref } from "vue";
2
- import * as components from "./index.js";
3
- const meta = {
4
- title: "Other/Focus",
5
- args: {
6
- outline: true
7
- }
8
- };
9
- const template = `
10
- <div class="focus-outline-no-offset border border-accent-600" tabindex="0">focus-outline-no-offset (outlined i.e. outlined-focus-visible)</div>
11
- <div class="focus-outline border border-accent-600" tabindex="0">focus-outline (outlined i.e. outlined-focus-visible)</div>
12
- <div class="outline-hidden outlined-focus:border-danger-500 border border-accent-600" tabindex="0">outlined-focus</div>
13
- <div class="outline-hidden outlined-within:border-danger-500 border border-accent-600" >
14
- outlined-within<div tabindex="0">Inner</div>
15
- </div>
16
- <div class="outline-hidden focus:border-danger-500 border border-accent-600" tabindex="0">Has Manual Focus Classes</div>
17
- `;
18
- export default meta;
19
- export const Primary = {
20
- render: (args) => ({
21
- components,
22
- setup: () => {
23
- const el = ref(null);
24
- onMounted(() => {
25
- });
26
- return { ...args, el };
27
- },
28
- template
29
- })
30
- };
31
- export const OutlineForcedTrue = {
32
- ...Primary,
33
- args: {
34
- ...Primary.args,
35
- forceOutline: true
36
- }
37
- };
38
- export const OutlineFalse = {
39
- ...Primary,
40
- args: {
41
- ...Primary.args,
42
- outline: false
43
- }
44
- };
45
- export const AlwaysAllowFocusVisible = {
46
- render: (args) => ({
47
- components,
48
- setup: () => args,
49
- template: `
50
- <div class="outlined-visible group">${template}</div>
51
- `
52
- })
53
- };
@@ -1,12 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/vue3";
2
- import * as components from "../index.js.js";
3
- declare const meta: Meta<typeof components.LibButton>;
4
- export default meta;
5
- type Story = StoryObj<typeof components.LibButton>;
6
- export declare const Primary: Story;
7
- export declare const IconAfter: Story;
8
- export declare const OnlyIcon: Story;
9
- export declare const Disabled: Story;
10
- export declare const Borderless: Story;
11
- export declare const BorderlessDisabled: Story;
12
- export declare const WithDivInside: Story;
@@ -1,94 +0,0 @@
1
- import { capitalize } from "@alanscodelog/utils/capitalize.js";
2
- import IconFaSolidBell from "~icons/fa-solid/bell";
3
- import * as components from "../index.js";
4
- const meta = {
5
- component: components.LibButton,
6
- title: "Components/Button",
7
- args: {
8
- label: "Label",
9
- // @ts-expect-error - custom prop for story
10
- _iconAfter: true
11
- }
12
- };
13
- export default meta;
14
- export const Primary = {
15
- render: (args) => ({
16
- components: {
17
- ...components,
18
- IconFaSolidBell
19
- },
20
- setup: () => ({ args, capitalize }),
21
- template: `
22
- <div class="flex gap-4 justify-center">
23
- <template v-for="type of [false, 'ok', 'warning', 'danger', 'primary', 'secondary' ]">
24
- <lib-button v-bind="{...args, color: type, label: !args.label ? undefined : args.label + ' ' + capitalize(type || 'false')}">
25
- <template #icon>
26
- <icon class="w-[1em]"><icon-fa-solid-bell /></icon>
27
- </template>
28
- </lib-button>
29
- </template>
30
- </div>
31
- <div class="flex flex-col gap-4 pt-10">
32
- <template v-for="type of [false, 'ok', 'warning', 'danger', 'primary', 'secondary']">
33
- <lib-button v-bind="{...args, color: type , label: !args.label ? undefined : args.label + ' ' + capitalize(type || 'false') }">
34
- ${args._iconAfter ? `
35
- <template #icon-after>
36
- <icon class="w-[1em]"><icon-fa-solid-bell /></icon>
37
- </template>
38
- ` : ``}
39
- </lib-button>
40
- </template>
41
- </div>
42
- `
43
- })
44
- };
45
- export const IconAfter = {
46
- ...Primary,
47
- args: {
48
- ...Primary.args,
49
- // @ts-expect-error - .
50
- _iconAfter: true
51
- }
52
- };
53
- export const OnlyIcon = {
54
- ...Primary,
55
- args: {
56
- ...Primary.args,
57
- label: void 0
58
- }
59
- };
60
- export const Disabled = {
61
- ...Primary,
62
- args: {
63
- ...Primary.args,
64
- disabled: true
65
- }
66
- };
67
- export const Borderless = {
68
- ...Primary,
69
- args: {
70
- ...Primary.args,
71
- border: false
72
- }
73
- };
74
- export const BorderlessDisabled = {
75
- ...Primary,
76
- args: {
77
- ...Primary.args,
78
- border: false,
79
- disabled: true
80
- }
81
- };
82
- export const WithDivInside = {
83
- render: (args) => ({
84
- components,
85
- setup: () => ({ args }),
86
- template: `
87
- <div class="flex gap-4 justify-center">
88
- <lib-button v-bind="{...args}">
89
- <div>Div inside button still has a pointer cursor.</div>
90
- </lib-button>
91
- </div>
92
- `
93
- })
94
- };
@@ -1,14 +0,0 @@
1
- import type { StoryObj } from "@storybook/vue3";
2
- import * as components from "../index.js.js";
3
- declare const meta: {
4
- component: any;
5
- title: string;
6
- args: {
7
- modelValue: boolean;
8
- label: string;
9
- };
10
- };
11
- export default meta;
12
- type Story = StoryObj<typeof components.LibCheckbox>;
13
- export declare const Primary: Story;
14
- export declare const Disabled: any;
@@ -1,29 +0,0 @@
1
- import * as components from "../index.js";
2
- const meta = {
3
- component: components.LibCheckbox,
4
- title: "Components/Checkbox",
5
- args: {
6
- modelValue: true,
7
- label: "Label"
8
- }
9
- };
10
- export default meta;
11
- export const Primary = {
12
- render: (args) => ({
13
- components,
14
- setup: () => ({ args }),
15
- template: `
16
- <lib-checkbox v-bind="args" v-model="args.modelValue"></lib-checkbox>
17
- <br>
18
- Opposite State:
19
- <br>
20
- <lib-checkbox v-bind="args" :modelValue="!args.modelValue" @update:modelValue="args.modelValue = !$event"></lib-checkbox>
21
- `
22
- })
23
- };
24
- export const Disabled = {
25
- ...Primary,
26
- args: {
27
- disabled: true
28
- }
29
- };
@@ -1,7 +0,0 @@
1
- import type { Meta, StoryObj } from "@storybook/vue3";
2
- import LibColorInput from "./LibColorInput.vue.js";
3
- declare const meta: Meta<typeof LibColorInput>;
4
- export default meta;
5
- type Story = StoryObj<typeof LibColorInput>;
6
- export declare const Primary: Story;
7
- export declare const DoesNotAllowAlpha: Story;