@itfin/components 1.2.65 → 1.2.67

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.65",
3
+ "version": "1.2.67",
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() {
@@ -21,7 +21,7 @@
21
21
  </div>
22
22
  </template>
23
23
  <script>
24
- import { Vue, Component, Prop } from 'vue-property-decorator';
24
+ import { Vue, Component, Prop, Watch } from 'vue-property-decorator';
25
25
  import { DateTime } from 'luxon';
26
26
  import ITFSettings from '../../ITFSettings';
27
27
 
@@ -58,6 +58,7 @@ class itfDatePickerInline extends Vue {
58
58
  this.createCalendar();
59
59
  }
60
60
 
61
+ @Watch('minDate')
61
62
  async createCalendar() {
62
63
  if (this.calendar) {
63
64
  this.destroyCalendar();
@@ -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"
@@ -93,7 +93,7 @@ class itfDateRangePicker extends Vue {
93
93
 
94
94
  @Prop({ default: () => ([]) }) value;
95
95
  @Prop({ type: String, default: 'ISO' }) valueFormat;
96
- @Prop({ type: String, default: ITFSettings.defaultDisplayDateFormat }) displayFormat;
96
+ @Prop({ type: String }) displayFormat;
97
97
  @Prop({ type: String, default: 'days', validator: (value) => ['days', 'months', 'years'].includes(value) }) startView;
98
98
  @Prop({ type: Boolean, default: false }) onlyCalendar;
99
99
  @Prop({ type: Boolean, default: false }) clearable;
@@ -124,6 +124,10 @@ class itfDateRangePicker extends Vue {
124
124
  },
125
125
  };
126
126
 
127
+ get dateFormat() {
128
+ return this.displayFormat || ITFSettings.defaultDisplayDateFormat;
129
+ }
130
+
127
131
  isInvalid() {
128
132
  return this.itemLabel && this.itemLabel.isHasError();
129
133
  }
@@ -170,13 +174,13 @@ class itfDateRangePicker extends Vue {
170
174
  return ['', ''];
171
175
  }
172
176
  return [
173
- this.valueAsLuxon[0].toFormat(this.displayFormat),
174
- this.valueAsLuxon[1].toFormat(this.displayFormat)
177
+ this.valueAsLuxon[0].toFormat(this.dateFormat),
178
+ this.valueAsLuxon[1].toFormat(this.dateFormat)
175
179
  ];
176
180
  }
177
181
 
178
182
  updateValue(value, index, emitEmpty = false) {
179
- const val = value && DateTime.fromFormat(value, this.displayFormat);
183
+ const val = value && DateTime.fromFormat(value, this.dateFormat);
180
184
  if (!val || !val.isValid) {
181
185
  if (emitEmpty) {
182
186
  this.$emit('input', []);
@@ -191,11 +195,11 @@ class itfDateRangePicker extends Vue {
191
195
  }
192
196
 
193
197
  format(date) {
194
- return DateTime.fromJSDate(date).toFormat(this.displayFormat);
198
+ return DateTime.fromJSDate(date).toFormat(this.dateFormat);
195
199
  }
196
200
 
197
201
  parse(str) {
198
- return DateTime.fromFormat(str, this.displayFormat).toJSDate();
202
+ return DateTime.fromFormat(str, this.dateFormat).toJSDate();
199
203
  }
200
204
 
201
205
  onFocus() {
@@ -21,7 +21,7 @@
21
21
  </div>
22
22
  </template>
23
23
  <script>
24
- import { Vue, Component, Prop } from 'vue-property-decorator';
24
+ import { Vue, Component, Prop, Watch } from 'vue-property-decorator';
25
25
  import { DateTime } from 'luxon';
26
26
  import ITFSettings from '../../ITFSettings';
27
27
 
@@ -57,6 +57,7 @@ class itfDatePickerInline extends Vue {
57
57
  this.createCalendar();
58
58
  }
59
59
 
60
+ @Watch('minDate')
60
61
  async createCalendar() {
61
62
  if (this.calendar) {
62
63
  this.destroyCalendar();
@@ -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) {