@itfin/components 1.2.65 → 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
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
@blur="onBlur"
|
|
15
15
|
:value="displayValue"
|
|
16
16
|
:mask="Date"
|
|
17
|
-
:pattern="
|
|
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="
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
171
|
+
return DateTime.fromJSDate(date).toFormat(this.dateFormat);
|
|
168
172
|
}
|
|
169
173
|
|
|
170
174
|
parse(str) {
|
|
171
|
-
return DateTime.fromFormat(str, this.
|
|
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="
|
|
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="
|
|
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
|
|
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.
|
|
174
|
-
this.valueAsLuxon[1].toFormat(this.
|
|
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.
|
|
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.
|
|
198
|
+
return DateTime.fromJSDate(date).toFormat(this.dateFormat);
|
|
195
199
|
}
|
|
196
200
|
|
|
197
201
|
parse(str) {
|
|
198
|
-
return DateTime.fromFormat(str, this.
|
|
202
|
+
return DateTime.fromFormat(str, this.dateFormat).toJSDate();
|
|
199
203
|
}
|
|
200
204
|
|
|
201
205
|
onFocus() {
|
|
@@ -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
|
|
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.
|
|
183
|
-
this.valueAsLuxon[1].toFormat(this.
|
|
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
|
|
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) {
|