Skip to content

Commit 88720fc

Browse files
authored
refactor(input-date-picker)!: Removed deprecated start, startAsDate, end, endAsDate properties (#6076)
BREAKING CHANGE: Removed the `start`, `end`, `startAsDate`, and `endAsDate` properties. - Removed the property `start`, use `value` instead. - Removed the property `end`, use `value` instead. - Removed the property `startAsDate`, use `valueAsDate` instead. - Removed the property `endAsDate`, use `valueAsDate` instead.
1 parent 0697e10 commit 88720fc

File tree

2 files changed

+14
-72
lines changed

2 files changed

+14
-72
lines changed

src/components/input-date-picker/input-date-picker.stories.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ export const range = (): string => html`
3131
<div style="width: 400px">
3232
<calcite-input-date-picker
3333
scale="${select("scale", ["s", "m", "l"], "m")}"
34-
start="${text("start", "2020-12-12")}"
35-
end="${text("end", "2020-12-16")}"
3634
min="${text("min", "2016-08-09")}"
3735
max="${text("max", "2023-12-18")}"
3836
lang="${select("locale", locales, "en")}"

src/components/input-date-picker/input-date-picker.tsx

Lines changed: 14 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,6 @@ export class InputDatePicker
128128
let newValueAsDate;
129129
if (Array.isArray(newValue)) {
130130
newValueAsDate = getValueAsDateRange(newValue);
131-
this.start = newValue[0];
132-
this.end = newValue[1];
133131
} else if (newValue) {
134132
newValueAsDate = dateFromISO(newValue);
135133
} else {
@@ -178,20 +176,6 @@ export class InputDatePicker
178176
/** The component's value as a full date object. */
179177
@Prop({ mutable: true }) valueAsDate: Date | Date[];
180178

181-
/**
182-
* The component's start date as a full date object.
183-
*
184-
* @deprecated use `valueAsDate` instead.
185-
*/
186-
@Prop({ mutable: true }) startAsDate: Date;
187-
188-
/**
189-
* The component's end date as a full date object.
190-
*
191-
* @deprecated use `valueAsDate` instead.
192-
*/
193-
@Prop({ mutable: true }) endAsDate: Date;
194-
195179
/** Specifies the earliest allowed date as a full date object. */
196180
@Prop({ mutable: true }) minAsDate: Date;
197181

@@ -269,20 +253,6 @@ export class InputDatePicker
269253
*/
270254
@Prop({ reflect: true }) required = false;
271255

272-
/**
273-
* The component's start date.
274-
*
275-
* @deprecated use `value` instead.
276-
*/
277-
@Prop({ mutable: true, reflect: true }) start: string;
278-
279-
/**
280-
* The component's end date.
281-
*
282-
* @deprecated use `value` instead.
283-
*/
284-
@Prop({ mutable: true, reflect: true }) end: string;
285-
286256
/**
287257
* Determines the type of positioning to use for the overlaid content.
288258
*
@@ -427,29 +397,17 @@ export class InputDatePicker
427397
open && this.openHandler(open);
428398
if (Array.isArray(this.value)) {
429399
this.valueAsDate = getValueAsDateRange(this.value);
430-
this.start = this.value[0];
431-
this.end = this.value[1];
432400
} else if (this.value) {
433401
try {
434402
this.valueAsDate = dateFromISO(this.value);
435403
} catch (error) {
436404
this.warnAboutInvalidValue(this.value);
437405
this.value = "";
438406
}
439-
this.start = "";
440-
this.end = "";
441407
} else if (this.range && this.valueAsDate) {
442408
this.setRangeValue(this.valueAsDate as Date[]);
443409
}
444410

445-
if (this.start) {
446-
this.startAsDate = dateFromISO(this.start);
447-
}
448-
449-
if (this.end) {
450-
this.endAsDate = setEndOfDay(dateFromISO(this.end));
451-
}
452-
453411
if (this.min) {
454412
this.minAsDate = dateFromISO(this.min);
455413
}
@@ -550,7 +508,6 @@ export class InputDatePicker
550508
<calcite-date-picker
551509
activeDate={this.datePickerActiveDate}
552510
activeRange={this.focusedInput}
553-
endAsDate={this.endAsDate}
554511
headingLevel={this.headingLevel}
555512
max={this.max}
556513
maxAsDate={this.maxAsDate}
@@ -563,7 +520,6 @@ export class InputDatePicker
563520
proximitySelectionDisabled={this.proximitySelectionDisabled}
564521
range={this.range}
565522
scale={this.scale}
566-
startAsDate={this.startAsDate}
567523
tabIndex={0}
568524
valueAsDate={this.valueAsDate}
569525
/>
@@ -809,16 +765,6 @@ export class InputDatePicker
809765
this.setReferenceEl();
810766
};
811767

812-
@Watch("start")
813-
startWatcher(start: string): void {
814-
this.startAsDate = dateFromISO(start);
815-
}
816-
817-
@Watch("end")
818-
endWatcher(end: string): void {
819-
this.endAsDate = end ? setEndOfDay(dateFromISO(end)) : dateFromISO(end);
820-
}
821-
822768
@Watch("effectiveLocale")
823769
private async loadLocaleData(): Promise<void> {
824770
if (!Build.isBrowser) {
@@ -849,21 +795,15 @@ export class InputDatePicker
849795
};
850796

851797
private shouldFocusRangeStart(): boolean {
852-
return !!(
853-
this.endAsDate &&
854-
!this.startAsDate &&
855-
this.focusedInput === "end" &&
856-
this.startInput
857-
);
798+
const startValue = this.value[0] || undefined;
799+
const endValue = this.value[1] || undefined;
800+
return !!(endValue && !startValue && this.focusedInput === "end" && this.startInput);
858801
}
859802

860803
private shouldFocusRangeEnd(): boolean {
861-
return !!(
862-
this.startAsDate &&
863-
!this.endAsDate &&
864-
this.focusedInput === "start" &&
865-
this.endInput
866-
);
804+
const startValue = this.value[0] || undefined;
805+
const endValue = this.value[1] || undefined;
806+
return !!(startValue && !endValue && this.focusedInput === "start" && this.endInput);
867807
}
868808

869809
private handleDateRangeChange = (event: CustomEvent<void>): void => {
@@ -887,12 +827,18 @@ export class InputDatePicker
887827

888828
private localizeInputValues(): void {
889829
const date = dateFromRange(
890-
this.range ? this.startAsDate : this.valueAsDate,
830+
(this.range
831+
? (Array.isArray(this.valueAsDate) && this.valueAsDate[0]) || undefined
832+
: this.valueAsDate) as Date,
891833
this.minAsDate,
892834
this.maxAsDate
893835
);
894836
const endDate = this.range
895-
? dateFromRange(this.endAsDate, this.minAsDate, this.maxAsDate)
837+
? dateFromRange(
838+
(Array.isArray(this.valueAsDate) && this.valueAsDate[1]) || undefined,
839+
this.minAsDate,
840+
this.maxAsDate
841+
)
896842
: null;
897843

898844
const localizedDate =
@@ -935,8 +881,6 @@ export class InputDatePicker
935881
this.userChangedValue = true;
936882
this.value = newValue;
937883
this.valueAsDate = newValue ? getValueAsDateRange(newValue) : undefined;
938-
this.start = newStartDateISO;
939-
this.end = newEndDateISO;
940884

941885
const eventDetail = {
942886
startDate: newStartDate as Date,

0 commit comments

Comments
 (0)