@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
@@ -2,13 +2,14 @@
2
2
  <TransitionGroup name="list"
3
3
  tag="div"
4
4
  :class="twMerge(`notifications
5
- fixed
5
+ absolute
6
6
  z-50
7
7
  inset-y-0 right-0
8
8
  w-1/3
9
9
  min-w-[300px]
10
10
  pointer-events-none
11
11
  overflow-hidden
12
+ flex flex-col
12
13
  `, ($attrs as any).class)"
13
14
  v-bind="{ ...$attrs, class: undefined }"
14
15
  >
@@ -21,22 +22,25 @@
21
22
  />
22
23
  </TransitionGroup>
23
24
  <Transition>
24
- <div v-show="topNotifications.length > 0"/>
25
+ <div
26
+ v-show="topNotifications.length > 0"
27
+ :class="twMerge(`notifications--none`, ($attrs as any).class)"
28
+ />
25
29
  </Transition>
26
30
  <Transition>
27
31
  <dialog v-show="topNotifications.length > 0"
28
32
  :id="id"
29
- class="modal
33
+ :class="twMerge(`notifications-modal
30
34
  bg-transparent
31
35
  p-0
32
36
  backdrop:bg-black/50
33
37
  backdrop:p-5
34
- "
38
+ `, ($attrs as any).class)"
35
39
  ref="dialogEl"
36
- @click.self.prevent="NotificationHandler.dismiss(topNotifications[0])"
40
+ @click.self.prevent="topNotifications[0] && NotificationHandler.dismiss(topNotifications[0])"
37
41
  >
38
42
  <form>
39
- <lib-notification v-if="topNotifications.length > 0"
43
+ <lib-notification v-if="topNotifications.length > 0 && topNotifications[0]"
40
44
  :handler="handler"
41
45
  class="top-notification"
42
46
  :notification="topNotifications[0]"
@@ -48,10 +52,11 @@
48
52
  </template>
49
53
  <script setup lang="ts">
50
54
  import { removeIfIn } from "@alanscodelog/utils/removeIfIn.js"
51
- import { type HTMLAttributes,nextTick, onBeforeUnmount, type PropType, ref, shallowReactive } from "vue"
55
+ import { type HTMLAttributes,nextTick, onBeforeUnmount, ref,shallowReactive, Transition, TransitionGroup } from "vue"
52
56
 
53
57
  import LibNotification from "./LibNotification.vue"
54
58
 
59
+ import { useNotificationHandler } from "../../composables/useNotificationHandler.js"
55
60
  import { type NotificationEntry, NotificationHandler } from "../../helpers/NotificationHandler.js"
56
61
  import { twMerge } from "../../utils/twMerge.js"
57
62
  import type { LinkableByIdProps, TailwindClassProp } from "../shared/props.js"
@@ -62,7 +67,6 @@ defineOptions({
62
67
  })
63
68
 
64
69
 
65
- // eslint-disable-next-line no-use-before-define
66
70
  const props = defineProps<Props>()
67
71
 
68
72
  const dialogEl = ref<HTMLDialogElement | null>(null)
@@ -108,11 +112,14 @@ const notificationListener = (entry: NotificationEntry, type: "added" | "resolve
108
112
  addNotification(entry)
109
113
  }
110
114
  }
111
- props.handler.addNotificationListener(notificationListener)
112
115
 
113
- for (const entry of props.handler.queue) { addNotification(entry) }
116
+ const handler = props.handler ?? useNotificationHandler()
117
+
118
+ handler.addNotificationListener(notificationListener)
119
+
120
+ for (const entry of handler.queue) { addNotification(entry) }
114
121
  onBeforeUnmount(() => {
115
- props.handler.removeNotificationListener(notificationListener)
122
+ handler.removeNotificationListener(notificationListener)
116
123
  })
117
124
 
118
125
  </script>
@@ -121,7 +128,8 @@ onBeforeUnmount(() => {
121
128
  type RealProps =
122
129
  & LinkableByIdProps
123
130
  & {
124
- handler: NotificationHandler
131
+ /** If not provided, uses the global handler (this requires useNotificationHandler be called and configured). */
132
+ handler?: NotificationHandler
125
133
  }
126
134
 
127
135
  interface Props
@@ -44,9 +44,9 @@ export const Primary: Story = {
44
44
  <a v-bind="linkProps" @click="changePage($event, linkProps.i)">{{ linkProps.text ?? linkProps.i }}</a>
45
45
  </template>
46
46
  </lib-pagination>
47
- <lib-input :label="'Change Page'" :modelValue="num.toString()" @update:modelValue="num = parseInt($event)" type="number" min="0" :max="args.total">
47
+ <lib-simple-input :label="'Change Page'" :modelValue="num.toString()" @update:modelValue="num = parseInt($event)" type="number" min="0" :max="args.total">
48
48
 
49
- </lib-input>
49
+ </lib-simple-input>
50
50
  `,
51
51
  }),
52
52
  }
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <nav
3
3
  :class="twMerge(`
4
+ pagination--wrapper
4
5
  flex flex-wrap items-center justify-center gap-2
5
6
  `, ($attrs as any).class)"
6
7
  role="navigation"
@@ -12,33 +13,33 @@
12
13
  :href="prevLink.href"
13
14
  :text="t('pagination.previous-page')"
14
15
  :aria-label=" t('pagination.aria.go-to-previous-page',{count:prevLink.i})"
15
- :class="pageClasses"
16
+ :class="`pagination--link ${pageClasses}`"
16
17
  >
17
18
  <a
18
- :class="pageClasses"
19
+ :class="`pagination--link ${pageClasses}`"
19
20
  :href="prevLink.href"
20
21
  :aria-label=" t('pagination.aria.go-to-previous-page', {count:prevLink.i})"
21
22
  />
22
23
  </slot>
23
- <div class="flex-1"/>
24
+ <div class="pagination--spacer flex-1"/>
24
25
  <slot v-if="firstLink.i !== currentLink.i"
25
26
  name="link"
26
27
  :i="0"
27
28
  :href="firstLink.href"
28
29
  :text="firstLink.i"
29
30
  :aria-label="t('pagination.aria.go-to-page', {count:firstLink.i})"
30
- :class="pageClasses"
31
+ :class="`pagination--link pagination--first-link ${pageClasses}`"
31
32
  >
32
33
  {{ firstLink.href }}
33
34
  <a
34
- :class="pageClasses"
35
+ :class="`pagination--link pagination--first-link ${pageClasses}`"
35
36
  :href="firstLink.href"
36
37
  :aria-label="t('pagination.aria.go-to-page', {count:firstLink.i})"
37
38
  >
38
39
  {{ firstLink.i }}
39
40
  </a>
40
41
  </slot>
41
- <div v-if="prevLink.i - extraPages > firstLink.i" class="page-fill">
42
+ <div v-if="prevLink.i - extraPages > firstLink.i" class="pagination--page-fill">
42
43
  ...
43
44
  </div>
44
45
  <template
@@ -46,13 +47,13 @@
46
47
  :key="entry.i"
47
48
  >
48
49
  <slot name="link"
49
- :class="pageClasses"
50
+ :class="`pagination--link ${pageClasses}`"
50
51
  :i="entry.i"
51
52
  :href="entry.href"
52
53
  :aria-label="t('pagination.aria.go-to-page', {count:entry.i})"
53
54
  >
54
55
  <a
55
- :class="pageClasses"
56
+ :class="`pagination--link ${pageClasses}`"
56
57
  :href="entry.href"
57
58
  :aria-label="t('pagination.aria.go-to-page', {count:entry.i})"
58
59
  >
@@ -61,15 +62,14 @@
61
62
  </slot>
62
63
  </template>
63
64
  <slot name="current"
64
- :class="currentPageClasses"
65
+ :class="`pagination--link ${currentPageClasses}`"
65
66
  tabindex="0"
66
67
  :i="currentLink.i"
67
68
  :aria-label="t('pagination.aria.current-page', {count:currentLink.i})"
68
69
  :aria_current="true"
69
70
  >
70
- <div class="a"
71
+ <div :class="`pagination--current-page a ${currentPageClasses}`"
71
72
  tabindex="0"
72
- :class="currentPageClasses"
73
73
  :aria-label="t('pagination.aria.current-page', {count:currentLink.i})"
74
74
  aria-current="true"
75
75
  @click="$event.preventDefault()"
@@ -82,13 +82,13 @@
82
82
  :key="entry.i"
83
83
  >
84
84
  <slot name="link"
85
- :class="pageClasses"
85
+ :class="`pagination--link ${pageClasses}`"
86
86
  :i="entry.i"
87
87
  :href="entry.href"
88
88
  :aria-label="t('pagination.aria.go-to-page', {count:entry.i})"
89
89
  >
90
90
  <a
91
- :class="pageClasses"
91
+ :class="`pagination--link ${pageClasses}`"
92
92
  :href="entry.href"
93
93
  :aria-label="t('pagination.aria.go-to-page', {count:entry.i})"
94
94
  >
@@ -96,29 +96,29 @@
96
96
  </a>
97
97
  </slot>
98
98
  </template>
99
- <div v-if="nextLink.i + extraPages < total" class="page-fill" aria-hidden="true">
99
+ <div v-if="nextLink.i + extraPages < total" class="pagination--page-fill" aria-hidden="true">
100
100
  ...
101
101
  </div>
102
102
  <slot v-if="lastLink.i !== currentLink.i"
103
103
  name="link"
104
- :class="pageClasses"
104
+ :class="`pagination--link ${pageClasses}`"
105
105
  :i="lastLink.i"
106
106
  :href="lastLink.href"
107
107
  :text="total"
108
108
  :aria-label="t('pagination.aria.go-to-page', {count:lastLink.i})"
109
109
  >
110
110
  <a
111
- :class="pageClasses"
111
+ :class="`pagination--link ${pageClasses}`"
112
112
  :href="lastLink.href"
113
113
  :aria-label="t('pagination.aria.go-to-page', {count:lastLink.i})"
114
114
  >
115
115
  {{ total }}
116
116
  </a>
117
117
  </slot>
118
- <div class="flex-1"/>
118
+ <div class="pagination--spacer flex-1"/>
119
119
  <slot
120
120
  v-if="nextLink.i <= total && nextLink.i !== currentLink.i"
121
- :class="pageClasses"
121
+ :class="`pagination--link ${pageClasses}`"
122
122
  name="link"
123
123
  :i="nextLink.i"
124
124
  :href="nextLink.href"
@@ -126,7 +126,7 @@
126
126
  :aria-label="t('pagination.aria.go-to-next-page', {count:nextLink.i})"
127
127
  >
128
128
  <a
129
- :class="pageClasses"
129
+ :class="`pagination--link ${pageClasses}`"
130
130
  :href="nextLink.href"
131
131
  :aria-label="t('pagination.aria.go-to-next-page', {count:nextLink.i})"
132
132
  >
@@ -170,7 +170,6 @@ defineOptions({
170
170
  inheritAttrs: false,
171
171
  })
172
172
 
173
- // eslint-disable-next-line no-use-before-define
174
173
  const props = withDefaults(defineProps<Props>(), {
175
174
  customRoute: (route: string, i: number) => {
176
175
  if (i === 0 || i === 1) {
@@ -1,11 +1,11 @@
1
1
  <template>
2
- <div class="flex h-full flex-col items-center justify-center ">
3
- <div class="container mx-auto ">
2
+ <div class="theme-palette flex h-full flex-col items-center justify-center ">
3
+ <div class="theme-palette--container mx-auto ">
4
4
  <div class="grid grid-cols-11 gap-2 gap-y-10 px-10">
5
5
  <template v-for="color, i in colors" :key="color">
6
6
  <div
7
7
  :style="`background-color: var(${color});`"
8
- :class="`h-10 rounded-sm flex items-center justify-center text-fg dark:text-bg`"
8
+ :class="`theme-palette--item h-10 rounded-sm flex items-center justify-center text-fg dark:text-bg`"
9
9
  >
10
10
  {{ [5, 16, 27, 38, 49].includes(i) ? 'Text':'' }}
11
11
  </div>
@@ -61,14 +61,14 @@ export const Primary: Story = {
61
61
  }
62
62
  },
63
63
  template: `
64
- <lib-input
64
+ <lib-simple-input
65
65
  :suggestions="['TL', 'TR', 'BL', 'BR']"
66
66
  :restrict-to-suggestions="true"
67
67
  :suggestions-filter="(_, items) => items"
68
68
  :label="'Button Position'"
69
69
  v-model="buttonPos"
70
70
  >
71
- </lib-input>
71
+ </lib-simple-input>
72
72
  <div>
73
73
  <label>Auto Rotate Position</label>
74
74
  <input type="checkbox" v-model="autoRotatePos">
@@ -6,21 +6,30 @@
6
6
  />
7
7
  <!-- <Transition> -->
8
8
  <component
9
+ v-if="modelValue || useDialogForBackdrop"
9
10
  :id="id ?? fallbackId"
10
11
  :class="twMerge(
11
- useBackdrop && `bg-transparent
12
+ useBackdrop && useDialogForBackdrop && `
13
+ popup--backdrop
14
+ bg-transparent
12
15
  p-0
13
16
  backdrop:bg-transparent
14
17
  `,
18
+ modelValue && useBackdrop && !useDialogForBackdrop && `
19
+ popup--backdrop
20
+ z-100
21
+ fixed
22
+ inset-0
23
+ `,
15
24
  $attrs.class as any
16
25
  )"
17
26
  v-bind="{...$attrs, class:undefined}"
18
- :is="useBackdrop ? 'dialog' : 'div'"
27
+ :is="useDialogForBackdrop ? 'dialog' : 'div'"
19
28
  ref="dialogEl"
20
29
  @mousedown.self="handleMouseup"
21
30
  >
22
- <div v-if="useBackdrop || modelValue"
23
- :class="`fixed ${props.avoidRepositioning ? 'transition-[top,left]' : ''}`"
31
+ <div v-if="modelValue"
32
+ :class="`popup z-100 fixed ${props.avoidRepositioning ? 'transition-[top,left]' : ''}`"
24
33
  :style="`
25
34
  top:${pos.y}px;
26
35
  left:${pos.x}px;
@@ -41,7 +50,7 @@
41
50
  <script setup lang="ts">
42
51
  // eslint-disable-next-line simple-import-sort/imports
43
52
  import { onMounted, nextTick, ref, useAttrs, watch , type HTMLAttributes } from "vue"
44
- import { getFallbackId, type LinkableByIdProps,type TailwindClassProp } from "../shared/props.js"
53
+ import { getFallbackId, type LinkableByIdProps, type TailwindClassProp, type PopupProps } from "../shared/props.js"
45
54
 
46
55
  import { twMerge } from "../../utils/twMerge.js"
47
56
  import { castType } from "@alanscodelog/utils/castType.js"
@@ -49,16 +58,24 @@ import { isArray } from "@alanscodelog/utils/isArray.js"
49
58
  import type { IPopupReference, PopupPosition, PopupPositioner, PopupPositionModifier, SimpleDOMRect } from "../../types/index.js"
50
59
 
51
60
  const fallbackId = getFallbackId()
52
- // eslint-disable-next-line no-use-before-define
53
61
  const props = withDefaults(defineProps<Props>(), {
54
62
  useBackdrop: true,
63
+ useDialogForBackdrop: false,
55
64
  // vue is getting confused when the prop type can also be a function
56
65
  preferredHorizontal: () => ["center-most", "either"] satisfies Props["preferredHorizontal"],
57
66
  preferredVertical: () => ["top", "bottom", "either"] satisfies Props["preferredVertical"] ,
58
67
  avoidRepositioning: false,
68
+ canClose: true,
59
69
  })
60
70
  const $attrs = useAttrs()
61
- defineOptions({ name: "lib-popup" })
71
+ defineOptions({
72
+ name: "lib-popup",
73
+ inheritAttrs: false
74
+ })
75
+
76
+ const emit = defineEmits<{
77
+ (e: "close"): void
78
+ }>()
62
79
 
63
80
 
64
81
  const dialogEl = ref<HTMLDialogElement | null>(null)
@@ -97,7 +114,6 @@ const recompute = (force: boolean = false): void => {
97
114
  const canBePositionedWithoutButton =
98
115
  (horzHasCenterScreen || typeof props.preferredHorizontal === "function")
99
116
  && (vertHasCenterScreen || typeof props.preferredVertical === "function")
100
-
101
117
  if (!popupEl.value || !dialogEl.value || (!buttonEl.value && !canBePositionedWithoutButton)) {
102
118
  pos.value = {} as any
103
119
  return
@@ -310,17 +326,20 @@ const show = () => {
310
326
  if (!isOpen) {
311
327
  isOpen = true
312
328
  modelValue.value = isOpen
313
- if (props.useBackdrop) dialogEl.value?.showModal()
329
+ if (props.useBackdrop && props.useDialogForBackdrop) dialogEl.value?.showModal()
314
330
  recompute(true)
315
331
  }
316
332
  }
317
333
 
318
334
  const close = () => {
319
335
  if (isOpen) {
336
+ const res = props.canClose ?? false
337
+ emit("close")
338
+ if (res === false) return
320
339
  isOpen = false
321
340
  modelValue.value = isOpen
322
341
  pos.value.maxWidth = undefined
323
- if (props.useBackdrop) dialogEl.value?.close()
342
+ if (props.useBackdrop && props.useDialogForBackdrop) dialogEl.value?.close()
324
343
  }
325
344
  }
326
345
 
@@ -375,63 +394,7 @@ defineExpose({
375
394
 
376
395
  type RealProps =
377
396
  & LinkableByIdProps
378
- & {
379
- useBackdrop?: boolean
380
- /**
381
- * The preferred horizontal positioning of the popup. The first position in the array to fit is used.
382
- *
383
- * All elements need to have box-sizing: border-box set. Also note that while the component should work with dynamic popup sizes, in practice there's issues with the positioning being slightly off. Giving the popup element a static size is better. If you need margins around the popup, this can be done with a wrapper element + padding.
384
- *
385
- * The positions `right`/`left`/`top`/`bottom` are relative to the opposite side of the button element so as to try not to cover the triggering button.
386
- *
387
- * So positioning `right` and `left` look like this:
388
- *
389
- * ```
390
- * // right
391
- * [button]
392
- * [----popup----]
393
- *
394
- * // left
395
- * [button]
396
- * [----popup----]
397
- * ```
398
- *
399
- * Positions `*-most` try to position the popup as close to that side of the screen as possible, otherwise limiting the popup to that edge. For example:
400
- *
401
- * ```
402
- * [--------------screen---------------]
403
- * // right-most
404
- * [button]
405
- * [----popup----]
406
- * // near the edge:
407
- * [button]
408
- * [----popup----]
409
- * ```
410
- *
411
- * There is also the `center-screen` position, which centers the popup on the screen.
412
- *
413
- * These last two (`*-most` and `center-screen`) are greedy, they will always find a position that fits. Positions listed after are ignored.
414
- *
415
- * You can also specify a function instead which is given some additional information regarding the space around the button reference element. It should a number for the x position (or y, if preferredVertical).
416
- *
417
- * If you only need to slightly modify the position, you can use the `modifyPosition` option instead.
418
- */
419
- preferredHorizontal?: ("center" | "right" | "left" | "either" | "center-screen" | "right-most" | "left-most" | "center-most")[] | PopupPositioner
420
- /** See `preferredHorizontal`. */
421
- preferredVertical?: ("top" | "bottom" | "center" | "either" | "center-screen" | "top-most" | "bottom-most" | "center-most")[] | PopupPositioner
422
- /**
423
- * When the user scrolls or resizes, normally the entire popup position is recomputed, taking into account the preferred positioning.
424
- *
425
- * This can cause it to shift around.
426
- *
427
- * Set this to true to only shift the popup depending on how much the button element moved and avoid recalculating the best position.
428
- */
429
- avoidRepositioning?: boolean
430
- /**
431
- * Allows modifying the calculated position, to for example, clamp it.
432
- */
433
- modifyPosition?: PopupPositionModifier
434
- }
397
+ & PopupProps
435
398
 
436
399
  interface Props
437
400
  extends
@@ -3,6 +3,7 @@
3
3
  <div v-if="!hide"
4
4
  :id="id ?? fallbackId"
5
5
  :class="twMerge(`
6
+ progress-bar
6
7
  w-[200px]
7
8
  whitespace-nowrap
8
9
  overflow-x-scroll
@@ -47,7 +48,7 @@
47
48
  v-bind="{...$attrs, class:undefined}"
48
49
  :style="`--progress: ${clampVal(progress, clamp[0] ?? 0, clamp[1] ?? 100)}%;`"
49
50
  >
50
- <div class="label-wrapper relative flex-1">
51
+ <div class="procgress-bar--label-wrapper relative flex-1">
51
52
  <span class="before:content-vertical-holder"/>
52
53
  <Transition>
53
54
  <slot>
@@ -71,6 +72,7 @@
71
72
  <label
72
73
  v-if="!psuedoHide"
73
74
  class="
75
+ progress-bar--label
74
76
  contrast-label
75
77
  pointer-events-none
76
78
  absolute
@@ -105,7 +107,6 @@ defineOptions({
105
107
  inheritAttrs: false,
106
108
  })
107
109
  const fallbackId = getFallbackId()
108
- // eslint-disable-next-line no-use-before-define
109
110
  const props = withDefaults(defineProps<Props>(), {
110
111
  autohideOnComplete: -1,
111
112
  keepSpaceWhenHidden: false,
@@ -43,7 +43,7 @@
43
43
  >
44
44
  <!-- :aria-description="recording ? recordingTitle : ''" -->
45
45
  <div
46
- :class="twMerge(`recorder-indicator
46
+ :class="twMerge(`recorder--indicator
47
47
  inline-block
48
48
  bg-red-700
49
49
  rounded-full
@@ -62,7 +62,7 @@
62
62
  )"
63
63
  ref="recorderIndicatorEl"
64
64
  />
65
- <div class="recorder-value before:content-vertical-holder truncate">
65
+ <div class="recorder--value before:content-vertical-holder truncate">
66
66
  {{ recording
67
67
  ? recordingValue ?? t("recorder.recording")
68
68
  : tempValue }}
@@ -93,7 +93,6 @@ const emits = defineEmits<{
93
93
  (e: "focus:parent"): void
94
94
  }>()
95
95
  const fallbackId = getFallbackId()
96
- // eslint-disable-next-line no-use-before-define
97
96
  const props = withDefaults(defineProps<Props>(), {
98
97
  recordingTitle: "",
99
98
  id: undefined,
@@ -32,6 +32,7 @@
32
32
  ($attrs as any).attrs?.class)"
33
33
  >
34
34
  <TestControls v-if="testWrapperMode" :show-outline="showOutline"/>
35
+ <Notifications v-if="useNotifications && isClientSide"/>
35
36
  <slot/>
36
37
  </div>
37
38
  </div>
@@ -44,12 +45,15 @@ import { type ComponentPublicInstance, computed, onBeforeUnmount, onMounted, ref
44
45
 
45
46
  import { useAccesibilityOutline } from "../../composables/useAccesibilityOutline.js"
46
47
  import { useDivideAttrs } from "../../composables/useDivideAttrs.js"
48
+ import { useNotificationHandler } from "../../composables/useNotificationHandler.js"
47
49
  import { useSetupDarkMode } from "../../composables/useSetupDarkMode.js"
48
50
  import { useSetupI18n } from "../../composables/useSetupI18n.js"
49
51
  import { useSetupLocale } from "../../composables/useSetupLocale.js"
50
52
  import { useShowDevOnlyKey } from "../../composables/useShowDevOnlyKey.js"
53
+ import { NotificationHandler } from "../../helpers/NotificationHandler.js"
51
54
  import { theme as defaultTheme } from "../../theme.js"
52
55
  import { twMerge } from "../../utils/twMerge.js"
56
+ import Notifications from "../LibNotifications/LibNotifications.vue"
53
57
  import TestControls from "../TestControls/TestControls.vue"
54
58
 
55
59
  const $attrs = useDivideAttrs(["wrapper"])
@@ -66,6 +70,8 @@ const props = withDefaults(defineProps<{
66
70
  /** True by default, should be passed import.meta.client if using nuxt, or false when running server side. */
67
71
  isClientSide?: boolean
68
72
  useBuiltinTranslations?: boolean
73
+ useNotifications?: boolean
74
+ notificationHandler?: NotificationHandler
69
75
  }>(), {
70
76
  theme: undefined,
71
77
  testWrapperMode: false,
@@ -74,7 +80,9 @@ const props = withDefaults(defineProps<{
74
80
  id: "app",
75
81
  getRef: undefined,
76
82
  isClientSide: true,
77
- useBuiltinTranslations: true
83
+ useBuiltinTranslations: true,
84
+ useNotifications: true,
85
+ notificationHandler: undefined
78
86
  })
79
87
 
80
88
  const el = ref<HTMLElement | null>(null)
@@ -85,6 +93,11 @@ function handleRef(_: Element | ComponentPublicInstance | null): void {
85
93
  props.getRef?.(_)
86
94
  }
87
95
 
96
+ if (props.useNotifications) {
97
+ const handler = props.notificationHandler ?? new NotificationHandler()
98
+ useNotificationHandler(handler, props.isClientSide)
99
+ }
100
+
88
101
  const autoOutline = useAccesibilityOutline(el).outline
89
102
 
90
103
  const showOutline = computed(() => (props.outline && autoOutline.value) || props.forceOutline)
@@ -7,7 +7,7 @@ import * as components from "../index.js"
7
7
 
8
8
  const meta = {
9
9
  component: components.LibSimpleInput,
10
- title: "Components/SimpleInput",
10
+ title: "Components/Input",
11
11
  args: {
12
12
  modelValue: "Value",
13
13
  placeholder: "Placeholder",
@@ -2,7 +2,7 @@
2
2
  <input
3
3
  :id="id ?? fallbackId"
4
4
  :class="twMerge(`
5
- input
5
+ simple-input
6
6
  flex-1
7
7
  grow-[999999]
8
8
  rounded-sm
@@ -48,7 +48,7 @@
48
48
  placeholder:text-danger-700
49
49
  border-danger-700
50
50
  focus:border-danger-700
51
- outlined:!ring-danger-700
51
+ outlined:!outline-danger-700
52
52
  text-danger-800
53
53
  dark:text-danger-400
54
54
  dark:placeholder:text-danger-700
@@ -71,13 +71,10 @@
71
71
 
72
72
 
73
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"
74
+ import { type InputHTMLAttributes, useAttrs } from "vue"
79
75
 
80
76
  import { useAriaLabel } from "../../composables/useAriaLabel.js"
77
+ import { usePreHydrationValue } from "../../composables/usePreHydrationValue.js"
81
78
  import { hasModifiers } from "../../helpers/hasModifiers.js"
82
79
  import { twMerge } from "../../utils/twMerge.js"
83
80
  import { type BaseInteractiveProps, baseInteractivePropsDefaults, getFallbackId,type LabelProps, type LinkableByIdProps, type TailwindClassProp } from "../shared/props.js"
@@ -90,7 +87,6 @@ defineOptions({
90
87
 
91
88
  const fallbackId = getFallbackId()
92
89
 
93
- // eslint-disable-next-line no-use-before-define
94
90
  const props = withDefaults(defineProps<Props>(), {
95
91
  id: "",
96
92
  placeholder: "",
@@ -115,6 +111,7 @@ function handleKeydown(e: KeyboardEvent) {
115
111
  emit("submit", modelValue.value)
116
112
  }
117
113
  }
114
+ usePreHydrationValue(props.id ?? fallbackId, modelValue)
118
115
 
119
116
  </script>
120
117