Skip to content

Commit 108c25b

Browse files
committed
fix(datepicker): multiple and range not working #62
1 parent 8c2ebbe commit 108c25b

File tree

2 files changed

+52
-28
lines changed

2 files changed

+52
-28
lines changed

dev/pages/inputs/DatePicker.vue

Lines changed: 42 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,49 @@
22
const primeAttributes = 'dateFormat, showIcon, icon, .... (see documentation)'
33
44
const schema
5-
= [
6-
{
7-
$formkit: 'primeDatePicker',
8-
id: 'basic',
9-
name: 'basic',
10-
label: 'Basic',
11-
placeholder: 'MM/DD/YYYY',
12-
validation: 'required',
13-
},
14-
{
15-
$formkit: 'primeDatePicker',
16-
name: 'styled',
17-
label: 'Styled',
18-
style: { background: 'gray' },
19-
class: 'customClass',
20-
showIcon: true,
21-
},
22-
{
23-
$formkit: 'primeDatePicker',
24-
name: 'icon',
25-
label: 'Custom Icon',
26-
dateFormat: 'yy-mm',
27-
showIcon: true,
28-
icon: 'pi pi-question',
29-
},
30-
]
5+
= [
6+
{
7+
$formkit: 'primeDatePicker',
8+
id: 'basic',
9+
name: 'basic',
10+
label: 'Basic',
11+
placeholder: 'MM/DD/YYYY',
12+
validation: 'required',
13+
},
14+
{
15+
$formkit: 'primeDatePicker',
16+
name: 'styled',
17+
label: 'Styled',
18+
style: { background: 'gray' },
19+
class: 'customClass',
20+
showIcon: true,
21+
},
22+
{
23+
$formkit: 'primeDatePicker',
24+
name: 'icon',
25+
label: 'Custom Icon',
26+
dateFormat: 'yy-mm',
27+
showIcon: true,
28+
icon: 'pi pi-question',
29+
},
30+
{
31+
$formkit: 'primeDatePicker',
32+
name: 'range',
33+
label: 'Date Range',
34+
selectionMode: 'range',
35+
manualInput: false,
36+
},
37+
{
38+
$formkit: 'primeDatePicker',
39+
name: 'multiple',
40+
label: 'Multiple Dates',
41+
selectionMode: 'multiple',
42+
manualInput: false,
43+
},
3144
32-
const data = { }
45+
]
46+
47+
const data = {}
3348
</script>
3449

3550
<template>

src/components/PrimeDatePicker.vue

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const props = defineProps({
5959
},
6060
})
6161
62-
const { validSlotNames, unstyled, isInvalid, handleInput, handleSelect } = useFormKitInput(props.context)
62+
const { validSlotNames, unstyled, isInvalid, handleInput } = useFormKitInput(props.context)
6363
6464
function handleBlur(e: DatePickerBlurEvent) {
6565
props.context?.handlers.blur(e.originalEvent)
@@ -68,6 +68,15 @@ function handleBlur(e: DatePickerBlurEvent) {
6868
function handleClearClick() {
6969
props.context?.node.input(null)
7070
}
71+
72+
function handleSelect(e: any) {
73+
if (props.context?.selectionMode === 'range' || props.context?.selectionMode === 'multiple') {
74+
props.context?.node.input(props.context._value)
75+
}
76+
else {
77+
props.context?.node.input(e)
78+
}
79+
}
7180
</script>
7281

7382
<template>

0 commit comments

Comments
 (0)