-
Notifications
You must be signed in to change notification settings - Fork 13.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: ion-datetime with date range #23572
Comments
We really need this, as long as we don't have this feature I still need to use tools external to Ionic |
it's a very useful feature. we need it also. |
any news ? |
which external things are you using . I want to show multiple date range in same calendar is there any way you are aware about. |
|
@liamdebeasi @willmartian almost one year from this request . Any news? |
is for vue, use https://vcalendar.io/datepicker.html |
Not a great solution but this is what I am doing in Angular. It allows me to select one date or all dates between two selected dates. HTML
TS
|
any update about the ion-date-range range? |
Is there any update about this feature? |
updates? |
Hi everyone, We do not have any updates regarding this feature. Any updates will be posted on this thread as we have them. |
Also very interested in an update to this. Thanks. |
any update? |
Hello! Is there any update??? |
1 similar comment
Hello! Is there any update??? |
Following. This would be so helpful. Thanks. |
This could be helpful. |
I think a direction to fix this issue for the ionic developer could be adding a property in html element that stop year / month wheel emitting value automatically each time user click on the wheel. It's not a perfect solution but, at the moment, a very cost-effective way to unlock the possibility to make a day range component first that is bug free. Developer can actually implement a proper day-range with a work-around function (just play with the date array) once this feature is disabled. |
At work we managed the range selection this way (using Ionic v7, Vue3 + TypeScript and Luxon): Using the component <CustomDateRange
id="datetime-filter" // Using a ion-datetime-button to open it
min="2023-01-01T00:00:00"
:start="startDate"
:end="endDate"
@update:start="(d) => (startDate = d)"
@update:end="(d) => (endDate = d)"
/>
const startDate = ref<string>('2023-10-01');
const endDate = ref<string>('2023-10-23'); The component<template>
<ion-datetime
class="clink-date-time-range"
presentation="date"
locale="es-ES"
multiple
:value="currentUserSelection"
v-on:ion-change="handleDateChange"
:highlighted-dates="defineHighlightStyle"
v-bind="$attrs"
/>
</template>
<script setup lang="ts">
import { IonDatetime, DatetimeChangeEventDetail } from '@ionic/vue';
import { IonDatetimeCustomEvent, DatetimeHighlightCallback } from '@ionic/core';
import { onMounted, ref } from 'vue';
import { DateTime } from 'luxon';
interface ClinkDatetimeRange {
start: string;
end: string;
}
const props = defineProps<ClinkDatetimeRange>();
const emit = defineEmits<{
(e: 'update:start' | 'update:end', date: string): void;
}>();
const currentUserSelection = ref<string[] | undefined>();
const previousUserSelection = ref<string[] | undefined>();
onMounted(() => {
const initRange: string[] = [props.start, props.end];
currentUserSelection.value = previousUserSelection.value = initRange;
});
const defineHighlightStyle: DatetimeHighlightCallback = (date: string) => {
if (!currentUserSelection.value || currentUserSelection.value.length < 2)
return;
const startDateCurrentRange = DateTime.fromFormat(
currentUserSelection.value[0],
'yyyy-MM-dd'
);
const endDateCurrentRange = DateTime.fromFormat(
currentUserSelection.value.at(-1) as string,
'yyyy-MM-dd'
);
const formattedDate = DateTime.fromFormat(date, 'yyyy-MM-dd');
const isDateWhithinRange =
formattedDate > startDateCurrentRange &&
formattedDate < endDateCurrentRange;
if (isDateWhithinRange)
return {
backgroundColor: '#4818f717',
};
};
const handleDateChange = (
e: IonDatetimeCustomEvent<DatetimeChangeEventDetail>
) => {
currentUserSelection.value = e.detail.value as string[] | undefined;
if (!currentUserSelection.value && !previousUserSelection.value) return;
if (!currentUserSelection.value || currentUserSelection.value.length < 2)
return;
currentUserSelection.value = [...currentUserSelection.value].sort((a, b) =>
a > b ? 1 : -1
);
if (previousUserSelection.value && previousUserSelection.value.length >= 2) {
const isSelectionWhithinPreviousRange =
currentUserSelection.value.length < previousUserSelection.value.length;
if (isSelectionWhithinPreviousRange) {
const selectedDateWhithinPreviousRange =
previousUserSelection.value.filter(
(date) => !(currentUserSelection.value as string[]).includes(date)
);
currentUserSelection.value = selectedDateWhithinPreviousRange;
} else {
const lastUserSelection = [(e.detail.value as string[]).at(-1) as string];
currentUserSelection.value = lastUserSelection;
}
}
previousUserSelection.value = currentUserSelection.value;
emit('update:start', currentUserSelection.value[0]);
emit('update:end', currentUserSelection.value.at(-1) as string);
};
</script> |
did anybody manage to do this with angular 17? |
I'm using the library @googlproxer/ion-range-calendar with Angular 17 and Ionic 7 and it works like a charm. |
@djabif is there a example to look at? cant seem to get it running |
@lukasrgr sorry but I can't share the code of this app but I can help you with the integration if you have any specific question |
This is essential for a framework, please have this consider. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This needs to be added. |
Is that component available for Angular Ivy? |
Doesn't this one only have official support for ionic 2, 3 & 4? Can you get it working on ionic 8? |
Hey there, I've upgraded this component to work with Ionic 6 and beyond. Feel free to check out the preview and the source code. |
i ma using ionic with standalone and i am getting problem with dayjs,any comment on it |
Do you have any tentative date for this feature? |
I have solution for this range feature if you need please reply to mail
with Need Solution I will share files using which I made this feature work
Thankyou
Mohit Chouhan
…On Sun, 21 Jul 2024 at 3:22 PM, Mohammed Alshehri ***@***.***> wrote:
Do you have any tentative date for this feature?
It is an essential feature for a calendar component. even angular material
supports it check it out here: link
<https://material.angular.io/components/datepicker/examples>
—
Reply to this email directly, view it on GitHub
<#23572 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AT7RRZCHPDFXIV5KBTPHVNLZNOAGFAVCNFSM47WJQOL2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMRUGE2TIOBYG44A>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
2024 Ionic 8 still no talks about this feature? |
I think they don't want to support it because it's not in apple. but I would pay attention to the design https://github.com/simla-tech/Fastis |
Feature Request
It would be great if the new ion-datetime would support a range feature (like for example in a hotel booking webpage) where you can provide a start and enddate and it shows on the calendar component.
Ionic version:
[ ] 4.x
[ ] 5.x
[x] 6.x
The text was updated successfully, but these errors were encountered: