@witchcraft/ui 0.0.1 → 0.1.0

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 (155) hide show
  1. package/README.md +18 -28
  2. package/dist/module.d.mts +3 -1
  3. package/dist/module.d.ts +3 -1
  4. package/dist/module.json +2 -2
  5. package/dist/module.mjs +20 -11
  6. package/dist/runtime/assets/base.css +1 -1
  7. package/dist/runtime/assets/locales/en.json +2 -2
  8. package/dist/runtime/assets/tailwind.css +1 -1
  9. package/dist/runtime/assets/utils.css +1 -0
  10. package/dist/runtime/build/WitchcraftUiResolver.js +1 -1
  11. package/dist/runtime/components/Icon/Icon.vue +10 -5
  12. package/dist/runtime/components/LibButton/LibButton.vue +41 -46
  13. package/dist/runtime/components/LibCheckbox/LibCheckbox.vue +7 -3
  14. package/dist/runtime/components/LibColorInput/LibColorInput.vue +111 -36
  15. package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.d.ts +2 -0
  16. package/dist/runtime/components/LibColorPicker/LibColorPicker.stories.js +26 -9
  17. package/dist/runtime/components/LibColorPicker/LibColorPicker.vue +242 -131
  18. package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.d.ts +2 -0
  19. package/dist/runtime/components/LibColorPicker/utils/safeConvertToHsva.js +18 -0
  20. package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.d.ts +2 -0
  21. package/dist/runtime/components/LibColorPicker/utils/safeConvertToRgba.js +17 -0
  22. package/dist/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.d.ts +2 -0
  23. package/dist/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.js +8 -0
  24. package/dist/runtime/components/LibColorPicker/utils/truncate.d.ts +1 -0
  25. package/dist/runtime/components/LibColorPicker/utils/truncate.js +5 -0
  26. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.js +1 -1
  27. package/dist/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +11 -8
  28. package/dist/runtime/components/LibDatePicker/LibDatePicker.vue +4 -17
  29. package/dist/runtime/components/LibDatePicker/LibRangeDatePicker.vue +192 -131
  30. package/dist/runtime/components/LibDatePicker/LibSingleDatePicker.vue +183 -115
  31. package/dist/runtime/components/LibDatePicker/LibTimeZonePicker.vue +3 -3
  32. package/dist/runtime/components/LibDebug/LibDebug.vue +15 -5
  33. package/dist/runtime/components/LibDevOnly/LibDevOnly.vue +1 -3
  34. package/dist/runtime/components/LibFileInput/LibFileInput.vue +54 -28
  35. package/dist/runtime/components/{LibInput/LibInput.stories.d.ts → LibInputDeprecated/LibInputDeprecated.stories.d.ts} +6 -6
  36. package/dist/runtime/components/{LibInput/LibInput.stories.js → LibInputDeprecated/LibInputDeprecated.stories.js} +64 -19
  37. package/{src/runtime/components/LibInput/LibInput.vue → dist/runtime/components/LibInputDeprecated/LibInputDeprecated.vue} +40 -33
  38. package/dist/runtime/components/LibLabel/LibLabel.vue +2 -2
  39. package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.d.ts +1 -1
  40. package/dist/runtime/components/LibMultiValues/LibMultiValues.stories.js +5 -4
  41. package/dist/runtime/components/LibMultiValues/LibMultiValues.vue +11 -12
  42. package/dist/runtime/components/LibNotifications/LibNotification.vue +19 -10
  43. package/dist/runtime/components/LibNotifications/LibNotifications.stories.js +2 -2
  44. package/dist/runtime/components/LibNotifications/LibNotifications.vue +20 -11
  45. package/dist/runtime/components/LibPagination/LibPagination.stories.js +2 -2
  46. package/dist/runtime/components/LibPagination/LibPagination.vue +19 -19
  47. package/dist/runtime/components/LibPalette/LibPalette.vue +3 -3
  48. package/dist/runtime/components/LibPopup/LibPopup.stories.js +2 -2
  49. package/dist/runtime/components/LibPopup/LibPopup.vue +30 -66
  50. package/dist/runtime/components/LibProgressBar/LibProgressBar.vue +3 -1
  51. package/dist/runtime/components/LibRecorder/LibRecorder.vue +2 -2
  52. package/dist/runtime/components/LibRoot/LibRoot.vue +14 -1
  53. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.stories.js +1 -1
  54. package/dist/runtime/components/LibSimpleInput/LibSimpleInput.vue +5 -7
  55. package/dist/runtime/components/LibSuggestions/LibSuggestions.vue +42 -25
  56. package/dist/runtime/components/LibTable/LibTable.vue +8 -8
  57. package/dist/runtime/components/Scrolling.stories.d.ts +6 -0
  58. package/dist/runtime/components/Scrolling.stories.js +44 -0
  59. package/dist/runtime/components/Template/NAME.vue +1 -1
  60. package/dist/runtime/components/TestControls/TestControls.vue +1 -1
  61. package/dist/runtime/components/index.d.ts +12 -11
  62. package/dist/runtime/components/index.js +12 -11
  63. package/dist/runtime/components/shared/props.d.ts +81 -16
  64. package/dist/runtime/components/shared/storyHelpers/playInput.js +5 -5
  65. package/dist/runtime/components/shared/storyHelpers/playSuggestions.js +15 -11
  66. package/dist/runtime/composables/index.d.ts +5 -0
  67. package/dist/runtime/composables/index.js +5 -0
  68. package/dist/runtime/composables/useDivideAttrs.js +1 -0
  69. package/dist/runtime/composables/useDragWithThreshold.d.ts +71 -0
  70. package/dist/runtime/composables/useDragWithThreshold.js +40 -0
  71. package/dist/runtime/composables/usePreHydrationValue.d.ts +12 -0
  72. package/dist/runtime/composables/usePreHydrationValue.js +15 -0
  73. package/dist/runtime/composables/useSetupI18n.d.ts +2 -0
  74. package/dist/runtime/composables/useSetupI18n.js +5 -1
  75. package/dist/runtime/composables/useSuggestions.d.ts +7 -5
  76. package/dist/runtime/composables/useSuggestions.js +94 -57
  77. package/dist/runtime/directives/vResizableCols.js +3 -1
  78. package/dist/runtime/helpers/NotificationHandler.d.ts +5 -0
  79. package/dist/runtime/helpers/index.d.ts +3 -1
  80. package/dist/runtime/helpers/index.js +3 -1
  81. package/dist/runtime/types/index.d.ts +6 -0
  82. package/dist/runtime/utils/notifyIfError.d.ts +14 -0
  83. package/dist/runtime/utils/notifyIfError.js +29 -0
  84. package/package.json +18 -20
  85. package/src/module.ts +31 -12
  86. package/src/runtime/assets/base.css +10 -1
  87. package/src/runtime/assets/locales/en.json +2 -2
  88. package/src/runtime/assets/tailwind.css +1 -1
  89. package/src/runtime/assets/{style.css → utils.css} +86 -4
  90. package/src/runtime/build/WitchcraftUiResolver.ts +1 -1
  91. package/src/runtime/components/Icon/Icon.vue +10 -5
  92. package/src/runtime/components/LibButton/LibButton.vue +41 -46
  93. package/src/runtime/components/LibCheckbox/LibCheckbox.vue +7 -3
  94. package/src/runtime/components/LibColorInput/LibColorInput.vue +111 -36
  95. package/src/runtime/components/LibColorPicker/LibColorPicker.stories.ts +25 -4
  96. package/src/runtime/components/LibColorPicker/LibColorPicker.vue +242 -131
  97. package/src/runtime/components/LibColorPicker/utils/safeConvertToHsva.ts +25 -0
  98. package/src/runtime/components/LibColorPicker/utils/safeConvertToRgba.ts +23 -0
  99. package/src/runtime/components/LibColorPicker/utils/toLowPrecisionRgbaString.ts +13 -0
  100. package/src/runtime/components/LibColorPicker/utils/truncate.ts +6 -0
  101. package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.stories.ts +1 -1
  102. package/src/runtime/components/LibDarkModeSwitcher/LibDarkModeSwitcher.vue +11 -8
  103. package/src/runtime/components/LibDatePicker/LibDatePicker.vue +4 -17
  104. package/src/runtime/components/LibDatePicker/LibRangeDatePicker.vue +192 -131
  105. package/src/runtime/components/LibDatePicker/LibSingleDatePicker.vue +183 -115
  106. package/src/runtime/components/LibDatePicker/LibTimeZonePicker.vue +3 -3
  107. package/src/runtime/components/LibDebug/LibDebug.vue +15 -5
  108. package/src/runtime/components/LibDevOnly/LibDevOnly.vue +1 -3
  109. package/src/runtime/components/LibFileInput/LibFileInput.vue +54 -28
  110. package/src/runtime/components/{LibInput/LibInput.stories.ts → LibInputDeprecated/LibInputDeprecated.stories.ts} +64 -19
  111. package/{dist/runtime/components/LibInput/LibInput.vue → src/runtime/components/LibInputDeprecated/LibInputDeprecated.vue} +40 -33
  112. package/src/runtime/components/LibLabel/LibLabel.vue +2 -2
  113. package/src/runtime/components/LibMultiValues/LibMultiValues.stories.ts +5 -4
  114. package/src/runtime/components/LibMultiValues/LibMultiValues.vue +11 -12
  115. package/src/runtime/components/LibNotifications/LibNotification.vue +19 -10
  116. package/src/runtime/components/LibNotifications/LibNotifications.stories.ts +2 -2
  117. package/src/runtime/components/LibNotifications/LibNotifications.vue +20 -11
  118. package/src/runtime/components/LibPagination/LibPagination.stories.ts +2 -2
  119. package/src/runtime/components/LibPagination/LibPagination.vue +19 -19
  120. package/src/runtime/components/LibPalette/LibPalette.vue +3 -3
  121. package/src/runtime/components/LibPopup/LibPopup.stories.ts +2 -2
  122. package/src/runtime/components/LibPopup/LibPopup.vue +30 -66
  123. package/src/runtime/components/LibProgressBar/LibProgressBar.vue +3 -1
  124. package/src/runtime/components/LibRecorder/LibRecorder.vue +2 -2
  125. package/src/runtime/components/LibRoot/LibRoot.vue +14 -1
  126. package/src/runtime/components/LibSimpleInput/LibSimpleInput.stories.ts +1 -1
  127. package/src/runtime/components/LibSimpleInput/LibSimpleInput.vue +5 -7
  128. package/src/runtime/components/LibSuggestions/LibSuggestions.vue +42 -25
  129. package/src/runtime/components/LibTable/LibTable.vue +8 -8
  130. package/src/runtime/components/Scrolling.stories.ts +58 -0
  131. package/src/runtime/components/Template/NAME.vue +1 -1
  132. package/src/runtime/components/TestControls/TestControls.vue +1 -1
  133. package/src/runtime/components/index.ts +12 -12
  134. package/src/runtime/components/shared/props.ts +82 -19
  135. package/src/runtime/components/shared/storyHelpers/playInput.ts +6 -5
  136. package/src/runtime/components/shared/storyHelpers/playSuggestions.ts +25 -11
  137. package/src/runtime/composables/index.ts +5 -0
  138. package/src/runtime/composables/useDarkMode.ts +2 -2
  139. package/src/runtime/composables/useDivideAttrs.ts +1 -0
  140. package/src/runtime/composables/useDragWithThreshold.ts +108 -0
  141. package/src/runtime/composables/usePreHydrationValue.ts +30 -0
  142. package/src/runtime/composables/useSetupI18n.ts +8 -2
  143. package/src/runtime/composables/useSuggestions.ts +92 -45
  144. package/src/runtime/directives/vResizableCols.ts +3 -1
  145. package/src/runtime/helpers/NotificationHandler.ts +5 -0
  146. package/src/runtime/helpers/index.ts +3 -1
  147. package/src/runtime/types/index.ts +5 -0
  148. package/src/runtime/utils/notifyIfError.ts +45 -0
  149. package/dist/runtime/assets/style.css +0 -1
  150. package/dist/runtime/helpers/addValue.d.ts +0 -1
  151. package/dist/runtime/helpers/addValue.js +0 -8
  152. package/src/runtime/helpers/addValue.ts +0 -10
  153. /package/dist/runtime/components/{reset.stories.d.ts → Reset.stories.d.ts} +0 -0
  154. /package/dist/runtime/components/{reset.stories.js → Reset.stories.js} +0 -0
  155. /package/src/runtime/components/{reset.stories.ts → Reset.stories.ts} +0 -0
@@ -0,0 +1,5 @@
1
+ export function truncate(val, precision) {
2
+ const str = val.toFixed(precision);
3
+ const float = parseFloat(str);
4
+ return float.toString();
5
+ }
@@ -31,6 +31,6 @@ export const WithoutLabel = {
31
31
  ...Primary,
32
32
  args: {
33
33
  ...Primary.args,
34
- autoLabel: false
34
+ showLabel: false
35
35
  }
36
36
  };
@@ -2,38 +2,41 @@
2
2
  <lib-button
3
3
  v-bind="{...$attrs, class:undefined}"
4
4
  :class="!($attrs as any).unstyle && twMerge(`
5
+ dark-mode-switcher
5
6
  rounded-full
6
7
  after:rounded-full
7
8
  `,
8
9
  ($attrs as any)?.class
9
10
  )"
10
11
  :title="`${t('dark-mode-switcher.title')}${t(`dark-mode-switcher.${darkModeState}`)}`"
11
- :label="showLabel
12
- ? t(`dark-mode-switcher.${darkModeState}`)
13
- : ''
14
- "
15
12
  @click="cycleDarkMode"
16
13
  >
14
+ <!-- content-vertical-holder will keep the icon the height of a text line regardless of the svg used -->
17
15
  <template #icon>
18
16
  <icon
19
17
  v-if="darkModeState==='dark'"
20
- class="w-[1em] flex items-center"
18
+ class="w-[1em] flex items-center content-vertical-holder"
21
19
  >
22
20
  <i-fa-solid-moon/>
23
21
  </icon>
24
22
  <icon
25
23
  v-else-if="darkModeState==='light'"
26
- class="w-[1em]"
24
+ class="w-[1em] content-vertical-holder"
27
25
  >
28
26
  <i-ph-sun-bold/>
29
27
  </icon>
30
28
  <icon
31
29
  v-else
32
- class="w-[1em]"
30
+ class="w-[1em] content-vertical-holder"
33
31
  >
34
32
  <i-fa6-solid-circle-half-stroke/>
35
33
  </icon>
36
34
  </template>
35
+ <template #default v-if="showLabel">
36
+ <div class="dark-mode-switcher--label pr-[2px]">
37
+ {{ t(`dark-mode-switcher.${darkModeState}`) }}
38
+ </div>
39
+ </template>
37
40
  </lib-button>
38
41
  </template>
39
42
  <script lang="ts" setup>
@@ -57,7 +60,7 @@ const emit = defineEmits<{
57
60
  const $attrs = useAttrs()
58
61
 
59
62
  // eslint-disable-next-line no-use-before-define
60
- withDefaults(defineProps<Props>(), { })
63
+ withDefaults(defineProps<Props>(), { showLabel: true })
61
64
 
62
65
 
63
66
  const {
@@ -38,30 +38,17 @@ const isRange = computed(() => date.value !== undefined && !(date.value instance
38
38
  </script>
39
39
 
40
40
  <template>
41
- <LibSingleDatePicker
42
- v-if="!isRange"
43
- v-bind="attrs"
44
- :id="id ?? fallbackId"
45
- :use-time="showTime"
46
- :time-zone="timeZone"
47
- :fallback-date="fallbackDate"
48
- v-model="date as SingleDate"
49
- >
50
- <template #default="slotProps">
51
- <slot v-bind="slotProps"/>
52
- </template>
53
- </LibSingleDatePicker>
54
- <LibRangeDatePicker
55
- v-else
41
+ <component
56
42
  :id="id ?? fallbackId"
57
43
  v-bind="attrs"
58
44
  :use-time="showTime"
59
45
  :time-zone="timeZone"
60
46
  :fallback-date="fallbackDate"
61
- v-model="date as RangeDate"
47
+ :is="isRange ? LibRangeDatePicker : LibSingleDatePicker"
48
+ v-model="date as any"
62
49
  >
63
50
  <template #default="slotProps">
64
51
  <slot v-bind="slotProps"/>
65
52
  </template>
66
- </LibRangeDatePicker>
53
+ </component>
67
54
  </template>
@@ -1,7 +1,7 @@
1
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"
2
+ import { CalendarDate, type DateValue, getLocalTimeZone, ZonedDateTime } from "@internationalized/date"
3
+ import type { DateRange } from "reka-ui"
4
+ import { DateRangePickerArrow, DateRangePickerCalendar, DateRangePickerCell, DateRangePickerCellTrigger, DateRangePickerContent, DateRangePickerField, DateRangePickerGrid, DateRangePickerGridBody, DateRangePickerGridHead, DateRangePickerGridRow, DateRangePickerHeadCell,DateRangePickerHeader, DateRangePickerHeading, DateRangePickerInput, DateRangePickerNext, DateRangePickerPrev, DateRangePickerRoot, DateRangePickerTrigger } from "reka-ui"
5
5
  import { onBeforeUnmount, ref, toRaw, useAttrs, watch } from "vue"
6
6
 
7
7
  import { convertDateWithFallback, getNow,toEmittableDate } from "./helpers.js"
@@ -28,26 +28,48 @@ const props = withDefaults(defineProps<{
28
28
  const date = defineModel<RangeDate>({ required: true })
29
29
 
30
30
 
31
- const tempDate = ref({
32
- start: convertDateWithFallback(date.value?.start, props),
33
- end: convertDateWithFallback(date.value?.end, props)
31
+ let justSet = false
32
+
33
+ const tempDate = ref<{
34
+ start?: CalendarDate | ZonedDateTime
35
+ end?: CalendarDate | ZonedDateTime
36
+ }>({})
37
+ function updateTempDate(keys: ("start" | "end")[] = ["start", "end"]) {
38
+ const newValue = { ...tempDate.value }
39
+ for (const key of keys) {
40
+ newValue[key] = convertDateWithFallback(date.value?.[key], props)
41
+ }
42
+ // the WHOLE object must be updated due to how the reka date picker works
43
+ tempDate.value = newValue
44
+ }
45
+
46
+ // to avoid too deep of a watch
47
+ watch([() => date.value.start, () => date.value.end], () => {
48
+ if (!justSet) {
49
+ updateTempDate()
50
+ } else {
51
+ justSet = false
52
+ }
34
53
  })
35
- watch(() => props.timeZone, () => {
36
- tempDate.value = {
37
- start: convertDateWithFallback(date.value?.start, props),
38
- end: convertDateWithFallback(date.value?.end, props)
54
+
55
+ watch(tempDate, () => {
56
+ if (!tempDate.value.start || !tempDate.value.end) return
57
+ justSet = true
58
+ date.value = {
59
+ start: tempDate.value.start ? toEmittableDate(toRaw(tempDate.value.start) as any) : undefined,
60
+ end: tempDate.value.end ? toEmittableDate(toRaw(tempDate.value.end) as any) : undefined
39
61
  }
40
62
  })
41
63
 
64
+ watch(() => props.timeZone, () => {
65
+ updateTempDate()
66
+ })
67
+
68
+
42
69
  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
- }
70
+ // update suggested date if none is set
71
+ if (!date.value.start) updateTempDate(["start"])
72
+ if (!date.value.end) updateTempDate(["end"])
51
73
  }, props.updateInterval)
52
74
 
53
75
  onBeforeUnmount(() => {
@@ -56,25 +78,20 @@ onBeforeUnmount(() => {
56
78
 
57
79
  const locale = useInjectedLocale().timeLocale
58
80
 
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
- })
81
+
65
82
  </script>
66
83
 
67
84
  <template>
68
85
  <DateRangePickerRoot
69
86
  :id="id"
70
87
  :locale="locale"
71
- class="root"
88
+ class="date-range-picker--root"
72
89
  v-model="tempDate as DateRange"
73
90
  >
74
91
  <DateRangePickerField
75
92
  v-slot="{ segments }"
76
93
  :class="twMerge(`
77
- container
94
+ date-range-picker--field
78
95
  flex items-center justify-between
79
96
  select-none
80
97
  data-[invalid]:border-red-500
@@ -82,8 +99,13 @@ watch(tempDate, () => {
82
99
  rounded-sm
83
100
  `, (attrs as any).class)"
84
101
  >
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')">
102
+ <div class="date-range-picker--segments-input flex items-center flex-1 overflow-scroll scrollbar-hidden whitespace-nowrap">
103
+ <div :class="twMerge(`
104
+ date-range-picker--start-segment
105
+ flex
106
+ items-center
107
+ `, date.start === undefined && 'text-neutral-400')"
108
+ >
87
109
  <template
88
110
  v-for="item in segments.start"
89
111
  :key="item.part"
@@ -92,7 +114,7 @@ watch(tempDate, () => {
92
114
  v-if="item.part === 'literal'"
93
115
  :part="item.part"
94
116
  type="start"
95
- class="input-literal"
117
+ class="date-range-picker--segment-literal"
96
118
  >
97
119
  {{ item.value }}
98
120
  </DateRangePickerInput>
@@ -101,7 +123,7 @@ watch(tempDate, () => {
101
123
  type="start"
102
124
  :part="item.part"
103
125
  class="
104
- input
126
+ date-range-picker--segment-input
105
127
  focus-outline-hidden
106
128
  border
107
129
  border-transparent
@@ -110,6 +132,7 @@ watch(tempDate, () => {
110
132
  >
111
133
  <div
112
134
  class="
135
+ date-range-picker--segment-value
113
136
  group-focus:z-[2]
114
137
  group-focus:bg-accent-500/50
115
138
  group-focus:rounded-xs
@@ -121,10 +144,15 @@ watch(tempDate, () => {
121
144
  </DateRangePickerInput>
122
145
  </template>
123
146
  </div>
124
- <div class="range-separator text-center px-1">
147
+ <div class="date-range-picker--range-separator text-center px-1">
125
148
 
126
149
  </div>
127
- <div :class="twMerge(`end-segment flex items-center`, date.end === undefined && 'text-neutral-400')">
150
+ <div :class="twMerge(`
151
+ date-range-picker--end-segment
152
+ flex
153
+ items-center
154
+ `, date.end === undefined && 'text-neutral-400')"
155
+ >
128
156
  <template
129
157
  v-for="item in segments.end"
130
158
  :key="item.part"
@@ -133,7 +161,7 @@ watch(tempDate, () => {
133
161
  v-if="item.part === 'literal'"
134
162
  :part="item.part"
135
163
  type="end"
136
- class="input-literal"
164
+ class="date-range-picker--segment-literal"
137
165
  >
138
166
  {{ item.value }}
139
167
  </DateRangePickerInput>
@@ -142,7 +170,7 @@ watch(tempDate, () => {
142
170
  type="end"
143
171
  :part="item.part"
144
172
  class="
145
- input
173
+ date-range-picker--segment-input
146
174
  focus-outline-hidden
147
175
  border
148
176
  border-transparent
@@ -151,6 +179,7 @@ watch(tempDate, () => {
151
179
  >
152
180
  <div
153
181
  class="
182
+ date-range-picker--segment-value
154
183
  group-focus:z-[2]
155
184
  group-focus:bg-accent-500/50
156
185
  group-focus:rounded-xs
@@ -165,7 +194,7 @@ watch(tempDate, () => {
165
194
  </div>
166
195
  <DateRangePickerTrigger
167
196
  class="
168
- trigger
197
+ date-range-picker--trigger
169
198
  px-1
170
199
  focus-outline
171
200
  rounded-tr-sm
@@ -183,45 +212,52 @@ watch(tempDate, () => {
183
212
  </DateRangePickerTrigger>
184
213
  </DateRangePickerField>
185
214
 
186
- <!-- @vue-expect-error to exists -->
215
+ <!-- side=bottom makes months easier to click through -->
216
+ <!-- @vue-expect-error to exists-->
187
217
  <DateRangePickerContent
188
218
  :side-offset="4"
219
+ :avoid-collisions="true"
220
+ :prioritize-position="true"
221
+ side="bottom"
189
222
  to="#root"
190
223
  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
- "
224
+ date-range-picker--content
225
+ z-100
226
+ mx-2
227
+ rounded-sm
228
+ bg-bg
229
+ dark:bg-neutral-800
230
+ border
231
+ border-neutral-300
232
+ dark:border-neutral-700
233
+ shadow-lg
234
+ will-change-[transform,opacity]
235
+ data-[state=open]:data-[side=top]:animate-slideDownAndFade
236
+ data-[state=open]:data-[side=right]:animate-slideLeftAndFade
237
+ data-[state=open]:data-[side=bottom]:animate-slideUpAndFade
238
+ data-[state=open]:data-[side=left]:animate-slideRightAndFade
239
+ text-fg
240
+ dark:text-neutral-200
241
+ "
207
242
  >
208
- <DateRangePickerArrow class="fill-neutral-500"/>
243
+ <DateRangePickerArrow class="date-range-picker--arrow fill-neutral-500"/>
209
244
  <DateRangePickerCalendar
210
245
  v-slot="{ weekDays, grid }"
211
- class="p-2 flex flex-col"
246
+ class="date-range-picker--calendar p-2 flex flex-col"
212
247
  >
213
- <DateRangePickerHeader class="flex items-center justify-between">
248
+ <DateRangePickerHeader class="date-range-picker--header flex items-center justify-between">
214
249
  <DateRangePickerPrev
215
250
  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
- "
251
+ date-range-picker--year-prev
252
+ inline-flex
253
+ items-center
254
+ cursor-pointer
255
+ active:scale-125
256
+ justify-center
257
+ rounded-sm
258
+ outlined
259
+ px-1
260
+ "
225
261
  :prev-page="(date: DateValue) => date.subtract({ years: 1 })"
226
262
  >
227
263
  <Icon class="scale-150">
@@ -230,6 +266,7 @@ watch(tempDate, () => {
230
266
  </DateRangePickerPrev>
231
267
  <DateRangePickerPrev
232
268
  class="
269
+ date-range-picker--prev
233
270
  inline-flex
234
271
  items-center
235
272
  cursor-pointer
@@ -245,18 +282,19 @@ watch(tempDate, () => {
245
282
  </Icon>
246
283
  </DateRangePickerPrev>
247
284
 
248
- <DateRangePickerHeading class="min-w-[14ch] text-center"/>
285
+ <DateRangePickerHeading class="date-range-picker--heading min-w-[14ch] text-center"/>
249
286
  <DateRangePickerNext
250
287
  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
- "
288
+ date-range-picker--next
289
+ inline-flex
290
+ items-center
291
+ cursor-pointer
292
+ active:scale-125
293
+ justify-center
294
+ rounded-sm
295
+ outlined
296
+ px-1
297
+ "
260
298
  >
261
299
  <Icon class="scale-150">
262
300
  <i-radix-icons-chevron-right/>
@@ -264,15 +302,16 @@ watch(tempDate, () => {
264
302
  </DateRangePickerNext>
265
303
  <DateRangePickerNext
266
304
  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
- "
305
+ date-range-picker--year-next
306
+ inline-flex
307
+ items-center
308
+ cursor-pointer
309
+ active:scale-125
310
+ justify-center
311
+ rounded-sm
312
+ outlined
313
+ px-1
314
+ "
276
315
  :next-page="(date: DateValue) => date.add({ years: 1 })"
277
316
  >
278
317
  <Icon class="scale-150">
@@ -282,25 +321,37 @@ watch(tempDate, () => {
282
321
  </DateRangePickerHeader>
283
322
  <div
284
323
  class="
285
- flex
286
- flex-col
287
- pt-4
288
- "
324
+ date-range-picker--grid-wrapper
325
+ flex
326
+ flex-col
327
+ pt-4
328
+ "
289
329
  >
290
330
  <DateRangePickerGrid
291
- class="border-collapse select-none"
331
+ class="
332
+ date-range-picker--grid
333
+ border-collapse
334
+ select-none
335
+ "
292
336
  v-for="month in grid"
293
337
  :key="month.value.toString()"
294
338
  >
295
- <DateRangePickerGridHead>
296
- <DateRangePickerGridRow class="mb-1 flex justify-between">
339
+ <DateRangePickerGridHead class="date-range-picker--grid-head">
340
+ <DateRangePickerGridRow class="
341
+ date-range-picker--grid-row
342
+ mb-1
343
+ flex
344
+ justify-between
345
+ "
346
+ >
297
347
  <DateRangePickerHeadCell
298
348
  class="
299
- w-6
300
- rounded-md
301
- text-xs
302
- text-accent-500
303
- "
349
+ date-range-picker--head-cell
350
+ w-6
351
+ rounded-md
352
+ text-xs
353
+ text-accent-500
354
+ "
304
355
  v-for="day in weekDays"
305
356
  :key="day"
306
357
  >
@@ -308,14 +359,21 @@ watch(tempDate, () => {
308
359
  </DateRangePickerHeadCell>
309
360
  </DateRangePickerGridRow>
310
361
  </DateRangePickerGridHead>
311
- <DateRangePickerGridBody>
362
+ <DateRangePickerGridBody class="date-range-picker--grid-body">
312
363
  <DateRangePickerGridRow
313
- class="flex w-full justify-between my-1"
364
+ class="
365
+ date-range-picker--grid-row
366
+ flex
367
+ w-full
368
+ justify-between
369
+ my-1
370
+ "
314
371
  v-for="(weekDates, index) in month.rows"
315
372
  :key="`weekDate-${index}`"
316
373
  >
317
374
  <DateRangePickerCell
318
375
  :date="weekDate"
376
+ class="date-range-picker--cell"
319
377
  v-for="weekDate in weekDates"
320
378
  :key="weekDate.toString()"
321
379
  >
@@ -323,39 +381,43 @@ watch(tempDate, () => {
323
381
  :day="weekDate"
324
382
  :month="month.value"
325
383
  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
- "
384
+ date-range-picker--cell-trigger
385
+ relative
386
+ flex
387
+ items-center
388
+ justify-center
389
+ whitespace-nowrap
390
+ rounded-sm
391
+ border
392
+ border-transparent
393
+ bg-transparent
394
+ text-sm
395
+ w-6
396
+ h-6
397
+ focus:shadow
398
+ focus-outline
399
+ hover:border-accent-500
400
+ data-[selected]:bg-accent-500
401
+ dark:data-[selected]:bg-accent-500/80
402
+ data-[selected]:shadow
403
+ data-[disabled]:text-neutral-500
404
+ data-[selected]:text-white
405
+ data-[unavailable]:pointer-events-none
406
+ data-[unavailable]:text-neutral-500
407
+ data-[unavailable]:line-through
408
+ data-[outside-view]:text-neutral-500
409
+ before:absolute
410
+ before:bottom-[1px]
411
+ before:hidden
412
+ before:rounded-full
413
+ before:w-4
414
+ before:h-[2px]
415
+ before:bg-white
416
+ data-[today]:before:block
417
+ data-[today]:before:bg-accent-700
418
+ dark:data-[today]:before:bg-accent-300
419
+ data-[selected]:before:bg-white
420
+ "
359
421
  />
360
422
  </DateRangePickerCell>
361
423
  </DateRangePickerGridRow>
@@ -363,7 +425,6 @@ watch(tempDate, () => {
363
425
  </DateRangePickerGrid>
364
426
  </div>
365
427
  <slot v-bind="{tempValue: tempDate}"/>
366
- <slot/>
367
428
  </DateRangePickerCalendar>
368
429
  </DateRangePickerContent>
369
430
  </DateRangePickerRoot>