v-datepicker-lite 0.1.0 → 0.1.2
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/README.md +75 -38
- package/components/DatePicker.vue.d.ts +3 -3
- package/components/TimeView.vue.d.ts +6 -4
- package/components/time-picker/TimePicker.vue.d.ts +4 -0
- package/components/time-picker/TimePickerDropdown.vue.d.ts +18 -3
- package/composables/useTime.d.ts +1 -1
- package/index.js +580 -551
- package/package.json +1 -1
- package/style.css +1 -1
- package/types/index.d.ts +1 -2
package/README.md
CHANGED
|
@@ -4,13 +4,13 @@ A lightweight and customizable Vue 3 date picker component with support for date
|
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
7
|
+
- **Multiple Selection Modes**: Supports `date`, `time`, `dateTime`, `week`, and `month` modes.
|
|
8
|
+
- **Responsive Design**: Adapts to various screen sizes with a clean, modern UI.
|
|
9
|
+
- **Accessibility**: Includes ARIA attributes and keyboard navigation for enhanced usability.
|
|
10
|
+
- **Customizable**: Flexible props for date format, time format, min/max dates, disabled dates, and more.
|
|
11
|
+
- **Configurable Time Intervals**: Supports any minute interval (1-60 minutes) for time selection in both TimePicker and DatePicker components.
|
|
12
|
+
- **Performance Optimized**: Uses Vue 3 composition API for efficient rendering and state management.
|
|
13
|
+
- **TypeScript Support**: Fully typed with TypeScript for better developer experience.
|
|
14
14
|
|
|
15
15
|
## Demo
|
|
16
16
|
|
|
@@ -45,7 +45,7 @@ import { ref } from 'vue'
|
|
|
45
45
|
import DatePicker from 'v-datepicker-lite'
|
|
46
46
|
import 'v-datepicker-lite/style.css'
|
|
47
47
|
|
|
48
|
-
const selectedDate =
|
|
48
|
+
const selectedDate = ref(null)
|
|
49
49
|
</script>
|
|
50
50
|
|
|
51
51
|
<template>
|
|
@@ -69,7 +69,7 @@ Select an entire week starting from the first day of the selected week.
|
|
|
69
69
|
import { ref } from 'vue'
|
|
70
70
|
import DatePicker from 'v-datepicker-lite'
|
|
71
71
|
|
|
72
|
-
const selectedWeek =
|
|
72
|
+
const selectedWeek = ref(null)
|
|
73
73
|
</script>
|
|
74
74
|
|
|
75
75
|
<template>
|
|
@@ -93,7 +93,7 @@ Select a month and year.
|
|
|
93
93
|
import { ref } from 'vue'
|
|
94
94
|
import DatePicker from 'v-datepicker-lite'
|
|
95
95
|
|
|
96
|
-
const selectedMonth =
|
|
96
|
+
const selectedMonth = ref(null)
|
|
97
97
|
</script>
|
|
98
98
|
|
|
99
99
|
<template>
|
|
@@ -108,26 +108,26 @@ const selectedMonth = (ref < Date) | (null > null)
|
|
|
108
108
|
</template>
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
### 4. DateTime Picker
|
|
111
|
+
### 4. DateTime Picker with Custom Intervals
|
|
112
112
|
|
|
113
|
-
Select both date and time with
|
|
113
|
+
Select both date and time with configurable minute intervals.
|
|
114
114
|
|
|
115
115
|
```vue
|
|
116
116
|
<script setup>
|
|
117
117
|
import { ref } from 'vue'
|
|
118
118
|
import DatePicker from 'v-datepicker-lite'
|
|
119
119
|
|
|
120
|
-
const selectedDateTime =
|
|
120
|
+
const selectedDateTime = ref(null)
|
|
121
121
|
</script>
|
|
122
122
|
|
|
123
123
|
<template>
|
|
124
124
|
<div>
|
|
125
|
-
<h3>DateTime Picker</h3>
|
|
125
|
+
<h3>DateTime Picker - 5 minute intervals</h3>
|
|
126
126
|
<DatePicker
|
|
127
127
|
v-model:value="selectedDateTime"
|
|
128
128
|
mode="dateTime"
|
|
129
129
|
time-format="12h"
|
|
130
|
-
|
|
130
|
+
:minute-interval="5" />
|
|
131
131
|
<p>
|
|
132
132
|
Selected:
|
|
133
133
|
{{ selectedDateTime ? selectedDateTime.toLocaleString() : 'None' }}
|
|
@@ -145,7 +145,7 @@ Restrict date selection with minimum date and disabled date ranges.
|
|
|
145
145
|
import { ref } from 'vue'
|
|
146
146
|
import DatePicker from 'v-datepicker-lite'
|
|
147
147
|
|
|
148
|
-
const selectedDate =
|
|
148
|
+
const selectedDate = ref(null)
|
|
149
149
|
</script>
|
|
150
150
|
|
|
151
151
|
<template>
|
|
@@ -164,24 +164,30 @@ const selectedDate = (ref < Date) | (null > null)
|
|
|
164
164
|
</template>
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
-
### 6. Standalone Time Picker
|
|
167
|
+
### 6. Standalone Time Picker with Custom Intervals
|
|
168
168
|
|
|
169
|
-
A time picker component for selecting time only, with
|
|
169
|
+
A time picker component for selecting time only, with configurable minute intervals.
|
|
170
170
|
|
|
171
171
|
```vue
|
|
172
172
|
<script setup>
|
|
173
173
|
import { ref } from 'vue'
|
|
174
174
|
import { TimePicker } from 'v-datepicker-lite'
|
|
175
175
|
import 'v-datepicker-lite/style.css'
|
|
176
|
-
|
|
176
|
+
|
|
177
|
+
const selectedTime = ref(null)
|
|
177
178
|
</script>
|
|
179
|
+
|
|
178
180
|
<template>
|
|
179
181
|
<div>
|
|
180
|
-
<h3>Time Picker</h3>
|
|
181
|
-
<TimePicker v-model:model-value="selectedTime" time-format="12h" />
|
|
182
|
+
<h3>Time Picker - 15 minute intervals</h3>
|
|
183
|
+
<TimePicker v-model:model-value="selectedTime" time-format="12h" :minute-interval="15" />
|
|
182
184
|
|
|
183
185
|
<!-- With Custom Trigger -->
|
|
184
|
-
<TimePicker
|
|
186
|
+
<TimePicker
|
|
187
|
+
v-model:model-value="selectedTime"
|
|
188
|
+
time-format="12h"
|
|
189
|
+
:minute-interval="5"
|
|
190
|
+
v-slot="{ displayTime }">
|
|
185
191
|
<button>{{ displayTime }}</button>
|
|
186
192
|
</TimePicker>
|
|
187
193
|
|
|
@@ -195,25 +201,26 @@ const selectedTime = (ref < string) | (null > null)
|
|
|
195
201
|
|
|
196
202
|
## Props
|
|
197
203
|
|
|
198
|
-
| Prop
|
|
199
|
-
|
|
|
200
|
-
| `value`
|
|
201
|
-
| `mode`
|
|
202
|
-
| `format`
|
|
203
|
-
| `timeFormat`
|
|
204
|
-
| `
|
|
205
|
-
| `minDate`
|
|
206
|
-
| `maxDate`
|
|
207
|
-
| `disabledDates`
|
|
208
|
-
| `disabled`
|
|
209
|
-
| `readonly`
|
|
204
|
+
| Prop | Type | Default | Description |
|
|
205
|
+
| ---------------- | ------------------------ | -------------- | ------------------------------------------------------------------------------ |
|
|
206
|
+
| `value` | `Date \| string \| null` | `null` | v-model binding for the selected date/time. |
|
|
207
|
+
| `mode` | `string` | `'date'` | Selection mode: `date`, `time`, `dateTime`, `week`, or `month`. |
|
|
208
|
+
| `format` | `string` | `'YYYY-MM-DD'` | Date format for string output (e.g., `YYYY-MM-DD HH:mm`). |
|
|
209
|
+
| `timeFormat` | `string` | `'24h'` | Time format: `12h` or `24h`. |
|
|
210
|
+
| `minuteInterval` | `number` | `1` | Minute selection interval (1-60). Controls minute options displayed in picker. |
|
|
211
|
+
| `minDate` | `string` | `undefined` | Minimum selectable date (ISO format: `YYYY-MM-DD`). |
|
|
212
|
+
| `maxDate` | `string` | `undefined` | Maximum selectable date (ISO format: `YYYY-MM-DD`). |
|
|
213
|
+
| `disabledDates` | `Array` | `[]` | Array of disabled date ranges: `{ start: string, end?: string }`. |
|
|
214
|
+
| `disabled` | `boolean` | `false` | Disables the date picker. |
|
|
215
|
+
| `readonly` | `boolean` | `false` | Makes the date picker read-only. |
|
|
210
216
|
|
|
211
217
|
## Props - TimePicker
|
|
212
218
|
|
|
213
|
-
| Prop
|
|
214
|
-
|
|
|
215
|
-
| `modelValue`
|
|
216
|
-
| `timeFormat`
|
|
219
|
+
| Prop | Type | Default | Description |
|
|
220
|
+
| ---------------- | ---------------- | ------- | ------------------------------------------------------------------------------ |
|
|
221
|
+
| `modelValue` | `string \| null` | `null` | v-model binding for the selected time (format: `HH:mm`). |
|
|
222
|
+
| `timeFormat` | `string` | `'12h'` | Time format: `12h` or `24h`. |
|
|
223
|
+
| `minuteInterval` | `number` | `1` | Minute selection interval (1-60). Controls minute options displayed in picker. |
|
|
217
224
|
|
|
218
225
|
## Events
|
|
219
226
|
|
|
@@ -229,6 +236,36 @@ const selectedTime = (ref < string) | (null > null)
|
|
|
229
236
|
| ------------------- | ------------ | --------------------------------------- |
|
|
230
237
|
| `update:modelValue` | `string` | Emitted when the selected time changes. |
|
|
231
238
|
|
|
239
|
+
## Minute Interval Configuration
|
|
240
|
+
|
|
241
|
+
The `minuteInterval` prop allows you to customize the minute options displayed in both the TimePicker and DatePicker (when in `dateTime` or `time` mode). This is useful for:
|
|
242
|
+
|
|
243
|
+
- **Scheduling applications**: Set 15 or 30-minute intervals for appointment booking
|
|
244
|
+
- **Time tracking**: Use 5 or 10-minute intervals for precise time logging
|
|
245
|
+
- **Simplified selection**: Use 60-minute intervals to show only full hours
|
|
246
|
+
|
|
247
|
+
### Examples:
|
|
248
|
+
|
|
249
|
+
```vue
|
|
250
|
+
<!-- 5-minute intervals: 00, 05, 10, 15, ... 55 -->
|
|
251
|
+
<DatePicker mode="dateTime" :minute-interval="5" />
|
|
252
|
+
|
|
253
|
+
<!-- 10-minute intervals: 00, 10, 20, 30, ... 50 -->
|
|
254
|
+
<TimePicker :minute-interval="10" />
|
|
255
|
+
|
|
256
|
+
<!-- 15-minute intervals: 00, 15, 30, 45 -->
|
|
257
|
+
<DatePicker mode="time" :minute-interval="15" />
|
|
258
|
+
|
|
259
|
+
<!-- 30-minute intervals: 00, 30 -->
|
|
260
|
+
<TimePicker :minute-interval="30" />
|
|
261
|
+
|
|
262
|
+
<!-- 60-minute intervals: Only 00 (full hours) -->
|
|
263
|
+
<DatePicker mode="dateTime" :minute-interval="60" />
|
|
264
|
+
|
|
265
|
+
<!-- 1-minute intervals (default): 00, 01, 02, ... 59 -->
|
|
266
|
+
<TimePicker :minute-interval="1" />
|
|
267
|
+
```
|
|
268
|
+
|
|
232
269
|
## Styling
|
|
233
270
|
|
|
234
271
|
Customize the appearance using the following CSS variables defined in `style.css`:
|
|
@@ -6,7 +6,7 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
6
6
|
mode: string;
|
|
7
7
|
format: string;
|
|
8
8
|
timeFormat: string;
|
|
9
|
-
|
|
9
|
+
minuteInterval: number;
|
|
10
10
|
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
11
11
|
"update:value": (value: string | Date) => void;
|
|
12
12
|
change: (value: string | Date) => void;
|
|
@@ -15,14 +15,14 @@ declare const _default: import('vue').DefineComponent<import('vue').ExtractPropT
|
|
|
15
15
|
mode: string;
|
|
16
16
|
format: string;
|
|
17
17
|
timeFormat: string;
|
|
18
|
-
|
|
18
|
+
minuteInterval: number;
|
|
19
19
|
}>>> & Readonly<{
|
|
20
20
|
onSelect?: (value: string | Date) => any;
|
|
21
21
|
"onUpdate:value"?: (value: string | Date) => any;
|
|
22
22
|
onChange?: (value: string | Date) => any;
|
|
23
23
|
}>, {
|
|
24
24
|
timeFormat: "12h" | "24h";
|
|
25
|
-
|
|
25
|
+
minuteInterval: number;
|
|
26
26
|
mode: "date" | "time" | "dateTime" | "week" | "month";
|
|
27
27
|
format: string;
|
|
28
28
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
interface Props {
|
|
2
2
|
selectedTime: Date | null;
|
|
3
3
|
timeFormat?: '12h' | '24h';
|
|
4
|
-
|
|
4
|
+
minuteInterval?: number;
|
|
5
5
|
}
|
|
6
6
|
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
7
7
|
timeFormat: string;
|
|
8
|
-
|
|
8
|
+
minuteInterval: number;
|
|
9
9
|
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
10
10
|
update: (time: Date) => void;
|
|
11
|
+
"clear-time": () => void;
|
|
11
12
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
12
13
|
timeFormat: string;
|
|
13
|
-
|
|
14
|
+
minuteInterval: number;
|
|
14
15
|
}>>> & Readonly<{
|
|
16
|
+
"onClear-time"?: () => any;
|
|
15
17
|
onUpdate?: (time: Date) => any;
|
|
16
18
|
}>, {
|
|
17
19
|
timeFormat: "12h" | "24h";
|
|
18
|
-
|
|
20
|
+
minuteInterval: number;
|
|
19
21
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
20
22
|
export default _default;
|
|
21
23
|
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
@@ -5,6 +5,7 @@ interface Props {
|
|
|
5
5
|
style?: any;
|
|
6
6
|
className?: any;
|
|
7
7
|
offset?: [number, number];
|
|
8
|
+
minuteInterval?: number;
|
|
8
9
|
}
|
|
9
10
|
declare function __VLS_template(): {
|
|
10
11
|
default?(_: {
|
|
@@ -15,16 +16,19 @@ declare const __VLS_component: import('vue').DefineComponent<import('vue').Extra
|
|
|
15
16
|
modelValue: any;
|
|
16
17
|
timeFormat: string;
|
|
17
18
|
offset: () => number[];
|
|
19
|
+
minuteInterval: number;
|
|
18
20
|
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
19
21
|
"update:modelValue": (value: string) => void;
|
|
20
22
|
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
21
23
|
modelValue: any;
|
|
22
24
|
timeFormat: string;
|
|
23
25
|
offset: () => number[];
|
|
26
|
+
minuteInterval: number;
|
|
24
27
|
}>>> & Readonly<{
|
|
25
28
|
"onUpdate:modelValue"?: (value: string) => any;
|
|
26
29
|
}>, {
|
|
27
30
|
timeFormat: "12h" | "24h";
|
|
31
|
+
minuteInterval: number;
|
|
28
32
|
modelValue: string | null;
|
|
29
33
|
offset: [number, number];
|
|
30
34
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
@@ -3,20 +3,27 @@ interface Props {
|
|
|
3
3
|
selectedMinute: number;
|
|
4
4
|
selectedPeriod: 'AM' | 'PM';
|
|
5
5
|
is12Hour: boolean;
|
|
6
|
+
minuteInterval?: number;
|
|
6
7
|
}
|
|
7
|
-
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<Props
|
|
8
|
+
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
9
|
+
minuteInterval: number;
|
|
10
|
+
}>>, {
|
|
8
11
|
scrollToSelected: () => void;
|
|
9
12
|
}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
10
13
|
"select-hour": (hour: number) => void;
|
|
11
14
|
"select-minute": (minute: number) => void;
|
|
12
15
|
"select-period": (period: "AM" | "PM") => void;
|
|
13
16
|
close: () => void;
|
|
14
|
-
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_TypePropsToRuntimeProps<Props
|
|
17
|
+
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<Props>, {
|
|
18
|
+
minuteInterval: number;
|
|
19
|
+
}>>> & Readonly<{
|
|
15
20
|
"onSelect-hour"?: (hour: number) => any;
|
|
16
21
|
"onSelect-minute"?: (minute: number) => any;
|
|
17
22
|
"onSelect-period"?: (period: "AM" | "PM") => any;
|
|
18
23
|
onClose?: () => any;
|
|
19
|
-
}>, {
|
|
24
|
+
}>, {
|
|
25
|
+
minuteInterval: number;
|
|
26
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
20
27
|
export default _default;
|
|
21
28
|
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
22
29
|
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
@@ -27,3 +34,11 @@ type __VLS_TypePropsToRuntimeProps<T> = {
|
|
|
27
34
|
required: true;
|
|
28
35
|
};
|
|
29
36
|
};
|
|
37
|
+
type __VLS_WithDefaults<P, D> = {
|
|
38
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
39
|
+
default: D[K];
|
|
40
|
+
}> : P[K];
|
|
41
|
+
};
|
|
42
|
+
type __VLS_Prettify<T> = {
|
|
43
|
+
[K in keyof T]: T[K];
|
|
44
|
+
} & {};
|
package/composables/useTime.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function useTime(selectedTime: Date | null, timeFormat: '12h' | '24h',
|
|
1
|
+
export declare function useTime(selectedTime: Date | null, timeFormat: '12h' | '24h', minuteInterval: number, emit: any): {
|
|
2
2
|
hours: import('vue').Ref<number, number>;
|
|
3
3
|
minutes: import('vue').Ref<number, number>;
|
|
4
4
|
timeOptions: import('vue').Ref<string[], string[]>;
|