@itfin/components 1.2.73 → 1.2.74

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itfin/components",
3
- "version": "1.2.73",
3
+ "version": "1.2.74",
4
4
  "author": "Vitalii Savchuk <esvit666@gmail.com>",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -496,7 +496,19 @@
496
496
  border-radius: 0;
497
497
 
498
498
  &:hover {
499
- background: var(--adp-cell-background-color-in-range-hover);
499
+ position: relative;
500
+ &:after {
501
+ content: '';
502
+ position: absolute;
503
+ top: 0;
504
+ left: 0;
505
+ width: 100%;
506
+ height: 100%;
507
+ border-radius: var(--adp-cell-border-radius);
508
+ background: var(--adp-cell-background-color-in-range-hover);
509
+ opacity: .5;
510
+ pointer-events: none;
511
+ }
500
512
  }
501
513
  }
502
514
 
@@ -999,6 +1011,10 @@ $rangeThumbSize: 12px;
999
1011
  padding: 0;
1000
1012
  max-width: 100px;
1001
1013
 
1014
+ &.placeholder-visible {
1015
+ max-width: none;
1016
+ }
1017
+
1002
1018
  &:focus, &:active {
1003
1019
  border: 0;
1004
1020
  box-shadow: none;
@@ -74,7 +74,7 @@ class itfApp extends Vue {
74
74
  try {
75
75
  await func();
76
76
  } catch (err) {
77
- this.showError(this.$t('components.sorrySomethingWentWrongPleaseTryAgainOrContactSupport'));
77
+ this.showError(err.message);
78
78
  if (errFunc) {
79
79
  errFunc(err);
80
80
  }
@@ -156,6 +156,10 @@ class itfDatePicker extends Vue {
156
156
  return this.valueAsLuxon.toFormat(this.dateFormat);
157
157
  }
158
158
 
159
+ get minDateLuxon() {
160
+ return this.minDate && (typeof this.minDate === 'string' ? DateTime.fromISO(this.minDate) : DateTime.fromJSDate(this.minDate));
161
+ }
162
+
159
163
  updateValue(value, emitEmpty = false) {
160
164
  const val = value && DateTime.fromFormat(value, this.dateFormat, { zone: 'UTC' });
161
165
  if (!val || !val.isValid) {
@@ -164,6 +168,9 @@ class itfDatePicker extends Vue {
164
168
  }
165
169
  return;
166
170
  }
171
+ if (this.minDateLuxon && val < this.minDateLuxon) {
172
+ return;
173
+ }
167
174
  this.setValue(this.valueFormat === 'ISO' ? val.toISO() : val.toFormat(this.valueFormat));
168
175
  }
169
176
 
@@ -11,6 +11,7 @@
11
11
  <button
12
12
  v-for="(item, n) in daysList"
13
13
  :key="n"
14
+ :disabled="!isEnabled(item.date)"
14
15
  :class="{'active': isSelected(item.date)}"
15
16
  @click="selectDate(item.date)"
16
17
  class="btn btn-outline-primary btn-sm text-start">
@@ -162,9 +163,27 @@ class itfDatePickerInline extends Vue {
162
163
  return this.valueAsLuxon.hasSame(DateTime.local().plus(date), 'day');
163
164
  }
164
165
 
165
- selectDate(date) {
166
+ get minDateLuxon() {
167
+ return this.minDate && (typeof this.minDate === 'string' ? DateTime.fromISO(this.minDate) : DateTime.fromJSDate(this.minDate));
168
+ }
169
+
170
+ isEnabled(date) {
166
171
  const lxDate = DateTime.local().plus(date);
172
+ return !(this.minDateLuxon && lxDate < this.minDateLuxon);
173
+ }
174
+
175
+ selectDate(date) {
176
+ let lxDate = DateTime.local().plus(date);
177
+ if (this.minDateLuxon && lxDate < this.minDateLuxon) {
178
+ return;
179
+ }
180
+ this.calendar.selectDate(lxDate.toJSDate());
167
181
  this.updateValue(lxDate.toFormat(this.displayFormat));
168
182
  }
183
+
184
+ @Watch('value')
185
+ onValueChanged() {
186
+ this.calendar.selectDate(this.valueAsLuxon && this.valueAsLuxon.toJSDate());
187
+ }
169
188
  }
170
189
  </script>
@@ -11,6 +11,7 @@
11
11
  <i-mask-component
12
12
  ref="input"
13
13
  class="form-control"
14
+ :class="{ 'placeholder-visible': !displayValue || !displayValue[0] }"
14
15
  @input="updateValue($event, 0)"
15
16
  @focus="onFocus"
16
17
  @blur="onBlur($event, 0)"
@@ -24,9 +25,10 @@
24
25
  :lazy="!focused"
25
26
  :placeholder="placeholder"
26
27
  />
27
- <span class="input-group-text" :class="{'hidden': !focused && (value && !value[0])}">-</span>
28
+ <span v-if="displayValue && displayValue[0]" class="input-group-text" :class="{'hidden': !focused && (value && !value[0])}">-</span>
28
29
 
29
30
  <i-mask-component
31
+ v-if="displayValue && displayValue[0]"
30
32
  ref="input2"
31
33
  class="form-control"
32
34
  @input="updateValue($event, 1)"
@@ -179,6 +181,10 @@ class itfDateRangePicker extends Vue {
179
181
  ];
180
182
  }
181
183
 
184
+ get minDateLuxon() {
185
+ return this.minDate && (typeof this.minDate === 'string' ? DateTime.fromISO(this.minDate) : DateTime.fromJSDate(this.minDate));
186
+ }
187
+
182
188
  updateValue(value, index, emitEmpty = false) {
183
189
  const val = value && DateTime.fromFormat(value, this.dateFormat);
184
190
  if (!val || !val.isValid) {
@@ -191,6 +197,9 @@ class itfDateRangePicker extends Vue {
191
197
  current[0] = current[0] || null;
192
198
  current[1] = current[1] || null;
193
199
  current[index] = (this.valueFormat === 'ISO') ? val.toISO() : val.toFormat(this.valueFormat);
200
+ if (this.minDateLuxon && val < this.minDateLuxon) {
201
+ return;
202
+ }
194
203
  this.$emit('input', current);
195
204
  }
196
205
 
@@ -209,7 +218,10 @@ class itfDateRangePicker extends Vue {
209
218
  onBlur(e, index) {
210
219
  this.focused = false;
211
220
  if (this.valueAsLuxon && this.valueAsLuxon[0] && this.valueAsLuxon[1] && this.valueAsLuxon[0] > this.valueAsLuxon[1]) {
212
- this.$emit('input', [this.value[1], this.value[0]]);
221
+ if (this.minDateLuxon && (this.valueAsLuxon[0] < this.minDateLuxon || this.valueAsLuxon[1] < this.minDateLuxon)) {
222
+ return;
223
+ }
224
+ this.$emit('input', [this.value[0], this.value[1]]);
213
225
  }
214
226
  }
215
227
 
@@ -11,6 +11,7 @@
11
11
  <button
12
12
  v-for="(item, n) in daysList"
13
13
  :key="n"
14
+ :disabled="!isEnabled(item.date())"
14
15
  :class="{'active': isSelected(item.date())}"
15
16
  @click="selectDate(item.date())"
16
17
  class="btn btn-outline-primary btn-sm text-start">
@@ -78,6 +79,7 @@ class itfDatePickerInline extends Vue {
78
79
  minDate: this.minDate,
79
80
  locale: this.$i18n.locale === 'en' ? localeEn : localeUk,
80
81
  range: true,
82
+ dynamicRange: true,
81
83
  toggleSelected: false,
82
84
  selectedDates: this.valueAsLuxon
83
85
  ? [this.valueAsLuxon[0].toJSDate(), this.valueAsLuxon[1].toJSDate()]
@@ -139,12 +141,15 @@ class itfDatePickerInline extends Vue {
139
141
  updateValue(date1, date2, emitEmpty = false) {
140
142
  const val = date1 && DateTime.fromFormat(date1, this.displayFormat);
141
143
  const val2 = date2 && DateTime.fromFormat(date2, this.displayFormat);
142
- if (!val || !val.isValid) {
144
+ if (!val || !val.isValid || !val2 || !val2.isValid) {
143
145
  if (emitEmpty) {
144
146
  this.$emit('input', null);
145
147
  }
146
148
  return;
147
149
  }
150
+ if (this.minDateLuxon && (val < this.minDateLuxon || val2 < this.minDateLuxon)) {
151
+ return;
152
+ }
148
153
  if (this.valueFormat === 'ISO') {
149
154
  return this.$emit('input', [val.toISO(), val2.toISO()]);
150
155
  }
@@ -154,6 +159,16 @@ class itfDatePickerInline extends Vue {
154
159
  ]);
155
160
  }
156
161
 
162
+ get minDateLuxon() {
163
+ return this.minDate && (typeof this.minDate === 'string' ? DateTime.fromISO(this.minDate) : DateTime.fromJSDate(this.minDate));
164
+ }
165
+
166
+ isEnabled(date) {
167
+ const lxDate1 = date[0].set({ hours: 0, minutes: 0, seconds: 0 });
168
+ const lxDate2 = date[1].set({ hours: 23, minutes: 59, seconds: 59 });
169
+ return !this.minDateLuxon || (lxDate1 > this.minDateLuxon && lxDate2 > this.minDateLuxon);
170
+ }
171
+
157
172
  isSelected(date) {
158
173
  if (!this.valueAsLuxon || this.valueAsLuxon.length < 2) {
159
174
  return false;
@@ -166,6 +181,21 @@ class itfDatePickerInline extends Vue {
166
181
  const lxDate1 = date[0].set({ hours: 0, minutes: 0, seconds: 0 });
167
182
  const lxDate2 = date[1].set({ hours: 23, minutes: 59, seconds: 59 });
168
183
  this.updateValue(lxDate1.toFormat(this.displayFormat), lxDate2.toFormat(this.displayFormat));
184
+ this.calendar.selectDate([lxDate1.toJSDate(), lxDate2.toJSDate()]);
185
+ }
186
+
187
+ @Watch('value')
188
+ onValueChanged() {
189
+ if (!this.valueAsLuxon) {
190
+ return;
191
+ }
192
+ const date1 = this.calendar.rangeDateFrom && DateTime.fromJSDate(this.calendar.rangeDateFrom).toFormat('yyyy-MM-dd')
193
+ const date2 = this.calendar.rangeDateTo && DateTime.fromJSDate(this.calendar.rangeDateTo).toFormat('yyyy-MM-dd')
194
+ if (date1 !== this.valueAsLuxon[0].toFormat('yyyy-MM-dd') || date2 !== this.valueAsLuxon[1].toFormat('yyyy-MM-dd')) {
195
+ this.$nextTick(() => {
196
+ this.calendar.selectDate(this.valueAsLuxon && [this.valueAsLuxon[0].toJSDate(), this.valueAsLuxon[1].toJSDate()]);
197
+ });
198
+ }
169
199
  }
170
200
  }
171
201
  </script>
@@ -51,6 +51,8 @@ storiesOf('Common', module)
51
51
  <br />
52
52
  <itf-date-picker-inline value-format="yyyy-MM-dd" :custom-days="customDays" :value="date" v-model.lazy="date"></itf-date-picker-inline>
53
53
 
54
+ <itf-date-picker-inline value-format="yyyy-MM-dd" :custom-days="customDays" min-date="2023-05-01" :value="date" v-model.lazy="date"></itf-date-picker-inline>
55
+
54
56
  <br />
55
57
  <br />
56
58
 
@@ -59,7 +61,7 @@ storiesOf('Common', module)
59
61
  <br />
60
62
  <br />
61
63
 
62
- <itf-date-picker value-format="yyyy-MM-dd" :value="date" v-model.lazy="date"></itf-date-picker>
64
+ <itf-date-picker value-format="yyyy-MM-dd" :value="date" min-date="2023-05-01" v-model.lazy="date"></itf-date-picker>
63
65
 
64
66
  <br />
65
67
  <br />
@@ -68,7 +70,7 @@ storiesOf('Common', module)
68
70
 
69
71
  <h2>Range</h2>
70
72
 
71
- <itf-date-range-picker value-format="yyyy-MM-dd" v-model="dateRange"></itf-date-range-picker>
73
+ <itf-date-range-picker value-format="yyyy-MM-dd" min-date="2023-03-01" placeholder="loooooooooooooooong placeholder" v-model="dateRange"></itf-date-range-picker>
72
74
 
73
75
  <itf-date-range-picker-inline value-format="yyyy-MM-dd" v-model="dateRange"></itf-date-range-picker-inline>
74
76
 
package/src/locales/en.js CHANGED
@@ -46,7 +46,6 @@ module.exports = {
46
46
  invalidTimeValueShouldBeInFormat: 'Invalid time value. Should be in format 0d 0h 0m',
47
47
  yourTitleShouldDescribeTheWorkYouDo: 'Your title should describe the work you do',
48
48
  pleaseEnterValidCommaSeparatedEmailAddressesToSendInvoicing: 'Please enter valid, comma separated (,) email addresses to send invoicing',
49
- sorrySomethingWentWrongPleaseTryAgainOrContactSupport: 'Sorry, something went wrong. Please try again or contact support. Include a screenshot of this entire page so we can troubleshoot this issue faster.',
50
49
  noResults: 'No results',
51
50
  search: 'Search',
52
51
  dateBefore: 'The date should be before {date}',
package/src/locales/uk.js CHANGED
@@ -46,7 +46,6 @@ module.exports = {
46
46
  invalidTimeValueShouldBeInFormat: 'Недійсне значення часу. Має бути у форматі 0d 0h 0m',
47
47
  yourTitleShouldDescribeTheWorkYouDo: 'Ваша назва має описувати роботу, яку ви виконуєте',
48
48
  pleaseEnterValidCommaSeparatedEmailAddressesToSendInvoicing: 'Будь ласка, введіть дійсні адреси електронної пошти, розділені комами (,)',
49
- sorrySomethingWentWrongPleaseTryAgainOrContactSupport: 'Вибачте, щось пішло не так. Спробуйте ще раз або зверніться до служби підтримки. Додайте знімок екрана всієї сторінки, щоб ми могли швидше вирішити цю проблему.',
50
49
  noResults: 'Немає результатів',
51
50
  search: 'Пошук',
52
51
  dateBefore: 'Дата має бути раніше {date}',