@nexxtmove/ui 0.1.62 → 0.1.63

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nexxtmove/ui",
3
3
  "type": "module",
4
- "version": "0.1.62",
4
+ "version": "0.1.63",
5
5
  "exports": {
6
6
  ".": {
7
7
  "types": "./dist/index.d.ts",
@@ -21,6 +21,7 @@ import CalendarHeader from './_CalendarHeader.vue'
21
21
  import CalendarDayView from './_CalendarDayView.vue'
22
22
  import CalendarMonthView from './_CalendarMonthView.vue'
23
23
  import CalendarYearView from './_CalendarYearView.vue'
24
+ import CalendarTimePicker from './_CalendarTimePicker.vue'
24
25
  import type { NexxtCalendarProps } from './calendar.types'
25
26
 
26
27
  export type { NexxtCalendarProps }
@@ -44,6 +45,7 @@ const {
44
45
  maxDate,
45
46
  monthYearPicker = false,
46
47
  timezone = 'UTC',
48
+ datetime = false,
47
49
  } = defineProps<NexxtCalendarProps>()
48
50
 
49
51
  // ── State ─────────────────────────────────────────────────────────────────────
@@ -235,5 +237,7 @@ const currentDayTransition = computed(() =>
235
237
  />
236
238
  </Transition>
237
239
  </div>
240
+
241
+ <CalendarTimePicker v-if="datetime" v-model="model" />
238
242
  </div>
239
243
  </template>
@@ -0,0 +1,98 @@
1
+ <script lang="ts" setup>
2
+ import { computed } from 'vue'
3
+ import { setHours, setMinutes, getHours, getMinutes } from 'date-fns'
4
+ import NexxtIcon from '../Icon/Icon.vue'
5
+
6
+ const props = defineProps<{
7
+ modelValue: Date | null
8
+ }>()
9
+
10
+ const emit = defineEmits<{
11
+ (e: 'update:modelValue', value: Date | null): void
12
+ }>()
13
+
14
+ const hours = computed({
15
+ get: () => {
16
+ if (props.modelValue) return getHours(props.modelValue)
17
+ return getHours(new Date())
18
+ },
19
+ set: (val) => {
20
+ const base = props.modelValue || new Date()
21
+ emit('update:modelValue', setHours(base, Number(val)))
22
+ },
23
+ })
24
+
25
+ const minutes = computed({
26
+ get: () => {
27
+ if (props.modelValue) return getMinutes(props.modelValue)
28
+ return getMinutes(new Date())
29
+ },
30
+ set: (val) => {
31
+ const base = props.modelValue || new Date()
32
+ emit('update:modelValue', setMinutes(base, Number(val)))
33
+ },
34
+ })
35
+
36
+ const pad = (n: number) => n.toString().padStart(2, '0')
37
+
38
+ const incrementHours = () => {
39
+ hours.value = (hours.value + 1) % 24
40
+ }
41
+ const decrementHours = () => {
42
+ hours.value = (hours.value + 23) % 24
43
+ }
44
+ const incrementMinutes = () => {
45
+ minutes.value = (minutes.value + 1) % 60
46
+ }
47
+ const decrementMinutes = () => {
48
+ minutes.value = (minutes.value + 59) % 60
49
+ }
50
+ </script>
51
+
52
+ <template>
53
+ <div class="flex items-center justify-center gap-4 border-t border-gray-100 pt-4">
54
+ <!-- Hours -->
55
+ <div class="flex flex-col items-center">
56
+ <button
57
+ type="button"
58
+ class="flex h-8 w-8 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-cornflower-blue-500"
59
+ @click="incrementHours"
60
+ >
61
+ <NexxtIcon name="chevron-up" />
62
+ </button>
63
+ <span class="font-medium text-lg text-gray-900 tabular-nums">
64
+ {{ pad(hours) }}
65
+ </span>
66
+ <button
67
+ type="button"
68
+ class="flex h-8 w-8 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-cornflower-blue-500"
69
+ @click="decrementHours"
70
+ >
71
+ <NexxtIcon name="chevron-down" />
72
+ </button>
73
+ </div>
74
+
75
+ <span class="mb-1 font-medium text-xl text-gray-400">:</span>
76
+
77
+ <!-- Minutes -->
78
+ <div class="flex flex-col items-center">
79
+ <button
80
+ type="button"
81
+ class="flex h-8 w-8 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-cornflower-blue-500"
82
+ @click="incrementMinutes"
83
+ >
84
+ <NexxtIcon name="chevron-up" />
85
+ </button>
86
+ <span class="font-medium text-lg text-gray-900 tabular-nums">
87
+ {{ pad(minutes) }}
88
+ </span>
89
+ <button
90
+ type="button"
91
+ class="flex h-8 w-8 items-center justify-center rounded-full text-gray-400 transition-colors hover:bg-gray-100 hover:text-cornflower-blue-500"
92
+ @click="decrementMinutes"
93
+ >
94
+ <NexxtIcon name="chevron-down" />
95
+ </button>
96
+ </div>
97
+ </div>
98
+ </template>
@@ -8,4 +8,5 @@ export interface NexxtCalendarProps {
8
8
  maxDate?: Date
9
9
  monthYearPicker?: boolean
10
10
  timezone?: string
11
+ datetime?: boolean
11
12
  }
@@ -55,7 +55,7 @@ const floatingPlacement = computed(() => anchorToPlacement[props.anchor])
55
55
  // ── Handlers ──────────────────────────────────────────────────────────────────
56
56
 
57
57
  const handleSelect = () => {
58
- if (props.autoClose) panelRef.value?.close()
58
+ if (props.autoClose && !props.datetime) panelRef.value?.close()
59
59
  }
60
60
 
61
61
  const onPanelOpen = async () => {