diff --git a/packages/main/src/DatePicker.ts b/packages/main/src/DatePicker.ts index 9884dbce8ae8..28a836b9d175 100644 --- a/packages/main/src/DatePicker.ts +++ b/packages/main/src/DatePicker.ts @@ -366,6 +366,15 @@ class DatePicker extends DateComponentBase implements IFormInputElement { @property() accessibleDescriptionRef?: string; + /** + * Defines whether the clear icon of the input will be shown. + * @default false + * @public + * @since 1.16.0 + */ + @property({ type: Boolean }) + showClearIcon = false; + @property({ type: Object }) _respPopoverConfig?: object; @@ -878,6 +887,10 @@ class DatePicker extends DateComponentBase implements IFormInputElement { return this.getDisplayFormat().format(this.getValueFormat().parse(this.value, true), true); } + // get hasValue(): boolean { + // return !!this.value; + // } + get accInfo(): InputAccInfo { return { "ariaRoledescription": this.roleDescription, diff --git a/packages/main/src/DatePickerInputTemplate.tsx b/packages/main/src/DatePickerInputTemplate.tsx index d1cc46e08b54..7864caf60408 100644 --- a/packages/main/src/DatePickerInputTemplate.tsx +++ b/packages/main/src/DatePickerInputTemplate.tsx @@ -28,6 +28,7 @@ export default function DatePickerInputTemplate(this: DatePicker) { onInput={this._onInputInput} onSubmit={this._onInputSubmit} onKeyDown={this._onkeydown} + showClearIcon={this.showClearIcon} > {!this.open && this.valueStateMessage.length > 0 && diff --git a/packages/main/src/themes/DatePicker.css b/packages/main/src/themes/DatePicker.css index 11ceddfe6386..5ade497e9c46 100644 --- a/packages/main/src/themes/DatePicker.css +++ b/packages/main/src/themes/DatePicker.css @@ -60,6 +60,11 @@ background-color: var(--_ui5-datepicker-hover-background); } +:host([show-clear-icon]) .ui5-date-picker-input:not([value]), +:host([show-clear-icon]) .ui5-date-picker-input[value=""] { + width: calc(100% + 36px); +} + .ui5-date-picker-popover::part(header) { padding: 0; } \ No newline at end of file diff --git a/packages/main/src/themes/DateRangePicker.css b/packages/main/src/themes/DateRangePicker.css index 876c30c6a13e..d519390decef 100644 --- a/packages/main/src/themes/DateRangePicker.css +++ b/packages/main/src/themes/DateRangePicker.css @@ -13,4 +13,10 @@ min-width:inherit; color: inherit; background-color: inherit; +} + +:host([show-clear-icon]) .ui5-date-picker-input:not([value]), +:host([show-clear-icon]) .ui5-date-picker-input[value=""] { + width: 100%; + min-width:inherit; } \ No newline at end of file diff --git a/packages/main/src/themes/DateTimePicker.css b/packages/main/src/themes/DateTimePicker.css index 3eb355628e84..f059755a01e5 100644 --- a/packages/main/src/themes/DateTimePicker.css +++ b/packages/main/src/themes/DateTimePicker.css @@ -8,4 +8,10 @@ min-width: inherit; color: inherit; background-color: inherit; +} + +:host([show-clear-icon]) .ui5-date-picker-input:not([value]), +:host([show-clear-icon]) .ui5-date-picker-input[value=""] { + width: 100%; + min-width:inherit; } \ No newline at end of file diff --git a/packages/main/test/pages/DatePicker.html b/packages/main/test/pages/DatePicker.html index 17d3689a3969..8cbc6067fd5f 100644 --- a/packages/main/test/pages/DatePicker.html +++ b/packages/main/test/pages/DatePicker.html @@ -76,7 +76,7 @@