Skip to content

Commit 5559141

Browse files
committed
checkpoint
1 parent 8c1fedc commit 5559141

File tree

4 files changed

+446
-141
lines changed

4 files changed

+446
-141
lines changed

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

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import { LitElement, html, nothing } from 'lit';
22
import { property, query, queryAssignedElements } from 'lit/decorators.js';
33
import { ifDefined } from 'lit/directives/if-defined.js';
4+
import { live } from 'lit/directives/live.js';
45
import { convertToDate } from '../calendar/helpers.js';
56
import { registerComponent } from '../common/definitions/register.js';
67
import type { Constructor } from '../common/mixins/constructor.js';
78
import { EventEmitterMixin } from '../common/mixins/event-emitter.js';
89
import { createCounter } from '../common/util.js';
910
import IgcDateTimeInputComponent from '../date-time-input/date-time-input.js';
1011

11-
export const setInputFormat = Symbol();
12-
export const setDisplayFormat = Symbol();
13-
1412
export interface IgcDatePickerComponentEventMap {
1513
igcToggleIconClicked: CustomEvent<void>;
1614
igcClearIconClicked: CustomEvent<void>;
@@ -50,10 +48,36 @@ export default class IgcDateRangeInputComponent extends EventEmitterMixin<
5048
private _open = false;
5149
private _value: Date | null = null;
5250

53-
/**
54-
* The value of the picker
55-
* @attr
56-
*/
51+
@property()
52+
public inputFormat = '';
53+
54+
@property()
55+
public displayFormat = '';
56+
57+
@property()
58+
public locale = 'en';
59+
60+
@property()
61+
public prompt = '_';
62+
63+
@property()
64+
public readOnly = false;
65+
66+
@property()
67+
public disabled = false;
68+
69+
@property()
70+
public invalid = false;
71+
72+
@property()
73+
public required = false;
74+
75+
@property()
76+
public min: Date | null = null;
77+
78+
@property()
79+
public max: Date | null = null;
80+
5781
@property({ converter: convertToDate })
5882
public set value(value: Date | string | null | undefined) {
5983
this._value = value as Date | null;
@@ -63,10 +87,6 @@ export default class IgcDateRangeInputComponent extends EventEmitterMixin<
6387
return this._value;
6488
}
6589

66-
/**
67-
* The label of the datepicker.
68-
* @attr label
69-
*/
7090
@property()
7191
public label!: string;
7292

@@ -76,24 +96,19 @@ export default class IgcDateRangeInputComponent extends EventEmitterMixin<
7696
return root;
7797
}
7898

99+
private handleAnchorPointerDown(event: Event) {
100+
event.preventDefault();
101+
}
102+
79103
private handleAnchorClick() {
104+
this._open = !this._open;
80105
this.emitEvent('igcToggleIconClicked');
81106
}
82107

83108
private clearIconClick() {
84109
this.emitEvent('igcClearIconClicked');
85110
}
86111

87-
/** @private @hidden @internal */
88-
public async [setInputFormat](value: string) {
89-
this._input.inputFormat = value;
90-
}
91-
92-
/** @private @hidden @internal */
93-
public async [setDisplayFormat](value: string) {
94-
this._input.displayFormat = value;
95-
}
96-
97112
public clear() {
98113
this.value = null;
99114
this._input.clear();
@@ -135,7 +150,12 @@ export default class IgcDateRangeInputComponent extends EventEmitterMixin<
135150
const state = this._open ? 'calendar-icon-open' : 'calendar-icon';
136151

137152
return html`
138-
<span slot="prefix" part=${state} @click=${this.handleAnchorClick}>
153+
<span
154+
slot="prefix"
155+
part=${state}
156+
@pointerdown=${this.handleAnchorPointerDown}
157+
@click=${this.handleAnchorClick}
158+
>
139159
<slot name=${state}>${defaultIcon}</slot>
140160
</span>
141161
`;
@@ -145,8 +165,18 @@ export default class IgcDateRangeInputComponent extends EventEmitterMixin<
145165
return html`
146166
<igc-date-time-input
147167
id=${this.inputId}
168+
.inputFormat=${this.inputFormat}
169+
.displayFormat=${this.displayFormat}
148170
.value=${this.value}
149171
.label=${this.label}
172+
.locale=${this.locale}
173+
.prompt=${this.prompt}
174+
?readonly=${this.readOnly}
175+
?disabled=${this.disabled}
176+
?required=${this.required}
177+
.min=${this.min}
178+
.max=${this.max}
179+
.invalid=${live(this.invalid)}
150180
@igcChange=${this.handleInputChangeEvent}
151181
@igcInput=${this.handleInputEvent}
152182
>

0 commit comments

Comments
 (0)