@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,89 +1,82 @@
1
- <script setup lang="ts">
2
- import { type DateValue, getLocalTimeZone } from "@internationalized/date"
3
- import type { DateRange } from "radix-vue"
4
- import { DateRangePickerArrow, DateRangePickerCalendar, DateRangePickerCell, DateRangePickerCellTrigger, DateRangePickerContent, DateRangePickerField, DateRangePickerGrid, DateRangePickerGridBody, DateRangePickerGridHead, DateRangePickerGridRow, DateRangePickerHeadCell,DateRangePickerHeader, DateRangePickerHeading, DateRangePickerInput, DateRangePickerNext, DateRangePickerPrev, DateRangePickerRoot, DateRangePickerTrigger } from "radix-vue"
5
- import { onBeforeUnmount, ref, toRaw, useAttrs, watch } from "vue"
6
-
7
- import { convertDateWithFallback, getNow,toEmittableDate } from "./helpers.js"
8
-
9
- import { useInjectedLocale } from "../../composables/useInjectedLocale.js"
10
- import type { RangeDate } from "../../types/index.js"
11
- import { twMerge } from "../../utils/twMerge.js"
12
- import Icon from "../Icon/Icon.vue"
13
- const attrs = useAttrs()
14
-
15
- const props = withDefaults(defineProps<{
16
- useTime?: boolean
17
- id: string
18
- fallbackDate?: Date
19
- timeZone?: string
20
- updateInterval?: number
21
- }>(), {
22
- timeZone: getLocalTimeZone(),
23
- useTime: false,
24
- fallbackDate: _ => getNow({ withTime: _.useTime ?? false }).toDate(_.timeZone ?? getLocalTimeZone()),
25
- updateInterval: 10000
26
- })
27
-
28
- const date = defineModel<RangeDate>({ required: true })
29
-
30
-
31
- const tempDate = ref({
32
- start: convertDateWithFallback(date.value?.start, props),
33
- end: convertDateWithFallback(date.value?.end, props)
34
- })
1
+ <script setup>
2
+ import { CalendarDate, getLocalTimeZone, ZonedDateTime } from "@internationalized/date";
3
+ import { DateRangePickerArrow, DateRangePickerCalendar, DateRangePickerCell, DateRangePickerCellTrigger, DateRangePickerContent, DateRangePickerField, DateRangePickerGrid, DateRangePickerGridBody, DateRangePickerGridHead, DateRangePickerGridRow, DateRangePickerHeadCell, DateRangePickerHeader, DateRangePickerHeading, DateRangePickerInput, DateRangePickerNext, DateRangePickerPrev, DateRangePickerRoot, DateRangePickerTrigger } from "reka-ui";
4
+ import { onBeforeUnmount, ref, toRaw, useAttrs, watch } from "vue";
5
+ import { convertDateWithFallback, getNow, toEmittableDate } from "./helpers.js";
6
+ import { useInjectedLocale } from "../../composables/useInjectedLocale.js";
7
+ import { twMerge } from "../../utils/twMerge.js";
8
+ import Icon from "../Icon/Icon.vue";
9
+ const attrs = useAttrs();
10
+ const props = defineProps({
11
+ useTime: { type: Boolean, required: false, default: false },
12
+ id: { type: String, required: true },
13
+ fallbackDate: { type: Date, required: false, default: (_) => getNow({ withTime: _.useTime ?? false }).toDate(_.timeZone ?? getLocalTimeZone()) },
14
+ timeZone: { type: String, required: false, default: getLocalTimeZone() },
15
+ updateInterval: { type: Number, required: false, default: 1e4 }
16
+ });
17
+ const date = defineModel({ type: Object, ...{ required: true } });
18
+ let justSet = false;
19
+ const tempDate = ref({});
20
+ function updateTempDate(keys = ["start", "end"]) {
21
+ const newValue = { ...tempDate.value };
22
+ for (const key of keys) {
23
+ newValue[key] = convertDateWithFallback(date.value?.[key], props);
24
+ }
25
+ tempDate.value = newValue;
26
+ }
27
+ watch([() => date.value.start, () => date.value.end], () => {
28
+ if (!justSet) {
29
+ updateTempDate();
30
+ } else {
31
+ justSet = false;
32
+ }
33
+ });
34
+ watch(tempDate, () => {
35
+ if (!tempDate.value.start || !tempDate.value.end) return;
36
+ justSet = true;
37
+ date.value = {
38
+ start: tempDate.value.start ? toEmittableDate(toRaw(tempDate.value.start)) : void 0,
39
+ end: tempDate.value.end ? toEmittableDate(toRaw(tempDate.value.end)) : void 0
40
+ };
41
+ });
35
42
  watch(() => props.timeZone, () => {
36
- tempDate.value = {
37
- start: convertDateWithFallback(date.value?.start, props),
38
- end: convertDateWithFallback(date.value?.end, props)
39
- }
40
- })
41
-
43
+ updateTempDate();
44
+ });
42
45
  const interval = setInterval(() => {
43
- if (!date.value.start) {
44
- // update suggested date if none is set
45
- tempDate.value.start = convertDateWithFallback(date.value.start, props)
46
- }
47
- if (!date.value.end) {
48
- // update suggested date if none is set
49
- tempDate.value.end = convertDateWithFallback(date.value.end, props)
50
- }
51
- }, props.updateInterval)
52
-
46
+ if (!date.value.start) updateTempDate(["start"]);
47
+ if (!date.value.end) updateTempDate(["end"]);
48
+ }, props.updateInterval);
53
49
  onBeforeUnmount(() => {
54
- clearInterval(interval)
55
- })
56
-
57
- const locale = useInjectedLocale().timeLocale
58
-
59
- watch(tempDate, () => {
60
- date.value = {
61
- start: tempDate.value.start ? toEmittableDate(toRaw(tempDate.value.start) as any) : undefined,
62
- end: tempDate.value.end ? toEmittableDate(toRaw(tempDate.value.end) as any) : undefined
63
- }
64
- })
50
+ clearInterval(interval);
51
+ });
52
+ const locale = useInjectedLocale().timeLocale;
65
53
  </script>
66
54
 
67
55
  <template>
68
56
  <DateRangePickerRoot
69
57
  :id="id"
70
58
  :locale="locale"
71
- class="root"
72
- v-model="tempDate as DateRange"
59
+ class="date-range-picker--root"
60
+ v-model="tempDate"
73
61
  >
74
62
  <DateRangePickerField
75
63
  v-slot="{ segments }"
76
64
  :class="twMerge(`
77
- container
65
+ date-range-picker--field
78
66
  flex items-center justify-between
79
67
  select-none
80
68
  data-[invalid]:border-red-500
81
69
  metadata-input-border
82
70
  rounded-sm
83
- `, (attrs as any).class)"
71
+ `, attrs.class)"
84
72
  >
85
- <div class="segments flex items-center flex-1 overflow-scroll scrollbar-hidden whitespace-nowrap">
86
- <div :class="twMerge(`start-segment flex items-center`, date.start === undefined && 'text-neutral-400')">
73
+ <div class="date-range-picker--segments-input flex items-center flex-1 overflow-scroll scrollbar-hidden whitespace-nowrap">
74
+ <div :class="twMerge(`
75
+ date-range-picker--start-segment
76
+ flex
77
+ items-center
78
+ `, date.start === void 0 && 'text-neutral-400')"
79
+ >
87
80
  <template
88
81
  v-for="item in segments.start"
89
82
  :key="item.part"
@@ -92,7 +85,7 @@ watch(tempDate, () => {
92
85
  v-if="item.part === 'literal'"
93
86
  :part="item.part"
94
87
  type="start"
95
- class="input-literal"
88
+ class="date-range-picker--segment-literal"
96
89
  >
97
90
  {{ item.value }}
98
91
  </DateRangePickerInput>
@@ -101,7 +94,7 @@ watch(tempDate, () => {
101
94
  type="start"
102
95
  :part="item.part"
103
96
  class="
104
- input
97
+ date-range-picker--segment-input
105
98
  focus-outline-hidden
106
99
  border
107
100
  border-transparent
@@ -110,6 +103,7 @@ watch(tempDate, () => {
110
103
  >
111
104
  <div
112
105
  class="
106
+ date-range-picker--segment-value
113
107
  group-focus:z-[2]
114
108
  group-focus:bg-accent-500/50
115
109
  group-focus:rounded-xs
@@ -121,10 +115,15 @@ watch(tempDate, () => {
121
115
  </DateRangePickerInput>
122
116
  </template>
123
117
  </div>
124
- <div class="range-separator text-center px-1">
118
+ <div class="date-range-picker--range-separator text-center px-1">
125
119
 
126
120
  </div>
127
- <div :class="twMerge(`end-segment flex items-center`, date.end === undefined && 'text-neutral-400')">
121
+ <div :class="twMerge(`
122
+ date-range-picker--end-segment
123
+ flex
124
+ items-center
125
+ `, date.end === void 0 && 'text-neutral-400')"
126
+ >
128
127
  <template
129
128
  v-for="item in segments.end"
130
129
  :key="item.part"
@@ -133,7 +132,7 @@ watch(tempDate, () => {
133
132
  v-if="item.part === 'literal'"
134
133
  :part="item.part"
135
134
  type="end"
136
- class="input-literal"
135
+ class="date-range-picker--segment-literal"
137
136
  >
138
137
  {{ item.value }}
139
138
  </DateRangePickerInput>
@@ -142,7 +141,7 @@ watch(tempDate, () => {
142
141
  type="end"
143
142
  :part="item.part"
144
143
  class="
145
- input
144
+ date-range-picker--segment-input
146
145
  focus-outline-hidden
147
146
  border
148
147
  border-transparent
@@ -151,6 +150,7 @@ watch(tempDate, () => {
151
150
  >
152
151
  <div
153
152
  class="
153
+ date-range-picker--segment-value
154
154
  group-focus:z-[2]
155
155
  group-focus:bg-accent-500/50
156
156
  group-focus:rounded-xs
@@ -165,7 +165,7 @@ watch(tempDate, () => {
165
165
  </div>
166
166
  <DateRangePickerTrigger
167
167
  class="
168
- trigger
168
+ date-range-picker--trigger
169
169
  px-1
170
170
  focus-outline
171
171
  rounded-tr-sm
@@ -183,46 +183,53 @@ watch(tempDate, () => {
183
183
  </DateRangePickerTrigger>
184
184
  </DateRangePickerField>
185
185
 
186
- <!-- @vue-expect-error to exists -->
186
+ <!-- side=bottom makes months easier to click through -->
187
+ <!-- @vue-expect-error to exists-->
187
188
  <DateRangePickerContent
188
189
  :side-offset="4"
190
+ :avoid-collisions="true"
191
+ :prioritize-position="true"
192
+ side="bottom"
189
193
  to="#root"
190
194
  class="
191
- mx-2
192
- rounded-sm
193
- bg-bg
194
- dark:bg-neutral-800
195
- border
196
- border-neutral-300
197
- dark:border-neutral-700
198
- shadow-lg
199
- will-change-[transform,opacity]
200
- data-[state=open]:data-[side=top]:animate-slideDownAndFade
201
- data-[state=open]:data-[side=right]:animate-slideLeftAndFade
202
- data-[state=open]:data-[side=bottom]:animate-slideUpAndFade
203
- data-[state=open]:data-[side=left]:animate-slideRightAndFade
204
- text-fg
205
- dark:text-neutral-200
206
- "
195
+ date-range-picker--content
196
+ z-100
197
+ mx-2
198
+ rounded-sm
199
+ bg-bg
200
+ dark:bg-neutral-800
201
+ border
202
+ border-neutral-300
203
+ dark:border-neutral-700
204
+ shadow-lg
205
+ will-change-[transform,opacity]
206
+ data-[state=open]:data-[side=top]:animate-slideDownAndFade
207
+ data-[state=open]:data-[side=right]:animate-slideLeftAndFade
208
+ data-[state=open]:data-[side=bottom]:animate-slideUpAndFade
209
+ data-[state=open]:data-[side=left]:animate-slideRightAndFade
210
+ text-fg
211
+ dark:text-neutral-200
212
+ "
207
213
  >
208
- <DateRangePickerArrow class="fill-neutral-500"/>
214
+ <DateRangePickerArrow class="date-range-picker--arrow fill-neutral-500"/>
209
215
  <DateRangePickerCalendar
210
216
  v-slot="{ weekDays, grid }"
211
- class="p-2 flex flex-col"
217
+ class="date-range-picker--calendar p-2 flex flex-col"
212
218
  >
213
- <DateRangePickerHeader class="flex items-center justify-between">
219
+ <DateRangePickerHeader class="date-range-picker--header flex items-center justify-between">
214
220
  <DateRangePickerPrev
215
221
  class="
216
- inline-flex
217
- items-center
218
- cursor-pointer
219
- active:scale-125
220
- justify-center
221
- rounded-sm
222
- outlined
223
- px-1
224
- "
225
- :prev-page="(date: DateValue) => date.subtract({ years: 1 })"
222
+ date-range-picker--year-prev
223
+ inline-flex
224
+ items-center
225
+ cursor-pointer
226
+ active:scale-125
227
+ justify-center
228
+ rounded-sm
229
+ outlined
230
+ px-1
231
+ "
232
+ :prev-page="(date2) => date2.subtract({ years: 1 })"
226
233
  >
227
234
  <Icon class="scale-150">
228
235
  <i-radix-icons-double-arrow-left/>
@@ -230,6 +237,7 @@ watch(tempDate, () => {
230
237
  </DateRangePickerPrev>
231
238
  <DateRangePickerPrev
232
239
  class="
240
+ date-range-picker--prev
233
241
  inline-flex
234
242
  items-center
235
243
  cursor-pointer
@@ -245,18 +253,19 @@ watch(tempDate, () => {
245
253
  </Icon>
246
254
  </DateRangePickerPrev>
247
255
 
248
- <DateRangePickerHeading class="min-w-[14ch] text-center"/>
256
+ <DateRangePickerHeading class="date-range-picker--heading min-w-[14ch] text-center"/>
249
257
  <DateRangePickerNext
250
258
  class="
251
- inline-flex
252
- items-center
253
- cursor-pointer
254
- active:scale-125
255
- justify-center
256
- rounded-sm
257
- outlined
258
- px-1
259
- "
259
+ date-range-picker--next
260
+ inline-flex
261
+ items-center
262
+ cursor-pointer
263
+ active:scale-125
264
+ justify-center
265
+ rounded-sm
266
+ outlined
267
+ px-1
268
+ "
260
269
  >
261
270
  <Icon class="scale-150">
262
271
  <i-radix-icons-chevron-right/>
@@ -264,16 +273,17 @@ watch(tempDate, () => {
264
273
  </DateRangePickerNext>
265
274
  <DateRangePickerNext
266
275
  class="
267
- inline-flex
268
- items-center
269
- cursor-pointer
270
- active:scale-125
271
- justify-center
272
- rounded-sm
273
- outlined
274
- px-1
275
- "
276
- :next-page="(date: DateValue) => date.add({ years: 1 })"
276
+ date-range-picker--year-next
277
+ inline-flex
278
+ items-center
279
+ cursor-pointer
280
+ active:scale-125
281
+ justify-center
282
+ rounded-sm
283
+ outlined
284
+ px-1
285
+ "
286
+ :next-page="(date2) => date2.add({ years: 1 })"
277
287
  >
278
288
  <Icon class="scale-150">
279
289
  <i-radix-icons-double-arrow-right/>
@@ -282,25 +292,37 @@ watch(tempDate, () => {
282
292
  </DateRangePickerHeader>
283
293
  <div
284
294
  class="
285
- flex
286
- flex-col
287
- pt-4
288
- "
295
+ date-range-picker--grid-wrapper
296
+ flex
297
+ flex-col
298
+ pt-4
299
+ "
289
300
  >
290
301
  <DateRangePickerGrid
291
- class="border-collapse select-none"
302
+ class="
303
+ date-range-picker--grid
304
+ border-collapse
305
+ select-none
306
+ "
292
307
  v-for="month in grid"
293
308
  :key="month.value.toString()"
294
309
  >
295
- <DateRangePickerGridHead>
296
- <DateRangePickerGridRow class="mb-1 flex justify-between">
310
+ <DateRangePickerGridHead class="date-range-picker--grid-head">
311
+ <DateRangePickerGridRow class="
312
+ date-range-picker--grid-row
313
+ mb-1
314
+ flex
315
+ justify-between
316
+ "
317
+ >
297
318
  <DateRangePickerHeadCell
298
319
  class="
299
- w-6
300
- rounded-md
301
- text-xs
302
- text-accent-500
303
- "
320
+ date-range-picker--head-cell
321
+ w-6
322
+ rounded-md
323
+ text-xs
324
+ text-accent-500
325
+ "
304
326
  v-for="day in weekDays"
305
327
  :key="day"
306
328
  >
@@ -308,14 +330,21 @@ watch(tempDate, () => {
308
330
  </DateRangePickerHeadCell>
309
331
  </DateRangePickerGridRow>
310
332
  </DateRangePickerGridHead>
311
- <DateRangePickerGridBody>
333
+ <DateRangePickerGridBody class="date-range-picker--grid-body">
312
334
  <DateRangePickerGridRow
313
- class="flex w-full justify-between my-1"
335
+ class="
336
+ date-range-picker--grid-row
337
+ flex
338
+ w-full
339
+ justify-between
340
+ my-1
341
+ "
314
342
  v-for="(weekDates, index) in month.rows"
315
343
  :key="`weekDate-${index}`"
316
344
  >
317
345
  <DateRangePickerCell
318
346
  :date="weekDate"
347
+ class="date-range-picker--cell"
319
348
  v-for="weekDate in weekDates"
320
349
  :key="weekDate.toString()"
321
350
  >
@@ -323,47 +352,50 @@ watch(tempDate, () => {
323
352
  :day="weekDate"
324
353
  :month="month.value"
325
354
  class="
326
- relative
327
- flex
328
- items-center
329
- justify-center
330
- whitespace-nowrap
331
- rounded-sm
332
- border
333
- border-transparent
334
- bg-transparent
335
- text-sm
336
- w-6
337
- h-6
338
- focus:shadow
339
- focus-outline
340
- hover:border-accent-500
341
- data-[selected]:bg-accent-700
342
- data-[selected]:shadow
343
- data-[disabled]:text-neutral-500
344
- data-[selected]:text-white
345
- data-[unavailable]:pointer-events-none
346
- data-[unavailable]:text-neutral-500
347
- data-[unavailable]:line-through
348
- before:absolute
349
- before:bottom-[1px]
350
- before:hidden
351
- before:rounded-full
352
- before:w-4
353
- before:h-[2px]
354
- before:bg-white
355
- data-[today]:before:block
356
- data-[today]:before:bg-accent-500
357
- data-[selected]:before:bg-white
358
- "
355
+ date-range-picker--cell-trigger
356
+ relative
357
+ flex
358
+ items-center
359
+ justify-center
360
+ whitespace-nowrap
361
+ rounded-sm
362
+ border
363
+ border-transparent
364
+ bg-transparent
365
+ text-sm
366
+ w-6
367
+ h-6
368
+ focus:shadow
369
+ focus-outline
370
+ hover:border-accent-500
371
+ data-[selected]:bg-accent-500
372
+ dark:data-[selected]:bg-accent-500/80
373
+ data-[selected]:shadow
374
+ data-[disabled]:text-neutral-500
375
+ data-[selected]:text-white
376
+ data-[unavailable]:pointer-events-none
377
+ data-[unavailable]:text-neutral-500
378
+ data-[unavailable]:line-through
379
+ data-[outside-view]:text-neutral-500
380
+ before:absolute
381
+ before:bottom-[1px]
382
+ before:hidden
383
+ before:rounded-full
384
+ before:w-4
385
+ before:h-[2px]
386
+ before:bg-white
387
+ data-[today]:before:block
388
+ data-[today]:before:bg-accent-700
389
+ dark:data-[today]:before:bg-accent-300
390
+ data-[selected]:before:bg-white
391
+ "
359
392
  />
360
393
  </DateRangePickerCell>
361
394
  </DateRangePickerGridRow>
362
395
  </DateRangePickerGridBody>
363
396
  </DateRangePickerGrid>
364
397
  </div>
365
- <slot v-bind="{tempValue: tempDate}"/>
366
- <slot/>
398
+ <slot v-bind="{ tempValue: tempDate }"/>
367
399
  </DateRangePickerCalendar>
368
400
  </DateRangePickerContent>
369
401
  </DateRangePickerRoot>
@@ -0,0 +1,34 @@
1
+ import type { RangeDate } from "../../types/index.js.js";
2
+ type __VLS_Props = {
3
+ useTime?: boolean;
4
+ id: string;
5
+ fallbackDate?: Date;
6
+ timeZone?: string;
7
+ updateInterval?: number;
8
+ };
9
+ type __VLS_PublicProps = __VLS_Props & {
10
+ modelValue: RangeDate;
11
+ };
12
+ declare var __VLS_167: {
13
+ tempValue: any;
14
+ };
15
+ type __VLS_Slots = {} & {
16
+ default?: (props: typeof __VLS_167) => any;
17
+ };
18
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_PublicProps, void, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
19
+ "update:modelValue": (value: RangeDate) => any;
20
+ }, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
21
+ "onUpdate:modelValue"?: ((value: RangeDate) => any) | undefined;
22
+ }>, {
23
+ fallbackDate: Date;
24
+ timeZone: string;
25
+ useTime: boolean;
26
+ updateInterval: number;
27
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
28
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
29
+ export default _default;
30
+ type __VLS_WithSlots<T, S> = T & {
31
+ new (): {
32
+ $slots: S;
33
+ };
34
+ };