()
| 2742 | } |
| 2743 | |
| 2744 | render() { |
| 2745 | const { |
| 2746 | name, |
| 2747 | value, |
| 2748 | disabled, |
| 2749 | el, |
| 2750 | color, |
| 2751 | readonly, |
| 2752 | showMonthAndYear, |
| 2753 | preferWheel, |
| 2754 | presentation, |
| 2755 | size, |
| 2756 | isGridStyle, |
| 2757 | } = this; |
| 2758 | const mode = getIonMode(this); |
| 2759 | const isMonthAndYearPresentation = |
| 2760 | presentation === 'year' || presentation === 'month' || presentation === 'month-year'; |
| 2761 | const shouldShowMonthAndYear = showMonthAndYear || isMonthAndYearPresentation; |
| 2762 | const monthYearPickerOpen = showMonthAndYear && !isMonthAndYearPresentation; |
| 2763 | const hasDatePresentation = presentation === 'date' || presentation === 'date-time' || presentation === 'time-date'; |
| 2764 | const hasWheelVariant = hasDatePresentation && preferWheel; |
| 2765 | |
| 2766 | renderHiddenInput(true, el, name, formatValue(value), disabled); |
| 2767 | |
| 2768 | return ( |
| 2769 | <Host |
| 2770 | aria-disabled={disabled ? 'true' : null} |
| 2771 | onFocus={this.onFocus} |
| 2772 | onBlur={this.onBlur} |
| 2773 | class={{ |
| 2774 | ...createColorClasses(color, { |
| 2775 | [mode]: true, |
| 2776 | ['datetime-readonly']: readonly, |
| 2777 | ['datetime-disabled']: disabled, |
| 2778 | 'show-month-and-year': shouldShowMonthAndYear, |
| 2779 | 'month-year-picker-open': monthYearPickerOpen, |
| 2780 | [`datetime-presentation-${presentation}`]: true, |
| 2781 | [`datetime-size-${size}`]: true, |
| 2782 | [`datetime-prefer-wheel`]: hasWheelVariant, |
| 2783 | [`datetime-grid`]: isGridStyle, |
| 2784 | }), |
| 2785 | }} |
| 2786 | > |
| 2787 | {/* |
| 2788 | WebKit has a quirk where IntersectionObserver callbacks are delayed until after |
| 2789 | an accelerated animation finishes if the "root" specified in the config is the |
| 2790 | browser viewport (the default behavior if "root" is not specified). This means |
| 2791 | that when presenting a datetime in a modal on iOS the calendar body appears |
| 2792 | blank until the modal animation finishes. |
| 2793 | |
| 2794 | We can work around this by observing .intersection-tracker and using the host |
| 2795 | (ion-datetime) as the "root". This allows the IO callback to fire the moment |
| 2796 | the datetime is visible. The .intersection-tracker element should not have |
| 2797 | dimensions or additional styles, and it should not be positioned absolutely |
| 2798 | otherwise the IO callback may fire at unexpected times. |
| 2799 | */} |
| 2800 | <div class="intersection-tracker" ref={(el) => (this.intersectionTrackerRef = el)}></div> |
| 2801 | {this.renderDatetime(mode)} |
nothing calls this directly
no test coverage detected