@itfin/components 1.2.77 → 1.2.79
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/ITFSettings.js
CHANGED
|
@@ -53,6 +53,7 @@
|
|
|
53
53
|
:display-format="displayFormat"
|
|
54
54
|
:value-format="valueFormat"
|
|
55
55
|
:min-date="minDate"
|
|
56
|
+
:max-date="maxDate"
|
|
56
57
|
@input="selectInlineDate"
|
|
57
58
|
></itf-date-range-picker-inline>
|
|
58
59
|
</div>
|
|
@@ -102,7 +103,8 @@ class itfDateRangePicker extends Vue {
|
|
|
102
103
|
@Prop({ type: String, default: '' }) placeholder;
|
|
103
104
|
@Prop({ type: String, default: '' }) prependIcon;
|
|
104
105
|
@Prop({ type: String, default: 'bottom-start' }) placement;
|
|
105
|
-
@Prop({ type:
|
|
106
|
+
@Prop({ type: [String, Date], default: '' }) minDate;
|
|
107
|
+
@Prop({ type: [String, Date], default: ''}) maxDate;
|
|
106
108
|
|
|
107
109
|
focused = false;
|
|
108
110
|
|
|
@@ -182,7 +184,15 @@ class itfDateRangePicker extends Vue {
|
|
|
182
184
|
}
|
|
183
185
|
|
|
184
186
|
get minDateLuxon() {
|
|
185
|
-
return this.minDate &&
|
|
187
|
+
return this.minDate && this.dateLuxon(this.minDate);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
get maxDateLuxon() {
|
|
191
|
+
return this.maxDate && this.dateLuxon(this.maxDate);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
dateLuxon(date) {
|
|
195
|
+
return (typeof date === 'string' ? DateTime.fromISO(date) : DateTime.fromJSDate(date));
|
|
186
196
|
}
|
|
187
197
|
|
|
188
198
|
updateValue(value, index, emitEmpty = false) {
|
|
@@ -197,7 +207,9 @@ class itfDateRangePicker extends Vue {
|
|
|
197
207
|
current[0] = current[0] || null;
|
|
198
208
|
current[1] = current[1] || null;
|
|
199
209
|
current[index] = (this.valueFormat === 'ISO') ? val.toISO() : val.toFormat(this.valueFormat);
|
|
200
|
-
if (this.minDateLuxon && val < this.minDateLuxon)
|
|
210
|
+
if ((this.minDateLuxon && val < this.minDateLuxon) ||
|
|
211
|
+
(this.maxDateLuxon && val > this.maxDateLuxon)
|
|
212
|
+
) {
|
|
201
213
|
return;
|
|
202
214
|
}
|
|
203
215
|
this.$emit('input', current);
|
|
@@ -218,7 +230,9 @@ class itfDateRangePicker extends Vue {
|
|
|
218
230
|
onBlur(e, index) {
|
|
219
231
|
this.focused = false;
|
|
220
232
|
if (this.valueAsLuxon && this.valueAsLuxon[0] && this.valueAsLuxon[1] && this.valueAsLuxon[0] > this.valueAsLuxon[1]) {
|
|
221
|
-
if (this.minDateLuxon && (this.valueAsLuxon[0] < this.minDateLuxon || this.valueAsLuxon[1] < this.minDateLuxon))
|
|
233
|
+
if ((this.minDateLuxon && (this.valueAsLuxon[0] < this.minDateLuxon || this.valueAsLuxon[1] < this.minDateLuxon)) ||
|
|
234
|
+
(this.maxDateLuxon && (this.valueAsLuxon[0] > this.maxDateLuxon || this.valueAsLuxon[1] > this.maxDateLuxon))
|
|
235
|
+
) {
|
|
222
236
|
return;
|
|
223
237
|
}
|
|
224
238
|
this.$emit('input', [this.value[0], this.value[1]]);
|
|
@@ -36,6 +36,7 @@ class itfDatePickerInline extends Vue {
|
|
|
36
36
|
@Prop({ type: Boolean, default: false }) onlyCalendar;
|
|
37
37
|
@Prop({ type: Object, default: () => ({}) }) customDays;
|
|
38
38
|
@Prop({ type: [String, Date], default: '' }) minDate;
|
|
39
|
+
@Prop({ type: [String, Date], default: '' }) maxDate;
|
|
39
40
|
@Prop({
|
|
40
41
|
type: Array,
|
|
41
42
|
default: function () {
|
|
@@ -59,6 +60,7 @@ class itfDatePickerInline extends Vue {
|
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
@Watch('minDate')
|
|
63
|
+
@Watch('maxDate')
|
|
62
64
|
async createCalendar() {
|
|
63
65
|
if (this.calendar) {
|
|
64
66
|
this.destroyCalendar();
|
|
@@ -77,6 +79,7 @@ class itfDatePickerInline extends Vue {
|
|
|
77
79
|
firstDay: 1,
|
|
78
80
|
altFieldDateFormat: this.valueFormat,
|
|
79
81
|
minDate: this.minDate,
|
|
82
|
+
maxDate: this.maxDate,
|
|
80
83
|
locale: this.$i18n.locale === 'en' ? localeEn : localeUk,
|
|
81
84
|
range: true,
|
|
82
85
|
dynamicRange: true,
|
|
@@ -147,9 +150,12 @@ class itfDatePickerInline extends Vue {
|
|
|
147
150
|
}
|
|
148
151
|
return;
|
|
149
152
|
}
|
|
150
|
-
if (this.minDateLuxon && (val < this.minDateLuxon || val2 < this.minDateLuxon))
|
|
153
|
+
if ((this.minDateLuxon && (val < this.minDateLuxon || val2 < this.minDateLuxon)) ||
|
|
154
|
+
(this.maxDateLuxon && (val > this.maxDateLuxon || val2 > this.maxDateLuxon))
|
|
155
|
+
) {
|
|
151
156
|
return;
|
|
152
157
|
}
|
|
158
|
+
|
|
153
159
|
if (this.valueFormat === 'ISO') {
|
|
154
160
|
return this.$emit('input', [val.toISO(), val2.toISO()]);
|
|
155
161
|
}
|
|
@@ -160,13 +166,31 @@ class itfDatePickerInline extends Vue {
|
|
|
160
166
|
}
|
|
161
167
|
|
|
162
168
|
get minDateLuxon() {
|
|
163
|
-
return this.minDate &&
|
|
169
|
+
return this.minDate && this.dateLuxon(this.minDate);
|
|
170
|
+
}
|
|
171
|
+
get maxDateLuxon() {
|
|
172
|
+
return this.maxDate && this.dateLuxon(this.maxDate);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
dateLuxon(date) {
|
|
176
|
+
return typeof date === 'string' ? DateTime.fromISO(date) : DateTime.fromJSDate(date);
|
|
164
177
|
}
|
|
165
178
|
|
|
166
179
|
isEnabled(date) {
|
|
167
180
|
const lxDate1 = date[0].set({ hours: 0, minutes: 0, seconds: 0 });
|
|
168
181
|
const lxDate2 = date[1].set({ hours: 23, minutes: 59, seconds: 59 });
|
|
169
|
-
|
|
182
|
+
|
|
183
|
+
if (this.minDateLuxon) {
|
|
184
|
+
if (this.maxDateLuxon) {
|
|
185
|
+
return lxDate1 > this.minDateLuxon && lxDate2 > this.minDateLuxon && lxDate1 < this.maxDateLuxon && lxDate2 < this.maxDateLuxon;
|
|
186
|
+
} else {
|
|
187
|
+
return lxDate1 > this.minDateLuxon && lxDate2 > this.minDateLuxon;
|
|
188
|
+
}
|
|
189
|
+
} else if (this.maxDateLuxon) {
|
|
190
|
+
return lxDate1 < this.maxDateLuxon && lxDate2 < this.maxDateLuxon;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
return true;
|
|
170
194
|
}
|
|
171
195
|
|
|
172
196
|
isSelected(date) {
|