@itfin/components 1.2.64 → 1.2.66

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.64",
3
+ "version": "1.2.66",
4
4
  "author": "Vitalii Savchuk <esvit666@gmail.com>",
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -14,7 +14,7 @@
14
14
  @blur="onBlur"
15
15
  :value="displayValue"
16
16
  :mask="Date"
17
- :pattern="displayFormat"
17
+ :pattern="dateFormat"
18
18
  :blocks="blocks"
19
19
  :format="format"
20
20
  :parse="parse"
@@ -40,7 +40,7 @@
40
40
  :value="value"
41
41
  :start-view="startView"
42
42
  :only-calendar="onlyCalendar"
43
- :display-format="displayFormat"
43
+ :display-format="dateFormat"
44
44
  :value-format="valueFormat"
45
45
  :min-date="minDate"
46
46
  @input="selectInlineDate"
@@ -77,7 +77,7 @@ class itfDatePicker extends Vue {
77
77
  @Prop({ type: String }) value;
78
78
  @Prop({ type: [Number, String], default: 300 }) delayInput;
79
79
  @Prop({ type: String, default: 'ISO' }) valueFormat;
80
- @Prop({ type: String, default: ITFSettings.defaultDisplayDateFormat }) displayFormat;
80
+ @Prop({ type: String }) displayFormat;
81
81
  @Prop({ type: String, default: 'days', validator: (value) => ['days', 'months', 'years'].includes(value) }) startView;
82
82
  @Prop({ type: Boolean, default: false }) onlyCalendar;
83
83
  @Prop({ type: String, default: '' }) placeholder;
@@ -145,15 +145,19 @@ class itfDatePicker extends Vue {
145
145
  return DateTime.fromFormat(this.value, this.valueFormat);
146
146
  }
147
147
 
148
+ get dateFormat() {
149
+ return this.displayFormat || ITFSettings.defaultDisplayDateFormat;
150
+ }
151
+
148
152
  get displayValue() {
149
153
  if (!this.valueAsLuxon) {
150
154
  return '';
151
155
  }
152
- return this.valueAsLuxon.toFormat(this.displayFormat);
156
+ return this.valueAsLuxon.toFormat(this.dateFormat);
153
157
  }
154
158
 
155
159
  updateValue(value, emitEmpty = false) {
156
- const val = value && DateTime.fromFormat(value, this.displayFormat, { zone: 'UTC' });
160
+ const val = value && DateTime.fromFormat(value, this.dateFormat, { zone: 'UTC' });
157
161
  if (!val || !val.isValid) {
158
162
  if (emitEmpty) {
159
163
  this.setValue(null);
@@ -164,11 +168,11 @@ class itfDatePicker extends Vue {
164
168
  }
165
169
 
166
170
  format(date) {
167
- return DateTime.fromJSDate(date).toFormat(this.displayFormat);
171
+ return DateTime.fromJSDate(date).toFormat(this.dateFormat);
168
172
  }
169
173
 
170
174
  parse(str) {
171
- return DateTime.fromFormat(str, this.displayFormat).toJSDate();
175
+ return DateTime.fromFormat(str, this.dateFormat).toJSDate();
172
176
  }
173
177
 
174
178
  onFocus() {
@@ -16,7 +16,7 @@
16
16
  @blur="onBlur($event, 0)"
17
17
  :value="displayValue[0]"
18
18
  :mask="Date"
19
- :pattern="displayFormat"
19
+ :pattern="dateFormat"
20
20
  :blocks="blocks"
21
21
  :format="format"
22
22
  :parse="parse"
@@ -34,7 +34,7 @@
34
34
  @blur="onBlur($event, 1)"
35
35
  :value="displayValue[1]"
36
36
  :mask="Date"
37
- :pattern="displayFormat"
37
+ :pattern="dateFormat"
38
38
  :blocks="blocks"
39
39
  :format="format"
40
40
  :parse="parse"
@@ -50,6 +50,7 @@
50
50
  :only-calendar="onlyCalendar"
51
51
  :display-format="displayFormat"
52
52
  :value-format="valueFormat"
53
+ :min-date="minDate"
53
54
  @input="selectInlineDate"
54
55
  ></itf-date-range-picker-inline>
55
56
  </div>
@@ -92,13 +93,14 @@ class itfDateRangePicker extends Vue {
92
93
 
93
94
  @Prop({ default: () => ([]) }) value;
94
95
  @Prop({ type: String, default: 'ISO' }) valueFormat;
95
- @Prop({ type: String, default: ITFSettings.defaultDisplayDateFormat }) displayFormat;
96
+ @Prop({ type: String }) displayFormat;
96
97
  @Prop({ type: String, default: 'days', validator: (value) => ['days', 'months', 'years'].includes(value) }) startView;
97
98
  @Prop({ type: Boolean, default: false }) onlyCalendar;
98
99
  @Prop({ type: Boolean, default: false }) clearable;
99
100
  @Prop({ type: String, default: '' }) placeholder;
100
101
  @Prop({ type: String, default: '' }) prependIcon;
101
102
  @Prop({ type: String, default: 'bottom-start' }) placement;
103
+ @Prop({ type: [String, Date], default: '' }) minDate;
102
104
 
103
105
  focused = false;
104
106
 
@@ -122,6 +124,10 @@ class itfDateRangePicker extends Vue {
122
124
  },
123
125
  };
124
126
 
127
+ get dateFormat() {
128
+ return this.displayFormat || ITFSettings.defaultDisplayDateFormat;
129
+ }
130
+
125
131
  isInvalid() {
126
132
  return this.itemLabel && this.itemLabel.isHasError();
127
133
  }
@@ -168,13 +174,13 @@ class itfDateRangePicker extends Vue {
168
174
  return ['', ''];
169
175
  }
170
176
  return [
171
- this.valueAsLuxon[0].toFormat(this.displayFormat),
172
- this.valueAsLuxon[1].toFormat(this.displayFormat)
177
+ this.valueAsLuxon[0].toFormat(this.dateFormat),
178
+ this.valueAsLuxon[1].toFormat(this.dateFormat)
173
179
  ];
174
180
  }
175
181
 
176
182
  updateValue(value, index, emitEmpty = false) {
177
- const val = value && DateTime.fromFormat(value, this.displayFormat);
183
+ const val = value && DateTime.fromFormat(value, this.dateFormat);
178
184
  if (!val || !val.isValid) {
179
185
  if (emitEmpty) {
180
186
  this.$emit('input', []);
@@ -189,11 +195,11 @@ class itfDateRangePicker extends Vue {
189
195
  }
190
196
 
191
197
  format(date) {
192
- return DateTime.fromJSDate(date).toFormat(this.displayFormat);
198
+ return DateTime.fromJSDate(date).toFormat(this.dateFormat);
193
199
  }
194
200
 
195
201
  parse(str) {
196
- return DateTime.fromFormat(str, this.displayFormat).toJSDate();
202
+ return DateTime.fromFormat(str, this.dateFormat).toJSDate();
197
203
  }
198
204
 
199
205
  onFocus() {
@@ -34,6 +34,7 @@ class itfDatePickerInline extends Vue {
34
34
  @Prop({ type: String, default: ITFSettings.defaultDisplayDateFormat }) displayFormat;
35
35
  @Prop({ type: Boolean, default: false }) onlyCalendar;
36
36
  @Prop({ type: Object, default: () => ({}) }) customDays;
37
+ @Prop({ type: [String, Date], default: '' }) minDate;
37
38
  @Prop({
38
39
  type: Array,
39
40
  default: function () {
@@ -73,6 +74,7 @@ class itfDatePickerInline extends Vue {
73
74
  this.calendar = new AirDatepicker(this.$refs.calendar, {
74
75
  firstDay: 1,
75
76
  altFieldDateFormat: this.valueFormat,
77
+ minDate: this.minDate,
76
78
  locale: this.$i18n.locale === 'en' ? localeEn : localeUk,
77
79
  range: true,
78
80
  toggleSelected: false,
@@ -78,6 +78,7 @@ import { DateTime } from 'luxon';
78
78
  import tippy from 'tippy.js';
79
79
  import itfIcon from '../icon/Icon';
80
80
  import itfButton from '../button/Button';
81
+ import ITFSettings from '../../ITFSettings';
81
82
 
82
83
  export default @Component({
83
84
  name: 'itfPeriodPicker',
@@ -96,7 +97,7 @@ class itfPeriodPicker extends Vue {
96
97
 
97
98
  @Prop({ type: Array }) value;
98
99
  @Prop({ type: String, default: 'ISO' }) valueFormat;
99
- @Prop({ type: String, default: 'MM/dd/yyyy' }) displayFormat;
100
+ @Prop({ type: String }) displayFormat;
100
101
  @Prop({ type: String, default: 'bottom-start' }) placement;
101
102
  @Prop({ type: String, default: 'days', validator: (value) => ['days', 'months', 'years'].includes(value) }) startView;
102
103
  @Prop({ type: Boolean, default: false }) onlyCalendar;
@@ -117,6 +118,10 @@ class itfPeriodPicker extends Vue {
117
118
  ];
118
119
  }
119
120
 
121
+ get dateFormat() {
122
+ return this.displayFormat || ITFSettings.defaultDisplayDateFormat;
123
+ }
124
+
120
125
  get nextYear() {
121
126
  return this.year + 1;
122
127
  }
@@ -179,8 +184,8 @@ class itfPeriodPicker extends Vue {
179
184
  return [];
180
185
  }
181
186
  return [
182
- this.valueAsLuxon[0].toFormat(this.displayFormat),
183
- this.valueAsLuxon[1].toFormat(this.displayFormat)
187
+ this.valueAsLuxon[0].toFormat(this.dateFormat),
188
+ this.valueAsLuxon[1].toFormat(this.dateFormat)
184
189
  ];
185
190
  }
186
191
 
@@ -1,4 +1,5 @@
1
1
  import { DateTime } from 'luxon';
2
+ import ITFSettings from '../ITFSettings';
2
3
 
3
4
  export function parseHours (str, { hoursInDay } = { hoursInDay: 8 }) {
4
5
  const source = (str || '').toString();
@@ -31,8 +32,8 @@ export function parseHours (str, { hoursInDay } = { hoursInDay: 8 }) {
31
32
  return seconds;
32
33
  }
33
34
 
34
- export function formatDate (date, inputFormat = 'yyyy-MM-dd', toFormat = 'MM/dd/yyyy') {
35
- return DateTime.fromFormat(date, inputFormat).toFormat(toFormat);
35
+ export function formatDate (date, inputFormat = 'yyyy-MM-dd', toFormat) {
36
+ return DateTime.fromFormat(date, inputFormat).toFormat(toFormat || ITFSettings.defaultDisplayDateFormat);
36
37
  }
37
38
 
38
39
  export function formatRangeDates(begin, end = null) {