@witchcraft/ui 0.2.1-beta.2 → 0.2.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 (173) hide show
  1. package/dist/module.json +1 -1
  2. package/dist/module.mjs +4 -5
  3. package/dist/runtime/build/WitchcraftUiResolver.d.ts +2 -2
  4. package/dist/runtime/build/generateTheme.js +2 -2
  5. package/dist/runtime/components/Aria/Aria.vue +4 -2
  6. package/dist/runtime/components/Aria/Aria.vue.d.ts +1 -1
  7. package/dist/runtime/components/Icon/Icon.vue +3 -3
  8. package/dist/runtime/components/Icon/Icon.vue.d.ts +1 -1
  9. package/dist/runtime/components/LibButton/LibButton.vue +9 -4
  10. package/dist/runtime/components/LibButton/LibButton.vue.d.ts +1 -1
  11. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +3 -4
  12. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue.d.ts +1 -1
  13. package/dist/runtime/components/LibColorInput/LibColorInput.vue +15 -8
  14. package/dist/runtime/components/LibColorInput/LibColorInput.vue.d.ts +1 -1
  15. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +10 -6
  16. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue.d.ts +1 -1
  17. package/dist/runtime/components/LibColorPicker/utils/truncate.js +1 -1
  18. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +5 -2
  19. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue.d.ts +1 -1
  20. package/dist/runtime/components/LibDatePicker/LibDatePicker.vue.d.ts +1 -1
  21. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +8 -6
  22. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue.d.ts +1 -1
  23. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +7 -5
  24. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue.d.ts +1 -1
  25. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue.d.ts +1 -1
  26. package/dist/runtime/components/LibDebug/LibDebug.vue +9 -4
  27. package/dist/runtime/components/LibDebug/LibDebug.vue.d.ts +1 -1
  28. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +2 -1
  29. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue.d.ts +4 -1
  30. package/dist/runtime/components/LibFileInput/LibFileInput.vue +29 -13
  31. package/dist/runtime/components/LibFileInput/LibFileInput.vue.d.ts +2 -2
  32. package/dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +42 -12
  33. package/dist/runtime/components/LibLabel/LibLabel.vue +2 -2
  34. package/dist/runtime/components/LibLabel/LibLabel.vue.d.ts +3 -3
  35. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +1 -2
  36. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue.d.ts +2 -2
  37. package/dist/runtime/components/LibNotifications/LibNotification.vue +19 -8
  38. package/dist/runtime/components/LibNotifications/LibNotifications.vue +10 -6
  39. package/dist/runtime/components/LibNotifications/LibNotifications.vue.d.ts +2 -2
  40. package/dist/runtime/components/LibPagination/LibPagination.vue +25 -12
  41. package/dist/runtime/components/LibPagination/LibPagination.vue.d.ts +2 -2
  42. package/dist/runtime/components/LibPalette/LibPalette.vue +6 -5
  43. package/dist/runtime/components/LibPalette/LibPalette.vue.d.ts +5 -5
  44. package/dist/runtime/components/LibPopup/LibPopup.vue +6 -4
  45. package/dist/runtime/components/LibPopup/LibPopup.vue.d.ts +3 -3
  46. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +5 -3
  47. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue.d.ts +9 -9
  48. package/dist/runtime/components/LibRecorder/LibRecorder.vue +1 -1
  49. package/dist/runtime/components/LibRecorder/LibRecorder.vue.d.ts +2 -2
  50. package/dist/runtime/components/LibRoot/LibRoot.vue +11 -6
  51. package/dist/runtime/components/LibRoot/LibRoot.vue.d.ts +1 -1
  52. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +1 -1
  53. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue.d.ts +1 -1
  54. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +5 -3
  55. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue.d.ts +1 -1
  56. package/dist/runtime/components/LibTable/LibTable.vue +23 -8
  57. package/dist/runtime/components/LibTable/LibTable.vue.d.ts +1 -1
  58. package/dist/runtime/components/Template/NAME.vue +2 -3
  59. package/dist/runtime/components/Template/NAME.vue.d.ts +1 -1
  60. package/dist/runtime/components/TestControls/TestControls.vue +4 -2
  61. package/dist/runtime/components/TestControls/TestControls.vue.d.ts +1 -1
  62. package/dist/runtime/composables/useDragWithThreshold.d.ts +1 -1
  63. package/dist/runtime/composables/useInjectedI18n.d.ts +1 -1
  64. package/dist/runtime/composables/useScrollNearContainerEdges.d.ts +1 -1
  65. package/dist/runtime/composables/useSetupI18n.d.ts +1 -1
  66. package/dist/runtime/composables/useSuggestions.d.ts +2 -2
  67. package/dist/runtime/helpers/NotificationHandler.d.ts +1 -1
  68. package/dist/runtime/helpers/base64ToImg.js +2 -2
  69. package/dist/runtime/tailwind/themeConvertionOpts.d.ts +1 -1
  70. package/dist/runtime/types/index.d.ts +1 -1
  71. package/dist/runtime/utils/notifyIfError.d.ts +1 -1
  72. package/package.json +4 -6
  73. package/src/module.ts +28 -32
  74. package/src/runtime/build/WitchcraftUiResolver.ts +3 -3
  75. package/src/runtime/build/generateTheme.ts +3 -2
  76. package/src/runtime/build/unpluginIconViteOptions.ts +1 -1
  77. package/src/runtime/components/Aria/Aria.vue +5 -6
  78. package/src/runtime/components/Focus.stories.ts +11 -12
  79. package/src/runtime/components/Icon/Icon.vue +5 -9
  80. package/src/runtime/components/LibButton/LibButton.stories.ts +21 -22
  81. package/src/runtime/components/LibButton/LibButton.vue +23 -21
  82. package/src/runtime/components/LibCheckbox/LibCheckbox.stories.ts +6 -10
  83. package/src/runtime/components/LibCheckbox/LibCheckbox.vue +17 -19
  84. package/src/runtime/components/LibColorInput/LibColorInput.stories.ts +8 -13
  85. package/src/runtime/components/LibColorInput/LibColorInput.vue +49 -45
  86. package/src/runtime/components/LibColorPicker/LibColorPicker.stories.ts +14 -18
  87. package/src/runtime/components/LibColorPicker/LibColorPicker.vue +50 -52
  88. package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +1 -2
  89. package/src/runtime/components/LibColorPicker/utils/safeConvertToRgba.ts +1 -2
  90. package/src/runtime/components/LibColorPicker/utils/truncate.ts +1 -2
  91. package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts +5 -8
  92. package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +11 -9
  93. package/src/runtime/components/LibDatePicker/LibDatePicker.stories.ts +14 -15
  94. package/src/runtime/components/LibDatePicker/LibDatePicker.vue +1 -2
  95. package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +13 -13
  96. package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +9 -8
  97. package/src/runtime/components/LibDatePicker/LibTimeZonePicker.vue +2 -1
  98. package/src/runtime/components/LibDatePicker/helpers.ts +0 -2
  99. package/src/runtime/components/LibDebug/LibDebug.stories.ts +11 -15
  100. package/src/runtime/components/LibDebug/LibDebug.vue +14 -11
  101. package/src/runtime/components/LibDevOnly/LibDevOnly.vue +8 -4
  102. package/src/runtime/components/LibFileInput/LibFileInput.stories.ts +12 -15
  103. package/src/runtime/components/LibFileInput/LibFileInput.vue +65 -47
  104. package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.stories.ts +59 -67
  105. package/src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue +73 -48
  106. package/src/runtime/components/LibLabel/LibLabel.stories.ts +4 -8
  107. package/src/runtime/components/LibLabel/LibLabel.vue +8 -8
  108. package/src/runtime/components/LibMultiValues/LibMultiValues.stories.ts +10 -15
  109. package/src/runtime/components/LibMultiValues/LibMultiValues.vue +14 -18
  110. package/src/runtime/components/LibNotifications/LibNotification.stories.ts +30 -34
  111. package/src/runtime/components/LibNotifications/LibNotification.vue +27 -17
  112. package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +11 -15
  113. package/src/runtime/components/LibNotifications/LibNotifications.vue +21 -16
  114. package/src/runtime/components/LibPagination/LibPagination.stories.ts +5 -9
  115. package/src/runtime/components/LibPagination/LibPagination.vue +46 -32
  116. package/src/runtime/components/LibPalette/LibPalette.stories.ts +3 -7
  117. package/src/runtime/components/LibPalette/LibPalette.vue +13 -12
  118. package/src/runtime/components/LibPopup/LibPopup.stories.ts +19 -23
  119. package/src/runtime/components/LibPopup/LibPopup.vue +31 -35
  120. package/src/runtime/components/LibProgressBar/LibProgressBar.stories.ts +13 -17
  121. package/src/runtime/components/LibProgressBar/LibProgressBar.vue +36 -33
  122. package/src/runtime/components/LibRecorder/LibRecorder.stories.ts +11 -12
  123. package/src/runtime/components/LibRecorder/LibRecorder.vue +34 -34
  124. package/src/runtime/components/LibRoot/LibRoot.vue +16 -12
  125. package/src/runtime/components/LibSimpleInput/LibSimpleInput.stories.ts +20 -24
  126. package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +17 -21
  127. package/src/runtime/components/LibSuggestions/LibSuggestions.stories.ts +16 -19
  128. package/src/runtime/components/LibSuggestions/LibSuggestions.vue +27 -30
  129. package/src/runtime/components/LibTable/LibTable.stories.ts +30 -33
  130. package/src/runtime/components/LibTable/LibTable.vue +38 -24
  131. package/src/runtime/components/Reset.stories.ts +3 -6
  132. package/src/runtime/components/Scrolling.stories.ts +5 -8
  133. package/src/runtime/components/Template/NAME.vue +11 -11
  134. package/src/runtime/components/Template/TemplateStory.ts +9 -10
  135. package/src/runtime/components/TestControls/TestControls.vue +5 -5
  136. package/src/runtime/components/shared/props.ts +4 -6
  137. package/src/runtime/components/shared/storyHelpers/playInput.ts +2 -3
  138. package/src/runtime/components/shared/storyHelpers/playSuggestions.ts +5 -9
  139. package/src/runtime/composables/useAccesibilityOutline.ts +1 -1
  140. package/src/runtime/composables/useAriaLabel.ts +1 -1
  141. package/src/runtime/composables/useDarkMode.ts +15 -19
  142. package/src/runtime/composables/useDragWithThreshold.ts +6 -8
  143. package/src/runtime/composables/useGlobalResizeObserver.ts +0 -1
  144. package/src/runtime/composables/useInjectedDarkMode.ts +2 -2
  145. package/src/runtime/composables/useInjectedI18n.ts +1 -1
  146. package/src/runtime/composables/useInjectedLocale.ts +3 -4
  147. package/src/runtime/composables/useScrollNearContainerEdges.stories.ts +4 -4
  148. package/src/runtime/composables/useScrollNearContainerEdges.ts +12 -13
  149. package/src/runtime/composables/useSetupI18n.ts +4 -7
  150. package/src/runtime/composables/useSetupLocale.ts +3 -5
  151. package/src/runtime/composables/useSuggestions.ts +25 -30
  152. package/src/runtime/directives/vDetectFlex.ts +5 -8
  153. package/src/runtime/directives/vExtractRootEl.ts +1 -1
  154. package/src/runtime/directives/vResizableCols.ts +3 -7
  155. package/src/runtime/directives/vResizeObserver.ts +1 -2
  156. package/src/runtime/globalResizeObserver.ts +0 -1
  157. package/src/runtime/helpers/NotificationHandler.ts +8 -12
  158. package/src/runtime/helpers/base64ToImg.ts +2 -3
  159. package/src/runtime/helpers/createNoonUtcDate.ts +0 -1
  160. package/src/runtime/helpers/defaultTranslationFunction.ts +0 -1
  161. package/src/runtime/helpers/getTimeZoneList.ts +0 -1
  162. package/src/runtime/helpers/readFile.ts +2 -2
  163. package/src/runtime/helpers/resizeObserverWrapper.ts +0 -1
  164. package/src/runtime/helpers/storybook.ts +2 -3
  165. package/src/runtime/main.lib.ts +0 -2
  166. package/src/runtime/nuxt/plugins/vue-plugin.ts +4 -5
  167. package/src/runtime/tailwind/themeConvertionOpts.ts +3 -4
  168. package/src/runtime/theme.ts +0 -1
  169. package/src/runtime/types/index.ts +3 -4
  170. package/src/runtime/utils/notifyIfError.ts +2 -2
  171. package/src/runtime/utils/twMerge.ts +2 -2
  172. package/src/runtime/vue/VueComponentsPlugin.ts +1 -2
  173. package/src/runtime/vue/registerComponents.ts +0 -1
@@ -1,5 +1,4 @@
1
- import { computed, type InjectionKey, onMounted, provide, type Ref,ref, watch } from "vue"
2
-
1
+ import { computed, type InjectionKey, onMounted, provide, type Ref, ref, watch } from "vue"
3
2
 
4
3
  const defaultLocalStorageKey = "prefersColorSchemeDark"
5
4
  const defaultOrder = ["system", "dark", "light"] as const
@@ -29,7 +28,7 @@ export const useDarkMode = ({
29
28
  }: DarkModeOptions = {}): DarkModeState & DarkModeCommands => {
30
29
  const systemDarkMode = ref(false)
31
30
  const manualDarkMode = ref<boolean | undefined>(undefined)
32
-
31
+
33
32
  if (useLocalStorage && isClientSide) {
34
33
  watch(manualDarkMode, () => {
35
34
  localStorage.setItem(defaultLocalStorageKey, manualDarkMode.value ? "true" : "false")
@@ -39,19 +38,19 @@ export const useDarkMode = ({
39
38
  const darkMode = computed(() => manualDarkMode.value ?? systemDarkMode.value)
40
39
  const darkModeState = computed(() =>
41
40
  manualDarkMode.value === undefined
42
- ? "system"
43
- : manualDarkMode.value
44
- ? "dark"
45
- : "light"
41
+ ? "system"
42
+ : manualDarkMode.value
43
+ ? "dark"
44
+ : "light"
46
45
  )
47
46
  // todo move to useinjected
48
47
  function setDarkMode(value: "dark" | "light" | "system"): void {
49
- manualDarkMode.value =
50
- value === "dark"
51
- ? true
52
- : value === "light"
53
- ? false
54
- : undefined
48
+ manualDarkMode.value
49
+ = value === "dark"
50
+ ? true
51
+ : value === "light"
52
+ ? false
53
+ : undefined
55
54
  }
56
55
  function cycleDarkMode(): void {
57
56
  const index = darkModeOrder.indexOf(darkModeState.value)
@@ -90,11 +89,11 @@ export const useDarkMode = ({
90
89
  darkMode,
91
90
  darkModeState,
92
91
  manualDarkMode,
93
- systemDarkMode,
92
+ systemDarkMode
94
93
  })
95
94
  provide(commandsInjectionKey, {
96
95
  setDarkMode,
97
- cycleDarkMode,
96
+ cycleDarkMode
98
97
  })
99
98
 
100
99
  return {
@@ -103,7 +102,7 @@ export const useDarkMode = ({
103
102
  setDarkMode,
104
103
  cycleDarkMode,
105
104
  manualDarkMode,
106
- systemDarkMode,
105
+ systemDarkMode
107
106
  }
108
107
  }
109
108
  export const defaultDarkModeOrder = defaultOrder
@@ -116,7 +115,6 @@ export const darkModeCommandsInjectionKey = commandsInjectionKey
116
115
 
117
116
  export const darkModeStateInjectionKey = stateInjectionKey
118
117
 
119
-
120
118
  export type DarkModeOptions = {
121
119
  /* Whether to save the manual dark mode to local storage. Uses the key "prefersColorSchemeDark" by default. You can pass a key instead of true to use that as the key instead. */
122
120
  useLocalStorage?: boolean | string
@@ -126,13 +124,11 @@ export type DarkModeOptions = {
126
124
  isClientSide?: boolean
127
125
  }
128
126
 
129
-
130
127
  export interface DarkModeCommands {
131
128
  setDarkMode: (value: "dark" | "light" | "system") => void
132
129
  cycleDarkMode: () => void
133
130
  }
134
131
 
135
-
136
132
  export interface DarkModeState {
137
133
  /** Whether the dark mode should be enabled or not */
138
134
  darkMode: Ref<boolean>
@@ -2,7 +2,6 @@ import { type Ref, ref } from "vue"
2
2
 
3
3
  import type { Point } from "../types/index.js"
4
4
 
5
-
6
5
  /**
7
6
  * A composable for dragging items only after a certain threshold of movement has been reached.
8
7
  *
@@ -58,12 +57,12 @@ import type { Point } from "../types/index.js"
58
57
  export const useDragWithThreshold = ({
59
58
  initialOffset = ref({ x: 0, y: 0 }),
60
59
  pointerCoords = ref({ x: 0, y: 0 }),
61
- threshold = ref(10),
60
+ threshold = ref(10)
62
61
  }: {
63
62
  initialOffset?: Ref<Point | undefined>
64
63
  pointerCoords?: Ref<Point | undefined>
65
64
  threshold?: Ref<number>
66
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
65
+
67
66
  } = {}) => {
68
67
  const passedDragThreshold = ref(false)
69
68
  function getDistance(p1: Point, p2: Point): number {
@@ -80,9 +79,9 @@ export const useDragWithThreshold = ({
80
79
  function checkDragThreshold(e: PointerEvent): void {
81
80
  pointerCoords.value = getEventCoords(e)
82
81
  // don't allow it to be reset to false
83
- passedDragThreshold.value ||=
84
- initialOffset.value !== undefined &&
85
- getDistance(initialOffset.value, pointerCoords.value) >= threshold.value
82
+ passedDragThreshold.value
83
+ ||= initialOffset.value !== undefined
84
+ && getDistance(initialOffset.value, pointerCoords.value) >= threshold.value
86
85
  }
87
86
  function startDragThresholdCheck(e: PointerEvent): void {
88
87
  passedDragThreshold.value = false
@@ -102,7 +101,6 @@ export const useDragWithThreshold = ({
102
101
  getEventCoords,
103
102
  checkDragThreshold,
104
103
  startDragThresholdCheck,
105
- endDragThresholdCheck,
104
+ endDragThresholdCheck
106
105
  }
107
106
  }
108
-
@@ -3,7 +3,6 @@ import { onBeforeUnmount, onMounted, type Ref, watch } from "vue"
3
3
 
4
4
  import { globalResizeObserver } from "../globalResizeObserver.js"
5
5
 
6
-
7
6
  export const useGlobalResizeObserver = (el: Ref<HTMLElement | null>, cb: AnyFunction): void => {
8
7
  let wasMounted = false
9
8
  // in case we accidentally use it in an onMounted hook or somewhere where the element already exists
@@ -1,6 +1,6 @@
1
1
  import { inject } from "vue"
2
2
 
3
- import { type DarkModeCommands, darkModeCommandsInjectionKey, type DarkModeState,darkModeStateInjectionKey } from "./useDarkMode.js"
3
+ import { type DarkModeCommands, darkModeCommandsInjectionKey, type DarkModeState, darkModeStateInjectionKey } from "./useDarkMode.js"
4
4
 
5
5
  export function useInjectedDarkMode(): DarkModeState & DarkModeCommands {
6
6
  const darkModeState = inject(darkModeStateInjectionKey)
@@ -10,6 +10,6 @@ export function useInjectedDarkMode(): DarkModeState & DarkModeCommands {
10
10
  }
11
11
  return {
12
12
  ...darkModeState,
13
- ...darkModeCommands,
13
+ ...darkModeCommands
14
14
  }
15
15
  }
@@ -1,7 +1,7 @@
1
1
  import { inject } from "vue"
2
2
 
3
+ import type { TranslationFunction } from "./useSetupI18n.js"
3
4
  import { i18nInjectionKey } from "./useSetupI18n.js"
4
- import { type TranslationFunction } from "./useSetupI18n.js"
5
5
 
6
6
  export function useInjectedI18n(): TranslationFunction {
7
7
  const val = inject(i18nInjectionKey, undefined)
@@ -1,6 +1,6 @@
1
1
  import { inject } from "vue"
2
2
 
3
- import { languageLocaleInjectionKey , timeLocaleInjectionKey , type useSetupLocale } from "./useSetupLocale.js"
3
+ import { languageLocaleInjectionKey, timeLocaleInjectionKey, type useSetupLocale } from "./useSetupLocale.js"
4
4
 
5
5
  export function useInjectedLocale(): ReturnType<typeof useSetupLocale> {
6
6
  const timeLocale = inject(timeLocaleInjectionKey)
@@ -14,11 +14,10 @@ export function useInjectedLocale(): ReturnType<typeof useSetupLocale> {
14
14
  function setTimeLocale(value: string): void {
15
15
  timeLocale!.value = value
16
16
  }
17
- return{
17
+ return {
18
18
  timeLocale,
19
19
  languageLocale,
20
20
  setLanguageLocale,
21
- setTimeLocale,
21
+ setTimeLocale
22
22
  }
23
23
  }
24
-
@@ -6,7 +6,7 @@ import { useScrollNearContainerEdges } from "./useScrollNearContainerEdges.js"
6
6
  import { twMerge } from "../utils/twMerge.js"
7
7
 
8
8
  const meta = {
9
- title: "Composables/ScrollNearContainerEdges",
9
+ title: "Composables/ScrollNearContainerEdges"
10
10
  }
11
11
 
12
12
  export default meta
@@ -25,7 +25,7 @@ export const Primary: Story = {
25
25
  } = useScrollNearContainerEdges({
26
26
  containerEl,
27
27
  scrollMargin: 20,
28
- outerScrollMargin: 20,
28
+ outerScrollMargin: 20
29
29
  })
30
30
  const pos = ref({ x: 0, y: 0 })
31
31
  onMounted(() => {
@@ -88,6 +88,6 @@ export const Primary: Story = {
88
88
  ></div>
89
89
  </div>
90
90
  </div>
91
- `,
92
- }),
91
+ `
92
+ })
93
93
  }
@@ -2,7 +2,6 @@ import { reactive, type Ref, ref } from "vue"
2
2
 
3
3
  import type { ScrollNearContainerEdgesOptions } from "../types/index.js"
4
4
 
5
-
6
5
  /**
7
6
  * Creates a function `scrollContainer` that allows scrolling a container manually when the coordinates are near it's edges.
8
7
  * Supports scrolling faster the closer one is to the edge, and configuing an inner and outer margin.
@@ -55,7 +54,7 @@ import type { ScrollNearContainerEdgesOptions } from "../types/index.js"
55
54
  * </div>
56
55
  * ```
57
56
  */
58
-
57
+
59
58
  export const useScrollNearContainerEdges = ({
60
59
  containerEl,
61
60
  scrollMargin = 10,
@@ -63,16 +62,16 @@ export const useScrollNearContainerEdges = ({
63
62
  fastPixelMultiplier = 4,
64
63
  fastPixelAmount,
65
64
  useTimer = true,
66
- timerInterval = 1,
65
+ timerInterval = 1
67
66
  }: ScrollNearContainerEdgesOptions): {
68
- scrollEdges: (clientX: number, clientY: number, overrideUseTimer?: boolean) => void
69
- /** Reactive. */
70
- scrollIndicator: { left: boolean, right: boolean, down: boolean, up: boolean }
71
- resetScrollIndicator: () => void
72
- clearScrollInterval: () => void
73
- isScrolling: Ref<boolean>
74
- endScroll: () => void
75
- } => {
67
+ scrollEdges: (clientX: number, clientY: number, overrideUseTimer?: boolean) => void
68
+ /** Reactive. */
69
+ scrollIndicator: { left: boolean, right: boolean, down: boolean, up: boolean }
70
+ resetScrollIndicator: () => void
71
+ clearScrollInterval: () => void
72
+ isScrolling: Ref<boolean>
73
+ endScroll: () => void
74
+ } => {
76
75
  fastPixelMultiplier = fastPixelAmount !== undefined ? fastPixelAmount * 2 : fastPixelMultiplier
77
76
  const scrollIndicator = reactive({ left: false, right: false, down: false, up: false })
78
77
  const isScrolling = ref(false)
@@ -104,7 +103,7 @@ export const useScrollNearContainerEdges = ({
104
103
  const el = containerEl.value
105
104
  if (!el) return
106
105
  const box = el.getBoundingClientRect()
107
-
106
+
108
107
  /*
109
108
  rightRightLimit│
110
109
 
@@ -199,7 +198,7 @@ export const useScrollNearContainerEdges = ({
199
198
  resetScrollIndicator,
200
199
  clearScrollInterval,
201
200
  isScrolling,
202
- endScroll,
201
+ endScroll
203
202
  /* resetMove does not need to be returned since the user cannot call the timer interval manually and the scrollContainer function resets it before starting. */
204
203
  }
205
204
  }
@@ -3,12 +3,11 @@ import {
3
3
  provide,
4
4
  type Ref,
5
5
  ref,
6
- watch,
6
+ watch
7
7
  } from "vue"
8
8
 
9
9
  import { defaultTranslationFunction } from "../helpers/defaultTranslationFunction.js"
10
10
 
11
-
12
11
  export type TranslationFunction = (key: string, replacements?: Record<string, any>) => string
13
12
 
14
13
  const _i18nInjectionKey = Symbol("witchcraftUiI18n") as InjectionKey<TranslationFunction>
@@ -19,17 +18,16 @@ const loaded: Record<string, any> = {}
19
18
  const dummyLibraryMessages = new Proxy({}, {
20
19
  get() {
21
20
  return "..."
22
- },
21
+ }
23
22
  })
24
23
  const dummyMessageSet = new Proxy({}, {
25
24
  get(_, key: string) {
26
25
  if (key === "witchcraft-ui") {
27
26
  return dummyLibraryMessages
28
27
  } else return undefined
29
- },
28
+ }
30
29
  })
31
30
 
32
-
33
31
  /**
34
32
  * A composable for providing a translation function + messages for the library. Note the Root component already takes care of setting this up with defaults, disable it via it's `useBuiltinTranslations` option.
35
33
  *
@@ -43,7 +41,7 @@ export async function useSetupI18n({
43
41
  locale,
44
42
  useBuiltinTranslations = false,
45
43
  useDummyMessageSetWhileLoading = true,
46
- translationFunction = defaultTranslationFunction,
44
+ translationFunction = defaultTranslationFunction
47
45
  }: {
48
46
  locale: Ref<string>
49
47
  /** Will asynchronously load the built-in translations for the current locale (watching and updating if needed). If you don't use this, you'll need to provide a custom translation function. */
@@ -80,4 +78,3 @@ export async function useSetupI18n({
80
78
 
81
79
  export const i18nInjectionKey = _i18nInjectionKey
82
80
  export const translationMessagesInjectionKey = _translationMessagesInjectionKey
83
-
@@ -1,5 +1,4 @@
1
- import { type InjectionKey, provide,type Ref,ref } from "vue"
2
-
1
+ import { type InjectionKey, provide, type Ref, ref } from "vue"
3
2
 
4
3
  export const languageLocaleInjectionKey = Symbol("witchcraftUiLanguageLocale") as InjectionKey<Ref<string>>
5
4
  export const timeLocaleInjectionKey = Symbol("witchcraftUiTimeLocale") as InjectionKey<Ref<string>>
@@ -19,14 +18,13 @@ export function useSetupLocale(): {
19
18
  function setTimeLocale(value: string): void {
20
19
  timeLocale.value = value
21
20
  }
22
-
21
+
23
22
  provide(languageLocaleInjectionKey, languageLocale)
24
23
  provide(timeLocaleInjectionKey, timeLocale)
25
24
  return {
26
25
  languageLocale,
27
26
  timeLocale,
28
27
  setLanguageLocale,
29
- setTimeLocale,
28
+ setTimeLocale
30
29
  }
31
30
  }
32
-
@@ -1,20 +1,19 @@
1
1
  /* eslint-disable no-console */
2
- import { type AnyFunction } from "@alanscodelog/utils"
2
+ import type { AnyFunction } from "@alanscodelog/utils"
3
3
  import { isBlank } from "@alanscodelog/utils/isBlank"
4
4
  import { isObject } from "@alanscodelog/utils/isObject"
5
5
  import { pushIfNotIn } from "@alanscodelog/utils/pushIfNotIn"
6
6
  import { removeIfIn } from "@alanscodelog/utils/removeIfIn"
7
7
  import { computed, type Ref, ref, toRaw, watch } from "vue"
8
8
 
9
- import { type SuggestionsEmits,type SuggestionsOptions } from "../components/shared/props.js"
10
-
9
+ import type { SuggestionsEmits, SuggestionsOptions } from "../components/shared/props.js"
11
10
 
12
11
  /**
13
12
  * The logic for the suggestions component.
14
13
  *
15
14
  * Note that while object suggestions are supported, the `suggestionLabel` prop is required and $inputModel and $modelValue will still be string values (as returned by the suggestionLabel function).
16
15
  */
17
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
16
+
18
17
  export function useSuggestions<TSuggestion, TMultivalue extends boolean = false>(
19
18
  $inputValue: Ref<string>,
20
19
  $modelValue: Ref<TMultivalue extends true ? string[] : string>,
@@ -46,12 +45,12 @@ export function useSuggestions<TSuggestion, TMultivalue extends boolean = false>
46
45
  const defaultSuggestionsFilter = (input: string, items: TSuggestion[]): TSuggestion[] => input === ""
47
46
  ? [...items]
48
47
  : items.filter(item => {
49
- if (Array.isArray($modelValue.value)) {
48
+ if (Array.isArray($modelValue.value)) {
50
49
  // always include selected values for unselecting
51
- if ($modelValue.value.includes(getSuggestionLabel(item))) return true
52
- }
53
- return getSuggestionLabel(item).toLowerCase().includes(input.toLowerCase())
54
- })
50
+ if ($modelValue.value.includes(getSuggestionLabel(item))) return true
51
+ }
52
+ return getSuggestionLabel(item).toLowerCase().includes(input.toLowerCase())
53
+ })
55
54
  const suggestionsFilter = computed(() => opts.suggestionsFilter ?? defaultSuggestionsFilter)
56
55
 
57
56
  const suggestionsList = computed(() => {
@@ -81,8 +80,8 @@ export function useSuggestions<TSuggestion, TMultivalue extends boolean = false>
81
80
 
82
81
  const openable = computed(() =>
83
82
  opts.canOpen && (
84
- (isBlank($inputValue.value) && opts.allowOpenEmpty) ||
85
- suggestionAvailable.value
83
+ (isBlank($inputValue.value) && opts.allowOpenEmpty)
84
+ || suggestionAvailable.value
86
85
 
87
86
  )
88
87
  )
@@ -99,7 +98,6 @@ export function useSuggestions<TSuggestion, TMultivalue extends boolean = false>
99
98
  return undefined
100
99
  })
101
100
 
102
-
103
101
  // methods
104
102
  // returns true if the value was removed
105
103
  function setValue(val: string): boolean {
@@ -135,12 +133,12 @@ export function useSuggestions<TSuggestion, TMultivalue extends boolean = false>
135
133
  }
136
134
  $open.value = true
137
135
  }
138
-
136
+
139
137
  function enterSuggestion(num: number, doClose: boolean = true): void {
140
138
  if (num < -1 || num > (filteredSuggestions.value?.length ?? 0)) return
141
139
  if (debug) console.log("enterSuggestion", num)
142
140
  if (filteredSuggestions.value === undefined) return
143
-
141
+
144
142
  const suggestion = filteredSuggestions.value[num]
145
143
  const val = getSuggestionLabel(suggestion)
146
144
  const wasRemoved = setValue(val)
@@ -174,7 +172,7 @@ export function useSuggestions<TSuggestion, TMultivalue extends boolean = false>
174
172
  activeSuggestion.value = filteredSuggestions.value!.length - 1
175
173
  }
176
174
  }
177
-
175
+
178
176
  function toggleSuggestions(): void {
179
177
  $open.value ? closeSuggestions() : openSuggestions()
180
178
  }
@@ -202,7 +200,7 @@ export function useSuggestions<TSuggestion, TMultivalue extends boolean = false>
202
200
  function lastSuggestion(): void {
203
201
  selectSuggestion(Infinity)
204
202
  }
205
-
203
+
206
204
  function cancel(): void {
207
205
  if (Array.isArray($modelValue.value)) {
208
206
  $inputValue.value = ""
@@ -213,30 +211,29 @@ export function useSuggestions<TSuggestion, TMultivalue extends boolean = false>
213
211
  closeSuggestions()
214
212
  }
215
213
 
216
-
217
214
  watch(() => opts.canOpen, val => {
218
215
  if (!val) {
219
216
  if (debug) console.log("canOpen changed to false, closing suggestions")
220
217
  closeSuggestions()
221
218
  }
222
219
  })
223
-
220
+
224
221
  watch(openable, val => {
225
222
  if (!val) {
226
223
  if (debug) console.log("openable changed to false, closing suggestions")
227
224
  closeSuggestions()
228
225
  }
229
226
  })
230
-
227
+
231
228
  watch(isValidSuggestion, () => {
232
229
  if (!isValidSuggestion.value) {
233
230
  if (debug) console.log("isValidSuggestion changed to false, opening suggestions")
234
231
  openSuggestions()
235
232
  }
236
233
  })
237
-
234
+
238
235
  // sync vmodels and vmodel effects
239
-
236
+
240
237
  watch($modelValue, () => {
241
238
  if (Array.isArray($modelValue.value)) {
242
239
  $inputValue.value = ""
@@ -272,7 +269,7 @@ export function useSuggestions<TSuggestion, TMultivalue extends boolean = false>
272
269
  if (debug) console.log("input changed, suggestion available, opening suggestions")
273
270
  openSuggestions()
274
271
  }
275
-
272
+
276
273
  if (!opts.restrictToSuggestions && !Array.isArray($modelValue.value)) {
277
274
  if (debug) console.log("input changed, unrestricted, setting modelValue")
278
275
  setValue($inputValue.value)
@@ -282,16 +279,15 @@ export function useSuggestions<TSuggestion, TMultivalue extends boolean = false>
282
279
  selectSuggestion(suggestionsList.value.indexOf(exactlyMatchingSuggestion.value))
283
280
  } else {
284
281
  if (debug) console.log("input changed, not exactly matching, finding longest match")
285
-
286
- const i =
287
- opts.suggestionSelector?.(filteredSuggestions.value ?? [], $inputValue.value)
288
- ?? defaultSuggestionSelector(filteredSuggestions.value ?? [], $inputValue.value)
282
+
283
+ const i
284
+ = opts.suggestionSelector?.(filteredSuggestions.value ?? [], $inputValue.value)
285
+ ?? defaultSuggestionSelector(filteredSuggestions.value ?? [], $inputValue.value)
289
286
 
290
287
  selectSuggestion(i)
291
288
  }
292
289
  })
293
290
 
294
-
295
291
  return {
296
292
  list: suggestionsList,
297
293
  filtered: filteredSuggestions,
@@ -314,12 +310,11 @@ export function useSuggestions<TSuggestion, TMultivalue extends boolean = false>
314
310
  prev: prevSuggestion,
315
311
  next: nextSuggestion,
316
312
  first: firstSuggestion,
317
- last: lastSuggestion,
313
+ last: lastSuggestion
318
314
 
319
315
  }
320
316
  }
321
317
 
322
- // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
323
318
  export function useSuggestionsInputAria(
324
319
  id: Ref<string>,
325
320
  $open: Ref<boolean>,
@@ -331,7 +326,7 @@ export function useSuggestionsInputAria(
331
326
  "aria-controls": suggestions !== undefined ? `suggestions-${id.value}` : undefined,
332
327
  role: suggestions ? "combobox" : undefined,
333
328
  "aria-expanded": suggestions !== undefined ? $open.value : undefined,
334
- "aria-activedescendant": $open.value ? `suggestion-${id.value}-${activeSuggestion.value}` : undefined,
329
+ "aria-activedescendant": $open.value ? `suggestion-${id.value}-${activeSuggestion.value}` : undefined
335
330
  }))
336
331
  return ariaInputProps
337
332
  }
@@ -7,7 +7,6 @@ import type { Directive } from "vue"
7
7
  import { globalResizeObserver } from "../globalResizeObserver.js"
8
8
  import type { ResizeCallback } from "../types/index.js"
9
9
 
10
-
11
10
  const observer = globalResizeObserver
12
11
  /**
13
12
  * Directive for detecting flex wrap on element. It will bind a resize-observer to the element to detect when it's children have wrapped and add a .wrapped class when they are.
@@ -56,7 +55,7 @@ function removeCallback(throttleTime: number): void {
56
55
 
57
56
  function callback(_rect: DOMRectReadOnly, el: Element): void {
58
57
  const _ = elMap.get(el as HTMLElement)
59
- if (!_) {unreachable()}
58
+ if (!_) { unreachable() }
60
59
  const pos = _.vertical ? "x" : "y"
61
60
  const dimension = _.vertical ? "width" : "height"
62
61
 
@@ -78,7 +77,6 @@ function callback(_rect: DOMRectReadOnly, el: Element): void {
78
77
  const firstRect = firstChild.getBoundingClientRect()
79
78
  const lastRect = lastChild.getBoundingClientRect()
80
79
 
81
-
82
80
  // should work even if the flex items are different heights
83
81
  // only exceptions i think are if the element aligns itself below another element somehow
84
82
  // rounded to nearest 10th since getBoundingClientRect can have rounding errors
@@ -89,14 +87,13 @@ function callback(_rect: DOMRectReadOnly, el: Element): void {
89
87
  }
90
88
  }
91
89
 
92
-
93
90
  export const vDetectFlex: Directive = {
94
91
  mounted(el: HTMLElement, { value: { condition = true, vertical = false, throttleTime = 50, ignoreSelector = ".detect-flex-ignore" } = {} }: DetectFlexOptions) {
95
92
  const _: PrivateState = {
96
93
  vertical,
97
94
  lastCondition: condition,
98
95
  lastThrottleTime: throttleTime,
99
- ignoreSelector,
96
+ ignoreSelector
100
97
  }
101
98
  elMap.set(el, _)
102
99
  if (condition) {
@@ -106,7 +103,7 @@ export const vDetectFlex: Directive = {
106
103
  },
107
104
  updated(el: HTMLElement, { value: { condition = true, vertical = false, throttleTime = 50, ignoreSelector = ".detect-flex-ignore" } = {} }: DetectFlexOptions) {
108
105
  const _ = elMap.get(el)
109
- if (!_) {unreachable()}
106
+ if (!_) { unreachable() }
110
107
 
111
108
  _.vertical = vertical
112
109
  _.ignoreSelector = ignoreSelector
@@ -135,7 +132,7 @@ export const vDetectFlex: Directive = {
135
132
  },
136
133
  unmounted(el: HTMLElement, { value: { vertical = false, throttleTime = 50, ignoreSelector = ".detect-flex-ignore" } = {} }: DetectFlexOptions) {
137
134
  const _ = elMap.get(el)
138
- if (!_) {unreachable()}
135
+ if (!_) { unreachable() }
139
136
  _.vertical = vertical
140
137
  _.ignoreSelector = ignoreSelector
141
138
  _.lastThrottleTime = throttleTime
@@ -147,7 +144,7 @@ export const vDetectFlex: Directive = {
147
144
  },
148
145
  getSSRProps() {
149
146
  return {}
150
- },
147
+ }
151
148
  }
152
149
  type DetectFlexOptions = {
153
150
  value: {
@@ -31,7 +31,7 @@ export const vExtractRootEl: Directive = {
31
31
  },
32
32
  getSSRProps() {
33
33
  return {}
34
- },
34
+ }
35
35
  }
36
36
  type Options = {
37
37
  value: (el: HTMLElement | null) => void
@@ -7,7 +7,6 @@ import type { Directive, Ref } from "vue"
7
7
  import { globalResizeObserver } from "../globalResizeObserver.js"
8
8
  import type { ResizableOptions, ResizeCallback } from "../types/index.js"
9
9
 
10
-
11
10
  const observer = globalResizeObserver
12
11
  type Data = {
13
12
  margin: number
@@ -32,7 +31,7 @@ type ResizableElement = HTMLElement
32
31
  const defaultOpts: Omit<ResizableOptions, "colCount" | "widths" | "selector"> = {
33
32
  fitWidth: true,
34
33
  margin: "dynamic",
35
- enabled: true,
34
+ enabled: true
36
35
  }
37
36
 
38
37
  const callback: ResizeCallback = (_rect: DOMRectReadOnly, el: Element): void => {
@@ -132,10 +131,9 @@ export const vResizableCols: Directive = {
132
131
  },
133
132
  getSSRProps() {
134
133
  return {}
135
- },
134
+ }
136
135
  }
137
136
 
138
-
139
137
  function setWidth(col: HTMLElement, amountInPx: number, el: ResizableElement): void {
140
138
  const $el = getElInfo(el)
141
139
  const width = Math.max($el.margin, amountInPx)
@@ -148,7 +146,6 @@ function setWidth(col: HTMLElement, amountInPx: number, el: ResizableElement): v
148
146
  }
149
147
  }
150
148
 
151
-
152
149
  function getBox(el: Element): { x: number, width: number } {
153
150
  const rect = el.getBoundingClientRect()
154
151
  // the numbers need to be rounded or else the columns will start to shift
@@ -228,7 +225,6 @@ function createPointerMoveHandler(el: ResizableElement) {
228
225
  return
229
226
  }
230
227
 
231
-
232
228
  setWidth(col, newWidth, el)
233
229
  setWidth(colNext!, rightBox.width + diff, el)
234
230
  }
@@ -309,7 +305,7 @@ function setupColumns(el: ResizableElement, opts: ResizableOptions): void {
309
305
  margin: opts.margin === "dynamic" ? gripWidth : opts.margin,
310
306
  colCount: opts.colCount,
311
307
  widths: opts.widths,
312
- selector: opts.selector,
308
+ selector: opts.selector
313
309
  }
314
310
  elMap.set(el, $el)
315
311
  const els = getColEls(el)
@@ -3,7 +3,6 @@ import type { Directive } from "vue"
3
3
  import { globalResizeObserver } from "../globalResizeObserver.js"
4
4
  import type { ResizeCallback } from "../types/index.js"
5
5
 
6
-
7
6
  const observer = globalResizeObserver
8
7
  const lastCondition = Symbol("lastCondition")
9
8
  const checkCallback = (cb: any): void => {
@@ -35,7 +34,7 @@ export const vResizeObserver: Directive = {
35
34
  },
36
35
  getSSRProps() {
37
36
  return {}
38
- },
37
+ }
39
38
  }
40
39
  type Options = {
41
40
  value: {