Skip to content
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

refactor: integrate datepicker with the internal dropdown #69

Merged
merged 10 commits into from
Dec 10, 2024
2 changes: 1 addition & 1 deletion components/combobox/demo/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ Sets the help text displayed below the trigger. The `helpText` slot can be used

#### in Dialog

The focus method will apply focus state to the datepicker's input field.
The component can be in a dialog

<div class="exampleWrapper">
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/inDialog.html) -->
Expand Down
1 change: 1 addition & 0 deletions components/combobox/demo/api.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -3246,6 +3246,7 @@ class AuroDropdown extends r$5 {
* to the `bibContent` element. If a callback function `onSlotChange` is defined, it is invoked to
* notify about the slot change.
*
* @private
* @method handleDefaultSlot
* @param {Event} event - The event object representing the slot change.
* @fires Function#onSlotChange - Optional callback invoked when the slot content changes.
Expand Down
1 change: 1 addition & 0 deletions components/combobox/demo/index.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -3150,6 +3150,7 @@ class AuroDropdown extends r$5 {
* to the `bibContent` element. If a callback function `onSlotChange` is defined, it is invoked to
* notify about the slot change.
*
* @private
* @method handleDefaultSlot
* @param {Event} event - The event object representing the slot change.
* @fires Function#onSlotChange - Optional callback invoked when the slot content changes.
Expand Down
2 changes: 1 addition & 1 deletion components/combobox/docs/partials/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ Sets the help text displayed below the trigger. The `helpText` slot can be used

#### in Dialog

The focus method will apply focus state to the datepicker's input field.
The component can be in a dialog

<div class="exampleWrapper">
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/inDialog.html) -->
Expand Down
2 changes: 1 addition & 1 deletion components/datepicker/demo/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ export function alertValueExample() {

#### in Dialog

The focus method will apply focus state to the datepicker's input field.
The component can be in a dialog

<div class="exampleWrapper">
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/inDialog.html) -->
Expand Down
35 changes: 22 additions & 13 deletions components/datepicker/demo/api.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -10373,6 +10373,7 @@ class CalendarUtilities {
* @prop {Date | undefined} selectedDate - The selected date, usually synchronized with datepicker-input.
* Not to be confused with the focused date (therefore not necessarily in active month view).
* @prop {string} weekdayHeaderNotation - Weekday header notation, based on Intl DatetimeFormat:
* @prop {Boolean} visible - Flag indicating if the calendar is visible.
* - 'short' (e.g., Thu)
* - 'narrow' (e.g., T).
* Default is 'short'.
Expand Down Expand Up @@ -10424,10 +10425,7 @@ class AuroCalendar extends RangeDatepicker {
this.numCalendars = undefined;


/**
* @private
*/
this.isVisible = false;
this.visible = false;


/**
Expand Down Expand Up @@ -10475,6 +10473,10 @@ class AuroCalendar extends RangeDatepicker {
type: String,
reflect: true
},
visible: {
type: Boolean,
reflect: false
}
};
}

Expand Down Expand Up @@ -10503,7 +10505,7 @@ class AuroCalendar extends RangeDatepicker {
*/
renderAllCalendars() {
let renderedHtml = undefined;
if (this.isVisible) {
if (this.visible) {
this.utilCalRender.setFirstRenderableMonthDate(this);

const dropdown = AuroLibraryRuntimeUtils$2.prototype.closestElement('auro-dropdown, [auro-dropdown]', this);
Expand Down Expand Up @@ -10609,13 +10611,6 @@ class AuroCalendar extends RangeDatepicker {
});
}

toggleVisibility(visibility) {
this.isVisible = visibility;

// wait for dropdownbib's fullscreen attribute
setTimeout(() => this.requestUpdate());
}

injectSlot(slotName, nodes) {
this.slots[slotName] = nodes;
}
Expand All @@ -10636,6 +10631,10 @@ class AuroCalendar extends RangeDatepicker {
if (changedProperties.has('centralDate')) {
this.utilCal.centralDateChanged(this);
}

if (changedProperties.has('visible')) {
setTimeout(() => this.requestUpdate());
}
}

render() {
Expand Down Expand Up @@ -13426,6 +13425,7 @@ class AuroDropdown extends r$5 {
* to the `bibContent` element. If a callback function `onSlotChange` is defined, it is invoked to
* notify about the slot change.
*
* @private
* @method handleDefaultSlot
* @param {Event} event - The event object representing the slot change.
* @fires Function#onSlotChange - Optional callback invoked when the slot content changes.
Expand Down Expand Up @@ -17676,7 +17676,7 @@ class AuroDatePicker extends r$7 {
this.setAttribute('aria-expanded', this.dropdown.isPopoverVisible);
this.notifyDatepickerToggled();

this.calendar.toggleVisibility(this.dropdown.isPopoverVisible);
this.calendar.visible = this.dropdown.isPopoverVisible;

if (this.dropdown.getAttribute('data-show')) {
if (this.forceScrollOnNextMobileCalendarRender) {
Expand Down Expand Up @@ -17898,6 +17898,7 @@ class AuroDatePicker extends r$7 {

/**
* Emits an event to notify the calendar cells to fetch their slot content.
* @private
* @returns {void}
*/
pushSlotContent() {
Expand Down Expand Up @@ -18074,6 +18075,14 @@ class AuroDatePicker extends r$7 {
}
}

/**
* Handles the transfer of content between slots in the component.
*
* @private
* @method handleSlotToSlot
* @param {Event} event - The event object containing information about the slot transfer.
* @throws {Error} Throws an error if the slot cannot be found or injected.
*/
handleSlotToSlot(event) {
const slot = this.querySelector(`[slot='${event.target.name}']`);
this.calendar.injectSlot(event.target.name, slot.cloneNode(true));
Expand Down
35 changes: 22 additions & 13 deletions components/datepicker/demo/index.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -10121,6 +10121,7 @@ class CalendarUtilities {
* @prop {Date | undefined} selectedDate - The selected date, usually synchronized with datepicker-input.
* Not to be confused with the focused date (therefore not necessarily in active month view).
* @prop {string} weekdayHeaderNotation - Weekday header notation, based on Intl DatetimeFormat:
* @prop {Boolean} visible - Flag indicating if the calendar is visible.
* - 'short' (e.g., Thu)
* - 'narrow' (e.g., T).
* Default is 'short'.
Expand Down Expand Up @@ -10172,10 +10173,7 @@ class AuroCalendar extends RangeDatepicker {
this.numCalendars = undefined;


/**
* @private
*/
this.isVisible = false;
this.visible = false;


/**
Expand Down Expand Up @@ -10223,6 +10221,10 @@ class AuroCalendar extends RangeDatepicker {
type: String,
reflect: true
},
visible: {
type: Boolean,
reflect: false
}
};
}

Expand Down Expand Up @@ -10251,7 +10253,7 @@ class AuroCalendar extends RangeDatepicker {
*/
renderAllCalendars() {
let renderedHtml = undefined;
if (this.isVisible) {
if (this.visible) {
this.utilCalRender.setFirstRenderableMonthDate(this);

const dropdown = AuroLibraryRuntimeUtils$2.prototype.closestElement('auro-dropdown, [auro-dropdown]', this);
Expand Down Expand Up @@ -10357,13 +10359,6 @@ class AuroCalendar extends RangeDatepicker {
});
}

toggleVisibility(visibility) {
this.isVisible = visibility;

// wait for dropdownbib's fullscreen attribute
setTimeout(() => this.requestUpdate());
}

injectSlot(slotName, nodes) {
this.slots[slotName] = nodes;
}
Expand All @@ -10384,6 +10379,10 @@ class AuroCalendar extends RangeDatepicker {
if (changedProperties.has('centralDate')) {
this.utilCal.centralDateChanged(this);
}

if (changedProperties.has('visible')) {
setTimeout(() => this.requestUpdate());
}
}

render() {
Expand Down Expand Up @@ -13174,6 +13173,7 @@ class AuroDropdown extends r$5 {
* to the `bibContent` element. If a callback function `onSlotChange` is defined, it is invoked to
* notify about the slot change.
*
* @private
* @method handleDefaultSlot
* @param {Event} event - The event object representing the slot change.
* @fires Function#onSlotChange - Optional callback invoked when the slot content changes.
Expand Down Expand Up @@ -17424,7 +17424,7 @@ class AuroDatePicker extends r$7 {
this.setAttribute('aria-expanded', this.dropdown.isPopoverVisible);
this.notifyDatepickerToggled();

this.calendar.toggleVisibility(this.dropdown.isPopoverVisible);
this.calendar.visible = this.dropdown.isPopoverVisible;

if (this.dropdown.getAttribute('data-show')) {
if (this.forceScrollOnNextMobileCalendarRender) {
Expand Down Expand Up @@ -17646,6 +17646,7 @@ class AuroDatePicker extends r$7 {

/**
* Emits an event to notify the calendar cells to fetch their slot content.
* @private
* @returns {void}
*/
pushSlotContent() {
Expand Down Expand Up @@ -17822,6 +17823,14 @@ class AuroDatePicker extends r$7 {
}
}

/**
* Handles the transfer of content between slots in the component.
*
* @private
* @method handleSlotToSlot
* @param {Event} event - The event object containing information about the slot transfer.
* @throws {Error} Throws an error if the slot cannot be found or injected.
*/
handleSlotToSlot(event) {
const slot = this.querySelector(`[slot='${event.target.name}']`);
this.calendar.injectSlot(event.target.name, slot.cloneNode(true));
Expand Down
2 changes: 1 addition & 1 deletion components/datepicker/docs/partials/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ The following example listens for the `auroDatePicker-valueSet` event. Once trig

#### in Dialog

The focus method will apply focus state to the datepicker's input field.
The component can be in a dialog

<div class="exampleWrapper">
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/inDialog.html) -->
Expand Down
23 changes: 11 additions & 12 deletions components/datepicker/src/auro-calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { UtilitiesCalendarRender } from './utilitiesCalendarRender.js';
* @prop {Date | undefined} selectedDate - The selected date, usually synchronized with datepicker-input.
* Not to be confused with the focused date (therefore not necessarily in active month view).
* @prop {string} weekdayHeaderNotation - Weekday header notation, based on Intl DatetimeFormat:
* @prop {Boolean} visible - Flag indicating if the calendar is visible.
* - 'short' (e.g., Thu)
* - 'narrow' (e.g., T).
* Default is 'short'.
Expand Down Expand Up @@ -77,10 +78,7 @@ export class AuroCalendar extends RangeDatepicker {
this.numCalendars = undefined;


/**
* @private
*/
this.isVisible = false;
this.visible = false;


/**
Expand Down Expand Up @@ -128,6 +126,10 @@ export class AuroCalendar extends RangeDatepicker {
type: String,
reflect: true
},
visible: {
type: Boolean,
reflect: false
}
};
}

Expand Down Expand Up @@ -156,7 +158,7 @@ export class AuroCalendar extends RangeDatepicker {
*/
renderAllCalendars() {
let renderedHtml = undefined;
if (this.isVisible) {
if (this.visible) {
this.utilCalRender.setFirstRenderableMonthDate(this);

const dropdown = AuroLibraryRuntimeUtils.prototype.closestElement('auro-dropdown, [auro-dropdown]', this);
Expand Down Expand Up @@ -262,13 +264,6 @@ export class AuroCalendar extends RangeDatepicker {
});
}

toggleVisibility(visibility) {
this.isVisible = visibility;

// wait for dropdownbib's fullscreen attribute
setTimeout(() => this.requestUpdate());
}

injectSlot(slotName, nodes) {
this.slots[slotName] = nodes;
}
Expand All @@ -289,6 +284,10 @@ export class AuroCalendar extends RangeDatepicker {
if (changedProperties.has('centralDate')) {
this.utilCal.centralDateChanged(this);
}

if (changedProperties.has('visible')) {
setTimeout(() => this.requestUpdate());
}
}

render() {
Expand Down
2 changes: 1 addition & 1 deletion components/datepicker/src/auro-datepicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ export class AuroDatePicker extends LitElement {
this.setAttribute('aria-expanded', this.dropdown.isPopoverVisible);
this.notifyDatepickerToggled();

this.calendar.toggleVisibility(this.dropdown.isPopoverVisible);
this.calendar.visible = this.dropdown.isPopoverVisible;

if (this.dropdown.getAttribute('data-show')) {
if (this.forceScrollOnNextMobileCalendarRender) {
Expand Down
11 changes: 5 additions & 6 deletions components/dropdown/demo/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,10 @@

## Methods

| Method | Type | Description |
|---------------------|------------------------|--------------------------------------------------|
| [handleDefaultSlot](#handleDefaultSlot) | `(event: Event): void` | Handles the default slot change event and updates the content.<br /><br />This method retrieves all nodes assigned to the default slot of the event target and appends them<br />to the `bibContent` element. If a callback function `onSlotChange` is defined, it is invoked to<br />notify about the slot change.<br /><br />**event**: The event object representing the slot change. |
| [hide](#hide) | `(): void` | Public method to hide the dropdown. |
| [show](#show) | `(): void` | Public method to show the dropdown. |
| Method | Type | Description |
|--------|------------|-------------------------------------|
| [hide](#hide) | `(): void` | Public method to hide the dropdown. |
| [show](#show) | `(): void` | Public method to show the dropdown. |

## Events

Expand Down Expand Up @@ -1066,7 +1065,7 @@ This example demonstrations collapsing the dropdown by clicking a button within

#### in Dialog

The focus method will apply focus state to the datepicker's input field.
The component can be in a dialog

<div class="exampleWrapper">
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/inDialog.html) -->
Expand Down
1 change: 1 addition & 0 deletions components/dropdown/demo/api.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -2774,6 +2774,7 @@ class AuroDropdown extends r {
* to the `bibContent` element. If a callback function `onSlotChange` is defined, it is invoked to
* notify about the slot change.
*
* @private
* @method handleDefaultSlot
* @param {Event} event - The event object representing the slot change.
* @fires Function#onSlotChange - Optional callback invoked when the slot content changes.
Expand Down
1 change: 1 addition & 0 deletions components/dropdown/demo/index.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -2749,6 +2749,7 @@ class AuroDropdown extends r {
* to the `bibContent` element. If a callback function `onSlotChange` is defined, it is invoked to
* notify about the slot change.
*
* @private
* @method handleDefaultSlot
* @param {Event} event - The event object representing the slot change.
* @fires Function#onSlotChange - Optional callback invoked when the slot content changes.
Expand Down
9 changes: 4 additions & 5 deletions components/dropdown/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,10 @@

## Methods

| Method | Type | Description |
|---------------------|------------------------|--------------------------------------------------|
| `handleDefaultSlot` | `(event: Event): void` | Handles the default slot change event and updates the content.<br /><br />This method retrieves all nodes assigned to the default slot of the event target and appends them<br />to the `bibContent` element. If a callback function `onSlotChange` is defined, it is invoked to<br />notify about the slot change.<br /><br />**event**: The event object representing the slot change. |
| `hide` | `(): void` | Public method to hide the dropdown. |
| `show` | `(): void` | Public method to show the dropdown. |
| Method | Type | Description |
|--------|------------|-------------------------------------|
| `hide` | `(): void` | Public method to hide the dropdown. |
| `show` | `(): void` | Public method to show the dropdown. |

## Events

Expand Down
Loading
Loading